Changeset 13802 for trunk/wp-includes/classes.php
- Timestamp:
- 03/22/2010 07:56:16 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/classes.php
r13725 r13802 935 935 $children_elements[ $e->$parent_field ][] = $e; 936 936 } 937 937 938 938 /* 939 939 * when none of the elements is top level … … 1125 1125 1126 1126 /** 1127 * Create HTML list of nav menu items. 1128 * 1129 * @package WordPress 1130 * @since 3.0.0 1131 * @uses Walker 1132 */ 1133 class 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 /** 1127 1223 * Create HTML list of pages. 1128 1224 *
Note: See TracChangeset
for help on using the changeset viewer.