| @@ 107-121 (lines=15) @@ | ||
| 104 | * groups:array |
|
| 105 | * site_id:int |
|
| 106 | */ |
|
| 107 | public function get_mailchimp_groups() { |
|
| 108 | $is_wpcom = ( defined( 'IS_WPCOM' ) && IS_WPCOM ); |
|
| 109 | $site_id = $is_wpcom ? get_current_blog_id() : Jetpack_Options::get_option( 'id' ); |
|
| 110 | if ( ! $site_id ) { |
|
| 111 | return new WP_Error( |
|
| 112 | 'unavailable_site_id', |
|
| 113 | __( 'Sorry, something is wrong with your Jetpack connection.', 'jetpack' ), |
|
| 114 | 403 |
|
| 115 | ); |
|
| 116 | } |
|
| 117 | $path = sprintf( '/sites/%d/mailchimp/groups', absint( $site_id ) ); |
|
| 118 | $request = Client::wpcom_json_api_request_as_blog( $path ); |
|
| 119 | $body = wp_remote_retrieve_body( $request ); |
|
| 120 | return json_decode( $body ); |
|
| 121 | } |
|
| 122 | } |
|
| 123 | ||
| 124 | wpcom_rest_api_v2_load_plugin( 'WPCOM_REST_API_V2_Endpoint_Mailchimp' ); |
|
| @@ 50-68 (lines=19) @@ | ||
| 47 | * @param WP_REST_Request $request The REST API request data. |
|
| 48 | * @return mixed The REST API response from public-api. |
|
| 49 | */ |
|
| 50 | public function get_search_results( $request ) { |
|
| 51 | $is_wpcom = ( defined( 'IS_WPCOM' ) && IS_WPCOM ); |
|
| 52 | $site_id = $is_wpcom ? get_current_blog_id() : Jetpack_Options::get_option( 'id' ); |
|
| 53 | if ( ! $site_id ) { |
|
| 54 | return new WP_Error( |
|
| 55 | 'unavailable_site_id', |
|
| 56 | __( 'Sorry, something is wrong with your Jetpack connection.', 'jetpack' ), |
|
| 57 | 403 |
|
| 58 | ); |
|
| 59 | } |
|
| 60 | ||
| 61 | $path = add_query_arg( |
|
| 62 | $request->get_query_params(), |
|
| 63 | sprintf( '/sites/%d/search', absint( $site_id ) ) |
|
| 64 | ); |
|
| 65 | $request = Client::wpcom_json_api_request_as_blog( $path, '1.3' ); |
|
| 66 | $body = wp_remote_retrieve_body( $request ); |
|
| 67 | return json_decode( $body ); |
|
| 68 | } |
|
| 69 | } |
|
| 70 | ||
| 71 | wpcom_rest_api_v2_load_plugin( 'WPCOM_REST_API_V2_Endpoint_Search' ); |
|