Completed
Push — update/sync-defaults-from-wpco... ( 8ac9eb )
by
unknown
10:11
created

Jetpack_Sync_Defaults::match_option_key()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 7
nc 4
nop 2
dl 0
loc 11
rs 8.8571
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Just some defaults that we share with the server
5
 */
6
class Jetpack_Sync_Defaults {
7
8
	static $default_options_whitelist = array(
0 ignored issues
show
Coding Style introduced by
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...
9
		'stylesheet',
10
		'blogname',
11
		'blogdescription',
12
		'blog_charset',
13
		'permalink_structure',
14
		'category_base',
15
		'tag_base',
16
		'sidebars_widgets',
17
		'comment_moderation',
18
		'default_comment_status',
19
		'page_on_front',
20
		'rss_use_excerpt',
21
		'subscription_options',
22
		'stb_enabled',
23
		'stc_enabled',
24
		'comment_registration',
25
		'show_avatars',
26
		'avatar_default',
27
		'avatar_rating',
28
		'highlander_comment_form_prompt',
29
		'jetpack_comment_form_color_scheme',
30
		'stats_options',
31
		'gmt_offset',
32
		'timezone_string',
33
		'jetpack_sync_non_public_post_stati',
34
		'jetpack_options',
35
		'site_icon', // (int) - ID of core's Site Icon attachment ID
36
		'default_post_format',
37
		'default_category',
38
		'large_size_w',
39
		'large_size_h',
40
		'thumbnail_size_w',
41
		'thumbnail_size_h',
42
		'medium_size_w',
43
		'medium_size_h',
44
		'thumbnail_crop',
45
		'image_default_link_type',
46
		'site_logo',
47
		'sharing-options',
48
		'sharing-services',
49
		'post_count',
50
		'default_ping_status',
51
		'sticky_posts',
52
		'blog_public',
53
		'default_pingback_flag',
54
		'require_name_email',
55
		'close_comments_for_old_posts',
56
		'close_comments_days_old',
57
		'thread_comments',
58
		'thread_comments_depth',
59
		'page_comments',
60
		'comments_per_page',
61
		'default_comments_page',
62
		'comment_order',
63
		'comments_notify',
64
		'moderation_notify',
65
		'social_notifications_like',
66
		'social_notifications_reblog',
67
		'social_notifications_subscribe',
68
		'comment_whitelist',
69
		'comment_max_links',
70
		'moderation_keys',
71
		'jetpack_wga',
72
		'disabled_likes',
73
		'disabled_reblogs',
74
		'jetpack_comment_likes_enabled',
75
		'twitter_via',
76
		'jetpack-twitter-cards-site-tag',
77
		'wpcom_publish_posts_with_markdown',
78
		'wpcom_publish_comments_with_markdown',
79
		'jetpack_activated',
80
		'jetpack_active_modules',
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
		/**
121
		 * Filter the list of WordPress options that are manageable via the JSON API.
122
		 *
123
		 * @module sync
124
		 *
125
		 * @since 4.8
126
		 *
127
		 * @param array The default list of options.
128
		 */
129
		return apply_filters( 'jetpack_sync_options_whitelist', $options_whitelist );
130
	}
131
132
	/**
133
	 * These are options that don't need to go in the regular wp_options table.
134
	 * The reason we're putting them here is that all wp_options are pre-loaded to memory and we don't want to abuse that.
135
	 *
136
	 * @var array
137
	 */
138
	private static $options_whitelist_no_autoload = array(
139
		'woocommerce_currency'                              => 'string',
140
		'woocommerce_db_version'                            => 'string',
141
		'woocommerce_weight_unit'                           => 'string',
142
		'woocommerce_version'                               => 'string',
143
		'woocommerce_unforce_ssl_checkout'                  => 'string',
144
		'woocommerce_tax_total_display'                     => 'string',
145
		'woocommerce_tax_round_at_subtotal'                 => 'string',
146
		'woocommerce_tax_display_shop'                      => 'string',
147
		'woocommerce_tax_display_cart'                      => 'string',
148
		'woocommerce_prices_include_tax'                    => 'string',
149
		'woocommerce_price_thousand_sep'                    => 'string',
150
		'woocommerce_price_num_decimals'                    => 'string',
151
		'woocommerce_price_decimal_sep'                     => 'string',
152
		'woocommerce_notify_low_stock'                      => 'string',
153
		'woocommerce_notify_low_stock_amount'               => 'int',
154
		'woocommerce_notify_no_stock'                       => 'string',
155
		'woocommerce_notify_no_stock_amount'                => 'int',
156
		'woocommerce_manage_stock'                          => 'string',
157
		'woocommerce_force_ssl_checkout'                    => 'string',
158
		'woocommerce_hide_out_of_stock_items'               => 'string',
159
		'woocommerce_file_download_method'                  => 'string',
160
		'woocommerce_enable_signup_and_login_from_checkout' => 'string',
161
		'woocommerce_enable_shipping_calc'                  => 'string',
162
		'woocommerce_enable_review_rating'                  => 'string',
163
		'woocommerce_enable_guest_checkout'                 => 'string',
164
		'woocommerce_enable_coupons'                        => 'string',
165
		'woocommerce_enable_checkout_login_reminder'        => 'string',
166
		'woocommerce_enable_ajax_add_to_cart'               => 'string',
167
		'woocommerce_dimension_unit'                        => 'string',
168
		'woocommerce_default_country'                       => 'string',
169
		'woocommerce_default_customer_address'              => 'string',
170
		'woocommerce_currency_pos'                          => 'string',
171
		'woocommerce_api_enabled'                           => 'string',
172
		'woocommerce_allow_tracking'                        => 'string',
173
	);
174
175
	static $default_constants_whitelist = array(
0 ignored issues
show
Coding Style introduced by
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...
176
		'EMPTY_TRASH_DAYS',
177
		'WP_POST_REVISIONS',
178
		'AUTOMATIC_UPDATER_DISABLED',
179
		'ABSPATH',
180
		'WP_CONTENT_DIR',
181
		'FS_METHOD',
182
		'DISALLOW_FILE_EDIT',
183
		'DISALLOW_FILE_MODS',
184
		'WP_AUTO_UPDATE_CORE',
185
		'WP_HTTP_BLOCK_EXTERNAL',
186
		'WP_ACCESSIBLE_HOSTS',
187
		'JETPACK__VERSION',
188
		'IS_PRESSABLE',
189
		'DISABLE_WP_CRON',
190
		'ALTERNATE_WP_CRON',
191
		'WP_CRON_LOCK_TIMEOUT',
192
		'PHP_VERSION',
193
		'WP_MEMORY_LIMIT',
194
		'WP_MAX_MEMORY_LIMIT',
195
	);
196
197
	public static function get_constants_whitelist() {
198
		/**
199
		 * Filter the list of PHP constants that are manageable via the JSON API.
200
		 *
201
		 * @module sync
202
		 *
203
		 * @since 4.8
204
		 *
205
		 * @param array The default list of constants options.
206
		 */
207
		return apply_filters( 'jetpack_sync_constants_whitelist', self::$default_constants_whitelist );
208
	}
209
210
	private static $constants_whitelist_no_autoload = array(
211
		'WC_PLUGIN_FILE'            => 'string',
212
		'WC_ABSPATH'                => 'string',
213
		'WC_PLUGIN_BASENAME'        => 'string',
214
		'WC_VERSION'                => 'string',
215
		'WOOCOMMERCE_VERSION'       => 'string',
216
		'WC_ROUNDING_PRECISION'     => 'int',
217
		'WC_DISCOUNT_ROUNDING_MODE' => 'int',
218
		'WC_TAX_ROUNDING_MODE'      => 'int',
219
		'WC_DELIMITER'              => 'string',
220
		'WC_LOG_DIR'                => 'string',
221
		'WC_SESSION_CACHE_GROUP'    => 'string',
222
		'WC_TEMPLATE_DEBUG_MODE'    => 'bool',
223
	);
224
225
	static $default_callable_whitelist = array(
0 ignored issues
show
Coding Style introduced by
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...
226
		'wp_max_upload_size'               => 'wp_max_upload_size',
227
		'is_main_network'                  => array( 'Jetpack', 'is_multi_network' ),
228
		'is_multi_site'                    => 'is_multisite',
229
		'main_network_site'                => array( 'Jetpack_Sync_Functions', 'main_network_site_url' ),
230
		'site_url'                         => array( 'Jetpack_Sync_Functions', 'site_url' ),
231
		'home_url'                         => array( 'Jetpack_Sync_Functions', 'home_url' ),
232
		'single_user_site'                 => array( 'Jetpack', 'is_single_user_site' ),
233
		'updates'                          => array( 'Jetpack', 'get_updates' ),
234
		'has_file_system_write_access'     => array( 'Jetpack_Sync_Functions', 'file_system_write_access' ),
235
		'is_version_controlled'            => array( 'Jetpack_Sync_Functions', 'is_version_controlled' ),
236
		'taxonomies'                       => array( 'Jetpack_Sync_Functions', 'get_taxonomies' ),
237
		'post_types'                       => array( 'Jetpack_Sync_Functions', 'get_post_types' ),
238
		'post_type_features'               => array( 'Jetpack_Sync_Functions', 'get_post_type_features' ),
239
		'shortcodes'                       => array( 'Jetpack_Sync_Functions', 'get_shortcodes' ),
240
		'rest_api_allowed_post_types'      => array( 'Jetpack_Sync_Functions', 'rest_api_allowed_post_types' ),
241
		'rest_api_allowed_public_metadata' => array( 'Jetpack_Sync_Functions', 'rest_api_allowed_public_metadata' ),
242
		'sso_is_two_step_required'         => array( 'Jetpack_SSO_Helpers', 'is_two_step_required' ),
243
		'sso_should_hide_login_form'       => array( 'Jetpack_SSO_Helpers', 'should_hide_login_form' ),
244
		'sso_match_by_email'               => array( 'Jetpack_SSO_Helpers', 'match_by_email' ),
245
		'sso_new_user_override'            => array( 'Jetpack_SSO_Helpers', 'new_user_override' ),
246
		'sso_bypass_default_login_form'    => array( 'Jetpack_SSO_Helpers', 'bypass_login_forward_wpcom' ),
247
		'wp_version'                       => array( 'Jetpack_Sync_Functions', 'wp_version' ),
248
		'get_plugins'                      => array( 'Jetpack_Sync_Functions', 'get_plugins' ),
249
		'active_modules'                   => array( 'Jetpack', 'get_active_modules' ),
250
		'hosting_provider'                 => array( 'Jetpack_Sync_Functions', 'get_hosting_provider' ),
251
		'locale'                           => 'get_locale',
252
		'site_icon_url'                    => array( 'Jetpack_Sync_Functions', 'site_icon_url' ),
253
	);
254
255
	public static function get_callable_whitelist() {
256
		/**
257
		 * Filter the list of 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 callables.
264
		 */
265
		return apply_filters( 'jetpack_sync_callable_whitelist', self::$default_callable_whitelist );
266
	}
267
268
	static $blacklisted_post_types = array(
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $blacklisted_post_types.

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...
269
		'ai1ec_event',
270
		'snitch',
271
		'secupress_log_action',
272
		'http',
273
		'bwg_gallery',
274
		'bwg_album',
275
		'idx_page',
276
		'postman_sent_mail',
277
		'rssmi_feed_item',
278
		'rssap-feed',
279
		'wp_automatic',
280
	);
281
282
	static $default_post_checksum_columns = array(
0 ignored issues
show
Coding Style introduced by
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...
283
		'ID',
284
		'post_modified',
285
	);
286
287
	static $default_post_meta_checksum_columns = array(
0 ignored issues
show
Coding Style introduced by
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...
288
		'meta_id',
289
		'meta_value',
290
	);
291
292
	static $default_comment_checksum_columns = array(
0 ignored issues
show
Coding Style introduced by
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...
293
		'comment_ID',
294
		'comment_content',
295
	);
296
297
	static $default_comment_meta_checksum_columns = array(
0 ignored issues
show
Coding Style introduced by
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...
298
		'meta_id',
299
		'meta_value',
300
	);
301
302
	static $default_option_checksum_columns = array(
0 ignored issues
show
Coding Style introduced by
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...
303
		'option_name',
304
		'option_value',
305
	);
306
307
	// returns escapted SQL that can be injected into a WHERE clause
308
	static function get_blacklisted_post_types_sql() {
309
		return 'post_type NOT IN (\'' . join( '\', \'', array_map( 'esc_sql', self::$blacklisted_post_types ) ) . '\')';
310
	}
311
312
	static $default_multisite_callable_whitelist = array(
0 ignored issues
show
Coding Style introduced by
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...
313
		'network_name'                        => array( 'Jetpack', 'network_name' ),
314
		'network_allow_new_registrations'     => array( 'Jetpack', 'network_allow_new_registrations' ),
315
		'network_add_new_users'               => array( 'Jetpack', 'network_add_new_users' ),
316
		'network_site_upload_space'           => array( 'Jetpack', 'network_site_upload_space' ),
317
		'network_upload_file_types'           => array( 'Jetpack', 'network_upload_file_types' ),
318
		'network_enable_administration_menus' => array( 'Jetpack', 'network_enable_administration_menus' ),
319
	);
320
321
	public static function get_multisite_callable_whitelist() {
322
		/**
323
		 * Filter the list of multisite callables that are manageable via the JSON API.
324
		 *
325
		 * @module sync
326
		 *
327
		 * @since 4.8
328
		 *
329
		 * @param array The default list of multisite callables.
330
		 */
331
		return apply_filters( 'jetpack_sync_multisite_callable_whitelist', self::$default_multisite_callable_whitelist );
332
	}
333
334
	static $post_meta_whitelist = array(
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $post_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...
335
		'_feedback_akismet_values',
336
		'_feedback_email',
337
		'_feedback_extra_fields',
338
		'_g_feedback_shortcode',
339
		'_jetpack_post_thumbnail',
340
		'_menu_item_classes',
341
		'_menu_item_menu_item_parent',
342
		'_menu_item_object',
343
		'_menu_item_object_id',
344
		'_menu_item_orphaned',
345
		'_menu_item_type',
346
		'_menu_item_xfn',
347
		'_publicize_facebook_user',
348
		'_publicize_twitter_user',
349
		'_thumbnail_id',
350
		'_wp_attached_file',
351
		'_wp_attachment_backup_sizes',
352
		'_wp_attachment_context',
353
		'_wp_attachment_image_alt',
354
		'_wp_attachment_is_custom_background',
355
		'_wp_attachment_is_custom_header',
356
		'_wp_attachment_metadata',
357
		'_wp_page_template',
358
		'_wp_trash_meta_comments_status',
359
		'_wpas_mess',
360
		'advanced_seo_description', // Jetpack_SEO_Posts::DESCRIPTION_META_KEY
361
		'content_width',
362
		'custom_css_add',
363
		'custom_css_preprocessor',
364
		'enclosure',
365
		'imagedata',
366
		'nova_price',
367
		'publicize_results',
368
		'sharing_disabled',
369
		'switch_like_status',
370
		'videopress_guid',
371
		'vimeo_poster_image',
372
373
		//woocommerce products
374
		'_stock_status',
375
		'_visibility',
376
		'total_sales',
377
		'_downloadable',
378
		'_virtual',
379
		'_regular_price',
380
		'_sale_price',
381
		'_tax_status',
382
		'_tax_class',
383
		'_featured',
384
		'_price',
385
		'_stock',
386
		'_backorders',
387
		'_manage_stock',
388
389
		//woocommerce orders
390
		'_order_currency',
391
		'_prices_include_tax',
392
		'_created_via',
393
		'_billing_country',
394
		'_billing_city',
395
		'_billing_state',
396
		'_billing_postcode',
397
		'_shipping_country',
398
		'_shipping_city',
399
		'_shipping_state',
400
		'_shipping_postcode',
401
		'_payment_method',
402
		'_payment_method_title',
403
		'_order_shipping',
404
		'_cart_discount',
405
		'_cart_discount_tax',
406
		'_order_tax',
407
		'_order_shipping_tax',
408
		'_order_total',
409
		'_download_permissions_granted',
410
		'_recorded_sales',
411
		'_order_stock_reduced',
412
	);
413
414
	public static function get_post_meta_whitelist() {
415
		/**
416
		 * Filter the list of post meta data that are manageable via the JSON API.
417
		 *
418
		 * @module sync
419
		 *
420
		 * @since 4.8
421
		 *
422
		 * @param array The default list of meta data keys.
423
		 */
424
		return apply_filters( 'jetpack_sync_post_meta_whitelist', self::$post_meta_whitelist );
425
	}
426
427
	static $comment_meta_whitelist = array(
0 ignored issues
show
Coding Style introduced by
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...
428
		'hc_avatar',
429
		'hc_post_as',
430
		'hc_wpcom_id_sig',
431
		'hc_foreign_user_id'
432
	);
433
434
	// 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...
435
	// that should be synced as jetpack_current_theme_supports_foo option values
436
	static $default_theme_support_whitelist = array(
0 ignored issues
show
Coding Style introduced by
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...
437
		'post-thumbnails',
438
		'post-formats',
439
		'custom-header',
440
		'custom-background',
441
		'custom-logo',
442
		'menus',
443
		'automatic-feed-links',
444
		'editor-style',
445
		'widgets',
446
		'html5',
447
		'title-tag',
448
		'jetpack-social-menu',
449
		'jetpack-responsive-videos',
450
		'infinite-scroll',
451
		'site-logo',
452
	);
453
454
	static function is_whitelisted_option( $option ) {
455
		return null !== self::match_option_key( $option, self::$default_options_whitelist );
456
	}
457
458
	/**
459
	 * Gets the sanitization type of the option.
460
	 * Null means the option is either not whitelisted at all or is an auto loaded options.
461
	 *
462
	 * @param $option string The option name
463
	 *
464
	 * @return mixed|null null of nothing found, the type otherwise
465
	 */
466
	public static function get_option_type( $option ) {
467
		$key = self::match_option_key( $option, array_keys( self::$options_whitelist_no_autoload ) );
468
469
		return null === $key ? null : self::$options_whitelist_no_autoload[ $key ];
470
	}
471
472
	private static function match_option_key( $option, $list ) {
473
		foreach ( $list as $whitelisted_option ) {
474
			if ( '/' === $whitelisted_option[0] && preg_match( $whitelisted_option, $option ) ) {
475
				return $whitelisted_option;
476
			} elseif ( $whitelisted_option === $option ) {
477
				return $whitelisted_option;
478
			}
479
		}
480
481
		return null;
482
	}
483
484
	/**
485
	 * Gets the sanitization type of the constant.
486
	 * Null means the option is either not whitelisted at all or is an auto loaded options.
487
	 *
488
	 * @param $name string name of the constant
489
	 *
490
	 * @return mixed|null
491
	 */
492
	public static function get_constant_type( $name ) {
493
		if ( isset( self::$constants_whitelist_no_autoload[ $name ] ) ) {
494
			return self::$constants_whitelist_no_autoload[ $name ];
495
		}
496
497
		return null;
498
	}
499
500
	static function is_whitelisted_post_meta_key( $meta_key ) {
501
		if ( in_array( $meta_key, self::get_post_meta_whitelist() ) ) {
502
			return true;
503
		}
504
505
		$blog_id = get_current_blog_id();
506
		if ( ! empty( $blog_id ) ) {
507
			return in_array( $blog_id, self::$allow_all_post_meta_blog_ids );
508
		}
509
510
		return false;
511
	}
512
513
	static function get_max_sync_execution_time() {
514
		$max_exec_time = intval( ini_get( 'max_execution_time' ) );
515
		if ( 0 === $max_exec_time ) {
516
			// 0 actually means "unlimited", but let's not treat it that way
517
			$max_exec_time = 60;
518
		}
519
		return floor( $max_exec_time / 3 );
520
	}
521
522
	static $default_network_options_whitelist = array(
0 ignored issues
show
Coding Style introduced by
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...
523
		'site_name',
524
		'jetpack_protect_key',
525
		'jetpack_protect_global_whitelist',
526
		'active_sitewide_plugins',
527
	);
528
529
	static $default_taxonomy_whitelist = array();
0 ignored issues
show
Coding Style introduced by
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...
530
	static $default_dequeue_max_bytes = 500000; // very conservative value, 1/2 MB
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $default_dequeue_max_bytes.

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...
531
	static $default_upload_max_bytes = 600000; // a little bigger than the upload limit to account for serialization
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $default_upload_max_bytes.

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...
532
	static $default_upload_max_rows = 500;
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $default_upload_max_rows.

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...
533
	static $default_sync_wait_time = 10; // seconds, between syncs
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $default_sync_wait_time.

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...
534
	static $default_sync_wait_threshold = 5; // only wait before next send if the current send took more than X seconds
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $default_sync_wait_threshold.

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...
535
	static $default_enqueue_wait_time = 10; // wait between attempting to continue a full sync, via requests
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $default_enqueue_wait_time.

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...
536
	static $default_max_queue_size = 1000;
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $default_max_queue_size.

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...
537
	static $default_max_queue_lag = 900; // 15 minutes
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $default_max_queue_lag.

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...
538
	static $default_queue_max_writes_sec = 100; // 100 rows a second
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $default_queue_max_writes_sec.

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...
539
	static $default_post_types_blacklist = array();
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $default_post_types_blacklist.

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...
540
	static $default_post_meta_whitelist = array();
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $default_post_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...
541
	static $default_comment_meta_whitelist = array();
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $default_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...
542
	static $default_disable = 0; // completely disable sending data to wpcom
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $default_disable.

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...
543
	static $default_sync_via_cron = 1; // use cron to sync
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $default_sync_via_cron.

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...
544
	static $default_render_filtered_content = 0; // render post_filtered_content
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $default_render_filtered_content.

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...
545
	static $default_max_enqueue_full_sync = 100; // max number of items to enqueue at a time when running full sync
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $default_max_enqueue_full_sync.

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...
546
	static $default_max_queue_size_full_sync = 1000; // max number of total items in the full sync queue
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $default_max_queue_size_full_sync.

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...
547
	static $default_sync_callables_wait_time = MINUTE_IN_SECONDS; // seconds before sending callables again
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $default_sync_callables_wait_time.

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...
548
	static $default_sync_constants_wait_time = HOUR_IN_SECONDS; // seconds before sending constants again
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $default_sync_constants_wait_time.

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...
549
	static $default_sync_queue_lock_timeout = 120; // 2 minutes
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $default_sync_queue_lock_timeout.

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...
550
	static $default_cron_sync_time_limit = 30; // 30 seconds
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $default_cron_sync_time_limit.

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...
551
}
552