WordPress.org

Make WordPress Core

Ticket #12946: 12946.diff

File 12946.diff, 5.6 KB (added by nacin, 5 years ago)
  • wp-content/themes/twentyten/functions.php

     
    284284} 
    285285endif; 
    286286 
    287 if ( ! function_exists( 'twentyten_cat_list' ) ) : 
    288 /** 
    289  * Returns the list of categories 
    290  * 
    291  * Returns the list of categories based on if we are or are 
    292  * not browsing a category archive page. 
    293  * 
    294  * @uses twentyten_term_list 
    295  * 
    296  * @return string 
    297  */ 
    298 function twentyten_cat_list() { 
    299         return twentyten_term_list( 'category', ', ', __( 'Posted in %s', 'twentyten' ), __( 'Also posted in %s', 'twentyten' ) ); 
    300 } 
    301 endif; 
    302287 
    303 if ( ! function_exists( 'twentyten_tag_list' ) ) : 
    304 /** 
    305  * Returns the list of tags 
    306  * 
    307  * Returns the list of tags based on if we are or are not 
    308  * browsing a tag archive page 
    309  * 
    310  * @uses twentyten_term_list 
    311  * 
    312  * @return string 
    313  */ 
    314 function twentyten_tag_list() { 
    315         return twentyten_term_list( 'post_tag', ', ', __( 'Tagged %s', 'twentyten' ), __( 'Also tagged %s', 'twentyten' ) ); 
     288add_filter( 'term_links-category', 'twentyten_term_filter' ); 
     289add_filter( 'term_links-post_tag', 'twentyten_term_filter' ); 
     290function twentyten_term_filter( $term_links ) { 
     291        global $wp_query; 
     292        if ( ! is_tax() && ! is_category() && ! is_tag() ) 
     293                return $term_links; 
     294        $term = $wp_query->get_queried_object(); 
     295        if ( is_wp_error( $term ) ) 
     296                return $term_links; 
     297        if ( isset( $term_links[ $term->slug ] ) ) 
     298                unset( $term_links[ $term->slug ] );     
     299        return $term_links; 
    316300} 
    317 endif; 
    318301 
    319  
    320 if ( ! function_exists( 'twentyten_term_list' ) ) : 
    321302/** 
    322  * Returns the list of taxonomy items in multiple ways 
    323  * 
    324  * Returns the list of taxonomy items differently based on 
    325  * if we are browsing a term archive page or a different 
    326  * type of page.  If browsing a term archive page and the 
    327  * post has no other taxonomied terms, it returns empty 
    328  * 
    329  * @return string 
    330  */ 
    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 /** 
    359303 * Register widgetized areas, including two sidebars and four widget-ready columns in the footer. 
    360304 * 
    361305 * To override twentyten_widgets_init() in a child theme, remove the action hook and add your own 
  • wp-content/themes/twentyten/loop.php

     
    142142        <?php endif; ?> 
    143143 
    144144                        <div class="entry-utility"> 
    145                                 <span class="cat-links"><span class="entry-utility-prep entry-utility-prep-cat-links"><?php echo twentyten_cat_list(); ?></span></span> 
    146                                 <span class="meta-sep"> | </span> 
    147                                 <?php $tags_text = twentyten_tag_list(); ?> 
    148                                 <?php if ( ! empty( $tags_text ) ) : ?> 
    149                                 <span class="tag-links"><span class="entry-utility-prep entry-utility-prep-tag-links"><?php echo $tags_text; ?></span></span> 
    150                                 <span class="meta-sep"> | </span> 
    151                                 <?php endif; //$tags_text ?> 
     145                                <?php $also_posted_in = is_category() ? __( 'Also posted in', 'twentyten' ) : __( 'Posted in', 'twentyten' ); 
     146                                echo get_the_term_list( 0, 'category', '<span class="cat-links"><span class="entry-utility-prep entry-utility-prep-cat-links">' . $also_posted_in . ' ', ', ', '</span></span> <span class="meta-sep"> | </span>' ); 
     147                                $also_tagged = ( is_tag() ) ? __( 'Also tagged', 'twentyten' ) : __( 'Tagged', 'twentyten' ); 
     148                                the_tags( '<span class="tag-links"><span class="entry-utility-prep entry-utility-prep-tag-links">' . $also_tagged . ' ', ', ', '</span></span> <span class="meta-sep"> | </span>' ); ?> 
    152149                                <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span> 
    153150                                <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?> 
    154151                        </div><!-- #entry-utility --> 
  • wp-includes/category-template.php

     
    939939                $link = get_term_link( $term, $taxonomy ); 
    940940                if ( is_wp_error( $link ) ) 
    941941                        return $link; 
    942                 $term_links[] = '<a href="' . $link . '" rel="tag">' . $term->name . '</a>'; 
     942                $term_links[ $term->slug ] = '<a href="' . $link . '" rel="tag">' . $term->name . '</a>'; 
    943943        } 
    944944 
    945945        $term_links = apply_filters( "term_links-$taxonomy", $term_links ); 
    946946 
     947        if ( empty( $term_links ) ) 
     948                return ''; 
    947949        return $before . join( $sep, $term_links ) . $after; 
    948950} 
    949951