Created
October 11, 2014 03:38
-
-
Save CamdenSegal/146534b56be8b6bd684f to your computer and use it in GitHub Desktop.
WP_JSON_CustomPostType Endpoint Generation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MAP_API_DemoItemType extends WP_JSON_CustomPostType { | |
protected $base = '/map/demo'; | |
protected $type = 'demo'; | |
public function register_routes( $routes ) { | |
$routes = parent::register_routes( $routes ); | |
return $routes; | |
} | |
} | |
function map_api_init( $server ) { | |
global $map_api_demoitemtype; | |
$map_api_demoitemtype = new MAP_API_DemoItemType( $server ); | |
add_filter( 'json_endpoints', array( $map_api_demoitemtype, 'register_routes' ) ); | |
} | |
add_action( 'wp_json_server_before_serve', 'map_api_init' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment