Skip to content

Commit

Permalink
Merge pull request #54 from wp-cli/fix/wpcs-3.0-issues
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy authored Aug 30, 2023
2 parents f602698 + 6b1dfff commit 9a1932d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
20 changes: 9 additions & 11 deletions src/Super_Admin_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand All @@ -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 ) {
Expand Down
2 changes: 1 addition & 1 deletion super-admin-command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 9a1932d

Please sign in to comment.