Completed
Push — add/improve-search-upgrade-mes... ( 2d1617 )
by
unknown
06:46
created

WPCOM_REST_API_V2_Endpoint_Hello::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
class WPCOM_REST_API_V2_Endpoint_Hello {
4
	public function __construct() {
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
			),
14
		) );
15
	}
16
17
	public function get_data( $request ) {
18
		return array( 'hello' => 'world' );
19
	}
20
}
21
22
wpcom_rest_api_v2_load_plugin( 'WPCOM_REST_API_V2_Endpoint_Hello' );
23