@TwitterHandle [change in Slide > Edit Master]
Introduction To VueJS & The
WordPress REST API
Josh Pollock | CalderaLabs.org
@Josh412
CalderaLabs.org
Hi I'm Josh
Founder/ Lead Developer/ Space Astronaut Grade 3:
Caldera Labs
I make WordPress plugins @calderaforms
I teach about WordPress @calderalearn
I wrote a book about the WordPress REST API
I wrote a book about PHP object oriented programing.
I am core contributor to WordPress
I am a member of The WPCrowd @thewpcrowd
@Josh412
What We're Covering Today
A little background on Josh + JavaScript
Frameworks
Why VueJS Is Really Cool
Some Basics On VueJS
Some Things That Are Not So Cool About VueJS
How To Go Further With VueJS
@Josh412
CalderaLearn.com
0.
Josh + VueJS
Didn’t You Talk About Angular Last Year?
@Josh412
CalderaLabs.org
@Josh412
NG1 Is Cool
@Josh412
React and NG2 Are More Than I Need
@Josh412
VueJS Is A Good Balance
@Josh412
CalderaLabs.org
BONUS LINK #1
calderalearn.com/wcmia-js-frameworks
@Josh412
CalderaLearn.com
1.
Why VueJS Is Really Cool
Simple, Reactive, Lightweight
@Josh412
VueJS: Simplicity
Fast Start
Works with ES5
Better with ES6
Reusable Components
Familiar Syntax
HTML(ish) Templates
18kB
@Josh412
Reactive !== ReactJS
@Josh412
Reactive Seems Familiar
VueJS Lifecycle Diagram
vuejs.org/images/lifecycle.png
@Josh412
CalderaLabs.org
@Josh412
We’re Used To
Event-Based Systems
@Josh412
Event-Based Systems
Like WordPress Hooks
@Josh412
VueJS Doesn’t Include But Has Official Packages
HTTP
Router
Flux/ Redux State Manager
@Josh412
CalderaLearn.com
2.
VueJS + WordPress Basics
Enough To Get Started
@Josh412
A Few Notes Before We Look At Code
All of this is ES5
You should use ES6
We’re using jQuery.ajax()
Read the docs for install
Just need one CDN link
@Josh412
CalderaLabs.org
Example One
calderalearn.com/wcmia-example-1
@Josh412
Vue Templates
<div id="post">
<article>
<header>
<h1 class="post-title">
{{post.title.rendered}}
</h1>
</header>
<div class="entry-content">
{{post.content.rendered}}
</div>
</article>
</div>
@Josh412
The Vue Instance
var ex1 = new Vue({
el: '#post',
data: {
post: {
title: {
rendered: 'Hello World!'
},
content: {
rendered: "<p>Welcome to WordPress. This is your first post. Edit or delete it, then start
writing!</p>n",
}
}
}
});
@Josh412
CalderaLabs.org
Example Two
calderalearn.com/wcmia-example-2
@Josh412
Adding AJAX
@Josh412
The Vue Instance
/** You should use wp_localize_script() to provide this data dynamically */
var config = {
api: 'https://calderaforms.com/wp-json/wp/v2/posts/45218',
};
/** GET post and then construct Vue instance with it **/
var ex2;
$.get({
url: config.api
}).success( function(r) {
ex2 = new Vue({
el: '#post',
data: {
post: r
}
});
});
@Josh412
Data Attributes
@Josh412
Vue Templates
<div id="post">
<article>
<header>
<h1 class="post-title">
{{post.title.rendered}}
</h1>
</header>
<div class="entry-content" v-html="post.content.rendered"></div>
</article>
</div>
@Josh412
CalderaLabs.org
Example Three
calderalearn.com/wcmia-example-3
@Josh412
Form Inputs
@Josh412
Vue Templates
<div id="post">
<form v-on:submit.prevent="save">
<div>
<label for="post-title-edit">
Post Title
</label>
<input id="post-title-edit" v-model="post.title.rendered">
</div>
<div>
<label for="post-content-edit">
Post Content
</label>
<textarea id="post-content-edit" v-model="post.content.rendered"></textarea>
</div>
<input type="submit" value="save">
</form>
<article>
<header>
<h1 class="post-title">
{{post.title.rendered}}
</h1>
</header>
<div class="entry-content" v-html="post.content.rendered"></div>
</article>
</div>
@Josh412
Event Handling
https://vuejs.org/v2/guide/events.html
@Josh412
Vue Templates
<div id="post">
<form v-on:submit.prevent="save">
<div>
<label for="post-title-edit">
Post Title
</label>
<input id="post-title-edit" v-model="post.title.rendered">
</div>
<div>
<label for="post-content-edit">
Post Content
</label>
<textarea id="post-content-edit" v-model="post.content.rendered"></textarea>
</div>
<input type="submit" value="save">
</form>
<article>
<header>
<h1 class="post-title">
{{post.title.rendered}}
</h1>
</header>
<div class="entry-content" v-html="post.content.rendered"></div>
</article>
</div>
@Josh412
Methods
@Josh412
The Vue Instance
var ex3;
jQuery.ajax({
url: config.api,
success: function(r) {
ex3 = new Vue({
el: '#post',
data: {
post: r
},
methods: {
save: function(){
var self = this;
$.ajax( {
url: config.api,
method: 'POST',
beforeSend: function ( xhr ) {
xhr.setRequestHeader( 'X-WP-Nonce', config.nonce );
},
data:{
title : self.post.title.rendered,
content: self.post.content.rendered
}
} ).done( function ( response ) {
console.log( response );
} );
}
}
});
}
});
@Josh412
CalderaLabs.org
Example Four
calderalearn.com/wcmia-example-4
@Josh412
Components
Let’s Make Our Code More Reusable!
@Josh412
App HTML
<div id="app">
<post-list></post-list>
</div>
@Josh412
Templates
We Could Have Used A Template Before
@Josh412
Template HTML
<script type="text/html" id="post-list-tmpl">
<div id="posts">
<div v-for="post in posts">
<article v-bind:id="'post-' + post.id">
<header>
<h2 class="post-title">
{{post.title.rendered}}
</h2>
</header>
<div class="entry-content" v-html="post.excerpt.rendered"></div>
</article>
</div>
</div>
</script>
@Josh412
Instantiating
Components
@Josh412
Vue Instance
(function($){
var vue;
$.when( $.get( config.api.posts ) ).then( function( d ){
Vue.component('post-list', {
template: '#post-list-tmpl',
data: function () {
return {
posts: d
}
},
});
vue = new Vue({
el: '#app',
data: { }
});
});
})( jQuery );
@Josh412
Components
Improve code reuse.
Can be shared between vue instances.
The Vue Router can switch components based
on state.
@Josh412
CalderaLearn.com
3.
Downsides To VueJS
It’s Cool But...
@Josh412
VueJS Downsides
Super minimal
Small, but you’re going to need other things
Less popular
Less tutorials
Less developers
Less Packages
Never going to be in WordPress core
@Josh412
CalderaLabs.org
Slides, Links & More:
CalderaLearn.com/wcmia
CalderaLabs.org
Thanks!
JoshPress.net
CalderaLearn.com
CalderaForms.com
CalderaLabs.org
@Josh412
Slides, Links & More:
CalderaLearn.com/wcmia

More Related Content

PDF
WordPress 2017 with VueJS and GraphQL
PPTX
Real World Lessons in Progressive Web Application & Service Worker Caching
PDF
Build your application in seconds and optimize workflow as much as you can us...
PDF
A Debugging Adventure: Journey through Ember.js Glue
PPT
Migraine Drupal - syncing your staging and live sites
PDF
Laravel 8 export data as excel file with example
PDF
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
PDF
Angular js vs. Facebook react
WordPress 2017 with VueJS and GraphQL
Real World Lessons in Progressive Web Application & Service Worker Caching
Build your application in seconds and optimize workflow as much as you can us...
A Debugging Adventure: Journey through Ember.js Glue
Migraine Drupal - syncing your staging and live sites
Laravel 8 export data as excel file with example
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Angular js vs. Facebook react

What's hot (20)

PDF
Choosing a Javascript Framework
PDF
Integrating React.js Into a PHP Application
PDF
[Bristol WordPress] Supercharging WordPress Development
PPT
Grails Connecting to MySQL
PPTX
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
PDF
DrupalGap. How to create native application for mobile devices based on Drupa...
PDF
Parse Apps with Ember.js
PPTX
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
PDF
Writing Software not Code with Cucumber
PDF
How to React Native
PPTX
Rethinking Best Practices
PDF
Enemy of the state
PPTX
Introduction to modern front-end with Vue.js
PDF
Using React with Grails 3
PDF
JS Chicago Meetup 2/23/16 - Redux & Routes
KEY
SproutCore is Awesome - HTML5 Summer DevFest
PDF
Service workers
PDF
From Hacker to Programmer (w/ Webpack, Babel and React)
PDF
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
PDF
The Complementarity of React and Web Components
Choosing a Javascript Framework
Integrating React.js Into a PHP Application
[Bristol WordPress] Supercharging WordPress Development
Grails Connecting to MySQL
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
DrupalGap. How to create native application for mobile devices based on Drupa...
Parse Apps with Ember.js
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
Writing Software not Code with Cucumber
How to React Native
Rethinking Best Practices
Enemy of the state
Introduction to modern front-end with Vue.js
Using React with Grails 3
JS Chicago Meetup 2/23/16 - Redux & Routes
SproutCore is Awesome - HTML5 Summer DevFest
Service workers
From Hacker to Programmer (w/ Webpack, Babel and React)
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
The Complementarity of React and Web Components
Ad

Viewers also liked (15)

PDF
Caldera Learn - LoopConf WP API + Angular FTW Workshop
PDF
Presentación de exhibition en español final 2016 2017 padres
PPTX
Cuadro Comparativo Angustia / Ansiedad
PDF
TITUS 4 - SAVED IN ORDER TO DO GOOD - PS. VETTY GUTIERREZ - 10AM MORNING SERVICE
PPTX
Sistema de gestión de base de datos
PPTX
Ingeniero informático y de sistemas
PPTX
Fecundacion
PPTX
SISTEMAS OPERATIVOS II - SEGURIDAD INFORMATICA
PPTX
Faithfulness &amp; self control
PPTX
Obelis semprún
DOCX
CONVENCION COLECTIVA DEL TRABAJO
DOC
Triada epidemiologica
PDF
Plan anual promotor
PPTX
USF Alumni Association to Guide 11-Day Tour of Ireland
PPTX
Derecho agrario
Caldera Learn - LoopConf WP API + Angular FTW Workshop
Presentación de exhibition en español final 2016 2017 padres
Cuadro Comparativo Angustia / Ansiedad
TITUS 4 - SAVED IN ORDER TO DO GOOD - PS. VETTY GUTIERREZ - 10AM MORNING SERVICE
Sistema de gestión de base de datos
Ingeniero informático y de sistemas
Fecundacion
SISTEMAS OPERATIVOS II - SEGURIDAD INFORMATICA
Faithfulness &amp; self control
Obelis semprún
CONVENCION COLECTIVA DEL TRABAJO
Triada epidemiologica
Plan anual promotor
USF Alumni Association to Guide 11-Day Tour of Ireland
Derecho agrario
Ad

Similar to Introduction to VueJS & The WordPress REST API (20)

PDF
Connecting Content Silos: One CMS, Many Sites With The WordPress REST API
PDF
Using the new WordPress REST API
PDF
Modern JavaScript, without giving up on Rails
PDF
Introduction to the Pods JSON API
PDF
Rails + Webpack
PDF
2014 09 30_sparkling_water_hands_on
PDF
How Bitbucket Pipelines Loads Connect UI Assets Super-fast
PDF
Our Hybrid Future: WordPress As Part of the Stack #WCNYC
PDF
Front End Development for Back End Developers - Devoxx UK 2017
PPTX
20171108 PDN HOL React Basics
PDF
EWD 3 Training Course Part 14: Using Ajax for QEWD Messages
PDF
Web Components v1
PDF
125 고성능 web view-deview 2013 발표 자료_공유용
PDF
Comparing Native Java REST API Frameworks - Seattle JUG 2022
PDF
Idiomatic Gradle Plugin Writing
PDF
Rapid Application Development with WSO2 Platform
PDF
RESTful OSGi middleware for NoSQL databases with Docker
PPT
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
PPTX
WordCamp Montreal 2016 WP-API + React with server rendering
PDF
Building a Single Page Application with VueJS
Connecting Content Silos: One CMS, Many Sites With The WordPress REST API
Using the new WordPress REST API
Modern JavaScript, without giving up on Rails
Introduction to the Pods JSON API
Rails + Webpack
2014 09 30_sparkling_water_hands_on
How Bitbucket Pipelines Loads Connect UI Assets Super-fast
Our Hybrid Future: WordPress As Part of the Stack #WCNYC
Front End Development for Back End Developers - Devoxx UK 2017
20171108 PDN HOL React Basics
EWD 3 Training Course Part 14: Using Ajax for QEWD Messages
Web Components v1
125 고성능 web view-deview 2013 발표 자료_공유용
Comparing Native Java REST API Frameworks - Seattle JUG 2022
Idiomatic Gradle Plugin Writing
Rapid Application Development with WSO2 Platform
RESTful OSGi middleware for NoSQL databases with Docker
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
WordCamp Montreal 2016 WP-API + React with server rendering
Building a Single Page Application with VueJS

More from Caldera Labs (17)

PDF
Slightly Advanced Topics in Gutenberg Development
PDF
Financial Forecasting For WordPress Businesses
PDF
Five Attitudes Stopping You From Building Accessible Wordpress Websites
PDF
Our Hybrid Future: WordPress As Part of the Stack
PDF
Introduction to plugin development
PDF
It all starts with a story
PDF
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
PDF
Introduction to AngularJS For WordPress Developers
PDF
A/B Testing FTW
PDF
Five events in the life of every WordPress request you should know
PDF
Extending the WordPress REST API - Josh Pollock
PDF
WPSessions Composer for WordPress Plugin Development
PDF
Introduction to AJAX In WordPress
PDF
Josh Pollock #wcatl using composer to increase your word press development po...
PDF
Content Marketing With WordPress -- Tallahassee WordPress Meetup
PDF
Writing About WordPress: Helping Yourself, by Helping Others -- WordCamp Orl...
PDF
WordPress Tallahassee Meetup: Turning WordPress Sites Into Web & Mobile Apps
Slightly Advanced Topics in Gutenberg Development
Financial Forecasting For WordPress Businesses
Five Attitudes Stopping You From Building Accessible Wordpress Websites
Our Hybrid Future: WordPress As Part of the Stack
Introduction to plugin development
It all starts with a story
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Introduction to AngularJS For WordPress Developers
A/B Testing FTW
Five events in the life of every WordPress request you should know
Extending the WordPress REST API - Josh Pollock
WPSessions Composer for WordPress Plugin Development
Introduction to AJAX In WordPress
Josh Pollock #wcatl using composer to increase your word press development po...
Content Marketing With WordPress -- Tallahassee WordPress Meetup
Writing About WordPress: Helping Yourself, by Helping Others -- WordCamp Orl...
WordPress Tallahassee Meetup: Turning WordPress Sites Into Web & Mobile Apps

Recently uploaded (20)

PDF
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
PDF
The Dynamic Duo Transforming Financial Accounting Systems Through Modern Expe...
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
PPTX
Matchmaking for JVMs: How to Pick the Perfect GC Partner
PPTX
Weekly report ppt - harsh dattuprasad patel.pptx
PDF
DNT Brochure 2025 – ISV Solutions @ D365
PDF
Website Design Services for Small Businesses.pdf
PPTX
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
PDF
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
DOCX
How to Use SharePoint as an ISO-Compliant Document Management System
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PPTX
MLforCyber_MLDataSetsandFeatures_Presentation.pptx
PPTX
Computer Software - Technology and Livelihood Education
PDF
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
PDF
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
PDF
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
PDF
Introduction to Ragic - #1 No Code Tool For Digitalizing Your Business Proces...
PDF
Guide to Food Delivery App Development.pdf
PDF
Autodesk AutoCAD Crack Free Download 2025
PDF
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
The Dynamic Duo Transforming Financial Accounting Systems Through Modern Expe...
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
Matchmaking for JVMs: How to Pick the Perfect GC Partner
Weekly report ppt - harsh dattuprasad patel.pptx
DNT Brochure 2025 – ISV Solutions @ D365
Website Design Services for Small Businesses.pdf
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
How to Use SharePoint as an ISO-Compliant Document Management System
Advanced SystemCare Ultimate Crack + Portable (2025)
MLforCyber_MLDataSetsandFeatures_Presentation.pptx
Computer Software - Technology and Livelihood Education
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
Introduction to Ragic - #1 No Code Tool For Digitalizing Your Business Proces...
Guide to Food Delivery App Development.pdf
Autodesk AutoCAD Crack Free Download 2025
Top 10 Software Development Trends to Watch in 2025 🚀.pdf

Introduction to VueJS & The WordPress REST API