2

My text editor in Theme Options doesn't have font color option. How can I add that? I've searched around the web, but no luck. On regular pages and posts I can see the font color option.

I'm using Options framework. Here's the code snippet:

$options[] = array(
        'name' => __('Main text block', 'options_check'),
        'id' => 'main_text_editor',
        'type' => 'editor',
        'settings' => $wp_editor_settings );
  • Can you explain your question with the arguments, there you pass in the var $wp_editor_settings. It is much helpful to understand your configuration. – bueltge Dec 22 '15 at 12:53
3

In theme options, I had to define wp_editor_settings. So, just in options.php, I used:

//WP_editor settigs
    $wp_editor_settings = array(
        'wpautop' => true, // Default
        'textarea_rows' => 15,
        'tinymce' => array( 
            'plugins' => 'fullscreen,wordpress,wplink, textcolor'
        ));

Basically, I'm adding tinymce plugin.

2

I think you mean the font color inside the TinyMCE editor. The wp_editor() function have the settings parameter, there you reference to an var like ``.

This parameter need a array and this array can use a lot of parameters. The follow example demonstrate this and the codex have also a documentation.

$settings = array(
    'wpautop' => true,
    'media_buttons' =>  false,
    'textarea_name' => 'test-editor',
    'textarea_rows' => get_option('default_post_edit_rows', 10),
    'tabindex' => '',
    'editor_css' => '',
    'editor_class' => '',
    'teeny' => true,
    'dfw' => true,
    'tinymce' => array(
          'theme_advanced_buttons1' => 'bold,italic,underline' 
    ),
    'quicktags' => false
);
wp_editor( 'Text in editor', 'test-editor', $settings );

The argument inside the array tinymce accept also a array with different parameters to customize the editor bar.

The follow buttons was in default defined for the 'teeny' buttons, the PressThis bar, different from the default editor:

'teeny_mce_buttons',
array( 
    'bold', 'italic', 'underline', 'blockquote', 'strikethrough', 'bullist',   
    'numlist', 'alignleft', 'aligncenter', 'alignright', 'undo', 
    'redo', 'link', 'unlink', 'fullscreen'
)

Also is the second row possibel:

'mce_buttons_2'
array( 
    'formatselect', 'underline', 'alignjustify', 'forecolor', 'pastetext',
    'removeformat', 'charmap', 'outdent', 'indent', 'undo', 'redo'
)

Default WP Editor Settings

    $set = wp_parse_args( $settings, array(
        'wpautop'             => true,
        'media_buttons'       => true,
        'default_editor'      => '',
        'drag_drop_upload'    => false,
        'textarea_name'       => $editor_id,
        'textarea_rows'       => 20,
        'tabindex'            => '',
        'tabfocus_elements'   => ':prev,:next',
        'editor_css'          => '',
        'editor_class'        => '',
        'teeny'               => false,
        'dfw'                 => false,
        '_content_editor_dfw' => false,
        'tinymce'             => true,
        'quicktags'           => true
    ) );

Custom plugins in the TinyMCE editor

You can also add custom plugins for the TinyMCE in this settings array, like the follow example.

'tinymce' => array( 
    'plugins' => 'fullscreen, wordpress, wplink, textcolor'
)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.