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

Move filter registration out of CPT constructor #126

Merged
merged 1 commit into from Apr 6, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/class-wp-json-customposttype.php
Expand Up @@ -38,10 +38,18 @@ public function __construct(WP_JSON_ResponseHandler $server) {
return;
}

parent::__construct($server);
}

/**
* Add actions and filters for the post type
*
* This method should be called after instantiation to automatically add the
* required filters for the post type.
*/
public function register_filters() {
add_filter( 'json_endpoints', array( $this, 'register_routes' ) );
add_filter( 'json_post_type_data', array( $this, 'type_archive_link' ), 10, 2 );

parent::__construct($server);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions plugin.php
Expand Up @@ -51,8 +51,7 @@ function json_api_default_filters($server) {

// Pages
$wp_json_pages = new WP_JSON_Pages($server);
add_filter( 'json_endpoints', array( $wp_json_pages, 'register_routes' ), 1 );
add_filter( 'json_post_type_data', array( $wp_json_pages, 'type_archive_link' ), 10, 2 );
$wp_json_pages->register_filters();

// Media
$wp_json_media = new WP_JSON_Media($server);
Expand Down