Make WordPress Core

Changeset 17796


Ignore:
Timestamp:
05/04/2011 06:59:40 PM (15 years ago)
Author:
ryan
Message:

Show hierarchy for pages and taxonomies in nav menus admin. Props greuben. fixes #17029

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/nav-menu.php

    r17143 r17796  
    208208 */
    209209class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu  {
     210        function __construct( $fields = false ) {
     211                if ( $fields ) {
     212                        $this->db_fields = $fields;
     213                }
     214        }
     215
     216        function start_lvl( &$output, $depth ) {
     217                $indent = str_repeat( "\t", $depth );
     218                $output .= "\n$indent<ul class='children'>\n";
     219        }
     220
     221        function end_lvl( &$output, $depth ) {
     222                $indent = str_repeat( "\t", $depth );
     223                $output .= "\n$indent</ul>";
     224        }
    210225
    211226        /**
     
    614629        if ( !$posts )
    615630                $error = '<li id="error">'. $post_type['args']->labels->not_found .'</li>';
    616 
    617         $walker = new Walker_Nav_Menu_Checklist;
     631       
     632        $db_fields = false;
     633        if ( is_post_type_hierarchical( $post_type_name ) ) {
     634                $db_fields = array( 'parent' => 'post_parent', 'id' => 'ID' );
     635        }
     636
     637        $walker = new Walker_Nav_Menu_Checklist( $db_fields );
    618638
    619639        $current_tab = 'most-recent';
     
    717737                                                        'post_content' => '',
    718738                                                        'post_excerpt' => '',
     739                                                        'post_parent' => '',
    719740                                                        'post_title' => _x('Home', 'nav menu home label'),
    720741                                                        'post_type' => 'nav_menu_item',
     
    822843        ));
    823844
    824         $walker = new Walker_Nav_Menu_Checklist;
     845        $db_fields = false;
     846        if ( is_taxonomy_hierarchical( $taxonomy_name ) ) {
     847                $db_fields = array( 'parent' => 'parent', 'id' => 'term_id' );
     848        }
     849
     850        $walker = new Walker_Nav_Menu_Checklist( $db_fields );
    825851
    826852        $current_tab = 'most-used';
Note: See TracChangeset for help on using the changeset viewer.