Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Minor updates to extending docs #88

Merged
merged 1 commit into from

3 participants

@tlovett1

WP_JSON_CustomPostType __construct() requires a param of type WP_JSON_Response. 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.

@tlovett1 tlovett1 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.
c0dc49e
@rachelbaker rachelbaker merged commit 3cd1770 into WP-API:master

1 check failed

Details default The Travis CI build failed
@rmccue rmccue added the Bug label
@rmccue rmccue added this to the 0.9 milestone
@rachelbaker rachelbaker was assigned by rmccue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 24, 2014
  1. @tlovett1

    WP_JSON_CustomPostType __construct() requires a param of type WP_JSON…

    tlovett1 authored
    …_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.
This page is out of date. Refresh to see the latest.
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' );
Something went wrong with that request. Please try again.