Making WordPress.org

Changeset 1674


Ignore:
Timestamp:
06/18/2015 06:59:30 PM (9 years ago)
Author:
ocean90
Message:

Translate: Remove a database query for slugs of translation sets in the routes plugin.

See https://glotpress.trac.wordpress.org/changeset/1052/.

Location:
sites/trunk/translate.wordpress.org/includes/gp-plugins/wporg-routes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/translate.wordpress.org/includes/gp-plugins/wporg-routes/routes/locale.php

    r1586 r1674  
    123123        }
    124124
     125        if ( 'default' !== $current_set_slug && ! isset( $set_slugs[ $current_set_slug ] ) ) {
     126            return $this->die_with_404();
     127        }
     128
    125129        if ( $set_slugs ) {
    126130            // Make default the first item.
  • sites/trunk/translate.wordpress.org/includes/gp-plugins/wporg-routes/wporg-routes.php

    r1586 r1674  
    1818
    1919    public function init() {
     20        $path = '(.+?)';
    2021        $locale = '(' . implode( '|', array_map( function( $locale ) { return $locale->slug; }, GP_Locales::locales() ) ) . ')';
    21         $set_slug = '(' . implode( '|', GP::$translation_set->existing_slugs() ) . ')';
    2222
    2323        /*
     
    2626         */
    2727        unset( GP::$router->urls['/'] );
    28         unset( GP::$router->urls["get:/languages/$locale/$set_slug"] );
     28        unset( GP::$router->urls["get:/languages/$locale/$path"] );
    2929        unset( GP::$router->urls["get:/languages/$locale"] );
    3030        unset( GP::$router->urls['get:/languages'] );
     
    3232        GP::$router->add( '/', array( 'GP_WPorg_Route_Index', 'get_index' ) );
    3333        GP::$router->add( '/languages', array( 'GP_WPorg_Route_Locale', 'get_locales' ) );
    34         GP::$router->add( "/languages/$locale/$set_slug/(.+?)", array( 'GP_WPorg_Route_Locale', 'get_locale_projects' ) );
    35         GP::$router->add( "/languages/$locale/$set_slug", array( 'GP_WPorg_Route_Locale', 'get_locale_projects' ) );
     34        GP::$router->add( "/languages/$locale/$path/$path", array( 'GP_WPorg_Route_Locale', 'get_locale_projects' ) );
     35        GP::$router->add( "/languages/$locale/$path", array( 'GP_WPorg_Route_Locale', 'get_locale_projects' ) );
    3636        GP::$router->add( "/languages/$locale", array( 'GP_WPorg_Route_Locale', 'get_locale_projects' ) );
    3737    }
Note: See TracChangeset for help on using the changeset viewer.