[wp-trac] [WordPress Trac] #21898: Custom Fields for Menu Items

WordPress Trac wp-trac at lists.automattic.com
Sat Sep 15 15:34:35 UTC 2012


#21898: Custom Fields for Menu Items
-----------------------------+-------------------------
 Reporter:  helgatheviking   |       Type:  enhancement
   Status:  new              |   Priority:  normal
Milestone:  Awaiting Review  |  Component:  General
  Version:  trunk            |   Severity:  normal
 Keywords:                   |
-----------------------------+-------------------------
 I think plugin authors should be able to able to add custom fields to menu
 items.  I'd like to set certain menu items as viewable only by certain
 roles.  Currently this ''is'' possible, but only by duplicating the entire
 `Walker_Nav_Menu_Edit` walker.  It'd be much easier if there was a hook
 inside the Walker instead.

 For instance, `in /wp-admin/includes/nav-menu.php`

 directly following:


 {{{
 <p class="field-description description description-wide">
         <label for="edit-menu-item-description-<?php echo $item_id; ?>">
                 <?php _e( 'Description' ); ?><br />
                 <textarea id="edit-menu-item-description-<?php echo
 $item_id; ?>" class="widefat edit-menu-item-description" rows="3"
 cols="20" name="menu-item-description[<?php echo $item_id; ?>]"><?php echo
 esc_html( $item->description ); // textarea_escaped ?></textarea>
                 <span class="description"><?php _e('The description will
 be displayed in the menu if the current theme supports it.'); ?></span>
         </label>
 </p>
 }}}


 You could easily place:


 {{{
 <?php do_action( 'wp_nav_menu_custom_fields', $item, $depth, $args ); ?>
 }}}

 Since there are already hooks for `wp_update_nav_menu_item` and
 `wp_setup_nav_menu_item` it is already possible to save the save and to
 call it back when using it in the front-end Walker.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/21898>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list