Making WordPress.org

Changeset 9829


Ignore:
Timestamp:
05/07/2020 12:52:06 AM (5 years ago)
Author:
dd32
Message:

Login: Add canonical tags for some sub-pages, correct the title for when wp-login.php is serving the page.

File:
1 edited

Legend:

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

    r9462 r9829  
    362362    $canonical = false;
    363363
    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 ?: '/' );
     364    $matching_route = stripos( WP_WPOrg_SSO::$matched_route_regex, '(' );
     365    if ( false === $matching_route ) {
     366        $canonical = home_url( WP_WPOrg_SSO::$matched_route_regex ?: '/' );
     367
     368    // Else, if there's a long enough slug followed by a `/`, that's a parent page.
     369    } elseif ( $matching_route >= 3 && '/' === substr( WP_WPOrg_SSO::$matched_route_regex, $matching_route + 1, 1 ) ) {
     370        $canonical = home_url( substr( WP_WPOrg_SSO::$matched_route_regex, 0, $matching_route ) );
     371
    367372    }
    368373
     
    373378add_action( 'login_head', 'wporg_login_canonical_link' );
    374379add_action( 'wp_head', 'wporg_login_canonical_link' );
     380
     381/**
     382 * Set the title for the wp-login.php page.
     383 */
     384function wporg_login_title() {
     385    return get_bloginfo( 'name', 'display' );
     386}
     387add_filter( 'login_title', 'wporg_login_title' );
Note: See TracChangeset for help on using the changeset viewer.