Skip to content

Custom CSS: Fix custom css feature selector#11000

Open
aaronrobertshaw wants to merge 1 commit intoWordPress:trunkfrom
aaronrobertshaw:fix/custom-css-feature-selector
Open

Custom CSS: Fix custom css feature selector#11000
aaronrobertshaw wants to merge 1 commit intoWordPress:trunkfrom
aaronrobertshaw:fix/custom-css-feature-selector

Conversation

@aaronrobertshaw
Copy link
Copy Markdown

This backports the PHP changes from Gutenberg PR WordPress/gutenberg#75799 to support the css feature selector for block custom CSS in Global Styles.

Changes:

  1. get_styles_for_block() — When processing custom CSS rules, use the block's css feature selector if defined, falling back to the root selector.
  2. get_feature_declarations_for_node() — Skip the css key when iterating over feature selectors to prevent it being consumed as a regular style property.
  3. Three new tests covering the string selector, object-form selector, and fallback behavior.

Testing Instructions

This is an internal API change. No blocks currently define a selectors.css property, so there is no user-facing change. The new unit tests verify the behavior:

All three tests should pass:

  • test_get_styles_for_block_custom_css_uses_css_feature_selector — Custom CSS uses the css feature selector when defined as a string.
  • test_get_styles_for_block_custom_css_falls_back_to_root_selector — Custom CSS falls back to the root selector when no css feature selector is defined.
  • test_get_styles_for_block_custom_css_uses_css_feature_selector_object_form — Custom CSS uses the css feature selector when defined as an object with a root subkey.

Trac ticket: https://core.trac.wordpress.org/ticket/64695

@github-actions
Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props aaronrobertshaw.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant