Completed
Push — update/build-to-prepare-for-wp... ( a960c5...31a28f )
by
unknown
156:22 queued 147:01
created

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