business-hours.php
7 months ago
class-wpcom-rest-api-v2-endpoint-admin-bar.php
2 months ago
class-wpcom-rest-api-v2-endpoint-admin-color.php
7 months ago
class-wpcom-rest-api-v2-endpoint-admin-menu.php
1 month ago
class-wpcom-rest-api-v2-endpoint-agent-guidelines-ai.php
1 week ago
class-wpcom-rest-api-v2-endpoint-ai.php
1 week ago
class-wpcom-rest-api-v2-endpoint-app-media.php
7 months ago
class-wpcom-rest-api-v2-endpoint-application-password-extras.php
3 months ago
class-wpcom-rest-api-v2-endpoint-block-editor-assets.php
2 weeks ago
class-wpcom-rest-api-v2-endpoint-blog-stats.php
7 months ago
class-wpcom-rest-api-v2-endpoint-email-preview.php
2 months ago
class-wpcom-rest-api-v2-endpoint-external-media.php
7 months ago
class-wpcom-rest-api-v2-endpoint-following.php
7 months ago
class-wpcom-rest-api-v2-endpoint-goodreads.php
7 months ago
class-wpcom-rest-api-v2-endpoint-google-docs.php
7 months ago
class-wpcom-rest-api-v2-endpoint-guidelines-banner-dismissed.php
1 week ago
class-wpcom-rest-api-v2-endpoint-instagram-gallery.php
2 months ago
class-wpcom-rest-api-v2-endpoint-mailchimp.php
7 months ago
class-wpcom-rest-api-v2-endpoint-mcp-settings.php
6 days ago
class-wpcom-rest-api-v2-endpoint-newsletter-categories-list.php
7 months ago
class-wpcom-rest-api-v2-endpoint-newsletter-categories-subscriptions-count.php
7 months ago
class-wpcom-rest-api-v2-endpoint-newsletter-email-sent-status.php
3 months ago
class-wpcom-rest-api-v2-endpoint-podcast-player.php
2 months ago
class-wpcom-rest-api-v2-endpoint-profile.php
7 months ago
class-wpcom-rest-api-v2-endpoint-related-posts.php
7 months ago
class-wpcom-rest-api-v2-endpoint-resolve-redirect.php
7 months ago
class-wpcom-rest-api-v2-endpoint-search.php
1 week ago
class-wpcom-rest-api-v2-endpoint-send-email-preview.php
1 month ago
class-wpcom-rest-api-v2-endpoint-subscribers-list.php
2 weeks ago
class-wpcom-rest-api-v2-endpoint-template-loader.php
7 months ago
class-wpcom-rest-api-v2-endpoint-top-posts.php
2 months ago
class-wpcom-rest-api-v2-endpoint-transient.php
7 months ago
class-wpcom-rest-api-v3-endpoint-blogging-prompts.php
7 months ago
class-wpcom-rest-api-v3-endpoint-jitm.php
7 months ago
gutenberg-available-extensions.php
7 months ago
hello.php
7 months ago
memberships.php
2 weeks ago
publicize-connection-test-results.php
7 months ago
service-api-keys.php
1 month ago
sites-posts-featured-media-url.php
7 months ago
subscribers.php
7 months ago
class-wpcom-rest-api-v2-endpoint-search.php
61 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Proxy endpoint for Jetpack Search |
| 4 | * |
| 5 | * @package automattic/jetpack |
| 6 | */ |
| 7 | |
| 8 | use Automattic\Jetpack\Search\REST_Controller; |
| 9 | |
| 10 | if ( ! defined( 'ABSPATH' ) ) { |
| 11 | exit( 0 ); |
| 12 | } |
| 13 | |
| 14 | /** |
| 15 | * Jetpack Search: Makes authenticated requests to the site search API using blog tokens. |
| 16 | * This endpoint will only be used when trying to search private Jetpack and WordPress.com sites. |
| 17 | * |
| 18 | * @since 9.0.0 |
| 19 | */ |
| 20 | class WPCOM_REST_API_V2_Endpoint_Search extends WP_REST_Controller { |
| 21 | /** |
| 22 | * Forward request to controller in Search package. |
| 23 | * |
| 24 | * @var REST_Controller |
| 25 | */ |
| 26 | protected $controller; |
| 27 | |
| 28 | /** |
| 29 | * Constructor. |
| 30 | */ |
| 31 | public function __construct() { |
| 32 | $this->namespace = 'wpcom/v2'; |
| 33 | $this->rest_base = 'search'; |
| 34 | |
| 35 | add_action( 'rest_api_init', array( $this, 'register_routes' ) ); |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Called automatically on `rest_api_init()`. |
| 40 | * |
| 41 | * The Search package controller is instantiated here rather than in the |
| 42 | * constructor so that the package class is only loaded when the REST API is |
| 43 | * actually in use, not on every front-end, cron, or login request. |
| 44 | */ |
| 45 | public function register_routes() { |
| 46 | $this->controller = new REST_Controller( defined( 'IS_WPCOM' ) && IS_WPCOM ); |
| 47 | |
| 48 | register_rest_route( |
| 49 | $this->namespace, |
| 50 | $this->rest_base, |
| 51 | array( |
| 52 | 'methods' => WP_REST_Server::READABLE, |
| 53 | 'callback' => array( $this->controller, 'get_search_results' ), |
| 54 | 'permission_callback' => 'is_user_logged_in', |
| 55 | ) |
| 56 | ); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | wpcom_rest_api_v2_load_plugin( 'WPCOM_REST_API_V2_Endpoint_Search' ); |
| 61 |