Created
October 4, 2024 07:44
-
-
Save AtsushiA/c6a0e408418265f210cca722933329db to your computer and use it in GitHub Desktop.
localwp utils
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
wp user create admin [email protected] --role=administrator --user_pass=admin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
# 検索対象のディレクトリをセット | |
search_dir="./" | |
# 実行するWPコマンドを関数化 | |
execute_wp_commands() { | |
local wp_dir=$1 | |
# 実行するコマンドのリストを配列で設定 | |
wp_commands=( | |
"echo SiteURL : $(wp option get home --path=$wp_dir)" | |
"echo Version : $(wp core version --path=$wp_dir)" | |
"echo admin_email : $(wp option get admin_email --path=$wp_dir)" | |
# "wp core verify-checksums" | |
# "wp plugin verify-checksums --all" | |
"find $wp_dir/wp-content/uploads/ -name \"*.php\"" | |
) | |
# コマンドをまとめて1つのシェルコマンドにする | |
combined_command="" | |
for wp_command in "${wp_commands[@]}"; do | |
combined_command+="$wp_command && " | |
done | |
# 最後の '&&' を取り除く | |
combined_command=${combined_command%&& } | |
# wp-config.phpが存在するディレクトリに移動 | |
cd "$wp_dir" | |
# すべてのコマンドをまとめて実行 | |
echo -------------------------------------------------- | |
echo "Executing combined commands in $wp_dir" | |
eval "$combined_command" | |
wp plugin list --format=table --path=$wp_dir | |
echo -------------------------------------------------- | |
} | |
# 再帰的にwp-config.phpが存在するディレクトリを検索 | |
find "$search_dir" -type f -name "wp-config.php" | while read wp_config; do | |
# wp-config.phpが存在するディレクトリを取得 | |
wp_dir=$(dirname "$wp_config") | |
# WPコマンドを実行する関数を呼び出し | |
execute_wp_commands "$wp_dir" | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
#$REASSIGNUSER=`wp user list --role=administrator --field=user_login | grep -v "admin" | head -n 1` | |
#echo "$REASSIGNUSER" | |
wp user list --role=administrator --field=user_login | grep -v "admin" > text.text | |
cat ./text.text | |
wp user list --role=administrator --field=user_login | grep -v "admin" | head -n 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
## mod from (https://github.com/web-soudan/wp-cli-utility/blob/main/remote-import_wp.sh) | |
# Set backup file URL | |
read -p "Please set backup wpress file URL (Cancel: n/N): " backup_wpress_url | |
# Check cancel | |
if [[ $backup_wpress_url == [nN] ]]; then | |
echo "Canceld" | |
exit 0 | |
fi | |
echo update all plugin | |
wp plugin update --all | |
echo 'Restore from remote wpress file' | |
wp ai1wm url restore --yes "$backup_wpress_url" | |
echo 'import Done' | |
echo '----------------------------------------' | |
echo 'wp rewrite flush' | |
wp rewrite flush —hard | |
wp cache flush | |
echo '----------------------------------------' | |
echo 'wp cache flush' | |
wp cache flush | |
echo '----------------------------------------' | |
echo SiteURL : $(wp option get home) | |
echo Version : $(wp core version) | |
#echo '----------------------------------------' | |
#echo 'plugin verify-checksums' | |
#wp plugin verify-checksums --all | |
#echo '----------------------------------------' | |
#echo 'linstall plugin : Query Monitor' | |
#wp plugin install query-monitor --activate | |
echo '----------------------------------------' | |
echo 'find php files(wp-content/uploads)' | |
find ./wp-content/uploads/ -name "*.php" | |
echo 'Done' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment