最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

block editor - Get value of custom checkbox from Gutenberg sidebar in plugin

programmeradmin0浏览0评论

In older WordPress versions I have used post_submitbox_misc_actions. Now with the new Gutenberg editor, I'm struggling to achieve the same functionality with my existing WordPress plugin.

So basically I just need to add a simple checkbox in the "Post & Visibility" section/block in Gutenberg that must not be pre-filled or permanently stored. I just need the information whether the checkbox has been checked or not in the (PHP) WordPress plugin to perform a simple cURL call.

I have managed to add the the checkbox to Gutenberg using an registered JS file and the following code:

function MyPlugin({}) {
    return el(
        PluginPostStatusInfo,
        {
            className: 'my-plugin'
        },
        el(
            CheckboxControl,
            {
                name: 'notify',
                label: __( 'Send notification' ),
            }
        )
    );
}

registerPlugin( 'my-plugin', {
    render: MyPlugin
} );

But how can I process/read the checkbox information in my (PHP) WordPress plugin?

Thanks for helping!

发布评论

评论列表(0)

  1. 暂无评论