Completed
Push — add/amp-ads-support ( 39a9c8...65ae21 )
by
unknown
15:32 queued 08:17
created

Defaults   A

Complexity

Total Complexity 18

Size/Duplication

Total Lines 831
Duplicated Lines 0 %

Coupling/Cohesion

Components 9
Dependencies 1

Importance

Changes 0
Metric Value
wmc 18
lcom 9
cbo 1
dl 0
loc 831
rs 9.769
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
		'jp_img_sitemap',
318
		'jp_img_sitemap_index',
319
		'jp_sitemap',
320
		'jp_sitemap_index',
321
		'jp_sitemap_master',
322
		'jp_vid_sitemap',
323
		'jp_vid_sitemap_index',
324
		'postman_sent_mail',
325
		'rssap-feed',
326
		'rssmi_feed_item',
327
		'scheduled-action', // Action Scheduler - Job Queue for WordPress https://github.com/woocommerce/woocommerce/tree/e7762627c37ec1f7590e6cac4218ba0c6a20024d/includes/libraries/action-scheduler .
328
		'secupress_log_action',
329
		'sg_optimizer_jobs',
330
		'snitch',
331
		'vip-legacy-redirect',
332
		'wp_automatic',
333
		'wpephpcompat_jobs',
334
		'wprss_feed_item',
335
	);
336
337
	/**
338
	 * Taxonomies that we're not syncing by default.
339
	 *
340
	 * The list is compiled by auditing the dynamic filters and actions that contain taxonomy slugs
341
	 * and could conflict with other existing filters/actions in WP core, Jetpack and WooCommerce.
342
	 *
343
	 * @var array
344
	 */
345
	public static $blacklisted_taxonomies = array(
346
		'ancestors',
347
		'archives_link',
348
		'attached_file',
349
		'attached_media',
350
		'attached_media_args',
351
		'attachment',
352
		'available_languages',
353
		'avatar',
354
		'avatar_comment_types',
355
		'avatar_data',
356
		'avatar_url',
357
		'bloginfo_rss',
358
		'blogs_of_user',
359
		'bookmark_link',
360
		'bookmarks',
361
		'calendar',
362
		'canonical_url',
363
		'categories_per_page',
364
		'categories_taxonomy',
365
		'category_form',
366
		'category_form_fields',
367
		'category_form_pre',
368
		'comment',
369
		'comment_author',
370
		'comment_author_email',
371
		'comment_author_IP',
372
		'comment_author_link',
373
		'comment_author_url',
374
		'comment_author_url_link',
375
		'comment_date',
376
		'comment_excerpt',
377
		'comment_ID',
378
		'comment_link',
379
		'comment_misc_actions',
380
		'comment_text',
381
		'comment_time',
382
		'comment_type',
383
		'comments_link',
384
		'comments_number',
385
		'comments_pagenum_link',
386
		'custom_logo',
387
		'date_sql',
388
		'default_comment_status',
389
		'delete_post_link',
390
		'edit_bookmark_link',
391
		'edit_comment_link',
392
		'edit_post_link',
393
		'edit_tag_link',
394
		'edit_term_link',
395
		'edit_user_link',
396
		'enclosed',
397
		'feed_build_date',
398
		'form_advanced',
399
		'form_after_editor',
400
		'form_after_title',
401
		'form_before_permalink',
402
		'form_top',
403
		'handle_product_cat',
404
		'header_image_tag',
405
		'header_video_url',
406
		'image_tag',
407
		'image_tag_class',
408
		'lastpostdate',
409
		'lastpostmodified',
410
		'link',
411
		'link_category_form',
412
		'link_category_form_fields',
413
		'link_category_form_pre',
414
		'main_network_id',
415
		'media',
416
		'media_item_args',
417
		'ms_user',
418
		'network',
419
		'object_terms',
420
		'option',
421
		'page',
422
		'page_form',
423
		'page_of_comment',
424
		'page_uri',
425
		'pagenum_link',
426
		'pages',
427
		'plugin',
428
		'post',
429
		'post_galleries',
430
		'post_gallery',
431
		'post_link',
432
		'post_modified_time',
433
		'post_status',
434
		'post_time',
435
		'postmeta',
436
		'posts_per_page',
437
		'product_cat',
438
		'product_search_form',
439
		'profile_url',
440
		'pung',
441
		'role_list',
442
		'sample_permalink',
443
		'sample_permalink_html',
444
		'schedule',
445
		'search_form',
446
		'search_query',
447
		'shortlink',
448
		'site',
449
		'site_email_content',
450
		'site_icon_url',
451
		'site_option',
452
		'space_allowed',
453
		'tag',
454
		'tag_form',
455
		'tag_form_fields',
456
		'tag_form_pre',
457
		'tag_link',
458
		'tags',
459
		'tags_per_page',
460
		'term',
461
		'term_link',
462
		'term_relationships',
463
		'term_taxonomies',
464
		'term_taxonomy',
465
		'terms',
466
		'terms_args',
467
		'terms_defaults',
468
		'terms_fields',
469
		'terms_orderby',
470
		'the_archive_description',
471
		'the_archive_title',
472
		'the_categories',
473
		'the_date',
474
		'the_excerpt',
475
		'the_guid',
476
		'the_modified_date',
477
		'the_modified_time',
478
		'the_post_type_description',
479
		'the_tags',
480
		'the_terms',
481
		'the_time',
482
		'theme_starter_content',
483
		'to_ping',
484
		'user',
485
		'user_created_user',
486
		'user_form',
487
		'user_profile',
488
		'user_profile_update',
489
		'usermeta',
490
		'usernumposts',
491
		'users_drafts',
492
		'webhook',
493
		'widget',
494
		'woocommerce_archive',
495
		'wp_title_rss',
496
	);
497
498
	static $default_post_checksum_columns = array(
499
		'ID',
500
		'post_modified',
501
	);
502
503
	static $default_post_meta_checksum_columns = array(
504
		'meta_id',
505
		'meta_value',
506
	);
507
508
	static $default_comment_checksum_columns = array(
509
		'comment_ID',
510
		'comment_content',
511
	);
512
513
	static $default_comment_meta_checksum_columns = array(
514
		'meta_id',
515
		'meta_value',
516
	);
517
518
	static $default_option_checksum_columns = array(
519
		'option_name',
520
		'option_value',
521
	);
522
523
	static $default_term_checksum_columns = array(
524
		'term_id',
525
		'name',
526
		'slug',
527
	);
528
529
	static $default_term_taxonomy_checksum_columns = array(
530
		'term_taxonomy_id',
531
		'term_id',
532
		'taxonomy',
533
		'parent',
534
		'count',
535
	);
536
537
	static $default_term_relationships_checksum_columns = array(
538
		'object_id',
539
		'term_taxonomy_id',
540
		'term_order',
541
	);
542
543
	static $default_multisite_callable_whitelist = array(
544
		'network_name'                        => array( 'Jetpack', 'network_name' ),
545
		'network_allow_new_registrations'     => array( 'Jetpack', 'network_allow_new_registrations' ),
546
		'network_add_new_users'               => array( 'Jetpack', 'network_add_new_users' ),
547
		'network_site_upload_space'           => array( 'Jetpack', 'network_site_upload_space' ),
548
		'network_upload_file_types'           => array( 'Jetpack', 'network_upload_file_types' ),
549
		'network_enable_administration_menus' => array( 'Jetpack', 'network_enable_administration_menus' ),
550
	);
551
552
	public static function get_multisite_callable_whitelist() {
553
		/**
554
		 * Filter the list of multisite callables that are manageable via the JSON API.
555
		 *
556
		 * @module sync
557
		 *
558
		 * @since 4.8.0
559
		 *
560
		 * @param array The default list of multisite callables.
561
		 */
562
		return apply_filters( 'jetpack_sync_multisite_callable_whitelist', self::$default_multisite_callable_whitelist );
563
	}
564
565
	static $post_meta_whitelist = array(
566
		'_feedback_akismet_values',
567
		'_feedback_email',
568
		'_feedback_extra_fields',
569
		'_g_feedback_shortcode',
570
		'_jetpack_post_thumbnail',
571
		'_menu_item_classes',
572
		'_menu_item_menu_item_parent',
573
		'_menu_item_object',
574
		'_menu_item_object_id',
575
		'_menu_item_orphaned',
576
		'_menu_item_type',
577
		'_menu_item_xfn',
578
		'_publicize_facebook_user',
579
		'_publicize_twitter_user',
580
		'_thumbnail_id',
581
		'_wp_attached_file',
582
		'_wp_attachment_backup_sizes',
583
		'_wp_attachment_context',
584
		'_wp_attachment_image_alt',
585
		'_wp_attachment_is_custom_background',
586
		'_wp_attachment_is_custom_header',
587
		'_wp_attachment_metadata',
588
		'_wp_page_template',
589
		'_wp_trash_meta_comments_status',
590
		'_wpas_mess',
591
		'content_width',
592
		'custom_css_add',
593
		'custom_css_preprocessor',
594
		'enclosure',
595
		'imagedata',
596
		'nova_price',
597
		'publicize_results',
598
		'sharing_disabled',
599
		'switch_like_status',
600
		'videopress_guid',
601
		'vimeo_poster_image',
602
		'advanced_seo_description', // Jetpack_SEO_Posts::DESCRIPTION_META_KEY
603
	);
604
605
	public static function get_post_meta_whitelist() {
606
		/**
607
		 * Filter the list of post meta data that are manageable via the JSON API.
608
		 *
609
		 * @module sync
610
		 *
611
		 * @since 4.8.0
612
		 *
613
		 * @param array The default list of meta data keys.
614
		 */
615
		return apply_filters( 'jetpack_sync_post_meta_whitelist', self::$post_meta_whitelist );
616
	}
617
618
	static $comment_meta_whitelist = array(
619
		'hc_avatar',
620
		'hc_post_as',
621
		'hc_wpcom_id_sig',
622
		'hc_foreign_user_id',
623
	);
624
625
	public static function get_comment_meta_whitelist() {
626
		/**
627
		 * Filter the list of comment meta data that are manageable via the JSON API.
628
		 *
629
		 * @module sync
630
		 *
631
		 * @since 5.7.0
632
		 *
633
		 * @param array The default list of comment meta data keys.
634
		 */
635
		return apply_filters( 'jetpack_sync_comment_meta_whitelist', self::$comment_meta_whitelist );
636
	}
637
638
	// TODO: move this to server? - these are theme support values
639
	// that should be synced as jetpack_current_theme_supports_foo option values
640
	static $default_theme_support_whitelist = array(
641
		'post-thumbnails',
642
		'post-formats',
643
		'custom-header',
644
		'custom-background',
645
		'custom-logo',
646
		'menus',
647
		'automatic-feed-links',
648
		'editor-style',
649
		'widgets',
650
		'html5',
651
		'title-tag',
652
		'jetpack-social-menu',
653
		'jetpack-responsive-videos',
654
		'infinite-scroll',
655
		'site-logo',
656
	);
657
658
	static function is_whitelisted_option( $option ) {
659
		$whitelisted_options = self::get_options_whitelist();
660
		foreach ( $whitelisted_options as $whitelisted_option ) {
661
			if ( $whitelisted_option[0] === '/' && preg_match( $whitelisted_option, $option ) ) {
662
				return true;
663
			} elseif ( $whitelisted_option === $option ) {
664
				return true;
665
			}
666
		}
667
668
		return false;
669
	}
670
671
	static $default_capabilities_whitelist = array(
672
		'switch_themes',
673
		'edit_themes',
674
		'edit_theme_options',
675
		'install_themes',
676
		'activate_plugins',
677
		'edit_plugins',
678
		'install_plugins',
679
		'edit_users',
680
		'edit_files',
681
		'manage_options',
682
		'moderate_comments',
683
		'manage_categories',
684
		'manage_links',
685
		'upload_files',
686
		'import',
687
		'unfiltered_html',
688
		'edit_posts',
689
		'edit_others_posts',
690
		'edit_published_posts',
691
		'publish_posts',
692
		'edit_pages',
693
		'read',
694
		'publish_pages',
695
		'edit_others_pages',
696
		'edit_published_pages',
697
		'delete_pages',
698
		'delete_others_pages',
699
		'delete_published_pages',
700
		'delete_posts',
701
		'delete_others_posts',
702
		'delete_published_posts',
703
		'delete_private_posts',
704
		'edit_private_posts',
705
		'read_private_posts',
706
		'delete_private_pages',
707
		'edit_private_pages',
708
		'read_private_pages',
709
		'delete_users',
710
		'create_users',
711
		'unfiltered_upload',
712
		'edit_dashboard',
713
		'customize',
714
		'delete_site',
715
		'update_plugins',
716
		'delete_plugins',
717
		'update_themes',
718
		'update_core',
719
		'list_users',
720
		'remove_users',
721
		'add_users',
722
		'promote_users',
723
		'delete_themes',
724
		'export',
725
		'edit_comment',
726
		'upload_plugins',
727
		'upload_themes',
728
	);
729
730
	public static function get_capabilities_whitelist() {
731
		/**
732
		 * Filter the list of capabilities that we care about
733
		 *
734
		 * @module sync
735
		 *
736
		 * @since 5.5.0
737
		 *
738
		 * @param array The default list of capabilities.
739
		 */
740
		return apply_filters( 'jetpack_sync_capabilities_whitelist', self::$default_capabilities_whitelist );
741
	}
742
743
	static function get_max_sync_execution_time() {
744
		$max_exec_time = intval( ini_get( 'max_execution_time' ) );
745
		if ( 0 === $max_exec_time ) {
746
			// 0 actually means "unlimited", but let's not treat it that way
747
			$max_exec_time = 60;
748
		}
749
		return floor( $max_exec_time / 3 );
750
	}
751
752
	static function get_default_setting( $setting ) {
753
		$default_name = "default_$setting"; // e.g. default_dequeue_max_bytes
754
		return self::$$default_name;
755
	}
756
757
	static $default_network_options_whitelist = array(
758
		'site_name',
759
		'jetpack_protect_key',
760
		'jetpack_protect_global_whitelist',
761
		'active_sitewide_plugins',
762
	);
763
764
	/**
765
	 * A mapping of known importers to friendly names.
766
	 *
767
	 * Keys are the class name of the known importer.
768
	 * Values are the friendly name.
769
	 *
770
	 * @since 7.3.0
771
	 *
772
	 * @var array
773
	 */
774
	public static $default_known_importers = array(
775
		'Blogger_Importer'     => 'blogger',
776
		'LJ_API_Import'        => 'livejournal',
777
		'MT_Import'            => 'mt',
778
		'RSS_Import'           => 'rss',
779
		'WC_Tax_Rate_Importer' => 'woo-tax-rate',
780
		'WP_Import'            => 'wordpress',
781
	);
782
783
	/**
784
	 * Returns a list of known importers.
785
	 *
786
	 * @since 7.3.0
787
	 *
788
	 * @return array Known importers with importer class names as keys and friendly names as values.
789
	 */
790
	public static function get_known_importers() {
791
		/**
792
		 * Filter the list of known importers.
793
		 *
794
		 * @module sync
795
		 *
796
		 * @since 7.3.0
797
		 *
798
		 * @param array The default list of known importers.
799
		 */
800
		return apply_filters( 'jetpack_sync_known_importers', self::$default_known_importers );
801
	}
802
803
	/**
804
	 * Whether this is a system with a multiple networks.
805
	 * We currently need this static wrapper because we statically define our default list of callables.
806
	 *
807
	 * @since 7.6.0
808
	 *
809
	 * @uses Automattic\Jetpack\Status::is_multi_network
810
	 *
811
	 * @return boolean
812
	 */
813
	public static function is_multi_network() {
814
		$status = new Status();
815
		return $status->is_multi_network();
816
	}
817
818
	static $default_taxonomy_whitelist       = array();
819
	static $default_dequeue_max_bytes        = 500000; // very conservative value, 1/2 MB
820
	static $default_upload_max_bytes         = 600000; // a little bigger than the upload limit to account for serialization
821
	static $default_upload_max_rows          = 500;
822
	static $default_sync_wait_time           = 10; // seconds, between syncs
823
	static $default_sync_wait_threshold      = 5; // only wait before next send if the current send took more than X seconds
824
	static $default_enqueue_wait_time        = 10; // wait between attempting to continue a full sync, via requests
825
	static $default_max_queue_size           = 1000;
826
	static $default_max_queue_lag            = 900; // 15 minutes
827
	static $default_queue_max_writes_sec     = 100; // 100 rows a second
828
	static $default_post_types_blacklist     = array();
829
	static $default_taxonomies_blacklist     = array();
830
	static $default_post_meta_whitelist      = array();
831
	static $default_comment_meta_whitelist   = array();
832
	static $default_disable                  = 0; // completely disable sending data to wpcom
833
	static $default_network_disable          = 0; // completely disable sending data to wpcom network wide
834
	static $default_sync_via_cron            = 1; // use cron to sync
835
	static $default_render_filtered_content  = 0; // render post_filtered_content
836
	static $default_max_enqueue_full_sync    = 100; // max number of items to enqueue at a time when running full sync
837
	static $default_max_queue_size_full_sync = 1000; // max number of total items in the full sync queue
838
	static $default_sync_callables_wait_time = MINUTE_IN_SECONDS; // seconds before sending callables again
839
	static $default_sync_constants_wait_time = HOUR_IN_SECONDS; // seconds before sending constants again
840
	static $default_sync_queue_lock_timeout  = 120; // 2 minutes
841
	static $default_cron_sync_time_limit     = 30; // 30 seconds
842
843
}
844