[wp-trac] [WordPress Trac] #18584: Nav menus need more hooks for extensibility (on admin page & in customizer)

WordPress Trac noreply at wordpress.org
Fri Sep 16 05:56:39 UTC 2016


#18584: Nav menus need more hooks for extensibility (on admin page & in customizer)
--------------------------+-----------------------------
 Reporter:  Viper007Bond  |       Owner:
     Type:  enhancement   |      Status:  new
 Priority:  normal        |   Milestone:  Future Release
Component:  Customize     |     Version:  3.3
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:  javascript
--------------------------+-----------------------------

Comment (by westonruter):

 I've been spending some time this week working on a path to finally
 facilitating custom fields for nav menu items in the customizer.

 I have an alpha-state feature plugin that can be played around with:
 https://github.com/xwp/wp-customize-nav-menu-item-custom-fields

 Note that this plugin has two separate plugins embedded within it:
 “Customize Nav Menu Item Custom Fields” and “Customize Nav Menu Item
 Custom Field Examples”. The latter includes an example that adds a basic
 implementation of @helgatheviking's Nav Menu Roles plugin (allowing a nav
 menu item's display to be conditional based on whether a user is logged-
 in, logged-out, or if it should be shown for anyone.) You'll note that,
 being that the customizer is a JavaScript application, the integration
 here looks very different than how custom fields might currently be
 integrated with nav menu items in the nav menus admin page. The
 integration relies primarily on JavaScript events rather than PHP actions
 and filters. Example: https://github.com/xwp/wp-customize-nav-menu-item-
 custom-fields/tree/master/examples/user-visibility

 Note that since custom fields for nav menu items are postmeta, this
 feature plugin depends on Customize Posts which implements the necessary
 interface to represent postmeta in the customizer. You'll have to use the
 current `develop` branch to test the plugin: https://github.com/xwp/wp-
 customize-posts

 There is one key limitation currently with the plugin: it isn't possible
 to manage custom fields for newly-added nav menu items that haven't been
 saved yet. This is due to how we're using placeholder IDs as opposed to
 actual IDs, and postmeta aren't able to work with such placeholder IDs in
 core currently. For more on this, see #38072.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/18584#comment:82>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list