Make WordPress Core

Ticket #11817: menus_awesomesauce_patch.diff

File menus_awesomesauce_patch.diff, 127.7 KB (added by ptahdunbar, 14 years ago)

patch updated to address the translated strings being saved in the db. Append is now generated on the fly.

  • wp-includes/nav-menu-template.php

     
    99 * menu_class - CSS class to use for the div container of the menu list. Defaults to 'menu'.
    1010 * format - Whether to format the ul. Defaults to 'div'.
    1111 * fallback_cb - If the menu doesn't exists, a callback function will fire. Defaults to 'wp_page_menu'.
    12  * before_link - Output text before the link.
    13  * after_link - Output text after the link.
    14  * before_title - Output text before the link text.
    15  * before_title - Output text after the link text.
     12 * before - Text before the link text.
     13 * after - Text after the link text.
     14 * link_before - Text before the link.
     15 * link_after - Text after the link.
    1616 * echo - Whether to echo the menu or return it. Defaults to echo.
    17  *
    18  * TODO:
    1917 * show_home - If you set this argument, then it will display the link to the home page. The show_home argument really just needs to be set to the value of the text of the link.
    2018 *
    2119 * @since 3.0.0
     
    2422 */
    2523function wp_nav_menu( $args = array() ) {
    2624        $defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'menu_class' => 'menu', 'echo' => true,
    27         'fallback_cb' => 'wp_page_menu', 'before_link' => '', 'after_link' => '', 'before_title' => '', 'after_title' => '', );
     25        'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '',
     26        'depth' => 0, 'walker' => '' );
    2827
    2928        $args = wp_parse_args( $args, $defaults );
    3029        $args = apply_filters( 'wp_nav_menu_args', $args );
     
    8382 * @return mixed $output False if menu doesn't exists, else, returns the menu.
    8483 **/
    8584function wp_get_nav_menu( $args = array() ) {
    86         $defaults = array( 'menu' => '', 'menu_class' => 'menu', 'context' => 'frontend',
    87         'fallback_cb' => '', 'before_link' => '', 'after_link' => '', 'before_title' => '', 'after_title' => '', );
     85        $defaults = array( 'menu' => '', 'menu_class' => 'menu', 'context' => 'frontend', 'depth' => 0,
     86        'fallback_cb' => '', 'walker' => '', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', );
    8887       
    8988        $args = wp_parse_args( $args, $defaults );
    9089        $args = apply_filters( 'wp_get_nav_menu_args', $args );
     
    9392        // Variable setup
    9493        $nav_menu = '';
    9594        $items = '';
    96         $current_parent = 0;
    97         $parent_stack = array();
    98         $parent_menu_order = array();
    9995       
    10096        // Get the menu object
    10197        $menu = wp_get_nav_menu_object( $args->menu );
    10298       
    10399        // If the menu exists, get it's items.
    104100        if ( $menu && !is_wp_error($menu) )
    105                 $menu_items = wp_get_nav_menu_items( $menu->term_id, 'backend' );
     101                $menu_items = wp_get_nav_menu_items( $menu->term_id, $args->context );
    106102       
    107103        // If no menu was found or if the menu has no items, call the fallback_cb
    108104        if ( !$menu || is_wp_error($menu) || ( isset($menu_items) && empty($menu_items) ) ) {
    109                 if ( function_exists($args->fallback_cb) ) {
    110                         $_args = array_merge( (array)$args, array('echo' => false) );
     105                if ( function_exists($args->fallback_cb) || is_callable( $args->fallback_cb ) ) {
     106                        $_args = array_merge( (array) $args, array('echo' => false) );
    111107                        return call_user_func( $args->fallback_cb, $_args );
    112108                }
    113109        }
    114        
    115         foreach ( $menu_items as $key => $menu_item ) {
    116                 // Set up the $menu_item variables
    117                 $menu_item = wp_setup_nav_menu_item( $menu_item, 'frontend' );
    118 
    119                 $type = $menu_item->append;
    120                 $maybe_value = 'frontend' == $args->context ? '' : ' value="'. $menu_item->ID .'"';
    121                 $classes = 'frontend' == $args->context ? ' class="menu-item-type-'. $type . $menu_item->li_class .'"' : '';
    122110               
    123                 $items .= '<li id="menu-item-'. $menu_item->ID .'"'. $maybe_value . $classes .'>';
    124                 $items .= wp_get_nav_menu_item( $menu_item, $args->context, $args );
    125                
    126                 // Indent children
    127                 $last_item = ( count( $menu_items ) == $menu_item->menu_order );
    128                 if ( $last_item || $current_parent != $menu_items[$key + 1]->post_parent ) {
    129                         if ( $last_item || in_array( $menu_items[$key + 1]->post_parent, $parent_stack ) ) {
    130                                 $items .= '</li>';
    131                                 while ( !empty( $parent_stack ) && ($last_item || $menu_items[$key + 1]->post_parent != $current_parent ) ) {
    132                                         $items .= '</ul></li>';
    133                                         $current_parent = array_pop( $parent_stack );
    134                                 }
    135                         } else {
    136                                 array_push( $parent_stack, $current_parent );
    137                                 $current_parent = $menu_item->ID;
    138                                 $items .= '<ul class="sub-menu">';
    139                         }
    140                 } else {
    141                         $items .= '</li>';
    142                 }
    143         }
     111        // Set up the $menu_item variables
     112        foreach ( (array) $menu_items as $key => $menu_item )
     113                $menu_items[$menu_item->menu_order] = wp_setup_nav_menu_item( $menu_item, 'frontend' );
    144114       
     115        $items .= walk_nav_menu_tree( $menu_items, $args->depth, $args );
     116       
    145117        // CSS class
    146118        $ul_class = $args->menu_class ? ' class="'. $args->menu_class .'"' : '';
    147119        $nav_menu .= '<ul'. $ul_class .'>';
     
    174146        $output = '';
    175147        switch ( $context ) {
    176148                case 'frontend':
    177                         $attributes  = ( isset($menu_item->anchor_title) && '' != $menu_item->anchor_title ) ? ' title="'. esc_attr($menu_item->anchor_title) .'"' : '';
     149                        $attributes  = ( isset($menu_item->attr_title) && '' != $menu_item->attr_title ) ? ' title="'. esc_attr($menu_item->attr_title) .'"' : '';
    178150                        $attributes .= ( isset($menu_item->target) && '' != $menu_item->target ) ? ' target="'. esc_attr($menu_item->target) .'"' : '';
    179                         $attributes .= ( isset($menu_item->classes) && '' != $menu_item->classes ) ? ' class="'. esc_attr($menu_item->classes) .'"' : '';
    180151                        $attributes .= ( isset($menu_item->xfn) && '' != $menu_item->xfn ) ? ' rel="'. esc_attr($menu_item->xfn) .'"' : '';
    181152                        $attributes .= ( isset($menu_item->url) && '' != $menu_item->url ) ? ' href="'. esc_attr($menu_item->url) .'"' : '';
    182153                       
    183                         $output .= esc_html( $args->before_link );
     154                        $output .= esc_html( $args->before );
    184155                        $output .= '<a'. $attributes .'>';
    185                         $output .= esc_html( $args->before_title . $menu_item->title . $args->after_title );
     156                        $output .= esc_html( $args->link_before . apply_filters('the_title', $menu_item->title) . $args->link_after );
    186157                        $output .= '</a>';
    187                         $output .= esc_html( $args->after_link );
     158                        $output .= esc_html( $args->after );
    188159                       
    189160                        break;
    190161               
    191162                case 'backend':
    192163                        $output .= '<dl><dt>';
    193                         $output .= '<span class="item-title">'. esc_html($menu_item->title) .'</span>';
     164                        $output .= '<span class="item-title">'. esc_html( $menu_item->title ) .'</span>';
    194165                        $output .= '<span class="item-controls">';
    195                         if ( 'custom' == $menu_item->type ) {
    196                                 $label = __('Custom');
    197                         } elseif ( 'post_type' == $menu_item->type ) {
    198                                 $type_obj = get_post_type_object($menu_item->append);
    199                                 $label = $type_obj->singular_label;
    200                         } elseif ( 'taxonomy' == $menu_item->type ) {
    201                                 $taxonomy = get_taxonomy($menu_item->append);
    202                                 $label = $taxonomy->singular_label;
    203                         } else {
    204                                 $label = $menu_item->append;
    205                         }
    206                         $output .= '<span class="item-type">'. esc_html($label) .'</span>';
     166                        $output .= '<span class="item-type">'. esc_html( $menu_item->append ) .'</span>';
    207167                       
    208168                        // Actions
    209                         $output .= '<a class="item-edit thickbox" id="edit'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->menu_order ) .'" title="'. __('Edit Menu Item') .'" href="#TB_inline?height=540&width=300&inlineId=menu-item-settings">'. __('Edit') .'</a> | ';
    210                         $output .= '<a class="item-delete" id="delete'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->menu_order ) .'">'. __('Delete') .'</a>';
     169                        $output .= '<a class="item-edit thickbox" id="edit-'. esc_attr( $menu_item->ID ) .'" value="'. esc_attr( $menu_item->ID ) .'" title="'. __('Edit Menu Item') .'" href="#TB_inline?height=540&width=300&inlineId=menu-item-settings">'. __('Edit') .'</a> | ';
     170                        $output .= '<a class="item-delete" id="delete-'. esc_attr( $menu_item->ID ) .'" value="'. esc_attr( $menu_item->ID ) .'">'. __('Delete') .'</a>';
    211171                       
    212                         $output .= '</dt></dl>';
     172                        $output .= '</span></dt></dl>';
    213173                       
    214174                        // Menu Item Settings
    215                         $output .= '<input type="hidden" name="menu-item-db-id[]" id="menu-item-db-id'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->ID ) .'" />';
    216                         $output .= '<input type="hidden" name="menu-item-object-id[]" id="menu-item-object-id'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->object_id ) .'" />';
    217                         $output .= '<input type="hidden" name="menu-item-parent-id[]" id="menu-item-parent-id'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->post_parent ) .'" />';
    218                         $output .= '<input type="hidden" name="menu-item-position[]" id="menu-item-position'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->menu_order ) .'" />';
    219                         $output .= '<input type="hidden" name="menu-item-type[]" id="menu-item-type'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->type ) .'" />';
    220                         $output .= '<input type="hidden" name="menu-item-append[]" id="menu-item-append'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->append ) .'" />';
    221                         $output .= '<input type="hidden" name="menu-item-title[]" id="menu-item-title'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->title ) .'" />';
    222                         $output .= '<input type="hidden" name="menu-item-url[]" id="menu-item-url'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->url ) .'" />';
    223                         $output .= '<input type="hidden" name="menu-item-description[]" id="menu-item-description'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->description ) .'" />';
    224                         $output .= '<input type="hidden" name="menu-item-classes[]" id="menu-item-classes'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->classes ) .'" />';
    225                         $output .= '<input type="hidden" name="menu-item-xfn[]" id="menu-item-xfn'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->xfn ) .'" />';
    226                         $output .= '<input type="hidden" name="menu-item-attr-title[]" id="menu-item-attr-title'. esc_attr( $menu_item->menu_order ) .'" value="'.esc_attr( $menu_item->post_excerpt )  .'" />';
    227                         $output .= '<input type="hidden" name="menu-item-target[]" id="menu-item-target'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->target ) .'" />';
     175                        $output .= '<input type="hidden" name="menu-item-db-id[]" value="'. esc_attr( $menu_item->ID ) .'" />';
     176                        $output .= '<input type="hidden" name="menu-item-object-id[]" value="'. esc_attr( $menu_item->object_id ) .'" />';
     177                        $output .= '<input type="hidden" name="menu-item-object[]" value="'. esc_attr( $menu_item->object ) .'" />';
     178                        $output .= '<input type="hidden" name="menu-item-parent-id[]" value="'. esc_attr( $menu_item->post_parent ) .'" />';
     179                        $output .= '<input type="hidden" name="menu-item-position[]" value="'. esc_attr( $menu_item->menu_order ) .'" />';
     180                        $output .= '<input type="hidden" name="menu-item-type[]" value="'. esc_attr( $menu_item->type ) .'" />';
     181                        $output .= '<input type="hidden" name="menu-item-title[]" value="'. esc_attr( $menu_item->title ) .'" />';
     182                        $output .= '<input type="hidden" name="menu-item-url[]" value="'. esc_attr( $menu_item->url ) .'" />';
     183                        $output .= '<input type="hidden" name="menu-item-description[]" value="'. esc_attr( $menu_item->description ) .'" />';
     184                        $output .= '<input type="hidden" name="menu-item-classes[]" value="'. esc_attr( $menu_item->classes ) .'" />';
     185                        $output .= '<input type="hidden" name="menu-item-xfn[]" value="'. esc_attr( $menu_item->xfn ) .'" />';
     186                        $output .= '<input type="hidden" name="menu-item-attr-title[]" value="'.esc_attr( $menu_item->post_excerpt )  .'" />';
     187                        $output .= '<input type="hidden" name="menu-item-target[]" value="'. esc_attr( $menu_item->target ) .'" />';
    228188                        break;
    229189               
    230190                case 'custom':
    231                         $menu_id = 'menu-item-' . $menu_item->db_id;
    232                         $output .= '<label class="menu-item-title"><input type="checkbox" id="'. esc_attr( $menu_id ) .'" name="'. esc_attr( $menu_item->title ) .'" value="'. esc_attr( $menu_item->url ) .'" />'. $menu_item->title .'</label>';
     191                case 'taxonomy':
     192                case 'post_type':
     193                        $output .= '<label class="menu-item-title"><input type="checkbox" id="'. esc_attr( 'menu-item-' . $menu_item->object_id ) .'" value="'. esc_attr( $menu_item->url ) .'" />'. $menu_item->title .'</label>';
    233194                       
    234195                        // Menu item hidden fields
    235                         $output .= '<input type="hidden" class="menu-item-db-id" value="'. esc_attr( $menu_item->db_id ) .'" />';
     196                        $output .= '<input type="hidden" class="menu-item-db-id" value="0" />';
    236197                        $output .= '<input type="hidden" class="menu-item-object-id" value="'. esc_attr( $menu_item->object_id ) .'" />';
    237                         $output .= '<input type="hidden" class="menu-item-parent-id" value="'. esc_attr( $menu_item->parent_id ) .'" />';
     198                        $output .= '<input type="hidden" class="menu-item-object" value="'. esc_attr( $menu_item->object ) .'" />';
     199                        $output .= '<input type="hidden" class="menu-item-parent-id" value="'. esc_attr( $menu_item->post_parent ) .'" />';
    238200                        $output .= '<input type="hidden" class="menu-item-type" value="'. esc_attr( $menu_item->type ) .'" />';
    239201                        $output .= '<input type="hidden" class="menu-item-append" value="'. esc_attr( $menu_item->append ) .'" />';
    240202                        $output .= '<input type="hidden" class="menu-item-title" value="'. esc_attr( $menu_item->title ) .'" />';
    241203                        $output .= '<input type="hidden" class="menu-item-url" value="'. esc_attr( $menu_item->url ) .'" />';
     204                        $output .= '<input type="hidden" class="menu-item-append" value="'. esc_attr( $menu_item->append ) .'" />';
    242205                        $output .= '<input type="hidden" class="menu-item-target" value="'. esc_attr( $menu_item->target ) .'" />';
    243206                        $output .= '<input type="hidden" class="menu-item-attr_title" value="'. esc_attr( $menu_item->attr_title ) .'" />';
    244207                        $output .= '<input type="hidden" class="menu-item-description" value="'. esc_attr( $menu_item->description ) .'" />';
    245208                        $output .= '<input type="hidden" class="menu-item-classes" value="'. esc_attr( $menu_item->classes ) .'" />';
    246209                        $output .= '<input type="hidden" class="menu-item-xfn" value="'. esc_attr( $menu_item->xfn ) .'" />';
    247210                        break;
    248                
    249                 case 'taxonomy':
    250                 case 'post_type':
    251                         $menu_id = 'menu-item-' . $menu_item->db_id;
    252                         $output .= '<label class="menu-item-title"><input type="checkbox" id="'. esc_attr( $menu_id ) .'" name="'. esc_attr( $menu_item->title ) .'" value="'. esc_attr( $menu_item->url ) .'" />'. $menu_item->title .'</label>';
    253                        
    254                         // Menu item hidden fields
    255                         $output .= '<input type="hidden" class="menu-item-db-id" value="0" />';
    256                         $output .= '<input type="hidden" class="menu-item-object-id" value="'. esc_attr( $menu_item->object_id ) .'" />';
    257                         $output .= '<input type="hidden" class="menu-item-parent-id" value="'. esc_attr( $menu_item->parent_id ) .'" />';
    258                         $output .= '<input type="hidden" class="menu-item-type" value="'. esc_attr( $menu_item->type ) .'" />';
    259                         $output .= '<input type="hidden" class="menu-item-append" value="'. esc_attr( $menu_item->append ) .'" />';
    260                         $output .= '<input type="hidden" class="menu-item-title" value="'. esc_attr( $menu_item->title ) .'" />';
    261                         $output .= '<input type="hidden" class="menu-item-url" value="'. esc_attr( $menu_item->url ) .'" />';
    262                         $output .= '<input type="hidden" class="menu-item-append" value="'. esc_attr( $menu_item->append ) .'" />';
    263                         break;
    264211        }
    265212       
    266213        return $output;
  • wp-includes/taxonomy.php

     
    3939                                                                                                ) ) ;
    4040
    4141        register_taxonomy( 'nav_menu', 'nav_menu_item', array(  'hierarchical' => false,
     42                                                                                                                'label' => __('Navigation Menus'),
     43                                                                                                                'singular_label' => __('Navigation Menu'),
    4244                                                                                                                'query_var' => false,
    4345                                                                                                                'rewrite' => false,
    4446                                                                                                                'show_ui' => false,
  • wp-includes/post.php

     
    6363                                                                                        'query_var' => false,
    6464                                                                                ) );
    6565
    66         register_post_type( 'nav_menu_item', array(     'public' => false,
     66        register_post_type( 'nav_menu_item', array(     'label' => __('Navigation Menu Items'),
     67                                                                                                'singular_label' => __('Navigation Menu Item'),
     68                                                                                                'public' => false,
    6769                                                                                                'show_ui' => false,
    6870                                                                                                '_builtin' => true,
    6971                                                                                                'capability_type' => 'post',
  • wp-includes/version.php

     
    1515 *
    1616 * @global int $wp_db_version
    1717 */
    18 $wp_db_version = 13576;
     18$wp_db_version = 13578;
    1919
    2020/**
    2121 * Holds the TinyMCE version
  • wp-includes/classes.php

     
    934934                        else
    935935                                $children_elements[ $e->$parent_field ][] = $e;
    936936                }
    937 
     937               
    938938                /*
    939939                 * when none of the elements is top level
    940940                 * assume the first one must be root of the sub elements
     
    11241124}
    11251125
    11261126/**
     1127 * Create HTML list of nav menu items.
     1128 *
     1129 * @package WordPress
     1130 * @since 3.0.0
     1131 * @uses Walker
     1132 */
     1133class Walker_Nav_Menu extends Walker {
     1134        /**
     1135         * @see Walker::$tree_type
     1136         * @since 3.0.0
     1137         * @var string
     1138         */
     1139        var $tree_type = array( 'post_type', 'taxonomy', 'custom' );
     1140
     1141        /**
     1142         * @see Walker::$db_fields
     1143         * @since 3.0.0
     1144         * @todo Decouple this.
     1145         * @var array
     1146         */
     1147        var $db_fields = array( 'parent' => 'post_parent', 'id' => 'object_id' );
     1148
     1149        /**
     1150         * @see Walker::start_lvl()
     1151         * @since 3.0.0
     1152         *
     1153         * @param string $output Passed by reference. Used to append additional content.
     1154         * @param int $depth Depth of page. Used for padding.
     1155         */
     1156        function start_lvl(&$output, $depth) {
     1157                $indent = str_repeat("\t", $depth);
     1158                $output .= "\n$indent<ul class=\"sub-menu\">\n";
     1159        }
     1160
     1161        /**
     1162         * @see Walker::end_lvl()
     1163         * @since 3.0.0
     1164         *
     1165         * @param string $output Passed by reference. Used to append additional content.
     1166         * @param int $depth Depth of page. Used for padding.
     1167         */
     1168        function end_lvl(&$output, $depth) {
     1169                $indent = str_repeat("\t", $depth);
     1170                $output .= "$indent</ul>\n";
     1171        }
     1172
     1173        /**
     1174         * @see Walker::start_el()
     1175         * @since 3.0.0
     1176         *
     1177         * @param string $output Passed by reference. Used to append additional content.
     1178         * @param object $item Menu item data object.
     1179         * @param int $depth Depth of menu item. Used for padding.
     1180         * @param int $current_page Menu item ID.
     1181         * @param array $args
     1182         */
     1183        function start_el(&$output, $item, $depth, $args) {
     1184                $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
     1185               
     1186                if ( 'frontend' == $args->context ) {
     1187                        global $wp_query;
     1188                       
     1189                        $css_class = array( 'menu-item', 'menu-item-type-'. $item->type, $item->classes );
     1190                       
     1191                        if ( 'custom' != $item->object )
     1192                                $css_class[] = 'menu-item-object-'. $item->object;
     1193                       
     1194                        if ( $item->object_id == $wp_query->get_queried_object_id() )
     1195                                $css_class[] = 'current-menu-item';
     1196                       
     1197                        // @todo add classes for parent/child relationships
     1198
     1199                        $css_class = join( ' ', apply_filters('nav_menu_css_class', $css_class, $item) );
     1200                }
     1201                       
     1202                $maybe_value = ( 'backend' == $args->context ) ? ' value="'. $item->ID .'"' : '';
     1203                $maybe_classes = ( 'frontend' == $args->context ) ? ' class="'. $css_class .'"' : '';
     1204               
     1205                $output .= $indent . '<li id="menu-item-'. $item->ID .'"'. $maybe_value . $maybe_classes .'>' . wp_get_nav_menu_item( $item, $args->context, $args );
     1206        }
     1207
     1208        /**
     1209         * @see Walker::end_el()
     1210         * @since 3.0.0
     1211         *
     1212         * @param string $output Passed by reference. Used to append additional content.
     1213         * @param object $item Page data object. Not used.
     1214         * @param int $depth Depth of page. Not Used.
     1215         */
     1216        function end_el(&$output, $item, $depth) {
     1217                $output .= "</li>\n";
     1218        }
     1219
     1220}
     1221
     1222/**
    11271223 * Create HTML list of pages.
    11281224 *
    11291225 * @package WordPress
  • wp-includes/script-loader.php

     
    397397                ) );
    398398
    399399                // Custom Navigation
    400                 $scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", false, '20100317b' );
     400                $scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", false, '20100321' );
    401401                $scripts->localize( 'nav-menu', 'navMenuL10n', array(
    402402                        'custom' => _x('Custom', 'menu nav item type'),
    403                         'page' => _x('Page', 'menu nav item type'),
    404                         'category' => _x('Category', 'menu nav item type'),
    405403                        'thickbox' => _x('Edit Menu Item', 'Thickbox Title'),
    406404                        'edit' => _x('Edit', 'menu item edit text'),
    407405                        'warnDelete' => __( "You are about to permanently delete this menu. \n 'Cancel' to stop, 'OK' to delete." ),
     
    410408                $scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array('farbtastic'), '20100321' );
    411409                $scripts->add_data( 'custom-background', 'group', 1 );
    412410                // See wp_just_in_time_script_localization() for translation data for this object
    413 
    414411        }
    415412}
    416413
  • wp-includes/nav-menu.php

     
    88 */
    99
    1010/**
    11  * Returns a Navigation Menu object
     11 * Returns a navigation menu object.
    1212 *
    1313 * @since 3.0.0
    1414 *
    1515 * @param string $menu Menu id
    16  * @return mixed $menu|false
     16 * @return mixed $menu|false Or WP_Error
    1717 */
    1818function wp_get_nav_menu_object( $menu ) {
    1919        return is_nav_menu( $menu );
    2020}
    2121
    2222/**
    23  * Check if Menu exists.
     23 * Check if navigation menu exists.
    2424 *
    2525 * Returns the menu object, or false if the term doesn't exist.
    2626 *
    2727 * @since 3.0.0
    2828 *
    2929 * @param int|string $menu The menu to check
    30  * @return mixed Menu Object, if exists.
     30 * @return mixed Menu Object, if it exists. Else, false or WP_Error
    3131 */
    3232function is_nav_menu( $menu ) {
    3333        if ( !$menu )
     
    4949}
    5050
    5151/**
    52  * Creates a navigation menu.
     52 * Create a Navigation Menu.
    5353 *
    5454 * Optional args:
    5555 * slug - the url friendly version of the nav menu.
     
    5858 *
    5959 * @param string $menu_name Menu Name
    6060 * @param string $args Optional.
    61  * @return mixed Menu object|WP_Error
     61 * @return mixed Menu object on sucess|WP_Error on failure
    6262 */
    6363function wp_create_nav_menu( $menu_name, $args = array() ) {
    6464        $menu_exists = get_term_by( 'name', $menu_name, 'nav_menu' );
    6565
    6666        if ( $menu_exists )
    67                 return new WP_Error( 'menu_exists', sprintf( __('A menu named &#8220;%s&#8221; already exists; please try another name.'), esc_html( $menu_exists->name ) ) );
     67                return new WP_Error( 'menu_exists', sprintf( __('A menu named <strong>%s</strong> already exists; please try another name.'), esc_html( $menu_exists->name ) ) );
    6868
    6969        if ( isset($args['slug']) )
    7070                $slug = $args['slug'];
     
    7676        if ( is_wp_error($menu) )
    7777                return $menu;
    7878
    79         return get_term( $menu['term_id'], 'nav_menu') ;
     79        $result = get_term( $menu['term_id'], 'nav_menu' );
     80       
     81        if ( $result && !is_wp_error($result) ) {
     82                do_action( 'wp_create_nav_menu', $menu['term_id'] );
     83                return $result;
     84        } else {
     85                return $result;
     86        }
    8087}
    8188
    8289/**
    83  * Deletes a navigation menu.
     90 * Delete a Navigation Menu.
    8491 *
    8592 * @since 3.0.0
    8693 *
    8794 * @param string $menu name|id|slug
    88  * @return bool true on success, else false.
     95 * @return mixed Menu object on sucess|WP_Error on failure
    8996 */
    9097function wp_delete_nav_menu( $menu ) {
    9198        $menu = wp_get_nav_menu_object( $menu );
     
    98105                        wp_delete_post( $item );
    99106                }
    100107        }
    101         wp_delete_term( $menu->term_id, 'nav_menu' );
     108       
     109        $result = wp_delete_term( $menu->term_id, 'nav_menu' );
     110       
     111        if ( $result && !is_wp_error($result) ) {
     112                do_action( 'wp_delete_nav_menu', $menu->term_id );
     113                return $result;
     114        } else {
     115                return $result;
     116        }
    102117}
    103118
    104119/**
    105  * Returns all Navigation Menu objects.
     120 * Returns all navigation menu objects.
    106121 *
    107122 * @since 3.0.0
    108123 *
     
    153168}
    154169
    155170/**
    156  * Adds all the nav menu properties to the $menu_item.
     171 * Retrieve the HTML list content for nav menu items.
    157172 *
     173 * @uses Walker_Nav_Menu to create HTML list content.
     174 * @since 2.1.0
     175 * @see Walker::walk() for parameters and return description.
     176 */
     177function walk_nav_menu_tree( $items, $depth, $r ) {
     178        $walker = ( empty($r->walker) ) ? new Walker_Nav_Menu : $r->walker;
     179        $args = array( $items, $depth, $r );
     180       
     181        return call_user_func_array(array(&$walker, 'walk'), $args);
     182}
     183
     184/**
     185 * Adds all the navigation menu properties to the menu item.
     186 *
    158187 * @since 3.0.0
    159188 *
    160189 * @param string $menu_item The menu item to modify
    161  * @param string $menu_item_type The menu item type (template, custom, post_type, taxonomy).
     190 * @param string $menu_item_type The menu item type (frontend, custom, post_type, taxonomy).
    162191 * @param string $menu_item_object Optional. The menu item object type (post type or taxonomy).
    163  * @return object $menu_item The modtified menu item.
     192 * @return object $menu_item The modified menu item.
    164193 */
    165194function wp_setup_nav_menu_item( $menu_item, $menu_item_type = null, $menu_item_object = '' ) {
    166         global $wp_query;
    167 
    168195        switch ( $menu_item_type ) {
    169196                case 'frontend':
    170197                        $menu_item->db_id = (int) $menu_item->ID;
    171                         $menu_item->object_id = get_post_meta( $menu_item->ID, 'menu_item_object_id', true );
    172                         $menu_item->parent_id = (int) $menu_item->post_parent;
    173                         $menu_item->type = get_post_meta( $menu_item->ID, 'menu_item_type', true );
    174 
    175                         $menu_item->append = get_post_meta( $menu_item->ID, 'menu_item_append', true );
    176 
     198                        $menu_item->object_id = get_post_meta( $menu_item->ID, '_menu_item_object_id', true );
     199                        $menu_item->object = get_post_meta( $menu_item->ID, '_menu_item_object', true );
     200                        $menu_item->type = get_post_meta( $menu_item->ID, '_menu_item_type', true );
     201                       
     202                        if ( 'post_type' == $menu_item->type ) {
     203                                $object = get_post_type_object( $menu_item->object );
     204                                $menu_item->append = $object->singular_label;
     205                               
     206                        } elseif ( 'taxonomy' == $menu_item->type ) {
     207                                $object = get_taxonomy( $menu_item->object );
     208                                $menu_item->append = $object->singular_label;
     209                               
     210                        } else {
     211                                $menu_item->append = __('Custom');
     212                        }
     213                       
    177214                        $menu_item->title = $menu_item->post_title;
    178                         $menu_item->url = get_post_meta( $menu_item->ID, 'menu_item_url', true );
    179                         $menu_item->target = get_post_meta( $menu_item->ID, 'menu_item_target', true );
     215                        $menu_item->url = get_post_meta( $menu_item->ID, '_menu_item_url', true );
     216                        $menu_item->target = get_post_meta( $menu_item->ID, '_menu_item_target', true );
    180217
    181218                        $menu_item->attr_title = strip_tags( $menu_item->post_excerpt );
    182219                        $menu_item->description = strip_tags( $menu_item->post_content );
    183220
    184                         $menu_item->classes = get_post_meta( $menu_item->ID, 'menu_item_classes', true );;
    185                         $menu_item->xfn = get_post_meta( $menu_item->ID, 'menu_item_xfn', true );
    186                         $menu_item->li_class = ( $menu_item->object_id == $wp_query->get_queried_object_id() ) ? ' current_page_item' : '';
     221                        $menu_item->classes = get_post_meta( $menu_item->ID, '_menu_item_classes', true );;
     222                        $menu_item->xfn = get_post_meta( $menu_item->ID, '_menu_item_xfn', true );
    187223                        break;
    188224
    189225                case 'custom':
    190                         $menu_item->db_id = (int) $menu_item->ID;
     226                        $menu_item->db_id = 0;
    191227                        $menu_item->object_id = (int) $menu_item->ID;
    192                         $menu_item->parent_id = (int) $menu_item->post_parent;
    193                         $menu_item->type = 'custom'; //$menu_item_type
    194                         $menu_item->append = 'custom';
     228                        $menu_item->object = 'custom';
     229                        $menu_item->type = 'custom';
     230                        $menu_item->append = __('custom');
    195231
    196232                        $menu_item->attr_title = strip_tags( $menu_item->post_excerpt );
    197233                        $menu_item->description = strip_tags( $menu_item->post_content );
    198234
    199235                        $menu_item->title = $menu_item->post_title;
    200                         $menu_item->url = get_post_meta( $menu_item->ID, 'menu_item_url', true );
    201                         $menu_item->target = get_post_meta( $menu_item->ID, 'menu_item_target', true );
     236                        $menu_item->url = get_post_meta( $menu_item->ID, '_menu_item_url', true );
     237                        $menu_item->target = get_post_meta( $menu_item->ID, '_menu_item_target', true );
     238                        $menu_item->classes = '';
     239                        $menu_item->xfn = '';
    202240                        break;
    203241
    204242                case 'post_type':
    205243                        $menu_item->db_id = 0;
    206244                        $menu_item->object_id = (int) $menu_item->ID;
    207                         $menu_item->parent_id = (int) $menu_item->post_parent;
    208245                        $menu_item->type = $menu_item_type;
    209246
    210247                        $object = get_post_type_object( $menu_item_object );
    211                         $menu_item->append = $object->name;
     248                        $menu_item->object = $object->name;
     249                        $menu_item->append = strtolower( $object->singular_label );
    212250
    213251                        $menu_item->title = $menu_item->post_title;
    214252                        $menu_item->url = get_permalink( $menu_item->ID );
     
    216254
    217255                        $menu_item->attr_title = '';
    218256                        $menu_item->description = strip_tags( $menu_item->post_content );
     257                        $menu_item->classes = '';
     258                        $menu_item->xfn = '';
    219259                        break;
    220260
    221261                case 'taxonomy':
    222262                        $menu_item->ID = $menu_item->term_id;
    223263                        $menu_item->db_id = 0;
    224264                        $menu_item->object_id = (int) $menu_item->term_id;
    225                         $menu_item->parent_id = (int) $menu_item->parent;
     265                        $menu_item->post_parent = (int) $menu_item->parent;
    226266                        $menu_item->type = $menu_item_type;
    227267
    228268                        $object = get_taxonomy( $menu_item_object );
    229                         $menu_item->append = $object->name;
     269                        $menu_item->object = $object->name;
     270                        $menu_item->append = strtolower( $object->singular_label );
    230271
    231272                        $menu_item->title = $menu_item->name;
    232273                        $menu_item->url = get_term_link( $menu_item, $menu_item_object );
    233274                        $menu_item->target = '_self';
    234275                        $menu_item->attr_title = '';
    235276                        $menu_item->description = strip_tags( $menu_item->description );
     277                        $menu_item->classes = '';
     278                        $menu_item->xfn = '';
    236279                        break;
    237         }
    238 
    239         $menu_item->classes = get_post_meta( $menu_item->ID, 'menu_item_classes', true );
    240         $menu_item->xfn = get_post_meta( $menu_item->ID, 'menu_item_xfn', true );
    241 
     280        }       
    242281        return $menu_item;
    243282}
    244283?>
     284 No newline at end of file
  • wp-admin/admin-ajax.php

     
    10041004                update_user_option($user->ID, "closedpostboxes_$page", $closed);
    10051005
    10061006        if ( is_array($hidden) ) {
    1007                 $hidden = array_diff( $hidden, array('submitdiv', 'linksubmitdiv') ); // postboxes that are always shown
     1007                $hidden = array_diff( $hidden, array('submitdiv', 'linksubmitdiv', 'manage-menu', 'create-menu') ); // postboxes that are always shown
    10081008                update_user_option($user->ID, "meta-box-hidden_$page", $hidden);
    10091009        }
    10101010
     
    13951395                }
    13961396        }
    13971397        die( '0' );
     1398case 'save-custom-link':       
     1399        if ( ! current_user_can('manage_links') )
     1400                die('-1');
     1401       
     1402        $link_name = isset( $_POST['link_name'] ) ? esc_html($_POST['link_name']) : null;
     1403        $link_url = isset( $_POST['link_url'] ) ? esc_url_raw($_POST['link_url']) : null;
     1404       
     1405        if ( !$link_name || !$link_url )
     1406                die('-1');
     1407       
     1408        $post = array(
     1409                'post_status' => 'draft', 'post_type' => 'nav_menu_item', 'ping_status' => 0,
     1410                'post_author' => $user_ID, 'post_title' => $link_name, 'post_excerpt' => '',
     1411                'post_parent' => 0, 'menu_order' => 0, 'post_content' => '',
     1412        );
     1413       
     1414        $link_id = wp_insert_post( $post );
     1415       
     1416        update_post_meta( $link_id, '_menu_item_type', 'custom' );
     1417        update_post_meta( $link_id, '_menu_item_object_id', (int) $link_id );
     1418        update_post_meta( $link_id, '_menu_item_object', 'custom' );
     1419        update_post_meta( $link_id, '_menu_item_target', '_self' );
     1420        update_post_meta( $link_id, '_menu_item_classes', '' );
     1421        update_post_meta( $link_id, '_menu_item_xfn', '' );
     1422        update_post_meta( $link_id, '_menu_item_url', $link_url );
     1423       
     1424        die( json_encode($link_id) );
    13981425default :
    13991426        do_action( 'wp_ajax_' . $_POST['action'] );
    14001427        die('0');
  • wp-admin/includes/upgrade.php

     
    11051105 * @since 3.0.0
    11061106 */
    11071107function upgrade_300() {
    1108         global $wp_current_db_version;
     1108        global $wp_current_db_version, $wpdb;
    11091109
    11101110        if ( $wp_current_db_version < 12751 ) {
    11111111                populate_roles_300();
    11121112                if ( is_multisite() && is_main_site() && ! defined( 'MULTISITE' ) && get_site_option( 'siteurl' ) === false )
    11131113                        add_site_option( 'siteurl', '' );
    11141114        }
     1115       
     1116        if ( $wp_current_db_version < 13577 ) {
     1117                // remove old nav menu post meta keys
     1118                $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key IN( 'menu_type', 'object_id', 'menu_new_window', 'menu_link', '_menu_item_append', 'menu_item_append' )" ) );
     1119               
     1120                // update nav menu post meta keys to underscore prefixes
     1121                $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_key = '_menu_item_type' WHERE meta_key = 'menu_item_type'" ) );
     1122                $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_key = '_menu_item_object_id' WHERE meta_key = 'menu_item_object_id'" ) );
     1123                $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_key = '_menu_item_target' WHERE meta_key = 'menu_item_target'" ) );
     1124                $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_key = '_menu_item_classes' WHERE meta_key = 'menu_item_classes'" ) );
     1125                $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_key = '_menu_item_xfn' WHERE meta_key = 'menu_item_xfn'" ) );
     1126                $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_key = '_menu_item_url' WHERE meta_key = 'menu_item_url'" ) );
     1127        }
    11151128}
    11161129
    11171130/**
  • wp-admin/includes/nav-menu.php

     
    11<?php
     2/**
     3 * Register nav menu metaboxes
     4 *
     5 * @since 3.0.0
     6 **/
     7function wp_nav_menu_metaboxes_setup() {
     8        add_meta_box( 'add-custom-links', __('Add Custom Links'), 'wp_nav_menu_item_link_metabox', 'nav-menus', 'side', 'default' );
     9        wp_nav_menu_post_type_metaboxes();
     10        wp_nav_menu_taxonomy_metaboxes();
     11}
    212
    3 /* Register Metaboxes */
    4 add_meta_box( 'create-menu', __('Create Menu'), 'wp_nav_menu_create_metabox', 'menus', 'side', 'core' );
    5 add_meta_box( 'add-custom-links', __('Add Custom Links'), 'wp_nav_menu_item_link_metabox', 'menus', 'side', 'default' );
    6 wp_nav_menu_post_type_metaboxes();
    7 wp_nav_menu_taxonomy_metaboxes();
     13/**
     14 * Limit the amount of meta boxes to just links, pages and cats for first time users.
     15 *
     16 * @since 3.0.0
     17 **/
     18function wp_initial_nav_menu_meta_boxes() {
     19        global $wp_meta_boxes;
     20       
     21        if ( !get_user_option( 'meta-box-hidden_nav-menus' ) && is_array($wp_meta_boxes) ) {
     22               
     23                $initial_meta_boxes = array( 'manage-menu', 'create-menu', 'add-custom-links', 'add-page', 'add-category' );
     24                $hidden_meta_boxes = array();
     25               
     26                foreach ( array_keys($wp_meta_boxes['nav-menus']) as $context ) {
     27                        foreach ( array_keys($wp_meta_boxes['nav-menus'][$context]) as $priority ) {
     28                                foreach ( $wp_meta_boxes['nav-menus'][$context][$priority] as $box ) {
     29                                        if ( in_array( $box['id'], $initial_meta_boxes ) ) {
     30                                                unset( $box['id'] );
     31                                        } else {
     32                                                $hidden_meta_boxes[] = $box['id'];
     33                                        }
     34                                }
     35                        }
     36                }
     37                $user = wp_get_current_user();
     38                update_user_meta( $user->ID, 'meta-box-hidden_nav-menus', $hidden_meta_boxes );
     39               
     40                // returns all the hidden metaboxes to the js function: wpNavMenu.initial_meta_boxes()
     41                return join( ',', $hidden_meta_boxes );
     42        }
     43}
    844
    945/**
    1046 * Creates metaboxes for any post type menu item.
     
    1551        $post_types = get_post_types( array( 'public' => true ), 'object' );
    1652
    1753        if ( !$post_types )
    18                 return false;
     54                return;
    1955
    20         $allowed_types = apply_filters('post_types_allowed_in_menus', array('page'));
    2156        foreach ( $post_types as $post_type ) {
    22                 if ( !in_array($post_type->name, $allowed_types) )
    23                         continue;
    2457                $id = $post_type->name;
    25 
    26                 add_meta_box( "add-{$id}", sprintf( __('Add an Existing %s'), $post_type->singular_label ), 'wp_nav_menu_item_post_type_metabox', 'menus', 'side', 'default', $post_type );
     58                add_meta_box( "add-{$id}", sprintf( __('Add an Existing %s'), $post_type->singular_label ), 'wp_nav_menu_item_post_type_metabox', 'nav-menus', 'side', 'default', $post_type );
    2759        }
    2860}
    2961
     
    3668        $taxonomies = get_taxonomies( array( 'show_ui' => true ), 'object' );
    3769
    3870        if ( !$taxonomies )
    39                 return false;
     71                return;
    4072
    41         $allowed_types = apply_filters('taxonomies_allowed_in_menus', array('category'));
    4273        foreach ( $taxonomies as $tax ) {
    43                 if ( !in_array($tax->name, $allowed_types) )
    44                         continue;
    4574                $id = $tax->name;
    4675
    47                 add_meta_box( "add-{$id}", sprintf( __('Add an Existing %s'), $tax->singular_label ), 'wp_nav_menu_item_taxonomy_metabox', 'menus', 'side', 'default', $tax );
     76                add_meta_box( "add-{$id}", sprintf( __('Add an Existing %s'), $tax->singular_label ), 'wp_nav_menu_item_taxonomy_metabox', 'nav-menus', 'side', 'default', $tax );
    4877        }
    4978}
    5079
     
    98127 * @since 3.0.0
    99128 */
    100129function wp_nav_menu_item_link_metabox() {
    101         $args = array( 'post_status' => 'any', 'post_type' => 'nav_menu_item', 'meta_value' => 'custom', 'showposts' => -1 );
     130        // @note: hacky query, see #12660
     131        $args = array( 'post_type' => 'nav_menu_item', 'post_status' => 'any', 'meta_key' => '_menu_item_type', 'numberposts' => -1, 'orderby' => 'title', );
    102132
    103133        // @todo transient caching of these results with proper invalidation on updating links
    104         $query = new WP_Query( $args );
    105 
     134        $links = get_posts( $args );
    106135        ?>
    107136        <p id="menu-item-url-wrap">
    108137                <label class="howto" for="menu-item-url">
     
    110139                        <input id="custom-menu-item-url" name="custom-menu-item-url" type="text" class="code menu-item-textbox" value="http://" />
    111140                </label>
    112141        </p>
    113         <br class="clear" />
    114142        <p id="menu-item-name-wrap">
    115143                <label class="howto" for="custom-menu-item-name">
    116144                        <span><?php _e('Text'); ?></span>
     
    119147        </p>
    120148
    121149        <p class="button-controls">
    122                 <a class="show-all"><?php _e('View All'); ?></a>
    123                 <a class="hide-all"><?php _e('Hide All'); ?></a>
     150                <span class="lists-controls">
     151                        <a class="show-all"><?php _e('View All'); ?></a>
     152                        <a class="hide-all"><?php _e('Hide All'); ?></a>
     153                </span>
     154               
     155                <span class="add-to-menu">
     156                        <a class="button"><?php _e('Add to Menu'); ?></a>
     157                </span>
    124158        </p>
    125159        <div id="available-links" class="list-wrap">
    126160                <div class="list-container">
    127161                        <ul class="list">
    128                                 <?php echo wp_nav_menu_get_items( $query->posts, 'custom' ); ?>
     162                                <?php echo wp_nav_menu_get_items( $links, 'custom', 'custom' ); ?>
    129163                        </ul>
    130164                </div><!-- /.list-container-->
    131165        </div><!-- /#available-links-->
    132         <p class="add-to-menu">
    133                 <a class="button"><?php _e('Add to Menu'); ?></a>
    134         </p>
    135166        <div class="clear"></div>
    136167        <?php
    137168}
     
    145176 * @param string $post_type The post type object.
    146177 */
    147178function wp_nav_menu_item_post_type_metabox( $object, $post_type ) {
    148         $args = array( 'post_type' => $post_type['args']->name, 'post_status' => 'publish', 'showposts' => -1 );
     179        $args = array( 'post_type' => $post_type['args']->name, 'numberposts' => -1, 'orderby' => 'title', );
    149180
    150         if ( 'attachment' == $post_type['args']->name )
    151                 $args['post_status'] = 'any';
    152 
    153181        // @todo transient caching of these results with proper invalidation on updating of a post of this type
    154         $query = new WP_Query( $args );
     182        $posts = get_posts( $args );
    155183
    156         if ( !$query->posts )
     184        if ( !$posts )
    157185                $error = '<li id="error">'. sprintf( __( 'No %s exists' ), $post_type['args']->label ) .'</li>';
    158186
    159187        $pt_names = '';
    160         if ( is_array($query->posts) ) {
    161                 foreach ( $query->posts as $post ) {
     188        if ( is_array($posts) ) {
     189                foreach ( $posts as $post ) {
    162190                        if ( $post->post_title ) {
    163191                                $pt_names .= htmlentities( $post->post_title ) .'|';
    164                         } else {
    165                                 $pt_names = sprintf( __('No %s exists'), $post_type['args']->label );
    166192                        }
    167193                }
    168194        }
     
    175201        </p>
    176202
    177203        <p class="button-controls">
    178                 <a class="show-all"><?php _e('View All'); ?></a>
    179                 <a class="hide-all"><?php _e('Hide All'); ?></a>
     204                <span class="lists-controls">
     205                        <a class="show-all"><?php _e('View All'); ?></a>
     206                        <a class="hide-all"><?php _e('Hide All'); ?></a>
     207                </span>
     208               
     209                <span class="add-to-menu">
     210                        <a class="button"><?php _e('Add to Menu'); ?></a>
     211                </span>
    180212        </p>
    181213
    182214        <div id="existing-<?php echo esc_attr( $id ); ?>" class="list-wrap">
    183215                <div class="list-container">
    184216                        <ul class="list">
    185                                 <?php echo isset( $error ) ? $error : wp_nav_menu_get_items( $query->posts, 'post_type', $id ); ?>
     217                                <?php echo isset( $error ) ? $error : wp_nav_menu_get_items( $posts, 'post_type', $id ); ?>
    186218                        </ul>
    187219                </div><!-- /.list-container-->
    188220        </div><!-- /#existing-categories-->
    189         <p class="add-to-menu">
    190                 <a class="button-secondary"><?php _e('Add to Menu'); ?></a>
    191         </p>
    192221        <input type="hidden" class="autocomplete" name="autocomplete-<?php echo esc_attr( $id ); ?>-names" value="<?php echo esc_js( $pt_names ); ?>" />
    193222        <br class="clear" />
    194223        <script type="text/javascript" charset="utf-8">
    195224                // <![CDATA[
    196225                jQuery(document).ready(function(){
    197                         wp_nav_menu_autocomplete('<?php echo esc_attr($id); ?>');
     226                        wpNavMenu.autocomplete('<?php echo esc_attr($id); ?>');
    198227                });
    199228                // ]]>
    200229        </script>
     
    227256                foreach ( $terms as $term ) {
    228257                        if ( $term->name ) {
    229258                                $term_names .= htmlentities( $term->name ) .'|';
    230                         } else {
    231                                 $term_names = sprintf( __('No %s exists'), $taxonomy['args']->label );
    232259                        }
    233260                }
    234261        }
     
    241268        </p>
    242269
    243270        <p class="button-controls">
    244                 <a class="show-all"><?php _e('View All'); ?></a>
    245                 <a class="hide-all"><?php _e('Hide All'); ?></a>
     271                <span class="lists-controls">
     272                        <a class="show-all"><?php _e('View All'); ?></a>
     273                        <a class="hide-all"><?php _e('Hide All'); ?></a>
     274                </span>
     275               
     276                <span class="add-to-menu">
     277                        <a class="button"><?php _e('Add to Menu'); ?></a>
     278                </span>
    246279        </p>
    247280
    248281        <div id="existing-<?php echo esc_attr( $id ); ?>" class="list-wrap">
     
    252285                        </ul>
    253286                </div><!-- /.list-container-->
    254287        </div><!-- /#existing-categories-->
    255         <p class="add-to-menu">
    256                 <a class="button-secondary"><?php _e('Add to Menu'); ?></a>
    257         </p>
    258288        <input type="hidden" class="autocomplete" name="autocomplete-<?php echo esc_attr($id); ?>-names" value="<?php echo esc_js( $term_names ); ?>" />
    259289        <br class="clear" />
    260290        <script type="text/javascript" charset="utf-8">
    261291                // <![CDATA[
    262292                jQuery(document).ready(function(){
    263                         wp_nav_menu_autocomplete('<?php echo esc_attr($id); ?>');
     293                        wpNavMenu.autocomplete('<?php echo esc_attr($id); ?>');
    264294                });
    265295                // ]]>
    266296        </script>
     
    290320                if ( !isset($menu_item->post_parent) )
    291321                        $menu_item->post_parent = $menu_item->parent;
    292322
    293                 // Cleanest way to get all attachements
    294                 if ( 'attachment' == $object )
     323                // Get all attachements and links
     324                if ( in_array($object, array( 'attachment', 'custom' )) )
    295325                        $menu_item->post_parent = 0;
    296326
    297327                if ( 0 == $menu_item->post_parent ) {
    298328                        // Set up the menu item
    299329                        $menu_item = wp_setup_nav_menu_item( $menu_item, $object_type, $object );
     330                       
     331                        // No blank titles
     332                        if ( empty($menu_item->title) )
     333                                continue;
     334                       
    300335                        $attributes = ( 'backend' == $context ) ? ' id="menu-item-'. $i .'" value="'. $i .'"' : '';
    301 
     336                       
    302337                        $output .= '<li'. $attributes .'>';
    303338                        $output .= wp_get_nav_menu_item( $menu_item, $object_type, $object );
    304339                        $output .= wp_get_nav_menu_sub_items( $menu_item->ID, $object_type, $object, $context );
  • wp-admin/js/nav-menu.dev.js

     
    11/**
    2  * WordPress Administration Custom Navigation
     2 * WordPress Administration Navigation Menu
    33 * Interface JS functions
    44 *
    5  * @version 1.1.0
     5 * @version 2.0.0
    66 *
    77 * @package WordPress
    88 * @subpackage Administration
    99 */
    1010
    11 function wp_nav_menu_autocomplete( id ) {
    12         jQuery('#add-'+ id +' .quick-search').autocomplete(jQuery( '#add-'+ id +' .autocomplete' ).val().split('|'));
     11var wpNavMenu;
    1312
    14         jQuery('#add-'+ id +' .quick-search').result(function(event, data, formatted) {
    15                 jQuery('#add-'+ id +' .list-wrap').css( 'display', 'block' );
    16                 jQuery("#add-"+ id +" .list-wrap li:contains('" + data + "')").css( 'display', 'block' );
    17                 jQuery('#add-'+ id +' .show-all').hide();
    18                 jQuery('#add-'+ id +' .hide-all').show();
    19         });
    20 }
     13(function($) {
     14       
     15        wpNavMenu = {
     16               
     17                // Functions that run on init.
     18                init : function() {
     19                       
     20                        wpNavMenu.initial_meta_boxes();
     21                       
     22                        wpNavMenu.drag_and_drop();
     23                       
     24                        // Delete AYS
     25                        $('#update-nav-menu .deletion').click(function(){
     26                                if ( confirm( navMenuL10n.warnDelete ) ) {
     27                                        return true;
     28                                } else {
     29                                        return false;
     30                                };
     31                        });
    2132
    22 /**
    23  * Populate the thickbox window with the selected menu items
    24  *
    25  * @param int id - the id of the menu li to edit.
    26  */
    27 function wp_edit_menu_item( id ) {
    28         var item_type = jQuery('#menu-item-type' + id).val();
    29         var item_title = jQuery('#menu-item-title' + id).val();
    30         var item_link = jQuery('#menu-item-url' + id).val();
    31         var item_attr_title = jQuery('#menu-item-attr-title' + id).val();
    32         var item_target = jQuery('#menu-item-target' + id).val();
    33         var item_description = jQuery('#menu-item-description' + id).val();
    34         var item_classes = jQuery('#menu-item-classes' + id).val();
    35         var item_xfn = jQuery('#menu-item-xfn' + id).val();
     33                        // Handle Save Button Clicks
     34                        $('#update-nav-menu').submit(function(){
     35                                wpNavMenu.update_post_data();
     36                        });
    3637
    37         // Only allow custom links to be editable.
    38         if ( 'custom' != item_type )
    39                 jQuery( '#edit-menu-item-url' ).attr('disabled', 'disabled' );
     38                        // Handle some return keypresses
     39                        $('#create-menu-name').keypress(function(e){
     40                                if ( 13 == e.keyCode ) {
     41                                        $('#create-menu-button').click();
     42                                        return false;
     43                                }
     44                        });
    4045
    41         // Populate the fields for thickbox
    42         jQuery( '#edit-menu-item-id' ).val(id);
    43         jQuery( '#edit-menu-item-title' ).val(item_title);
    44         jQuery( '#edit-menu-item-url' ).val(item_link);
    45         jQuery( '#edit-menu-item-attr-title' ).val(item_attr_title);
    46         jQuery( '#edit-menu-item-target' ).val(item_target);
    47         jQuery( "#edit-menu-item-target option[value='" + item_target  + "']" ).attr('selected', 'selected');
    48         jQuery( '#edit-menu-item-description' ).val(item_description);
    49         jQuery( '#edit-menu-item-classes' ).val(item_classes);
    50         jQuery( '#edit-menu-item-xfn' ).val(item_xfn);
     46                        $('#custom-menu-item-url, #custom-menu-item-name').keypress(function(e){
     47                                if ( 13 == e.keyCode ) {
     48                                        $('#add-custom-links a.button').click();
     49                                        return false;
     50                                }
     51                        }).focus(function(){
     52                                if ( $(this).val() == $(this).attr('defaultValue') && $(this).attr('id') != 'custom-menu-item-url' ) {
     53                                        $(this).val('');
     54                                }
     55                        }).blur(function(){
     56                                if ( $(this).val() == '' ) {
     57                                        $(this).val($(this).attr('defaultValue'));
     58                                }
     59                        });
    5160
    52         // focus
    53         jQuery( '#edit-menu-item-title' ).focus();
    54 };
     61                        $('#create-menu-name').focus(function(){
     62                                if ( $(this).val() == $(this).attr('defaultValue') ) {
     63                                        $(this).val('');
     64                                }
     65                        }).blur(function(){
     66                                if ( $(this).val() == '' ) {
     67                                        $(this).val($(this).attr('defaultValue'));
     68                                }
     69                        });
    5570
    56 /**
    57  * Update the values for the menu item being editing
    58  */
    59 function wp_update_menu_item() {
    60         var id = jQuery('#edit-menu-item-id').val();
    61         var item_title = jQuery('#edit-menu-item-title').val();
    62         var item_link = jQuery('#edit-menu-item-url').val();
    63         var item_attr_title = jQuery('#edit-menu-item-attr-title').val();
    64         var item_target = jQuery('#edit-menu-item-target').val();
    65         var item_description = jQuery('#edit-menu-item-description').val();
    66         var item_classes = jQuery('#edit-menu-item-classes').val();
    67         var item_xfn = jQuery('#edit-menu-item-xfn').val();
     71                        // close postboxes that should be closed
     72                        $('.if-js-closed').removeClass('if-js-closed').addClass('closed');
    6873
    69         // update menu item settings
    70         jQuery('.menu #menu-item' + id).find('span.item-title').html(item_title);
    71         jQuery('.menu #menu-item-title' + id).val(item_title);
    72         jQuery('.menu #menu-item-url' + id).val(item_link);
    73         jQuery('.menu #menu-item-attr-title' + id).val(item_attr_title);
    74         jQuery('.menu #menu-item-target' + id).val(item_target);
    75         jQuery('.menu #menu-item-description' + id).val(item_description);
    76         jQuery('.menu #menu-item-classes' + id).val(item_classes);
    77         jQuery('.menu #menu-item-xfn' + id).val(item_xfn);
     74                        // postboxes setup
     75                        postboxes.add_postbox_toggles('nav-menus');
    7876
    79         jQuery('.menu #menu-item' + id + ' dt:first').animate( { backgroundColor: '#FFFF33' }, { duration: 'normal', complete: function() { jQuery(this).css( 'backgroundColor', '' ); }});
    80 }
     77                        // Clear the quick search textbox
     78                        $('.quick-search').click(function(){
     79                                $(this).attr( 'value', '' );
     80                        });
    8181
    82 /**
    83  * Removes a menu item from current menu
    84  *
    85  * @param int o - the id of the menu li to remove.
    86  */
    87 function wp_remove_menu_item( o ) {
    88         var todelete = document.getElementById('menu-item' + o);
     82                        // Quick Search submit
     83                        $('.quick-search-submit').click(function(){
     84                                $(this).siblings('.quick-search').search();
     85                        });
    8986
    90         if ( todelete ) {
    91                 // Give some feedback to the user
    92                 jQuery( todelete ).find('dt').each(function(){
    93                         jQuery(this).animate( { backgroundColor: '#FF3333' }, { duration: 'normal', complete: function() { jQuery(this).parent().parent().remove() } } );
    94                 });
    95         }
    96 };
     87                        // Edit menu item
     88                        $('#menu-container .item-edit').click(function(){
     89                                wpNavMenu.edit_menu_item( $(this).attr('value') );
     90                        });
    9791
    98 /**
    99  * Adds the item to the menu
    100  *
    101  * @param string item_db_id - The menu item's db id.
    102  * @param string item_object_id - The menu item's object id.
    103  * @param string item_type - The menu item's object type.
    104  * @param string item_append - The menu item's nice name.
    105  * @param string item_parent_id - The menu item's parent id.
    106  * @param string item_title - The menu item title.
    107  * @param string item_url - The menu item url
    108  * @param string item_description - The menu item description.
    109  * @param string item_attr_title - The title attribute.
    110  * @param string item_target - The target attribute.
    111  * @param string item_classes - Optional. Additional CSS classes for the menu item
    112  * @param string item_xfn - Optional. The rel attribute.
    113  */
    114 function wp_add_item_to_menu( item_db_id, item_object_id, item_type, item_append, item_parent_id, item_title, item_url, item_description, item_attr_title, item_target, item_classes, item_xfn ) {
    115         var randomnumber = wp_get_unique_menu_id();
    116         var hidden = wp_get_hidden_inputs( randomnumber, item_db_id, item_object_id, item_type, item_append, item_parent_id, item_title, item_url, item_description, item_attr_title, item_target, item_classes, item_xfn );
     92                        // Delete menu item
     93                        $('#menu-container .item-delete').click(function(){
     94                                wpNavMenu.remove_menu_item( $(this).attr('value') );
     95                        });
    11796
    118         // Adds the item in the queue
    119         jQuery('.menu').append('<li id="menu-item' + randomnumber + '" value="' + randomnumber + '"><div class="dropzone ui-droppable"></div><dl class="ui-droppable"><dt><span class="item-title">' + item_title + '</span><span class="item-controls"><span class="item-type">' + item_append + '</span><a class="item-edit thickbox" id="edit' + randomnumber + '" value="' + randomnumber +'" onClick="wp_edit_menu_item('+ randomnumber +')" title="' + navMenuL10n.thickbox + '" href="#TB_inline?height=540&width=300&inlineId=menu-item-settings">' + navMenuL10n.edit + '</a> | <a class="item-delete" id="delete' + randomnumber + '" value="' + randomnumber +'">Delete</a></span></dt></dl>' + hidden + '</li>');
     97                        // Update menu item settings (thickbox)
     98                        $('#update-menu-item').click(function(){
     99                                wpNavMenu.update_menu_item();
     100                                tb_remove();
     101                        });
    120102
    121         // Give some feedback to the user
    122         jQuery( '.menu #menu-item' + randomnumber + ' dt:first' ).animate( { backgroundColor: '#FFFF33' }, { duration: 'normal', complete: function() { jQuery(this).css( 'backgroundColor', '' ); }});
     103                        // Close thickbox
     104                        $('#cancel-save').click(function(){
     105                                tb_remove();
     106                        });
    123107
    124         // Enable drag-n-drop
    125         wp_drag_and_drop();
     108                        // Show All Button
     109                        $('.show-all').click(function(e){
     110                                $(e.currentTarget).parent().parent().siblings('.list-wrap').css( 'display', 'block' );
     111                                $(e.currentTarget).parent().parent().siblings('.list-wrap').find('li').css( 'display', 'block' );
     112                                $(e.currentTarget).hide();
     113                                $(e.currentTarget).siblings('.hide-all').show();
     114                        });
    126115
    127         // Reload thickbox
    128         tb_init('a.thickbox, area.thickbox, input.thickbox');
    129 };
     116                        // Hide All Button
     117                        $('.hide-all').click(function(e){
     118                                $(e.currentTarget).parent().parent().siblings('.list-wrap').css( 'display', 'none' );
     119                                $(e.currentTarget).parent().parent().siblings('.list-wrap').find('li').css( 'display', 'none' );
     120                                $(e.currentTarget).hide();
     121                                $(e.currentTarget).siblings('.show-all').show();
     122                        });
    130123
    131 /**
    132  * Grabs items from the queue and adds them to the menu.
    133  *
    134  * @param string button - a reference to the button that was clicked
    135  */
    136 function wp_add_checked_items_to_menu( button ) {
    137         // Grab checked items
    138         var items = jQuery(button).siblings('.list-wrap').find(':checked');
     124                        // Add menu items into the menu
     125                        $('.add-to-menu').click(function(e){
     126                                wpNavMenu.add_checked_items_to_menu(e.currentTarget);
     127                        });
    139128
    140         // If nothing was checked, cancel
    141         if ( 0 == items.length )
    142                 return false;
     129                        // Create a new link then add it to the menu
     130                        $('#add-custom-links .add-to-menu a').click(function(e){
     131                                // Add link to menu
     132                                if ( $('#custom-menu-item-url').val() == $('#custom-menu-item-url').attr('defaultValue') )
     133                                        return; // Do not allow "http://" submissions to go through
    143134
    144         // Loop through each item, grab it's hidden data and add it to the menu.
    145         jQuery(items).each(function(){
    146                 var item_type = jQuery(this).parent().siblings('.menu-item-type').val();
     135                                wpNavMenu.add_custom_link( $('#custom-menu-item-name').val(), $('#custom-menu-item-url').val() );
     136                               
     137                                // Reset the fields back to their defaults
     138                                $('#custom-menu-item-name').val($('#custom-menu-item-name').attr('defaultValue'));
     139                                $('#custom-menu-item-url' ).val($('#custom-menu-item-url' ).attr('defaultValue')).focus();
     140                        });
     141                },
     142               
     143                add_custom_link : function( link_name, link_url ) {
     144                        var params = {
     145                                action: 'save-custom-link',
     146                                link_name: link_name,
     147                                link_url: link_url
     148                        }
     149                       
     150                        $.post( ajaxurl, params, function(link_id) {
     151                                if ( '-1' == link_id )
     152                                        return;
    147153
    148                 if ( 'custom' == item_type ) {
    149                         var item_attr_title = jQuery(this).parent().siblings('.menu-item-attr-title').val();
    150                         var item_target = jQuery(this).parent().siblings('.menu-item-target').val();
    151                         var item_classes = jQuery(this).parent().siblings('.menu-item-classes').val();
    152                         var item_xfn = jQuery(this).parent().siblings('.menu-item-xfn').val();
    153                 } else {
    154                         var item_attr_title = '';
    155                         var item_target = '_self';
    156                         var item_classes = '';
    157                         var item_xfn = '';
    158                 };
     154                                wpNavMenu.add_to_menu( link_id, link_id, 'custom', 'custom', navMenuL10n.custom, 0, link_name, link_url, '', '', '_self', '', '' );
     155                        }, 'json');
     156                },
     157               
     158                /**
     159                 * In combination with the php function wp_initial_nav_menu_meta_boxes(),
     160                 * this function limits the metaboxes for first time users to just links, pages and cats.
     161                 */
     162                initial_meta_boxes : function() {
     163                        var hidden = $('#hidden-metaboxes').val().split( ',' );
    159164
    160                 var item_db_id = jQuery(this).parent().siblings('.menu-item-db-id').val();
    161                 var item_object_id = jQuery(this).parent().siblings('.menu-item-object-id').val();
    162                 var item_append = jQuery(this).parent().siblings('.menu-item-append').val();
    163                 var item_parent_id = jQuery(this).parent().siblings('.menu-item-parent-id').val();
    164                 var item_title = jQuery(this).parent().siblings('.menu-item-title').val();
    165                 var item_url = jQuery(this).parent().siblings('.menu-item-url').val();
    166                 var item_description = jQuery(this).parent().siblings('.menu-item-description').val();
     165                        if ( '' != hidden ) {
     166                                for ( var i = 0; i < hidden.length; i++ ) {
     167                                        $( '#' + hidden[i] ).attr( 'style', 'display: none;' );
     168                                        $( '#' + hidden[i] + '-hide' ).attr( 'checked', false );
     169                                };
     170                        };
     171                },
     172               
     173                // Makes the menu items drag and droppable.
     174                drag_and_drop : function() {
     175                        // Make sure all li's have dropzones
     176                        $('.menu li').each(function(){
     177                                if ( !$(this).children('.dropzone').attr('class') ) {
     178                                        $(this).prepend('<div class="dropzone"></div>');
     179                                };
     180                        });
    167181
    168                 if ( undefined == item_description ) {
    169                         item_description = '';
    170                 };
     182                        // make menu item draggable
     183                        $('.menu li').draggable({
     184                                handle: ' > dl',
     185                                opacity: .8,
     186                                addClasses: false,
     187                                helper: 'clone',
     188                                zIndex: 100
     189                        });
    171190
    172                 // Add the menu item to the menu
    173                 wp_add_item_to_menu( item_db_id, item_object_id, item_type, item_append, item_parent_id, item_title, item_url, item_description, item_attr_title, item_target, item_classes, item_xfn );
     191                        // make menu item droppable
     192                        $('.menu li dl, .menu li .dropzone').droppable({
     193                                accept: '.menu li',
     194                                tolerance: 'pointer',
     195                                drop: function(e, ui) {
     196                                        var li = $(this).parent();
     197                                        var child = !$(this).hasClass('dropzone');
    174198
    175                 // uncheck the menu item in the list
    176                 jQuery(this).attr( 'checked', false );
    177         });
    178 };
     199                                        // Append UL to first child
     200                                        if ( child && li.children('ul').length == 0 ) {
     201                                                li.append( '<ul class="sub-menu" />' );
     202                                        }
     203                                        // Make it draggable
     204                                        if ( child ) {
     205                                                li.children('ul').append( ui.draggable );
     206                                        } else {
     207                                                li.before( ui.draggable );
     208                                        }
    179209
    180 /**
    181  * Makes the menu items drag and droppable.
    182  */
    183 function wp_drag_and_drop() {
    184         // Make sure all li's have dropzones
    185         jQuery('.menu li').each(function(){
    186                 if ( !jQuery(this).children('.dropzone').attr('class') ) {
    187                         jQuery(this).prepend('<div class="dropzone"></div>');
    188                 };
    189         });
     210                                        li.find('dl,.dropzone').css({ backgroundColor: '', borderColor: '' });
    190211
    191         // make menu item draggable
    192         jQuery('.menu li').draggable({
    193                 handle: ' > dl',
    194                 opacity: .8,
    195                 addClasses: false,
    196                 helper: 'clone',
    197                 zIndex: 100
    198         });
     212                                        var draggablevalue = ui.draggable.attr('value');
     213                                        var droppablevalue = li.attr('value');
    199214
    200         // make menu item droppable
    201         jQuery('.menu li dl, .menu li .dropzone').droppable({
    202                 accept: '.menu li',
    203                 tolerance: 'pointer',
    204                 drop: function(e, ui) {
    205                         var li = jQuery(this).parent();
    206                         var child = !jQuery(this).hasClass('dropzone');
     215                                        li.find('#menu-' + draggablevalue).find('#parent' + draggablevalue).val(droppablevalue);
     216                                        $(this).parent().find('dt').removeAttr('style');
     217                                        $(this).parent().find('div:first').removeAttr('style');
    207218
    208                         // Append UL to first child
    209                         if ( child && li.children('ul').length == 0 ) {
    210                                 li.append( '<ul class="sub-menu" />' );
    211                         }
    212                         // Make it draggable
    213                         if ( child ) {
    214                                 li.children('ul').append( ui.draggable );
    215                         } else {
    216                                 li.before( ui.draggable );
    217                         }
    218 
    219                         li.find('dl,.dropzone').css({ backgroundColor: '', borderColor: '' });
    220 
    221                         var draggablevalue = ui.draggable.attr('value');
    222                         var droppablevalue = li.attr('value');
    223 
    224                         li.find('#menu-' + draggablevalue).find('#parent' + draggablevalue).val(droppablevalue);
    225                         jQuery(this).parent().find('dt').removeAttr('style');
    226                         jQuery(this).parent().find('div:first').removeAttr('style');
    227 
     219                                },
     220                                over: function(e) {
     221                                // Add child
     222                                        if ( $(this).attr('class') == 'dropzone ui-droppable' ) {
     223                                        $(this).parent().find('div:first').css({ background: '#f5f5f5', border: '1px dashed #bbb', margin: '10px 0px', height: '40px' });
     224                                }
     225                                        // Add above
     226                                else if ( $(this).attr('class') == 'ui-droppable' ) {
     227                                                $(this).parent().find('dt:first').css('background', '#d8d8d8');
     228                                } else {
     229                                                // Do nothing
     230                                }
     231                        },
     232                            out: function() {
     233                                $(this).parent().find('dt').removeAttr('style');
     234                                $(this).parent().find('div:first').removeAttr('style');
     235                                $(this).filter('.dropzone').css({ borderColor: '' });
     236                        }
     237                        });
    228238                },
    229                 over: function() {
    230                         // Add child
    231                         if ( jQuery(this).attr('class') == 'dropzone ui-droppable' ) {
    232                                 jQuery(this).parent().find('div:first').css('background', 'none').css('height', '50px');
    233                         }
    234                         // Add above
    235                         else if ( jQuery(this).attr('class') == 'ui-droppable' ) {
    236                                 jQuery(this).parent().find('dt:first').css('background', '#d8d8d8');
    237                         } else {
    238                                         // do nothing
    239                         }
    240                         var parentid = jQuery(this).parent().attr('id');
     239       
     240                // Prepares menu items for POST.
     241                update_post_data : function() {
     242                        var i = 0; // counter
    241243
    242                 },
    243                 out: function() {
    244                         jQuery(this).parent().find('dt').removeAttr('style');
    245                         jQuery(this).parent().find('div:first').removeAttr('style');
    246                         jQuery(this).filter('.dropzone').css({ borderColor: '' });
    247                 }
    248                 }
    249         );
    250 }
     244                        $('.menu li').each(function(){
     245                                i = i + 1; // the menu order for each item
    251246
    252 /**
    253  * Prepares menu items for POST.
    254  */
    255 function wp_update_post_data() {
    256         var i = 0;
     247                                var j = $(this).attr('value'); // reference to the current menu item (e.g. li#menu-item + j)
    257248
    258          jQuery('.menu li').each(function(i) {
    259                 i = i + 1;
    260         var j = jQuery(this).attr('value');
     249                                // Grab the menu item id
     250                                var id = $(this).children('input[name=menu-item-db-id[]]').val();
    261251
    262         jQuery(this).find('#menu-item-position' + j).attr('value', i);
    263         jQuery(this).attr('id','menu-item' + i);
    264         jQuery(this).attr('value', i);
     252                                // Update the li value to equal the menu order
     253                                $(this).attr('value', i);
    265254
    266         jQuery(this).find('#menu-item-db-id' + j).attr('id','menu-item-db-id' + i);
    267         jQuery(this).find('#menu-item-object-id' + j).attr('id','menu-item-object-id' + i);
    268                 jQuery(this).find('#menu-item-append' + j).attr('id', 'menu-item-append' + i);
    269                 jQuery(this).find('#menu-item-type' + j).attr('id', 'menu-item-type' + i);
    270                 jQuery(this).find('#menu-item-position' + j).attr('id', 'menu-item-position' + i);
     255                                // Update the position
     256                                $(this).children('input[name=menu-item-position[]]').attr( 'value', i );
    271257
    272         var p = jQuery(this).find('#menu-item-parent-id' + j).parent().parent().parent().attr('value');
    273                 jQuery(this).find('#menu-item-parent-id' + j).attr('id','menu-item-parent-id' + i);
    274                 if (p) {
    275                         // Do nothing
    276                 } else {
    277                         // reset p to be top level
    278                         p = 0;
    279                 }
    280                 jQuery(this).find('#menu-item-parent-id' + j).attr('value', p);
     258                                // Update the parent id
     259                                var pid = $(this).parent('.sub-menu').siblings('input[name=menu-item-object-id[]]').val();
     260                               
     261                                if ( undefined == pid ) {
     262                                        pid = 0;
     263                                };
    281264
    282                 jQuery(this).find('#menu-item-title' + j).attr('id','menu-item-title' + i);
    283                 jQuery(this).find('#menu-item-url' + j).attr('id','menu-item-url' + i);
    284                 jQuery(this).find('#menu-item-description' + j).attr('id','menu-item-description' + i);
    285                 jQuery(this).find('#menu-item-classes' + j).attr('id','menu-item-classes' + i);
    286                 jQuery(this).find('#menu-item-xfn' + j).attr('id','menu-item-xfn' + i);
    287                 jQuery(this).find('#menu-item-description' + j).attr('id','menu-item-description' + i);
    288                 jQuery(this).find('#menu-item-attr-title' + j).attr('id','menu-item-attr-title' + i);
    289                 jQuery(this).find('#menu-item-target' + j).attr('id','menu-item-target' + i);
     265                                $(this).children('input[name=menu-item-parent-id[]]').attr( 'value', pid );
    290266
    291                 jQuery('#li-count').attr( 'value', i );
    292    });
    293 };
     267                                // Update the menu item count
     268                                $('#li-count').attr( 'value', i );
     269                        });
     270                },
     271               
     272                /**
     273                 * Enables autocomplete for nav menu types.
     274                 *
     275                 * @param int id - the id of the menu item type.
     276                 */
     277                autocomplete : function( id ) {
     278                        $('#add-'+ id +' .quick-search').autocomplete( $( '#add-'+ id +' .autocomplete' ).val().split('|') );
    294279
    295 /**
    296  * Gets a unique number based on how many items are in the menu
    297  */
    298 function wp_get_unique_menu_id() {
    299         var count = jQuery('.menu li').length + 1;
    300         var randomnumber = count;
    301         var validatetest = 0;
     280                        $('#add-'+ id +' .quick-search').result(function( event, data, formatted ) {
     281                                $('#add-'+ id +' .list-wrap').css( 'display', 'block' );
     282                                $("#add-"+ id +" .list-wrap li:contains('" + data + "')").css( 'display', 'block' );
     283                                $('#add-'+ id +' .show-all').hide();
     284                                $('#add-'+ id +' .hide-all').show();
     285                        });
     286                },
     287               
     288                /**
     289                 * Populate the thickbox window with the selected menu items
     290                 *
     291                 * @param int id - the id of the menu item to edit.
     292                 */
     293                edit_menu_item : function( id ) {
     294                        var item_type = $('#menu-item-' + id).children('input[name=menu-item-type[]]').val();
     295                        var item_title = $('#menu-item-' + id).children('input[name=menu-item-title[]]').val();
     296                        var item_link = $('#menu-item-' + id).children('input[name=menu-item-url[]]').val();
     297                        var item_attr_title = $('#menu-item-' + id).children('input[name=menu-item-attr-title[]]').val();
     298                        var item_target = $('#menu-item-' + id).children('input[name=menu-item-target[]]').val();
     299                        var item_description = $('#menu-item-' + id).children('input[name=menu-item-description[]]').val();
     300                        var item_classes = $('#menu-item-' + id).children('input[name=menu-item-classes[]]').val();
     301                        var item_xfn = $('#menu-item-' + id).children('input[name=menu-item-xfn[]]').val();
    302302
    303         try {
    304                 var test = document.getElementById( 'menu-' + randomnumber.toString() ).value;
    305         }
    306         catch ( err ) {
    307                 validatetest = 1;
    308         }
     303                        // Only allow custom links to be editable.
     304                        if ( 'custom' != item_type )
     305                                $( '#edit-menu-item-url' ).attr('disabled', 'disabled' );
    309306
    310         while ( validatetest == 0 ) {
    311                 randomnumber = randomnumber + 1;
    312                 try {
    313                         var test2 = document.getElementById( 'menu-' + randomnumber.toString() ).value;
    314                 }
    315                 catch ( err ) {
    316                         validatetest = 1;
    317                 }
    318         }
    319         return randomnumber;
    320 }
     307                        // Populate the fields for thickbox
     308                        $( '#edit-menu-item-id' ).val(id);
     309                        $( '#edit-menu-item-title' ).val(item_title);
     310                        $( '#edit-menu-item-url' ).val(item_link);
     311                        $( '#edit-menu-item-attr-title' ).val(item_attr_title);
     312                        $( '#edit-menu-item-target' ).val(item_target);
     313                        $( "#edit-menu-item-target option[value='" + item_target  + "']" ).attr('selected', 'selected');
     314                        $( '#edit-menu-item-description' ).val(item_description);
     315                        $( '#edit-menu-item-classes' ).val(item_classes);
     316                        $( '#edit-menu-item-xfn' ).val(item_xfn);
    321317
    322 /**
    323  * Returns all the nessecary hidden inputs for each menu item.
    324  *
    325  * @param string item_db_id - The menu item's db id.
    326  * @param string item_object_id - The menu item's object id.
    327  * @param string item_type - The menu item's object type.
    328  * @param string item_append - The menu item's nice name.
    329  * @param string item_parent_id - The menu item's parent id.
    330  * @param string item_title - The menu item title.
    331  * @param string item_url - The menu item url
    332  * @param string item_description - The menu item description.
    333  * @param string item_attr_title - The title attribute.
    334  * @param string item_target - The target attribute.
    335  * @param string item_classes - Optional. Additional CSS classes for the menu item
    336  * @param string item_xfn - Optional. The rel attribute.
    337  */
    338 function wp_get_hidden_inputs( randomnumber, item_db_id, item_object_id, item_type, item_append, item_parent_id, item_title, item_url, item_description, item_attr_title, item_target, item_classes, item_xfn ) {
    339         var hidden = '';
     318                        // @todo: focus on #edit-menu-item-title
     319                },
     320               
     321                /**
     322                 * Update the values for the menu item being editing
     323                 */
     324                update_menu_item : function() {
     325                        var id = $('#edit-menu-item-id').val();
     326                        var item_title = $('#edit-menu-item-title').val();
     327                        var item_link = $('#edit-menu-item-url').val();
     328                        var item_attr_title = $('#edit-menu-item-attr-title').val();
     329                        var item_target = $('#edit-menu-item-target').val();
     330                        var item_description = $('#edit-menu-item-description').val();
     331                        var item_classes = $('#edit-menu-item-classes').val();
     332                        var item_xfn = $('#edit-menu-item-xfn').val();
    340333
    341         hidden += '<input type="hidden" name="menu-item-db-id[]" id="menu-item-db-id' + randomnumber + '" value="' + item_db_id + '" />';
    342         hidden += '<input type="hidden" name="menu-item-object-id[]" id="menu-item-object-id' + randomnumber + '" value="' + item_object_id + '" />';
    343         hidden += '<input type="hidden" name="menu-item-type[]" id="menu-item-type' + randomnumber + '" value="' + item_type + '" />';
    344         hidden += '<input type="hidden" name="menu-item-append[]" id="menu-item-append' + randomnumber + '" value="' + item_append + '" />';
    345         hidden += '<input type="hidden" name="menu-item-parent-id[]" id="menu-item-parent-id' + randomnumber + '" value="' + item_parent_id + '" />';
    346         hidden += '<input type="hidden" name="menu-item-position[]" id="menu-item-position' + randomnumber + '" value="' + randomnumber + '" />';
    347         hidden += '<input type="hidden" name="menu-item-title[]" id="menu-item-title' + randomnumber + '" value="' + item_title + '" />';
    348         hidden += '<input type="hidden" name="menu-item-attr-title[]" id="menu-item-attr-title' + randomnumber + '" value="' + item_attr_title + '" />';
    349         hidden += '<input type="hidden" name="menu-item-url[]" id="menu-item-url' + randomnumber + '" value="' + item_url + '" />';
    350         hidden += '<input type="hidden" name="menu-item-target[]" id="menu-item-target' + randomnumber + '" value="' + item_target + '" />';
    351         hidden += '<input type="hidden" name="menu-item-description[]" id="menu-item-description' + randomnumber + '" value="' + item_description + '" />';
    352         hidden += '<input type="hidden" name="menu-item-classes[]" id="menu-item-classes' + randomnumber + '" value="' + item_classes + '" />';
    353         hidden += '<input type="hidden" name="menu-item-xfn[]" id="menu-item-xfn' + randomnumber + '" value="' + item_xfn + '" />';
     334                        // update menu item settings
     335                        $('.menu #menu-item-' + id).find('span.item-title:first').html(item_title);
    354336
    355         return hidden;
    356 }
     337                        $('#menu-item-' + id).children('input[name=menu-item-title[]]').val(item_title);
     338                        $('#menu-item-' + id).children('input[name=menu-item-url[]]').val(item_link);
     339                        $('#menu-item-' + id).children('input[name=menu-item-attr-title[]]').val(item_attr_title);
     340                        $('#menu-item-' + id).children('input[name=menu-item-target[]]').val(item_target);
     341                        $('#menu-item-' + id).children('input[name=menu-item-description[]]').val(item_description);
     342                        $('#menu-item-' + id).children('input[name=menu-item-classes[]]').val(item_classes);
     343                        $('#menu-item-' + id).children('input[name=menu-item-xfn[]]').val(item_xfn);
    357344
    358 /**
    359  * WordPress Administration Custom Navigation
    360  * Interface $ functions
    361  *
    362  * @version 2.0.0
    363  *
    364  * @package WordPress
    365  * @subpackage Administration
    366  */
     345                        $('.menu #menu-item-' + id + ' dt:first').animate( { backgroundColor: '#FFFF33' }, { duration: 'normal', complete: function() { $(this).css( 'backgroundColor', '' ); }});
     346                },
     347               
     348                /**
     349                 * Removes a menu item from current menu
     350                 *
     351                 * @param int id - the id of the menu item to remove.
     352                 */
     353                remove_menu_item : function( id ) {
     354                        var todelete = $('#menu-item-' + id);
    367355
    368 /**
    369  * Init Functions
    370  */
    371 jQuery(document).ready(function($){
     356                        if ( todelete ) {
     357                                // Give some feedback to the user
     358                                $( todelete ).find('dt').each(function(){
     359                                        $(this).animate( { backgroundColor: '#FF3333' }, { duration: 'normal', complete: function() { $(this).parent().parent().remove() } } );
     360                                });
     361                        }
     362                },
     363               
     364                /**
     365                 * Adds the item to the menu
     366                 *
     367                 * @param string item_db_id - The menu item's db id.
     368                 * @param string item_object_id - The menu item's object id.
     369                 * @param string item_object - The menu item's object name.
     370                 * @param string item_type - The menu item's object type.
     371                 * @param string item_append - The menu item's nice name.
     372                 * @param string item_parent_id - The menu item's parent id.
     373                 * @param string item_title - The menu item title.
     374                 * @param string item_url - The menu item url
     375                 * @param string item_description - The menu item description.
     376                 * @param string item_attr_title - The title attribute.
     377                 * @param string item_target - The target attribute.
     378                 * @param string item_classes - Optional. Additional CSS classes for the menu item
     379                 * @param string item_xfn - Optional. The rel attribute.
     380                 */
     381                add_to_menu : function( item_db_id, item_object_id, item_object, item_type, item_append, item_parent_id, item_title, item_url, item_description, item_attr_title, item_target, item_classes, item_xfn ) {
     382                        var randomnumber = $('.menu li').length + 1;
     383                        var hidden = wpNavMenu.get_hidden_inputs( randomnumber, item_db_id, item_object_id, item_object, item_type, item_parent_id, item_title, item_url, item_description, item_attr_title, item_target, item_classes, item_xfn );
     384                       
     385                        // Adds the item to the menu
     386                        $('.menu').append('<li id="menu-item-' + randomnumber + '" value="' + randomnumber + '"><div class="dropzone ui-droppable"></div><dl class="ui-droppable"><dt><span class="item-title">' + item_title + '</span><span class="item-controls"><span class="item-type">' + item_append + '</span><a class="item-edit thickbox" id="edit' + randomnumber + '" value="' + randomnumber +'" onclick="wpNavMenu.edit_menu_item('+ randomnumber +');" title="' + navMenuL10n.thickbox + '" href="#TB_inline?height=540&width=300&inlineId=menu-item-settings">' + navMenuL10n.edit + '</a> | <a class="item-delete" id="delete' + randomnumber + '" value="' + randomnumber +'" onclick="wpNavMenu.remove_menu_item('+ randomnumber +');">Delete</a></span></dt></dl>' + hidden + '</li>');
    372387
    373         wp_drag_and_drop();
     388                        // Give some feedback to the user
     389                        $( '.menu #menu-item-' + randomnumber + ' dt:first' ).animate( { backgroundColor: '#FFFF33' }, { duration: 'normal', complete: function() { $(this).css( 'backgroundColor', '' ); }});
    374390
    375         // Delete AYS
    376         $('#update-nav-menu .deletion').click(function(){
    377                 if ( confirm( navMenuL10n.warnDelete ) ) {
    378                         return true;
    379                 } else {
    380                         return false;
    381                 };
    382         });
     391                        // Enable drag-n-drop
     392                        wpNavMenu.drag_and_drop();
    383393
    384         // Handle Save Button Clicks
    385         $('#save_menu').click(function(){
    386                 return wp_update_post_data();
    387         });
     394                        // Reload thickbox
     395                        tb_init('a.thickbox, area.thickbox, input.thickbox');
     396                },
     397               
     398                /**
     399                 * Grabs items from the queue and adds them to the menu.
     400                 *
     401                 * @param string button - a reference to the button that was clicked
     402                 */
     403                add_checked_items_to_menu : function( button ) {
     404                        // Grab checked items
     405                        var items = $(button).parent().siblings('.list-wrap').find(':checked');
    388406
    389         // Handle some return keypresses
    390         $('#create-menu-name').keypress(function(e){
    391                 if ( 13 == e.keyCode ) {
    392                         $('#create-menu-button').click();
    393                         return false;
    394                 }
    395         });
     407                        // If nothing was checked, cancel
     408                        if ( 0 == items.length )
     409                                return false;
    396410
    397         $('#custom-menu-item-url, #custom-menu-item-name').keypress(function(e){
    398                 if ( 13 == e.keyCode ) {
    399                         $('#add-custom-links a.button').click();
    400                         return false;
    401                 }
    402         }).focus(function(){
    403                 if ( $(this).val() == $(this).attr('defaultValue') && $(this).attr('id') != 'custom-menu-item-url' ) {
    404                         $(this).val('');
    405                 }
    406         }).blur(function(){
    407                 if ( $(this).val() == '' ) {
    408                         $(this).val($(this).attr('defaultValue'));
    409                 }
    410         });
     411                        // Loop through each item, grab it's hidden data and add it to the menu.
     412                        $(items).each(function(){
     413                                var item_type = $(this).parent().siblings('.menu-item-type').val();
    411414
    412         $('#create-menu-name').focus(function(){
    413                 if ( $(this).val() == $(this).attr('defaultValue') ) {
    414                         $(this).val('');
    415                 }
    416         }).blur(function(){
    417                 if ( $(this).val() == '' ) {
    418                         $(this).val($(this).attr('defaultValue'));
    419                 }
    420         });
     415                                if ( 'custom' == item_type ) {
     416                                        var item_attr_title = $(this).parent().siblings('.menu-item-attr-title').val();
     417                                        var item_target = $(this).parent().siblings('.menu-item-target').val();
     418                                        var item_classes = $(this).parent().siblings('.menu-item-classes').val();
     419                                        var item_xfn = $(this).parent().siblings('.menu-item-xfn').val();
     420                                } else {
     421                                        var item_attr_title = '';
     422                                        var item_target = '_self';
     423                                        var item_classes = '';
     424                                        var item_xfn = '';
     425                                };
    421426
    422         // close postboxes that should be closed
    423         $('.if-js-closed').removeClass('if-js-closed').addClass('closed');
     427                                var item_db_id = $(this).parent().siblings('.menu-item-db-id').val();
     428                                var item_object_id = $(this).parent().siblings('.menu-item-object-id').val();
     429                                var item_object = $(this).parent().siblings('.menu-item-object').val();
     430                                var item_append = $(this).parent().siblings('.menu-item-append').val();
     431                                var item_parent_id = $(this).parent().siblings('.menu-item-parent-id').val();
     432                                var item_title = $(this).parent().siblings('.menu-item-title').val();
     433                                var item_url = $(this).parent().siblings('.menu-item-url').val();
     434                                var item_description = $(this).parent().siblings('.menu-item-description').val();
    424435
    425         // postboxes setup
    426         postboxes.add_postbox_toggles('menus');
     436                                if ( undefined == item_description ) {
     437                                        item_description = '';
     438                                };
    427439
    428         // Clear the quick search textbox
    429         $('.quick-search').click(function(){
    430                 $(this).attr( 'value', '' );
    431         });
     440                                if ( undefined == item_attr_title ) {
     441                                        item_attr_title = '';
     442                                };
    432443
    433         // Quick Search submit
    434         $('.quick-search-submit').click(function(){
    435                 $(this).siblings('.quick-search').search();
    436         });
     444                                // Add the menu item to the menu
     445                                wpNavMenu.add_to_menu( item_db_id, item_object_id, item_object, item_type, item_append, item_parent_id, item_title, item_url, item_description, item_attr_title, item_target, item_classes, item_xfn );
    437446
    438         // Edit menu item
    439         $('#menu-container .item-edit').click(function(){
    440                 return wp_edit_menu_item( $(this).attr('value') );
    441         });
     447                                // uncheck the menu item in the list
     448                                $(this).attr( 'checked', false );
     449                        });
     450                },
     451               
     452                /**
     453                 * Returns all the nessecary hidden inputs for each menu item.
     454                 *
     455                 * @param string item_db_id - The menu item's db id.
     456                 * @param string item_object_id - The menu item's object id.
     457                 * @param string item_object - The menu item's object name.
     458                 * @param string item_type - The menu item's object type.
     459                 * @param string item_append - The menu item's nice name.
     460                 * @param string item_parent_id - The menu item's parent id.
     461                 * @param string item_title - The menu item title.
     462                 * @param string item_url - The menu item url
     463                 * @param string item_description - The menu item description.
     464                 * @param string item_attr_title - The title attribute.
     465                 * @param string item_target - The target attribute.
     466                 * @param string item_classes - Optional. Additional CSS classes for the menu item
     467                 * @param string item_xfn - Optional. The rel attribute.
     468                 */
     469                get_hidden_inputs : function( randomnumber, item_db_id, item_object_id, item_object, item_type, item_parent_id, item_title, item_url, item_description, item_attr_title, item_target, item_classes, item_xfn ) {
     470                        var hidden = '';
    442471
    443         // Delete menu item
    444         $('#menu-container .item-delete').live( 'click', function(e){
    445                 return wp_remove_menu_item( $(this).attr('value') );
    446         });
     472                        hidden += '<input type="hidden" name="menu-item-db-id[]" value="' + item_db_id + '" />';
     473                        hidden += '<input type="hidden" name="menu-item-object-id[]" value="' + item_object_id + '" />';
     474                        hidden += '<input type="hidden" name="menu-item-object[]" value="' + item_object + '" />';
     475                        hidden += '<input type="hidden" name="menu-item-type[]" value="' + item_type + '" />';
     476                        hidden += '<input type="hidden" name="menu-item-parent-id[]" value="' + item_parent_id + '" />';
     477                        hidden += '<input type="hidden" name="menu-item-position[]" value="' + randomnumber + '" />';
     478                        hidden += '<input type="hidden" name="menu-item-title[]" value="' + item_title + '" />';
     479                        hidden += '<input type="hidden" name="menu-item-attr-title[]" value="' + item_attr_title + '" />';
     480                        hidden += '<input type="hidden" name="menu-item-url[]" value="' + item_url + '" />';
     481                        hidden += '<input type="hidden" name="menu-item-target[]" value="' + item_target + '" />';
     482                        hidden += '<input type="hidden" name="menu-item-description[]" value="' + item_description + '" />';
     483                        hidden += '<input type="hidden" name="menu-item-classes[]" value="' + item_classes + '" />';
     484                        hidden += '<input type="hidden" name="menu-item-xfn[]" value="' + item_xfn + '" />';
    447485
    448         // Update menu item settings (thickbox)
    449         $('#update-menu-item').click(function(){
    450                 wp_update_menu_item();
    451                 return tb_remove();
    452         });
    453 
    454         // Close thickbox
    455         $('#cancel-save').click(function(){
    456                 return tb_remove();
    457         });
    458 
    459         // Show All Button
    460         $('.show-all').click(function(e){
    461                 jQuery(e.currentTarget).parent().siblings('.list-wrap').css( 'display', 'block' );
    462                 jQuery(e.currentTarget).parent().siblings('.list-wrap').find('li').css( 'display', 'block' );
    463                 jQuery(e.currentTarget).hide();
    464                 jQuery(e.currentTarget).siblings('.hide-all').show();
    465         });
    466 
    467         // Hide All Button
    468         $('.hide-all').click(function(e){
    469                 jQuery(e.currentTarget).parent().siblings('.list-wrap').css( 'display', 'none' );
    470                 jQuery(e.currentTarget).parent().siblings('.list-wrap').find('li').css( 'display', 'none' );
    471                 jQuery(e.currentTarget).hide();
    472                 jQuery(e.currentTarget).siblings('.show-all').show();
    473         });
    474 
    475         // Add menu items into the menu
    476         $('.add-to-menu').click(function(e){
    477                 return wp_add_checked_items_to_menu(e.currentTarget);
    478         });
    479 
    480         // Create a new link then add it to the menu
    481         $('#add-custom-links .add-to-menu a').click(function(e){
    482                 // Add link to menu
    483                 if ( $('#custom-menu-item-url').val() == $('#custom-menu-item-url').attr('defaultValue') )
    484                         return; // Do not allow "http://" submissions to go through
    485                 wp_add_item_to_menu( 0, '', 'custom', navMenuL10n.custom, 0, $('#custom-menu-item-name').val(), $('#custom-menu-item-url').val(), '', '', '_self', '', '' );
    486                 $('#custom-menu-item-name').val($('#custom-menu-item-name').attr('defaultValue'));
    487                 $('#custom-menu-item-url' ).val($('#custom-menu-item-url' ).attr('defaultValue')).focus();
    488         });
    489 });
    490  No newline at end of file
     486                        return hidden;
     487                }
     488        }
     489       
     490        $(document).ready(function($){ wpNavMenu.init(); });
     491})(jQuery);
     492 No newline at end of file
  • wp-admin/js/nav-menu.js

     
    1 function wp_nav_menu_autocomplete(a){jQuery("#add-"+a+" .quick-search").autocomplete(jQuery("#add-"+a+" .autocomplete").val().split("|"));jQuery("#add-"+a+" .quick-search").result(function(b,d,c){jQuery("#add-"+a+" .list-wrap").css("display","block");jQuery("#add-"+a+" .list-wrap li:contains('"+d+"')").css("display","block");jQuery("#add-"+a+" .show-all").hide();jQuery("#add-"+a+" .hide-all").show()})}function wp_edit_menu_item(a){var f=jQuery("#menu-item-type"+a).val();var b=jQuery("#menu-item-title"+a).val();var g=jQuery("#menu-item-url"+a).val();var c=jQuery("#menu-item-attr-title"+a).val();var d=jQuery("#menu-item-target"+a).val();var h=jQuery("#menu-item-description"+a).val();var e=jQuery("#menu-item-classes"+a).val();var i=jQuery("#menu-item-xfn"+a).val();if("custom"!=f){jQuery("#edit-menu-item-url").attr("disabled","disabled")}jQuery("#edit-menu-item-id").val(a);jQuery("#edit-menu-item-title").val(b);jQuery("#edit-menu-item-url").val(g);jQuery("#edit-menu-item-attr-title").val(c);jQuery("#edit-menu-item-target").val(d);jQuery("#edit-menu-item-target option[value='"+d+"']").attr("selected","selected");jQuery("#edit-menu-item-description").val(h);jQuery("#edit-menu-item-classes").val(e);jQuery("#edit-menu-item-xfn").val(i);jQuery("#edit-menu-item-title").focus()}function wp_update_menu_item(){var h=jQuery("#edit-menu-item-id").val();var f=jQuery("#edit-menu-item-title").val();var b=jQuery("#edit-menu-item-url").val();var g=jQuery("#edit-menu-item-attr-title").val();var d=jQuery("#edit-menu-item-target").val();var c=jQuery("#edit-menu-item-description").val();var a=jQuery("#edit-menu-item-classes").val();var e=jQuery("#edit-menu-item-xfn").val();jQuery(".menu #menu-item"+h).find("span.item-title").html(f);jQuery(".menu #menu-item-title"+h).val(f);jQuery(".menu #menu-item-url"+h).val(b);jQuery(".menu #menu-item-attr-title"+h).val(g);jQuery(".menu #menu-item-target"+h).val(d);jQuery(".menu #menu-item-description"+h).val(c);jQuery(".menu #menu-item-classes"+h).val(a);jQuery(".menu #menu-item-xfn"+h).val(e);jQuery(".menu #menu-item"+h+" dt:first").animate({backgroundColor:"#FFFF33"},{duration:"normal",complete:function(){jQuery(this).css("backgroundColor","")}})}function wp_remove_menu_item(b){var a=document.getElementById("menu-item"+b);if(a){jQuery(a).find("dt").each(function(){jQuery(this).animate({backgroundColor:"#FF3333"},{duration:"normal",complete:function(){jQuery(this).parent().parent().remove()}})})}}function wp_add_item_to_menu(a,k,f,n,l,b,m,h,e,d,c,i){var j=wp_get_unique_menu_id();var g=wp_get_hidden_inputs(j,a,k,f,n,l,b,m,h,e,d,c,i);jQuery(".menu").append('<li id="menu-item'+j+'" value="'+j+'"><div class="dropzone ui-droppable"></div><dl class="ui-droppable"><dt><span class="item-title">'+b+'</span><span class="item-controls"><span class="item-type">'+n+'</span><a class="item-edit thickbox" id="edit'+j+'" value="'+j+'" onClick="wp_edit_menu_item('+j+')" title="'+navMenuL10n.thickbox+'" href="#TB_inline?height=540&width=300&inlineId=menu-item-settings">'+navMenuL10n.edit+'</a> | <a class="item-delete" id="delete'+j+'" value="'+j+'">Delete</a></span></dt></dl>'+g+"</li>");jQuery(".menu #menu-item"+j+" dt:first").animate({backgroundColor:"#FFFF33"},{duration:"normal",complete:function(){jQuery(this).css("backgroundColor","")}});wp_drag_and_drop();tb_init("a.thickbox, area.thickbox, input.thickbox")}function wp_add_checked_items_to_menu(b){var a=jQuery(b).siblings(".list-wrap").find(":checked");if(0==a.length){return false}jQuery(a).each(function(){var h=jQuery(this).parent().siblings(".menu-item-type").val();if("custom"==h){var e=jQuery(this).parent().siblings(".menu-item-attr-title").val();var f=jQuery(this).parent().siblings(".menu-item-target").val();var g=jQuery(this).parent().siblings(".menu-item-classes").val();var j=jQuery(this).parent().siblings(".menu-item-xfn").val()}else{var e="";var f="_self";var g="";var j=""}var c=jQuery(this).parent().siblings(".menu-item-db-id").val();var k=jQuery(this).parent().siblings(".menu-item-object-id").val();var n=jQuery(this).parent().siblings(".menu-item-append").val();var l=jQuery(this).parent().siblings(".menu-item-parent-id").val();var d=jQuery(this).parent().siblings(".menu-item-title").val();var m=jQuery(this).parent().siblings(".menu-item-url").val();var i=jQuery(this).parent().siblings(".menu-item-description").val();if(undefined==i){i=""}wp_add_item_to_menu(c,k,h,n,l,d,m,i,e,f,g,j);jQuery(this).attr("checked",false)})}function wp_drag_and_drop(){jQuery(".menu li").each(function(){if(!jQuery(this).children(".dropzone").attr("class")){jQuery(this).prepend('<div class="dropzone"></div>')}});jQuery(".menu li").draggable({handle:" > dl",opacity:0.8,addClasses:false,helper:"clone",zIndex:100});jQuery(".menu li dl, .menu li .dropzone").droppable({accept:".menu li",tolerance:"pointer",drop:function(f,d){var a=jQuery(this).parent();var g=!jQuery(this).hasClass("dropzone");if(g&&a.children("ul").length==0){a.append('<ul class="sub-menu" />')}if(g){a.children("ul").append(d.draggable)}else{a.before(d.draggable)}a.find("dl,.dropzone").css({backgroundColor:"",borderColor:""});var c=d.draggable.attr("value");var b=a.attr("value");a.find("#menu-"+c).find("#parent"+c).val(b);jQuery(this).parent().find("dt").removeAttr("style");jQuery(this).parent().find("div:first").removeAttr("style")},over:function(){if(jQuery(this).attr("class")=="dropzone ui-droppable"){jQuery(this).parent().find("div:first").css("background","none").css("height","50px")}else{if(jQuery(this).attr("class")=="ui-droppable"){jQuery(this).parent().find("dt:first").css("background","#d8d8d8")}else{}}var a=jQuery(this).parent().attr("id")},out:function(){jQuery(this).parent().find("dt").removeAttr("style");jQuery(this).parent().find("div:first").removeAttr("style");jQuery(this).filter(".dropzone").css({borderColor:""})}})}function wp_update_post_data(){var a=0;jQuery(".menu li").each(function(c){c=c+1;var b=jQuery(this).attr("value");jQuery(this).find("#menu-item-position"+b).attr("value",c);jQuery(this).attr("id","menu-item"+c);jQuery(this).attr("value",c);jQuery(this).find("#menu-item-db-id"+b).attr("id","menu-item-db-id"+c);jQuery(this).find("#menu-item-object-id"+b).attr("id","menu-item-object-id"+c);jQuery(this).find("#menu-item-append"+b).attr("id","menu-item-append"+c);jQuery(this).find("#menu-item-type"+b).attr("id","menu-item-type"+c);jQuery(this).find("#menu-item-position"+b).attr("id","menu-item-position"+c);var d=jQuery(this).find("#menu-item-parent-id"+b).parent().parent().parent().attr("value");jQuery(this).find("#menu-item-parent-id"+b).attr("id","menu-item-parent-id"+c);if(d){}else{d=0}jQuery(this).find("#menu-item-parent-id"+b).attr("value",d);jQuery(this).find("#menu-item-title"+b).attr("id","menu-item-title"+c);jQuery(this).find("#menu-item-url"+b).attr("id","menu-item-url"+c);jQuery(this).find("#menu-item-description"+b).attr("id","menu-item-description"+c);jQuery(this).find("#menu-item-classes"+b).attr("id","menu-item-classes"+c);jQuery(this).find("#menu-item-xfn"+b).attr("id","menu-item-xfn"+c);jQuery(this).find("#menu-item-description"+b).attr("id","menu-item-description"+c);jQuery(this).find("#menu-item-attr-title"+b).attr("id","menu-item-attr-title"+c);jQuery(this).find("#menu-item-target"+b).attr("id","menu-item-target"+c);jQuery("#li-count").attr("value",c)})}function wp_get_unique_menu_id(){var d=jQuery(".menu li").length+1;var e=d;var a=0;try{var f=document.getElementById("menu-"+e.toString()).value}catch(c){a=1}while(a==0){e=e+1;try{var b=document.getElementById("menu-"+e.toString()).value}catch(c){a=1}}return e}function wp_get_hidden_inputs(j,a,k,f,n,l,b,m,h,e,d,c,i){var g="";g+='<input type="hidden" name="menu-item-db-id[]" id="menu-item-db-id'+j+'" value="'+a+'" />';g+='<input type="hidden" name="menu-item-object-id[]" id="menu-item-object-id'+j+'" value="'+k+'" />';g+='<input type="hidden" name="menu-item-type[]" id="menu-item-type'+j+'" value="'+f+'" />';g+='<input type="hidden" name="menu-item-append[]" id="menu-item-append'+j+'" value="'+n+'" />';g+='<input type="hidden" name="menu-item-parent-id[]" id="menu-item-parent-id'+j+'" value="'+l+'" />';g+='<input type="hidden" name="menu-item-position[]" id="menu-item-position'+j+'" value="'+j+'" />';g+='<input type="hidden" name="menu-item-title[]" id="menu-item-title'+j+'" value="'+b+'" />';g+='<input type="hidden" name="menu-item-attr-title[]" id="menu-item-attr-title'+j+'" value="'+e+'" />';g+='<input type="hidden" name="menu-item-url[]" id="menu-item-url'+j+'" value="'+m+'" />';g+='<input type="hidden" name="menu-item-target[]" id="menu-item-target'+j+'" value="'+d+'" />';g+='<input type="hidden" name="menu-item-description[]" id="menu-item-description'+j+'" value="'+h+'" />';g+='<input type="hidden" name="menu-item-classes[]" id="menu-item-classes'+j+'" value="'+c+'" />';g+='<input type="hidden" name="menu-item-xfn[]" id="menu-item-xfn'+j+'" value="'+i+'" />';return g}jQuery(document).ready(function(a){wp_drag_and_drop();a("#update-nav-menu .deletion").click(function(){if(confirm(navMenuL10n.warnDelete)){return true}else{return false}});a("#save_menu").click(function(){return wp_update_post_data()});a("#create-menu-name").keypress(function(b){if(13==b.keyCode){a("#create-menu-button").click();return false}});a("#custom-menu-item-url, #custom-menu-item-name").keypress(function(b){if(13==b.keyCode){a("#add-custom-links a.button").click();return false}}).focus(function(){if(a(this).val()==a(this).attr("defaultValue")&&a(this).attr("id")!="custom-menu-item-url"){a(this).val("")}}).blur(function(){if(a(this).val()==""){a(this).val(a(this).attr("defaultValue"))}});a("#create-menu-name").focus(function(){if(a(this).val()==a(this).attr("defaultValue")){a(this).val("")}}).blur(function(){if(a(this).val()==""){a(this).val(a(this).attr("defaultValue"))}});a(".if-js-closed").removeClass("if-js-closed").addClass("closed");postboxes.add_postbox_toggles("menus");a(".quick-search").click(function(){a(this).attr("value","")});a(".quick-search-submit").click(function(){a(this).siblings(".quick-search").search()});a("#menu-container .item-edit").click(function(){return wp_edit_menu_item(a(this).attr("value"))});a("#menu-container .item-delete").live("click",function(b){return wp_remove_menu_item(a(this).attr("value"))});a("#update-menu-item").click(function(){wp_update_menu_item();return tb_remove()});a("#cancel-save").click(function(){return tb_remove()});a(".show-all").click(function(b){jQuery(b.currentTarget).parent().siblings(".list-wrap").css("display","block");jQuery(b.currentTarget).parent().siblings(".list-wrap").find("li").css("display","block");jQuery(b.currentTarget).hide();jQuery(b.currentTarget).siblings(".hide-all").show()});a(".hide-all").click(function(b){jQuery(b.currentTarget).parent().siblings(".list-wrap").css("display","none");jQuery(b.currentTarget).parent().siblings(".list-wrap").find("li").css("display","none");jQuery(b.currentTarget).hide();jQuery(b.currentTarget).siblings(".show-all").show()});a(".add-to-menu").click(function(b){return wp_add_checked_items_to_menu(b.currentTarget)});a("#add-custom-links .add-to-menu a").click(function(b){if(a("#custom-menu-item-url").val()==a("#custom-menu-item-url").attr("defaultValue")){return}wp_add_item_to_menu(0,"","custom",navMenuL10n.custom,0,a("#custom-menu-item-name").val(),a("#custom-menu-item-url").val(),"","","_self","","");a("#custom-menu-item-name").val(a("#custom-menu-item-name").attr("defaultValue"));a("#custom-menu-item-url").val(a("#custom-menu-item-url").attr("defaultValue")).focus()})});
    2  No newline at end of file
     1var wpNavMenu;(function($){wpNavMenu={init:function(){wpNavMenu.initial_meta_boxes();wpNavMenu.drag_and_drop();$("#update-nav-menu .deletion").click(function(){if(confirm(navMenuL10n.warnDelete)){return true}else{return false}});$("#update-nav-menu").submit(function(){wpNavMenu.update_post_data()});$("#create-menu-name").keypress(function(e){if(13==e.keyCode){$("#create-menu-button").click();return false}});$("#custom-menu-item-url, #custom-menu-item-name").keypress(function(e){if(13==e.keyCode){$("#add-custom-links a.button").click();return false}}).focus(function(){if($(this).val()==$(this).attr("defaultValue")&&$(this).attr("id")!="custom-menu-item-url"){$(this).val("")}}).blur(function(){if($(this).val()==""){$(this).val($(this).attr("defaultValue"))}});$("#create-menu-name").focus(function(){if($(this).val()==$(this).attr("defaultValue")){$(this).val("")}}).blur(function(){if($(this).val()==""){$(this).val($(this).attr("defaultValue"))}});$(".if-js-closed").removeClass("if-js-closed").addClass("closed");postboxes.add_postbox_toggles("nav-menus");$(".quick-search").click(function(){$(this).attr("value","")});$(".quick-search-submit").click(function(){$(this).siblings(".quick-search").search()});$("#menu-container .item-edit").click(function(){wpNavMenu.edit_menu_item($(this).attr("value"))});$("#menu-container .item-delete").click(function(){wpNavMenu.remove_menu_item($(this).attr("value"))});$("#update-menu-item").click(function(){wpNavMenu.update_menu_item();tb_remove()});$("#cancel-save").click(function(){tb_remove()});$(".show-all").click(function(e){$(e.currentTarget).parent().parent().siblings(".list-wrap").css("display","block");$(e.currentTarget).parent().parent().siblings(".list-wrap").find("li").css("display","block");$(e.currentTarget).hide();$(e.currentTarget).siblings(".hide-all").show()});$(".hide-all").click(function(e){$(e.currentTarget).parent().parent().siblings(".list-wrap").css("display","none");$(e.currentTarget).parent().parent().siblings(".list-wrap").find("li").css("display","none");$(e.currentTarget).hide();$(e.currentTarget).siblings(".show-all").show()});$(".add-to-menu").click(function(e){wpNavMenu.add_checked_items_to_menu(e.currentTarget)});$("#add-custom-links .add-to-menu a").click(function(e){if($("#custom-menu-item-url").val()==$("#custom-menu-item-url").attr("defaultValue")){return}wpNavMenu.add_custom_link($("#custom-menu-item-name").val(),$("#custom-menu-item-url").val());$("#custom-menu-item-name").val($("#custom-menu-item-name").attr("defaultValue"));$("#custom-menu-item-url").val($("#custom-menu-item-url").attr("defaultValue")).focus()})},add_custom_link:function(link_name,link_url){var params={action:"save-custom-link",link_name:link_name,link_url:link_url};$.post(ajaxurl,params,function(link_id){if("-1"==link_id){return}wpNavMenu.add_to_menu(link_id,link_id,"custom","custom",navMenuL10n.custom,0,link_name,link_url,"","","_self","","")},"json")},initial_meta_boxes:function(){var hidden=$("#hidden-metaboxes").val().split(",");if(""!=hidden){for(var i=0;i<hidden.length;i++){$("#"+hidden[i]).attr("style","display: none;");$("#"+hidden[i]+"-hide").attr("checked",false)}}},drag_and_drop:function(){$(".menu li").each(function(){if(!$(this).children(".dropzone").attr("class")){$(this).prepend('<div class="dropzone"></div>')}});$(".menu li").draggable({handle:" > dl",opacity:0.8,addClasses:false,helper:"clone",zIndex:100});$(".menu li dl, .menu li .dropzone").droppable({accept:".menu li",tolerance:"pointer",drop:function(e,ui){var li=$(this).parent();var child=!$(this).hasClass("dropzone");if(child&&li.children("ul").length==0){li.append('<ul class="sub-menu" />')}if(child){li.children("ul").append(ui.draggable)}else{li.before(ui.draggable)}li.find("dl,.dropzone").css({backgroundColor:"",borderColor:""});var draggablevalue=ui.draggable.attr("value");var droppablevalue=li.attr("value");li.find("#menu-"+draggablevalue).find("#parent"+draggablevalue).val(droppablevalue);$(this).parent().find("dt").removeAttr("style");$(this).parent().find("div:first").removeAttr("style")},over:function(e){if($(this).attr("class")=="dropzone ui-droppable"){$(this).parent().find("div:first").css({background:"#f5f5f5",border:"1px dashed #bbb",margin:"10px 0px",height:"40px"})}else{if($(this).attr("class")=="ui-droppable"){$(this).parent().find("dt:first").css("background","#d8d8d8")}else{}}},out:function(){$(this).parent().find("dt").removeAttr("style");$(this).parent().find("div:first").removeAttr("style");$(this).filter(".dropzone").css({borderColor:""})}})},update_post_data:function(){var i=0;$(".menu li").each(function(){i=i+1;var j=$(this).attr("value");var id=$(this).children("input[name=menu-item-db-id[]]").val();$(this).attr("value",i);$(this).children("input[name=menu-item-position[]]").attr("value",i);var pid=$(this).parent(".sub-menu").siblings("input[name=menu-item-object-id[]]").val();if(undefined==pid){pid=0}$(this).children("input[name=menu-item-parent-id[]]").attr("value",pid);$("#li-count").attr("value",i)})},autocomplete:function(id){$("#add-"+id+" .quick-search").autocomplete($("#add-"+id+" .autocomplete").val().split("|"));$("#add-"+id+" .quick-search").result(function(event,data,formatted){$("#add-"+id+" .list-wrap").css("display","block");$("#add-"+id+" .list-wrap li:contains('"+data+"')").css("display","block");$("#add-"+id+" .show-all").hide();$("#add-"+id+" .hide-all").show()})},edit_menu_item:function(id){var item_type=$("#menu-item-"+id).children("input[name=menu-item-type[]]").val();var item_title=$("#menu-item-"+id).children("input[name=menu-item-title[]]").val();var item_link=$("#menu-item-"+id).children("input[name=menu-item-url[]]").val();var item_attr_title=$("#menu-item-"+id).children("input[name=menu-item-attr-title[]]").val();var item_target=$("#menu-item-"+id).children("input[name=menu-item-target[]]").val();var item_description=$("#menu-item-"+id).children("input[name=menu-item-description[]]").val();var item_classes=$("#menu-item-"+id).children("input[name=menu-item-classes[]]").val();var item_xfn=$("#menu-item-"+id).children("input[name=menu-item-xfn[]]").val();if("custom"!=item_type){$("#edit-menu-item-url").attr("disabled","disabled")}$("#edit-menu-item-id").val(id);$("#edit-menu-item-title").val(item_title);$("#edit-menu-item-url").val(item_link);$("#edit-menu-item-attr-title").val(item_attr_title);$("#edit-menu-item-target").val(item_target);$("#edit-menu-item-target option[value='"+item_target+"']").attr("selected","selected");$("#edit-menu-item-description").val(item_description);$("#edit-menu-item-classes").val(item_classes);$("#edit-menu-item-xfn").val(item_xfn)},update_menu_item:function(){var id=$("#edit-menu-item-id").val();var item_title=$("#edit-menu-item-title").val();var item_link=$("#edit-menu-item-url").val();var item_attr_title=$("#edit-menu-item-attr-title").val();var item_target=$("#edit-menu-item-target").val();var item_description=$("#edit-menu-item-description").val();var item_classes=$("#edit-menu-item-classes").val();var item_xfn=$("#edit-menu-item-xfn").val();$(".menu #menu-item-"+id).find("span.item-title:first").html(item_title);$("#menu-item-"+id).children("input[name=menu-item-title[]]").val(item_title);$("#menu-item-"+id).children("input[name=menu-item-url[]]").val(item_link);$("#menu-item-"+id).children("input[name=menu-item-attr-title[]]").val(item_attr_title);$("#menu-item-"+id).children("input[name=menu-item-target[]]").val(item_target);$("#menu-item-"+id).children("input[name=menu-item-description[]]").val(item_description);$("#menu-item-"+id).children("input[name=menu-item-classes[]]").val(item_classes);$("#menu-item-"+id).children("input[name=menu-item-xfn[]]").val(item_xfn);$(".menu #menu-item-"+id+" dt:first").animate({backgroundColor:"#FFFF33"},{duration:"normal",complete:function(){$(this).css("backgroundColor","")}})},remove_menu_item:function(id){var todelete=$("#menu-item-"+id);if(todelete){$(todelete).find("dt").each(function(){$(this).animate({backgroundColor:"#FF3333"},{duration:"normal",complete:function(){$(this).parent().parent().remove()}})})}},add_to_menu:function(item_db_id,item_object_id,item_object,item_type,item_append,item_parent_id,item_title,item_url,item_description,item_attr_title,item_target,item_classes,item_xfn){var randomnumber=$(".menu li").length+1;var hidden=wpNavMenu.get_hidden_inputs(randomnumber,item_db_id,item_object_id,item_object,item_type,item_parent_id,item_title,item_url,item_description,item_attr_title,item_target,item_classes,item_xfn);$(".menu").append('<li id="menu-item-'+randomnumber+'" value="'+randomnumber+'"><div class="dropzone ui-droppable"></div><dl class="ui-droppable"><dt><span class="item-title">'+item_title+'</span><span class="item-controls"><span class="item-type">'+item_append+'</span><a class="item-edit thickbox" id="edit'+randomnumber+'" value="'+randomnumber+'" onclick="wpNavMenu.edit_menu_item('+randomnumber+');" title="'+navMenuL10n.thickbox+'" href="#TB_inline?height=540&width=300&inlineId=menu-item-settings">'+navMenuL10n.edit+'</a> | <a class="item-delete" id="delete'+randomnumber+'" value="'+randomnumber+'" onclick="wpNavMenu.remove_menu_item('+randomnumber+');">Delete</a></span></dt></dl>'+hidden+"</li>");$(".menu #menu-item-"+randomnumber+" dt:first").animate({backgroundColor:"#FFFF33"},{duration:"normal",complete:function(){$(this).css("backgroundColor","")}});wpNavMenu.drag_and_drop();tb_init("a.thickbox, area.thickbox, input.thickbox")},add_checked_items_to_menu:function(button){var items=$(button).parent().siblings(".list-wrap").find(":checked");if(0==items.length){return false}$(items).each(function(){var item_type=$(this).parent().siblings(".menu-item-type").val();if("custom"==item_type){var item_attr_title=$(this).parent().siblings(".menu-item-attr-title").val();var item_target=$(this).parent().siblings(".menu-item-target").val();var item_classes=$(this).parent().siblings(".menu-item-classes").val();var item_xfn=$(this).parent().siblings(".menu-item-xfn").val()}else{var item_attr_title="";var item_target="_self";var item_classes="";var item_xfn=""}var item_db_id=$(this).parent().siblings(".menu-item-db-id").val();var item_object_id=$(this).parent().siblings(".menu-item-object-id").val();var item_object=$(this).parent().siblings(".menu-item-object").val();var item_append=$(this).parent().siblings(".menu-item-append").val();var item_parent_id=$(this).parent().siblings(".menu-item-parent-id").val();var item_title=$(this).parent().siblings(".menu-item-title").val();var item_url=$(this).parent().siblings(".menu-item-url").val();var item_description=$(this).parent().siblings(".menu-item-description").val();if(undefined==item_description){item_description=""}if(undefined==item_attr_title){item_attr_title=""}wpNavMenu.add_to_menu(item_db_id,item_object_id,item_object,item_type,item_append,item_parent_id,item_title,item_url,item_description,item_attr_title,item_target,item_classes,item_xfn);$(this).attr("checked",false)})},get_hidden_inputs:function(randomnumber,item_db_id,item_object_id,item_object,item_type,item_parent_id,item_title,item_url,item_description,item_attr_title,item_target,item_classes,item_xfn){var hidden="";hidden+='<input type="hidden" name="menu-item-db-id[]" value="'+item_db_id+'" />';hidden+='<input type="hidden" name="menu-item-object-id[]" value="'+item_object_id+'" />';hidden+='<input type="hidden" name="menu-item-object[]" value="'+item_object+'" />';hidden+='<input type="hidden" name="menu-item-type[]" value="'+item_type+'" />';hidden+='<input type="hidden" name="menu-item-parent-id[]" value="'+item_parent_id+'" />';hidden+='<input type="hidden" name="menu-item-position[]" value="'+randomnumber+'" />';hidden+='<input type="hidden" name="menu-item-title[]" value="'+item_title+'" />';hidden+='<input type="hidden" name="menu-item-attr-title[]" value="'+item_attr_title+'" />';hidden+='<input type="hidden" name="menu-item-url[]" value="'+item_url+'" />';hidden+='<input type="hidden" name="menu-item-target[]" value="'+item_target+'" />';hidden+='<input type="hidden" name="menu-item-description[]" value="'+item_description+'" />';hidden+='<input type="hidden" name="menu-item-classes[]" value="'+item_classes+'" />';hidden+='<input type="hidden" name="menu-item-xfn[]" value="'+item_xfn+'" />';return hidden}};$(document).ready(function($){wpNavMenu.init()})})(jQuery);
     2 No newline at end of file
  • wp-admin/nav-menus.php

     
    1212/** Load WordPress Administration Bootstrap */
    1313require_once( 'admin.php' );
    1414
     15// Load all the nav menu interface functions
     16require_once( ABSPATH . 'wp-admin/includes/nav-menu.php' );
     17
    1518// Permissions Check
    1619if ( ! current_user_can('switch_themes') )
    1720        wp_die( __( 'Cheatin&#8217; uh?' ));
     
    3740// Thickbox
    3841add_thickbox();
    3942
    40 // Load all the nav menu interface functions
    41 require_once( ABSPATH . 'wp-admin/includes/nav-menu.php' );
    42 
    4343// Container for any messages displayed to the user
    4444$messages_div = '';
    4545
     
    5757                check_admin_referer( 'delete-nav_menu-' . $nav_menu_selected_id );
    5858
    5959                if ( is_nav_menu($nav_menu_selected_id) ) {
    60                         wp_delete_nav_menu( $nav_menu_selected_id );
    61                         $messages_div = '<div id="message" class="updated fade below-h2"><p>' . __('Menu successfully deleted.') . '</p></div>';
    62                         $nav_menu_selected_id = 0;
     60                        $delete_nav_menu = wp_delete_nav_menu( $nav_menu_selected_id );
     61                       
     62                        if ( is_wp_error($delete_nav_menu) ) {
     63                                $messages_div = '<div id="message" class="error"><p>' . $delete_nav_menu->get_error_message() . '</p></div>';
     64                        } else {
     65                                $messages_div = '<div id="message" class="updated"><p>' . __('The menu has been successfully deleted.') . '</p></div>';
     66                                $nav_menu_selected_id = 0; // Reset the selected menu
     67                        }
     68                        unset( $delete_nav_menu );
    6369                }
    6470                break;
    6571
     
    7581                                        $add_nav_menu = wp_create_nav_menu( $add_nav_menu );
    7682
    7783                                        if ( is_wp_error( $add_nav_menu ) ) {
    78                                                 $messages_div = '<div id="message" class="error fade below-h2"><p>' . $add_nav_menu->get_error_message() . '</p></div>';
     84                                                $messages_div = '<div id="message" class="error"><p>' . $add_nav_menu->get_error_message() . '</p></div>';
    7985                                        } else {
    8086                                                $nav_menu_selected_id = $add_nav_menu->term_id;
    8187                                                $nav_menu_selected_title = $add_nav_menu->name;
    82                                                 $messages_div = '<div id="message" class="updated fade below-h2"><p>' . sprintf( __('The <strong>%s</strong> menu has been successfully created.'), esc_html( $add_nav_menu->name ) ) . '</p></div>';
     88                                                $messages_div = '<div id="message" class="updated"><p>' . sprintf( __('The <strong>%s</strong> menu has been successfully created.'), $add_nav_menu->name ) . '</p></div>';
    8389                                        }
    8490                                } else {
    85                                         $messages_div = '<div id="message" class="error fade below-h2"><p>' . __('Please enter a valid menu name.') . '</p></div>';
     91                                        $messages_div = '<div id="message" class="error"><p>' . __('Please enter a valid menu name.') . '</p></div>';
    8692                                }
    87                                 unset($add_nav_menu);
     93                                unset( $add_nav_menu );
    8894                        }
    8995                } else {
     96                       
     97                        // @todo wrap this into wp_update_nav_menu_object();
    9098                        if ( isset($_POST['menu-name']) ) {
    9199                                $old_nav_menu = get_term( $nav_menu_selected_id, 'nav_menu', ARRAY_A );
    92100                                $args = array( 'name' => $_POST['menu-name'], 'slug' => null, 'description' => $old_nav_menu['description'], 'parent' => $old_nav_menu['parent'], );
    93101                                $new_nav_menu = wp_update_term( $nav_menu_selected_id, 'nav_menu', $args );
    94102                        }
    95 
     103                       
    96104                        // Update menu items
    97                         $update_nav_items = isset( $_POST['li-count'] ) ? (int) $_POST['li-count'] : 0;
     105                       
     106                        // @todo: wrap update logic into wp_update_nav_menu();
     107                        $update_count = isset( $_POST['li-count'] ) ? (int) $_POST['li-count'] : 0;
    98108                        $update_nav_menu = is_nav_menu( $nav_menu_selected_id );
    99109
    100110                        if ( !is_wp_error($update_nav_menu) ) {
    101111                                $menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array('orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID') );
    102                                 $parent_menu_ids = array();
    103 
     112                               
    104113                                // Loop through all POST variables
    105                                 for ( $k = 0; $k < $update_nav_items; $k++ ) {
     114                                for ( $k = 0; $k < $update_count; $k++ ) {
     115                                       
     116                                        // Menu item title can't be blank
     117                                        if ( '' == $_POST['menu-item-title'][$k] )
     118                                                continue;
     119                                       
    106120                                        $menu_item_db_id       = isset( $_POST['menu-item-db-id'][$k] )       ? $_POST['menu-item-db-id'][$k]       : 0;
    107121                                        $menu_item_object_id   = isset( $_POST['menu-item-object-id'][$k] )   ? $_POST['menu-item-object-id'][$k]   : 0;
     122                                        $menu_item_object      = isset( $_POST['menu-item-object'][$k] )      ? $_POST['menu-item-object'][$k]      : '';
    108123                                        $menu_item_parent_id   = isset( $_POST['menu-item-parent-id'][$k] )   ? $_POST['menu-item-parent-id'][$k]   : 0;
    109124                                        $menu_item_position    = isset( $_POST['menu-item-position'][$k] )    ? $_POST['menu-item-position'][$k]    : 0;
    110125                                        $menu_item_type        = isset( $_POST['menu-item-type'][$k] )        ? $_POST['menu-item-type'][$k]        : 'custom';
     
    113128                                        $menu_item_url         = isset( $_POST['menu-item-url'][$k] )         ? $_POST['menu-item-url'][$k]         : '';
    114129                                        $menu_item_description = isset( $_POST['menu-item-description'][$k] ) ? $_POST['menu-item-description'][$k] : '';
    115130                                        $menu_item_attr_title  = isset( $_POST['menu-item-attr-title'][$k] )  ? $_POST['menu-item-attr-title'][$k]  : '';
    116                                         $menu_item_target      = isset( $_POST['menu-item-target'][$k] )      ? $_POST['menu-item-target'][$k]      : 0;
     131                                        $menu_item_target      = isset( $_POST['menu-item-target'][$k] )      ? $_POST['menu-item-target'][$k]      : '_self';
    117132                                        $menu_item_classes     = isset( $_POST['menu-item-classes'][$k] )     ? $_POST['menu-item-classes'][$k]     : '';
    118133                                        $menu_item_xfn         = isset( $_POST['menu-item-xfn'][$k] )         ? $_POST['menu-item-xfn'][$k]         : '';
    119134
    120                                         // Menu item title can't be blank
    121                                         if ( '' == $menu_item_title )
    122                                                 continue;
    123 
    124                                         // Populate the menu item
    125                                         $post = array( 'post_status' => 'publish', 'post_type' => 'nav_menu_item', 'post_author' => $user_ID,
    126                                                 'ping_status' => 0, 'post_parent' => $menu_item_parent_id, 'menu_order' => $menu_item_position,
    127                                                 'post_excerpt' => $menu_item_attr_title, 'tax_input' => array( 'nav_menu' => $update_nav_menu->name ),
    128                                                 'post_content' => $menu_item_description, 'post_title' => $menu_item_title );
    129 
     135                                        // Populate the menu item object
     136                                        $post = array(
     137                                                'post_status' => 'publish', 'post_type' => 'nav_menu_item', 'ping_status' => 0,
     138                                                'post_author' => $user_ID, 'tax_input' => array( 'nav_menu' => $update_nav_menu->name ),
     139                                                'post_title' => $menu_item_title, 'post_excerpt' => $menu_item_attr_title,
     140                                                'post_parent' => $menu_item_parent_id, 'menu_order' => $menu_item_position,
     141                                                'post_content' => $menu_item_description,
     142                                        );
     143                                       
    130144                                        // New menu item
    131145                                        if ( $menu_item_db_id == 0 ) {
    132146                                                $menu_item_db_id = wp_insert_post( $post );
    133                                         } elseif ( isset( $menu_items[$menu_item_db_id] ) ) {
     147                                       
     148                                        // Update existing menu item
     149                                        } elseif ( isset($menu_items[$menu_item_db_id]) || ( 'custom' == $menu_item_type && 0 != $menu_item_db_id ) ) {
    134150                                                $post['ID'] = $menu_item_db_id;
    135151                                                wp_update_post( $post );
    136152                                                unset( $menu_items[$menu_item_db_id] );
    137153                                        }
    138                                         $parent_menu_ids[$k] = $menu_item_db_id;
    139154
    140                                         // @todo sanitize type append and ID.
    141                                         update_post_meta( $menu_item_db_id, 'menu_item_type', $menu_item_type );
    142                                         update_post_meta( $menu_item_db_id, 'menu_item_append', $menu_item_append );
    143                                         update_post_meta( $menu_item_db_id, 'menu_item_object_id', $menu_item_object_id );
    144                                         update_post_meta( $menu_item_db_id, 'menu_item_target', sanitize_key($menu_item_target) );
     155                                        update_post_meta( $menu_item_db_id, '_menu_item_type', sanitize_key($menu_item_type) );
     156                                        update_post_meta( $menu_item_db_id, '_menu_item_object_id', (int) $menu_item_object_id );
     157                                        update_post_meta( $menu_item_db_id, '_menu_item_object', sanitize_key($menu_item_object) );
     158                                        update_post_meta( $menu_item_db_id, '_menu_item_target', sanitize_key($menu_item_target) );
    145159                                        // @todo handle sanitizing multiple classes separated by whitespace.
    146                                         update_post_meta( $menu_item_db_id, 'menu_item_classes', sanitize_html_class($menu_item_classes) );
    147                                         update_post_meta( $menu_item_db_id, 'menu_item_xfn', sanitize_html_class($menu_item_xfn) );
     160                                        update_post_meta( $menu_item_db_id, '_menu_item_classes', sanitize_html_class($menu_item_classes) );
     161                                        update_post_meta( $menu_item_db_id, '_menu_item_xfn', sanitize_html_class($menu_item_xfn) );
    148162
    149163                                        // @todo: only save custom link urls.
    150                                         update_post_meta( $menu_item_db_id, 'menu_item_url', esc_url_raw( $menu_item_url ) );
     164                                        update_post_meta( $menu_item_db_id, '_menu_item_url', esc_url_raw($menu_item_url) );
    151165                                }
    152166
    153167                                // Remove menu items from the menu that weren't in $_POST
     
    156170                                                wp_delete_post( $menu_item_id );
    157171                                        }
    158172                                }
    159                                 $messages_div = '<div id="message" class="updated fade below-h2"><p>' . __('The menu has been updated.') . '</p></div>';
     173                               
     174                                do_action( 'wp_update_nav_menu', $nav_menu_selected_id );
     175                               
     176                                $messages_div = '<div id="message" class="updated"><p>' . sprintf( __('The <strong>%s</strong> menu has been updated.'), $update_nav_menu->name ) . '</p></div>';
     177                                unset( $update_nav_menu, $update_count, $menu_items );
    160178                        }
    161179                }
    162180                break;
     
    192210
    193211// The user has no menus.
    194212if ( !is_nav_menu( $nav_menu_selected_id ) ) {
    195         if ( current_theme_supports('nav-menus') ) {
    196                 $messages_div = '<div id="message" class="updated"><p>' . __('You do not have any menus. Create a new menu.') . '</p></div>';
    197         } else {
    198                 $messages_div = '<div id="message" class="error"><p>' . __('The current theme does not support menus.') . '</p></div>';
    199         }
     213        $messages_div = '<div id="message" class="updated"><p>' . __('You do not have any menus. Create a new menu.') . '</p></div>';
     214
     215// The theme supports menus
     216} elseif ( current_theme_supports('nav-menus') ) {
     217       
     218        // Register nav menu metaboxes
     219        add_meta_box( 'create-menu', __('Create Menu'), 'wp_nav_menu_create_metabox', 'nav-menus', 'side', 'core' );
     220        add_meta_box( 'manage-menu', __( 'Menu Settings' ), 'wp_nav_menu_manage_menu_metabox', 'nav-menus', 'side', 'high', array( $nav_menu_selected_id, $nav_menu_selected_title ) );
     221        wp_nav_menu_metaboxes_setup();
     222
     223// The theme does not support menus
    200224} else {
    201         add_meta_box( 'manage-menu', __( 'Menu Settings' ), 'wp_nav_menu_manage_menu_metabox', 'menus', 'side', 'high', array( $nav_menu_selected_id, $nav_menu_selected_title ) );
     225        $messages_div = '<div id="message" class="error"><p>' . __('The current theme does not support menus.') . '</p></div>';
    202226}
    203227
    204228// Get the admin header
     
    210234        <?php echo $messages_div; ?>
    211235        <div class="hide-if-js error"><p><?php _e('You do not have JavaScript enabled in your browser. Please enable it to access the Menus functionality.'); ?></p></div>
    212236
    213         <?php if ( !empty($nav_menus) && count($nav_menus) > 1 ) : ?>
     237        <?php if ( !empty($nav_menus) && count($nav_menus) > 1 && current_theme_supports('nav-menus') ) : ?>
    214238        <ul class="subsubsub">
    215239                <?php
    216240                        foreach ( $nav_menus as $_nav_menu ) {
     
    226250        <?php endif; ?>
    227251
    228252        <div id="menu-management" class="metabox-holder has-right-sidebar">
    229                 <form id="update-nav-menu" onsubmit="wp_update_post_data();" action="<?php echo admin_url( 'nav-menus.php' ); ?>" method="post" enctype="multipart/form-data">
     253                <form id="update-nav-menu" action="<?php echo admin_url( 'nav-menus.php' ); ?>" method="post" enctype="multipart/form-data">
    230254                        <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
    231255                        <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
    232256                        <?php wp_nonce_field( 'update-nav_menu' ); ?>
    233257                        <input type="hidden" name="action" value="update" />
    234                         <input type="hidden" name="li-count" id="li-count" value="0" />
     258                        <input type="hidden" name="li-count" id="li-count" value="-1" />
    235259                        <input type="hidden" name="menu" id="menu" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" />
    236 
     260                        <input type="hidden" id="hidden-metaboxes" value="<?php echo wp_initial_nav_menu_meta_boxes(); ?>" />
    237261                        <div id="post-body">
    238262                                <div id="post-body-content">
    239                                         <?php if ( is_nav_menu($nav_menu_selected_id) ) : ?>
     263                                        <?php if ( is_nav_menu($nav_menu_selected_id) && current_theme_supports('nav-menus') ) : ?>
    240264                                                <div id="menu-container" class="postbox">
    241265                                                        <h3 class="hndle"><?php echo esc_html( $nav_menu_selected_title ); ?></h3>
    242266                                                        <div class="inside">
    243 
    244267                                                                <?php echo wp_get_nav_menu( array( 'context' => 'backend', 'menu' => $nav_menu_selected_id ) ); ?>
    245 
    246268                                                        </div><!-- /.inside -->
    247269                                                <!-- /#nav-menu-canvas .postbox-->
    248270                                                </div>
    249                                                 <script type="text/javascript">
    250                                                         wp_update_post_data();
    251                                                 </script>
    252271                                        <?php endif; ?>
    253272                                </div><!-- /#post-body-content-->
    254273                        </div><!--- /#post-body -->
    255274                        <div id="menu-settings-column" class="inner-sidebar">
    256275
    257                                 <?php do_meta_boxes( 'menus', 'side', null ); ?>
     276                                <?php do_meta_boxes( 'nav-menus', 'side', null ); ?>
    258277
    259278                        </div><!-- /#menu-settings-column -->
    260279                </form><!--/#update-nav-menu-->
  • wp-admin/css/nav-menu.css

    Cannot display: file marked as a binary type.
    svn:mime-type = application/octet-stream
    Cannot display: file marked as a binary type.
    svn:mime-type = application/octet-stream
    Cannot display: file marked as a binary type.
    svn:mime-type = application/octet-stream
    Cannot display: file marked as a binary type.
    svn:mime-type = application/octet-stream
     
    1 #menu-management{clear:both;}#menu-management .inside{padding:0 10px;}#menu-container .submit{margin:0 0 10px;padding:0;}.submitdelete{font-size:11px;}#cancel-save{color:#f00;text-decoration:underline;font-size:11px;margin-left:20px;margin-top:5px;}#cancel-save:hover{background-color:#F00;color:#fff;}.button-controls{float:left;}.add-to-menu{float:right;}#manage-menu .inside{padding:0;}#create-menu-name{width:159px;}#available-links{margin:15px 0 0;}#available-links dt{display:block;}#add-custom-link .howto{font-size:11px;}#add-custom-link label span{display:block;float:left;margin-top:5px;padding-right:5px;}.menu-item-textbox{float:right;width:220px;}.howto span{margin-top:4px;display:block;float:left;}.show-all,.hide-all{cursor:pointer;}.hide-all{display:none;}.quick-search{width:190px;}.list-wrap{display:none;clear:both;}.list-container{max-height:200px;overflow-y:auto;padding:10px 10px 5px;border:1px solid #DFDFDF;-moz-border-radius:4px;}.postbox p.submit{margin-bottom:0;}.list li{display:none;margin:0;margin-bottom:5px;}.list li .menu-item-title{cursor:pointer;display:block;}.list li .menu-item-title input{margin-right:3px;margin-top:-3px;}.list li ul li .menu-item-title{margin-left:14px;}.list li ul li ul li .menu-item-title{margin-left:28px;}.list li ul li ul li ul li .menu-item-title{margin-left:42px;}.list li ul li ul li ul li ul li .menu-item-title{margin-left:56px;}.list li ul li ul li ul li ul li ul li .menu-item-title{margin-left:70px;}.list li ul li ul li ul li ul li ul li ul li .menu-item-title{margin-left:84px;}.list li ul li ul li ul li ul li ul li ul li ul li .menu-item-title{margin-left:98px;}.list li ul li ul li ul li ul li ul li ul li ul li ul li .menu-item-title{margin-left:112px;}#menu-container .inside{padding-bottom:10px;}.menu ul{width:100%;}.menu li{margin:0;}.menu li dl dt{-webkit-border-bottom-left-radius:6px;-webkit-border-bottom-right-radius:6px;-webkit-border-top-left-radius:6px;-webkit-border-top-right-radius:6px;border-bottom-left-radius:6px;border-bottom-right-radius:6px;border-top-left-radius:6px;border-top-right-radius:6px;-moz-border-radius-bottomleft:6px;-moz-border-radius-bottomright:6px;-moz-border-radius-topleft:6px;-moz-border-radius-topright:6px;border:1px solid #E6E6E6;position:relative;padding-left:10px;background-color:#f1f1f1;height:35px;line-height:35px;}.menu li dl dt:hover{cursor:move;}.menu li ul li{margin-left:20px;opacity:.7;}.menu li ul li ul li{opacity:.9;}.menu li ul li ul li ul li{opacity:.9;}.menu li ul li ul li ul li ul li{opacity:.95;}.dropzone{height:7px;margin:3px 0 3px 0;}.ui-draggable-dragging{width:600px;}.item-type{text-transform:uppercase;font-size:11px;color:#999;padding-right:10px;}.item-controls{font-size:11px;position:absolute;right:15px;top:-1px;}.item-controls a{text-decoration:none;}.item-controls a:hover{cursor:pointer;}.item-controls .menu-item-delete:hover{color:#f00;}#menu-item-settings{display:none;}#cancel-save{cursor:pointer;}#cancel-save:hover{color:#fff!important;}#update-menu-item{color:#fff!important;}#update-menu-item:hover,#update-menu-item:active,#update-menu-item:focus{color:#eaf2fa!important;border-color:#13455b!important;}
    2  No newline at end of file
     1#menu-management{clear:both;}#menu-management .inside{padding:0 10px;}#menu-container .submit{margin:0 0 10px;padding:0;}.submitdelete{font-size:11px;}#cancel-save{color:#f00;text-decoration:underline;font-size:11px;margin-left:20px;margin-top:5px;}#cancel-save:hover{background-color:#F00;color:#fff;}.list-controls{float:left;}.add-to-menu{float:right;}.button-controls{margin:10px 0;}.show-all,.hide-all{cursor:pointer;}.hide-all{display:none;}#create-menu-name{width:159px;}#manage-menu .inside{padding:0;}#available-links dt{display:block;}#add-custom-link .howto{font-size:11px;}#add-custom-link label span{display:block;float:left;margin-top:5px;padding-right:5px;}.menu-item-textbox{float:right;width:220px;}.howto span{margin-top:4px;display:block;float:left;}.quick-search{width:190px;}.list-wrap{display:none;clear:both;margin-bottom:10px;}.list-container{max-height:200px;overflow-y:auto;padding:10px 10px 5px;border:1px solid #DFDFDF;-moz-border-radius:4px;}.postbox p.submit{margin-bottom:0;}.list li{display:none;margin:0;margin-bottom:5px;}.list li .menu-item-title{cursor:pointer;display:block;}.list li .menu-item-title input{margin-right:3px;margin-top:-3px;}.list li ul li .menu-item-title{margin-left:14px;}.list li ul li ul li .menu-item-title{margin-left:28px;}.list li ul li ul li ul li .menu-item-title{margin-left:42px;}.list li ul li ul li ul li ul li .menu-item-title{margin-left:56px;}.list li ul li ul li ul li ul li ul li .menu-item-title{margin-left:70px;}.list li ul li ul li ul li ul li ul li ul li .menu-item-title{margin-left:84px;}.list li ul li ul li ul li ul li ul li ul li ul li .menu-item-title{margin-left:98px;}.list li ul li ul li ul li ul li ul li ul li ul li ul li .menu-item-title{margin-left:112px;}#menu-container .inside{padding-bottom:10px;}.menu ul{width:100%;}.menu li{margin:0;}.menu li dl dt{-webkit-border-radius:6px;border-radius:6px;-moz-border-radius:6px;border:1px solid #E6E6E6;position:relative;padding-left:10px;background-color:#f1f1f1;height:35px;line-height:35px;}.menu li dl dt:hover{cursor:move;}.menu li ul li{margin-left:20px;opacity:.7;}.menu li ul li ul li{opacity:.9;}.menu li ul li ul li ul li{opacity:.9;}.menu li ul li ul li ul li ul li{opacity:.95;}.dropzone{height:7px;margin:3px 0 3px 0;}.ui-draggable-dragging{width:600px;}.item-type{text-transform:uppercase;font-size:11px;color:#999;padding-right:10px;}.item-controls{font-size:11px;position:absolute;right:15px;top:-1px;}.item-controls a{text-decoration:none;}.item-controls a:hover{cursor:pointer;}.item-controls .menu-item-delete:hover{color:#f00;}#menu-item-settings{display:none;}#cancel-save{cursor:pointer;}#cancel-save:hover{color:#fff!important;}#update-menu-item{color:#fff!important;}#update-menu-item:hover,#update-menu-item:active,#update-menu-item:focus{color:#eaf2fa!important;border-color:#13455b!important;}.button-controls:after,#menu-item-url-wrap:after,#menu-item-name-wrap:after{content:".";display:block;height:0;clear:both;visibility:hidden;}.button-controls,#menu-item-url-wrap,#menu-item-name-wrap{display:block;}
     2 No newline at end of file
  • wp-admin/css/nav-menu.dev.css

     
    2020#cancel-save:hover { background-color: #FF0000; color: #fff; }
    2121
    2222/* Button Secondary Actions */
    23 .button-controls { float: left; }
     23.list-controls { float: left; }
    2424.add-to-menu { float: right; }
     25.button-controls { margin: 10px 0; }
     26.show-all, .hide-all { cursor: pointer; }
     27.hide-all { display: none; }
    2528
    26 #manage-menu .inside { padding: 0px 0px; }
    27 
    2829/* Create Menu */
    2930#create-menu-name { width: 159px; }
     31#manage-menu .inside { padding: 0px 0px; }
    3032
    3133/* Custom Links */
    32 #available-links { margin: 15px 0px 0px; }
    3334#available-links dt { display: block; }
    3435#add-custom-link .howto { font-size: 11px; }
    3536#add-custom-link label span { display: block; float: left; margin-top: 5px; padding-right: 5px; }
    3637.menu-item-textbox { float: right; width: 220px; }
    3738.howto span { margin-top: 4px; display: block; float: left; }
    3839
    39 /* Pages/Categories */
    40 .show-all, .hide-all { cursor: pointer; }
    41 .hide-all { display: none; }
    42 
     40/* Menu item types */
    4341.quick-search { width: 190px; }
    44 .list-wrap { display: none; clear: both; }
     42.list-wrap { display: none; clear: both; margin-bottom: 10px; }
    4543.list-container { max-height: 200px; overflow-y: auto; padding: 10px 10px 5px; border: 1px solid #DFDFDF; -moz-border-radius: 4px; }
    4644.postbox p.submit { margin-bottom: 0; }
    4745
     
    6058.list li ul li ul li ul li ul li ul li ul li ul li .menu-item-title  { margin-left: 98px; }
    6159.list li ul li ul li ul li ul li ul li ul li ul li ul li .menu-item-title  { margin-left: 112px; }
    6260
    63 /* Menu */
     61/* Nav Menu */
    6462#menu-container .inside { padding-bottom: 10px; }
    6563
    6664.menu ul { width: 100%; }
    6765.menu li { margin: 0; }
    68 .menu li dl dt { -webkit-border-bottom-left-radius: 6px; -webkit-border-bottom-right-radius: 6px; -webkit-border-top-left-radius: 6px; -webkit-border-top-right-radius: 6px; border-bottom-left-radius: 6px; border-bottom-right-radius: 6px; border-top-left-radius: 6px; border-top-right-radius: 6px; -moz-border-radius-bottomleft: 6px; -moz-border-radius-bottomright: 6px; -moz-border-radius-topleft: 6px; -moz-border-radius-topright: 6px; border: 1px solid #E6E6E6;position: relative; padding-left:10px; background-color: #f1f1f1; height: 35px; line-height: 35px; }
     66.menu li dl dt { -webkit-border-radius: 6px; border-radius: 6px; -moz-border-radius: 6px; border: 1px solid #E6E6E6; position: relative; padding-left: 10px; background-color: #f1f1f1; height: 35px; line-height: 35px; }
    6967.menu li dl dt:hover { cursor: move; }
    7068
    7169.menu li .item-title { }
     
    7876.dropzone { height: 7px; margin: 3px 0 3px 0; }
    7977.ui-draggable-dragging  { width: 600px; }
    8078
    81 /* Menu Controls */
     79/* Menu item controls */
    8280.item-type { text-transform: uppercase; font-size: 11px; color: #999999; padding-right: 10px; }
    8381.item-controls { font-size: 11px; position: absolute; right: 15px; top: -1px; }
    8482.item-controls a { text-decoration: none; }
     
    9290#update-menu-item { color: #fff !important; }
    9391#update-menu-item:hover,
    9492#update-menu-item:active,
    95 #update-menu-item:focus { color: #eaf2fa !important; border-color: #13455b !important; }
    96  No newline at end of file
     93#update-menu-item:focus { color: #eaf2fa !important; border-color: #13455b !important; }
     94
     95/* Clearfix */
     96.button-controls:after, #menu-item-url-wrap:after, #menu-item-name-wrap:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
     97.button-controls, #menu-item-url-wrap, #menu-item-name-wrap { display: block; }
     98 No newline at end of file