我正在使用以下代码在mce工具栏中添加样式下拉列表,我希望能够使用下拉列表添加h1元素,但我的代码不起作用,我尝试了几种不同的方法,但都不起作用,我得到了此代码表单here
add_filter( \'mce_buttons_2\', \'my_mce_buttons_2\' );
function my_mce_buttons_2( $buttons ) {
array_unshift( $buttons, \'styleselect\' );
return $buttons;
}
//mce custom classes
add_filter( \'tiny_mce_before_init\', \'my_mce_before_init\' );
function my_mce_before_init( $settings ) {
$style_formats = array(
array(
\'title\' => \'Button\',
\'selector\' => \'h1\',
\'classes\' => \'button\'
),
array(
\'title\' => \'h1\',
\'block\' => \'h1\',
\'classes\' => \'superHead\',
\'wrapper\' => true
),
array(
\'title\' => \'Bold Brown\',
\'inline\' => \'span\',
\'styles\' => array(
\'color\' => \'#481e07\',
\'fontWeight\' => \'bold\'
)
),
array(
\'title\' => \'Header\',
\'inline\' => \'span\',
\'styles\' => array(
\'font-size\' => \'24px\'
)
)
);
$settings[\'style_formats\'] = json_encode( $style_formats );
return $settings;
}
//mse custome classes
add_action( \'admin_init\', \'add_my_editor_style\' );
function add_my_editor_style() {
add_editor_style();
}