Skip to content

Commit decd946

Browse files
Fix: Revert [54305].
This commit caused an incompatibility with the latest released Gutenberg version. Props bernhard-reiter. git-svn-id: https://develop.svn.wordpress.org/trunk@54306 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 2b1febd commit decd946

File tree

3 files changed

+13
-205
lines changed

3 files changed

+13
-205
lines changed

src/wp-includes/block-supports/settings.php

Lines changed: 0 additions & 152 deletions
This file was deleted.

src/wp-includes/class-wp-theme-json.php

Lines changed: 13 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ protected static function get_blocks_metadata() {
773773
static::$blocks_metadata[ $block_name ]['features'] = $features;
774774
}
775775

776-
// Assign defaults, then override those that the block sets by itself.
776+
// Assign defaults, then overwrite those that the block sets by itself.
777777
// If the block selector is compounded, will append the element to each
778778
// individual block selector.
779779
$block_selectors = explode( ',', static::$blocks_metadata[ $block_name ]['selector'] );
@@ -866,13 +866,11 @@ public function get_settings() {
866866
* @param array $types Types of styles to load. Will load all by default. It accepts:
867867
* - `variables`: only the CSS Custom Properties for presets & custom ones.
868868
* - `styles`: only the styles section in theme.json.
869-
* - `presets`: only the classes for the presets. @param array $origins A list of origins to include. By default it includes VALID_ORIGINS.
870-
* @param array $options An array of options for now used for internal purposes only (may change without notice).
871-
* The options currently supported are 'scope' that makes sure all style are scoped to a given selector,
872-
* and root_selector which overwrites and forces a given selector to be used on the root node.
869+
* - `presets`: only the classes for the presets.
870+
* @param array $origins A list of origins to include. By default it includes VALID_ORIGINS.
873871
* @return string Stylesheet.
874872
*/
875-
public function get_stylesheet( $types = array( 'variables', 'styles', 'presets' ), $origins = null, $options = array() ) {
873+
public function get_stylesheet( $types = array( 'variables', 'styles', 'presets' ), $origins = null ) {
876874
if ( null === $origins ) {
877875
$origins = static::VALID_ORIGINS;
878876
}
@@ -893,58 +891,30 @@ public function get_stylesheet( $types = array( 'variables', 'styles', 'presets'
893891
$style_nodes = static::get_style_nodes( $this->theme_json, $blocks_metadata );
894892
$setting_nodes = static::get_setting_nodes( $this->theme_json, $blocks_metadata );
895893

896-
$root_style_key = array_search( static::ROOT_BLOCK_SELECTOR, array_column( $style_nodes, 'selector' ), true );
897-
$root_settings_key = array_search( static::ROOT_BLOCK_SELECTOR, array_column( $setting_nodes, 'selector' ), true );
898-
899-
if ( ! empty( $options['scope'] ) ) {
900-
foreach ( $setting_nodes as &$node ) {
901-
$node['selector'] = static::scope_selector( $options['scope'], $node['selector'] );
902-
}
903-
foreach ( $style_nodes as &$node ) {
904-
$node['selector'] = static::scope_selector( $options['scope'], $node['selector'] );
905-
}
906-
}
907-
908-
if ( ! empty( $options['root_selector'] ) ) {
909-
if ( false !== $root_settings_key ) {
910-
$setting_nodes[ $root_settings_key ]['selector'] = $options['root_selector'];
911-
}
912-
if ( false !== $root_style_key ) {
913-
$setting_nodes[ $root_style_key ]['selector'] = $options['root_selector'];
914-
}
915-
}
916-
917894
$stylesheet = '';
918895

919896
if ( in_array( 'variables', $types, true ) ) {
920897
$stylesheet .= $this->get_css_variables( $setting_nodes, $origins );
921898
}
922899

923900
if ( in_array( 'styles', $types, true ) ) {
924-
if ( false !== $root_style_key ) {
925-
$stylesheet .= $this->get_root_layout_rules( $style_nodes[ $root_style_key ]['selector'], $style_nodes[ $root_style_key ] );
901+
$root_block_key = array_search( static::ROOT_BLOCK_SELECTOR, array_column( $style_nodes, 'selector' ), true );
902+
903+
if ( false !== $root_block_key ) {
904+
$stylesheet .= $this->get_root_layout_rules( static::ROOT_BLOCK_SELECTOR, $style_nodes[ $root_block_key ] );
926905
}
927906
$stylesheet .= $this->get_block_classes( $style_nodes );
928907
} elseif ( in_array( 'base-layout-styles', $types, true ) ) {
929-
$root_selector = static::ROOT_BLOCK_SELECTOR;
930-
$columns_selector = '.wp-block-columns';
931-
if ( ! empty( $options['scope'] ) ) {
932-
$root_selector = static::scope_selector( $options['scope'], $root_selector );
933-
$columns_selector = static::scope_selector( $options['scope'], $columns_selector );
934-
}
935-
if ( ! empty( $options['root_selector'] ) ) {
936-
$root_selector = $options['root_selector'];
937-
}
938908
// Base layout styles are provided as part of `styles`, so only output separately if explicitly requested.
939909
// For backwards compatibility, the Columns block is explicitly included, to support a different default gap value.
940910
$base_styles_nodes = array(
941911
array(
942912
'path' => array( 'styles' ),
943-
'selector' => $root_selector,
913+
'selector' => static::ROOT_BLOCK_SELECTOR,
944914
),
945915
array(
946916
'path' => array( 'styles', 'blocks', 'core/columns' ),
947-
'selector' => $columns_selector,
917+
'selector' => '.wp-block-columns',
948918
'name' => 'core/columns',
949919
),
950920
);
@@ -1395,27 +1365,18 @@ protected static function compute_preset_classes( $settings, $selector, $origins
13951365
* @param string $selector Original selector.
13961366
* @return string Scoped selector.
13971367
*/
1398-
public static function scope_selector( $scope, $selector ) {
1368+
protected static function scope_selector( $scope, $selector ) {
13991369
$scopes = explode( ',', $scope );
14001370
$selectors = explode( ',', $selector );
14011371

14021372
$selectors_scoped = array();
14031373
foreach ( $scopes as $outer ) {
14041374
foreach ( $selectors as $inner ) {
1405-
$outer = trim( $outer );
1406-
$inner = trim( $inner );
1407-
if ( ! empty( $outer ) && ! empty( $inner ) ) {
1408-
$selectors_scoped[] = $outer . ' ' . $inner;
1409-
} elseif ( empty( $outer ) ) {
1410-
$selectors_scoped[] = $inner;
1411-
} elseif ( empty( $inner ) ) {
1412-
$selectors_scoped[] = $outer;
1413-
}
1375+
$selectors_scoped[] = trim( $outer ) . ' ' . trim( $inner );
14141376
}
14151377
}
14161378

1417-
$result = implode( ', ', $selectors_scoped );
1418-
return $result;
1379+
return implode( ', ', $selectors_scoped );
14191380
}
14201381

14211382
/**

src/wp-settings.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@
322322
require ABSPATH . WPINC . '/block-patterns.php';
323323
require ABSPATH . WPINC . '/class-wp-block-supports.php';
324324
require ABSPATH . WPINC . '/block-supports/utils.php';
325-
require ABSPATH . WPINC . '/block-supports/settings.php';
326325
require ABSPATH . WPINC . '/block-supports/align.php';
327326
require ABSPATH . WPINC . '/block-supports/border.php';
328327
require ABSPATH . WPINC . '/block-supports/colors.php';

0 commit comments

Comments
 (0)