Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update hook's names from global_styles_* to theme_json_* #44159

Merged
merged 1 commit into from
Sep 14, 2022

Conversation

oandregal
Copy link
Member

@oandregal oandregal commented Sep 14, 2022

What?

In #44015 we've added a few hooks to filter the theme.json data at the different layer levels. This PR proposes that we rename them:

  • global_styles_default => theme_json_default
  • global_styles_blocks => theme_json_blocks
  • global_styles_theme => theme_json_theme
  • global_styles_user => theme_json_user

Why?

Because we're not filtering "global styles" but a specific part of it: the theme.json data it takes as input. The new names make this clearer. We also leave the global_styles_ prefix free for the future, in case we want to offer other kind of filters.

How?

  • Renames the filters.
  • Updates the docs.

Testing Instructions

Use the filters to modify some of the data. For example, this is how the theme data can be modified:

<?php

function filter_theme_json_theme( $theme_json ){
        $new_data = array(
                'version'  => 2,
                'settings' => array(
                        'color' => array(
                                'text'  => false, /* disable text color UI */
                                'palette'    => array( /* New palette */
                                        array(
                                                'slug'  => 'foreground',
                                                'color' => 'red',
                                                'name'  => 'Foreground',
                                        ),
                                ),
                        ),
                ),
        );
        return $theme_json->update_with( $new_data );
}
add_filter( 'theme_json_theme', 'filter_theme_json_theme' );

@oandregal oandregal self-assigned this Sep 14, 2022
@oandregal oandregal added [Type] Code Quality Issues or PRs that relate to code quality Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Sep 14, 2022
@oandregal oandregal changed the title Update/hook name from global styles to theme json Update hook's name from global_styles_* to theme_json_* Sep 14, 2022
@oandregal oandregal changed the title Update hook's name from global_styles_* to theme_json_* Update hook's names from global_styles_* to theme_json_* Sep 14, 2022
@oandregal oandregal force-pushed the update/hook-name-from-global-styles-to-theme-json branch from d1c5066 to 1ab90c0 Compare September 14, 2022 15:24
Copy link
Member

@jorgefilipecosta jorgefilipecosta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@@ -1,11 +1,11 @@
# Global Styles Filters

WordPress 6.1 has introduced some server-side filters to hook into the data provided to Global Styles & Settings:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only updates the names of the filters. I'm undecided as to whether we should rename the "Global Styles Filters" page to "Theme.json Filters". Because it's published to the block editor handbook already, renaming it requires asking someone from the meta team to remove the old one. As it is also works fine if we want to add new filters later, so I lean towards maintaining what we have.

@oandregal
Copy link
Member Author

oandregal commented Sep 14, 2022

These changes are being backported as part of WordPress/wordpress-develop#3247

@oandregal oandregal merged commit 12bda86 into trunk Sep 14, 2022
@oandregal oandregal deleted the update/hook-name-from-global-styles-to-theme-json branch September 14, 2022 19:27
@github-actions github-actions bot added this to the Gutenberg 14.2 milestone Sep 14, 2022
@bph bph added the Needs Dev Note Requires a developer note for a major WordPress release cycle label Sep 14, 2022
@bph
Copy link
Contributor

bph commented Sep 14, 2022

@c4rl0sbr4v0 Shall this be moved to milestone 14.1, so you can cherry-pick for the 14.1 release tomorrow?

@bph bph added the Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) label Sep 14, 2022
@cbravobernal
Copy link
Contributor

Cherrypicked for 14.1

@ockham ockham added the Backport to WP 6.6 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Sep 19, 2022
@ockham
Copy link
Contributor

ockham commented Sep 19, 2022

I just cherry-picked this PR to the wp/6.1 branch to get it included in the next release: 6d76c1b

@ockham ockham removed the Backport to WP 6.6 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Sep 19, 2022
pento pushed a commit to WordPress/wordpress-develop that referenced this pull request Sep 20, 2022
…6.1.

This changeset ports the work done in Gutenberg (released in 14.1) to add hooks to filter the `theme.json` data. Specifically, it adds the following filters: `theme_json_default`, `theme_json_blocks`, `theme_json_theme`, and `theme_json_user`.

For more details, see the following Gutenberg pull requests:

- [WordPress/gutenberg#44015 gutenberg#44015]: Make global styles data filterable
- [WordPress/gutenberg#44109 gutenberg#44109]: Prepare `WP_Theme_JSON_Data` class for backporting
- [WordPress/gutenberg#44159 gutenberg#44159]: Update hook's names from `global_styles_*` to `theme_json_*`

Props oandregal, czapla, gziolo, bernhard-reiter.
See #56467.


git-svn-id: https://develop.svn.wordpress.org/trunk@54251 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Sep 20, 2022
…6.1.

This changeset ports the work done in Gutenberg (released in 14.1) to add hooks to filter the `theme.json` data. Specifically, it adds the following filters: `theme_json_default`, `theme_json_blocks`, `theme_json_theme`, and `theme_json_user`.

For more details, see the following Gutenberg pull requests:

- [WordPress/gutenberg#44015 gutenberg#44015]: Make global styles data filterable
- [WordPress/gutenberg#44109 gutenberg#44109]: Prepare `WP_Theme_JSON_Data` class for backporting
- [WordPress/gutenberg#44159 gutenberg#44159]: Update hook's names from `global_styles_*` to `theme_json_*`

Props oandregal, czapla, gziolo, bernhard-reiter.
See #56467.

Built from https://develop.svn.wordpress.org/trunk@54251


git-svn-id: http://core.svn.wordpress.org/trunk@53810 1a063a9b-81f0-0310-95a4-ce76da25c4cd
github-actions bot pushed a commit to platformsh/wordpress-performance that referenced this pull request Sep 20, 2022
…6.1.

This changeset ports the work done in Gutenberg (released in 14.1) to add hooks to filter the `theme.json` data. Specifically, it adds the following filters: `theme_json_default`, `theme_json_blocks`, `theme_json_theme`, and `theme_json_user`.

For more details, see the following Gutenberg pull requests:

- [WordPress/gutenberg#44015 gutenberg#44015]: Make global styles data filterable
- [WordPress/gutenberg#44109 gutenberg#44109]: Prepare `WP_Theme_JSON_Data` class for backporting
- [WordPress/gutenberg#44159 gutenberg#44159]: Update hook's names from `global_styles_*` to `theme_json_*`

Props oandregal, czapla, gziolo, bernhard-reiter.
See #56467.

Built from https://develop.svn.wordpress.org/trunk@54251


git-svn-id: https://core.svn.wordpress.org/trunk@53810 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@bph bph mentioned this pull request Oct 3, 2022
89 tasks
@aaronrobertshaw aaronrobertshaw removed the Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) label Oct 12, 2022
ootwch pushed a commit to ootwch/wordpress-develop that referenced this pull request Nov 4, 2022
…6.1.

This changeset ports the work done in Gutenberg (released in 14.1) to add hooks to filter the `theme.json` data. Specifically, it adds the following filters: `theme_json_default`, `theme_json_blocks`, `theme_json_theme`, and `theme_json_user`.

For more details, see the following Gutenberg pull requests:

- [WordPress/gutenberg#44015 gutenberg#44015]: Make global styles data filterable
- [WordPress/gutenberg#44109 gutenberg#44109]: Prepare `WP_Theme_JSON_Data` class for backporting
- [WordPress/gutenberg#44159 gutenberg#44159]: Update hook's names from `global_styles_*` to `theme_json_*`

Props oandregal, czapla, gziolo, bernhard-reiter.
See #56467.


git-svn-id: https://develop.svn.wordpress.org/trunk@54251 602fd350-edb4-49c9-b593-d223f7449a82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json Needs Dev Note Requires a developer note for a major WordPress release cycle [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants