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