Navigation block: update fallback nav creation to most recently created menu#46286
Navigation block: update fallback nav creation to most recently created menu#46286
Conversation
|
Size Change: -18 B (0%) Total Size: 1.33 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
I think this syntax was introduced in PHP 7.4. WordPress says it requires PHP 7.4, but I don't see any use of arrow functions in WordPress or Gutenberg, so maybe it's better to avoid them?
There was a problem hiding this comment.
Fixed in 3871774f423eed36338a57633418c3e8be4a3f6f
There was a problem hiding this comment.
Why are locations in this part of the calculation?
There was a problem hiding this comment.
Good question, I realized the logic was convoluted. Cleaned this up in 9abfcd5
3871774 to
6dc44f0
Compare
|
This wasn't working for me in the editor as navigation menus have an |
|
Thanks for the fixes, this is testing correctly for me. Any other feedback to address? |
…ed menu (WordPress#46286) * Sort fallback classic menu conversion by most recently created. * Separate sorting calc from location calc. * Use standard anonymous function syntax. * Format php. * change the property name and simplify the functions Co-authored-by: Ben Dwyer <ben@scruffian.com>
What?
This PR sorts the classic menus so the most recently created menu is used in the series of fallback nav creation.
If there is a menu named primary or has a primary location, that menu still takes precedence.
Why?
Before #45976, a navigation would only be created if the site had a single classic menu. Now that the fallback system can handle multiple cases, we need to consider which menu should be prioritized in the fallback order.
The WP function that get classic menus returns an array of menus sorted by name, alphabetically by default. So we need to instead sort by their
term_idif we want the most recently created.How?
See above.
Testing Instructions
wp_navigations previouslywp_navigation, repeat step 4 but visiting the front-end first, then the editor.Testing Instructions for Keyboard
Screenshots or screencast