Making WordPress.org


Ignore:
Timestamp:
06/17/2016 12:04:06 PM (8 years ago)
Author:
obenland
Message:

Plugin Directory: Redirect tags to their new categories.

Redirects to a search if it's not one of the 1,000 most popular tags, or to the
home page if the tags page was requested.

See #1584.

File:
1 edited

Legend:

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

    r3408 r3409  
    22namespace WordPressdotorg\Plugin_Directory;
    33use WordPressdotorg\Plugin_Directory\Admin\Customizations;
     4use WordPressdotorg\Plugin_Directory\CLI\Tag_To_Category;
    45
    56/**
     
    567568
    568569            // [1] => plugins [2] => example-plugin-name [2..] => random()
    569             $plugin_slug = explode( '/', $_SERVER['REQUEST_URI'] )[2];
    570 
    571             if ( $plugin = self::get_plugin_post( $plugin_slug ) ) {
     570            $path = explode( '/', $_SERVER['REQUEST_URI'] );
     571
     572            if ( 'tags' === $path[2] ) {
     573                if ( isset( Tag_To_Category::$map[ $path[3] ] ) ) {
     574                    wp_safe_redirect( home_url( '/category/' . Tag_To_Category::$map[ $path[3] ] . '/' ) );
     575                    die();
     576                } else if ( isset( $path[3] ) ) {
     577                    wp_safe_redirect( home_url( '/search/' . $path[3] . '/' ) );
     578                    die();
     579                } else {
     580                    wp_safe_redirect( home_url( '/' ) );
     581                    die();
     582                }
     583            }
     584
     585            if ( $plugin = self::get_plugin_post( $path[2] ) ) {
    572586                $is_disabled = in_array( $plugin->post_status, array( 'disabled', 'closed' ), true );
    573587
Note: See TracChangeset for help on using the changeset viewer.