NEXT craftinamerica.org. Base setup for headless wordpress https://www.craftinamerica.org
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

cia-end-points.php 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * Craft in America Custom Endpoints Plugin
  4. *
  5. * @since 1.0.0
  6. * @package cia_endpoints
  7. *
  8. * @wordpress-plugin
  9. * Plugin Name: Craft in America - API Endpoints
  10. * Plugin URI:
  11. * Description: Plugin that adds custom rest interface
  12. * Version: 1.0.0
  13. * Author: TOJ <john@yvvas.com>
  14. */
  15. // If this file is called directly, abort.
  16. if ( ! defined( 'WPINC' ) ) { die; }
  17. require_once('includes/class.make-endpoint.php');
  18. require_once('includes/class.make-sortby.php');
  19. /**
  20. * The standard wordpress post_types
  21. */
  22. add_action( 'rest_api_init', function () {
  23. $post_controller = new Make_Endpoint_For('post');
  24. $post_controller->register_custom_route('posts');
  25. });
  26. add_action( 'rest_api_init', function () {
  27. $page_controller = new Make_Endpoint_For('page');
  28. $page_controller->register_custom_route('pages');
  29. });
  30. add_action( 'rest_api_init', function () {
  31. $media_controller = new Make_Endpoint_For('media');
  32. $media_controller->register_custom_route('media');
  33. });
  34. /**
  35. * Craft in America custom post_types
  36. */
  37. add_action( 'rest_api_init', function () {
  38. $media_controller = new Make_Endpoint_For('episode');
  39. $media_controller->register_custom_route('episodes');
  40. });
  41. add_action( 'rest_api_init', function () {
  42. $media_controller = new Make_Endpoint_For('artist');
  43. $media_controller->register_custom_route('artists');
  44. });
  45. /**
  46. * Craft in America custom sort_types
  47. */
  48. add_action( 'rest_api_init', function () {
  49. $media_controller = new Make_Sort_By('artist', 'by_alpha');
  50. $media_controller->register_custom_route('artists/by-alpha');
  51. $media_controller = new Make_Sort_By('artist', 'by_material');
  52. $media_controller->register_custom_route('artists/by-material');
  53. });