要实现下拉样式,我们必须使用过滤器挂钩tiny_mce_before_init
. 此过滤器允许开发人员访问TinyMCE设置数组。
以下示例将自定义样式选项添加到现有样式下拉列表中。
add_filter( \'tiny_mce_before_init\', \'my_mce_before_init\' );
function my_mce_before_init( $settings ) {
$style_formats = array(
array(
\'title\' => \'1/5 Block\',
\'block\' => \'div\',
\'classes\' => \'col-md-5\',
\'wrapper\' => true
),
array(
\'title\' => \'Pull Left\',
\'block\' => \'div\',
\'classes\' => \'pull-left\',
\'wrapper\' => true
),
array(
\'title\' => \'Button R\',
\'selector\' => \'a\',
\'classes\' => \'btn btn-default pull-right\'
),
array(
\'title\' => \'Text Center Green Button\',
\'selector\' => \'a\',
\'classes\' => \'btn btn-green center\'
),
array(
\'title\' => \'Clearfix\',
\'block\' => \'div\',
\'classes\' => \'clearfix\'
),
);
$settings[\'style_formats\'] = json_encode( $style_formats );
return $settings;
}
有关tinymce按钮及其用法和挂钩的更多信息,请访问
here.