Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
38.46% covered (danger)
38.46%
10 / 26
57.14% covered (warning)
57.14%
8 / 14
CRAP
0.00% covered (danger)
0.00%
0 / 1
Defaults
38.46% covered (danger)
38.46%
10 / 26
57.14% covered (warning)
57.14%
8 / 14
103.13
0.00% covered (danger)
0.00%
0 / 1
 get_options_whitelist
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 get_options_contentless
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 get_constants_whitelist
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_callable_whitelist
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 get_multisite_callable_whitelist
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_post_meta_whitelist
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 get_comment_meta_whitelist
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 get_comment_types_whitelist
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 is_whitelisted_option
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
30
 get_capabilities_whitelist
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_max_sync_execution_time
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
 get_default_setting
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 get_known_importers
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 is_multi_network
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 * Jetpack Sync Defaults
4 *
5 * @package automattic/jetpack-sync
6 */
7
8namespace Automattic\Jetpack\Sync;
9
10use Automattic\Jetpack\Status;
11
12/**
13 * Just some defaults that we share with the server.
14 */
15class Defaults {
16
17    /**
18     * Default Options.
19     *
20     * @var array
21     */
22    public static $default_options_whitelist = array(
23        'active_plugins',
24        'admin_email',
25        'advanced_seo_front_page_description', // Jetpack_SEO_Utils::FRONT_PAGE_META_OPTION.
26        'advanced_seo_title_formats', // Jetpack_SEO_Titles::TITLE_FORMATS_OPTION.
27        'avatar_default',
28        'avatar_rating',
29        'blog_charset',
30        'blog_public',
31        'wpcom_data_sharing_opt_out',
32        'blogdescription',
33        'blogname',
34        'carousel_background_color',
35        'carousel_display_comments',
36        'carousel_display_exif',
37        'category_base',
38        'ce4wp_referred_by', // Creative Mail. See pbtFPC-H5-p2.
39        'close_comments_days_old',
40        'close_comments_for_old_posts',
41        'comment_max_links',
42        'comment_moderation',
43        'comment_order',
44        'comment_previously_approved',
45        'comment_registration',
46        'comments_notify',
47        'comments_per_page',
48        'date_format',
49        'default_category',
50        'default_comment_status',
51        'default_comments_page',
52        'default_email_category',
53        'default_ping_status',
54        'default_pingback_flag',
55        'default_post_format',
56        'default_role',
57        'disabled_likes',
58        'disabled_reblogs',
59        'disallowed_keys',
60        'enable_header_ad',
61        'gmt_offset',
62        'gravatar_disable_hovercards',
63        'highlander_comment_form_prompt',
64        'image_default_link_type',
65        'infinite_scroll',
66        'infinite_scroll_google_analytics',
67        'jetpack-memberships-has-connected-account',
68        'jetpack-twitter-cards-site-tag',
69        'jetpack_activated',
70        'jetpack_allowed_xsite_search_ids',
71        'jetpack_api_cache_enabled',
72        'jetpack_autoupdate_core',
73        'jetpack_autoupdate_plugins',
74        'jetpack_autoupdate_plugins_translations',
75        'jetpack_autoupdate_themes',
76        'jetpack_autoupdate_themes_translations',
77        'jetpack_autoupdate_translations',
78        'jetpack_available_modules',
79        'jetpack_comment_form_color_scheme',
80        'jetpack_comment_likes_enabled',
81        'jetpack_excluded_extensions',
82        'jetpack_holiday_snow_enabled',
83        'jetpack_mailchimp',
84        'jetpack_options',
85        'jetpack_portfolio',
86        'jetpack_portfolio_posts_per_page',
87        'jetpack_protect_global_whitelist',
88        'jetpack_protect_key',
89        'jetpack_publicize_options',
90        'jetpack_relatedposts',
91        'jetpack_social_message_template',
92        'jetpack_social_notes_config',
93        'jetpack_social_settings',
94        'jetpack_social_utm_settings',
95        'jetpack_sso_match_by_email',
96        'jetpack_sso_require_two_step',
97        'jetpack_sync_non_blocking', // is non-blocking Jetpack Sync flow enabled.
98        'jetpack_sync_non_public_post_stati',
99        'jetpack_sync_settings_comment_meta_whitelist',
100        'jetpack_sync_settings_post_meta_whitelist',
101        'jetpack_sync_settings_post_types_blacklist',
102        'jetpack_sync_settings_taxonomies_blacklist',
103        'jetpack_sync_settings_dedicated_sync_enabled', // is Dedicated Sync flow enabled.
104        'jetpack_sync_settings_custom_queue_table_enabled', // is custom queue table enabled.
105        'jetpack_sync_settings_wpcom_rest_api_enabled', // is wpcom rest api enabled.
106        'jetpack_testimonial',
107        'jetpack_testimonial_posts_per_page',
108        'jetpack_wga',
109        'large_size_h',
110        'large_size_w',
111        'launch-status',
112        'launchpad_checklist_tasks_statuses',
113        'launchpad_screen',
114        'mailserver_login', // Not syncing contents, only the option name.
115        'mailserver_pass', // Not syncing contents, only the option name.
116        'mailserver_port',
117        'mailserver_url',
118        'medium_size_h',
119        'medium_size_w',
120        'moderation_keys',
121        'moderation_notify',
122        'monitor_receive_notifications',
123        'new_admin_email',
124        'page_comments',
125        'page_for_posts',
126        'page_on_front',
127        'permalink_structure',
128        'ping_sites',
129        'post_by_email_address',
130        'post_count',
131        'posts_per_page',
132        'posts_per_rss',
133        'require_name_email',
134        'rss_use_excerpt',
135        'sharing-options',
136        'sharing-services',
137        'show_avatars',
138        'show_on_front',
139        'sidebars_widgets',
140        'site_icon', // (int) - ID of core's Site Icon attachment ID
141        'site_logo',
142        'site_segment',
143        'site_user_type',
144        'site_vertical',
145        'social_notifications_like',
146        'social_notifications_reblog',
147        'social_notifications_subscribe',
148        'start_of_week',
149        'stats_options',
150        'stb_enabled',
151        'stc_enabled',
152        'sm_enabled',
153        'sticky_posts',
154        'stylesheet',
155        'subscription_options',
156        'tag_base',
157        'thread_comments',
158        'thread_comments_depth',
159        'thumbnail_crop',
160        'thumbnail_size_h',
161        'thumbnail_size_w',
162        'tiled_galleries',
163        'time_format',
164        'timezone_string',
165        'twitter_via',
166        'uninstall_plugins',
167        'uploads_use_yearmonth_folders',
168        'users_can_register',
169        'verification_services_codes',
170        'videopress_auto_subtitles_disabled',
171        'videopress_private_enabled_for_site',
172        'wordads_ccpa_enabled',
173        'wordads_ccpa_privacy_policy_url',
174        'wordads_cmp_enabled',
175        'wordads_custom_adstxt',
176        'wordads_custom_adstxt_enabled',
177        'wordads_display_archive',
178        'wordads_display_front_page',
179        'wordads_display_page',
180        'wordads_display_post',
181        'wordads_second_belowpost',
182        'wordads_inline_enabled',
183        'woocommerce_custom_orders_table_enabled',
184        'wp_mobile_app_promos',
185        'wp_mobile_excerpt',
186        'wp_mobile_featured_images',
187        'wp_page_for_privacy_policy',
188        'wpcom_ai_launchpad_completed',
189        'wpcom_ai_launchpad_dismissed',
190        'wpcom_ai_launchpad_enabled',
191        'wpcom_ai_site_prompt',
192        'wpcom_classic_early_release',
193        'wpcom_newsletter_send_default',
194        'wpcom_featured_image_in_email',
195        'jetpack_gravatar_in_email',
196        'jetpack_author_in_email',
197        'jetpack_post_date_in_email',
198        'wpcom_gifting_subscription',
199        'wpcom_is_fse_activated',
200        'wpcom_legacy_contact',
201        'wpcom_locked_mode',
202        'wpcom_newsletter_categories',
203        'wpcom_newsletter_categories_enabled',
204        'wpcom_publish_comments_with_markdown',
205        'wpcom_publish_posts_with_markdown',
206        'wpcom_reader_views_enabled',
207        'wpcom_site_setup',
208        'wpcom_subscription_emails_use_excerpt',
209        'jetpack_subscriptions_reply_to',
210        'jetpack_subscriptions_from_name',
211        'jetpack_verbum_subscription_modal',
212        'jetpack_blocks_disabled',
213        'jetpack_newsletters_publishing_default_frequency',
214        'jetpack_scheduled_plugins_update',
215        'jetpack_waf_automatic_rules',
216        'jetpack_waf_ip_allow_list',
217        'jetpack_waf_ip_allow_list_enabled',
218        'jetpack_waf_ip_block_list',
219        'jetpack_waf_ip_block_list_enabled',
220        'jetpack_waf_share_data',
221        'jetpack_waf_share_debug_data',
222        'jetpack_waf_automatic_rules_last_updated_timestamp',
223    );
224
225    /**
226     * Return options whitelist filtered.
227     *
228     * @return array Options whitelist.
229     */
230    public static function get_options_whitelist() {
231        /** This filter is already documented in json-endpoints/jetpack/class.wpcom-json-api-get-option-endpoint.php */
232        $options_whitelist = apply_filters( 'jetpack_options_whitelist', self::$default_options_whitelist );
233        /**
234         * Filter the list of WordPress options that are manageable via the JSON API.
235         *
236         * @module sync
237         *
238         * @since 1.6.3
239         * @since-jetpack 4.8.0
240         *
241         * @param array The default list of options.
242         */
243        return apply_filters( 'jetpack_sync_options_whitelist', $options_whitelist );
244    }
245
246    /**
247     * "Contentless" Options.
248     *
249     * Do not sync contents for these events, only the option name. Good for sensitive information that Sync does not need.
250     *
251     * @var array Options to sync name only.
252     */
253    public static $default_options_contentless = array(
254        'mailserver_login',
255        'mailserver_pass',
256    );
257
258    /**
259     * Return contentless options.
260     *
261     * These are options that Sync only uses the option names, not the content of the option.
262     *
263     * @return array
264     */
265    public static function get_options_contentless() {
266        /**
267         * Filter the list of WordPress options that should be synced without content
268         *
269         * @module sync
270         *
271         * @since 1.6.3
272         * @since-jetpack 6.1.0
273         *
274         * @param array The list of options synced without content.
275         */
276        return apply_filters( 'jetpack_sync_options_contentless', self::$default_options_contentless );
277    }
278
279    /**
280     * Array of defaulted constants whitelisted.
281     *
282     * @var array Default constants whitelist
283     */
284    public static $default_constants_whitelist = array(
285        'ABSPATH',
286        'ALTERNATE_WP_CRON',
287        'ATOMIC_CLIENT_ID',
288        'AUTOMATIC_UPDATER_DISABLED',
289        'DISABLE_WP_CRON',
290        'DISALLOW_FILE_EDIT',
291        'DISALLOW_FILE_MODS',
292        'EMPTY_TRASH_DAYS',
293        'FS_METHOD',
294        'IS_PRESSABLE',
295        'JETPACK__VERSION',
296        'PHP_VERSION',
297        'WP_ACCESSIBLE_HOSTS',
298        'WP_AUTO_UPDATE_CORE',
299        'WP_CONTENT_DIR',
300        'WP_CRON_LOCK_TIMEOUT',
301        'WP_DEBUG',
302        'WP_HTTP_BLOCK_EXTERNAL',
303        'WP_MAX_MEMORY_LIMIT',
304        'WP_MEMORY_LIMIT',
305        'WP_POST_REVISIONS',
306    );
307
308    /**
309     * Get constants whitelisted by Sync.
310     *
311     * @return array Constants accessible via sync.
312     */
313    public static function get_constants_whitelist() {
314        /**
315         * Filter the list of PHP constants that are manageable via the JSON API.
316         *
317         * @module sync
318         *
319         * @since 1.6.3
320         * @since-jetpack 4.8.0
321         *
322         * @param array The default list of constants options.
323         */
324        return apply_filters( 'jetpack_sync_constants_whitelist', self::$default_constants_whitelist );
325    }
326
327    /**
328     * Callables able to be managed via JSON API.
329     *
330     * @var array Default whitelist of callables.
331     */
332    public static $default_callable_whitelist = array(
333        'get_loaded_extensions'             => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_loaded_extensions' ),
334        'get_plugins'                       => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_plugins' ),
335        'get_themes'                        => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_themes' ),
336        'get_plugins_action_links'          => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_plugins_action_links' ),
337        'has_file_system_write_access'      => array( 'Automattic\\Jetpack\\Sync\\Functions', 'file_system_write_access' ),
338        'home_url'                          => array( 'Automattic\\Jetpack\\Connection\\Urls', 'home_url' ),
339        'hosting_provider'                  => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_hosting_provider' ),
340        'is_fse_theme'                      => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_is_fse_theme' ),
341        'is_main_network'                   => array( __CLASS__, 'is_multi_network' ),
342        'is_multi_site'                     => 'is_multisite',
343        'is_version_controlled'             => array( 'Automattic\\Jetpack\\Sync\\Functions', 'is_version_controlled' ),
344        'locale'                            => 'get_locale',
345        'main_network_site'                 => array( 'Automattic\\Jetpack\\Connection\\Urls', 'main_network_site_url' ),
346        'main_network_site_wpcom_id'        => array( 'Automattic\\Jetpack\\Sync\\Functions', 'main_network_site_wpcom_id' ),
347        'paused_plugins'                    => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_paused_plugins' ),
348        'paused_themes'                     => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_paused_themes' ),
349        'post_type_features'                => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_post_type_features' ),
350        'post_types'                        => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_post_types' ),
351        'rest_api_allowed_post_types'       => array( 'Automattic\\Jetpack\\Sync\\Functions', 'rest_api_allowed_post_types' ),
352        'rest_api_allowed_public_metadata'  => array( 'Automattic\\Jetpack\\Sync\\Functions', 'rest_api_allowed_public_metadata' ),
353        'roles'                             => array( 'Automattic\\Jetpack\\Sync\\Functions', 'roles' ),
354        'shortcodes'                        => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_shortcodes' ),
355        'site_icon_url'                     => array( 'Automattic\\Jetpack\\Sync\\Functions', 'site_icon_url' ),
356        'site_url'                          => array( 'Automattic\\Jetpack\\Connection\\Urls', 'site_url' ),
357        'taxonomies'                        => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_taxonomies' ),
358        'theme_support'                     => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_theme_support' ),
359        'timezone'                          => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_timezone' ),
360        'wp_get_environment_type'           => 'wp_get_environment_type',
361        'wp_max_upload_size'                => 'wp_max_upload_size',
362        'wp_version'                        => array( 'Automattic\\Jetpack\\Sync\\Functions', 'wp_version' ),
363        'active_modules'                    => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_active_modules' ),
364        'jetpack_connection_active_plugins' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_jetpack_connection_active_plugins' ),
365        'jetpack_package_versions'          => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_jetpack_package_versions' ),
366        'jetpack_sync_active_modules'       => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_jetpack_sync_active_modules' ),
367    );
368
369    /**
370     * Array of post type attributes synced.
371     *
372     * @var array Default post type attributes.
373     */
374    public static $default_post_type_attributes = array(
375        '_builtin'            => false,
376        '_edit_link'          => 'post.php?post=%d',
377        'can_export'          => true,
378        'cap'                 => array(),
379        'capabilities'        => array(),
380        'capability_type'     => 'post',
381        'delete_with_user'    => null,
382        'description'         => '',
383        'exclude_from_search' => true,
384        'has_archive'         => false,
385        'hierarchical'        => false,
386        'label'               => '',
387        'labels'              => array(),
388        'map_meta_cap'        => true,
389        'menu_icon'           => null,
390        'menu_position'       => null,
391        'name'                => '',
392        'public'              => false,
393        'publicly_queryable'  => null,
394        'query_var'           => true,
395        'rest_base'           => false,
396        'rewrite'             => true,
397        'show_in_admin_bar'   => false,
398        'show_in_menu'        => null,
399        'show_in_nav_menus'   => null,
400        'show_in_rest'        => false,
401        'show_ui'             => false,
402        'supports'            => array(),
403        'taxonomies'          => array(),
404    );
405
406    /**
407     * Get the whitelist of callables allowed to be managed via the JSON API.
408     *
409     * @return array Whitelist of callables allowed to be managed via the JSON API.
410     */
411    public static function get_callable_whitelist() {
412        /**
413         * Filter the list of callables that are manageable via the JSON API.
414         *
415         * @module sync
416         *
417         * @since 1.6.3
418         * @since-jetpack 4.8.0
419         *
420         * @param array The default list of callables.
421         */
422        return apply_filters( 'jetpack_sync_callable_whitelist', self::$default_callable_whitelist );
423    }
424
425    /**
426     * Post types that will not be synced.
427     *
428     * These are usually automated post types (sitemaps, logs, etc).
429     *
430     * @var array Blacklisted post types.
431     */
432    public static $blacklisted_post_types = array(
433        '_term_meta',
434        'ai1ec_event',
435        'ai_log', // Logger - https://github.com/alleyinteractive/logger.
436        'amp_validated_url', // AMP Validation Errors.
437        'bwg_album',
438        'bwg_gallery',
439        'customize_changeset', // WP built-in post type for Customizer changesets.
440        'dn_wp_yt_log',
441        'flamingo_contact', // https://wordpress.org/plugins/flamingo/.
442        'flamingo_inbound',
443        'flamingo_outbound',
444        'http',
445        'idx_page',
446        'jetpack_inspect_log', // Jetpack Inspect dev tool. p1HpG7-nkd-p2
447        'jetpack_migration',
448        'jp_img_sitemap',
449        'jp_img_sitemap_index',
450        'jp_sitemap',
451        'jp_sitemap_index',
452        'jp_sitemap_master',
453        'jp_vid_sitemap',
454        'jp_vid_sitemap_index',
455        'msm_sitemap', // Metro Sitemap Plugin.
456        'postman_sent_mail',
457        'rssap-feed',
458        'rssmi_feed_item',
459        'scheduled-action', // Action Scheduler - Job Queue for WordPress https://github.com/woocommerce/woocommerce/tree/e7762627c37ec1f7590e6cac4218ba0c6a20024d/includes/libraries/action-scheduler .
460        'secupress_log_action',
461        'sg_optimizer_jobs',
462        'sl-insta-media',
463        'snitch',
464        'vip-legacy-redirect',
465        'wp-rest-api-log', // https://wordpress.org/plugins/wp-rest-api-log/.
466        'wp_automatic',
467        'wp_log', // WP Logging Plugin.
468        'wpephpcompat_jobs',
469        'wprss_feed_item',
470        'tribe-ea-record', // The Events Calendar Plugin - Store Event Aggregator record information.
471        'wphb_minify_group', // Hummingbird Plugin - Used internally to keep data about assets minification.
472        'bigcommerce_task', // BigCommerce Plugin - Store import queue.
473        'secupress_log_err404', // SecuPress Plugin - Log 404 pages
474        'iw_omnibus_price_log', // Omnibus Plugin - Log price changes.
475        'od_url_metrics', // Optimization Detective - Log URL metrics.
476        'ap_outbox', // ActivityPub Outbox; only used for broadcasting ActivityPub activity to followers.
477        'shop_order_placehold', // WooCommerce placeholder - Used to maintain compatibility and references when switching between WP Posts-based order storage and the newer HPOS tables.
478    );
479
480    /**
481     * Taxonomies that we're not syncing by default.
482     *
483     * The list is compiled by auditing the dynamic filters and actions that contain taxonomy slugs
484     * and could conflict with other existing filters/actions in WP core, Jetpack and WooCommerce.
485     *
486     * @var array
487     */
488    public static $blacklisted_taxonomies = array(
489        'ancestors',
490        'archives_link',
491        'attached_file',
492        'attached_media',
493        'attached_media_args',
494        'attachment',
495        'available_languages',
496        'avatar',
497        'avatar_comment_types',
498        'avatar_data',
499        'avatar_url',
500        'bloginfo_rss',
501        'blogs_of_user',
502        'bookmark_link',
503        'bookmarks',
504        'calendar',
505        'canonical_url',
506        'categories_per_page',
507        'categories_taxonomy',
508        'category_form',
509        'category_form_fields',
510        'category_form_pre',
511        'comment',
512        'comment_ID',
513        'comment_author',
514        'comment_author_IP',
515        'comment_author_email',
516        'comment_author_link',
517        'comment_author_url',
518        'comment_author_url_link',
519        'comment_date',
520        'comment_excerpt',
521        'comment_link',
522        'comment_misc_actions',
523        'comment_text',
524        'comment_time',
525        'comment_type',
526        'comments_link',
527        'comments_number',
528        'comments_pagenum_link',
529        'custom_logo',
530        'date_sql',
531        'default_comment_status',
532        'delete_post_link',
533        'edit_bookmark_link',
534        'edit_comment_link',
535        'edit_post_link',
536        'edit_tag_link',
537        'edit_term_link',
538        'edit_user_link',
539        'enclosed',
540        'feed_build_date',
541        'form_advanced',
542        'form_after_editor',
543        'form_after_title',
544        'form_before_permalink',
545        'form_top',
546        'handle_product_cat',
547        'header_image_tag',
548        'header_video_url',
549        'image_tag',
550        'image_tag_class',
551        'lastpostdate',
552        'lastpostmodified',
553        'link',
554        'link_category_form',
555        'link_category_form_fields',
556        'link_category_form_pre',
557        'main_network_id',
558        'media',
559        'media_item_args',
560        'ms_user',
561        'network',
562        'object_terms',
563        'option',
564        'page',
565        'page_form',
566        'page_of_comment',
567        'page_uri',
568        'pagenum_link',
569        'pages',
570        'plugin',
571        'post',
572        'post_galleries',
573        'post_gallery',
574        'post_link',
575        'post_modified_time',
576        'post_status',
577        'post_time',
578        'postmeta',
579        'posts_per_page',
580        'product_search_form',
581        'profile_url',
582        'pung',
583        'role_list',
584        'sample_permalink',
585        'sample_permalink_html',
586        'schedule',
587        'search_form',
588        'search_query',
589        'shortlink',
590        'site',
591        'site_email_content',
592        'site_icon_url',
593        'site_option',
594        'space_allowed',
595        'tag',
596        'tag_form',
597        'tag_form_fields',
598        'tag_form_pre',
599        'tag_link',
600        'tags',
601        'tags_per_page',
602        'term',
603        'term_link',
604        'term_relationships',
605        'term_taxonomies',
606        'term_taxonomy',
607        'terms',
608        'terms_args',
609        'terms_defaults',
610        'terms_fields',
611        'terms_orderby',
612        'the_archive_description',
613        'the_archive_title',
614        'the_categories',
615        'the_date',
616        'the_excerpt',
617        'the_guid',
618        'the_modified_date',
619        'the_modified_time',
620        'the_post_type_description',
621        'the_tags',
622        'the_terms',
623        'the_time',
624        'theme_starter_content',
625        'to_ping',
626        'user',
627        'user_created_user',
628        'user_form',
629        'user_profile',
630        'user_profile_update',
631        'usermeta',
632        'usernumposts',
633        'users_drafts',
634        'webhook',
635        'widget',
636        'woocommerce_archive',
637        'wp_title_rss',
638    );
639
640    /**
641     * Default array of post table columns.
642     *
643     * @var array Post table columns.
644     */
645    public static $default_post_checksum_columns = array(
646        'ID',
647        'post_modified',
648    );
649
650    /**
651     * Default array of post meta table columns.
652     *
653     * @var array Post meta table columns.
654     */
655    public static $default_post_meta_checksum_columns = array(
656        'meta_id',
657        'meta_value',
658    );
659
660    /**
661     * Default array of comment table columns.
662     *
663     * @var array Default comment table columns.
664     */
665    public static $default_comment_checksum_columns = array(
666        'comment_ID',
667        'comment_content',
668    );
669
670    /**
671     * Default array of comment meta columns.
672     *
673     * @var array Comment meta table columns.
674     */
675    public static $default_comment_meta_checksum_columns = array(
676        'meta_id',
677        'meta_value',
678    );
679
680    /**
681     * Default array of option table columns.
682     *
683     * @var array Default array of option columns.
684     */
685    public static $default_option_checksum_columns = array(
686        'option_name',
687        'option_value',
688    );
689
690    /**
691     * Default array of term columns.
692     *
693     * @var array array of term columns.
694     */
695    public static $default_term_checksum_columns = array(
696        'name',
697        'slug',
698        'term_id',
699    );
700
701    /**
702     * Default array of term taxonomy columns.
703     *
704     * @var array Array of term taxonomy columns.
705     */
706    public static $default_term_taxonomy_checksum_columns = array(
707        'count',
708        'parent',
709        'taxonomy',
710        'term_id',
711        'term_taxonomy_id',
712    );
713
714    /**
715     * Default term relationship columns.
716     *
717     * @var array Array of term relationship columns.
718     */
719    public static $default_term_relationships_checksum_columns = array(
720        'object_id',
721        'term_order',
722        'term_taxonomy_id',
723    );
724
725    /**
726     * Default multisite callables able to be managed via JSON API.
727     *
728     * @var array multsite callables whitelisted
729     */
730    public static $default_multisite_callable_whitelist = array();
731
732    /**
733     * Get array of multisite callables whitelisted.
734     *
735     * @return array Multisite callables managable via JSON API.
736     */
737    public static function get_multisite_callable_whitelist() {
738        /**
739         * Filter the list of multisite callables that are manageable via the JSON API.
740         *
741         * @module sync
742         *
743         * @since 1.6.3
744         * @since-jetpack 4.8.0
745         *
746         * @param array The default list of multisite callables.
747         */
748        return apply_filters( 'jetpack_sync_multisite_callable_whitelist', self::$default_multisite_callable_whitelist );
749    }
750
751    /**
752     * Array of post meta keys whitelisted.
753     *
754     * @var array Post meta whitelist.
755     */
756    public static $post_meta_whitelist = array(
757        '_feedback_akismet_values',
758        '_feedback_email',
759        '_feedback_extra_fields',
760        '_g_feedback_shortcode',
761        '_jetpack_post_thumbnail',
762        '_last_editor_used_jetpack',
763        '_menu_item_classes',
764        '_menu_item_menu_item_parent',
765        '_menu_item_object',
766        '_menu_item_object_id',
767        '_menu_item_orphaned',
768        '_menu_item_type',
769        '_menu_item_xfn',
770        '_publicize_facebook_user',
771        '_publicize_twitter_user',
772        '_thumbnail_id',
773        '_wp_attached_file',
774        '_wp_attachment_backup_sizes',
775        '_wp_attachment_context',
776        '_wp_attachment_image_alt',
777        '_wp_attachment_is_custom_background',
778        '_wp_attachment_is_custom_header',
779        '_wp_attachment_metadata',
780        '_wp_old_date',
781        '_wp_page_template',
782        '_wp_trash_meta_comments_status',
783        '_wpas_feature_enabled',
784        '_wpas_connection_overrides',
785        '_wpas_customize_per_network',
786        '_wpas_mess',
787        '_wpas_options',
788        '_jetpack_social_image_focal_point', // Publicize_Base::ATTACHMENT_IMAGE_FOCAL_POINT.
789        'advanced_seo_description', // Jetpack_SEO_Posts::DESCRIPTION_META_KEY.
790        'content_width',
791        'custom_css_add',
792        'custom_css_preprocessor',
793        'enclosure',
794        'imagedata',
795        'nova_price',
796        'publicize_results',
797        'sharing_disabled',
798        'switch_like_status',
799        'videopress_guid',
800        'vimeo_poster_image',
801        '_jetpack_blogging_prompt_key',
802        'footnotes', // Core footnotes block
803    );
804
805    /**
806     * Get the post meta key whitelist.
807     *
808     * @return array Post meta whitelist.
809     */
810    public static function get_post_meta_whitelist() {
811        /**
812         * Filter the list of post meta data that are manageable via the JSON API.
813         *
814         * @module sync
815         *
816         * @since 1.6.3
817         * @since-jetpack 4.8.0
818         *
819         * @param array The default list of meta data keys.
820         */
821        return apply_filters( 'jetpack_sync_post_meta_whitelist', self::$post_meta_whitelist );
822    }
823
824    /**
825     * Comment meta whitelist.
826     *
827     * @var array Comment meta whitelist.
828     */
829    public static $comment_meta_whitelist = array(
830        'hc_avatar',
831        'hc_foreign_user_id',
832        'hc_post_as',
833        'hc_wpcom_id_sig',
834        'protocol',
835    );
836
837    /**
838     * Get the comment meta whitelist.
839     *
840     * @return array
841     */
842    public static function get_comment_meta_whitelist() {
843        /**
844         * Filter the list of comment meta data that are manageable via the JSON API.
845         *
846         * @module sync
847         *
848         * @since 1.6.3
849         * @since-jetpack 5.7.0
850         *
851         * @param array The default list of comment meta data keys.
852         */
853        return apply_filters( 'jetpack_sync_comment_meta_whitelist', self::$comment_meta_whitelist );
854    }
855
856    /**
857     * Comment types whitelist.
858     *
859     * @var array Comment types that are synced.
860     */
861    public static $comment_types_whitelist = array( '', 'comment', 'trackback', 'pingback', 'review', 'note' );
862
863    /**
864     * Get the comment types whitelist.
865     *
866     * @return array
867     */
868    public static function get_comment_types_whitelist() {
869        /**
870         * Comment types present in this list will be synced to WordPress.com.
871         *
872         * @module sync
873         *
874         * @since 1.6.3
875         * @since-jetpack 7.6.0
876         *
877         * @param array A list of comment types.
878         */
879        return apply_filters( 'jetpack_sync_whitelisted_comment_types', self::$comment_types_whitelist );
880    }
881
882    /**
883     * Default theme support whitelist.
884     *
885     * @todo move this to server? - these are theme support values
886     * that should be synced as jetpack_current_theme_supports_foo option values
887     *
888     * @var array Default theme support whitelist.
889     */
890    public static $default_theme_support_whitelist = array(
891        'align-wide',
892        'appearance-tools', // In Gutenberg.
893        'automatic-feed-links',
894        'block-templates',
895        'block-template-parts', // WP 6.1. Added via https://core.trac.wordpress.org/changeset/54176
896        'custom-background',
897        'custom-header',
898        'custom-logo',
899        'customize-selective-refresh-widgets',
900        'dark-editor-style',
901        'default-color-palette', // In Gutenberg.
902        'default-gradient-presets', // In Gutenberg.
903        'disable-custom-colors',
904        'disable-custom-font-sizes',
905        'disable-custom-gradients',
906        'disable-layout-styles', // WP 6.1. Added via https://core.trac.wordpress.org/changeset/54159
907        'editor-color-palette',
908        'editor-font-sizes',
909        'editor-gradient-presets',
910        'editor-spacing-sizes',
911        'editor-style', // deprecated.
912        'editor-styles',
913        'html5',
914        'infinite-scroll',
915        'jetpack-responsive-videos',
916        'jetpack-social-menu',
917        'menus',
918        'post-formats',
919        'post-thumbnails',
920        'responsive-embeds',
921        'site-logo',
922        'title-tag',
923        'widgets',
924        'wp-block-styles',
925    );
926
927    /**
928     * Is an option whitelisted?
929     *
930     * @param string $option Option name.
931     * @return bool If option is on the whitelist.
932     */
933    public static function is_whitelisted_option( $option ) {
934        $whitelisted_options = self::get_options_whitelist();
935        foreach ( $whitelisted_options as $whitelisted_option ) {
936            if ( '/' === $whitelisted_option[0] && preg_match( $whitelisted_option, $option ) ) {
937                return true;
938            } elseif ( $whitelisted_option === $option ) {
939                return true;
940            }
941        }
942
943        return false;
944    }
945
946    /**
947     * Default whitelist of capabilities to sync.
948     *
949     * @var array Array of WordPress capabilities.
950     */
951    public static $default_capabilities_whitelist = array(
952        'activate_plugins',
953        'add_users',
954        'create_users',
955        'customize',
956        'delete_others_pages',
957        'delete_others_posts',
958        'delete_pages',
959        'delete_plugins',
960        'delete_posts',
961        'delete_private_pages',
962        'delete_private_posts',
963        'delete_published_pages',
964        'delete_published_posts',
965        'delete_site',
966        'delete_themes',
967        'delete_users',
968        'edit_dashboard',
969        'edit_files',
970        'edit_others_pages',
971        'edit_others_posts',
972        'edit_pages',
973        'edit_plugins',
974        'edit_posts',
975        'edit_private_pages',
976        'edit_private_posts',
977        'edit_published_pages',
978        'edit_published_posts',
979        'edit_theme_options',
980        'edit_themes',
981        'edit_users',
982        'export',
983        'import',
984        'install_plugins',
985        'install_themes',
986        'list_users',
987        'manage_categories',
988        'manage_links',
989        'manage_options',
990        'moderate_comments',
991        'promote_users',
992        'publish_pages',
993        'publish_posts',
994        'read',
995        'read_private_pages',
996        'read_private_posts',
997        'remove_users',
998        'switch_themes',
999        'unfiltered_html',
1000        'unfiltered_upload',
1001        'update_core',
1002        'update_plugins',
1003        'update_themes',
1004        'upload_files',
1005        'upload_plugins',
1006        'upload_themes',
1007    );
1008
1009    /**
1010     * Get default capabilities whitelist.
1011     *
1012     * @return array
1013     */
1014    public static function get_capabilities_whitelist() {
1015        /**
1016         * Filter the list of capabilities that we care about
1017         *
1018         * @module sync
1019         *
1020         * @since 1.6.3
1021         * @since-jetpack 5.5.0
1022         *
1023         * @param array The default list of capabilities.
1024         */
1025        return apply_filters( 'jetpack_sync_capabilities_whitelist', self::$default_capabilities_whitelist );
1026    }
1027
1028    /**
1029     * Get max execution sync time.
1030     *
1031     * @return float Number of seconds.
1032     */
1033    public static function get_max_sync_execution_time() {
1034        $max_exec_time = (int) ini_get( 'max_execution_time' );
1035        if ( 0 === $max_exec_time ) {
1036            // 0 actually means "unlimited", but let's not treat it that way.
1037            $max_exec_time = 60;
1038        }
1039        return floor( $max_exec_time / 3 );
1040    }
1041
1042    /**
1043     * Get default for a given setting.
1044     *
1045     * @param string $setting Setting to get.
1046     * @return mixed Value will be a string, int, array, based on the particular setting requested.
1047     */
1048    public static function get_default_setting( $setting ) {
1049        $default_name = "default_$setting"; // e.g. default_dequeue_max_bytes.
1050        return self::$$default_name;
1051    }
1052
1053    /**
1054     * Default list of network options.
1055     *
1056     * @var array network options
1057     */
1058    public static $default_network_options_whitelist = array(
1059        'active_sitewide_plugins',
1060        'auto_update_plugins', // WordPress 5.5+ auto-updates.
1061        'jetpack_protect_global_whitelist',
1062        'jetpack_protect_key',
1063        'site_name',
1064    );
1065
1066    /**
1067     * A mapping of known importers to friendly names.
1068     *
1069     * Keys are the class name of the known importer.
1070     * Values are the friendly name.
1071     *
1072     * @since 1.6.3
1073     * @since-jetpack 7.3.0
1074     *
1075     * @var array
1076     */
1077    public static $default_known_importers = array(
1078        'Blogger_Importer'     => 'blogger',
1079        'LJ_API_Import'        => 'livejournal',
1080        'MT_Import'            => 'mt',
1081        'RSS_Import'           => 'rss',
1082        'WC_Tax_Rate_Importer' => 'woo-tax-rate',
1083        'WP_Import'            => 'wordpress',
1084    );
1085
1086    /**
1087     * Returns a list of known importers.
1088     *
1089     * @since 1.6.3
1090     * @since-jetpack 7.3.0
1091     *
1092     * @return array Known importers with importer class names as keys and friendly names as values.
1093     */
1094    public static function get_known_importers() {
1095        /**
1096         * Filter the list of known importers.
1097         *
1098         * @module sync
1099         *
1100         * @since 1.6.3
1101         * @since-jetpack 7.3.0
1102         *
1103         * @param array The default list of known importers.
1104         */
1105        return apply_filters( 'jetpack_sync_known_importers', self::$default_known_importers );
1106    }
1107
1108    /**
1109     * Whether this is a system with a multiple networks.
1110     * We currently need this static wrapper because we statically define our default list of callables.
1111     *
1112     * @since 1.6.3
1113     * @since-jetpack 7.6.0
1114     *
1115     * @uses Automattic\Jetpack\Status::is_multi_network
1116     *
1117     * @return boolean
1118     */
1119    public static function is_multi_network() {
1120        $status = new Status();
1121        return $status->is_multi_network();
1122    }
1123
1124    /**
1125     * Default bytes to dequeue.
1126     *
1127     * @var int Bytes.
1128     */
1129    public static $default_dequeue_max_bytes = 500000; // very conservative value, 1/2 MB.
1130
1131    /**
1132     * Default upload bytes.
1133     *
1134     * This value is a little bigger than the upload limit to account for serialization.
1135     *
1136     * @var int Bytes.
1137     */
1138    public static $default_upload_max_bytes = 600000;
1139
1140    /**
1141     * Default number of rows uploaded.
1142     *
1143     * @var int Number of rows.
1144     */
1145    public static $default_upload_max_rows = 500;
1146
1147    /**
1148     * Default sync wait time.
1149     *
1150     * @var int Number of seconds.
1151     */
1152    public static $default_sync_wait_time = 10; // seconds, between syncs.
1153
1154    /**
1155     * Only wait before next send if the current send took more than this number of seconds.
1156     *
1157     * @var int Number of seconds.
1158     */
1159    public static $default_sync_wait_threshold = 10;
1160
1161    /**
1162     * Default wait between attempting to continue a full sync via requests.
1163     *
1164     * @var int Number of seconds.
1165     */
1166    public static $default_enqueue_wait_time = 1;
1167
1168    /**
1169     * Maximum queue size.
1170     *
1171     * Each item is represented with a new row in the wp_options table.
1172     *
1173     * @var int Number of queue items.
1174     */
1175    public static $default_max_queue_size = 5000;
1176
1177    /**
1178     * Default maximum lag allowed in the queue.
1179     *
1180     * @var int Number of seconds
1181     */
1182    public static $default_max_queue_lag = 7200; // 2 hours.
1183
1184    /**
1185     * Default for default writes per sec.
1186     *
1187     * @var int Rows per second.
1188     */
1189    public static $default_queue_max_writes_sec = 100; // 100 rows a second.
1190
1191    /**
1192     * Default for post types blacklist.
1193     *
1194     * @var array Empty array.
1195     */
1196    public static $default_post_types_blacklist = array();
1197
1198    /**
1199     * Default for taxonomies blacklist.
1200     *
1201     * @var array Empty array.
1202     */
1203    public static $default_taxonomies_blacklist = array();
1204
1205    /**
1206     * Default for taxonomies whitelist.
1207     *
1208     * @var array Empty array.
1209     */
1210    public static $default_taxonomy_whitelist = array();
1211
1212    /**
1213     * Default for post meta whitelist.
1214     *
1215     * @var array Empty array.
1216     */
1217    public static $default_post_meta_whitelist = array();
1218
1219    /**
1220     * Default for comment meta whitelist.
1221     *
1222     * @var array Empty array.
1223     */
1224    public static $default_comment_meta_whitelist = array();
1225
1226    /**
1227     * Default for sync actions blacklist.
1228     *
1229     * @var array Empty array.
1230     */
1231    public static $default_sync_actions_blacklist = array();
1232
1233    /**
1234     * Default for disabling sync across the site.
1235     *
1236     * @var int Bool-ish. Default to 0.
1237     */
1238    public static $default_disable = 0; // completely disable sending data to wpcom.
1239
1240    /**
1241     * Default for disabling sync across the entire network on multisite.
1242     *
1243     * @var int Bool-ish. Default 0.
1244     */
1245    public static $default_network_disable = 0;
1246
1247    /**
1248     * Default for disabling checksums.
1249     *
1250     * @var int Bool-ish. Default 0.
1251     */
1252    public static $default_checksum_disable = 0;
1253
1254    /**
1255     * Should Sync use cron?
1256     *
1257     * @var int Bool-ish value. Default 1.
1258     */
1259    public static $default_sync_via_cron = 1;
1260
1261    /**
1262     * Default if Sync should render content.
1263     *
1264     * @var int Bool-ish value. Default is 0.
1265     */
1266    public static $default_render_filtered_content = 0;
1267
1268    /**
1269     * Default number of items to enqueue at a time when running full sync.
1270     *
1271     * @var int Number of items.
1272     */
1273    public static $default_max_enqueue_full_sync = 100;
1274
1275    /**
1276     * Default for maximum queue size during a full sync.
1277     *
1278     * Each item will represent a value in the wp_options table.
1279     *
1280     * @var int Number of items.
1281     */
1282    public static $default_max_queue_size_full_sync = 1000; // max number of total items in the full sync queue.
1283
1284    /**
1285     * Default max time for sending in immediate mode.
1286     *
1287     * @var float Number of Seconds
1288     */
1289    public static $default_full_sync_send_duration = 9;
1290
1291    /**
1292     * Defaul for time between syncing callables.
1293     *
1294     * @var int Number of seconds.
1295     */
1296    public static $default_sync_callables_wait_time = MINUTE_IN_SECONDS; // seconds before sending callables again.
1297
1298    /**
1299     * Default for time between syncing constants.
1300     *
1301     * @var int Number of seconds.
1302     */
1303    public static $default_sync_constants_wait_time = HOUR_IN_SECONDS; // seconds before sending constants again.
1304    /**
1305     * Default for sync queue lock timeout time.
1306     *
1307     * @var int Number of seconds.
1308     */
1309    public static $default_sync_queue_lock_timeout = 120; // 2 minutes.
1310
1311    /**
1312     * Default for cron sync time limit.
1313     *
1314     * @var int Number of seconds.
1315     */
1316    public static $default_cron_sync_time_limit = 4 * MINUTE_IN_SECONDS;
1317
1318    /**
1319     * Default for number of term relationship items sent in an full sync item.
1320     *
1321     * @var int Number of items.
1322     */
1323    public static $default_term_relationships_full_sync_item_size = 100;
1324
1325    /**
1326     * Default for enabling incremental sync.
1327     *
1328     * @var int 1 for true.
1329     */
1330    public static $default_sync_sender_enabled = 1; // Should send incremental sync items.
1331
1332    /**
1333     * Default for enabling Full Sync.
1334     *
1335     * @var int 1 for true.
1336     */
1337    public static $default_full_sync_sender_enabled = 1; // Should send full sync items.
1338
1339    /**
1340     * Default Full Sync config
1341     *
1342     * @var array list of module names.
1343     */
1344    public static $default_full_sync_config = array(
1345        'constants'          => 1,
1346        'functions'          => 1,
1347        'options'            => 1,
1348        'terms'              => 1,
1349        'themes'             => 1,
1350        'users'              => 1,
1351        'posts'              => 1,
1352        'comments'           => 1,
1353        'updates'            => 1,
1354        'term_relationships' => 1,
1355    );
1356
1357    /**
1358     * Default Full Sync limits for one module.
1359     *
1360     * @var array list of limits.
1361     */
1362    public static $default_full_sync_limits_per_module = array(
1363        'chunk_size' => 100,
1364        'max_chunks' => 10,
1365    );
1366    /**
1367     * Default Full Sync max objects to send on a single request.
1368     *
1369     * @var array list of module => max.
1370     */
1371    public static $default_full_sync_limits = array(
1372        'comments'                => array(
1373            'chunk_size' => 100,
1374            'max_chunks' => 10,
1375        ),
1376        'posts'                   => array(
1377            'chunk_size' => 500,
1378            'max_chunks' => 1,
1379        ),
1380        'term_relationships'      => array(
1381            'chunk_size' => 1000,
1382            'max_chunks' => 10,
1383        ),
1384        'terms'                   => array(
1385            'chunk_size' => 1000,
1386            'max_chunks' => 10,
1387        ),
1388        'users'                   => array(
1389            'chunk_size' => 100,
1390            'max_chunks' => 10,
1391        ),
1392        'woocommerce'             => array(
1393            'chunk_size' => 100,
1394            'max_chunks' => 10,
1395        ),
1396        'woocommerce_hpos_orders' => array(
1397            'chunk_size' => 100,
1398            'max_chunks' => 10,
1399        ),
1400    );
1401
1402    /**
1403     * Default for enabling dedicated Sync flow.
1404     *
1405     * @var int Bool-ish. Default 0.
1406     */
1407    public static $default_dedicated_sync_enabled = 0;
1408
1409    /**
1410     * Default for enabling custom queue table for Sync.
1411     *
1412     * @var int Bool-ish. Default 0.
1413     */
1414    public static $default_custom_queue_table_enabled = 0;
1415
1416    /**
1417     * Default for enabling wpcom rest api for Sync.
1418     *
1419     * @var int Bool-ish. Default 1.
1420     */
1421    public static $default_wpcom_rest_api_enabled = 1;
1422
1423    /**
1424     * A list of 'jetpack_options' specific keys we want to ignore.
1425     *
1426     * @var array
1427     */
1428    public static $jetpack_options_blacklist = array(
1429        'last_heartbeat',
1430    );
1431}