NEXT craftinamerica.org. Base setup for headless wordpress https://www.craftinamerica.org
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

cia-end-points.php 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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: The test plugin that adds rest functionality
  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. /**
  19. * The standard wordpress post_types
  20. */
  21. add_action( 'rest_api_init', function () {
  22. $post_controller = new Make_Endpoint_For('post');
  23. $post_controller->register_custom_route('posts');
  24. });
  25. add_action( 'rest_api_init', function () {
  26. $page_controller = new Make_Endpoint_For('page');
  27. $page_controller->register_custom_route('pages');
  28. });
  29. add_action( 'rest_api_init', function () {
  30. $media_controller = new Make_Endpoint_For('media');
  31. $media_controller->register_custom_route('media');
  32. });
  33. /**
  34. * Craft in America custom post_types
  35. */
  36. add_action( 'rest_api_init', function () {
  37. $media_controller = new Make_Endpoint_For('episode');
  38. $media_controller->register_custom_route('episodes');
  39. });
  40. add_action( 'rest_api_init', function () {
  41. $media_controller = new Make_Endpoint_For('artist');
  42. $media_controller->register_custom_route('artists');
  43. });