Gutenberg编辑器中的自定义操作按钮(post_submitbox_misc_action-等效)

时间:2019-01-08 作者:Jerzy Jerzynka

关于经典编辑器和Wordress 4。x我用过\'post_submitbox_misc_actions\' 将自定义控件添加到提交框区域的操作。古腾堡编辑有没有办法做到这一点?一些相当于旧动作的动作?

谢谢你的帮助。

1 个回复
SO网友:mihdan
wp_enqueue_script(
    \'some-slug\',
    \'/path/to/script.js\',
    array( \'wp-edit-post\', \'wp-plugins\', \'wp-i18n\', \'wp-element\' ),
    \'0.1\'
);

script.js:

var el = wp.element.createElement;
var __ = wp.i18n.__;
var registerPlugin = wp.plugins.registerPlugin;
var PluginPostStatusInfo = wp.editPost.PluginPostStatusInfo;
var TextControl = wp.components.TextControl;

function MyPostStatusInfoPlugin({}) {
    return el(
        PluginPostStatusInfo,
        {
            className: \'my-post-status-info\'
        },
        el(
            TextControl,
            {
                name: \'my_edit_summary\',
                label: __( \'Edit summary\' ),
                help: __( \'Briefly summarise your changes\' )
            }
        )
    );
}

registerPlugin( \'my-post-status-info-plugin\', {
    render: MyPostStatusInfoPlugin
} );

相关推荐