Make WordPress Core


Ignore:
Timestamp:
09/14/2022 02:19:16 PM (23 months ago)
Author:
audrasjb
Message:

Editor: Backport foundation for Layout block support refactor (part 1).

This change backports the following changes from Gutenberg repository:

  • [WordPress/gutenberg#40875 gutenberg#40875] Layout: Use semantic classnames, centralize layout definitions, reduce duplication, and fix blockGap in theme.json
  • [WordPress/gutenberg#42544 gutenberg#42544] Layout: Add a disable-layout-styles theme supports flag to opt out of all layout styles gutenberg#42544
  • [WordPress/gutenberg#42087 gutenberg#42087] Theme.json: Add block support feature level selectors for blocks gutenberg#42087
  • [WordPress/gutenberg#43792 gutenberg#43792] Global Styles: Split root layout rules into a different function gutenberg#43792
  • [WordPress/gutenberg#42544 gutenberg#42544] Layout: Add a disable-layout-styles theme supports flag to opt out of all layout styles gutenberg#42544
  • [WordPress/gutenberg#42665 gutenberg#42665] Layout: Reduce specificity of fallback blockGap styles gutenberg#42665
  • [WordPress/gutenberg#42085 gutenberg#42085] Core CSS support for root padding and alignfull blocks gutenberg#42085

Note that it doesn't entirely port over PR40875 — the remaining PHP changes for that PR will be explored in a separate PR targeting layout.php.

Props andrewserong, aaronrobertshaw, isabel_brison.
See #56467.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/block-editor.php

    r54155 r54159  
    210210        'disableCustomFontSizes'           => get_theme_support( 'disable-custom-font-sizes' ),
    211211        'disableCustomGradients'           => get_theme_support( 'disable-custom-gradients' ),
     212        'disableLayoutStyles'              => get_theme_support( 'disable-layout-styles' ),
    212213        'enableCustomLineHeight'           => get_theme_support( 'custom-line-height' ),
    213214        'enableCustomSpacing'              => get_theme_support( 'custom-spacing' ),
     
    418419            $global_styles[]      = $block_classes;
    419420        }
     421    } else {
     422        // If there is no `theme.json` file, ensure base layout styles are still available.
     423        $block_classes = array(
     424            'css'            => 'base-layout-styles',
     425            '__unstableType' => 'base-layout',
     426            'isGlobalStyles' => true,
     427        );
     428        $actual_css    = wp_get_global_stylesheet( array( $block_classes['css'] ) );
     429        if ( '' !== $actual_css ) {
     430            $block_classes['css'] = $actual_css;
     431            $global_styles[]  = $block_classes;
     432        }
    420433    }
    421434
     
    475488        unset( $editor_settings['__experimentalFeatures']['spacing']['padding'] );
    476489    }
     490    if ( isset( $editor_settings['__experimentalFeatures']['spacing']['customSpacingSize'] ) ) {
     491        $editor_settings['disableCustomSpacingSizes'] = ! $editor_ettings['__experimentalFeatures']['spacing']['customSpacingSize'];
     492        unset( $editor_settings['__experimentalFeatures']['spacing']['customSpacingSize'] );
     493    }
     494    if ( isset( $editor_settings['__experimentalFeatures']['spacing']['spacingSizes'] ) ) {
     495        $spacing_sizes_by_origin  = $editor_settings['__experimentalFeatures']['spacing']['spacingSizes'];
     496        $editor_settings['spacingSizes'] = isset( $spacing_sizes_by_origin['custom'] ) ?
     497            $spacing_sizes_by_origin['custom'] : (
     498                isset( $spacing_sizes_by_origin['theme'] ) ?
     499                    $spacing_sizes_by_origin['theme'] :
     500                    $spacing_sizes_by_origin['default']
     501            );
     502    }
    477503
    478504    $editor_settings['__unstableResolvedAssets']         = _wp_get_iframed_editor_assets();
    479505    $editor_settings['localAutosaveInterval']            = 15;
     506    $editor_settings['disableLayoutStyles']              = current_theme_supports( 'disable-layout-styles' );
    480507    $editor_settings['__experimentalDiscussionSettings'] = array(
    481508        'commentOrder'         => get_option( 'comment_order' ),
Note: See TracChangeset for help on using the changeset viewer.