Making WordPress.org

Changeset 2278


Ignore:
Timestamp:
01/12/2016 05:07:48 PM (9 years ago)
Author:
ocean90
Message:

Translate: Restore CLI commands for updating cached data.

Available commands:

  • wp wporg-translate update-cache all
  • wp wporg-translate update-cache contributors-count
  • wp wporg-translate update-cache translation-status

See #1352.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/wporg-gp-routes.php

    r2275 r2278  
    1919    public function __construct() {
    2020        add_action( 'template_redirect', array( $this, 'register_routes' ), 5 );
     21
     22        if ( defined( 'WP_CLI' ) && WP_CLI ) {
     23            $this->register_cli_commands();
     24        }
    2125    }
    2226
     27    /**
     28     * Registers custom routes and removes default routes.
     29     *
     30     * Removes:
     31     *  - API: /languages/$locale
     32     *  - /languages/$locale
     33     *  - /languages/$locale
     34     *  - /languages/$locale/$path
     35     *  - /profile/$path
     36     *
     37     * Adds:
     38     *  - /
     39     *  - /locale/$locale
     40     *  - /locale/$locale/$path
     41     *  - /locale/$locale/$path/$path
     42     *  - /locale/$locale/$path/$path/$path
     43     *  - /stats/?
     44     *  - /projects/wp-plugins/$project
     45     */
    2346    public function register_routes() {
    2447        $request_uri = GP::$router->request_uri();
     
    3356            GP::$router->remove( "/languages/$locale" );
    3457            GP::$router->remove( "/languages/$locale/$path" );
    35             GP::$router->remove( '/profile/(.+?)' );
     58            GP::$router->remove( "/profile/$path" );
    3659
    3760            // Redirect routes.
     
    5073        }
    5174    }
     75
     76    /**
     77     * Registers CLI commands if WP-CLI is loaded.
     78     */
     79    function register_cli_commands() {
     80        require_once __DIR__ . '/cli/update-caches.php';
     81
     82        WP_CLI::add_command( 'wporg-translate update-cache', 'WPorg_GP_CLI_Update_Caches' );
     83    }
    5284}
    5385
Note: See TracChangeset for help on using the changeset viewer.