-
Notifications
You must be signed in to change notification settings - Fork 49
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
refactor: wizards menu order handling #3501
refactor: wizards menu order handling #3501
Conversation
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.
@miguelpeixe have tested the code and works as described.
Additionally: I really like your approach, first time i’ve come across custom_menu_order hook - looks like the right tool for the job!
Approved!
Thanks, @jaredrethman! Since this touches on a core aspect of the project, I'll also wait for @ronchambers feedback before merging. |
Not sure if this has any impact here, but for awareness: https://core.trac.wordpress.org/ticket/52035 I've been meaning to circle back to this and help it get to the finish line |
I didn't test locally, but I trust the two of you 😃 Overall, I agree that moving the menus around for the 3 different plugins (Listings, Newsletters, and Network - my original tasks ) became cumbersome where each plugin had a different approach... So yes, a standard approach is great! Since Listings and Newsletters were re-assigned to @miguelpeixe I won't worry about testing those. I do need to do some final testing on the Network plugin wizard so I'll be sure to merge this (or epic/ia after it's merged) to my Network branch and verify it's all good there too. Approved for me! Thanks! |
Thanks for flagging! The strategy doesn't cover submenu pages. I'm assuming we have tighter control over the execution order for submenu pages so it's less problematic. |
All Submissions:
Changes proposed in this Pull Request:
I started investigating the different ways we're managing menu order for wizard, prompted by @ronchambers comment regarding the Newsletters' wizard menu order:
Turns out we have multiple strategies in place:
add_menu_page()
argumentThis is hard to maintain and unpredictable. In this refactor PR I propose a consolidated strategy applied in the
class-wizards.php
:newspack-plugin/includes/class-wizards.php
Lines 141 to 172 in 406bc54
Each wizard with a parent menu item can use the public vars
parent_menu
andmenu_order
to determine how it should render relative to thenewspack-dashboard
wizard:newspack-plugin/includes/wizards/class-network-wizard.php
Lines 33 to 45 in 406bc54
Result:
This PR also deprecates the
menu_priority
variable from the abstract class. It's a bit misleading, as it only applies the hook priority to theadmin_menu
hook. This is not a guaranteed way of setting the menu order because it gets overridden by theadd_menu_page
argument.How to test the changes in this Pull Request:
Other information: