【发布时间】:2017-11-17 10:11:15
【问题描述】:
我正在为我的 wp 主题构建自定义 tinymce 栏按钮,使用 wp_editor 和 teeny,但我遇到了问题。当我添加 hr 和 charmap 时,这些按钮不会出现在 tinymce 栏中。
这是 wp_editor 配置:
$settings = array(
'textarea_name' => 'xor_options[' . $editor . ']',
'quicktags' => array( 'buttons' => 'strong,em,del,ul,ol,li,close' ),
'media_buttons' => true,
'wpautop' => false,
'textarea_rows' => 5,
'editor_height' => 200,
'teeny' => true,
'tinymce' => true
);
wp_editor( $xor_output, $xor_editor_id, $settings );
现在我正在为小按钮使用过滤器。
add_filter( 'teeny_mce_buttons', 'xor_editor_buttons', 10, 2 );
function xor_editor_buttons( $buttons, $editor_id ) {
if( $editor_id != 'footer-editor' ) return $buttons;
$buttons = array(
'undo',
'redo',
'formatselect',
'bold',
'italic',
'underline',
'strikethrough',
'blockquote',
'bullist',
'numlist',
'outdent',
'indent',
'alignleft',
'alignright',
'aligncenter',
'alignjustify',
'link',
'unlink',
'hr', // not appears!
'charmap', // not appears!
'removeformat',
'fullscreen'
);
return $buttons;
}
我的代码中的错误在哪里,或者这是一个小错误?我正在使用 Wordpress 4.9。谢谢!
已解决
我设置了 false teeny。然后我将 tinymce 设置为数组:
'tinymce' => array(
'toolbar1' => $b,
'toolbar2' => '',
'toolbar3' => '',
)
$b 是我需要的所有按钮(包括 hr 和charmap)。看: Wordpress Developers
【问题讨论】: