Created
February 23, 2017 17:56
-
-
Save diekaines/90ba4761717846d007be3970cd3fa9ad to your computer and use it in GitHub Desktop.
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
@echo off | |
:: FOR THIS SCRIPT TO GENERATE PRETTY URLS YOU MUST ADD WP_CLI_CONFIG_PATH=%USERPROFILE%\.wp-cli\config.yml to your user/system environment variables | |
:: in config.yml you must specify apache_modules: - mod_rewrite | |
:: Important variables | |
SET ROOT=C:\wamp\www | |
SET DBUSER=root | |
SET DBPASS= | |
SET USER=admin | |
Set PASSWORD=admin | |
SET EMAIL=admin@example.org | |
:: Was an argument passed? | |
IF [%1] == [] GOTO fatal | |
echo. | |
echo -------------------------------------------------------------------------------- | |
echo Install WordPress | |
echo. | |
:: Navigate to the local project folder | |
cd %ROOT% | |
:: Set the name of the new install | |
SET NAME=%1 | |
:: Set the name of the new install | |
SET DBNAME=wp_%NAME% | |
echo. | |
echo -------------------------------------------------------------------------------- | |
echo Installing WordPress.. | |
echo. | |
:: Create directory | |
mkdir %NAME% | |
:: Go into directory | |
cd %NAME% | |
:: Download WordPress | |
call wp core download | |
:: Generate wp-config | |
:: We need to escape the php we pass in to the wp-config or we will get syntax errors | |
(echo define^^^('WP_DEBUG', true^^^);^ | |
& echo define^^^('WP_DEBUG_LOG', true ^^^);^ | |
& echo define^^^('WP_DEBUG_DISPLAY', false ^^^);^ | |
& echo @ini_set^^^('display_errors', 0 ^^^);^ | |
& echo define^^^('CONCATENATE_SCRIPTS', false ^^^);) | wp core config --dbname=%DBNAME% --dbuser=%DBUSER% --dbpass=%DBPASS% --extra-php | |
:: Create DB | |
call wp db create | |
:: Install wordpress | |
call wp core install --url="http://localhost/%NAME%" --title="%NAME%" --admin_user="%USER%" --admin_password="%PASSWORD%" --admin_email="%EMAIL%" | |
echo. | |
echo -------------------------------------------------------------------------------- | |
echo Cleaning Plugins | |
echo. | |
:: Discourage search engines | |
call wp option update blog_public 0 | |
:: show only 6 posts on an archive page | |
:: call wp option update posts_per_page 6 | |
:: Delete akismet and hello dolly | |
call wp plugin delete akismet | |
call wp plugin delete hello | |
:: Add our own plugins here | |
call wp plugin install woocommerce --activate | |
echo. | |
echo -------------------------------------------------------------------------------- | |
echo. | |
:: set pretty urls | |
:: we set pretty urls here to give it some time to complete before flushing the permalinks later | |
:: unfortunatly call does not work on this command so we have to open and run in a seperate cmd window | |
start cmd /c wp rewrite structure /%%postname%%/ --hard | |
:: Add and activate your own themes here | |
:: Clear Window | |
:: cls | |
echo. | |
echo -------------------------------------------------------------------------------- | |
echo Installation is complete. Your username/password have been added to your clipboard and are listed below. | |
echo. | |
echo Username: %USER% | |
echo Password: %PASSWORD% | |
echo. | |
echo. | |
:: Add to clipboard | |
:: echo Username: %USER% Password: %PASSWORD% | clip | |
:: start the project in browser | |
start http://localhost/%NAME%/wp-admin | |
:: unfortunatly call does not work on this command so we have to open and run in a seperate cmd window | |
start cmd /c wp rewrite flush --hard | |
pause | |
goto:eof | |
:fatal | |
echo. | |
echo -------------------------------------------------------------------------------- | |
echo Please specify a name for your WordPress Install | |
echo. | |
goto:eof | |
:END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment