WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/17/2010 05:41:22 AM (9 years ago)
Author:
dd32
Message:

Merge Category/Tag URL creation/rewriting into general Taxonomy system. Removes the legacy handling for these url's. See #12659

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/category-template.php

    r15677 r15825  
    1111 *
    1212 * @since 1.0.0
    13  * @uses apply_filters() Calls 'category_link' filter on category link and category ID.
     13 * @see get_term_link()
    1414 *
    1515 * @param int $category_id Category ID.
     
    1717 */
    1818function get_category_link( $category_id ) {
    19     global $wp_rewrite;
    20     $catlink = $wp_rewrite->get_category_permastruct();
    21 
    22     if ( empty( $catlink ) ) {
    23         $catlink = home_url('?cat=' . $category_id);
    24     } else {
    25         $category = &get_category( $category_id );
    26         if ( is_wp_error( $category ) )
    27             return $category;
    28         $category_nicename = $category->slug;
    29 
    30         if ( $category->parent == $category_id ) // recursive recursion
    31             $category->parent = 0;
    32         elseif ($category->parent != 0 )
    33             $category_nicename = get_category_parents( $category->parent, false, '/', true ) . $category_nicename;
    34 
    35         $catlink = str_replace( '%category%', $category_nicename, $catlink );
    36         $catlink = home_url( user_trailingslashit( $catlink, 'category' ) );
    37     }
    38     return apply_filters( 'category_link', $catlink, $category_id );
     19    return get_term_link((int)$category_id, 'category');
    3920}
    4021
     
    771752 *
    772753 * @since 2.3.0
    773  * @uses apply_filters() Calls 'tag_link' with tag link and tag ID as parameters.
     754 * @see get_term_link()
    774755 *
    775756 * @param int $tag_id Tag (term) ID.
     
    777758 */
    778759function get_tag_link( $tag_id ) {
    779     global $wp_rewrite;
    780     $taglink = $wp_rewrite->get_tag_permastruct();
    781 
    782     $tag = &get_term( $tag_id, 'post_tag' );
    783     if ( is_wp_error( $tag ) )
    784         return $tag;
    785     $slug = $tag->slug;
    786 
    787     if ( empty( $taglink ) ) {
    788         $file = get_option( 'home' ) . '/';
    789         $taglink = $file . '?tag=' . $slug;
    790     } else {
    791         $taglink = str_replace( '%tag%', $slug, $taglink );
    792         $taglink = get_option( 'home' ) . user_trailingslashit( $taglink, 'category' );
    793     }
    794     return apply_filters( 'tag_link', $taglink, $tag_id );
     760    return get_term_link( (int)$tag_id, 'post_tag');
    795761}
    796762
Note: See TracChangeset for help on using the changeset viewer.