From 5cb3ed94ae5867b63e2e21e1251a502d9ca393e2 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 4 May 2011 18:59:40 +0000 Subject: [PATCH] Show hierarchy for pages and taxonomies in nav menus admin. Props greuben. fixes #17029 git-svn-id: https://develop.svn.wordpress.org/trunk@17796 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/nav-menu.php | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/wp-admin/includes/nav-menu.php b/wp-admin/includes/nav-menu.php index 6e92928666..6f5962ae95 100644 --- a/wp-admin/includes/nav-menu.php +++ b/wp-admin/includes/nav-menu.php @@ -207,6 +207,21 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu { * @uses Walker_Nav_Menu */ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu { + function __construct( $fields = false ) { + if ( $fields ) { + $this->db_fields = $fields; + } + } + + function start_lvl( &$output, $depth ) { + $indent = str_repeat( "\t", $depth ); + $output .= "\n$indent"; + } /** * @see Walker::start_el() @@ -613,8 +628,13 @@ function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) { if ( !$posts ) $error = '
  • '. $post_type['args']->labels->not_found .'
  • '; + + $db_fields = false; + if ( is_post_type_hierarchical( $post_type_name ) ) { + $db_fields = array( 'parent' => 'post_parent', 'id' => 'ID' ); + } - $walker = new Walker_Nav_Menu_Checklist; + $walker = new Walker_Nav_Menu_Checklist( $db_fields ); $current_tab = 'most-recent'; if ( isset( $_REQUEST[$post_type_name . '-tab'] ) && in_array( $_REQUEST[$post_type_name . '-tab'], array('all', 'search') ) ) { @@ -716,6 +736,7 @@ function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) { 'object_id' => $_nav_menu_placeholder, 'post_content' => '', 'post_excerpt' => '', + 'post_parent' => '', 'post_title' => _x('Home', 'nav menu home label'), 'post_type' => 'nav_menu_item', 'type' => 'custom', @@ -821,7 +842,12 @@ function wp_nav_menu_item_taxonomy_meta_box( $object, $taxonomy ) { 'current' => $pagenum )); - $walker = new Walker_Nav_Menu_Checklist; + $db_fields = false; + if ( is_taxonomy_hierarchical( $taxonomy_name ) ) { + $db_fields = array( 'parent' => 'parent', 'id' => 'term_id' ); + } + + $walker = new Walker_Nav_Menu_Checklist( $db_fields ); $current_tab = 'most-used'; if ( isset( $_REQUEST[$taxonomy_name . '-tab'] ) && in_array( $_REQUEST[$taxonomy_name . '-tab'], array('all', 'most-used', 'search') ) ) {