Completed
Push — fix/close-button-bg-color ( da7e83...c55173 )
by
unknown
11:17
created

SAL_Site::get_p2_hub_blog_id()   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
	/**
153
	 * Get hub blog id for P2 sites.
154
	 *
155
	 * @return null
156
	 */
157
	public function get_p2_hub_blog_id() {
158
		return null;
159
	}
160
161
	/**
162
	 * Getter for the p2 organization ID.
163
	 *
164
	 * @return int
165
	 */
166
	public function get_p2_organization_id() {
167
		return 0; // WPForTeams\Constants\NO_ORG_ID not loaded.
168
	}
169
170
	public function is_wpcom_atomic() {
171
		return false;
172
	}
173
174
	public function is_wpcom_store() {
175
		return false;
176
	}
177
178
	public function woocommerce_is_active() {
179
		return false;
180
	}
181
182
	public function is_cloud_eligible() {
183
		return false;
184
	}
185
186
	public function get_products() {
187
		return array();
188
	}
189
190
	public function get_post_by_id( $post_id, $context ) {
191
		$post = get_post( $post_id, OBJECT, $context );
192
193
		if ( ! $post ) {
194
			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...
195
		}
196
197
		$wrapped_post = $this->wrap_post( $post, $context );
198
199
		// validate access
200
		return $this->validate_access( $wrapped_post );
201
	}
202
203
	/**
204
	 * Validate current user can access the post
205
	 *
206
	 * @return WP_Error or post
207
	 */
208
	private function validate_access( $post ) {
209
		$context = $post->context;
210
211
		if (
212
			! $this->is_post_type_allowed( $post->post_type )
213
			&& ! $this->is_a8c_publication( $post->ID )
214
		) {
215
			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...
216
		}
217
218
		switch ( $context ) {
219
		case 'edit' :
220
			if ( ! current_user_can( 'edit_post', $post->ID ) ) {
221
				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...
222
			}
223
			break;
224
		case 'display' :
225
			$can_view = $this->user_can_view_post( $post );
226
			if ( is_wp_error( $can_view ) ) {
227
				return $can_view;
228
			}
229
			break;
230
		default :
231
			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...
232
		}
233
234
		return $post;
235
	}
236
237 View Code Duplication
	public function current_user_can_access_post_type( $post_type, $context ) {
238
		$post_type_object = $this->get_post_type_object( $post_type );
239
		if ( ! $post_type_object ) {
240
			return false;
241
		}
242
243
		switch( $context ) {
244
			case 'edit':
245
				return current_user_can( $post_type_object->cap->edit_posts );
246
			case 'display':
247
				return $post_type_object->public || current_user_can( $post_type_object->cap->read_private_posts );
248
			default:
249
				return false;
250
		}
251
	}
252
253
	protected function get_post_type_object( $post_type ) {
254
		return get_post_type_object( $post_type );
255
	}
256
257
	// copied from class.json-api-endpoints.php
258 View Code Duplication
	public function is_post_type_allowed( $post_type ) {
259
		// if the post type is empty, that's fine, WordPress will default to post
260
		if ( empty( $post_type ) ) {
261
			return true;
262
		}
263
264
		// allow special 'any' type
265
		if ( 'any' == $post_type ) {
266
			return true;
267
		}
268
269
		// check for allowed types
270
		if ( in_array( $post_type, $this->get_whitelisted_post_types() ) ) {
271
			return true;
272
		}
273
274
		if ( $post_type_object = get_post_type_object( $post_type ) ) {
275
			if ( ! empty( $post_type_object->show_in_rest ) ) {
276
				return $post_type_object->show_in_rest;
277
			}
278
			if ( ! empty( $post_type_object->publicly_queryable ) ) {
279
				return $post_type_object->publicly_queryable;
280
			}
281
		}
282
283
		return ! empty( $post_type_object->public );
284
	}
285
286
	// copied from class.json-api-endpoints.php
287
	/**
288
	 * Gets the whitelisted post types that JP should allow access to.
289
	 *
290
	 * @return array Whitelisted post types.
291
	 */
292 View Code Duplication
	public function get_whitelisted_post_types() {
293
		$allowed_types = array( 'post', 'page', 'revision' );
294
295
		/**
296
		 * Filter the post types Jetpack has access to, and can synchronize with WordPress.com.
297
		 *
298
		 * @module json-api
299
		 *
300
		 * @since 2.2.3
301
		 *
302
		 * @param array $allowed_types Array of whitelisted post types. Default to `array( 'post', 'page', 'revision' )`.
303
		 */
304
		$allowed_types = apply_filters( 'rest_api_allowed_post_types', $allowed_types );
305
306
		return array_unique( $allowed_types );
307
	}
308
309
	// copied and modified a little from class.json-api-endpoints.php
310
	private function user_can_view_post( $post ) {
311
		if ( !$post || is_wp_error( $post ) ) {
312
			return false;
313
		}
314
315 View Code Duplication
		if ( 'inherit' === $post->post_status ) {
316
			$parent_post = get_post( $post->post_parent );
317
			$post_status_obj = get_post_status_object( $parent_post->post_status );
318
		} else {
319
			$post_status_obj = get_post_status_object( $post->post_status );
320
		}
321
322
		$authorized = (
323
			$post_status_obj->public ||
324
			( is_user_logged_in() &&
325
				(
326
					( $post_status_obj->protected    && current_user_can( 'edit_post', $post->ID ) ) ||
327
					( $post_status_obj->private      && current_user_can( 'read_post', $post->ID ) ) ||
328
					( 'trash' === $post->post_status && current_user_can( 'edit_post', $post->ID ) ) ||
329
					'auto-draft' === $post->post_status
330
				)
331
			)
332
		);
333
334
		if ( ! $authorized ) {
335
			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...
336
		}
337
338 View Code Duplication
		if (
339
			-1 == get_option( 'blog_public' ) &&
340
			/**
341
			 * Filter access to a specific post.
342
			 *
343
			 * @module json-api
344
			 *
345
			 * @since 3.4.0
346
			 *
347
			 * @param bool current_user_can( 'read_post', $post->ID ) Can the current user access the post.
348
			 * @param WP_Post $post Post data.
349
			 */
350
			! apply_filters(
351
				'wpcom_json_api_user_can_view_post',
352
				current_user_can( 'read_post', $post->ID ),
353
				$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...
354
			)
355
		) {
356
			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...
357
		}
358
359 View Code Duplication
		if ( strlen( $post->post_password ) && !current_user_can( 'edit_post', $post->ID ) ) {
360
			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...
361
		}
362
363
		return true;
364
	}
365
366
	/**
367
	 * Get post ID by name
368
	 *
369
	 * Attempts to match name on post title and page path
370
	 *
371
	 * @param string $name
372
	 *
373
	 * @return int|object Post ID on success, WP_Error object on failure
374
	 */
375
	public function get_post_id_by_name( $name ) {
376
		$name = sanitize_title( $name );
377
378
		if ( ! $name ) {
379
			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...
380
		}
381
382
		$posts = get_posts( array(
383
			'name' => $name,
384
			'numberposts' => 1,
385
			'post_type' => $this->get_whitelisted_post_types(),
386
		) );
387
388
		if ( ! $posts || ! isset( $posts[0]->ID ) || ! $posts[0]->ID ) {
389
			$page = get_page_by_path( $name );
390
391
			if ( ! $page ) {
392
				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...
393
			}
394
395
			return $page->ID;
396
		}
397
398
		return (int) $posts[0]->ID;
399
	}
400
401
	/**
402
	 * Get post by name
403
	 *
404
	 * Attempts to match name on post title and page path
405
	 *
406
	 * @param string $name
407
	 * @param string $context (display or edit)
408
	 *
409
	 * @return object Post object on success, WP_Error object on failure
410
	 **/
411
	public function get_post_by_name( $name, $context ) {
412
		$post_id = $this->get_post_id_by_name( $name );
413
		if ( is_wp_error( $post_id ) ) {
414
			return $post_id;
415
		}
416
417
		return $this->get_post_by_id( $post_id, $context );
418
	}
419
420
	function user_can_manage() {
421
		current_user_can( 'manage_options' );
422
	}
423
424
	function get_xmlrpc_url() {
425
		$xmlrpc_scheme = apply_filters( 'wpcom_json_api_xmlrpc_scheme', wp_parse_url( get_option( 'home' ), PHP_URL_SCHEME ) );
426
		return site_url( 'xmlrpc.php', $xmlrpc_scheme );
427
	}
428
429
	function get_registered_date() {
430
		if ( function_exists( 'get_blog_details' ) ) {
431
			$blog_details = get_blog_details();
432
			if ( ! empty( $blog_details->registered ) ) {
433
				return WPCOM_JSON_API_Date::format_date( $blog_details->registered );
434
			}
435
		}
436
437
		return '0000-00-00T00:00:00+00:00';
438
	}
439
440
	function get_capabilities() {
441
		$is_wpcom_blog_owner = wpcom_get_blog_owner() === (int) get_current_user_id();
442
443
		return array(
444
			'edit_pages'          => current_user_can( 'edit_pages' ),
445
			'edit_posts'          => current_user_can( 'edit_posts' ),
446
			'edit_others_posts'   => current_user_can( 'edit_others_posts' ),
447
			'edit_others_pages'   => current_user_can( 'edit_others_pages' ),
448
			'delete_posts'        => current_user_can( 'delete_posts' ),
449
			'delete_others_posts' => current_user_can( 'delete_others_posts' ),
450
			'edit_theme_options'  => current_user_can( 'edit_theme_options' ),
451
			'edit_users'          => current_user_can( 'edit_users' ),
452
			'list_users'          => current_user_can( 'list_users' ),
453
			'manage_categories'   => current_user_can( 'manage_categories' ),
454
			'manage_options'      => current_user_can( 'manage_options' ),
455
			'moderate_comments'   => current_user_can( 'moderate_comments' ),
456
			'activate_wordads'    => $is_wpcom_blog_owner,
457
			'promote_users'       => current_user_can( 'promote_users' ),
458
			'publish_posts'       => current_user_can( 'publish_posts' ),
459
			'upload_files'        => current_user_can( 'upload_files' ),
460
			'delete_users'        => current_user_can( 'delete_users' ),
461
			'remove_users'        => current_user_can( 'remove_users' ),
462
			'own_site'            => $is_wpcom_blog_owner,
463
			/**
464
		 	 * Filter whether the Hosting section in Calypso should be available for site.
465
			 *
466
			 * @module json-api
467
			 *
468
			 * @since 8.2.0
469
			 *
470
			 * @param bool $view_hosting Can site access Hosting section. Default to false.
471
			 */
472
			'view_hosting'        => apply_filters( 'jetpack_json_api_site_can_view_hosting', false ),
473
			'view_stats'          => stats_is_blog_user( $this->blog_id ),
474
			'activate_plugins'    => current_user_can( 'activate_plugins' ),
475
		);
476
	}
477
478
	function is_visible() {
479
		if ( is_user_logged_in() ) {
480
			$current_user = wp_get_current_user();
481
			$visible      = (array) get_user_meta( $current_user->ID, 'blog_visibility', true );
482
483
			$is_visible = true;
484
			if ( isset( $visible[ $this->blog_id ] ) ) {
485
				$is_visible = (bool) $visible[ $this->blog_id ];
486
			}
487
488
			// null and true are visible
489
			return $is_visible;
490
		}
491
492
		return null;
493
	}
494
495
	function get_logo() {
496
497
		// Set an empty response array.
498
		$logo_setting = array(
499
			'id'    => (int) 0,
500
			'sizes' => array(),
501
			'url'   => '',
502
		);
503
504
		// Get current site logo values.
505
		$logo = get_option( 'site_logo' );
506
507
		// Update the response array if there's a site logo currenty active.
508
		if ( $logo && 0 != $logo['id'] ) {
509
			$logo_setting['id']  = $logo['id'];
510
			$logo_setting['url'] = $logo['url'];
511
512
			foreach ( $logo['sizes'] as $size => $properties ) {
513
				$logo_setting['sizes'][ $size ] = $properties;
514
			}
515
		}
516
517
		return $logo_setting;
518
	}
519
520
	function get_timezone() {
521
		return (string) get_option( 'timezone_string' );
522
	}
523
524
	function get_gmt_offset() {
525
		return (float) get_option( 'gmt_offset' );
526
	}
527
528
	function get_login_url() {
529
		return wp_login_url();
530
	}
531
532
	function get_admin_url() {
533
		return get_admin_url();
534
	}
535
536
	function get_theme_slug() {
537
		return get_option( 'stylesheet' );
538
	}
539
540
	function get_header_image() {
541
		return get_theme_mod( 'header_image_data' );
542
	}
543
544
	function get_background_color() {
545
		return get_theme_mod( 'background_color' );
546
	}
547
548
	function get_image_default_link_type() {
549
		return get_option( 'image_default_link_type' );
550
	}
551
552
	function get_image_thumbnail_width() {
553
		return (int) get_option( 'thumbnail_size_w' );
554
	}
555
556
	function get_image_thumbnail_height() {
557
		return (int) get_option( 'thumbnail_size_h' );
558
	}
559
560
	function get_image_thumbnail_crop() {
561
		return get_option( 'thumbnail_crop' );
562
	}
563
564
	function get_image_medium_width() {
565
		return (int) get_option( 'medium_size_w' );
566
	}
567
568
	function get_image_medium_height() {
569
		return (int) get_option( 'medium_size_h' );
570
	}
571
572
	function get_image_large_width() {
573
		return (int) get_option( 'large_size_w' );
574
	}
575
576
	function get_image_large_height() {
577
		return (int) get_option( 'large_size_h' );
578
	}
579
580
	function get_permalink_structure() {
581
		return get_option( 'permalink_structure' );
582
	}
583
584
	function get_default_post_format() {
585
		return get_option( 'default_post_format' );
586
	}
587
588
	function get_default_category() {
589
		return (int) get_option( 'default_category' );
590
	}
591
592
	function get_show_on_front() {
593
		return get_option( 'show_on_front' );
594
	}
595
596
	function is_custom_front_page() {
597
		return ( 'page' === $this->get_show_on_front() );
598
	}
599
600
	function get_default_likes_enabled() {
601
		return (bool) apply_filters( 'wpl_is_enabled_sitewide', ! get_option( 'disabled_likes' ) );
602
	}
603
604
	function get_default_sharing_status() {
605
		$default_sharing_status = false;
606
		if ( class_exists( 'Sharing_Service' ) ) {
607
			$ss                     = new Sharing_Service();
608
			$blog_services          = $ss->get_blog_services();
609
			$default_sharing_status = ! empty( $blog_services['visible'] );
610
		}
611
		return (bool) $default_sharing_status;
612
	}
613
614
	function get_default_comment_status() {
615
		return 'closed' !== get_option( 'default_comment_status' );
616
	}
617
618
	function default_ping_status() {
619
		return 'closed' !== get_option( 'default_ping_status' );
620
	}
621
622
	function is_publicize_permanently_disabled() {
623
		$publicize_permanently_disabled = false;
624
		if ( function_exists( 'is_publicize_permanently_disabled' ) ) {
625
			$publicize_permanently_disabled = is_publicize_permanently_disabled( $this->blog_id );
626
		}
627
		return $publicize_permanently_disabled;
628
	}
629
630
	function get_page_on_front() {
631
		return (int) get_option( 'page_on_front' );
632
	}
633
634
	function get_page_for_posts() {
635
		return (int) get_option( 'page_for_posts' );
636
	}
637
638
	function is_headstart() {
639
		return get_option( 'headstart' );
640
	}
641
642
	function get_wordpress_version() {
643
		global $wp_version;
644
		return $wp_version;
645
	}
646
647
	function is_domain_only() {
648
		$options = get_option( 'options' );
649
		return ! empty ( $options['is_domain_only'] ) ? (bool) $options['is_domain_only'] : false;
650
	}
651
652
	function get_blog_public() {
653
		return (int) get_option( 'blog_public' );
654
	}
655
656
	function has_pending_automated_transfer() {
657
		/**
658
		 * Filter if a site is in pending automated transfer state.
659
		 *
660
		 * @module json-api
661
		 *
662
		 * @since 6.4.0
663
		 *
664
		 * @param bool has_site_pending_automated_transfer( $this->blog_id )
665
		 * @param int  $blog_id Blog identifier.
666
		 */
667
		return apply_filters(
668
			'jetpack_site_pending_automated_transfer',
669
			false,
670
			$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...
671
		);
672
	}
673
674
	function signup_is_store() {
675
		return $this->get_design_type() === 'store';
676
	}
677
678
	function get_roles() {
679
		return new WP_Roles();
680
	}
681
682
	function get_design_type() {
683
		$options = get_option( 'options' );
684
		return empty( $options[ 'designType'] ) ? null : $options[ 'designType' ];
685
	}
686
687
	function get_site_goals() {
688
		$options = get_option( 'options' );
689
		return empty( $options[ 'siteGoals'] ) ? null : $options[ 'siteGoals' ];
690
	}
691
692
	function get_launch_status() {
693
		return false;
694
	}
695
696
	function get_migration_meta() {
697
		return null;
698
	}
699
700
	function get_site_segment() {
701
		return false;
702
	}
703
704
	function get_site_creation_flow() {
705
		return get_option( 'site_creation_flow' );
706
	}
707
708
	public function get_selected_features() {
709
		return get_option( 'selected_features' );
710
	}
711
712
	/**
713
	 * Get the option storing the Anchor podcast ID that identifies a site as a podcasting site.
714
	 *
715
	 * @return string
716
	 */
717
	public function get_anchor_podcast() {
718
		return get_option( 'anchor_podcast' );
719
	}
720
}
721