Scaling Complexity in WordPress Enterprise Apps
-
Upload
mike-schinkel -
Category
Technology
-
view
200 -
download
2
Transcript of Scaling Complexity in WordPress Enterprise Apps
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 - @mikeschinkelManaging 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?!?
Schinkel’s Law
The Code Quality, Maintainability
and Extensibility of a WordPress Theme (or Plugin) is
inversely proportional to how visually impressive it is.
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
$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
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