Skip to content

Commit 4b4dfc3

Browse files
committed
Fix count
1 parent c90c458 commit 4b4dfc3

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/Plugin_Language_Command.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,9 @@ public function uninstall( $args, $assoc_args ) {
481481
"$plugin-$language_code.l10n.php",
482482
);
483483

484-
$count_files_removed = 0;
485-
$had_one_file = false;
484+
$count_files_to_remove = 0;
485+
$count_files_removed = 0;
486+
$had_one_file = false;
486487

487488
foreach ( $files as $file ) {
488489
if ( '.' === $file[0] || is_dir( $file ) ) {
@@ -498,14 +499,16 @@ public function uninstall( $args, $assoc_args ) {
498499

499500
$had_one_file = true;
500501

502+
++$count_files_to_remove;
503+
501504
if ( $wp_filesystem->delete( WP_LANG_DIR . $dir . '/' . $file ) ) {
502505
++$count_files_removed;
503506
} else {
504507
\WP_CLI::error( "Couldn't uninstall language: $language_code from plugin $plugin." );
505508
}
506509
}
507510

508-
if ( count( $files_to_remove ) === $count_files_removed ) {
511+
if ( $count_files_to_remove === $count_files_removed ) {
509512
$result['status'] = 'uninstalled';
510513
++$successes;
511514
\WP_CLI::log( "Language '{$language_code}' for '{$plugin}' uninstalled." );

src/Theme_Language_Command.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,9 @@ public function uninstall( $args, $assoc_args ) {
492492
"$theme-$language_code.l10n.php",
493493
);
494494

495-
$count_files_removed = 0;
496-
$had_one_file = false;
495+
$count_files_to_remove = 0;
496+
$count_files_removed = 0;
497+
$had_one_file = false;
497498

498499
foreach ( $files as $file ) {
499500
if ( '.' === $file[0] || is_dir( $file ) ) {
@@ -509,14 +510,16 @@ public function uninstall( $args, $assoc_args ) {
509510

510511
$had_one_file = true;
511512

513+
++$count_files_to_remove;
514+
512515
if ( $wp_filesystem->delete( WP_LANG_DIR . $dir . '/' . $file ) ) {
513516
++$count_files_removed;
514517
} else {
515518
\WP_CLI::error( "Couldn't uninstall language: $language_code from theme $theme." );
516519
}
517520
}
518521

519-
if ( count( $files_to_remove ) === $count_files_removed ) {
522+
if ( $count_files_to_remove === $count_files_removed ) {
520523
$result['status'] = 'uninstalled';
521524
++$successes;
522525
\WP_CLI::log( "Language '{$language_code}' for '{$theme}' uninstalled." );

0 commit comments

Comments
 (0)