business-hours.php
4 years ago
class-wpcom-rest-api-v2-endpoint-admin-color.php
2 years ago
class-wpcom-rest-api-v2-endpoint-admin-menu.php
1 year ago
class-wpcom-rest-api-v2-endpoint-ai.php
2 years ago
class-wpcom-rest-api-v2-endpoint-app-media.php
1 year ago
class-wpcom-rest-api-v2-endpoint-block-editor-assets.php
1 year ago
class-wpcom-rest-api-v2-endpoint-blog-stats.php
1 year ago
class-wpcom-rest-api-v2-endpoint-email-preview.php
1 year ago
class-wpcom-rest-api-v2-endpoint-external-media.php
1 year ago
class-wpcom-rest-api-v2-endpoint-following.php
2 years ago
class-wpcom-rest-api-v2-endpoint-goodreads.php
2 years ago
class-wpcom-rest-api-v2-endpoint-google-docs.php
4 years ago
class-wpcom-rest-api-v2-endpoint-instagram-gallery.php
3 years ago
class-wpcom-rest-api-v2-endpoint-mailchimp.php
2 years ago
class-wpcom-rest-api-v2-endpoint-newsletter-categories-list.php
1 year ago
class-wpcom-rest-api-v2-endpoint-newsletter-categories-subscriptions-count.php
1 year ago
class-wpcom-rest-api-v2-endpoint-podcast-player.php
2 years ago
class-wpcom-rest-api-v2-endpoint-profile.php
2 years ago
class-wpcom-rest-api-v2-endpoint-related-posts.php
1 year ago
class-wpcom-rest-api-v2-endpoint-resolve-redirect.php
2 years ago
class-wpcom-rest-api-v2-endpoint-search.php
4 years ago
class-wpcom-rest-api-v2-endpoint-send-email-preview.php
1 year ago
class-wpcom-rest-api-v2-endpoint-template-loader.php
3 years ago
class-wpcom-rest-api-v2-endpoint-top-posts.php
2 years ago
class-wpcom-rest-api-v2-endpoint-transient.php
5 years ago
class-wpcom-rest-api-v3-endpoint-blogging-prompts.php
1 year ago
class-wpcom-rest-api-v3-endpoint-jitm.php
1 year ago
gutenberg-available-extensions.php
2 years ago
hello.php
4 years ago
memberships.php
1 year ago
publicize-connection-test-results.php
1 year ago
service-api-keys.php
2 years ago
sites-posts-featured-media-url.php
2 years ago
subscribers.php
1 year ago
hello.php
46 lines
| 1 | <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 | /** |
| 3 | * Example of a WP.com endpoint. |
| 4 | * |
| 5 | * @package automattic/jetpack |
| 6 | */ |
| 7 | |
| 8 | /** |
| 9 | * Example endpoint. |
| 10 | */ |
| 11 | class WPCOM_REST_API_V2_Endpoint_Hello { |
| 12 | /** |
| 13 | * Constructor. |
| 14 | */ |
| 15 | public function __construct() { |
| 16 | add_action( 'rest_api_init', array( $this, 'register_routes' ) ); |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * Register endpoint route. |
| 21 | */ |
| 22 | public function register_routes() { |
| 23 | register_rest_route( |
| 24 | 'wpcom/v2', |
| 25 | '/hello', |
| 26 | array( |
| 27 | array( |
| 28 | 'methods' => WP_REST_Server::READABLE, |
| 29 | 'callback' => array( $this, 'get_data' ), |
| 30 | 'permission_callback' => '__return_true', |
| 31 | ), |
| 32 | ) |
| 33 | ); |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Get data in response to the endpoint request. |
| 38 | * |
| 39 | * @param WP_REST_Request $request API request. |
| 40 | */ |
| 41 | public function get_data( $request ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
| 42 | return array( 'hello' => 'world' ); |
| 43 | } |
| 44 | } |
| 45 | wpcom_rest_api_v2_load_plugin( 'WPCOM_REST_API_V2_Endpoint_Hello' ); |
| 46 |