Changeset 13743
- Timestamp:
- 03/17/2010 09:34:24 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/nav-menu-template.php
r13738 r13743 46 46 } 47 47 48 if ( !is_wp_error($menu) && $menu)48 if ( $menu && ! is_wp_error( $menu ) ) 49 49 $args->menu = $menu->term_id; 50 50 $nav_menu = ''; … … 52 52 if ( 'div' == $args->container ) { 53 53 $class = $args->container_class ? ' class="' . esc_attr($args->container_class) . '"' : ''; 54 54 55 55 if ( is_nav_menu($menu) ) { 56 56 $nav_menu .= '<div id="menu-' . $menu->slug . '"'. $class .'>'; … … 64 64 if ( 'div' == $args->container ) 65 65 $nav_menu .= '</div>'; 66 66 67 67 $nav_menu = apply_filters( 'wp_nav_menu', $nav_menu, $args ); 68 68 … … 86 86 $defaults = array( 'menu' => '', 'menu_class' => 'menu', 'context' => 'frontend', 87 87 'fallback_cb' => '', 'before_link' => '', 'after_link' => '', 'before_title' => '', 'after_title' => '', ); 88 88 89 89 $args = wp_parse_args( $args, $defaults ); 90 90 $args = apply_filters( 'wp_get_nav_menu_args', $args ); 91 91 $args = (object) $args; 92 92 93 93 // Variable setup 94 94 $nav_menu = ''; … … 97 97 $parent_stack = array(); 98 98 $parent_menu_order = array(); 99 99 100 100 // Get the menu object 101 101 $menu = wp_get_nav_menu_object( $args->menu ); 102 102 103 103 // If the menu exists, get it's items. 104 104 if ( $menu && !is_wp_error($menu) ) 105 105 $menu_items = wp_get_nav_menu_items( $menu->term_id, 'backend' ); 106 106 107 107 // If no menu was found or if the menu has no items, call the fallback_cb 108 108 if ( !$menu || is_wp_error($menu) || ( isset($menu_items) && empty($menu_items) ) ) { … … 112 112 } 113 113 } 114 114 115 115 foreach ( $menu_items as $key => $menu_item ) { 116 116 // Set up the $menu_item variables … … 120 120 $maybe_value = 'frontend' == $args->context ? '' : ' value="'. $menu_item->ID .'"'; 121 121 $classes = 'frontend' == $args->context ? ' class="menu-item-type-'. $type . $menu_item->li_class .'"' : ''; 122 122 123 123 $items .= '<li id="menu-item-'. $menu_item->ID .'"'. $maybe_value . $classes .'>'; 124 124 $items .= wp_get_nav_menu_item( $menu_item, $args->context, $args ); 125 125 126 126 // Indent children 127 127 $last_item = ( count( $menu_items ) == $menu_item->menu_order ); … … 142 142 } 143 143 } 144 144 145 145 // CSS class 146 146 $ul_class = $args->menu_class ? ' class="'. $args->menu_class .'"' : ''; 147 147 $nav_menu .= '<ul'. $ul_class .'>'; 148 148 149 149 // Allow plugins to hook into the menu to add their own <li>'s 150 150 if ( 'frontend' == $args->context ) { … … 155 155 $nav_menu .= $items; 156 156 } 157 157 158 158 $nav_menu .= '</ul>'; 159 159 160 160 return apply_filters( 'wp_get_nav_menu', $nav_menu ); 161 161 } … … 180 180 $attributes .= ( isset($menu_item->xfn) && '' != $menu_item->xfn ) ? ' rel="'. esc_attr($menu_item->xfn) .'"' : ''; 181 181 $attributes .= ( isset($menu_item->url) && '' != $menu_item->url ) ? ' href="'. esc_attr($menu_item->url) .'"' : ''; 182 182 183 183 $output .= esc_html( $args->before_link ); 184 184 $output .= '<a'. $attributes .'>'; … … 186 186 $output .= '</a>'; 187 187 $output .= esc_html( $args->after_link ); 188 189 break; 190 188 189 break; 190 191 191 case 'backend': 192 192 $output .= '<dl><dt>'; … … 205 205 } 206 206 $output .= '<span class="item-type">'. esc_html($label) .'</span>'; 207 207 208 208 // Actions 209 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 210 $output .= '<a class="item-delete" id="delete'. esc_attr( $menu_item->menu_order ) .'" value="'. esc_attr( $menu_item->menu_order ) .'">'. __('Delete') .'</a>'; 211 211 212 212 $output .= '</dt></dl>'; 213 213 214 214 // Menu Item Settings 215 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 ) .'" />'; … … 227 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 ) .'" />'; 228 228 break; 229 229 230 230 case 'custom': 231 231 $menu_id = 'menu-item-' . $menu_item->db_id; 232 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>'; 233 233 234 234 // Menu item hidden fields 235 235 $output .= '<input type="hidden" class="menu-item-db-id" value="'. esc_attr( $menu_item->db_id ) .'" />'; … … 246 246 $output .= '<input type="hidden" class="menu-item-xfn" value="'. esc_attr( $menu_item->xfn ) .'" />'; 247 247 break; 248 248 249 249 case 'taxonomy': 250 250 case 'post_type': 251 251 $menu_id = 'menu-item-' . $menu_item->db_id; 252 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 253 254 254 // Menu item hidden fields 255 255 $output .= '<input type="hidden" class="menu-item-db-id" value="0" />'; … … 263 263 break; 264 264 } 265 265 266 266 return $output; 267 267 }
Note: See TracChangeset
for help on using the changeset viewer.