Make WordPress Core

Changeset 13286


Ignore:
Timestamp:
02/22/2010 12:26:21 AM (17 years ago)
Author:
wpmuguru
Message:

add custom menu hierarchy support to admin, See #11817

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/custom-navigation.php

    r13284 r13286  
    135135                        if (isset($_POST['dbid'.$k])) { $db_id = $_POST['dbid'.$k]; } else { $db_id = 0; }
    136136                        if (isset($_POST['postmenu'.$k])) { $object_id = $_POST['postmenu'.$k]; } else { $object_id = 0; }
    137                         //@todo implement heirarchy
    138137                        if (isset($_POST['parent'.$k])) { $parent_id = $_POST['parent'.$k]; } else { $parent_id = 0; }
    139138                        if (isset($_POST['title'.$k])) { $custom_title = $_POST['title'.$k]; } else { $custom_title = ''; }
     
    155154                        else
    156155                                $post['post_content_filtered'] = '';
     156                        if ( $parent_id > 0 && isset( $_POST[ 'dbid' . $parent_id ] ) )
     157                                $post[ 'post_parent' ] = (int) $_POST[ 'dbid' . $parent_id ];
    157158
    158159                        // New menu item
  • trunk/wp-includes/custom-navigation.php

    r13284 r13286  
    115115                elseif ( is_category() )
    116116                        $queried_id = $wp_query->get_queried_object_id();
     117
     118                $parent_stack = array();
    117119            // Display Loop
    118120                foreach ( $menu_items as $menu_item ) {
     
    192194                        }
    193195*/
     196                        // Indent children
     197                        if ( empty( $parent_stack ) ) {
     198                                array_unshift( $parent_stack, $menu_item->ID );
     199                        } elseif ( $menu_item->post_parent > 0 ) {
     200                                if ( $menu_item->post_parent == $parent_stack[0] ) { ?>
     201                        <ul>
     202<?php                                   array_unshift( $parent_stack, $menu_item->ID );
     203                                } elseif ( count( $parent_stack ) > 1 && $menu_item->post_parent == $parent_stack[1] ) { ?>
     204                        </li>
     205<?php                                   $parent_stack[0] = $menu_item->ID;
     206                                } elseif ( in_array( $menu_item->post_parent, $parent_stack ) ) {
     207                                        while ( !empty( $parent_stack ) && $menu_item->post_parent != $parent_stack[0] ) { ?>
     208                        </li></ul>
     209<?                                              array_shift( $parent_stack );
     210                                        }
     211                                }
     212                        } else { ?>
     213                        </li>
     214<?php                           $parent_stack[0] = $menu_item->ID;
     215                        }
     216
    194217                        // List Items
    195218                        ?><li id="menu-<?php echo $menu_item->ID; ?>" value="<?php echo $menu_item->ID; ?>" <?php echo $li_class; ?>><?php
     
    257280                                                <?php
    258281                                        }
    259 
    260                                         //@todo: implement menu heirarchy
    261 /*                                      //DISPLAY menu sub items
    262                                         if ($wp_custom_nav_menu_items->parent_id == 0)
    263                                         {
    264                                                 //FRONTEND
    265                                                 if ($type == 'frontend')
    266                                                 {
    267                                                         //Recursive function
    268                                                         $intj = wp_custom_navigation_sub_items($wp_custom_nav_menu_items->id,$wp_custom_nav_menu_items->link_type,$table_name,$type,$wp_custom_nav_menu_id);
    269                                                 }
    270                                                 //BACKEND
    271                                                 else
    272                                                 {
    273                                                         //Recursive function
    274                                                         $intj = wp_custom_navigation_sub_items($wp_custom_nav_menu_items->id,$wp_custom_nav_menu_items->link_type,$table_name,$type,$id);
    275                                                 }
    276                                         }
    277 */                      ?></li>
    278                         <?php
    279282                }
     283                while ( !empty( $parent_stack ) ) { ?>
     284                        </li></ul>
     285<?                      array_shift( $parent_stack );
     286                }
     287                if ( !empty( $menu_items ) ) { ?>
     288                </li>
     289<?php           }
    280290}
    281291//@todo: implement menu heirarchy
Note: See TracChangeset for help on using the changeset viewer.