-
Notifications
You must be signed in to change notification settings - Fork 360
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
Blockbase: Changed the trigger to render social icons #6079
Conversation
I'm not sure about this. The aim of FSE is that users will see the same in the frontend and the editor. It's not possible to add social links to the navigation using the customizer, which is why this was introduced, but once a user starts working in the Site Editor they can add their own social links to the navigation block, so there's no need for this feature. If we are going to change how this works then I think my preference would be to just remove the feature entirely. |
I've been on the fence about that. I don't think we can remove the feature entirely, that would change the navigation of existing installations and I'm keen to ensure that as the theme progresses we don't break anything that's already happening. I'm keen to remove the feature, but I'm not sure that can be done without breaking said existing installations. I think the best scenario we can work toward is:
The downside to keeping the social bits but not making this change is that users that already have navigation that includes social will lose that and will have to rebuild their navigation if they make any changes to the header template. I'm not sure how likely that is or if it's something we should worry about but that's the scenario I'm thinking about. I'm also not sure if the navigation bits of the Customizer CAN be removed if we keep the navigation targets assigned so maybe that's not even an option. |
…lMenuLocation is therefore available)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the change in place modify the header and make changes to any part of the header EXCEPT the navigation block. Note that the navigation continues to render as expected. (This is the bug noted in #6077)
Now modify the navigation block in the FSE (creating a menu from scratch, or assigning it an existing menu from, etc). Note that the social navigation items are no longer being shown now that the menu has been edited via the FSE.
I tested and verified the above scenarios with this PR.
) | ||
); | ||
// Register two nav menus if Gutenberg is activated (otherwise the __experimentalMenuLocation attribute isn't available) | ||
if ( defined( 'IS_GUTENBERG_PLUGIN' ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are keen to remove this feature but not break existing installations, could we do something like the following?
if ( defined( 'IS_GUTENBERG_PLUGIN' ) ) { | |
$nav_menus = get_nav_menu_locations(); | |
if ( defined( 'IS_GUTENBERG_PLUGIN' ) && ! empty( $nav_menus[ 'social' ] ) ) { |
This way, users who have already defined menus will continue to be able to edit them via the customizer. For fresh sites with no menus defined yet, they will have to go to the site editor to edit their navigation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was actually tinkering with exactly that! However I found that the 'get_nav_menu_locations' returns the menus that are defined in the code that follows. The 'locations' are what the theme provides. I was not able to discern what to call to determine if the user had any menus defined.
I think that's a good idea for the reasons you state, though I still think that checking for Gutenberg is still important. If that's not installed leveraging the 'classic menus' still wouldn't be supported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking that we would only register the menu locations if there are already menus assigned to that location, which get_nav_menu_locations
returns just that.
I was not able to discern what to call to determine if the user had any menus defined.
If we wanted to make the condition for if the user had any menus defined, regardless of whether they are assigned to a location, we could use https://developer.wordpress.org/reference/functions/wp_get_nav_menus/
To clarify my review — this PR fixes the issue in my testing (you can edit the header without losing your social menu) and removing the feature entirely will change / break existing sites, so I think it makes sense to ship this and decide if / how we want to retire the feature in a follow up. |
I'm going to move this into the "Blockbase 3.0" bucket. We can't remove the feature for reasons noted above and this would fix the issue at hand. There don't seem to be any obvious side-effects. |
Refactor/blockbase color admin (#6043) Moved templates from old folder location to new (#6073) Blockbase: Implement the Button elements API (#6041) Blockbase: Implement Comment Block and removed CSS (#6080) Fix/migrate blockbase font self hosted (#6123) Blockbase children: update comments block (#6153) Blockbase: Changed the trigger to render social icons (#6079) Blockbase: move button padding styles from ponyfill to theme.json (#5901) Co-authored-by: Grant Kinney <[email protected]> Co-authored-by: Jeremy Yip <[email protected]> Co-authored-by: MaggieCabrera <[email protected]> Co-authored-by: madhusudhand <[email protected]>
Closing: Work merged in #6167 |
Changes proposed in this Pull Request:
This changes the trigger to add/style social media icons from the Block attribute
__unstableSocialLinks
to the classsocial-links
This was done because when the templates that contain navigation blocks with an
unstableSocialLinks
attribute when saved that attribute is removed, thus social links are no longer rendered.A class is used instead because it will persist across edits.
The logic used to determine if the social bits should be rendered has been updated to ensure that:
__unstableLocation
attribute (which IS sanctioned by Gutenberg and that was already the case for all template instances)social-links
class.Additionally instead of getting the target menu location previously defined via the
__unstableSocialLinks
attribute the location ofsocial
is assumed. (All instances in the templates were using that location.)Lastly all of the template parts/patterns that were leveraging the
__unstableSocialLinks
attribute have been changed to use the classsocial-links
instead.To test ensure the following scenarios work as expected:
A site using Blockbase (or Blockbase child) that has [primary|social] location(s) assigned (via customizer) and have no other modifications to their header continue to show the primary menu and/or social menu as expected.
With the change in place modify the header and make changes to any part of the header EXCEPT the navigation block. Note that the navigation continues to render as expected. (This is the bug noted in #6077)
Now modify the navigation block in the FSE (creating a menu from scratch, or assigning it an existing menu from, etc). Note that the social navigation items are no longer being shown now that the menu has been edited via the FSE.
Related issue(s):
Fixes #6077