NEXT craftinamerica.org. Base setup for headless wordpress https://www.craftinamerica.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cia-end-points.php 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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_routes('posts', true);
  24. });
  25. add_action( 'rest_api_init', function () {
  26. $page_controller = new Make_Endpoint_For('page');
  27. $page_controller->register_routes('pages', true);
  28. });
  29. add_action( 'rest_api_init', function () {
  30. $media_controller = new Make_Endpoint_For('media');
  31. $media_controller->register_routes('media', false);
  32. });
  33. /**
  34. * Craft in America custom post_types
  35. */
  36. add_action( 'rest_api_init', function () {
  37. $media_controller = new Make_Endpoint_For('customtype');
  38. $media_controller->register_routes('custometypes', false);
  39. });