SlideShare a Scribd company logo
1
A new way to develop with
WordPress!
2
1. Introduction
2. Classic WordPress workflow
3. The Composer way
a. Overview
b. Integrating with WordPress
c. WordPress Packagist
4. Enter Bedrock
a. Overview
b. Working on your project
c. PhpDotEnv
d. Deploying your project
e. Multisite
5. Theming with Twig and Timber
a. Overview
b. Templating files
c. Bonus (Debug bar)
Table of content
6. Developing plugins with Herbert
a. Overview
b. Basis
7. References
3
A report on 1 july 2016 suggest
that WordPress powers
26.6% of the internet.
Introduction
4
How to?
1. Download WordPress
2. Push WordPress using FTP
3. Install WordPress (generate wp-config.php)
4. Install plugins/themes using FTP or backend
5. Update manually plugins/themes
Classic WordPress workflow
Issues
1. Updating WordPress/plugins can break site
2. Manually keep track of WordPress and
plugins/themes versions (on Git)
3. Deploys can be cumbersome (hours)
4. Configuring WordPress in multiple environments
is difficult (wp-config.php, unversioned)
5
Tools
โ— Git
โ— Composer
โ— WordPress Packagist
Advantages
โ— Dependencies explicitly declared in a single place (composer.json)
โ— Installing/Updating handled by Composer
โ— Project locked onto specific versions
โ— Donโ€™t need to include the actual 3rd party code in your version control repository
The Composer way: Overview
6
Dependencies
โ— WordPress itself
โ— Plugins
โ— Themes
โ— Private repos
Structure
The Composer way: Integrating with WordPress
Composer.json
โž” auto-updating fork (syncs every 15 minutes
with the official WP repo) that includes
composer.json
{
"require": {
"php": ">=5.4",
"johnpbloch/wordpress": "~4.5"
},
"extra": {
"wordpress-install-dir": "wp"
}
}
.
โ”œโ”€โ”€ wp
โ”œโ”€โ”€ wp-content
โ”œโ”€โ”€ index.php
โ””โ”€โ”€ wp-config.php
โž” require johnpbloch/wordpress-core-installer
7
โž” Mirror of the WordPress plugin directory as a
Composer repository
The Composer way: WordPress Packagist
{
"extra": {
"installer-paths": {
"content/mu-plugins/{$name}/": [
"type:wordpress-muplugin"
],
"content/plugins/{$name}/": [
"type:wordpress-plugin"
],
"content/themes/{$name}/": [
"type:wordpress-theme"
]
}
}
}
{
"repositories": [
{
"type": "composer",
"url": "http://wpackagist.org"
}
]
}
1. Add the repository to your composer.json
2. Add the desired plugins and themes
3. Run
composer require wpackagist-plugin/contact-
form-7
Extra: customize installer paths
composer update
8
Features
โ— Better folder structure
โ— Dependency management with Composer
โ— Easy WordPress configuration with environment specific files
โ— Environment variables with Dotenv
โ— Autoloader for mu-plugins (use regular plugins as mu-plugins)
โ— Enhanced security (separated web root and secure passwords with wp-password-bcrypt)
Requirements
โ˜… PHP >= 5.6
โ˜… Composer
Enter Bedrock: Overview
9
Enter Bedrock: Working on your project
Installation
1. composer create-project roots/bedrock
2. Copy .env.example to .env
3. Vhost => /path/to/site/web/
4. http://example.com/wp/wp-admin
.
โ”œโ”€โ”€ config
โ”‚ โ”œโ”€โ”€ application.php
โ”‚ โ””โ”€โ”€ environments
โ”‚ โ”œโ”€โ”€ development.php
โ”‚ โ”œโ”€โ”€ production.php
โ”‚ โ””โ”€โ”€ staging.php
โ”œโ”€โ”€ vendor
โ”œโ”€โ”€ web
โ”‚ โ”œโ”€โ”€ app
โ”‚ โ”‚ โ”œโ”€โ”€ mu-plugins
โ”‚ โ”‚ โ”œโ”€โ”€ plugins
โ”‚ โ”‚ โ”œโ”€โ”€ themes
โ”‚ โ”‚ โ””โ”€โ”€ uploads
โ”‚ โ”œโ”€โ”€ wp
โ”‚ โ””โ”€โ”€ wp-config.php
Folder structure of Bedrock
10
Configuration and environment variables
Enter Bedrock: PhpDotEnv
DB_NAME=database_name
DB_USER=database_user
DB_PASSWORD=database_password
DB_HOST=database_host
WP_ENV=development
WP_HOME=http://example.com
WP_SITEURL=${WP_HOME}/wp
# Generate your keys here: https://roots.io/salts.html
AUTH_KEY='generateme'
SECURE_AUTH_KEY='generateme'
LOGGED_IN_KEY='generateme'
NONCE_KEY='generateme'
AUTH_SALT='generateme'
SECURE_AUTH_SALT='generateme'
LOGGED_IN_SALT='generateme'
NONCE_SALT='generateme'
Stage Switcher
โž” A WordPress plugin that allows you to
switch between different environments
from the admin bar.
โž” https://roots.io/plugins/stage-switcher/
Installation
composer require roots/wp-stage-switcher
11
How to?
Enter Bedrock: Deploying your project
Migrating an existing project to Bedrock
1. Install Bedrock
2. Configure WordPress
3. Install plugins/themes with Composer
composer install
12
Features
โ— Better folder structure
โ— Dependency management with Composer
โ— Easy WordPress configuration with environment specific files
โ— Environment variables with Dotenv
โ— Autoloader for mu-plugins (use regular plugins as mu-plugins)
โ— Debug Bar plugin
โ— Developer plugin
โ— Stage Switcher plugin
โ— MultisiteDirectoryResolver: filters that correct directory paths
โ— Koodimonni composer lang support
Installation
Enter Bedrock: Multisite
composer create-project gwa-bedrock-multisite-
skeleton
13
Advantages Of Using A Templating Language
1. Concise
2. Template orientated
3. Full-featured
4. Easy to learn
5. Extensibility
6. Fast
Theming with Twig and Timber: Overview
Timber presentation
1. Integrates the Twig engine into WordPress
2. Creates a foundation WordPress data set
3. Handles the rendering of Twig templates
Installing Timber
composer require wpackagist-plugin/timber-
library
14
PHP files are only concerned with
collating the required data
Theming with Twig and Timber: Templating files
<?php
/**
* The main template file.
*/
// set up page data
$data = Timber::get_context();
$data['posts'] = Timber::get_posts();
$data['page'] = 'home';
// render using Twig template index.twig
Timber::render('twig/index.twig', $data);
{% extends 'twig/base.twig' %}
{% block content %}
<!-- start the loop -->
{% for post in posts %}
{{ include( 'twig/content.twig', ignore_missing = true )
}}
{% else %}
{{ include( 'twig/content-none.twig' ) }}
{% endfor %}
{% if posts %}{{ function( 'bosco_paging_nav' ) }}{% endif %}
{% endblock %}
Timber methods to get the generic data and then renders
the index.twig template
15
Letโ€™s have a look at the base template
Theming with Twig and Timber: Templating files
{% import 'twig/macros.twig' as macros %}
{{ function( 'get_header' ) }}
<div id="primary" class="content-area">
<div id="main" class="site-main" role="main">
{% block content %}{% endblock %}
</div><!-- #main -->
</div><!-- #primary -->
{{ function( 'get_sidebar' ) }}
{{ function( 'get_footer' ) }}
OK, But PHP And Twig? Isnโ€™t That Doubling-Up?
1. Checking is_singular
2. Checking page type:
a. is_single
b. is_page
c. is_home
d. is_category
e. is_tag
f. is_author
// render using Twig template index.twig
Timber::render('twig/' . $template . '.twig',
$data);
16
What is WordPress Debug Bar?
โ— debug menu to the admin bar
โ— Shows query, cache, other helpful
debugging information
How To install?
https://wordpress.org/plugins/debug-bar/
Theming with Twig and Timber: Bonus (Debug Bar)
What is Timber Debug Bar?
โ— current template name
โ— absolute location on your server
โ— full contents of the context
How To install?
https://wordpress.org/plugins/debug-bar-timber/
composer require wpackagist-plugin/debug-bar
composer require wpackagist-plugin/debug-bar-
timber
17
Overview
โ— OOP
โ— MVC
โ— Twig template engine
โ— Composer
โ— Laravel Eloquent ORM
Requirements
โž” PHP 5.4+
โž” WordPress 3.4+
Installation
Developing plugins with Herbert: Overview
composer require getherbert/herbert-plugin
Features
โ— Config
โ— Routes
โ— Panels
โ— Enqueue (JS + CSS scripts)
โ— Helper
โ— Controllers
โ— Views
โ— Input (GET; POST)
โ— API
โ— Shortcodes
โ— Activate & Deactivate
โ— Messages (notifications)
โ— Widgets
โ— Saving data (Eloquent ORM)
โ— Custom Post Types
18
Naming your Plugin
Developing plugins with Herbert: Basis
.
โ”œโ”€โ”€ app
โ”‚ โ”œโ”€โ”€ Helper.php
โ”‚ โ”œโ”€โ”€ api.php
โ”‚ โ”œโ”€โ”€ enqueue.php
โ”‚ โ”œโ”€โ”€ panels.php
โ”‚ โ”œโ”€โ”€ routes.php
โ”‚ โ”œโ”€โ”€ shortcodes.php
โ”‚ โ””โ”€โ”€ widgets.php
โ”œโ”€โ”€ resources
โ”‚ โ”œโ”€โ”€ assets
โ”‚ โ””โ”€โ”€ views
โ”œโ”€โ”€ composer.json
โ”œโ”€โ”€ herbert.config.php
โ””โ”€โ”€ plugin.php
/**
* @wordpress-plugin
* Plugin Name: My Plugin
* Plugin URI: http://plugin-name.com/
* Description: A plugin.
* Version: 1.0.0
* Author: Author
* Author URI: http://author.com/
* License: MIT
*/
Folder structure of your Plugin
19
โ— https://roots.io/using-composer-with-wordpress/
โ— https://roots.io/bedrock/
โ— https://roots.io/bedrock/docs/
โ— https://roots.io/plugins/stage-switcher/
โ— https://css-tricks.com/intro-bedrock-wordpress/
โ— https://premium.wpmudev.org/blog/simplify-your-wordpress-theming-with-twig-and-timber/
โ— http://getherbert.com
โ— https://github.com/studio24/wordpress-multi-env-config
References

More Related Content

PPTX
PHP7 Presentation
PDF
The new features of PHP 7
PDF
Key features PHP 5.3 - 5.6
PDF
Melhorando sua API com DSLs
PDF
PHP7 - Scalar Type Hints & Return Types
PPTX
Introducing PHP Latest Updates
PDF
What's new in PHP 5.5
PDF
Codeigniter4ใฎๆฏ”่ผƒใจๆคœ่จผ
PHP7 Presentation
The new features of PHP 7
Key features PHP 5.3 - 5.6
Melhorando sua API com DSLs
PHP7 - Scalar Type Hints & Return Types
Introducing PHP Latest Updates
What's new in PHP 5.5
Codeigniter4ใฎๆฏ”่ผƒใจๆคœ่จผ

What's hot (20)

ZIP
Web Apps in Perl - HTTP 101
KEY
Zend Framework Study@Tokyo #2
PPTX
Webrtc mojo
ODP
PHP5.5 is Here
PDF
Controlling Arduino With PHP
PDF
Asynchronous I/O in PHP
PDF
Perl web frameworks
ย 
PDF
Redis & ZeroMQ: How to scale your application
ย 
ODP
The why and how of moving to PHP 5.4/5.5
PPTX
Php 7 hhvm and co
ODP
Php in 2013 (Web-5 2013 conference)
ODP
ekb.py - Python VS ...
PDF
้–ข่ฅฟPHPๅ‹‰ๅผทไผš php5.4ใคใพใฟใใ„
PPTX
New in php 7
PPTX
Zephir - A Wind of Change for writing PHP extensions
PDF
React PHP: the NodeJS challenger
ย 
ODP
PHP Tips for certification - OdW13
ODP
The why and how of moving to PHP 5.5/5.6
KEY
groovy & grails - lecture 2
PDF
Cli the other SAPI confoo11
Web Apps in Perl - HTTP 101
Zend Framework Study@Tokyo #2
Webrtc mojo
PHP5.5 is Here
Controlling Arduino With PHP
Asynchronous I/O in PHP
Perl web frameworks
ย 
Redis & ZeroMQ: How to scale your application
ย 
The why and how of moving to PHP 5.4/5.5
Php 7 hhvm and co
Php in 2013 (Web-5 2013 conference)
ekb.py - Python VS ...
้–ข่ฅฟPHPๅ‹‰ๅผทไผš php5.4ใคใพใฟใใ„
New in php 7
Zephir - A Wind of Change for writing PHP extensions
React PHP: the NodeJS challenger
ย 
PHP Tips for certification - OdW13
The why and how of moving to PHP 5.5/5.6
groovy & grails - lecture 2
Cli the other SAPI confoo11
Ad

Viewers also liked (20)

PPTX
Presentation of Python, Django, DockerStack
PDF
PDF
Nouveauteฬs php 7
PDF
PHP 7 - Think php7
PDF
Prot. 121 17 pl autoriza o poder executivo municipal a realizar obras de p...
PPTX
Licencia creative commons - TI4
PPTX
Vaccines
ODP
Ejemplo Impress
PPTX
ะŸั€ะตะทะตะฝั‚ะฐั†ะธั ะบ ะพั‚ะบั€ั‹ั‚ะพะผัƒ ัƒั€ะพะบัƒ
PDF
Trabajo individual quidam
PPTX
Five key elements to create a culture of accountability
PPTX
Cross-Cultural Competence - CLS
PPTX
TI Quidam / Josรฉ Alejandro Brescia Sellรฉs
PPTX
Presentation @ #cesicon 2017 on the Provision of Computer Science in Upper Se...
PDF
Modern Control Matlab_Dr. Khaki Seddigh
ODP
La segunda repรบblica espaรฑola
PDF
Introduction To Mechanical Smoke Control CPD Presentation
PDF
Introduce php7
PPTX
Whatโ€™s New in PHP7?
PDF
PHP7 e Rich Domain Model
Presentation of Python, Django, DockerStack
Nouveauteฬs php 7
PHP 7 - Think php7
Prot. 121 17 pl autoriza o poder executivo municipal a realizar obras de p...
Licencia creative commons - TI4
Vaccines
Ejemplo Impress
ะŸั€ะตะทะตะฝั‚ะฐั†ะธั ะบ ะพั‚ะบั€ั‹ั‚ะพะผัƒ ัƒั€ะพะบัƒ
Trabajo individual quidam
Five key elements to create a culture of accountability
Cross-Cultural Competence - CLS
TI Quidam / Josรฉ Alejandro Brescia Sellรฉs
Presentation @ #cesicon 2017 on the Provision of Computer Science in Upper Se...
Modern Control Matlab_Dr. Khaki Seddigh
La segunda repรบblica espaรฑola
Introduction To Mechanical Smoke Control CPD Presentation
Introduce php7
Whatโ€™s New in PHP7?
PHP7 e Rich Domain Model
Ad

Similar to A new way to develop with WordPress! (20)

PDF
WordPress modern development
PDF
The Enterprise Wor/d/thy/Press
PDF
Deploying WP Multisite to Heroku
PDF
[WLDN] Supercharging word press development in 2018
PDF
Managing a WordPress Site as a Composer Project by Rahul Bansal @ WordCamp Na...
ย 
PPTX
Use Symfony2 components inside WordPress
PDF
Modern Gentlemen's WordPress
PDF
WordCamp Belfast DevOps for Beginners
PDF
Web development automatisation for fun and profit (Artem Daniliants)
PPTX
WordPress Continuous Maintenance
PDF
eMusic: WordPress in the Enterprise
PDF
The WP Engine Developer Experience. Increased agility, improved efficiency.
PDF
Twig, the flexible, fast, and secure template language for PHP
PPTX
WordPress Development Environments
PPTX
Improving WordPress Theme Development Workflow - Naveen Kharwar.
PDF
A Better WordPress Workflow with WP-CLI
PDF
The Enterprise Wor/d/thy/Press
PPTX
Introduction to git & WordPress
PDF
Developers, Be a Bada$$ with WP-CLI
PDF
No More Cowboy Coding: Modern WordPress Development Workflow That Scales
WordPress modern development
The Enterprise Wor/d/thy/Press
Deploying WP Multisite to Heroku
[WLDN] Supercharging word press development in 2018
Managing a WordPress Site as a Composer Project by Rahul Bansal @ WordCamp Na...
ย 
Use Symfony2 components inside WordPress
Modern Gentlemen's WordPress
WordCamp Belfast DevOps for Beginners
Web development automatisation for fun and profit (Artem Daniliants)
WordPress Continuous Maintenance
eMusic: WordPress in the Enterprise
The WP Engine Developer Experience. Increased agility, improved efficiency.
Twig, the flexible, fast, and secure template language for PHP
WordPress Development Environments
Improving WordPress Theme Development Workflow - Naveen Kharwar.
A Better WordPress Workflow with WP-CLI
The Enterprise Wor/d/thy/Press
Introduction to git & WordPress
Developers, Be a Bada$$ with WP-CLI
No More Cowboy Coding: Modern WordPress Development Workflow That Scales

Recently uploaded (20)

PDF
Sims 4 Historia para lo sims 4 para jugar
PDF
Testing WebRTC applications at scale.pdf
PDF
Cloud-Scale Log Monitoring _ Datadog.pdf
PDF
WebRTC in SignalWire - troubleshooting media negotiation
PDF
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
ย 
PPTX
Introuction about ICD -10 and ICD-11 PPT.pptx
PDF
Unit-1 introduction to cyber security discuss about how to secure a system
PPTX
Slides PPTX World Game (s) Eco Economic Epochs.pptx
PDF
Introduction to the IoT system, how the IoT system works
ย 
PDF
Paper PDF World Game (s) Great Redesign.pdf
PPTX
innovation process that make everything different.pptx
PDF
Automated vs Manual WooCommerce to Shopify Migration_ Pros & Cons.pdf
PDF
Slides PDF The World Game (s) Eco Economic Epochs.pdf
PDF
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
PDF
FINAL CALL-6th International Conference on Networks & IOT (NeTIOT 2025)
PDF
๐Ÿ’ฐ ๐”๐Š๐“๐ˆ ๐Š๐„๐Œ๐„๐๐€๐๐†๐€๐ ๐Š๐ˆ๐๐„๐‘๐Ÿ’๐ƒ ๐‡๐€๐‘๐ˆ ๐ˆ๐๐ˆ ๐Ÿ๐ŸŽ๐Ÿ๐Ÿ“ ๐Ÿ’ฐ
ย 
PPTX
SAP Ariba Sourcing PPT for learning material
PPTX
introduction about ICD -10 & ICD-11 ppt.pptx
PPTX
presentation_pfe-universite-molay-seltan.pptx
PDF
Decoding a Decade: 10 Years of Applied CTI Discipline
Sims 4 Historia para lo sims 4 para jugar
Testing WebRTC applications at scale.pdf
Cloud-Scale Log Monitoring _ Datadog.pdf
WebRTC in SignalWire - troubleshooting media negotiation
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
ย 
Introuction about ICD -10 and ICD-11 PPT.pptx
Unit-1 introduction to cyber security discuss about how to secure a system
Slides PPTX World Game (s) Eco Economic Epochs.pptx
Introduction to the IoT system, how the IoT system works
ย 
Paper PDF World Game (s) Great Redesign.pdf
innovation process that make everything different.pptx
Automated vs Manual WooCommerce to Shopify Migration_ Pros & Cons.pdf
Slides PDF The World Game (s) Eco Economic Epochs.pdf
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
FINAL CALL-6th International Conference on Networks & IOT (NeTIOT 2025)
๐Ÿ’ฐ ๐”๐Š๐“๐ˆ ๐Š๐„๐Œ๐„๐๐€๐๐†๐€๐ ๐Š๐ˆ๐๐„๐‘๐Ÿ’๐ƒ ๐‡๐€๐‘๐ˆ ๐ˆ๐๐ˆ ๐Ÿ๐ŸŽ๐Ÿ๐Ÿ“ ๐Ÿ’ฐ
ย 
SAP Ariba Sourcing PPT for learning material
introduction about ICD -10 & ICD-11 ppt.pptx
presentation_pfe-universite-molay-seltan.pptx
Decoding a Decade: 10 Years of Applied CTI Discipline

A new way to develop with WordPress!

  • 1. 1 A new way to develop with WordPress!
  • 2. 2 1. Introduction 2. Classic WordPress workflow 3. The Composer way a. Overview b. Integrating with WordPress c. WordPress Packagist 4. Enter Bedrock a. Overview b. Working on your project c. PhpDotEnv d. Deploying your project e. Multisite 5. Theming with Twig and Timber a. Overview b. Templating files c. Bonus (Debug bar) Table of content 6. Developing plugins with Herbert a. Overview b. Basis 7. References
  • 3. 3 A report on 1 july 2016 suggest that WordPress powers 26.6% of the internet. Introduction
  • 4. 4 How to? 1. Download WordPress 2. Push WordPress using FTP 3. Install WordPress (generate wp-config.php) 4. Install plugins/themes using FTP or backend 5. Update manually plugins/themes Classic WordPress workflow Issues 1. Updating WordPress/plugins can break site 2. Manually keep track of WordPress and plugins/themes versions (on Git) 3. Deploys can be cumbersome (hours) 4. Configuring WordPress in multiple environments is difficult (wp-config.php, unversioned)
  • 5. 5 Tools โ— Git โ— Composer โ— WordPress Packagist Advantages โ— Dependencies explicitly declared in a single place (composer.json) โ— Installing/Updating handled by Composer โ— Project locked onto specific versions โ— Donโ€™t need to include the actual 3rd party code in your version control repository The Composer way: Overview
  • 6. 6 Dependencies โ— WordPress itself โ— Plugins โ— Themes โ— Private repos Structure The Composer way: Integrating with WordPress Composer.json โž” auto-updating fork (syncs every 15 minutes with the official WP repo) that includes composer.json { "require": { "php": ">=5.4", "johnpbloch/wordpress": "~4.5" }, "extra": { "wordpress-install-dir": "wp" } } . โ”œโ”€โ”€ wp โ”œโ”€โ”€ wp-content โ”œโ”€โ”€ index.php โ””โ”€โ”€ wp-config.php โž” require johnpbloch/wordpress-core-installer
  • 7. 7 โž” Mirror of the WordPress plugin directory as a Composer repository The Composer way: WordPress Packagist { "extra": { "installer-paths": { "content/mu-plugins/{$name}/": [ "type:wordpress-muplugin" ], "content/plugins/{$name}/": [ "type:wordpress-plugin" ], "content/themes/{$name}/": [ "type:wordpress-theme" ] } } } { "repositories": [ { "type": "composer", "url": "http://wpackagist.org" } ] } 1. Add the repository to your composer.json 2. Add the desired plugins and themes 3. Run composer require wpackagist-plugin/contact- form-7 Extra: customize installer paths composer update
  • 8. 8 Features โ— Better folder structure โ— Dependency management with Composer โ— Easy WordPress configuration with environment specific files โ— Environment variables with Dotenv โ— Autoloader for mu-plugins (use regular plugins as mu-plugins) โ— Enhanced security (separated web root and secure passwords with wp-password-bcrypt) Requirements โ˜… PHP >= 5.6 โ˜… Composer Enter Bedrock: Overview
  • 9. 9 Enter Bedrock: Working on your project Installation 1. composer create-project roots/bedrock 2. Copy .env.example to .env 3. Vhost => /path/to/site/web/ 4. http://example.com/wp/wp-admin . โ”œโ”€โ”€ config โ”‚ โ”œโ”€โ”€ application.php โ”‚ โ””โ”€โ”€ environments โ”‚ โ”œโ”€โ”€ development.php โ”‚ โ”œโ”€โ”€ production.php โ”‚ โ””โ”€โ”€ staging.php โ”œโ”€โ”€ vendor โ”œโ”€โ”€ web โ”‚ โ”œโ”€โ”€ app โ”‚ โ”‚ โ”œโ”€โ”€ mu-plugins โ”‚ โ”‚ โ”œโ”€โ”€ plugins โ”‚ โ”‚ โ”œโ”€โ”€ themes โ”‚ โ”‚ โ””โ”€โ”€ uploads โ”‚ โ”œโ”€โ”€ wp โ”‚ โ””โ”€โ”€ wp-config.php Folder structure of Bedrock
  • 10. 10 Configuration and environment variables Enter Bedrock: PhpDotEnv DB_NAME=database_name DB_USER=database_user DB_PASSWORD=database_password DB_HOST=database_host WP_ENV=development WP_HOME=http://example.com WP_SITEURL=${WP_HOME}/wp # Generate your keys here: https://roots.io/salts.html AUTH_KEY='generateme' SECURE_AUTH_KEY='generateme' LOGGED_IN_KEY='generateme' NONCE_KEY='generateme' AUTH_SALT='generateme' SECURE_AUTH_SALT='generateme' LOGGED_IN_SALT='generateme' NONCE_SALT='generateme' Stage Switcher โž” A WordPress plugin that allows you to switch between different environments from the admin bar. โž” https://roots.io/plugins/stage-switcher/ Installation composer require roots/wp-stage-switcher
  • 11. 11 How to? Enter Bedrock: Deploying your project Migrating an existing project to Bedrock 1. Install Bedrock 2. Configure WordPress 3. Install plugins/themes with Composer composer install
  • 12. 12 Features โ— Better folder structure โ— Dependency management with Composer โ— Easy WordPress configuration with environment specific files โ— Environment variables with Dotenv โ— Autoloader for mu-plugins (use regular plugins as mu-plugins) โ— Debug Bar plugin โ— Developer plugin โ— Stage Switcher plugin โ— MultisiteDirectoryResolver: filters that correct directory paths โ— Koodimonni composer lang support Installation Enter Bedrock: Multisite composer create-project gwa-bedrock-multisite- skeleton
  • 13. 13 Advantages Of Using A Templating Language 1. Concise 2. Template orientated 3. Full-featured 4. Easy to learn 5. Extensibility 6. Fast Theming with Twig and Timber: Overview Timber presentation 1. Integrates the Twig engine into WordPress 2. Creates a foundation WordPress data set 3. Handles the rendering of Twig templates Installing Timber composer require wpackagist-plugin/timber- library
  • 14. 14 PHP files are only concerned with collating the required data Theming with Twig and Timber: Templating files <?php /** * The main template file. */ // set up page data $data = Timber::get_context(); $data['posts'] = Timber::get_posts(); $data['page'] = 'home'; // render using Twig template index.twig Timber::render('twig/index.twig', $data); {% extends 'twig/base.twig' %} {% block content %} <!-- start the loop --> {% for post in posts %} {{ include( 'twig/content.twig', ignore_missing = true ) }} {% else %} {{ include( 'twig/content-none.twig' ) }} {% endfor %} {% if posts %}{{ function( 'bosco_paging_nav' ) }}{% endif %} {% endblock %} Timber methods to get the generic data and then renders the index.twig template
  • 15. 15 Letโ€™s have a look at the base template Theming with Twig and Timber: Templating files {% import 'twig/macros.twig' as macros %} {{ function( 'get_header' ) }} <div id="primary" class="content-area"> <div id="main" class="site-main" role="main"> {% block content %}{% endblock %} </div><!-- #main --> </div><!-- #primary --> {{ function( 'get_sidebar' ) }} {{ function( 'get_footer' ) }} OK, But PHP And Twig? Isnโ€™t That Doubling-Up? 1. Checking is_singular 2. Checking page type: a. is_single b. is_page c. is_home d. is_category e. is_tag f. is_author // render using Twig template index.twig Timber::render('twig/' . $template . '.twig', $data);
  • 16. 16 What is WordPress Debug Bar? โ— debug menu to the admin bar โ— Shows query, cache, other helpful debugging information How To install? https://wordpress.org/plugins/debug-bar/ Theming with Twig and Timber: Bonus (Debug Bar) What is Timber Debug Bar? โ— current template name โ— absolute location on your server โ— full contents of the context How To install? https://wordpress.org/plugins/debug-bar-timber/ composer require wpackagist-plugin/debug-bar composer require wpackagist-plugin/debug-bar- timber
  • 17. 17 Overview โ— OOP โ— MVC โ— Twig template engine โ— Composer โ— Laravel Eloquent ORM Requirements โž” PHP 5.4+ โž” WordPress 3.4+ Installation Developing plugins with Herbert: Overview composer require getherbert/herbert-plugin Features โ— Config โ— Routes โ— Panels โ— Enqueue (JS + CSS scripts) โ— Helper โ— Controllers โ— Views โ— Input (GET; POST) โ— API โ— Shortcodes โ— Activate & Deactivate โ— Messages (notifications) โ— Widgets โ— Saving data (Eloquent ORM) โ— Custom Post Types
  • 18. 18 Naming your Plugin Developing plugins with Herbert: Basis . โ”œโ”€โ”€ app โ”‚ โ”œโ”€โ”€ Helper.php โ”‚ โ”œโ”€โ”€ api.php โ”‚ โ”œโ”€โ”€ enqueue.php โ”‚ โ”œโ”€โ”€ panels.php โ”‚ โ”œโ”€โ”€ routes.php โ”‚ โ”œโ”€โ”€ shortcodes.php โ”‚ โ””โ”€โ”€ widgets.php โ”œโ”€โ”€ resources โ”‚ โ”œโ”€โ”€ assets โ”‚ โ””โ”€โ”€ views โ”œโ”€โ”€ composer.json โ”œโ”€โ”€ herbert.config.php โ””โ”€โ”€ plugin.php /** * @wordpress-plugin * Plugin Name: My Plugin * Plugin URI: http://plugin-name.com/ * Description: A plugin. * Version: 1.0.0 * Author: Author * Author URI: http://author.com/ * License: MIT */ Folder structure of your Plugin
  • 19. 19 โ— https://roots.io/using-composer-with-wordpress/ โ— https://roots.io/bedrock/ โ— https://roots.io/bedrock/docs/ โ— https://roots.io/plugins/stage-switcher/ โ— https://css-tricks.com/intro-bedrock-wordpress/ โ— https://premium.wpmudev.org/blog/simplify-your-wordpress-theming-with-twig-and-timber/ โ— http://getherbert.com โ— https://github.com/studio24/wordpress-multi-env-config References