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