Changeset 3024
- Timestamp:
- 04/27/2016 03:40:45 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-plugin-directory/inc/sync/class-translation-sync.php
r3018 r3024 48 48 } 49 49 50 $time = date( 'r' ); 51 $message = "_Time: {$time}_\nTranslation sync from dev to stable in process...\n"; 50 52 foreach ( $translation_sets as $translation_set ) { 51 53 if ( 0 == $translation_set->current_count() ) { … … 55 57 // Sync translations in a separate process. 56 58 $cmd = WPORGTRANSLATE_WPCLI . ' wporg-translate sync-plugin-translations ' . escapeshellarg( $args['gp_project'] ) . ' ' . escapeshellarg( $translation_set->locale ) . ' --set=' . escapeshellarg( $translation_set->slug ); 57 echo shell_exec( $cmd ); 58 } 59 $output = shell_exec( $cmd ); 60 if ( 'No translations available.' !== $output ) { 61 $message .= "\t" . $output; 62 } 63 } 64 $message .= 'Translation sync was successfully processed.'; 65 66 $attachment = [ 67 'title' => "Translation Sync for {$args['plugin']}", 68 'title_link' => "https://translate.wordpress.org/projects/wp-plugins/{$args['plugin']}", 69 'text' => $message, 70 'fallback' => "Translations for {$args['plugin']} were synced.", 71 'color' => '#00a0d2', 72 'mrkdwn_in' => [ 'text' ], 73 ]; 74 $this->slack( $attachment ); 59 75 60 76 return true; … … 241 257 return true; 242 258 } 259 260 /** 261 * Sends a notifcation to the the Slack channel. 262 * 263 * @param array $attachment The attachment of a notification. 264 */ 265 private function slack( $attachment ) { 266 if ( ! defined( 'GLOTPRESS_SLACK_WEBHOOK' ) ) { 267 return; 268 } 269 270 require_once API_WPORGPATH . 'includes/slack-config.php'; 271 $send = new \Dotorg\Slack\Send( GLOTPRESS_SLACK_WEBHOOK ); 272 $send->add_attachment( $attachment ); 273 $send->set_username( 'Plugin Translation Sync' ); 274 $send->send( '#meta-language-packs' ); 275 } 243 276 }
Note: See TracChangeset
for help on using the changeset viewer.