1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Class Jetpack_Deprecated |
4
|
|
|
* |
5
|
|
|
* A place to hold deprecated things from the Jetpack class to try to reduce the size of the mega file. |
6
|
|
|
* |
7
|
|
|
* @package automattic/jetpack |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
use Automattic\Jetpack\Assets; |
11
|
|
|
use Automattic\Jetpack\Connection\Manager as Connection_Manager; |
12
|
|
|
use Automattic\Jetpack\Connection\Rest_Authentication as Connection_Rest_Authentication; |
13
|
|
|
use Automattic\Jetpack\Roles; |
14
|
|
|
use Automattic\Jetpack\Status; |
15
|
|
|
use Automattic\Jetpack\Sync\Functions; |
16
|
|
|
use Automattic\Jetpack\Sync\Users; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Class Jetpack_Deprecated |
20
|
|
|
*/ |
21
|
|
|
class Jetpack_Deprecated { |
22
|
|
|
/** |
23
|
|
|
* Map of roles we care about, and their corresponding minimum capabilities. |
24
|
|
|
* |
25
|
|
|
* @deprecated 7.6 Use Automattic\Jetpack\Roles::$capability_translations instead. |
26
|
|
|
* |
27
|
|
|
* @access public |
28
|
|
|
* @static |
29
|
|
|
* |
30
|
|
|
* @var array |
31
|
|
|
*/ |
32
|
|
|
public static $capability_translations = array( |
33
|
|
|
'administrator' => 'manage_options', |
34
|
|
|
'editor' => 'edit_others_posts', |
35
|
|
|
'author' => 'publish_posts', |
36
|
|
|
'contributor' => 'edit_posts', |
37
|
|
|
'subscriber' => 'read', |
38
|
|
|
); |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Checks if a Jetpack site is both active and not in offline mode. |
42
|
|
|
* |
43
|
|
|
* This is a DRY function to avoid repeating `Jetpack::is_active && ! Automattic\Jetpack\Status->is_offline_mode`. |
44
|
|
|
* |
45
|
|
|
* @deprecated 8.8.0 |
46
|
|
|
* |
47
|
|
|
* @return bool True if Jetpack is active and not in offline mode. |
48
|
|
|
*/ |
49
|
|
View Code Duplication |
public static function is_active_and_not_development_mode() { |
50
|
|
|
_deprecated_function( __FUNCTION__, 'jetpack-8.8.0', 'Jetpack::is_active_and_not_offline_mode' ); |
51
|
|
|
if ( ! Jetpack::is_active() || ( new Status() )->is_offline_mode() ) { |
52
|
|
|
return false; |
53
|
|
|
} |
54
|
|
|
return true; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Deprecated manage functions |
59
|
|
|
*/ |
60
|
|
|
public function prepare_manage_jetpack_notice() { |
61
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.3' ); |
62
|
|
|
} |
63
|
|
|
/** |
64
|
|
|
* Deprecated manage functions |
65
|
|
|
*/ |
66
|
|
|
public function manage_activate_screen() { |
67
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.3' ); |
68
|
|
|
} |
69
|
|
|
/** |
70
|
|
|
* Deprecated manage functions |
71
|
|
|
*/ |
72
|
|
|
public function admin_jetpack_manage_notice() { |
73
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.3' ); |
74
|
|
|
} |
75
|
|
|
/** |
76
|
|
|
* Deprecated manage functions |
77
|
|
|
*/ |
78
|
|
|
public function opt_out_jetpack_manage_url() { |
79
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.3' ); |
80
|
|
|
} |
81
|
|
|
/** |
82
|
|
|
* Deprecated manage functions |
83
|
|
|
*/ |
84
|
|
|
public function opt_in_jetpack_manage_url() { |
85
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.3' ); |
86
|
|
|
} |
87
|
|
|
/** |
88
|
|
|
* Deprecated manage functions |
89
|
|
|
*/ |
90
|
|
|
public function opt_in_jetpack_manage_notice() { |
91
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.3' ); |
92
|
|
|
} |
93
|
|
|
/** |
94
|
|
|
* Deprecated manage functions |
95
|
|
|
*/ |
96
|
|
|
public function can_display_jetpack_manage_notice() { |
97
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.3' ); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Deprecated function |
102
|
|
|
* |
103
|
|
|
* @deprecated 7.6.0 |
104
|
|
|
* |
105
|
|
|
* @see Automattic\Jetpack\Sync\Modules\Users::is_function_in_backtrace |
106
|
|
|
*/ |
107
|
|
|
public static function is_function_in_backtrace() { |
108
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.6.0' ); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Stores and prints out domains to prefetch for page speed optimization. |
113
|
|
|
* |
114
|
|
|
* @deprecated 8.8.0 Use Jetpack::add_resource_hints. |
115
|
|
|
* |
116
|
|
|
* @param string|array $urls URLs to hint. |
|
|
|
|
117
|
|
|
*/ |
118
|
|
|
public static function dns_prefetch( $urls = null ) { |
119
|
|
|
_deprecated_function( __FUNCTION__, 'jetpack-8.8.0', 'Automattic\Jetpack\Assets::add_resource_hint' ); |
120
|
|
|
if ( $urls ) { |
121
|
|
|
Assets::add_resource_hint( $urls ); |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* Strip http:// or https:// from a url, replaces forward slash with ::, |
127
|
|
|
* so we can bring them directly to their site in calypso. |
128
|
|
|
* |
129
|
|
|
* @deprecated 9.2.0 Use Automattic\Jetpack\Status::get_site_suffix |
130
|
|
|
* |
131
|
|
|
* @param string $url URL. |
132
|
|
|
*/ |
133
|
|
|
public static function build_raw_urls( $url ) { |
134
|
|
|
_deprecated_function( __METHOD__, 'jetpack-9.2.0', 'Automattic\Jetpack\Status::get_site_suffix' ); |
135
|
|
|
|
136
|
|
|
return ( new Status() )->get_site_suffix( $url ); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* Deprecated. |
141
|
|
|
* |
142
|
|
|
* @deprecated |
143
|
|
|
* @see Automattic\Jetpack\Assets\add_async_script |
144
|
|
|
*/ |
145
|
|
|
public function script_add_async() { |
146
|
|
|
_deprecated_function( __METHOD__, 'jetpack-8.6.0' ); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* Checks whether the home and siteurl specifically are allowed. |
151
|
|
|
* Written so that we don't have re-check $key and $value params every time |
152
|
|
|
* we want to check if this site is allowed, for example in footer.php |
153
|
|
|
* |
154
|
|
|
* @since 3.8.0 |
155
|
|
|
* @return bool True = already allowed False = not on the allowed list. |
156
|
|
|
*/ |
157
|
|
|
public static function is_staging_site() { |
158
|
|
|
_deprecated_function( 'Jetpack::is_staging_site', 'jetpack-8.1', '/Automattic/Jetpack/Status->is_staging_site' ); |
159
|
|
|
return ( new Status() )->is_staging_site(); |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* Serve a WordPress.com static resource via a randomized wp.com subdomain. |
164
|
|
|
* |
165
|
|
|
* @deprecated 9.3.0 Use Assets::staticize_subdomain. |
166
|
|
|
* |
167
|
|
|
* @param string $url WordPress.com static resource URL. |
168
|
|
|
*/ |
169
|
|
|
public static function staticize_subdomain( $url ) { |
170
|
|
|
_deprecated_function( __METHOD__, 'jetpack-9.3.0', 'Automattic\Jetpack\Assets::staticize_subdomain' ); |
171
|
|
|
return Assets::staticize_subdomain( $url ); |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* Adds Jetpack-specific options to the output of the XMLRPC options method. |
176
|
|
|
* |
177
|
|
|
* @deprecated since 7.7.0 |
178
|
|
|
* @see Automattic\Jetpack\Connection\Manager::xmlrpc_options() |
179
|
|
|
* |
180
|
|
|
* @param array $options Standard Core options. |
181
|
|
|
* @return array Amended options. |
182
|
|
|
*/ |
183
|
|
View Code Duplication |
public function xmlrpc_options( $options ) { |
184
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.7', 'Automattic\\Jetpack\\Connection\\Manager::xmlrpc_options' ); |
185
|
|
|
|
186
|
|
|
if ( ! $this->connection_manager ) { |
187
|
|
|
$this->connection_manager = new Connection_Manager(); |
|
|
|
|
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
return $this->connection_manager->xmlrpc_options( $options ); |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* Handles a getOptions XMLRPC method call. |
195
|
|
|
* |
196
|
|
|
* @deprecated since 7.7.0 |
197
|
|
|
* @see Automattic\Jetpack\Connection\Manager::jetpack_getOptions() |
198
|
|
|
* |
199
|
|
|
* @param array $args method call arguments. |
200
|
|
|
* @return array an amended XMLRPC server options array. |
201
|
|
|
*/ |
202
|
|
View Code Duplication |
public function jetpack_getOptions( $args ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid |
203
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.7', 'Automattic\\Jetpack\\Connection\\Manager::jetpack_getOptions' ); |
204
|
|
|
|
205
|
|
|
if ( ! $this->connection_manager ) { |
206
|
|
|
$this->connection_manager = new Connection_Manager(); |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
return $this->connection_manager->jetpack_getOptions( $args ); |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* In some setups, $HTTP_RAW_POST_DATA can be emptied during some IXR_Server paths since it is passed by reference to various methods. |
214
|
|
|
* Capture it here so we can verify the signature later. |
215
|
|
|
* |
216
|
|
|
* @deprecated since 7.7.0 |
217
|
|
|
* @see Automattic\Jetpack\Connection\Manager::xmlrpc_methods() |
218
|
|
|
* |
219
|
|
|
* @param array $methods XMLRPC methods. |
220
|
|
|
* @return array XMLRPC methods, with the $HTTP_RAW_POST_DATA one. |
221
|
|
|
*/ |
222
|
|
View Code Duplication |
public function xmlrpc_methods( $methods ) { |
223
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.7', 'Automattic\\Jetpack\\Connection\\Manager::xmlrpc_methods' ); |
224
|
|
|
|
225
|
|
|
if ( ! $this->connection_manager ) { |
226
|
|
|
$this->connection_manager = new Connection_Manager(); |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
return $this->connection_manager->xmlrpc_methods( $methods ); |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
/** |
233
|
|
|
* Register additional public XMLRPC methods. |
234
|
|
|
* |
235
|
|
|
* @deprecated since 7.7.0 |
236
|
|
|
* @see Automattic\Jetpack\Connection\Manager::public_xmlrpc_methods() |
237
|
|
|
* |
238
|
|
|
* @param array $methods Public XMLRPC methods. |
239
|
|
|
* @return array Public XMLRPC methods, with the getOptions one. |
240
|
|
|
*/ |
241
|
|
View Code Duplication |
public function public_xmlrpc_methods( $methods ) { |
242
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.7', 'Automattic\\Jetpack\\Connection\\Manager::public_xmlrpc_methods' ); |
243
|
|
|
|
244
|
|
|
if ( ! $this->connection_manager ) { |
245
|
|
|
$this->connection_manager = new Connection_Manager(); |
246
|
|
|
} |
247
|
|
|
|
248
|
|
|
return $this->connection_manager->public_xmlrpc_methods( $methods ); |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* Loads the Jetpack XML-RPC client. |
253
|
|
|
* No longer necessary, as the XML-RPC client will be automagically loaded. |
254
|
|
|
* |
255
|
|
|
* @deprecated since 7.7.0 |
256
|
|
|
*/ |
257
|
|
|
public static function load_xml_rpc_client() { |
258
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.7' ); |
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
/** |
262
|
|
|
* Resets the saved authentication state in between testing requests. |
263
|
|
|
* |
264
|
|
|
* @deprecated since 8.9.0 |
265
|
|
|
* @see Automattic\Jetpack\Connection\Rest_Authentication::reset_saved_auth_state() |
266
|
|
|
*/ |
267
|
|
|
public function reset_saved_auth_state() { |
268
|
|
|
_deprecated_function( __METHOD__, 'jetpack-8.9', 'Automattic\\Jetpack\\Connection\\Rest_Authentication::reset_saved_auth_state' ); |
269
|
|
|
Connection_Rest_Authentication::init()->reset_saved_auth_state(); |
270
|
|
|
} |
271
|
|
|
|
272
|
|
|
/** |
273
|
|
|
* Verifies the signature of the current request. |
274
|
|
|
* |
275
|
|
|
* @deprecated since 7.7.0 |
276
|
|
|
* @see Automattic\Jetpack\Connection\Manager::verify_xml_rpc_signature() |
277
|
|
|
* |
278
|
|
|
* @return false|array |
279
|
|
|
*/ |
280
|
|
|
public function verify_xml_rpc_signature() { |
281
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.7', 'Automattic\\Jetpack\\Connection\\Manager::verify_xml_rpc_signature' ); |
282
|
|
|
return self::connection()->verify_xml_rpc_signature(); |
|
|
|
|
283
|
|
|
} |
284
|
|
|
|
285
|
|
|
/** |
286
|
|
|
* Verifies the signature of the current request. |
287
|
|
|
* |
288
|
|
|
* This function has side effects and should not be used. Instead, |
289
|
|
|
* use the memoized version `->verify_xml_rpc_signature()`. |
290
|
|
|
* |
291
|
|
|
* @deprecated since 7.7.0 |
292
|
|
|
* @see Automattic\Jetpack\Connection\Manager::internal_verify_xml_rpc_signature() |
293
|
|
|
* @internal |
294
|
|
|
*/ |
295
|
|
|
private function internal_verify_xml_rpc_signature() { |
296
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.7', 'Automattic\\Jetpack\\Connection\\Manager::internal_verify_xml_rpc_signature' ); |
297
|
|
|
} |
298
|
|
|
|
299
|
|
|
/** |
300
|
|
|
* Authenticates XML-RPC and other requests from the Jetpack Server. |
301
|
|
|
* |
302
|
|
|
* @deprecated since 7.7.0 |
303
|
|
|
* @see Automattic\Jetpack\Connection\Manager::authenticate_jetpack() |
304
|
|
|
* |
305
|
|
|
* @param \WP_User|mixed $user User object if authenticated. |
306
|
|
|
* @param string $username Username. |
307
|
|
|
* @param string $password Password string. |
308
|
|
|
* @return \WP_User|mixed Authenticated user or error. |
309
|
|
|
*/ |
310
|
|
View Code Duplication |
public function authenticate_jetpack( $user, $username, $password ) { |
311
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.7', 'Automattic\\Jetpack\\Connection\\Manager::authenticate_jetpack' ); |
312
|
|
|
|
313
|
|
|
if ( ! $this->connection_manager ) { |
314
|
|
|
$this->connection_manager = new Connection_Manager(); |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
return $this->connection_manager->authenticate_jetpack( $user, $username, $password ); |
318
|
|
|
} |
319
|
|
|
|
320
|
|
|
/** |
321
|
|
|
* Authenticates requests from Jetpack server to WP REST API endpoints. |
322
|
|
|
* Uses the existing XMLRPC request signing implementation. |
323
|
|
|
* |
324
|
|
|
* @deprecated since 8.9.0 |
325
|
|
|
* @see Automattic\Jetpack\Connection\Rest_Authentication::wp_rest_authenticate() |
326
|
|
|
* |
327
|
|
|
* @param mixed $user User. |
328
|
|
|
*/ |
329
|
|
|
public function wp_rest_authenticate( $user ) { |
330
|
|
|
_deprecated_function( __METHOD__, 'jetpack-8.9', 'Automattic\\Jetpack\\Connection\\Rest_Authentication::wp_rest_authenticate' ); |
331
|
|
|
return Connection_Rest_Authentication::init()->wp_rest_authenticate( $user ); |
332
|
|
|
} |
333
|
|
|
|
334
|
|
|
/** |
335
|
|
|
* Report authentication status to the WP REST API. |
336
|
|
|
* |
337
|
|
|
* @deprecated since 8.9.0 |
338
|
|
|
* @see Automattic\Jetpack\Connection\Rest_Authentication::wp_rest_authentication_errors() |
339
|
|
|
* |
340
|
|
|
* @param WP_Error|mixed $value Error from another authentication handler, null if we should handle it, or another value if not. |
341
|
|
|
* |
342
|
|
|
* @return WP_Error|boolean|null {@see WP_JSON_Server::check_authentication} |
343
|
|
|
*/ |
344
|
|
|
public function wp_rest_authentication_errors( $value ) { |
345
|
|
|
_deprecated_function( __METHOD__, 'jetpack-8.9', 'Automattic\\Jetpack\\Connection\\Rest_Authentication::wp_rest_authenication_errors' ); |
346
|
|
|
return Connection_Rest_Authentication::init()->wp_rest_authentication_errors( $value ); |
347
|
|
|
} |
348
|
|
|
|
349
|
|
|
/** |
350
|
|
|
* Takes the response from the Jetpack register new site endpoint and |
351
|
|
|
* verifies it worked properly. |
352
|
|
|
* |
353
|
|
|
* @since 2.6 |
354
|
|
|
* @deprecated since 7.7.0 |
355
|
|
|
* @see Automattic\Jetpack\Connection\Manager::validate_remote_register_response() |
356
|
|
|
**/ |
357
|
|
|
public function validate_remote_register_response() { |
358
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.7', 'Automattic\\Jetpack\\Connection\\Manager::validate_remote_register_response' ); |
359
|
|
|
} |
360
|
|
|
|
361
|
|
|
/** |
362
|
|
|
* Builds the timeout limit for queries talking with the wpcom servers. |
363
|
|
|
* |
364
|
|
|
* Based on local php max_execution_time in php.ini |
365
|
|
|
* |
366
|
|
|
* @since 2.6 |
367
|
|
|
* @return int |
368
|
|
|
* @deprecated |
369
|
|
|
**/ |
370
|
|
|
public function get_remote_query_timeout_limit() { |
371
|
|
|
_deprecated_function( __METHOD__, 'jetpack-5.4' ); |
372
|
|
|
return Jetpack::get_max_execution_time(); |
373
|
|
|
} |
374
|
|
|
|
375
|
|
|
/** |
376
|
|
|
* Deprecated. |
377
|
|
|
* |
378
|
|
|
* @deprecated 7.5 Use Connection_Manager instead. |
379
|
|
|
* |
380
|
|
|
* @param string $action Action. |
381
|
|
|
* @param mixed $user_id User ID. |
382
|
|
|
*/ |
383
|
|
|
public static function delete_secrets( $action, $user_id ) { |
384
|
|
|
return Jetpack::connection()->delete_secrets( $action, $user_id ); |
385
|
|
|
} |
386
|
|
|
|
387
|
|
|
/** |
388
|
|
|
* Returns the Jetpack XML-RPC API |
389
|
|
|
* |
390
|
|
|
* @deprecated 8.0 Use Connection_Manager instead. |
391
|
|
|
* @return string |
392
|
|
|
*/ |
393
|
|
|
public static function xmlrpc_api_url() { |
394
|
|
|
_deprecated_function( __METHOD__, 'jetpack-8.0', 'Automattic\\Jetpack\\Connection\\Manager::xmlrpc_api_url()' ); |
395
|
|
|
return Jetpack::connection()->xmlrpc_api_url(); |
396
|
|
|
} |
397
|
|
|
|
398
|
|
|
/** |
399
|
|
|
* Deprecated. |
400
|
|
|
* |
401
|
|
|
* @deprecated 8.0 |
402
|
|
|
* |
403
|
|
|
* @param string $url URL. |
404
|
|
|
*/ |
405
|
|
|
public static function fix_url_for_bad_hosts( $url ) { |
406
|
|
|
_deprecated_function( __METHOD__, 'jetpack-8.0' ); |
407
|
|
|
return $url; |
408
|
|
|
} |
409
|
|
|
|
410
|
|
|
/** |
411
|
|
|
* Returns the requested Jetpack API URL |
412
|
|
|
* |
413
|
|
|
* @deprecated since 7.7 |
414
|
|
|
* |
415
|
|
|
* @param string $relative_url Relative URL. |
416
|
|
|
* |
417
|
|
|
* @return string |
418
|
|
|
*/ |
419
|
|
|
public static function api_url( $relative_url ) { |
420
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.7', 'Automattic\\Jetpack\\Connection\\Manager::api_url' ); |
421
|
|
|
return Jetpack::connection()->api_url( $relative_url ); |
422
|
|
|
} |
423
|
|
|
|
424
|
|
|
/** |
425
|
|
|
* Get our assumed site creation date. |
426
|
|
|
* Calculated based on the earlier date of either: |
427
|
|
|
* - Earliest admin user registration date. |
428
|
|
|
* - Earliest date of post of any post type. |
429
|
|
|
* |
430
|
|
|
* @since 7.2.0 |
431
|
|
|
* @deprecated since 7.8.0 |
432
|
|
|
* |
433
|
|
|
* @return string Assumed site creation date and time. |
434
|
|
|
*/ |
435
|
|
|
public static function get_assumed_site_creation_date() { |
436
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.8', 'Automattic\\Jetpack\\Connection\\Manager' ); |
437
|
|
|
return self::connection()->get_assumed_site_creation_date(); |
|
|
|
|
438
|
|
|
} |
439
|
|
|
|
440
|
|
|
/** |
441
|
|
|
* Filters the URL that will process the connection data. It can be different from the URL |
442
|
|
|
* that we send the user to after everything is done. |
443
|
|
|
* |
444
|
|
|
* @param String $processing_url the default redirect URL used by the package. |
445
|
|
|
* @return String the modified URL. |
446
|
|
|
* |
447
|
|
|
* @deprecated since Jetpack 9.5.0 |
448
|
|
|
*/ |
449
|
|
|
public static function filter_connect_processing_url( $processing_url ) { |
450
|
|
|
_deprecated_function( __METHOD__, 'jetpack-9.5' ); |
451
|
|
|
|
452
|
|
|
$processing_url = admin_url( 'admin.php?page=jetpack' ); // Making PHPCS happy. |
453
|
|
|
return $processing_url; |
454
|
|
|
} |
455
|
|
|
|
456
|
|
|
/** |
457
|
|
|
* Sign a user role with the master access token. |
458
|
|
|
* If not specified, will default to the current user. |
459
|
|
|
* |
460
|
|
|
* @deprecated since 7.7 |
461
|
|
|
* @see Automattic\Jetpack\Connection\Manager::sign_role() |
462
|
|
|
* |
463
|
|
|
* @access public |
464
|
|
|
* @static |
465
|
|
|
* |
466
|
|
|
* @param string $role User role. |
467
|
|
|
* @param int $user_id ID of the user. |
|
|
|
|
468
|
|
|
* @return string Signed user role. |
469
|
|
|
*/ |
470
|
|
|
public static function sign_role( $role, $user_id = null ) { |
471
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.7', 'Automattic\\Jetpack\\Connection\\Manager::sign_role' ); |
472
|
|
|
return Jetpack::connection()->sign_role( $role, $user_id ); |
473
|
|
|
} |
474
|
|
|
|
475
|
|
|
/** |
476
|
|
|
* Get the minimum capability for a role. |
477
|
|
|
* |
478
|
|
|
* @deprecated 7.6 Use Automattic\Jetpack\Roles::translate_role_to_cap() instead. |
479
|
|
|
* |
480
|
|
|
* @access public |
481
|
|
|
* @static |
482
|
|
|
* |
483
|
|
|
* @param string $role Role name. |
484
|
|
|
* @return string|boolean Capability, false if role isn't mapped to any capabilities. |
485
|
|
|
*/ |
486
|
|
|
public static function translate_role_to_cap( $role ) { |
487
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.6.0' ); |
488
|
|
|
|
489
|
|
|
$roles = new Roles(); |
490
|
|
|
return $roles->translate_role_to_cap( $role ); |
491
|
|
|
} |
492
|
|
|
|
493
|
|
|
/** |
494
|
|
|
* Get the role of a particular user. |
495
|
|
|
* |
496
|
|
|
* @deprecated 7.6 Use Automattic\Jetpack\Roles::translate_user_to_role() instead. |
497
|
|
|
* |
498
|
|
|
* @access public |
499
|
|
|
* @static |
500
|
|
|
* |
501
|
|
|
* @param \WP_User $user User object. |
502
|
|
|
* @return string|boolean User's role, false if not enough capabilities for any of the roles. |
503
|
|
|
*/ |
504
|
|
|
public static function translate_user_to_role( $user ) { |
505
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.6.0' ); |
506
|
|
|
|
507
|
|
|
$roles = new Roles(); |
508
|
|
|
return $roles->translate_user_to_role( $user ); |
509
|
|
|
} |
510
|
|
|
|
511
|
|
|
/** |
512
|
|
|
* Get the role of the current user. |
513
|
|
|
* |
514
|
|
|
* @deprecated 7.6 Use Automattic\Jetpack\Roles::translate_current_user_to_role() instead. |
515
|
|
|
* |
516
|
|
|
* @access public |
517
|
|
|
* @static |
518
|
|
|
* |
519
|
|
|
* @return string|boolean Current user's role, false if not enough capabilities for any of the roles. |
520
|
|
|
*/ |
521
|
|
|
public static function translate_current_user_to_role() { |
522
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.6.0' ); |
523
|
|
|
|
524
|
|
|
$roles = new Roles(); |
525
|
|
|
return $roles->translate_current_user_to_role(); |
526
|
|
|
} |
527
|
|
|
|
528
|
|
|
/** |
529
|
|
|
* Unlinks the current user from the linked WordPress.com user. |
530
|
|
|
* |
531
|
|
|
* @deprecated since 7.7 |
532
|
|
|
* @see Automattic\Jetpack\Connection\Manager::disconnect_user() |
533
|
|
|
* |
534
|
|
|
* @param Integer $user_id the user identifier. |
|
|
|
|
535
|
|
|
* @return Boolean Whether the disconnection of the user was successful. |
536
|
|
|
*/ |
537
|
|
|
public static function unlink_user( $user_id = null ) { |
538
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.7', 'Automattic\\Jetpack\\Connection\\Manager::disconnect_user' ); |
539
|
|
|
return Connection_Manager::disconnect_user( $user_id ); |
540
|
|
|
} |
541
|
|
|
|
542
|
|
|
/** |
543
|
|
|
* Deprecated. |
544
|
|
|
*/ |
545
|
|
|
public function activate_module_actions() { |
546
|
|
|
_deprecated_function( __METHOD__, 'jetpack-4.2' ); |
547
|
|
|
} |
548
|
|
|
|
549
|
|
|
/** |
550
|
|
|
* Deprecated. |
551
|
|
|
* |
552
|
|
|
* @deprecated 8.0 Use Automattic\Jetpack\Connection\Utils::update_user_token() instead. |
553
|
|
|
* |
554
|
|
|
* Enters a user token into the user_tokens option |
555
|
|
|
* |
556
|
|
|
* @param int $user_id The user id. |
557
|
|
|
* @param string $token The user token. |
558
|
|
|
* @param bool $is_master_user Whether the user is the master user. |
559
|
|
|
* @return bool |
560
|
|
|
*/ |
561
|
|
|
public static function update_user_token( $user_id, $token, $is_master_user ) { |
562
|
|
|
_deprecated_function( __METHOD__, 'jetpack-8.0', 'Automattic\\Jetpack\\Connection\\Utils::update_user_token' ); |
563
|
|
|
return Connection_Utils::update_user_token( $user_id, $token, $is_master_user ); |
564
|
|
|
} |
565
|
|
|
|
566
|
|
|
/** |
567
|
|
|
* Deletes the given option. May be passed multiple option names as an array. |
568
|
|
|
* Updates jetpack_options and/or deletes jetpack_$name as appropriate. |
569
|
|
|
* |
570
|
|
|
* @deprecated 3.4 use Jetpack_Options::delete_option() instead. |
571
|
|
|
* @param string|array $names Option name(s). |
572
|
|
|
*/ |
573
|
|
|
public static function delete_option( $names ) { |
574
|
|
|
_deprecated_function( __METHOD__, 'jetpack-3.4', 'Jetpack_Options::delete_option()' ); |
575
|
|
|
return Jetpack_Options::delete_option( $names ); |
576
|
|
|
} |
577
|
|
|
|
578
|
|
|
/** |
579
|
|
|
* Updates the multiple given options. Updates jetpack_options and/or jetpack_$name as appropriate. |
580
|
|
|
* |
581
|
|
|
* @deprecated 3.4 use Jetpack_Options::update_options() instead. |
582
|
|
|
* |
583
|
|
|
* @param array $array array( option name => option value, ... ). |
584
|
|
|
*/ |
585
|
|
|
public static function update_options( $array ) { |
586
|
|
|
_deprecated_function( __METHOD__, 'jetpack-3.4', 'Jetpack_Options::update_options()' ); |
587
|
|
|
return Jetpack_Options::update_options( $array ); |
588
|
|
|
} |
589
|
|
|
|
590
|
|
|
/** |
591
|
|
|
* Updates the single given option. Updates jetpack_options or jetpack_$name as appropriate. |
592
|
|
|
* |
593
|
|
|
* @deprecated 3.4 use Jetpack_Options::update_option() instead. |
594
|
|
|
* @param string $name Option name. |
595
|
|
|
* @param mixed $value Option value. |
596
|
|
|
*/ |
597
|
|
|
public static function update_option( $name, $value ) { |
598
|
|
|
_deprecated_function( __METHOD__, 'jetpack-3.4', 'Jetpack_Options::update_option()' ); |
599
|
|
|
return Jetpack_Options::update_option( $name, $value ); |
600
|
|
|
} |
601
|
|
|
|
602
|
|
|
/** |
603
|
|
|
* Allows plugins to submit security reports. |
604
|
|
|
*/ |
605
|
|
|
public static function submit_security_report() { |
606
|
|
|
_deprecated_function( __FUNCTION__, 'jetpack-4.2', null ); |
607
|
|
|
} |
608
|
|
|
|
609
|
|
|
/** |
610
|
|
|
* Synchronize connected user role changes |
611
|
|
|
* |
612
|
|
|
* @param mixed $user_id User Id. |
613
|
|
|
*/ |
614
|
|
|
public function user_role_change( $user_id ) { |
615
|
|
|
_deprecated_function( __METHOD__, 'jetpack-4.2', 'Users::user_role_change()' ); |
616
|
|
|
Users::user_role_change( $user_id ); |
617
|
|
|
} |
618
|
|
|
|
619
|
|
|
/** |
620
|
|
|
* Whether the current user is the connection owner. |
621
|
|
|
* |
622
|
|
|
* @deprecated since 7.7 |
623
|
|
|
* |
624
|
|
|
* @return bool Whether the current user is the connection owner. |
625
|
|
|
*/ |
626
|
|
|
public function current_user_is_connection_owner() { |
627
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.7', 'Automattic\\Jetpack\\Connection\\Manager::is_connection_owner' ); |
628
|
|
|
return Jetpack::connection()->is_connection_owner(); |
629
|
|
|
} |
630
|
|
|
|
631
|
|
|
/** |
632
|
|
|
* Is a given user (or the current user if none is specified) linked to a WordPress.com user? |
633
|
|
|
* |
634
|
|
|
* @param mixed $user_id User Id. |
635
|
|
|
*/ |
636
|
|
|
public static function is_user_connected( $user_id = false ) { |
637
|
|
|
_deprecated_function( __METHOD__, 'jetpack-9.5', 'Automattic\\Jetpack\\Connection\\Manager\\is_user_connected' ); |
638
|
|
|
return Jetpack::connection()->is_user_connected( $user_id ); |
639
|
|
|
} |
640
|
|
|
|
641
|
|
|
/** |
642
|
|
|
* Get the wpcom user data of the current|specified connected user. |
643
|
|
|
* |
644
|
|
|
* @param mixed $user_id User Id. |
645
|
|
|
*/ |
646
|
|
|
public static function get_connected_user_data( $user_id = null ) { |
647
|
|
|
_deprecated_function( __METHOD__, 'jetpack-9.5', 'Automattic\\Jetpack\\Connection\\Manager\\get_connected_user_data' ); |
648
|
|
|
return Jetpack::connection()->get_connected_user_data( $user_id ); |
649
|
|
|
} |
650
|
|
|
|
651
|
|
|
/** |
652
|
|
|
* Determine whether the active plan supports a particular feature |
653
|
|
|
* |
654
|
|
|
* @deprecated 7.2.0 Use Jetpack_Plan::supports. |
655
|
|
|
* |
656
|
|
|
* @param string $feature Feature. |
657
|
|
|
* |
658
|
|
|
* @return bool True if plan supports feature, false if not. |
659
|
|
|
*/ |
660
|
|
|
public static function active_plan_supports( $feature ) { |
661
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.2.0', 'Jetpack_Plan::supports' ); |
662
|
|
|
return Jetpack_Plan::supports( $feature ); |
663
|
|
|
} |
664
|
|
|
|
665
|
|
|
/** |
666
|
|
|
* Make an API call to WordPress.com for plan status |
667
|
|
|
* |
668
|
|
|
* @deprecated 7.2.0 Use Jetpack_Plan::refresh_from_wpcom. |
669
|
|
|
* |
670
|
|
|
* @return bool True if plan is updated, false if no update |
671
|
|
|
*/ |
672
|
|
|
public static function refresh_active_plan_from_wpcom() { |
673
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.2.0', 'Jetpack_Plan::refresh_from_wpcom' ); |
674
|
|
|
return Jetpack_Plan::refresh_from_wpcom(); |
675
|
|
|
} |
676
|
|
|
|
677
|
|
|
/** |
678
|
|
|
* Get the plan that this Jetpack site is currently using |
679
|
|
|
* |
680
|
|
|
* @deprecated 7.2.0 Use Jetpack_Plan::get. |
681
|
|
|
* @return array Active Jetpack plan details. |
682
|
|
|
*/ |
683
|
|
|
public static function get_active_plan() { |
684
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.2.0', 'Jetpack_Plan::get' ); |
685
|
|
|
return Jetpack_Plan::get(); |
686
|
|
|
} |
687
|
|
|
|
688
|
|
|
/** |
689
|
|
|
* Deprecated. |
690
|
|
|
*/ |
691
|
|
|
public static function refresh_update_data() { |
692
|
|
|
_deprecated_function( __METHOD__, 'jetpack-4.2' ); |
693
|
|
|
|
694
|
|
|
} |
695
|
|
|
|
696
|
|
|
/** |
697
|
|
|
* Deprecated. |
698
|
|
|
*/ |
699
|
|
|
public static function refresh_theme_data() { |
700
|
|
|
_deprecated_function( __METHOD__, 'jetpack-4.2' ); |
701
|
|
|
} |
702
|
|
|
|
703
|
|
|
/** |
704
|
|
|
* Wrapper for core's get_avatar_url(). This one is deprecated. |
705
|
|
|
* |
706
|
|
|
* @deprecated 4.7 use get_avatar_url instead. |
707
|
|
|
* @param int|string|object $id_or_email A user ID, email address, or comment object. |
708
|
|
|
* @param int $size Size of the avatar image. |
709
|
|
|
* @param string $default URL to a default image to use if no avatar is available. |
710
|
|
|
* @param bool $force_display Whether to force it to return an avatar even if show_avatars is disabled. |
711
|
|
|
* |
712
|
|
|
* @return array |
713
|
|
|
*/ |
714
|
|
|
public static function get_avatar_url( $id_or_email, $size = 96, $default = '', $force_display = false ) { |
715
|
|
|
_deprecated_function( __METHOD__, 'jetpack-4.7', 'get_avatar_url' ); |
716
|
|
|
return get_avatar_url( |
717
|
|
|
$id_or_email, |
718
|
|
|
array( |
719
|
|
|
'size' => $size, |
720
|
|
|
'default' => $default, |
721
|
|
|
'force_default' => $force_display, |
722
|
|
|
) |
723
|
|
|
); |
724
|
|
|
} |
725
|
|
|
|
726
|
|
|
/** |
727
|
|
|
* Finds out if a site is using a version control system. |
728
|
|
|
* |
729
|
|
|
* @return string ( '1' | '0' ) |
730
|
|
|
**/ |
731
|
|
|
public static function is_version_controlled() { |
732
|
|
|
_deprecated_function( __METHOD__, 'jetpack-4.2', 'Functions::is_version_controlled' ); |
733
|
|
|
return (string) (int) Functions::is_version_controlled(); |
734
|
|
|
} |
735
|
|
|
|
736
|
|
|
/** |
737
|
|
|
* Determines whether the current theme supports featured images or not. |
738
|
|
|
* |
739
|
|
|
* @return string ( '1' | '0' ) |
740
|
|
|
*/ |
741
|
|
|
public static function featured_images_enabled() { |
742
|
|
|
_deprecated_function( __METHOD__, 'jetpack-4.2' ); |
743
|
|
|
return current_theme_supports( 'post-thumbnails' ) ? '1' : '0'; |
744
|
|
|
} |
745
|
|
|
|
746
|
|
|
/** |
747
|
|
|
* Trigger an update to the main_network_site when we update the siteurl of a site. |
748
|
|
|
*/ |
749
|
|
|
public function update_jetpack_main_network_site_option() { |
750
|
|
|
_deprecated_function( __METHOD__, 'jetpack-4.2' ); |
751
|
|
|
} |
752
|
|
|
/** |
753
|
|
|
* Triggered after a user updates the network settings via Network Settings Admin Page |
754
|
|
|
*/ |
755
|
|
|
public function update_jetpack_network_settings() { |
756
|
|
|
_deprecated_function( __METHOD__, 'jetpack-4.2' ); |
757
|
|
|
// Only sync this info for the main network site. |
758
|
|
|
} |
759
|
|
|
|
760
|
|
|
/** |
761
|
|
|
* Require a Jetpack authentication. |
762
|
|
|
* |
763
|
|
|
* @deprecated since 7.7.0 |
764
|
|
|
* @see Automattic\Jetpack\Connection\Manager::require_jetpack_authentication() |
765
|
|
|
*/ |
766
|
|
View Code Duplication |
public function require_jetpack_authentication() { |
767
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.7', 'Automattic\\Jetpack\\Connection\\Manager::require_jetpack_authentication' ); |
768
|
|
|
|
769
|
|
|
if ( ! $this->connection_manager ) { |
770
|
|
|
$this->connection_manager = new Connection_Manager(); |
771
|
|
|
} |
772
|
|
|
|
773
|
|
|
$this->connection_manager->require_jetpack_authentication(); |
774
|
|
|
} |
775
|
|
|
|
776
|
|
|
/** |
777
|
|
|
* The callback for the JITM ajax requests. |
778
|
|
|
* |
779
|
|
|
* @deprecated since 7.9.0 |
780
|
|
|
*/ |
781
|
|
|
public function jetpack_jitm_ajax_callback() { |
782
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.9' ); |
783
|
|
|
} |
784
|
|
|
|
785
|
|
|
/** |
786
|
|
|
* Since a lot of hosts use a hammer approach to "protecting" WordPress sites, |
787
|
|
|
* and just blanket block all requests to /xmlrpc.php, or apply other overly-sensitive |
788
|
|
|
* security/firewall policies, we provide our own alternate XML RPC API endpoint |
789
|
|
|
* which is accessible via a different URI. Most of the below is copied directly |
790
|
|
|
* from /xmlrpc.php so that we're replicating it as closely as possible. |
791
|
|
|
* |
792
|
|
|
* @deprecated since 7.7.0 |
793
|
|
|
* @see Automattic\Jetpack\Connection\Manager::alternate_xmlrpc() |
794
|
|
|
*/ |
795
|
|
View Code Duplication |
public function alternate_xmlrpc() { |
796
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.7', 'Automattic\\Jetpack\\Connection\\Manager::alternate_xmlrpc' ); |
797
|
|
|
|
798
|
|
|
if ( ! $this->connection_manager ) { |
799
|
|
|
$this->connection_manager = new Connection_Manager(); |
800
|
|
|
} |
801
|
|
|
|
802
|
|
|
$this->connection_manager->alternate_xmlrpc(); |
803
|
|
|
} |
804
|
|
|
|
805
|
|
|
/** |
806
|
|
|
* Removes all XML-RPC methods that are not `jetpack.*`. |
807
|
|
|
* Only used in our alternate XML-RPC endpoint, where we want to |
808
|
|
|
* ensure that Core and other plugins' methods are not exposed. |
809
|
|
|
* |
810
|
|
|
* @deprecated since 7.7.0 |
811
|
|
|
* @see Automattic\Jetpack\Connection\Manager::remove_non_jetpack_xmlrpc_methods() |
812
|
|
|
* |
813
|
|
|
* @param array $methods A list of registered WordPress XMLRPC methods. |
814
|
|
|
* @return array Filtered $methods |
815
|
|
|
*/ |
816
|
|
View Code Duplication |
public function remove_non_jetpack_xmlrpc_methods( $methods ) { |
817
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.7', 'Automattic\\Jetpack\\Connection\\Manager::remove_non_jetpack_xmlrpc_methods' ); |
818
|
|
|
|
819
|
|
|
if ( ! $this->connection_manager ) { |
820
|
|
|
$this->connection_manager = new Connection_Manager(); |
821
|
|
|
} |
822
|
|
|
|
823
|
|
|
return $this->connection_manager->remove_non_jetpack_xmlrpc_methods( $methods ); |
824
|
|
|
} |
825
|
|
|
|
826
|
|
|
/** |
827
|
|
|
* Initialize REST API registration connector. |
828
|
|
|
* |
829
|
|
|
* @deprecated since 7.7.0 |
830
|
|
|
* @see Automattic\Jetpack\Connection\Manager::initialize_rest_api_registration_connector() |
831
|
|
|
*/ |
832
|
|
View Code Duplication |
public function initialize_rest_api_registration_connector() { |
833
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.7', 'Automattic\\Jetpack\\Connection\\Manager::initialize_rest_api_registration_connector' ); |
834
|
|
|
|
835
|
|
|
if ( ! $this->connection_manager ) { |
836
|
|
|
$this->connection_manager = new Connection_Manager(); |
837
|
|
|
} |
838
|
|
|
|
839
|
|
|
$this->connection_manager->initialize_rest_api_registration_connector(); |
840
|
|
|
} |
841
|
|
|
|
842
|
|
|
/** |
843
|
|
|
* Sets up the XMLRPC request handlers. |
844
|
|
|
* |
845
|
|
|
* @deprecated since 7.7.0 |
846
|
|
|
* @see Automattic\Jetpack\Connection\Manager::setup_xmlrpc_handlers() |
847
|
|
|
* |
848
|
|
|
* @param array $request_params Incoming request parameters. |
849
|
|
|
* @param Boolean $is_active Whether the connection is currently active. |
850
|
|
|
* @param Boolean $is_signed Whether the signature check has been successful. |
851
|
|
|
* @param Jetpack_XMLRPC_Server $xmlrpc_server (optional) An instance of the server to use instead of instantiating a new one. |
|
|
|
|
852
|
|
|
*/ |
853
|
|
View Code Duplication |
public function setup_xmlrpc_handlers( |
854
|
|
|
$request_params, |
855
|
|
|
$is_active, |
856
|
|
|
$is_signed, |
857
|
|
|
Jetpack_XMLRPC_Server $xmlrpc_server = null |
858
|
|
|
) { |
859
|
|
|
_deprecated_function( __METHOD__, 'jetpack-7.7', 'Automattic\\Jetpack\\Connection\\Manager::setup_xmlrpc_handlers' ); |
860
|
|
|
|
861
|
|
|
if ( ! $this->connection_manager ) { |
862
|
|
|
$this->connection_manager = new Connection_Manager(); |
863
|
|
|
} |
864
|
|
|
|
865
|
|
|
return $this->connection_manager->setup_xmlrpc_handlers( |
866
|
|
|
$request_params, |
867
|
|
|
$is_active, |
868
|
|
|
$is_signed, |
869
|
|
|
$xmlrpc_server |
870
|
|
|
); |
871
|
|
|
} |
872
|
|
|
} |
873
|
|
|
|
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.