Default Block Editor Preferences for Everyone
Sets sensible defaults for every user of the block editor, such as the top toolbar, the List View opened and button text labels, while each person can still change them.
Opens WPIDE on
Code
// Editor preferences (true or false).
$wpide_editor_defaults = array(
'fixedToolbar' => true,
'showListViewByDefault' => true,
'showIconLabels' => false,
'showBlockBreadcrumbs' => true,
);
add_action( 'enqueue_block_editor_assets', function () use ( $wpide_editor_defaults ) {
wp_add_inline_script(
'wp-preferences',
'wp.domReady(function(){(window._wpLoadBlockEditor||Promise.resolve()).then(function(){wp.data.dispatch("core/preferences").setDefaults("core",' . wp_json_encode( array_map( 'boolval', $wpide_editor_defaults ) ) . ');});});'
);
} );
Notes
Only defaults change; anything a user has already set in Preferences wins. Set a value to true or false to taste.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.