WordPress.org

Making WordPress.org

Changeset 11141


Ignore:
Timestamp:
07/20/2021 05:53:11 PM (2 months ago)
Author:
ocean90
Message:

Translate: Add --projects argument to export command for limiting the projects to export.

See #5829.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/inc/cli/class-export.php

    r10222 r11141  
    2626     * [--locale-slug]
    2727     * : Slug of the locale. Default: 'default'.
     28     *
     29     * [--projects]
     30     * : Comma-separated list of projects to export. Default: 'frontend,admin,admin-network,continents-cities'.
    2831     */
    2932    public function __invoke( $args, $assoc_args ) {
     
    3437        $args = wp_parse_args( $assoc_args, [
    3538            'locale-slug' => 'default',
     39            'projects'    => 'frontend,admin,admin-network,continents-cities',
    3640        ] );
    3741
     
    4650        if ( 'default' !== $args['locale-slug'] ) {
    4751            $wp_locale = $wp_locale . '_' . $args['locale-slug'];
     52        }
     53
     54        $contexts_to_export = explode( ',', $args['projects'] );
     55        $frontend_context   = array_search( 'frontend', $contexts_to_export, true );
     56        if ( false !== $frontend_context ) {
     57            // Replace 'frontend' with an empty string which is used as project context.
     58            $contexts_to_export[ $frontend_context ] = '';
    4859        }
    4960
     
    5869
    5970        foreach ( $projects as $path => $context ) {
     71            if ( ! in_array( $context, $contexts_to_export, true ) ) {
     72                continue;
     73            }
     74
    6075            $gp_project = GP::$project->by_path( $path );
    6176            if ( ! $gp_project ) {
Note: See TracChangeset for help on using the changeset viewer.