PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 6.9.2
Jetpack – WP Security, Backup, Speed, & Growth v6.9.2
16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 All 501 releases
jetpack / sync / class.jetpack-sync-defaults.php

class.jetpack-sync-defaults.php in Jetpack – WP Security, Backup, Speed, & Growth 6.9.2, at sync/class.jetpack-sync-defaults.php

582 lines 17.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 require_once( JETPACK__PLUGIN_DIR . 'modules/sso/class.jetpack-sso-helpers.php' );
3
4 /**
5 * Just some defaults that we share with the server
6 */
7 class Jetpack_Sync_Defaults {
8
9 static $default_options_whitelist = array(
10 'stylesheet',
11 'blogname',
12 'blogdescription',
13 'blog_charset',
14 'permalink_structure',
15 'category_base',
16 'tag_base',
17 'sidebars_widgets',
18 'comment_moderation',
19 'default_comment_status',
20 'page_on_front',
21 'rss_use_excerpt',
22 'subscription_options',
23 'stb_enabled',
24 'stc_enabled',
25 'comment_registration',
26 'show_avatars',
27 'avatar_default',
28 'avatar_rating',
29 'highlander_comment_form_prompt',
30 'jetpack_comment_form_color_scheme',
31 'stats_options',
32 'gmt_offset',
33 'timezone_string',
34 'jetpack_sync_non_public_post_stati',
35 'jetpack_options',
36 'site_icon', // (int) - ID of core's Site Icon attachment ID
37 'default_post_format',
38 'default_category',
39 'large_size_w',
40 'large_size_h',
41 'thumbnail_size_w',
42 'thumbnail_size_h',
43 'medium_size_w',
44 'medium_size_h',
45 'thumbnail_crop',
46 'image_default_link_type',
47 'site_logo',
48 'sharing-options',
49 'sharing-services',
50 'post_count',
51 'default_ping_status',
52 'sticky_posts',
53 'blog_public',
54 'default_pingback_flag',
55 'require_name_email',
56 'close_comments_for_old_posts',
57 'close_comments_days_old',
58 'thread_comments',
59 'thread_comments_depth',
60 'page_comments',
61 'comments_per_page',
62 'default_comments_page',
63 'comment_order',
64 'comments_notify',
65 'moderation_notify',
66 'social_notifications_like',
67 'social_notifications_reblog',
68 'social_notifications_subscribe',
69 'comment_whitelist',
70 'comment_max_links',
71 'moderation_keys',
72 'jetpack_wga',
73 'disabled_likes',
74 'disabled_reblogs',
75 'jetpack_comment_likes_enabled',
76 'twitter_via',
77 'jetpack-twitter-cards-site-tag',
78 'wpcom_publish_posts_with_markdown',
79 'wpcom_publish_comments_with_markdown',
80 'jetpack_activated',
81 'jetpack_available_modules',
82 'jetpack_autoupdate_plugins',
83 'jetpack_autoupdate_plugins_translations',
84 'jetpack_autoupdate_themes',
85 'jetpack_autoupdate_themes_translations',
86 'jetpack_autoupdate_core',
87 'jetpack_autoupdate_translations',
88 'carousel_background_color',
89 'carousel_display_exif',
90 'jetpack_portfolio',
91 'jetpack_portfolio_posts_per_page',
92 'jetpack_testimonial',
93 'jetpack_testimonial_posts_per_page',
94 'tiled_galleries',
95 'gravatar_disable_hovercards',
96 'infinite_scroll',
97 'infinite_scroll_google_analytics',
98 'wp_mobile_excerpt',
99 'wp_mobile_featured_images',
100 'wp_mobile_app_promos',
101 'monitor_receive_notifications',
102 'post_by_email_address',
103 'jetpack_protect_key',
104 'jetpack_protect_global_whitelist',
105 'jetpack_sso_require_two_step',
106 'jetpack_sso_match_by_email',
107 'jetpack_relatedposts',
108 'verification_services_codes',
109 'users_can_register',
110 'active_plugins',
111 'uninstall_plugins',
112 'advanced_seo_front_page_description', // Jetpack_SEO_Utils::FRONT_PAGE_META_OPTION
113 'advanced_seo_title_formats', // Jetpack_SEO_Titles::TITLE_FORMATS_OPTION
114 'jetpack_api_cache_enabled',
115 'start_of_week',
116 'blacklist_keys',
117 'posts_per_page',
118 'posts_per_rss',
119 'show_on_front',
120 'ping_sites',
121 'uploads_use_yearmonth_folders',
122 'date_format',
123 'time_format',
124 'admin_email',
125 'new_admin_email',
126 'default_email_category',
127 'default_role',
128 'page_for_posts',
129 'mailserver_url',
130 'mailserver_login', // Not syncing contents, only the option name
131 'mailserver_pass', // Not syncing contents, only the option name
132 'mailserver_port',
133 'wp_page_for_privacy_policy',
134 'enable_header_ad',
135 'wordads_second_belowpost',
136 'wordads_display_front_page',
137 'wordads_display_post',
138 'wordads_display_page',
139 'wordads_display_archive',
140 'wordads_custom_adstxt',
141 );
142
143 public static function get_options_whitelist() {
144 /** This filter is already documented in json-endpoints/jetpack/class.wpcom-json-api-get-option-endpoint.php */
145 $options_whitelist = apply_filters( 'jetpack_options_whitelist', self::$default_options_whitelist );
146 /**
147 * Filter the list of WordPress options that are manageable via the JSON API.
148 *
149 * @module sync
150 *
151 * @since 4.8.0
152 *
153 * @param array The default list of options.
154 */
155 return apply_filters( 'jetpack_sync_options_whitelist', $options_whitelist );
156 }
157
158 // Do not sync contents for these events, only the option name
159 static $default_options_contentless = array(
160 'mailserver_login',
161 'mailserver_pass',
162 );
163
164 public static function get_options_contentless() {
165 /**
166 * Filter the list of WordPress options that should be synced without content
167 *
168 * @module sync
169 *
170 * @since 6.1.0
171 *
172 * @param array The list of options synced without content.
173 */
174 return apply_filters( 'jetpack_sync_options_contentless', self::$default_options_contentless );
175 }
176
177 static $default_constants_whitelist = array(
178 'EMPTY_TRASH_DAYS',
179 'WP_POST_REVISIONS',
180 'AUTOMATIC_UPDATER_DISABLED',
181 'ABSPATH',
182 'WP_CONTENT_DIR',
183 'FS_METHOD',
184 'DISALLOW_FILE_EDIT',
185 'DISALLOW_FILE_MODS',
186 'WP_AUTO_UPDATE_CORE',
187 'WP_HTTP_BLOCK_EXTERNAL',
188 'WP_ACCESSIBLE_HOSTS',
189 'JETPACK__VERSION',
190 'IS_PRESSABLE',
191 'DISABLE_WP_CRON',
192 'ALTERNATE_WP_CRON',
193 'WP_CRON_LOCK_TIMEOUT',
194 'PHP_VERSION',
195 'WP_MEMORY_LIMIT',
196 'WP_MAX_MEMORY_LIMIT'
197 );
198
199 public static function get_constants_whitelist() {
200 /**
201 * Filter the list of PHP constants that are manageable via the JSON API.
202 *
203 * @module sync
204 *
205 * @since 4.8.0
206 *
207 * @param array The default list of constants options.
208 */
209 return apply_filters( 'jetpack_sync_constants_whitelist', self::$default_constants_whitelist );
210 }
211
212 static $default_callable_whitelist = array(
213 'wp_max_upload_size' => 'wp_max_upload_size',
214 'is_main_network' => array( 'Jetpack', 'is_multi_network' ),
215 'is_multi_site' => 'is_multisite',
216 'main_network_site' => array( 'Jetpack_Sync_Functions', 'main_network_site_url' ),
217 'site_url' => array( 'Jetpack_Sync_Functions', 'site_url' ),
218 'home_url' => array( 'Jetpack_Sync_Functions', 'home_url' ),
219 'single_user_site' => array( 'Jetpack', 'is_single_user_site' ),
220 'updates' => array( 'Jetpack', 'get_updates' ),
221 'has_file_system_write_access' => array( 'Jetpack_Sync_Functions', 'file_system_write_access' ),
222 'is_version_controlled' => array( 'Jetpack_Sync_Functions', 'is_version_controlled' ),
223 'taxonomies' => array( 'Jetpack_Sync_Functions', 'get_taxonomies' ),
224 'post_types' => array( 'Jetpack_Sync_Functions', 'get_post_types' ),
225 'post_type_features' => array( 'Jetpack_Sync_Functions', 'get_post_type_features' ),
226 'shortcodes' => array( 'Jetpack_Sync_Functions', 'get_shortcodes' ),
227 'rest_api_allowed_post_types' => array( 'Jetpack_Sync_Functions', 'rest_api_allowed_post_types' ),
228 'rest_api_allowed_public_metadata' => array( 'Jetpack_Sync_Functions', 'rest_api_allowed_public_metadata' ),
229 'sso_is_two_step_required' => array( 'Jetpack_SSO_Helpers', 'is_two_step_required' ),
230 'sso_should_hide_login_form' => array( 'Jetpack_SSO_Helpers', 'should_hide_login_form' ),
231 'sso_match_by_email' => array( 'Jetpack_SSO_Helpers', 'match_by_email' ),
232 'sso_new_user_override' => array( 'Jetpack_SSO_Helpers', 'new_user_override' ),
233 'sso_bypass_default_login_form' => array( 'Jetpack_SSO_Helpers', 'bypass_login_forward_wpcom' ),
234 'wp_version' => array( 'Jetpack_Sync_Functions', 'wp_version' ),
235 'get_plugins' => array( 'Jetpack_Sync_Functions', 'get_plugins' ),
236 'get_plugins_action_links' => array( 'Jetpack_Sync_functions', 'get_plugins_action_links' ),
237 'active_modules' => array( 'Jetpack', 'get_active_modules' ),
238 'hosting_provider' => array( 'Jetpack_Sync_Functions', 'get_hosting_provider' ),
239 'locale' => 'get_locale',
240 'site_icon_url' => array( 'Jetpack_Sync_Functions', 'site_icon_url' ),
241 'roles' => array( 'Jetpack_Sync_Functions', 'roles' ),
242 'timezone' => array( 'Jetpack_Sync_Functions', 'get_timezone' ),
243 'available_jetpack_blocks' => array( 'Jetpack_Gutenberg', 'get_block_availability' ),
244 );
245
246
247 static $default_post_type_attributes = array(
248 'name' => '',
249 'label' => '',
250 'labels' => array(),
251 'description' => '',
252 'public' => false,
253 'hierarchical' => false,
254 'exclude_from_search' => true,
255 'publicly_queryable' => null,
256 'show_ui' => false,
257 'show_in_menu' => null,
258 'show_in_nav_menus' => null,
259 'show_in_admin_bar' => false,
260 'menu_position' => null,
261 'menu_icon' => null,
262 'supports' => array(),
263 'capability_type' => 'post',
264 'capabilities' => array(),
265 'cap' => array(),
266 'map_meta_cap' => true,
267 'taxonomies' => array(),
268 'has_archive' => false,
269 'rewrite' => true,
270 'query_var' => true,
271 'can_export' => true,
272 'delete_with_user' => null,
273 'show_in_rest' => false,
274 'rest_base' => false,
275 '_builtin' => false,
276 '_edit_link' => 'post.php?post=%d',
277 );
278
279 public static function get_callable_whitelist() {
280 /**
281 * Filter the list of callables that are manageable via the JSON API.
282 *
283 * @module sync
284 *
285 * @since 4.8.0
286 *
287 * @param array The default list of callables.
288 */
289 return apply_filters( 'jetpack_sync_callable_whitelist', self::$default_callable_whitelist );
290 }
291
292 static $blacklisted_post_types = array(
293 'ai1ec_event',
294 'bwg_album',
295 'bwg_gallery',
296 'customize_changeset', // WP built-in post type for Customizer changesets
297 'dn_wp_yt_log',
298 'http',
299 'idx_page',
300 'jetpack_migration',
301 'postman_sent_mail',
302 'rssap-feed',
303 'rssmi_feed_item',
304 'secupress_log_action',
305 'sg_optimizer_jobs',
306 'snitch',
307 'wpephpcompat_jobs',
308 'wprss_feed_item',
309 'wp_automatic',
310 'jp_sitemap_master',
311 'jp_sitemap',
312 'jp_sitemap_index',
313 'jp_img_sitemap',
314 'jp_img_sitemap_index',
315 'jp_vid_sitemap',
316 'jp_vid_sitemap_index',
317 );
318
319 static $default_post_checksum_columns = array(
320 'ID',
321 'post_modified',
322 );
323
324 static $default_post_meta_checksum_columns = array(
325 'meta_id',
326 'meta_value'
327 );
328
329 static $default_comment_checksum_columns = array(
330 'comment_ID',
331 'comment_content',
332 );
333
334 static $default_comment_meta_checksum_columns = array(
335 'meta_id',
336 'meta_value'
337 );
338
339 static $default_option_checksum_columns = array(
340 'option_name',
341 'option_value',
342 );
343
344 static $default_multisite_callable_whitelist = array(
345 'network_name' => array( 'Jetpack', 'network_name' ),
346 'network_allow_new_registrations' => array( 'Jetpack', 'network_allow_new_registrations' ),
347 'network_add_new_users' => array( 'Jetpack', 'network_add_new_users' ),
348 'network_site_upload_space' => array( 'Jetpack', 'network_site_upload_space' ),
349 'network_upload_file_types' => array( 'Jetpack', 'network_upload_file_types' ),
350 'network_enable_administration_menus' => array( 'Jetpack', 'network_enable_administration_menus' ),
351 );
352
353 public static function get_multisite_callable_whitelist() {
354 /**
355 * Filter the list of multisite callables that are manageable via the JSON API.
356 *
357 * @module sync
358 *
359 * @since 4.8.0
360 *
361 * @param array The default list of multisite callables.
362 */
363 return apply_filters( 'jetpack_sync_multisite_callable_whitelist', self::$default_multisite_callable_whitelist );
364 }
365
366 static $post_meta_whitelist = array(
367 '_feedback_akismet_values',
368 '_feedback_email',
369 '_feedback_extra_fields',
370 '_g_feedback_shortcode',
371 '_jetpack_post_thumbnail',
372 '_menu_item_classes',
373 '_menu_item_menu_item_parent',
374 '_menu_item_object',
375 '_menu_item_object_id',
376 '_menu_item_orphaned',
377 '_menu_item_type',
378 '_menu_item_xfn',
379 '_publicize_facebook_user',
380 '_publicize_twitter_user',
381 '_thumbnail_id',
382 '_wp_attached_file',
383 '_wp_attachment_backup_sizes',
384 '_wp_attachment_context',
385 '_wp_attachment_image_alt',
386 '_wp_attachment_is_custom_background',
387 '_wp_attachment_is_custom_header',
388 '_wp_attachment_metadata',
389 '_wp_page_template',
390 '_wp_trash_meta_comments_status',
391 '_wpas_mess',
392 'content_width',
393 'custom_css_add',
394 'custom_css_preprocessor',
395 'enclosure',
396 'imagedata',
397 'nova_price',
398 'publicize_results',
399 'sharing_disabled',
400 'switch_like_status',
401 'videopress_guid',
402 'vimeo_poster_image',
403 'advanced_seo_description', // Jetpack_SEO_Posts::DESCRIPTION_META_KEY
404 );
405
406 public static function get_post_meta_whitelist() {
407 /**
408 * Filter the list of post meta data that are manageable via the JSON API.
409 *
410 * @module sync
411 *
412 * @since 4.8.0
413 *
414 * @param array The default list of meta data keys.
415 */
416 return apply_filters( 'jetpack_sync_post_meta_whitelist', self::$post_meta_whitelist );
417 }
418
419 static $comment_meta_whitelist = array(
420 'hc_avatar',
421 'hc_post_as',
422 'hc_wpcom_id_sig',
423 'hc_foreign_user_id'
424 );
425
426 public static function get_comment_meta_whitelist() {
427 /**
428 * Filter the list of comment meta data that are manageable via the JSON API.
429 *
430 * @module sync
431 *
432 * @since 5.7.0
433 *
434 * @param array The default list of comment meta data keys.
435 */
436 return apply_filters( 'jetpack_sync_comment_meta_whitelist', self::$comment_meta_whitelist );
437 }
438
439 // TODO: move this to server? - these are theme support values
440 // that should be synced as jetpack_current_theme_supports_foo option values
441 static $default_theme_support_whitelist = array(
442 'post-thumbnails',
443 'post-formats',
444 'custom-header',
445 'custom-background',
446 'custom-logo',
447 'menus',
448 'automatic-feed-links',
449 'editor-style',
450 'widgets',
451 'html5',
452 'title-tag',
453 'jetpack-social-menu',
454 'jetpack-responsive-videos',
455 'infinite-scroll',
456 'site-logo',
457 );
458
459 static function is_whitelisted_option( $option ) {
460 foreach ( self::$default_options_whitelist as $whitelisted_option ) {
461 if ( $whitelisted_option[0] === '/' && preg_match( $whitelisted_option, $option ) ) {
462 return true;
463 } elseif ( $whitelisted_option === $option ) {
464 return true;
465 }
466 }
467
468 return false;
469 }
470
471 static $default_capabilities_whitelist = array(
472 'switch_themes',
473 'edit_themes',
474 'edit_theme_options',
475 'install_themes',
476 'activate_plugins',
477 'edit_plugins',
478 'install_plugins',
479 'edit_users',
480 'edit_files',
481 'manage_options',
482 'moderate_comments',
483 'manage_categories',
484 'manage_links',
485 'upload_files',
486 'import',
487 'unfiltered_html',
488 'edit_posts',
489 'edit_others_posts',
490 'edit_published_posts',
491 'publish_posts',
492 'edit_pages',
493 'read',
494 'publish_pages',
495 'edit_others_pages',
496 'edit_published_pages',
497 'delete_pages',
498 'delete_others_pages',
499 'delete_published_pages',
500 'delete_posts',
501 'delete_others_posts',
502 'delete_published_posts',
503 'delete_private_posts',
504 'edit_private_posts',
505 'read_private_posts',
506 'delete_private_pages',
507 'edit_private_pages',
508 'read_private_pages',
509 'delete_users',
510 'create_users',
511 'unfiltered_upload',
512 'edit_dashboard',
513 'customize',
514 'delete_site',
515 'update_plugins',
516 'delete_plugins',
517 'update_themes',
518 'update_core',
519 'list_users',
520 'remove_users',
521 'add_users',
522 'promote_users',
523 'delete_themes',
524 'export',
525 'edit_comment',
526 'upload_plugins',
527 'upload_themes',
528 );
529
530 public static function get_capabilities_whitelist() {
531 /**
532 * Filter the list of capabilities that we care about
533 *
534 * @module sync
535 *
536 * @since 5.5.0
537 *
538 * @param array The default list of capabilities.
539 */
540 return apply_filters( 'jetpack_sync_capabilities_whitelist', self::$default_capabilities_whitelist );
541 }
542
543 static function get_max_sync_execution_time() {
544 $max_exec_time = intval( ini_get( 'max_execution_time' ) );
545 if ( 0 === $max_exec_time ) {
546 // 0 actually means "unlimited", but let's not treat it that way
547 $max_exec_time = 60;
548 }
549 return floor( $max_exec_time / 3 );
550 }
551
552 static $default_network_options_whitelist = array(
553 'site_name',
554 'jetpack_protect_key',
555 'jetpack_protect_global_whitelist',
556 'active_sitewide_plugins',
557 );
558
559 static $default_taxonomy_whitelist = array();
560 static $default_dequeue_max_bytes = 500000; // very conservative value, 1/2 MB
561 static $default_upload_max_bytes = 600000; // a little bigger than the upload limit to account for serialization
562 static $default_upload_max_rows = 500;
563 static $default_sync_wait_time = 10; // seconds, between syncs
564 static $default_sync_wait_threshold = 5; // only wait before next send if the current send took more than X seconds
565 static $default_enqueue_wait_time = 10; // wait between attempting to continue a full sync, via requests
566 static $default_max_queue_size = 1000;
567 static $default_max_queue_lag = 900; // 15 minutes
568 static $default_queue_max_writes_sec = 100; // 100 rows a second
569 static $default_post_types_blacklist = array();
570 static $default_post_meta_whitelist = array();
571 static $default_comment_meta_whitelist = array();
572 static $default_disable = 0; // completely disable sending data to wpcom
573 static $default_sync_via_cron = 1; // use cron to sync
574 static $default_render_filtered_content = 0; // render post_filtered_content
575 static $default_max_enqueue_full_sync = 100; // max number of items to enqueue at a time when running full sync
576 static $default_max_queue_size_full_sync = 1000; // max number of total items in the full sync queue
577 static $default_sync_callables_wait_time = MINUTE_IN_SECONDS; // seconds before sending callables again
578 static $default_sync_constants_wait_time = HOUR_IN_SECONDS; // seconds before sending constants again
579 static $default_sync_queue_lock_timeout = 120; // 2 minutes
580 static $default_cron_sync_time_limit = 30; // 30 seconds
581 }
582