Make WordPress Core


Ignore:
Timestamp:
02/14/2010 10:02:38 AM (17 years ago)
Author:
dd32
Message:

Replace $authordata usage with API, Restore "Also posted in.."/"Also tagged..." on taxonomy archives, Handle Excerpts for Asides correctly on Archives. See #9015

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/themes/twentyten/functions.php

    r13144 r13147  
    119119add_filter( 'gallery_style', 'twentyten_remove_gallery_css' );
    120120
    121 
    122 // For category lists on category archives: Returns other categories except the current one (redundant)
    123 function cats_meow( $glue ) {
    124         $current_cat = single_cat_title( '', false );
    125         $separator = "\n";
    126         $cats = explode( $separator, get_the_category_list($separator) );
    127         foreach ( $cats as $i => $str ) {
    128                 if ( strstr( $str, ">$current_cat<" ) ) {
    129                         unset( $cats[$i] );
    130                         break;
     121function twentyten_cat_list() {
     122        return twentyten_term_list('category', ', ', __('Posted in %s', 'twentyten'), __('Also posted in %s', 'twentyten') );
     123}
     124function twentyten_tag_list() {
     125        return twentyten_term_list('post_tag', ', ', __('Tagged %s', 'twentyten'), __('Also tagged %s', 'twentyten') );
     126}
     127function twentyten_term_list($taxonomy, $glue = ', ', $text = '', $also_text = '') {
     128        global $wp_query, $post;
     129        $current_term = $wp_query->queried_object;
     130        $terms = wp_get_object_terms($post->ID, $taxonomy);
     131        // If we're viewing a Taxonomy page..
     132        if ( isset($current_term->taxonomy) && $taxonomy == $current_term->taxonomy ) {
     133                // Remove the term from display.
     134                foreach ( (array)$terms as $key => $term ) {
     135                        if ( $term->term_id == $current_term->term_id ) {
     136                                unset($terms[$key]);
     137                                break;
     138                        }
    131139                }
     140                // Change to Also text as we've now removed something from the terms list.
     141                $text = $also_text;
    132142        }
    133         if ( empty($cats) )
    134                 return false;
    135 
    136         return trim( join( $glue, $cats ) );
    137 } // end cats_meow
    138 
    139 
    140 // For tag lists on tag archives: Returns other tags except the current one (redundant)
    141 function tag_ur_it( $glue ) {
    142         $current_tag = single_tag_title( '', '',  false );
    143         $separator = "\n";
    144         $tags = explode( $separator, get_the_tag_list( "", "$separator", "" ) );
    145         foreach ( $tags as $i => $str ) {
    146                 if ( strstr( $str, ">$current_tag<" ) ) {
    147                         unset( $tags[$i] );
    148                         break;
    149                 }
     143        $tlist = array();
     144        $rel = 'category' == $taxonomy ? 'rel="category"' : 'rel="tag"';
     145        foreach ( (array)$terms as $term ) {
     146                $tlist[] = '<a href="' . get_term_link( $term, $taxonomy ) . '" title="' . esc_attr( sprintf( __( 'View all posts in %s', 'twentyten' ), $term->name ) ) . '" ' . $rel . '>' . $term->name . '</a>';
    150147        }
    151         if ( empty($tags) )
    152                 return false;
    153 
    154         return trim( join( $glue, $tags ) );
    155 } // end tag_ur_it
     148        if ( !empty($tlist) )
     149                return sprintf($text, join($glue, $tlist));
     150        return '';
     151}
    156152
    157153// Register widgetized areas
Note: See TracChangeset for help on using the changeset viewer.