SlideShare una empresa de Scribd logo
1 de 22
Descargar para leer sin conexión
Building better WordPress applications
PBWEB.CO.UK
@PHILL_BROWN
Problems with WordPress applications
• Business logic in themes
• Repeated code
• Tight coupling
• Portability
Rule #1
Do not write your application in
functions.php
Decoupling plugins and themes
Logic Templates
Templates
Plugin
Theme
Rule #2
Every action should be hooked
function my_plugin_start() {
// Fire up application
}
// Wrong
my_plugin_start();
// Right
add_action( ‘plugins_loaded’, ‘my_plugin_start’ );
Rule #3
Use WordPress
Core checklist
• Custom post types and post meta
• Roles, capabilities and user meta
• Options and transients
• Scheduler
• Remote HTTP
Rule #4
Use plugin dependencies
• Scribu’s Plugin Dependencies
• if ( ! class_exists( ‘plugin_x’ ) ) {
wp_die( ‘Plugin Y requires plugin x’ );
}
Rule #5
Standardise code
• WordPress coding standards:
http://codex.wordpress.org/WordPress_Coding_Standards
• PHPDoc
http://en.wikipedia.org/wiki/PHPDoc
Rule #6
Choose your PHP version
• WordPress core (v3.0+) – 5.1.1
• 5.2 – DateTime
• 5.3 – Late static binding, closures,
namespacing
• 5.4 - Traits
Rule #7
Avoid global scoping
add_action( ‘init’, function() {
// do something 
} );
Closures
namespace wordpressmy_plugin;
class Post {} 
Namespacing
class My_Plugin_Post {} 
PHP 5.3
PHP 5.1
Rule #8
Activation hooks
register_activation_hook( __FILE__, ‘my_plugin_activate’ );
function my_plugin_activate() {
// Create tables, roles, capabilities
}
register_uninstall_hook( __FILE__, ‘my_plugin_uninstall’ );
function my_plugin_uninstall() {
// Cleanup data
}
Rule #9define( ‘WP_DEBUG’, true );
Rule #10
Release your code
Questions?
@PHILL_BROWN
WP@PBWEB.CO.UK

Más contenido relacionado

La actualidad más candente

Instagram filters (8 24)
Instagram filters (8 24)Instagram filters (8 24)
Instagram filters (8 24)
Ivy Rueb
 
Pluggable patterns
Pluggable patternsPluggable patterns
Pluggable patterns
Corey Oordt
 
ASP .NET MVC
ASP .NET MVC ASP .NET MVC
ASP .NET MVC
eldorina
 

La actualidad más candente (20)

ASP.NET Core Unit Testing
ASP.NET Core Unit TestingASP.NET Core Unit Testing
ASP.NET Core Unit Testing
 
Rails review
Rails reviewRails review
Rails review
 
Asp.net c# MVC-5 Training-Day-1 of Day-9
Asp.net c# MVC-5 Training-Day-1 of Day-9Asp.net c# MVC-5 Training-Day-1 of Day-9
Asp.net c# MVC-5 Training-Day-1 of Day-9
 
Modular PHP Development using CodeIgniter Bonfire
Modular PHP Development using CodeIgniter BonfireModular PHP Development using CodeIgniter Bonfire
Modular PHP Development using CodeIgniter Bonfire
 
ASP.NET Core 1.0 Overview
ASP.NET Core 1.0 OverviewASP.NET Core 1.0 Overview
ASP.NET Core 1.0 Overview
 
Instagram filters (8 24)
Instagram filters (8 24)Instagram filters (8 24)
Instagram filters (8 24)
 
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
Javascript Frameworks Comparison - Angular, Knockout, Ember and BackboneJavascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
 
ASP.NET Core 1.0 Overview: Pre-RC2
ASP.NET Core 1.0 Overview: Pre-RC2ASP.NET Core 1.0 Overview: Pre-RC2
ASP.NET Core 1.0 Overview: Pre-RC2
 
Introduction to Adobe Flex - Zaloni
Introduction to Adobe Flex - ZaloniIntroduction to Adobe Flex - Zaloni
Introduction to Adobe Flex - Zaloni
 
Pluggable patterns
Pluggable patternsPluggable patterns
Pluggable patterns
 
Building Cool apps with flex
Building Cool apps with flexBuilding Cool apps with flex
Building Cool apps with flex
 
An approach to app security - For beginners
An approach to app security - For beginnersAn approach to app security - For beginners
An approach to app security - For beginners
 
ASP .Net MVC 5
ASP .Net MVC 5ASP .Net MVC 5
ASP .Net MVC 5
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentation
 
Building Modern Web Applications with ASP.NET5
Building Modern Web Applications with ASP.NET5Building Modern Web Applications with ASP.NET5
Building Modern Web Applications with ASP.NET5
 
ASP .NET MVC
ASP .NET MVC ASP .NET MVC
ASP .NET MVC
 
Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013
 
Progressive EPiServer Development
Progressive EPiServer DevelopmentProgressive EPiServer Development
Progressive EPiServer Development
 
Selenium WebDriver: Tips and Tricks
Selenium WebDriver: Tips and TricksSelenium WebDriver: Tips and Tricks
Selenium WebDriver: Tips and Tricks
 
ASP.NET - Ivan Marković
ASP.NET - Ivan MarkovićASP.NET - Ivan Marković
ASP.NET - Ivan Marković
 

Destacado

Introduction to git
Introduction to gitIntroduction to git
Introduction to git
Phill Brown
 
PHP, Handle with care
PHP, Handle with carePHP, Handle with care
PHP, Handle with care
Phill Brown
 
Word Press Power Point
Word Press Power PointWord Press Power Point
Word Press Power Point
Lisa Sjogren
 
(In)Secure Ajax-Y Websites With PHP
(In)Secure Ajax-Y Websites With PHP(In)Secure Ajax-Y Websites With PHP
(In)Secure Ajax-Y Websites With PHP
chw
 
6 weeks 6 months live project summer industrial training in cmc limited 2012
6 weeks  6 months live project summer industrial training in cmc limited  20126 weeks  6 months live project summer industrial training in cmc limited  2012
6 weeks 6 months live project summer industrial training in cmc limited 2012
CMC Limited
 

Destacado (20)

WordPress Workflows
WordPress WorkflowsWordPress Workflows
WordPress Workflows
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
 
PHP, Handle with care
PHP, Handle with carePHP, Handle with care
PHP, Handle with care
 
Git Introduction
Git IntroductionGit Introduction
Git Introduction
 
Subversion to Git Migration
Subversion to Git MigrationSubversion to Git Migration
Subversion to Git Migration
 
Puppet and Telefonica R&D
Puppet and Telefonica R&DPuppet and Telefonica R&D
Puppet and Telefonica R&D
 
WordPress for Applications
WordPress for ApplicationsWordPress for Applications
WordPress for Applications
 
Future-proofing your WordPress site - WordCamp Sydney 2014
Future-proofing your WordPress site - WordCamp Sydney 2014Future-proofing your WordPress site - WordCamp Sydney 2014
Future-proofing your WordPress site - WordCamp Sydney 2014
 
Word Press Power Point
Word Press Power PointWord Press Power Point
Word Press Power Point
 
Drupal vs WordPress
Drupal vs WordPressDrupal vs WordPress
Drupal vs WordPress
 
TAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith AdamsTAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith Adams
 
Higher Order WordPress Security
Higher Order WordPress SecurityHigher Order WordPress Security
Higher Order WordPress Security
 
WordPress and Web Accessibility - 2013
WordPress and Web Accessibility - 2013WordPress and Web Accessibility - 2013
WordPress and Web Accessibility - 2013
 
Elastic: Why WYSIWYG is the future of WordPress themes — WordCamp NYC 2009
Elastic: Why WYSIWYG is the future of WordPress themes — WordCamp NYC 2009Elastic: Why WYSIWYG is the future of WordPress themes — WordCamp NYC 2009
Elastic: Why WYSIWYG is the future of WordPress themes — WordCamp NYC 2009
 
The Future of WordPress (WordCamp Montréal)
The Future of WordPress (WordCamp Montréal)The Future of WordPress (WordCamp Montréal)
The Future of WordPress (WordCamp Montréal)
 
(In)Secure Ajax-Y Websites With PHP
(In)Secure Ajax-Y Websites With PHP(In)Secure Ajax-Y Websites With PHP
(In)Secure Ajax-Y Websites With PHP
 
Alibaba Case Study on Strategic Management
Alibaba Case Study on Strategic ManagementAlibaba Case Study on Strategic Management
Alibaba Case Study on Strategic Management
 
Web scraper using PHP
Web scraper using PHPWeb scraper using PHP
Web scraper using PHP
 
The Future Of WordPress Presentation
The Future Of WordPress PresentationThe Future Of WordPress Presentation
The Future Of WordPress Presentation
 
6 weeks 6 months live project summer industrial training in cmc limited 2012
6 weeks  6 months live project summer industrial training in cmc limited  20126 weeks  6 months live project summer industrial training in cmc limited  2012
6 weeks 6 months live project summer industrial training in cmc limited 2012
 

Similar a Building better WordPress applications

WordPress Harrisburg Meetup - Best Practices
WordPress Harrisburg Meetup - Best PracticesWordPress Harrisburg Meetup - Best Practices
WordPress Harrisburg Meetup - Best Practices
ryanduff
 

Similar a Building better WordPress applications (20)

Codeigniter
CodeigniterCodeigniter
Codeigniter
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress Applications
 
Developing WordPress Plugins : For Begineers
Developing WordPress Plugins :  For BegineersDeveloping WordPress Plugins :  For Begineers
Developing WordPress Plugins : For Begineers
 
Best Practices for WordPress
Best Practices for WordPressBest Practices for WordPress
Best Practices for WordPress
 
Asp.Net MVC 5 in Arabic
Asp.Net MVC 5 in ArabicAsp.Net MVC 5 in Arabic
Asp.Net MVC 5 in Arabic
 
Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress development
 
Codeigniter framework
Codeigniter framework Codeigniter framework
Codeigniter framework
 
Advanced php code igniter framework
Advanced php code igniter frameworkAdvanced php code igniter framework
Advanced php code igniter framework
 
WordPress Harrisburg Meetup - Best Practices
WordPress Harrisburg Meetup - Best PracticesWordPress Harrisburg Meetup - Best Practices
WordPress Harrisburg Meetup - Best Practices
 
Ember - introduction
Ember - introductionEmber - introduction
Ember - introduction
 
presentation
presentationpresentation
presentation
 
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
 
Here Be Dragons - Debugging WordPress
Here Be Dragons - Debugging WordPressHere Be Dragons - Debugging WordPress
Here Be Dragons - Debugging WordPress
 
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
 
Introduction to cypress in Angular (Chinese)
Introduction to cypress in Angular (Chinese)Introduction to cypress in Angular (Chinese)
Introduction to cypress in Angular (Chinese)
 
Headless cms architecture
Headless cms architectureHeadless cms architecture
Headless cms architecture
 
doing_it_right() with WordPress
doing_it_right() with WordPressdoing_it_right() with WordPress
doing_it_right() with WordPress
 
Writing a Wordpress plugin from scratch
Writing a Wordpress plugin from scratchWriting a Wordpress plugin from scratch
Writing a Wordpress plugin from scratch
 
Miami2015
Miami2015Miami2015
Miami2015
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 

Building better WordPress applications