Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Thanks Rachel Baker for this :)
register_json_route( 'wp', '/comments/(?P<id>[\d]+)', array(
array(
'methods' => WP_JSON_Server::READABLE,
'callback' => array( $controller, 'get_item' ),
'args' => array(
'context' => array(
'default' => 'view',
),
),
),
array(
'methods' => WP_JSON_Server::EDITABLE,
'callback' => array( $controller, 'update_item' ),
'args' => array(
'post_id' => array(),
'status' => array(),
'content' => array(),
'author' => array(),
'author_email' => array(),
'author_url' => array(),
'date' => array(),
),
),
array(
'methods' => WP_JSON_Server::DELETABLE,
'callback' => array( $controller, 'delete_item' ),
'args' => array(
'force' => array(),
),
),
) );
@krogsgard

This comment has been minimized.

Copy link
Owner Author

krogsgard commented Feb 11, 2015

This is a WordPress endpoint, but plugins and themes can register their own, replacing "wp" (which is reserved for core) with something like "plugin/events/v1". And then of course custom arguments for the endpoint.

Also from the team's notes:
Apart from the core routes, routes should be prefixed to avoid overlapping between plugins. The version should be included with the namespace to create a route prefix. The easiest way of achieving this is to require both a namespace and version when defining the routes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.