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