Anzeige

Best Practices for creating WP REST API by Galkin Nikita

25. Mar 2016
Anzeige

Más contenido relacionado

Similar a Best Practices for creating WP REST API by Galkin Nikita(20)

Anzeige

Más de WordCamp Kyiv(19)

Anzeige

Best Practices for creating WP REST API by Galkin Nikita

  1. Best Practices for creating WordPress REST API by Galkin Nikita WORDPRESS KITCHEN MEETUP SPRING 2016
  2. Useful links http://v2.wp-api.org https://wordpress.org/plugins/rest-api/ http://raml.org https://www.getpostman.com https://c9.io https://wp-rest-galk-in.c9users.io
  3. Default REST in Wordpress 4.4 Start endpoint http://example.com/wp-json/ Added oembed/1.0/ namespace Off REST API add_filter('rest_enabled', function() {return false;});
  4. Standart REST API { "name": "Example WordPress Site", "namespaces": [ "wp/v2", "oembed/1.0/" ] }
  5. Add route add_action( 'rest_api_init', function () { register_rest_route( 'myplugin/v1', '/example/', array( 'methods' => 'GET', 'callback' => function($request) { return "Hello world!"; }, ) ); } );
  6. Namespace = <plugin|theme>/<version>
  7. Route last part of endpoint
  8. Arguments methods callback permission_callback args default required sanitize_callback
  9. Middleware
  10. ETAG
  11. R A M L
Anzeige