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