Skip to content

Instantly share code, notes, and snippets.

@manishsongirkar
Created August 29, 2014 07:49
Show Gist options
  • Save manishsongirkar/e437d7c9da5d40ced81b to your computer and use it in GitHub Desktop.
Save manishsongirkar/e437d7c9da5d40ced81b to your computer and use it in GitHub Desktop.
Add wp_editor to Category Description and remove default category description box
/**
* Remove HTML Filtering
*/
remove_filter( 'pre_term_description', 'wp_filter_kses' );
remove_filter( 'term_description', 'wp_kses_data' );
/**
* Add WP_Editor to Category Description
*
* @param type $tag
*/
function rtp_cat_description( $tag ) { ?>
<table class="form-table">
<tr class="form-field">
<th scope="row" valign="top">
<label for="description"><?php _ex( 'Description', 'Taxonomy Description' ); ?></label>
</th>
<td><?php
$settings = array(
'wpautop' => true,
'media_buttons' => false,
'quicktags' => false,
'teeny' => true,
'textarea_rows' => '10',
'textarea_name' => 'description',
'drag_drop_upload' => false
);
wp_editor( wp_kses_post( $tag->description, ENT_QUOTES, 'UTF-8' ), 'cat_description', $settings ); ?>
<br />
<span class="description"><?php _e( 'The description is not prominent by default; however, some themes may show it.' ); ?></span>
</td>
</tr>
</table><?php
}
add_filter( 'edit_category_form_fields', 'rtp_cat_description' );
/**
* Remove Default Category Description
* @global type $current_screen
*/
function rtp_remove_default_category_description() {
global $current_screen;
if ( $current_screen->id == 'edit-category' ) { ?>
<script type="text/javascript">
jQuery( function( $ ) {
$( 'textarea#description' ).closest( 'tr.form-field' ).remove();
} );
</script><?php
}
}
add_action( 'admin_head', 'rtp_remove_default_category_description' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment