Changeset 14248 for trunk/wp-includes/classes.php
- Timestamp:
- 04/27/2010 01:05:58 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/classes.php
r14246 r14248 1125 1125 1126 1126 /** 1127 * Create HTML list of nav menu items.1128 *1129 * @package WordPress1130 * @since 3.0.01131 * @uses Walker1132 */1133 class Walker_Nav_Menu extends Walker {1134 /**1135 * @see Walker::$tree_type1136 * @since 3.0.01137 * @var string1138 */1139 var $tree_type = array( 'post_type', 'taxonomy', 'custom' );1140 1141 /**1142 * @see Walker::$db_fields1143 * @since 3.0.01144 * @todo Decouple this.1145 * @var array1146 */1147 var $db_fields = array( 'parent' => 'post_parent', 'id' => 'object_id' );1148 1149 /**1150 * @see Walker::start_lvl()1151 * @since 3.0.01152 *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.01164 *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.01176 *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 object $args1182 */1183 function start_el(&$output, $item, $depth, $args) {1184 $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';1185 1186 $classes = $value = '';1187 if ( 'frontend' == $args->context ) {1188 global $wp_query;1189 1190 $classes = array( 'menu-item', 'menu-item-type-'. $item->type, $item->classes );1191 1192 if ( 'custom' != $item->object )1193 $classes[] = 'menu-item-object-'. $item->object;1194 1195 if ( $item->object_id == $wp_query->get_queried_object_id() )1196 $classes[] = 'current-menu-item';1197 1198 // @todo add classes for parent/child relationships1199 1200 $classes = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );1201 $classes = ' class="' . esc_attr( $classes ) . '"';1202 } else {1203 $value = ' value="' . $item->ID . '"';1204 }1205 1206 $output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $classes .'>' . wp_get_nav_menu_item( $item, $args->context, $args );1207 }1208 1209 /**1210 * @see Walker::end_el()1211 * @since 3.0.01212 *1213 * @param string $output Passed by reference. Used to append additional content.1214 * @param object $item Page data object. Not used.1215 * @param int $depth Depth of page. Not Used.1216 */1217 function end_el(&$output, $item, $depth) {1218 $output .= "</li>\n";1219 }1220 }1221 1222 /**1223 1127 * Create HTML list of pages. 1224 1128 *
Note: See TracChangeset
for help on using the changeset viewer.