在 WordPress 中,我希望将 TinyMCE 的文本颜色选择 HTML 输出从样式更新为跨度,添加自定义类。例如,
<style color="#ffffff">highlighted text</style>
=> <span class="white">highlighted text</span>
我当前的功能是更新颜色。我没有看到任何关于支持这个的 Tiny 文档的文档。但也许可以使用 style_formats?
function mce_color_options( $init ) {
$default_colours = '
"000000", "Black",
"FFFFFF", "White"
';
$custom_colours = '
"9A3359", "Red",
"E21D79", "Pink",
';
$init['textcolor_map'] = '['.$default_colours.','.$custom_colours.']';
$init['textcolor_rows'] = 1;
return $init;
}
add_filter('tiny_mce_before_init', 'mce_color_options');