WordCamp Manchester 2014
Optimising your Front-End Workflow for WordPress
With Simon Owen / @s10wen
A bit about me
I'm Simon Owen, a Front-End Developer.
I run a monthly meetup in Manchester, McrFRED.
A bit about me
I'm not 12.
Yes, I know I look young.
Yes, I do have my ID.
Where am I now?
Working at Carbon Creative.
Building sites to help a variety of businesses.
We love WordPress.
Disclaimer!
This is only one approach, there's many others.
Optimising your Front-End Workflow
- Make improvements with each project.
- Experiment with your workflow.
- Find what works best for you.
- Automate tasks.
- Save time with shortcuts.
- Version control with Git / GitHub / BitBucket.
- A little bash can go a long way.
The web is moving fast.
There's a bazillion things to learn.
We can't learn everything.
Don't Panic.
We have help.
Things I find helpful
- Dotfiles - Tutsplus tutorial
- Version Control
- Tooling
- Working Locally
Git / GitHub / BitBucket
View Commits
Check Over Code
Create a boilerplate theme
"Boilerplate code is any seemingly repetitive code that shows up again and again in order to get some result that seems like it ought to be much simpler."
Source: What is boilerplate code?
Risk
Implementing too much can be risky.
Make improvements in small chunks.
Always be able to carry out your work.
Use version control to avoid risk.
Local Database
Here I'm using Sequel Pro.
Connect locally to 127.0.0.1
.
Create a new database.
Local Development Environment
Let's step into Terminal
I just created a new directory
&&
I'm in it!
Install WordPress
Let's go to:
https://wordpress.org/download/
Right?
Nope
Back to the terminal!
Download WordPress as a zip file:
$ wget http://wordpress.org/latest.tar.gz
Unzip WordPress:
$ tar xfz latest.tar.gz
Move the contents of WordPress back a folder:
$ mv wordpress/* ./
Remove the wordpress directory:
$ rmdir wordpress
Remove the zip file:
$ rm -f latest.tar.gz
Go to themes folder:
$ cd wp-content/themes/
Remove twentyfourteen, twentythirteen, twentytwelve themes:
$ rm -rf twenty*
wordpress-install.sh
Copy and paste the into a new file,
or from my GitHub gist.
$ bash wordpress-install.sh
Voilà! A clean WordPress install.
Install your boilerplate theme
.gitconfig
c = clone --recursive
.aliases
alias g="git"
Means:
$ g c git@bitbucket.org:yourname/yourtheme.git
More time savers
# List all files colorized in long format
alias l="ls -l ${colorflag}"
# Open current directory in Sublime Text
alias s="subl ."
Cmd+T > Start typing out a filename > Enter
README.md
In your boilerplate theme (and pretty much any repo) it's worth having a README.md
Hopefully everyone is familiar with Markdown, if not check it out here http://daringfireball.net/projects/markdown/basics
Markdown is a massive time saver. Here's an example of the H5BP's README.md
https://raw.githubusercontent.com/h5bp/html5-boilerplate/master/README.md
Dependencies
One time installs
Node
Bower and Gulp
$ npm install -g bower gulp
Ok, but why?
Unicorns and rainbows await. Bear with me.
npm = package.json
bower = bower.json
gulp = gulpfile.js
Ok, so what did that do?
A whole bunch of awesome, that's what.
First let's install WordPress.
Install WordPress
http://sitename.dev/wp-admin/install.php
Activate your theme
Appearance > Themes
Let's Install something
Say we want bootstrap?, so we go to:
Right?
Nope
Back to the terminal!
Search
$ bower search bootstrap
Install
$ bower install bootstrap-sass-twbs --save
What did that do then?
Not only has that now pulled in bootstrap to our theme.
It's also saved it into the `bower.json` file.
Use wp_enqueue_script to pull in.
So next time when we do `$ bower install` it automatically installs.
Yayayaya
Styling with Sass
With gulp watch
, gulp will watch for changes in the /sass
folder.
With Sass it's possible to split code up into separate files called partials.
Live Reload Styling
Sass - CSS with superpowers
- Variables
- Nesting
- Mixins
Workflow Superpowers
- Sublime Text
- OS X Apps
- Git Goodness
Sublime Superpowers
Chrome Dev Tools
Responsive testing.
Power Tools
Quickly get to the app you're after.
Power Tools
Quickly view apps side by side.
@eczarny is ace and helped me out with my dotfiles.
Device Testing
GhostLab + DeviceLab
Browser Testing
Modern.ie - The place to go to get old IE browsers.
Automated installation of IE VMs.
Update VB hosts file to point VB to local.
Optimising
https://www.npmjs.org/package/gulp-minify-css
https://github.com/terinjokes/gulp-uglify
https://www.npmjs.org/package/gulp-imagemin
Images are huuuuge.
The End
WordCamp Manchester 2014
Optimising your Front-End Workflow for WordPress
With Simon Owen / @s10wen
WordCamp Manchester 2014
By Simon Owen
WordCamp Manchester 2014
- 5,421