Changeset 4995 for sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/inc/class-plugin.php
- Timestamp:
- 02/23/2017 10:41:06 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/inc/class-plugin.php
r4926 r4995 30 30 */ 31 31 private function __construct() { 32 add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ));32 add_action( 'plugins_loaded', [ $this, 'plugins_loaded' ] ); 33 33 } 34 34 … … 41 41 } 42 42 43 add_action( 'template_redirect', array( $this, 'register_routes' ), 5 ); 43 add_action( 'template_redirect', [ $this, 'register_routes' ], 5 ); 44 add_filter( 'gp_locale_glossary_path_prefix', [ $this, 'set_locale_glossary_path_prefix' ] ); 44 45 45 46 if ( defined( 'WP_CLI' ) && WP_CLI ) { 46 47 $this->register_cli_commands(); 47 48 } 49 } 50 51 /** 52 * Changes the path prefix for a locale glossary to '/locale'. 53 * 54 * @return string '/locale' 55 */ 56 public function set_locale_glossary_path_prefix() { 57 return '/locale'; 48 58 } 49 59 … … 56 66 * - /languages/$locale 57 67 * - /languages/$locale/$path 68 * - (/languages)/$locale/$dir/glossary 69 * - (/languages)/$locale/$dir/glossary/-new 70 * - (/languages)/$locale/$dir/glossary/-delete 71 * - (/languages)/$locale/$dir/glossary/-export 72 * - (/languages)/$locale/$dir/glossary/-import 58 73 * - /profile/$path 59 74 * - /projects/wp-plugins/? … … 66 81 * - /locale/$locale/$path/$path 67 82 * - /locale/$locale/$path/$path/$path 83 * - (/locale)/$locale/$dir/glossary 84 * - (/locale)/$locale/$dir/glossary/-new 85 * - (/locale)/$locale/$dir/glossary/-delete 86 * - (/locale)/$locale/$dir/glossary/-export 87 * - (/locale)/$locale/$dir/glossary/-import 68 88 * - /stats/? 69 89 * - /projects/wp-plugins/$project … … 89 109 GP::$router->remove( "/languages/$locale" ); 90 110 GP::$router->remove( "/languages/$locale/$path" ); 111 GP::$router->remove( "(/languages)/$locale/$dir/glossary" ); 112 GP::$router->remove( "(/languages)/$locale/$dir/glossary", 'post' ); 113 GP::$router->remove( "(/languages)/$locale/$dir/glossary/-new", 'post' ); 114 GP::$router->remove( "(/languages)/$locale/$dir/glossary/-delete", 'post' ); 115 GP::$router->remove( "(/languages)/$locale/$dir/glossary/-export" ); 116 GP::$router->remove( "(/languages)/$locale/$dir/glossary/-import" ); 117 GP::$router->remove( "(/languages)/$locale/$dir/glossary/-import", 'post' ); 118 91 119 GP::$router->remove( '/profile' ); 92 120 GP::$router->remove( "/profile/$path" ); … … 98 126 GP::$router->prepend( '/projects/wp-themes/?', array( __NAMESPACE__ . '\Routes\Redirector', 'redirect_index' ) ); 99 127 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 105 128 // Register custom routes. 106 129 GP::$router->prepend( '/', array( __NAMESPACE__ . '\Routes\Index', 'get_locales' ) ); … … 109 132 GP::$router->prepend( "/locale/$locale/$path/$path", array( __NAMESPACE__ . '\Routes\Locale', 'get_locale_projects' ) ); 110 133 GP::$router->prepend( "/locale/$locale/$path/$path/$path", array( __NAMESPACE__ . '\Routes\Locale', 'get_locale_project' ) ); 134 GP::$router->prepend( "(/locale)/$locale/$dir/glossary", array( 'GP_Route_Glossary_Entry', 'glossary_entries_get' ) ); 135 GP::$router->prepend( "(/locale)/$locale/$dir/glossary", array( 'GP_Route_Glossary_Entry', 'glossary_entries_post' ), 'post' ); 136 GP::$router->prepend( "(/locale)/$locale/$dir/glossary/-new", array( 'GP_Route_Glossary_Entry', 'glossary_entry_add_post' ), 'post' ); 137 GP::$router->prepend( "(/locale)/$locale/$dir/glossary/-delete", array( 'GP_Route_Glossary_Entry', 'glossary_entry_delete_post' ), 'post' ); 138 GP::$router->prepend( "(/locale)/$locale/$dir/glossary/-export", array( 'GP_Route_Glossary_Entry', 'export_glossary_entries_get' ) ); 139 GP::$router->prepend( "(/locale)/$locale/$dir/glossary/-import", array( 'GP_Route_Glossary_Entry', 'import_glossary_entries_get' ) ); 140 GP::$router->prepend( "(/locale)/$locale/$dir/glossary/-import", array( 'GP_Route_Glossary_Entry', 'import_glossary_entries_post' ), 'post' ); 111 141 GP::$router->prepend( '/stats', array( __NAMESPACE__ . '\Routes\Stats', 'get_stats_overview' ) ); 112 142 GP::$router->prepend( '/consistency', array( __NAMESPACE__ . '\Routes\Consistency', 'get_search_form' ) ); 113 114 143 115 144 // Project routes.
Note: See TracChangeset
for help on using the changeset viewer.