Download - WP REST API: Actionable.co
![Page 1: WP REST API: Actionable.co](https://reader031.vdocuments.site/reader031/viewer/2022021507/58e49d091a28abf5428b5625/html5/thumbnails/1.jpg)
Blog - shawnhooper.ca Twitter - @shawnhooper
REST API Case Study: Actionable.co
WordCamp Miami 2017
Shawn Hooper Director of IT, actionable.co
![Page 2: WP REST API: Actionable.co](https://reader031.vdocuments.site/reader031/viewer/2022021507/58e49d091a28abf5428b5625/html5/thumbnails/2.jpg)
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
![Page 3: WP REST API: Actionable.co](https://reader031.vdocuments.site/reader031/viewer/2022021507/58e49d091a28abf5428b5625/html5/thumbnails/3.jpg)
Blog - shawnhooper.ca Twitter - @shawnhooper
Our core offering is the Actionable Conversations platform. (NodeJS)
Actionable
![Page 4: WP REST API: Actionable.co](https://reader031.vdocuments.site/reader031/viewer/2022021507/58e49d091a28abf5428b5625/html5/thumbnails/4.jpg)
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
![Page 5: WP REST API: Actionable.co](https://reader031.vdocuments.site/reader031/viewer/2022021507/58e49d091a28abf5428b5625/html5/thumbnails/5.jpg)
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
![Page 6: WP REST API: Actionable.co](https://reader031.vdocuments.site/reader031/viewer/2022021507/58e49d091a28abf5428b5625/html5/thumbnails/6.jpg)
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
![Page 9: WP REST API: Actionable.co](https://reader031.vdocuments.site/reader031/viewer/2022021507/58e49d091a28abf5428b5625/html5/thumbnails/9.jpg)
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…
![Page 10: WP REST API: Actionable.co](https://reader031.vdocuments.site/reader031/viewer/2022021507/58e49d091a28abf5428b5625/html5/thumbnails/10.jpg)
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…
![Page 11: WP REST API: Actionable.co](https://reader031.vdocuments.site/reader031/viewer/2022021507/58e49d091a28abf5428b5625/html5/thumbnails/11.jpg)
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…
![Page 13: WP REST API: Actionable.co](https://reader031.vdocuments.site/reader031/viewer/2022021507/58e49d091a28abf5428b5625/html5/thumbnails/13.jpg)
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
![Page 14: WP REST API: Actionable.co](https://reader031.vdocuments.site/reader031/viewer/2022021507/58e49d091a28abf5428b5625/html5/thumbnails/14.jpg)
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
![Page 17: WP REST API: Actionable.co](https://reader031.vdocuments.site/reader031/viewer/2022021507/58e49d091a28abf5428b5625/html5/thumbnails/17.jpg)
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.
![Page 18: WP REST API: Actionable.co](https://reader031.vdocuments.site/reader031/viewer/2022021507/58e49d091a28abf5428b5625/html5/thumbnails/18.jpg)
Blog - shawnhooper.ca Twitter - @shawnhooper
Clearing the CacheClear the cache only on data change
![Page 20: WP REST API: Actionable.co](https://reader031.vdocuments.site/reader031/viewer/2022021507/58e49d091a28abf5428b5625/html5/thumbnails/20.jpg)
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
![Page 21: WP REST API: Actionable.co](https://reader031.vdocuments.site/reader031/viewer/2022021507/58e49d091a28abf5428b5625/html5/thumbnails/21.jpg)
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
![Page 22: WP REST API: Actionable.co](https://reader031.vdocuments.site/reader031/viewer/2022021507/58e49d091a28abf5428b5625/html5/thumbnails/22.jpg)
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
![Page 23: WP REST API: Actionable.co](https://reader031.vdocuments.site/reader031/viewer/2022021507/58e49d091a28abf5428b5625/html5/thumbnails/23.jpg)
Blog - shawnhooper.ca Twitter - @shawnhooper
POST /wp/v2/users/
combined with Google Apps Login plugin.
Bulk User Creation
![Page 24: WP REST API: Actionable.co](https://reader031.vdocuments.site/reader031/viewer/2022021507/58e49d091a28abf5428b5625/html5/thumbnails/24.jpg)
Blog - shawnhooper.ca Twitter - @shawnhooper
You can find these slides, notes and more atshawnhooper.ca
Tweet Me @shawnhooper
WordPress Slack: shooper
Thank You!