├── .gitignore ├── config-sample.cfg ├── newproject.command └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | config.cfg 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /config-sample.cfg: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # -------------------- 4 | # Variables declaration 5 | # -------------------- 6 | 7 | # If you left current directory blank, it will take the current directory 8 | DIRECTORY="/Applications/MAMP/htdocs/" 9 | 10 | # wordpress url must be a zip to download 11 | WORDPRESS_URL="https://wordpress.org/latest.zip" 12 | 13 | # Theme must be a git repository 14 | THEME_URL="https://github.com/jeremycastelli/Jelli.git" 15 | 16 | # Plugins must be zips to download 17 | # separate files with a space 18 | PLUGINS_URL=("https://downloads.wordpress.org/plugin/underconstruction.1.17.zip" "https://downloads.wordpress.org/plugin/ajax-thumbnail-rebuild.1.12.zip") 19 | 20 | # Path for mysql 21 | MYSQL_PATH='/Applications/MAMP/Library/bin/mysql' 22 | # OR if you don't use MAMP 23 | #MYSQL_PATH='mysql' 24 | 25 | # Local database with MAMP 26 | DB_USER='root' 27 | DB_PASSWORD='root' 28 | DB_HOST='localhost' 29 | 30 | # Local URL 31 | LOCAL_URL='http://localhost:8888/' 32 | 33 | # Sublime text path 34 | SUBLIME_PATH=/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl 35 | # OR if you created a symlink : https://gist.github.com/artero/1236170 36 | #SUBLIME_PATH='sublime' 37 | 38 | -------------------------------------------------------------------------------- /newproject.command: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Version = 1.3.3 4 | # 5 | 6 | 7 | # -------------------- 8 | # Load Variables 9 | # -------------------- 10 | CURRENTDIRECTORY=$(cd -P -- "$(dirname -- "$0")" && pwd -P) 11 | source $CURRENTDIRECTORY/config.cfg 12 | 13 | # -------------------- 14 | # Set directory 15 | # -------------------- 16 | cd $DIRECTORY 17 | 18 | # -------------------- 19 | # Set project name 20 | # -------------------- 21 | echo "What is the project name ?" 22 | read PROJECT_NAME 23 | while [[ -z "$PROJECT_NAME" ]]; do 24 | echo "Please, type your project name:" 25 | read PROJECT_NAME 26 | done 27 | 28 | # -------------------- 29 | # Create database 30 | # -------------------- 31 | echo "For local database configuration, I will use project name as database name, I just need table prefix (default : wp_)" 32 | read TABLE_PREFIX 33 | if [[ $TABLE_PREFIX == "" ]]; then 34 | TABLE_PREFIX="wp_" 35 | fi 36 | $MYSQL_PATH -u$DB_USER -p$DB_PASSWORD -e "create database "$PROJECT_NAME 37 | 38 | # -------------------- 39 | # Set FTP parmmeters for sublime SFTP mapping 40 | # -------------------- 41 | echo "If you want to configure sFTP now, please enter FTP host. Type Q to skip sFTP configuration" 42 | read FTP_HOST 43 | if [[ $FTP_HOST =~ ^[Qq]$ ]]; then 44 | FTP_HOST='' 45 | fi 46 | if [[ -n "$FTP_HOST" ]]; then 47 | 48 | ABORT_SFTP=false 49 | 50 | echo "FTP user ? (or Q to quit sFTP configuration)" 51 | read FTP_USER 52 | while [[ -z "$FTP_USER" ]]; do 53 | echo "Please, type your FTP user (or Q to quit sFTP configuration):" 54 | read FTP_USER 55 | done 56 | 57 | if [[ $FTP_USER =~ ^[Qq]$ ]]; then 58 | ABORT_SFTP=true 59 | fi 60 | 61 | if [[ $ABORT_SFTP == false ]]; then 62 | echo "FTP password ? (or Q to quit sFTP configuration)" 63 | read FTP_PASS 64 | while [[ -z "$FTP_PASS" ]]; do 65 | echo "Please, type your FTP password (or Q to quit sFTP configuration):" 66 | read FTP_PASS 67 | done 68 | fi 69 | 70 | if [[ $FTP_PASS =~ ^[Qq]$ ]]; then 71 | ABORT_SFTP=true 72 | fi 73 | 74 | if [[ $ABORT_SFTP == false ]]; then 75 | echo "FTP remote path ? (or Q to quit sFTP configuration)" 76 | read FTP_ROOT 77 | while [[ -z "$FTP_ROOT" ]]; do 78 | echo "Please, type your FTP remote path (or Q to quit sFTP configuration):" 79 | read FTP_ROOT 80 | done 81 | fi 82 | 83 | if [[ $FTP_ROOT =~ ^[Qq]$ ]]; then 84 | ABORT_SFTP=true 85 | fi 86 | 87 | # If sFTP has been aborted, set $FTP_HOST to null 88 | # so FTP files are not created 89 | if [[ $ABORT_SFTP == true ]]; then 90 | FTP_HOST='' 91 | fi 92 | 93 | fi 94 | 95 | 96 | # -------------------- 97 | # Function 98 | # Download unzip and remove 99 | # -------------------- 100 | function fetch_zip() 101 | { 102 | curl -o file.zip $1 103 | unzip -q file.zip 104 | rm file.zip 105 | } 106 | 107 | # -------------------- 108 | # Create project directory 109 | # -------------------- 110 | mkdir $PROJECT_NAME 111 | PROJECT_DIR=$DIRECTORY"/"$PROJECT_NAME 112 | cd $PROJECT_NAME 113 | 114 | # -------------------- 115 | # Fetch Wordpress latest build 116 | # -------------------- 117 | echo 'Download Wordpress...' 118 | fetch_zip $WORDPRESS_URL 119 | cp -R wordpress/* . 120 | rm -rf wordpress && rm readme.html && rm license.txt 121 | 122 | # -------------------- 123 | # Fetch H5BP server-config .htaccess 124 | # -------------------- 125 | git clone https://github.com/h5bp/server-configs-apache.git 126 | cp server-configs-apache/.htaccess .htaccess 127 | rm -rf server-configs 128 | 129 | # -------------------- 130 | # Fetch base theme & remove default themes 131 | # -------------------- 132 | echo 'Remove default themes and fetch your starter theme' 133 | cd wp-content/themes/ 134 | git clone --recursive $THEME_URL $PROJECT_NAME 135 | rm -r twentyten 136 | rm -r twentyeleven 137 | rm -r twentytwelve 138 | rm -r twentythirteen 139 | rm -r twentyfourteen 140 | rm -r twentyfifteen 141 | rm -r twentysixteen 142 | 143 | # -------------------- 144 | # Remove Hello Dolly plugin and fetch plugins 145 | # -------------------- 146 | echo 'Remove Hello Dolly and fetch your plugins' 147 | cd ../plugins/ 148 | rm hello.php 149 | 150 | for PLUGIN in ${PLUGINS_URL[@]} 151 | do 152 | fetch_zip $PLUGIN 153 | done 154 | 155 | # -------------------- 156 | # Create Wordpress wp-config.php 157 | # -------------------- 158 | echo 'Create wp-config...' 159 | cd $PROJECT_DIR 160 | touch wp-config-local.php 161 | echo "wp-config-local.php 166 | touch db.txt 167 | echo "if ( file_exists( dirname( __FILE__ ) . '/wp-config-local.php' ) ) { 168 | include( dirname( __FILE__ ) . '/wp-config-local.php' ); 169 | } else { 170 | define( 'DB_NAME', '' ); 171 | define( 'DB_USER', '' ); 172 | define( 'DB_PASSWORD', '' ); 173 | define( 'DB_HOST', '' ); // Probably 'localhost' 174 | }" > db.txt 175 | 176 | sed -e' 177 | /DB_NAME/,/localhost/ c\ 178 | hello 179 | ' \ 180 | wp-config-temp.php 181 | 182 | sed '/hello/ { 183 | r db.txt 184 | d 185 | }'wp-config.php 186 | mv wp-config.php wp-config-temp.php 187 | 188 | curl -o salt.txt https://api.wordpress.org/secret-key/1.1/salt/ 189 | 190 | sed '/#@-/r salt.txt' wp-config.php 191 | mv wp-config.php wp-config-temp.php 192 | 193 | sed "/#@+/,/#@-/d" wp-config.php 194 | mv wp-config.php wp-config-temp.php 195 | 196 | sed s/wp_/$TABLE_PREFIX/ wp-config.php 197 | 198 | rm wp-config-temp.php 199 | rm db.txt 200 | rm salt.txt 201 | 202 | # -------------------- 203 | # Create Sublime Project config file 204 | # -------------------- 205 | echo 'Create Sublime text 2 project file...' 206 | SUBLIME_PROJECT_FILE=$PROJECT_NAME".sublime-project" 207 | touch $SUBLIME_PROJECT_FILE 208 | echo '{ 209 | "folders": 210 | [ 211 | 212 | { 213 | "path": "./wp-content/themes/'$PROJECT_NAME'", 214 | "name": "My theme", 215 | "file_exclude_patterns":[ 216 | "._*" 217 | ], 218 | "folder_exclude_patterns": [".sass-cache"] 219 | }, 220 | { 221 | "path": "./wp-content/plugins", 222 | "file_exclude_patterns":[ 223 | "._*" 224 | ] 225 | }, 226 | { 227 | "path": ".", 228 | "name": "All website", 229 | "file_exclude_patterns":[ 230 | "._*", 231 | "*.sublime-project", 232 | "*.sublime-workspace" 233 | ], 234 | "folder_exclude_patterns": [".sass-cache"] 235 | } 236 | ] 237 | }' > $SUBLIME_PROJECT_FILE 238 | 239 | # -------------------- 240 | # Create sFTP config files 241 | # -------------------- 242 | echo 'Create FTP files...' 243 | function create_FTP_file() 244 | { 245 | touch sftp-config.json 246 | echo '{ 247 | // The tab key will cycle through the settings when first created 248 | // Visit http://wbond.net/sublime_packages/sftp/settings for help 249 | 250 | // sftp, ftp or ftps 251 | "type": "ftp", 252 | 253 | "save_before_upload": true, 254 | "upload_on_save": false, 255 | "sync_down_on_open": false, 256 | "sync_skip_deletes": false, 257 | "confirm_downloads": false, 258 | "confirm_sync": true, 259 | "confirm_overwrite_newer": false, 260 | 261 | "host": "'$FTP_HOST'", 262 | "user": "'$FTP_USER'", 263 | "password": "'$FTP_PASS'", 264 | //"port": "22", 265 | 266 | "remote_path": "'$1'", 267 | "ignore_regexes": [ 268 | "\\\\.sublime-(project|workspace)", "sftp-config(-alt\\\\d?)?\\\\.json", 269 | "sftp-settings\\\\.json", "/venv/", "\\\\.svn", "\\\\.hg", "\\\\.git", 270 | "\\\\.bzr", "_darcs", "CVS", "\\\\.DS_Store", "Thumbs\\\\.db", "desktop\\\\.ini","wp-config-local.php" 271 | ], 272 | //"file_permissions": "664", 273 | //"dir_permissions": "775", 274 | 275 | //"extra_list_connections": 0, 276 | 277 | "connect_timeout": 30, 278 | //"keepalive": 120, 279 | //"FTP_PASSive_mode": true, 280 | //"ssh_key_file": "~/.ssh/id_rsa", 281 | //"sftp_flags": ["-F", "/path/to/ssh_config"], 282 | 283 | //"preserve_modification_times": false, 284 | //"remote_time_offset_in_hours": 0, 285 | //"remote_encoding": "utf-8", 286 | //"remote_locale": "C", 287 | }' > sftp-config.json 288 | } 289 | if [[ $FTP_HOST != "" ]]; then 290 | create_FTP_file $FTP_ROOT 291 | cd "wp-content/themes/"$PROJECT_NAME 292 | create_FTP_file $FTP_ROOT"/wp-content/themes/"$PROJECT_NAME 293 | cd ../../plugins 294 | create_FTP_file $FTP_ROOT"/wp-content/plugins" 295 | fi 296 | 297 | # -------------------- 298 | # Launch sublime project 299 | # -------------------- 300 | echo 'Launch Sublime text 2' 301 | cd $PROJECT_DIR 302 | "$SUBLIME_PATH" $SUBLIME_PROJECT_FILE 303 | 304 | # -------------------- 305 | # Create a new project in CodeKit 306 | # -------------------- 307 | echo 'Create codekit project' 308 | open -a /Applications/CodeKit.app $PROJECT_DIR"/wp-content/themes/"$PROJECT_NAME 309 | 310 | # -------------------- 311 | # git init 312 | # -------------------- 313 | echo 'git init' 314 | git init 315 | echo ".DS_Store 316 | wp-config-local.php 317 | .sass-cache" > .gitignore 318 | 319 | # -------------------- 320 | # Launch default browser 321 | # -------------------- 322 | echo 'Launch browser' 323 | open $LOCAL_URL$PROJECT_NAME 324 | 325 | echo 'Installation Complete, press enter to quit' 326 | read 327 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | Wordpress New Project Config 2 | ==================== 3 | 4 | ##What is Wordpress New Project Config? 5 | This little script will save you the hassle of all the repetitives tasks each time you start a new wordpress project. 6 | 7 | ##So what it does? 8 | The script will 9 | - Prompt you for a project name 10 | - Create a new folder with the project name 11 | - Fetch and Install the latest wordpress build 12 | - Remove readme.html and license.txt 13 | - Fetch your favorite starter theme and rename it with your project name 14 | - Remove twentyten, twentyeleven and twentytwelve themes 15 | - Fetch a list of plugins you want on every projects 16 | - Remove Hello Dolly plugin 17 | - Fetch H5BP server-configs .htaccess 18 | - Create a database with your project name 19 | - Prompt you for a table prefix 20 | - Configure wp-config.php and change update salt strings 21 | - Create a wp-config-local.php file for local database parameters 22 | - Exclude wp-config-local.php in .gitignore and Sublime ftp config file 23 | - Create a Sublime text 2 project config file (projectName.sublime-project) 24 | - Configure .sublime-project file with 3 folders : 25 | - My theme 26 | - plugins 27 | - All website (it will be helpfull for the 1st migration on a remote server) 28 | - Prompt you if you want to configure ftp for Sublime text 2 29 | - Create a Sublime text 2 sFTP config file sftp-config.json in each folder. 30 | - Create a new project in codeKit 31 | - Launch your project in Sublime text 2 32 | - Open your newly created wordpress website in your favourite browser 33 | 34 | ##Requirements 35 | - I created this script for MAC, I don't know if it works on other platforms. 36 | - MAMP 37 | - git 38 | - codeKit 39 | - sublime text 2 40 | - and sFTP plugin if you want 41 | 42 | ##Installation 43 | Just duplicate config-sample.cfg to config.cfg 44 | 45 | ##Configuration 46 | You can edit the script with your favourite code editor and change some variables. 47 | - DIRECTORY you can type your projects folder path 48 | - WORDPRESS_URL must be a zip to download, I use zip download rather than a git repository cause I personally fetch a locale (french) version of wordpress 49 | - THEME_URL must be a git repository 50 | - PLUGINS_URL is a list of plugins from the wordpress.org plugin directory 51 | - DB_USER, DB_PASSWORD, DB_HOST these are the defaults for MAMP 52 | - LOCAL_URL default is localhost:8888/ for MAMP but you could have changed it 53 | 54 | and for sure, you can modify or delete some part not useful for you 55 | 56 | ##Why a .command extension? 57 | The script is a common shell script with normally a .sh extension 58 | The .command extension allow to make the script double clickable 59 | Tip : If you are using Alfred or an other launcher application, you can execute the script from everywhere! 60 | 61 | ##Changelog 62 | 63 | ###v1.3.3 64 | - recursively clone submodules in theme repository 65 | - Remove twentyfifteen and twentysixteen themes 66 | 67 | ###v1.3.2 68 | - fixe a mySQL issue 69 | - Remove twentythirteen and twentyfourteen themes 70 | - Update fetching of the new H5BP .htaccess 71 | 72 | ###v1.3.1 73 | - Add mysql path in the config file 74 | - Add sublime text path in the config file 75 | 76 | ###v1.3 77 | - Now you can fetch a list a plugins from the wordpress.org plugin directory 78 | 79 | ###v1.2.2 80 | - Fixed the path for browser launching (thanks to Aarow) 81 | 82 | ###v1.2.1 83 | - Fixed sftp config process (thanks to Carles Jove) 84 | 85 | ###v1.2 86 | - Do not allow empty strings on FTP config, and allow to abort process (thanks to Carles Jove) 87 | 88 | ###v1.1.2 89 | - Empty values are now not allowed for project name (thanks to Carles Jove) 90 | 91 | ###v1.1.1 92 | - Fixed table_prefix issue 93 | 94 | ###v1.1 95 | - Split the configuration part in an another file config.cfg 96 | - gitignore config.cfg --------------------------------------------------------------------------------