Making WordPress.org


Ignore:
Timestamp:
02/04/2020 12:16:34 AM (5 years ago)
Author:
dd32
Message:

Login: Add a Canonical header to the login screens.

Fixes #5004.

File:
1 edited

Legend:

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

    r9253 r9461  
    355355}
    356356add_action( 'login_purge_pending_registrations', 'wporg_login_purge_pending_registrations' );
     357
     358/**
     359 * Add a canonical tag to the login screens.
     360 */
     361function wporg_login_canonical_link() {
     362    $canonical = false;
     363
     364    // If the regular expression for this route is not matching, it's the canonical.
     365    if ( false === stripos( WP_WPOrg_SSO::$matched_route_regex, '(' ) ) {
     366        $canonical = site_url( WP_WPOrg_SSO::$matched_route_regex );
     367    }
     368
     369    if ( $canonical ) {
     370        printf( '<link rel="canonical" href="%s" />', esc_url( $canonical ) );
     371    }
     372}
     373add_action( 'login_head', 'wporg_login_canonical_link' );
     374add_action( 'wp_head', 'wporg_login_canonical_link' );
Note: See TracChangeset for help on using the changeset viewer.