Skip to content

Instantly share code, notes, and snippets.

@Ebeldev
Created November 21, 2021 05:06
Show Gist options
  • Save Ebeldev/b6d2ef7954fd8376103f3deec952747e to your computer and use it in GitHub Desktop.
Save Ebeldev/b6d2ef7954fd8376103f3deec952747e to your computer and use it in GitHub Desktop.
My ultimate 30 seconds WordPress and roots/sage install.
function makesage() {
wp valet new $1 --dbname=$1 --admin_user=adminusertoreplace --admin_password=adminpasswordtoreplace --admin_email=adminemailtoreplace
cd $1
installAndActivePlugins
installPlugins
if [ -s "@:2"]
then
wp plugin install ${@:2} --activate
fi
valet secure $1 && cd ./wp-content/themes/ && composer create-project roots/sage $1 && rm -rf twentynineteen && rm -rf twentytwenty && rm -rf twentytwentyone && cd $1 && sageInstallLanguages && npm i && open -a "Firefox" https://$1.test && open -a "Firefox" https://$1.test/wp-admin
# cd ../../.. && wp theme activate $1 && cd ./wp-content/themes/$1
}
function installsage(){
composer create-project roost/sage $1
}
function sageInstallLanguages() {
mkdir -p ./resources/lang && find ./resources ./app -iname '*.php' | xargs xgettext --add-comments=TRANSLATORS --force-po --from-code=UTF-8 --default-domain=de_DE -k__ -k_e -k_n:1,2 -k_x:1,2c -k_ex:1,2c -k_nx:4c,12 -kesc_attr__ -kesc_attr_e -kesc_attr_x:1,2c -kesc_html__ -kesc_html_e -kesc_html_x:1,2c -k_n_noop:1,2 -k_nx_noop:3c,1,2, -k__ngettext_noop:1,2 -o resources/lang/sage.pot && find ./resources -iname '*.blade.php' | xargs xgettext --language=Python --add-comments=TRANSLATORS --force-po --from-code=UTF-8 --default-domain=de_DE -k__ -k_e -k_n:1,2 -k_x:1,2c -k_ex:1,2c -k_nx:4c,12 -kesc_attr__ -kesc_attr_e -kesc_attr_x:1,2c -kesc_html__ -kesc_html_e -kesc_html_x:1,2c -k_n_noop:1,2 -k_nx_noop:3c,1,2, -k__ngettext_noop:1,2 -j -o resources/lang/sage.pot
}
function installAndActivePlugins(){
wp plugin install query-monitor really-simple-ssl duracelltomi-google-tag-manager imsanity --activate
}
function installPlugins(){
wp plugin install all-in-one-wp-security-and-firewall wordfence webp-express
}
@Ebeldev
Copy link
Author

Ebeldev commented Nov 21, 2021

It install WordPress, makes a database, create the admin user, install some default plugins and other ones as 2nd arguments when invoke makewp, makes a https site, install roots/sage, make a .pot file for translation, install sage dependencies with npm and open a Firefox browser tab.

To work you need 3 things:

  1. wp_cli
  2. valet
  3. aaemnnosttv / wp-cli-valet-command package.

Usage:

  1. Edit this file and put the admin user, admin password and admin email and you are good to go.
  2. cd into your park folder of valet
  3. makewp andthenameofsiteyouwant

@Ebeldev
Copy link
Author

Ebeldev commented Nov 21, 2021

Example of use:
makesage mysupersite
or
makesage mysupersite wordpress-seo two-factor another-plugin-name andanother-plugin-name-and-etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment