Jonathan Bossenger
Let’s Code
Learn.WordPress.org
Extending the WP REST API - custom routes &
endpoints
2
👋🏽
Welcome!
As you join, please make sure you have your local
development environment ready:
• A local WordPress installation
• A code editor like VSCode or Sublime
• Postman
https://www.postman.com/downloads/
Then, let everyone know in the chat where you’re
joining us from, and something interesting about your
city/state/country…
Hello!
○ My name is Jonathan Bossenger
○ From Cape Town, South Africa
○ Ex-developer turned code instructor
○ Sponsored contributor at Automattic
○ jonathanbossenger.com
Learn.WordPress.org
Let's code!
The WP REST API -
custom routes and
endpoints
Jonathan Bossenger
Announcements
○ Welcome, and thank you to Joshua for co-hosting!
○ We are presenting in focus mode, but please feel free to enable your video.
○ Please let me know if you can’t see my shared screen.
○ You are welcome to ask questions.
○ You are welcome to post questions in the chat, or unmute to ask questions.
Announcements
○ Make sure your local install is ready
• https://www.postman.com/downloads/
○ If I am going too fast, please let me know!
○ We will be posting this session to https://wordpress.tv/ afterwards
○ For more WordPress focused content please visit https://learn.wordpress.org/
○ Follow up questions/feedback - https://github.com/WordPress/Learn/issues/1304
Learning Outcomes
1. Registering a custom WP REST API route
2. Registering different route endpoints
3. How to access WP REST API request data in your custom route
4. Protecting routes/requiring authentication
5. Adding and using path variables on routes
Objectives
1. Create a form submissions REST API plugin
2. Create a custom table to store form submissions
3. Register a custom WP REST API route to fetch submissions
4. Register a custom WP REST API route to post submissions
5. Register a custom WP REST API endpoint to fetch a single submission
7
8
Let’s code.
Resources
○ https://github.com/WordPress/Learn/issues/1304
○ https://www.postman.com/downloads/
○ https://developer.wordpress.org/rest-api/extending-the-rest-api/adding-custom-endpoints/
○ https://developer.wordpress.org/rest-api/extending-the-rest-api/routes-and-endpoints/
○ https://developer.wordpress.org/reference/functions/dbdelta/
○ https://developer.wordpress.org/reference/functions/register_rest_route/
○ https://developer.wordpress.org/reference/functions/register_activation_hook/
○ https://developer.wordpress.org/reference/functions/current_user_can/
○ https://github.com/CastosHQ/Seriously-Simple-Podcasting/tree/master/php/classes/rest

Let's code_ WP REST API - custom routes and endpoints.pptx

  • 1.
    Jonathan Bossenger Let’s Code Learn.WordPress.org Extendingthe WP REST API - custom routes & endpoints
  • 2.
    2 👋🏽 Welcome! As you join,please make sure you have your local development environment ready: • A local WordPress installation • A code editor like VSCode or Sublime • Postman https://www.postman.com/downloads/ Then, let everyone know in the chat where you’re joining us from, and something interesting about your city/state/country… Hello! ○ My name is Jonathan Bossenger ○ From Cape Town, South Africa ○ Ex-developer turned code instructor ○ Sponsored contributor at Automattic ○ jonathanbossenger.com
  • 3.
    Learn.WordPress.org Let's code! The WPREST API - custom routes and endpoints Jonathan Bossenger
  • 4.
    Announcements ○ Welcome, andthank you to Joshua for co-hosting! ○ We are presenting in focus mode, but please feel free to enable your video. ○ Please let me know if you can’t see my shared screen. ○ You are welcome to ask questions. ○ You are welcome to post questions in the chat, or unmute to ask questions.
  • 5.
    Announcements ○ Make sureyour local install is ready • https://www.postman.com/downloads/ ○ If I am going too fast, please let me know! ○ We will be posting this session to https://wordpress.tv/ afterwards ○ For more WordPress focused content please visit https://learn.wordpress.org/ ○ Follow up questions/feedback - https://github.com/WordPress/Learn/issues/1304
  • 6.
    Learning Outcomes 1. Registeringa custom WP REST API route 2. Registering different route endpoints 3. How to access WP REST API request data in your custom route 4. Protecting routes/requiring authentication 5. Adding and using path variables on routes
  • 7.
    Objectives 1. Create aform submissions REST API plugin 2. Create a custom table to store form submissions 3. Register a custom WP REST API route to fetch submissions 4. Register a custom WP REST API route to post submissions 5. Register a custom WP REST API endpoint to fetch a single submission 7
  • 8.
  • 9.
    Resources ○ https://github.com/WordPress/Learn/issues/1304 ○ https://www.postman.com/downloads/ ○https://developer.wordpress.org/rest-api/extending-the-rest-api/adding-custom-endpoints/ ○ https://developer.wordpress.org/rest-api/extending-the-rest-api/routes-and-endpoints/ ○ https://developer.wordpress.org/reference/functions/dbdelta/ ○ https://developer.wordpress.org/reference/functions/register_rest_route/ ○ https://developer.wordpress.org/reference/functions/register_activation_hook/ ○ https://developer.wordpress.org/reference/functions/current_user_can/ ○ https://github.com/CastosHQ/Seriously-Simple-Podcasting/tree/master/php/classes/rest

Editor's Notes

  • #2 TITLE SLIDE: Make a copy of this presentation to your Google Drive, and edit to replace with your details.