TinyMCE编辑器formatselect中如何添加代码code项?
分类:WordPress
我想在TinyMCE编辑器formatselect中添加代码code项,自带的只有段落p、各级标题h1-h6以及pre,我想要加入代码<code></code>标签,这样可以用highlight使代码高亮。
4个回复
-
/** * Change the block formats available in TinyMCE. * * @link http://codex.wordpress.org/TinyMCE_Custom_Styles * * @param array $init Default settings to be overridden. * * @return array The modified $init array. */ function cdils_change_mce_block_formats( $init ) { $block_formats = array( 'Paragraph=p', 'Heading 1=h1', 'Heading 2=h2', 'Heading 3=h3', 'Heading 4=h4', 'Heading 5=h5', 'Heading 6=h6', 'Preformatted=pre', 'Code=code', ); $init['block_formats'] = implode( ';', $block_formats ); return $init; } add_filter( 'tiny_mce_before_init', 'cdils_change_mce_block_formats' );
3年前 我来评论