Changeset 9940
- Timestamp:
- 05/29/2020 01:56:01 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/head.php
r9758 r9940 24 24 add_filter( 'document_title_parts', array( __CLASS__, 'document_title' ) ); 25 25 add_filter( 'document_title_separator', array( __CLASS__, 'document_title_separator' ) ); 26 add_action( 'wp_head', array( __CLASS__, 'rel_canonical' ), 9 );27 26 add_action( 'wp_head', array( __CLASS__, 'output_head_tags' ), 2 ); 28 27 } … … 179 178 } 180 179 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 203 180 } // DevHub_Head 204 181
Note: See TracChangeset
for help on using the changeset viewer.