-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Site Logo: Delete sitelogo option rather than syncing it when setting theme mod #26895
Conversation
Size Change: 0 B Total Size: 1.19 MB ℹ️ View Unchanged
|
I'll restate in other words to make sure I share the understanding:
One change (related to the fact that this fixes #25173) is that if you set a Will the block continue to work with gutenberg/packages/block-library/src/site-logo/edit.js Lines 233 to 251 in 4fa1856
|
Ah, good point, I hadn't thought about that 🤔 It seems like this would no longer work with this change. Maybe we can change the client stuff to read from the |
Seems like there isn't one yet. We can probably register it one-off style to Gutenberg (and work on having it integrated into Core). Means we'd need to inflate the scope of this PR though. |
Aside: This PR, as it is now, would fix the custom logo issue sufficiently in a context where the Site Editor isn't enabled (and the Site Logo block is thus unavailable), right @sirreal? 😬 |
I know it's not ideal as we're relying on the implementation of Reading through the logic in this PR, it seems like it might fix the problem by preventing the logo setting from persisting between themes and/or syncing with the |
I've just noticed that while this PR fixes the issue of setting a custom logo and later removing it (both through the customizer), it doesn't actually fix the case of setting a logo through the Site Logo block, and removing it through the customizer. It appears that we really need to tap into |
Yeah, that would be an option. I'm a bit wary of it though since it's very low-level. If we filter
Yep, I think that's accurate.
Yeah, that's a good point. There's also the (tangential) question whether all FSE enabled themes need to support the |
Yes that's my concern is that we'd be tying it to the implementation of
If that's the case, then we're essentially removing the functionality altogether. We could delete the code that's doing the syncing, and probably use something simpler.
Yes, that's something to consider. Ideally the Customizer wouldn't be needed for FSE themes, but I suppose it will take some time before it can be removed completely. |
Yeah, that sounds reasonable.
Hmm, my impression was that we're actually retaining most of the functionality. It's true that we're removing the (option-writing) sync, but that's more of an implementation detail; due to how the override (at read time) works, we still get a de-facto sync, at least in one direction: |
@pablinos Could you (or your team) maybe carry this over the finish line, along the lines we've discussed? I'm currently rather busy with other Gutenthings, so it'd be really great if y'all could take care of that ❤️ |
No problem @ockham. I've been meaning to sort out a PR for the
You're right, sorry. I think we're retaining the sync one way. If the theory works hopefully we can fix it, but otherwise, we can go with this for now. |
Awesome, thanks a lot, @pablinos 🙏 ! Feel free to add me as a reviewer 😄
👍 |
Closing in favor of #30427 (which seems to be sufficient, now that the Customizer is disabled for FSE themes). |
Description
Tentative fix for #25173. Will update with more details and testing instructions a bit later today.
The Site Logo block (introduced in #18811) uses the custom logo theme mod concept. This allows it to be set both through the actual Site Block UI, and through the customizer. However, being a theme mod, a custom logo is stored per-theme, and is lost when switching themes.
The Site Logo block thus tapped into two hooks to extend the theme mod behavior, so a site logo would persist across theme changes:
theme_mod_custom_logo
is called when theget_custom_logo()
is called (e.g. by a theme, or the Site Block). The Site Block added theoverride_custom_logo_theme_mod
in order to return thesitelogo
option if it's set, and otherwise fall back to the custom logo theme mod.pre_set_theme_mod_custom_logo
is called whenever a custom logo is set viaset_theme_mod()
(e.g. by the customizer). The Site Block added thesync_site_logo_to_theme_mod
filter to it, and propagated the changes to thesitelogo
option.The latter caused #25173: If a custom logo was removed via
remove_theme_mod
through the customizer, thepre_set_theme_mod_custom_logo
filter isn't run (there are no filters run from insideremove_theme_mod
). Thus, while the custom logo theme mod was deleted, thesitelogo
remained untouched. This means the next timeget_custom_logo
was called, theoverride_custom_logo_theme_mod
filter would kick in, and return thesitelogo
option.One way to fix this would be to add a filter or hook to
remove_theme_mod
that we can tap into (props @sirreal ), but that's a change that would need to be made in Core.I think we can get away with a simpler fix:
We change the
pre_set_theme_mod_custom_logo
filter to a function calleddelete_site_logo_when_setting_theme_mod
, which does just that: When the custom logo theme mod is set (customizer), it deletes thesitelogo
option. That way, theoverride_custom_logo_theme_mod
won't find a site logo, and return the custom logo theme mod.All other behavior should be retained as desired.
How has this been tested?
See #25173 for instructions how to repro the issue, and verify that it's fixed.
Furthermore, this issue was caught by the
test_get_custom_logo
andtest_has_custom_logo
Core unit tests when run against GB 9.3. Verify that with this change, they now pass.Types of changes
Bugfix.
Checklist:
cc/ @carolinan @sirreal @scruffian @pablinos @creativecoder