Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
612 views
in Technique[技术] by (71.8m points)

How to add custom TinyMCE button to ACF editor?

I have added custom tinyMCE button to editor, but I can't figure out how to add it to editor in ACF.

function mce_cta_button() {
    if ( is_admin() ) {
        add_filter( 'mce_external_plugins', 'custom_tinymce_plugin' );
        add_filter( 'mce_buttons', 'register_mce_buttons' );
    }
}
add_action('admin_head', 'mce_cta_button');

I have tried to add this:

add_filter( 'acf/fields/wysiwyg/toolbars' , 'my_toolbars'  );
function my_toolbars( $toolbars )
{
    return array();
}

then it works, but I get error:

Warning: array_unshift() expects parameter 1 to be array, null given in .../themes/behold-standard/libs/others.php on line 50

Warning: implode(): Invalid arguments passed in .../plugins/advanced-custom-fields-pro/includes/fields/class-acf-field-wysiwyg.php on line 176

in others.php file I have this script:

function customToolbars( $toolbars ) {
    array_unshift( $toolbars ['Basic'][1], 'fontsizeselect', 'forecolor', 'subscript', 'superscript' );
    return $toolbars;
}
add_filter( 'acf/fields/wysiwyg/toolbars' , 'customToolbars'  );

where is my mistake?

question from:https://stackoverflow.com/questions/65946607/how-to-add-custom-tinymce-button-to-acf-editor

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...