Leaving the worn path

Finding your own custom WordPress workflow


Thomas Kräftner
http://kraftner.com | @tkraftner

Highlighting issues, hinting at solutions.


"Trust me, do this. Never mind why."

Getting started with WordPress is easy.

Lifecycle of a site

  • Feature A
  • Feature B
  • Feature C
  • Content
  • Updates
  • Bugfixes
  • New Features
  • Broken Site
  • Common approach - not recommended!

  • Upload WordPress with FTP
  • Setup theme & plugins
  • Update on the live site
  • Hope nothing ever breaks
    


Local Server Resources

  • A Feat

Version Control

  • Record history changes
  • Branch out & try stuff
  • Compare changes


GIT

  • Feature A
  • Feature B
  • Feature A
  •  

Code, Uploads & Database


  • Develop

  • Feature A
  • Feature B
  • Feature C
  • Updates
  • Bugfixes
  • More Features

 







  • Staging

  • Feature A
  • Feature B
  • Feature C
  • Updates
  • Bugfixes
  • More Features

 







  • Production

  • Feature A
  • Feature B
  • Feature C
  • Updates
  • Bugfixes
  • More Features
  • FTP
  • Git
    1. Push to Git-server
    2. SSH into webserver
    3. Pull from Git-server

Deployment

Manual Deployment

Automated Deployment

Deployment Tools and Services

  • Push branch "stage" to Git-server (e.g. github)
  • SSH into staging web server
  • Create backup before deployment
  • Pull branch "stage" from Git-server
  • Automatically install dependencies

Deployments fail & sites break

  • Rollbacks
    • Automate Deployment Tools
    • Keep X deployments for rollbacks
  • Backup & Restore
    • Fresh automated
    • Working try restore
    • Also during development
    • Easy restore
  • Code
  • Database
  • Uploads

Database Migration

  1. Overwrite DB on target with source DB
  2. Replace URL references in target DB

Uploads Migration

  1. Copy/Sync upload folder

Migrations as one simple task Deployment Tools

  • Prepare changes on local machine
  • Copy site to local machine for debugging

Third party code

Dependencies in Git
wp-admin/js/common.js
wp-admin/js/customize-controls.min.js
wp-admin/js/editor.min.js
wp-admin/js/customize-nav-menus.min.js
wp-admin/js/tags-box.js
wp-admin/js/customize-controls.js
wp-admin/js/editor.js
wp-admin/js/customize-nav-menus.js
wp-admin/js/common.min.js
wp-admin/js/tags-box.min.js
wp-admin/plugins.php
wp-admin/includes/class-wp-press-this.php
wp-admin/includes/media.php
wp-admin/includes/image.php
wp-admin/about.php
wp-includes/embed.php
wp-includes/class-wp-customize-manager.php
wp-includes/rest-api.php
wp-includes/js/media-views.min.js
wp-includes/js/wp-api.js
wp-includes/js/tinymce/plugins/wpeditimage/plugin.min.js
wp-includes/js/tinymce/plugins/wpeditimage/plugin.js
wp-includes/js/tinymce/wp-tinymce.js.gz
wp-includes/js/customize-selective-refresh.min.js
wp-includes/js/media-views.js
wp-includes/js/customize-preview.min.js
wp-includes/js/customize-views.min.js
wp-includes/js/customize-selective-refresh.js
wp-includes/js/wp-api.min.js
wp-includes/js/customize-preview.js
wp-includes/js/customize-views.js
wp-includes/class-wp-image-editor-imagick.php
wp-includes/class-wp-customize-nav-menus.php
wp-includes/version.php
wp-includes/class-walker-page.php
wp-includes/pluggable.php
wp-includes/formatting.php
wp-includes/class-wp-customize-widgets.php
wp-includes/rest-api/class-wp-rest-request.php
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php
wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
wp-includes/class-wp-customize-setting.php
wp-includes/theme.php
wp-includes/functions.php
wp-includes/media.php
wp-includes/class-wp-http-requests-hooks.php
wp-includes/class-wp-taxonomy.php
                                
Dependencies managed with Composer
Updated WordPress from 4.7.2 to 4.7.3

Dependency Management

Composer

  • Don't commit 3rd party code …
  • … instead define dependencies.
Source: https://xkcd.com/1205/ (CC BY-NC 2.5)

Time != Time

  1. Tasks in high-pressure situations
  2. Great time spent/saved ratio
  3. Everything else

Thanks!

Questions?

See you at the happiness bar!


Thomas Kräftner
http://kraftner.com | @tkraftner