SlideShare a Scribd company logo
1 of 33
#complexwp | wplib.org | @mikeschinkel
Developing Complex
WordPress Sites*
*Without Fear of Failure
Presenter: Mike Schinkel
WordCamp Raleigh 2015
#complexwp | wplib.org | @mikeschinkel
What to Expect
• Target Audience for the Talk
• Overview of Professional Workflow
• Use of Object Orientation
• Demo of code from a real-world project
• How to make it easy by using WPLib
#complexwp | wplib.org | @mikeschinkel
Prerequisites
• Experience building WordPress websites
• Comfortable developing in PHP
#complexwp | wplib.org | @mikeschinkel
About Me
• Self-Styled WordPress Architect
• Typical Work: $100k+ Agency Projects
• Many WordCamps, LoopConf
• WordPress is my 4th developer ecosystem
2006-2009: Drupal
1993-2006: Visual Basic
1986-1993: Clipper - a dBase Compiler
• Yada, yada
#complexwp | wplib.org | @mikeschinkel
Avoiding a WordPress
House of Cards
A.K.A. Avoiding
Kevin Spacey
#complexwp | wplib.org | @mikeschinkel
Best For Large Budget Projects
Where clients
just expect
us to:
#complexwp | wplib.org | @mikeschinkel
This approach NOT for "Tinkerers"
Who want to
fiddle with it after
you leave.
(And then yell at you
and ask for support
when they break it.)
#complexwp | wplib.org | @mikeschinkel
Disallow Adding of Plugins and
Themes in the Admin Consule
• Use a Custom
Theme
• Minimize 3rd
Party Plugins
#complexwp | wplib.org | @mikeschinkel
Use a Professional Workflow
● A Professional IDE
o PhpStorm+XDebug
● Version Control/Branching
o For Features, and
o For Bug Fixes
● A Deployment Process
o Development (Local)
o Test Server
o Staging Server
o Production Server
● See "Advanced WordPress Workflow”
o That is Micah Wood's talk, next session...
#complexwp | wplib.org | @mikeschinkel
Use an Intelligent Process
• Focus on Requirements
• Create clickable mockups using
moqups.com
• Then Architecture
• Decide on Post Types, Taxonomies, etc
• Separate Theming from
Architecture & Backend Coding
• Best if people with the different skills
are in the different roles
• Maximize “Deployable” Code
• User-entered Configuration Sux
#complexwp | wplib.org | @mikeschinkel
Use an Object Oriented Architecture
•Heard of MVC?
• Embrace Models and Views.
• And Items,
• And Lists,
• And Applications.
• And Helpers,
• And Templates,
• And Modules.
• More on those in a bit…
#complexwp | wplib.org | @mikeschinkel
Wherest thou Objects?
• Post Types
• Taxonomies
• User Roles
• And more!
#complexwp | wplib.org | @mikeschinkel
• Controllers = the "C" in MVC
• But Objects/Classes for
Routing != WordPress
• But you can usually hack it:
URL Routing In WordPress
http://tinyurl.com/wp-url-routing
WordPress handles the Controller (mostly)
#complexwp | wplib.org | @mikeschinkel
DEMO
Reviewing the Code of a
Real World Client Project
Warts and All
(see http://github/wplib for online examples)
#complexwp | wplib.org | @mikeschinkel
Make it easy with WPLib
• Designed for PHP Developers
• Assumes Persistent Cache
• Great for Building Reusable Code
#complexwp | wplib.org | @mikeschinkel
•It is Small
•Does not try to do that much
•Highly Consistent!
•Presents Structured Constraints
•Compatible with (all?) other Frameworks
•WPLib provides incremental value
•Can be used a little, or a lot
•Solves a problem no one else(?) is addressing
WPLib's Positive Attributes
#complexwp | wplib.org | @mikeschinkel
• One Application per site
• Provides root class for a site/app.
• Provides global but site-specific functionality, i.e.
$list = MyApp::get_featured_slide_list([$query]);
MyAPP::the_current_campaign_html();
$url = MyAPP::get_asset_url( 'images/visa-logo.png' );
if ( MyApp::is_featured_slider_enabled() ) {
//...
}
The Application Class
#complexwp | wplib.org | @mikeschinkel
Theme Class
• One Theme Class per theme
• Put your theme hooks here, e.g.
'wp_head'
'wp_enqueue_scripts'
• Location for theme global functionality, e.g.
$theme->the_ad_html();
$theme->the_slider_html();
• Lots of functionality in parent class, e.g.
$theme->the_header_html(); // same as get_header()
$theme->the_site_name();
$page_id = $theme->front_page_id();
#complexwp | wplib.org | @mikeschinkel
Model Classes
• Most of the “business logic" goes here.
• All the “facts” about a type of Item
• One per Item type
class MyApp_Story_Model extends WPLib_Post_Model {
function has_sponsor() {
$has = get_post_meta( $this->ID(), '_myapp_has_sponsor', true );
return 1 == intval( $has );
}
}
#complexwp | wplib.org | @mikeschinkel
View Classes
• Specific methods for outputting Item info
• One or more Views per Item type
• Maybe one View for HTML, one for JSON, etc.
• Most functionality needed in parent class
class MyApp_Featured_Slide_View extends WPLib_Post_View_Base {
function the_embed_code_html() {
echo $this->embed_code();
}
function the_embed_code_textarea() {
echo htmlspecialchars( $this->embed_code() );
}
}
#complexwp | wplib.org | @mikeschinkel
Item Classes
• Container for a Model and a View.
• ONLY class of Model+View+Item you actually use
• Most functionality in the parent class
• Rarely has much if any code
class MyApp_Campaign extends WPLib_Post_Base {
const POST_TYPE = MyApp_Campaigns::POST_TYPE;
const VAR_NAME = 'campaign';
}
#complexwp | wplib.org | @mikeschinkel
List Classes
• Smart arrays of Items
• Can be custom classes with use-case specific methods
• But usually you only need the Default List Class
foreach( MyApp_Featured_Slides::get_list() as $slide ) {
$slide->the_template( 'slide-card' );
}
// OR JUST:
MyApp_Featured_Slides::get_list()->the_template( 'slide-card' );
#complexwp | wplib.org | @mikeschinkel
Helper Classes
• Think of a Helper as "A List of Related Functions"
• Contributes Static Methods
• To your Application class
• We do the same for the WPLib class
• Enables making small, easy to learn APIs
• The Application class is the method "router"
• Helper Method names must be unique across an Application
• Better approach than a single "God" Class
• Allows for many smaller files
• Clearer source code organization
• Better source file management
#complexwp | wplib.org | @mikeschinkel
Helper Classes (cont'd)
class MyApp_Date_Range extends WPLib_Module_Base {
static $_post_types = array();
static function on_load() {
self::register_helper( __CLASS__, 'MyApp' );
}
static function register_date_range_post_type( $post_type ) {
self::$_post_types[ $post_type ] = $post_type;
}
static function date_range_post_types() {
return self::$_post_types;
}
}
MyApp_Date_Range::on_load();
//----------
MyApp::register_date_range_post_type( MyApp_Story::POST_TYPE );
print_r( MyApp::date_range_post_types() );
#complexwp | wplib.org | @mikeschinkel
Module Classes
• Provides Functionality
• Like a Plugin
• Designed for Developers
• Unlike a Plugin
• Designed to be small
• If one grows too big, split it up!
• Should be highly cohesive
• Group related functionality together
#complexwp | wplib.org | @mikeschinkel
• A Main "Entry Point" file
• Contains a main class
• Should hook all hooks needed on page load
• Optimized to load efficiently
• Zero or more /includes/ files
• One class per file
• Include files are autoloaded
• Architected to be Composible
• Reusability: Yeah Baby!
Module Classes (cont'd)
#complexwp | wplib.org | @mikeschinkel
WPLib Templates
• Like Template Parts
• Not template files like single.php, home.php, et. al.
• Typically scoped to an Item
• Or scoped to the Theme class ($theme)
• Or with no scope (called using MyApp::)
• Loaded by $item->the_template('part') method
• Templates in {theme}/templates/{part}.php
#complexwp | wplib.org | @mikeschinkel
Constraints are your Friends
• Templates should contain NO
implementation details
•Should contain ONLY site-specific HTML or
CSS and method calls.
•No WP_Query, no get_post_meta(), etc.
#complexwp | wplib.org | @mikeschinkel
• Contains NO site-specific HTML or CSS
•Auto-generate "the_" methods
•For rendering output
•Conventions for escaping output
•"_url"
•"_attr"
•"_html"
•suffix, etc.
View Methods
#complexwp | wplib.org | @mikeschinkel
A Few Well-Known Constants
•POST_TYPE
•Use to specify the post type in a Post Type Module.
•TAXONOMY
•Use to specify the taxonomy in a Taxonomy Module.
•ROLE
•Use to specify the user role in a User Role Module.
•VAR_NAME
•Use to specify an $item's auto assigned variable name in a template.
•INSTANCE_CLASS
•Use to specify the $item's class name in an MVI module class.
#complexwp | wplib.org | @mikeschinkel
To Learn More about WPLib
•Clone from GitHub, Review sample apps:
•github.com/wplib
•Visit wplib.org
•For Quick Start and other Docs
•Submit issues on GitHub:
•github.com/wplib/wplib/issues
•Ask questions on Twitter:
•@mikeschinkel / @wpscholar
•Discuss on Slack
•Ok: wordpress.slack.com (mikeschinkel/wpscholar)
•Best: thecodersguild.slack.com#wplib
•Email mike@newclarity.net for access
#complexwp | wplib.org | @mikeschinkel
Questions?
#complexwp | wplib.org | @mikeschinkel
THANK YOU
Mike Schinkel
mike@newclarity.net
about.me/mikeschinkel
See also:
www.slideshare.net/mikeschinkel

More Related Content

What's hot

Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3Wen-Tien Chang
 
Joomla! multiplied - How to run Multi-Sites - JandBeyond 2014
Joomla! multiplied - How to run Multi-Sites - JandBeyond 2014Joomla! multiplied - How to run Multi-Sites - JandBeyond 2014
Joomla! multiplied - How to run Multi-Sites - JandBeyond 2014Viktor Vogel
 
2011 NetUG HH: ASP.NET MVC & HTML 5
2011 NetUG HH: ASP.NET MVC & HTML 52011 NetUG HH: ASP.NET MVC & HTML 5
2011 NetUG HH: ASP.NET MVC & HTML 5Daniel Fisher
 
Untangling the web week 2 - SEO
Untangling the web week 2 - SEOUntangling the web week 2 - SEO
Untangling the web week 2 - SEODerek Jacoby
 
An Introduction to the Laravel Framework (AFUP Forum PHP 2014)
An Introduction to the Laravel Framework (AFUP Forum PHP 2014)An Introduction to the Laravel Framework (AFUP Forum PHP 2014)
An Introduction to the Laravel Framework (AFUP Forum PHP 2014)daylerees
 
Untangling spring week1
Untangling spring week1Untangling spring week1
Untangling spring week1Derek Jacoby
 
Saving Time By Testing With Jest
Saving Time By Testing With JestSaving Time By Testing With Jest
Saving Time By Testing With JestBen McCormick
 
Best Practices in SharePoint Development - Just Freakin Work! Overcoming Hurd...
Best Practices in SharePoint Development - Just Freakin Work! Overcoming Hurd...Best Practices in SharePoint Development - Just Freakin Work! Overcoming Hurd...
Best Practices in SharePoint Development - Just Freakin Work! Overcoming Hurd...Geoff Varosky
 
Untangling the web week1
Untangling the web week1Untangling the web week1
Untangling the web week1Derek Jacoby
 
Windycityrails page performance
Windycityrails page performanceWindycityrails page performance
Windycityrails page performanceJohn McCaffrey
 
 Active Storage - Modern File Storage? 
 Active Storage - Modern File Storage?  Active Storage - Modern File Storage? 
 Active Storage - Modern File Storage? Michael Yagudaev
 
Untangling the web11
Untangling the web11Untangling the web11
Untangling the web11Derek Jacoby
 
Angular.js in XPages
Angular.js in XPagesAngular.js in XPages
Angular.js in XPagesMark Roden
 
SharePoint PowerShell for the Admin and Developer - A Venn Diagram Experience
SharePoint PowerShell for the Admin and Developer - A Venn Diagram ExperienceSharePoint PowerShell for the Admin and Developer - A Venn Diagram Experience
SharePoint PowerShell for the Admin and Developer - A Venn Diagram ExperienceRicardo Wilkins
 
Untangling - fall2017 - week5
Untangling - fall2017 - week5Untangling - fall2017 - week5
Untangling - fall2017 - week5Derek Jacoby
 
Widening your JavaScript Application
Widening your JavaScript ApplicationWidening your JavaScript Application
Widening your JavaScript ApplicationAlex McPherson
 
C# Async/Await Explained
C# Async/Await ExplainedC# Async/Await Explained
C# Async/Await ExplainedJeremy Likness
 
Contentful with Netgen Layouts workshop
Contentful with Netgen Layouts workshopContentful with Netgen Layouts workshop
Contentful with Netgen Layouts workshopIvo Lukac
 

What's hot (20)

Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3
 
Joomla! multiplied - How to run Multi-Sites - JandBeyond 2014
Joomla! multiplied - How to run Multi-Sites - JandBeyond 2014Joomla! multiplied - How to run Multi-Sites - JandBeyond 2014
Joomla! multiplied - How to run Multi-Sites - JandBeyond 2014
 
2011 NetUG HH: ASP.NET MVC & HTML 5
2011 NetUG HH: ASP.NET MVC & HTML 52011 NetUG HH: ASP.NET MVC & HTML 5
2011 NetUG HH: ASP.NET MVC & HTML 5
 
Untangling the web week 2 - SEO
Untangling the web week 2 - SEOUntangling the web week 2 - SEO
Untangling the web week 2 - SEO
 
An Introduction to the Laravel Framework (AFUP Forum PHP 2014)
An Introduction to the Laravel Framework (AFUP Forum PHP 2014)An Introduction to the Laravel Framework (AFUP Forum PHP 2014)
An Introduction to the Laravel Framework (AFUP Forum PHP 2014)
 
Untangling spring week1
Untangling spring week1Untangling spring week1
Untangling spring week1
 
Saving Time By Testing With Jest
Saving Time By Testing With JestSaving Time By Testing With Jest
Saving Time By Testing With Jest
 
Irb Tips and Tricks
Irb Tips and TricksIrb Tips and Tricks
Irb Tips and Tricks
 
Best Practices in SharePoint Development - Just Freakin Work! Overcoming Hurd...
Best Practices in SharePoint Development - Just Freakin Work! Overcoming Hurd...Best Practices in SharePoint Development - Just Freakin Work! Overcoming Hurd...
Best Practices in SharePoint Development - Just Freakin Work! Overcoming Hurd...
 
Untangling the web week1
Untangling the web week1Untangling the web week1
Untangling the web week1
 
Windycityrails page performance
Windycityrails page performanceWindycityrails page performance
Windycityrails page performance
 
 Active Storage - Modern File Storage? 
 Active Storage - Modern File Storage?  Active Storage - Modern File Storage? 
 Active Storage - Modern File Storage? 
 
Untangling the web11
Untangling the web11Untangling the web11
Untangling the web11
 
Angular.js in XPages
Angular.js in XPagesAngular.js in XPages
Angular.js in XPages
 
SharePoint PowerShell for the Admin and Developer - A Venn Diagram Experience
SharePoint PowerShell for the Admin and Developer - A Venn Diagram ExperienceSharePoint PowerShell for the Admin and Developer - A Venn Diagram Experience
SharePoint PowerShell for the Admin and Developer - A Venn Diagram Experience
 
Untangling - fall2017 - week5
Untangling - fall2017 - week5Untangling - fall2017 - week5
Untangling - fall2017 - week5
 
Widening your JavaScript Application
Widening your JavaScript ApplicationWidening your JavaScript Application
Widening your JavaScript Application
 
Java™ in Web 2.0
Java™ in Web 2.0Java™ in Web 2.0
Java™ in Web 2.0
 
C# Async/Await Explained
C# Async/Await ExplainedC# Async/Await Explained
C# Async/Await Explained
 
Contentful with Netgen Layouts workshop
Contentful with Netgen Layouts workshopContentful with Netgen Layouts workshop
Contentful with Netgen Layouts workshop
 

Similar to Developing Complex WordPress Sites without Fear of Failure (with MVC)

The WordPress University
The WordPress UniversityThe WordPress University
The WordPress UniversityStephanie Leary
 
SE2016 Java Alex Theedom "Java EE revisits design patterns"
SE2016 Java Alex Theedom "Java EE revisits design patterns"SE2016 Java Alex Theedom "Java EE revisits design patterns"
SE2016 Java Alex Theedom "Java EE revisits design patterns"Inhacking
 
Ready. Set. Drupal! An Intro to Drupal 8, Part 2
Ready. Set. Drupal! An Intro to Drupal 8, Part 2Ready. Set. Drupal! An Intro to Drupal 8, Part 2
Ready. Set. Drupal! An Intro to Drupal 8, Part 2Acquia
 
Why use Go for web development?
Why use Go for web development?Why use Go for web development?
Why use Go for web development?Weng Wei
 
Creating a Documentation Portal
Creating a Documentation PortalCreating a Documentation Portal
Creating a Documentation PortalSteve Anderson
 
Drupal 8 deeper dive
Drupal 8 deeper diveDrupal 8 deeper dive
Drupal 8 deeper diveAmazee Labs
 
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slides
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slidesKeep Your Code Organized! WordCamp Montreal 2013 Presentation slides
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slidesJer Clarke
 
Building a Simple Theme Framework
Building a Simple Theme FrameworkBuilding a Simple Theme Framework
Building a Simple Theme FrameworkJoe Casabona
 
Java EE revisits design patterns
Java EE revisits design patternsJava EE revisits design patterns
Java EE revisits design patternsAlex Theedom
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsTaylor Lovett
 
Drupal: an Overview
Drupal: an OverviewDrupal: an Overview
Drupal: an OverviewMatt Weaver
 
Java EE Revisits Design Patterns
Java EE Revisits Design PatternsJava EE Revisits Design Patterns
Java EE Revisits Design PatternsAlex Theedom
 
Add-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his DutyAdd-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his Dutyreedmaniac
 
5 Common Mistakes You are Making on your Website
 5 Common Mistakes You are Making on your Website 5 Common Mistakes You are Making on your Website
5 Common Mistakes You are Making on your WebsiteAcquia
 
Best Practices for WordPress
Best Practices for WordPressBest Practices for WordPress
Best Practices for WordPressTaylor Lovett
 
The things we found in your website
The things we found in your websiteThe things we found in your website
The things we found in your websitehernanibf
 

Similar to Developing Complex WordPress Sites without Fear of Failure (with MVC) (20)

Last Call Media Drupal 8 Case Study
Last Call Media Drupal 8 Case StudyLast Call Media Drupal 8 Case Study
Last Call Media Drupal 8 Case Study
 
The WordPress University
The WordPress UniversityThe WordPress University
The WordPress University
 
SE2016 Java Alex Theedom "Java EE revisits design patterns"
SE2016 Java Alex Theedom "Java EE revisits design patterns"SE2016 Java Alex Theedom "Java EE revisits design patterns"
SE2016 Java Alex Theedom "Java EE revisits design patterns"
 
Alex Theedom Java ee revisits design patterns
Alex Theedom	Java ee revisits design patternsAlex Theedom	Java ee revisits design patterns
Alex Theedom Java ee revisits design patterns
 
Ready. Set. Drupal! An Intro to Drupal 8, Part 2
Ready. Set. Drupal! An Intro to Drupal 8, Part 2Ready. Set. Drupal! An Intro to Drupal 8, Part 2
Ready. Set. Drupal! An Intro to Drupal 8, Part 2
 
Why use Go for web development?
Why use Go for web development?Why use Go for web development?
Why use Go for web development?
 
Creating a Documentation Portal
Creating a Documentation PortalCreating a Documentation Portal
Creating a Documentation Portal
 
Drupal 8 deeper dive
Drupal 8 deeper diveDrupal 8 deeper dive
Drupal 8 deeper dive
 
Frontend as a first class citizen
Frontend as a first class citizenFrontend as a first class citizen
Frontend as a first class citizen
 
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slides
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slidesKeep Your Code Organized! WordCamp Montreal 2013 Presentation slides
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slides
 
Building a Simple Theme Framework
Building a Simple Theme FrameworkBuilding a Simple Theme Framework
Building a Simple Theme Framework
 
Java EE revisits design patterns
Java EE revisits design patternsJava EE revisits design patterns
Java EE revisits design patterns
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress Applications
 
Drupal: an Overview
Drupal: an OverviewDrupal: an Overview
Drupal: an Overview
 
Java EE Revisits Design Patterns
Java EE Revisits Design PatternsJava EE Revisits Design Patterns
Java EE Revisits Design Patterns
 
Add-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his DutyAdd-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his Duty
 
presentation
presentationpresentation
presentation
 
5 Common Mistakes You are Making on your Website
 5 Common Mistakes You are Making on your Website 5 Common Mistakes You are Making on your Website
5 Common Mistakes You are Making on your Website
 
Best Practices for WordPress
Best Practices for WordPressBest Practices for WordPress
Best Practices for WordPress
 
The things we found in your website
The things we found in your websiteThe things we found in your website
The things we found in your website
 

Recently uploaded

Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.soniya singh
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Servicesexy call girls service in goa
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceDelhi Call girls
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsThierry TROUIN ☁
 
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...aditipandeya
 
Radiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsRadiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsstephieert
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...Diya Sharma
 
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607dollysharma2066
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Servicegwenoracqe6
 
Gram Darshan PPT cyber rural in villages of india
Gram Darshan PPT cyber rural  in villages of indiaGram Darshan PPT cyber rural  in villages of india
Gram Darshan PPT cyber rural in villages of indiaimessage0108
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts servicevipmodelshub1
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Delhi Call girls
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGAPNIC
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 

Recently uploaded (20)

Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
 
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with Flows
 
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
 
Radiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsRadiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girls
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
 
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
 
Gram Darshan PPT cyber rural in villages of india
Gram Darshan PPT cyber rural  in villages of indiaGram Darshan PPT cyber rural  in villages of india
Gram Darshan PPT cyber rural in villages of india
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
 
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOG
 
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
 

Developing Complex WordPress Sites without Fear of Failure (with MVC)

  • 1. #complexwp | wplib.org | @mikeschinkel Developing Complex WordPress Sites* *Without Fear of Failure Presenter: Mike Schinkel WordCamp Raleigh 2015
  • 2. #complexwp | wplib.org | @mikeschinkel What to Expect • Target Audience for the Talk • Overview of Professional Workflow • Use of Object Orientation • Demo of code from a real-world project • How to make it easy by using WPLib
  • 3. #complexwp | wplib.org | @mikeschinkel Prerequisites • Experience building WordPress websites • Comfortable developing in PHP
  • 4. #complexwp | wplib.org | @mikeschinkel About Me • Self-Styled WordPress Architect • Typical Work: $100k+ Agency Projects • Many WordCamps, LoopConf • WordPress is my 4th developer ecosystem 2006-2009: Drupal 1993-2006: Visual Basic 1986-1993: Clipper - a dBase Compiler • Yada, yada
  • 5. #complexwp | wplib.org | @mikeschinkel Avoiding a WordPress House of Cards A.K.A. Avoiding Kevin Spacey
  • 6. #complexwp | wplib.org | @mikeschinkel Best For Large Budget Projects Where clients just expect us to:
  • 7. #complexwp | wplib.org | @mikeschinkel This approach NOT for "Tinkerers" Who want to fiddle with it after you leave. (And then yell at you and ask for support when they break it.)
  • 8. #complexwp | wplib.org | @mikeschinkel Disallow Adding of Plugins and Themes in the Admin Consule • Use a Custom Theme • Minimize 3rd Party Plugins
  • 9. #complexwp | wplib.org | @mikeschinkel Use a Professional Workflow ● A Professional IDE o PhpStorm+XDebug ● Version Control/Branching o For Features, and o For Bug Fixes ● A Deployment Process o Development (Local) o Test Server o Staging Server o Production Server ● See "Advanced WordPress Workflow” o That is Micah Wood's talk, next session...
  • 10. #complexwp | wplib.org | @mikeschinkel Use an Intelligent Process • Focus on Requirements • Create clickable mockups using moqups.com • Then Architecture • Decide on Post Types, Taxonomies, etc • Separate Theming from Architecture & Backend Coding • Best if people with the different skills are in the different roles • Maximize “Deployable” Code • User-entered Configuration Sux
  • 11. #complexwp | wplib.org | @mikeschinkel Use an Object Oriented Architecture •Heard of MVC? • Embrace Models and Views. • And Items, • And Lists, • And Applications. • And Helpers, • And Templates, • And Modules. • More on those in a bit…
  • 12. #complexwp | wplib.org | @mikeschinkel Wherest thou Objects? • Post Types • Taxonomies • User Roles • And more!
  • 13. #complexwp | wplib.org | @mikeschinkel • Controllers = the "C" in MVC • But Objects/Classes for Routing != WordPress • But you can usually hack it: URL Routing In WordPress http://tinyurl.com/wp-url-routing WordPress handles the Controller (mostly)
  • 14. #complexwp | wplib.org | @mikeschinkel DEMO Reviewing the Code of a Real World Client Project Warts and All (see http://github/wplib for online examples)
  • 15. #complexwp | wplib.org | @mikeschinkel Make it easy with WPLib • Designed for PHP Developers • Assumes Persistent Cache • Great for Building Reusable Code
  • 16. #complexwp | wplib.org | @mikeschinkel •It is Small •Does not try to do that much •Highly Consistent! •Presents Structured Constraints •Compatible with (all?) other Frameworks •WPLib provides incremental value •Can be used a little, or a lot •Solves a problem no one else(?) is addressing WPLib's Positive Attributes
  • 17. #complexwp | wplib.org | @mikeschinkel • One Application per site • Provides root class for a site/app. • Provides global but site-specific functionality, i.e. $list = MyApp::get_featured_slide_list([$query]); MyAPP::the_current_campaign_html(); $url = MyAPP::get_asset_url( 'images/visa-logo.png' ); if ( MyApp::is_featured_slider_enabled() ) { //... } The Application Class
  • 18. #complexwp | wplib.org | @mikeschinkel Theme Class • One Theme Class per theme • Put your theme hooks here, e.g. 'wp_head' 'wp_enqueue_scripts' • Location for theme global functionality, e.g. $theme->the_ad_html(); $theme->the_slider_html(); • Lots of functionality in parent class, e.g. $theme->the_header_html(); // same as get_header() $theme->the_site_name(); $page_id = $theme->front_page_id();
  • 19. #complexwp | wplib.org | @mikeschinkel Model Classes • Most of the “business logic" goes here. • All the “facts” about a type of Item • One per Item type class MyApp_Story_Model extends WPLib_Post_Model { function has_sponsor() { $has = get_post_meta( $this->ID(), '_myapp_has_sponsor', true ); return 1 == intval( $has ); } }
  • 20. #complexwp | wplib.org | @mikeschinkel View Classes • Specific methods for outputting Item info • One or more Views per Item type • Maybe one View for HTML, one for JSON, etc. • Most functionality needed in parent class class MyApp_Featured_Slide_View extends WPLib_Post_View_Base { function the_embed_code_html() { echo $this->embed_code(); } function the_embed_code_textarea() { echo htmlspecialchars( $this->embed_code() ); } }
  • 21. #complexwp | wplib.org | @mikeschinkel Item Classes • Container for a Model and a View. • ONLY class of Model+View+Item you actually use • Most functionality in the parent class • Rarely has much if any code class MyApp_Campaign extends WPLib_Post_Base { const POST_TYPE = MyApp_Campaigns::POST_TYPE; const VAR_NAME = 'campaign'; }
  • 22. #complexwp | wplib.org | @mikeschinkel List Classes • Smart arrays of Items • Can be custom classes with use-case specific methods • But usually you only need the Default List Class foreach( MyApp_Featured_Slides::get_list() as $slide ) { $slide->the_template( 'slide-card' ); } // OR JUST: MyApp_Featured_Slides::get_list()->the_template( 'slide-card' );
  • 23. #complexwp | wplib.org | @mikeschinkel Helper Classes • Think of a Helper as "A List of Related Functions" • Contributes Static Methods • To your Application class • We do the same for the WPLib class • Enables making small, easy to learn APIs • The Application class is the method "router" • Helper Method names must be unique across an Application • Better approach than a single "God" Class • Allows for many smaller files • Clearer source code organization • Better source file management
  • 24. #complexwp | wplib.org | @mikeschinkel Helper Classes (cont'd) class MyApp_Date_Range extends WPLib_Module_Base { static $_post_types = array(); static function on_load() { self::register_helper( __CLASS__, 'MyApp' ); } static function register_date_range_post_type( $post_type ) { self::$_post_types[ $post_type ] = $post_type; } static function date_range_post_types() { return self::$_post_types; } } MyApp_Date_Range::on_load(); //---------- MyApp::register_date_range_post_type( MyApp_Story::POST_TYPE ); print_r( MyApp::date_range_post_types() );
  • 25. #complexwp | wplib.org | @mikeschinkel Module Classes • Provides Functionality • Like a Plugin • Designed for Developers • Unlike a Plugin • Designed to be small • If one grows too big, split it up! • Should be highly cohesive • Group related functionality together
  • 26. #complexwp | wplib.org | @mikeschinkel • A Main "Entry Point" file • Contains a main class • Should hook all hooks needed on page load • Optimized to load efficiently • Zero or more /includes/ files • One class per file • Include files are autoloaded • Architected to be Composible • Reusability: Yeah Baby! Module Classes (cont'd)
  • 27. #complexwp | wplib.org | @mikeschinkel WPLib Templates • Like Template Parts • Not template files like single.php, home.php, et. al. • Typically scoped to an Item • Or scoped to the Theme class ($theme) • Or with no scope (called using MyApp::) • Loaded by $item->the_template('part') method • Templates in {theme}/templates/{part}.php
  • 28. #complexwp | wplib.org | @mikeschinkel Constraints are your Friends • Templates should contain NO implementation details •Should contain ONLY site-specific HTML or CSS and method calls. •No WP_Query, no get_post_meta(), etc.
  • 29. #complexwp | wplib.org | @mikeschinkel • Contains NO site-specific HTML or CSS •Auto-generate "the_" methods •For rendering output •Conventions for escaping output •"_url" •"_attr" •"_html" •suffix, etc. View Methods
  • 30. #complexwp | wplib.org | @mikeschinkel A Few Well-Known Constants •POST_TYPE •Use to specify the post type in a Post Type Module. •TAXONOMY •Use to specify the taxonomy in a Taxonomy Module. •ROLE •Use to specify the user role in a User Role Module. •VAR_NAME •Use to specify an $item's auto assigned variable name in a template. •INSTANCE_CLASS •Use to specify the $item's class name in an MVI module class.
  • 31. #complexwp | wplib.org | @mikeschinkel To Learn More about WPLib •Clone from GitHub, Review sample apps: •github.com/wplib •Visit wplib.org •For Quick Start and other Docs •Submit issues on GitHub: •github.com/wplib/wplib/issues •Ask questions on Twitter: •@mikeschinkel / @wpscholar •Discuss on Slack •Ok: wordpress.slack.com (mikeschinkel/wpscholar) •Best: thecodersguild.slack.com#wplib •Email mike@newclarity.net for access
  • 32. #complexwp | wplib.org | @mikeschinkel Questions?
  • 33. #complexwp | wplib.org | @mikeschinkel THANK YOU Mike Schinkel mike@newclarity.net about.me/mikeschinkel See also: www.slideshare.net/mikeschinkel