Skip to content
This repository has been archived by the owner on Sep 24, 2018. It is now read-only.

Minor updates to extending docs #88

Merged
merged 1 commit into from
Feb 24, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/guides/extending.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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 Alternatively, use the custom post type base class, which will handle the
hooking and more for you: hooking and more for you:


// main.php // main.php
function myplugin_api_init() { function myplugin_api_init( $server ) {
global $myplugin_api_mytype; global $myplugin_api_mytype;


require_once dirname( __FILE__ ) . '/class-myplugin-api-mytype.php'; 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' ); add_action( 'wp_json_server_before_serve', 'myplugin_api_init' );


Expand Down