SlideShare a Scribd company logo
Using WordPress as 
your application stack 
WHY AND HOW
@me 
Senior Full Stack WordPress Developer 
Plugin author of Author Avatars List http://wordpress.org/plugins/author-avatars/ 
and WP Site Verification tool http://wordpress.org/plugins/wp-site-verification-tool/ 
Slides @ http://www.slideshare.net/pbearne
Why WordPress? 
•Stable 
•Supported 
•Community 
•Scales
Why not WordPress? 
•Code debt 
•PHP 
•Has PHP global’s 
•Not sexy
23% 
OF THE SITES IN WHOLE INTERNET
34,000 
PLUG-INS
2,800 
THEMES
How 
•Actions and filters 
•JSON API 
•jQuery - Backbone 
•Template hierarchy 
•Custom post types
Filter 
add_filter(‘fliter_name’, ‘function_to_run’); 
Function function_to_run( $var ){ 
$var .= ‘hello world’; 
return $var; 
} 
http://codex.wordpress.org/Plugin_API#Filters
Action 
add_action(‘action_name’, ‘function_to_run’); 
Function function_to_run( $var = null ){ 
echo ‘hello world’; 
} 
http://codex.wordpress.org/Plugin_API#Actions
Ajax Route 
/** 
* Register a rewrite endpoint for the API. 
*/ 
function prefix_add_api_endpoints() { 
add_rewrite_tag( '%api_item_id%', '([0-9]+)' ); 
add_rewrite_rule( 'api/items/([0-9]+)/?', 
'index.php?api_item_id=$matches[1]', 'top' ); 
} 
add_action( 'init', 'prefix_add_api_endpoints' ); 
https://10up.github.io/Engineering-Best-Practices/php/#ajax-endpoints
Ajax handler 
function prefix_do_api() { 
global $wp_query; 
$item_id = $wp_query->get( 'api_item_id' ); 
if ( ! empty( $item_id ) ) { 
$response = array(); 
// Do stuff with $item_id 
wp_send_json( $response ); 
} 
} 
add_action( 'template_redirect', 'prefix_do_api' );
JSON API wordpress.com 
Part of the Jetpack plug-in 
http://developer.wordpress.com/docs/api/ 
https://developer.wordpress.com/docs/api/console/ 
End point 
https://public-api.wordpress.com/rest/v1/ 
e.g. 
https://public-api. 
wordpress.com/rest/v1/sites/authoravatars.wordpress.com/
JSON API wp.org (self host) 
Part of next version of core (currently plug-in) 
http://wp-api.org/ 
End point 
https://domain.com/wp-json/
JSON API wp-api.org/ v. WP.com 
WP.com 
Wp-api.org 
Caching 
On you server 
Little load on your servers 
Extendable 
Access to WordPress.com user and stats 
More complete 
The API’s don’t match (yet)
BackBone 
Included with WordPress  
To just load it 
wp_enqueue_script( ‘backbone’ ); 
Or better still load as a dependency of your script 
wp_enqueue_script( ‘myscript’, ‘path/to/script, array( 'backbone' ) ); 
https://github.com/tlovett1/_s_backbone
Template Hierarchy 
The order Wordpress load its template files 
http://codex.wordpress.org/Template_Hierarchy
Template Hierarchy
Custom post types 
The main logical data object 
in WordPress 
The standard types are : 
post, page, media 
add_action( 'init', 'create_post_type' ); 
function create_post_type() { 
register_post_type( 
'acme_product', 
array( 'labels' => array( 
'name' => __( 'Products' ), 
'singular_name' => __( 'Product' ) 
), 
'public' => true, 
'has_archive' => true, ) 
); 
} 
http://codex.wordpress.org/Post_Types
Custom metadata 
The data linked to a post object 
Text or serialized data 
Use CMB2 to easily create admin forms 
Hide the metadata from admin by 
starting the id with an “_” 
$meta_boxes[ 'tombstone_page_metabox' ] = array( 
'id' => __( 'tombstone_page_metabox', 
Config::get_text_domain() ), 
'title' => __( 'Tombstone Details', 
Config::get_text_domain() ), 
'object_types' => array( self::get_tombstone_post_type() ), 
https://github.com/WebDevStudios/CMB2 
// Post types 
'context' => 'normal', 
'priority' => 'high', 
'show_names' => true, // Show field names on the left 
'fields' => array( 
array( 
'name' => __( 'Tag line', Config::get_text_domain() 
), 
'desc' => __( 'Enter the pull Quote', 
Config::get_text_domain() ), 
'id' => Config::_get_prefix() . 'tagline', 
'type' => 'textarea_small', 
'attributes' => array( 
'style' => 'width:100%;', 
), 
), 
) 
);
Call external API and cache 
Use the internal 
wp_remote_get() get remote data. 
Then cache the data with a 
transients cache 
or 
tlc_transient() 
$request = wp_remote_get('http://example.com'); 
$response = wp_remote_retrieve_body( $request ); 
echo $response; 
<?php 
// Define your callback (other examples use 
this) 
function my_callback() { 
return wp_remote_retrieve_body( 
wp_remote_get( 'http://example.com/feed.xml', 
array( 'timeout' => 30 ) ) 
); 
} // Grab that feed echo 
$data = tlc_transient( 'example-feed' ) 
->updates_with( 'my_callback' ) 
->expires_in( 300 ) 
->get(); 
If( false != $data ){ 
// show data 
} 
?> 
https://github.com/markjaquith/WP-TLC-Transients
Questions? 
http://www.slideshare.net/pbearne

More Related Content

What's hot

An introduction to Laravel Passport
An introduction to Laravel PassportAn introduction to Laravel Passport
An introduction to Laravel Passport
Michael Peacock
 
Keeping it small: Getting to know the Slim micro framework
Keeping it small: Getting to know the Slim micro frameworkKeeping it small: Getting to know the Slim micro framework
Keeping it small: Getting to know the Slim micro frameworkJeremy Kendall
 
REST APIs in Laravel 101
REST APIs in Laravel 101REST APIs in Laravel 101
REST APIs in Laravel 101
Samantha Geitz
 
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
Ryan Weaver
 
Phpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsPhpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsMichael Peacock
 
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Arc & Codementor
 
Keeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro frameworkKeeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro framework
Jeremy Kendall
 
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram VaswaniCreating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
vvaswani
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5
Elena Kolevska
 
Developing apps using Perl
Developing apps using PerlDeveloping apps using Perl
Developing apps using Perl
Anatoly Sharifulin
 
Childthemes ottawa-word camp-1919
Childthemes ottawa-word camp-1919Childthemes ottawa-word camp-1919
Childthemes ottawa-word camp-1919
Paul Bearne
 
Silex, the microframework
Silex, the microframeworkSilex, the microframework
Silex, the microframework
Inviqa
 
Inside Bokete: Web Application with Mojolicious and others
Inside Bokete:  Web Application with Mojolicious and othersInside Bokete:  Web Application with Mojolicious and others
Inside Bokete: Web Application with Mojolicious and others
Yusuke Wada
 
WordPress REST API hacking
WordPress REST API hackingWordPress REST API hacking
WordPress REST API hacking
Jeroen van Dijk
 
The Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/PressThe Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/Press
Jeroen van Dijk
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overviewYehuda Katz
 

What's hot (20)

An introduction to Laravel Passport
An introduction to Laravel PassportAn introduction to Laravel Passport
An introduction to Laravel Passport
 
Keeping it small: Getting to know the Slim micro framework
Keeping it small: Getting to know the Slim micro frameworkKeeping it small: Getting to know the Slim micro framework
Keeping it small: Getting to know the Slim micro framework
 
REST APIs in Laravel 101
REST APIs in Laravel 101REST APIs in Laravel 101
REST APIs in Laravel 101
 
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
 
Phpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsPhpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friends
 
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
 
Keeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro frameworkKeeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro framework
 
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram VaswaniCreating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
 
RESTful web services
RESTful web servicesRESTful web services
RESTful web services
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5
 
Developing apps using Perl
Developing apps using PerlDeveloping apps using Perl
Developing apps using Perl
 
Childthemes ottawa-word camp-1919
Childthemes ottawa-word camp-1919Childthemes ottawa-word camp-1919
Childthemes ottawa-word camp-1919
 
Silex, the microframework
Silex, the microframeworkSilex, the microframework
Silex, the microframework
 
Inside Bokete: Web Application with Mojolicious and others
Inside Bokete:  Web Application with Mojolicious and othersInside Bokete:  Web Application with Mojolicious and others
Inside Bokete: Web Application with Mojolicious and others
 
Symfony 2
Symfony 2Symfony 2
Symfony 2
 
Mojolicious
MojoliciousMojolicious
Mojolicious
 
WordPress REST API hacking
WordPress REST API hackingWordPress REST API hacking
WordPress REST API hacking
 
Rails 4.0
Rails 4.0Rails 4.0
Rails 4.0
 
The Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/PressThe Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/Press
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
 

Viewers also liked

Daughter Themes
Daughter ThemesDaughter Themes
Daughter Themes
Paul Bearne
 
Vagrant WordCamp Hamilton
Vagrant  WordCamp HamiltonVagrant  WordCamp Hamilton
Vagrant WordCamp Hamilton
Paul Bearne
 
WordPress overloading Gravityforms using hooks, filters and extending classes
WordPress overloading Gravityforms using hooks, filters and extending classes WordPress overloading Gravityforms using hooks, filters and extending classes
WordPress overloading Gravityforms using hooks, filters and extending classes
Paul Bearne
 
Gravity Forms Hooks & Filters
Gravity Forms Hooks & FiltersGravity Forms Hooks & Filters
Gravity Forms Hooks & Filtersiamdangavin
 
Tips and tricks for using wordpress as application platform.
Tips and tricks for using wordpress as application platform.Tips and tricks for using wordpress as application platform.
Tips and tricks for using wordpress as application platform.
danwestall
 
Professional Frontend Engineering
Professional Frontend EngineeringProfessional Frontend Engineering
Professional Frontend EngineeringCheton Wu
 
High Performance Web Sites - Tips for faster pages
High Performance Web Sites - Tips for faster pagesHigh Performance Web Sites - Tips for faster pages
High Performance Web Sites - Tips for faster pagesCheton Wu
 

Viewers also liked (7)

Daughter Themes
Daughter ThemesDaughter Themes
Daughter Themes
 
Vagrant WordCamp Hamilton
Vagrant  WordCamp HamiltonVagrant  WordCamp Hamilton
Vagrant WordCamp Hamilton
 
WordPress overloading Gravityforms using hooks, filters and extending classes
WordPress overloading Gravityforms using hooks, filters and extending classes WordPress overloading Gravityforms using hooks, filters and extending classes
WordPress overloading Gravityforms using hooks, filters and extending classes
 
Gravity Forms Hooks & Filters
Gravity Forms Hooks & FiltersGravity Forms Hooks & Filters
Gravity Forms Hooks & Filters
 
Tips and tricks for using wordpress as application platform.
Tips and tricks for using wordpress as application platform.Tips and tricks for using wordpress as application platform.
Tips and tricks for using wordpress as application platform.
 
Professional Frontend Engineering
Professional Frontend EngineeringProfessional Frontend Engineering
Professional Frontend Engineering
 
High Performance Web Sites - Tips for faster pages
High Performance Web Sites - Tips for faster pagesHigh Performance Web Sites - Tips for faster pages
High Performance Web Sites - Tips for faster pages
 

Similar to Using WordPress as your application stack

Custom post-framworks
Custom post-framworksCustom post-framworks
Custom post-framworks
wcto2017
 
Custom post-framworks
Custom post-framworksCustom post-framworks
Custom post-framworks
Kiera Howe
 
WordPress as the Backbone(.js)
WordPress as the Backbone(.js)WordPress as the Backbone(.js)
WordPress as the Backbone(.js)
Beau Lebens
 
Blog Hacks 2011
Blog Hacks 2011Blog Hacks 2011
Blog Hacks 2011
Yusuke Wada
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the FinishYehuda Katz
 
WordPress and Ajax
WordPress and AjaxWordPress and Ajax
WordPress and Ajax
Ronald Huereca
 
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 developmentTammy Hart
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
Hisateru Tanaka
 
Using and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareUsing and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middleware
Alona Mekhovova
 
WordPress Plugin development
WordPress Plugin developmentWordPress Plugin development
WordPress Plugin development
Mostafa Soufi
 
Caldera Learn - LoopConf WP API + Angular FTW Workshop
Caldera Learn - LoopConf WP API + Angular FTW WorkshopCaldera Learn - LoopConf WP API + Angular FTW Workshop
Caldera Learn - LoopConf WP API + Angular FTW Workshop
CalderaLearn
 
Silex Cheat Sheet
Silex Cheat SheetSilex Cheat Sheet
Silex Cheat Sheet
Andréia Bohner
 
Silex Cheat Sheet
Silex Cheat SheetSilex Cheat Sheet
Silex Cheat Sheet
Andréia Bohner
 
WordPress for developers - phpday 2011
WordPress for developers -  phpday 2011WordPress for developers -  phpday 2011
WordPress for developers - phpday 2011
Maurizio Pelizzone
 
Digging into WordPress custom fields - WordCamp Brno 2017
Digging into WordPress custom fields - WordCamp Brno 2017Digging into WordPress custom fields - WordCamp Brno 2017
Digging into WordPress custom fields - WordCamp Brno 2017
Magdalena Paciorek
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
Bo-Yi Wu
 
Developing Plugins For WordPress
Developing Plugins For WordPressDeveloping Plugins For WordPress
Developing Plugins For WordPress
Lester Chan
 
20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdevFrank Rousseau
 
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 PluginWill Norris
 
Introduction to backbone presentation
Introduction to backbone presentationIntroduction to backbone presentation
Introduction to backbone presentation
Brian Hogg
 

Similar to Using WordPress as your application stack (20)

Custom post-framworks
Custom post-framworksCustom post-framworks
Custom post-framworks
 
Custom post-framworks
Custom post-framworksCustom post-framworks
Custom post-framworks
 
WordPress as the Backbone(.js)
WordPress as the Backbone(.js)WordPress as the Backbone(.js)
WordPress as the Backbone(.js)
 
Blog Hacks 2011
Blog Hacks 2011Blog Hacks 2011
Blog Hacks 2011
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
 
WordPress and Ajax
WordPress and AjaxWordPress and Ajax
WordPress and Ajax
 
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
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
Using and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareUsing and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middleware
 
WordPress Plugin development
WordPress Plugin developmentWordPress Plugin development
WordPress Plugin development
 
Caldera Learn - LoopConf WP API + Angular FTW Workshop
Caldera Learn - LoopConf WP API + Angular FTW WorkshopCaldera Learn - LoopConf WP API + Angular FTW Workshop
Caldera Learn - LoopConf WP API + Angular FTW Workshop
 
Silex Cheat Sheet
Silex Cheat SheetSilex Cheat Sheet
Silex Cheat Sheet
 
Silex Cheat Sheet
Silex Cheat SheetSilex Cheat Sheet
Silex Cheat Sheet
 
WordPress for developers - phpday 2011
WordPress for developers -  phpday 2011WordPress for developers -  phpday 2011
WordPress for developers - phpday 2011
 
Digging into WordPress custom fields - WordCamp Brno 2017
Digging into WordPress custom fields - WordCamp Brno 2017Digging into WordPress custom fields - WordCamp Brno 2017
Digging into WordPress custom fields - WordCamp Brno 2017
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
 
Developing Plugins For WordPress
Developing Plugins For WordPressDeveloping Plugins For WordPress
Developing Plugins For WordPress
 
20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev
 
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
 
Introduction to backbone presentation
Introduction to backbone presentationIntroduction to backbone presentation
Introduction to backbone presentation
 

More from Paul Bearne

WP json api
WP json apiWP json api
WP json api
Paul Bearne
 
Unit tests with vagrant
Unit tests with vagrantUnit tests with vagrant
Unit tests with vagrant
Paul Bearne
 
How To Set a Vagrant Development System
How To Set a Vagrant Development SystemHow To Set a Vagrant Development System
How To Set a Vagrant Development System
Paul Bearne
 
HirshHorn theme: how I created it
HirshHorn theme: how I created itHirshHorn theme: how I created it
HirshHorn theme: how I created it
Paul Bearne
 
WortdPress Child themes: Why and How
WortdPress Child themes: Why and HowWortdPress Child themes: Why and How
WortdPress Child themes: Why and How
Paul Bearne
 
Author Avatars List demo slides
Author Avatars List demo slidesAuthor Avatars List demo slides
Author Avatars List demo slides
Paul Bearne
 

More from Paul Bearne (6)

WP json api
WP json apiWP json api
WP json api
 
Unit tests with vagrant
Unit tests with vagrantUnit tests with vagrant
Unit tests with vagrant
 
How To Set a Vagrant Development System
How To Set a Vagrant Development SystemHow To Set a Vagrant Development System
How To Set a Vagrant Development System
 
HirshHorn theme: how I created it
HirshHorn theme: how I created itHirshHorn theme: how I created it
HirshHorn theme: how I created it
 
WortdPress Child themes: Why and How
WortdPress Child themes: Why and HowWortdPress Child themes: Why and How
WortdPress Child themes: Why and How
 
Author Avatars List demo slides
Author Avatars List demo slidesAuthor Avatars List demo slides
Author Avatars List demo slides
 

Recently uploaded

Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
Srikant77
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Jay Das
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 

Recently uploaded (20)

Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 

Using WordPress as your application stack

  • 1. Using WordPress as your application stack WHY AND HOW
  • 2. @me Senior Full Stack WordPress Developer Plugin author of Author Avatars List http://wordpress.org/plugins/author-avatars/ and WP Site Verification tool http://wordpress.org/plugins/wp-site-verification-tool/ Slides @ http://www.slideshare.net/pbearne
  • 3. Why WordPress? •Stable •Supported •Community •Scales
  • 4. Why not WordPress? •Code debt •PHP •Has PHP global’s •Not sexy
  • 5. 23% OF THE SITES IN WHOLE INTERNET
  • 8. How •Actions and filters •JSON API •jQuery - Backbone •Template hierarchy •Custom post types
  • 9. Filter add_filter(‘fliter_name’, ‘function_to_run’); Function function_to_run( $var ){ $var .= ‘hello world’; return $var; } http://codex.wordpress.org/Plugin_API#Filters
  • 10. Action add_action(‘action_name’, ‘function_to_run’); Function function_to_run( $var = null ){ echo ‘hello world’; } http://codex.wordpress.org/Plugin_API#Actions
  • 11. Ajax Route /** * Register a rewrite endpoint for the API. */ function prefix_add_api_endpoints() { add_rewrite_tag( '%api_item_id%', '([0-9]+)' ); add_rewrite_rule( 'api/items/([0-9]+)/?', 'index.php?api_item_id=$matches[1]', 'top' ); } add_action( 'init', 'prefix_add_api_endpoints' ); https://10up.github.io/Engineering-Best-Practices/php/#ajax-endpoints
  • 12. Ajax handler function prefix_do_api() { global $wp_query; $item_id = $wp_query->get( 'api_item_id' ); if ( ! empty( $item_id ) ) { $response = array(); // Do stuff with $item_id wp_send_json( $response ); } } add_action( 'template_redirect', 'prefix_do_api' );
  • 13. JSON API wordpress.com Part of the Jetpack plug-in http://developer.wordpress.com/docs/api/ https://developer.wordpress.com/docs/api/console/ End point https://public-api.wordpress.com/rest/v1/ e.g. https://public-api. wordpress.com/rest/v1/sites/authoravatars.wordpress.com/
  • 14. JSON API wp.org (self host) Part of next version of core (currently plug-in) http://wp-api.org/ End point https://domain.com/wp-json/
  • 15. JSON API wp-api.org/ v. WP.com WP.com Wp-api.org Caching On you server Little load on your servers Extendable Access to WordPress.com user and stats More complete The API’s don’t match (yet)
  • 16. BackBone Included with WordPress  To just load it wp_enqueue_script( ‘backbone’ ); Or better still load as a dependency of your script wp_enqueue_script( ‘myscript’, ‘path/to/script, array( 'backbone' ) ); https://github.com/tlovett1/_s_backbone
  • 17. Template Hierarchy The order Wordpress load its template files http://codex.wordpress.org/Template_Hierarchy
  • 19. Custom post types The main logical data object in WordPress The standard types are : post, page, media add_action( 'init', 'create_post_type' ); function create_post_type() { register_post_type( 'acme_product', array( 'labels' => array( 'name' => __( 'Products' ), 'singular_name' => __( 'Product' ) ), 'public' => true, 'has_archive' => true, ) ); } http://codex.wordpress.org/Post_Types
  • 20. Custom metadata The data linked to a post object Text or serialized data Use CMB2 to easily create admin forms Hide the metadata from admin by starting the id with an “_” $meta_boxes[ 'tombstone_page_metabox' ] = array( 'id' => __( 'tombstone_page_metabox', Config::get_text_domain() ), 'title' => __( 'Tombstone Details', Config::get_text_domain() ), 'object_types' => array( self::get_tombstone_post_type() ), https://github.com/WebDevStudios/CMB2 // Post types 'context' => 'normal', 'priority' => 'high', 'show_names' => true, // Show field names on the left 'fields' => array( array( 'name' => __( 'Tag line', Config::get_text_domain() ), 'desc' => __( 'Enter the pull Quote', Config::get_text_domain() ), 'id' => Config::_get_prefix() . 'tagline', 'type' => 'textarea_small', 'attributes' => array( 'style' => 'width:100%;', ), ), ) );
  • 21. Call external API and cache Use the internal wp_remote_get() get remote data. Then cache the data with a transients cache or tlc_transient() $request = wp_remote_get('http://example.com'); $response = wp_remote_retrieve_body( $request ); echo $response; <?php // Define your callback (other examples use this) function my_callback() { return wp_remote_retrieve_body( wp_remote_get( 'http://example.com/feed.xml', array( 'timeout' => 30 ) ) ); } // Grab that feed echo $data = tlc_transient( 'example-feed' ) ->updates_with( 'my_callback' ) ->expires_in( 300 ) ->get(); If( false != $data ){ // show data } ?> https://github.com/markjaquith/WP-TLC-Transients