Last active
June 2, 2021 21:41
-
-
Save edheltzel/a4665805bcf41d2f306ec67a09b37ee7 to your computer and use it in GitHub Desktop.
This is my VERY opinionated install script for WordPress - you'll need to have wp-cli installed for this to work - I have this wrapped as an ZSH function inside of my dotfiles setup but you can easily convert to a bash script.
This file contains hidden or 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
# ------------------------------------------------------------------- | |
# This file live inside of your ~/.wp-cli | |
# ------------------------------------------------------------------- | |
# path: cms # this is the path to your WordPress files | |
core install: | |
admin_user: <YOUR ADMIN USERNAME> | |
admin_password: <YOUR ADMIN PASSWORD> | |
admin_email: <YOUR ADMIN EMAIL> | |
title: The Next Big Deal in WordPress Sites | |
core config: | |
dbuser: root | |
dbpass: root | |
dbhost: localhost | |
extra-php: | | |
define( 'WP_DEBUG', true ); | |
define( 'WP_DEBUG_LOG', true ); | |
define( 'AUTOSAVE_INTERVAL', '120' ); | |
define( 'WP_POST_REVISIONS', false ); | |
define( 'MEDIA_TRASH', true ); | |
define( 'WP_AUTO_UPDATE_CORE', 'minor' ); | |
define( 'DISALLOW_FILE_EDIT', true ); |
This file contains hidden or 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
# ------------------------------------------------------------------- | |
# Wordpress | |
# ------------------------------------------------------------------- | |
fucntion wpinstall(){ | |
mkdir -p ~/Sites/"$@" && cd ~/Sites/"$@" | |
projectroot=$(pwd) | |
echo -e "$fg_bold[blue]---------------------------------------------------------------------------------" | |
echo -e "$fg_bold[blue] Project Root --> $projectroot " | |
echo -e "$fg_bold[blue]---------------------------------------------------------------------------------$reset_color" | |
wp core download | |
wp core config --dbname="$@" --dbuser=root --dbpass=root --dbprefix=rdm_ --extra-php <<PHP | |
define( 'WP_DEBUG', true ); | |
define( 'WP_DEBUG_LOG', true ); | |
define( 'AUTOSAVE_INTERVAL', '120' ); /** AutoSave every 2 minute */ | |
define( 'WP_POST_REVISIONS', false ); /** Disable Post Revisions. */ | |
define( 'MEDIA_TRASH', true ); /** Trash can for Media Library */ | |
define( 'WP_AUTO_UPDATE_CORE', 'minor' ); /** Auto Update only on minor releases */ | |
define( 'DISALLOW_FILE_EDIT', true ); /** No Plugin or Theme editor */ | |
PHP | |
wp db create | |
wp core install --url="http://[email protected]" --title="$@" --admin_user=ginfuru --admin_password=Passw0rd --admin_email="[email protected]" | |
# create pages and menus | |
wp post create --post_type=page --post_title=Home --post_status=publish --post_author=$(wp user get ginfuru --field=ID --format=ids) | |
wp post create --post_type=page --post_title=About --post_status=publish --post_author$(wp user get ginfuru --field=ID --format=ids) | |
wp post create --post_type=page --post_title=Contact --post_status=publish --post_author$(wp user get ginfuru --field=ID --format=ids) | |
wp menu create "Main Navigation" # create a navigation bar | |
# add pages to navigation | |
export IFS=" " | |
for pageid in $(wp post list --order="ASC" --orderby="date" --post_type=page --post_status=publish --posts_per_page=-1 --field=ID --format=ids); do | |
wp menu item add-post main-navigation $pageid | |
done | |
# assign navigaiton to primary location | |
wp menu location assign main-navigation primary | |
# update options | |
wp option update show_on_front 'page' | |
wp option update page_on_front $(wp post list --post_type=page --post_status=publish --posts_per_page=1 --pagename=home --field=ID --format=ids) | |
wp option update blogdescription '' | |
wp option update start_of_week 0 | |
wp option update timezone_string 'America/New_York' | |
wp option update permalink_structure '/%postname%' | |
# delete stupid stuff like plugins/themes | |
wp post delete 1 2--force # delete WP sample post/page | |
wp plugin delete akismet | |
wp plugin delete hello | |
wp theme delete twentytwelve | |
wp theme delete twentythirteen | |
wp theme delete twentyfourteen | |
wp theme delete twentyfifteen | |
# installing some good plugins and starter theme | |
wp theme install https://github.com/RainyDayMedia/flux/archive/master.zip # RDM Flux | |
wp plugin install wordpress-seo --activate # Yoast SEO | |
wp plugin install members --activate # Members | |
wp plugin install advanced-custom-fields # ACF | |
wp plugin install piklist --activate # Piklist - slowing migrating Flux away from ACF | |
wp plugin install wp-helpers --activate # Piklist WP Helper | |
wp plugin install adminimize --activate # Adminimize | |
wp plugin install ~/Dropbox\ \(Rainy\ Day\ Media\)/Company\ Info/Operations/Documents/Processes/webStandards/Wordpress_Standards/Plugins/GravityForms/gravityforms.zip --activate | |
wp plugin install ~/Dropbox\ \(Rainy\ Day\ Media\)/Company\ Info/Operations/Documents/Processes/webStandards/Wordpress_Standards/Plugins/iThemes/backupbuddy.zip | |
wp plugin install amr-shortcode-any-widget # Widget Stuff | |
wp plugin install user-switching # user switching | |
wp plugin install regenerate-thumbnails # regenerate thumbnails | |
wp plugin install social-networks-auto-poster-facebook-twitter-g | |
rm -rf readme.html license.txt wp-config-sample.php; | |
echo -e "$fg_bold[yellow]---------------------------------------------------------------------------------" | |
echo -e "$fg_bold[yellow] SETTING UP GIT" | |
echo -e "$fg_bold[yellow]---------------------------------------------------------------------------------$reset_color" | |
git init; | |
#setting up local-wp-config.php to avoid | |
var=$(cat <<EOF >> local-wp-config.php | |
<?php | |
define( 'DB_NAME', '"$@"' ); | |
define( 'DB_USER', 'root' ); | |
define( 'DB_PASSWORD', 'root' ); | |
define( 'DB_HOST', 'localhost' ); | |
EOF | |
) | |
echo -e "$fg_bold[red]---------------------------------------------------------------------------------" | |
echo -e "$fg_bold[red] HAPPY HACKING!" | |
echo -e "$fg_bold[red]---------------------------------------------------------------------------------$reset_color" | |
/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl -b . && open . && subl wp-config.php; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment