Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
常用的 wp-cli 指令,用於開一個初始化新站。
#!/usr/bin/env bash
clear
# Take User Inputs
read -p "Site URL: " url
read -p "Site title: " title
read -p "Site Slug: " sslug
read -p "DB Name: " db
read -p "DB Pass: " dbpass
read -p "WP Prefix: " pf
pass=$(date +%s | sha256sum | base64 | head -c 32 ; echo)
wp core download --allow-root
# using proc_open() function
wp core config --dbname="$db" --dbuser="$db" --dbpass="$dbpass" --locale=zh_TW --allow-root --dbprefix="$pf"_ --extra-php <<PHP
define('WP_MEMORY_LIMIT', '256M');
define('WP_POST_REVISIONS', 3);
define('WPLANG', 'zh_TW');
PHP
# wp db create --allow-root
# Run WP Install
wp core install --url="$url" --title="$title" --admin_user="$sslug"_user --admin_password="$pass" --admin_email="wp@example.com" --allow-root
wp plugin install mxp-dev-tools --activate --allow-root
wp plugin delete hello --allow-root
wp post delete $(wp post list --post_type='page' --format=ids --allow-root) --force --allow-root
wp post delete $(wp post list --post_type='post' --format=ids --allow-root) --force --allow-root
wp post create --post_type='page' --post_title="Home" --post_status="publish" --allow-root
wp core language install zh_TW --activate --allow-root
# wp scaffold child-theme childtheme --parent_theme=basetheme --author=Knockers --allow-root
wp option update timezone_string Asia/Taipei --allow-root
wp option update blogdescription "" --allow-root
wp option update default_pingback_flag 0 --allow-root
wp option update default_ping_status 0 --allow-root
wp option update default_comment_status 0 --allow-root
wp option update comment_registration 1 --allow-root
wp option update blog_public 0 --allow-root
wp option update show_on_front page --allow-root
wp option update page_on_front 3 --allow-root
wp option update date_format "Y-m-d" --allow-root
wp option update time_format "H:i:s" --allow-root
chown www:www * -R
echo "admin_user : $sslug"_user
echo "admin_password: $pass"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.