Successfully reported this slideshow.
Your SlideShare is downloading. ×

Practical REST API

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad

Check these out next

1 of 32 Ad
Advertisement

More Related Content

Slideshows for you (20)

Similar to Practical REST API (20)

Advertisement

Recently uploaded (20)

Practical REST API

  1. 1. Practical REST API Why admin-ajax.php should be avoided and how Aki Björklund CTO,H1 @akibjorklund
  2. 2. Communication between JavaScript and PHP is done with Ajax
  3. 3. Historically that is done in WordPress by calling
 /wp-admin/admin-ajax.php
  4. 4. Why admin-ajax.php is bad?
  5. 5. 1. Inefficient
  6. 6. 2. Not cached
  7. 7. 3. No infrastructure like authentication, data validation, …
  8. 8. 4.
 Ad hoc: messy
  9. 9. WordPress REST API in core from 4.4
  10. 10. There are no built-in endpoints yet
  11. 11. Unless you install the REST API plugin
  12. 12. In many cases no need to write any PHP to do a lot.
  13. 13. But what can you do just with what the core already has?
  14. 14. Example: Comment Reactions
  15. 15. Converting admin-ajax.php to REST API
  16. 16. Before
  17. 17. After
  18. 18. Best practice is to implement what you just saw as a REST Controller. Currently available only with the REST API plugin.
  19. 19. Summary
  20. 20. Use the REST API instead of admin-ajax.php
  21. 21. It’s faster and cleaner
  22. 22. It’s also both easy to implement and migrate to
  23. 23. . Aki Björklund CTO,H1 @akibjorklund

×