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

Do not register global styles CPT in WordPress 5.9 #37282

Merged
merged 2 commits into from
Dec 10, 2021

Conversation

oandregal
Copy link
Member

Follow-up to #36978

This PR makes sure we only register the global styles Custom Post Type in environments other than WordPress 5.9. It moves some more code to lib/compat/wordpress-5.9.

How to test

  • Use WordPress 5.8.
  • Activate TwentyTwentyTwo or any other theme that uses the site editor.
  • Load the site editor, go to the global styles sidebar and do some changes (change color background, font size, etc.)
  • Save and publish.
  • Go to the front-end and verify that the changes are reflected.

The expected result is that everything worked as expected and there were no errors due to the CPT not being registered.

@oandregal oandregal self-assigned this Dec 10, 2021
@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 Dec 10, 2021
@oandregal oandregal requested review from a team, Mamaduka and youknowriad and removed request for a team December 10, 2021 13:02
*
* This has been ported to src/wp-includes/post.php
*/
function register_global_styles_custom_post_type() {
Copy link
Member Author

Choose a reason for hiding this comment

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

The code of this function is the same, just indented.

*
* @return void
*/
function maybe_register_global_styles_custom_post_type() {
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 was gutenberg_experimental_is_site_editor_available which I've removed and substituted by direct calls to wp_is_block_theme in the plugin.

* @return void
*/
function maybe_register_global_styles_custom_post_type() {
if ( wp_is_block_theme() ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If I'm not wrong on Core we don't care about this, we always register the CPT. We might do the same here.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's right, we don't.

function register_global_styles_custom_post_type() {
$args = array(
'label' => __( 'Global Styles', 'gutenberg' ),
'description' => 'Global styles to include in themes.',
Copy link
Member Author

Choose a reason for hiding this comment

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

In a second commit, I actually updated this text to be in line with core's naming.

@oandregal oandregal merged commit 96f899f into trunk Dec 10, 2021
@oandregal oandregal deleted the update/do-not-register-gs-cpt-on-wp-59 branch December 10, 2021 17:16
@github-actions github-actions bot added this to the Gutenberg 12.2 milestone Dec 10, 2021
@youknowriad youknowriad added the Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Dec 10, 2021
@noisysocks noisysocks removed the Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Dec 13, 2021
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 [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