Completed
Push — add/core-api-ping ( 2e6549 )
by
unknown
07:30
created

WPCOM_REST_API_V2_Endpoint_Ping::__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_Ping {
4
5
	public function __construct() {
6
		add_action( 'rest_api_init', array( $this, 'register_routes' ) );
7
	}
8
9 View Code Duplication
	public function register_routes() {
10
		register_rest_route( 'wpcom/v2', '/ping', array(
11
			array(
12
				'methods'  => WP_REST_Server::READABLE,
13
				'callback' => array( $this, 'get_data' ),
14
			),
15
		) );
16
	}
17
18
	public function get_data( $request ) {
19
		sleep(3);
20
		return array( 'end' => time() );
21
	}
22
}
23
24
wpcom_rest_api_v2_load_plugin( 'WPCOM_REST_API_V2_Endpoint_Ping' );
25