Changeset 14384 for trunk/wp-content/themes/twentyten/functions.php
- Timestamp:
- 05/03/2010 07:16:47 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-content/themes/twentyten/functions.php
r14374 r14384 285 285 endif; 286 286 287 if ( ! function_exists( 'twentyten_cat_list' ) ) :288 /**289 * Returns the list of categories290 *291 * Returns the list of categories based on if we are or are292 * not browsing a category archive page.293 *294 * @uses twentyten_term_list295 *296 * @return string297 */298 function twentyten_cat_list() {299 return twentyten_term_list( 'category', ', ', __( 'Posted in %s', 'twentyten' ), __( 'Also posted in %s', 'twentyten' ) );300 }301 endif;302 303 if ( ! function_exists( 'twentyten_tag_list' ) ) :304 /**305 * Returns the list of tags306 *307 * Returns the list of tags based on if we are or are not308 * browsing a tag archive page309 *310 * @uses twentyten_term_list311 *312 * @return string313 */314 function twentyten_tag_list() {315 return twentyten_term_list( 'post_tag', ', ', __( 'Tagged %s', 'twentyten' ), __( 'Also tagged %s', 'twentyten' ) );316 }317 endif;318 319 320 if ( ! function_exists( 'twentyten_term_list' ) ) :321 /**322 * Returns the list of taxonomy items in multiple ways323 *324 * Returns the list of taxonomy items differently based on325 * if we are browsing a term archive page or a different326 * type of page. If browsing a term archive page and the327 * post has no other taxonomied terms, it returns empty328 *329 * @return string330 */331 function twentyten_term_list( $taxonomy, $glue = ', ', $text = '', $also_text = '' ) {332 global $wp_query, $post;333 $current_term = $wp_query->get_queried_object();334 $terms = wp_get_object_terms( $post->ID, $taxonomy );335 // If we're viewing a Taxonomy page..336 if ( isset( $current_term->taxonomy ) && $taxonomy == $current_term->taxonomy ) {337 // Remove the term from display.338 foreach ( (array) $terms as $key => $term ) {339 if ( $term->term_id == $current_term->term_id ) {340 unset( $terms[$key] );341 break;342 }343 }344 // Change to Also text as we've now removed something from the terms list.345 $text = $also_text;346 }347 $tlist = array();348 $rel = 'category' == $taxonomy ? 'rel="category"' : 'rel="tag"';349 foreach ( (array) $terms as $term ) {350 $tlist[] = '<a href="' . get_term_link( $term, $taxonomy ) . '" title="' . esc_attr( sprintf( __( 'View all posts in %s', 'twentyten' ), $term->name ) ) . '" ' . $rel . '>' . $term->name . '</a>';351 }352 if ( ! empty( $tlist ) )353 return sprintf( $text, join( $glue, $tlist ) );354 return '';355 }356 endif;357 358 287 /** 359 288 * Register widgetized areas, including two sidebars and four widget-ready columns in the footer. … … 440 369 } 441 370 add_action( 'widgets_init', 'twentyten_remove_recent_comments_style' ); 371 372 /** 373 * Get the URL of the next image in a gallery for attachment pages 374 */ 375 function twentyten_get_next_attachment_url() { 376 global $post; 377 $post = get_post($post); 378 $attachments = array_values(get_children( array('post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') )); 379 380 foreach ( $attachments as $k => $attachment ) 381 if ( $attachment->ID == $post->ID ) 382 break; 383 384 $k = $k + 1; 385 386 if ( isset($attachments[$k]) ) { 387 return get_attachment_link($attachments[$k]->ID); 388 } else { 389 return get_permalink($post->post_parent); 390 } 391 }
Note: See TracChangeset
for help on using the changeset viewer.