Completed
Push — fix/12791-track-upgrade ( 62035b...97a755 )
by
unknown
26:48 queued 17:41
created

Defaults   A

Complexity

Total Complexity 18

Size/Duplication

Total Lines 767
Duplicated Lines 0 %

Coupling/Cohesion

Components 9
Dependencies 1

Importance

Changes 0
Metric Value
wmc 18
lcom 9
cbo 1
dl 0
loc 767
rs 9.833
c 0
b 0
f 0

13 Methods

Rating   Name   Duplication   Size   Complexity  
A get_options_whitelist() 0 14 1
A get_options_contentless() 0 12 1
A get_constants_whitelist() 0 12 1
A get_callable_whitelist() 0 12 1
A get_multisite_callable_whitelist() 0 12 1
A get_post_meta_whitelist() 0 12 1
A get_comment_meta_whitelist() 0 12 1
A is_whitelisted_option() 0 12 5
A get_capabilities_whitelist() 0 12 1
A get_max_sync_execution_time() 0 8 2
A get_default_setting() 0 4 1
A get_known_importers() 0 12 1
A is_multi_network() 0 4 1
1
<?php
2
3
namespace Automattic\Jetpack\Sync;
4
5
require_once JETPACK__PLUGIN_DIR . 'modules/sso/class.jetpack-sso-helpers.php';
6
7
use Automattic\Jetpack\Status;
8
use Automattic\Jetpack\Sync\Functions;
9
10
/**
11
 * Just some defaults that we share with the server
12
 */
13
class Defaults {
14
15
	static $default_options_whitelist = array(
16
		'stylesheet',
17
		'blogname',
18
		'blogdescription',
19
		'blog_charset',
20
		'permalink_structure',
21
		'category_base',
22
		'tag_base',
23
		'sidebars_widgets',
24
		'comment_moderation',
25
		'default_comment_status',
26
		'page_on_front',
27
		'rss_use_excerpt',
28
		'subscription_options',
29
		'stb_enabled',
30
		'stc_enabled',
31
		'comment_registration',
32
		'show_avatars',
33
		'avatar_default',
34
		'avatar_rating',
35
		'highlander_comment_form_prompt',
36
		'jetpack_comment_form_color_scheme',
37
		'stats_options',
38
		'gmt_offset',
39
		'timezone_string',
40
		'jetpack_sync_non_public_post_stati',
41
		'jetpack_options',
42
		'site_icon', // (int) - ID of core's Site Icon attachment ID
43
		'default_post_format',
44
		'default_category',
45
		'large_size_w',
46
		'large_size_h',
47
		'thumbnail_size_w',
48
		'thumbnail_size_h',
49
		'medium_size_w',
50
		'medium_size_h',
51
		'thumbnail_crop',
52
		'image_default_link_type',
53
		'site_logo',
54
		'sharing-options',
55
		'sharing-services',
56
		'post_count',
57
		'default_ping_status',
58
		'sticky_posts',
59
		'blog_public',
60
		'default_pingback_flag',
61
		'require_name_email',
62
		'close_comments_for_old_posts',
63
		'close_comments_days_old',
64
		'thread_comments',
65
		'thread_comments_depth',
66
		'page_comments',
67
		'comments_per_page',
68
		'default_comments_page',
69
		'comment_order',
70
		'comments_notify',
71
		'moderation_notify',
72
		'social_notifications_like',
73
		'social_notifications_reblog',
74
		'social_notifications_subscribe',
75
		'comment_whitelist',
76
		'comment_max_links',
77
		'moderation_keys',
78
		'jetpack_wga',
79
		'disabled_likes',
80
		'disabled_reblogs',
81
		'jetpack_comment_likes_enabled',
82
		'twitter_via',
83
		'jetpack-memberships-connected-account-id',
84
		'jetpack-twitter-cards-site-tag',
85
		'wpcom_publish_posts_with_markdown',
86
		'wpcom_publish_comments_with_markdown',
87
		'jetpack_activated',
88
		'jetpack_available_modules',
89
		'jetpack_allowed_xsite_search_ids',
90
		'jetpack_autoupdate_plugins',
91
		'jetpack_autoupdate_plugins_translations',
92
		'jetpack_autoupdate_themes',
93
		'jetpack_autoupdate_themes_translations',
94
		'jetpack_autoupdate_core',
95
		'jetpack_autoupdate_translations',
96
		'carousel_background_color',
97
		'carousel_display_exif',
98
		'jetpack_portfolio',
99
		'jetpack_portfolio_posts_per_page',
100
		'jetpack_testimonial',
101
		'jetpack_testimonial_posts_per_page',
102
		'tiled_galleries',
103
		'gravatar_disable_hovercards',
104
		'infinite_scroll',
105
		'infinite_scroll_google_analytics',
106
		'wp_mobile_excerpt',
107
		'wp_mobile_featured_images',
108
		'wp_mobile_app_promos',
109
		'monitor_receive_notifications',
110
		'post_by_email_address',
111
		'jetpack_mailchimp',
112
		'jetpack_protect_key',
113
		'jetpack_protect_global_whitelist',
114
		'jetpack_sso_require_two_step',
115
		'jetpack_sso_match_by_email',
116
		'jetpack_relatedposts',
117
		'verification_services_codes',
118
		'users_can_register',
119
		'active_plugins',
120
		'uninstall_plugins',
121
		'advanced_seo_front_page_description', // Jetpack_SEO_Utils::FRONT_PAGE_META_OPTION
122
		'advanced_seo_title_formats', // Jetpack_SEO_Titles::TITLE_FORMATS_OPTION
123
		'jetpack_api_cache_enabled',
124
		'start_of_week',
125
		'blacklist_keys',
126
		'posts_per_page',
127
		'posts_per_rss',
128
		'show_on_front',
129
		'ping_sites',
130
		'uploads_use_yearmonth_folders',
131
		'date_format',
132
		'time_format',
133
		'admin_email',
134
		'new_admin_email',
135
		'default_email_category',
136
		'default_role',
137
		'page_for_posts',
138
		'mailserver_url',
139
		'mailserver_login', // Not syncing contents, only the option name
140
		'mailserver_pass', // Not syncing contents, only the option name
141
		'mailserver_port',
142
		'wp_page_for_privacy_policy',
143
		'enable_header_ad',
144
		'wordads_second_belowpost',
145
		'wordads_display_front_page',
146
		'wordads_display_post',
147
		'wordads_display_page',
148
		'wordads_display_archive',
149
		'wordads_custom_adstxt',
150
		'site_segment',
151
		'site_user_type',
152
		'site_vertical',
153
		'jetpack_excluded_extensions',
154
	);
155
156
	public static function get_options_whitelist() {
157
		/** This filter is already documented in json-endpoints/jetpack/class.wpcom-json-api-get-option-endpoint.php */
158
		$options_whitelist = apply_filters( 'jetpack_options_whitelist', self::$default_options_whitelist );
159
		/**
160
		 * Filter the list of WordPress options that are manageable via the JSON API.
161
		 *
162
		 * @module sync
163
		 *
164
		 * @since 4.8.0
165
		 *
166
		 * @param array The default list of options.
167
		 */
168
		return apply_filters( 'jetpack_sync_options_whitelist', $options_whitelist );
169
	}
170
171
	// Do not sync contents for these events, only the option name
172
	static $default_options_contentless = array(
173
		'mailserver_login',
174
		'mailserver_pass',
175
	);
176
177
	public static function get_options_contentless() {
178
		/**
179
		 * Filter the list of WordPress options that should be synced without content
180
		 *
181
		 * @module sync
182
		 *
183
		 * @since 6.1.0
184
		 *
185
		 * @param array The list of options synced without content.
186
		 */
187
		return apply_filters( 'jetpack_sync_options_contentless', self::$default_options_contentless );
188
	}
189
190
	static $default_constants_whitelist = array(
191
		'EMPTY_TRASH_DAYS',
192
		'WP_POST_REVISIONS',
193
		'AUTOMATIC_UPDATER_DISABLED',
194
		'ABSPATH',
195
		'WP_CONTENT_DIR',
196
		'FS_METHOD',
197
		'DISALLOW_FILE_EDIT',
198
		'DISALLOW_FILE_MODS',
199
		'WP_AUTO_UPDATE_CORE',
200
		'WP_HTTP_BLOCK_EXTERNAL',
201
		'WP_ACCESSIBLE_HOSTS',
202
		'JETPACK__VERSION',
203
		'IS_PRESSABLE',
204
		'DISABLE_WP_CRON',
205
		'ALTERNATE_WP_CRON',
206
		'WP_CRON_LOCK_TIMEOUT',
207
		'PHP_VERSION',
208
		'WP_MEMORY_LIMIT',
209
		'WP_MAX_MEMORY_LIMIT',
210
		'WP_DEBUG',
211
	);
212
213
	public static function get_constants_whitelist() {
214
		/**
215
		 * Filter the list of PHP constants that are manageable via the JSON API.
216
		 *
217
		 * @module sync
218
		 *
219
		 * @since 4.8.0
220
		 *
221
		 * @param array The default list of constants options.
222
		 */
223
		return apply_filters( 'jetpack_sync_constants_whitelist', self::$default_constants_whitelist );
224
	}
225
226
	static $default_callable_whitelist = array(
227
		'wp_max_upload_size'               => 'wp_max_upload_size',
228
		'is_main_network'                  => array( __CLASS__, 'is_multi_network' ),
229
		'is_multi_site'                    => 'is_multisite',
230
		'main_network_site'                => array( 'Automattic\\Jetpack\\Sync\\Functions', 'main_network_site_url' ),
231
		'site_url'                         => array( 'Automattic\\Jetpack\\Sync\\Functions', 'site_url' ),
232
		'home_url'                         => array( 'Automattic\\Jetpack\\Sync\\Functions', 'home_url' ),
233
		'single_user_site'                 => array( 'Jetpack', 'is_single_user_site' ),
234
		'updates'                          => array( 'Jetpack', 'get_updates' ),
235
		'has_file_system_write_access'     => array( 'Automattic\\Jetpack\\Sync\\Functions', 'file_system_write_access' ),
236
		'is_version_controlled'            => array( 'Automattic\\Jetpack\\Sync\\Functions', 'is_version_controlled' ),
237
		'taxonomies'                       => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_taxonomies' ),
238
		'post_types'                       => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_post_types' ),
239
		'post_type_features'               => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_post_type_features' ),
240
		'shortcodes'                       => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_shortcodes' ),
241
		'rest_api_allowed_post_types'      => array( 'Automattic\\Jetpack\\Sync\\Functions', 'rest_api_allowed_post_types' ),
242
		'rest_api_allowed_public_metadata' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'rest_api_allowed_public_metadata' ),
243
		'sso_is_two_step_required'         => array( 'Jetpack_SSO_Helpers', 'is_two_step_required' ),
244
		'sso_should_hide_login_form'       => array( 'Jetpack_SSO_Helpers', 'should_hide_login_form' ),
245
		'sso_match_by_email'               => array( 'Jetpack_SSO_Helpers', 'match_by_email' ),
246
		'sso_new_user_override'            => array( 'Jetpack_SSO_Helpers', 'new_user_override' ),
247
		'sso_bypass_default_login_form'    => array( 'Jetpack_SSO_Helpers', 'bypass_login_forward_wpcom' ),
248
		'wp_version'                       => array( 'Automattic\\Jetpack\\Sync\\Functions', 'wp_version' ),
249
		'get_plugins'                      => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_plugins' ),
250
		'get_plugins_action_links'         => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_plugins_action_links' ),
251
		'active_modules'                   => array( 'Jetpack', 'get_active_modules' ),
252
		'hosting_provider'                 => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_hosting_provider' ),
253
		'locale'                           => 'get_locale',
254
		'site_icon_url'                    => array( 'Automattic\\Jetpack\\Sync\\Functions', 'site_icon_url' ),
255
		'roles'                            => array( 'Automattic\\Jetpack\\Sync\\Functions', 'roles' ),
256
		'timezone'                         => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_timezone' ),
257
		'available_jetpack_blocks'         => array( 'Jetpack_Gutenberg', 'get_availability' ), // Includes both Gutenberg blocks *and* plugins
258
		'paused_themes'                    => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_paused_themes' ),
259
		'paused_plugins'                   => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_paused_plugins' ),
260
	);
261
262
263
	static $default_post_type_attributes = array(
264
		'name'                => '',
265
		'label'               => '',
266
		'labels'              => array(),
267
		'description'         => '',
268
		'public'              => false,
269
		'hierarchical'        => false,
270
		'exclude_from_search' => true,
271
		'publicly_queryable'  => null,
272
		'show_ui'             => false,
273
		'show_in_menu'        => null,
274
		'show_in_nav_menus'   => null,
275
		'show_in_admin_bar'   => false,
276
		'menu_position'       => null,
277
		'menu_icon'           => null,
278
		'supports'            => array(),
279
		'capability_type'     => 'post',
280
		'capabilities'        => array(),
281
		'cap'                 => array(),
282
		'map_meta_cap'        => true,
283
		'taxonomies'          => array(),
284
		'has_archive'         => false,
285
		'rewrite'             => true,
286
		'query_var'           => true,
287
		'can_export'          => true,
288
		'delete_with_user'    => null,
289
		'show_in_rest'        => false,
290
		'rest_base'           => false,
291
		'_builtin'            => false,
292
		'_edit_link'          => 'post.php?post=%d',
293
	);
294
295
	public static function get_callable_whitelist() {
296
		/**
297
		 * Filter the list of callables that are manageable via the JSON API.
298
		 *
299
		 * @module sync
300
		 *
301
		 * @since 4.8.0
302
		 *
303
		 * @param array The default list of callables.
304
		 */
305
		return apply_filters( 'jetpack_sync_callable_whitelist', self::$default_callable_whitelist );
306
	}
307
308
	static $blacklisted_post_types = array(
309
		'ai1ec_event',
310
		'bwg_album',
311
		'bwg_gallery',
312
		'customize_changeset', // WP built-in post type for Customizer changesets
313
		'dn_wp_yt_log',
314
		'http',
315
		'idx_page',
316
		'jetpack_migration',
317
		'postman_sent_mail',
318
		'rssap-feed',
319
		'rssmi_feed_item',
320
		'secupress_log_action',
321
		'sg_optimizer_jobs',
322
		'snitch',
323
		'wpephpcompat_jobs',
324
		'wprss_feed_item',
325
		'wp_automatic',
326
		'jp_sitemap_master',
327
		'jp_sitemap',
328
		'jp_sitemap_index',
329
		'jp_img_sitemap',
330
		'jp_img_sitemap_index',
331
		'jp_vid_sitemap',
332
		'jp_vid_sitemap_index',
333
		'vip-legacy-redirect',
334
	);
335
336
	/**
337
	 * Taxonomies that we're not syncing by default.
338
	 *
339
	 * @var array
340
	 */
341
	public static $blacklisted_taxonomies = array(
342
		// Conflicting with WP core filters.
343
		'ancestors',
344
		'archives_link',
345
		'attached_file',
346
		'attached_media',
347
		'attached_media_args',
348
		'available_languages',
349
		'avatar',
350
		'avatar_comment_types',
351
		'avatar_data',
352
		'avatar_url',
353
		'bloginfo_rss',
354
		'blogs_of_user',
355
		'bookmarks',
356
		'calendar',
357
		'canonical_url',
358
		'categories_taxonomy',
359
		'comment',
360
		'comment_author',
361
		'comment_author_email',
362
		'comment_author_IP',
363
		'comment_author_link',
364
		'comment_author_url',
365
		'comment_author_url_link',
366
		'comment_date',
367
		'comment_excerpt',
368
		'comment_ID',
369
		'comment_link',
370
		'comment_text',
371
		'comment_time',
372
		'comment_type',
373
		'comments_link',
374
		'comments_number',
375
		'comments_pagenum_link',
376
		'custom_logo',
377
		'date_sql',
378
		'default_comment_status',
379
		'delete_post_link',
380
		'edit_bookmark_link',
381
		'edit_comment_link',
382
		'edit_post_link',
383
		'edit_tag_link',
384
		'edit_term_link',
385
		'edit_user_link',
386
		'enclosed',
387
		'feed_build_date',
388
		'header_image_tag',
389
		'header_video_url',
390
		'image_tag',
391
		'image_tag_class',
392
		'lastpostdate',
393
		'lastpostmodified',
394
		'main_network_id',
395
		'media_item_args',
396
		'network',
397
		'object_terms',
398
		'page_of_comment',
399
		'page_uri',
400
		'pagenum_link',
401
		'pages',
402
		'post_galleries',
403
		'post_gallery',
404
		'post_modified_time',
405
		'post_status',
406
		'post_time',
407
		'product_search_form',
408
		'pung',
409
		'role_list',
410
		'sample_permalink',
411
		'sample_permalink_html',
412
		'schedule',
413
		'search_form',
414
		'search_query',
415
		'shortlink',
416
		'site',
417
		'site_icon_url',
418
		'space_allowed',
419
		'tags',
420
		'term',
421
		'terms',
422
		'terms_args',
423
		'terms_defaults',
424
		'terms_fields',
425
		'terms_orderby',
426
		'the_archive_description',
427
		'the_archive_title',
428
		'the_categories',
429
		'the_date',
430
		'the_excerpt',
431
		'the_guid',
432
		'the_modified_date',
433
		'the_modified_time',
434
		'the_post_type_description',
435
		'the_tags',
436
		'the_terms',
437
		'the_time',
438
		'theme_starter_content',
439
		'to_ping',
440
		'usernumposts',
441
		'users_drafts',
442
		'wp_title_rss',
443
444
		// Conflicting with Jetpack filters.
445
		'attachment',
446
	);
447
448
	static $default_post_checksum_columns = array(
449
		'ID',
450
		'post_modified',
451
	);
452
453
	static $default_post_meta_checksum_columns = array(
454
		'meta_id',
455
		'meta_value',
456
	);
457
458
	static $default_comment_checksum_columns = array(
459
		'comment_ID',
460
		'comment_content',
461
	);
462
463
	static $default_comment_meta_checksum_columns = array(
464
		'meta_id',
465
		'meta_value',
466
	);
467
468
	static $default_option_checksum_columns = array(
469
		'option_name',
470
		'option_value',
471
	);
472
473
	static $default_term_checksum_columns = array(
474
		'term_id',
475
		'name',
476
		'slug',
477
	);
478
479
	static $default_multisite_callable_whitelist = array(
480
		'network_name'                        => array( 'Jetpack', 'network_name' ),
481
		'network_allow_new_registrations'     => array( 'Jetpack', 'network_allow_new_registrations' ),
482
		'network_add_new_users'               => array( 'Jetpack', 'network_add_new_users' ),
483
		'network_site_upload_space'           => array( 'Jetpack', 'network_site_upload_space' ),
484
		'network_upload_file_types'           => array( 'Jetpack', 'network_upload_file_types' ),
485
		'network_enable_administration_menus' => array( 'Jetpack', 'network_enable_administration_menus' ),
486
	);
487
488
	public static function get_multisite_callable_whitelist() {
489
		/**
490
		 * Filter the list of multisite callables that are manageable via the JSON API.
491
		 *
492
		 * @module sync
493
		 *
494
		 * @since 4.8.0
495
		 *
496
		 * @param array The default list of multisite callables.
497
		 */
498
		return apply_filters( 'jetpack_sync_multisite_callable_whitelist', self::$default_multisite_callable_whitelist );
499
	}
500
501
	static $post_meta_whitelist = array(
502
		'_feedback_akismet_values',
503
		'_feedback_email',
504
		'_feedback_extra_fields',
505
		'_g_feedback_shortcode',
506
		'_jetpack_post_thumbnail',
507
		'_menu_item_classes',
508
		'_menu_item_menu_item_parent',
509
		'_menu_item_object',
510
		'_menu_item_object_id',
511
		'_menu_item_orphaned',
512
		'_menu_item_type',
513
		'_menu_item_xfn',
514
		'_publicize_facebook_user',
515
		'_publicize_twitter_user',
516
		'_thumbnail_id',
517
		'_wp_attached_file',
518
		'_wp_attachment_backup_sizes',
519
		'_wp_attachment_context',
520
		'_wp_attachment_image_alt',
521
		'_wp_attachment_is_custom_background',
522
		'_wp_attachment_is_custom_header',
523
		'_wp_attachment_metadata',
524
		'_wp_page_template',
525
		'_wp_trash_meta_comments_status',
526
		'_wpas_mess',
527
		'content_width',
528
		'custom_css_add',
529
		'custom_css_preprocessor',
530
		'enclosure',
531
		'imagedata',
532
		'nova_price',
533
		'publicize_results',
534
		'sharing_disabled',
535
		'switch_like_status',
536
		'videopress_guid',
537
		'vimeo_poster_image',
538
		'advanced_seo_description', // Jetpack_SEO_Posts::DESCRIPTION_META_KEY
539
	);
540
541
	public static function get_post_meta_whitelist() {
542
		/**
543
		 * Filter the list of post meta data that are manageable via the JSON API.
544
		 *
545
		 * @module sync
546
		 *
547
		 * @since 4.8.0
548
		 *
549
		 * @param array The default list of meta data keys.
550
		 */
551
		return apply_filters( 'jetpack_sync_post_meta_whitelist', self::$post_meta_whitelist );
552
	}
553
554
	static $comment_meta_whitelist = array(
555
		'hc_avatar',
556
		'hc_post_as',
557
		'hc_wpcom_id_sig',
558
		'hc_foreign_user_id',
559
	);
560
561
	public static function get_comment_meta_whitelist() {
562
		/**
563
		 * Filter the list of comment meta data that are manageable via the JSON API.
564
		 *
565
		 * @module sync
566
		 *
567
		 * @since 5.7.0
568
		 *
569
		 * @param array The default list of comment meta data keys.
570
		 */
571
		return apply_filters( 'jetpack_sync_comment_meta_whitelist', self::$comment_meta_whitelist );
572
	}
573
574
	// TODO: move this to server? - these are theme support values
575
	// that should be synced as jetpack_current_theme_supports_foo option values
576
	static $default_theme_support_whitelist = array(
577
		'post-thumbnails',
578
		'post-formats',
579
		'custom-header',
580
		'custom-background',
581
		'custom-logo',
582
		'menus',
583
		'automatic-feed-links',
584
		'editor-style',
585
		'widgets',
586
		'html5',
587
		'title-tag',
588
		'jetpack-social-menu',
589
		'jetpack-responsive-videos',
590
		'infinite-scroll',
591
		'site-logo',
592
	);
593
594
	static function is_whitelisted_option( $option ) {
595
		$whitelisted_options = self::get_options_whitelist();
596
		foreach ( $whitelisted_options as $whitelisted_option ) {
597
			if ( $whitelisted_option[0] === '/' && preg_match( $whitelisted_option, $option ) ) {
598
				return true;
599
			} elseif ( $whitelisted_option === $option ) {
600
				return true;
601
			}
602
		}
603
604
		return false;
605
	}
606
607
	static $default_capabilities_whitelist = array(
608
		'switch_themes',
609
		'edit_themes',
610
		'edit_theme_options',
611
		'install_themes',
612
		'activate_plugins',
613
		'edit_plugins',
614
		'install_plugins',
615
		'edit_users',
616
		'edit_files',
617
		'manage_options',
618
		'moderate_comments',
619
		'manage_categories',
620
		'manage_links',
621
		'upload_files',
622
		'import',
623
		'unfiltered_html',
624
		'edit_posts',
625
		'edit_others_posts',
626
		'edit_published_posts',
627
		'publish_posts',
628
		'edit_pages',
629
		'read',
630
		'publish_pages',
631
		'edit_others_pages',
632
		'edit_published_pages',
633
		'delete_pages',
634
		'delete_others_pages',
635
		'delete_published_pages',
636
		'delete_posts',
637
		'delete_others_posts',
638
		'delete_published_posts',
639
		'delete_private_posts',
640
		'edit_private_posts',
641
		'read_private_posts',
642
		'delete_private_pages',
643
		'edit_private_pages',
644
		'read_private_pages',
645
		'delete_users',
646
		'create_users',
647
		'unfiltered_upload',
648
		'edit_dashboard',
649
		'customize',
650
		'delete_site',
651
		'update_plugins',
652
		'delete_plugins',
653
		'update_themes',
654
		'update_core',
655
		'list_users',
656
		'remove_users',
657
		'add_users',
658
		'promote_users',
659
		'delete_themes',
660
		'export',
661
		'edit_comment',
662
		'upload_plugins',
663
		'upload_themes',
664
	);
665
666
	public static function get_capabilities_whitelist() {
667
		/**
668
		 * Filter the list of capabilities that we care about
669
		 *
670
		 * @module sync
671
		 *
672
		 * @since 5.5.0
673
		 *
674
		 * @param array The default list of capabilities.
675
		 */
676
		return apply_filters( 'jetpack_sync_capabilities_whitelist', self::$default_capabilities_whitelist );
677
	}
678
679
	static function get_max_sync_execution_time() {
680
		$max_exec_time = intval( ini_get( 'max_execution_time' ) );
681
		if ( 0 === $max_exec_time ) {
682
			// 0 actually means "unlimited", but let's not treat it that way
683
			$max_exec_time = 60;
684
		}
685
		return floor( $max_exec_time / 3 );
686
	}
687
688
	static function get_default_setting( $setting ) {
689
		$default_name = "default_$setting"; // e.g. default_dequeue_max_bytes
690
		return self::$$default_name;
691
	}
692
693
	static $default_network_options_whitelist = array(
694
		'site_name',
695
		'jetpack_protect_key',
696
		'jetpack_protect_global_whitelist',
697
		'active_sitewide_plugins',
698
	);
699
700
	/**
701
	 * A mapping of known importers to friendly names.
702
	 *
703
	 * Keys are the class name of the known importer.
704
	 * Values are the friendly name.
705
	 *
706
	 * @since 7.3.0
707
	 *
708
	 * @var array
709
	 */
710
	public static $default_known_importers = array(
711
		'Blogger_Importer'     => 'blogger',
712
		'LJ_API_Import'        => 'livejournal',
713
		'MT_Import'            => 'mt',
714
		'RSS_Import'           => 'rss',
715
		'WC_Tax_Rate_Importer' => 'woo-tax-rate',
716
		'WP_Import'            => 'wordpress',
717
	);
718
719
	/**
720
	 * Returns a list of known importers.
721
	 *
722
	 * @since 7.3.0
723
	 *
724
	 * @return array Known importers with importer class names as keys and friendly names as values.
725
	 */
726
	public static function get_known_importers() {
727
		/**
728
		 * Filter the list of known importers.
729
		 *
730
		 * @module sync
731
		 *
732
		 * @since 7.3.0
733
		 *
734
		 * @param array The default list of known importers.
735
		 */
736
		return apply_filters( 'jetpack_sync_known_importers', self::$default_known_importers );
737
	}
738
739
	/**
740
	 * Whether this is a system with a multiple networks.
741
	 * We currently need this static wrapper because we statically define our default list of callables.
742
	 *
743
	 * @since 7.6.0
744
	 *
745
	 * @uses Automattic\Jetpack\Status::is_multi_network
746
	 *
747
	 * @return boolean
748
	 */
749
	public static function is_multi_network() {
750
		$status = new Status();
751
		return $status->is_multi_network();
752
	}
753
754
	static $default_taxonomy_whitelist       = array();
755
	static $default_dequeue_max_bytes        = 500000; // very conservative value, 1/2 MB
756
	static $default_upload_max_bytes         = 600000; // a little bigger than the upload limit to account for serialization
757
	static $default_upload_max_rows          = 500;
758
	static $default_sync_wait_time           = 10; // seconds, between syncs
759
	static $default_sync_wait_threshold      = 5; // only wait before next send if the current send took more than X seconds
760
	static $default_enqueue_wait_time        = 10; // wait between attempting to continue a full sync, via requests
761
	static $default_max_queue_size           = 1000;
762
	static $default_max_queue_lag            = 900; // 15 minutes
763
	static $default_queue_max_writes_sec     = 100; // 100 rows a second
764
	static $default_post_types_blacklist     = array();
765
	static $default_taxonomies_blacklist     = array();
766
	static $default_post_meta_whitelist      = array();
767
	static $default_comment_meta_whitelist   = array();
768
	static $default_disable                  = 0; // completely disable sending data to wpcom
769
	static $default_network_disable          = 0; // completely disable sending data to wpcom network wide
770
	static $default_sync_via_cron            = 1; // use cron to sync
771
	static $default_render_filtered_content  = 0; // render post_filtered_content
772
	static $default_max_enqueue_full_sync    = 100; // max number of items to enqueue at a time when running full sync
773
	static $default_max_queue_size_full_sync = 1000; // max number of total items in the full sync queue
774
	static $default_sync_callables_wait_time = MINUTE_IN_SECONDS; // seconds before sending callables again
775
	static $default_sync_constants_wait_time = HOUR_IN_SECONDS; // seconds before sending constants again
776
	static $default_sync_queue_lock_timeout  = 120; // 2 minutes
777
	static $default_cron_sync_time_limit     = 30; // 30 seconds
778
779
}
780