Making WordPress.org

Changeset 10267


Ignore:
Timestamp:
09/16/2020 06:54:10 AM (4 years ago)
Author:
dd32
Message:

Plugin Directory: Redirect plugins to their canonical location, avoiding mixed case urls.

Fixes #5324.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php

    r10257 r10267  
    977977
    978978    /**
    979      * Adjust the login URL to point back to whatever part of the support forums we're
     979     * Adjust the login URL to point back to whatever part of the plugin directory we're
    980980     * currently looking at. This allows the redirect to come back to the same place
    981981     * instead of the main /support URL by default.
    982982     */
    983983    public function fix_login_url( $login_url, $redirect, $force_reauth ) {
    984         // modify the redirect_to for the support forums to point to the current page
     984        // modify the redirect_to for the plugin directory to point to the current page
    985985        if ( 0 === strpos( $_SERVER['REQUEST_URI'], '/plugins' ) ) {
    986986            // Note that this is not normal because of the code in /mu-plugins/wporg-sso/class-wporg-sso.php.
     
    10041004        return $login_url;
    10051005    }
    1006 
    10071006
    10081007    /**
     
    12701269     */
    12711270    function custom_redirects() {
     1271        global $wp_query;
     1272
    12721273        // Handle a redirect for /$plugin/$tab_name/ to /$plugin/#$tab_name.
    12731274        if ( get_query_var( 'redirect_plugin' ) && get_query_var( 'redirect_plugin_tab' ) ) {
     
    13341335        }
    13351336
     1337        // Redirect mixed-case plugin names to the canonical location.
     1338        if (
     1339            get_query_var( 'name' ) && // A sanitized lowercase value is here
     1340            is_singular() &&
     1341            ! empty( $wp_query->query['name'] ) && // The raw value is available here.
     1342            get_query_var( 'name' ) != $wp_query->query['name']
     1343        ) {
     1344            $url = get_permalink();
     1345            if ( get_query_var( 'plugin_advanced' ) ) {
     1346                $url .= 'advanced/';
     1347            }
     1348
     1349            wp_safe_redirect( $url, 301 );
     1350            die();
     1351        }
     1352
    13361353        // If it's an old search query, handle that too.
    13371354        if ( 'search.php' == get_query_var( 'name' ) && isset( $_GET['q'] ) ) {
     
    13821399        }
    13831400
    1384         // disable feeds
     1401        // Disable feeds
    13851402        if ( is_feed() ) {
    13861403            if ( isset( $_GET['feed'] ) ) {
Note: See TracChangeset for help on using the changeset viewer.