Skip to content

Instantly share code, notes, and snippets.

@JordanForeman
Last active December 29, 2015 22:27
Show Gist options
  • Select an option

  • Save JordanForeman/04875a7d44049c12146e to your computer and use it in GitHub Desktop.

Select an option

Save JordanForeman/04875a7d44049c12146e to your computer and use it in GitHub Desktop.
Extending WP API - Code Sample 2
namespace HM\REST_API;
class REST_API {
public function __construct() {
add_action('rest_api_init', array($this, 'register_routes'));
}
public function register_routes() {
$api_namespace = 'hm/v1';
// Register our first endpoint
register_rest_route(
$api_namespace,
'/user',
array(
'methods' => 'GET',
'callback' => array($this, 'get_user_callback')
)
);
}
}
new REST_API();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment