1 | <?php |
||
20 | class REST_Connector { |
||
21 | /** |
||
22 | * The Connection Manager. |
||
23 | * |
||
24 | * @var Manager |
||
25 | */ |
||
26 | private $connection; |
||
27 | |||
28 | /** |
||
29 | * This property stores the localized "Insufficient Permissions" error message. |
||
30 | * |
||
31 | * @var string Generic error message when user is not allowed to perform an action. |
||
32 | */ |
||
33 | private static $user_permissions_error_msg; |
||
34 | |||
35 | const JETPACK__DEBUGGER_PUBLIC_KEY = "\r\n" . '-----BEGIN PUBLIC KEY-----' . "\r\n" |
||
36 | . 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAm+uLLVoxGCY71LS6KFc6' . "\r\n" |
||
37 | . '1UnF6QGBAsi5XF8ty9kR3/voqfOkpW+gRerM2Kyjy6DPCOmzhZj7BFGtxSV2ZoMX' . "\r\n" |
||
38 | . '9ZwWxzXhl/Q/6k8jg8BoY1QL6L2K76icXJu80b+RDIqvOfJruaAeBg1Q9NyeYqLY' . "\r\n" |
||
39 | . 'lEVzN2vIwcFYl+MrP/g6Bc2co7Jcbli+tpNIxg4Z+Hnhbs7OJ3STQLmEryLpAxQO' . "\r\n" |
||
40 | . 'q8cbhQkMx+FyQhxzSwtXYI/ClCUmTnzcKk7SgGvEjoKGAmngILiVuEJ4bm7Q1yok' . "\r\n" |
||
41 | . 'xl9+wcfW6JAituNhml9dlHCWnn9D3+j8pxStHihKy2gVMwiFRjLEeD8K/7JVGkb/' . "\r\n" |
||
42 | . 'EwIDAQAB' . "\r\n" |
||
43 | . '-----END PUBLIC KEY-----' . "\r\n"; |
||
44 | |||
45 | /** |
||
46 | * Constructor. |
||
47 | * |
||
48 | * @param Manager $connection The Connection Manager. |
||
49 | */ |
||
50 | public function __construct( Manager $connection ) { |
||
116 | |||
117 | /** |
||
118 | * Handles verification that a site is registered. |
||
119 | * |
||
120 | * @since 5.4.0 |
||
121 | * |
||
122 | * @param WP_REST_Request $request The request sent to the WP REST API. |
||
123 | * |
||
124 | * @return string|WP_Error |
||
125 | */ |
||
126 | public function verify_registration( WP_REST_Request $request ) { |
||
131 | |||
132 | /** |
||
133 | * Handles verification that a site is registered |
||
134 | * |
||
135 | * @since 5.4.0 |
||
136 | * |
||
137 | * @param WP_REST_Request $request The request sent to the WP REST API. |
||
138 | * |
||
139 | * @return array|wp-error |
||
|
|||
140 | */ |
||
141 | public static function remote_authorize( $request ) { |
||
151 | |||
152 | /** |
||
153 | * Get connection status for this Jetpack site. |
||
154 | * |
||
155 | * @since 4.3.0 |
||
156 | * |
||
157 | * @param bool $rest_response Should we return a rest response or a simple array. Default to rest response. |
||
158 | * |
||
159 | * @return WP_REST_Response|array Connection information. |
||
160 | */ |
||
161 | public static function connection_status( $rest_response = true ) { |
||
198 | |||
199 | /** |
||
200 | * Get plugins connected to the Jetpack. |
||
201 | * |
||
202 | * @since 8.6.0 |
||
203 | * |
||
204 | * @return WP_REST_Response|WP_Error Response or error object, depending on the request result. |
||
205 | */ |
||
206 | public function get_connection_plugins() { |
||
222 | |||
223 | /** |
||
224 | * Verify that user can view Jetpack admin page and can activate plugins. |
||
225 | * |
||
226 | * @since 8.8.0 |
||
227 | * |
||
228 | * @return bool|WP_Error Whether user has the capability 'activate_plugins'. |
||
229 | */ |
||
230 | public static function activate_plugins_permission_check() { |
||
237 | |||
238 | /** |
||
239 | * Permission check for the connection_plugins endpoint |
||
240 | * |
||
241 | * @return bool|WP_Error |
||
242 | */ |
||
243 | public static function connection_plugins_permission_check() { |
||
255 | |||
256 | /** |
||
257 | * Verifies if the request was signed with the Jetpack Debugger key |
||
258 | * |
||
259 | * @param string|null $pub_key The public key used to verify the signature. Default is the Jetpack Debugger key. This is used for testing purposes. |
||
260 | * |
||
261 | * @return bool |
||
262 | */ |
||
263 | public static function is_request_signed_by_jetpack_debugger( $pub_key = null ) { |
||
299 | |||
300 | /** |
||
301 | * Verify that user is allowed to disconnect Jetpack. |
||
302 | * |
||
303 | * @since 8.8.0 |
||
304 | * |
||
305 | * @return bool|WP_Error Whether user has the capability 'jetpack_disconnect'. |
||
306 | */ |
||
307 | public static function jetpack_reconnect_permission_check() { |
||
314 | |||
315 | /** |
||
316 | * Returns generic error message when user is not allowed to perform an action. |
||
317 | * |
||
318 | * @return string The error message. |
||
319 | */ |
||
320 | public static function get_user_permissions_error_msg() { |
||
323 | |||
324 | /** |
||
325 | * The endpoint tried to partially or fully reconnect the website to WP.com. |
||
326 | * |
||
327 | * @since 8.8.0 |
||
328 | * |
||
329 | * @return \WP_REST_Response|WP_Error |
||
330 | */ |
||
331 | public function connection_reconnect() { |
||
367 | |||
368 | } |
||
369 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.