Changeset 2132 for sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/wporg-gp-routes.php
- Timestamp:
- 11/25/2015 10:56:07 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/wporg-gp-routes.php
r2109 r2132 18 18 19 19 public function register_routes() { 20 // Bail for API requests.21 20 $request_uri = GP::$router->request_uri(); 22 if ( gp_startswith( $request_uri, '/' . GP::$router->api_prefix . '/' ) ) {23 return;24 }25 26 21 $path = '(.+?)'; 27 22 $locale = '(' . implode( '|', array_map( function( $locale ) { return $locale->slug; }, GP_Locales::locales() ) ) . ')'; 28 23 29 // Delete default routes. 30 GP::$router->remove("/languages/$locale"); 31 GP::$router->remove("/languages/$locale/$path"); 24 if ( gp_startswith( $request_uri, '/' . GP::$router->api_prefix . '/' ) ) { // API requests. 25 // Delete default routes. 26 GP::$router->remove("/languages/$locale"); 27 } else { 28 // Delete default routes. 29 GP::$router->remove("/languages/$locale"); 30 GP::$router->remove("/languages/$locale/$path"); 32 31 33 // Redirect routes.34 GP::$router->prepend( '/languages', array( 'WPorg_GP_Route_Redirector', 'redirect_languages' ) );35 GP::$router->prepend( "/languages/$path", array( 'WPorg_GP_Route_Redirector', 'redirect_languages' ) );32 // Redirect routes. 33 GP::$router->prepend( '/languages', array( 'GP_WPorg_Route_Redirector', 'redirect_languages' ) ); 34 GP::$router->prepend( "/languages/$path", array( 'GP_WPorg_Route_Redirector', 'redirect_languages' ) ); 36 35 37 // Register custom routes. 38 GP::$router->prepend( '/', array( 'WPorg_GP_Route_Index', 'get_locales' ) ); 39 GP::$router->prepend( "/locale/$locale", array( 'WPorg_GP_Route_Locale', 'get_locale_projects' ) ); 40 GP::$router->prepend( "/locale/$locale/$path", array( 'WPorg_GP_Route_Locale', 'get_locale_projects' ) ); 41 GP::$router->prepend( "/locale/$locale/$path/$path", array( 'WPorg_GP_Route_Locale', 'get_locale_projects' ) ); 42 GP::$router->prepend( "/locale/$locale/$path/$path/$path", array( 'WPorg_GP_Route_Locale', 'get_locale_project' ) ); 43 GP::$router->prepend( '/stats/?', array( 'WPorg_GP_Route_Stats', 'get_stats_overview' ) ); 44 $project = '([^/]*)/?'; 45 GP::$router->prepend( "/projects/wp-plugins/$project", array( 'WPorg_GP_Route_WP_Plugins', 'get_plugin_projects' ) ); 36 // Register custom routes. 37 GP::$router->prepend( '/', array( 'GP_WPorg_Route_Index', 'get_locales' ) ); 38 GP::$router->prepend( "/locale/$locale", array( 'GP_WPorg_Route_Locale', 'get_locale_projects' ) ); 39 GP::$router->prepend( "/locale/$locale/$path", array( 'GP_WPorg_Route_Locale', 'get_locale_projects' ) ); 40 GP::$router->prepend( "/locale/$locale/$path/$path", array( 'GP_WPorg_Route_Locale', 'get_locale_projects' ) ); 41 GP::$router->prepend( "/locale/$locale/$path/$path/$path", array( 'GP_WPorg_Route_Locale', 'get_locale_project' ) ); 42 GP::$router->prepend( '/stats/?', array( 'GP_WPorg_Route_Stats', 'get_stats_overview' ) ); 43 $project = '([^/]*)/?'; 44 GP::$router->prepend( "/projects/wp-plugins/$project", array( 'GP_WPorg_Route_WP_Plugins', 'get_plugin_projects' ) ); 45 } 46 46 } 47 47 }
Note: See TracChangeset
for help on using the changeset viewer.