From 7f74df5438a164150281a0b2b2ab693019da51f8 Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Fri, 10 Jun 2022 15:04:05 +0100 Subject: [PATCH 01/10] Add ui for button elements --- .../global-styles/screen-button-color.js | 70 +++++++++++++++++++ .../components/global-styles/screen-colors.js | 26 +++++++ .../screen-typography-element.js | 4 ++ .../global-styles/screen-typography.js | 6 ++ .../src/components/global-styles/ui.js | 11 +++ 5 files changed, 117 insertions(+) create mode 100644 packages/edit-site/src/components/global-styles/screen-button-color.js diff --git a/packages/edit-site/src/components/global-styles/screen-button-color.js b/packages/edit-site/src/components/global-styles/screen-button-color.js new file mode 100644 index 0000000000000..d5c3c508b89d1 --- /dev/null +++ b/packages/edit-site/src/components/global-styles/screen-button-color.js @@ -0,0 +1,70 @@ +/** + * WordPress dependencies + */ +import { __ } from '@wordpress/i18n'; +import { __experimentalColorGradientControl as ColorGradientControl } from '@wordpress/block-editor'; + +/** + * Internal dependencies + */ +import ScreenHeader from './header'; +import { + getSupportedGlobalStylesPanels, + useSetting, + useStyle, + useColorsPerOrigin, +} from './hooks'; + +function ScreenButtonColor( { name } ) { + const supports = getSupportedGlobalStylesPanels( name ); + const [ solids ] = useSetting( 'color.palette', name ); + const [ areCustomSolidsEnabled ] = useSetting( 'color.custom', name ); + + const colorsPerOrigin = useColorsPerOrigin( name ); + + const [ isLinkEnabled ] = useSetting( 'color.link', name ); + + const hasButtonColor = + supports.includes( 'linkColor' ) && + isLinkEnabled && + ( solids.length > 0 || areCustomSolidsEnabled ); // TODO - use the right check + + const [ buttonColor, setButtonColor ] = useStyle( + 'elements.button.color.text', + name + ); + const [ userButtonColor ] = useStyle( + 'elements.button.color.text', + name, + 'user' + ); + + if ( ! hasButtonColor ) { + return null; + } + + return ( + <> + + + + ); +} + +export default ScreenButtonColor; diff --git a/packages/edit-site/src/components/global-styles/screen-colors.js b/packages/edit-site/src/components/global-styles/screen-colors.js index 4e961dcf0e75b..25b360600c5fa 100644 --- a/packages/edit-site/src/components/global-styles/screen-colors.js +++ b/packages/edit-site/src/components/global-styles/screen-colors.js @@ -88,6 +88,28 @@ function LinkColorItem( { name, parentMenu } ) { ); } +function ButtonColorItem( { name, parentMenu } ) { + const supports = getSupportedGlobalStylesPanels( name ); + const hasSupport = supports.includes( 'linkColor' ); // TODO - use a real support + const [ color ] = useStyle( 'elements.button.color.text', name ); + + if ( ! hasSupport ) { + return null; + } + + return ( + + + + + + { __( 'Buttons' ) } + + + ); +} + + function ScreenColors( { name } ) { const parentMenu = name === undefined ? '' : '/blocks/' + name; @@ -119,6 +141,10 @@ function ScreenColors( { name } ) { name={ name } parentMenu={ parentMenu } /> + diff --git a/packages/edit-site/src/components/global-styles/screen-typography-element.js b/packages/edit-site/src/components/global-styles/screen-typography-element.js index 46b53a3a7b3d3..4f7abe955803e 100644 --- a/packages/edit-site/src/components/global-styles/screen-typography-element.js +++ b/packages/edit-site/src/components/global-styles/screen-typography-element.js @@ -18,6 +18,10 @@ const elements = { description: __( 'Manage the fonts and typography used on the links.' ), title: __( 'Links' ), }, + button: { + description: __( 'Manage the fonts and typography used on buttons.' ), + title: __( 'Buttons' ), + }, }; function ScreenTypographyElement( { name, element } ) { diff --git a/packages/edit-site/src/components/global-styles/screen-typography.js b/packages/edit-site/src/components/global-styles/screen-typography.js index 32e93cd6af37e..08fda42065f0d 100644 --- a/packages/edit-site/src/components/global-styles/screen-typography.js +++ b/packages/edit-site/src/components/global-styles/screen-typography.js @@ -95,6 +95,12 @@ function ScreenTypography( { name } ) { element="link" label={ __( 'Links' ) } /> + diff --git a/packages/edit-site/src/components/global-styles/ui.js b/packages/edit-site/src/components/global-styles/ui.js index 793b0939d9014..837a3fedb85bc 100644 --- a/packages/edit-site/src/components/global-styles/ui.js +++ b/packages/edit-site/src/components/global-styles/ui.js @@ -20,6 +20,7 @@ import ScreenColorPalette from './screen-color-palette'; import ScreenBackgroundColor from './screen-background-color'; import ScreenTextColor from './screen-text-color'; import ScreenLinkColor from './screen-link-color'; +import ScreenButtonColor from './screen-button-color'; import ScreenLayout from './screen-layout'; import ScreenStyleVariations from './screen-style-variations'; @@ -58,6 +59,12 @@ function ContextScreens( { name } ) { + + + + @@ -82,6 +89,10 @@ function ContextScreens( { name } ) { + + + + From a714b0e310fe17fe635e0e1acaf9e956e960a0c6 Mon Sep 17 00:00:00 2001 From: Andrei Draganescu Date: Thu, 16 Jun 2022 12:33:51 +0300 Subject: [PATCH 02/10] prettier fixes --- .../edit-site/src/components/global-styles/screen-colors.js | 1 - packages/edit-site/src/components/global-styles/ui.js | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/edit-site/src/components/global-styles/screen-colors.js b/packages/edit-site/src/components/global-styles/screen-colors.js index 25b360600c5fa..9b33828013ffd 100644 --- a/packages/edit-site/src/components/global-styles/screen-colors.js +++ b/packages/edit-site/src/components/global-styles/screen-colors.js @@ -109,7 +109,6 @@ function ButtonColorItem( { name, parentMenu } ) { ); } - function ScreenColors( { name } ) { const parentMenu = name === undefined ? '' : '/blocks/' + name; diff --git a/packages/edit-site/src/components/global-styles/ui.js b/packages/edit-site/src/components/global-styles/ui.js index 837a3fedb85bc..750985ad1f94f 100644 --- a/packages/edit-site/src/components/global-styles/ui.js +++ b/packages/edit-site/src/components/global-styles/ui.js @@ -89,7 +89,9 @@ function ContextScreens( { name } ) { - + From a0afa3dc09ef10b424d44b1efdaa838d75746bcd Mon Sep 17 00:00:00 2001 From: Andrei Draganescu Date: Thu, 16 Jun 2022 18:07:07 +0300 Subject: [PATCH 03/10] attempt to bring background color for button styling --- packages/blocks/src/api/constants.js | 8 ++++ .../src/components/global-styles/hooks.js | 1 + .../global-styles/screen-button-color.js | 43 ++++++++++++++----- .../src/components/global-styles/utils.js | 3 ++ 4 files changed, 45 insertions(+), 10 deletions(-) diff --git a/packages/blocks/src/api/constants.js b/packages/blocks/src/api/constants.js index df0f05fdf5fe9..fbc02bfdef2cc 100644 --- a/packages/blocks/src/api/constants.js +++ b/packages/blocks/src/api/constants.js @@ -114,6 +114,14 @@ export const __EXPERIMENTAL_STYLE_PROPERTY = { value: [ 'elements', 'link', 'color', 'text' ], support: [ 'color', 'link' ], }, + buttonColor: { + value: [ 'elements', 'button', 'color', 'text' ], + support: [ 'color', 'button' ], + }, + buttonBackground: { + value: [ 'elements', 'button', 'color', 'background' ], + support: [ 'color', 'button' ], + }, fontFamily: { value: [ 'typography', 'fontFamily' ], support: [ 'typography', '__experimentalFontFamily' ], diff --git a/packages/edit-site/src/components/global-styles/hooks.js b/packages/edit-site/src/components/global-styles/hooks.js index 431a2471a3509..da7a9ccf6de23 100644 --- a/packages/edit-site/src/components/global-styles/hooks.js +++ b/packages/edit-site/src/components/global-styles/hooks.js @@ -159,6 +159,7 @@ const ROOT_BLOCK_SUPPORTS = [ 'backgroundColor', 'color', 'linkColor', + 'buttonColor', 'fontFamily', 'fontSize', 'fontStyle', diff --git a/packages/edit-site/src/components/global-styles/screen-button-color.js b/packages/edit-site/src/components/global-styles/screen-button-color.js index d5c3c508b89d1..972e36ed9e5e6 100644 --- a/packages/edit-site/src/components/global-styles/screen-button-color.js +++ b/packages/edit-site/src/components/global-styles/screen-button-color.js @@ -22,23 +22,30 @@ function ScreenButtonColor( { name } ) { const colorsPerOrigin = useColorsPerOrigin( name ); - const [ isLinkEnabled ] = useSetting( 'color.link', name ); - const hasButtonColor = - supports.includes( 'linkColor' ) && - isLinkEnabled && + supports.includes( 'buttonColor' ) && ( solids.length > 0 || areCustomSolidsEnabled ); // TODO - use the right check - const [ buttonColor, setButtonColor ] = useStyle( + const [ buttonTextColor, setButtonTextColor ] = useStyle( 'elements.button.color.text', name ); - const [ userButtonColor ] = useStyle( + const [ userButtonTextColor ] = useStyle( 'elements.button.color.text', name, 'user' ); + const [ buttonBgColor, setButtonBgColor ] = useStyle( + 'elements.button.backgound.color', + name + ); + const [ userButtonBgColor ] = useStyle( + 'elements.button.backgound.color', + name, + 'user' + ); + if ( ! hasButtonColor ) { return null; } @@ -48,9 +55,25 @@ function ScreenButtonColor( { name } ) { + +

{ __( 'Set text color' ) }

+ + +

{ __( 'Set background color' ) }

); diff --git a/packages/edit-site/src/components/global-styles/utils.js b/packages/edit-site/src/components/global-styles/utils.js index 50c412fc06cd5..b6323f44f47bd 100644 --- a/packages/edit-site/src/components/global-styles/utils.js +++ b/packages/edit-site/src/components/global-styles/utils.js @@ -11,6 +11,7 @@ export const ROOT_BLOCK_SUPPORTS = [ 'backgroundColor', 'color', 'linkColor', + 'buttonColor', 'fontFamily', 'fontSize', 'fontStyle', @@ -75,6 +76,8 @@ const STYLE_PATH_TO_CSS_VAR_INFIX = { 'color.background': 'color', 'color.text': 'color', 'elements.link.color.text': 'color', + 'elements.button.color.text': 'color', + 'elements.button.color.background': 'background', 'color.gradient': 'gradient', 'typography.fontSize': 'font-size', 'typography.fontFamily': 'font-family', From f1f08421f10f2141edbc23d40345ef3395b1eb17 Mon Sep 17 00:00:00 2001 From: Andrei Draganescu Date: Fri, 17 Jun 2022 17:42:09 +0300 Subject: [PATCH 04/10] set background color for button element --- packages/blocks/src/api/constants.js | 2 +- .../src/components/global-styles/screen-button-color.js | 9 +++++---- packages/edit-site/src/components/global-styles/utils.js | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/blocks/src/api/constants.js b/packages/blocks/src/api/constants.js index fbc02bfdef2cc..5e1e556f96cf3 100644 --- a/packages/blocks/src/api/constants.js +++ b/packages/blocks/src/api/constants.js @@ -118,7 +118,7 @@ export const __EXPERIMENTAL_STYLE_PROPERTY = { value: [ 'elements', 'button', 'color', 'text' ], support: [ 'color', 'button' ], }, - buttonBackground: { + buttonBackgroundColor: { value: [ 'elements', 'button', 'color', 'background' ], support: [ 'color', 'button' ], }, diff --git a/packages/edit-site/src/components/global-styles/screen-button-color.js b/packages/edit-site/src/components/global-styles/screen-button-color.js index 972e36ed9e5e6..0af4c339b1dc2 100644 --- a/packages/edit-site/src/components/global-styles/screen-button-color.js +++ b/packages/edit-site/src/components/global-styles/screen-button-color.js @@ -8,6 +8,7 @@ import { __experimentalColorGradientControl as ColorGradientControl } from '@wor * Internal dependencies */ import ScreenHeader from './header'; +import Subtitle from './subtitle'; import { getSupportedGlobalStylesPanels, useSetting, @@ -37,11 +38,11 @@ function ScreenButtonColor( { name } ) { ); const [ buttonBgColor, setButtonBgColor ] = useStyle( - 'elements.button.backgound.color', + 'elements.button.color.background', name ); const [ userButtonBgColor ] = useStyle( - 'elements.button.backgound.color', + 'elements.button.color.background', name, 'user' ); @@ -59,7 +60,7 @@ function ScreenButtonColor( { name } ) { ) } /> -

{ __( 'Set text color' ) }

+ { __( 'Set text color' ) } -

{ __( 'Set background color' ) }

+ { __( 'Set background color' ) } Date: Mon, 20 Jun 2022 14:36:50 +0300 Subject: [PATCH 05/10] enables multiple color stack in the color indicator --- .../src/components/global-styles/screen-colors.js | 7 ++++++- .../src/components/global-styles/style.scss | 13 +++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/edit-site/src/components/global-styles/screen-colors.js b/packages/edit-site/src/components/global-styles/screen-colors.js index 9b33828013ffd..c779fb2b7d165 100644 --- a/packages/edit-site/src/components/global-styles/screen-colors.js +++ b/packages/edit-site/src/components/global-styles/screen-colors.js @@ -92,6 +92,7 @@ function ButtonColorItem( { name, parentMenu } ) { const supports = getSupportedGlobalStylesPanels( name ); const hasSupport = supports.includes( 'linkColor' ); // TODO - use a real support const [ color ] = useStyle( 'elements.button.color.text', name ); + const [ bgColor ] = useStyle( 'elements.button.color.background', name ); if ( ! hasSupport ) { return null; @@ -100,8 +101,12 @@ function ButtonColorItem( { name, parentMenu } ) { return ( - + + { __( 'Buttons' ) } diff --git a/packages/edit-site/src/components/global-styles/style.scss b/packages/edit-site/src/components/global-styles/style.scss index 122b753dffa17..62facddd21f72 100644 --- a/packages/edit-site/src/components/global-styles/style.scss +++ b/packages/edit-site/src/components/global-styles/style.scss @@ -102,3 +102,16 @@ // Match the height of the rest of the icons (24px). height: $grid-unit * 3; } + +.edit-site-global-styles__color-indicator-wrapper > .component-color-indicator:first-child { + // the point is to be on top of other colors + z-index: 3; + position: relative; + right: 0; +} + +.edit-site-global-styles__color-indicator-wrapper > .component-color-indicator, +.edit-site-global-styles__color-indicator-wrapper.has-multiple-colors + .components-flex-item { + position: relative; + right: 20px; +} From 451405e3a2801ac08deb8ea1d6d58ffc6590b2c0 Mon Sep 17 00:00:00 2001 From: Andrei Draganescu Date: Mon, 20 Jun 2022 15:27:13 +0300 Subject: [PATCH 06/10] use zstack for multiple color display, cleanup the UI for multiple color selection --- .../global-styles/screen-button-color.js | 11 ++++++--- .../components/global-styles/screen-colors.js | 16 +++++++------ .../src/components/global-styles/style.scss | 24 +++++++++---------- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/packages/edit-site/src/components/global-styles/screen-button-color.js b/packages/edit-site/src/components/global-styles/screen-button-color.js index 0af4c339b1dc2..4468855171db0 100644 --- a/packages/edit-site/src/components/global-styles/screen-button-color.js +++ b/packages/edit-site/src/components/global-styles/screen-button-color.js @@ -8,7 +8,6 @@ import { __experimentalColorGradientControl as ColorGradientControl } from '@wor * Internal dependencies */ import ScreenHeader from './header'; -import Subtitle from './subtitle'; import { getSupportedGlobalStylesPanels, useSetting, @@ -60,7 +59,10 @@ function ScreenButtonColor( { name } ) { ) } /> - { __( 'Set text color' ) } +

+ { __( 'Text color' ) } +

+ - { __( 'Set background color' ) } +

+ { __( 'Background color' ) } +

+ - - - - + + + + + + + + { __( 'Buttons' ) }
diff --git a/packages/edit-site/src/components/global-styles/style.scss b/packages/edit-site/src/components/global-styles/style.scss index 62facddd21f72..1b58a0ec05adb 100644 --- a/packages/edit-site/src/components/global-styles/style.scss +++ b/packages/edit-site/src/components/global-styles/style.scss @@ -57,6 +57,16 @@ font-size: 11px !important; } +.edit-site-global-styles-section-title { + font-size: calc(1.95 * 8px); + color: rgb(30, 30, 30); + font-weight: 600; + line-height: 1.2; + padding: $grid-unit-20; + padding-bottom: 0; + margin: 0; +} + .edit-site-screen-color-palette-toggle.edit-site-screen-color-palette-toggle { margin-right: $grid-unit-20; margin-left: $grid-unit-20; @@ -68,6 +78,7 @@ .edit-site-screen-text-color__control, .edit-site-screen-link-color__control, +.edit-site-screen-button-color__control, .edit-site-screen-background-color__control { padding: $grid-unit-20; } @@ -102,16 +113,3 @@ // Match the height of the rest of the icons (24px). height: $grid-unit * 3; } - -.edit-site-global-styles__color-indicator-wrapper > .component-color-indicator:first-child { - // the point is to be on top of other colors - z-index: 3; - position: relative; - right: 0; -} - -.edit-site-global-styles__color-indicator-wrapper > .component-color-indicator, -.edit-site-global-styles__color-indicator-wrapper.has-multiple-colors + .components-flex-item { - position: relative; - right: 20px; -} From dd008e3fb35db382316fcca03bb20a69fe7bb011 Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Mon, 20 Jun 2022 17:53:33 +0100 Subject: [PATCH 07/10] Elements: Fix button element selectors --- lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php | 5 ++++- .../class-wp-theme-json-resolver-gutenberg.php | 4 ++-- lib/load.php | 1 + packages/block-library/src/button/block.json | 8 -------- packages/block-library/src/file/block.json | 11 ++++++++++- packages/block-library/src/file/style.scss | 4 ---- packages/block-library/src/search/style.scss | 2 -- .../global-styles/use-global-styles-output.js | 9 ++++++++- 8 files changed, 25 insertions(+), 19 deletions(-) diff --git a/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php b/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php index 55716b3cf58fa..968b7c7d43e7b 100644 --- a/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php +++ b/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php @@ -91,7 +91,10 @@ protected static function get_blocks_metadata() { break; } - $element_selector[] = $selector . ' ' . $el_selector; + $el_selectors = explode( ',', $el_selector ); + foreach( $el_selectors as $el_selector_item ) { + $element_selector[] = $selector . ' ' . $el_selector_item; + } } static::$blocks_metadata[ $block_name ]['elements'][ $el_name ] = implode( ',', $element_selector ); } diff --git a/lib/experimental/class-wp-theme-json-resolver-gutenberg.php b/lib/experimental/class-wp-theme-json-resolver-gutenberg.php index 6cb5ce994fce4..6c4e5b534a4f7 100644 --- a/lib/experimental/class-wp-theme-json-resolver-gutenberg.php +++ b/lib/experimental/class-wp-theme-json-resolver-gutenberg.php @@ -15,7 +15,7 @@ * * @access private */ -class WP_Theme_JSON_Resolver_Gutenberg extends WP_Theme_JSON_Resolver_6_0 { +class WP_Theme_JSON_Resolver_Gutenberg extends WP_Theme_JSON_Resolver_6_1 { /** * Returns the theme's data. * @@ -115,7 +115,7 @@ public static function get_block_data() { // Core here means it's the lower level part of the styles chain. // It can be a core or a third-party block. - return new WP_Theme_JSON( $config, 'core' ); + return new WP_Theme_JSON_Gutenberg( $config, 'core' ); } /** diff --git a/lib/load.php b/lib/load.php index f7cad4597b692..d76ec3181b7cf 100644 --- a/lib/load.php +++ b/lib/load.php @@ -127,6 +127,7 @@ function gutenberg_is_experiment_enabled( $name ) { require __DIR__ . '/compat/wordpress-6.1/persisted-preferences.php'; require __DIR__ . '/compat/wordpress-6.1/get-global-styles-and-settings.php'; require __DIR__ . '/compat/wordpress-6.1/class-wp-theme-json-6-1.php'; +require __DIR__ . '/compat/wordpress-6.1/class-wp-theme-json-resolver-6-1.php'; require __DIR__ . '/compat/wordpress-6.1/block-template-utils.php'; require __DIR__ . '/compat/wordpress-6.1/wp-theme-get-post-templates.php'; require __DIR__ . '/compat/wordpress-6.1/script-loader.php'; diff --git a/packages/block-library/src/button/block.json b/packages/block-library/src/button/block.json index 20c20771b4b56..35887f057ca81 100644 --- a/packages/block-library/src/button/block.json +++ b/packages/block-library/src/button/block.json @@ -95,14 +95,6 @@ "//": "100% causes an oval, but any explicit but really high value retains the pill shape.", "radius": "9999px" }, - "color": { - "text": "#fff", - "background": "#32373c" - }, - "typography": { - "fontSize": "1.125em", - "textDecoration": "none" - }, "spacing": { "padding": { "//": "The extra 2px are added to size solids the same as the outline versions.", diff --git a/packages/block-library/src/file/block.json b/packages/block-library/src/file/block.json index 8e90825a64dfd..674027747f960 100644 --- a/packages/block-library/src/file/block.json +++ b/packages/block-library/src/file/block.json @@ -56,7 +56,16 @@ }, "supports": { "anchor": true, - "align": true + "align": true, + "__experimentalStyle": { + "elements": { + "button": { + "typography": { + "fontSize": "0.8em" + } + } + } + } }, "viewScript": "file:./view.min.js", "editorStyle": "wp-block-file-editor", diff --git a/packages/block-library/src/file/style.scss b/packages/block-library/src/file/style.scss index bba0f5e165ce7..2362f0529eb09 100644 --- a/packages/block-library/src/file/style.scss +++ b/packages/block-library/src/file/style.scss @@ -21,14 +21,10 @@ //This needs a low specificity so it won't override the rules from the button element if defined in theme.json. .wp-block-file__button { - background: #32373c; border-radius: 2em; - color: $white; - font-size: 0.8em; padding: 0.5em 1em; &:is(a) { - text-decoration: none; &:hover, &:visited, diff --git a/packages/block-library/src/search/style.scss b/packages/block-library/src/search/style.scss index d6b54065e41d9..426e34662cde9 100644 --- a/packages/block-library/src/search/style.scss +++ b/packages/block-library/src/search/style.scss @@ -1,8 +1,6 @@ .wp-block-search__button { - background: #f7f7f7; border: 1px solid #ccc; padding: 0.375em 0.625em; - color: #32373c; margin-left: 0.625em; word-break: normal; font-size: inherit; diff --git a/packages/edit-site/src/components/global-styles/use-global-styles-output.js b/packages/edit-site/src/components/global-styles/use-global-styles-output.js index 0be47a7000b53..4f6265a56a920 100644 --- a/packages/edit-site/src/components/global-styles/use-global-styles-output.js +++ b/packages/edit-site/src/components/global-styles/use-global-styles-output.js @@ -283,7 +283,14 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => { styles: value, selector: blockSelectors[ blockName ].selector .split( ',' ) - .map( ( sel ) => sel + ' ' + ELEMENTS[ elementName ] ) + .map( ( sel ) => { + const elementSelectors = + ELEMENTS[ elementName ].split( ',' ); + return elementSelectors.map( + ( elementSelector ) => + sel + ' ' + elementSelector + ); + } ) .join( ',' ), } ); } From 04a5b42903b85173c1075eebebdc0684695d57ce Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Tue, 21 Jun 2022 12:32:49 +0100 Subject: [PATCH 08/10] add missing files --- .../class-wp-theme-json-resolver-6-1.php | 35 +++ lib/compat/wordpress-6.1/theme.json | 257 ++++++++++++++++++ 2 files changed, 292 insertions(+) create mode 100644 lib/compat/wordpress-6.1/class-wp-theme-json-resolver-6-1.php create mode 100644 lib/compat/wordpress-6.1/theme.json diff --git a/lib/compat/wordpress-6.1/class-wp-theme-json-resolver-6-1.php b/lib/compat/wordpress-6.1/class-wp-theme-json-resolver-6-1.php new file mode 100644 index 0000000000000..58abcc27c04ec --- /dev/null +++ b/lib/compat/wordpress-6.1/class-wp-theme-json-resolver-6-1.php @@ -0,0 +1,35 @@ + Date: Wed, 22 Jun 2022 11:51:09 +0100 Subject: [PATCH 09/10] lint fix --- lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php b/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php index 968b7c7d43e7b..2f9ff0aac2ebc 100644 --- a/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php +++ b/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php @@ -92,7 +92,7 @@ protected static function get_blocks_metadata() { } $el_selectors = explode( ',', $el_selector ); - foreach( $el_selectors as $el_selector_item ) { + foreach ( $el_selectors as $el_selector_item ) { $element_selector[] = $selector . ' ' . $el_selector_item; } } From 2615d79432f4885101dd474660b8195f5a9bb8df Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Wed, 22 Jun 2022 12:03:34 +0100 Subject: [PATCH 10/10] add comment --- lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php b/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php index 2f9ff0aac2ebc..b02fffdbbbd0d 100644 --- a/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php +++ b/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php @@ -91,6 +91,8 @@ protected static function get_blocks_metadata() { break; } + // This converts selectors like '.wp-element-button, .wp-block-button__link' + // to an array, so that the block selector is added to both parts of the selector. $el_selectors = explode( ',', $el_selector ); foreach ( $el_selectors as $el_selector_item ) { $element_selector[] = $selector . ' ' . $el_selector_item;