Skip to content
This repository has been archived by the owner on Feb 26, 2020. It is now read-only.

GP-CLI: remove reference to wp.org code #24

Merged
merged 3 commits into from
Dec 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 2 additions & 37 deletions wp-content/plugins/cp-gp-cli/inc/class-language-pack.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,30 +108,6 @@ public static function remove_temp_directory( $dir ) {
return is_dir( $dir );
}

/**
* Retrieves activate language packs for a project.
*
* @param string $domain Slug of a theme/plugin.
* @return array Array of active language packs.
*/
private function get_active_language_packs( $domain ) {
global $wpdb;

$active_language_packs = $wpdb->get_results(
$wpdb->prepare(
'SELECT language, updated FROM language_packs WHERE domain = %s',
$domain
),
OBJECT_K
);

if ( ! $active_language_packs ) {
return [];
}

return $active_language_packs;
}

/**
* Builds a PO file for translations.
*
Expand Down Expand Up @@ -184,7 +160,6 @@ private function execute_command( $command ) {
* @param object $data The data of a language pack.
*/
private function build_language_packs( $data ) {
$existing_packs = $this->get_active_language_packs( $data->domain );
$endpoint = array();

foreach ( $data->translation_sets as $set ) {
Expand All @@ -207,17 +182,6 @@ private function build_language_packs( $data ) {
continue;
}

// Check if new translations are available since last build.
if ( isset( $existing_packs[ $wp_locale ] ) ) {
$pack_time = strtotime( $existing_packs[ $wp_locale ]->updated );
$glotpress_time = strtotime( $set->last_modified() );

if ( $pack_time >= $glotpress_time ) {
WP_CLI::log( "Skip {$wp_locale}, no new translations." );
continue;
}
}

$export_directory = self::BUILD_DIR . "/{$data->domain}/export/{$wp_locale}";
$build_directory = self::BUILD_DIR . "/{$data->domain}";
$filename = "{$data->domain}-{$wp_locale}";
Expand Down Expand Up @@ -263,9 +227,10 @@ private function build_language_packs( $data ) {
}

// Create ZIP file.
// TODO install the real `zip` and use it instead
$result = $this->execute_command(
sprintf(
'zip -9 -j %s %s %s 2>&1',
'zip-hack -9 -j %s %s %s 2>&1',
escapeshellarg( $zip_file ),
escapeshellarg( $po_file ),
escapeshellarg( $mo_file )
Expand Down