1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
require_once dirname( __FILE__ ) . '/class.json-api-date.php'; |
4
|
|
|
require_once dirname( __FILE__ ) . '/class.json-api-post-base.php'; |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* Base class for the Site Abstraction Layer (SAL) |
8
|
|
|
* Note that this is the site "as seen by user $user_id with token $token", which |
9
|
|
|
* is why we pass the token to the platform; these site instances are value objects |
10
|
|
|
* to be used in the context of a single request for a single user. |
11
|
|
|
* Also note that at present this class _assumes_ you've "switched to" |
12
|
|
|
* the site in question, and functions like `get_bloginfo( 'name' )` will |
13
|
|
|
* therefore return the correct value |
14
|
|
|
**/ |
15
|
|
|
abstract class SAL_Site { |
16
|
|
|
public $blog_id; |
17
|
|
|
public $platform; |
18
|
|
|
|
19
|
|
|
public function __construct( $blog_id, $platform ) { |
20
|
|
|
$this->blog_id = $blog_id; |
21
|
|
|
$this->platform = $platform; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
public function get_id() { |
25
|
|
|
return $this->blog_id; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function get_name() { |
29
|
|
|
return (string) htmlspecialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function get_description() { |
33
|
|
|
return (string) htmlspecialchars_decode( get_bloginfo( 'description' ), ENT_QUOTES ); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function get_url() { |
37
|
|
|
return (string) home_url(); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function get_post_count() { |
41
|
|
|
return (int) wp_count_posts( 'post' )->publish; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function get_quota() { |
45
|
|
|
return null; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
abstract public function has_videopress(); |
49
|
|
|
|
50
|
|
|
abstract public function upgraded_filetypes_enabled(); |
51
|
|
|
|
52
|
|
|
abstract public function is_mapped_domain(); |
53
|
|
|
|
54
|
|
|
abstract public function get_unmapped_url(); |
55
|
|
|
|
56
|
|
|
abstract public function is_redirect(); |
57
|
|
|
|
58
|
|
|
abstract public function is_headstart_fresh(); |
59
|
|
|
|
60
|
|
|
abstract public function featured_images_enabled(); |
61
|
|
|
|
62
|
|
|
abstract public function has_wordads(); |
63
|
|
|
|
64
|
|
|
abstract public function get_frame_nonce(); |
65
|
|
|
|
66
|
|
|
abstract public function get_jetpack_frame_nonce(); |
67
|
|
|
|
68
|
|
|
abstract public function allowed_file_types(); |
69
|
|
|
|
70
|
|
|
abstract public function get_post_formats(); |
71
|
|
|
|
72
|
|
|
abstract public function is_private(); |
73
|
|
|
|
74
|
|
|
abstract public function is_following(); |
75
|
|
|
|
76
|
|
|
abstract public function get_subscribers_count(); |
77
|
|
|
|
78
|
|
|
abstract public function get_locale(); |
79
|
|
|
|
80
|
|
|
abstract public function is_jetpack(); |
81
|
|
|
|
82
|
|
|
abstract public function get_jetpack_modules(); |
83
|
|
|
|
84
|
|
|
abstract public function is_module_active( $module ); |
85
|
|
|
|
86
|
|
|
abstract public function is_vip(); |
87
|
|
|
|
88
|
|
|
abstract public function is_multisite(); |
89
|
|
|
|
90
|
|
|
abstract public function is_single_user_site(); |
91
|
|
|
|
92
|
|
|
abstract public function get_plan(); |
93
|
|
|
|
94
|
|
|
abstract public function get_ak_vp_bundle_enabled(); |
95
|
|
|
|
96
|
|
|
abstract public function get_podcasting_archive(); |
97
|
|
|
|
98
|
|
|
abstract public function get_import_engine(); |
99
|
|
|
|
100
|
|
|
abstract public function get_jetpack_seo_front_page_description(); |
101
|
|
|
|
102
|
|
|
abstract public function get_jetpack_seo_title_formats(); |
103
|
|
|
|
104
|
|
|
abstract public function get_verification_services_codes(); |
105
|
|
|
|
106
|
|
|
abstract public function before_render(); |
107
|
|
|
|
108
|
|
|
abstract public function after_render( &$response ); |
109
|
|
|
|
110
|
|
|
// TODO - factor this out? Seems an odd thing to have on a site |
111
|
|
|
abstract public function after_render_options( &$options ); |
112
|
|
|
|
113
|
|
|
// wrap a WP_Post object with SAL methods |
114
|
|
|
abstract public function wrap_post( $post, $context ); |
115
|
|
|
|
116
|
|
|
abstract protected function is_a8c_publication( $post_id ); |
117
|
|
|
|
118
|
|
|
public function is_automated_transfer() { |
119
|
|
|
/** |
120
|
|
|
* Filter if a site is an automated-transfer site. |
121
|
|
|
* |
122
|
|
|
* @module json-api |
123
|
|
|
* |
124
|
|
|
* @since 6.4.0 |
125
|
|
|
* |
126
|
|
|
* @param bool is_automated_transfer( $this->blog_id ) |
127
|
|
|
* @param int $blog_id Blog identifier. |
128
|
|
|
*/ |
129
|
|
|
return apply_filters( |
130
|
|
|
'jetpack_site_automated_transfer', |
131
|
|
|
false, |
132
|
|
|
$this->blog_id |
133
|
|
|
); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
public function is_wpcom_atomic() { |
137
|
|
|
return false; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
public function is_wpcom_store() { |
141
|
|
|
return false; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
public function woocommerce_is_active() { |
145
|
|
|
return false; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
public function get_post_by_id( $post_id, $context ) { |
149
|
|
|
// Remove the skyword tracking shortcode for posts returned via the API. |
150
|
|
|
remove_shortcode( 'skyword-tracking' ); |
151
|
|
|
add_shortcode( 'skyword-tracking', '__return_empty_string' ); |
152
|
|
|
|
153
|
|
|
$post = get_post( $post_id, OBJECT, $context ); |
154
|
|
|
|
155
|
|
|
if ( ! $post ) { |
156
|
|
|
return new WP_Error( 'unknown_post', 'Unknown post', 404 ); |
|
|
|
|
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
$wrapped_post = $this->wrap_post( $post, $context ); |
160
|
|
|
|
161
|
|
|
// validate access |
162
|
|
|
return $this->validate_access( $wrapped_post ); |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* Validate current user can access the post |
167
|
|
|
* |
168
|
|
|
* @return WP_Error or post |
169
|
|
|
*/ |
170
|
|
|
private function validate_access( $post ) { |
171
|
|
|
$context = $post->context; |
172
|
|
|
|
173
|
|
|
if ( |
174
|
|
|
! $this->is_post_type_allowed( $post->post_type ) |
175
|
|
|
&& ! $this->is_a8c_publication( $post->ID ) |
176
|
|
|
) { |
177
|
|
|
return new WP_Error( 'unknown_post', 'Unknown post', 404 ); |
|
|
|
|
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
switch ( $context ) { |
181
|
|
|
case 'edit' : |
182
|
|
|
if ( ! current_user_can( 'edit_post', $post->ID ) ) { |
183
|
|
|
return new WP_Error( 'unauthorized', 'User cannot edit post', 403 ); |
|
|
|
|
184
|
|
|
} |
185
|
|
|
break; |
186
|
|
|
case 'display' : |
187
|
|
|
$can_view = $this->user_can_view_post( $post ); |
188
|
|
|
if ( is_wp_error( $can_view ) ) { |
189
|
|
|
return $can_view; |
190
|
|
|
} |
191
|
|
|
break; |
192
|
|
|
default : |
193
|
|
|
return new WP_Error( 'invalid_context', 'Invalid API CONTEXT', 400 ); |
|
|
|
|
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
return $post; |
197
|
|
|
} |
198
|
|
|
|
199
|
|
View Code Duplication |
public function current_user_can_access_post_type( $post_type, $context ) { |
200
|
|
|
$post_type_object = $this->get_post_type_object( $post_type ); |
201
|
|
|
if ( ! $post_type_object ) { |
202
|
|
|
return false; |
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
switch( $context ) { |
206
|
|
|
case 'edit': |
207
|
|
|
return current_user_can( $post_type_object->cap->edit_posts ); |
208
|
|
|
case 'display': |
209
|
|
|
return $post_type_object->public || current_user_can( $post_type_object->cap->read_private_posts ); |
210
|
|
|
default: |
211
|
|
|
return false; |
212
|
|
|
} |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
protected function get_post_type_object( $post_type ) { |
216
|
|
|
return get_post_type_object( $post_type ); |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
// copied from class.json-api-endpoints.php |
220
|
|
View Code Duplication |
public function is_post_type_allowed( $post_type ) { |
221
|
|
|
// if the post type is empty, that's fine, WordPress will default to post |
222
|
|
|
if ( empty( $post_type ) ) { |
223
|
|
|
return true; |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
// allow special 'any' type |
227
|
|
|
if ( 'any' == $post_type ) { |
228
|
|
|
return true; |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
// check for allowed types |
232
|
|
|
if ( in_array( $post_type, $this->get_whitelisted_post_types() ) ) { |
233
|
|
|
return true; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
if ( $post_type_object = get_post_type_object( $post_type ) ) { |
237
|
|
|
if ( ! empty( $post_type_object->show_in_rest ) ) { |
238
|
|
|
return $post_type_object->show_in_rest; |
239
|
|
|
} |
240
|
|
|
if ( ! empty( $post_type_object->publicly_queryable ) ) { |
241
|
|
|
return $post_type_object->publicly_queryable; |
242
|
|
|
} |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
return ! empty( $post_type_object->public ); |
246
|
|
|
} |
247
|
|
|
|
248
|
|
|
// copied from class.json-api-endpoints.php |
249
|
|
|
/** |
250
|
|
|
* Gets the whitelisted post types that JP should allow access to. |
251
|
|
|
* |
252
|
|
|
* @return array Whitelisted post types. |
253
|
|
|
*/ |
254
|
|
View Code Duplication |
public function get_whitelisted_post_types() { |
255
|
|
|
$allowed_types = array( 'post', 'page', 'revision' ); |
256
|
|
|
|
257
|
|
|
/** |
258
|
|
|
* Filter the post types Jetpack has access to, and can synchronize with WordPress.com. |
259
|
|
|
* |
260
|
|
|
* @module json-api |
261
|
|
|
* |
262
|
|
|
* @since 2.2.3 |
263
|
|
|
* |
264
|
|
|
* @param array $allowed_types Array of whitelisted post types. Default to `array( 'post', 'page', 'revision' )`. |
265
|
|
|
*/ |
266
|
|
|
$allowed_types = apply_filters( 'rest_api_allowed_post_types', $allowed_types ); |
267
|
|
|
|
268
|
|
|
return array_unique( $allowed_types ); |
269
|
|
|
} |
270
|
|
|
|
271
|
|
|
// copied and modified a little from class.json-api-endpoints.php |
272
|
|
|
private function user_can_view_post( $post ) { |
273
|
|
|
if ( !$post || is_wp_error( $post ) ) { |
274
|
|
|
return false; |
275
|
|
|
} |
276
|
|
|
|
277
|
|
View Code Duplication |
if ( 'inherit' === $post->post_status ) { |
278
|
|
|
$parent_post = get_post( $post->post_parent ); |
279
|
|
|
$post_status_obj = get_post_status_object( $parent_post->post_status ); |
280
|
|
|
} else { |
281
|
|
|
$post_status_obj = get_post_status_object( $post->post_status ); |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
$authorized = ( |
285
|
|
|
$post_status_obj->public || |
286
|
|
|
( is_user_logged_in() && |
287
|
|
|
( |
288
|
|
|
( $post_status_obj->protected && current_user_can( 'edit_post', $post->ID ) ) || |
289
|
|
|
( $post_status_obj->private && current_user_can( 'read_post', $post->ID ) ) || |
290
|
|
|
( 'trash' === $post->post_status && current_user_can( 'edit_post', $post->ID ) ) || |
291
|
|
|
'auto-draft' === $post->post_status |
292
|
|
|
) |
293
|
|
|
) |
294
|
|
|
); |
295
|
|
|
|
296
|
|
|
if ( ! $authorized ) { |
297
|
|
|
return new WP_Error( 'unauthorized', 'User cannot view post', 403 ); |
|
|
|
|
298
|
|
|
} |
299
|
|
|
|
300
|
|
View Code Duplication |
if ( |
301
|
|
|
-1 == get_option( 'blog_public' ) && |
302
|
|
|
/** |
303
|
|
|
* Filter access to a specific post. |
304
|
|
|
* |
305
|
|
|
* @module json-api |
306
|
|
|
* |
307
|
|
|
* @since 3.4.0 |
308
|
|
|
* |
309
|
|
|
* @param bool current_user_can( 'read_post', $post->ID ) Can the current user access the post. |
310
|
|
|
* @param WP_Post $post Post data. |
311
|
|
|
*/ |
312
|
|
|
! apply_filters( |
313
|
|
|
'wpcom_json_api_user_can_view_post', |
314
|
|
|
current_user_can( 'read_post', $post->ID ), |
315
|
|
|
$post |
316
|
|
|
) |
317
|
|
|
) { |
318
|
|
|
return new WP_Error( 'unauthorized', 'User cannot view post', array( 'status_code' => 403, 'error' => 'private_blog' ) ); |
|
|
|
|
319
|
|
|
} |
320
|
|
|
|
321
|
|
View Code Duplication |
if ( strlen( $post->post_password ) && !current_user_can( 'edit_post', $post->ID ) ) { |
322
|
|
|
return new WP_Error( 'unauthorized', 'User cannot view password protected post', array( 'status_code' => 403, 'error' => 'password_protected' ) ); |
|
|
|
|
323
|
|
|
} |
324
|
|
|
|
325
|
|
|
return true; |
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
/** |
329
|
|
|
* Get post ID by name |
330
|
|
|
* |
331
|
|
|
* Attempts to match name on post title and page path |
332
|
|
|
* |
333
|
|
|
* @param string $name |
334
|
|
|
* |
335
|
|
|
* @return int|object Post ID on success, WP_Error object on failure |
336
|
|
|
*/ |
337
|
|
|
public function get_post_id_by_name( $name ) { |
338
|
|
|
$name = sanitize_title( $name ); |
339
|
|
|
|
340
|
|
|
if ( ! $name ) { |
341
|
|
|
return new WP_Error( 'invalid_post', 'Invalid post', 400 ); |
|
|
|
|
342
|
|
|
} |
343
|
|
|
|
344
|
|
|
$posts = get_posts( array( |
345
|
|
|
'name' => $name, |
346
|
|
|
'numberposts' => 1, |
347
|
|
|
'post_type' => $this->get_whitelisted_post_types(), |
348
|
|
|
) ); |
349
|
|
|
|
350
|
|
|
if ( ! $posts || ! isset( $posts[0]->ID ) || ! $posts[0]->ID ) { |
351
|
|
|
$page = get_page_by_path( $name ); |
352
|
|
|
|
353
|
|
|
if ( ! $page ) { |
354
|
|
|
return new WP_Error( 'unknown_post', 'Unknown post', 404 ); |
|
|
|
|
355
|
|
|
} |
356
|
|
|
|
357
|
|
|
return $page->ID; |
358
|
|
|
} |
359
|
|
|
|
360
|
|
|
return (int) $posts[0]->ID; |
361
|
|
|
} |
362
|
|
|
|
363
|
|
|
/** |
364
|
|
|
* Get post by name |
365
|
|
|
* |
366
|
|
|
* Attempts to match name on post title and page path |
367
|
|
|
* |
368
|
|
|
* @param string $name |
369
|
|
|
* @param string $context (display or edit) |
370
|
|
|
* |
371
|
|
|
* @return object Post object on success, WP_Error object on failure |
372
|
|
|
**/ |
373
|
|
|
public function get_post_by_name( $name, $context ) { |
374
|
|
|
$post_id = $this->get_post_id_by_name( $name ); |
375
|
|
|
if ( is_wp_error( $post_id ) ) { |
376
|
|
|
return $post_id; |
377
|
|
|
} |
378
|
|
|
|
379
|
|
|
return $this->get_post_by_id( $post_id, $context ); |
380
|
|
|
} |
381
|
|
|
|
382
|
|
|
function user_can_manage() { |
383
|
|
|
current_user_can( 'manage_options' ); |
384
|
|
|
} |
385
|
|
|
|
386
|
|
|
function get_xmlrpc_url() { |
387
|
|
|
$xmlrpc_scheme = apply_filters( 'wpcom_json_api_xmlrpc_scheme', wp_parse_url( get_option( 'home' ), PHP_URL_SCHEME ) ); |
388
|
|
|
return site_url( 'xmlrpc.php', $xmlrpc_scheme ); |
389
|
|
|
} |
390
|
|
|
|
391
|
|
|
function get_registered_date() { |
392
|
|
|
if ( function_exists( 'get_blog_details' ) ) { |
393
|
|
|
$blog_details = get_blog_details(); |
394
|
|
|
if ( ! empty( $blog_details->registered ) ) { |
395
|
|
|
return WPCOM_JSON_API_Date::format_date( $blog_details->registered ); |
396
|
|
|
} |
397
|
|
|
} |
398
|
|
|
|
399
|
|
|
return '0000-00-00T00:00:00+00:00'; |
400
|
|
|
} |
401
|
|
|
|
402
|
|
|
function get_capabilities() { |
403
|
|
|
return array( |
404
|
|
|
'edit_pages' => current_user_can( 'edit_pages' ), |
405
|
|
|
'edit_posts' => current_user_can( 'edit_posts' ), |
406
|
|
|
'edit_others_posts' => current_user_can( 'edit_others_posts' ), |
407
|
|
|
'edit_others_pages' => current_user_can( 'edit_others_pages' ), |
408
|
|
|
'delete_posts' => current_user_can( 'delete_posts' ), |
409
|
|
|
'delete_others_posts' => current_user_can( 'delete_others_posts' ), |
410
|
|
|
'edit_theme_options' => current_user_can( 'edit_theme_options' ), |
411
|
|
|
'edit_users' => current_user_can( 'edit_users' ), |
412
|
|
|
'list_users' => current_user_can( 'list_users' ), |
413
|
|
|
'manage_categories' => current_user_can( 'manage_categories' ), |
414
|
|
|
'manage_options' => current_user_can( 'manage_options' ), |
415
|
|
|
'moderate_comments' => current_user_can( 'moderate_comments' ), |
416
|
|
|
'activate_wordads' => wpcom_get_blog_owner() === (int) get_current_user_id(), |
417
|
|
|
'promote_users' => current_user_can( 'promote_users' ), |
418
|
|
|
'publish_posts' => current_user_can( 'publish_posts' ), |
419
|
|
|
'upload_files' => current_user_can( 'upload_files' ), |
420
|
|
|
'delete_users' => current_user_can( 'delete_users' ), |
421
|
|
|
'remove_users' => current_user_can( 'remove_users' ), |
422
|
|
|
'view_stats' => stats_is_blog_user( $this->blog_id ) |
423
|
|
|
); |
424
|
|
|
} |
425
|
|
|
|
426
|
|
|
function is_visible() { |
427
|
|
|
if ( is_user_logged_in() ) { |
428
|
|
|
$current_user = wp_get_current_user(); |
429
|
|
|
$visible = (array) get_user_meta( $current_user->ID, 'blog_visibility', true ); |
430
|
|
|
|
431
|
|
|
$is_visible = true; |
432
|
|
|
if ( isset( $visible[ $this->blog_id ] ) ) { |
433
|
|
|
$is_visible = (bool) $visible[ $this->blog_id ]; |
434
|
|
|
} |
435
|
|
|
|
436
|
|
|
// null and true are visible |
437
|
|
|
return $is_visible; |
438
|
|
|
} |
439
|
|
|
|
440
|
|
|
return null; |
441
|
|
|
} |
442
|
|
|
|
443
|
|
|
function get_logo() { |
444
|
|
|
|
445
|
|
|
// Set an empty response array. |
446
|
|
|
$logo_setting = array( |
447
|
|
|
'id' => (int) 0, |
448
|
|
|
'sizes' => array(), |
449
|
|
|
'url' => '', |
450
|
|
|
); |
451
|
|
|
|
452
|
|
|
// Get current site logo values. |
453
|
|
|
$logo = get_option( 'site_logo' ); |
454
|
|
|
|
455
|
|
|
// Update the response array if there's a site logo currenty active. |
456
|
|
|
if ( $logo && 0 != $logo['id'] ) { |
457
|
|
|
$logo_setting['id'] = $logo['id']; |
458
|
|
|
$logo_setting['url'] = $logo['url']; |
459
|
|
|
|
460
|
|
|
foreach ( $logo['sizes'] as $size => $properties ) { |
461
|
|
|
$logo_setting['sizes'][ $size ] = $properties; |
462
|
|
|
} |
463
|
|
|
} |
464
|
|
|
|
465
|
|
|
return $logo_setting; |
466
|
|
|
} |
467
|
|
|
|
468
|
|
|
function get_timezone() { |
469
|
|
|
return (string) get_option( 'timezone_string' ); |
470
|
|
|
} |
471
|
|
|
|
472
|
|
|
function get_gmt_offset() { |
473
|
|
|
return (float) get_option( 'gmt_offset' ); |
474
|
|
|
} |
475
|
|
|
|
476
|
|
|
function get_login_url() { |
477
|
|
|
return wp_login_url(); |
478
|
|
|
} |
479
|
|
|
|
480
|
|
|
function get_admin_url() { |
481
|
|
|
return get_admin_url(); |
482
|
|
|
} |
483
|
|
|
|
484
|
|
|
function get_theme_slug() { |
485
|
|
|
return get_option( 'stylesheet' ); |
486
|
|
|
} |
487
|
|
|
|
488
|
|
|
function get_header_image() { |
489
|
|
|
return get_theme_mod( 'header_image_data' ); |
490
|
|
|
} |
491
|
|
|
|
492
|
|
|
function get_background_color() { |
493
|
|
|
return get_theme_mod( 'background_color' ); |
494
|
|
|
} |
495
|
|
|
|
496
|
|
|
function get_image_default_link_type() { |
497
|
|
|
return get_option( 'image_default_link_type' ); |
498
|
|
|
} |
499
|
|
|
|
500
|
|
|
function get_image_thumbnail_width() { |
501
|
|
|
return (int) get_option( 'thumbnail_size_w' ); |
502
|
|
|
} |
503
|
|
|
|
504
|
|
|
function get_image_thumbnail_height() { |
505
|
|
|
return (int) get_option( 'thumbnail_size_h' ); |
506
|
|
|
} |
507
|
|
|
|
508
|
|
|
function get_image_thumbnail_crop() { |
509
|
|
|
return get_option( 'thumbnail_crop' ); |
510
|
|
|
} |
511
|
|
|
|
512
|
|
|
function get_image_medium_width() { |
513
|
|
|
return (int) get_option( 'medium_size_w' ); |
514
|
|
|
} |
515
|
|
|
|
516
|
|
|
function get_image_medium_height() { |
517
|
|
|
return (int) get_option( 'medium_size_h' ); |
518
|
|
|
} |
519
|
|
|
|
520
|
|
|
function get_image_large_width() { |
521
|
|
|
return (int) get_option( 'large_size_w' ); |
522
|
|
|
} |
523
|
|
|
|
524
|
|
|
function get_image_large_height() { |
525
|
|
|
return (int) get_option( 'large_size_h' ); |
526
|
|
|
} |
527
|
|
|
|
528
|
|
|
function get_permalink_structure() { |
529
|
|
|
return get_option( 'permalink_structure' ); |
530
|
|
|
} |
531
|
|
|
|
532
|
|
|
function get_default_post_format() { |
533
|
|
|
return get_option( 'default_post_format' ); |
534
|
|
|
} |
535
|
|
|
|
536
|
|
|
function get_default_category() { |
537
|
|
|
return (int) get_option( 'default_category' ); |
538
|
|
|
} |
539
|
|
|
|
540
|
|
|
function get_show_on_front() { |
541
|
|
|
return get_option( 'show_on_front' ); |
542
|
|
|
} |
543
|
|
|
|
544
|
|
|
function is_custom_front_page() { |
545
|
|
|
return ( 'page' === $this->get_show_on_front() ); |
546
|
|
|
} |
547
|
|
|
|
548
|
|
|
function get_default_likes_enabled() { |
549
|
|
|
return (bool) apply_filters( 'wpl_is_enabled_sitewide', ! get_option( 'disabled_likes' ) ); |
550
|
|
|
} |
551
|
|
|
|
552
|
|
|
function get_default_sharing_status() { |
553
|
|
|
$default_sharing_status = false; |
554
|
|
|
if ( class_exists( 'Sharing_Service' ) ) { |
555
|
|
|
$ss = new Sharing_Service(); |
556
|
|
|
$blog_services = $ss->get_blog_services(); |
557
|
|
|
$default_sharing_status = ! empty( $blog_services['visible'] ); |
558
|
|
|
} |
559
|
|
|
return (bool) $default_sharing_status; |
560
|
|
|
} |
561
|
|
|
|
562
|
|
|
function get_default_comment_status() { |
563
|
|
|
return 'closed' !== get_option( 'default_comment_status' ); |
564
|
|
|
} |
565
|
|
|
|
566
|
|
|
function default_ping_status() { |
567
|
|
|
return 'closed' !== get_option( 'default_ping_status' ); |
568
|
|
|
} |
569
|
|
|
|
570
|
|
|
function is_publicize_permanently_disabled() { |
571
|
|
|
$publicize_permanently_disabled = false; |
572
|
|
|
if ( function_exists( 'is_publicize_permanently_disabled' ) ) { |
573
|
|
|
$publicize_permanently_disabled = is_publicize_permanently_disabled( $this->blog_id ); |
574
|
|
|
} |
575
|
|
|
return $publicize_permanently_disabled; |
576
|
|
|
} |
577
|
|
|
|
578
|
|
|
function get_page_on_front() { |
579
|
|
|
return (int) get_option( 'page_on_front' ); |
580
|
|
|
} |
581
|
|
|
|
582
|
|
|
function get_page_for_posts() { |
583
|
|
|
return (int) get_option( 'page_for_posts' ); |
584
|
|
|
} |
585
|
|
|
|
586
|
|
|
function is_headstart() { |
587
|
|
|
return get_option( 'headstart' ); |
588
|
|
|
} |
589
|
|
|
|
590
|
|
|
function get_wordpress_version() { |
591
|
|
|
global $wp_version; |
592
|
|
|
return $wp_version; |
593
|
|
|
} |
594
|
|
|
|
595
|
|
|
function is_domain_only() { |
596
|
|
|
$options = get_option( 'options' ); |
597
|
|
|
return ! empty ( $options['is_domain_only'] ) ? (bool) $options['is_domain_only'] : false; |
598
|
|
|
} |
599
|
|
|
|
600
|
|
|
function get_blog_public() { |
601
|
|
|
return (int) get_option( 'blog_public' ); |
602
|
|
|
} |
603
|
|
|
|
604
|
|
|
function has_pending_automated_transfer() { |
605
|
|
|
/** |
606
|
|
|
* Filter if a site is in pending automated transfer state. |
607
|
|
|
* |
608
|
|
|
* @module json-api |
609
|
|
|
* |
610
|
|
|
* @since 6.4.0 |
611
|
|
|
* |
612
|
|
|
* @param bool has_site_pending_automated_transfer( $this->blog_id ) |
613
|
|
|
* @param int $blog_id Blog identifier. |
614
|
|
|
*/ |
615
|
|
|
return apply_filters( |
616
|
|
|
'jetpack_site_pending_automated_transfer', |
617
|
|
|
false, |
618
|
|
|
$this->blog_id |
619
|
|
|
); |
620
|
|
|
} |
621
|
|
|
|
622
|
|
|
function signup_is_store() { |
623
|
|
|
return $this->get_design_type() === 'store'; |
624
|
|
|
} |
625
|
|
|
|
626
|
|
|
function get_roles() { |
627
|
|
|
return new WP_Roles(); |
628
|
|
|
} |
629
|
|
|
|
630
|
|
|
function get_design_type() { |
631
|
|
|
$options = get_option( 'options' ); |
632
|
|
|
return empty( $options[ 'designType'] ) ? null : $options[ 'designType' ]; |
633
|
|
|
} |
634
|
|
|
|
635
|
|
|
function get_site_goals() { |
636
|
|
|
$options = get_option( 'options' ); |
637
|
|
|
return empty( $options[ 'siteGoals'] ) ? null : $options[ 'siteGoals' ]; |
638
|
|
|
} |
639
|
|
|
|
640
|
|
|
function get_launch_status() { |
641
|
|
|
return false; |
642
|
|
|
} |
643
|
|
|
|
644
|
|
|
function get_migration_status() { |
645
|
|
|
return false; |
646
|
|
|
} |
647
|
|
|
|
648
|
|
|
function get_site_segment() { |
649
|
|
|
return false; |
650
|
|
|
} |
651
|
|
|
} |
652
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.