Custom Fields
Re-Envisioned
Support General How to add Text Color button to TinyMCE/WYSIWYG field

  • Creator
    Topic
  • #32199
    phil
    Participant

    I'd like to add the text color option like this - https://imgur.com/60QoaPI

    Here is my code for the field, however it does not work. I think "forecolor" is not the correct ID for the button, but I do not know what it should be. What is the correct ID to add this button?

    array(
        'name' => 'WYSIWYG Field',
        'id' => 'wysiwyg_field',
        'type' => 'wysiwyg',
        'dfw' => false,
        'options' => array(
            'textarea_rows' => 8,
            'teeny' => true,
            'media_buttons' => false,
            'quicktags' => false,
            'tinymce' => array(
                'keep_styles' => false,
                'paste_remove_styles' => true,
                'paste_remove_spans' => true,
                'paste_as_text' => true,
                'toolbar1' => 'bold,italic,forecolor',                   
            ),
        ),
        'required' => true,
    )
    
Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #32214
    Long Nguyen
    Moderator

    Hi,

    The option forecolor works as well on my demo site. If you want to show the forecolor in the second toolbar, you can try to use this code

    'options' => array(
        'textarea_rows' => 8,
        'teeny' => true,
        'media_buttons' => false,
        'quicktags' => false,
        'tinymce' => array(
            'keep_styles' => false,
            'paste_remove_styles' => true,
            'paste_remove_spans' => true,
            'paste_as_text' => true,
            'toolbar1' => 'bold,italic,strikethrough,bullist,numlist,blockquote,hr,alignleft,aligncenter,alignright,link,unlink,wp_more,spellchecker,wp_fullscreen,wp_adv',
            'toolbar2' => 'forecolor' //here   
        ),
    ),

    Refer to this documentation https://codex.wordpress.org/TinyMCE

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.