[ 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(
  10                  array(
  11                      'translation_set_id' => $set->id,
  12                      'status'             => 'current',
  13                  ),
  14                  'original_id ASC'
  15              );
  16              $prev_original_id = null;
  17              foreach ( $translations as $translation ) {
  18                  if ( $translation->original_id == $prev_original_id ) {
  19                      WP_CLI::warning(
  20                          sprintf(
  21                              /* translators: 1: original ID, 2: new ID */
  22                              __( 'Duplicate with original_id #%1$d. Translation #%2$d', 'glotpress' ),
  23                              $prev_original_id,
  24                              $translation->id
  25                          )
  26                      );
  27                      $translation->delete();
  28                  }
  29                  $prev_original_id = $translation->original_id;
  30              }
  31          }
  32  
  33          WP_CLI::success( 'Multiple currents are cleaned up.' );
  34      }
  35  }


Generated: Sun Nov 24 01:01:03 2024 Cross-referenced by PHPXref 0.7.1