SlideShare a Scribd company logo
Managing themes and
server environments
with extensible
configuration arrays
Chris Olbekson
@chris_olbekson @X_Team
Managing Environments
Making your code aware
wp-config.php
The Environment Config Class
class WPized_Env_Config {
1. Get defined environment from active-env and assign to $active_env
2. Load default.env
The Environment Config Class
class WPized_Env_Config {
1. Get defined environment from active-env and assign to $active_env
2. Load default.env
3. Load defined environment (each environment checks for an override)
a. local.env.php
b. vagrant.env.php
c. staging.env.php
d. production.env.php
The Environment Config Class
class WPized_Env_Config {
1. Get defined environment from active-env and assign to $active_env
2. Load default.env
3. Load defined environment (each environment checks for an override)
a. local.env.php
b. vagrant.env.php
c. staging.env.php
d. production.env.php
4. Recursively merge the loaded environment configuration array with the
default
The Environment Config Class
static function merge_arrays( array $array ) {
return call_user_func_array(
array( 'WPized_Theme_Config',
'recursive_array_merge_assoc'
),
func_get_args());
}
continue loading WordPress.
/** Sets up WordPress vars and included files */
require_once(ABSPATH, 'wp-settings.php');
Component Libraries
Keeping a common codebase
Components generic enough to be used in any WordPress
project.
● Redirection
● oEmbeds
● Post/Taxonomy Ordering
Components used specifically in WordPress projects for
specific client.
● Ad Utility
● Event Post Type
● Social Panel Widget
Components are housed in multiple
libraries
WPized
Base
Client
Name
Common
Components
Let's make 'em configurable!
1. Default configs can be defined in the component's setup() method.
2. Since theme configs can override these defaults we can use the same
component code for any project!
3. "Mixin" themes are now possible (like child theme groups) which can be
very useful on large multisite installs.
4. Child themes are the final authority.
The merge order of configs
#4
Child Theme
config.php
#3
Mixin Theme
config.php
#2
Parent Theme
config.php
#1
Component
(defaults)
foo.php
Load a component in functions.php
Path shortcut to the library we'll be using for this example.
define( 'WPIZED_BASE_LIB', WP_CONTENT_DIR . '/includes/wpized_base' );
function foo_load_config {
require_once( WPIZED_BASE_LIB . '/theme_config.php' );
// Custom logo
if ( WPized_Theme_Config::defined( 'custom_logo' ) ) {
require_once( WPIZED_BASE_LIB . '/custom-logo.php' );
WPized_Custom_Logo::setup( WPized_Theme_Config::get( 'custom_logo' ) );
}
}
add_action( 'after_setup_theme', 'foo_load_config' );
Load a component in functions.php
The component will load when the theme is initialized.
define( 'WPIZED_BASE_LIB', WP_CONTENT_DIR . '/includes/wpized_base' );
function foo_load_config {
require_once( WPIZED_BASE_LIB . '/theme_config.php' );
// Custom logo
if ( WPized_Theme_Config::defined( 'custom_logo' ) ) {
require_once( WPIZED_BASE_LIB . '/custom-logo.php' );
WPized_Custom_Logo::setup( WPized_Theme_Config::get( 'custom_logo' ) );
}
}
add_action( 'after_setup_theme', 'foo_load_config' );
Load a component in functions.php
Allows us to use some methods for fetching and merging configs.
define( 'WPIZED_BASE_LIB', WP_CONTENT_DIR . '/includes/wpized_base' );
function foo_load_config {
require_once( WPIZED_BASE_LIB . '/theme_config.php' );
// Custom logo
if ( WPized_Theme_Config::defined( 'custom_logo' ) ) {
require_once( WPIZED_BASE_LIB . '/custom-logo.php' );
WPized_Custom_Logo::setup( WPized_Theme_Config::get( 'custom_logo' ) );
}
}
add_action( 'after_setup_theme', 'foo_load_config' );
Load a component in functions.php
If there's no config key provided for the component, it never runs.
define( 'WPIZED_BASE_LIB', WP_CONTENT_DIR . '/includes/wpized_base' );
function foo_load_config {
require_once( WPIZED_BASE_LIB . '/theme_config.php' );
// Custom logo
if ( WPized_Theme_Config::defined( 'custom_logo' ) ) {
require_once( WPIZED_BASE_LIB . '/custom-logo.php' );
WPized_Custom_Logo::setup( WPized_Theme_Config::get( 'custom_logo' ) );
}
}
add_action( 'after_setup_theme', 'foo_load_config' );
Theme's config.php
We have a key! So this component will be loaded.
return array(
'brightcove_oembed' => array(
'players' => array( ... ),
),
'custom_logo' => array(
'default' => get_stylesheet_directory_uri() . '/images/common/logo.png',
'width' => 300,
'height' => 100,
),
'ads' => array(
'site' => 'example.com/foo',
),
);
The simple concept
We can setup the component differently on a site-by-site basis!
Theme Configs
setup( )
in component's
class
Parent > Mixin > Child
Default config values
Load a component in functions.php
The config gets passed to component's setup() method.
define( 'WPIZED_BASE_LIB', WP_CONTENT_DIR . '/includes/wpized_base' );
function foo_load_config {
require_once( WPIZED_BASE_LIB . '/theme_config.php' );
// Custom logo
if ( WPized_Theme_Config::defined( 'custom_logo' ) ) {
require_once( WPIZED_BASE_LIB . '/custom-logo.php' );
WPized_Custom_Logo::setup( WPized_Theme_Config::get( 'custom_logo' ) );
}
}
add_action( 'after_setup_theme', 'foo_load_config' );
class WPized_Custom_Logo {
public static $options = array();
public static function setup( $overrides = array() ) {
self::$options = WPized_Theme_Config::recursive_array_merge_assoc(
array(
'default' => null,
'width' => 250,
'height' => 100,
),
$overrides
);
}
}
echo esc_html( WPized_Custom_Logo::$options['width'] ); // 300
Custom logo component
class WPized_Custom_Logo {
public static $options = array();
public static function setup( $really_default_defaults = array()) {
self::$options = WPized_Theme_Config::recursive_array_merge_assoc(
array(
'default' => null,
'width' => 250,
'height' => 100,
),
$really_default_defaults
);
}
}
echo esc_html( WPized_Custom_Logo::$options['width'] ); // 300
Custom logo component
class WPized_Custom_Logo {
public static $options = array();
public static function setup( $really_default_defaults = array() ) {
self::$options = WPized_Theme_Config::recursive_array_merge_assoc(
array(
'default' => null,
'width' => 250,
'height' => 100,
),
$really_default_defaults
);
}
}
echo esc_html( WPized_Custom_Logo::$options['width'] ); // 300
Custom logo component
class WPized_Custom_Logo {
public static $options = array();
public static function setup( $really_default_defaults = array() ) {
self::$options = WPized_Theme_Config::recursive_array_merge_assoc(
array(
'default' => null,
'width' => 250,
'height' => 100,
),
$really_default_defaults
);
}
}
echo esc_html( WPized_Custom_Logo::$options['width'] ); // 300
Custom logo component
class WPized_Custom_Logo {
public static $options = array();
public static function setup( $really_default_defaults = array() ) {
self::$options = WPized_Theme_Config::recursive_array_merge_assoc(
array(
'default' => null,
'width' => 250,
'height' => 100,
),
$really_default_defaults
);
}
}
echo esc_html( WPized_Custom_Logo::$options['width'] ); // 300
Custom logo component
class WPized_Custom_Logo {
public static $options = array();
public static function setup( $really_default_defaults = array() ) {
self::$options = WPized_Theme_Config::recursive_array_merge_assoc(
array(
'default' => null,
'width' => 250,
'height' => 100,
),
$really_default_defaults
);
}
}
echo esc_html( WPized_Custom_Logo::$options['width'] ); // 300
Custom logo component
Thank you!

More Related Content

What's hot

Getting Into Drupal 8 Configuration
Getting Into Drupal 8 ConfigurationGetting Into Drupal 8 Configuration
Getting Into Drupal 8 Configuration
Philip Norton
 
CodeIgniter 3.0
CodeIgniter 3.0CodeIgniter 3.0
CodeIgniter 3.0
Phil Sturgeon
 
WordPress Queries - the right way
WordPress Queries - the right wayWordPress Queries - the right way
WordPress Queries - the right way
Anthony Hortin
 
Introduction to Webpack - Ordina JWorks - CC JS & Web
Introduction to Webpack - Ordina JWorks - CC JS & WebIntroduction to Webpack - Ordina JWorks - CC JS & Web
Introduction to Webpack - Ordina JWorks - CC JS & Web
JWORKS powered by Ordina
 
Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3
Kris Wallsmith
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable Applications
Alessandro Molina
 
Rally - Benchmarking_as_a_service - Openstack meetup
Rally - Benchmarking_as_a_service - Openstack meetupRally - Benchmarking_as_a_service - Openstack meetup
Rally - Benchmarking_as_a_service - Openstack meetup
Ananth Padmanabhan
 
AnsibleFest 2014 - Role Tips and Tricks
AnsibleFest 2014 - Role Tips and TricksAnsibleFest 2014 - Role Tips and Tricks
AnsibleFest 2014 - Role Tips and Tricks
jimi-c
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode Chef
Sri Ram
 
Generators
GeneratorsGenerators
Generators
Allan Davis
 
Head First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & ApplicationHead First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & Application
Jace Ju
 
Advanced symfony Techniques
Advanced symfony TechniquesAdvanced symfony Techniques
Advanced symfony Techniques
Kris Wallsmith
 
Bye bye $GLOBALS['TYPO3_DB']
Bye bye $GLOBALS['TYPO3_DB']Bye bye $GLOBALS['TYPO3_DB']
Bye bye $GLOBALS['TYPO3_DB']
Jan Helke
 
symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207
patter
 
Extending the WordPress REST API - Josh Pollock
Extending the WordPress REST API - Josh PollockExtending the WordPress REST API - Josh Pollock
Extending the WordPress REST API - Josh Pollock
Caldera Labs
 
Hacking ansible
Hacking ansibleHacking ansible
Hacking ansible
bcoca
 
Api Design
Api DesignApi Design
Api Design
sartak
 
Immutable Deployments with AWS CloudFormation and AWS Lambda
Immutable Deployments with AWS CloudFormation and AWS LambdaImmutable Deployments with AWS CloudFormation and AWS Lambda
Immutable Deployments with AWS CloudFormation and AWS Lambda
AOE
 
PuppetConf. 2016: Puppet Best Practices: Roles & Profiles – Gary Larizza, Puppet
PuppetConf. 2016: Puppet Best Practices: Roles & Profiles – Gary Larizza, PuppetPuppetConf. 2016: Puppet Best Practices: Roles & Profiles – Gary Larizza, Puppet
PuppetConf. 2016: Puppet Best Practices: Roles & Profiles – Gary Larizza, Puppet
Puppet
 
ACADGILD:: HADOOP LESSON
ACADGILD:: HADOOP LESSON ACADGILD:: HADOOP LESSON
ACADGILD:: HADOOP LESSON
Padma shree. T
 

What's hot (20)

Getting Into Drupal 8 Configuration
Getting Into Drupal 8 ConfigurationGetting Into Drupal 8 Configuration
Getting Into Drupal 8 Configuration
 
CodeIgniter 3.0
CodeIgniter 3.0CodeIgniter 3.0
CodeIgniter 3.0
 
WordPress Queries - the right way
WordPress Queries - the right wayWordPress Queries - the right way
WordPress Queries - the right way
 
Introduction to Webpack - Ordina JWorks - CC JS & Web
Introduction to Webpack - Ordina JWorks - CC JS & WebIntroduction to Webpack - Ordina JWorks - CC JS & Web
Introduction to Webpack - Ordina JWorks - CC JS & Web
 
Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable Applications
 
Rally - Benchmarking_as_a_service - Openstack meetup
Rally - Benchmarking_as_a_service - Openstack meetupRally - Benchmarking_as_a_service - Openstack meetup
Rally - Benchmarking_as_a_service - Openstack meetup
 
AnsibleFest 2014 - Role Tips and Tricks
AnsibleFest 2014 - Role Tips and TricksAnsibleFest 2014 - Role Tips and Tricks
AnsibleFest 2014 - Role Tips and Tricks
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode Chef
 
Generators
GeneratorsGenerators
Generators
 
Head First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & ApplicationHead First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & Application
 
Advanced symfony Techniques
Advanced symfony TechniquesAdvanced symfony Techniques
Advanced symfony Techniques
 
Bye bye $GLOBALS['TYPO3_DB']
Bye bye $GLOBALS['TYPO3_DB']Bye bye $GLOBALS['TYPO3_DB']
Bye bye $GLOBALS['TYPO3_DB']
 
symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207
 
Extending the WordPress REST API - Josh Pollock
Extending the WordPress REST API - Josh PollockExtending the WordPress REST API - Josh Pollock
Extending the WordPress REST API - Josh Pollock
 
Hacking ansible
Hacking ansibleHacking ansible
Hacking ansible
 
Api Design
Api DesignApi Design
Api Design
 
Immutable Deployments with AWS CloudFormation and AWS Lambda
Immutable Deployments with AWS CloudFormation and AWS LambdaImmutable Deployments with AWS CloudFormation and AWS Lambda
Immutable Deployments with AWS CloudFormation and AWS Lambda
 
PuppetConf. 2016: Puppet Best Practices: Roles & Profiles – Gary Larizza, Puppet
PuppetConf. 2016: Puppet Best Practices: Roles & Profiles – Gary Larizza, PuppetPuppetConf. 2016: Puppet Best Practices: Roles & Profiles – Gary Larizza, Puppet
PuppetConf. 2016: Puppet Best Practices: Roles & Profiles – Gary Larizza, Puppet
 
ACADGILD:: HADOOP LESSON
ACADGILD:: HADOOP LESSON ACADGILD:: HADOOP LESSON
ACADGILD:: HADOOP LESSON
 

Similar to Managing themes and server environments with extensible configuration arrays

WordPress Plugin development
WordPress Plugin developmentWordPress Plugin development
WordPress Plugin development
Mostafa Soufi
 
Laying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme developmentLaying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme development
Tammy Hart
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practices
markparolisi
 
Web development automatisation for fun and profit (Artem Daniliants)
Web development automatisation for fun and profit (Artem Daniliants)Web development automatisation for fun and profit (Artem Daniliants)
Web development automatisation for fun and profit (Artem Daniliants)
LumoSpark
 
A WordPress workshop at Cefalo
A WordPress workshop at Cefalo A WordPress workshop at Cefalo
A WordPress workshop at Cefalo
Beroza Paul
 
Childthemes ottawa-word camp-1919
Childthemes ottawa-word camp-1919Childthemes ottawa-word camp-1919
Childthemes ottawa-word camp-1919
Paul Bearne
 
WCLA12 JavaScript
WCLA12 JavaScriptWCLA12 JavaScript
WCLA12 JavaScript
Jeffrey Zinn
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
Bo-Yi Wu
 
Introduction to backbone presentation
Introduction to backbone presentationIntroduction to backbone presentation
Introduction to backbone presentation
Brian Hogg
 
Как получить чёрный пояс по WordPress?
Как получить чёрный пояс по WordPress?Как получить чёрный пояс по WordPress?
Как получить чёрный пояс по WordPress?
Yevhen Kotelnytskyi
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin Development
Brad Williams
 
Symfony tips and tricks
Symfony tips and tricksSymfony tips and tricks
Symfony tips and tricks
Javier Eguiluz
 
Beyond the WordPress 5 minute Install
Beyond the WordPress 5 minute InstallBeyond the WordPress 5 minute Install
Beyond the WordPress 5 minute Install
Steve Taylor
 
How to make a WordPress theme
How to make a WordPress themeHow to make a WordPress theme
How to make a WordPress theme
Hardeep Asrani
 
Zend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolZend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_Tool
Gordon Forsythe
 
How Not to Build a WordPress Plugin
How Not to Build a WordPress PluginHow Not to Build a WordPress Plugin
How Not to Build a WordPress Plugin
Will Norris
 
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cliWordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
GetSource
 
Creating Your First WordPress Plugin
Creating Your First WordPress PluginCreating Your First WordPress Plugin
Creating Your First WordPress Plugin
Brad Williams
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
Hisateru Tanaka
 
The Solar Framework for PHP 5 (2010 Confoo)
The Solar Framework for PHP 5 (2010 Confoo)The Solar Framework for PHP 5 (2010 Confoo)
The Solar Framework for PHP 5 (2010 Confoo)
Paul Jones
 

Similar to Managing themes and server environments with extensible configuration arrays (20)

WordPress Plugin development
WordPress Plugin developmentWordPress Plugin development
WordPress Plugin development
 
Laying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme developmentLaying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme development
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practices
 
Web development automatisation for fun and profit (Artem Daniliants)
Web development automatisation for fun and profit (Artem Daniliants)Web development automatisation for fun and profit (Artem Daniliants)
Web development automatisation for fun and profit (Artem Daniliants)
 
A WordPress workshop at Cefalo
A WordPress workshop at Cefalo A WordPress workshop at Cefalo
A WordPress workshop at Cefalo
 
Childthemes ottawa-word camp-1919
Childthemes ottawa-word camp-1919Childthemes ottawa-word camp-1919
Childthemes ottawa-word camp-1919
 
WCLA12 JavaScript
WCLA12 JavaScriptWCLA12 JavaScript
WCLA12 JavaScript
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
 
Introduction to backbone presentation
Introduction to backbone presentationIntroduction to backbone presentation
Introduction to backbone presentation
 
Как получить чёрный пояс по WordPress?
Как получить чёрный пояс по WordPress?Как получить чёрный пояс по WordPress?
Как получить чёрный пояс по WordPress?
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin Development
 
Symfony tips and tricks
Symfony tips and tricksSymfony tips and tricks
Symfony tips and tricks
 
Beyond the WordPress 5 minute Install
Beyond the WordPress 5 minute InstallBeyond the WordPress 5 minute Install
Beyond the WordPress 5 minute Install
 
How to make a WordPress theme
How to make a WordPress themeHow to make a WordPress theme
How to make a WordPress theme
 
Zend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolZend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_Tool
 
How Not to Build a WordPress Plugin
How Not to Build a WordPress PluginHow Not to Build a WordPress Plugin
How Not to Build a WordPress Plugin
 
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cliWordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
WordCamp Vancouver 2012 - Manage WordPress with Awesome using wp-cli
 
Creating Your First WordPress Plugin
Creating Your First WordPress PluginCreating Your First WordPress Plugin
Creating Your First WordPress Plugin
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
The Solar Framework for PHP 5 (2010 Confoo)
The Solar Framework for PHP 5 (2010 Confoo)The Solar Framework for PHP 5 (2010 Confoo)
The Solar Framework for PHP 5 (2010 Confoo)
 

More from Chris Olbekson

Magical WordPress Development with Vagrant
Magical WordPress Development with VagrantMagical WordPress Development with Vagrant
Magical WordPress Development with Vagrant
Chris Olbekson
 
The Query the Whole Query and Nothing but the Query
The Query the Whole Query and Nothing but the QueryThe Query the Whole Query and Nothing but the Query
The Query the Whole Query and Nothing but the Query
Chris Olbekson
 
WordPress Houston Meetup - Using WordPress as a CMS
WordPress Houston Meetup - Using WordPress as a CMSWordPress Houston Meetup - Using WordPress as a CMS
WordPress Houston Meetup - Using WordPress as a CMS
Chris Olbekson
 
Cognac gautier presentation
Cognac gautier   presentationCognac gautier   presentation
Cognac gautier presentation
Chris Olbekson
 
Theme frameworks & child themes
Theme frameworks & child themesTheme frameworks & child themes
Theme frameworks & child themes
Chris Olbekson
 
Optimizing WordPress for Performance - WordCamp Houston
Optimizing WordPress for Performance - WordCamp HoustonOptimizing WordPress for Performance - WordCamp Houston
Optimizing WordPress for Performance - WordCamp Houston
Chris Olbekson
 

More from Chris Olbekson (6)

Magical WordPress Development with Vagrant
Magical WordPress Development with VagrantMagical WordPress Development with Vagrant
Magical WordPress Development with Vagrant
 
The Query the Whole Query and Nothing but the Query
The Query the Whole Query and Nothing but the QueryThe Query the Whole Query and Nothing but the Query
The Query the Whole Query and Nothing but the Query
 
WordPress Houston Meetup - Using WordPress as a CMS
WordPress Houston Meetup - Using WordPress as a CMSWordPress Houston Meetup - Using WordPress as a CMS
WordPress Houston Meetup - Using WordPress as a CMS
 
Cognac gautier presentation
Cognac gautier   presentationCognac gautier   presentation
Cognac gautier presentation
 
Theme frameworks & child themes
Theme frameworks & child themesTheme frameworks & child themes
Theme frameworks & child themes
 
Optimizing WordPress for Performance - WordCamp Houston
Optimizing WordPress for Performance - WordCamp HoustonOptimizing WordPress for Performance - WordCamp Houston
Optimizing WordPress for Performance - WordCamp Houston
 

Recently uploaded

Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
Pixlogix Infotech
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Zilliz
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Zilliz
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 

Recently uploaded (20)

Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 

Managing themes and server environments with extensible configuration arrays

  • 1. Managing themes and server environments with extensible configuration arrays Chris Olbekson @chris_olbekson @X_Team
  • 4. The Environment Config Class class WPized_Env_Config { 1. Get defined environment from active-env and assign to $active_env 2. Load default.env
  • 5. The Environment Config Class class WPized_Env_Config { 1. Get defined environment from active-env and assign to $active_env 2. Load default.env 3. Load defined environment (each environment checks for an override) a. local.env.php b. vagrant.env.php c. staging.env.php d. production.env.php
  • 6. The Environment Config Class class WPized_Env_Config { 1. Get defined environment from active-env and assign to $active_env 2. Load default.env 3. Load defined environment (each environment checks for an override) a. local.env.php b. vagrant.env.php c. staging.env.php d. production.env.php 4. Recursively merge the loaded environment configuration array with the default
  • 7. The Environment Config Class static function merge_arrays( array $array ) { return call_user_func_array( array( 'WPized_Theme_Config', 'recursive_array_merge_assoc' ), func_get_args()); } continue loading WordPress. /** Sets up WordPress vars and included files */ require_once(ABSPATH, 'wp-settings.php');
  • 9. Components generic enough to be used in any WordPress project. ● Redirection ● oEmbeds ● Post/Taxonomy Ordering Components used specifically in WordPress projects for specific client. ● Ad Utility ● Event Post Type ● Social Panel Widget Components are housed in multiple libraries WPized Base Client Name Common
  • 10. Components Let's make 'em configurable!
  • 11. 1. Default configs can be defined in the component's setup() method. 2. Since theme configs can override these defaults we can use the same component code for any project! 3. "Mixin" themes are now possible (like child theme groups) which can be very useful on large multisite installs. 4. Child themes are the final authority. The merge order of configs #4 Child Theme config.php #3 Mixin Theme config.php #2 Parent Theme config.php #1 Component (defaults) foo.php
  • 12. Load a component in functions.php Path shortcut to the library we'll be using for this example. define( 'WPIZED_BASE_LIB', WP_CONTENT_DIR . '/includes/wpized_base' ); function foo_load_config { require_once( WPIZED_BASE_LIB . '/theme_config.php' ); // Custom logo if ( WPized_Theme_Config::defined( 'custom_logo' ) ) { require_once( WPIZED_BASE_LIB . '/custom-logo.php' ); WPized_Custom_Logo::setup( WPized_Theme_Config::get( 'custom_logo' ) ); } } add_action( 'after_setup_theme', 'foo_load_config' );
  • 13. Load a component in functions.php The component will load when the theme is initialized. define( 'WPIZED_BASE_LIB', WP_CONTENT_DIR . '/includes/wpized_base' ); function foo_load_config { require_once( WPIZED_BASE_LIB . '/theme_config.php' ); // Custom logo if ( WPized_Theme_Config::defined( 'custom_logo' ) ) { require_once( WPIZED_BASE_LIB . '/custom-logo.php' ); WPized_Custom_Logo::setup( WPized_Theme_Config::get( 'custom_logo' ) ); } } add_action( 'after_setup_theme', 'foo_load_config' );
  • 14. Load a component in functions.php Allows us to use some methods for fetching and merging configs. define( 'WPIZED_BASE_LIB', WP_CONTENT_DIR . '/includes/wpized_base' ); function foo_load_config { require_once( WPIZED_BASE_LIB . '/theme_config.php' ); // Custom logo if ( WPized_Theme_Config::defined( 'custom_logo' ) ) { require_once( WPIZED_BASE_LIB . '/custom-logo.php' ); WPized_Custom_Logo::setup( WPized_Theme_Config::get( 'custom_logo' ) ); } } add_action( 'after_setup_theme', 'foo_load_config' );
  • 15. Load a component in functions.php If there's no config key provided for the component, it never runs. define( 'WPIZED_BASE_LIB', WP_CONTENT_DIR . '/includes/wpized_base' ); function foo_load_config { require_once( WPIZED_BASE_LIB . '/theme_config.php' ); // Custom logo if ( WPized_Theme_Config::defined( 'custom_logo' ) ) { require_once( WPIZED_BASE_LIB . '/custom-logo.php' ); WPized_Custom_Logo::setup( WPized_Theme_Config::get( 'custom_logo' ) ); } } add_action( 'after_setup_theme', 'foo_load_config' );
  • 16. Theme's config.php We have a key! So this component will be loaded. return array( 'brightcove_oembed' => array( 'players' => array( ... ), ), 'custom_logo' => array( 'default' => get_stylesheet_directory_uri() . '/images/common/logo.png', 'width' => 300, 'height' => 100, ), 'ads' => array( 'site' => 'example.com/foo', ), );
  • 17. The simple concept We can setup the component differently on a site-by-site basis! Theme Configs setup( ) in component's class Parent > Mixin > Child Default config values
  • 18. Load a component in functions.php The config gets passed to component's setup() method. define( 'WPIZED_BASE_LIB', WP_CONTENT_DIR . '/includes/wpized_base' ); function foo_load_config { require_once( WPIZED_BASE_LIB . '/theme_config.php' ); // Custom logo if ( WPized_Theme_Config::defined( 'custom_logo' ) ) { require_once( WPIZED_BASE_LIB . '/custom-logo.php' ); WPized_Custom_Logo::setup( WPized_Theme_Config::get( 'custom_logo' ) ); } } add_action( 'after_setup_theme', 'foo_load_config' );
  • 19. class WPized_Custom_Logo { public static $options = array(); public static function setup( $overrides = array() ) { self::$options = WPized_Theme_Config::recursive_array_merge_assoc( array( 'default' => null, 'width' => 250, 'height' => 100, ), $overrides ); } } echo esc_html( WPized_Custom_Logo::$options['width'] ); // 300 Custom logo component
  • 20. class WPized_Custom_Logo { public static $options = array(); public static function setup( $really_default_defaults = array()) { self::$options = WPized_Theme_Config::recursive_array_merge_assoc( array( 'default' => null, 'width' => 250, 'height' => 100, ), $really_default_defaults ); } } echo esc_html( WPized_Custom_Logo::$options['width'] ); // 300 Custom logo component
  • 21. class WPized_Custom_Logo { public static $options = array(); public static function setup( $really_default_defaults = array() ) { self::$options = WPized_Theme_Config::recursive_array_merge_assoc( array( 'default' => null, 'width' => 250, 'height' => 100, ), $really_default_defaults ); } } echo esc_html( WPized_Custom_Logo::$options['width'] ); // 300 Custom logo component
  • 22. class WPized_Custom_Logo { public static $options = array(); public static function setup( $really_default_defaults = array() ) { self::$options = WPized_Theme_Config::recursive_array_merge_assoc( array( 'default' => null, 'width' => 250, 'height' => 100, ), $really_default_defaults ); } } echo esc_html( WPized_Custom_Logo::$options['width'] ); // 300 Custom logo component
  • 23. class WPized_Custom_Logo { public static $options = array(); public static function setup( $really_default_defaults = array() ) { self::$options = WPized_Theme_Config::recursive_array_merge_assoc( array( 'default' => null, 'width' => 250, 'height' => 100, ), $really_default_defaults ); } } echo esc_html( WPized_Custom_Logo::$options['width'] ); // 300 Custom logo component
  • 24. class WPized_Custom_Logo { public static $options = array(); public static function setup( $really_default_defaults = array() ) { self::$options = WPized_Theme_Config::recursive_array_merge_assoc( array( 'default' => null, 'width' => 250, 'height' => 100, ), $really_default_defaults ); } } echo esc_html( WPized_Custom_Logo::$options['width'] ); // 300 Custom logo component