How to add Text Color button to TinyMCE/WYSIWYG field

Support General How to add Text Color button to TinyMCE/WYSIWYG fieldResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #32199
    philphil
    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,
    )
    
    #32214
    Long NguyenLong 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

    #35272
    Robert EhniRobert Ehni
    Participant

    Hi Long,

    how can I pass these options when I add a WYSWIG using the meta box builder (https://docs.metabox.io/extensions/meta-box-builder/)?

    Best,
    Robert

    Edit: somehow it should be enabled by default but it wasn't. Deleting the field and adding it again fixed the issue for me...

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.