WP REST API: Actionable.co

download WP REST API: Actionable.co

of 24

  • date post

    05-Apr-2017
  • Category

    Internet

  • view

    104
  • download

    0

Embed Size (px)

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

    http://shawnhooper.cahttp://actionable.co

  • Blog - shawnhooper.ca Twitter - @shawnhooper

    Good Afternoon!

    Im Shawn Hooper, the Director of IT at Actionable.co

    Being a distributed company, everything we do is in the cloud.

    Actionable

    http://shawnhooper.ca

  • Blog - shawnhooper.ca Twitter - @shawnhooper

    Our core offering is the Actionable Conversations platform. (NodeJS)

    Actionable

    http://shawnhooper.ca

  • 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

    http://shawnhooper.ca

  • 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

    http://shawnhooper.ca

  • 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

    http://shawnhooper.ca

  • Blog - shawnhooper.ca Twitter - @shawnhooper

    How we use the REST API

    http://shawnhooper.ca

  • Blog - shawnhooper.ca Twitter - @shawnhooper

    To Manage Content

    http://shawnhooper.ca

  • 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

    http://shawnhooper.ca

  • 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

    http://shawnhooper.ca

  • 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

    http://shawnhooper.ca

  • Blog - shawnhooper.ca Twitter - @shawnhooper

    Linking Between Blogs

    http://shawnhooper.ca

  • 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

    http://shawnhooper.ca

  • 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

    http://shawnhooper.ca

  • Blog - shawnhooper.ca Twitter - @shawnhooper

    To Optimize

    http://shawnhooper.ca

  • Blog - shawnhooper.ca Twitter - @shawnhooper

    Clearing the Cache

    http://shawnhooper.ca

  • 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.

    http://shawnhooper.ca

  • Blog - shawnhooper.ca Twitter - @shawnhooper

    Clearing the CacheClear the cache only on data change

    http://shawnhooper.ca

  • Blog - shawnhooper.ca Twitter - @shawnhooper

    To Automate

    http://shawnhooper.ca

  • Blog - shawnhooper.ca Twitter - @shawnhooper

    Problem:

    An employees 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

    http://shawnhooper.ca

  • 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

    http://shawnhooper.ca

  • 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

    http://shawnhooper.ca

  • Blog - shawnhooper.ca Twitter - @shawnhooper

    POST /wp/v2/users/

    combined with Google Apps Login plugin.

    Bulk User Creation

    http://shawnhooper.ca

  • Blog - shawnhooper.ca Twitter - @shawnhooper

    You can find these slides, notes and more atshawnhooper.ca

    Tweet Me @shawnhooper

    WordPress Slack: shooper

    Thank You!

    http://shawnhooper.ca