WordPress.org

Making WordPress.org

Ticket #3748: 3748.7.diff

File 3748.7.diff, 3.6 KB (added by herregroen, 22 months ago)
  • wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/i18n/class-code-import.php

    diff --git wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/i18n/class-code-import.php wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/i18n/class-code-import.php
    index cff90f2ae..e0eae8483 100644
    class Code_Import extends I18n_Import { 
    4242                        throw new Exception( 'Plugin is not compatible with language packs: ' . $valid->get_error_message() );
    4343                }
    4444
    45                 if ( ! class_exists( '\PotExtMeta' ) ) {
    46                         require_once plugin_dir_path( \WordPressdotorg\Plugin_Directory\PLUGIN_FILE ) . 'libs/i18n-tools/makepot.php';
    47                 }
    48 
    4945                $pot_file = "{$tmp_directory}/{$this->plugin}-code.pot";
    50                 $makepot  = new \MakePOT();
    5146
    52                 if ( ! $makepot->wp_plugin( $export_directory, $pot_file, $this->plugin ) || ! file_exists( $pot_file ) ) {
     47                exec(
     48                        sprintf(
     49                                'wp i18n make-pot %s %s --slug=%s --ignore-domain',
     50                                escapeshellarg( $export_directory ),
     51                                escapeshellarg( $pot_file ),
     52                                escapeshellarg( $this->plugin )
     53                        ),
     54                        $output,
     55                        $return_code
     56                );
     57
     58                if ( $return_code !== 0 || ! file_exists( $pot_file ) ) {
    5359                        throw new Exception( "POT file couldn't be created." );
    5460                }
    5561
  • wordpress.org/public_html/wp-content/plugins/wporg-gp-theme-directory/inc/cli/class-set-theme-project.php

    diff --git wordpress.org/public_html/wp-content/plugins/wporg-gp-theme-directory/inc/cli/class-set-theme-project.php wordpress.org/public_html/wp-content/plugins/wporg-gp-theme-directory/inc/cli/class-set-theme-project.php
    index 9feea2711..949410589 100644
     
    33namespace WordPressdotorg\GlotPress\Theme_Directory\CLI;
    44
    55use GP;
    6 use MakePOT;
    76use WordPressdotorg\GlotPress\Theme_Directory\Plugin;
    87use WP_CLI;
    98use WP_CLI_Command;
    class Set_Theme_Project extends WP_CLI_Command { 
    2423         */
    2524        private $temp_dir;
    2625
    27         /**
    28          * MakePot instance.
    29          *
    30          * @var MakePot
    31          */
    32         private $makepot;
    33 
    3426        public function __construct() {
    3527                if ( ! file_exists( '/tmp/wporg-themes-i18n/' ) ) {
    3628                        mkdir( '/tmp/wporg-themes-i18n/' );
    class Set_Theme_Project extends WP_CLI_Command { 
    4133                if ( ! mkdir( $this->temp_dir ) ) {
    4234                        WP_CLI::error( "Couldn't create temporary directory." );
    4335                }
    44 
    45                 $this->checkout_tools();
    46                 if ( ! file_exists( $this->temp_dir . '/i18n-tools/makepot.php' ) ) {
    47                         WP_CLI::error( "Couldn't find MakePot." );
    48                 }
    49                 require_once $this->temp_dir . '/i18n-tools/makepot.php';
    50                 $this->makepot = new MakePot();
    5136        }
    5237
    5338        /**
    class Set_Theme_Project extends WP_CLI_Command { 
    157142         */
    158143        private function generate_pot( $theme_slug, $theme_dir ) {
    159144                $pot_file = "{$this->temp_dir}/{$theme_slug}.pot";
    160                 $this->makepot->wp_theme( $theme_dir, $pot_file );
     145                WP_CLI::runcommand(
     146                        sprintf(
     147                                'wp i18n make-pot %s %s --ignore-domain',
     148                                escapeshellarg( $theme_dir ),
     149                                escapeshellarg( $pot_file )
     150                        )
     151                );
    161152                return $pot_file;
    162153        }
    163154
    class Set_Theme_Project extends WP_CLI_Command { 
    304295                return $data;
    305296        }
    306297
    307         /**
    308          * Creates an i18n-tools checkout so we have MakePot available.
    309          */
    310         private function checkout_tools() {
    311                 $tools_dir = "{$this->temp_dir}/i18n-tools/";
    312                 if ( ! file_exists( $tools_dir ) ) {
    313                         $esc_tools_dir = escapeshellarg( $tools_dir );
    314                         `svn export --non-interactive https://i18n.svn.wordpress.org/tools/trunk {$esc_tools_dir}`;
    315                 }
    316         }
    317 
    318298        /**
    319299         * Cleanup a theme directory, for when this is used in batch mode.
    320300         */