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