• I cannot work out how to gain complete, independent control over the buttons displayed in the editor when using wp_editor($content,$editor_id,$settings) with hidden Text tab and displayed Visual tab.

    To remove the ability to switch between the ‘Text’ tab and ‘Visual’ tab on the top right, the documentation says to use a false ‘quicktags’ element of the $settings parameter array (“Set to false to remove your editor’s Visual and Text tabs.”)

    When I use this method to hide ‘Text’ and ‘Visual’ tabs, I need to use the mce_buttons filter to determine which bold,underline, etc buttons are shown – and this applies to ALL wp_editor() thingos I use:

    add_filter("mce_buttons", "tinymce_editor_buttons", 99);
    add_filter("mce_buttons_2", "tinymce_editor_buttons_second_row", 99);
    function tinymce_editor_buttons($buttons) {
    	// by exclusion:
    	foreach(array('strikethrough','blockquote','hr','alignleft','alignright','aligncenter','wp_more','fullscreen','wp_adv') as $toRemove) {
    		$key = array_search($toRemove,$buttons);
    		if ($key!==false) unset($buttons[$key]);
    	}
    	return $buttons;
    	
    	// or by inclusion:
    	
    	return array('bold','italic','numlist','bullist');
    
    }
    
    function tinymce_editor_buttons_second_row($buttons) {
       //return an empty array to remove this line
        return array();
    }

    I tried controlling which buttons are displayed using wp_editor’s $settings parameter’s shortcode like this:

    wp_editor(
    $content,
    $editor_id,
    array(
    ‘quicktags’ => array(
    ‘buttons’ => ‘link,ins,img,close’
    )
    )
    )

    but this did not work for me, and even if I could use this method, the $quicktags is no longer == false, so the different tabs are displayed.

    I thought about putting some conditions inside the filter code above to return a different $buttons array when different pages are being loaded, but I want to separately control several wp_editor() fields on the one page, so this technique would not work.

    How can I control on a case by case basis which buttons and editor tabs are displayed in wp_editor?

Viewing 1 replies (of 1 total)
  • Thread Starter autefrum

    (@autefrum)

    I also tried this technique – using tinymce as a settings array element with theme_advanced_buttons1:

    wp_editor(
        $content,
        $editor_id,
        array(
          'media_buttons' => false,
          'tinymce' => array(
            'theme_advanced_buttons1' => 'bold, italic',
          ),
        )
    );

    but it just shows up the full set of default tinymce buttons int the editor.

Viewing 1 replies (of 1 total)
  • The topic ‘mce wp_editor Control ‘Text’ & ‘Visual’ tabs & buttons independently’ is closed to new replies.