Making WordPress.org

Changeset 4926


Ignore:
Timestamp:
02/18/2017 04:40:12 PM (8 years ago)
Author:
ocean90
Message:

Translate: Re-add locale glossary GET routes because of the /languages redirect route.

It's currently not possible to change the prefix of locale glossaries, see https://github.com/GlotPress/GlotPress-WP/issues/655.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/inc/class-plugin.php

    r4354 r4926  
    7777        $request_uri = GP::$router->request_uri();
    7878        $path = '(.+?)';
     79        $dir = '([^_/][^/]*)';
     80        $project = '([^/]*)/?';
     81
    7982        $locale = '(' . implode( '|', array_map( function( $locale ) { return $locale->slug; }, GP_Locales::locales() ) ) . ')';
    8083
     
    9598            GP::$router->prepend( '/projects/wp-themes/?', array( __NAMESPACE__ . '\Routes\Redirector', 'redirect_index' ) );
    9699
     100            // Re-add locale glossary GET routes because of the redirect route from above. https://github.com/GlotPress/GlotPress-WP/issues/655.
     101            GP::$router->prepend( "(/languages)/$locale/$dir/glossary", array( 'GP_Route_Glossary_Entry', 'glossary_entries_get' ) );
     102            GP::$router->prepend( "(/languages)/$locale/$dir/glossary/-export", array( 'GP_Route_Glossary_Entry', 'export_glossary_entries_get' ) );
     103            GP::$router->prepend( "(/languages)/$locale/$dir/glossary/-import", array( 'GP_Route_Glossary_Entry', 'import_glossary_entries_get' ) );
     104
    97105            // Register custom routes.
    98106            GP::$router->prepend( '/', array( __NAMESPACE__ . '\Routes\Index', 'get_locales' ) );
     
    104112            GP::$router->prepend( '/consistency', array( __NAMESPACE__ . '\Routes\Consistency', 'get_search_form' ) );
    105113
    106             $project = '([^/]*)/?';
     114
     115            // Project routes.
    107116            GP::$router->prepend( "/projects/wp-plugins/$project", array( __NAMESPACE__ . '\Routes\WP_Plugins', 'get_plugin_projects' ) );
    108117            GP::$router->prepend( "/projects/wp-plugins/$project/contributors", array( __NAMESPACE__ . '\Routes\WP_Plugins', 'get_plugin_contributors' ) );
Note: See TracChangeset for help on using the changeset viewer.