不通过teeny_mce_buttons筛选器显示心率



我正在使用wp_editor和Teeny为我的wp主题构建自定义的tinymce栏按钮,但我有一个问题。当我添加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。谢谢!


解决

我开始假小。然后我将 tinymce 设置为数组:

'tinymce'       => array(
            'toolbar1'      => $b,
            'toolbar2'      => '',
            'toolbar3'      => '',
        )

$b是我需要的所有按钮(包括hr和charmap(。看: WordPress开发人员

在加载工具栏按钮之前,您需要加载插件:

https://www.tinymce.com/docs/plugins/hr/https://www.tinymce.com/docs/plugins/charmap/

您首先需要查看嵌入在WP版本中的TinyMCE是否包含这些插件(它们在标准的WordPress设置中(。 然后,您需要将这些插件添加到已加载的插件列表中。 加载后,将按钮添加到工具栏将起作用。

我对teenymce一无所知,但是(例如(这就是TinyMCE Advanced通过WordPress钩子加载额外插件的方式:

 add_filter( 'tiny_mce_plugins', array( $this, 'tiny_mce_plugins' ), 999 );  

(该数组是插件文件夹名称的列表(

最新更新