您可以通过以下方式控制“格式”下拉列表中的字体大小和类型adding an editor style.
WPSE用户helgatheviking 解释了如何在她的帖子中向格式下拉列表添加样式here. 我已经包含了下面的相关代码,其中有一个小的调整,允许下拉项也继承CSS属性,如颜色和线条高度。
function mce_mod( $init ) {
$init[\'block_formats\'] = \'Paragraph=p;Heading 3=h3;Heading 4=h4\';
//This allows color styles to be inherited from the editor styelsheet.
unset($init[\'preview_styles\']);
$style_formats = array (
array( \'title\' => \'Bold text\', \'inline\' => \'b\' ),
array( \'title\' => \'Red text\', \'inline\' => \'span\', \'styles\' => array( \'color\' => \'#ff0000\' ) ),
array( \'title\' => \'Red header\', \'block\' => \'h1\', \'styles\' => array( \'color\' => \'#ff0000\' ) ),
array( \'title\' => \'Example 1\', \'inline\' => \'span\', \'classes\' => \'example1\' ),
array( \'title\' => \'Example 2\', \'inline\' => \'span\', \'classes\' => \'example2\' )
);
$init[\'style_formats\'] = json_encode( $style_formats );
$init[\'style_formats_merge\'] = false;
return $init;
}
add_filter(\'tiny_mce_before_init\', \'mce_mod\');
function mce_add_buttons( $buttons ){
array_splice( $buttons, 1, 0, \'styleselect\' );
return $buttons;
}
add_filter( \'mce_buttons_2\', \'mce_add_buttons\' );