Making WordPress.org

Changeset 10858


Ignore:
Timestamp:
03/29/2021 07:10:25 AM (3 years ago)
Author:
coffee2code
Message:

Jobs: Output rel="canonical" link for home page.

Props jonoaldersonwp, coffee2code.
Fixes #5673.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/jobs.wordpress.net/public_html/wp-content/plugins/jobswp/jobswp.php

    r10856 r10858  
    131131
    132132        add_filter( 'wp_sitemaps_add_provider',       array( $this, 'disable_users_sitemap' ), 10, 2 );
     133
     134        add_action( 'wp_head',                        array( $this, 'rel_canonical_link' ) );
    133135    }
    134136
     
    10721074        return $provider;
    10731075    }
     1076
     1077    /**
     1078     * Outputs a rel="canonical" link tag.
     1079     */
     1080    public function rel_canonical_link() {
     1081        $url = '';
     1082
     1083        if ( is_front_page() ) {
     1084            $url = home_url( '/' );
     1085        }
     1086
     1087        if ( $url ) {
     1088            printf( '<link rel="canonical" href="%s" />' . "\n", esc_url( $url ) );
     1089        }
     1090    }
     1091
    10741092}
    10751093
Note: See TracChangeset for help on using the changeset viewer.