PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 7.4.3
Jetpack – WP Security, Backup, Speed, & Growth v7.4.3
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
639 lines 19.5 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-memberships-connected-account-id',
78 'jetpack-twitter-cards-site-tag',
79 'wpcom_publish_posts_with_markdown',
80 'wpcom_publish_comments_with_markdown',
81 'jetpack_activated',
82 'jetpack_available_modules',
83 'jetpack_allowed_xsite_search_ids',
84 'jetpack_autoupdate_plugins',
85 'jetpack_autoupdate_plugins_translations',
86 'jetpack_autoupdate_themes',
87 'jetpack_autoupdate_themes_translations',
88 'jetpack_autoupdate_core',
89 'jetpack_autoupdate_translations',
90 'carousel_background_color',
91 'carousel_display_exif',
92 'jetpack_portfolio',
93 'jetpack_portfolio_posts_per_page',
94 'jetpack_testimonial',
95 'jetpack_testimonial_posts_per_page',
96 'tiled_galleries',
97 'gravatar_disable_hovercards',
98 'infinite_scroll',
99 'infinite_scroll_google_analytics',
100 'wp_mobile_excerpt',
101 'wp_mobile_featured_images',
102 'wp_mobile_app_promos',
103 'monitor_receive_notifications',
104 'post_by_email_address',
105 'jetpack_mailchimp',
106 'jetpack_protect_key',
107 'jetpack_protect_global_whitelist',
108 'jetpack_sso_require_two_step',
109 'jetpack_sso_match_by_email',
110 'jetpack_relatedposts',
111 'verification_services_codes',
112 'users_can_register',
113 'active_plugins',
114 'uninstall_plugins',
115 'advanced_seo_front_page_description', // Jetpack_SEO_Utils::FRONT_PAGE_META_OPTION
116 'advanced_seo_title_formats', // Jetpack_SEO_Titles::TITLE_FORMATS_OPTION
117 'jetpack_api_cache_enabled',
118 'start_of_week',
119 'blacklist_keys',
120 'posts_per_page',
121 'posts_per_rss',
122 'show_on_front',
123 'ping_sites',
124 'uploads_use_yearmonth_folders',
125 'date_format',
126 'time_format',
127 'admin_email',
128 'new_admin_email',
129 'default_email_category',
130 'default_role',
131 'page_for_posts',
132 'mailserver_url',
133 'mailserver_login', // Not syncing contents, only the option name
134 'mailserver_pass', // Not syncing contents, only the option name
135 'mailserver_port',
136 'wp_page_for_privacy_policy',
137 'enable_header_ad',
138 'wordads_second_belowpost',
139 'wordads_display_front_page',
140 'wordads_display_post',
141 'wordads_display_page',
142 'wordads_display_archive',
143 'wordads_custom_adstxt',
144 'site_segment',
145 'site_user_type',
146 'site_vertical',
147 'jetpack_excluded_extensions',
148 );
149
150 public static function get_options_whitelist() {
151 /** This filter is already documented in json-endpoints/jetpack/class.wpcom-json-api-get-option-endpoint.php */
152 $options_whitelist = apply_filters( 'jetpack_options_whitelist', self::$default_options_whitelist );
153 /**
154 * Filter the list of WordPress options that are manageable via the JSON API.
155 *
156 * @module sync
157 *
158 * @since 4.8.0
159 *
160 * @param array The default list of options.
161 */
162 return apply_filters( 'jetpack_sync_options_whitelist', $options_whitelist );
163 }
164
165 // Do not sync contents for these events, only the option name
166 static $default_options_contentless = array(
167 'mailserver_login',
168 'mailserver_pass',
169 );
170
171 public static function get_options_contentless() {
172 /**
173 * Filter the list of WordPress options that should be synced without content
174 *
175 * @module sync
176 *
177 * @since 6.1.0
178 *
179 * @param array The list of options synced without content.
180 */
181 return apply_filters( 'jetpack_sync_options_contentless', self::$default_options_contentless );
182 }
183
184 static $default_constants_whitelist = array(
185 'EMPTY_TRASH_DAYS',
186 'WP_POST_REVISIONS',
187 'AUTOMATIC_UPDATER_DISABLED',
188 'ABSPATH',
189 'WP_CONTENT_DIR',
190 'FS_METHOD',
191 'DISALLOW_FILE_EDIT',
192 'DISALLOW_FILE_MODS',
193 'WP_AUTO_UPDATE_CORE',
194 'WP_HTTP_BLOCK_EXTERNAL',
195 'WP_ACCESSIBLE_HOSTS',
196 'JETPACK__VERSION',
197 'IS_PRESSABLE',
198 'DISABLE_WP_CRON',
199 'ALTERNATE_WP_CRON',
200 'WP_CRON_LOCK_TIMEOUT',
201 'PHP_VERSION',
202 'WP_MEMORY_LIMIT',
203 'WP_MAX_MEMORY_LIMIT',
204 );
205
206 public static function get_constants_whitelist() {
207 /**
208 * Filter the list of PHP constants that are manageable via the JSON API.
209 *
210 * @module sync
211 *
212 * @since 4.8.0
213 *
214 * @param array The default list of constants options.
215 */
216 return apply_filters( 'jetpack_sync_constants_whitelist', self::$default_constants_whitelist );
217 }
218
219 static $default_callable_whitelist = array(
220 'wp_max_upload_size' => 'wp_max_upload_size',
221 'is_main_network' => array( 'Jetpack', 'is_multi_network' ),
222 'is_multi_site' => 'is_multisite',
223 'main_network_site' => array( 'Jetpack_Sync_Functions', 'main_network_site_url' ),
224 'site_url' => array( 'Jetpack_Sync_Functions', 'site_url' ),
225 'home_url' => array( 'Jetpack_Sync_Functions', 'home_url' ),
226 'single_user_site' => array( 'Jetpack', 'is_single_user_site' ),
227 'updates' => array( 'Jetpack', 'get_updates' ),
228 'has_file_system_write_access' => array( 'Jetpack_Sync_Functions', 'file_system_write_access' ),
229 'is_version_controlled' => array( 'Jetpack_Sync_Functions', 'is_version_controlled' ),
230 'taxonomies' => array( 'Jetpack_Sync_Functions', 'get_taxonomies' ),
231 'post_types' => array( 'Jetpack_Sync_Functions', 'get_post_types' ),
232 'post_type_features' => array( 'Jetpack_Sync_Functions', 'get_post_type_features' ),
233 'shortcodes' => array( 'Jetpack_Sync_Functions', 'get_shortcodes' ),
234 'rest_api_allowed_post_types' => array( 'Jetpack_Sync_Functions', 'rest_api_allowed_post_types' ),
235 'rest_api_allowed_public_metadata' => array( 'Jetpack_Sync_Functions', 'rest_api_allowed_public_metadata' ),
236 'sso_is_two_step_required' => array( 'Jetpack_SSO_Helpers', 'is_two_step_required' ),
237 'sso_should_hide_login_form' => array( 'Jetpack_SSO_Helpers', 'should_hide_login_form' ),
238 'sso_match_by_email' => array( 'Jetpack_SSO_Helpers', 'match_by_email' ),
239 'sso_new_user_override' => array( 'Jetpack_SSO_Helpers', 'new_user_override' ),
240 'sso_bypass_default_login_form' => array( 'Jetpack_SSO_Helpers', 'bypass_login_forward_wpcom' ),
241 'wp_version' => array( 'Jetpack_Sync_Functions', 'wp_version' ),
242 'get_plugins' => array( 'Jetpack_Sync_Functions', 'get_plugins' ),
243 'get_plugins_action_links' => array( 'Jetpack_Sync_functions', 'get_plugins_action_links' ),
244 'active_modules' => array( 'Jetpack', 'get_active_modules' ),
245 'hosting_provider' => array( 'Jetpack_Sync_Functions', 'get_hosting_provider' ),
246 'locale' => 'get_locale',
247 'site_icon_url' => array( 'Jetpack_Sync_Functions', 'site_icon_url' ),
248 'roles' => array( 'Jetpack_Sync_Functions', 'roles' ),
249 'timezone' => array( 'Jetpack_Sync_Functions', 'get_timezone' ),
250 'available_jetpack_blocks' => array( 'Jetpack_Gutenberg', 'get_availability' ), // Includes both Gutenberg blocks *and* plugins
251 'paused_themes' => array( 'Jetpack_Sync_Functions', 'get_paused_themes' ),
252 'paused_plugins' => array( 'Jetpack_Sync_Functions', 'get_paused_plugins' ),
253 );
254
255
256 static $default_post_type_attributes = array(
257 'name' => '',
258 'label' => '',
259 'labels' => array(),
260 'description' => '',
261 'public' => false,
262 'hierarchical' => false,
263 'exclude_from_search' => true,
264 'publicly_queryable' => null,
265 'show_ui' => false,
266 'show_in_menu' => null,
267 'show_in_nav_menus' => null,
268 'show_in_admin_bar' => false,
269 'menu_position' => null,
270 'menu_icon' => null,
271 'supports' => array(),
272 'capability_type' => 'post',
273 'capabilities' => array(),
274 'cap' => array(),
275 'map_meta_cap' => true,
276 'taxonomies' => array(),
277 'has_archive' => false,
278 'rewrite' => true,
279 'query_var' => true,
280 'can_export' => true,
281 'delete_with_user' => null,
282 'show_in_rest' => false,
283 'rest_base' => false,
284 '_builtin' => false,
285 '_edit_link' => 'post.php?post=%d',
286 );
287
288 public static function get_callable_whitelist() {
289 /**
290 * Filter the list of callables that are manageable via the JSON API.
291 *
292 * @module sync
293 *
294 * @since 4.8.0
295 *
296 * @param array The default list of callables.
297 */
298 return apply_filters( 'jetpack_sync_callable_whitelist', self::$default_callable_whitelist );
299 }
300
301 static $blacklisted_post_types = array(
302 'ai1ec_event',
303 'bwg_album',
304 'bwg_gallery',
305 'customize_changeset', // WP built-in post type for Customizer changesets
306 'dn_wp_yt_log',
307 'http',
308 'idx_page',
309 'jetpack_migration',
310 'postman_sent_mail',
311 'rssap-feed',
312 'rssmi_feed_item',
313 'secupress_log_action',
314 'sg_optimizer_jobs',
315 'snitch',
316 'wpephpcompat_jobs',
317 'wprss_feed_item',
318 'wp_automatic',
319 'jp_sitemap_master',
320 'jp_sitemap',
321 'jp_sitemap_index',
322 'jp_img_sitemap',
323 'jp_img_sitemap_index',
324 'jp_vid_sitemap',
325 'jp_vid_sitemap_index',
326 'vip-legacy-redirect',
327 );
328
329 static $default_post_checksum_columns = array(
330 'ID',
331 'post_modified',
332 );
333
334 static $default_post_meta_checksum_columns = array(
335 'meta_id',
336 'meta_value',
337 );
338
339 static $default_comment_checksum_columns = array(
340 'comment_ID',
341 'comment_content',
342 );
343
344 static $default_comment_meta_checksum_columns = array(
345 'meta_id',
346 'meta_value',
347 );
348
349 static $default_option_checksum_columns = array(
350 'option_name',
351 'option_value',
352 );
353
354 static $default_multisite_callable_whitelist = array(
355 'network_name' => array( 'Jetpack', 'network_name' ),
356 'network_allow_new_registrations' => array( 'Jetpack', 'network_allow_new_registrations' ),
357 'network_add_new_users' => array( 'Jetpack', 'network_add_new_users' ),
358 'network_site_upload_space' => array( 'Jetpack', 'network_site_upload_space' ),
359 'network_upload_file_types' => array( 'Jetpack', 'network_upload_file_types' ),
360 'network_enable_administration_menus' => array( 'Jetpack', 'network_enable_administration_menus' ),
361 );
362
363 public static function get_multisite_callable_whitelist() {
364 /**
365 * Filter the list of multisite callables that are manageable via the JSON API.
366 *
367 * @module sync
368 *
369 * @since 4.8.0
370 *
371 * @param array The default list of multisite callables.
372 */
373 return apply_filters( 'jetpack_sync_multisite_callable_whitelist', self::$default_multisite_callable_whitelist );
374 }
375
376 static $post_meta_whitelist = array(
377 '_feedback_akismet_values',
378 '_feedback_email',
379 '_feedback_extra_fields',
380 '_g_feedback_shortcode',
381 '_jetpack_post_thumbnail',
382 '_menu_item_classes',
383 '_menu_item_menu_item_parent',
384 '_menu_item_object',
385 '_menu_item_object_id',
386 '_menu_item_orphaned',
387 '_menu_item_type',
388 '_menu_item_xfn',
389 '_publicize_facebook_user',
390 '_publicize_twitter_user',
391 '_thumbnail_id',
392 '_wp_attached_file',
393 '_wp_attachment_backup_sizes',
394 '_wp_attachment_context',
395 '_wp_attachment_image_alt',
396 '_wp_attachment_is_custom_background',
397 '_wp_attachment_is_custom_header',
398 '_wp_attachment_metadata',
399 '_wp_page_template',
400 '_wp_trash_meta_comments_status',
401 '_wpas_mess',
402 'content_width',
403 'custom_css_add',
404 'custom_css_preprocessor',
405 'enclosure',
406 'imagedata',
407 'nova_price',
408 'publicize_results',
409 'sharing_disabled',
410 'switch_like_status',
411 'videopress_guid',
412 'vimeo_poster_image',
413 'advanced_seo_description', // Jetpack_SEO_Posts::DESCRIPTION_META_KEY
414 );
415
416 public static function get_post_meta_whitelist() {
417 /**
418 * Filter the list of post meta data that are manageable via the JSON API.
419 *
420 * @module sync
421 *
422 * @since 4.8.0
423 *
424 * @param array The default list of meta data keys.
425 */
426 return apply_filters( 'jetpack_sync_post_meta_whitelist', self::$post_meta_whitelist );
427 }
428
429 static $comment_meta_whitelist = array(
430 'hc_avatar',
431 'hc_post_as',
432 'hc_wpcom_id_sig',
433 'hc_foreign_user_id',
434 );
435
436 public static function get_comment_meta_whitelist() {
437 /**
438 * Filter the list of comment meta data that are manageable via the JSON API.
439 *
440 * @module sync
441 *
442 * @since 5.7.0
443 *
444 * @param array The default list of comment meta data keys.
445 */
446 return apply_filters( 'jetpack_sync_comment_meta_whitelist', self::$comment_meta_whitelist );
447 }
448
449 // TODO: move this to server? - these are theme support values
450 // that should be synced as jetpack_current_theme_supports_foo option values
451 static $default_theme_support_whitelist = array(
452 'post-thumbnails',
453 'post-formats',
454 'custom-header',
455 'custom-background',
456 'custom-logo',
457 'menus',
458 'automatic-feed-links',
459 'editor-style',
460 'widgets',
461 'html5',
462 'title-tag',
463 'jetpack-social-menu',
464 'jetpack-responsive-videos',
465 'infinite-scroll',
466 'site-logo',
467 );
468
469 static function is_whitelisted_option( $option ) {
470 $whitelisted_options = self::get_options_whitelist();
471 foreach ( $whitelisted_options as $whitelisted_option ) {
472 if ( $whitelisted_option[0] === '/' && preg_match( $whitelisted_option, $option ) ) {
473 return true;
474 } elseif ( $whitelisted_option === $option ) {
475 return true;
476 }
477 }
478
479 return false;
480 }
481
482 static $default_capabilities_whitelist = array(
483 'switch_themes',
484 'edit_themes',
485 'edit_theme_options',
486 'install_themes',
487 'activate_plugins',
488 'edit_plugins',
489 'install_plugins',
490 'edit_users',
491 'edit_files',
492 'manage_options',
493 'moderate_comments',
494 'manage_categories',
495 'manage_links',
496 'upload_files',
497 'import',
498 'unfiltered_html',
499 'edit_posts',
500 'edit_others_posts',
501 'edit_published_posts',
502 'publish_posts',
503 'edit_pages',
504 'read',
505 'publish_pages',
506 'edit_others_pages',
507 'edit_published_pages',
508 'delete_pages',
509 'delete_others_pages',
510 'delete_published_pages',
511 'delete_posts',
512 'delete_others_posts',
513 'delete_published_posts',
514 'delete_private_posts',
515 'edit_private_posts',
516 'read_private_posts',
517 'delete_private_pages',
518 'edit_private_pages',
519 'read_private_pages',
520 'delete_users',
521 'create_users',
522 'unfiltered_upload',
523 'edit_dashboard',
524 'customize',
525 'delete_site',
526 'update_plugins',
527 'delete_plugins',
528 'update_themes',
529 'update_core',
530 'list_users',
531 'remove_users',
532 'add_users',
533 'promote_users',
534 'delete_themes',
535 'export',
536 'edit_comment',
537 'upload_plugins',
538 'upload_themes',
539 );
540
541 public static function get_capabilities_whitelist() {
542 /**
543 * Filter the list of capabilities that we care about
544 *
545 * @module sync
546 *
547 * @since 5.5.0
548 *
549 * @param array The default list of capabilities.
550 */
551 return apply_filters( 'jetpack_sync_capabilities_whitelist', self::$default_capabilities_whitelist );
552 }
553
554 static function get_max_sync_execution_time() {
555 $max_exec_time = intval( ini_get( 'max_execution_time' ) );
556 if ( 0 === $max_exec_time ) {
557 // 0 actually means "unlimited", but let's not treat it that way
558 $max_exec_time = 60;
559 }
560 return floor( $max_exec_time / 3 );
561 }
562
563 static function get_default_setting( $setting ) {
564 $default_name = "default_$setting"; // e.g. default_dequeue_max_bytes
565 return Jetpack_Sync_Defaults::$$default_name;
566 }
567
568 static $default_network_options_whitelist = array(
569 'site_name',
570 'jetpack_protect_key',
571 'jetpack_protect_global_whitelist',
572 'active_sitewide_plugins',
573 );
574
575 /**
576 * A mapping of known importers to friendly names.
577 *
578 * Keys are the class name of the known importer.
579 * Values are the friendly name.
580 *
581 * @since 7.3.0
582 *
583 * @var array
584 */
585 public static $default_known_importers = array(
586 'Blogger_Importer' => 'blogger',
587 'LJ_API_Import' => 'livejournal',
588 'MT_Import' => 'mt',
589 'RSS_Import' => 'rss',
590 'WC_Tax_Rate_Importer' => 'woo-tax-rate',
591 'WP_Import' => 'wordpress',
592 );
593
594 /**
595 * Returns a list of known importers.
596 *
597 * @since 7.3.0
598 *
599 * @return array Known importers with importer class names as keys and friendly names as values.
600 */
601 public static function get_known_importers() {
602 /**
603 * Filter the list of known importers.
604 *
605 * @module sync
606 *
607 * @since 7.3.0
608 *
609 * @param array The default list of known importers.
610 */
611 return apply_filters( 'jetpack_sync_known_importers', self::$default_known_importers );
612 }
613
614 static $default_taxonomy_whitelist = array();
615 static $default_dequeue_max_bytes = 500000; // very conservative value, 1/2 MB
616 static $default_upload_max_bytes = 600000; // a little bigger than the upload limit to account for serialization
617 static $default_upload_max_rows = 500;
618 static $default_sync_wait_time = 10; // seconds, between syncs
619 static $default_sync_wait_threshold = 5; // only wait before next send if the current send took more than X seconds
620 static $default_enqueue_wait_time = 10; // wait between attempting to continue a full sync, via requests
621 static $default_max_queue_size = 1000;
622 static $default_max_queue_lag = 900; // 15 minutes
623 static $default_queue_max_writes_sec = 100; // 100 rows a second
624 static $default_post_types_blacklist = array();
625 static $default_post_meta_whitelist = array();
626 static $default_comment_meta_whitelist = array();
627 static $default_disable = 0; // completely disable sending data to wpcom
628 static $default_network_disable = 0; // completely disable sending data to wpcom network wide
629 static $default_sync_via_cron = 1; // use cron to sync
630 static $default_render_filtered_content = 0; // render post_filtered_content
631 static $default_max_enqueue_full_sync = 100; // max number of items to enqueue at a time when running full sync
632 static $default_max_queue_size_full_sync = 1000; // max number of total items in the full sync queue
633 static $default_sync_callables_wait_time = MINUTE_IN_SECONDS; // seconds before sending callables again
634 static $default_sync_constants_wait_time = HOUR_IN_SECONDS; // seconds before sending constants again
635 static $default_sync_queue_lock_timeout = 120; // 2 minutes
636 static $default_cron_sync_time_limit = 30; // 30 seconds
637
638 }
639