Changeset 2109 for sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/wporg-gp-routes.php
- Timestamp:
- 11/22/2015 08:01:41 PM (9 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes
- Files:
-
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/wporg-gp-routes.php
r2108 r2109 1 1 <?php 2 2 /** 3 * Register custom routes for translate.wordpress.org. 4 * 5 * @author ocean90, obenland, dd32 3 * Plugin name: GlotPress: Register custom routes for translate.wordpress.org. 4 * Plugin author: ocean90, obenland, dd32 6 5 */ 7 6 … … 12 11 require_once __DIR__ . '/routes/wp-plugins.php'; 13 12 14 class GP_WPorg_Routes extends GP_Plugin { 15 public $id = 'wporg-routes'; 13 class WPorg_GP_Routes { 16 14 17 15 public function __construct() { 18 parent::__construct(); 19 $this->add_action( 'init' ); 16 add_action( 'init', array( $this, 'register_routes' ) ); 20 17 } 21 18 22 public function init() {19 public function register_routes() { 23 20 // Bail for API requests. 24 21 $request_uri = GP::$router->request_uri(); … … 35 32 36 33 // 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' ) );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' ) ); 39 36 40 37 // 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' ) );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' ) ); 47 44 $project = '([^/]*)/?'; 48 GP::$router->prepend( "/projects/wp-plugins/$project", array( ' GP_WPorg_Route_WP_Plugins', 'get_plugin_projects' ) );45 GP::$router->prepend( "/projects/wp-plugins/$project", array( 'WPorg_GP_Route_WP_Plugins', 'get_plugin_projects' ) ); 49 46 } 50 47 } 51 48 52 GP::$plugins->wporg_routes = new GP_WPorg_Routes; 49 function wporg_gp_routes() { 50 global $wporg_gp_routes; 51 52 if ( ! isset( $wporg_gp_routes ) ) { 53 $wporg_gp_routes = new WPorg_GP_Routes(); 54 } 55 56 return $wporg_gp_routes; 57 } 58 add_action( 'plugins_loaded', 'wporg_gp_routes' );
Note: See TracChangeset
for help on using the changeset viewer.