admin管理员组文章数量:1122832
I'd like to remove the Discussion Panel in the post editor sidebar with removeEditorPanel()
.
I'm trying to do the following:
const { removeEditorPanel } = wp.data.dispatch( 'core/edit-post' )
removeEditorPanel( 'discussion-panel' )
However, I get an error that removeEditorPanel
is undefined because, I assume, core/edit-post
hasn't loaded yet. Is there an event or hook that I can use to know that the post editor is loaded?
As a workaround, I'm using an interval to check that window.wp
exists and a querySelector()
to check for .edit-post-sidebar
, but that just feels janky.
I'd like to remove the Discussion Panel in the post editor sidebar with removeEditorPanel()
.
I'm trying to do the following:
const { removeEditorPanel } = wp.data.dispatch( 'core/edit-post' )
removeEditorPanel( 'discussion-panel' )
However, I get an error that removeEditorPanel
is undefined because, I assume, core/edit-post
hasn't loaded yet. Is there an event or hook that I can use to know that the post editor is loaded?
As a workaround, I'm using an interval to check that window.wp
exists and a querySelector()
to check for .edit-post-sidebar
, but that just feels janky.
1 Answer
Reset to default 0I think this is due to how you've destructured it out. I believe dispatch works as a realtime "action". So you need call dispatch()
when you want to remove the panel.
Try this:
const { dispatch } = wp.data;
dispatch( 'core/edit-post' ).removeEditorPanel( 'discussion-panel' )
本文标签: block editorWhen to use removeEditorPanel()
版权声明:本文标题:block editor - When to use removeEditorPanel() 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736285754a1927524.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
wp_enqueue_script( 'orthoscan_blocks-js', plugins_url( '/dist/blocks.build.js', dirname( __FILE__ ) ),array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor' ), true );
– Mattimator Commented Jul 10, 2019 at 15:21