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

Add fallback handling for plugins or themes using the Customizer #35877

Conversation

Clorith
Copy link
Member

@Clorith Clorith commented Oct 22, 2021

Description

This change introduces a new function, gutenberg_site_requires_customizer(), which looks up if any plugins, or theme features, have added support for the Customizer.

It then utilizes that check before letting Full Site Editing filter away the Customizer access points. It is worth noting that the Customizer is not deactivated even without this patch, but it is important to maintain a canonical entry-point for the user when any plugin, or theme feature, relies on it.

This would fix #35874

How has this been tested?

  1. Activate the Twenty Twenty One theme
  2. Install the WooCommerce plugin (no setup required, it just needs to be active)
  3. You should now see the Appearance > Customizer menu items
  4. Switch to the TT1-Blocks theme
  5. The Customizer menu is now missing, but a custom "Customize WooCommerce" link is added instead (this is WooCommerce working around the flaw as described in Ensure the Customizer is available for plugins or theme options when using a FSE theme #35874)
  6. Apply this patch
  7. The Appearance > Customizer link should now have returned
  8. De-activate WooCommerce
  9. The Appearance > Customizer link should disapear as no more plugins or theme features rely on it.

Types of changes

Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Oct 22, 2021
@github-actions
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @Clorith! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@carolinan
Copy link
Contributor

carolinan commented Oct 22, 2021

I am still curious why the removal of the menu item simply can't be reverted.

@Clorith
Copy link
Member Author

Clorith commented Oct 22, 2021

Adding a quick note that my patch here implements a new function, gutenberg_site_requires_customizer(), although we could just as easily just add in an if statement for has_action() into the two locations that rely on it, this was done in case it needed to be more flexible (for example if strange edge cases needed to be accounted for as well, making it easier to add them in one location right away).

As for the discussion about whether something should be reverted or not, I'll leave that for the product team to tackle, my main concern with this PR was to ensure backwards compatibility and nothing more :)

@noisysocks
Copy link
Member

Thanks for working on this!

I think we should strive to implement this PR as the solution to #35874. If possible I'd prefer to not always show a link to the Customizer as I feel it will be confusing to users who are brand new to WordPress to have both an Appearance → Editor and Appearance → Customize.

We may end up having to always show a link to the Customizer. For example, if we don't end up with a solution for #29126 in time for WP 5.9 then we don't really have a choice. We can make this decision in the 5.9 beta period if need be.

@noisysocks noisysocks requested a review from Mamaduka October 29, 2021 05:30
Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

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

Hi, @Clorith, can you rebase this branch on top of the current trunk and I think we're good to merge once all checks are green ✅

@noisysocks
Copy link
Member

Sorry @Clorith, looks like there are more conflicts. Could you please rebase again? Feel free to merge once resolved.

@Mamaduka Mamaduka merged commit 537bce7 into WordPress:trunk Nov 2, 2021
@github-actions github-actions bot added this to the Gutenberg 11.9 milestone Nov 2, 2021
@Clorith Clorith deleted the enhancement/fallback-handling-customizer-entrypoints branch November 10, 2021 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ensure the Customizer is available for plugins or theme options when using a FSE theme
4 participants