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

Prepare WP_Theme_JSON_Data class for backporting #44109

Merged
merged 6 commits into from
Sep 13, 2022

Conversation

oandregal
Copy link
Member

What

This PR follows-up #44015 addressing some post-merge feedback for improving code quality and make it easier to backport.

How

  • Class renamed from WP_Theme_JSON_Data to WP_Theme_JSON_Data_Gutenberg.
  • Document the new filters inline.
  • Create specific temp variables for the filters (input/output) and don't overload the existing.

How to test

Make sure it still works as before.

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

<?php

function filter_global_styles_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( 'global_styles_theme', 'filter_global_styles_theme' );

@oandregal oandregal self-assigned this Sep 13, 2022
@oandregal oandregal added the [Type] Code Quality Issues or PRs that relate to code quality label Sep 13, 2022
@gziolo
Copy link
Member

gziolo commented Sep 13, 2022

Thank you for a quick follow-up 💯

@oandregal oandregal merged commit b46a119 into trunk Sep 13, 2022
@oandregal oandregal deleted the update/theme-json-data-and-filters branch September 13, 2022 09:51
@github-actions github-actions bot added this to the Gutenberg 14.1 milestone Sep 13, 2022
@oandregal
Copy link
Member Author

This is being backported as part of WordPress/wordpress-develop#3247

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
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
[Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants