[wp-trac] [WordPress Trac] #36832: Refactor for class-walker-nav-menu-edit.php

WordPress Trac noreply at wordpress.org
Fri May 13 13:23:45 UTC 2016


#36832: Refactor for class-walker-nav-menu-edit.php
----------------------------+-----------------------------
 Reporter:  iamntz          |      Owner:
     Type:  enhancement     |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Menus           |    Version:  trunk
 Severity:  normal          |   Keywords:
  Focuses:  administration  |
----------------------------+-----------------------------
 Hi guys.

 I present you a ''small'' refactor of the class-walker-nav-menu-edit.php
 class. Reasoning:

 - The start_el method is huge;
 - The start_el method have a lot of responsibilities;
 - The walker is impossible to extend without duplicating a lot of code
 (basically the whole start_el method)

 '''The idea behind this refactor:'''

 - reduce responsibilities for the main method;
 - adding a hook that allows extending fields (so will close #18584);
 - adding a hook that allows extending title & controls;

 '''So, what did i do?'''

 - I added a hook for: title, controls and settings fields;
 - I extracted everything into its own method: title, submenu status,
 controls, settings;
 - I extracted most conditionals into its own methods;
 - All methods are now easier to follow (under 20 lines each)

 '''Additional work'''

 Depending on how this patch will be received, I'm planning to do a similar
 refactor for Walker_nav_menu, because it kind of have the same issues with
 the start_el method.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36832>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list