Completed
Push — fix/videopress-missing-from-se... ( 60564b )
by
unknown
22:41 queued 12:31
created

sync/class.jetpack-sync-defaults.php (14 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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(
0 ignored issues
show
The visibility should be declared for property $default_options_whitelist.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
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
	);
115
116
	public static function get_options_whitelist() {
117
		/** This filter is already documented in json-endpoints/jetpack/class.wpcom-json-api-get-option-endpoint.php */
118
		$options_whitelist = apply_filters( 'jetpack_options_whitelist', self::$default_options_whitelist );
119
		/**
120
		 * Filter the list of WordPress options that are manageable via the JSON API.
121
		 *
122
		 * @module sync
123
		 *
124
		 * @since 4.8
125
		 *
126
		 * @param array The default list of options.
127
		 */
128
		return apply_filters( 'jetpack_sync_options_whitelist', $options_whitelist );
129
	}
130
131
	static $default_constants_whitelist = array(
0 ignored issues
show
The visibility should be declared for property $default_constants_whitelist.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
132
		'EMPTY_TRASH_DAYS',
133
		'WP_POST_REVISIONS',
134
		'AUTOMATIC_UPDATER_DISABLED',
135
		'ABSPATH',
136
		'WP_CONTENT_DIR',
137
		'FS_METHOD',
138
		'DISALLOW_FILE_EDIT',
139
		'DISALLOW_FILE_MODS',
140
		'WP_AUTO_UPDATE_CORE',
141
		'WP_HTTP_BLOCK_EXTERNAL',
142
		'WP_ACCESSIBLE_HOSTS',
143
		'JETPACK__VERSION',
144
		'IS_PRESSABLE',
145
		'DISABLE_WP_CRON',
146
		'ALTERNATE_WP_CRON',
147
		'WP_CRON_LOCK_TIMEOUT',
148
		'PHP_VERSION',
149
	);
150
151
	public static function get_constants_whitelist() {
152
		/**
153
		 * Filter the list of PHP constants that are manageable via the JSON API.
154
		 *
155
		 * @module sync
156
		 *
157
		 * @since 4.8
158
		 *
159
		 * @param array The default list of constants options.
160
		 */
161
		return apply_filters( 'jetpack_sync_constants_whitelist', self::$default_constants_whitelist );
162
	}
163
164
	static $default_callable_whitelist = array(
0 ignored issues
show
The visibility should be declared for property $default_callable_whitelist.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
165
		'wp_max_upload_size'               => 'wp_max_upload_size',
166
		'is_main_network'                  => array( 'Jetpack', 'is_multi_network' ),
167
		'is_multi_site'                    => 'is_multisite',
168
		'main_network_site'                => array( 'Jetpack_Sync_Functions', 'main_network_site_url' ),
169
		'site_url'                         => array( 'Jetpack_Sync_Functions', 'site_url' ),
170
		'home_url'                         => array( 'Jetpack_Sync_Functions', 'home_url' ),
171
		'single_user_site'                 => array( 'Jetpack', 'is_single_user_site' ),
172
		'updates'                          => array( 'Jetpack', 'get_updates' ),
173
		'has_file_system_write_access'     => array( 'Jetpack_Sync_Functions', 'file_system_write_access' ),
174
		'is_version_controlled'            => array( 'Jetpack_Sync_Functions', 'is_version_controlled' ),
175
		'taxonomies'                       => array( 'Jetpack_Sync_Functions', 'get_taxonomies' ),
176
		'post_types'                       => array( 'Jetpack_Sync_Functions', 'get_post_types' ),
177
		'post_type_features'               => array( 'Jetpack_Sync_Functions', 'get_post_type_features' ),
178
		'shortcodes'                       => array( 'Jetpack_Sync_Functions', 'get_shortcodes' ),
179
		'rest_api_allowed_post_types'      => array( 'Jetpack_Sync_Functions', 'rest_api_allowed_post_types' ),
180
		'rest_api_allowed_public_metadata' => array( 'Jetpack_Sync_Functions', 'rest_api_allowed_public_metadata' ),
181
		'sso_is_two_step_required'         => array( 'Jetpack_SSO_Helpers', 'is_two_step_required' ),
182
		'sso_should_hide_login_form'       => array( 'Jetpack_SSO_Helpers', 'should_hide_login_form' ),
183
		'sso_match_by_email'               => array( 'Jetpack_SSO_Helpers', 'match_by_email' ),
184
		'sso_new_user_override'            => array( 'Jetpack_SSO_Helpers', 'new_user_override' ),
185
		'sso_bypass_default_login_form'    => array( 'Jetpack_SSO_Helpers', 'bypass_login_forward_wpcom' ),
186
		'wp_version'                       => array( 'Jetpack_Sync_Functions', 'wp_version' ),
187
		'get_plugins'                      => array( 'Jetpack_Sync_Functions', 'get_plugins' ),
188
		'active_modules'                   => array( 'Jetpack', 'get_active_modules' ),
189
		'hosting_provider'                 => array( 'Jetpack_Sync_Functions', 'get_hosting_provider' ),
190
		'locale'                           => 'get_locale',
191
		'site_icon_url'                    => array( 'Jetpack_Sync_Functions', 'site_icon_url' ),
192
	);
193
194
	public static function get_callable_whitelist() {
195
		/**
196
		 * Filter the list of callables that are manageable via the JSON API.
197
		 *
198
		 * @module sync
199
		 *
200
		 * @since 4.8
201
		 *
202
		 * @param array The default list of callables.
203
		 */
204
		return apply_filters( 'jetpack_sync_callable_whitelist', self::$default_callable_whitelist );
205
	}
206
207
	static $blacklisted_post_types = array(
208
		'ai1ec_event',
209
		'snitch',
210
		'secupress_log_action',
211
		'http',
212
		'bwg_gallery',
213
		'bwg_album',
214
		'idx_page',
215
		'postman_sent_mail',
216
		'rssmi_feed_item',
217
		'rssap-feed',
218
		'wp_automatic',
219
	);
220
221
	static $default_post_checksum_columns = array(
0 ignored issues
show
The visibility should be declared for property $default_post_checksum_columns.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
222
		'ID',
223
		'post_modified',
224
	);
225
226
	static $default_post_meta_checksum_columns = array(
0 ignored issues
show
The visibility should be declared for property $default_post_meta_checksum_columns.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
227
		'meta_id',
228
		'meta_value'
229
	);
230
231
	static $default_comment_checksum_columns = array(
0 ignored issues
show
The visibility should be declared for property $default_comment_checksum_columns.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
232
		'comment_ID',
233
		'comment_content',
234
	);
235
236
	static $default_comment_meta_checksum_columns = array(
0 ignored issues
show
The visibility should be declared for property $default_comment_meta_checksum_columns.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
237
		'meta_id',
238
		'meta_value'
239
	);
240
241
	static $default_option_checksum_columns = array(
0 ignored issues
show
The visibility should be declared for property $default_option_checksum_columns.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
242
		'option_name',
243
		'option_value',
244
	);
245
246
	static $default_multisite_callable_whitelist = array(
0 ignored issues
show
The visibility should be declared for property $default_multisite_callable_whitelist.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
247
		'network_name'                        => array( 'Jetpack', 'network_name' ),
248
		'network_allow_new_registrations'     => array( 'Jetpack', 'network_allow_new_registrations' ),
249
		'network_add_new_users'               => array( 'Jetpack', 'network_add_new_users' ),
250
		'network_site_upload_space'           => array( 'Jetpack', 'network_site_upload_space' ),
251
		'network_upload_file_types'           => array( 'Jetpack', 'network_upload_file_types' ),
252
		'network_enable_administration_menus' => array( 'Jetpack', 'network_enable_administration_menus' ),
253
	);
254
255
	public static function get_multisite_callable_whitelist() {
256
		/**
257
		 * Filter the list of multisite callables that are manageable via the JSON API.
258
		 *
259
		 * @module sync
260
		 *
261
		 * @since 4.8
262
		 *
263
		 * @param array The default list of multisite callables.
264
		 */
265
		return apply_filters( 'jetpack_sync_multisite_callable_whitelist', self::$default_multisite_callable_whitelist );
266
	}
267
268
	static $post_meta_whitelist = array(
269
		'_feedback_akismet_values',
270
		'_feedback_email',
271
		'_feedback_extra_fields',
272
		'_g_feedback_shortcode',
273
		'_jetpack_post_thumbnail',
274
		'_menu_item_classes',
275
		'_menu_item_menu_item_parent',
276
		'_menu_item_object',
277
		'_menu_item_object_id',
278
		'_menu_item_orphaned',
279
		'_menu_item_type',
280
		'_menu_item_xfn',
281
		'_publicize_facebook_user',
282
		'_publicize_twitter_user',
283
		'_thumbnail_id',
284
		'_wp_attached_file',
285
		'_wp_attachment_backup_sizes',
286
		'_wp_attachment_context',
287
		'_wp_attachment_image_alt',
288
		'_wp_attachment_is_custom_background',
289
		'_wp_attachment_is_custom_header',
290
		'_wp_attachment_metadata',
291
		'_wp_page_template',
292
		'_wp_trash_meta_comments_status',
293
		'_wpas_mess',
294
		'content_width',
295
		'custom_css_add',
296
		'custom_css_preprocessor',
297
		'enclosure',
298
		'imagedata',
299
		'nova_price',
300
		'publicize_results',
301
		'sharing_disabled',
302
		'switch_like_status',
303
		'videopress_guid',
304
		'vimeo_poster_image',
305
		'advanced_seo_description', // Jetpack_SEO_Posts::DESCRIPTION_META_KEY
306
	);
307
308
	public static function get_post_meta_whitelist() {
309
		/**
310
		 * Filter the list of post meta data that are manageable via the JSON API.
311
		 *
312
		 * @module sync
313
		 *
314
		 * @since 4.8
315
		 *
316
		 * @param array The default list of meta data keys.
317
		 */
318
		return apply_filters( 'jetpack_sync_post_meta_whitelist', self::$post_meta_whitelist );
319
	}
320
321
	static $comment_meta_whitelist = array(
0 ignored issues
show
The visibility should be declared for property $comment_meta_whitelist.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
322
		'hc_avatar',
323
		'hc_post_as',
324
		'hc_wpcom_id_sig',
325
		'hc_foreign_user_id'
326
	);
327
328
	// TODO: move this to server? - these are theme support values
0 ignored issues
show
Coding Style Best Practice introduced by
Comments for TODO tasks are often forgotten in the code; it might be better to use a dedicated issue tracker.
Loading history...
329
	// that should be synced as jetpack_current_theme_supports_foo option values
330
	static $default_theme_support_whitelist = array(
0 ignored issues
show
The visibility should be declared for property $default_theme_support_whitelist.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
331
		'post-thumbnails',
332
		'post-formats',
333
		'custom-header',
334
		'custom-background',
335
		'custom-logo',
336
		'menus',
337
		'automatic-feed-links',
338
		'editor-style',
339
		'widgets',
340
		'html5',
341
		'title-tag',
342
		'jetpack-social-menu',
343
		'jetpack-responsive-videos',
344
		'infinite-scroll',
345
		'site-logo',
346
	);
347
348
	static function is_whitelisted_option( $option ) {
349
		foreach ( self::$default_options_whitelist as $whitelisted_option ) {
350
			if ( $whitelisted_option[0] === '/' && preg_match( $whitelisted_option, $option ) ) {
351
				return true;
352
			} elseif ( $whitelisted_option === $option ) {
353
				return true;
354
			}
355
		}
356
357
		return false;
358
	}
359
360
	static function get_max_sync_execution_time() {
361
		$max_exec_time = intval( ini_get( 'max_execution_time' ) );
362
		if ( 0 === $max_exec_time ) {
363
			// 0 actually means "unlimited", but let's not treat it that way
364
			$max_exec_time = 60;
365
		}
366
		return floor( $max_exec_time / 3 );
367
	}
368
369
	static $default_network_options_whitelist = array(
0 ignored issues
show
The visibility should be declared for property $default_network_options_whitelist.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
370
		'site_name',
371
		'jetpack_protect_key',
372
		'jetpack_protect_global_whitelist',
373
		'active_sitewide_plugins',
374
	);
375
376
	static $default_taxonomy_whitelist = array();
0 ignored issues
show
The visibility should be declared for property $default_taxonomy_whitelist.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
377
	static $default_dequeue_max_bytes = 500000; // very conservative value, 1/2 MB
378
	static $default_upload_max_bytes = 600000; // a little bigger than the upload limit to account for serialization
379
	static $default_upload_max_rows = 500;
380
	static $default_sync_wait_time = 10; // seconds, between syncs
381
	static $default_sync_wait_threshold = 5; // only wait before next send if the current send took more than X seconds
382
	static $default_enqueue_wait_time = 10; // wait between attempting to continue a full sync, via requests
383
	static $default_max_queue_size = 1000;
384
	static $default_max_queue_lag = 900; // 15 minutes
385
	static $default_queue_max_writes_sec = 100; // 100 rows a second
386
	static $default_post_types_blacklist = array();
387
	static $default_post_meta_whitelist = array();
388
	static $default_comment_meta_whitelist = array();
389
	static $default_disable = 0; // completely disable sending data to wpcom
390
	static $default_sync_via_cron = 1; // use cron to sync
391
	static $default_render_filtered_content = 0; // render post_filtered_content
392
	static $default_max_enqueue_full_sync = 100; // max number of items to enqueue at a time when running full sync
393
	static $default_max_queue_size_full_sync = 1000; // max number of total items in the full sync queue
394
	static $default_sync_callables_wait_time = MINUTE_IN_SECONDS; // seconds before sending callables again
395
	static $default_sync_constants_wait_time = HOUR_IN_SECONDS; // seconds before sending constants again
396
	static $default_sync_queue_lock_timeout = 120; // 2 minutes
397
	static $default_cron_sync_time_limit = 30; // 30 seconds
398
}
399