Changeset 1721 for sites/trunk/translate.wordpress.org/includes/gp-plugins/wporg-routes/wporg-routes.php
- Timestamp:
- 07/10/2015 05:29:36 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/translate.wordpress.org/includes/gp-plugins/wporg-routes/wporg-routes.php
r1684 r1721 1 1 <?php 2 2 /** 3 * This plugins overrides some of the default routes of GlotPress.3 * Register custom routes for translate.wordpress.org. 4 4 * 5 5 * @author ocean90 6 6 */ 7 7 8 require_once __DIR__ . '/routes/redirector.php'; 8 9 require_once __DIR__ . '/routes/index.php'; 9 10 require_once __DIR__ . '/routes/locale.php'; … … 18 19 19 20 public function init() { 21 // Bail for API requests. 22 $request_uri = GP::$router->request_uri(); 23 if ( gp_startswith( $request_uri, '/' . GP::$router->api_prefix . '/' ) ) { 24 return; 25 } 26 20 27 $path = '(.+?)'; 21 28 $locale = '(' . implode( '|', array_map( function( $locale ) { return $locale->slug; }, GP_Locales::locales() ) ) . ')'; 22 29 23 /* 24 * Unset default routes. 25 * The `routes` filter can't be used, see https://glotpress.trac.wordpress.org/ticket/249. 26 */ 30 // Unset default routes. 27 31 unset( GP::$router->urls['/'] ); 28 32 unset( GP::$router->urls["get:/languages/$locale/$path"] ); … … 30 34 unset( GP::$router->urls['get:/languages'] ); 31 35 32 GP::$router->add( '/', array( 'GP_WPorg_Route_Index', 'get_index' ) ); 33 GP::$router->add( "/languages/$locale/$path/$path/$path", array( 'GP_WPorg_Route_Locale', 'get_locale_project' ) ); 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' ) ); 36 GP::$router->add( "/languages/$locale", array( 'GP_WPorg_Route_Locale', 'get_locale_projects' ) ); 37 GP::$router->add( '/languages', array( 'GP_WPorg_Route_Locale', 'get_locales' ) ); 36 // Redirect routes. 37 GP::$router->add( "/languages/$path", array( 'GP_WPorg_Route_Redirector', 'redirect_languages' ) ); 38 GP::$router->add( '/languages', array( 'GP_WPorg_Route_Redirector', 'redirect_languages' ) ); 39 40 // Register custom routes. 41 GP::$router->add( '/', array( 'GP_WPorg_Route_Index', 'get_locales' ) ); 42 GP::$router->add( "/locale/$locale/$path/$path/$path", array( 'GP_WPorg_Route_Locale', 'get_locale_project' ) ); 43 GP::$router->add( "/locale/$locale/$path/$path", array( 'GP_WPorg_Route_Locale', 'get_locale_projects' ) ); 44 GP::$router->add( "/locale/$locale/$path", array( 'GP_WPorg_Route_Locale', 'get_locale_projects' ) ); 45 GP::$router->add( "/locale/$locale", array( 'GP_WPorg_Route_Locale', 'get_locale_projects' ) ); 38 46 } 39 47 }
Note: See TracChangeset
for help on using the changeset viewer.