Making WordPress.org


Ignore:
Timestamp:
02/23/2017 10:41:06 PM (9 years ago)
Author:
ocean90
Message:

Translate: Change the path prefix for a locale glossary to '/locale'.

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  
    3030         */
    3131        private function __construct() {
    32                 add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
     32                add_action( 'plugins_loaded', [ $this, 'plugins_loaded' ] );
    3333        }
    3434
     
    4141                }
    4242
    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' ] );
    4445
    4546                if ( defined( 'WP_CLI' ) && WP_CLI ) {
    4647                        $this->register_cli_commands();
    4748                }
     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';
    4858        }
    4959
     
    5666         *  - /languages/$locale
    5767         *  - /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
    5873         *  - /profile/$path
    5974         *  - /projects/wp-plugins/?
     
    6681         *  - /locale/$locale/$path/$path
    6782         *  - /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
    6888         *  - /stats/?
    6989         *  - /projects/wp-plugins/$project
     
    89109                        GP::$router->remove( "/languages/$locale" );
    90110                        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
    91119                        GP::$router->remove( '/profile' );
    92120                        GP::$router->remove( "/profile/$path" );
     
    98126                        GP::$router->prepend( '/projects/wp-themes/?', array( __NAMESPACE__ . '\Routes\Redirector', 'redirect_index' ) );
    99127
    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 
    105128                        // Register custom routes.
    106129                        GP::$router->prepend( '/', array( __NAMESPACE__ . '\Routes\Index', 'get_locales' ) );
     
    109132                        GP::$router->prepend( "/locale/$locale/$path/$path", array( __NAMESPACE__ . '\Routes\Locale', 'get_locale_projects' ) );
    110133                        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' );
    111141                        GP::$router->prepend( '/stats', array( __NAMESPACE__ . '\Routes\Stats', 'get_stats_overview' ) );
    112142                        GP::$router->prepend( '/consistency', array( __NAMESPACE__ . '\Routes\Consistency', 'get_search_form' ) );
    113 
    114143
    115144                        // Project routes.
Note: See TracChangeset for help on using the changeset viewer.