Browse files

WP_JSON_CustomPostType __construct() requires a param of type WP_JSON…

…_ResponseHandler. This needs to be documented. It's not clear how to write getPost, editPost, getPosts, and newPost methods mentioned in the MyPlugin_API_MyType class: I added a sentence explaining where you could start with these.
  • Loading branch information...
1 parent 306e700 commit c0dc49e8d1c06c214189431e2237866c578c1287 @tlovett1 tlovett1 committed Feb 24, 2014
Showing with 4 additions and 2 deletions.
  1. +4 −2 docs/guides/extending.md
View
6 docs/guides/extending.md
@@ -257,15 +257,17 @@ built-in types, your registration code should look something like this:
// ...
}
+You will need to implement the getPost, editPost, getPosts, and newPost methods within your new class. Take a look at the WP_JSON_Posts class to see examples of how these methods can be written.
+
Alternatively, use the custom post type base class, which will handle the
hooking and more for you:
// main.php
- function myplugin_api_init() {
+ function myplugin_api_init( $server ) {
global $myplugin_api_mytype;
require_once dirname( __FILE__ ) . '/class-myplugin-api-mytype.php';
- $myplugin_api_mytype = new MyPlugin_API_MyType();
+ $myplugin_api_mytype = new MyPlugin_API_MyType( $server );
}
add_action( 'wp_json_server_before_serve', 'myplugin_api_init' );

0 comments on commit c0dc49e

Please sign in to comment.