This correctly shows
true
/false
when the option for Reduce the interface is enabled/disabled through the GUI.
Are you sure isFeatureActive( 'reduceInterface' )
worked?
Because I looked at the source code (see wp-includes/js/dist/edit-post.js
) and then I found out that the feature name is actually reducedUI
and not reduceInterface
.
So try with reducedUI
instead:
let reduceInterface = wp.data.select( 'core/edit-post' ).isFeatureActive( 'reducedUI' );
console.log( 'before', reduceInterface );
wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'reducedUI' ); // enable/disable it
reduceInterface = wp.data.select( 'core/edit-post' ).isFeatureActive( 'reducedUI' );
console.log( 'after', reduceInterface );
The above worked for me on WordPress 5.8 and 5.8.2 (the latest release as of writing).