我有一个用例,在使用javascript加载页面后,我们需要更新Gutenberg全局调色板。我知道add_theme_support('editor-color-palette', ...) PHP选项,但它在这种情况下不起作用。
似乎可以使用以下命令分派操作:
wp.data.dispatch( 'core/editor' ).updateEditorSettings( {colors: [{name: 'test', slug: 'test', color: '#00FF00'}]} );此操作用于更新编辑器设置,可以使用以下命令进行确认:
wp.data.select( "core/editor" ).getEditorSettings()但是,UI不会重新渲染以显示更新的调色板选项。
有没有一种方法可以使用更新编辑器设置来触发块重新渲染?
发布于 2020-05-06 09:15:49
根据Github上的这个问题,它现在被称为updateSettings。
wp.data.dispatch('core/block-editor').updateSettings({
colors: [{name: 'test', slug: 'test', color: '#00FF00'}]
})https://stackoverflow.com/questions/56438265
复制相似问题