Skip to content

Instantly share code, notes, and snippets.

@MoatazAbdAlmageed
Last active July 15, 2022 11:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MoatazAbdAlmageed/ef6739345851943bc7c86854fbc31054 to your computer and use it in GitHub Desktop.
Save MoatazAbdAlmageed/ef6739345851943bc7c86854fbc31054 to your computer and use it in GitHub Desktop.
#!/bin/bash
alias plugin="wp plugin install --activate "
alias plugindeactivate="wp plugin deactivate --skip-plugins "
alias theme="wp theme install --activate "
wp_fix(){
wp db export
wp cache flush
wp core check-update
wp core update
wp db optimize
wp transient delete --all
echo "Backup database..."
wp db export
}
wp_generate(){
# TODO: make it like https://github.com/iandunn/wp-cli-rename-db-prefix/blob/master/wp-cli-rename-db-prefix.php
# usage
# wp_generate --dbname test1 --dbuser root --url http://localhost/test1/ --title "test1" --admin_user admin --admin_password admin --admin_email moataz.mohamamdy@gmail.com --prefix site_test1_
local dbname dbuser dbpass url title admin_user admin_password admin_email prefix
while [[ ${1} ]]; do
case "${1}" in
--dbname)
dbname=${2}
shift
;;
--dbuser)
dbuser=${2}
shift
;;
--dbpass)
dbpass=${2}
shift
;;
--url)
url=${2}
shift
;;
--title)
title=${2}
shift
;;
--admin_user)
admin_user=${2}
shift
;;
--admin_password)
admin_password=${2}
shift
;;
--admin_email)
admin_email=${2}
shift
;;
--prefix)
prefix=${2}
shift
;;
*)
echo "Unknown parameter: ${1}" >&2
return 1
esac
if ! shift; then
echo 'Missing parameter argument.' >&2
return 1
fi
done
echo $dbname $dbuser $dbpass $url $title $admin_user $admin_password $admin_email $prefix
www
mkdir $dbname
cd $dbname
echo "installing wordpress..."
wp core download
wp config create --dbname=$dbname --dbuser=$dbuser --dbpass="$dbpass"
wp db create
wp core install --url=$url --title="$title" --admin_user=$admin_user --admin_password=$admin_password --admin_email=$admin_email
echo "installing Astra theme..."
theme astra
echo "installing plugins..."
# wp option update siteurl
plugin really-simple-ssl updraftplus wpforms-lite elementor all-in-one-seo-pack wordpress-seo jetpack w3-total-cache wp-smushit akismet wp-optimize better-wp-security google-analytics-for-wordpress auto-terms-of-service-and-privacy-policy
wp rsssl activate_ssl seo-by-rank-math
wp plugin delete hello
echo "changing prefix..."
wp package install iandunn/wp-cli-rename-db-prefix
wp db export
wp rename-db-prefix $prefix
# iThemes Security – WordPress plugin | WordPress.org
wp plugin list
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment