Ye ole WordPress 

for Big Budgets
a.k.a 

Using WordPress for Complex 

Enterprise Applications
#wpfbb
The Slide Added 

After Presentation
To the designers whose sensibilities I offended
for using Papyrus, I apologize sincerely. 



I am not a designer and do not recognize these
things. I blame Apple and Keynote.


We Champion WordPress
for the Lords (Agencies) 

who service the 

Kings (Larger Organizations) 

- Mike Schinkel - @mikeschinkel

Managing Partner

NewClarity Consulting LLC
About Me?
Show of Hands?
Developer of Locked-down Client Site?
Internal Developer of Corporate Sites
Developer of Vertical Market Products
None of the above?
What Means Enterprise?
Performance & Scalability?
Security Concerns?
Rapid Development?
Professional Workflow?
Scaling Complexity?
Or Big Company Politics?!?
This Talk:
Scaling 

Complexity
Schinkel’s Law
The Code Quality, Maintainability
and Extensibility of a 

WordPress Theme (or Plugin) is 

inversely proportional 

to how visually impressive it is.
A Tale of Two
WordPresses
In Days of Yor
WordPress was Just a Blog
Themes were Just Templates
Sites were Built by Adding Plugins
And Cowboy Coders Ruled the Land
Then the Settlers Came
They Wanted Sites for Business
Agencies Emerged to Serve Them
Designers Envisioned Great Designs
And the Settlers Wanted it Now
But the Cowboy Coders Failed Them All
New Sheriffs Are in Town
They are Cleaning up Bad Practices
They are Requiring Version Control and 

Multi-server Deployment Processes
And they Separate Concerns in Code
All while Respecting the Townsfolk
Are Best Practices 

Always Best?
i.e. “No Post Types 

in a Theme!”
Agency-built Sites:
Do Not Need 

to Switch 

Custom Themes!
So Let’s Slay 

Another

Sacred Cow
Death to 

“The Loop”
Yeah: It’s LoopConf.
I Get the Irony.
Instead: Use an

MV* Approach
(Inspired by the Backbone 

library for Javascript)
Models & Views:
For each Post Type
For each Taxonomy
For each User Role
For Comments
And more….
“List” Classes 

wrap

WP_Query
  	
  
	
   $partners	
  =	
  new	
  WP_Query(	
  array(	
  	
  	
  	
  	
  
	
   	
   ‘post_type’	
  =>	
  ‘lp_person’,	
  
	
   	
   ‘order’	
  	
  	
   =>	
  ‘asc’	
  
	
   	
   ‘orderby’	
  	
   =>	
  ‘title’	
  
	
   	
   ‘meta_key’	
  	
  =>	
  ‘_position’,	
  
	
   	
   ‘meta_value’=>	
  ‘partner’,	
  
	
   	
   ‘posts_per_page’	
  =>	
  99,	
  
	
   ));?>	
  
	
   <ul	
  id=“partner-­‐list”>	
   	
  
	
   <?php	
  while	
  ($partners-­‐>have_posts()):	
  
	
   	
   $partners-­‐>the_post();	
  ?>

	
   	
   <li><a	
  href=“<?php	
  get_permalink();	
  ?>”>	
  
	
   	
   	
   	
   	
   	
   <?php	
  the_title();	
  ?></a></li>	
  	
  	
  
	
   <?php	
  endwhile;	
  ?></ul>	
  
Typical Theme Code
  	
  
	
   <ul	
  id=“partner-­‐list”>	
  
!
	
   <?php	
  	
  
	
   foreach	
  (LawPress::partner_list()	
  as	
  $partner):	
  
	
   ?>	
  

	
   	
   	
  
	
   	
   <li><?php	
  $partner-­‐>the_title_link();	
  ?></li>	
  	
  	
  
!
	
   <?php	
  	
  
	
   endforeach;	
  	
  
	
   ?>	
  
!
	
   </ul>	
  
MV* Theme Code
  	
  
	
   $person	
  =	
  new	
  LawPress_Person(	
  $post	
  );	
  
	
   <h1><?php	
  $person-­‐>the_fullname();	
  ?></h1>	
  
	
   <?php	
  $person-­‐>the_template(‘person-­‐contact’);	
  ?>	
  	
  	
  
	
   <div	
  class=“bio”>	
  
	
   	
   <?php	
  $person-­‐>the_content_html();	
  ?>	
  
	
   </div>	
  
	
   <div	
  class=“team-­‐list”>	
  
	
   <?php	
  	
  
	
   	
   $person-­‐>team_list()-­‐>the_template(‘team-­‐link’);	
  
	
   ?>	
  
	
   </div>	
  
Full Visibility for Themers
  	
  
!
	
   <div	
  id=“<?php	
  $article-­‐>the_slug_attr();	
  ?>”>	
  	
  	
  	
  
!
	
   	
   <h1><?php	
  $article-­‐>the_title();	
  ?></h1>	
  
!
	
   	
   <?php	
  $article-­‐>the_content_html();	
  ?>	
  
!
	
   	
   <img	
  src=“<?php	
  $article-­‐>the_image_url();	
  ?>”	
  	
  	
  
!
	
   </div>	
  
!
Suffixes Define Escape
Convention-Driven Escaping
	 _attr() => esc_attr()
	 _html() => wp_kses_post()
	 _link() => wp_kses_post()
	 _url() => esc_url()
	 (none) => esc_html()
Automatic View Methods
Define a Model method slug()
to automatically get a
View method the_slug_attr()
with automatic escaping!
Benefits of MV*
Business Logic in the Model
Repetitive HTML in Views
Simple, Easy-to-read Templates
Easier Fragment Caching
Automated Testing (mostly)
Benefits, cont’d
Fewer Global Variable Bugs
Fewer Hook Side-effect Bugs
Separates Team Member Concerns
HTML/CSS vs. Javascript vs. PHP/MySQL
Enables Reusable Modules
Techniques in use at	:
Dell
Coca-Cola
Internally
But you ask,
How?!?
Announcing
WPLib
Based on~5 Years
Experience
WPLib	
An Architecture, not an MVC Plugin
A “Foundation Library” to support
the architecture.
Built for Coders, not for 

End-users or “Sitebuilders”
Available Now	
Open Source - GPLv2
On github.com/wplib
Docs are on wplib.org
WPLib Goal:
Adoption among Agencies
Curated Reusable Modules
Enable Faster Implementation 

of Complex Sites 

Thank You!
mike@newclarity.net
@mikeschinkel

Scaling Complexity in WordPress Enterprise Apps

  • 1.
    Ye ole WordPress
 for Big Budgets a.k.a 
 Using WordPress for Complex 
 Enterprise Applications #wpfbb
  • 2.
    The Slide Added
 After Presentation To the designers whose sensibilities I offended for using Papyrus, I apologize sincerely. 
 
 I am not a designer and do not recognize these things. I blame Apple and Keynote.
  • 3.
    
 We Champion WordPress forthe Lords (Agencies) 
 who service the 
 Kings (Larger Organizations) 
 - Mike Schinkel - @mikeschinkel
 Managing Partner
 NewClarity Consulting LLC About Me?
  • 4.
    Show of Hands? Developerof Locked-down Client Site? Internal Developer of Corporate Sites Developer of Vertical Market Products None of the above?
  • 5.
    What Means Enterprise? Performance& Scalability? Security Concerns? Rapid Development? Professional Workflow? Scaling Complexity? Or Big Company Politics?!?
  • 6.
  • 7.
    Schinkel’s Law The CodeQuality, Maintainability and Extensibility of a 
 WordPress Theme (or Plugin) is 
 inversely proportional 
 to how visually impressive it is.
  • 8.
    A Tale ofTwo WordPresses
  • 9.
    In Days ofYor WordPress was Just a Blog Themes were Just Templates Sites were Built by Adding Plugins And Cowboy Coders Ruled the Land
  • 10.
    Then the SettlersCame They Wanted Sites for Business Agencies Emerged to Serve Them Designers Envisioned Great Designs And the Settlers Wanted it Now But the Cowboy Coders Failed Them All
  • 11.
    New Sheriffs Arein Town They are Cleaning up Bad Practices They are Requiring Version Control and 
 Multi-server Deployment Processes And they Separate Concerns in Code All while Respecting the Townsfolk
  • 12.
    Are Best Practices
 Always Best? i.e. “No Post Types 
 in a Theme!”
  • 13.
    Agency-built Sites: Do NotNeed 
 to Switch 
 Custom Themes!
  • 14.
    So Let’s Slay
 Another
 Sacred Cow
  • 15.
    Death to 
 “TheLoop” Yeah: It’s LoopConf. I Get the Irony.
  • 16.
    Instead: Use an
 MV*Approach (Inspired by the Backbone 
 library for Javascript)
  • 17.
    Models & Views: Foreach Post Type For each Taxonomy For each User Role For Comments And more….
  • 18.
  • 19.
          $partners  =  new  WP_Query(  array(               ‘post_type’  =>  ‘lp_person’,       ‘order’       =>  ‘asc’       ‘orderby’     =>  ‘title’       ‘meta_key’    =>  ‘_position’,       ‘meta_value’=>  ‘partner’,       ‘posts_per_page’  =>  99,     ));?>     <ul  id=“partner-­‐list”>       <?php  while  ($partners-­‐>have_posts()):       $partners-­‐>the_post();  ?>
     <li><a  href=“<?php  get_permalink();  ?>”>               <?php  the_title();  ?></a></li>         <?php  endwhile;  ?></ul>   Typical Theme Code
  • 20.
          <ul  id=“partner-­‐list”>   !   <?php       foreach  (LawPress::partner_list()  as  $partner):     ?>  
           <li><?php  $partner-­‐>the_title_link();  ?></li>       !   <?php       endforeach;       ?>   !   </ul>   MV* Theme Code
  • 21.
          $person  =  new  LawPress_Person(  $post  );     <h1><?php  $person-­‐>the_fullname();  ?></h1>     <?php  $person-­‐>the_template(‘person-­‐contact’);  ?>         <div  class=“bio”>       <?php  $person-­‐>the_content_html();  ?>     </div>     <div  class=“team-­‐list”>     <?php         $person-­‐>team_list()-­‐>the_template(‘team-­‐link’);     ?>     </div>   Full Visibility for Themers
  • 22.
        !   <div  id=“<?php  $article-­‐>the_slug_attr();  ?>”>         !     <h1><?php  $article-­‐>the_title();  ?></h1>   !     <?php  $article-­‐>the_content_html();  ?>   !     <img  src=“<?php  $article-­‐>the_image_url();  ?>”       !   </div>   ! Suffixes Define Escape
  • 23.
    Convention-Driven Escaping _attr()=> esc_attr() _html() => wp_kses_post() _link() => wp_kses_post() _url() => esc_url() (none) => esc_html()
  • 24.
    Automatic View Methods Definea Model method slug() to automatically get a View method the_slug_attr() with automatic escaping!
  • 25.
    Benefits of MV* BusinessLogic in the Model Repetitive HTML in Views Simple, Easy-to-read Templates Easier Fragment Caching Automated Testing (mostly)
  • 26.
    Benefits, cont’d Fewer GlobalVariable Bugs Fewer Hook Side-effect Bugs Separates Team Member Concerns HTML/CSS vs. Javascript vs. PHP/MySQL Enables Reusable Modules
  • 27.
    Techniques in useat : Dell Coca-Cola Internally
  • 28.
  • 29.
  • 30.
    WPLib An Architecture, notan MVC Plugin A “Foundation Library” to support the architecture. Built for Coders, not for 
 End-users or “Sitebuilders”
  • 31.
    Available Now Open Source- GPLv2 On github.com/wplib Docs are on wplib.org
  • 32.
    WPLib Goal: Adoption amongAgencies Curated Reusable Modules Enable Faster Implementation 
 of Complex Sites 

  • 33.