Making WordPress.org

Changeset 897


Ignore:
Timestamp:
10/10/2014 10:16:40 PM (7 years ago)
Author:
coffee2code
Message:

Code Reference: redirect pluralized slugs for handbooks to correct singularized version

File:
1 edited

Legend:

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

    r896 r897  
    2525        add_action( 'template_redirect', array( __CLASS__, 'redirect_handbook' ) );
    2626        add_action( 'template_redirect', array( __CLASS__, 'redirect_resources' ) );
     27        add_action( 'template_redirect', array( __CLASS__, 'redirect_pluralized_handbooks' ), 1 );
    2728    }
    2829
     
    6465    }
    6566
     67    /**
     68     * Redirects requests for the pluralized slugs of the handbooks.
     69     *
     70     * Note: this is a convenience redirect of just the naked slugs and not a
     71     * fix for any deployed links.
     72     */
     73    public static function redirect_pluralized_handbooks() {
     74        $name = get_query_var( 'name' );
     75
     76        // '/plugins' => '/plugin'
     77        if ( 'plugins' == $name ) {
     78            wp_redirect( get_post_type_archive_link( 'plugin-handbook' ), 301 );
     79            exit();
     80        }
     81
     82        // '/themes' => '/theme'
     83        if ( 'themes' == $name ) {
     84            wp_redirect( get_post_type_archive_link( 'theme-handbook' ), 301 );
     85            exit();
     86        }
     87    }
     88
    6689} // DevHub_Redirects
    6790
Note: See TracChangeset for help on using the changeset viewer.