Add tinymce editor for post excerpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'add_meta_boxes', array ( 'add_tinymce_to_excerpt', 'switch_boxes' ) ); | |
class add_tinymce_to_excerpt{ | |
public static function switch_boxes(){ | |
if ( ! post_type_supports( $GLOBALS['post']->post_type, 'excerpt' ) ){ | |
return; | |
} | |
remove_meta_box( 'postexcerpt', '', 'normal' ); | |
add_meta_box( 'postexcerpt2', 'Excerpt' , array ( __CLASS__, 'show' ), null, 'normal', 'core' ); | |
} | |
public static function show( $post ){ | |
?> | |
<label class="screen-reader-text" for="excerpt">Excerpt</label> | |
<?php | |
wp_editor( self::unescape( $post->post_excerpt ), 'excerpt', array ( 'textarea_rows' => 15, 'media_buttons' => false, 'teeny' => false, 'tinymce' => true ) ); | |
} | |
public static function unescape( $str ){ | |
return str_replace( array ( '<', '>', '"', '&', ' ', '&nbsp;' ), array ( '<', '>', '"', '&', ' ', ' ' ), $str); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment