WordPress.org

Making WordPress.org

Changeset 9940


Ignore:
Timestamp:
05/29/2020 01:56:01 AM (6 weeks ago)
Author:
dd32
Message:

Developer: Remove the rel="canonical" implementation that can output incorrect links on some requests.
This will fall back to using the wporg-seo canonical implementation now instead.

See #5173.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/head.php

    r9758 r9940  
    2424        add_filter( 'document_title_parts',     array( __CLASS__, 'document_title' ) );
    2525        add_filter( 'document_title_separator', array( __CLASS__, 'document_title_separator' ) );
    26         add_action( 'wp_head',                  array( __CLASS__, 'rel_canonical' ), 9 );
    2726        add_action( 'wp_head',                  array( __CLASS__, 'output_head_tags' ), 2 );
    2827    }
     
    179178    }
    180179
    181     /**
    182      * Outputs `<link rel="canonical">` tags where appropriate.
    183      */
    184     public static function rel_canonical() {
    185         $canonical = false;
    186         $queried_object = get_queried_object();
    187 
    188         if ( is_tax() || is_tag() || is_category() ) {
    189             $canonical = get_term_link( $queried_object );
    190         } elseif ( is_post_type_archive() ) {
    191             $canonical = get_post_type_archive_link( $queried_object->name );
    192         }
    193 
    194         if ( $canonical && get_query_var( 'paged' ) > 1 ) {
    195             $canonical .= 'page/' . (int) get_query_var( 'paged' ) . '/';
    196         }
    197 
    198         if ( $canonical ) {
    199             printf( '<link rel="canonical" href="%s">' . "\n", esc_url( $canonical ) );
    200         }
    201     }
    202 
    203180} // DevHub_Head
    204181
Note: See TracChangeset for help on using the changeset viewer.