[ Index ]

PHP Cross Reference of GlotPress

title

Body

[close]

/gp-includes/cli/ -> remove-multiple-currents.php (source)

   1  <?php
   2  
   3  class GP_CLI_Remove_Multiple_Currents extends WP_CLI_Command {
   4  	public function __invoke() {
   5          $sets = GP::$translation_set->all();
   6          foreach( $sets as $set ) {
   7              /* translators: %d: Set ID */
   8              WP_CLI::log( sprintf( __( 'Processing set #%d..', 'glotpress' ), $set->id ) );
   9              $translations = GP::$translation->find( array( 'translation_set_id' => $set->id, 'status' => 'current' ), 'original_id ASC' );
  10              $prev_original_id = null;
  11              foreach( $translations as $translation ) {
  12                  if ( $translation->original_id == $prev_original_id ) {
  13                      WP_CLI::warning( sprintf(
  14                          /* translators: 1: original ID, 2: new ID */
  15                          __( 'Duplicate with original_id #%1$d. Translation #%2$d', 'glotpress' ),
  16                          $prev_original_id,
  17                          $translation->id
  18                      ) );
  19                      $translation->delete();
  20                  }
  21                  $prev_original_id = $translation->original_id;
  22              }
  23          }
  24  
  25          WP_CLI::success( 'Multiple currents are cleaned up.' );
  26      }
  27  }


Generated: Tue Dec 10 01:02:00 2019 Cross-referenced by PHPXref 0.7.1