Making WordPress.org


Ignore:
Timestamp:
04/15/2020 10:12:33 PM (5 years ago)
Author:
coffee2code
Message:

Developer theme: Centralize page HEAD-related customizations into recently added inc/head.php file.

File:
1 edited

Legend:

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

    r9717 r9733  
    167167    add_filter( 'breadcrumb_trail_items',  __NAMESPACE__ . '\\breadcrumb_trail_items_for_handbook_root', 10, 2 );
    168168
    169     add_filter( 'document_title_separator', __NAMESPACE__ . '\\theme_title_separator', 10, 2 );
    170 
    171169    add_filter( 'syntaxhighlighter_htmlresult', __NAMESPACE__ . '\\syntaxhighlighter_htmlresult' );
    172 }
    173 
    174 /**
    175  * Customize the theme title separator.
    176  *
    177  * @return string
    178  */
    179 function theme_title_separator(){
    180     return '|';
    181170}
    182171
     
    420409}
    421410
    422 /**
    423  * Outputs `<link rel="canonical">` tags where appropriate.
    424  */
    425 function rel_canonical() {
    426     $canonical = false;
    427     $queried_object = get_queried_object();
    428 
    429     if ( is_tax() || is_tag() || is_category() ) {
    430         $canonical = get_term_link( $queried_object );
    431     } elseif ( is_post_type_archive() ) {
    432         $canonical = get_post_type_archive_link( $queried_object->name );
    433     }
    434 
    435     if ( $canonical && get_query_var( 'paged' ) > 1 ) {
    436         $canonical .= 'page/' . (int) get_query_var( 'paged' ) . '/';
    437     }
    438 
    439     if ( $canonical ) {
    440         printf( '<link rel="canonical" href="%s">' . "\n", esc_url( $canonical ) );
    441     }
    442 }
    443 add_action( 'wp_head', __NAMESPACE__ . '\rel_canonical', 9 );
    444 
Note: See TracChangeset for help on using the changeset viewer.