refactor: wizards menu order handling#3501
Conversation
jaredrethman
left a comment
There was a problem hiding this comment.
@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_menuandmenu_orderto determine how it should render relative to thenewspack-dashboardwizard:newspack-plugin/includes/wizards/class-network-wizard.php
Lines 33 to 45 in 406bc54
Result:
This PR also deprecates the
menu_priorityvariable from the abstract class. It's a bit misleading, as it only applies the hook priority to theadmin_menuhook. This is not a guaranteed way of setting the menu order because it gets overridden by theadd_menu_pageargument.How to test the changes in this Pull Request:
Other information: