古腾堡Options > Preferences 菜单包含许多其他设置,可定制古腾堡体验。默认GUI如下所示。我想以编程方式启用Reduce the interface 选项
当前代码
使用wp.data.select
作用const reduceInterface = wp.data.select( \'core/edit-post\' )
.isFeatureActive( \'reduceInterface\' )
console.log( reduceInterface )
这正确地显示true
/false
当选项Reduce the interface 通过GUI启用/禁用。但是,使用以编程方式更改值wp.data.dispatch
, 正如通常所做的那样,似乎不起作用。
if ( !reduceInterface ) {
wp.data.dispatch( \'core/edit-post\' )
.toggleFeature( \'reduceInterface\' )
}
不会引发错误,但不会更改选项。