Completed
Push — add/sync-rest-2 ( e0eac0...35d25f )
by
unknown
323:03 queued 313:25
created

Jetpack_Sync_Client::send_wp_version()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 3
eloc 4
nc 2
nop 2
1
<?php
2
require_once dirname( __FILE__ ) . '/class.jetpack-sync-deflate-codec.php';
3
require_once dirname( __FILE__ ) . '/class.jetpack-sync-queue.php';
4
require_once dirname( __FILE__ ) . '/class.jetpack-sync-functions.php';
5
require_once dirname( __FILE__ ) . '/class.jetpack-sync-full.php';
6
7
class Jetpack_Sync_Client {
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
		'/^theme_mods_.*$/',
11
		'blogname',
12
		'home',
13
		'siteurl',
14
		'blogdescription',
15
		'blog_charset',
16
		'permalink_structure',
17
		'category_base',
18
		'tag_base',
19
		'comment_moderation',
20
		'default_comment_status',
21
		'thread_comments',
22
		'thread_comments_depth',
23
		'jetpack_site_icon_url',
24
		'social_notifications_like',
25
		'page_on_front',
26
		'rss_use_excerpt',
27
		'subscription_options',
28
		'stb_enabled',
29
		'stc_enabled',
30
		'comment_registration',
31
		'require_name_email',
32
		'show_avatars',
33
		'avatar_default',
34
		'avatar_rating',
35
		'highlander_comment_form_prompt',
36
		'jetpack_comment_form_color_scheme',
37
		'stats_options',
38
		'gmt_offset',
39
		'timezone_string',
40
		'jetpack_sync_non_public_post_stati',
41
		'jetpack_options',
42
		'site_icon', // (int) - ID of core's Site Icon attachment ID
43
		'default_post_format',
44
		'default_category',
45
		'large_size_w',
46
		'large_size_h',
47
		'thumbnail_size_w',
48
		'thumbnail_size_h',
49
		'medium_size_w',
50
		'medium_size_h',
51
		'thumbnail_crop',
52
		'image_default_link_type',
53
		'site_logo',
54
		'sharing-options',
55
		'sharing-services',
56
		'post_count',
57
		'default_ping_status',
58
		'sticky_posts',
59
		'disabled_likes',
60
		'blog_public',
61
		'default_pingback_flag',
62
		'require_name_email',
63
		'close_comments_for_old_posts',
64
		'close_comments_days_old',
65
		'thread_comments',
66
		'thread_comments_depth',
67
		'page_comments',
68
		'comments_per_page',
69
		'default_comments_page',
70
		'comment_order',
71
		'comments_notify',
72
		'moderation_notify',
73
		'social_notifications_like',
74
		'social_notifications_reblog',
75
		'social_notifications_subscribe',
76
		'comment_whitelist',
77
		'comment_max_links',
78
		'moderation_keys',
79
		'blacklist_keys',
80
		'lang_id',
81
		'wga',
82
		'disabled_likes',
83
		'disabled_reblogs',
84
		'jetpack_comment_likes_enabled',
85
		'twitter_via',
86
		'twitter-cards-site-tag' );
87
88
	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...
89
		'EMPTY_TRASH_DAYS',
90
		'WP_POST_REVISIONS',
91
		'AUTOMATIC_UPDATER_DISABLED',
92
		'ABSPATH',
93
		'WP_CONTENT_DIR',
94
		'FS_METHOD',
95
		'DISALLOW_FILE_EDIT',
96
		'DISALLOW_FILE_MODS',
97
		'WP_AUTO_UPDATE_CORE',
98
		'WP_HTTP_BLOCK_EXTERNAL',
99
		'WP_ACCESSIBLE_HOSTS',
100
		'JETPACK__VERSION'
101
	);
102
103
	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...
104
		'wp_max_upload_size' => 'wp_max_upload_size',
105
		'is_main_network' => array( 'Jetpack', 'is_multi_network' ),
106
		'is_multi_site' => 'is_multisite',
107
		'main_network_site' => 'network_site_url',
108
		'single_user_site' => array( 'Jetpack', 'is_single_user_site' ),
109
		'has_file_system_write_access' => array( 'Jetpack_Sync_Functions', 'file_system_write_access' ),
110
		'is_version_controlled' => array( 'Jetpack_Sync_Functions', 'is_version_controlled' ),
111
		'modules' => array( 'Jetpack_Sync_Functions', 'get_modules' )
112
	);
113
114
	// 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...
115
	// that should be synced as jetpack_current_theme_supports_foo option values
116
	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...
117
		'post-thumbnails',          
118
		'post-formats',
119
		'custom-header',
120
		'custom-background',
121
		'custom-logo',
122
		'menus',
123
		'automatic-feed-links',
124
		'editor-style',
125
		'widgets',
126
		'html5',
127
		'title-tag',
128
		'jetpack-social-menu',
129
		'jetpack-responsive-videos',
130
		'infinite-scroll',
131
		'site-logo',
132
	);
133
134
	static $default_network_options_whitelist = array( 'site_name' );
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...
135
	static $constants_checksum_option_name = 'jetpack_constants_sync_checksum';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $constants_checksum_option_name.

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

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...
137
	static $default_send_buffer_size = 20;
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $default_send_buffer_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...
138
	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...
139
140
	private $sync_queue;
141
	private $full_sync_client;
142
	private $codec;
143
	private $options_whitelist;
144
	private $constants_whitelist;
145
	private $meta_types = array( 'post' );
146
	private $callable_whitelist;
147
	private $network_options_whitelist;
148
	private $taxonomy_whitelist;
149
150
	// singleton functions
151
	private static $instance;
152
153
	public static function getInstance() {
154
		if ( null === self::$instance ) {
155
			self::$instance = new self();
156
		}
157
158
		return self::$instance;
159
	}
160
161
	// this is necessary because you can't use "new" when you declare instance properties >:(
162
	protected function __construct() {
163
		$this->set_defaults();
164
		$this->init();
165
	}
166
167
	private function init() {
168
169
		$handler = array( $this, 'action_handler' );
170
171
		// constants
172
		add_action( 'jetpack_sync_current_constants', $handler, 10 );
173
174
		// functions
175
		add_action( 'jetpack_sync_current_callables', $handler, 10 );
176
177
		// posts
178
		add_action( 'wp_insert_post', $handler, 10, 3 );
179
		add_action( 'deleted_post', $handler, 10 );
180
181
		// comments
182
		add_action( 'wp_insert_comment', $handler, 10, 2 );
183
		add_action( 'deleted_comment', $handler, 10 );
184
		add_action( 'trashed_comment', $handler, 10 );
185
		add_action( 'spammed_comment', $handler, 10 );
186
187
		// even though it's messy, we implement these hooks because 
188
		// the edit_comment hook doesn't include the data
189
		// so this saves us a DB read for every comment event
190
		foreach ( array( '', 'trackback', 'pingback' ) as $comment_type ) {
191
			foreach ( array( 'unapproved', 'approved' ) as $comment_status ) {
192
				add_action( "comment_{$comment_status}_{$comment_type}", $handler, 10, 2 );
193
			}
194
		}
195
196
		// options
197
		add_action( 'added_option', $handler, 10, 2 );
198
		add_action( 'updated_option', $handler, 10, 3 );
199
		add_action( 'deleted_option', $handler, 10, 1 );
200
201
		// Sync Core Icon: Detect changes in Core's Site Icon and make it syncable.
202
		add_action( 'add_option_site_icon',    array( $this, 'jetpack_sync_core_icon' ) );
203
		add_action( 'update_option_site_icon', array( $this, 'jetpack_sync_core_icon' ) );
204
		add_action( 'delete_option_site_icon', array( $this, 'jetpack_sync_core_icon' ) );
205
206
		// wordpress version
207
		add_action( 'upgrader_process_complete', array( $this, 'send_wp_version' ), 10, 2 );
208
		add_action( 'jetpack_sync_wp_version', $handler );
209
		// themes
210
		add_action( 'switch_theme', array( $this, 'send_theme_info' ) );
211
		add_action( 'jetpack_sync_current_theme_support', $handler, 10 ); // custom hook, see meta-hooks below
212
213
		// post-meta, and in the future - other meta?
214
		foreach ( $this->meta_types as $meta_type ) {
215
			// we need to make sure we don't commit before we receive these,
216
			// because they're invoked after meta changes are saved to the DB
217
			add_action( "added_{$meta_type}_meta", $handler, 99, 4 );
218
			add_action( "updated_{$meta_type}_meta", $handler, 99, 4 );
219
			add_action( "deleted_{$meta_type}_meta", $handler, 99, 4 );
220
		}
221
222
		// synthetic actions for full sync
223
		add_action( 'jp_full_sync_start', $handler );
224
		add_action( 'jp_full_sync_posts', $handler );
225
		add_action( 'jp_full_sync_comments', $handler );
226
		add_action( 'jp_full_sync_option', $handler, 10, 2 );
227
		add_action( 'jp_full_sync_postmeta', $handler, 10, 2 );
228
229
		/**
230
		 * Other hooks - fire synthetic hooks for all the properties we need to sync,
231
		 * e.g. when a theme changes
232
		 */
233
234
		// themes
235
		add_action( 'set_site_transient_update_plugins', $handler, 10, 1 );
236
		add_action( 'set_site_transient_update_themes', $handler, 10, 1 );
237
		add_action( 'set_site_transient_update_core', $handler, 10, 1 );
238
239
		// multi site network options
240
		if ( $this->is_multisite ) {
0 ignored issues
show
Bug introduced by
The property is_multisite does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
241
			add_action( 'add_site_option', $handler, 10, 2 );
242
			add_action( 'update_site_option', $handler, 10, 3 );
243
			add_action( 'delete_site_option', $handler, 10, 1 );
244
		}
245
246
247
		/**
248
		 * Sync all pending actions with server
249
		 */
250
		add_action( 'jetpack_sync_actions', array( $this, 'do_sync' ) );
251
252
		// terms
253
		add_action( 'created_term', array( $this, 'save_term_handler' ), 10, 3 );
254
		add_action( 'edited_term', array( $this, 'save_term_handler' ), 10, 3 );
255
		add_action( 'jetapack_sync_save_term', $handler, 10, 4 );
256
		add_action( 'delete_term', $handler, 10, 5 );
257
	}
258
259
	// TODO: Refactor to use one set whitelist function, with one is_whitelisted.
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...
260
	function set_options_whitelist( $options ) {
261
		$this->options_whitelist = $options;
262
	}
263
264
	function set_constants_whitelist( $constants ) {
265
		$this->constants_whitelist = $constants;
266
	}
267
268
	function get_callable_whitelist( $functions ) {
0 ignored issues
show
Unused Code introduced by
The parameter $functions is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
269
		return $this->callable_whitelist;
270
	}
271
272
	function set_callable_whitelist( $functions ) {
273
		$this->callable_whitelist = $functions;
274
	}
275
276
	function set_network_options_whitelist( $options ) {
277
		$this->network_options_whitelist = $options;
278
	}
279
280
	function set_send_buffer_size( $size ) {
281
		$this->sync_queue->set_checkout_size( $size );
282
	}
283
284
	function set_taxonomy_whitelist( $taxonomies ) {
285
		$this->taxonomy_whitelist = $taxonomies;
286
	}
287
288
	function is_whitelisted_option( $option ) {
289
		foreach ( $this->options_whitelist as $whitelisted_option ) {
290
			if ( $whitelisted_option[0] === '/' && preg_match( $whitelisted_option, $option ) ) {
291
				return true;
292
			} elseif ( $whitelisted_option === $option ) {
293
				return true;
294
			}
295
		}
296
297
		return false;
298
	}
299
300
	function is_whitelisted_network_option( $option ) {
301
		return $this->is_multisite && in_array( $option, $this->network_options_whitelist );
302
	}
303
304
	function set_codec( iJetpack_Sync_Codec $codec ) {
305
		$this->codec = $codec;
306
	}
307
308
	function set_full_sync_client( $full_sync_client ) {
309
		if ( $this->full_sync_client ) {
310
			remove_action( 'jetpack_sync_full', array( $this->full_sync_client, 'start' ) );
311
		}
312
313
		$this->full_sync_client = $full_sync_client;
314
315
		/**
316
		 * Sync all objects in the database with the server
317
		 */
318
		add_action( 'jetpack_sync_full', array( $this->full_sync_client, 'start' ) );
319
	}
320
321
	function action_handler() {
322
		// TODO: it's really silly to have this function here - it should be
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...
323
		// wherever we initialize the action listeners or we're just wasting cycles
324
		if ( Jetpack::is_development_mode() || Jetpack::is_staging_site() ) {
325
			return false;
326
		}
327
328
		$current_filter = current_filter();
329
		$args           = func_get_args();
330
331
		if ( $current_filter === 'wp_insert_post' && $args[1]->post_type === 'revision' ) {
332
			return;
333
		}
334
335
		if ( in_array( $current_filter, array( 'deleted_option', 'added_option', 'updated_option' ) )
336
		     &&
337
		     ! $this->is_whitelisted_option( $args[0] )
338
		) {
339
			return;
340
		}
341
342
		if ( in_array( $current_filter, array( 'delete_site_option', 'add_site_option', 'update_site_option' ) )
343
		     &&
344
		     ! $this->is_whitelisted_network_option( $args[0] )
345
		) {
346
			return;
347
		}
348
349
		$this->sync_queue->add( array(
350
			$current_filter,
351
			$args
352
		) );
353
	}
354
355
	function send_theme_info() {
356
		global $_wp_theme_features;
357
		do_action( 'jetpack_sync_current_theme_support', $_wp_theme_features );
358
	}
359
360
	function send_wp_version( $update, $meta_data ) {
361
		if ( 'update' === $meta_data['action'] && 'core' === $meta_data['type'] ) {
362
			global $wp_version;
363
			do_action( 'jetpack_sync_wp_version', $wp_version );
364
		}
365
	}
366
367
	function save_term_handler( $term_id, $tt_id, $taxonomy ) {
368
		$term_object = WP_Term::get_instance( $term_id, $taxonomy );
369
		do_action( 'jetapack_sync_save_term', $term_id, $tt_id, $taxonomy, $term_object );
370
	}
371
372
	function do_sync() {
373
		if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
374
			$this->schedule_sync( "+1 minute" );
375
376
			return false;
377
		}
378
379
		$this->maybe_sync_constants();
380
		$this->maybe_sync_callables();
381
382
		$buffer = $this->sync_queue->checkout();
383
384
		if ( ! $buffer ) {
385
			// buffer has no items
386
			return;
387
		}
388
389
		if ( is_wp_error( $buffer ) ) {
390
			error_log( "Error fetching buffer: " . $buffer->get_error_message() );
0 ignored issues
show
Bug introduced by
The method get_error_message() does not seem to exist on object<Jetpack_Sync_Queue_Buffer>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
391
392
			return;
393
		}
394
395
		$data = $this->codec->encode( $buffer->get_items() );
396
397
		/**
398
		 * Fires when data is ready to send to the server.
399
		 * Return false or WP_Error to abort the sync (e.g. if there's an error)
400
		 * The items will be automatically re-sent later
401
		 *
402
		 * @since 4.1
403
		 *
404
		 * @param array $data The action buffer
405
		 */
406
		$result = apply_filters( 'jetpack_sync_client_send_data', $data );
407
408
		if ( ! $result || is_wp_error( $result ) ) {
409
			$this->sync_queue->checkin( $buffer );
410
			// try again in 1 minute
411
			$this->schedule_sync( "+1 minute" );
412
		} else {
413
			$this->sync_queue->close( $buffer );
414
			// check if there are any more events in the buffer
415
			// if so, schedule a cron job to happen soon
416
			if ( $this->sync_queue->has_any_items() ) {
417
				$this->schedule_sync( "+1 minute" );
418
			}
419
		}
420
	}
421
422
423
	private function schedule_sync( $when ) {
424
		wp_schedule_single_event( strtotime( $when ), 'jetpack_sync_actions' );
425
	}
426
427
	function force_sync_constants() {
428
		delete_option( self::$constants_checksum_option_name );
429
		$this->maybe_sync_constants();
430
	}
431
432 View Code Duplication
	private function maybe_sync_constants() {
433
		$constants = $this->get_all_constants();
434
		if ( empty( $constants ) ) {
435
			return;
436
		}
437
		$constants_check_sum = $this->get_check_sum( $constants );
438
		if ( $constants_check_sum !== get_option( self::$constants_checksum_option_name ) ) {
439
			do_action( 'jetpack_sync_current_constants', $constants );
440
			update_option( self::$constants_checksum_option_name, $constants_check_sum );
441
		}
442
	}
443
444
	private function get_all_constants() {
445
		return array_combine(
446
			$this->constants_whitelist,
447
			array_map( array( $this, 'get_constant' ), $this->constants_whitelist )
448
		);
449
	}
450
451
	private function get_constant( $constant ) {
452
		if ( defined( $constant ) ) {
453
			return constant( $constant );
454
		}
455
456
		return null;
457
	}
458
459
	public function force_sync_callables() {
460
		delete_option( self::$functions_checksum_option_name );
461
		$this->maybe_sync_callables();
462
	}
463
464 View Code Duplication
	private function maybe_sync_callables() {
465
		$callables = $this->get_all_callables();
466
		if ( empty( $callables ) ) {
467
			return;
468
		}
469
		$callables_check_sum = $this->get_check_sum( $callables );
470
471
		if ( $callables_check_sum !== get_option( self::$functions_checksum_option_name ) ) {
472
			do_action( 'jetpack_sync_current_callables', $callables );
473
			update_option( self::$functions_checksum_option_name, $callables_check_sum );
474
		}
475
	}
476
477
	private function get_all_callables() {
478
		return array_combine(
479
			array_keys( $this->callable_whitelist ),
480
			array_map( array( $this, 'get_callable' ), array_values( $this->callable_whitelist ) )
481
		);
482
	}
483
484
	private function get_callable( $callable ) {
485
		return call_user_func( $callable );
486
	}
487
488
	private function get_check_sum( $values ) {
489
		return crc32( serialize( $values ) );
490
	}
491
492 View Code Duplication
	function jetpack_sync_core_icon() {
493
		error_log("syncing core icon");
494
		if ( function_exists( 'get_site_icon_url' ) ) {
495
			$url = get_site_icon_url();
496
		} else {
497
			return;
498
		}
499
500
		require_once( JETPACK__PLUGIN_DIR . 'modules/site-icon/site-icon-functions.php' );
501
		// If there's a core icon, maybe update the option.  If not, fall back to Jetpack's.
502
		if ( ! empty( $url ) && $url !== jetpack_site_icon_url() ) {
503
			// This is the option that is synced with dotcom
504
			Jetpack_Options::update_option( 'site_icon_url', $url );
505
		} else if ( empty( $url ) && did_action( 'delete_option_site_icon' ) ) {
506
			Jetpack_Options::delete_option( 'site_icon_url' );
507
		}
508
	}
509
510
	function get_sync_queue() {
511
		return $this->sync_queue;
512
	}
513
514
	function reset_sync_queue() {
515
		$this->sync_queue->reset();
516
	}
517
518
	function set_defaults() {
519
		$this->sync_queue = new Jetpack_Sync_Queue( 'sync', self::$default_send_buffer_size );
520
		$this->set_full_sync_client( new Jetpack_Sync_Full( $this->sync_queue ) );
0 ignored issues
show
Unused Code introduced by
The call to Jetpack_Sync_Full::__construct() has too many arguments starting with $this->sync_queue.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
521
		$this->codec                     = new Jetpack_Sync_Deflate_Codec();
522
		$this->constants_whitelist       = self::$default_constants_whitelist;
523
		$this->options_whitelist         = self::$default_options_whitelist;
524
		$this->callable_whitelist        = self::$default_callable_whitelist;
525
		$this->network_options_whitelist = self::$default_network_options_whitelist;
526
		$this->taxonomy_whitelist        = self::$default_taxonomy_whitelist;
527
		$this->is_multisite              = is_multisite();
528
	}
529
530
	function reset_data() {
531
		delete_option( self::$constants_checksum_option_name );
532
		$this->reset_sync_queue();
533
	}
534
}
535
536
if ( is_multisite() ) {
537
	$client = Jetpack_Sync_Client::getInstance();
538
	$existing_callables = $client->get_callable_whitelist();
539
	$client->set_callable_whitelist( array_merge( $existing_callables, array(
540
		'network_name'                        => array( 'Jetpack', 'network_name' ),
541
		'network_allow_new_registrations'     => array( 'Jetpack', 'network_allow_new_registrations' ),
542
		'network_add_new_users'               => array( 'Jetpack', 'network_add_new_users' ),
543
		'network_site_upload_space'           => array( 'Jetpack', 'network_site_upload_space' ),
544
		'network_upload_file_types'           => array( 'Jetpack', 'network_upload_file_types' ),
545
		'network_enable_administration_menus' => array( 'Jetpack', 'network_enable_administration_menus' ),
546
	) ) );
547
}
548