summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/hello.php')
-rw-r--r--plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/hello.php40
1 files changed, 31 insertions, 9 deletions
diff --git a/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/hello.php b/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/hello.php
index ff3349b8..6b78e7ce 100644
--- a/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/hello.php
+++ b/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/hello.php
@@ -1,23 +1,45 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * Example of a WP.com endpoint.
+ *
+ * @package automattic/jetpack
+ */
+/**
+ * Example endpoint.
+ */
class WPCOM_REST_API_V2_Endpoint_Hello {
+ /**
+ * Constructor.
+ */
public function __construct() {
add_action( 'rest_api_init', array( $this, 'register_routes' ) );
}
+ /**
+ * Register endpoint route.
+ */
public function register_routes() {
- register_rest_route( 'wpcom/v2', '/hello', array(
+ register_rest_route(
+ 'wpcom/v2',
+ '/hello',
array(
- 'methods' => WP_REST_Server::READABLE,
- 'callback' => array( $this, 'get_data' ),
- 'permission_callback' => '__return_true',
- ),
- ) );
+ array(
+ 'methods' => WP_REST_Server::READABLE,
+ 'callback' => array( $this, 'get_data' ),
+ 'permission_callback' => '__return_true',
+ ),
+ )
+ );
}
- public function get_data( $request ) {
+ /**
+ * Get data in response to the endpoint request.
+ *
+ * @param WP_REST_Request $request API request.
+ */
+ public function get_data( $request ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
return array( 'hello' => 'world' );
}
}
-
wpcom_rest_api_v2_load_plugin( 'WPCOM_REST_API_V2_Endpoint_Hello' );