Make WordPress Core

Ticket #18660: 18660.diff

File 18660.diff, 2.6 KB (added by markjaquith, 14 years ago)
  • wp-includes/link-template.php

    function get_edit_profile_url( $user, $scheme = 'admin' ) { 
    23552355}
    23562356
    23572357/**
    2358  * Output rel=canonical for singular queries
     2358 * Output rel=canonical
    23592359 *
    23602360 * @package WordPress
    23612361 * @since 2.9.0
    23622362*/
    23632363function rel_canonical() {
    2364         if ( !is_singular() )
    2365                 return;
     2364        $link = false;
     2365        $pagination_type = false;
     2366
     2367        if ( is_singular() ) {
     2368                $link = get_permalink( get_queried_object() );
     2369                if ( get_query_var('page') > 1 ) {
     2370                        if ( !$wp_rewrite->using_permalinks() ) {
     2371                                $link = add_query_arg( 'page', get_query_var('page'), $link );
     2372                        } else {
     2373                                $link = user_trailingslashit( trailingslashit( $link ) . get_query_var( 'page' ), 'single_paged');
     2374                        }
     2375                }
     2376        } else {
     2377                if ( is_front_page() ) {
     2378                        $link = home_url( '/' );
     2379                } else if ( is_home() && "page" == get_option('show_on_front') ) {
     2380                        $link = get_permalink( get_option( 'page_for_posts' ) );
     2381                } else if ( is_tax() || is_tag() || is_category() ) {
     2382                        $term = get_queried_object();
     2383                        $link = get_term_link( $term, $term->taxonomy );
     2384                } else if ( is_post_type_archive() ) {
     2385                        $link = get_post_type_archive_link( get_post_type() );
     2386                } else if ( is_author() ) {
     2387                        $link = get_author_posts_url( get_query_var('author') );
     2388                } else if ( is_archive() ) {
     2389                        if ( is_date() ) {
     2390                                if ( is_day() ) {
     2391                                        $link = get_day_link( get_query_var('year'), get_query_var('monthnum'), get_query_var('day') );
     2392                                } else if ( is_month() ) {
     2393                                        $link = get_month_link( get_query_var('year'), get_query_var('monthnum') );
     2394                                } else if ( is_year() ) {
     2395                                        $link = get_year_link( get_query_var('year') );
     2396                                }
     2397                        }
     2398                }
     2399               
     2400                if ( $link && get_query_var( 'paged' ) > 1 ) {
     2401                        global $wp_rewrite;
     2402                        if ( !$wp_rewrite->using_permalinks() ) {
     2403                                $link = add_query_arg( 'paged', get_query_var( 'paged' ), $link );
     2404                        } else {
     2405                                $link = user_trailingslashit( trailingslashit( $link ) . trailingslashit( $wp_rewrite->pagination_base ) . get_query_var( 'paged' ), 'paged' );
     2406                        }
     2407                }
     2408        }
    23662409
    2367         global $wp_the_query;
    2368         if ( !$id = $wp_the_query->get_queried_object_id() )
    2369                 return;
     2410        $link = apply_filters( 'rel_canonical', $link );
    23702411
    2371         $link = get_permalink( $id );
    2372         echo "<link rel='canonical' href='$link' />\n";
     2412        if ( $link )
     2413                echo "<link rel='canonical' href='" . esc_url( $link ) . "' />\n";
    23732414}
    23742415
    23752416/**
    function the_shortlink( $text = '', $title = '', $before = '', $after = '' ) { 
    24852526        }
    24862527}
    24872528
    2488 ?>
     2529?>
     2530 No newline at end of file