get_block_editor_settings() – Returns the contextualized block editor settings for a selected editor context.

Description

Returns the contextualized block editor settings for a selected editor context.

Usage

$array = get_block_editor_settings( $custom_settings, $block_editor_context );

Parameters

$custom_settings
( array ) required – Custom settings to use with the given editor type.
$block_editor_context
( WP_Block_Editor_Context ) required – The current block editor context.

Returns

array The contextualized block editor settings.

Source

File name: wordpress/wp-includes/block-editor.php
Lines:

1 to 100 of 174
function get_block_editor_settings( array $custom_settings, $block_editor_context ) {
  $editor_settings = array_merge(
    get_default_block_editor_settings(),
    array(
      'allowedBlockTypes' => get_allowed_block_types( $block_editor_context ),
      'blockCategories'   => get_block_categories( $block_editor_context ),
    ),
    $custom_settings
  );

  $global_styles = array();
  $presets       = array(
    array(
      'css'            => 'variables',
      '__unstableType' => 'presets',
      'isGlobalStyles' => true,
    ),
    array(
      'css'            => 'presets',
      '__unstableType' => 'presets',
      'isGlobalStyles' => true,
    ),
  );
  foreach ( $presets as $preset_style ) {
    $actual_css = wp_get_global_stylesheet( array( $preset_style['css'] ) );
    if ( '' !== $actual_css ) {
      $preset_style['css'] = $actual_css;
      $global_styles[]     = $preset_style;
    }
  }

  if ( WP_Theme_JSON_Resolver::theme_has_support() ) {
    $block_classes = array(
      'css'            => 'styles',
      '__unstableType' => 'theme',
      'isGlobalStyles' => true,
    );
    $actual_css    = wp_get_global_stylesheet( array( $block_classes['css'] ) );
    if ( '' !== $actual_css ) {
      $block_classes['css'] = $actual_css;
      $global_styles[]      = $block_classes;
    }
  } else {
    // If there is no `theme.json` file, ensure base layout styles are still available.
    $block_classes = array(
      'css'            => 'base-layout-styles',
      '__unstableType' => 'base-layout',
      'isGlobalStyles' => true,
    );
    $actual_css    = wp_get_global_stylesheet( array( $block_classes['css'] ) );
    if ( '' !== $actual_css ) {
      $block_classes['css'] = $actual_css;
      $global_styles[]      = $block_classes;
    }
  }

  $editor_settings['styles'] = array_merge( $global_styles, get_block_editor_theme_styles() );

  $editor_settings['__experimentalFeatures'] = wp_get_global_settings();
  // These settings may need to be updated based on data coming from theme.json sources.
  if ( isset( $editor_settings['__experimentalFeatures']['color']['palette'] ) ) {
    $colors_by_origin          = $editor_settings['__experimentalFeatures']['color']['palette'];
    $editor_settings['colors'] = isset( $colors_by_origin['custom'] ) ?
      $colors_by_origin['custom'] : (
        isset( $colors_by_origin['theme'] ) ?
          $colors_by_origin['theme'] :
          $colors_by_origin['default']
      );
  }
  if ( isset( $editor_settings['__experimentalFeatures']['color']['gradients'] ) ) {
    $gradients_by_origin          = $editor_settings['__experimentalFeatures']['color']['gradients'];
    $editor_settings['gradients'] = isset( $gradients_by_origin['custom'] ) ?
      $gradients_by_origin['custom'] : (
        isset( $gradients_by_origin['theme'] ) ?
          $gradients_by_origin['theme'] :
          $gradients_by_origin['default']
      );
  }
  if ( isset( $editor_settings['__experimentalFeatures']['typography']['fontSizes'] ) ) {
    $font_sizes_by_origin         = $editor_settings['__experimentalFeatures']['typography']['fontSizes'];
    $editor_settings['fontSizes'] = isset( $font_sizes_by_origin['custom'] ) ?
      $font_sizes_by_origin['custom'] : (
        isset( $font_sizes_by_origin['theme'] ) ?
          $font_sizes_by_origin['theme'] :
          $font_sizes_by_origin['default']
      );
  }
  if ( isset( $editor_settings['__experimentalFeatures']['color']['custom'] ) ) {
    $editor_settings['disableCustomColors'] = ! $editor_settings['__experimentalFeatures']['color']['custom'];
    unset( $editor_settings['__experimentalFeatures']['color']['custom'] );
  }
  if ( isset( $editor_settings['__experimentalFeatures']['color']['customGradient'] ) ) {
    $editor_settings['disableCustomGradients'] = ! $editor_settings['__experimentalFeatures']['color']['customGradient'];
    unset( $editor_settings['__experimentalFeatures']['color']['customGradient'] );
  }
  if ( isset( $editor_settings['__experimentalFeatures']['typography']['customFontSize'] ) ) {
    $editor_settings['disableCustomFontSizes'] = ! $editor_settings['__experimentalFeatures']['typography']['customFontSize'];
    unset( $editor_settings['__experimentalFeatures']['typography']['customFontSize'] );
  }
  if ( isset( $editor_settings['__experimentalFeatures']['typography']['lineHeight'] ) ) {
 

 View on GitHub View on Trac

Invoked by

    Call hooks

    API Letters: ,,,