Changeset 3704 for trunk/wp-includes/template-functions-category.php
- Timestamp:
- 04/13/2006 04:40:48 AM (20 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/template-functions-category.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/template-functions-category.php
r3691 r3704 1 1 <?php 2 3 function walk_category_tree() { 4 $walker = new Walker_Category; 5 $args = func_get_args(); 6 return call_user_func_array(array(&$walker, 'walk'), $args); 7 } 8 9 function walk_category_dropdown_tree() { 10 $walker = new Walker_CategoryDropdown; 11 $args = func_get_args(); 12 return call_user_func_array(array(&$walker, 'walk'), $args); 13 } 2 14 3 15 function get_the_category($id = false) { … … 186 198 $depth = -1; // Flat. 187 199 188 $output .= walk_category_ tree($categories, $depth, '_category_dropdown_element', '', '', '', $selected, $r);200 $output .= walk_category_dropdown_tree($categories, $depth, $r); 189 201 $output .= "</select>\n"; 190 202 } … … 194 206 if ( $echo ) 195 207 echo $output; 196 197 return $output;198 }199 200 function _category_dropdown_element($output, $category, $depth, $selected, $args) {201 $pad = str_repeat(' ', $depth * 3);202 203 $cat_name = apply_filters('list_cats', $category->cat_name, $category);204 $output .= "\t<option value=\"".$category->cat_ID."\"";205 if ( $category->cat_ID == $selected )206 $output .= ' selected="selected"';207 $output .= '>';208 $output .= $cat_name;209 if ( $args['show_count'] )210 $output .= ' ('. $category->category_count .')';211 if ( $args['show_last_update'] ) {212 $format = 'Y-m-d';213 $output .= ' ' . gmdate($format, $category->last_update_timestamp);214 }215 $output .= "</option>\n";216 208 217 209 return $output; … … 246 238 } else { 247 239 global $wp_query; 248 $ current_category= $wp_query->get_queried_object_id();240 $r['current_category'] = $wp_query->get_queried_object_id(); 249 241 if ( $hierarchical ) 250 242 $depth = 0; // Walk the full depth. … … 252 244 $depth = -1; // Flat. 253 245 254 $output .= walk_category_tree($categories, $depth, '_category_list_element_start', '_category_list_element_end', '_category_list_level_start', '_category_list_level_end', $current_category,$r);246 $output .= walk_category_tree($categories, $depth, $r); 255 247 } 256 248 … … 259 251 260 252 echo apply_filters('list_cats', $output); 261 }262 263 function _category_list_level_start($output, $depth, $cat, $args) {264 if ( 'list' != $args['style'] )265 return $output;266 267 $indent = str_repeat("\t", $depth);268 $output .= "$indent<ul class='children'>\n";269 return $output;270 }271 272 function _category_list_level_end($output, $depth, $cat, $args) {273 if ( 'list' != $args['style'] )274 return $output;275 276 $indent = str_repeat("\t", $depth);277 $output .= "$indent</ul>\n";278 return $output;279 }280 281 function _category_list_element_start($output, $category, $depth, $current_category, $args) {282 extract($args);283 284 $link = '<a href="' . get_category_link($category->cat_ID) . '" ';285 if ( $use_desc_for_title == 0 || empty($category->category_description) )286 $link .= 'title="'. sprintf(__("View all posts filed under %s"), wp_specialchars($category->cat_name)) . '"';287 else288 $link .= 'title="' . wp_specialchars(apply_filters('category_description',$category->category_description,$category)) . '"';289 $link .= '>';290 $link .= apply_filters('list_cats', $category->cat_name, $category).'</a>';291 292 if ( (! empty($feed_image)) || (! empty($feed)) ) {293 $link .= ' ';294 295 if ( empty($feed_image) )296 $link .= '(';297 298 $link .= '<a href="' . get_category_rss_link(0, $category->cat_ID, $category->category_nicename) . '"';299 300 if ( !empty($feed) ) {301 $title = ' title="' . $feed . '"';302 $alt = ' alt="' . $feed . '"';303 $name = $feed;304 $link .= $title;305 }306 307 $link .= '>';308 309 if ( !empty($feed_image) )310 $link .= "<img src='$feed_image' $alt$title" . ' />';311 else312 $link .= $name;313 $link .= '</a>';314 if (empty($feed_image))315 $link .= ')';316 }317 318 if ( $show_count )319 $link .= ' ('.intval($category->category_count).')';320 321 if ( $show_date ) {322 $link .= ' ' . gmdate('Y-m-d', $category->last_update_timestamp);323 }324 325 if ( 'list' == $args['style'] ) {326 $output .= "\t<li";327 if ( ($category->cat_ID == $current_category) && is_category() )328 $output .= ' class="current-cat"';329 $output .= ">$link\n";330 } else {331 $output .= "\t$link<br />\n";332 }333 334 return $output;335 }336 337 function _category_list_element_end($output, $category, $depth, $cat, $args) {338 if ( 'list' != $args['style'] )339 return $output;340 341 $output .= "</li>\n";342 return $output;343 253 } 344 254
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)