apply_filters_deprecated( ‘block_editor_settings’, array $editor_settings, WP_Post $post )

This hook has been deprecated. Use the {@see ‘block_editor_settings_all’} filter instead.

Filters the settings to pass to the block editor.

Parameters

$editor_settingsarray
Default editor settings.
$postWP_Post
Post being edited.

Source

$editor_settings = apply_filters_deprecated( 'block_editor_settings', array( $editor_settings, $post ), '5.8.0', 'block_editor_settings_all' );

Changelog

VersionDescription
5.8.0Use the 'block_editor_settings_all' filter instead.
5.0.0Introduced.

User Contributed Notes

  1. Skip to note 3 content
    /**
     * Remove DropCap option from settings panel.
     * 
     * @param   array       $settings   Default editor settings. 
     * @return  array       $settings   Filtered block editor settings.
     */
    add_filter( 'block_editor_settings', function( $editor_settings ) {
    	$editor_settings['__experimentalFeatures']['global']['typography']['dropCap'] = false;
    	return $editor_settings;
    } );
  2. Skip to note 4 content
    /**
     * Adds a custom parameter to the editor settings that is used
     * to track whether the main sidebar has widgets.
     *
     * @param 	array   	$settings 	Default editor settings.
     * @param 	WP_Post 	$post 		Post being edited.
     * @return 	array 		$settings 	Filtered block editor settings.
     */
    function prefix_custom_editor_settings( $settings, $post ) {
    	$settings['isSidebarActive'] = FALSE;
    	
    	// Determines whether a sidebar is in use.
    	if ( is_active_sidebar( 'sidebar-1' ) ) {
    		$settings['isSidebarActive'] = TRUE;
    	} // End If Statement
    	
    	return $settings;
    }
    add_filter( 'block_editor_settings', 'prefix_custom_editor_settings', 10, 2 );
    ( function() {
    	/**
    	 * Check if the main sidebar is active (has widgets).
    	 *
    	 * This uses a custom property `isSidebarActive` added via the
    	 * `block_editor_settings` filter.
    	 *
    	 * @return 	{boolean} 	Whether sidebar is active.
    	 */
    	const sidebarIsActive = () => {
    		let settings = wp.data.select( 'core/editor' ).getEditorSettings();
    
    		if ( settings.hasOwnProperty( 'isSidebarActive' ) && !! settings.isSidebarActive ) {
    			return true;
    		} // End If Statement
    
    		return false;
    	};
    } )();

You must log in before being able to contribute a note or feedback.