3

The script below is taken from a plugin that converts all textareas in the category and tags editors to rich text editors.

I'm using it to convert the category "Description" textarea input box to rich text. However, I have another text area on this same edit screen (one that I've added as a custom field) that I don't want rich text enabled. However, the plugin applies rich text to all edit fields.

Can someone tell from the code below how to do one of the following:

Disable rich text on a textarea with ID "myTextarea"?

OR

Only apply the rich text to the Category "description" text area and no others? (preferred)

add_action('init', 'catde_init');
function catde_init() {
    if ( is_admin() || defined('DOING_AJAX') ) {
        if ( current_user_can('manage_categories') )
            remove_filter('pre_term_description', 'wp_filter_kses');
    }
}

add_action('load-categories.php', 'catde_admin_init');
add_action('load-edit-tags.php', 'catde_admin_init');
function catde_admin_init() {
    if ( user_can_richedit() && isset($_GET['action']) && 'edit' === $_GET['action'] && ( !empty($_GET['cat_ID']) || ( !empty($_GET['taxonomy']) && !empty($_GET['tag_ID']) ) ) ) {
        add_filter( 'tiny_mce_before_init', 'catde_mceinit');
        add_action('admin_footer', 'wp_tiny_mce');
        add_action('admin_head', 'catde_head');
    }
}

function catde_mceinit($init) {

    $init['mode'] = 'textareas';
    $init['editor_selector'] = '';
    $init['elements'] = 'category_description,description';
    $init['plugins'] = 'safari,inlinepopups,autosave,spellchecker,paste,wordpress,media,fullscreen';
    $init['theme_advanced_buttons1'] .= ',image';
    $init['theme_advanced_buttons2'] .= ',code';
    $init['onpageload'] = '';
    $init['save_callback'] = '';

    return $init;
}

function catde_head() { ?>
    <style type="text/css">#category_description_tbl,#description_tbl{border:1px solid #dfdfdf;}.wp_themeSkin .mceStatusbar{border-color:#dfdfdf;}</style>
<?php
}

1 Answer 1

4

Currently you're telling it to target all textareas on the page so you need to change

$init['mode'] = 'textareas'; to $init['mode'] = 'specific_textareas' or $init['mode'] = 'exact' and then name the textarea by id where you have $init['elements'] = 'category_description,description'; defined.

To read more about tinyMCE options go to http://tinymce.moxiecode.com/wiki.php/Configuration and the mode configuration description is here http://tinymce.moxiecode.com/wiki.php/Configuration:mode

1
  • 1
    +1 would go +5 if allowed :-) had to use "mode=exact" and elements = description. Worked a charm!
    – Scott B
    Feb 21, 2011 at 19:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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