diff --git a/composer.json b/composer.json index 8737eaab..9b312087 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ }, "require-dev": { "wp-cli/entity-command": "^1.3 || ^2", - "wp-cli/wp-cli-tests": "^3.1" + "wp-cli/wp-cli-tests": "^4" }, "config": { "process-timeout": 7200, diff --git a/src/Super_Admin_Command.php b/src/Super_Admin_Command.php index fb0ece09..66f695d2 100644 --- a/src/Super_Admin_Command.php +++ b/src/Super_Admin_Command.php @@ -117,7 +117,7 @@ public function add( $args, $_ ) { $new_super_admins[] = $user->ID; $super_admins[] = $user->user_login; - $successes++; + ++$successes; } if ( count( $super_admins ) === $num_super_admins ) { @@ -127,18 +127,16 @@ public function add( $args, $_ ) { } else { WP_CLI::success( 'Super admins remain unchanged.' ); } - } else { - if ( update_site_option( 'site_admins', $super_admins ) ) { - if ( $errors ) { - $user_count = count( $args ); - WP_CLI::error( "Only granted super-admin capabilities to {$successes} of {$user_count} users." ); - } else { - $message = $successes > 1 ? 'users' : 'user'; - WP_CLI::success( "Granted super-admin capabilities to {$successes} {$message}." ); - } + } elseif ( update_site_option( 'site_admins', $super_admins ) ) { + if ( $errors ) { + $user_count = count( $args ); + WP_CLI::error( "Only granted super-admin capabilities to {$successes} of {$user_count} users." ); } else { - WP_CLI::error( 'Site options update failed.' ); + $message = $successes > 1 ? 'users' : 'user'; + WP_CLI::success( "Granted super-admin capabilities to {$successes} {$message}." ); } + } else { + WP_CLI::error( 'Site options update failed.' ); } foreach ( $new_super_admins as $user_id ) { diff --git a/super-admin-command.php b/super-admin-command.php index c80bd228..ccdd03dc 100644 --- a/super-admin-command.php +++ b/super-admin-command.php @@ -4,7 +4,7 @@ return; } -$wpcli_super_admin_autoloader = dirname( __FILE__ ) . '/vendor/autoload.php'; +$wpcli_super_admin_autoloader = __DIR__ . '/vendor/autoload.php'; if ( file_exists( $wpcli_super_admin_autoloader ) ) { require_once $wpcli_super_admin_autoloader; }