SlideShare a Scribd company logo
1 of 35
Download to read offline
http://jpwp.me/2y 
Using The New 
WordPress REST API 
Josh Pollock - JoshPress.net - @Josh412
Hello World.json
The Universal Connector 
http://xkcd.com/1406/
The WordPress REST API 
A new way to consume and modify data from 
WordPress, using a standards-compliant JSON 
RESTful API--from within WordPress or from 
another application.
Plugin, Feature 
or What? 
Feature as a plugin...
The WordPress REST API 
● Currently under development, totally 
functional. In WordPress core *soon*. 
● For now, its a plugin: 
● Download: 
○ https://wordpress.org/plugins/json-rest-api/ 
● Docs 
○ http://wp-api.org
This Is A Big 
Deal 
WordPress runs over 20% of the internet.
It's Very Easy To 
Use 
Kind of like WordPress:)
Except 
You do not need to know much about 
WordPress To Use It.
Capabilities 
Almost all front-end capabilities of WordPress. 
Super extensible, just like WordPress. 
Adding Custom Routes/ Endpoints Is Easy.
https://speakerdeck.com/rmccue/wcmke2014
Not Yet... 
What About 
Admin?
Authentication 
Follows WordPress' Existing User Capabilities 
● Basic Auth 
○ Testing Only 
● oAuth1 
○ Most secure 
● Public/Secret Key Pair 
○ OK, over HTTPS
Why This Is A Big Deal 
● Quality WordPress developers are in 
demand and expensive. 
● With a little prep work, any front-end 
developer can work on your WordPress, 
REST API-Powered Site.
Why This Is A Big Deal 
Decouple the front-end: 
● Front-end can be on a different server. 
● Front-end can be in a different language.
What Can You Use It For? 
● Make your existing site more interactive 
● Use WordPress as the backend for an app 
● Process forms 
● Integrate your WordPress site with other 
platforms 
● Integrate other platforms 
● Make cool plugins
Not Just For 
Blogs! 
Neither Is WordPress
Pods- Power Tools For WordPress as a CMS.
Custom Content Types 
● Custom Post Types 
● Custom Taxonomies 
● Pods Advanced Content Types 
○ Separate tables
Pods Has A JSON API 
Adds routes to the JSON API For Custom 
Content Types & Fields 
https://github.com/pods-framework/pods-json-api
What Have I Made With It? 
● JP-REST-API-Client - A simple client for creating and updating posts via the WordPress 
REST API via the WordPress HTTP API. 
● Pods JSON API - I added new routes, endpoints and documentation to the add-on to the API 
for Pods. 
● Pods Deploy - A tool for automating the process of moving Pods configurations between 
sites. 
● JP-Tax-Query - A custom endpoint for making tax queries via the REST API. 
● A basic front-end post editor, detailed in this Torque article.
And: Josie, A Starter Single Page App
Routing Via Node/ Express 
var express = require('express'); 
var path = require('path'); 
var server = express(); 
server.use(express.static(__dirname + '/public')); 
server.use(express.static(path.join(__dirname, 'public'))); 
server.get('*', function(req, res){ 
res.sendFile(__dirname + '/public/index.html'); 
}); 
var port = 10001; 
server.listen(port, function() { 
console.log('server listening on port ' + port); 
}); 
https://gist.github.com/Shelob9/460ed491f3a2b2773dac#file-routing-via-node-express-js
Demo Time 
http://jpwp.me/app
Advantages 
● Fast 
● Simple 
● Templating in PHP is less than ideal... 
● Simple code, any front-end dev can work 
with
Disadvantages 
● Some front-end plugins will not work. 
● Two systems, two points of failure, etc...
Basic Code Patterns 
● All examples in JavaScript 
● Will Work In WordPress or Outside of it 
● Skipping PHP Today 
○ https://github.com/Shelob9/jp-wp-api-rest-api-client
Get A Post: AJAX 
$.ajax({ 
type: 'GET', 
url: 'http://example.com/wp-json/posts', 
dataType: 'json', 
success: function(posts){ 
$.each( posts, function(index, post) { 
//do something with each post 
}); 
}, 
error: function(error){ 
console.log(error); 
} 
}); 
https://gist.github.com/Shelob9/460ed491f3a2b2773dac#file-get-post-via-wp-api-js
Get Posts: AJAX 
$.ajax({ 
type: 'GET', 
url: 'http://example.com/wp-json/posts', 
dataType: 'json', 
success: function(posts){ 
$.each( posts, function(index, post) { 
//do something with each post 
}); 
}, 
error: function(error){ 
console.log(error); 
} 
}); 
https://gist.github.com/Shelob9/460ed491f3a2b2773dac#file-get-posts-via-wp-api-js
Parse With Handlebars 
$.ajax({ 
type: 'GET', 
url: 'http://example.com/wp-json/posts', 
dataType: 'json', 
success: function(posts){ 
$.each( posts, function(index, post) { 
var source = $('#posts').html(); 
var template = Handlebars.compile(source); 
var html = template(post); 
}); 
}, 
error: function(error){ 
console.log(error); 
} 
}); 
https://gist.github.com/Shelob9/460ed491f3a2b2773dac#file-get-posts-via-wp-api-handlebars-js
Get All Posts With Tag 
$( '[rel="tag"]' ).click( function( event ) { 
event.preventDefault(); 
var href = this.href; 
if ( href.substr(-1) == '/') { 
href = href.substr( 0, href.length - 1 ); 
} 
var slug = href.split('/').pop(); 
$.ajax({ 
type: 'GET', 
cache: true, 
url: rootURL + '/posts?filter[tag]=' + slug, 
dataType: 'json', 
success: function(posts) { 
var html = '<ul>'; 
$.each( posts, function(index, post ) { 
html += '<li><a href="' + post.link + '">' + post.title + '</a></li>'; 
}); 
html += '</ul>'; 
$('article').append( html); 
} 
}); 
}); 
https://gist.github.com/Shelob9/460ed491f3a2b2773dac#file-all-posts-with-tag-js
Backbone Based JS Client 
https://github.com/WP-API/client-js
JS Client Example: Users 
function loadUsers ( users, container, templateID ) { 
$.each(users, function( i, val ) { 
var user = new wp.api.models.User( { ID: val } ); 
user.fetch().done(function () { 
loadUser( user, container, templateID ); 
}); 
}); 
} 
function loadUser( user, container, templateID ) { 
var name = user.attributes.name; 
var avatar = user.attributes.avatar; 
var ID = user.attributes.ID; 
var source = $( templateID ).html(); 
var data = { 
name: name, 
avatar: avatar, 
ID: ID 
}; 
var template = Handlebars.compile( source ); 
var html = template( data ); 
$( container ).append( html ); 
} 
https://gist.github.com/Shelob9/460ed491f3a2b2773dac#file-users-js
Learn More 
Read My Articles In Torque 
Come To The Tallahassee WordPress Meetup: 
Turning WordPress Sites Into Web & Mobile 
Apps Thursday, November 13, 2014 @ Domi
Josh@JoshPress.net - @Josh412 
Questions? 
Slides and info: http://jpwp.me/2y

More Related Content

What's hot

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 othersYusuke Wada
 
Undercover Pods / WP Functions
Undercover Pods / WP FunctionsUndercover Pods / WP Functions
Undercover Pods / WP Functionspodsframework
 
Introduction to the Pods JSON API
Introduction to the Pods JSON APIIntroduction to the Pods JSON API
Introduction to the Pods JSON APIpodsframework
 
Slim RedBeanPHP and Knockout
Slim RedBeanPHP and KnockoutSlim RedBeanPHP and Knockout
Slim RedBeanPHP and KnockoutVic Metcalfe
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Elena Kolevska
 
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 frameworkJeremy Kendall
 
Head First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & ApplicationHead First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & ApplicationJace Ju
 
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
 
Introduction To Lamp
Introduction To LampIntroduction To Lamp
Introduction To LampAmzad Hossain
 
Codeigniter : Using Third Party Components - Zend Framework Components
Codeigniter : Using Third Party Components - Zend Framework ComponentsCodeigniter : Using Third Party Components - Zend Framework Components
Codeigniter : Using Third Party Components - Zend Framework ComponentsAbdul Malik Ikhsan
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworksdiego_k
 
AngularJS with Slim PHP Micro Framework
AngularJS with Slim PHP Micro FrameworkAngularJS with Slim PHP Micro Framework
AngularJS with Slim PHP Micro FrameworkBackand Cohen
 

What's hot (20)

RESTful web services
RESTful web servicesRESTful web services
RESTful web services
 
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
 
Undercover Pods / WP Functions
Undercover Pods / WP FunctionsUndercover Pods / WP Functions
Undercover Pods / WP Functions
 
Developing apps using Perl
Developing apps using PerlDeveloping apps using Perl
Developing apps using Perl
 
Mojolicious
MojoliciousMojolicious
Mojolicious
 
Introduction to the Pods JSON API
Introduction to the Pods JSON APIIntroduction to the Pods JSON API
Introduction to the Pods JSON API
 
Slim RedBeanPHP and Knockout
Slim RedBeanPHP and KnockoutSlim RedBeanPHP and Knockout
Slim RedBeanPHP and Knockout
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5
 
Zend framework
Zend frameworkZend framework
Zend framework
 
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
 
Head First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & ApplicationHead First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & Application
 
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
 
Phinx talk
Phinx talkPhinx talk
Phinx talk
 
4.2 PHP Function
4.2 PHP Function4.2 PHP Function
4.2 PHP Function
 
Mojo as a_client
Mojo as a_clientMojo as a_client
Mojo as a_client
 
Introduction To Lamp
Introduction To LampIntroduction To Lamp
Introduction To Lamp
 
Codeigniter : Using Third Party Components - Zend Framework Components
Codeigniter : Using Third Party Components - Zend Framework ComponentsCodeigniter : Using Third Party Components - Zend Framework Components
Codeigniter : Using Third Party Components - Zend Framework Components
 
Rest api with Python
Rest api with PythonRest api with Python
Rest api with Python
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworks
 
AngularJS with Slim PHP Micro Framework
AngularJS with Slim PHP Micro FrameworkAngularJS with Slim PHP Micro Framework
AngularJS with Slim PHP Micro Framework
 

Viewers also liked

Composer による依存管理 と Packagist によるライブラリの公開
Composer による依存管理 と Packagist によるライブラリの公開Composer による依存管理 と Packagist によるライブラリの公開
Composer による依存管理 と Packagist によるライブラリの公開Shogo Kawahara
 
Agile Data Rationalization for Operational Intelligence
Agile Data Rationalization for Operational IntelligenceAgile Data Rationalization for Operational Intelligence
Agile Data Rationalization for Operational IntelligenceInside Analysis
 
WordPress REST API: Expert Advice & Practical Use Cases
WordPress REST API: Expert Advice & Practical Use CasesWordPress REST API: Expert Advice & Practical Use Cases
WordPress REST API: Expert Advice & Practical Use CasesPantheon
 
Photography for Websites
Photography for WebsitesPhotography for Websites
Photography for WebsitesScott Fisk
 
Typography: The Backbone of Your Website
Typography: The Backbone of Your WebsiteTypography: The Backbone of Your Website
Typography: The Backbone of Your WebsiteAlison Chandler
 
新標準PSRに学ぶきれいなPHP
新標準PSRに学ぶきれいなPHP新標準PSRに学ぶきれいなPHP
新標準PSRに学ぶきれいなPHPYusuke Ando
 

Viewers also liked (6)

Composer による依存管理 と Packagist によるライブラリの公開
Composer による依存管理 と Packagist によるライブラリの公開Composer による依存管理 と Packagist によるライブラリの公開
Composer による依存管理 と Packagist によるライブラリの公開
 
Agile Data Rationalization for Operational Intelligence
Agile Data Rationalization for Operational IntelligenceAgile Data Rationalization for Operational Intelligence
Agile Data Rationalization for Operational Intelligence
 
WordPress REST API: Expert Advice & Practical Use Cases
WordPress REST API: Expert Advice & Practical Use CasesWordPress REST API: Expert Advice & Practical Use Cases
WordPress REST API: Expert Advice & Practical Use Cases
 
Photography for Websites
Photography for WebsitesPhotography for Websites
Photography for Websites
 
Typography: The Backbone of Your Website
Typography: The Backbone of Your WebsiteTypography: The Backbone of Your Website
Typography: The Backbone of Your Website
 
新標準PSRに学ぶきれいなPHP
新標準PSRに学ぶきれいなPHP新標準PSRに学ぶきれいなPHP
新標準PSRに学ぶきれいなPHP
 

Similar to Using the new WordPress REST API

WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!Evan Mullins
 
Plugin development demystified 2017
Plugin development demystified 2017Plugin development demystified 2017
Plugin development demystified 2017ylefebvre
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.pptWalaSidhom1
 
WordPress and Client Side Web Applications WCTO
WordPress and Client Side Web Applications WCTOWordPress and Client Side Web Applications WCTO
WordPress and Client Side Web Applications WCTORoy Sivan
 
The future of server side JavaScript
The future of server side JavaScriptThe future of server side JavaScript
The future of server side JavaScriptOleg Podsechin
 
Single Page Web Applications with WordPress REST API
Single Page Web Applications with WordPress REST APISingle Page Web Applications with WordPress REST API
Single Page Web Applications with WordPress REST APITejaswini Deshpande
 
Wordcamp Toronto Presentation
Wordcamp Toronto PresentationWordcamp Toronto Presentation
Wordcamp Toronto PresentationRoy Sivan
 
Nodejs first class
Nodejs first classNodejs first class
Nodejs first classFin Chen
 
Pywps a tutorial for beginners and developers
Pywps a tutorial for beginners and developersPywps a tutorial for beginners and developers
Pywps a tutorial for beginners and developersJorge Mendes
 
An Overview of Node.js
An Overview of Node.jsAn Overview of Node.js
An Overview of Node.jsAyush Mishra
 
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...King Foo
 
5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY
5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY
5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTYWilliam Chong
 
How and why i roll my own node.js framework
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js frameworkBen Lin
 
Make the Web 3D
Make the Web 3DMake the Web 3D
Make the Web 3DAdam Nagy
 
WordPress APIs
WordPress APIsWordPress APIs
WordPress APIsmdawaffe
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryTatsuhiko Miyagawa
 

Similar to Using the new WordPress REST API (20)

WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
 
Plugin development demystified 2017
Plugin development demystified 2017Plugin development demystified 2017
Plugin development demystified 2017
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.ppt
 
NodeJS
NodeJSNodeJS
NodeJS
 
WordPress and Client Side Web Applications WCTO
WordPress and Client Side Web Applications WCTOWordPress and Client Side Web Applications WCTO
WordPress and Client Side Web Applications WCTO
 
The future of server side JavaScript
The future of server side JavaScriptThe future of server side JavaScript
The future of server side JavaScript
 
Single Page Web Applications with WordPress REST API
Single Page Web Applications with WordPress REST APISingle Page Web Applications with WordPress REST API
Single Page Web Applications with WordPress REST API
 
Wordcamp Toronto Presentation
Wordcamp Toronto PresentationWordcamp Toronto Presentation
Wordcamp Toronto Presentation
 
Nodejs first class
Nodejs first classNodejs first class
Nodejs first class
 
Pywps a tutorial for beginners and developers
Pywps a tutorial for beginners and developersPywps a tutorial for beginners and developers
Pywps a tutorial for beginners and developers
 
An Overview of Node.js
An Overview of Node.jsAn Overview of Node.js
An Overview of Node.js
 
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
 
Crafting APIs
Crafting APIsCrafting APIs
Crafting APIs
 
5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY
5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY
5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY
 
How and why i roll my own node.js framework
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js framework
 
PHP Development Tools
PHP  Development ToolsPHP  Development Tools
PHP Development Tools
 
Make the Web 3D
Make the Web 3DMake the Web 3D
Make the Web 3D
 
WordPress APIs
WordPress APIsWordPress APIs
WordPress APIs
 
Switch to Backend 2023
Switch to Backend 2023Switch to Backend 2023
Switch to Backend 2023
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
 

More from Caldera Labs

Slightly Advanced Topics in Gutenberg Development
Slightly Advanced Topics in Gutenberg Development Slightly Advanced Topics in Gutenberg Development
Slightly Advanced Topics in Gutenberg Development Caldera Labs
 
Financial Forecasting For WordPress Businesses
Financial Forecasting For WordPress BusinessesFinancial Forecasting For WordPress Businesses
Financial Forecasting For WordPress BusinessesCaldera Labs
 
Five Attitudes Stopping You From Building Accessible Wordpress Websites
Five Attitudes Stopping You From Building Accessible Wordpress WebsitesFive Attitudes Stopping You From Building Accessible Wordpress Websites
Five Attitudes Stopping You From Building Accessible Wordpress WebsitesCaldera Labs
 
Our Hybrid Future: WordPress As Part of the Stack #WCNYC
Our Hybrid Future: WordPress As Part of the Stack #WCNYCOur Hybrid Future: WordPress As Part of the Stack #WCNYC
Our Hybrid Future: WordPress As Part of the Stack #WCNYCCaldera Labs
 
Our Hybrid Future: WordPress As Part of the Stack
Our Hybrid Future: WordPress As Part of the StackOur Hybrid Future: WordPress As Part of the Stack
Our Hybrid Future: WordPress As Part of the StackCaldera Labs
 
Introduction to VueJS & The WordPress REST API
Introduction to VueJS & The WordPress REST APIIntroduction to VueJS & The WordPress REST API
Introduction to VueJS & The WordPress REST APICaldera Labs
 
Introduction to plugin development
Introduction to plugin developmentIntroduction to plugin development
Introduction to plugin developmentCaldera Labs
 
It all starts with a story
It all starts with a storyIt all starts with a story
It all starts with a storyCaldera Labs
 
Five events in the life of every WordPress request you should know
Five events in the life of every WordPress request you should knowFive events in the life of every WordPress request you should know
Five events in the life of every WordPress request you should knowCaldera Labs
 
WPSessions Composer for WordPress Plugin Development
WPSessions Composer for WordPress Plugin DevelopmentWPSessions Composer for WordPress Plugin Development
WPSessions Composer for WordPress Plugin DevelopmentCaldera Labs
 
Introduction to AJAX In WordPress
Introduction to AJAX In WordPressIntroduction to AJAX In WordPress
Introduction to AJAX In WordPressCaldera Labs
 
Josh Pollock #wcatl using composer to increase your word press development po...
Josh Pollock #wcatl using composer to increase your word press development po...Josh Pollock #wcatl using composer to increase your word press development po...
Josh Pollock #wcatl using composer to increase your word press development po...Caldera Labs
 
Content Marketing With WordPress -- Tallahassee WordPress Meetup
Content Marketing With WordPress -- Tallahassee WordPress MeetupContent Marketing With WordPress -- Tallahassee WordPress Meetup
Content Marketing With WordPress -- Tallahassee WordPress MeetupCaldera Labs
 
Writing About WordPress: Helping Yourself, by Helping Others -- WordCamp Orl...
Writing About WordPress: Helping Yourself, by Helping Others -- WordCamp Orl...Writing About WordPress: Helping Yourself, by Helping Others -- WordCamp Orl...
Writing About WordPress: Helping Yourself, by Helping Others -- WordCamp Orl...Caldera Labs
 
WordPress Tallahassee Meetup: Turning WordPress Sites Into Web & Mobile Apps
WordPress Tallahassee Meetup: Turning WordPress Sites Into Web & Mobile AppsWordPress Tallahassee Meetup: Turning WordPress Sites Into Web & Mobile Apps
WordPress Tallahassee Meetup: Turning WordPress Sites Into Web & Mobile AppsCaldera Labs
 

More from Caldera Labs (16)

Slightly Advanced Topics in Gutenberg Development
Slightly Advanced Topics in Gutenberg Development Slightly Advanced Topics in Gutenberg Development
Slightly Advanced Topics in Gutenberg Development
 
Financial Forecasting For WordPress Businesses
Financial Forecasting For WordPress BusinessesFinancial Forecasting For WordPress Businesses
Financial Forecasting For WordPress Businesses
 
Five Attitudes Stopping You From Building Accessible Wordpress Websites
Five Attitudes Stopping You From Building Accessible Wordpress WebsitesFive Attitudes Stopping You From Building Accessible Wordpress Websites
Five Attitudes Stopping You From Building Accessible Wordpress Websites
 
Our Hybrid Future: WordPress As Part of the Stack #WCNYC
Our Hybrid Future: WordPress As Part of the Stack #WCNYCOur Hybrid Future: WordPress As Part of the Stack #WCNYC
Our Hybrid Future: WordPress As Part of the Stack #WCNYC
 
Our Hybrid Future: WordPress As Part of the Stack
Our Hybrid Future: WordPress As Part of the StackOur Hybrid Future: WordPress As Part of the Stack
Our Hybrid Future: WordPress As Part of the Stack
 
Introduction to VueJS & The WordPress REST API
Introduction to VueJS & The WordPress REST APIIntroduction to VueJS & The WordPress REST API
Introduction to VueJS & The WordPress REST API
 
Introduction to plugin development
Introduction to plugin developmentIntroduction to plugin development
Introduction to plugin development
 
It all starts with a story
It all starts with a storyIt all starts with a story
It all starts with a story
 
A/B Testing FTW
A/B Testing FTWA/B Testing FTW
A/B Testing FTW
 
Five events in the life of every WordPress request you should know
Five events in the life of every WordPress request you should knowFive events in the life of every WordPress request you should know
Five events in the life of every WordPress request you should know
 
WPSessions Composer for WordPress Plugin Development
WPSessions Composer for WordPress Plugin DevelopmentWPSessions Composer for WordPress Plugin Development
WPSessions Composer for WordPress Plugin Development
 
Introduction to AJAX In WordPress
Introduction to AJAX In WordPressIntroduction to AJAX In WordPress
Introduction to AJAX In WordPress
 
Josh Pollock #wcatl using composer to increase your word press development po...
Josh Pollock #wcatl using composer to increase your word press development po...Josh Pollock #wcatl using composer to increase your word press development po...
Josh Pollock #wcatl using composer to increase your word press development po...
 
Content Marketing With WordPress -- Tallahassee WordPress Meetup
Content Marketing With WordPress -- Tallahassee WordPress MeetupContent Marketing With WordPress -- Tallahassee WordPress Meetup
Content Marketing With WordPress -- Tallahassee WordPress Meetup
 
Writing About WordPress: Helping Yourself, by Helping Others -- WordCamp Orl...
Writing About WordPress: Helping Yourself, by Helping Others -- WordCamp Orl...Writing About WordPress: Helping Yourself, by Helping Others -- WordCamp Orl...
Writing About WordPress: Helping Yourself, by Helping Others -- WordCamp Orl...
 
WordPress Tallahassee Meetup: Turning WordPress Sites Into Web & Mobile Apps
WordPress Tallahassee Meetup: Turning WordPress Sites Into Web & Mobile AppsWordPress Tallahassee Meetup: Turning WordPress Sites Into Web & Mobile Apps
WordPress Tallahassee Meetup: Turning WordPress Sites Into Web & Mobile Apps
 

Recently uploaded

( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...nilamkumrai
 
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...SUHANI PANDEY
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"growthgrids
 
Real Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts ServiceReal Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts ServiceEscorts Call Girls
 
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...Escorts Call Girls
 
Microsoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftMicrosoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftAanSulistiyo
 
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdfMatthew Sinclair
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableSeo
 
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Delhi Call girls
 
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...nirzagarg
 
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...roncy bisnoi
 
Al Barsha Night Partner +0567686026 Call Girls Dubai
Al Barsha Night Partner +0567686026 Call Girls  DubaiAl Barsha Night Partner +0567686026 Call Girls  Dubai
Al Barsha Night Partner +0567686026 Call Girls DubaiEscorts Call Girls
 
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdfMatthew Sinclair
 
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...SUHANI PANDEY
 
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...SUHANI PANDEY
 

Recently uploaded (20)

6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
 
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
 
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
 
Real Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts ServiceReal Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts Service
 
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
 
Microsoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftMicrosoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck Microsoft
 
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
 
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
 
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
 
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
 
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
 
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
 
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
 
Al Barsha Night Partner +0567686026 Call Girls Dubai
Al Barsha Night Partner +0567686026 Call Girls  DubaiAl Barsha Night Partner +0567686026 Call Girls  Dubai
Al Barsha Night Partner +0567686026 Call Girls Dubai
 
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
 
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
 
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
 

Using the new WordPress REST API

  • 1. http://jpwp.me/2y Using The New WordPress REST API Josh Pollock - JoshPress.net - @Josh412
  • 3. The Universal Connector http://xkcd.com/1406/
  • 4. The WordPress REST API A new way to consume and modify data from WordPress, using a standards-compliant JSON RESTful API--from within WordPress or from another application.
  • 5. Plugin, Feature or What? Feature as a plugin...
  • 6. The WordPress REST API ● Currently under development, totally functional. In WordPress core *soon*. ● For now, its a plugin: ● Download: ○ https://wordpress.org/plugins/json-rest-api/ ● Docs ○ http://wp-api.org
  • 7. This Is A Big Deal WordPress runs over 20% of the internet.
  • 8. It's Very Easy To Use Kind of like WordPress:)
  • 9. Except You do not need to know much about WordPress To Use It.
  • 10. Capabilities Almost all front-end capabilities of WordPress. Super extensible, just like WordPress. Adding Custom Routes/ Endpoints Is Easy.
  • 12. Not Yet... What About Admin?
  • 13. Authentication Follows WordPress' Existing User Capabilities ● Basic Auth ○ Testing Only ● oAuth1 ○ Most secure ● Public/Secret Key Pair ○ OK, over HTTPS
  • 14. Why This Is A Big Deal ● Quality WordPress developers are in demand and expensive. ● With a little prep work, any front-end developer can work on your WordPress, REST API-Powered Site.
  • 15. Why This Is A Big Deal Decouple the front-end: ● Front-end can be on a different server. ● Front-end can be in a different language.
  • 16. What Can You Use It For? ● Make your existing site more interactive ● Use WordPress as the backend for an app ● Process forms ● Integrate your WordPress site with other platforms ● Integrate other platforms ● Make cool plugins
  • 17. Not Just For Blogs! Neither Is WordPress
  • 18. Pods- Power Tools For WordPress as a CMS.
  • 19. Custom Content Types ● Custom Post Types ● Custom Taxonomies ● Pods Advanced Content Types ○ Separate tables
  • 20. Pods Has A JSON API Adds routes to the JSON API For Custom Content Types & Fields https://github.com/pods-framework/pods-json-api
  • 21. What Have I Made With It? ● JP-REST-API-Client - A simple client for creating and updating posts via the WordPress REST API via the WordPress HTTP API. ● Pods JSON API - I added new routes, endpoints and documentation to the add-on to the API for Pods. ● Pods Deploy - A tool for automating the process of moving Pods configurations between sites. ● JP-Tax-Query - A custom endpoint for making tax queries via the REST API. ● A basic front-end post editor, detailed in this Torque article.
  • 22. And: Josie, A Starter Single Page App
  • 23. Routing Via Node/ Express var express = require('express'); var path = require('path'); var server = express(); server.use(express.static(__dirname + '/public')); server.use(express.static(path.join(__dirname, 'public'))); server.get('*', function(req, res){ res.sendFile(__dirname + '/public/index.html'); }); var port = 10001; server.listen(port, function() { console.log('server listening on port ' + port); }); https://gist.github.com/Shelob9/460ed491f3a2b2773dac#file-routing-via-node-express-js
  • 25. Advantages ● Fast ● Simple ● Templating in PHP is less than ideal... ● Simple code, any front-end dev can work with
  • 26. Disadvantages ● Some front-end plugins will not work. ● Two systems, two points of failure, etc...
  • 27. Basic Code Patterns ● All examples in JavaScript ● Will Work In WordPress or Outside of it ● Skipping PHP Today ○ https://github.com/Shelob9/jp-wp-api-rest-api-client
  • 28. Get A Post: AJAX $.ajax({ type: 'GET', url: 'http://example.com/wp-json/posts', dataType: 'json', success: function(posts){ $.each( posts, function(index, post) { //do something with each post }); }, error: function(error){ console.log(error); } }); https://gist.github.com/Shelob9/460ed491f3a2b2773dac#file-get-post-via-wp-api-js
  • 29. Get Posts: AJAX $.ajax({ type: 'GET', url: 'http://example.com/wp-json/posts', dataType: 'json', success: function(posts){ $.each( posts, function(index, post) { //do something with each post }); }, error: function(error){ console.log(error); } }); https://gist.github.com/Shelob9/460ed491f3a2b2773dac#file-get-posts-via-wp-api-js
  • 30. Parse With Handlebars $.ajax({ type: 'GET', url: 'http://example.com/wp-json/posts', dataType: 'json', success: function(posts){ $.each( posts, function(index, post) { var source = $('#posts').html(); var template = Handlebars.compile(source); var html = template(post); }); }, error: function(error){ console.log(error); } }); https://gist.github.com/Shelob9/460ed491f3a2b2773dac#file-get-posts-via-wp-api-handlebars-js
  • 31. Get All Posts With Tag $( '[rel="tag"]' ).click( function( event ) { event.preventDefault(); var href = this.href; if ( href.substr(-1) == '/') { href = href.substr( 0, href.length - 1 ); } var slug = href.split('/').pop(); $.ajax({ type: 'GET', cache: true, url: rootURL + '/posts?filter[tag]=' + slug, dataType: 'json', success: function(posts) { var html = '<ul>'; $.each( posts, function(index, post ) { html += '<li><a href="' + post.link + '">' + post.title + '</a></li>'; }); html += '</ul>'; $('article').append( html); } }); }); https://gist.github.com/Shelob9/460ed491f3a2b2773dac#file-all-posts-with-tag-js
  • 32. Backbone Based JS Client https://github.com/WP-API/client-js
  • 33. JS Client Example: Users function loadUsers ( users, container, templateID ) { $.each(users, function( i, val ) { var user = new wp.api.models.User( { ID: val } ); user.fetch().done(function () { loadUser( user, container, templateID ); }); }); } function loadUser( user, container, templateID ) { var name = user.attributes.name; var avatar = user.attributes.avatar; var ID = user.attributes.ID; var source = $( templateID ).html(); var data = { name: name, avatar: avatar, ID: ID }; var template = Handlebars.compile( source ); var html = template( data ); $( container ).append( html ); } https://gist.github.com/Shelob9/460ed491f3a2b2773dac#file-users-js
  • 34. Learn More Read My Articles In Torque Come To The Tallahassee WordPress Meetup: Turning WordPress Sites Into Web & Mobile Apps Thursday, November 13, 2014 @ Domi
  • 35. Josh@JoshPress.net - @Josh412 Questions? Slides and info: http://jpwp.me/2y