Changeset 2132
- Timestamp:
- 11/25/2015 10:56:07 AM (8 years ago)
- Location:
- sites/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/translate.wordpress.org/includes/gp-plugins/wporg-routes/wporg-routes.php
r2108 r2132 21 21 22 22 public function init() { 23 // Bail for API requests.24 23 $request_uri = GP::$router->request_uri(); 25 if ( gp_startswith( $request_uri, '/' . GP::$router->api_prefix . '/' ) ) {26 return;27 }28 29 24 $path = '(.+?)'; 30 25 $locale = '(' . implode( '|', array_map( function( $locale ) { return $locale->slug; }, GP_Locales::locales() ) ) . ')'; 31 26 32 // Delete default routes. 33 GP::$router->remove("/languages/$locale"); 34 GP::$router->remove("/languages/$locale/$path"); 27 if ( gp_startswith( $request_uri, '/' . GP::$router->api_prefix . '/' ) ) { // API requests. 28 // Delete default routes. 29 GP::$router->remove("/languages/$locale"); 30 } else { 31 // Delete default routes. 32 GP::$router->remove("/languages/$locale"); 33 GP::$router->remove("/languages/$locale/$path"); 35 34 36 // Redirect routes.37 GP::$router->prepend( '/languages', array( 'GP_WPorg_Route_Redirector', 'redirect_languages' ) );38 GP::$router->prepend( "/languages/$path", array( 'GP_WPorg_Route_Redirector', 'redirect_languages' ) );35 // Redirect routes. 36 GP::$router->prepend( '/languages', array( 'GP_WPorg_Route_Redirector', 'redirect_languages' ) ); 37 GP::$router->prepend( "/languages/$path", array( 'GP_WPorg_Route_Redirector', 'redirect_languages' ) ); 39 38 40 // Register custom routes. 41 GP::$router->prepend( '/', array( 'GP_WPorg_Route_Index', 'get_locales' ) ); 42 GP::$router->prepend( "/locale/$locale", array( 'GP_WPorg_Route_Locale', 'get_locale_projects' ) ); 43 GP::$router->prepend( "/locale/$locale/$path", array( 'GP_WPorg_Route_Locale', 'get_locale_projects' ) ); 44 GP::$router->prepend( "/locale/$locale/$path/$path", array( 'GP_WPorg_Route_Locale', 'get_locale_projects' ) ); 45 GP::$router->prepend( "/locale/$locale/$path/$path/$path", array( 'GP_WPorg_Route_Locale', 'get_locale_project' ) ); 46 GP::$router->prepend( '/stats/?', array( 'GP_WPorg_Route_Stats', 'get_stats_overview' ) ); 47 $project = '([^/]*)/?'; 48 GP::$router->prepend( "/projects/wp-plugins/$project", array( 'GP_WPorg_Route_WP_Plugins', 'get_plugin_projects' ) ); 39 // Register custom routes. 40 GP::$router->prepend( '/', array( 'GP_WPorg_Route_Index', 'get_locales' ) ); 41 GP::$router->prepend( "/locale/$locale", array( 'GP_WPorg_Route_Locale', 'get_locale_projects' ) ); 42 GP::$router->prepend( "/locale/$locale/$path", array( 'GP_WPorg_Route_Locale', 'get_locale_projects' ) ); 43 GP::$router->prepend( "/locale/$locale/$path/$path", array( 'GP_WPorg_Route_Locale', 'get_locale_projects' ) ); 44 GP::$router->prepend( "/locale/$locale/$path/$path/$path", array( 'GP_WPorg_Route_Locale', 'get_locale_project' ) ); 45 GP::$router->prepend( '/stats/?', array( 'GP_WPorg_Route_Stats', 'get_stats_overview' ) ); 46 $project = '([^/]*)/?'; 47 GP::$router->prepend( "/projects/wp-plugins/$project", array( 'GP_WPorg_Route_WP_Plugins', 'get_plugin_projects' ) ); 48 } 49 49 } 50 50 } -
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.