WP REST API: Actionable.co
-
Upload
shawn-hooper -
Category
Internet
-
view
126 -
download
0
Transcript of WP REST API: Actionable.co
Blog - shawnhooper.ca Twitter - @shawnhooper
REST API Case Study: Actionable.co
WordCamp Miami 2017
Shawn Hooper Director of IT, actionable.co
Blog - shawnhooper.ca Twitter - @shawnhooper
Good Afternoon!
I’m Shawn Hooper, the Director of IT at Actionable.co
Being a distributed company, everything we do is in the cloud….
Actionable
Blog - shawnhooper.ca Twitter - @shawnhooper
Our core offering is the Actionable Conversations platform. (NodeJS)
Actionable
Blog - shawnhooper.ca Twitter - @shawnhooper
Our core offering is the Actionable Conversations platform. (NodeJS)
We also have 3 public-facing websites marketing to different audiences (all WordPress).
Actionable
Blog - shawnhooper.ca Twitter - @shawnhooper
Our core offering is the Actionable Conversations platform. (NodeJS)
We also have 3 public-facing websites marketing to different audiences (all WordPress).
Our Intranet is also a WordPress site.
Actionable
Blog - shawnhooper.ca Twitter - @shawnhooper
We also use many 3rd party services w/ APIs:
Teachable (Online Courses) Infusionsoft (CRM)
Zoom (Webinars & Conference Calls) G Suite (Google Apps)
Xero (Accounting)BambooHR (HR Management)
…. and many more
Actionable
Blog - shawnhooper.ca Twitter - @shawnhooper
Actionable Conversations
Learning & Development Platform
Developed in NodeJS
Our learning modules are content.Used the WP REST API to retrieve modules &
avoid making a custom CMS.
Why re-invent the wheel…
Blog - shawnhooper.ca Twitter - @shawnhooper
Modified ‘module’ Custom Post Type endpoint
to return required meta fields with the register_rest_field() function.
Why re-invent the wheel…
Blog - shawnhooper.ca Twitter - @shawnhooper
Modified ‘module’ Custom Post Type endpoint
to return required meta fields with the register_rest_field() function.
Wrote a plugin that added WPML information to this post type, showing current locale, and the locale, post ID and permalink to other available
languages.
Why re-invent the wheel…
Blog - shawnhooper.ca Twitter - @shawnhooper
We have three public facing websites with blogs.
Using the REST API, we retrieve the most recent post from each blog and display them in a widget
on all the sites.
/wp-json/wp/v2/posts/?per_page=1
(Cached for 24 hours)
Linking Between Blogs
Blog - shawnhooper.ca Twitter - @shawnhooper
We no longer use admin-ajax.php to handle AJAX
requests, but REST endpoints instead.
- Better Documented ( wp-json/ )- Code re-use from other sites and apps
(Example: Looking up valid email address)
Goodbye admin-ajax.php
Blog - shawnhooper.ca Twitter - @shawnhooper
Clearing the Cache
The data about our consultant network is maintained in one of our internal databases.
The page is populated using a shortcode.
This is slow.
So I cached it. Forever.
Blog - shawnhooper.ca Twitter - @shawnhooper
Clearing the CacheClear the cache only on data change
Blog - shawnhooper.ca Twitter - @shawnhooper
Problem:
An employee’s manager & HR need to know when a new team member completes their on boarding
courses in Teachable.
Solution:
Use REST API to accept web hooks from Teachable and then interface with Slack and our HRMS.
Teachable Webhooks
Blog - shawnhooper.ca Twitter - @shawnhooper
When an opportunity is marked as Closed-Won in Infusionsoft, we automatically create a record in our accounting software using the WP REST API.
Infusionsoft -> Xero
Blog - shawnhooper.ca Twitter - @shawnhooper
Problem:
User Management of Several Websites without Multisite
Solution:
Use REST API to remotely create user accounts from an admin page on our Intranet.
Bulk User Creation
Blog - shawnhooper.ca Twitter - @shawnhooper
POST /wp/v2/users/
combined with Google Apps Login plugin.
Bulk User Creation
Blog - shawnhooper.ca Twitter - @shawnhooper
You can find these slides, notes and more atshawnhooper.ca
Tweet Me @shawnhooper
WordPress Slack: shooper
Thank You!