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