Completed
Push — update/cover-block-upgrade ( bf8c6b...9590ba )
by
unknown
07:50
created

SAL_Site::is_cloud_eligible()   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
	abstract public function is_jetpack();
83
84
	abstract public function get_jetpack_modules();
85
86
	abstract public function is_module_active( $module );
87
88
	abstract public function is_vip();
89
90
	abstract public function is_multisite();
91
92
	abstract public function is_single_user_site();
93
94
	abstract public function get_plan();
95
96
	abstract public function get_ak_vp_bundle_enabled();
97
98
	abstract public function get_podcasting_archive();
99
100
	abstract public function get_import_engine();
101
102
	abstract public function get_jetpack_seo_front_page_description();
103
104
	abstract public function get_jetpack_seo_title_formats();
105
106
	abstract public function get_verification_services_codes();
107
108
	abstract public function before_render();
109
110
	abstract public function after_render( &$response );
111
112
	// TODO - factor this out? Seems an odd thing to have on a site
113
	abstract public function after_render_options( &$options );
114
115
	// wrap a WP_Post object with SAL methods
116
	abstract public function wrap_post( $post, $context );
117
118
	abstract protected function is_a8c_publication( $post_id );
119
120
	public function is_automated_transfer() {
121
		/**
122
		 * Filter if a site is an automated-transfer site.
123
		 *
124
		 * @module json-api
125
		 *
126
		 * @since 6.4.0
127
		 *
128
		 * @param bool is_automated_transfer( $this->blog_id )
129
		 * @param int  $blog_id Blog identifier.
130
		 */
131
		return apply_filters(
132
			'jetpack_site_automated_transfer',
133
			false,
134
			$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...
135
		);
136
	}
137
138
	abstract protected function is_wpforteams_site();
139
140
	public function is_wpcom_atomic() {
141
		return false;
142
	}
143
144
	public function is_wpcom_store() {
145
		return false;
146
	}
147
148
	public function woocommerce_is_active() {
149
		return false;
150
	}
151
152
	public function is_cloud_eligible() {
153
		return false;
154
	}
155
156
	public function get_products() {
157
		return array();
158
	}
159
160
	public function get_post_by_id( $post_id, $context ) {
161
		$post = get_post( $post_id, OBJECT, $context );
162
163
		if ( ! $post ) {
164
			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...
165
		}
166
167
		$wrapped_post = $this->wrap_post( $post, $context );
168
169
		// validate access
170
		return $this->validate_access( $wrapped_post );
171
	}
172
173
	/**
174
	 * Validate current user can access the post
175
	 *
176
	 * @return WP_Error or post
177
	 */
178
	private function validate_access( $post ) {
179
		$context = $post->context;
180
181
		if (
182
			! $this->is_post_type_allowed( $post->post_type )
183
			&& ! $this->is_a8c_publication( $post->ID )
184
		) {
185
			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...
186
		}
187
188
		switch ( $context ) {
189
		case 'edit' :
190
			if ( ! current_user_can( 'edit_post', $post->ID ) ) {
191
				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...
192
			}
193
			break;
194
		case 'display' :
195
			$can_view = $this->user_can_view_post( $post );
196
			if ( is_wp_error( $can_view ) ) {
197
				return $can_view;
198
			}
199
			break;
200
		default :
201
			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...
202
		}
203
204
		return $post;
205
	}
206
207 View Code Duplication
	public function current_user_can_access_post_type( $post_type, $context ) {
208
		$post_type_object = $this->get_post_type_object( $post_type );
209
		if ( ! $post_type_object ) {
210
			return false;
211
		}
212
213
		switch( $context ) {
214
			case 'edit':
215
				return current_user_can( $post_type_object->cap->edit_posts );
216
			case 'display':
217
				return $post_type_object->public || current_user_can( $post_type_object->cap->read_private_posts );
218
			default:
219
				return false;
220
		}
221
	}
222
223
	protected function get_post_type_object( $post_type ) {
224
		return get_post_type_object( $post_type );
225
	}
226
227
	// copied from class.json-api-endpoints.php
228 View Code Duplication
	public function is_post_type_allowed( $post_type ) {
229
		// if the post type is empty, that's fine, WordPress will default to post
230
		if ( empty( $post_type ) ) {
231
			return true;
232
		}
233
234
		// allow special 'any' type
235
		if ( 'any' == $post_type ) {
236
			return true;
237
		}
238
239
		// check for allowed types
240
		if ( in_array( $post_type, $this->get_whitelisted_post_types() ) ) {
241
			return true;
242
		}
243
244
		if ( $post_type_object = get_post_type_object( $post_type ) ) {
245
			if ( ! empty( $post_type_object->show_in_rest ) ) {
246
				return $post_type_object->show_in_rest;
247
			}
248
			if ( ! empty( $post_type_object->publicly_queryable ) ) {
249
				return $post_type_object->publicly_queryable;
250
			}
251
		}
252
253
		return ! empty( $post_type_object->public );
254
	}
255
256
	// copied from class.json-api-endpoints.php
257
	/**
258
	 * Gets the whitelisted post types that JP should allow access to.
259
	 *
260
	 * @return array Whitelisted post types.
261
	 */
262 View Code Duplication
	public function get_whitelisted_post_types() {
263
		$allowed_types = array( 'post', 'page', 'revision' );
264
265
		/**
266
		 * Filter the post types Jetpack has access to, and can synchronize with WordPress.com.
267
		 *
268
		 * @module json-api
269
		 *
270
		 * @since 2.2.3
271
		 *
272
		 * @param array $allowed_types Array of whitelisted post types. Default to `array( 'post', 'page', 'revision' )`.
273
		 */
274
		$allowed_types = apply_filters( 'rest_api_allowed_post_types', $allowed_types );
275
276
		return array_unique( $allowed_types );
277
	}
278
279
	// copied and modified a little from class.json-api-endpoints.php
280
	private function user_can_view_post( $post ) {
281
		if ( !$post || is_wp_error( $post ) ) {
282
			return false;
283
		}
284
285 View Code Duplication
		if ( 'inherit' === $post->post_status ) {
286
			$parent_post = get_post( $post->post_parent );
287
			$post_status_obj = get_post_status_object( $parent_post->post_status );
288
		} else {
289
			$post_status_obj = get_post_status_object( $post->post_status );
290
		}
291
292
		$authorized = (
293
			$post_status_obj->public ||
294
			( is_user_logged_in() &&
295
				(
296
					( $post_status_obj->protected    && current_user_can( 'edit_post', $post->ID ) ) ||
297
					( $post_status_obj->private      && current_user_can( 'read_post', $post->ID ) ) ||
298
					( 'trash' === $post->post_status && current_user_can( 'edit_post', $post->ID ) ) ||
299
					'auto-draft' === $post->post_status
300
				)
301
			)
302
		);
303
304
		if ( ! $authorized ) {
305
			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...
306
		}
307
308 View Code Duplication
		if (
309
			-1 == get_option( 'blog_public' ) &&
310
			/**
311
			 * Filter access to a specific post.
312
			 *
313
			 * @module json-api
314
			 *
315
			 * @since 3.4.0
316
			 *
317
			 * @param bool current_user_can( 'read_post', $post->ID ) Can the current user access the post.
318
			 * @param WP_Post $post Post data.
319
			 */
320
			! apply_filters(
321
				'wpcom_json_api_user_can_view_post',
322
				current_user_can( 'read_post', $post->ID ),
323
				$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...
324
			)
325
		) {
326
			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...
327
		}
328
329 View Code Duplication
		if ( strlen( $post->post_password ) && !current_user_can( 'edit_post', $post->ID ) ) {
330
			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...
331
		}
332
333
		return true;
334
	}
335
336
	/**
337
	 * Get post ID by name
338
	 *
339
	 * Attempts to match name on post title and page path
340
	 *
341
	 * @param string $name
342
	 *
343
	 * @return int|object Post ID on success, WP_Error object on failure
344
	 */
345
	public function get_post_id_by_name( $name ) {
346
		$name = sanitize_title( $name );
347
348
		if ( ! $name ) {
349
			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...
350
		}
351
352
		$posts = get_posts( array(
353
			'name' => $name,
354
			'numberposts' => 1,
355
			'post_type' => $this->get_whitelisted_post_types(),
356
		) );
357
358
		if ( ! $posts || ! isset( $posts[0]->ID ) || ! $posts[0]->ID ) {
359
			$page = get_page_by_path( $name );
360
361
			if ( ! $page ) {
362
				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...
363
			}
364
365
			return $page->ID;
366
		}
367
368
		return (int) $posts[0]->ID;
369
	}
370
371
	/**
372
	 * Get post by name
373
	 *
374
	 * Attempts to match name on post title and page path
375
	 *
376
	 * @param string $name
377
	 * @param string $context (display or edit)
378
	 *
379
	 * @return object Post object on success, WP_Error object on failure
380
	 **/
381
	public function get_post_by_name( $name, $context ) {
382
		$post_id = $this->get_post_id_by_name( $name );
383
		if ( is_wp_error( $post_id ) ) {
384
			return $post_id;
385
		}
386
387
		return $this->get_post_by_id( $post_id, $context );
388
	}
389
390
	function user_can_manage() {
391
		current_user_can( 'manage_options' );
392
	}
393
394
	function get_xmlrpc_url() {
395
		$xmlrpc_scheme = apply_filters( 'wpcom_json_api_xmlrpc_scheme', wp_parse_url( get_option( 'home' ), PHP_URL_SCHEME ) );
0 ignored issues
show
Unused Code introduced by
The call to wp_parse_url() has too many arguments starting with PHP_URL_SCHEME.

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