| @@ 8-16 (lines=9) @@ | ||
| 5 | add_action( 'rest_api_init', array( $this, 'register_routes' ) ); | |
| 6 | } | |
| 7 | ||
| 8 | 	public function register_routes() { | |
| 9 | register_rest_route( 'wpcom/v2', '/hello', array( | |
| 10 | array( | |
| 11 | 'methods' => WP_REST_Server::READABLE, | |
| 12 | 'callback' => array( $this, 'get_data' ), | |
| 13 | 'permission_callback' => '__return_true', | |
| 14 | ), | |
| 15 | ) ); | |
| 16 | } | |
| 17 | ||
| 18 | 	public function get_data( $request ) { | |
| 19 | return array( 'hello' => 'world' ); | |
| @@ 46-56 (lines=11) @@ | ||
| 43 | /** | |
| 44 | * Register the REST endpoint. | |
| 45 | */ | |
| 46 | 	public function register_endpoints() { | |
| 47 | register_rest_route( | |
| 48 | self::REST_BASE, | |
| 49 | '/mocker', | |
| 50 | array( | |
| 51 | 'methods' => WP_REST_Server::READABLE, | |
| 52 | 'callback' => array( $this, 'run' ), | |
| 53 | 'permission_callback' => '__return_true', | |
| 54 | ) | |
| 55 | ); | |
| 56 | } | |
| 57 | ||
| 58 | /** | |
| 59 | * Add submenu item. | |