Using WordPress ‘get_classic_theme_supports_block_editor_settings()’ PHP function

The get_classic_theme_supports_block_editor_settings() WordPress PHP function returns the classic theme supports settings for the block editor.

Usage

$settings = get_classic_theme_supports_block_editor_settings();

Parameters

This function has no parameters.

More information

See WordPress Developer Resources: get_classic_theme_supports_block_editor_settings()

Examples

Retrieve block editor settings for classic theme

This example retrieves the block editor settings for the classic theme and prints them out.

$settings = get_classic_theme_supports_block_editor_settings();
print_r($settings);

Check if a specific setting is enabled

This example checks if the ‘align-wide’ setting is enabled for the classic theme.

$settings = get_classic_theme_supports_block_editor_settings();
$is_align_wide_enabled = in_array('align-wide', $settings);

Add a custom block editor setting

This example adds a custom setting ‘custom-setting’ to the classic theme’s block editor settings.

add_theme_support('block-editor-settings', array('custom-setting'));

$settings = get_classic_theme_supports_block_editor_settings();
print_r($settings);

Remove a specific block editor setting

This example removes the ‘align-wide’ setting from the classic theme’s block editor settings.

add_filter('block_editor_settings', function($settings) {
    $key = array_search('align-wide', $settings);
    if (false !== $key) {
        unset($settings[$key]);
    }
    return $settings;
});

$updated_settings = get_classic_theme_supports_block_editor_settings();
print_r($updated_settings);

Combine multiple block editor settings

This example retrieves the classic theme’s block editor settings and combines them with additional custom settings.

$custom_settings = array('custom-setting-1', 'custom-setting-2');
$default_settings = get_classic_theme_supports_block_editor_settings();

$combined_settings = array_merge($default_settings, $custom_settings);
print_r($combined_settings);