Last active
December 29, 2015 22:27
-
-
Save JordanForeman/04875a7d44049c12146e to your computer and use it in GitHub Desktop.
Extending WP API - Code Sample 2
This file contains hidden or 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
| 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