From 5ade71556270e1d5565e5ba829c116fe5a427068 Mon Sep 17 00:00:00 2001 From: Jason Raveling Date: Tue, 17 Mar 2026 16:35:12 -0500 Subject: [PATCH 1/3] feat(plugin count): adds color to ACTIVE vs INACTIVE --- count-plugin.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/count-plugin.sh b/count-plugin.sh index 3566dfd..4893aae 100755 --- a/count-plugin.sh +++ b/count-plugin.sh @@ -41,10 +41,11 @@ for s in "${sites[@]}"; do if [[ $plugin_status -eq 0 ]]; then # Status 0: Plugin is ACTIVE ((active_count++)) - echo "Site: $s | ACTIVE" + echo -e "Site: $s | \e[42;30m ACTIVE \e[0m" + elif [[ $plugin_status -eq 1 ]]; then # Status 1: Plugin is INACTIVE or not installed - echo "Site: $s | INACTIVE" + echo -e "Site: $s | \e[41;37m INACTIVE \e[0m" else # Any other status: WP-CLI command failed echo "Site: $s | FAILED to get status (site may be archived or deleted)" From d9a5b327a4c43f61fbb62582e1e7e079966ba018 Mon Sep 17 00:00:00 2001 From: Jason Raveling Date: Thu, 21 May 2026 09:01:09 -0500 Subject: [PATCH 2/3] feat(functions): add option to config allow-root Add a new config option to add `--allow-root` to the wpcli command. The wpcli override functions are now dynamically built. --- source/config-sample.sh | 6 +++++ source/wp-cli-overrides.sh | 50 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/source/config-sample.sh b/source/config-sample.sh index 8946ca0..4dc99a9 100644 --- a/source/config-sample.sh +++ b/source/config-sample.sh @@ -14,4 +14,10 @@ declare -A config=( # This is set so that these scripts can live outside of the WordPress installation. [wp_path]='/var/www/public_html/' + # Whether or not to allow root to run wpcli. + # + # By default wpcli will display an error and exit if you run it as root. Set this to 1 to enable + # running wpcli as root. + [allow_root]=0 + ); diff --git a/source/wp-cli-overrides.sh b/source/wp-cli-overrides.sh index 757eeca..87f5357 100644 --- a/source/wp-cli-overrides.sh +++ b/source/wp-cli-overrides.sh @@ -6,7 +6,30 @@ # Usage of the wp command on the main site. Skips themes and plugins. wp_skip_all () { - wp --skip-themes --skip-plugins --path="${config[wp_path]}" "$@" + + # Setup the variable for building a wpcli command. + local -a cmd=( wp ) + + # Add the wpcli command to run and any additional flags that were used. + cmd+=( "$@" ) + + # Check if a path to a WP installation was provided. If none was provided, wpcli will default to + # the current directory. + if [[ -n "${config[wp_path]:-}" ]]; then + cmd+=( --path="${config[wp_path]}" ) + fi + + # Check if allow root was set to 1 and add the flag. + if (( config[allow_root] )); then + cmd+=( --allow-root ) + fi + + # Add flags to use every time. + cmd+=( '--skip-themes --skip-plugins' ) + + # Run the command + "${cmd[@]}" + } @@ -14,5 +37,28 @@ wp_skip_all () { # # It expects $site_url to be set. This is useful in a for loop of every site. wp_on_site () { - wp --skip-themes --skip-plugins --path="${config[wp_path]}" --url="${site_url}" "$@" + + # Setup the variable for building a wpcli command. + local -a cmd=( wp ) + + # Add the wpcli command to run and any additional flags that were used. + cmd+=( "$@" ) + + # Check if a path to a WP installation was provided. If none was provided, wpcli will default to + # the current directory. + if [[ -n "${config[wp_path]:-}" ]]; then + cmd+=( --path="${config[wp_path]}" ) + fi + + # Check if allow root was set to 1 and add the flag. + if (( config[allow_root] )); then + cmd+=( --allow-root ) + fi + + # Add flags to use every time. + cmd+=( --skip-themes --skip-plugins --url="${site_url}" ) + + # Run the command + "${cmd[@]}" + } From 6f2790685d84c0daca324e0525d4164b92f426ef Mon Sep 17 00:00:00 2001 From: Jason Raveling Date: Thu, 21 May 2026 09:01:47 -0500 Subject: [PATCH 3/3] feat(user list): output user list in csv format and update var name --- user-list.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/user-list.sh b/user-list.sh index 5b3c62e..628db8b 100755 --- a/user-list.sh +++ b/user-list.sh @@ -6,16 +6,16 @@ source 'source/includes.sh'; fields_to_display='user_login,user_email,roles'; -log_file='user-list.txt'; +output_file='user-list.txt'; -echo '#########################################################' | tee "$log_file"; -echo 'Users by WordPress site' | tee -a "$log_file"; -echo '#########################################################' | tee -a "$log_file"; +echo '#########################################################' | tee "$output_file"; +echo 'Users by WordPress site' | tee -a "$output_file"; +echo '#########################################################' | tee -a "$output_file"; for site_url in $(wp_skip_all site list --field="url" --archived=0 --deleted=0 --spam=0); do - echo '-------------------------------------------------' | tee -a "$log_file"; - echo "Site ${site_url}" | tee -a "$log_file"; - wp_on_site user list --fields="${fields_to_display}" | tee -a "$log_file"; + echo '-------------------------------------------------' | tee -a "$output_file"; + echo "Site ${site_url}" | tee -a "$output_file"; + wp_on_site user list --format=csv --fields="${fields_to_display}" | tee -a "$output_file"; done;