Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I know there are similar topics with accepted answers but I can't find what I'm looking for. I want to keep only basic buttons in wp_editor(). I'm using this in an option page to make writing more comfortable.

The problem is the theme adds a huge amount of quicktags I do not want on this specific page. How can I achieve this.

So far I've looked into wp-includes/wp-class-editor.php but the following line does not remove unecessary buttons :

'quicktags' => array('buttons' => 'link,ins,img,close')

:/ Any help would be much appreciated.

EDIT: I've tried to modify function given in similar topic with this :

function wpa_47010( $qtInit ) {
global $my_plugin_page;
    $screen = get_current_screen();
      if( $screen->id == $my_plugin_page ) 
          $qtInit['buttons'] = 'link,img,close';
return $qtInit;
}
add_filter('quicktags_settings', 'wpa_47010');

But it does not work !

share|improve this question
1  
Possible duplicate of: wordpress.stackexchange.com/questions/47010/… you need to use the quicktag_settings filter –  Matt.C Sep 16 '13 at 11:47
    
No that isn't simply because I do not want all editor to be restricted, I just want mine. –  JMau Sep 16 '13 at 12:29
    
Wait maybe I can use some page condition. –  JMau Sep 16 '13 at 12:54
    
Sorry, I've reread the question and have a clearer understanding of what you're trying to do, the code in the answer below works for me: –  Matt.C Sep 16 '13 at 16:35
    
check the perticular class from firebug add find that in wp-admin.css and add display none for that class –  Vikas Gautam Sep 17 '13 at 11:35

2 Answers 2

up vote 2 down vote accepted

If you are using the settings API, you can use exactly the same code for calling wp_editor as you would anywhere else

I've test the code below, it adds a setting section to the reading section, and then adds a field to the section containing a WYSIWYG editor with buttons limited to link, img and close

// Add a setting to the reading page
 function register_plugin_x_settings() {
    // Add a section to reading settings 
    add_settings_section('plugin_x_setting_section','Plugin X (section caption)','plugin_x_setting_section_callback','reading');

        // add setting field
    add_settings_field('plugin_x_setting_wysiwyg', 'WYSIWYG Content', 'plugin_x_setting_wysiwyg_callback', 'reading', 'plugin_x_setting_section');
    register_setting('reading','plugin_x_setting_wysiwyg');
 }
 add_action('admin_init', 'register_plugin_x_settings');

 // function to render the section
 function plugin_x_setting_section_callback() {
    echo '<p>Plugin X Settings</p>';
 }

// function to render the setting
function plugin_x_setting_wysiwyg_callback() {
    // global editor id (not necesary, but we may need it elsewhere)
    global $myPluginEditorID;
    $myPluginEditorID = "myPluginEditorUniqueID";

    // settings to pass to wp_editor, disables the upload button, and sets minimal quicktags and turns off tinymce
    $settings = array(
        'media_buttons' => false,
        'quicktags'     => array("buttons"=>"link,img,close"),
        'textarea_name' => "input_{$myPluginEditorID}",
        'tinymce'       => false,
    );

    // output the wysiwyg editor
    wp_editor( "Content Here", $myPluginEditorID,$settings);
 }
share|improve this answer

The following code works for me, it adds an options page, and adds a WYSIWYG box to that page, with ONLY 3 quicktags: link, img and close, and nothing else.

Note, I turned of tinyMCE, and passed a settings array (which contains another array for quicktag settings) to wp_editor.

By passing in unique id of the textarea field, it will only affect the correct box on your plugin options page

// add admin page
function my_admin_add_page() {
    global $my_admin_page;
    $my_admin_page = add_options_page(__('My Admin Page', 'map'), __('My Admin Page', 'map'), 'manage_options', 'map', 'my_admin_page');
}
add_action('admin_menu', 'my_admin_add_page');

// render admin page
function my_admin_page() {
    // global editor id (not necesary, but we may need it elsewhere)
    global $myPluginEditorID;
    $myPluginEditorID = "myPluginEditorUniqueID";

    // settings to pass to wp_editor, disables the upload button, and sets minimal quicktags and turns off tinymce
    $settings = array(
        'media_buttons' => false,
        'quicktags'     => array("buttons"=>"link,img,close"),
        'textarea_name' => "input_{$myPluginEditorID}",
        'tinymce'       => false,
    );

    // output the wysiwyg editor
    wp_editor( "Content Here", $myPluginEditorID,$settings);
}
share|improve this answer
    
Thanks but I'm using it with settings API –  JMau Sep 16 '13 at 16:55
    
Please could you clarify, are you adding wp_editor to an existing settings page, you should still be able to use part the code above to call wp_editor anywhere? see my second answer –  Matt.C Sep 17 '13 at 9:10
    
I gave you points, I've decided to proceed the opposite way that is to say less options. –  JMau Sep 17 '13 at 12:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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