Completed
Push — fusion-sync/undemian/r217904-w... ( a75af8 )
by
unknown
26:50 queued 17:42
created

SAL_Site::get_post_count()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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_coming_soon();
75
76
	abstract public function is_following();
77
78
	abstract public function get_subscribers_count();
79
80
	abstract public function get_locale();
81
82
	/**
83
	 * The flag indicates that the site has Jetpack installed
84
	 *
85
	 * @return bool
86
	 */
87
	abstract public function is_jetpack();
88
89
	/**
90
	 * The flag indicates that the site is connected to WP.com via Jetpack Connection
91
	 *
92
	 * @return bool
93
	 */
94
	abstract public function is_jetpack_connection();
95
96
	abstract public function get_jetpack_modules();
97
98
	abstract public function is_module_active( $module );
99
100
	abstract public function is_vip();
101
102
	abstract public function is_multisite();
103
104
	abstract public function is_single_user_site();
105
106
	abstract public function get_plan();
107
108
	abstract public function get_ak_vp_bundle_enabled();
109
110
	abstract public function get_podcasting_archive();
111
112
	abstract public function get_import_engine();
113
114
	abstract public function get_jetpack_seo_front_page_description();
115
116
	abstract public function get_jetpack_seo_title_formats();
117
118
	abstract public function get_verification_services_codes();
119
120
	abstract public function before_render();
121
122
	abstract public function after_render( &$response );
123
124
	// TODO - factor this out? Seems an odd thing to have on a site
125
	abstract public function after_render_options( &$options );
126
127
	// wrap a WP_Post object with SAL methods
128
	abstract public function wrap_post( $post, $context );
129
130
	abstract protected function is_a8c_publication( $post_id );
131
132
	public function is_automated_transfer() {
133
		/**
134
		 * Filter if a site is an automated-transfer site.
135
		 *
136
		 * @module json-api
137
		 *
138
		 * @since 6.4.0
139
		 *
140
		 * @param bool is_automated_transfer( $this->blog_id )
141
		 * @param int  $blog_id Blog identifier.
142
		 */
143
		return apply_filters(
144
			'jetpack_site_automated_transfer',
145
			false,
146
			$this->blog_id
0 ignored issues
show
Unused Code introduced by
The call to apply_filters() has too many arguments starting with $this->blog_id.

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.

Loading history...
147
		);
148
	}
149
150
	abstract protected function is_wpforteams_site();
151
152
	public function get_p2_organization_id() {
153
		return 0; // WPForTeams\Constants\NO_ORG_ID not loaded
154
	}
155
156
	public function is_wpcom_atomic() {
157
		return false;
158
	}
159
160
	public function is_wpcom_store() {
161
		return false;
162
	}
163
164
	public function woocommerce_is_active() {
165
		return false;
166
	}
167
168
	public function is_cloud_eligible() {
169
		return false;
170
	}
171
172
	public function get_products() {
173
		return array();
174
	}
175
176
	public function get_post_by_id( $post_id, $context ) {
177
		$post = get_post( $post_id, OBJECT, $context );
178
179
		if ( ! $post ) {
180
			return new WP_Error( 'unknown_post', 'Unknown post', 404 );
0 ignored issues
show
Unused Code introduced by
The call to WP_Error::__construct() has too many arguments starting with 'unknown_post'.

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.

Loading history...
181
		}
182
183
		$wrapped_post = $this->wrap_post( $post, $context );
184
185
		// validate access
186
		return $this->validate_access( $wrapped_post );
187
	}
188
189
	/**
190
	 * Validate current user can access the post
191
	 *
192
	 * @return WP_Error or post
193
	 */
194
	private function validate_access( $post ) {
195
		$context = $post->context;
196
197
		if (
198
			! $this->is_post_type_allowed( $post->post_type )
199
			&& ! $this->is_a8c_publication( $post->ID )
200
		) {
201
			return new WP_Error( 'unknown_post', 'Unknown post', 404 );
0 ignored issues
show
Unused Code introduced by
The call to WP_Error::__construct() has too many arguments starting with 'unknown_post'.

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.

Loading history...
202
		}
203
204
		switch ( $context ) {
205
		case 'edit' :
206
			if ( ! current_user_can( 'edit_post', $post->ID ) ) {
207
				return new WP_Error( 'unauthorized', 'User cannot edit post', 403 );
0 ignored issues
show
Unused Code introduced by
The call to WP_Error::__construct() has too many arguments starting with 'unauthorized'.

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.

Loading history...
208
			}
209
			break;
210
		case 'display' :
211
			$can_view = $this->user_can_view_post( $post );
212
			if ( is_wp_error( $can_view ) ) {
213
				return $can_view;
214
			}
215
			break;
216
		default :
217
			return new WP_Error( 'invalid_context', 'Invalid API CONTEXT', 400 );
0 ignored issues
show
Unused Code introduced by
The call to WP_Error::__construct() has too many arguments starting with 'invalid_context'.

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.

Loading history...
218
		}
219
220
		return $post;
221
	}
222
223 View Code Duplication
	public function current_user_can_access_post_type( $post_type, $context ) {
224
		$post_type_object = $this->get_post_type_object( $post_type );
225
		if ( ! $post_type_object ) {
226
			return false;
227
		}
228
229
		switch( $context ) {
230
			case 'edit':
231
				return current_user_can( $post_type_object->cap->edit_posts );
232
			case 'display':
233
				return $post_type_object->public || current_user_can( $post_type_object->cap->read_private_posts );
234
			default:
235
				return false;
236
		}
237
	}
238
239
	protected function get_post_type_object( $post_type ) {
240
		return get_post_type_object( $post_type );
241
	}
242
243
	// copied from class.json-api-endpoints.php
244 View Code Duplication
	public function is_post_type_allowed( $post_type ) {
245
		// if the post type is empty, that's fine, WordPress will default to post
246
		if ( empty( $post_type ) ) {
247
			return true;
248
		}
249
250
		// allow special 'any' type
251
		if ( 'any' == $post_type ) {
252
			return true;
253
		}
254
255
		// check for allowed types
256
		if ( in_array( $post_type, $this->get_whitelisted_post_types() ) ) {
257
			return true;
258
		}
259
260
		if ( $post_type_object = get_post_type_object( $post_type ) ) {
261
			if ( ! empty( $post_type_object->show_in_rest ) ) {
262
				return $post_type_object->show_in_rest;
263
			}
264
			if ( ! empty( $post_type_object->publicly_queryable ) ) {
265
				return $post_type_object->publicly_queryable;
266
			}
267
		}
268
269
		return ! empty( $post_type_object->public );
270
	}
271
272
	// copied from class.json-api-endpoints.php
273
	/**
274
	 * Gets the whitelisted post types that JP should allow access to.
275
	 *
276
	 * @return array Whitelisted post types.
277
	 */
278 View Code Duplication
	public function get_whitelisted_post_types() {
279
		$allowed_types = array( 'post', 'page', 'revision' );
280
281
		/**
282
		 * Filter the post types Jetpack has access to, and can synchronize with WordPress.com.
283
		 *
284
		 * @module json-api
285
		 *
286
		 * @since 2.2.3
287
		 *
288
		 * @param array $allowed_types Array of whitelisted post types. Default to `array( 'post', 'page', 'revision' )`.
289
		 */
290
		$allowed_types = apply_filters( 'rest_api_allowed_post_types', $allowed_types );
291
292
		return array_unique( $allowed_types );
293
	}
294
295
	// copied and modified a little from class.json-api-endpoints.php
296
	private function user_can_view_post( $post ) {
297
		if ( !$post || is_wp_error( $post ) ) {
298
			return false;
299
		}
300
301 View Code Duplication
		if ( 'inherit' === $post->post_status ) {
302
			$parent_post = get_post( $post->post_parent );
303
			$post_status_obj = get_post_status_object( $parent_post->post_status );
304
		} else {
305
			$post_status_obj = get_post_status_object( $post->post_status );
306
		}
307
308
		$authorized = (
309
			$post_status_obj->public ||
310
			( is_user_logged_in() &&
311
				(
312
					( $post_status_obj->protected    && current_user_can( 'edit_post', $post->ID ) ) ||
313
					( $post_status_obj->private      && current_user_can( 'read_post', $post->ID ) ) ||
314
					( 'trash' === $post->post_status && current_user_can( 'edit_post', $post->ID ) ) ||
315
					'auto-draft' === $post->post_status
316
				)
317
			)
318
		);
319
320
		if ( ! $authorized ) {
321
			return new WP_Error( 'unauthorized', 'User cannot view post', 403 );
0 ignored issues
show
Unused Code introduced by
The call to WP_Error::__construct() has too many arguments starting with 'unauthorized'.

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.

Loading history...
322
		}
323
324 View Code Duplication
		if (
325
			-1 == get_option( 'blog_public' ) &&
326
			/**
327
			 * Filter access to a specific post.
328
			 *
329
			 * @module json-api
330
			 *
331
			 * @since 3.4.0
332
			 *
333
			 * @param bool current_user_can( 'read_post', $post->ID ) Can the current user access the post.
334
			 * @param WP_Post $post Post data.
335
			 */
336
			! apply_filters(
337
				'wpcom_json_api_user_can_view_post',
338
				current_user_can( 'read_post', $post->ID ),
339
				$post
0 ignored issues
show
Unused Code introduced by
The call to apply_filters() has too many arguments starting with $post.

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.

Loading history...
340
			)
341
		) {
342
			return new WP_Error( 'unauthorized', 'User cannot view post', array( 'status_code' => 403, 'error' => 'private_blog' ) );
0 ignored issues
show
Unused Code introduced by
The call to WP_Error::__construct() has too many arguments starting with 'unauthorized'.

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.

Loading history...
343
		}
344
345 View Code Duplication
		if ( strlen( $post->post_password ) && !current_user_can( 'edit_post', $post->ID ) ) {
346
			return new WP_Error( 'unauthorized', 'User cannot view password protected post', array( 'status_code' => 403, 'error' => 'password_protected' ) );
0 ignored issues
show
Unused Code introduced by
The call to WP_Error::__construct() has too many arguments starting with 'unauthorized'.

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.

Loading history...
347
		}
348
349
		return true;
350
	}
351
352
	/**
353
	 * Get post ID by name
354
	 *
355
	 * Attempts to match name on post title and page path
356
	 *
357
	 * @param string $name
358
	 *
359
	 * @return int|object Post ID on success, WP_Error object on failure
360
	 */
361
	public function get_post_id_by_name( $name ) {
362
		$name = sanitize_title( $name );
363
364
		if ( ! $name ) {
365
			return new WP_Error( 'invalid_post', 'Invalid post', 400 );
0 ignored issues
show
Unused Code introduced by
The call to WP_Error::__construct() has too many arguments starting with 'invalid_post'.

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.

Loading history...
366
		}
367
368
		$posts = get_posts( array(
369
			'name' => $name,
370
			'numberposts' => 1,
371
			'post_type' => $this->get_whitelisted_post_types(),
372
		) );
373
374
		if ( ! $posts || ! isset( $posts[0]->ID ) || ! $posts[0]->ID ) {
375
			$page = get_page_by_path( $name );
376
377
			if ( ! $page ) {
378
				return new WP_Error( 'unknown_post', 'Unknown post', 404 );
0 ignored issues
show
Unused Code introduced by
The call to WP_Error::__construct() has too many arguments starting with 'unknown_post'.

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.

Loading history...
379
			}
380
381
			return $page->ID;
382
		}
383
384
		return (int) $posts[0]->ID;
385
	}
386
387
	/**
388
	 * Get post by name
389
	 *
390
	 * Attempts to match name on post title and page path
391
	 *
392
	 * @param string $name
393
	 * @param string $context (display or edit)
394
	 *
395
	 * @return object Post object on success, WP_Error object on failure
396
	 **/
397
	public function get_post_by_name( $name, $context ) {
398
		$post_id = $this->get_post_id_by_name( $name );
399
		if ( is_wp_error( $post_id ) ) {
400
			return $post_id;
401
		}
402
403
		return $this->get_post_by_id( $post_id, $context );
404
	}
405
406
	function user_can_manage() {
407
		current_user_can( 'manage_options' );
408
	}
409
410
	function get_xmlrpc_url() {
411
		$xmlrpc_scheme = apply_filters( 'wpcom_json_api_xmlrpc_scheme', wp_parse_url( get_option( 'home' ), PHP_URL_SCHEME ) );
412
		return site_url( 'xmlrpc.php', $xmlrpc_scheme );
413
	}
414
415
	function get_registered_date() {
416
		if ( function_exists( 'get_blog_details' ) ) {
417
			$blog_details = get_blog_details();
418
			if ( ! empty( $blog_details->registered ) ) {
419
				return WPCOM_JSON_API_Date::format_date( $blog_details->registered );
420
			}
421
		}
422
423
		return '0000-00-00T00:00:00+00:00';
424
	}
425
426
	function get_capabilities() {
427
		$is_wpcom_blog_owner = wpcom_get_blog_owner() === (int) get_current_user_id();
428
429
		return array(
430
			'edit_pages'          => current_user_can( 'edit_pages' ),
431
			'edit_posts'          => current_user_can( 'edit_posts' ),
432
			'edit_others_posts'   => current_user_can( 'edit_others_posts' ),
433
			'edit_others_pages'   => current_user_can( 'edit_others_pages' ),
434
			'delete_posts'        => current_user_can( 'delete_posts' ),
435
			'delete_others_posts' => current_user_can( 'delete_others_posts' ),
436
			'edit_theme_options'  => current_user_can( 'edit_theme_options' ),
437
			'edit_users'          => current_user_can( 'edit_users' ),
438
			'list_users'          => current_user_can( 'list_users' ),
439
			'manage_categories'   => current_user_can( 'manage_categories' ),
440
			'manage_options'      => current_user_can( 'manage_options' ),
441
			'moderate_comments'   => current_user_can( 'moderate_comments' ),
442
			'activate_wordads'    => $is_wpcom_blog_owner,
443
			'promote_users'       => current_user_can( 'promote_users' ),
444
			'publish_posts'       => current_user_can( 'publish_posts' ),
445
			'upload_files'        => current_user_can( 'upload_files' ),
446
			'delete_users'        => current_user_can( 'delete_users' ),
447
			'remove_users'        => current_user_can( 'remove_users' ),
448
			'own_site'            => $is_wpcom_blog_owner,
449
			/**
450
		 	 * Filter whether the Hosting section in Calypso should be available for site.
451
			 *
452
			 * @module json-api
453
			 *
454
			 * @since 8.2.0
455
			 *
456
			 * @param bool $view_hosting Can site access Hosting section. Default to false.
457
			 */
458
			'view_hosting'        => apply_filters( 'jetpack_json_api_site_can_view_hosting', false ),
459
			'view_stats'          => stats_is_blog_user( $this->blog_id )
460
		);
461
	}
462
463
	function is_visible() {
464
		if ( is_user_logged_in() ) {
465
			$current_user = wp_get_current_user();
466
			$visible      = (array) get_user_meta( $current_user->ID, 'blog_visibility', true );
467
468
			$is_visible = true;
469
			if ( isset( $visible[ $this->blog_id ] ) ) {
470
				$is_visible = (bool) $visible[ $this->blog_id ];
471
			}
472
473
			// null and true are visible
474
			return $is_visible;
475
		}
476
477
		return null;
478
	}
479
480
	function get_logo() {
481
482
		// Set an empty response array.
483
		$logo_setting = array(
484
			'id'    => (int) 0,
485
			'sizes' => array(),
486
			'url'   => '',
487
		);
488
489
		// Get current site logo values.
490
		$logo = get_option( 'site_logo' );
491
492
		// Update the response array if there's a site logo currenty active.
493
		if ( $logo && 0 != $logo['id'] ) {
494
			$logo_setting['id']  = $logo['id'];
495
			$logo_setting['url'] = $logo['url'];
496
497
			foreach ( $logo['sizes'] as $size => $properties ) {
498
				$logo_setting['sizes'][ $size ] = $properties;
499
			}
500
		}
501
502
		return $logo_setting;
503
	}
504
505
	function get_timezone() {
506
		return (string) get_option( 'timezone_string' );
507
	}
508
509
	function get_gmt_offset() {
510
		return (float) get_option( 'gmt_offset' );
511
	}
512
513
	function get_login_url() {
514
		return wp_login_url();
515
	}
516
517
	function get_admin_url() {
518
		return get_admin_url();
519
	}
520
521
	function get_theme_slug() {
522
		return get_option( 'stylesheet' );
523
	}
524
525
	function get_header_image() {
526
		return get_theme_mod( 'header_image_data' );
527
	}
528
529
	function get_background_color() {
530
		return get_theme_mod( 'background_color' );
531
	}
532
533
	function get_image_default_link_type() {
534
		return get_option( 'image_default_link_type' );
535
	}
536
537
	function get_image_thumbnail_width() {
538
		return (int) get_option( 'thumbnail_size_w' );
539
	}
540
541
	function get_image_thumbnail_height() {
542
		return (int) get_option( 'thumbnail_size_h' );
543
	}
544
545
	function get_image_thumbnail_crop() {
546
		return get_option( 'thumbnail_crop' );
547
	}
548
549
	function get_image_medium_width() {
550
		return (int) get_option( 'medium_size_w' );
551
	}
552
553
	function get_image_medium_height() {
554
		return (int) get_option( 'medium_size_h' );
555
	}
556
557
	function get_image_large_width() {
558
		return (int) get_option( 'large_size_w' );
559
	}
560
561
	function get_image_large_height() {
562
		return (int) get_option( 'large_size_h' );
563
	}
564
565
	function get_permalink_structure() {
566
		return get_option( 'permalink_structure' );
567
	}
568
569
	function get_default_post_format() {
570
		return get_option( 'default_post_format' );
571
	}
572
573
	function get_default_category() {
574
		return (int) get_option( 'default_category' );
575
	}
576
577
	function get_show_on_front() {
578
		return get_option( 'show_on_front' );
579
	}
580
581
	function is_custom_front_page() {
582
		return ( 'page' === $this->get_show_on_front() );
583
	}
584
585
	function get_default_likes_enabled() {
586
		return (bool) apply_filters( 'wpl_is_enabled_sitewide', ! get_option( 'disabled_likes' ) );
587
	}
588
589
	function get_default_sharing_status() {
590
		$default_sharing_status = false;
591
		if ( class_exists( 'Sharing_Service' ) ) {
592
			$ss                     = new Sharing_Service();
593
			$blog_services          = $ss->get_blog_services();
594
			$default_sharing_status = ! empty( $blog_services['visible'] );
595
		}
596
		return (bool) $default_sharing_status;
597
	}
598
599
	function get_default_comment_status() {
600
		return 'closed' !== get_option( 'default_comment_status' );
601
	}
602
603
	function default_ping_status() {
604
		return 'closed' !== get_option( 'default_ping_status' );
605
	}
606
607
	function is_publicize_permanently_disabled() {
608
		$publicize_permanently_disabled = false;
609
		if ( function_exists( 'is_publicize_permanently_disabled' ) ) {
610
			$publicize_permanently_disabled = is_publicize_permanently_disabled( $this->blog_id );
611
		}
612
		return $publicize_permanently_disabled;
613
	}
614
615
	function get_page_on_front() {
616
		return (int) get_option( 'page_on_front' );
617
	}
618
619
	function get_page_for_posts() {
620
		return (int) get_option( 'page_for_posts' );
621
	}
622
623
	function is_headstart() {
624
		return get_option( 'headstart' );
625
	}
626
627
	function get_wordpress_version() {
628
		global $wp_version;
629
		return $wp_version;
630
	}
631
632
	function is_domain_only() {
633
		$options = get_option( 'options' );
634
		return ! empty ( $options['is_domain_only'] ) ? (bool) $options['is_domain_only'] : false;
635
	}
636
637
	function get_blog_public() {
638
		return (int) get_option( 'blog_public' );
639
	}
640
641
	function has_pending_automated_transfer() {
642
		/**
643
		 * Filter if a site is in pending automated transfer state.
644
		 *
645
		 * @module json-api
646
		 *
647
		 * @since 6.4.0
648
		 *
649
		 * @param bool has_site_pending_automated_transfer( $this->blog_id )
650
		 * @param int  $blog_id Blog identifier.
651
		 */
652
		return apply_filters(
653
			'jetpack_site_pending_automated_transfer',
654
			false,
655
			$this->blog_id
0 ignored issues
show
Unused Code introduced by
The call to apply_filters() has too many arguments starting with $this->blog_id.

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.

Loading history...
656
		);
657
	}
658
659
	function signup_is_store() {
660
		return $this->get_design_type() === 'store';
661
	}
662
663
	function get_roles() {
664
		return new WP_Roles();
665
	}
666
667
	function get_design_type() {
668
		$options = get_option( 'options' );
669
		return empty( $options[ 'designType'] ) ? null : $options[ 'designType' ];
670
	}
671
672
	function get_site_goals() {
673
		$options = get_option( 'options' );
674
		return empty( $options[ 'siteGoals'] ) ? null : $options[ 'siteGoals' ];
675
	}
676
677
	function get_launch_status() {
678
		return false;
679
	}
680
681
	function get_migration_meta() {
682
		return null;
683
	}
684
685
	function get_site_segment() {
686
		return false;
687
	}
688
689
	function get_site_creation_flow() {
690
		return get_option( 'site_creation_flow' );
691
	}
692
693
	public function get_selected_features() {
694
		return get_option( 'selected_features' );
695
	}
696
697
	/**
698
	 * Get the option storing the Anchor podcast ID that identifies a site as a podcasting site.
699
	 *
700
	 * @return string
701
	 */
702
	public function get_anchor_podcast() {
703
		return get_option( 'anchor_podcast' );
704
	}
705
}
706