-
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
Add a few filters to make it possible to change the default navigation icons #44228
base: trunk
Are you sure you want to change the base?
Conversation
Added a few filters to make it possible to programmatically change the navigation icons.
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @SGr33n! 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. |
Fix lint check errors.
@@ -619,14 +619,34 @@ function render_block_core_navigation( $attributes, $content, $block ) { | |||
); | |||
|
|||
$should_display_icon_label = isset( $attributes['hasIcon'] ) && true === $attributes['hasIcon']; | |||
$toggle_button_icon = '<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><rect x="4" y="7.5" width="16" height="1.5" /><rect x="4" y="15" width="16" height="1.5" /></svg>'; | |||
$toggle_button_icon = apply_filters( |
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.
Thanks for picking this up.
The problem with filtering here is that the user could have selected a particular icon in the editor, but then a filter applied by a plugin renders something completely different on the frontend, which results in a very confusing experience.
I think ideally the solution would be a filter that modifies the array of available icons for the user to select.
That may require JS and PHP code though.
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.
You're right, or replace filters with making possible to upload custom icons on Gutenberg.
Warning: Type of PR label error To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. |
If you're still interested in this; there's active discussion about this at #53510 |
Added a few filters to make it possible to programmatically change the navigation icons.
At time #43674 there is no chance to change the default navigation icons. The only way to customize them is filtering inside render_block_core/navigation and making a string replacement on $block_content... not really the cleanest way.
So I added a few filters to make it possible.
They are: