Skip to content

Commit 2c27e4b

Browse files
committed
Gets configs and includes as source working.
1 parent 6930032 commit 2c27e4b

8 files changed

Lines changed: 30 additions & 20 deletions

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
.watchsyncrc*
2-
watchsync.sh
2+
watch-sync.sh

count-plugin.sh

100644100755
File mode changed.

count-themes.sh

100644100755
File mode changed.

delete-transient-every-network-site.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
#!/bin/sh
22

33
# Loop through each network site and delete a transient.
4-
4+
#
55
# The transient to search for (can use wild cards *).
66
transient_search_term='*events_*';
77

8+
source 'source/includes.sh';
9+
810
echo;
9-
for site_url in $(wp site list --allow-root --skip-themes --skip-plugins --deleted=0 --archived=0 --spam=0 --field=url); do
11+
for site_url in $(wp_skip_all site list --field=url); do
1012

11-
found_transients=$(wp transient list --allow-root --skip-themes --skip-plugins --format=csv --fields=name --search=$transient_search_term --url=$site_url | awk 'NR>1 {print}'
13+
found_transients=$(wp_skip_all transient list --format=csv --fields=name --search=$transient_search_term --url=$site_url | awk 'NR>1 {print}'
1214
);
1315

1416
echo '################################################'
@@ -18,13 +20,11 @@ for site_url in $(wp site list --allow-root --skip-themes --skip-plugins --delet
1820

1921
# Check if it is NOT empty.
2022
if [[ -z $found_transients ]]; then
21-
echo 'none';
23+
echo ' none';
2224
else
23-
echo $found_transients;
25+
echo " $found_transients";
2426
fi
2527

26-
echo;
27-
2828
for transient in $found_transients; do
2929

3030
wp transient delete --allow-root --skip-themes --skip-plugins --url=$site_url $transient;

delete-user.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# This interactive script deletes a given user by their ID and reattributes their content to another
44
# user based on the provided ID.
55

6+
source 'source/includes.sh';
7+
68
echo;
79
echo 'You are about to delete a user and attribute any content they may have to another use.';
810
echo;
@@ -28,22 +30,22 @@ done;
2830

2931
# Prompt for the site ID to delete the user from.
3032
if [[ 999 = $site_id ]]; then
31-
sites=$(wp --allow-root --skip-themes --skip-plugins site list --field="url" --archived=0);
33+
sites=$(wp_skip_all site list --field="url" --archived=0);
3234
sites_name='All sites in the WP network';
3335
else
34-
sites=$(wp --allow-root --skip-themes --skip-plugins site list --field="url" --site__in=${site_id});
36+
sites=$(wp_skip_all site list --field="url" --site__in=${site_id});
3537
sites_name="$sites";
3638
fi
3739

3840
echo;
3941

4042
# Add human readable info for the user to be deleted.
41-
user_name_delete=$(wp --allow-root --skip-themes --skip-plugins user get ${user_id_delete} --field="display_name");
42-
# user_login_delete=$(wp --allow-root --skip-themes --skip-plugins user get ${user_id_delete} --field="user_login");
43+
user_name_delete=$(wp_skip_all user get ${user_id_delete} --field="display_name");
44+
# user_login_delete=$(wp_skip_all user get ${user_id_delete} --field="user_login");
4345

4446
# Add human readable info for the user to get attribution of content.
45-
user_name_attribute=$(wp --allow-root --skip-themes --skip-plugins user get ${user_id_attribute} --field="display_name");
46-
# user_login_attribute=$(wp --allow-root --skip-themes --skip-plugins user get ${user_id_attribute} --field="user_login");
47+
user_name_attribute=$(wp_skip_all user get ${user_id_attribute} --field="display_name");
48+
# user_login_attribute=$(wp_skip_all user get ${user_id_attribute} --field="user_login");
4749

4850
# Confirm before moving on.
4951
while [[ -z "$confirmed" ]]; do
@@ -72,5 +74,5 @@ esac
7274
# you reattribute content.
7375
echo 'Removing the user...';
7476
for site in $sites; do
75-
wp --allow-root --skip-themes --skip-plugins user delete $user_id_delete --reassign="${user_id_attribute}" --url="${site}" ;
77+
wp_skip_all user delete $user_id_delete --reassign="${user_id_attribute}" --url="${site}" ;
7678
done;

source/configs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Global configs for these scripts.
22

3-
config=(
3+
declare -A config=(
44

55
# The path to the root of your WordPress installation.
66
#

source/includes.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
# This file is source'd / included with every script.
22

3-
source 'configs.sh';
4-
source 'wp-cli-overrides.sh';
3+
# The path to this file.
4+
# path_to_this_file=$(realpath "${BASH_SOURCE[0]}");
5+
directory_path=$(dirname "$(realpath "${BASH_SOURCE[0]}")")
6+
7+
source "$directory_path/configs.sh";
8+
source "$directory_path/wp-cli-overrides.sh";
9+
10+
echo '########################################################################';
11+
echo "Working with the site at ${config[wp_path]}";
12+
echo '########################################################################';
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
# Usage of the wp command on the main site. Skips themes and plugins.
55
wp_skip_all () {
6-
wp --skip-themes --skip-plugins --path=$config[wp_path] "$@"
6+
wp --skip-themes --skip-plugins --path="${config[wp_path]}" "$@"
77
}
88

99

1010
# Usage of the wp command for a specific site.
1111
#
1212
# It expects $site_url to be set. This is useful in a for loop of every site.
1313
wp_on_site () {
14-
wp --skip-themes --path=$config[wp_path] --url="${site_url}" "$@"
14+
wp --skip-themes --path="${config[wp_path]}" --url="${site_url}" "$@"
1515
}

0 commit comments

Comments
 (0)