Completed
Push — master ( d99bf9...491baf )
by Stephen
13:47
created
src/wp-includes/class-wp-customize-widgets.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -193,7 +193,7 @@
 block discarded – undo
193 193
 	 *
194 194
 	 * @param string $name    Post value.
195 195
 	 * @param mixed  $default Default post value.
196
-	 * @return mixed Unslashed post value or default value.
196
+	 * @return string Unslashed post value or default value.
197 197
 	 */
198 198
 	protected function get_post_value( $name, $default = null ) {
199 199
 		if ( ! isset( $_POST[ $name ] ) ) {
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1160,7 +1160,7 @@
 block discarded – undo
1160 1160
 	 *
1161 1161
 	 * @since 3.9.0
1162 1162
 	 * @access public
1163
-     *
1163
+	 *
1164 1164
 	 * @global array $wp_registered_sidebars
1165 1165
 	 * @global array $wp_registered_widgets
1166 1166
 	 */
Please login to merge, or discard this patch.
Spacing   +427 added lines, -427 removed lines patch added patch discarded remove patch
@@ -90,36 +90,36 @@  discard block
 block discarded – undo
90 90
 	 *
91 91
 	 * @param WP_Customize_Manager $manager Customize manager bootstrap instance.
92 92
 	 */
93
-	public function __construct( $manager ) {
93
+	public function __construct($manager) {
94 94
 		$this->manager = $manager;
95 95
 
96 96
 		// See https://github.com/xwp/wp-customize-snapshots/blob/962586659688a5b1fd9ae93618b7ce2d4e7a421c/php/class-customize-snapshot-manager.php#L420-L449
97
-		add_filter( 'customize_dynamic_setting_args',          array( $this, 'filter_customize_dynamic_setting_args' ), 10, 2 );
98
-		add_action( 'widgets_init',                            array( $this, 'register_settings' ), 95 );
99
-		add_action( 'customize_register',                      array( $this, 'schedule_customize_register' ), 1 );
97
+		add_filter('customize_dynamic_setting_args', array($this, 'filter_customize_dynamic_setting_args'), 10, 2);
98
+		add_action('widgets_init', array($this, 'register_settings'), 95);
99
+		add_action('customize_register', array($this, 'schedule_customize_register'), 1);
100 100
 
101 101
 		// Skip remaining hooks when the user can't manage widgets anyway.
102
-		if ( ! current_user_can( 'edit_theme_options' ) ) {
102
+		if ( ! current_user_can('edit_theme_options')) {
103 103
 			return;
104 104
 		}
105 105
 
106
-		add_action( 'wp_loaded',                               array( $this, 'override_sidebars_widgets_for_theme_switch' ) );
107
-		add_action( 'customize_controls_init',                 array( $this, 'customize_controls_init' ) );
108
-		add_action( 'customize_controls_enqueue_scripts',      array( $this, 'enqueue_scripts' ) );
109
-		add_action( 'customize_controls_print_styles',         array( $this, 'print_styles' ) );
110
-		add_action( 'customize_controls_print_scripts',        array( $this, 'print_scripts' ) );
111
-		add_action( 'customize_controls_print_footer_scripts', array( $this, 'print_footer_scripts' ) );
112
-		add_action( 'customize_controls_print_footer_scripts', array( $this, 'output_widget_control_templates' ) );
113
-		add_action( 'customize_preview_init',                  array( $this, 'customize_preview_init' ) );
114
-		add_filter( 'customize_refresh_nonces',                array( $this, 'refresh_nonces' ) );
106
+		add_action('wp_loaded', array($this, 'override_sidebars_widgets_for_theme_switch'));
107
+		add_action('customize_controls_init', array($this, 'customize_controls_init'));
108
+		add_action('customize_controls_enqueue_scripts', array($this, 'enqueue_scripts'));
109
+		add_action('customize_controls_print_styles', array($this, 'print_styles'));
110
+		add_action('customize_controls_print_scripts', array($this, 'print_scripts'));
111
+		add_action('customize_controls_print_footer_scripts', array($this, 'print_footer_scripts'));
112
+		add_action('customize_controls_print_footer_scripts', array($this, 'output_widget_control_templates'));
113
+		add_action('customize_preview_init', array($this, 'customize_preview_init'));
114
+		add_filter('customize_refresh_nonces', array($this, 'refresh_nonces'));
115 115
 
116
-		add_action( 'dynamic_sidebar',                         array( $this, 'tally_rendered_widgets' ) );
117
-		add_filter( 'is_active_sidebar',                       array( $this, 'tally_sidebars_via_is_active_sidebar_calls' ), 10, 2 );
118
-		add_filter( 'dynamic_sidebar_has_widgets',             array( $this, 'tally_sidebars_via_dynamic_sidebar_calls' ), 10, 2 );
116
+		add_action('dynamic_sidebar', array($this, 'tally_rendered_widgets'));
117
+		add_filter('is_active_sidebar', array($this, 'tally_sidebars_via_is_active_sidebar_calls'), 10, 2);
118
+		add_filter('dynamic_sidebar_has_widgets', array($this, 'tally_sidebars_via_dynamic_sidebar_calls'), 10, 2);
119 119
 
120 120
 		// Selective Refresh.
121
-		add_filter( 'customize_dynamic_partial_args',          array( $this, 'customize_dynamic_partial_args' ), 10, 2 );
122
-		add_action( 'customize_preview_init',                  array( $this, 'selective_refresh_init' ) );
121
+		add_filter('customize_dynamic_partial_args', array($this, 'customize_dynamic_partial_args'), 10, 2);
122
+		add_action('customize_preview_init', array($this, 'selective_refresh_init'));
123 123
 	}
124 124
 
125 125
 	/**
@@ -136,13 +136,13 @@  discard block
 block discarded – undo
136 136
 	 */
137 137
 	public function get_selective_refreshable_widgets() {
138 138
 		global $wp_widget_factory;
139
-		if ( ! current_theme_supports( 'customize-selective-refresh-widgets' ) ) {
139
+		if ( ! current_theme_supports('customize-selective-refresh-widgets')) {
140 140
 			return array();
141 141
 		}
142
-		if ( ! isset( $this->selective_refreshable_widgets ) ) {
142
+		if ( ! isset($this->selective_refreshable_widgets)) {
143 143
 			$this->selective_refreshable_widgets = array();
144
-			foreach ( $wp_widget_factory->widgets as $wp_widget ) {
145
-				$this->selective_refreshable_widgets[ $wp_widget->id_base ] = ! empty( $wp_widget->widget_options['customize_selective_refresh'] );
144
+			foreach ($wp_widget_factory->widgets as $wp_widget) {
145
+				$this->selective_refreshable_widgets[$wp_widget->id_base] = ! empty($wp_widget->widget_options['customize_selective_refresh']);
146 146
 			}
147 147
 		}
148 148
 		return $this->selective_refreshable_widgets;
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
 	 * @param string $id_base Widget ID Base.
158 158
 	 * @return bool Whether the widget can be selective refreshed.
159 159
 	 */
160
-	public function is_widget_selective_refreshable( $id_base ) {
160
+	public function is_widget_selective_refreshable($id_base) {
161 161
 		$selective_refreshable_widgets = $this->get_selective_refreshable_widgets();
162
-		return ! empty( $selective_refreshable_widgets[ $id_base ] );
162
+		return ! empty($selective_refreshable_widgets[$id_base]);
163 163
 	}
164 164
 
165 165
 	/**
@@ -173,14 +173,14 @@  discard block
 block discarded – undo
173 173
 	 * @param string $setting_id Setting ID.
174 174
 	 * @return string|void Setting type.
175 175
 	 */
176
-	protected function get_setting_type( $setting_id ) {
176
+	protected function get_setting_type($setting_id) {
177 177
 		static $cache = array();
178
-		if ( isset( $cache[ $setting_id ] ) ) {
179
-			return $cache[ $setting_id ];
178
+		if (isset($cache[$setting_id])) {
179
+			return $cache[$setting_id];
180 180
 		}
181
-		foreach ( $this->setting_id_patterns as $type => $pattern ) {
182
-			if ( preg_match( $pattern, $setting_id ) ) {
183
-				$cache[ $setting_id ] = $type;
181
+		foreach ($this->setting_id_patterns as $type => $pattern) {
182
+			if (preg_match($pattern, $setting_id)) {
183
+				$cache[$setting_id] = $type;
184 184
 				return $type;
185 185
 			}
186 186
 		}
@@ -195,25 +195,25 @@  discard block
 block discarded – undo
195 195
 	 */
196 196
 	public function register_settings() {
197 197
 		$widget_setting_ids = array();
198
-		$incoming_setting_ids = array_keys( $this->manager->unsanitized_post_values() );
199
-		foreach ( $incoming_setting_ids as $setting_id ) {
200
-			if ( ! is_null( $this->get_setting_type( $setting_id ) ) ) {
198
+		$incoming_setting_ids = array_keys($this->manager->unsanitized_post_values());
199
+		foreach ($incoming_setting_ids as $setting_id) {
200
+			if ( ! is_null($this->get_setting_type($setting_id))) {
201 201
 				$widget_setting_ids[] = $setting_id;
202 202
 			}
203 203
 		}
204
-		if ( $this->manager->doing_ajax( 'update-widget' ) && isset( $_REQUEST['widget-id'] ) ) {
205
-			$widget_setting_ids[] = $this->get_setting_id( wp_unslash( $_REQUEST['widget-id'] ) );
204
+		if ($this->manager->doing_ajax('update-widget') && isset($_REQUEST['widget-id'])) {
205
+			$widget_setting_ids[] = $this->get_setting_id(wp_unslash($_REQUEST['widget-id']));
206 206
 		}
207 207
 
208
-		$settings = $this->manager->add_dynamic_settings( array_unique( $widget_setting_ids ) );
208
+		$settings = $this->manager->add_dynamic_settings(array_unique($widget_setting_ids));
209 209
 
210 210
 		/*
211 211
 		 * Preview settings right away so that widgets and sidebars will get registered properly.
212 212
 		 * But don't do this if a customize_save because this will cause WP to think there is nothing
213 213
 		 * changed that needs to be saved.
214 214
 		 */
215
-		if ( ! $this->manager->doing_ajax( 'customize_save' ) ) {
216
-			foreach ( $settings as $setting ) {
215
+		if ( ! $this->manager->doing_ajax('customize_save')) {
216
+			foreach ($settings as $setting) {
217 217
 				$setting->preview();
218 218
 			}
219 219
 		}
@@ -229,9 +229,9 @@  discard block
 block discarded – undo
229 229
 	 * @param string      $setting_id ID for dynamic setting, usually coming from `$_POST['customized']`.
230 230
 	 * @return false|array Setting arguments, false otherwise.
231 231
 	 */
232
-	public function filter_customize_dynamic_setting_args( $args, $setting_id ) {
233
-		if ( $this->get_setting_type( $setting_id ) ) {
234
-			$args = $this->get_setting_args( $setting_id );
232
+	public function filter_customize_dynamic_setting_args($args, $setting_id) {
233
+		if ($this->get_setting_type($setting_id)) {
234
+			$args = $this->get_setting_args($setting_id);
235 235
 		}
236 236
 		return $args;
237 237
 	}
@@ -246,12 +246,12 @@  discard block
 block discarded – undo
246 246
 	 * @param mixed  $default Default post value.
247 247
 	 * @return mixed Unslashed post value or default value.
248 248
 	 */
249
-	protected function get_post_value( $name, $default = null ) {
250
-		if ( ! isset( $_POST[ $name ] ) ) {
249
+	protected function get_post_value($name, $default = null) {
250
+		if ( ! isset($_POST[$name])) {
251 251
 			return $default;
252 252
 		}
253 253
 
254
-		return wp_unslash( $_POST[ $name ] );
254
+		return wp_unslash($_POST[$name]);
255 255
 	}
256 256
 
257 257
 	/**
@@ -272,20 +272,20 @@  discard block
 block discarded – undo
272 272
 	public function override_sidebars_widgets_for_theme_switch() {
273 273
 		global $sidebars_widgets;
274 274
 
275
-		if ( $this->manager->doing_ajax() || $this->manager->is_theme_active() ) {
275
+		if ($this->manager->doing_ajax() || $this->manager->is_theme_active()) {
276 276
 			return;
277 277
 		}
278 278
 
279 279
 		$this->old_sidebars_widgets = wp_get_sidebars_widgets();
280
-		add_filter( 'customize_value_old_sidebars_widgets_data', array( $this, 'filter_customize_value_old_sidebars_widgets_data' ) );
281
-		$this->manager->set_post_value( 'old_sidebars_widgets_data', $this->old_sidebars_widgets ); // Override any value cached in changeset.
280
+		add_filter('customize_value_old_sidebars_widgets_data', array($this, 'filter_customize_value_old_sidebars_widgets_data'));
281
+		$this->manager->set_post_value('old_sidebars_widgets_data', $this->old_sidebars_widgets); // Override any value cached in changeset.
282 282
 
283 283
 		// retrieve_widgets() looks at the global $sidebars_widgets
284 284
 		$sidebars_widgets = $this->old_sidebars_widgets;
285
-		$sidebars_widgets = retrieve_widgets( 'customize' );
286
-		add_filter( 'option_sidebars_widgets', array( $this, 'filter_option_sidebars_widgets_for_theme_switch' ), 1 );
285
+		$sidebars_widgets = retrieve_widgets('customize');
286
+		add_filter('option_sidebars_widgets', array($this, 'filter_option_sidebars_widgets_for_theme_switch'), 1);
287 287
 		// reset global cache var used by wp_get_sidebars_widgets()
288
-		unset( $GLOBALS['_wp_sidebars_widgets'] );
288
+		unset($GLOBALS['_wp_sidebars_widgets']);
289 289
 	}
290 290
 
291 291
 	/**
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 	 * @param array $old_sidebars_widgets
305 305
 	 * @return array
306 306
 	 */
307
-	public function filter_customize_value_old_sidebars_widgets_data( $old_sidebars_widgets ) {
307
+	public function filter_customize_value_old_sidebars_widgets_data($old_sidebars_widgets) {
308 308
 		return $this->old_sidebars_widgets;
309 309
 	}
310 310
 
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 	 * @param array $sidebars_widgets
325 325
 	 * @return array
326 326
 	 */
327
-	public function filter_option_sidebars_widgets_for_theme_switch( $sidebars_widgets ) {
327
+	public function filter_option_sidebars_widgets_for_theme_switch($sidebars_widgets) {
328 328
 		$sidebars_widgets = $GLOBALS['sidebars_widgets'];
329 329
 		$sidebars_widgets['array_version'] = 3;
330 330
 		return $sidebars_widgets;
@@ -340,13 +340,13 @@  discard block
 block discarded – undo
340 340
 	 */
341 341
 	public function customize_controls_init() {
342 342
 		/** This action is documented in wp-admin/includes/ajax-actions.php */
343
-		do_action( 'load-widgets.php' );
343
+		do_action('load-widgets.php');
344 344
 
345 345
 		/** This action is documented in wp-admin/includes/ajax-actions.php */
346
-		do_action( 'widgets.php' );
346
+		do_action('widgets.php');
347 347
 
348 348
 		/** This action is documented in wp-admin/widgets.php */
349
-		do_action( 'sidebar_admin_setup' );
349
+		do_action('sidebar_admin_setup');
350 350
 	}
351 351
 
352 352
 	/**
@@ -359,10 +359,10 @@  discard block
 block discarded – undo
359 359
 	 * @access public
360 360
 	 */
361 361
 	public function schedule_customize_register() {
362
-		if ( is_admin() ) {
362
+		if (is_admin()) {
363 363
 			$this->customize_register();
364 364
 		} else {
365
-			add_action( 'wp', array( $this, 'customize_register' ) );
365
+			add_action('wp', array($this, 'customize_register'));
366 366
 		}
367 367
 	}
368 368
 
@@ -379,11 +379,11 @@  discard block
 block discarded – undo
379 379
 	public function customize_register() {
380 380
 		global $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_sidebars;
381 381
 
382
-		add_filter( 'sidebars_widgets', array( $this, 'preview_sidebars_widgets' ), 1 );
382
+		add_filter('sidebars_widgets', array($this, 'preview_sidebars_widgets'), 1);
383 383
 
384 384
 		$sidebars_widgets = array_merge(
385
-			array( 'wp_inactive_widgets' => array() ),
386
-			array_fill_keys( array_keys( $wp_registered_sidebars ), array() ),
385
+			array('wp_inactive_widgets' => array()),
386
+			array_fill_keys(array_keys($wp_registered_sidebars), array()),
387 387
 			wp_get_sidebars_widgets()
388 388
 		);
389 389
 
@@ -394,11 +394,11 @@  discard block
 block discarded – undo
394 394
 		 * inactive, and orphaned since a widget may get suppressed from a sidebar
395 395
 		 * via a plugin (like Widget Visibility).
396 396
 		 */
397
-		foreach ( array_keys( $wp_registered_widgets ) as $widget_id ) {
398
-			$setting_id   = $this->get_setting_id( $widget_id );
399
-			$setting_args = $this->get_setting_args( $setting_id );
400
-			if ( ! $this->manager->get_setting( $setting_id ) ) {
401
-				$this->manager->add_setting( $setting_id, $setting_args );
397
+		foreach (array_keys($wp_registered_widgets) as $widget_id) {
398
+			$setting_id   = $this->get_setting_id($widget_id);
399
+			$setting_args = $this->get_setting_args($setting_id);
400
+			if ( ! $this->manager->get_setting($setting_id)) {
401
+				$this->manager->add_setting($setting_id, $setting_args);
402 402
 			}
403 403
 			$new_setting_ids[] = $setting_id;
404 404
 		}
@@ -407,53 +407,53 @@  discard block
 block discarded – undo
407 407
 		 * Add a setting which will be supplied for the theme's sidebars_widgets
408 408
 		 * theme_mod when the theme is switched.
409 409
 		 */
410
-		if ( ! $this->manager->is_theme_active() ) {
410
+		if ( ! $this->manager->is_theme_active()) {
411 411
 			$setting_id = 'old_sidebars_widgets_data';
412
-			$setting_args = $this->get_setting_args( $setting_id, array(
412
+			$setting_args = $this->get_setting_args($setting_id, array(
413 413
 				'type' => 'global_variable',
414 414
 				'dirty' => true,
415
-			) );
416
-			$this->manager->add_setting( $setting_id, $setting_args );
415
+			));
416
+			$this->manager->add_setting($setting_id, $setting_args);
417 417
 		}
418 418
 
419
-		$this->manager->add_panel( 'widgets', array(
419
+		$this->manager->add_panel('widgets', array(
420 420
 			'type'            => 'widgets',
421
-			'title'           => __( 'Widgets' ),
422
-			'description'     => __( 'Widgets are independent sections of content that can be placed into widgetized areas provided by your theme (commonly called sidebars).' ),
421
+			'title'           => __('Widgets'),
422
+			'description'     => __('Widgets are independent sections of content that can be placed into widgetized areas provided by your theme (commonly called sidebars).'),
423 423
 			'priority'        => 110,
424
-			'active_callback' => array( $this, 'is_panel_active' ),
424
+			'active_callback' => array($this, 'is_panel_active'),
425 425
 			'auto_expand_sole_section' => true,
426
-		) );
426
+		));
427 427
 
428
-		foreach ( $sidebars_widgets as $sidebar_id => $sidebar_widget_ids ) {
429
-			if ( empty( $sidebar_widget_ids ) ) {
428
+		foreach ($sidebars_widgets as $sidebar_id => $sidebar_widget_ids) {
429
+			if (empty($sidebar_widget_ids)) {
430 430
 				$sidebar_widget_ids = array();
431 431
 			}
432 432
 
433
-			$is_registered_sidebar = is_registered_sidebar( $sidebar_id );
434
-			$is_inactive_widgets   = ( 'wp_inactive_widgets' === $sidebar_id );
435
-			$is_active_sidebar     = ( $is_registered_sidebar && ! $is_inactive_widgets );
433
+			$is_registered_sidebar = is_registered_sidebar($sidebar_id);
434
+			$is_inactive_widgets   = ('wp_inactive_widgets' === $sidebar_id);
435
+			$is_active_sidebar     = ($is_registered_sidebar && ! $is_inactive_widgets);
436 436
 
437 437
 			// Add setting for managing the sidebar's widgets.
438
-			if ( $is_registered_sidebar || $is_inactive_widgets ) {
439
-				$setting_id   = sprintf( 'sidebars_widgets[%s]', $sidebar_id );
440
-				$setting_args = $this->get_setting_args( $setting_id );
441
-				if ( ! $this->manager->get_setting( $setting_id ) ) {
442
-					if ( ! $this->manager->is_theme_active() ) {
438
+			if ($is_registered_sidebar || $is_inactive_widgets) {
439
+				$setting_id   = sprintf('sidebars_widgets[%s]', $sidebar_id);
440
+				$setting_args = $this->get_setting_args($setting_id);
441
+				if ( ! $this->manager->get_setting($setting_id)) {
442
+					if ( ! $this->manager->is_theme_active()) {
443 443
 						$setting_args['dirty'] = true;
444 444
 					}
445
-					$this->manager->add_setting( $setting_id, $setting_args );
445
+					$this->manager->add_setting($setting_id, $setting_args);
446 446
 				}
447 447
 				$new_setting_ids[] = $setting_id;
448 448
 
449 449
 				// Add section to contain controls.
450
-				$section_id = sprintf( 'sidebar-widgets-%s', $sidebar_id );
451
-				if ( $is_active_sidebar ) {
450
+				$section_id = sprintf('sidebar-widgets-%s', $sidebar_id);
451
+				if ($is_active_sidebar) {
452 452
 
453 453
 					$section_args = array(
454
-						'title' => $wp_registered_sidebars[ $sidebar_id ]['name'],
455
-						'description' => $wp_registered_sidebars[ $sidebar_id ]['description'],
456
-						'priority' => array_search( $sidebar_id, array_keys( $wp_registered_sidebars ) ),
454
+						'title' => $wp_registered_sidebars[$sidebar_id]['name'],
455
+						'description' => $wp_registered_sidebars[$sidebar_id]['description'],
456
+						'priority' => array_search($sidebar_id, array_keys($wp_registered_sidebars)),
457 457
 						'panel' => 'widgets',
458 458
 						'sidebar_id' => $sidebar_id,
459 459
 					);
@@ -467,35 +467,35 @@  discard block
 block discarded – undo
467 467
 					 * @param string     $section_id   Customizer section ID.
468 468
 					 * @param int|string $sidebar_id   Sidebar ID.
469 469
 					 */
470
-					$section_args = apply_filters( 'customizer_widgets_section_args', $section_args, $section_id, $sidebar_id );
470
+					$section_args = apply_filters('customizer_widgets_section_args', $section_args, $section_id, $sidebar_id);
471 471
 
472
-					$section = new WP_Customize_Sidebar_Section( $this->manager, $section_id, $section_args );
473
-					$this->manager->add_section( $section );
472
+					$section = new WP_Customize_Sidebar_Section($this->manager, $section_id, $section_args);
473
+					$this->manager->add_section($section);
474 474
 
475
-					$control = new WP_Widget_Area_Customize_Control( $this->manager, $setting_id, array(
475
+					$control = new WP_Widget_Area_Customize_Control($this->manager, $setting_id, array(
476 476
 						'section'    => $section_id,
477 477
 						'sidebar_id' => $sidebar_id,
478
-						'priority'   => count( $sidebar_widget_ids ), // place 'Add Widget' and 'Reorder' buttons at end.
479
-					) );
478
+						'priority'   => count($sidebar_widget_ids), // place 'Add Widget' and 'Reorder' buttons at end.
479
+					));
480 480
 					$new_setting_ids[] = $setting_id;
481 481
 
482
-					$this->manager->add_control( $control );
482
+					$this->manager->add_control($control);
483 483
 				}
484 484
 			}
485 485
 
486 486
 			// Add a control for each active widget (located in a sidebar).
487
-			foreach ( $sidebar_widget_ids as $i => $widget_id ) {
487
+			foreach ($sidebar_widget_ids as $i => $widget_id) {
488 488
 
489 489
 				// Skip widgets that may have gone away due to a plugin being deactivated.
490
-				if ( ! $is_active_sidebar || ! isset( $wp_registered_widgets[$widget_id] ) ) {
490
+				if ( ! $is_active_sidebar || ! isset($wp_registered_widgets[$widget_id])) {
491 491
 					continue;
492 492
 				}
493 493
 
494 494
 				$registered_widget = $wp_registered_widgets[$widget_id];
495
-				$setting_id        = $this->get_setting_id( $widget_id );
495
+				$setting_id        = $this->get_setting_id($widget_id);
496 496
 				$id_base           = $wp_registered_widget_controls[$widget_id]['id_base'];
497 497
 
498
-				$control = new WP_Widget_Form_Customize_Control( $this->manager, $setting_id, array(
498
+				$control = new WP_Widget_Form_Customize_Control($this->manager, $setting_id, array(
499 499
 					'label'          => $registered_widget['name'],
500 500
 					'section'        => $section_id,
501 501
 					'sidebar_id'     => $sidebar_id,
@@ -504,15 +504,15 @@  discard block
 block discarded – undo
504 504
 					'priority'       => $i,
505 505
 					'width'          => $wp_registered_widget_controls[$widget_id]['width'],
506 506
 					'height'         => $wp_registered_widget_controls[$widget_id]['height'],
507
-					'is_wide'        => $this->is_wide_widget( $widget_id ),
508
-				) );
509
-				$this->manager->add_control( $control );
507
+					'is_wide'        => $this->is_wide_widget($widget_id),
508
+				));
509
+				$this->manager->add_control($control);
510 510
 			}
511 511
 		}
512 512
 
513
-		if ( ! $this->manager->doing_ajax( 'customize_save' ) ) {
514
-			foreach ( $new_setting_ids as $new_setting_id ) {
515
-				$this->manager->get_setting( $new_setting_id )->preview();
513
+		if ( ! $this->manager->doing_ajax('customize_save')) {
514
+			foreach ($new_setting_ids as $new_setting_id) {
515
+				$this->manager->get_setting($new_setting_id)->preview();
516 516
 			}
517 517
 		}
518 518
 	}
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
 	 */
531 531
 	public function is_panel_active() {
532 532
 		global $wp_registered_sidebars;
533
-		return ! empty( $wp_registered_sidebars );
533
+		return ! empty($wp_registered_sidebars);
534 534
 	}
535 535
 
536 536
 	/**
@@ -542,12 +542,12 @@  discard block
 block discarded – undo
542 542
 	 * @param string $widget_id Widget ID.
543 543
 	 * @return string Maybe-parsed widget ID.
544 544
 	 */
545
-	public function get_setting_id( $widget_id ) {
546
-		$parsed_widget_id = $this->parse_widget_id( $widget_id );
547
-		$setting_id       = sprintf( 'widget_%s', $parsed_widget_id['id_base'] );
545
+	public function get_setting_id($widget_id) {
546
+		$parsed_widget_id = $this->parse_widget_id($widget_id);
547
+		$setting_id       = sprintf('widget_%s', $parsed_widget_id['id_base']);
548 548
 
549
-		if ( ! is_null( $parsed_widget_id['number'] ) ) {
550
-			$setting_id .= sprintf( '[%d]', $parsed_widget_id['number'] );
549
+		if ( ! is_null($parsed_widget_id['number'])) {
550
+			$setting_id .= sprintf('[%d]', $parsed_widget_id['number']);
551 551
 		}
552 552
 		return $setting_id;
553 553
 	}
@@ -570,13 +570,13 @@  discard block
 block discarded – undo
570 570
 	 * @param string $widget_id Widget ID.
571 571
 	 * @return bool Whether or not the widget is a "wide" widget.
572 572
 	 */
573
-	public function is_wide_widget( $widget_id ) {
573
+	public function is_wide_widget($widget_id) {
574 574
 		global $wp_registered_widget_controls;
575 575
 
576
-		$parsed_widget_id = $this->parse_widget_id( $widget_id );
576
+		$parsed_widget_id = $this->parse_widget_id($widget_id);
577 577
 		$width            = $wp_registered_widget_controls[$widget_id]['width'];
578
-		$is_core          = in_array( $parsed_widget_id['id_base'], $this->core_widget_id_bases );
579
-		$is_wide          = ( $width > 250 && ! $is_core );
578
+		$is_core          = in_array($parsed_widget_id['id_base'], $this->core_widget_id_bases);
579
+		$is_wide          = ($width > 250 && ! $is_core);
580 580
 
581 581
 		/**
582 582
 		 * Filters whether the given widget is considered "wide".
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 		 * @param bool   $is_wide   Whether the widget is wide, Default false.
587 587
 		 * @param string $widget_id Widget ID.
588 588
 		 */
589
-		return apply_filters( 'is_wide_widget_in_customizer', $is_wide, $widget_id );
589
+		return apply_filters('is_wide_widget_in_customizer', $is_wide, $widget_id);
590 590
 	}
591 591
 
592 592
 	/**
@@ -598,15 +598,15 @@  discard block
 block discarded – undo
598 598
 	 * @param string $widget_id Widget ID.
599 599
 	 * @return array Array containing a widget's id_base and number components.
600 600
 	 */
601
-	public function parse_widget_id( $widget_id ) {
601
+	public function parse_widget_id($widget_id) {
602 602
 		$parsed = array(
603 603
 			'number' => null,
604 604
 			'id_base' => null,
605 605
 		);
606 606
 
607
-		if ( preg_match( '/^(.+)-(\d+)$/', $widget_id, $matches ) ) {
607
+		if (preg_match('/^(.+)-(\d+)$/', $widget_id, $matches)) {
608 608
 			$parsed['id_base'] = $matches[1];
609
-			$parsed['number']  = intval( $matches[2] );
609
+			$parsed['number']  = intval($matches[2]);
610 610
 		} else {
611 611
 			// likely an old single widget
612 612
 			$parsed['id_base'] = $widget_id;
@@ -624,15 +624,15 @@  discard block
 block discarded – undo
624 624
 	 * @return WP_Error|array Array containing a widget's id_base and number components,
625 625
 	 *                        or a WP_Error object.
626 626
 	 */
627
-	public function parse_widget_setting_id( $setting_id ) {
628
-		if ( ! preg_match( '/^(widget_(.+?))(?:\[(\d+)\])?$/', $setting_id, $matches ) ) {
629
-			return new WP_Error( 'widget_setting_invalid_id' );
627
+	public function parse_widget_setting_id($setting_id) {
628
+		if ( ! preg_match('/^(widget_(.+?))(?:\[(\d+)\])?$/', $setting_id, $matches)) {
629
+			return new WP_Error('widget_setting_invalid_id');
630 630
 		}
631 631
 
632 632
 		$id_base = $matches[2];
633
-		$number  = isset( $matches[3] ) ? intval( $matches[3] ) : null;
633
+		$number  = isset($matches[3]) ? intval($matches[3]) : null;
634 634
 
635
-		return compact( 'id_base', 'number' );
635
+		return compact('id_base', 'number');
636 636
 	}
637 637
 
638 638
 	/**
@@ -644,10 +644,10 @@  discard block
 block discarded – undo
644 644
 	 */
645 645
 	public function print_styles() {
646 646
 		/** This action is documented in wp-admin/admin-header.php */
647
-		do_action( 'admin_print_styles-widgets.php' );
647
+		do_action('admin_print_styles-widgets.php');
648 648
 
649 649
 		/** This action is documented in wp-admin/admin-header.php */
650
-		do_action( 'admin_print_styles' );
650
+		do_action('admin_print_styles');
651 651
 	}
652 652
 
653 653
 	/**
@@ -659,10 +659,10 @@  discard block
 block discarded – undo
659 659
 	 */
660 660
 	public function print_scripts() {
661 661
 		/** This action is documented in wp-admin/admin-header.php */
662
-		do_action( 'admin_print_scripts-widgets.php' );
662
+		do_action('admin_print_scripts-widgets.php');
663 663
 
664 664
 		/** This action is documented in wp-admin/admin-header.php */
665
-		do_action( 'admin_print_scripts' );
665
+		do_action('admin_print_scripts');
666 666
 	}
667 667
 
668 668
 	/**
@@ -678,11 +678,11 @@  discard block
 block discarded – undo
678 678
 	public function enqueue_scripts() {
679 679
 		global $wp_scripts, $wp_registered_sidebars, $wp_registered_widgets;
680 680
 
681
-		wp_enqueue_style( 'customize-widgets' );
682
-		wp_enqueue_script( 'customize-widgets' );
681
+		wp_enqueue_style('customize-widgets');
682
+		wp_enqueue_script('customize-widgets');
683 683
 
684 684
 		/** This action is documented in wp-admin/admin-header.php */
685
-		do_action( 'admin_enqueue_scripts', 'widgets.php' );
685
+		do_action('admin_enqueue_scripts', 'widgets.php');
686 686
 
687 687
 		/*
688 688
 		 * Export available widgets with control_tpl removed from model
@@ -690,23 +690,23 @@  discard block
 block discarded – undo
690 690
 		 */
691 691
 		$available_widgets = array();
692 692
 
693
-		foreach ( $this->get_available_widgets() as $available_widget ) {
694
-			unset( $available_widget['control_tpl'] );
693
+		foreach ($this->get_available_widgets() as $available_widget) {
694
+			unset($available_widget['control_tpl']);
695 695
 			$available_widgets[] = $available_widget;
696 696
 		}
697 697
 
698 698
 		$widget_reorder_nav_tpl = sprintf(
699 699
 			'<div class="widget-reorder-nav"><span class="move-widget" tabindex="0">%1$s</span><span class="move-widget-down" tabindex="0">%2$s</span><span class="move-widget-up" tabindex="0">%3$s</span></div>',
700
-			__( 'Move to another area&hellip;' ),
701
-			__( 'Move down' ),
702
-			__( 'Move up' )
700
+			__('Move to another area&hellip;'),
701
+			__('Move down'),
702
+			__('Move up')
703 703
 		);
704 704
 
705 705
 		$move_widget_area_tpl = str_replace(
706
-			array( '{description}', '{btn}' ),
706
+			array('{description}', '{btn}'),
707 707
 			array(
708
-				__( 'Select an area to move this widget into:' ),
709
-				_x( 'Move', 'Move widget' ),
708
+				__('Select an area to move this widget into:'),
709
+				_x('Move', 'Move widget'),
710 710
 			),
711 711
 			'<div class="move-widget-area">
712 712
 				<p class="description">{description}</p>
@@ -728,61 +728,61 @@  discard block
 block discarded – undo
728 728
 		$some_non_rendered_areas_messages = array();
729 729
 		$some_non_rendered_areas_messages[1] = html_entity_decode(
730 730
 			/* translators: placeholder is the number of other widget areas registered but not rendered */
731
-			__( 'Your theme has 1 other widget area, but this particular page doesn&#8217;t display it.' ),
731
+			__('Your theme has 1 other widget area, but this particular page doesn&#8217;t display it.'),
732 732
 			ENT_QUOTES,
733
-			get_bloginfo( 'charset' )
733
+			get_bloginfo('charset')
734 734
 		);
735
-		$registered_sidebar_count = count( $wp_registered_sidebars );
736
-		for ( $non_rendered_count = 2; $non_rendered_count < $registered_sidebar_count; $non_rendered_count++ ) {
737
-			$some_non_rendered_areas_messages[ $non_rendered_count ] = html_entity_decode( sprintf(
735
+		$registered_sidebar_count = count($wp_registered_sidebars);
736
+		for ($non_rendered_count = 2; $non_rendered_count < $registered_sidebar_count; $non_rendered_count++) {
737
+			$some_non_rendered_areas_messages[$non_rendered_count] = html_entity_decode(sprintf(
738 738
 				/* translators: placeholder is the number of other widget areas registered but not rendered */
739 739
 				_n(
740 740
 					'Your theme has %s other widget area, but this particular page doesn&#8217;t display it.',
741 741
 					'Your theme has %s other widget areas, but this particular page doesn&#8217;t display them.',
742 742
 					$non_rendered_count
743 743
 				),
744
-				number_format_i18n( $non_rendered_count )
745
-			), ENT_QUOTES, get_bloginfo( 'charset' ) );
744
+				number_format_i18n($non_rendered_count)
745
+			), ENT_QUOTES, get_bloginfo('charset'));
746 746
 		}
747 747
 
748
-		if ( 1 === $registered_sidebar_count ) {
749
-			$no_areas_shown_message = html_entity_decode( sprintf(
748
+		if (1 === $registered_sidebar_count) {
749
+			$no_areas_shown_message = html_entity_decode(sprintf(
750 750
 				/* translators: placeholder is the total number of widget areas registered */
751
-				__( 'Your theme has 1 widget area, but this particular page doesn&#8217;t display it.' )
752
-			), ENT_QUOTES, get_bloginfo( 'charset' ) );
751
+				__('Your theme has 1 widget area, but this particular page doesn&#8217;t display it.')
752
+			), ENT_QUOTES, get_bloginfo('charset'));
753 753
 		} else {
754
-			$no_areas_shown_message = html_entity_decode( sprintf(
754
+			$no_areas_shown_message = html_entity_decode(sprintf(
755 755
 				/* translators: placeholder is the total number of widget areas registered */
756 756
 				_n(
757 757
 					'Your theme has %s widget area, but this particular page doesn&#8217;t display it.',
758 758
 					'Your theme has %s widget areas, but this particular page doesn&#8217;t display them.',
759 759
 					$registered_sidebar_count
760 760
 				),
761
-				number_format_i18n( $registered_sidebar_count )
762
-			), ENT_QUOTES, get_bloginfo( 'charset' ) );
761
+				number_format_i18n($registered_sidebar_count)
762
+			), ENT_QUOTES, get_bloginfo('charset'));
763 763
 		}
764 764
 
765 765
 		$settings = array(
766
-			'registeredSidebars'   => array_values( $wp_registered_sidebars ),
766
+			'registeredSidebars'   => array_values($wp_registered_sidebars),
767 767
 			'registeredWidgets'    => $wp_registered_widgets,
768 768
 			'availableWidgets'     => $available_widgets, // @todo Merge this with registered_widgets
769 769
 			'l10n' => array(
770
-				'saveBtnLabel'     => __( 'Apply' ),
771
-				'saveBtnTooltip'   => __( 'Save and preview changes before publishing them.' ),
772
-				'removeBtnLabel'   => __( 'Remove' ),
773
-				'removeBtnTooltip' => __( 'Trash widget by moving it to the inactive widgets sidebar.' ),
774
-				'error'            => __( 'An error has occurred. Please reload the page and try again.' ),
775
-				'widgetMovedUp'    => __( 'Widget moved up' ),
776
-				'widgetMovedDown'  => __( 'Widget moved down' ),
777
-				'navigatePreview'  => __( 'You can navigate to other pages on your site while using the Customizer to view and edit the widgets displayed on those pages.' ),
770
+				'saveBtnLabel'     => __('Apply'),
771
+				'saveBtnTooltip'   => __('Save and preview changes before publishing them.'),
772
+				'removeBtnLabel'   => __('Remove'),
773
+				'removeBtnTooltip' => __('Trash widget by moving it to the inactive widgets sidebar.'),
774
+				'error'            => __('An error has occurred. Please reload the page and try again.'),
775
+				'widgetMovedUp'    => __('Widget moved up'),
776
+				'widgetMovedDown'  => __('Widget moved down'),
777
+				'navigatePreview'  => __('You can navigate to other pages on your site while using the Customizer to view and edit the widgets displayed on those pages.'),
778 778
 				'someAreasShown'   => $some_non_rendered_areas_messages,
779 779
 				'noAreasShown'     => $no_areas_shown_message,
780
-				'reorderModeOn'    => __( 'Reorder mode enabled' ),
781
-				'reorderModeOff'   => __( 'Reorder mode closed' ),
782
-				'reorderLabelOn'   => esc_attr__( 'Reorder widgets' ),
780
+				'reorderModeOn'    => __('Reorder mode enabled'),
781
+				'reorderModeOff'   => __('Reorder mode closed'),
782
+				'reorderLabelOn'   => esc_attr__('Reorder widgets'),
783 783
 				/* translators: placeholder is the count for the number of widgets found */
784
-				'widgetsFound'     => __( 'Number of widgets found: %d' ),
785
-				'noWidgetsFound'   => __( 'No widgets found.' ),
784
+				'widgetsFound'     => __('Number of widgets found: %d'),
785
+				'noWidgetsFound'   => __('No widgets found.'),
786 786
 			),
787 787
 			'tpl' => array(
788 788
 				'widgetReorderNav' => $widget_reorder_nav_tpl,
@@ -791,14 +791,14 @@  discard block
 block discarded – undo
791 791
 			'selectiveRefreshableWidgets' => $this->get_selective_refreshable_widgets(),
792 792
 		);
793 793
 
794
-		foreach ( $settings['registeredWidgets'] as &$registered_widget ) {
795
-			unset( $registered_widget['callback'] ); // may not be JSON-serializeable
794
+		foreach ($settings['registeredWidgets'] as &$registered_widget) {
795
+			unset($registered_widget['callback']); // may not be JSON-serializeable
796 796
 		}
797 797
 
798 798
 		$wp_scripts->add_data(
799 799
 			'customize-widgets',
800 800
 			'data',
801
-			sprintf( 'var _wpCustomizeWidgetsSettings = %s;', wp_json_encode( $settings ) )
801
+			sprintf('var _wpCustomizeWidgetsSettings = %s;', wp_json_encode($settings))
802 802
 		);
803 803
 	}
804 804
 
@@ -814,30 +814,30 @@  discard block
 block discarded – undo
814 814
 		<div id="available-widgets">
815 815
 			<div class="customize-section-title">
816 816
 				<button class="customize-section-back" tabindex="-1">
817
-					<span class="screen-reader-text"><?php _e( 'Back' ); ?></span>
817
+					<span class="screen-reader-text"><?php _e('Back'); ?></span>
818 818
 				</button>
819 819
 				<h3>
820 820
 					<span class="customize-action"><?php
821 821
 						/* translators: &#9656; is the unicode right-pointing triangle, and %s is the section title in the Customizer */
822
-						echo sprintf( __( 'Customizing &#9656; %s' ), esc_html( $this->manager->get_panel( 'widgets' )->title ) );
822
+						echo sprintf(__('Customizing &#9656; %s'), esc_html($this->manager->get_panel('widgets')->title));
823 823
 					?></span>
824
-					<?php _e( 'Add a Widget' ); ?>
824
+					<?php _e('Add a Widget'); ?>
825 825
 				</h3>
826 826
 			</div>
827 827
 			<div id="available-widgets-filter">
828
-				<label class="screen-reader-text" for="widgets-search"><?php _e( 'Search Widgets' ); ?></label>
829
-				<input type="text" id="widgets-search" placeholder="<?php esc_attr_e( 'Search widgets&hellip;' ) ?>" aria-describedby="widgets-search-desc" />
828
+				<label class="screen-reader-text" for="widgets-search"><?php _e('Search Widgets'); ?></label>
829
+				<input type="text" id="widgets-search" placeholder="<?php esc_attr_e('Search widgets&hellip;') ?>" aria-describedby="widgets-search-desc" />
830 830
 				<div class="search-icon" aria-hidden="true"></div>
831
-				<button type="button" class="clear-results"><span class="screen-reader-text"><?php _e( 'Clear Results' ); ?></span></button>
832
-				<p class="screen-reader-text" id="widgets-search-desc"><?php _e( 'The search results will be updated as you type.' ); ?></p>
831
+				<button type="button" class="clear-results"><span class="screen-reader-text"><?php _e('Clear Results'); ?></span></button>
832
+				<p class="screen-reader-text" id="widgets-search-desc"><?php _e('The search results will be updated as you type.'); ?></p>
833 833
 			</div>
834 834
 			<div id="available-widgets-list">
835
-			<?php foreach ( $this->get_available_widgets() as $available_widget ): ?>
836
-				<div id="widget-tpl-<?php echo esc_attr( $available_widget['id'] ) ?>" data-widget-id="<?php echo esc_attr( $available_widget['id'] ) ?>" class="widget-tpl <?php echo esc_attr( $available_widget['id'] ) ?>" tabindex="0">
835
+			<?php foreach ($this->get_available_widgets() as $available_widget): ?>
836
+				<div id="widget-tpl-<?php echo esc_attr($available_widget['id']) ?>" data-widget-id="<?php echo esc_attr($available_widget['id']) ?>" class="widget-tpl <?php echo esc_attr($available_widget['id']) ?>" tabindex="0">
837 837
 					<?php echo $available_widget['control_tpl']; ?>
838 838
 				</div>
839 839
 			<?php endforeach; ?>
840
-			<p class="no-widgets-found-message"><?php _e( 'No widgets found.' ); ?></p>
840
+			<p class="no-widgets-found-message"><?php _e('No widgets found.'); ?></p>
841 841
 			</div><!-- #available-widgets-list -->
842 842
 		</div><!-- #available-widgets -->
843 843
 		</div><!-- #widgets-left -->
@@ -853,13 +853,13 @@  discard block
 block discarded – undo
853 853
 	 */
854 854
 	public function print_footer_scripts() {
855 855
 		/** This action is documented in wp-admin/admin-footer.php */
856
-		do_action( 'admin_print_footer_scripts-widgets.php' );
856
+		do_action('admin_print_footer_scripts-widgets.php');
857 857
 
858 858
 		/** This action is documented in wp-admin/admin-footer.php */
859
-		do_action( 'admin_print_footer_scripts' );
859
+		do_action('admin_print_footer_scripts');
860 860
 
861 861
 		/** This action is documented in wp-admin/admin-footer.php */
862
-		do_action( 'admin_footer-widgets.php' );
862
+		do_action('admin_footer-widgets.php');
863 863
 	}
864 864
 
865 865
 	/**
@@ -872,24 +872,24 @@  discard block
 block discarded – undo
872 872
 	 * @param array  $overrides Array of setting overrides.
873 873
 	 * @return array Possibly modified setting arguments.
874 874
 	 */
875
-	public function get_setting_args( $id, $overrides = array() ) {
875
+	public function get_setting_args($id, $overrides = array()) {
876 876
 		$args = array(
877 877
 			'type'       => 'option',
878 878
 			'capability' => 'edit_theme_options',
879 879
 			'default'    => array(),
880 880
 		);
881 881
 
882
-		if ( preg_match( $this->setting_id_patterns['sidebar_widgets'], $id, $matches ) ) {
883
-			$args['sanitize_callback'] = array( $this, 'sanitize_sidebar_widgets' );
884
-			$args['sanitize_js_callback'] = array( $this, 'sanitize_sidebar_widgets_js_instance' );
885
-			$args['transport'] = current_theme_supports( 'customize-selective-refresh-widgets' ) ? 'postMessage' : 'refresh';
886
-		} elseif ( preg_match( $this->setting_id_patterns['widget_instance'], $id, $matches ) ) {
887
-			$args['sanitize_callback'] = array( $this, 'sanitize_widget_instance' );
888
-			$args['sanitize_js_callback'] = array( $this, 'sanitize_widget_js_instance' );
889
-			$args['transport'] = $this->is_widget_selective_refreshable( $matches['id_base'] ) ? 'postMessage' : 'refresh';
882
+		if (preg_match($this->setting_id_patterns['sidebar_widgets'], $id, $matches)) {
883
+			$args['sanitize_callback'] = array($this, 'sanitize_sidebar_widgets');
884
+			$args['sanitize_js_callback'] = array($this, 'sanitize_sidebar_widgets_js_instance');
885
+			$args['transport'] = current_theme_supports('customize-selective-refresh-widgets') ? 'postMessage' : 'refresh';
886
+		} elseif (preg_match($this->setting_id_patterns['widget_instance'], $id, $matches)) {
887
+			$args['sanitize_callback'] = array($this, 'sanitize_widget_instance');
888
+			$args['sanitize_js_callback'] = array($this, 'sanitize_widget_js_instance');
889
+			$args['transport'] = $this->is_widget_selective_refreshable($matches['id_base']) ? 'postMessage' : 'refresh';
890 890
 		}
891 891
 
892
-		$args = array_merge( $args, $overrides );
892
+		$args = array_merge($args, $overrides);
893 893
 
894 894
 		/**
895 895
 		 * Filters the common arguments supplied when constructing a Customizer setting.
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
 		 * @param array  $args Array of Customizer setting arguments.
902 902
 		 * @param string $id   Widget setting ID.
903 903
 		 */
904
-		return apply_filters( 'widget_customizer_setting_args', $args, $id );
904
+		return apply_filters('widget_customizer_setting_args', $args, $id);
905 905
 	}
906 906
 
907 907
 	/**
@@ -915,11 +915,11 @@  discard block
 block discarded – undo
915 915
 	 * @param array $widget_ids Array of widget IDs.
916 916
 	 * @return array Array of sanitized widget IDs.
917 917
 	 */
918
-	public function sanitize_sidebar_widgets( $widget_ids ) {
919
-		$widget_ids = array_map( 'strval', (array) $widget_ids );
918
+	public function sanitize_sidebar_widgets($widget_ids) {
919
+		$widget_ids = array_map('strval', (array) $widget_ids);
920 920
 		$sanitized_widget_ids = array();
921
-		foreach ( $widget_ids as $widget_id ) {
922
-			$sanitized_widget_ids[] = preg_replace( '/[^a-z0-9_\-]/', '', $widget_id );
921
+		foreach ($widget_ids as $widget_id) {
922
+			$sanitized_widget_ids[] = preg_replace('/[^a-z0-9_\-]/', '', $widget_id);
923 923
 		}
924 924
 		return $sanitized_widget_ids;
925 925
 	}
@@ -940,31 +940,31 @@  discard block
 block discarded – undo
940 940
 	 */
941 941
 	public function get_available_widgets() {
942 942
 		static $available_widgets = array();
943
-		if ( ! empty( $available_widgets ) ) {
943
+		if ( ! empty($available_widgets)) {
944 944
 			return $available_widgets;
945 945
 		}
946 946
 
947 947
 		global $wp_registered_widgets, $wp_registered_widget_controls;
948
-		require_once ABSPATH . '/wp-admin/includes/widgets.php'; // for next_widget_id_number()
948
+		require_once ABSPATH.'/wp-admin/includes/widgets.php'; // for next_widget_id_number()
949 949
 
950 950
 		$sort = $wp_registered_widgets;
951
-		usort( $sort, array( $this, '_sort_name_callback' ) );
951
+		usort($sort, array($this, '_sort_name_callback'));
952 952
 		$done = array();
953 953
 
954
-		foreach ( $sort as $widget ) {
955
-			if ( in_array( $widget['callback'], $done, true ) ) { // We already showed this multi-widget
954
+		foreach ($sort as $widget) {
955
+			if (in_array($widget['callback'], $done, true)) { // We already showed this multi-widget
956 956
 				continue;
957 957
 			}
958 958
 
959
-			$sidebar = is_active_widget( $widget['callback'], $widget['id'], false, false );
959
+			$sidebar = is_active_widget($widget['callback'], $widget['id'], false, false);
960 960
 			$done[]  = $widget['callback'];
961 961
 
962
-			if ( ! isset( $widget['params'][0] ) ) {
962
+			if ( ! isset($widget['params'][0])) {
963 963
 				$widget['params'][0] = array();
964 964
 			}
965 965
 
966 966
 			$available_widget = $widget;
967
-			unset( $available_widget['callback'] ); // not serializable to JSON
967
+			unset($available_widget['callback']); // not serializable to JSON
968 968
 
969 969
 			$args = array(
970 970
 				'widget_id'   => $widget['id'],
@@ -973,37 +973,37 @@  discard block
 block discarded – undo
973 973
 			);
974 974
 
975 975
 			$is_disabled     = false;
976
-			$is_multi_widget = ( isset( $wp_registered_widget_controls[$widget['id']]['id_base'] ) && isset( $widget['params'][0]['number'] ) );
977
-			if ( $is_multi_widget ) {
976
+			$is_multi_widget = (isset($wp_registered_widget_controls[$widget['id']]['id_base']) && isset($widget['params'][0]['number']));
977
+			if ($is_multi_widget) {
978 978
 				$id_base            = $wp_registered_widget_controls[$widget['id']]['id_base'];
979 979
 				$args['_temp_id']   = "$id_base-__i__";
980
-				$args['_multi_num'] = next_widget_id_number( $id_base );
980
+				$args['_multi_num'] = next_widget_id_number($id_base);
981 981
 				$args['_add']       = 'multi';
982 982
 			} else {
983 983
 				$args['_add'] = 'single';
984 984
 
985
-				if ( $sidebar && 'wp_inactive_widgets' !== $sidebar ) {
985
+				if ($sidebar && 'wp_inactive_widgets' !== $sidebar) {
986 986
 					$is_disabled = true;
987 987
 				}
988 988
 				$id_base = $widget['id'];
989 989
 			}
990 990
 
991
-			$list_widget_controls_args = wp_list_widget_controls_dynamic_sidebar( array( 0 => $args, 1 => $widget['params'][0] ) );
992
-			$control_tpl = $this->get_widget_control( $list_widget_controls_args );
991
+			$list_widget_controls_args = wp_list_widget_controls_dynamic_sidebar(array(0 => $args, 1 => $widget['params'][0]));
992
+			$control_tpl = $this->get_widget_control($list_widget_controls_args);
993 993
 
994 994
 			// The properties here are mapped to the Backbone Widget model.
995
-			$available_widget = array_merge( $available_widget, array(
996
-				'temp_id'      => isset( $args['_temp_id'] ) ? $args['_temp_id'] : null,
995
+			$available_widget = array_merge($available_widget, array(
996
+				'temp_id'      => isset($args['_temp_id']) ? $args['_temp_id'] : null,
997 997
 				'is_multi'     => $is_multi_widget,
998 998
 				'control_tpl'  => $control_tpl,
999
-				'multi_number' => ( $args['_add'] === 'multi' ) ? $args['_multi_num'] : false,
999
+				'multi_number' => ($args['_add'] === 'multi') ? $args['_multi_num'] : false,
1000 1000
 				'is_disabled'  => $is_disabled,
1001 1001
 				'id_base'      => $id_base,
1002
-				'transport'    => $this->is_widget_selective_refreshable( $id_base ) ? 'postMessage' : 'refresh',
1002
+				'transport'    => $this->is_widget_selective_refreshable($id_base) ? 'postMessage' : 'refresh',
1003 1003
 				'width'        => $wp_registered_widget_controls[$widget['id']]['width'],
1004 1004
 				'height'       => $wp_registered_widget_controls[$widget['id']]['height'],
1005
-				'is_wide'      => $this->is_wide_widget( $widget['id'] ),
1006
-			) );
1005
+				'is_wide'      => $this->is_wide_widget($widget['id']),
1006
+			));
1007 1007
 
1008 1008
 			$available_widgets[] = $available_widget;
1009 1009
 		}
@@ -1021,8 +1021,8 @@  discard block
 block discarded – undo
1021 1021
 	 * @param array $widget_b The second widget to compare.
1022 1022
 	 * @return int Reorder position for the current widget comparison.
1023 1023
 	 */
1024
-	protected function _sort_name_callback( $widget_a, $widget_b ) {
1025
-		return strnatcasecmp( $widget_a['name'], $widget_b['name'] );
1024
+	protected function _sort_name_callback($widget_a, $widget_b) {
1025
+		return strnatcasecmp($widget_a['name'], $widget_b['name']);
1026 1026
 	}
1027 1027
 
1028 1028
 	/**
@@ -1034,13 +1034,13 @@  discard block
 block discarded – undo
1034 1034
 	 * @param array $args Widget control arguments.
1035 1035
 	 * @return string Widget control form HTML markup.
1036 1036
 	 */
1037
-	public function get_widget_control( $args ) {
1037
+	public function get_widget_control($args) {
1038 1038
 		$args[0]['before_form'] = '<div class="form">';
1039 1039
 		$args[0]['after_form'] = '</div><!-- .form -->';
1040 1040
 		$args[0]['before_widget_content'] = '<div class="widget-content">';
1041 1041
 		$args[0]['after_widget_content'] = '</div><!-- .widget-content -->';
1042 1042
 		ob_start();
1043
-		call_user_func_array( 'wp_widget_control', $args );
1043
+		call_user_func_array('wp_widget_control', $args);
1044 1044
 		$control_tpl = ob_get_clean();
1045 1045
 		return $control_tpl;
1046 1046
 	}
@@ -1057,23 +1057,23 @@  discard block
 block discarded – undo
1057 1057
 	 *     @type string $content The contents of the widget form itself.
1058 1058
 	 * }
1059 1059
 	 */
1060
-	public function get_widget_control_parts( $args ) {
1060
+	public function get_widget_control_parts($args) {
1061 1061
 		$args[0]['before_widget_content'] = '<div class="widget-content">';
1062 1062
 		$args[0]['after_widget_content'] = '</div><!-- .widget-content -->';
1063
-		$control_markup = $this->get_widget_control( $args );
1063
+		$control_markup = $this->get_widget_control($args);
1064 1064
 
1065
-		$content_start_pos = strpos( $control_markup, $args[0]['before_widget_content'] );
1066
-		$content_end_pos = strrpos( $control_markup, $args[0]['after_widget_content'] );
1065
+		$content_start_pos = strpos($control_markup, $args[0]['before_widget_content']);
1066
+		$content_end_pos = strrpos($control_markup, $args[0]['after_widget_content']);
1067 1067
 
1068
-		$control = substr( $control_markup, 0, $content_start_pos + strlen( $args[0]['before_widget_content'] ) );
1069
-		$control .= substr( $control_markup, $content_end_pos );
1070
-		$content = trim( substr(
1068
+		$control = substr($control_markup, 0, $content_start_pos + strlen($args[0]['before_widget_content']));
1069
+		$control .= substr($control_markup, $content_end_pos);
1070
+		$content = trim(substr(
1071 1071
 			$control_markup,
1072
-			$content_start_pos + strlen( $args[0]['before_widget_content'] ),
1073
-			$content_end_pos - $content_start_pos - strlen( $args[0]['before_widget_content'] )
1074
-		) );
1072
+			$content_start_pos + strlen($args[0]['before_widget_content']),
1073
+			$content_end_pos - $content_start_pos - strlen($args[0]['before_widget_content'])
1074
+		));
1075 1075
 
1076
-		return compact( 'control', 'content' );
1076
+		return compact('control', 'content');
1077 1077
 	}
1078 1078
 
1079 1079
 	/**
@@ -1083,9 +1083,9 @@  discard block
 block discarded – undo
1083 1083
 	 * @access public
1084 1084
 	 */
1085 1085
 	public function customize_preview_init() {
1086
-		add_action( 'wp_enqueue_scripts', array( $this, 'customize_preview_enqueue' ) );
1087
-		add_action( 'wp_print_styles',    array( $this, 'print_preview_css' ), 1 );
1088
-		add_action( 'wp_footer',          array( $this, 'export_preview_data' ), 20 );
1086
+		add_action('wp_enqueue_scripts', array($this, 'customize_preview_enqueue'));
1087
+		add_action('wp_print_styles', array($this, 'print_preview_css'), 1);
1088
+		add_action('wp_footer', array($this, 'export_preview_data'), 20);
1089 1089
 	}
1090 1090
 
1091 1091
 	/**
@@ -1097,8 +1097,8 @@  discard block
 block discarded – undo
1097 1097
 	 * @param  array $nonces Array of nonces.
1098 1098
 	 * @return array $nonces Array of nonces.
1099 1099
 	 */
1100
-	public function refresh_nonces( $nonces ) {
1101
-		$nonces['update-widget'] = wp_create_nonce( 'update-widget' );
1100
+	public function refresh_nonces($nonces) {
1101
+		$nonces['update-widget'] = wp_create_nonce('update-widget');
1102 1102
 		return $nonces;
1103 1103
 	}
1104 1104
 
@@ -1116,10 +1116,10 @@  discard block
 block discarded – undo
1116 1116
 	 * @param array $sidebars_widgets List of widgets for the current sidebar.
1117 1117
 	 * @return array
1118 1118
 	 */
1119
-	public function preview_sidebars_widgets( $sidebars_widgets ) {
1120
-		$sidebars_widgets = get_option( 'sidebars_widgets', array() );
1119
+	public function preview_sidebars_widgets($sidebars_widgets) {
1120
+		$sidebars_widgets = get_option('sidebars_widgets', array());
1121 1121
 
1122
-		unset( $sidebars_widgets['array_version'] );
1122
+		unset($sidebars_widgets['array_version']);
1123 1123
 		return $sidebars_widgets;
1124 1124
 	}
1125 1125
 
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
 	 * @access public
1131 1131
 	 */
1132 1132
 	public function customize_preview_enqueue() {
1133
-		wp_enqueue_script( 'customize-preview-widgets' );
1133
+		wp_enqueue_script('customize-preview-widgets');
1134 1134
 	}
1135 1135
 
1136 1136
 	/**
@@ -1167,30 +1167,30 @@  discard block
 block discarded – undo
1167 1167
 	public function export_preview_data() {
1168 1168
 		global $wp_registered_sidebars, $wp_registered_widgets;
1169 1169
 
1170
-		$switched_locale = switch_to_locale( get_user_locale() );
1170
+		$switched_locale = switch_to_locale(get_user_locale());
1171 1171
 		$l10n = array(
1172
-			'widgetTooltip'  => __( 'Shift-click to edit this widget.' ),
1172
+			'widgetTooltip'  => __('Shift-click to edit this widget.'),
1173 1173
 		);
1174
-		if ( $switched_locale ) {
1174
+		if ($switched_locale) {
1175 1175
 			restore_previous_locale();
1176 1176
 		}
1177 1177
 
1178 1178
 		// Prepare Customizer settings to pass to JavaScript.
1179 1179
 		$settings = array(
1180
-			'renderedSidebars'   => array_fill_keys( array_unique( $this->rendered_sidebars ), true ),
1181
-			'renderedWidgets'    => array_fill_keys( array_keys( $this->rendered_widgets ), true ),
1182
-			'registeredSidebars' => array_values( $wp_registered_sidebars ),
1180
+			'renderedSidebars'   => array_fill_keys(array_unique($this->rendered_sidebars), true),
1181
+			'renderedWidgets'    => array_fill_keys(array_keys($this->rendered_widgets), true),
1182
+			'registeredSidebars' => array_values($wp_registered_sidebars),
1183 1183
 			'registeredWidgets'  => $wp_registered_widgets,
1184 1184
 			'l10n'               => $l10n,
1185 1185
 			'selectiveRefreshableWidgets' => $this->get_selective_refreshable_widgets(),
1186 1186
 		);
1187
-		foreach ( $settings['registeredWidgets'] as &$registered_widget ) {
1188
-			unset( $registered_widget['callback'] ); // may not be JSON-serializeable
1187
+		foreach ($settings['registeredWidgets'] as &$registered_widget) {
1188
+			unset($registered_widget['callback']); // may not be JSON-serializeable
1189 1189
 		}
1190 1190
 
1191 1191
 		?>
1192 1192
 		<script type="text/javascript">
1193
-			var _wpWidgetCustomizerPreviewSettings = <?php echo wp_json_encode( $settings ); ?>;
1193
+			var _wpWidgetCustomizerPreviewSettings = <?php echo wp_json_encode($settings); ?>;
1194 1194
 		</script>
1195 1195
 		<?php
1196 1196
 	}
@@ -1203,8 +1203,8 @@  discard block
 block discarded – undo
1203 1203
 	 *
1204 1204
 	 * @param array $widget Rendered widget to tally.
1205 1205
 	 */
1206
-	public function tally_rendered_widgets( $widget ) {
1207
-		$this->rendered_widgets[ $widget['id'] ] = true;
1206
+	public function tally_rendered_widgets($widget) {
1207
+		$this->rendered_widgets[$widget['id']] = true;
1208 1208
 	}
1209 1209
 
1210 1210
 	/**
@@ -1216,8 +1216,8 @@  discard block
 block discarded – undo
1216 1216
 	 * @param string $widget_id Widget ID to check.
1217 1217
 	 * @return bool Whether the widget is rendered.
1218 1218
 	 */
1219
-	public function is_widget_rendered( $widget_id ) {
1220
-		return in_array( $widget_id, $this->rendered_widgets );
1219
+	public function is_widget_rendered($widget_id) {
1220
+		return in_array($widget_id, $this->rendered_widgets);
1221 1221
 	}
1222 1222
 
1223 1223
 	/**
@@ -1229,8 +1229,8 @@  discard block
 block discarded – undo
1229 1229
 	 * @param string $sidebar_id Sidebar ID to check.
1230 1230
 	 * @return bool Whether the sidebar is rendered.
1231 1231
 	 */
1232
-	public function is_sidebar_rendered( $sidebar_id ) {
1233
-		return in_array( $sidebar_id, $this->rendered_sidebars );
1232
+	public function is_sidebar_rendered($sidebar_id) {
1233
+		return in_array($sidebar_id, $this->rendered_sidebars);
1234 1234
 	}
1235 1235
 
1236 1236
 	/**
@@ -1247,8 +1247,8 @@  discard block
 block discarded – undo
1247 1247
 	 * @param string $sidebar_id Sidebar ID.
1248 1248
 	 * @return bool Whether the sidebar is active.
1249 1249
 	 */
1250
-	public function tally_sidebars_via_is_active_sidebar_calls( $is_active, $sidebar_id ) {
1251
-		if ( is_registered_sidebar( $sidebar_id ) ) {
1250
+	public function tally_sidebars_via_is_active_sidebar_calls($is_active, $sidebar_id) {
1251
+		if (is_registered_sidebar($sidebar_id)) {
1252 1252
 			$this->rendered_sidebars[] = $sidebar_id;
1253 1253
 		}
1254 1254
 		/*
@@ -1273,8 +1273,8 @@  discard block
 block discarded – undo
1273 1273
 	 * @param string $sidebar_id  Sidebar ID.
1274 1274
 	 * @return bool Whether the current sidebar has widgets.
1275 1275
 	 */
1276
-	public function tally_sidebars_via_dynamic_sidebar_calls( $has_widgets, $sidebar_id ) {
1277
-		if ( is_registered_sidebar( $sidebar_id ) ) {
1276
+	public function tally_sidebars_via_dynamic_sidebar_calls($has_widgets, $sidebar_id) {
1277
+		if (is_registered_sidebar($sidebar_id)) {
1278 1278
 			$this->rendered_sidebars[] = $sidebar_id;
1279 1279
 		}
1280 1280
 
@@ -1298,8 +1298,8 @@  discard block
 block discarded – undo
1298 1298
 	 * @param string $serialized_instance Widget instance.
1299 1299
 	 * @return string MAC for serialized widget instance.
1300 1300
 	 */
1301
-	protected function get_instance_hash_key( $serialized_instance ) {
1302
-		return wp_hash( $serialized_instance );
1301
+	protected function get_instance_hash_key($serialized_instance) {
1302
+		return wp_hash($serialized_instance);
1303 1303
 	}
1304 1304
 
1305 1305
 	/**
@@ -1314,29 +1314,29 @@  discard block
 block discarded – undo
1314 1314
 	 * @param array $value Widget instance to sanitize.
1315 1315
 	 * @return array|void Sanitized widget instance.
1316 1316
 	 */
1317
-	public function sanitize_widget_instance( $value ) {
1318
-		if ( $value === array() ) {
1317
+	public function sanitize_widget_instance($value) {
1318
+		if ($value === array()) {
1319 1319
 			return $value;
1320 1320
 		}
1321 1321
 
1322
-		if ( empty( $value['is_widget_customizer_js_value'] )
1323
-			|| empty( $value['instance_hash_key'] )
1324
-			|| empty( $value['encoded_serialized_instance'] ) )
1322
+		if (empty($value['is_widget_customizer_js_value'])
1323
+			|| empty($value['instance_hash_key'])
1324
+			|| empty($value['encoded_serialized_instance']))
1325 1325
 		{
1326 1326
 			return;
1327 1327
 		}
1328 1328
 
1329
-		$decoded = base64_decode( $value['encoded_serialized_instance'], true );
1330
-		if ( false === $decoded ) {
1329
+		$decoded = base64_decode($value['encoded_serialized_instance'], true);
1330
+		if (false === $decoded) {
1331 1331
 			return;
1332 1332
 		}
1333 1333
 
1334
-		if ( ! hash_equals( $this->get_instance_hash_key( $decoded ), $value['instance_hash_key'] ) ) {
1334
+		if ( ! hash_equals($this->get_instance_hash_key($decoded), $value['instance_hash_key'])) {
1335 1335
 			return;
1336 1336
 		}
1337 1337
 
1338
-		$instance = unserialize( $decoded );
1339
-		if ( false === $instance ) {
1338
+		$instance = unserialize($decoded);
1339
+		if (false === $instance) {
1340 1340
 			return;
1341 1341
 		}
1342 1342
 
@@ -1352,15 +1352,15 @@  discard block
 block discarded – undo
1352 1352
 	 * @param array $value Widget instance to convert to JSON.
1353 1353
 	 * @return array JSON-converted widget instance.
1354 1354
 	 */
1355
-	public function sanitize_widget_js_instance( $value ) {
1356
-		if ( empty( $value['is_widget_customizer_js_value'] ) ) {
1357
-			$serialized = serialize( $value );
1355
+	public function sanitize_widget_js_instance($value) {
1356
+		if (empty($value['is_widget_customizer_js_value'])) {
1357
+			$serialized = serialize($value);
1358 1358
 
1359 1359
 			$value = array(
1360
-				'encoded_serialized_instance'   => base64_encode( $serialized ),
1361
-				'title'                         => empty( $value['title'] ) ? '' : $value['title'],
1360
+				'encoded_serialized_instance'   => base64_encode($serialized),
1361
+				'title'                         => empty($value['title']) ? '' : $value['title'],
1362 1362
 				'is_widget_customizer_js_value' => true,
1363
-				'instance_hash_key'             => $this->get_instance_hash_key( $serialized ),
1363
+				'instance_hash_key'             => $this->get_instance_hash_key($serialized),
1364 1364
 			);
1365 1365
 		}
1366 1366
 		return $value;
@@ -1380,9 +1380,9 @@  discard block
 block discarded – undo
1380 1380
 	 * @param array $widget_ids List of widget IDs.
1381 1381
 	 * @return array Parsed list of widget IDs.
1382 1382
 	 */
1383
-	public function sanitize_sidebar_widgets_js_instance( $widget_ids ) {
1383
+	public function sanitize_sidebar_widgets_js_instance($widget_ids) {
1384 1384
 		global $wp_registered_widgets;
1385
-		$widget_ids = array_values( array_intersect( $widget_ids, array_keys( $wp_registered_widgets ) ) );
1385
+		$widget_ids = array_values(array_intersect($widget_ids, array_keys($wp_registered_widgets)));
1386 1386
 		return $widget_ids;
1387 1387
 	}
1388 1388
 
@@ -1401,93 +1401,93 @@  discard block
 block discarded – undo
1401 1401
 	 * @return WP_Error|array Array containing the updated widget information.
1402 1402
 	 *                        A WP_Error object, otherwise.
1403 1403
 	 */
1404
-	public function call_widget_update( $widget_id ) {
1404
+	public function call_widget_update($widget_id) {
1405 1405
 		global $wp_registered_widget_updates, $wp_registered_widget_controls;
1406 1406
 
1407
-		$setting_id = $this->get_setting_id( $widget_id );
1407
+		$setting_id = $this->get_setting_id($widget_id);
1408 1408
 
1409 1409
 		/*
1410 1410
 		 * Make sure that other setting changes have previewed since this widget
1411 1411
 		 * may depend on them (e.g. Menus being present for Custom Menu widget).
1412 1412
 		 */
1413
-		if ( ! did_action( 'customize_preview_init' ) ) {
1414
-			foreach ( $this->manager->settings() as $setting ) {
1415
-				if ( $setting->id !== $setting_id ) {
1413
+		if ( ! did_action('customize_preview_init')) {
1414
+			foreach ($this->manager->settings() as $setting) {
1415
+				if ($setting->id !== $setting_id) {
1416 1416
 					$setting->preview();
1417 1417
 				}
1418 1418
 			}
1419 1419
 		}
1420 1420
 
1421 1421
 		$this->start_capturing_option_updates();
1422
-		$parsed_id   = $this->parse_widget_id( $widget_id );
1423
-		$option_name = 'widget_' . $parsed_id['id_base'];
1422
+		$parsed_id   = $this->parse_widget_id($widget_id);
1423
+		$option_name = 'widget_'.$parsed_id['id_base'];
1424 1424
 
1425 1425
 		/*
1426 1426
 		 * If a previously-sanitized instance is provided, populate the input vars
1427 1427
 		 * with its values so that the widget update callback will read this instance
1428 1428
 		 */
1429 1429
 		$added_input_vars = array();
1430
-		if ( ! empty( $_POST['sanitized_widget_setting'] ) ) {
1431
-			$sanitized_widget_setting = json_decode( $this->get_post_value( 'sanitized_widget_setting' ), true );
1432
-			if ( false === $sanitized_widget_setting ) {
1430
+		if ( ! empty($_POST['sanitized_widget_setting'])) {
1431
+			$sanitized_widget_setting = json_decode($this->get_post_value('sanitized_widget_setting'), true);
1432
+			if (false === $sanitized_widget_setting) {
1433 1433
 				$this->stop_capturing_option_updates();
1434
-				return new WP_Error( 'widget_setting_malformed' );
1434
+				return new WP_Error('widget_setting_malformed');
1435 1435
 			}
1436 1436
 
1437
-			$instance = $this->sanitize_widget_instance( $sanitized_widget_setting );
1438
-			if ( is_null( $instance ) ) {
1437
+			$instance = $this->sanitize_widget_instance($sanitized_widget_setting);
1438
+			if (is_null($instance)) {
1439 1439
 				$this->stop_capturing_option_updates();
1440
-				return new WP_Error( 'widget_setting_unsanitized' );
1440
+				return new WP_Error('widget_setting_unsanitized');
1441 1441
 			}
1442 1442
 
1443
-			if ( ! is_null( $parsed_id['number'] ) ) {
1443
+			if ( ! is_null($parsed_id['number'])) {
1444 1444
 				$value = array();
1445 1445
 				$value[$parsed_id['number']] = $instance;
1446
-				$key = 'widget-' . $parsed_id['id_base'];
1447
-				$_REQUEST[$key] = $_POST[$key] = wp_slash( $value );
1446
+				$key = 'widget-'.$parsed_id['id_base'];
1447
+				$_REQUEST[$key] = $_POST[$key] = wp_slash($value);
1448 1448
 				$added_input_vars[] = $key;
1449 1449
 			} else {
1450
-				foreach ( $instance as $key => $value ) {
1451
-					$_REQUEST[$key] = $_POST[$key] = wp_slash( $value );
1450
+				foreach ($instance as $key => $value) {
1451
+					$_REQUEST[$key] = $_POST[$key] = wp_slash($value);
1452 1452
 					$added_input_vars[] = $key;
1453 1453
 				}
1454 1454
 			}
1455 1455
 		}
1456 1456
 
1457 1457
 		// Invoke the widget update callback.
1458
-		foreach ( (array) $wp_registered_widget_updates as $name => $control ) {
1459
-			if ( $name === $parsed_id['id_base'] && is_callable( $control['callback'] ) ) {
1458
+		foreach ((array) $wp_registered_widget_updates as $name => $control) {
1459
+			if ($name === $parsed_id['id_base'] && is_callable($control['callback'])) {
1460 1460
 				ob_start();
1461
-				call_user_func_array( $control['callback'], $control['params'] );
1461
+				call_user_func_array($control['callback'], $control['params']);
1462 1462
 				ob_end_clean();
1463 1463
 				break;
1464 1464
 			}
1465 1465
 		}
1466 1466
 
1467 1467
 		// Clean up any input vars that were manually added
1468
-		foreach ( $added_input_vars as $key ) {
1469
-			unset( $_POST[ $key ] );
1470
-			unset( $_REQUEST[ $key ] );
1468
+		foreach ($added_input_vars as $key) {
1469
+			unset($_POST[$key]);
1470
+			unset($_REQUEST[$key]);
1471 1471
 		}
1472 1472
 
1473 1473
 		// Make sure the expected option was updated.
1474
-		if ( 0 !== $this->count_captured_options() ) {
1475
-			if ( $this->count_captured_options() > 1 ) {
1474
+		if (0 !== $this->count_captured_options()) {
1475
+			if ($this->count_captured_options() > 1) {
1476 1476
 				$this->stop_capturing_option_updates();
1477
-				return new WP_Error( 'widget_setting_too_many_options' );
1477
+				return new WP_Error('widget_setting_too_many_options');
1478 1478
 			}
1479 1479
 
1480
-			$updated_option_name = key( $this->get_captured_options() );
1481
-			if ( $updated_option_name !== $option_name ) {
1480
+			$updated_option_name = key($this->get_captured_options());
1481
+			if ($updated_option_name !== $option_name) {
1482 1482
 				$this->stop_capturing_option_updates();
1483
-				return new WP_Error( 'widget_setting_unexpected_option' );
1483
+				return new WP_Error('widget_setting_unexpected_option');
1484 1484
 			}
1485 1485
 		}
1486 1486
 
1487 1487
 		// Obtain the widget instance.
1488
-		$option = $this->get_captured_option( $option_name );
1489
-		if ( null !== $parsed_id['number'] ) {
1490
-			$instance = $option[ $parsed_id['number'] ];
1488
+		$option = $this->get_captured_option($option_name);
1489
+		if (null !== $parsed_id['number']) {
1490
+			$instance = $option[$parsed_id['number']];
1491 1491
 		} else {
1492 1492
 			$instance = $option;
1493 1493
 		}
@@ -1498,19 +1498,19 @@  discard block
 block discarded – undo
1498 1498
 		 * in place from WP_Customize_Setting::preview() will use this value
1499 1499
 		 * instead of the default widget instance value (an empty array).
1500 1500
 		 */
1501
-		$this->manager->set_post_value( $setting_id, $this->sanitize_widget_js_instance( $instance ) );
1501
+		$this->manager->set_post_value($setting_id, $this->sanitize_widget_js_instance($instance));
1502 1502
 
1503 1503
 		// Obtain the widget control with the updated instance in place.
1504 1504
 		ob_start();
1505
-		$form = $wp_registered_widget_controls[ $widget_id ];
1506
-		if ( $form ) {
1507
-			call_user_func_array( $form['callback'], $form['params'] );
1505
+		$form = $wp_registered_widget_controls[$widget_id];
1506
+		if ($form) {
1507
+			call_user_func_array($form['callback'], $form['params']);
1508 1508
 		}
1509 1509
 		$form = ob_get_clean();
1510 1510
 
1511 1511
 		$this->stop_capturing_option_updates();
1512 1512
 
1513
-		return compact( 'instance', 'form' );
1513
+		return compact('instance', 'form');
1514 1514
 	}
1515 1515
 
1516 1516
 	/**
@@ -1528,53 +1528,53 @@  discard block
 block discarded – undo
1528 1528
 	 */
1529 1529
 	public function wp_ajax_update_widget() {
1530 1530
 
1531
-		if ( ! is_user_logged_in() ) {
1532
-			wp_die( 0 );
1531
+		if ( ! is_user_logged_in()) {
1532
+			wp_die(0);
1533 1533
 		}
1534 1534
 
1535
-		check_ajax_referer( 'update-widget', 'nonce' );
1535
+		check_ajax_referer('update-widget', 'nonce');
1536 1536
 
1537
-		if ( ! current_user_can( 'edit_theme_options' ) ) {
1537
+		if ( ! current_user_can('edit_theme_options')) {
1538 1538
 			wp_die( -1 );
1539 1539
 		}
1540 1540
 
1541
-		if ( empty( $_POST['widget-id'] ) ) {
1542
-			wp_send_json_error( 'missing_widget-id' );
1541
+		if (empty($_POST['widget-id'])) {
1542
+			wp_send_json_error('missing_widget-id');
1543 1543
 		}
1544 1544
 
1545 1545
 		/** This action is documented in wp-admin/includes/ajax-actions.php */
1546
-		do_action( 'load-widgets.php' );
1546
+		do_action('load-widgets.php');
1547 1547
 
1548 1548
 		/** This action is documented in wp-admin/includes/ajax-actions.php */
1549
-		do_action( 'widgets.php' );
1549
+		do_action('widgets.php');
1550 1550
 
1551 1551
 		/** This action is documented in wp-admin/widgets.php */
1552
-		do_action( 'sidebar_admin_setup' );
1552
+		do_action('sidebar_admin_setup');
1553 1553
 
1554
-		$widget_id = $this->get_post_value( 'widget-id' );
1555
-		$parsed_id = $this->parse_widget_id( $widget_id );
1554
+		$widget_id = $this->get_post_value('widget-id');
1555
+		$parsed_id = $this->parse_widget_id($widget_id);
1556 1556
 		$id_base = $parsed_id['id_base'];
1557 1557
 
1558 1558
 		$is_updating_widget_template = (
1559
-			isset( $_POST[ 'widget-' . $id_base ] )
1559
+			isset($_POST['widget-'.$id_base])
1560 1560
 			&&
1561
-			is_array( $_POST[ 'widget-' . $id_base ] )
1561
+			is_array($_POST['widget-'.$id_base])
1562 1562
 			&&
1563
-			preg_match( '/__i__|%i%/', key( $_POST[ 'widget-' . $id_base ] ) )
1563
+			preg_match('/__i__|%i%/', key($_POST['widget-'.$id_base]))
1564 1564
 		);
1565
-		if ( $is_updating_widget_template ) {
1566
-			wp_send_json_error( 'template_widget_not_updatable' );
1565
+		if ($is_updating_widget_template) {
1566
+			wp_send_json_error('template_widget_not_updatable');
1567 1567
 		}
1568 1568
 
1569
-		$updated_widget = $this->call_widget_update( $widget_id ); // => {instance,form}
1570
-		if ( is_wp_error( $updated_widget ) ) {
1571
-			wp_send_json_error( $updated_widget->get_error_code() );
1569
+		$updated_widget = $this->call_widget_update($widget_id); // => {instance,form}
1570
+		if (is_wp_error($updated_widget)) {
1571
+			wp_send_json_error($updated_widget->get_error_code());
1572 1572
 		}
1573 1573
 
1574 1574
 		$form = $updated_widget['form'];
1575
-		$instance = $this->sanitize_widget_js_instance( $updated_widget['instance'] );
1575
+		$instance = $this->sanitize_widget_js_instance($updated_widget['instance']);
1576 1576
 
1577
-		wp_send_json_success( compact( 'form', 'instance' ) );
1577
+		wp_send_json_success(compact('form', 'instance'));
1578 1578
 	}
1579 1579
 
1580 1580
 	/*
@@ -1591,22 +1591,22 @@  discard block
 block discarded – undo
1591 1591
 	 * @param string      $partial_id   Partial ID.
1592 1592
 	 * @return array (Maybe) modified partial arguments.
1593 1593
 	 */
1594
-	public function customize_dynamic_partial_args( $partial_args, $partial_id ) {
1595
-		if ( ! current_theme_supports( 'customize-selective-refresh-widgets' ) ) {
1594
+	public function customize_dynamic_partial_args($partial_args, $partial_id) {
1595
+		if ( ! current_theme_supports('customize-selective-refresh-widgets')) {
1596 1596
 			return $partial_args;
1597 1597
 		}
1598 1598
 
1599
-		if ( preg_match( '/^widget\[(?P<widget_id>.+)\]$/', $partial_id, $matches ) ) {
1600
-			if ( false === $partial_args ) {
1599
+		if (preg_match('/^widget\[(?P<widget_id>.+)\]$/', $partial_id, $matches)) {
1600
+			if (false === $partial_args) {
1601 1601
 				$partial_args = array();
1602 1602
 			}
1603 1603
 			$partial_args = array_merge(
1604 1604
 				$partial_args,
1605 1605
 				array(
1606 1606
 					'type'                => 'widget',
1607
-					'render_callback'     => array( $this, 'render_widget_partial' ),
1607
+					'render_callback'     => array($this, 'render_widget_partial'),
1608 1608
 					'container_inclusive' => true,
1609
-					'settings'            => array( $this->get_setting_id( $matches['widget_id'] ) ),
1609
+					'settings'            => array($this->get_setting_id($matches['widget_id'])),
1610 1610
 					'capability'          => 'edit_theme_options',
1611 1611
 				)
1612 1612
 			);
@@ -1622,13 +1622,13 @@  discard block
 block discarded – undo
1622 1622
 	 * @access public
1623 1623
 	 */
1624 1624
 	public function selective_refresh_init() {
1625
-		if ( ! current_theme_supports( 'customize-selective-refresh-widgets' ) ) {
1625
+		if ( ! current_theme_supports('customize-selective-refresh-widgets')) {
1626 1626
 			return;
1627 1627
 		}
1628
-		add_filter( 'dynamic_sidebar_params', array( $this, 'filter_dynamic_sidebar_params' ) );
1629
-		add_filter( 'wp_kses_allowed_html', array( $this, 'filter_wp_kses_allowed_data_attributes' ) );
1630
-		add_action( 'dynamic_sidebar_before', array( $this, 'start_dynamic_sidebar' ) );
1631
-		add_action( 'dynamic_sidebar_after', array( $this, 'end_dynamic_sidebar' ) );
1628
+		add_filter('dynamic_sidebar_params', array($this, 'filter_dynamic_sidebar_params'));
1629
+		add_filter('wp_kses_allowed_html', array($this, 'filter_wp_kses_allowed_data_attributes'));
1630
+		add_action('dynamic_sidebar_before', array($this, 'start_dynamic_sidebar'));
1631
+		add_action('dynamic_sidebar_after', array($this, 'end_dynamic_sidebar'));
1632 1632
 	}
1633 1633
 
1634 1634
 	/**
@@ -1644,7 +1644,7 @@  discard block
 block discarded – undo
1644 1644
 	 *
1645 1645
 	 * @return array Params.
1646 1646
 	 */
1647
-	public function filter_dynamic_sidebar_params( $params ) {
1647
+	public function filter_dynamic_sidebar_params($params) {
1648 1648
 		$sidebar_args = array_merge(
1649 1649
 			array(
1650 1650
 				'before_widget' => '',
@@ -1656,33 +1656,33 @@  discard block
 block discarded – undo
1656 1656
 		// Skip widgets not in a registered sidebar or ones which lack a proper wrapper element to attach the data-* attributes to.
1657 1657
 		$matches = array();
1658 1658
 		$is_valid = (
1659
-			isset( $sidebar_args['id'] )
1659
+			isset($sidebar_args['id'])
1660 1660
 			&&
1661
-			is_registered_sidebar( $sidebar_args['id'] )
1661
+			is_registered_sidebar($sidebar_args['id'])
1662 1662
 			&&
1663
-			( isset( $this->current_dynamic_sidebar_id_stack[0] ) && $this->current_dynamic_sidebar_id_stack[0] === $sidebar_args['id'] )
1663
+			(isset($this->current_dynamic_sidebar_id_stack[0]) && $this->current_dynamic_sidebar_id_stack[0] === $sidebar_args['id'])
1664 1664
 			&&
1665
-			preg_match( '#^<(?P<tag_name>\w+)#', $sidebar_args['before_widget'], $matches )
1665
+			preg_match('#^<(?P<tag_name>\w+)#', $sidebar_args['before_widget'], $matches)
1666 1666
 		);
1667
-		if ( ! $is_valid ) {
1667
+		if ( ! $is_valid) {
1668 1668
 			return $params;
1669 1669
 		}
1670
-		$this->before_widget_tags_seen[ $matches['tag_name'] ] = true;
1670
+		$this->before_widget_tags_seen[$matches['tag_name']] = true;
1671 1671
 
1672 1672
 		$context = array(
1673 1673
 			'sidebar_id' => $sidebar_args['id'],
1674 1674
 		);
1675
-		if ( isset( $this->context_sidebar_instance_number ) ) {
1675
+		if (isset($this->context_sidebar_instance_number)) {
1676 1676
 			$context['sidebar_instance_number'] = $this->context_sidebar_instance_number;
1677
-		} else if ( isset( $sidebar_args['id'] ) && isset( $this->sidebar_instance_count[ $sidebar_args['id'] ] ) ) {
1678
-			$context['sidebar_instance_number'] = $this->sidebar_instance_count[ $sidebar_args['id'] ];
1677
+		} else if (isset($sidebar_args['id']) && isset($this->sidebar_instance_count[$sidebar_args['id']])) {
1678
+			$context['sidebar_instance_number'] = $this->sidebar_instance_count[$sidebar_args['id']];
1679 1679
 		}
1680 1680
 
1681
-		$attributes = sprintf( ' data-customize-partial-id="%s"', esc_attr( 'widget[' . $sidebar_args['widget_id'] . ']' ) );
1681
+		$attributes = sprintf(' data-customize-partial-id="%s"', esc_attr('widget['.$sidebar_args['widget_id'].']'));
1682 1682
 		$attributes .= ' data-customize-partial-type="widget"';
1683
-		$attributes .= sprintf( ' data-customize-partial-placement-context="%s"', esc_attr( wp_json_encode( $context ) ) );
1684
-		$attributes .= sprintf( ' data-customize-widget-id="%s"', esc_attr( $sidebar_args['widget_id'] ) );
1685
-		$sidebar_args['before_widget'] = preg_replace( '#^(<\w+)#', '$1 ' . $attributes, $sidebar_args['before_widget'] );
1683
+		$attributes .= sprintf(' data-customize-partial-placement-context="%s"', esc_attr(wp_json_encode($context)));
1684
+		$attributes .= sprintf(' data-customize-widget-id="%s"', esc_attr($sidebar_args['widget_id']));
1685
+		$sidebar_args['before_widget'] = preg_replace('#^(<\w+)#', '$1 '.$attributes, $sidebar_args['before_widget']);
1686 1686
 
1687 1687
 		$params[0] = $sidebar_args;
1688 1688
 		return $params;
@@ -1711,20 +1711,20 @@  discard block
 block discarded – undo
1711 1711
 	 * @param array $allowed_html Allowed HTML.
1712 1712
 	 * @return array (Maybe) modified allowed HTML.
1713 1713
 	 */
1714
-	public function filter_wp_kses_allowed_data_attributes( $allowed_html ) {
1715
-		foreach ( array_keys( $this->before_widget_tags_seen ) as $tag_name ) {
1716
-			if ( ! isset( $allowed_html[ $tag_name ] ) ) {
1717
-				$allowed_html[ $tag_name ] = array();
1714
+	public function filter_wp_kses_allowed_data_attributes($allowed_html) {
1715
+		foreach (array_keys($this->before_widget_tags_seen) as $tag_name) {
1716
+			if ( ! isset($allowed_html[$tag_name])) {
1717
+				$allowed_html[$tag_name] = array();
1718 1718
 			}
1719
-			$allowed_html[ $tag_name ] = array_merge(
1720
-				$allowed_html[ $tag_name ],
1721
-				array_fill_keys( array(
1719
+			$allowed_html[$tag_name] = array_merge(
1720
+				$allowed_html[$tag_name],
1721
+				array_fill_keys(array(
1722 1722
 					'data-customize-partial-id',
1723 1723
 					'data-customize-partial-type',
1724 1724
 					'data-customize-partial-placement-context',
1725 1725
 					'data-customize-partial-widget-id',
1726 1726
 					'data-customize-partial-options',
1727
-				), true )
1727
+				), true)
1728 1728
 			);
1729 1729
 		}
1730 1730
 		return $allowed_html;
@@ -1769,14 +1769,14 @@  discard block
 block discarded – undo
1769 1769
 	 *
1770 1770
 	 * @param int|string $index Index, name, or ID of the dynamic sidebar.
1771 1771
 	 */
1772
-	public function start_dynamic_sidebar( $index ) {
1773
-		array_unshift( $this->current_dynamic_sidebar_id_stack, $index );
1774
-		if ( ! isset( $this->sidebar_instance_count[ $index ] ) ) {
1775
-			$this->sidebar_instance_count[ $index ] = 0;
1772
+	public function start_dynamic_sidebar($index) {
1773
+		array_unshift($this->current_dynamic_sidebar_id_stack, $index);
1774
+		if ( ! isset($this->sidebar_instance_count[$index])) {
1775
+			$this->sidebar_instance_count[$index] = 0;
1776 1776
 		}
1777
-		$this->sidebar_instance_count[ $index ] += 1;
1778
-		if ( ! $this->manager->selective_refresh->is_render_partials_request() ) {
1779
-			printf( "\n<!--dynamic_sidebar_before:%s:%d-->\n", esc_html( $index ), intval( $this->sidebar_instance_count[ $index ] ) );
1777
+		$this->sidebar_instance_count[$index] += 1;
1778
+		if ( ! $this->manager->selective_refresh->is_render_partials_request()) {
1779
+			printf("\n<!--dynamic_sidebar_before:%s:%d-->\n", esc_html($index), intval($this->sidebar_instance_count[$index]));
1780 1780
 		}
1781 1781
 	}
1782 1782
 
@@ -1790,10 +1790,10 @@  discard block
 block discarded – undo
1790 1790
 	 *
1791 1791
 	 * @param int|string $index Index, name, or ID of the dynamic sidebar.
1792 1792
 	 */
1793
-	public function end_dynamic_sidebar( $index ) {
1794
-		array_shift( $this->current_dynamic_sidebar_id_stack );
1795
-		if ( ! $this->manager->selective_refresh->is_render_partials_request() ) {
1796
-			printf( "\n<!--dynamic_sidebar_after:%s:%d-->\n", esc_html( $index ), intval( $this->sidebar_instance_count[ $index ] ) );
1793
+	public function end_dynamic_sidebar($index) {
1794
+		array_shift($this->current_dynamic_sidebar_id_stack);
1795
+		if ( ! $this->manager->selective_refresh->is_render_partials_request()) {
1796
+			printf("\n<!--dynamic_sidebar_after:%s:%d-->\n", esc_html($index), intval($this->sidebar_instance_count[$index]));
1797 1797
 		}
1798 1798
 	}
1799 1799
 
@@ -1824,8 +1824,8 @@  discard block
 block discarded – undo
1824 1824
 	 * @param array $sidebars_widgets Sidebars widgets.
1825 1825
 	 * @return array Filtered sidebars widgets.
1826 1826
 	 */
1827
-	public function filter_sidebars_widgets_for_rendering_widget( $sidebars_widgets ) {
1828
-		$sidebars_widgets[ $this->rendering_sidebar_id ] = array( $this->rendering_widget_id );
1827
+	public function filter_sidebars_widgets_for_rendering_widget($sidebars_widgets) {
1828
+		$sidebars_widgets[$this->rendering_sidebar_id] = array($this->rendering_widget_id);
1829 1829
 		return $sidebars_widgets;
1830 1830
 	}
1831 1831
 
@@ -1846,36 +1846,36 @@  discard block
 block discarded – undo
1846 1846
 	 * }
1847 1847
 	 * @return string|false
1848 1848
 	 */
1849
-	public function render_widget_partial( $partial, $context ) {
1849
+	public function render_widget_partial($partial, $context) {
1850 1850
 		$id_data   = $partial->id_data();
1851
-		$widget_id = array_shift( $id_data['keys'] );
1851
+		$widget_id = array_shift($id_data['keys']);
1852 1852
 
1853
-		if ( ! is_array( $context )
1854
-			|| empty( $context['sidebar_id'] )
1855
-			|| ! is_registered_sidebar( $context['sidebar_id'] )
1853
+		if ( ! is_array($context)
1854
+			|| empty($context['sidebar_id'])
1855
+			|| ! is_registered_sidebar($context['sidebar_id'])
1856 1856
 		) {
1857 1857
 			return false;
1858 1858
 		}
1859 1859
 
1860 1860
 		$this->rendering_sidebar_id = $context['sidebar_id'];
1861 1861
 
1862
-		if ( isset( $context['sidebar_instance_number'] ) ) {
1863
-			$this->context_sidebar_instance_number = intval( $context['sidebar_instance_number'] );
1862
+		if (isset($context['sidebar_instance_number'])) {
1863
+			$this->context_sidebar_instance_number = intval($context['sidebar_instance_number']);
1864 1864
 		}
1865 1865
 
1866 1866
 		// Filter sidebars_widgets so that only the queried widget is in the sidebar.
1867 1867
 		$this->rendering_widget_id = $widget_id;
1868 1868
 
1869
-		$filter_callback = array( $this, 'filter_sidebars_widgets_for_rendering_widget' );
1870
-		add_filter( 'sidebars_widgets', $filter_callback, 1000 );
1869
+		$filter_callback = array($this, 'filter_sidebars_widgets_for_rendering_widget');
1870
+		add_filter('sidebars_widgets', $filter_callback, 1000);
1871 1871
 
1872 1872
 		// Render the widget.
1873 1873
 		ob_start();
1874
-		dynamic_sidebar( $this->rendering_sidebar_id = $context['sidebar_id'] );
1874
+		dynamic_sidebar($this->rendering_sidebar_id = $context['sidebar_id']);
1875 1875
 		$container = ob_get_clean();
1876 1876
 
1877 1877
 		// Reset variables for next partial render.
1878
-		remove_filter( 'sidebars_widgets', $filter_callback, 1000 );
1878
+		remove_filter('sidebars_widgets', $filter_callback, 1000);
1879 1879
 
1880 1880
 		$this->context_sidebar_instance_number = null;
1881 1881
 		$this->rendering_sidebar_id = null;
@@ -1915,8 +1915,8 @@  discard block
 block discarded – undo
1915 1915
 	 * @param string $option_name Option name.
1916 1916
 	 * @return bool Whether the option capture is ignored.
1917 1917
 	 */
1918
-	protected function is_option_capture_ignored( $option_name ) {
1919
-		return ( 0 === strpos( $option_name, '_transient_' ) );
1918
+	protected function is_option_capture_ignored($option_name) {
1919
+		return (0 === strpos($option_name, '_transient_'));
1920 1920
 	}
1921 1921
 
1922 1922
 	/**
@@ -1941,9 +1941,9 @@  discard block
 block discarded – undo
1941 1941
 	 * @param mixed  $default     Optional. Default value to return if the option does not exist. Default false.
1942 1942
 	 * @return mixed Value set for the option.
1943 1943
 	 */
1944
-	protected function get_captured_option( $option_name, $default = false ) {
1945
-		if ( array_key_exists( $option_name, $this->_captured_options ) ) {
1946
-			$value = $this->_captured_options[ $option_name ];
1944
+	protected function get_captured_option($option_name, $default = false) {
1945
+		if (array_key_exists($option_name, $this->_captured_options)) {
1946
+			$value = $this->_captured_options[$option_name];
1947 1947
 		} else {
1948 1948
 			$value = $default;
1949 1949
 		}
@@ -1959,7 +1959,7 @@  discard block
 block discarded – undo
1959 1959
 	 * @return int Number of updated options.
1960 1960
 	 */
1961 1961
 	protected function count_captured_options() {
1962
-		return count( $this->_captured_options );
1962
+		return count($this->_captured_options);
1963 1963
 	}
1964 1964
 
1965 1965
 	/**
@@ -1969,13 +1969,13 @@  discard block
 block discarded – undo
1969 1969
 	 * @access protected
1970 1970
 	 */
1971 1971
 	protected function start_capturing_option_updates() {
1972
-		if ( $this->_is_capturing_option_updates ) {
1972
+		if ($this->_is_capturing_option_updates) {
1973 1973
 			return;
1974 1974
 		}
1975 1975
 
1976 1976
 		$this->_is_capturing_option_updates = true;
1977 1977
 
1978
-		add_filter( 'pre_update_option', array( $this, 'capture_filter_pre_update_option' ), 10, 3 );
1978
+		add_filter('pre_update_option', array($this, 'capture_filter_pre_update_option'), 10, 3);
1979 1979
 	}
1980 1980
 
1981 1981
 	/**
@@ -1989,16 +1989,16 @@  discard block
 block discarded – undo
1989 1989
 	 * @param mixed  $old_value   The old option value.
1990 1990
 	 * @return mixed Filtered option value.
1991 1991
 	 */
1992
-	public function capture_filter_pre_update_option( $new_value, $option_name, $old_value ) {
1993
-		if ( $this->is_option_capture_ignored( $option_name ) ) {
1992
+	public function capture_filter_pre_update_option($new_value, $option_name, $old_value) {
1993
+		if ($this->is_option_capture_ignored($option_name)) {
1994 1994
 			return;
1995 1995
 		}
1996 1996
 
1997
-		if ( ! isset( $this->_captured_options[ $option_name ] ) ) {
1998
-			add_filter( "pre_option_{$option_name}", array( $this, 'capture_filter_pre_get_option' ) );
1997
+		if ( ! isset($this->_captured_options[$option_name])) {
1998
+			add_filter("pre_option_{$option_name}", array($this, 'capture_filter_pre_get_option'));
1999 1999
 		}
2000 2000
 
2001
-		$this->_captured_options[ $option_name ] = $new_value;
2001
+		$this->_captured_options[$option_name] = $new_value;
2002 2002
 
2003 2003
 		return $old_value;
2004 2004
 	}
@@ -2012,14 +2012,14 @@  discard block
 block discarded – undo
2012 2012
 	 * @param mixed $value Value to return instead of the option value.
2013 2013
 	 * @return mixed Filtered option value.
2014 2014
 	 */
2015
-	public function capture_filter_pre_get_option( $value ) {
2016
-		$option_name = preg_replace( '/^pre_option_/', '', current_filter() );
2015
+	public function capture_filter_pre_get_option($value) {
2016
+		$option_name = preg_replace('/^pre_option_/', '', current_filter());
2017 2017
 
2018
-		if ( isset( $this->_captured_options[ $option_name ] ) ) {
2019
-			$value = $this->_captured_options[ $option_name ];
2018
+		if (isset($this->_captured_options[$option_name])) {
2019
+			$value = $this->_captured_options[$option_name];
2020 2020
 
2021 2021
 			/** This filter is documented in wp-includes/option.php */
2022
-			$value = apply_filters( 'option_' . $option_name, $value );
2022
+			$value = apply_filters('option_'.$option_name, $value);
2023 2023
 		}
2024 2024
 
2025 2025
 		return $value;
@@ -2032,14 +2032,14 @@  discard block
 block discarded – undo
2032 2032
 	 * @access protected
2033 2033
 	 */
2034 2034
 	protected function stop_capturing_option_updates() {
2035
-		if ( ! $this->_is_capturing_option_updates ) {
2035
+		if ( ! $this->_is_capturing_option_updates) {
2036 2036
 			return;
2037 2037
 		}
2038 2038
 
2039
-		remove_filter( 'pre_update_option', array( $this, 'capture_filter_pre_update_option' ), 10 );
2039
+		remove_filter('pre_update_option', array($this, 'capture_filter_pre_update_option'), 10);
2040 2040
 
2041
-		foreach ( array_keys( $this->_captured_options ) as $option_name ) {
2042
-			remove_filter( "pre_option_{$option_name}", array( $this, 'capture_filter_pre_get_option' ) );
2041
+		foreach (array_keys($this->_captured_options) as $option_name) {
2042
+			remove_filter("pre_option_{$option_name}", array($this, 'capture_filter_pre_get_option'));
2043 2043
 		}
2044 2044
 
2045 2045
 		$this->_captured_options = array();
@@ -2055,7 +2055,7 @@  discard block
 block discarded – undo
2055 2055
 	 * @deprecated 4.2.0 Deprecated in favor of the {@see 'customize_dynamic_setting_args'} filter.
2056 2056
 	 */
2057 2057
 	public function setup_widget_addition_previews() {
2058
-		_deprecated_function( __METHOD__, '4.2.0' );
2058
+		_deprecated_function(__METHOD__, '4.2.0');
2059 2059
 	}
2060 2060
 
2061 2061
 	/**
@@ -2067,7 +2067,7 @@  discard block
 block discarded – undo
2067 2067
 	 * @deprecated 4.2.0 Deprecated in favor of the {@see 'customize_dynamic_setting_args'} filter.
2068 2068
 	 */
2069 2069
 	public function prepreview_added_sidebars_widgets() {
2070
-		_deprecated_function( __METHOD__, '4.2.0' );
2070
+		_deprecated_function(__METHOD__, '4.2.0');
2071 2071
 	}
2072 2072
 
2073 2073
 	/**
@@ -2079,7 +2079,7 @@  discard block
 block discarded – undo
2079 2079
 	 * @deprecated 4.2.0 Deprecated in favor of the {@see 'customize_dynamic_setting_args'} filter.
2080 2080
 	 */
2081 2081
 	public function prepreview_added_widget_instance() {
2082
-		_deprecated_function( __METHOD__, '4.2.0' );
2082
+		_deprecated_function(__METHOD__, '4.2.0');
2083 2083
 	}
2084 2084
 
2085 2085
 	/**
@@ -2091,6 +2091,6 @@  discard block
 block discarded – undo
2091 2091
 	 * @deprecated 4.2.0 Deprecated in favor of the {@see 'customize_dynamic_setting_args'} filter.
2092 2092
 	 */
2093 2093
 	public function remove_prepreview_filters() {
2094
-		_deprecated_function( __METHOD__, '4.2.0' );
2094
+		_deprecated_function(__METHOD__, '4.2.0');
2095 2095
 	}
2096 2096
 }
Please login to merge, or discard this patch.
src/wp-includes/class-wp-post.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -205,7 +205,7 @@
 block discarded – undo
205 205
 	 * @global wpdb $wpdb WordPress database abstraction object.
206 206
 	 *
207 207
 	 * @param int $post_id Post ID.
208
-	 * @return WP_Post|false Post object, false otherwise.
208
+	 * @return string Post object, false otherwise.
209 209
 	 */
210 210
 	public static function get_instance( $post_id ) {
211 211
 		global $wpdb;
Please login to merge, or discard this patch.
Braces   +47 added lines, -32 removed lines patch added patch discarded remove patch
@@ -221,8 +221,9 @@  discard block
 block discarded – undo
221 221
 		if ( ! $_post ) {
222 222
 			$_post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post_id ) );
223 223
 
224
-			if ( ! $_post )
225
-				return false;
224
+			if ( ! $_post ) {
225
+							return false;
226
+			}
226 227
 
227 228
 			$_post = sanitize_post( $_post, 'raw' );
228 229
 			wp_cache_add( $_post->ID, $_post, 'posts' );
@@ -239,8 +240,9 @@  discard block
 block discarded – undo
239 240
 	 * @param WP_Post|object $post Post object.
240 241
 	 */
241 242
 	public function __construct( $post ) {
242
-		foreach ( get_object_vars( $post ) as $key => $value )
243
-			$this->$key = $value;
243
+		foreach ( get_object_vars( $post ) as $key => $value ) {
244
+					$this->$key = $value;
245
+		}
244 246
 	}
245 247
 
246 248
 	/**
@@ -250,17 +252,21 @@  discard block
 block discarded – undo
250 252
 	 * @return bool
251 253
 	 */
252 254
 	public function __isset( $key ) {
253
-		if ( 'ancestors' == $key )
254
-			return true;
255
+		if ( 'ancestors' == $key ) {
256
+					return true;
257
+		}
255 258
 
256
-		if ( 'page_template' == $key )
257
-			return true;
259
+		if ( 'page_template' == $key ) {
260
+					return true;
261
+		}
258 262
 
259
-		if ( 'post_category' == $key )
260
-		   return true;
263
+		if ( 'post_category' == $key ) {
264
+				   return true;
265
+		}
261 266
 
262
-		if ( 'tags_input' == $key )
263
-		   return true;
267
+		if ( 'tags_input' == $key ) {
268
+				   return true;
269
+		}
264 270
 
265 271
 		return metadata_exists( 'post', $this->ID, $key );
266 272
 	}
@@ -277,33 +283,39 @@  discard block
 block discarded – undo
277 283
 		}
278 284
 
279 285
 		if ( 'post_category' == $key ) {
280
-			if ( is_object_in_taxonomy( $this->post_type, 'category' ) )
281
-				$terms = get_the_terms( $this, 'category' );
286
+			if ( is_object_in_taxonomy( $this->post_type, 'category' ) ) {
287
+							$terms = get_the_terms( $this, 'category' );
288
+			}
282 289
 
283
-			if ( empty( $terms ) )
284
-				return array();
290
+			if ( empty( $terms ) ) {
291
+							return array();
292
+			}
285 293
 
286 294
 			return wp_list_pluck( $terms, 'term_id' );
287 295
 		}
288 296
 
289 297
 		if ( 'tags_input' == $key ) {
290
-			if ( is_object_in_taxonomy( $this->post_type, 'post_tag' ) )
291
-				$terms = get_the_terms( $this, 'post_tag' );
298
+			if ( is_object_in_taxonomy( $this->post_type, 'post_tag' ) ) {
299
+							$terms = get_the_terms( $this, 'post_tag' );
300
+			}
292 301
 
293
-			if ( empty( $terms ) )
294
-				return array();
302
+			if ( empty( $terms ) ) {
303
+							return array();
304
+			}
295 305
 
296 306
 			return wp_list_pluck( $terms, 'name' );
297 307
 		}
298 308
 
299 309
 		// Rest of the values need filtering.
300
-		if ( 'ancestors' == $key )
301
-			$value = get_post_ancestors( $this );
302
-		else
303
-			$value = get_post_meta( $this->ID, $key, true );
310
+		if ( 'ancestors' == $key ) {
311
+					$value = get_post_ancestors( $this );
312
+		} else {
313
+					$value = get_post_meta( $this->ID, $key, true );
314
+		}
304 315
 
305
-		if ( $this->filter )
306
-			$value = sanitize_post_field( $key, $value, $this->ID, $this->filter );
316
+		if ( $this->filter ) {
317
+					$value = sanitize_post_field( $key, $value, $this->ID, $this->filter );
318
+		}
307 319
 
308 320
 		return $value;
309 321
 	}
@@ -315,11 +327,13 @@  discard block
 block discarded – undo
315 327
 	 * @return self|array|bool|object|WP_Post
316 328
 	 */
317 329
 	public function filter( $filter ) {
318
-		if ( $this->filter == $filter )
319
-			return $this;
330
+		if ( $this->filter == $filter ) {
331
+					return $this;
332
+		}
320 333
 
321
-		if ( $filter == 'raw' )
322
-			return self::get_instance( $this->ID );
334
+		if ( $filter == 'raw' ) {
335
+					return self::get_instance( $this->ID );
336
+		}
323 337
 
324 338
 		return sanitize_post( $this, $filter );
325 339
 	}
@@ -333,8 +347,9 @@  discard block
 block discarded – undo
333 347
 		$post = get_object_vars( $this );
334 348
 
335 349
 		foreach ( array( 'ancestors', 'page_template', 'post_category', 'tags_input' ) as $key ) {
336
-			if ( $this->__isset( $key ) )
337
-				$post[ $key ] = $this->__get( $key );
350
+			if ( $this->__isset( $key ) ) {
351
+							$post[ $key ] = $this->__get( $key );
352
+			}
338 353
 		}
339 354
 
340 355
 		return $post;
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -207,29 +207,29 @@  discard block
 block discarded – undo
207 207
 	 * @param int $post_id Post ID.
208 208
 	 * @return WP_Post|false Post object, false otherwise.
209 209
 	 */
210
-	public static function get_instance( $post_id ) {
210
+	public static function get_instance($post_id) {
211 211
 		global $wpdb;
212 212
 
213 213
 		$post_id = (int) $post_id;
214
-		if ( ! $post_id ) {
214
+		if ( ! $post_id) {
215 215
 			return false;
216 216
 		}
217 217
 
218
-		$_post = wp_cache_get( $post_id, 'posts' );
218
+		$_post = wp_cache_get($post_id, 'posts');
219 219
 
220
-		if ( ! $_post ) {
221
-			$_post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post_id ) );
220
+		if ( ! $_post) {
221
+			$_post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post_id));
222 222
 
223
-			if ( ! $_post )
223
+			if ( ! $_post)
224 224
 				return false;
225 225
 
226
-			$_post = sanitize_post( $_post, 'raw' );
227
-			wp_cache_add( $_post->ID, $_post, 'posts' );
228
-		} elseif ( empty( $_post->filter ) ) {
229
-			$_post = sanitize_post( $_post, 'raw' );
226
+			$_post = sanitize_post($_post, 'raw');
227
+			wp_cache_add($_post->ID, $_post, 'posts');
228
+		} elseif (empty($_post->filter)) {
229
+			$_post = sanitize_post($_post, 'raw');
230 230
 		}
231 231
 
232
-		return new WP_Post( $_post );
232
+		return new WP_Post($_post);
233 233
 	}
234 234
 
235 235
 	/**
@@ -237,8 +237,8 @@  discard block
 block discarded – undo
237 237
 	 *
238 238
 	 * @param WP_Post|object $post Post object.
239 239
 	 */
240
-	public function __construct( $post ) {
241
-		foreach ( get_object_vars( $post ) as $key => $value )
240
+	public function __construct($post) {
241
+		foreach (get_object_vars($post) as $key => $value)
242 242
 			$this->$key = $value;
243 243
 	}
244 244
 
@@ -248,20 +248,20 @@  discard block
 block discarded – undo
248 248
 	 * @param string $key Property to check if set.
249 249
 	 * @return bool
250 250
 	 */
251
-	public function __isset( $key ) {
252
-		if ( 'ancestors' == $key )
251
+	public function __isset($key) {
252
+		if ('ancestors' == $key)
253 253
 			return true;
254 254
 
255
-		if ( 'page_template' == $key )
255
+		if ('page_template' == $key)
256 256
 			return true;
257 257
 
258
-		if ( 'post_category' == $key )
258
+		if ('post_category' == $key)
259 259
 		   return true;
260 260
 
261
-		if ( 'tags_input' == $key )
261
+		if ('tags_input' == $key)
262 262
 		   return true;
263 263
 
264
-		return metadata_exists( 'post', $this->ID, $key );
264
+		return metadata_exists('post', $this->ID, $key);
265 265
 	}
266 266
 
267 267
 	/**
@@ -270,39 +270,39 @@  discard block
 block discarded – undo
270 270
 	 * @param string $key Key to get.
271 271
 	 * @return mixed
272 272
 	 */
273
-	public function __get( $key ) {
274
-		if ( 'page_template' == $key && $this->__isset( $key ) ) {
275
-			return get_post_meta( $this->ID, '_wp_page_template', true );
273
+	public function __get($key) {
274
+		if ('page_template' == $key && $this->__isset($key)) {
275
+			return get_post_meta($this->ID, '_wp_page_template', true);
276 276
 		}
277 277
 
278
-		if ( 'post_category' == $key ) {
279
-			if ( is_object_in_taxonomy( $this->post_type, 'category' ) )
280
-				$terms = get_the_terms( $this, 'category' );
278
+		if ('post_category' == $key) {
279
+			if (is_object_in_taxonomy($this->post_type, 'category'))
280
+				$terms = get_the_terms($this, 'category');
281 281
 
282
-			if ( empty( $terms ) )
282
+			if (empty($terms))
283 283
 				return array();
284 284
 
285
-			return wp_list_pluck( $terms, 'term_id' );
285
+			return wp_list_pluck($terms, 'term_id');
286 286
 		}
287 287
 
288
-		if ( 'tags_input' == $key ) {
289
-			if ( is_object_in_taxonomy( $this->post_type, 'post_tag' ) )
290
-				$terms = get_the_terms( $this, 'post_tag' );
288
+		if ('tags_input' == $key) {
289
+			if (is_object_in_taxonomy($this->post_type, 'post_tag'))
290
+				$terms = get_the_terms($this, 'post_tag');
291 291
 
292
-			if ( empty( $terms ) )
292
+			if (empty($terms))
293 293
 				return array();
294 294
 
295
-			return wp_list_pluck( $terms, 'name' );
295
+			return wp_list_pluck($terms, 'name');
296 296
 		}
297 297
 
298 298
 		// Rest of the values need filtering.
299
-		if ( 'ancestors' == $key )
300
-			$value = get_post_ancestors( $this );
299
+		if ('ancestors' == $key)
300
+			$value = get_post_ancestors($this);
301 301
 		else
302
-			$value = get_post_meta( $this->ID, $key, true );
302
+			$value = get_post_meta($this->ID, $key, true);
303 303
 
304
-		if ( $this->filter )
305
-			$value = sanitize_post_field( $key, $value, $this->ID, $this->filter );
304
+		if ($this->filter)
305
+			$value = sanitize_post_field($key, $value, $this->ID, $this->filter);
306 306
 
307 307
 		return $value;
308 308
 	}
@@ -313,14 +313,14 @@  discard block
 block discarded – undo
313 313
 	 * @param string $filter Filter.
314 314
 	 * @return self|array|bool|object|WP_Post
315 315
 	 */
316
-	public function filter( $filter ) {
317
-		if ( $this->filter == $filter )
316
+	public function filter($filter) {
317
+		if ($this->filter == $filter)
318 318
 			return $this;
319 319
 
320
-		if ( $filter == 'raw' )
321
-			return self::get_instance( $this->ID );
320
+		if ($filter == 'raw')
321
+			return self::get_instance($this->ID);
322 322
 
323
-		return sanitize_post( $this, $filter );
323
+		return sanitize_post($this, $filter);
324 324
 	}
325 325
 
326 326
 	/**
@@ -329,11 +329,11 @@  discard block
 block discarded – undo
329 329
 	 * @return array Object as array.
330 330
 	 */
331 331
 	public function to_array() {
332
-		$post = get_object_vars( $this );
332
+		$post = get_object_vars($this);
333 333
 
334
-		foreach ( array( 'ancestors', 'page_template', 'post_category', 'tags_input' ) as $key ) {
335
-			if ( $this->__isset( $key ) )
336
-				$post[ $key ] = $this->__get( $key );
334
+		foreach (array('ancestors', 'page_template', 'post_category', 'tags_input') as $key) {
335
+			if ($this->__isset($key))
336
+				$post[$key] = $this->__get($key);
337 337
 		}
338 338
 
339 339
 		return $post;
Please login to merge, or discard this patch.
src/wp-includes/class-wp-user-query.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -183,7 +183,7 @@
 block discarded – undo
183 183
 	 * @access public
184 184
 	 *
185 185
 	 * @param string $name Property to check if set.
186
-	 * @return bool Whether the property is set.
186
+	 * @return boolean|null Whether the property is set.
187 187
 	 */
188 188
 	public function __isset( $name ) {
189 189
 		if ( in_array( $name, $this->compat_fields ) ) {
Please login to merge, or discard this patch.
Spacing   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	 */
62 62
 	public $request;
63 63
 
64
-	private $compat_fields = array( 'results', 'total_users' );
64
+	private $compat_fields = array('results', 'total_users');
65 65
 
66 66
 	// SQL clauses
67 67
 	public $query_fields;
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
 	 *
78 78
 	 * @param null|string|array $query Optional. The query variables.
79 79
 	 */
80
-	public function __construct( $query = null ) {
81
-		if ( ! empty( $query ) ) {
82
-			$this->prepare_query( $query );
80
+	public function __construct($query = null) {
81
+		if ( ! empty($query)) {
82
+			$this->prepare_query($query);
83 83
 			$this->query();
84 84
 		}
85 85
 	}
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 * @param array $args Query vars, as passed to `WP_User_Query`.
94 94
 	 * @return array Complete query variables with undefined ones filled in with defaults.
95 95
 	 */
96
-	public static function fill_query_vars( $args ) {
96
+	public static function fill_query_vars($args) {
97 97
 		$defaults = array(
98 98
 			'blog_id' => get_current_blog_id(),
99 99
 			'role' => '',
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 			'login__not_in' => array()
124 124
 		);
125 125
 
126
-		return wp_parse_args( $args, $defaults );
126
+		return wp_parse_args($args, $defaults);
127 127
 	}
128 128
 
129 129
 	/**
@@ -215,12 +215,12 @@  discard block
 block discarded – undo
215 215
 	 *                                             logins will not be included in results. Default empty array.
216 216
 	 * }
217 217
 	 */
218
-	public function prepare_query( $query = array() ) {
218
+	public function prepare_query($query = array()) {
219 219
 		global $wpdb;
220 220
 
221
-		if ( empty( $this->query_vars ) || ! empty( $query ) ) {
221
+		if (empty($this->query_vars) || ! empty($query)) {
222 222
 			$this->query_limit = null;
223
-			$this->query_vars = $this->fill_query_vars( $query );
223
+			$this->query_vars = $this->fill_query_vars($query);
224 224
 		}
225 225
 
226 226
 		/**
@@ -234,101 +234,101 @@  discard block
 block discarded – undo
234 234
 		 * @param WP_User_Query $this The current WP_User_Query instance,
235 235
 		 *                            passed by reference.
236 236
 		 */
237
-		do_action( 'pre_get_users', $this );
237
+		do_action('pre_get_users', $this);
238 238
 
239 239
 		// Ensure that query vars are filled after 'pre_get_users'.
240
-		$qv =& $this->query_vars;
241
-		$qv =  $this->fill_query_vars( $qv );
240
+		$qv = & $this->query_vars;
241
+		$qv = $this->fill_query_vars($qv);
242 242
 
243
-		if ( is_array( $qv['fields'] ) ) {
244
-			$qv['fields'] = array_unique( $qv['fields'] );
243
+		if (is_array($qv['fields'])) {
244
+			$qv['fields'] = array_unique($qv['fields']);
245 245
 
246 246
 			$this->query_fields = array();
247
-			foreach ( $qv['fields'] as $field ) {
248
-				$field = 'ID' === $field ? 'ID' : sanitize_key( $field );
247
+			foreach ($qv['fields'] as $field) {
248
+				$field = 'ID' === $field ? 'ID' : sanitize_key($field);
249 249
 				$this->query_fields[] = "$wpdb->users.$field";
250 250
 			}
251
-			$this->query_fields = implode( ',', $this->query_fields );
252
-		} elseif ( 'all' == $qv['fields'] ) {
251
+			$this->query_fields = implode(',', $this->query_fields);
252
+		} elseif ('all' == $qv['fields']) {
253 253
 			$this->query_fields = "$wpdb->users.*";
254 254
 		} else {
255 255
 			$this->query_fields = "$wpdb->users.ID";
256 256
 		}
257 257
 
258
-		if ( isset( $qv['count_total'] ) && $qv['count_total'] )
259
-			$this->query_fields = 'SQL_CALC_FOUND_ROWS ' . $this->query_fields;
258
+		if (isset($qv['count_total']) && $qv['count_total'])
259
+			$this->query_fields = 'SQL_CALC_FOUND_ROWS '.$this->query_fields;
260 260
 
261 261
 		$this->query_from = "FROM $wpdb->users";
262 262
 		$this->query_where = "WHERE 1=1";
263 263
 
264 264
 		// Parse and sanitize 'include', for use by 'orderby' as well as 'include' below.
265
-		if ( ! empty( $qv['include'] ) ) {
266
-			$include = wp_parse_id_list( $qv['include'] );
265
+		if ( ! empty($qv['include'])) {
266
+			$include = wp_parse_id_list($qv['include']);
267 267
 		} else {
268 268
 			$include = false;
269 269
 		}
270 270
 
271 271
 		$blog_id = 0;
272
-		if ( isset( $qv['blog_id'] ) ) {
273
-			$blog_id = absint( $qv['blog_id'] );
272
+		if (isset($qv['blog_id'])) {
273
+			$blog_id = absint($qv['blog_id']);
274 274
 		}
275 275
 
276
-		if ( $qv['has_published_posts'] && $blog_id ) {
277
-			if ( true === $qv['has_published_posts'] ) {
278
-				$post_types = get_post_types( array( 'public' => true ) );
276
+		if ($qv['has_published_posts'] && $blog_id) {
277
+			if (true === $qv['has_published_posts']) {
278
+				$post_types = get_post_types(array('public' => true));
279 279
 			} else {
280 280
 				$post_types = (array) $qv['has_published_posts'];
281 281
 			}
282 282
 
283
-			foreach ( $post_types as &$post_type ) {
284
-				$post_type = $wpdb->prepare( '%s', $post_type );
283
+			foreach ($post_types as &$post_type) {
284
+				$post_type = $wpdb->prepare('%s', $post_type);
285 285
 			}
286 286
 
287
-			$posts_table = $wpdb->get_blog_prefix( $blog_id ) . 'posts';
288
-			$this->query_where .= " AND $wpdb->users.ID IN ( SELECT DISTINCT $posts_table.post_author FROM $posts_table WHERE $posts_table.post_status = 'publish' AND $posts_table.post_type IN ( " . join( ", ", $post_types ) . " ) )";
287
+			$posts_table = $wpdb->get_blog_prefix($blog_id).'posts';
288
+			$this->query_where .= " AND $wpdb->users.ID IN ( SELECT DISTINCT $posts_table.post_author FROM $posts_table WHERE $posts_table.post_status = 'publish' AND $posts_table.post_type IN ( ".join(", ", $post_types)." ) )";
289 289
 		}
290 290
 
291 291
 		// nicename
292
-		if ( '' !== $qv['nicename']) {
293
-			$this->query_where .= $wpdb->prepare( ' AND user_nicename = %s', $qv['nicename'] );
292
+		if ('' !== $qv['nicename']) {
293
+			$this->query_where .= $wpdb->prepare(' AND user_nicename = %s', $qv['nicename']);
294 294
 		}
295 295
 
296
-		if ( ! empty( $qv['nicename__in'] ) ) {
297
-			$sanitized_nicename__in = array_map( 'esc_sql', $qv['nicename__in'] );
298
-			$nicename__in = implode( "','", $sanitized_nicename__in );
296
+		if ( ! empty($qv['nicename__in'])) {
297
+			$sanitized_nicename__in = array_map('esc_sql', $qv['nicename__in']);
298
+			$nicename__in = implode("','", $sanitized_nicename__in);
299 299
 			$this->query_where .= " AND user_nicename IN ( '$nicename__in' )";
300 300
 		}
301 301
 
302
-		if ( ! empty( $qv['nicename__not_in'] ) ) {
303
-			$sanitized_nicename__not_in = array_map( 'esc_sql', $qv['nicename__not_in'] );
304
-			$nicename__not_in = implode( "','", $sanitized_nicename__not_in );
302
+		if ( ! empty($qv['nicename__not_in'])) {
303
+			$sanitized_nicename__not_in = array_map('esc_sql', $qv['nicename__not_in']);
304
+			$nicename__not_in = implode("','", $sanitized_nicename__not_in);
305 305
 			$this->query_where .= " AND user_nicename NOT IN ( '$nicename__not_in' )";
306 306
 		}
307 307
 
308 308
 		// login
309
-		if ( '' !== $qv['login']) {
310
-			$this->query_where .= $wpdb->prepare( ' AND user_login = %s', $qv['login'] );
309
+		if ('' !== $qv['login']) {
310
+			$this->query_where .= $wpdb->prepare(' AND user_login = %s', $qv['login']);
311 311
 		}
312 312
 
313
-		if ( ! empty( $qv['login__in'] ) ) {
314
-			$sanitized_login__in = array_map( 'esc_sql', $qv['login__in'] );
315
-			$login__in = implode( "','", $sanitized_login__in );
313
+		if ( ! empty($qv['login__in'])) {
314
+			$sanitized_login__in = array_map('esc_sql', $qv['login__in']);
315
+			$login__in = implode("','", $sanitized_login__in);
316 316
 			$this->query_where .= " AND user_login IN ( '$login__in' )";
317 317
 		}
318 318
 
319
-		if ( ! empty( $qv['login__not_in'] ) ) {
320
-			$sanitized_login__not_in = array_map( 'esc_sql', $qv['login__not_in'] );
321
-			$login__not_in = implode( "','", $sanitized_login__not_in );
319
+		if ( ! empty($qv['login__not_in'])) {
320
+			$sanitized_login__not_in = array_map('esc_sql', $qv['login__not_in']);
321
+			$login__not_in = implode("','", $sanitized_login__not_in);
322 322
 			$this->query_where .= " AND user_login NOT IN ( '$login__not_in' )";
323 323
 		}
324 324
 
325 325
 		// Meta query.
326 326
 		$this->meta_query = new WP_Meta_Query();
327
-		$this->meta_query->parse_query_vars( $qv );
327
+		$this->meta_query->parse_query_vars($qv);
328 328
 
329
-		if ( isset( $qv['who'] ) && 'authors' == $qv['who'] && $blog_id ) {
329
+		if (isset($qv['who']) && 'authors' == $qv['who'] && $blog_id) {
330 330
 			$who_query = array(
331
-				'key' => $wpdb->get_blog_prefix( $blog_id ) . 'user_level',
331
+				'key' => $wpdb->get_blog_prefix($blog_id).'user_level',
332 332
 				'value' => 0,
333 333
 				'compare' => '!=',
334 334
 			);
@@ -336,47 +336,47 @@  discard block
 block discarded – undo
336 336
 			// Prevent extra meta query.
337 337
 			$qv['blog_id'] = $blog_id = 0;
338 338
 
339
-			if ( empty( $this->meta_query->queries ) ) {
340
-				$this->meta_query->queries = array( $who_query );
339
+			if (empty($this->meta_query->queries)) {
340
+				$this->meta_query->queries = array($who_query);
341 341
 			} else {
342 342
 				// Append the cap query to the original queries and reparse the query.
343 343
 				$this->meta_query->queries = array(
344 344
 					'relation' => 'AND',
345
-					array( $this->meta_query->queries, $who_query ),
345
+					array($this->meta_query->queries, $who_query),
346 346
 				);
347 347
 			}
348 348
 
349
-			$this->meta_query->parse_query_vars( $this->meta_query->queries );
349
+			$this->meta_query->parse_query_vars($this->meta_query->queries);
350 350
 		}
351 351
 
352 352
 		$roles = array();
353
-		if ( isset( $qv['role'] ) ) {
354
-			if ( is_array( $qv['role'] ) ) {
353
+		if (isset($qv['role'])) {
354
+			if (is_array($qv['role'])) {
355 355
 				$roles = $qv['role'];
356
-			} elseif ( is_string( $qv['role'] ) && ! empty( $qv['role'] ) ) {
357
-				$roles = array_map( 'trim', explode( ',', $qv['role'] ) );
356
+			} elseif (is_string($qv['role']) && ! empty($qv['role'])) {
357
+				$roles = array_map('trim', explode(',', $qv['role']));
358 358
 			}
359 359
 		}
360 360
 
361 361
 		$role__in = array();
362
-		if ( isset( $qv['role__in'] ) ) {
362
+		if (isset($qv['role__in'])) {
363 363
 			$role__in = (array) $qv['role__in'];
364 364
 		}
365 365
 
366 366
 		$role__not_in = array();
367
-		if ( isset( $qv['role__not_in'] ) ) {
367
+		if (isset($qv['role__not_in'])) {
368 368
 			$role__not_in = (array) $qv['role__not_in'];
369 369
 		}
370 370
 
371
-		if ( $blog_id && ( ! empty( $roles ) || ! empty( $role__in ) || ! empty( $role__not_in ) || is_multisite() ) ) {
371
+		if ($blog_id && ( ! empty($roles) || ! empty($role__in) || ! empty($role__not_in) || is_multisite())) {
372 372
 			$role_queries  = array();
373 373
 
374
-			$roles_clauses = array( 'relation' => 'AND' );
375
-			if ( ! empty( $roles ) ) {
376
-				foreach ( $roles as $role ) {
374
+			$roles_clauses = array('relation' => 'AND');
375
+			if ( ! empty($roles)) {
376
+				foreach ($roles as $role) {
377 377
 					$roles_clauses[] = array(
378
-						'key'     => $wpdb->get_blog_prefix( $blog_id ) . 'capabilities',
379
-						'value'   => '"' . $role . '"',
378
+						'key'     => $wpdb->get_blog_prefix($blog_id).'capabilities',
379
+						'value'   => '"'.$role.'"',
380 380
 						'compare' => 'LIKE',
381 381
 					);
382 382
 				}
@@ -384,12 +384,12 @@  discard block
 block discarded – undo
384 384
 				$role_queries[] = $roles_clauses;
385 385
 			}
386 386
 
387
-			$role__in_clauses = array( 'relation' => 'OR' );
388
-			if ( ! empty( $role__in ) ) {
389
-				foreach ( $role__in as $role ) {
387
+			$role__in_clauses = array('relation' => 'OR');
388
+			if ( ! empty($role__in)) {
389
+				foreach ($role__in as $role) {
390 390
 					$role__in_clauses[] = array(
391
-						'key'     => $wpdb->get_blog_prefix( $blog_id ) . 'capabilities',
392
-						'value'   => '"' . $role . '"',
391
+						'key'     => $wpdb->get_blog_prefix($blog_id).'capabilities',
392
+						'value'   => '"'.$role.'"',
393 393
 						'compare' => 'LIKE',
394 394
 					);
395 395
 				}
@@ -397,12 +397,12 @@  discard block
 block discarded – undo
397 397
 				$role_queries[] = $role__in_clauses;
398 398
 			}
399 399
 
400
-			$role__not_in_clauses = array( 'relation' => 'AND' );
401
-			if ( ! empty( $role__not_in ) ) {
402
-				foreach ( $role__not_in as $role ) {
400
+			$role__not_in_clauses = array('relation' => 'AND');
401
+			if ( ! empty($role__not_in)) {
402
+				foreach ($role__not_in as $role) {
403 403
 					$role__not_in_clauses[] = array(
404
-						'key'     => $wpdb->get_blog_prefix( $blog_id ) . 'capabilities',
405
-						'value'   => '"' . $role . '"',
404
+						'key'     => $wpdb->get_blog_prefix($blog_id).'capabilities',
405
+						'value'   => '"'.$role.'"',
406 406
 						'compare' => 'NOT LIKE',
407 407
 					);
408 408
 				}
@@ -411,9 +411,9 @@  discard block
 block discarded – undo
411 411
 			}
412 412
 
413 413
 			// If there are no specific roles named, make sure the user is a member of the site.
414
-			if ( empty( $role_queries ) ) {
414
+			if (empty($role_queries)) {
415 415
 				$role_queries[] = array(
416
-					'key' => $wpdb->get_blog_prefix( $blog_id ) . 'capabilities',
416
+					'key' => $wpdb->get_blog_prefix($blog_id).'capabilities',
417 417
 					'compare' => 'EXISTS',
418 418
 				);
419 419
 			}
@@ -421,50 +421,50 @@  discard block
 block discarded – undo
421 421
 			// Specify that role queries should be joined with AND.
422 422
 			$role_queries['relation'] = 'AND';
423 423
 
424
-			if ( empty( $this->meta_query->queries ) ) {
424
+			if (empty($this->meta_query->queries)) {
425 425
 				$this->meta_query->queries = $role_queries;
426 426
 			} else {
427 427
 				// Append the cap query to the original queries and reparse the query.
428 428
 				$this->meta_query->queries = array(
429 429
 					'relation' => 'AND',
430
-					array( $this->meta_query->queries, $role_queries ),
430
+					array($this->meta_query->queries, $role_queries),
431 431
 				);
432 432
 			}
433 433
 
434
-			$this->meta_query->parse_query_vars( $this->meta_query->queries );
434
+			$this->meta_query->parse_query_vars($this->meta_query->queries);
435 435
 		}
436 436
 
437
-		if ( ! empty( $this->meta_query->queries ) ) {
438
-			$clauses = $this->meta_query->get_sql( 'user', $wpdb->users, 'ID', $this );
437
+		if ( ! empty($this->meta_query->queries)) {
438
+			$clauses = $this->meta_query->get_sql('user', $wpdb->users, 'ID', $this);
439 439
 			$this->query_from .= $clauses['join'];
440 440
 			$this->query_where .= $clauses['where'];
441 441
 
442
-			if ( $this->meta_query->has_or_relation() ) {
443
-				$this->query_fields = 'DISTINCT ' . $this->query_fields;
442
+			if ($this->meta_query->has_or_relation()) {
443
+				$this->query_fields = 'DISTINCT '.$this->query_fields;
444 444
 			}
445 445
 		}
446 446
 
447 447
 		// sorting
448
-		$qv['order'] = isset( $qv['order'] ) ? strtoupper( $qv['order'] ) : '';
449
-		$order = $this->parse_order( $qv['order'] );
448
+		$qv['order'] = isset($qv['order']) ? strtoupper($qv['order']) : '';
449
+		$order = $this->parse_order($qv['order']);
450 450
 
451
-		if ( empty( $qv['orderby'] ) ) {
451
+		if (empty($qv['orderby'])) {
452 452
 			// Default order is by 'user_login'.
453
-			$ordersby = array( 'user_login' => $order );
454
-		} elseif ( is_array( $qv['orderby'] ) ) {
453
+			$ordersby = array('user_login' => $order);
454
+		} elseif (is_array($qv['orderby'])) {
455 455
 			$ordersby = $qv['orderby'];
456 456
 		} else {
457 457
 			// 'orderby' values may be a comma- or space-separated list.
458
-			$ordersby = preg_split( '/[,\s]+/', $qv['orderby'] );
458
+			$ordersby = preg_split('/[,\s]+/', $qv['orderby']);
459 459
 		}
460 460
 
461 461
 		$orderby_array = array();
462
-		foreach ( $ordersby as $_key => $_value ) {
463
-			if ( ! $_value ) {
462
+		foreach ($ordersby as $_key => $_value) {
463
+			if ( ! $_value) {
464 464
 				continue;
465 465
 			}
466 466
 
467
-			if ( is_int( $_key ) ) {
467
+			if (is_int($_key)) {
468 468
 				// Integer key means this is a flat array of 'orderby' fields.
469 469
 				$_orderby = $_value;
470 470
 				$_order = $order;
@@ -474,62 +474,62 @@  discard block
 block discarded – undo
474 474
 				$_order = $_value;
475 475
 			}
476 476
 
477
-			$parsed = $this->parse_orderby( $_orderby );
477
+			$parsed = $this->parse_orderby($_orderby);
478 478
 
479
-			if ( ! $parsed ) {
479
+			if ( ! $parsed) {
480 480
 				continue;
481 481
 			}
482 482
 
483
-			if ( 'nicename__in' === $_orderby || 'login__in' === $_orderby ) {
483
+			if ('nicename__in' === $_orderby || 'login__in' === $_orderby) {
484 484
 				$orderby_array[] = $parsed;
485 485
 			} else {
486
-				$orderby_array[] = $parsed . ' ' . $this->parse_order( $_order );
486
+				$orderby_array[] = $parsed.' '.$this->parse_order($_order);
487 487
 			}
488 488
 		}
489 489
 
490 490
 		// If no valid clauses were found, order by user_login.
491
-		if ( empty( $orderby_array ) ) {
491
+		if (empty($orderby_array)) {
492 492
 			$orderby_array[] = "user_login $order";
493 493
 		}
494 494
 
495
-		$this->query_orderby = 'ORDER BY ' . implode( ', ', $orderby_array );
495
+		$this->query_orderby = 'ORDER BY '.implode(', ', $orderby_array);
496 496
 
497 497
 		// limit
498
-		if ( isset( $qv['number'] ) && $qv['number'] > 0 ) {
499
-			if ( $qv['offset'] ) {
498
+		if (isset($qv['number']) && $qv['number'] > 0) {
499
+			if ($qv['offset']) {
500 500
 				$this->query_limit = $wpdb->prepare("LIMIT %d, %d", $qv['offset'], $qv['number']);
501 501
 			} else {
502
-				$this->query_limit = $wpdb->prepare( "LIMIT %d, %d", $qv['number'] * ( $qv['paged'] - 1 ), $qv['number'] );
502
+				$this->query_limit = $wpdb->prepare("LIMIT %d, %d", $qv['number'] * ($qv['paged'] - 1), $qv['number']);
503 503
 			}
504 504
 		}
505 505
 
506 506
 		$search = '';
507
-		if ( isset( $qv['search'] ) )
508
-			$search = trim( $qv['search'] );
507
+		if (isset($qv['search']))
508
+			$search = trim($qv['search']);
509 509
 
510
-		if ( $search ) {
511
-			$leading_wild = ( ltrim($search, '*') != $search );
512
-			$trailing_wild = ( rtrim($search, '*') != $search );
513
-			if ( $leading_wild && $trailing_wild )
510
+		if ($search) {
511
+			$leading_wild = (ltrim($search, '*') != $search);
512
+			$trailing_wild = (rtrim($search, '*') != $search);
513
+			if ($leading_wild && $trailing_wild)
514 514
 				$wild = 'both';
515
-			elseif ( $leading_wild )
515
+			elseif ($leading_wild)
516 516
 				$wild = 'leading';
517
-			elseif ( $trailing_wild )
517
+			elseif ($trailing_wild)
518 518
 				$wild = 'trailing';
519 519
 			else
520 520
 				$wild = false;
521
-			if ( $wild )
521
+			if ($wild)
522 522
 				$search = trim($search, '*');
523 523
 
524 524
 			$search_columns = array();
525
-			if ( $qv['search_columns'] )
526
-				$search_columns = array_intersect( $qv['search_columns'], array( 'ID', 'user_login', 'user_email', 'user_url', 'user_nicename' ) );
527
-			if ( ! $search_columns ) {
528
-				if ( false !== strpos( $search, '@') )
525
+			if ($qv['search_columns'])
526
+				$search_columns = array_intersect($qv['search_columns'], array('ID', 'user_login', 'user_email', 'user_url', 'user_nicename'));
527
+			if ( ! $search_columns) {
528
+				if (false !== strpos($search, '@'))
529 529
 					$search_columns = array('user_email');
530
-				elseif ( is_numeric($search) )
530
+				elseif (is_numeric($search))
531 531
 					$search_columns = array('user_login', 'ID');
532
-				elseif ( preg_match('|^https?://|', $search) && ! ( is_multisite() && wp_is_large_network( 'users' ) ) )
532
+				elseif (preg_match('|^https?://|', $search) && ! (is_multisite() && wp_is_large_network('users')))
533 533
 					$search_columns = array('user_url');
534 534
 				else
535 535
 					$search_columns = array('user_login', 'user_url', 'user_email', 'user_nicename', 'display_name');
@@ -547,23 +547,23 @@  discard block
 block discarded – undo
547 547
 			 * @param string        $search         Text being searched.
548 548
 			 * @param WP_User_Query $this           The current WP_User_Query instance.
549 549
 			 */
550
-			$search_columns = apply_filters( 'user_search_columns', $search_columns, $search, $this );
550
+			$search_columns = apply_filters('user_search_columns', $search_columns, $search, $this);
551 551
 
552
-			$this->query_where .= $this->get_search_sql( $search, $search_columns, $wild );
552
+			$this->query_where .= $this->get_search_sql($search, $search_columns, $wild);
553 553
 		}
554 554
 
555
-		if ( ! empty( $include ) ) {
555
+		if ( ! empty($include)) {
556 556
 			// Sanitized earlier.
557
-			$ids = implode( ',', $include );
557
+			$ids = implode(',', $include);
558 558
 			$this->query_where .= " AND $wpdb->users.ID IN ($ids)";
559
-		} elseif ( ! empty( $qv['exclude'] ) ) {
560
-			$ids = implode( ',', wp_parse_id_list( $qv['exclude'] ) );
559
+		} elseif ( ! empty($qv['exclude'])) {
560
+			$ids = implode(',', wp_parse_id_list($qv['exclude']));
561 561
 			$this->query_where .= " AND $wpdb->users.ID NOT IN ($ids)";
562 562
 		}
563 563
 
564 564
 		// Date queries are allowed for the user_registered field.
565
-		if ( ! empty( $qv['date_query'] ) && is_array( $qv['date_query'] ) ) {
566
-			$date_query = new WP_Date_Query( $qv['date_query'], 'user_registered' );
565
+		if ( ! empty($qv['date_query']) && is_array($qv['date_query'])) {
566
+			$date_query = new WP_Date_Query($qv['date_query'], 'user_registered');
567 567
 			$this->query_where .= $date_query->get_sql();
568 568
 		}
569 569
 
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
 		 * @param WP_User_Query $this The current WP_User_Query instance,
580 580
 		 *                            passed by reference.
581 581
 		 */
582
-		do_action_ref_array( 'pre_user_query', array( &$this ) );
582
+		do_action_ref_array('pre_user_query', array(&$this));
583 583
 	}
584 584
 
585 585
 	/**
@@ -592,14 +592,14 @@  discard block
 block discarded – undo
592 592
 	public function query() {
593 593
 		global $wpdb;
594 594
 
595
-		$qv =& $this->query_vars;
595
+		$qv = & $this->query_vars;
596 596
 
597 597
 		$this->request = "SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit";
598 598
 
599
-		if ( is_array( $qv['fields'] ) || 'all' == $qv['fields'] ) {
600
-			$this->results = $wpdb->get_results( $this->request );
599
+		if (is_array($qv['fields']) || 'all' == $qv['fields']) {
600
+			$this->results = $wpdb->get_results($this->request);
601 601
 		} else {
602
-			$this->results = $wpdb->get_col( $this->request );
602
+			$this->results = $wpdb->get_col($this->request);
603 603
 		}
604 604
 
605 605
 		/**
@@ -611,23 +611,23 @@  discard block
 block discarded – undo
611 611
 		 *
612 612
 		 * @param string $sql The SELECT FOUND_ROWS() query for the current WP_User_Query.
613 613
 		 */
614
-		if ( isset( $qv['count_total'] ) && $qv['count_total'] )
615
-			$this->total_users = (int) $wpdb->get_var( apply_filters( 'found_users_query', 'SELECT FOUND_ROWS()' ) );
614
+		if (isset($qv['count_total']) && $qv['count_total'])
615
+			$this->total_users = (int) $wpdb->get_var(apply_filters('found_users_query', 'SELECT FOUND_ROWS()'));
616 616
 
617
-		if ( !$this->results )
617
+		if ( ! $this->results)
618 618
 			return;
619 619
 
620
-		if ( 'all_with_meta' == $qv['fields'] ) {
621
-			cache_users( $this->results );
620
+		if ('all_with_meta' == $qv['fields']) {
621
+			cache_users($this->results);
622 622
 
623 623
 			$r = array();
624
-			foreach ( $this->results as $userid )
625
-				$r[ $userid ] = new WP_User( $userid, '', $qv['blog_id'] );
624
+			foreach ($this->results as $userid)
625
+				$r[$userid] = new WP_User($userid, '', $qv['blog_id']);
626 626
 
627 627
 			$this->results = $r;
628
-		} elseif ( 'all' == $qv['fields'] ) {
629
-			foreach ( $this->results as $key => $user ) {
630
-				$this->results[ $key ] = new WP_User( $user, '', $qv['blog_id'] );
628
+		} elseif ('all' == $qv['fields']) {
629
+			foreach ($this->results as $key => $user) {
630
+				$this->results[$key] = new WP_User($user, '', $qv['blog_id']);
631 631
 			}
632 632
 		}
633 633
 	}
@@ -641,8 +641,8 @@  discard block
 block discarded – undo
641 641
 	 * @param string $query_var Query variable key.
642 642
 	 * @return mixed
643 643
 	 */
644
-	public function get( $query_var ) {
645
-		if ( isset( $this->query_vars[$query_var] ) )
644
+	public function get($query_var) {
645
+		if (isset($this->query_vars[$query_var]))
646 646
 			return $this->query_vars[$query_var];
647 647
 
648 648
 		return null;
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
 	 * @param string $query_var Query variable key.
658 658
 	 * @param mixed $value Query variable value.
659 659
 	 */
660
-	public function set( $query_var, $value ) {
660
+	public function set($query_var, $value) {
661 661
 		$this->query_vars[$query_var] = $value;
662 662
 	}
663 663
 
@@ -675,23 +675,23 @@  discard block
 block discarded – undo
675 675
 	 *                       Single site allows leading and trailing wildcards, Network Admin only trailing.
676 676
 	 * @return string
677 677
 	 */
678
-	protected function get_search_sql( $string, $cols, $wild = false ) {
678
+	protected function get_search_sql($string, $cols, $wild = false) {
679 679
 		global $wpdb;
680 680
 
681 681
 		$searches = array();
682
-		$leading_wild = ( 'leading' == $wild || 'both' == $wild ) ? '%' : '';
683
-		$trailing_wild = ( 'trailing' == $wild || 'both' == $wild ) ? '%' : '';
684
-		$like = $leading_wild . $wpdb->esc_like( $string ) . $trailing_wild;
682
+		$leading_wild = ('leading' == $wild || 'both' == $wild) ? '%' : '';
683
+		$trailing_wild = ('trailing' == $wild || 'both' == $wild) ? '%' : '';
684
+		$like = $leading_wild.$wpdb->esc_like($string).$trailing_wild;
685 685
 
686
-		foreach ( $cols as $col ) {
687
-			if ( 'ID' == $col ) {
688
-				$searches[] = $wpdb->prepare( "$col = %s", $string );
686
+		foreach ($cols as $col) {
687
+			if ('ID' == $col) {
688
+				$searches[] = $wpdb->prepare("$col = %s", $string);
689 689
 			} else {
690
-				$searches[] = $wpdb->prepare( "$col LIKE %s", $like );
690
+				$searches[] = $wpdb->prepare("$col LIKE %s", $like);
691 691
 			}
692 692
 		}
693 693
 
694
-		return ' AND (' . implode(' OR ', $searches) . ')';
694
+		return ' AND ('.implode(' OR ', $searches).')';
695 695
 	}
696 696
 
697 697
 	/**
@@ -729,21 +729,21 @@  discard block
 block discarded – undo
729 729
 	 * @param string $orderby Alias for the field to order by.
730 730
 	 * @return string Value to used in the ORDER clause, if `$orderby` is valid.
731 731
 	 */
732
-	protected function parse_orderby( $orderby ) {
732
+	protected function parse_orderby($orderby) {
733 733
 		global $wpdb;
734 734
 
735 735
 		$meta_query_clauses = $this->meta_query->get_clauses();
736 736
 
737 737
 		$_orderby = '';
738
-		if ( in_array( $orderby, array( 'login', 'nicename', 'email', 'url', 'registered' ) ) ) {
739
-			$_orderby = 'user_' . $orderby;
740
-		} elseif ( in_array( $orderby, array( 'user_login', 'user_nicename', 'user_email', 'user_url', 'user_registered' ) ) ) {
738
+		if (in_array($orderby, array('login', 'nicename', 'email', 'url', 'registered'))) {
739
+			$_orderby = 'user_'.$orderby;
740
+		} elseif (in_array($orderby, array('user_login', 'user_nicename', 'user_email', 'user_url', 'user_registered'))) {
741 741
 			$_orderby = $orderby;
742
-		} elseif ( 'name' == $orderby || 'display_name' == $orderby ) {
742
+		} elseif ('name' == $orderby || 'display_name' == $orderby) {
743 743
 			$_orderby = 'display_name';
744
-		} elseif ( 'post_count' == $orderby ) {
744
+		} elseif ('post_count' == $orderby) {
745 745
 			// todo: avoid the JOIN
746
-			$where = get_posts_by_author_sql( 'post' );
746
+			$where = get_posts_by_author_sql('post');
747 747
 			$this->query_from .= " LEFT OUTER JOIN (
748 748
 				SELECT post_author, COUNT(*) as post_count
749 749
 				FROM $wpdb->posts
@@ -752,27 +752,27 @@  discard block
 block discarded – undo
752 752
 			) p ON ({$wpdb->users}.ID = p.post_author)
753 753
 			";
754 754
 			$_orderby = 'post_count';
755
-		} elseif ( 'ID' == $orderby || 'id' == $orderby ) {
755
+		} elseif ('ID' == $orderby || 'id' == $orderby) {
756 756
 			$_orderby = 'ID';
757
-		} elseif ( 'meta_value' == $orderby || $this->get( 'meta_key' ) == $orderby ) {
757
+		} elseif ('meta_value' == $orderby || $this->get('meta_key') == $orderby) {
758 758
 			$_orderby = "$wpdb->usermeta.meta_value";
759
-		} elseif ( 'meta_value_num' == $orderby ) {
759
+		} elseif ('meta_value_num' == $orderby) {
760 760
 			$_orderby = "$wpdb->usermeta.meta_value+0";
761
-		} elseif ( 'include' === $orderby && ! empty( $this->query_vars['include'] ) ) {
762
-			$include = wp_parse_id_list( $this->query_vars['include'] );
763
-			$include_sql = implode( ',', $include );
761
+		} elseif ('include' === $orderby && ! empty($this->query_vars['include'])) {
762
+			$include = wp_parse_id_list($this->query_vars['include']);
763
+			$include_sql = implode(',', $include);
764 764
 			$_orderby = "FIELD( $wpdb->users.ID, $include_sql )";
765
-		} elseif ( 'nicename__in' === $orderby ) {
766
-			$sanitized_nicename__in = array_map( 'esc_sql', $this->query_vars['nicename__in'] );
767
-			$nicename__in = implode( "','", $sanitized_nicename__in );
765
+		} elseif ('nicename__in' === $orderby) {
766
+			$sanitized_nicename__in = array_map('esc_sql', $this->query_vars['nicename__in']);
767
+			$nicename__in = implode("','", $sanitized_nicename__in);
768 768
 			$_orderby = "FIELD( user_nicename, '$nicename__in' )";
769
-		} elseif ( 'login__in' === $orderby ) {
770
-			$sanitized_login__in = array_map( 'esc_sql', $this->query_vars['login__in'] );
771
-			$login__in = implode( "','", $sanitized_login__in );
769
+		} elseif ('login__in' === $orderby) {
770
+			$sanitized_login__in = array_map('esc_sql', $this->query_vars['login__in']);
771
+			$login__in = implode("','", $sanitized_login__in);
772 772
 			$_orderby = "FIELD( user_login, '$login__in' )";
773
-		} elseif ( isset( $meta_query_clauses[ $orderby ] ) ) {
774
-			$meta_clause = $meta_query_clauses[ $orderby ];
775
-			$_orderby = sprintf( "CAST(%s.meta_value AS %s)", esc_sql( $meta_clause['alias'] ), esc_sql( $meta_clause['cast'] ) );
773
+		} elseif (isset($meta_query_clauses[$orderby])) {
774
+			$meta_clause = $meta_query_clauses[$orderby];
775
+			$_orderby = sprintf("CAST(%s.meta_value AS %s)", esc_sql($meta_clause['alias']), esc_sql($meta_clause['cast']));
776 776
 		}
777 777
 
778 778
 		return $_orderby;
@@ -787,12 +787,12 @@  discard block
 block discarded – undo
787 787
 	 * @param string $order The 'order' query variable.
788 788
 	 * @return string The sanitized 'order' query variable.
789 789
 	 */
790
-	protected function parse_order( $order ) {
791
-		if ( ! is_string( $order ) || empty( $order ) ) {
790
+	protected function parse_order($order) {
791
+		if ( ! is_string($order) || empty($order)) {
792 792
 			return 'DESC';
793 793
 		}
794 794
 
795
-		if ( 'ASC' === strtoupper( $order ) ) {
795
+		if ('ASC' === strtoupper($order)) {
796 796
 			return 'ASC';
797 797
 		} else {
798 798
 			return 'DESC';
@@ -808,8 +808,8 @@  discard block
 block discarded – undo
808 808
 	 * @param string $name Property to get.
809 809
 	 * @return mixed Property.
810 810
 	 */
811
-	public function __get( $name ) {
812
-		if ( in_array( $name, $this->compat_fields ) ) {
811
+	public function __get($name) {
812
+		if (in_array($name, $this->compat_fields)) {
813 813
 			return $this->$name;
814 814
 		}
815 815
 	}
@@ -824,8 +824,8 @@  discard block
 block discarded – undo
824 824
 	 * @param mixed  $value Property value.
825 825
 	 * @return mixed Newly-set property.
826 826
 	 */
827
-	public function __set( $name, $value ) {
828
-		if ( in_array( $name, $this->compat_fields ) ) {
827
+	public function __set($name, $value) {
828
+		if (in_array($name, $this->compat_fields)) {
829 829
 			return $this->$name = $value;
830 830
 		}
831 831
 	}
@@ -839,9 +839,9 @@  discard block
 block discarded – undo
839 839
 	 * @param string $name Property to check if set.
840 840
 	 * @return bool Whether the property is set.
841 841
 	 */
842
-	public function __isset( $name ) {
843
-		if ( in_array( $name, $this->compat_fields ) ) {
844
-			return isset( $this->$name );
842
+	public function __isset($name) {
843
+		if (in_array($name, $this->compat_fields)) {
844
+			return isset($this->$name);
845 845
 		}
846 846
 	}
847 847
 
@@ -853,9 +853,9 @@  discard block
 block discarded – undo
853 853
 	 *
854 854
 	 * @param string $name Property to unset.
855 855
 	 */
856
-	public function __unset( $name ) {
857
-		if ( in_array( $name, $this->compat_fields ) ) {
858
-			unset( $this->$name );
856
+	public function __unset($name) {
857
+		if (in_array($name, $this->compat_fields)) {
858
+			unset($this->$name);
859 859
 		}
860 860
 	}
861 861
 
@@ -869,9 +869,9 @@  discard block
 block discarded – undo
869 869
 	 * @param array    $arguments Arguments to pass when calling.
870 870
 	 * @return mixed Return value of the callback, false otherwise.
871 871
 	 */
872
-	public function __call( $name, $arguments ) {
873
-		if ( 'get_search_sql' === $name ) {
874
-			return call_user_func_array( array( $this, $name ), $arguments );
872
+	public function __call($name, $arguments) {
873
+		if ('get_search_sql' === $name) {
874
+			return call_user_func_array(array($this, $name), $arguments);
875 875
 		}
876 876
 		return false;
877 877
 	}
Please login to merge, or discard this patch.
Braces   +42 added lines, -32 removed lines patch added patch discarded remove patch
@@ -255,8 +255,9 @@  discard block
 block discarded – undo
255 255
 			$this->query_fields = "$wpdb->users.ID";
256 256
 		}
257 257
 
258
-		if ( isset( $qv['count_total'] ) && $qv['count_total'] )
259
-			$this->query_fields = 'SQL_CALC_FOUND_ROWS ' . $this->query_fields;
258
+		if ( isset( $qv['count_total'] ) && $qv['count_total'] ) {
259
+					$this->query_fields = 'SQL_CALC_FOUND_ROWS ' . $this->query_fields;
260
+		}
260 261
 
261 262
 		$this->query_from = "FROM $wpdb->users";
262 263
 		$this->query_where = "WHERE 1=1";
@@ -504,35 +505,40 @@  discard block
 block discarded – undo
504 505
 		}
505 506
 
506 507
 		$search = '';
507
-		if ( isset( $qv['search'] ) )
508
-			$search = trim( $qv['search'] );
508
+		if ( isset( $qv['search'] ) ) {
509
+					$search = trim( $qv['search'] );
510
+		}
509 511
 
510 512
 		if ( $search ) {
511 513
 			$leading_wild = ( ltrim($search, '*') != $search );
512 514
 			$trailing_wild = ( rtrim($search, '*') != $search );
513
-			if ( $leading_wild && $trailing_wild )
514
-				$wild = 'both';
515
-			elseif ( $leading_wild )
516
-				$wild = 'leading';
517
-			elseif ( $trailing_wild )
518
-				$wild = 'trailing';
519
-			else
520
-				$wild = false;
521
-			if ( $wild )
522
-				$search = trim($search, '*');
515
+			if ( $leading_wild && $trailing_wild ) {
516
+							$wild = 'both';
517
+			} elseif ( $leading_wild ) {
518
+							$wild = 'leading';
519
+			} elseif ( $trailing_wild ) {
520
+							$wild = 'trailing';
521
+			} else {
522
+							$wild = false;
523
+			}
524
+			if ( $wild ) {
525
+							$search = trim($search, '*');
526
+			}
523 527
 
524 528
 			$search_columns = array();
525
-			if ( $qv['search_columns'] )
526
-				$search_columns = array_intersect( $qv['search_columns'], array( 'ID', 'user_login', 'user_email', 'user_url', 'user_nicename' ) );
529
+			if ( $qv['search_columns'] ) {
530
+							$search_columns = array_intersect( $qv['search_columns'], array( 'ID', 'user_login', 'user_email', 'user_url', 'user_nicename' ) );
531
+			}
527 532
 			if ( ! $search_columns ) {
528
-				if ( false !== strpos( $search, '@') )
529
-					$search_columns = array('user_email');
530
-				elseif ( is_numeric($search) )
531
-					$search_columns = array('user_login', 'ID');
532
-				elseif ( preg_match('|^https?://|', $search) && ! ( is_multisite() && wp_is_large_network( 'users' ) ) )
533
-					$search_columns = array('user_url');
534
-				else
535
-					$search_columns = array('user_login', 'user_url', 'user_email', 'user_nicename', 'display_name');
533
+				if ( false !== strpos( $search, '@') ) {
534
+									$search_columns = array('user_email');
535
+				} elseif ( is_numeric($search) ) {
536
+									$search_columns = array('user_login', 'ID');
537
+				} elseif ( preg_match('|^https?://|', $search) && ! ( is_multisite() && wp_is_large_network( 'users' ) ) ) {
538
+									$search_columns = array('user_url');
539
+				} else {
540
+									$search_columns = array('user_login', 'user_url', 'user_email', 'user_nicename', 'display_name');
541
+				}
536 542
 			}
537 543
 
538 544
 			/**
@@ -611,18 +617,21 @@  discard block
 block discarded – undo
611 617
 		 *
612 618
 		 * @param string $sql The SELECT FOUND_ROWS() query for the current WP_User_Query.
613 619
 		 */
614
-		if ( isset( $qv['count_total'] ) && $qv['count_total'] )
615
-			$this->total_users = (int) $wpdb->get_var( apply_filters( 'found_users_query', 'SELECT FOUND_ROWS()' ) );
620
+		if ( isset( $qv['count_total'] ) && $qv['count_total'] ) {
621
+					$this->total_users = (int) $wpdb->get_var( apply_filters( 'found_users_query', 'SELECT FOUND_ROWS()' ) );
622
+		}
616 623
 
617
-		if ( !$this->results )
618
-			return;
624
+		if ( !$this->results ) {
625
+					return;
626
+		}
619 627
 
620 628
 		if ( 'all_with_meta' == $qv['fields'] ) {
621 629
 			cache_users( $this->results );
622 630
 
623 631
 			$r = array();
624
-			foreach ( $this->results as $userid )
625
-				$r[ $userid ] = new WP_User( $userid, '', $qv['blog_id'] );
632
+			foreach ( $this->results as $userid ) {
633
+							$r[ $userid ] = new WP_User( $userid, '', $qv['blog_id'] );
634
+			}
626 635
 
627 636
 			$this->results = $r;
628 637
 		} elseif ( 'all' == $qv['fields'] ) {
@@ -642,8 +651,9 @@  discard block
 block discarded – undo
642 651
 	 * @return mixed
643 652
 	 */
644 653
 	public function get( $query_var ) {
645
-		if ( isset( $this->query_vars[$query_var] ) )
646
-			return $this->query_vars[$query_var];
654
+		if ( isset( $this->query_vars[$query_var] ) ) {
655
+					return $this->query_vars[$query_var];
656
+		}
647 657
 
648 658
 		return null;
649 659
 	}
Please login to merge, or discard this patch.
src/wp-includes/class-wp-user.php 3 patches
Doc Comments   +1 added lines, -6 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 *
112 112
 	 * @global wpdb $wpdb WordPress database abstraction object.
113 113
 	 *
114
-	 * @param int|string|stdClass|WP_User $id User's ID, a WP_User object, or a user object from the DB.
114
+	 * @param integer $id User's ID, a WP_User object, or a user object from the DB.
115 115
 	 * @param string $name Optional. User's username
116 116
 	 * @param int $blog_id Optional Site ID, defaults to current site.
117 117
 	 */
@@ -702,11 +702,6 @@  discard block
 block discarded – undo
702 702
 	 * @see map_meta_cap()
703 703
 	 *
704 704
 	 * @param string $cap           Capability name.
705
-	 * @param int    $object_id,... Optional. ID of the specific object to check against if `$cap` is a "meta" cap.
706
-	 *                              "Meta" capabilities, e.g. 'edit_post', 'edit_user', etc., are capabilities used
707
-	 *                              by map_meta_cap() to map to other "primitive" capabilities, e.g. 'edit_posts',
708
-	 *                              'edit_others_posts', etc. The parameter is accessed via func_get_args() and passed
709
-	 *                              to map_meta_cap().
710 705
 	 * @return bool Whether the current user has the given capability. If `$cap` is a meta cap and `$object_id` is
711 706
 	 *              passed, whether the current user has the given meta capability for the given object.
712 707
 	 */
Please login to merge, or discard this patch.
Braces   +55 added lines, -38 removed lines patch added patch discarded remove patch
@@ -192,17 +192,20 @@  discard block
 block discarded – undo
192 192
 		if ( 'id' == $field ) {
193 193
 			// Make sure the value is numeric to avoid casting objects, for example,
194 194
 			// to int 1.
195
-			if ( ! is_numeric( $value ) )
196
-				return false;
195
+			if ( ! is_numeric( $value ) ) {
196
+							return false;
197
+			}
197 198
 			$value = intval( $value );
198
-			if ( $value < 1 )
199
-				return false;
199
+			if ( $value < 1 ) {
200
+							return false;
201
+			}
200 202
 		} else {
201 203
 			$value = trim( $value );
202 204
 		}
203 205
 
204
-		if ( !$value )
205
-			return false;
206
+		if ( !$value ) {
207
+					return false;
208
+		}
206 209
 
207 210
 		switch ( $field ) {
208 211
 			case 'id':
@@ -227,14 +230,16 @@  discard block
 block discarded – undo
227 230
 		}
228 231
 
229 232
 		if ( false !== $user_id ) {
230
-			if ( $user = wp_cache_get( $user_id, 'users' ) )
231
-				return $user;
233
+			if ( $user = wp_cache_get( $user_id, 'users' ) ) {
234
+							return $user;
235
+			}
232 236
 		}
233 237
 
234 238
 		if ( !$user = $wpdb->get_row( $wpdb->prepare(
235 239
 			"SELECT * FROM $wpdb->users WHERE $db_field = %s", $value
236
-		) ) )
237
-			return false;
240
+		) ) ) {
241
+					return false;
242
+		}
238 243
 
239 244
 		update_user_caches( $user );
240 245
 
@@ -279,11 +284,13 @@  discard block
 block discarded – undo
279 284
 			$key = 'ID';
280 285
 		}
281 286
 
282
-		if ( isset( $this->data->$key ) )
283
-			return true;
287
+		if ( isset( $this->data->$key ) ) {
288
+					return true;
289
+		}
284 290
 
285
-		if ( isset( self::$back_compat_keys[ $key ] ) )
286
-			$key = self::$back_compat_keys[ $key ];
291
+		if ( isset( self::$back_compat_keys[ $key ] ) ) {
292
+					$key = self::$back_compat_keys[ $key ];
293
+		}
287 294
 
288 295
 		return metadata_exists( 'user', $this->ID, $key );
289 296
 	}
@@ -312,8 +319,9 @@  discard block
 block discarded – undo
312 319
 		if ( isset( $this->data->$key ) ) {
313 320
 			$value = $this->data->$key;
314 321
 		} else {
315
-			if ( isset( self::$back_compat_keys[ $key ] ) )
316
-				$key = self::$back_compat_keys[ $key ];
322
+			if ( isset( self::$back_compat_keys[ $key ] ) ) {
323
+							$key = self::$back_compat_keys[ $key ];
324
+			}
317 325
 			$value = get_user_meta( $this->ID, $key, true );
318 326
 		}
319 327
 
@@ -449,15 +457,17 @@  discard block
 block discarded – undo
449 457
 	protected function _init_caps( $cap_key = '' ) {
450 458
 		global $wpdb;
451 459
 
452
-		if ( empty($cap_key) )
453
-			$this->cap_key = $wpdb->get_blog_prefix() . 'capabilities';
454
-		else
455
-			$this->cap_key = $cap_key;
460
+		if ( empty($cap_key) ) {
461
+					$this->cap_key = $wpdb->get_blog_prefix() . 'capabilities';
462
+		} else {
463
+					$this->cap_key = $cap_key;
464
+		}
456 465
 
457 466
 		$this->caps = get_user_meta( $this->ID, $this->cap_key, true );
458 467
 
459
-		if ( ! is_array( $this->caps ) )
460
-			$this->caps = array();
468
+		if ( ! is_array( $this->caps ) ) {
469
+					$this->caps = array();
470
+		}
461 471
 
462 472
 		$this->get_role_caps();
463 473
 	}
@@ -479,8 +489,9 @@  discard block
 block discarded – undo
479 489
 		$wp_roles = wp_roles();
480 490
 
481 491
 		//Filter out caps that are not role names and assign to $this->roles
482
-		if ( is_array( $this->caps ) )
483
-			$this->roles = array_filter( array_keys( $this->caps ), array( $wp_roles, 'is_role' ) );
492
+		if ( is_array( $this->caps ) ) {
493
+					$this->roles = array_filter( array_keys( $this->caps ), array( $wp_roles, 'is_role' ) );
494
+		}
484 495
 
485 496
 		//Build $allcaps from role caps, overlay user's $caps
486 497
 		$this->allcaps = array();
@@ -533,8 +544,9 @@  discard block
 block discarded – undo
533 544
 	 * @param string $role Role name.
534 545
 	 */
535 546
 	public function remove_role( $role ) {
536
-		if ( !in_array($role, $this->roles) )
537
-			return;
547
+		if ( !in_array($role, $this->roles) ) {
548
+					return;
549
+		}
538 550
 		unset( $this->caps[$role] );
539 551
 		update_user_meta( $this->ID, $this->cap_key, $this->caps );
540 552
 		$this->get_role_caps();
@@ -564,11 +576,13 @@  discard block
 block discarded – undo
564 576
 	 * @param string $role Role name.
565 577
 	 */
566 578
 	public function set_role( $role ) {
567
-		if ( 1 == count( $this->roles ) && $role == current( $this->roles ) )
568
-			return;
579
+		if ( 1 == count( $this->roles ) && $role == current( $this->roles ) ) {
580
+					return;
581
+		}
569 582
 
570
-		foreach ( (array) $this->roles as $oldrole )
571
-			unset( $this->caps[$oldrole] );
583
+		foreach ( (array) $this->roles as $oldrole ) {
584
+					unset( $this->caps[$oldrole] );
585
+		}
572 586
 
573 587
 		$old_roles = $this->roles;
574 588
 		if ( !empty( $role ) ) {
@@ -722,8 +736,9 @@  discard block
 block discarded – undo
722 736
 
723 737
 		// Multisite super admin has all caps by definition, Unless specifically denied.
724 738
 		if ( is_multisite() && is_super_admin( $this->ID ) ) {
725
-			if ( in_array('do_not_allow', $caps) )
726
-				return false;
739
+			if ( in_array('do_not_allow', $caps) ) {
740
+							return false;
741
+			}
727 742
 			return true;
728 743
 		}
729 744
 
@@ -745,8 +760,9 @@  discard block
 block discarded – undo
745 760
 
746 761
 		// Must have ALL requested caps.
747 762
 		foreach ( (array) $caps as $cap ) {
748
-			if ( empty( $capabilities[ $cap ] ) )
749
-				return false;
763
+			if ( empty( $capabilities[ $cap ] ) ) {
764
+							return false;
765
+			}
750 766
 		}
751 767
 
752 768
 		return true;
@@ -778,10 +794,11 @@  discard block
 block discarded – undo
778 794
 	 */
779 795
 	public function for_blog( $blog_id = '' ) {
780 796
 		global $wpdb;
781
-		if ( ! empty( $blog_id ) )
782
-			$cap_key = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities';
783
-		else
784
-			$cap_key = '';
797
+		if ( ! empty( $blog_id ) ) {
798
+					$cap_key = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities';
799
+		} else {
800
+					$cap_key = '';
801
+		}
785 802
 		$this->_init_caps( $cap_key );
786 803
 	}
787 804
 }
Please login to merge, or discard this patch.
Spacing   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -115,40 +115,40 @@  discard block
 block discarded – undo
115 115
 	 * @param string $name Optional. User's username
116 116
 	 * @param int $blog_id Optional Site ID, defaults to current site.
117 117
 	 */
118
-	public function __construct( $id = 0, $name = '', $blog_id = '' ) {
119
-		if ( ! isset( self::$back_compat_keys ) ) {
118
+	public function __construct($id = 0, $name = '', $blog_id = '') {
119
+		if ( ! isset(self::$back_compat_keys)) {
120 120
 			$prefix = $GLOBALS['wpdb']->prefix;
121 121
 			self::$back_compat_keys = array(
122 122
 				'user_firstname' => 'first_name',
123 123
 				'user_lastname' => 'last_name',
124 124
 				'user_description' => 'description',
125
-				'user_level' => $prefix . 'user_level',
126
-				$prefix . 'usersettings' => $prefix . 'user-settings',
127
-				$prefix . 'usersettingstime' => $prefix . 'user-settings-time',
125
+				'user_level' => $prefix.'user_level',
126
+				$prefix.'usersettings' => $prefix.'user-settings',
127
+				$prefix.'usersettingstime' => $prefix.'user-settings-time',
128 128
 			);
129 129
 		}
130 130
 
131
-		if ( $id instanceof WP_User ) {
132
-			$this->init( $id->data, $blog_id );
131
+		if ($id instanceof WP_User) {
132
+			$this->init($id->data, $blog_id);
133 133
 			return;
134
-		} elseif ( is_object( $id ) ) {
135
-			$this->init( $id, $blog_id );
134
+		} elseif (is_object($id)) {
135
+			$this->init($id, $blog_id);
136 136
 			return;
137 137
 		}
138 138
 
139
-		if ( ! empty( $id ) && ! is_numeric( $id ) ) {
139
+		if ( ! empty($id) && ! is_numeric($id)) {
140 140
 			$name = $id;
141 141
 			$id = 0;
142 142
 		}
143 143
 
144
-		if ( $id ) {
145
-			$data = self::get_data_by( 'id', $id );
144
+		if ($id) {
145
+			$data = self::get_data_by('id', $id);
146 146
 		} else {
147
-			$data = self::get_data_by( 'login', $name );
147
+			$data = self::get_data_by('login', $name);
148 148
 		}
149 149
 
150
-		if ( $data ) {
151
-			$this->init( $data, $blog_id );
150
+		if ($data) {
151
+			$this->init($data, $blog_id);
152 152
 		} else {
153 153
 			$this->data = new stdClass;
154 154
 		}
@@ -160,11 +160,11 @@  discard block
 block discarded – undo
160 160
 	 * @param object $data    User DB row object.
161 161
 	 * @param int    $blog_id Optional. The site ID to initialize for.
162 162
 	 */
163
-	public function init( $data, $blog_id = '' ) {
163
+	public function init($data, $blog_id = '') {
164 164
 		$this->data = $data;
165 165
 		$this->ID = (int) $data->ID;
166 166
 
167
-		$this->for_blog( $blog_id );
167
+		$this->for_blog($blog_id);
168 168
 	}
169 169
 
170 170
 	/**
@@ -181,30 +181,30 @@  discard block
 block discarded – undo
181 181
 	 * @param string|int $value The field value
182 182
 	 * @return object|false Raw user object
183 183
 	 */
184
-	public static function get_data_by( $field, $value ) {
184
+	public static function get_data_by($field, $value) {
185 185
 		global $wpdb;
186 186
 
187 187
 		// 'ID' is an alias of 'id'.
188
-		if ( 'ID' === $field ) {
188
+		if ('ID' === $field) {
189 189
 			$field = 'id';
190 190
 		}
191 191
 
192
-		if ( 'id' == $field ) {
192
+		if ('id' == $field) {
193 193
 			// Make sure the value is numeric to avoid casting objects, for example,
194 194
 			// to int 1.
195
-			if ( ! is_numeric( $value ) )
195
+			if ( ! is_numeric($value))
196 196
 				return false;
197
-			$value = intval( $value );
198
-			if ( $value < 1 )
197
+			$value = intval($value);
198
+			if ($value < 1)
199 199
 				return false;
200 200
 		} else {
201
-			$value = trim( $value );
201
+			$value = trim($value);
202 202
 		}
203 203
 
204
-		if ( !$value )
204
+		if ( ! $value)
205 205
 			return false;
206 206
 
207
-		switch ( $field ) {
207
+		switch ($field) {
208 208
 			case 'id':
209 209
 				$user_id = $value;
210 210
 				$db_field = 'ID';
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 				$db_field = 'user_email';
219 219
 				break;
220 220
 			case 'login':
221
-				$value = sanitize_user( $value );
221
+				$value = sanitize_user($value);
222 222
 				$user_id = wp_cache_get($value, 'userlogins');
223 223
 				$db_field = 'user_login';
224 224
 				break;
@@ -226,17 +226,17 @@  discard block
 block discarded – undo
226 226
 				return false;
227 227
 		}
228 228
 
229
-		if ( false !== $user_id ) {
230
-			if ( $user = wp_cache_get( $user_id, 'users' ) )
229
+		if (false !== $user_id) {
230
+			if ($user = wp_cache_get($user_id, 'users'))
231 231
 				return $user;
232 232
 		}
233 233
 
234
-		if ( !$user = $wpdb->get_row( $wpdb->prepare(
234
+		if ( ! $user = $wpdb->get_row($wpdb->prepare(
235 235
 			"SELECT * FROM $wpdb->users WHERE $db_field = %s", $value
236
-		) ) )
236
+		)))
237 237
 			return false;
238 238
 
239
-		update_user_caches( $user );
239
+		update_user_caches($user);
240 240
 
241 241
 		return $user;
242 242
 	}
@@ -251,9 +251,9 @@  discard block
 block discarded – undo
251 251
 	 * @param array    $arguments Arguments to pass when calling.
252 252
 	 * @return mixed|false Return value of the callback, false otherwise.
253 253
 	 */
254
-	public function __call( $name, $arguments ) {
255
-		if ( '_init_caps' === $name ) {
256
-			return call_user_func_array( array( $this, $name ), $arguments );
254
+	public function __call($name, $arguments) {
255
+		if ('_init_caps' === $name) {
256
+			return call_user_func_array(array($this, $name), $arguments);
257 257
 		}
258 258
 		return false;
259 259
 	}
@@ -267,25 +267,25 @@  discard block
 block discarded – undo
267 267
 	 * @param string $key User meta key to check if set.
268 268
 	 * @return bool Whether the given user meta key is set.
269 269
 	 */
270
-	public function __isset( $key ) {
271
-		if ( 'id' == $key ) {
272
-			_deprecated_argument( 'WP_User->id', '2.1.0',
270
+	public function __isset($key) {
271
+		if ('id' == $key) {
272
+			_deprecated_argument('WP_User->id', '2.1.0',
273 273
 				sprintf(
274 274
 					/* translators: %s: WP_User->ID */
275
-					__( 'Use %s instead.' ),
275
+					__('Use %s instead.'),
276 276
 					'<code>WP_User->ID</code>'
277 277
 				)
278 278
 			);
279 279
 			$key = 'ID';
280 280
 		}
281 281
 
282
-		if ( isset( $this->data->$key ) )
282
+		if (isset($this->data->$key))
283 283
 			return true;
284 284
 
285
-		if ( isset( self::$back_compat_keys[ $key ] ) )
286
-			$key = self::$back_compat_keys[ $key ];
285
+		if (isset(self::$back_compat_keys[$key]))
286
+			$key = self::$back_compat_keys[$key];
287 287
 
288
-		return metadata_exists( 'user', $this->ID, $key );
288
+		return metadata_exists('user', $this->ID, $key);
289 289
 	}
290 290
 
291 291
 	/**
@@ -297,28 +297,28 @@  discard block
 block discarded – undo
297 297
 	 * @param string $key User meta key to retrieve.
298 298
 	 * @return mixed Value of the given user meta key (if set). If `$key` is 'id', the user ID.
299 299
 	 */
300
-	public function __get( $key ) {
301
-		if ( 'id' == $key ) {
302
-			_deprecated_argument( 'WP_User->id', '2.1.0',
300
+	public function __get($key) {
301
+		if ('id' == $key) {
302
+			_deprecated_argument('WP_User->id', '2.1.0',
303 303
 				sprintf(
304 304
 					/* translators: %s: WP_User->ID */
305
-					__( 'Use %s instead.' ),
305
+					__('Use %s instead.'),
306 306
 					'<code>WP_User->ID</code>'
307 307
 				)
308 308
 			);
309 309
 			return $this->ID;
310 310
 		}
311 311
 
312
-		if ( isset( $this->data->$key ) ) {
312
+		if (isset($this->data->$key)) {
313 313
 			$value = $this->data->$key;
314 314
 		} else {
315
-			if ( isset( self::$back_compat_keys[ $key ] ) )
316
-				$key = self::$back_compat_keys[ $key ];
317
-			$value = get_user_meta( $this->ID, $key, true );
315
+			if (isset(self::$back_compat_keys[$key]))
316
+				$key = self::$back_compat_keys[$key];
317
+			$value = get_user_meta($this->ID, $key, true);
318 318
 		}
319 319
 
320
-		if ( $this->filter ) {
321
-			$value = sanitize_user_field( $key, $value, $this->ID, $this->filter );
320
+		if ($this->filter) {
321
+			$value = sanitize_user_field($key, $value, $this->ID, $this->filter);
322 322
 		}
323 323
 
324 324
 		return $value;
@@ -336,12 +336,12 @@  discard block
 block discarded – undo
336 336
 	 * @param string $key   User meta key.
337 337
 	 * @param mixed  $value User meta value.
338 338
 	 */
339
-	public function __set( $key, $value ) {
340
-		if ( 'id' == $key ) {
341
-			_deprecated_argument( 'WP_User->id', '2.1.0',
339
+	public function __set($key, $value) {
340
+		if ('id' == $key) {
341
+			_deprecated_argument('WP_User->id', '2.1.0',
342 342
 				sprintf(
343 343
 					/* translators: %s: WP_User->ID */
344
-					__( 'Use %s instead.' ),
344
+					__('Use %s instead.'),
345 345
 					'<code>WP_User->ID</code>'
346 346
 				)
347 347
 			);
@@ -360,23 +360,23 @@  discard block
 block discarded – undo
360 360
 	 *
361 361
 	 * @param string $key User meta key to unset.
362 362
 	 */
363
-	public function __unset( $key ) {
364
-		if ( 'id' == $key ) {
365
-			_deprecated_argument( 'WP_User->id', '2.1.0',
363
+	public function __unset($key) {
364
+		if ('id' == $key) {
365
+			_deprecated_argument('WP_User->id', '2.1.0',
366 366
 				sprintf(
367 367
 					/* translators: %s: WP_User->ID */
368
-					__( 'Use %s instead.' ),
368
+					__('Use %s instead.'),
369 369
 					'<code>WP_User->ID</code>'
370 370
 				)
371 371
 			);
372 372
 		}
373 373
 
374
-		if ( isset( $this->data->$key ) ) {
375
-			unset( $this->data->$key );
374
+		if (isset($this->data->$key)) {
375
+			unset($this->data->$key);
376 376
 		}
377 377
 
378
-		if ( isset( self::$back_compat_keys[ $key ] ) ) {
379
-			unset( self::$back_compat_keys[ $key ] );
378
+		if (isset(self::$back_compat_keys[$key])) {
379
+			unset(self::$back_compat_keys[$key]);
380 380
 		}
381 381
 	}
382 382
 
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 	 * @return bool True if user exists in the database, false if not.
390 390
 	 */
391 391
 	public function exists() {
392
-		return ! empty( $this->ID );
392
+		return ! empty($this->ID);
393 393
 	}
394 394
 
395 395
 	/**
@@ -402,8 +402,8 @@  discard block
 block discarded – undo
402 402
 	 * @param string $key Property
403 403
 	 * @return mixed
404 404
 	 */
405
-	public function get( $key ) {
406
-		return $this->__get( $key );
405
+	public function get($key) {
406
+		return $this->__get($key);
407 407
 	}
408 408
 
409 409
 	/**
@@ -416,8 +416,8 @@  discard block
 block discarded – undo
416 416
 	 * @param string $key Property
417 417
 	 * @return bool
418 418
 	 */
419
-	public function has_prop( $key ) {
420
-		return $this->__isset( $key );
419
+	public function has_prop($key) {
420
+		return $this->__isset($key);
421 421
 	}
422 422
 
423 423
 	/**
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 	 * @return array Array representation.
429 429
 	 */
430 430
 	public function to_array() {
431
-		return get_object_vars( $this->data );
431
+		return get_object_vars($this->data);
432 432
 	}
433 433
 
434 434
 	/**
@@ -446,17 +446,17 @@  discard block
 block discarded – undo
446 446
 	 *
447 447
 	 * @param string $cap_key Optional capability key
448 448
 	 */
449
-	protected function _init_caps( $cap_key = '' ) {
449
+	protected function _init_caps($cap_key = '') {
450 450
 		global $wpdb;
451 451
 
452
-		if ( empty($cap_key) )
453
-			$this->cap_key = $wpdb->get_blog_prefix() . 'capabilities';
452
+		if (empty($cap_key))
453
+			$this->cap_key = $wpdb->get_blog_prefix().'capabilities';
454 454
 		else
455 455
 			$this->cap_key = $cap_key;
456 456
 
457
-		$this->caps = get_user_meta( $this->ID, $this->cap_key, true );
457
+		$this->caps = get_user_meta($this->ID, $this->cap_key, true);
458 458
 
459
-		if ( ! is_array( $this->caps ) )
459
+		if ( ! is_array($this->caps))
460 460
 			$this->caps = array();
461 461
 
462 462
 		$this->get_role_caps();
@@ -479,16 +479,16 @@  discard block
 block discarded – undo
479 479
 		$wp_roles = wp_roles();
480 480
 
481 481
 		//Filter out caps that are not role names and assign to $this->roles
482
-		if ( is_array( $this->caps ) )
483
-			$this->roles = array_filter( array_keys( $this->caps ), array( $wp_roles, 'is_role' ) );
482
+		if (is_array($this->caps))
483
+			$this->roles = array_filter(array_keys($this->caps), array($wp_roles, 'is_role'));
484 484
 
485 485
 		//Build $allcaps from role caps, overlay user's $caps
486 486
 		$this->allcaps = array();
487
-		foreach ( (array) $this->roles as $role ) {
488
-			$the_role = $wp_roles->get_role( $role );
489
-			$this->allcaps = array_merge( (array) $this->allcaps, (array) $the_role->capabilities );
487
+		foreach ((array) $this->roles as $role) {
488
+			$the_role = $wp_roles->get_role($role);
489
+			$this->allcaps = array_merge((array) $this->allcaps, (array) $the_role->capabilities);
490 490
 		}
491
-		$this->allcaps = array_merge( (array) $this->allcaps, (array) $this->caps );
491
+		$this->allcaps = array_merge((array) $this->allcaps, (array) $this->caps);
492 492
 
493 493
 		return $this->allcaps;
494 494
 	}
@@ -503,13 +503,13 @@  discard block
 block discarded – undo
503 503
 	 *
504 504
 	 * @param string $role Role name.
505 505
 	 */
506
-	public function add_role( $role ) {
507
-		if ( empty( $role ) ) {
506
+	public function add_role($role) {
507
+		if (empty($role)) {
508 508
 			return;
509 509
 		}
510 510
 
511 511
 		$this->caps[$role] = true;
512
-		update_user_meta( $this->ID, $this->cap_key, $this->caps );
512
+		update_user_meta($this->ID, $this->cap_key, $this->caps);
513 513
 		$this->get_role_caps();
514 514
 		$this->update_user_level_from_caps();
515 515
 
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
 		 * @param int    $user_id The user ID.
522 522
 		 * @param string $role    The new role.
523 523
 		 */
524
-		do_action( 'add_user_role', $this->ID, $role );
524
+		do_action('add_user_role', $this->ID, $role);
525 525
 	}
526 526
 
527 527
 	/**
@@ -532,11 +532,11 @@  discard block
 block discarded – undo
532 532
 	 *
533 533
 	 * @param string $role Role name.
534 534
 	 */
535
-	public function remove_role( $role ) {
536
-		if ( !in_array($role, $this->roles) )
535
+	public function remove_role($role) {
536
+		if ( ! in_array($role, $this->roles))
537 537
 			return;
538
-		unset( $this->caps[$role] );
539
-		update_user_meta( $this->ID, $this->cap_key, $this->caps );
538
+		unset($this->caps[$role]);
539
+		update_user_meta($this->ID, $this->cap_key, $this->caps);
540 540
 		$this->get_role_caps();
541 541
 		$this->update_user_level_from_caps();
542 542
 
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 		 * @param int    $user_id The user ID.
549 549
 		 * @param string $role    The removed role.
550 550
 		 */
551
-		do_action( 'remove_user_role', $this->ID, $role );
551
+		do_action('remove_user_role', $this->ID, $role);
552 552
 	}
553 553
 
554 554
 	/**
@@ -563,21 +563,21 @@  discard block
 block discarded – undo
563 563
 	 *
564 564
 	 * @param string $role Role name.
565 565
 	 */
566
-	public function set_role( $role ) {
567
-		if ( 1 == count( $this->roles ) && $role == current( $this->roles ) )
566
+	public function set_role($role) {
567
+		if (1 == count($this->roles) && $role == current($this->roles))
568 568
 			return;
569 569
 
570
-		foreach ( (array) $this->roles as $oldrole )
571
-			unset( $this->caps[$oldrole] );
570
+		foreach ((array) $this->roles as $oldrole)
571
+			unset($this->caps[$oldrole]);
572 572
 
573 573
 		$old_roles = $this->roles;
574
-		if ( !empty( $role ) ) {
574
+		if ( ! empty($role)) {
575 575
 			$this->caps[$role] = true;
576
-			$this->roles = array( $role => true );
576
+			$this->roles = array($role => true);
577 577
 		} else {
578 578
 			$this->roles = false;
579 579
 		}
580
-		update_user_meta( $this->ID, $this->cap_key, $this->caps );
580
+		update_user_meta($this->ID, $this->cap_key, $this->caps);
581 581
 		$this->get_role_caps();
582 582
 		$this->update_user_level_from_caps();
583 583
 
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
 		 * @param string $role      The new role.
592 592
 		 * @param array  $old_roles An array of the user's previous roles.
593 593
 		 */
594
-		do_action( 'set_user_role', $this->ID, $role, $old_roles );
594
+		do_action('set_user_role', $this->ID, $role, $old_roles);
595 595
 	}
596 596
 
597 597
 	/**
@@ -613,10 +613,10 @@  discard block
 block discarded – undo
613 613
 	 * @param string $item Level capability name.
614 614
 	 * @return int Max Level.
615 615
 	 */
616
-	public function level_reduction( $max, $item ) {
617
-		if ( preg_match( '/^level_(10|[0-9])$/i', $item, $matches ) ) {
618
-			$level = intval( $matches[1] );
619
-			return max( $max, $level );
616
+	public function level_reduction($max, $item) {
617
+		if (preg_match('/^level_(10|[0-9])$/i', $item, $matches)) {
618
+			$level = intval($matches[1]);
619
+			return max($max, $level);
620 620
 		} else {
621 621
 			return $max;
622 622
 		}
@@ -636,8 +636,8 @@  discard block
 block discarded – undo
636 636
 	 */
637 637
 	public function update_user_level_from_caps() {
638 638
 		global $wpdb;
639
-		$this->user_level = array_reduce( array_keys( $this->allcaps ), array( $this, 'level_reduction' ), 0 );
640
-		update_user_meta( $this->ID, $wpdb->get_blog_prefix() . 'user_level', $this->user_level );
639
+		$this->user_level = array_reduce(array_keys($this->allcaps), array($this, 'level_reduction'), 0);
640
+		update_user_meta($this->ID, $wpdb->get_blog_prefix().'user_level', $this->user_level);
641 641
 	}
642 642
 
643 643
 	/**
@@ -649,9 +649,9 @@  discard block
 block discarded – undo
649 649
 	 * @param string $cap Capability name.
650 650
 	 * @param bool $grant Whether to grant capability to user.
651 651
 	 */
652
-	public function add_cap( $cap, $grant = true ) {
652
+	public function add_cap($cap, $grant = true) {
653 653
 		$this->caps[$cap] = $grant;
654
-		update_user_meta( $this->ID, $this->cap_key, $this->caps );
654
+		update_user_meta($this->ID, $this->cap_key, $this->caps);
655 655
 		$this->get_role_caps();
656 656
 		$this->update_user_level_from_caps();
657 657
 	}
@@ -664,12 +664,12 @@  discard block
 block discarded – undo
664 664
 	 *
665 665
 	 * @param string $cap Capability name.
666 666
 	 */
667
-	public function remove_cap( $cap ) {
668
-		if ( ! isset( $this->caps[ $cap ] ) ) {
667
+	public function remove_cap($cap) {
668
+		if ( ! isset($this->caps[$cap])) {
669 669
 			return;
670 670
 		}
671
-		unset( $this->caps[ $cap ] );
672
-		update_user_meta( $this->ID, $this->cap_key, $this->caps );
671
+		unset($this->caps[$cap]);
672
+		update_user_meta($this->ID, $this->cap_key, $this->caps);
673 673
 		$this->get_role_caps();
674 674
 		$this->update_user_level_from_caps();
675 675
 	}
@@ -685,8 +685,8 @@  discard block
 block discarded – undo
685 685
 	public function remove_all_caps() {
686 686
 		global $wpdb;
687 687
 		$this->caps = array();
688
-		delete_user_meta( $this->ID, $this->cap_key );
689
-		delete_user_meta( $this->ID, $wpdb->get_blog_prefix() . 'user_level' );
688
+		delete_user_meta($this->ID, $this->cap_key);
689
+		delete_user_meta($this->ID, $wpdb->get_blog_prefix().'user_level');
690 690
 		$this->get_role_caps();
691 691
 	}
692 692
 
@@ -710,19 +710,19 @@  discard block
 block discarded – undo
710 710
 	 * @return bool Whether the current user has the given capability. If `$cap` is a meta cap and `$object_id` is
711 711
 	 *              passed, whether the current user has the given meta capability for the given object.
712 712
 	 */
713
-	public function has_cap( $cap ) {
714
-		if ( is_numeric( $cap ) ) {
715
-			_deprecated_argument( __FUNCTION__, '2.0.0', __('Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead.') );
716
-			$cap = $this->translate_level_to_cap( $cap );
713
+	public function has_cap($cap) {
714
+		if (is_numeric($cap)) {
715
+			_deprecated_argument(__FUNCTION__, '2.0.0', __('Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead.'));
716
+			$cap = $this->translate_level_to_cap($cap);
717 717
 		}
718 718
 
719
-		$args = array_slice( func_get_args(), 1 );
720
-		$args = array_merge( array( $cap, $this->ID ), $args );
721
-		$caps = call_user_func_array( 'map_meta_cap', $args );
719
+		$args = array_slice(func_get_args(), 1);
720
+		$args = array_merge(array($cap, $this->ID), $args);
721
+		$caps = call_user_func_array('map_meta_cap', $args);
722 722
 
723 723
 		// Multisite super admin has all caps by definition, Unless specifically denied.
724
-		if ( is_multisite() && is_super_admin( $this->ID ) ) {
725
-			if ( in_array('do_not_allow', $caps) )
724
+		if (is_multisite() && is_super_admin($this->ID)) {
725
+			if (in_array('do_not_allow', $caps))
726 726
 				return false;
727 727
 			return true;
728 728
 		}
@@ -738,14 +738,14 @@  discard block
 block discarded – undo
738 738
 		 * @param array   $args    Optional parameters passed to has_cap(), typically object ID.
739 739
 		 * @param WP_User $user    The user object.
740 740
 		 */
741
-		$capabilities = apply_filters( 'user_has_cap', $this->allcaps, $caps, $args, $this );
741
+		$capabilities = apply_filters('user_has_cap', $this->allcaps, $caps, $args, $this);
742 742
 
743 743
 		// Everyone is allowed to exist.
744 744
 		$capabilities['exist'] = true;
745 745
 
746 746
 		// Must have ALL requested caps.
747
-		foreach ( (array) $caps as $cap ) {
748
-			if ( empty( $capabilities[ $cap ] ) )
747
+		foreach ((array) $caps as $cap) {
748
+			if (empty($capabilities[$cap]))
749 749
 				return false;
750 750
 		}
751 751
 
@@ -763,8 +763,8 @@  discard block
 block discarded – undo
763 763
 	 * @param int $level Level number, 1 to 10.
764 764
 	 * @return string
765 765
 	 */
766
-	public function translate_level_to_cap( $level ) {
767
-		return 'level_' . $level;
766
+	public function translate_level_to_cap($level) {
767
+		return 'level_'.$level;
768 768
 	}
769 769
 
770 770
 	/**
@@ -776,12 +776,12 @@  discard block
 block discarded – undo
776 776
 	 *
777 777
 	 * @param int $blog_id Optional. Site ID, defaults to current site.
778 778
 	 */
779
-	public function for_blog( $blog_id = '' ) {
779
+	public function for_blog($blog_id = '') {
780 780
 		global $wpdb;
781
-		if ( ! empty( $blog_id ) )
782
-			$cap_key = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities';
781
+		if ( ! empty($blog_id))
782
+			$cap_key = $wpdb->get_blog_prefix($blog_id).'capabilities';
783 783
 		else
784 784
 			$cap_key = '';
785
-		$this->_init_caps( $cap_key );
785
+		$this->_init_caps($cap_key);
786 786
 	}
787 787
 }
Please login to merge, or discard this patch.
src/wp-includes/customize/class-wp-customize-selective-refresh.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * @since 4.5.0
79 79
 	 * @access public
80 80
 	 *
81
-	 * @return array Partials.
81
+	 * @return WP_Customize_Partial[] Partials.
82 82
 	 */
83 83
 	public function partials() {
84 84
 		return $this->partials;
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 	 * @param string $errstr  Error string.
284 284
 	 * @param string $errfile Error file.
285 285
 	 * @param string $errline Error line.
286
-	 * @return true Always true.
286
+	 * @return boolean Always true.
287 287
 	 */
288 288
 	public function handle_error( $errno, $errstr, $errfile = null, $errline = null ) {
289 289
 		$this->triggered_errors[] = array(
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -65,11 +65,11 @@  discard block
 block discarded – undo
65 65
 	 *
66 66
 	 * @param WP_Customize_Manager $manager Manager instance.
67 67
 	 */
68
-	public function __construct( WP_Customize_Manager $manager ) {
68
+	public function __construct(WP_Customize_Manager $manager) {
69 69
 		$this->manager = $manager;
70
-		require_once( ABSPATH . WPINC . '/customize/class-wp-customize-partial.php' );
70
+		require_once(ABSPATH.WPINC.'/customize/class-wp-customize-partial.php');
71 71
 
72
-		add_action( 'customize_preview_init', array( $this, 'init_preview' ) );
72
+		add_action('customize_preview_init', array($this, 'init_preview'));
73 73
 	}
74 74
 
75 75
 	/**
@@ -113,22 +113,22 @@  discard block
 block discarded – undo
113 113
 	 * }
114 114
 	 * @return WP_Customize_Partial             The instance of the panel that was added.
115 115
 	 */
116
-	public function add_partial( $id, $args = array() ) {
117
-		if ( $id instanceof WP_Customize_Partial ) {
116
+	public function add_partial($id, $args = array()) {
117
+		if ($id instanceof WP_Customize_Partial) {
118 118
 			$partial = $id;
119 119
 		} else {
120 120
 			$class = 'WP_Customize_Partial';
121 121
 
122 122
 			/** This filter is documented in wp-includes/customize/class-wp-customize-selective-refresh.php */
123
-			$args = apply_filters( 'customize_dynamic_partial_args', $args, $id );
123
+			$args = apply_filters('customize_dynamic_partial_args', $args, $id);
124 124
 
125 125
 			/** This filter is documented in wp-includes/customize/class-wp-customize-selective-refresh.php */
126
-			$class = apply_filters( 'customize_dynamic_partial_class', $class, $id, $args );
126
+			$class = apply_filters('customize_dynamic_partial_class', $class, $id, $args);
127 127
 
128
-			$partial = new $class( $this, $id, $args );
128
+			$partial = new $class($this, $id, $args);
129 129
 		}
130 130
 
131
-		$this->partials[ $partial->id ] = $partial;
131
+		$this->partials[$partial->id] = $partial;
132 132
 		return $partial;
133 133
 	}
134 134
 
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
 	 * @param string $id Customize Partial ID.
142 142
 	 * @return WP_Customize_Partial|null The partial, if set. Otherwise null.
143 143
 	 */
144
-	public function get_partial( $id ) {
145
-		if ( isset( $this->partials[ $id ] ) ) {
146
-			return $this->partials[ $id ];
144
+	public function get_partial($id) {
145
+		if (isset($this->partials[$id])) {
146
+			return $this->partials[$id];
147 147
 		} else {
148 148
 			return null;
149 149
 		}
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
 	 *
158 158
 	 * @param string $id Customize Partial ID.
159 159
 	 */
160
-	public function remove_partial( $id ) {
161
-		unset( $this->partials[ $id ] );
160
+	public function remove_partial($id) {
161
+		unset($this->partials[$id]);
162 162
 	}
163 163
 
164 164
 	/**
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 	 * @access public
169 169
 	 */
170 170
 	public function init_preview() {
171
-		add_action( 'template_redirect', array( $this, 'handle_render_partials_request' ) );
172
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_preview_scripts' ) );
171
+		add_action('template_redirect', array($this, 'handle_render_partials_request'));
172
+		add_action('wp_enqueue_scripts', array($this, 'enqueue_preview_scripts'));
173 173
 	}
174 174
 
175 175
 	/**
@@ -179,8 +179,8 @@  discard block
 block discarded – undo
179 179
 	 * @access public
180 180
 	 */
181 181
 	public function enqueue_preview_scripts() {
182
-		wp_enqueue_script( 'customize-selective-refresh' );
183
-		add_action( 'wp_footer', array( $this, 'export_preview_data' ), 1000 );
182
+		wp_enqueue_script('customize-selective-refresh');
183
+		add_action('wp_footer', array($this, 'export_preview_data'), 1000);
184 184
 	}
185 185
 
186 186
 	/**
@@ -192,23 +192,23 @@  discard block
 block discarded – undo
192 192
 	public function export_preview_data() {
193 193
 		$partials = array();
194 194
 
195
-		foreach ( $this->partials() as $partial ) {
196
-			if ( $partial->check_capabilities() ) {
197
-				$partials[ $partial->id ] = $partial->json();
195
+		foreach ($this->partials() as $partial) {
196
+			if ($partial->check_capabilities()) {
197
+				$partials[$partial->id] = $partial->json();
198 198
 			}
199 199
 		}
200 200
 
201
-		$switched_locale = switch_to_locale( get_user_locale() );
201
+		$switched_locale = switch_to_locale(get_user_locale());
202 202
 		$l10n = array(
203
-			'shiftClickToEdit' => __( 'Shift-click to edit this element.' ),
204
-			'clickEditMenu' => __( 'Click to edit this menu.' ),
205
-			'clickEditWidget' => __( 'Click to edit this widget.' ),
206
-			'clickEditTitle' => __( 'Click to edit the site title.' ),
207
-			'clickEditMisc' => __( 'Click to edit this element.' ),
203
+			'shiftClickToEdit' => __('Shift-click to edit this element.'),
204
+			'clickEditMenu' => __('Click to edit this menu.'),
205
+			'clickEditWidget' => __('Click to edit this widget.'),
206
+			'clickEditTitle' => __('Click to edit the site title.'),
207
+			'clickEditMisc' => __('Click to edit this element.'),
208 208
 			/* translators: %s: document.write() */
209
-			'badDocumentWrite' => sprintf( __( '%s is forbidden' ), 'document.write()' ),
209
+			'badDocumentWrite' => sprintf(__('%s is forbidden'), 'document.write()'),
210 210
 		);
211
-		if ( $switched_locale ) {
211
+		if ($switched_locale) {
212 212
 			restore_previous_locale();
213 213
 		}
214 214
 
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 		);
220 220
 
221 221
 		// Export data to JS.
222
-		echo sprintf( '<script>var _customizePartialRefreshExports = %s;</script>', wp_json_encode( $exports ) );
222
+		echo sprintf('<script>var _customizePartialRefreshExports = %s;</script>', wp_json_encode($exports));
223 223
 	}
224 224
 
225 225
 	/**
@@ -233,14 +233,14 @@  discard block
 block discarded – undo
233 233
 	 * @param array $partial_ids The partial ID to add.
234 234
 	 * @return array Added WP_Customize_Partial instances.
235 235
 	 */
236
-	public function add_dynamic_partials( $partial_ids ) {
236
+	public function add_dynamic_partials($partial_ids) {
237 237
 		$new_partials = array();
238 238
 
239
-		foreach ( $partial_ids as $partial_id ) {
239
+		foreach ($partial_ids as $partial_id) {
240 240
 
241 241
 			// Skip partials already created.
242
-			$partial = $this->get_partial( $partial_id );
243
-			if ( $partial ) {
242
+			$partial = $this->get_partial($partial_id);
243
+			if ($partial) {
244 244
 				continue;
245 245
 			}
246 246
 
@@ -259,8 +259,8 @@  discard block
 block discarded – undo
259 259
 			 * @param false|array $partial_args The arguments to the WP_Customize_Partial constructor.
260 260
 			 * @param string      $partial_id   ID for dynamic partial.
261 261
 			 */
262
-			$partial_args = apply_filters( 'customize_dynamic_partial_args', $partial_args, $partial_id );
263
-			if ( false === $partial_args ) {
262
+			$partial_args = apply_filters('customize_dynamic_partial_args', $partial_args, $partial_id);
263
+			if (false === $partial_args) {
264 264
 				continue;
265 265
 			}
266 266
 
@@ -275,11 +275,11 @@  discard block
 block discarded – undo
275 275
 			 * @param string $partial_id    ID for dynamic partial.
276 276
 			 * @param array  $partial_args  The arguments to the WP_Customize_Partial constructor.
277 277
 			 */
278
-			$partial_class = apply_filters( 'customize_dynamic_partial_class', $partial_class, $partial_id, $partial_args );
278
+			$partial_class = apply_filters('customize_dynamic_partial_class', $partial_class, $partial_id, $partial_args);
279 279
 
280
-			$partial = new $partial_class( $this, $partial_id, $partial_args );
280
+			$partial = new $partial_class($this, $partial_id, $partial_args);
281 281
 
282
-			$this->add_partial( $partial );
282
+			$this->add_partial($partial);
283 283
 			$new_partials[] = $partial;
284 284
 		}
285 285
 		return $new_partials;
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 	 * @return bool Whether the request is for rendering partials.
298 298
 	 */
299 299
 	public function is_render_partials_request() {
300
-		return ! empty( $_POST[ self::RENDER_QUERY_VAR ] );
300
+		return ! empty($_POST[self::RENDER_QUERY_VAR]);
301 301
 	}
302 302
 
303 303
 	/**
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 	 * @param string $errline Error line.
315 315
 	 * @return true Always true.
316 316
 	 */
317
-	public function handle_error( $errno, $errstr, $errfile = null, $errline = null ) {
317
+	public function handle_error($errno, $errstr, $errfile = null, $errline = null) {
318 318
 		$this->triggered_errors[] = array(
319 319
 			'partial'      => $this->current_partial_id,
320 320
 			'error_number' => $errno,
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 	 * @access public
333 333
 	 */
334 334
 	public function handle_render_partials_request() {
335
-		if ( ! $this->is_render_partials_request() ) {
335
+		if ( ! $this->is_render_partials_request()) {
336 336
 			return;
337 337
 		}
338 338
 
@@ -341,22 +341,22 @@  discard block
 block discarded – undo
341 341
 		 * user passed the 'customize' capability check and the nonce check, since
342 342
 		 * WP_Customize_Manager::setup_theme() is where the previewing flag is set.
343 343
 		 */
344
-		if ( ! is_customize_preview() ) {
345
-			wp_send_json_error( 'expected_customize_preview', 403 );
346
-		} elseif ( ! isset( $_POST['partials'] ) ) {
347
-			wp_send_json_error( 'missing_partials', 400 );
344
+		if ( ! is_customize_preview()) {
345
+			wp_send_json_error('expected_customize_preview', 403);
346
+		} elseif ( ! isset($_POST['partials'])) {
347
+			wp_send_json_error('missing_partials', 400);
348 348
 		}
349 349
 
350 350
 		// Ensure that doing selective refresh on 404 template doesn't result in fallback rendering behavior (full refreshes).
351
-		status_header( 200 );
351
+		status_header(200);
352 352
 
353
-		$partials = json_decode( wp_unslash( $_POST['partials'] ), true );
353
+		$partials = json_decode(wp_unslash($_POST['partials']), true);
354 354
 
355
-		if ( ! is_array( $partials ) ) {
356
-			wp_send_json_error( 'malformed_partials' );
355
+		if ( ! is_array($partials)) {
356
+			wp_send_json_error('malformed_partials');
357 357
 		}
358 358
 
359
-		$this->add_dynamic_partials( array_keys( $partials ) );
359
+		$this->add_dynamic_partials(array_keys($partials));
360 360
 
361 361
 		/**
362 362
 		 * Fires immediately before partials are rendered.
@@ -371,35 +371,35 @@  discard block
 block discarded – undo
371 371
 		 *                                                 The array is keyed by partial ID, with each item being an array of
372 372
 		 *                                                 the placements' context data.
373 373
 		 */
374
-		do_action( 'customize_render_partials_before', $this, $partials );
374
+		do_action('customize_render_partials_before', $this, $partials);
375 375
 
376
-		set_error_handler( array( $this, 'handle_error' ), error_reporting() );
376
+		set_error_handler(array($this, 'handle_error'), error_reporting());
377 377
 
378 378
 		$contents = array();
379 379
 
380
-		foreach ( $partials as $partial_id => $container_contexts ) {
380
+		foreach ($partials as $partial_id => $container_contexts) {
381 381
 			$this->current_partial_id = $partial_id;
382 382
 
383
-			if ( ! is_array( $container_contexts ) ) {
384
-				wp_send_json_error( 'malformed_container_contexts' );
383
+			if ( ! is_array($container_contexts)) {
384
+				wp_send_json_error('malformed_container_contexts');
385 385
 			}
386 386
 
387
-			$partial = $this->get_partial( $partial_id );
387
+			$partial = $this->get_partial($partial_id);
388 388
 
389
-			if ( ! $partial || ! $partial->check_capabilities() ) {
390
-				$contents[ $partial_id ] = null;
389
+			if ( ! $partial || ! $partial->check_capabilities()) {
390
+				$contents[$partial_id] = null;
391 391
 				continue;
392 392
 			}
393 393
 
394
-			$contents[ $partial_id ] = array();
394
+			$contents[$partial_id] = array();
395 395
 
396 396
 			// @todo The array should include not only the contents, but also whether the container is included?
397
-			if ( empty( $container_contexts ) ) {
397
+			if (empty($container_contexts)) {
398 398
 				// Since there are no container contexts, render just once.
399
-				$contents[ $partial_id ][] = $partial->render( null );
399
+				$contents[$partial_id][] = $partial->render(null);
400 400
 			} else {
401
-				foreach ( $container_contexts as $container_context ) {
402
-					$contents[ $partial_id ][] = $partial->render( $container_context );
401
+				foreach ($container_contexts as $container_context) {
402
+					$contents[$partial_id][] = $partial->render($container_context);
403 403
 				}
404 404
 			}
405 405
 		}
@@ -420,18 +420,18 @@  discard block
 block discarded – undo
420 420
 		 *                                                 The array is keyed by partial ID, with each item being an array of
421 421
 		 *                                                 the placements' context data.
422 422
 		 */
423
-		do_action( 'customize_render_partials_after', $this, $partials );
423
+		do_action('customize_render_partials_after', $this, $partials);
424 424
 
425 425
 		$response = array(
426 426
 			'contents' => $contents,
427 427
 		);
428 428
 
429
-		if ( defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG_DISPLAY ) {
429
+		if (defined('WP_DEBUG_DISPLAY') && WP_DEBUG_DISPLAY) {
430 430
 			$response['errors'] = $this->triggered_errors;
431 431
 		}
432 432
 
433
-		$setting_validities = $this->manager->validate_setting_values( $this->manager->unsanitized_post_values() );
434
-		$exported_setting_validities = array_map( array( $this->manager, 'prepare_setting_validity_for_js' ), $setting_validities );
433
+		$setting_validities = $this->manager->validate_setting_values($this->manager->unsanitized_post_values());
434
+		$exported_setting_validities = array_map(array($this->manager, 'prepare_setting_validity_for_js'), $setting_validities);
435 435
 		$response['setting_validities'] = $exported_setting_validities;
436 436
 
437 437
 		/**
@@ -464,8 +464,8 @@  discard block
 block discarded – undo
464 464
 		 *                                                 The array is keyed by partial ID, with each item being an array of
465 465
 		 *                                                 the placements' context data.
466 466
 		 */
467
-		$response = apply_filters( 'customize_render_partials_response', $response, $this, $partials );
467
+		$response = apply_filters('customize_render_partials_response', $response, $this, $partials);
468 468
 
469
-		wp_send_json_success( $response );
469
+		wp_send_json_success($response);
470 470
 	}
471 471
 }
Please login to merge, or discard this patch.
src/wp-includes/pluggable.php 4 patches
Doc Comments   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
  *
743 743
  * @param string $cookie
744 744
  * @param string $scheme Optional. The cookie scheme to use: auth, secure_auth, or logged_in
745
- * @return array|false Authentication cookie components
745
+ * @return string Authentication cookie components
746 746
  */
747 747
 function wp_parse_auth_cookie($cookie = '', $scheme = '') {
748 748
 	if ( empty($cookie) ) {
@@ -1041,7 +1041,7 @@  discard block
 block discarded – undo
1041 1041
  *
1042 1042
  * @since 1.2.0
1043 1043
  *
1044
- * @param int|string $action    Action nonce.
1044
+ * @param integer $action    Action nonce.
1045 1045
  * @param string     $query_arg Optional. Key to check for nonce in `$_REQUEST` (since 2.5).
1046 1046
  *                              Default '_wpnonce'.
1047 1047
  * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
@@ -1081,7 +1081,7 @@  discard block
 block discarded – undo
1081 1081
  *
1082 1082
  * @since 2.0.3
1083 1083
  *
1084
- * @param int|string   $action    Action nonce.
1084
+ * @param integer   $action    Action nonce.
1085 1085
  * @param false|string $query_arg Optional. Key to check for the nonce in `$_REQUEST` (since 2.5). If false,
1086 1086
  *                                `$_REQUEST` values will be evaluated for '_ajax_nonce', and '_wpnonce'
1087 1087
  *                                (in that order). Default false.
@@ -1531,7 +1531,7 @@  discard block
 block discarded – undo
1531 1531
  * should be notified, overriding the site setting.
1532 1532
  *
1533 1533
  * @param int $comment_id Comment ID.
1534
- * @return true Always returns true.
1534
+ * @return boolean Always returns true.
1535 1535
  */
1536 1536
 function wp_notify_moderator($comment_id) {
1537 1537
 	global $wpdb;
@@ -1782,8 +1782,8 @@  discard block
 block discarded – undo
1782 1782
  * @since 2.0.3
1783 1783
  *
1784 1784
  * @param string     $nonce  Nonce that was used in the form to verify
1785
- * @param string|int $action Should give context to what is taking place and be the same when nonce was created.
1786
- * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
1785
+ * @param integer $action Should give context to what is taking place and be the same when nonce was created.
1786
+ * @return string False if the nonce is invalid, 1 if the nonce is valid and generated between
1787 1787
  *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
1788 1788
  */
1789 1789
 function wp_verify_nonce( $nonce, $action = -1 ) {
@@ -1846,7 +1846,7 @@  discard block
 block discarded – undo
1846 1846
  * @since 2.0.3
1847 1847
  * @since 4.0.0 Session tokens were integrated with nonce creation
1848 1848
  *
1849
- * @param string|int $action Scalar value to add context to the nonce.
1849
+ * @param integer $action Scalar value to add context to the nonce.
1850 1850
  * @return string The token.
1851 1851
  */
1852 1852
 function wp_create_nonce($action = -1) {
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -764,7 +764,7 @@
 block discarded – undo
764 764
 					$cookie_name = AUTH_COOKIE;
765 765
 					$scheme = 'auth';
766 766
 				}
767
-	    }
767
+		}
768 768
 
769 769
 		if ( empty($_COOKIE[$cookie_name]) )
770 770
 			return false;
Please login to merge, or discard this patch.
Spacing   +535 added lines, -535 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package WordPress
7 7
  */
8 8
 
9
-if ( !function_exists('wp_set_current_user') ) :
9
+if ( ! function_exists('wp_set_current_user')) :
10 10
 /**
11 11
  * Changes the current user by ID or name.
12 12
  *
@@ -27,30 +27,30 @@  discard block
 block discarded – undo
27 27
 	global $current_user;
28 28
 
29 29
 	// If `$id` matches the user who's already current, there's nothing to do.
30
-	if ( isset( $current_user )
31
-		&& ( $current_user instanceof WP_User )
32
-		&& ( $id == $current_user->ID )
33
-		&& ( null !== $id )
30
+	if (isset($current_user)
31
+		&& ($current_user instanceof WP_User)
32
+		&& ($id == $current_user->ID)
33
+		&& (null !== $id)
34 34
 	) {
35 35
 		return $current_user;
36 36
 	}
37 37
 
38
-	$current_user = new WP_User( $id, $name );
38
+	$current_user = new WP_User($id, $name);
39 39
 
40
-	setup_userdata( $current_user->ID );
40
+	setup_userdata($current_user->ID);
41 41
 
42 42
 	/**
43 43
 	 * Fires after the current user is set.
44 44
 	 *
45 45
 	 * @since 2.0.1
46 46
 	 */
47
-	do_action( 'set_current_user' );
47
+	do_action('set_current_user');
48 48
 
49 49
 	return $current_user;
50 50
 }
51 51
 endif;
52 52
 
53
-if ( !function_exists('wp_get_current_user') ) :
53
+if ( ! function_exists('wp_get_current_user')) :
54 54
 /**
55 55
  * Retrieve the current user object.
56 56
  *
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 }
71 71
 endif;
72 72
 
73
-if ( !function_exists('get_userdata') ) :
73
+if ( ! function_exists('get_userdata')) :
74 74
 /**
75 75
  * Retrieve user info by user ID.
76 76
  *
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
  * @param int $user_id User ID
80 80
  * @return WP_User|false WP_User object on success, false on failure.
81 81
  */
82
-function get_userdata( $user_id ) {
83
-	return get_user_by( 'id', $user_id );
82
+function get_userdata($user_id) {
83
+	return get_user_by('id', $user_id);
84 84
 }
85 85
 endif;
86 86
 
87
-if ( !function_exists('get_user_by') ) :
87
+if ( ! function_exists('get_user_by')) :
88 88
 /**
89 89
  * Retrieve user info by a given field
90 90
  *
@@ -95,20 +95,20 @@  discard block
 block discarded – undo
95 95
  * @param int|string $value A value for $field. A user ID, slug, email address, or login name.
96 96
  * @return WP_User|false WP_User object on success, false on failure.
97 97
  */
98
-function get_user_by( $field, $value ) {
99
-	$userdata = WP_User::get_data_by( $field, $value );
98
+function get_user_by($field, $value) {
99
+	$userdata = WP_User::get_data_by($field, $value);
100 100
 
101
-	if ( !$userdata )
101
+	if ( ! $userdata)
102 102
 		return false;
103 103
 
104 104
 	$user = new WP_User;
105
-	$user->init( $userdata );
105
+	$user->init($userdata);
106 106
 
107 107
 	return $user;
108 108
 }
109 109
 endif;
110 110
 
111
-if ( !function_exists('cache_users') ) :
111
+if ( ! function_exists('cache_users')) :
112 112
 /**
113 113
  * Retrieve info for user lists to prevent multiple queries by get_userdata()
114 114
  *
@@ -118,28 +118,28 @@  discard block
 block discarded – undo
118 118
  *
119 119
  * @param array $user_ids User ID numbers list
120 120
  */
121
-function cache_users( $user_ids ) {
121
+function cache_users($user_ids) {
122 122
 	global $wpdb;
123 123
 
124
-	$clean = _get_non_cached_ids( $user_ids, 'users' );
124
+	$clean = _get_non_cached_ids($user_ids, 'users');
125 125
 
126
-	if ( empty( $clean ) )
126
+	if (empty($clean))
127 127
 		return;
128 128
 
129
-	$list = implode( ',', $clean );
129
+	$list = implode(',', $clean);
130 130
 
131
-	$users = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($list)" );
131
+	$users = $wpdb->get_results("SELECT * FROM $wpdb->users WHERE ID IN ($list)");
132 132
 
133 133
 	$ids = array();
134
-	foreach ( $users as $user ) {
135
-		update_user_caches( $user );
134
+	foreach ($users as $user) {
135
+		update_user_caches($user);
136 136
 		$ids[] = $user->ID;
137 137
 	}
138
-	update_meta_cache( 'user', $ids );
138
+	update_meta_cache('user', $ids);
139 139
 }
140 140
 endif;
141 141
 
142
-if ( !function_exists( 'wp_mail' ) ) :
142
+if ( ! function_exists('wp_mail')) :
143 143
 /**
144 144
  * Send mail, similar to PHP's mail
145 145
  *
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
  * @param string|array $attachments Optional. Files to attach.
171 171
  * @return bool Whether the email contents were sent successfully.
172 172
  */
173
-function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) {
173
+function wp_mail($to, $subject, $message, $headers = '', $attachments = array()) {
174 174
 	// Compact the input, apply the filters, and extract them back out
175 175
 
176 176
 	/**
@@ -181,126 +181,126 @@  discard block
 block discarded – undo
181 181
 	 * @param array $args A compacted array of wp_mail() arguments, including the "to" email,
182 182
 	 *                    subject, message, headers, and attachments values.
183 183
 	 */
184
-	$atts = apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) );
184
+	$atts = apply_filters('wp_mail', compact('to', 'subject', 'message', 'headers', 'attachments'));
185 185
 
186
-	if ( isset( $atts['to'] ) ) {
186
+	if (isset($atts['to'])) {
187 187
 		$to = $atts['to'];
188 188
 	}
189 189
 
190
-	if ( !is_array( $to ) ) {
191
-		$to = explode( ',', $to );
190
+	if ( ! is_array($to)) {
191
+		$to = explode(',', $to);
192 192
 	}
193 193
 
194
-	if ( isset( $atts['subject'] ) ) {
194
+	if (isset($atts['subject'])) {
195 195
 		$subject = $atts['subject'];
196 196
 	}
197 197
 
198
-	if ( isset( $atts['message'] ) ) {
198
+	if (isset($atts['message'])) {
199 199
 		$message = $atts['message'];
200 200
 	}
201 201
 
202
-	if ( isset( $atts['headers'] ) ) {
202
+	if (isset($atts['headers'])) {
203 203
 		$headers = $atts['headers'];
204 204
 	}
205 205
 
206
-	if ( isset( $atts['attachments'] ) ) {
206
+	if (isset($atts['attachments'])) {
207 207
 		$attachments = $atts['attachments'];
208 208
 	}
209 209
 
210
-	if ( ! is_array( $attachments ) ) {
211
-		$attachments = explode( "\n", str_replace( "\r\n", "\n", $attachments ) );
210
+	if ( ! is_array($attachments)) {
211
+		$attachments = explode("\n", str_replace("\r\n", "\n", $attachments));
212 212
 	}
213 213
 	global $phpmailer;
214 214
 
215 215
 	// (Re)create it, if it's gone missing
216
-	if ( ! ( $phpmailer instanceof PHPMailer ) ) {
217
-		require_once ABSPATH . WPINC . '/class-phpmailer.php';
218
-		require_once ABSPATH . WPINC . '/class-smtp.php';
219
-		$phpmailer = new PHPMailer( true );
216
+	if ( ! ($phpmailer instanceof PHPMailer)) {
217
+		require_once ABSPATH.WPINC.'/class-phpmailer.php';
218
+		require_once ABSPATH.WPINC.'/class-smtp.php';
219
+		$phpmailer = new PHPMailer(true);
220 220
 	}
221 221
 
222 222
 	// Headers
223 223
 	$cc = $bcc = $reply_to = array();
224 224
 
225
-	if ( empty( $headers ) ) {
225
+	if (empty($headers)) {
226 226
 		$headers = array();
227 227
 	} else {
228
-		if ( !is_array( $headers ) ) {
228
+		if ( ! is_array($headers)) {
229 229
 			// Explode the headers out, so this function can take both
230 230
 			// string headers and an array of headers.
231
-			$tempheaders = explode( "\n", str_replace( "\r\n", "\n", $headers ) );
231
+			$tempheaders = explode("\n", str_replace("\r\n", "\n", $headers));
232 232
 		} else {
233 233
 			$tempheaders = $headers;
234 234
 		}
235 235
 		$headers = array();
236 236
 
237 237
 		// If it's actually got contents
238
-		if ( !empty( $tempheaders ) ) {
238
+		if ( ! empty($tempheaders)) {
239 239
 			// Iterate through the raw headers
240
-			foreach ( (array) $tempheaders as $header ) {
241
-				if ( strpos($header, ':') === false ) {
242
-					if ( false !== stripos( $header, 'boundary=' ) ) {
243
-						$parts = preg_split('/boundary=/i', trim( $header ) );
244
-						$boundary = trim( str_replace( array( "'", '"' ), '', $parts[1] ) );
240
+			foreach ((array) $tempheaders as $header) {
241
+				if (strpos($header, ':') === false) {
242
+					if (false !== stripos($header, 'boundary=')) {
243
+						$parts = preg_split('/boundary=/i', trim($header));
244
+						$boundary = trim(str_replace(array("'", '"'), '', $parts[1]));
245 245
 					}
246 246
 					continue;
247 247
 				}
248 248
 				// Explode them out
249
-				list( $name, $content ) = explode( ':', trim( $header ), 2 );
249
+				list($name, $content) = explode(':', trim($header), 2);
250 250
 
251 251
 				// Cleanup crew
252
-				$name    = trim( $name    );
253
-				$content = trim( $content );
252
+				$name    = trim($name);
253
+				$content = trim($content);
254 254
 
255
-				switch ( strtolower( $name ) ) {
255
+				switch (strtolower($name)) {
256 256
 					// Mainly for legacy -- process a From: header if it's there
257 257
 					case 'from':
258
-						$bracket_pos = strpos( $content, '<' );
259
-						if ( $bracket_pos !== false ) {
258
+						$bracket_pos = strpos($content, '<');
259
+						if ($bracket_pos !== false) {
260 260
 							// Text before the bracketed email is the "From" name.
261
-							if ( $bracket_pos > 0 ) {
262
-								$from_name = substr( $content, 0, $bracket_pos - 1 );
263
-								$from_name = str_replace( '"', '', $from_name );
264
-								$from_name = trim( $from_name );
261
+							if ($bracket_pos > 0) {
262
+								$from_name = substr($content, 0, $bracket_pos - 1);
263
+								$from_name = str_replace('"', '', $from_name);
264
+								$from_name = trim($from_name);
265 265
 							}
266 266
 
267
-							$from_email = substr( $content, $bracket_pos + 1 );
268
-							$from_email = str_replace( '>', '', $from_email );
269
-							$from_email = trim( $from_email );
267
+							$from_email = substr($content, $bracket_pos + 1);
268
+							$from_email = str_replace('>', '', $from_email);
269
+							$from_email = trim($from_email);
270 270
 
271 271
 						// Avoid setting an empty $from_email.
272
-						} elseif ( '' !== trim( $content ) ) {
273
-							$from_email = trim( $content );
272
+						} elseif ('' !== trim($content)) {
273
+							$from_email = trim($content);
274 274
 						}
275 275
 						break;
276 276
 					case 'content-type':
277
-						if ( strpos( $content, ';' ) !== false ) {
278
-							list( $type, $charset_content ) = explode( ';', $content );
279
-							$content_type = trim( $type );
280
-							if ( false !== stripos( $charset_content, 'charset=' ) ) {
281
-								$charset = trim( str_replace( array( 'charset=', '"' ), '', $charset_content ) );
282
-							} elseif ( false !== stripos( $charset_content, 'boundary=' ) ) {
283
-								$boundary = trim( str_replace( array( 'BOUNDARY=', 'boundary=', '"' ), '', $charset_content ) );
277
+						if (strpos($content, ';') !== false) {
278
+							list($type, $charset_content) = explode(';', $content);
279
+							$content_type = trim($type);
280
+							if (false !== stripos($charset_content, 'charset=')) {
281
+								$charset = trim(str_replace(array('charset=', '"'), '', $charset_content));
282
+							} elseif (false !== stripos($charset_content, 'boundary=')) {
283
+								$boundary = trim(str_replace(array('BOUNDARY=', 'boundary=', '"'), '', $charset_content));
284 284
 								$charset = '';
285 285
 							}
286 286
 
287 287
 						// Avoid setting an empty $content_type.
288
-						} elseif ( '' !== trim( $content ) ) {
289
-							$content_type = trim( $content );
288
+						} elseif ('' !== trim($content)) {
289
+							$content_type = trim($content);
290 290
 						}
291 291
 						break;
292 292
 					case 'cc':
293
-						$cc = array_merge( (array) $cc, explode( ',', $content ) );
293
+						$cc = array_merge((array) $cc, explode(',', $content));
294 294
 						break;
295 295
 					case 'bcc':
296
-						$bcc = array_merge( (array) $bcc, explode( ',', $content ) );
296
+						$bcc = array_merge((array) $bcc, explode(',', $content));
297 297
 						break;
298 298
 					case 'reply-to':
299
-						$reply_to = array_merge( (array) $reply_to, explode( ',', $content ) );
299
+						$reply_to = array_merge((array) $reply_to, explode(',', $content));
300 300
 						break;
301 301
 					default:
302 302
 						// Add it to our grand headers array
303
-						$headers[trim( $name )] = trim( $content );
303
+						$headers[trim($name)] = trim($content);
304 304
 						break;
305 305
 				}
306 306
 			}
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 
316 316
 	// From email and name
317 317
 	// If we don't have a name from the input headers
318
-	if ( !isset( $from_name ) )
318
+	if ( ! isset($from_name))
319 319
 		$from_name = 'WordPress';
320 320
 
321 321
 	/* If we don't have an email from the input headers default to wordpress@$sitename
@@ -325,14 +325,14 @@  discard block
 block discarded – undo
325 325
 	 * https://core.trac.wordpress.org/ticket/5007.
326 326
 	 */
327 327
 
328
-	if ( !isset( $from_email ) ) {
328
+	if ( ! isset($from_email)) {
329 329
 		// Get the site domain and get rid of www.
330
-		$sitename = strtolower( $_SERVER['SERVER_NAME'] );
331
-		if ( substr( $sitename, 0, 4 ) == 'www.' ) {
332
-			$sitename = substr( $sitename, 4 );
330
+		$sitename = strtolower($_SERVER['SERVER_NAME']);
331
+		if (substr($sitename, 0, 4) == 'www.') {
332
+			$sitename = substr($sitename, 4);
333 333
 		}
334 334
 
335
-		$from_email = 'wordpress@' . $sitename;
335
+		$from_email = 'wordpress@'.$sitename;
336 336
 	}
337 337
 
338 338
 	/**
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 	 *
343 343
 	 * @param string $from_email Email address to send from.
344 344
 	 */
345
-	$from_email = apply_filters( 'wp_mail_from', $from_email );
345
+	$from_email = apply_filters('wp_mail_from', $from_email);
346 346
 
347 347
 	/**
348 348
 	 * Filters the name to associate with the "from" email address.
@@ -351,16 +351,16 @@  discard block
 block discarded – undo
351 351
 	 *
352 352
 	 * @param string $from_name Name associated with the "from" email address.
353 353
 	 */
354
-	$from_name = apply_filters( 'wp_mail_from_name', $from_name );
354
+	$from_name = apply_filters('wp_mail_from_name', $from_name);
355 355
 
356 356
 	try {
357
-		$phpmailer->setFrom( $from_email, $from_name, false );
358
-	} catch ( phpmailerException $e ) {
359
-		$mail_error_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' );
357
+		$phpmailer->setFrom($from_email, $from_name, false);
358
+	} catch (phpmailerException $e) {
359
+		$mail_error_data = compact('to', 'subject', 'message', 'headers', 'attachments');
360 360
 		$mail_error_data['phpmailer_exception_code'] = $e->getCode();
361 361
 
362 362
 		/** This filter is documented in wp-includes/pluggable.php */
363
-		do_action( 'wp_mail_failed', new WP_Error( 'wp_mail_failed', $e->getMessage(), $mail_error_data ) );
363
+		do_action('wp_mail_failed', new WP_Error('wp_mail_failed', $e->getMessage(), $mail_error_data));
364 364
 
365 365
 		return false;
366 366
 	}
@@ -370,40 +370,40 @@  discard block
 block discarded – undo
370 370
 	$phpmailer->Body    = $message;
371 371
 
372 372
 	// Set destination addresses, using appropriate methods for handling addresses
373
-	$address_headers = compact( 'to', 'cc', 'bcc', 'reply_to' );
373
+	$address_headers = compact('to', 'cc', 'bcc', 'reply_to');
374 374
 
375
-	foreach ( $address_headers as $address_header => $addresses ) {
376
-		if ( empty( $addresses ) ) {
375
+	foreach ($address_headers as $address_header => $addresses) {
376
+		if (empty($addresses)) {
377 377
 			continue;
378 378
 		}
379 379
 
380
-		foreach ( (array) $addresses as $address ) {
380
+		foreach ((array) $addresses as $address) {
381 381
 			try {
382 382
 				// Break $recipient into name and address parts if in the format "Foo <[email protected]>"
383 383
 				$recipient_name = '';
384 384
 
385
-				if ( preg_match( '/(.*)<(.+)>/', $address, $matches ) ) {
386
-					if ( count( $matches ) == 3 ) {
385
+				if (preg_match('/(.*)<(.+)>/', $address, $matches)) {
386
+					if (count($matches) == 3) {
387 387
 						$recipient_name = $matches[1];
388 388
 						$address        = $matches[2];
389 389
 					}
390 390
 				}
391 391
 
392
-				switch ( $address_header ) {
392
+				switch ($address_header) {
393 393
 					case 'to':
394
-						$phpmailer->addAddress( $address, $recipient_name );
394
+						$phpmailer->addAddress($address, $recipient_name);
395 395
 						break;
396 396
 					case 'cc':
397
-						$phpmailer->addCc( $address, $recipient_name );
397
+						$phpmailer->addCc($address, $recipient_name);
398 398
 						break;
399 399
 					case 'bcc':
400
-						$phpmailer->addBcc( $address, $recipient_name );
400
+						$phpmailer->addBcc($address, $recipient_name);
401 401
 						break;
402 402
 					case 'reply_to':
403
-						$phpmailer->addReplyTo( $address, $recipient_name );
403
+						$phpmailer->addReplyTo($address, $recipient_name);
404 404
 						break;
405 405
 				}
406
-			} catch ( phpmailerException $e ) {
406
+			} catch (phpmailerException $e) {
407 407
 				continue;
408 408
 			}
409 409
 		}
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 
415 415
 	// Set Content-Type and charset
416 416
 	// If we don't have a content-type from the input headers
417
-	if ( !isset( $content_type ) )
417
+	if ( ! isset($content_type))
418 418
 		$content_type = 'text/plain';
419 419
 
420 420
 	/**
@@ -424,17 +424,17 @@  discard block
 block discarded – undo
424 424
 	 *
425 425
 	 * @param string $content_type Default wp_mail() content type.
426 426
 	 */
427
-	$content_type = apply_filters( 'wp_mail_content_type', $content_type );
427
+	$content_type = apply_filters('wp_mail_content_type', $content_type);
428 428
 
429 429
 	$phpmailer->ContentType = $content_type;
430 430
 
431 431
 	// Set whether it's plaintext, depending on $content_type
432
-	if ( 'text/html' == $content_type )
433
-		$phpmailer->isHTML( true );
432
+	if ('text/html' == $content_type)
433
+		$phpmailer->isHTML(true);
434 434
 
435 435
 	// If we don't have a charset from the input headers
436
-	if ( !isset( $charset ) )
437
-		$charset = get_bloginfo( 'charset' );
436
+	if ( ! isset($charset))
437
+		$charset = get_bloginfo('charset');
438 438
 
439 439
 	// Set the content-type and charset
440 440
 
@@ -445,23 +445,23 @@  discard block
 block discarded – undo
445 445
 	 *
446 446
 	 * @param string $charset Default email charset.
447 447
 	 */
448
-	$phpmailer->CharSet = apply_filters( 'wp_mail_charset', $charset );
448
+	$phpmailer->CharSet = apply_filters('wp_mail_charset', $charset);
449 449
 
450 450
 	// Set custom headers
451
-	if ( !empty( $headers ) ) {
452
-		foreach ( (array) $headers as $name => $content ) {
453
-			$phpmailer->addCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) );
451
+	if ( ! empty($headers)) {
452
+		foreach ((array) $headers as $name => $content) {
453
+			$phpmailer->addCustomHeader(sprintf('%1$s: %2$s', $name, $content));
454 454
 		}
455 455
 
456
-		if ( false !== stripos( $content_type, 'multipart' ) && ! empty($boundary) )
457
-			$phpmailer->addCustomHeader( sprintf( "Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary ) );
456
+		if (false !== stripos($content_type, 'multipart') && ! empty($boundary))
457
+			$phpmailer->addCustomHeader(sprintf("Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary));
458 458
 	}
459 459
 
460
-	if ( !empty( $attachments ) ) {
461
-		foreach ( $attachments as $attachment ) {
460
+	if ( ! empty($attachments)) {
461
+		foreach ($attachments as $attachment) {
462 462
 			try {
463 463
 				$phpmailer->addAttachment($attachment);
464
-			} catch ( phpmailerException $e ) {
464
+			} catch (phpmailerException $e) {
465 465
 				continue;
466 466
 			}
467 467
 		}
@@ -474,14 +474,14 @@  discard block
 block discarded – undo
474 474
 	 *
475 475
 	 * @param PHPMailer &$phpmailer The PHPMailer instance, passed by reference.
476 476
 	 */
477
-	do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
477
+	do_action_ref_array('phpmailer_init', array(&$phpmailer));
478 478
 
479 479
 	// Send!
480 480
 	try {
481 481
 		return $phpmailer->send();
482
-	} catch ( phpmailerException $e ) {
482
+	} catch (phpmailerException $e) {
483 483
 
484
-		$mail_error_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' );
484
+		$mail_error_data = compact('to', 'subject', 'message', 'headers', 'attachments');
485 485
 		$mail_error_data['phpmailer_exception_code'] = $e->getCode();
486 486
 
487 487
 		/**
@@ -492,14 +492,14 @@  discard block
 block discarded – undo
492 492
 		 * @param WP_Error $error A WP_Error object with the phpmailerException message, and an array
493 493
 		 *                        containing the mail recipient, subject, message, headers, and attachments.
494 494
 		 */
495
-		do_action( 'wp_mail_failed', new WP_Error( 'wp_mail_failed', $e->getMessage(), $mail_error_data ) );
495
+		do_action('wp_mail_failed', new WP_Error('wp_mail_failed', $e->getMessage(), $mail_error_data));
496 496
 
497 497
 		return false;
498 498
 	}
499 499
 }
500 500
 endif;
501 501
 
502
-if ( !function_exists('wp_authenticate') ) :
502
+if ( ! function_exists('wp_authenticate')) :
503 503
 /**
504 504
  * Authenticate a user, confirming the login credentials are valid.
505 505
  *
@@ -529,17 +529,17 @@  discard block
 block discarded – undo
529 529
 	 * @param string                $username Username or email address.
530 530
 	 * @param string                $password User password
531 531
 	 */
532
-	$user = apply_filters( 'authenticate', null, $username, $password );
532
+	$user = apply_filters('authenticate', null, $username, $password);
533 533
 
534
-	if ( $user == null ) {
534
+	if ($user == null) {
535 535
 		// TODO what should the error message be? (Or would these even happen?)
536 536
 		// Only needed if all authentication handlers fail to return anything.
537
-		$user = new WP_Error( 'authentication_failed', __( '<strong>ERROR</strong>: Invalid username, email address or incorrect password.' ) );
537
+		$user = new WP_Error('authentication_failed', __('<strong>ERROR</strong>: Invalid username, email address or incorrect password.'));
538 538
 	}
539 539
 
540 540
 	$ignore_codes = array('empty_username', 'empty_password');
541 541
 
542
-	if (is_wp_error($user) && !in_array($user->get_error_code(), $ignore_codes) ) {
542
+	if (is_wp_error($user) && ! in_array($user->get_error_code(), $ignore_codes)) {
543 543
 		/**
544 544
 		 * Fires after a user login has failed.
545 545
 		 *
@@ -548,14 +548,14 @@  discard block
 block discarded – undo
548 548
 		 *
549 549
 		 * @param string $username Username or email address.
550 550
 		 */
551
-		do_action( 'wp_login_failed', $username );
551
+		do_action('wp_login_failed', $username);
552 552
 	}
553 553
 
554 554
 	return $user;
555 555
 }
556 556
 endif;
557 557
 
558
-if ( !function_exists('wp_logout') ) :
558
+if ( ! function_exists('wp_logout')) :
559 559
 /**
560 560
  * Log the current user out.
561 561
  *
@@ -570,11 +570,11 @@  discard block
 block discarded – undo
570 570
 	 *
571 571
 	 * @since 1.5.0
572 572
 	 */
573
-	do_action( 'wp_logout' );
573
+	do_action('wp_logout');
574 574
 }
575 575
 endif;
576 576
 
577
-if ( !function_exists('wp_validate_auth_cookie') ) :
577
+if ( ! function_exists('wp_validate_auth_cookie')) :
578 578
 /**
579 579
  * Validates authentication cookie.
580 580
  *
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
  * @return false|int False if invalid cookie, User ID if valid.
594 594
  */
595 595
 function wp_validate_auth_cookie($cookie = '', $scheme = '') {
596
-	if ( ! $cookie_elements = wp_parse_auth_cookie($cookie, $scheme) ) {
596
+	if ( ! $cookie_elements = wp_parse_auth_cookie($cookie, $scheme)) {
597 597
 		/**
598 598
 		 * Fires if an authentication cookie is malformed.
599 599
 		 *
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 		 * @param string $scheme Authentication scheme. Values include 'auth', 'secure_auth',
604 604
 		 *                       or 'logged_in'.
605 605
 		 */
606
-		do_action( 'auth_cookie_malformed', $cookie, $scheme );
606
+		do_action('auth_cookie_malformed', $cookie, $scheme);
607 607
 		return false;
608 608
 	}
609 609
 
@@ -614,12 +614,12 @@  discard block
 block discarded – undo
614 614
 	$expired = $expiration = $cookie_elements['expiration'];
615 615
 
616 616
 	// Allow a grace period for POST and Ajax requests
617
-	if ( wp_doing_ajax() || 'POST' == $_SERVER['REQUEST_METHOD'] ) {
617
+	if (wp_doing_ajax() || 'POST' == $_SERVER['REQUEST_METHOD']) {
618 618
 		$expired += HOUR_IN_SECONDS;
619 619
 	}
620 620
 
621 621
 	// Quick check to see if an honest cookie has expired
622
-	if ( $expired < time() ) {
622
+	if ($expired < time()) {
623 623
 		/**
624 624
 		 * Fires once an authentication cookie has expired.
625 625
 		 *
@@ -627,12 +627,12 @@  discard block
 block discarded – undo
627 627
 		 *
628 628
 		 * @param array $cookie_elements An array of data for the authentication cookie.
629 629
 		 */
630
-		do_action( 'auth_cookie_expired', $cookie_elements );
630
+		do_action('auth_cookie_expired', $cookie_elements);
631 631
 		return false;
632 632
 	}
633 633
 
634 634
 	$user = get_user_by('login', $username);
635
-	if ( ! $user ) {
635
+	if ( ! $user) {
636 636
 		/**
637 637
 		 * Fires if a bad username is entered in the user authentication process.
638 638
 		 *
@@ -640,19 +640,19 @@  discard block
 block discarded – undo
640 640
 		 *
641 641
 		 * @param array $cookie_elements An array of data for the authentication cookie.
642 642
 		 */
643
-		do_action( 'auth_cookie_bad_username', $cookie_elements );
643
+		do_action('auth_cookie_bad_username', $cookie_elements);
644 644
 		return false;
645 645
 	}
646 646
 
647 647
 	$pass_frag = substr($user->user_pass, 8, 4);
648 648
 
649
-	$key = wp_hash( $username . '|' . $pass_frag . '|' . $expiration . '|' . $token, $scheme );
649
+	$key = wp_hash($username.'|'.$pass_frag.'|'.$expiration.'|'.$token, $scheme);
650 650
 
651 651
 	// If ext/hash is not present, compat.php's hash_hmac() does not support sha256.
652
-	$algo = function_exists( 'hash' ) ? 'sha256' : 'sha1';
653
-	$hash = hash_hmac( $algo, $username . '|' . $expiration . '|' . $token, $key );
652
+	$algo = function_exists('hash') ? 'sha256' : 'sha1';
653
+	$hash = hash_hmac($algo, $username.'|'.$expiration.'|'.$token, $key);
654 654
 
655
-	if ( ! hash_equals( $hash, $hmac ) ) {
655
+	if ( ! hash_equals($hash, $hmac)) {
656 656
 		/**
657 657
 		 * Fires if a bad authentication cookie hash is encountered.
658 658
 		 *
@@ -660,18 +660,18 @@  discard block
 block discarded – undo
660 660
 		 *
661 661
 		 * @param array $cookie_elements An array of data for the authentication cookie.
662 662
 		 */
663
-		do_action( 'auth_cookie_bad_hash', $cookie_elements );
663
+		do_action('auth_cookie_bad_hash', $cookie_elements);
664 664
 		return false;
665 665
 	}
666 666
 
667
-	$manager = WP_Session_Tokens::get_instance( $user->ID );
668
-	if ( ! $manager->verify( $token ) ) {
669
-		do_action( 'auth_cookie_bad_session_token', $cookie_elements );
667
+	$manager = WP_Session_Tokens::get_instance($user->ID);
668
+	if ( ! $manager->verify($token)) {
669
+		do_action('auth_cookie_bad_session_token', $cookie_elements);
670 670
 		return false;
671 671
 	}
672 672
 
673 673
 	// Ajax/POST grace period set above
674
-	if ( $expiration < time() ) {
674
+	if ($expiration < time()) {
675 675
 		$GLOBALS['login_grace_period'] = 1;
676 676
 	}
677 677
 
@@ -683,13 +683,13 @@  discard block
 block discarded – undo
683 683
 	 * @param array   $cookie_elements An array of data for the authentication cookie.
684 684
 	 * @param WP_User $user            User object.
685 685
 	 */
686
-	do_action( 'auth_cookie_valid', $cookie_elements, $user );
686
+	do_action('auth_cookie_valid', $cookie_elements, $user);
687 687
 
688 688
 	return $user->ID;
689 689
 }
690 690
 endif;
691 691
 
692
-if ( !function_exists('wp_generate_auth_cookie') ) :
692
+if ( ! function_exists('wp_generate_auth_cookie')) :
693 693
 /**
694 694
  * Generate authentication cookie contents.
695 695
  *
@@ -701,26 +701,26 @@  discard block
 block discarded – undo
701 701
  * @param string $token      User's session token to use for this cookie
702 702
  * @return string Authentication cookie contents. Empty string if user does not exist.
703 703
  */
704
-function wp_generate_auth_cookie( $user_id, $expiration, $scheme = 'auth', $token = '' ) {
704
+function wp_generate_auth_cookie($user_id, $expiration, $scheme = 'auth', $token = '') {
705 705
 	$user = get_userdata($user_id);
706
-	if ( ! $user ) {
706
+	if ( ! $user) {
707 707
 		return '';
708 708
 	}
709 709
 
710
-	if ( ! $token ) {
711
-		$manager = WP_Session_Tokens::get_instance( $user_id );
712
-		$token = $manager->create( $expiration );
710
+	if ( ! $token) {
711
+		$manager = WP_Session_Tokens::get_instance($user_id);
712
+		$token = $manager->create($expiration);
713 713
 	}
714 714
 
715 715
 	$pass_frag = substr($user->user_pass, 8, 4);
716 716
 
717
-	$key = wp_hash( $user->user_login . '|' . $pass_frag . '|' . $expiration . '|' . $token, $scheme );
717
+	$key = wp_hash($user->user_login.'|'.$pass_frag.'|'.$expiration.'|'.$token, $scheme);
718 718
 
719 719
 	// If ext/hash is not present, compat.php's hash_hmac() does not support sha256.
720
-	$algo = function_exists( 'hash' ) ? 'sha256' : 'sha1';
721
-	$hash = hash_hmac( $algo, $user->user_login . '|' . $expiration . '|' . $token, $key );
720
+	$algo = function_exists('hash') ? 'sha256' : 'sha1';
721
+	$hash = hash_hmac($algo, $user->user_login.'|'.$expiration.'|'.$token, $key);
722 722
 
723
-	$cookie = $user->user_login . '|' . $expiration . '|' . $token . '|' . $hash;
723
+	$cookie = $user->user_login.'|'.$expiration.'|'.$token.'|'.$hash;
724 724
 
725 725
 	/**
726 726
 	 * Filters the authentication cookie.
@@ -733,11 +733,11 @@  discard block
 block discarded – undo
733 733
 	 * @param string $scheme     Cookie scheme used. Accepts 'auth', 'secure_auth', or 'logged_in'.
734 734
 	 * @param string $token      User's session token used.
735 735
 	 */
736
-	return apply_filters( 'auth_cookie', $cookie, $user_id, $expiration, $scheme, $token );
736
+	return apply_filters('auth_cookie', $cookie, $user_id, $expiration, $scheme, $token);
737 737
 }
738 738
 endif;
739 739
 
740
-if ( !function_exists('wp_parse_auth_cookie') ) :
740
+if ( ! function_exists('wp_parse_auth_cookie')) :
741 741
 /**
742 742
  * Parse a cookie into its components
743 743
  *
@@ -748,8 +748,8 @@  discard block
 block discarded – undo
748 748
  * @return array|false Authentication cookie components
749 749
  */
750 750
 function wp_parse_auth_cookie($cookie = '', $scheme = '') {
751
-	if ( empty($cookie) ) {
752
-		switch ($scheme){
751
+	if (empty($cookie)) {
752
+		switch ($scheme) {
753 753
 			case 'auth':
754 754
 				$cookie_name = AUTH_COOKIE;
755 755
 				break;
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
 				$cookie_name = LOGGED_IN_COOKIE;
761 761
 				break;
762 762
 			default:
763
-				if ( is_ssl() ) {
763
+				if (is_ssl()) {
764 764
 					$cookie_name = SECURE_AUTH_COOKIE;
765 765
 					$scheme = 'secure_auth';
766 766
 				} else {
@@ -769,23 +769,23 @@  discard block
 block discarded – undo
769 769
 				}
770 770
 	    }
771 771
 
772
-		if ( empty($_COOKIE[$cookie_name]) )
772
+		if (empty($_COOKIE[$cookie_name]))
773 773
 			return false;
774 774
 		$cookie = $_COOKIE[$cookie_name];
775 775
 	}
776 776
 
777 777
 	$cookie_elements = explode('|', $cookie);
778
-	if ( count( $cookie_elements ) !== 4 ) {
778
+	if (count($cookie_elements) !== 4) {
779 779
 		return false;
780 780
 	}
781 781
 
782
-	list( $username, $expiration, $token, $hmac ) = $cookie_elements;
782
+	list($username, $expiration, $token, $hmac) = $cookie_elements;
783 783
 
784
-	return compact( 'username', 'expiration', 'token', 'hmac', 'scheme' );
784
+	return compact('username', 'expiration', 'token', 'hmac', 'scheme');
785 785
 }
786 786
 endif;
787 787
 
788
-if ( !function_exists('wp_set_auth_cookie') ) :
788
+if ( ! function_exists('wp_set_auth_cookie')) :
789 789
 /**
790 790
  * Log in a user by setting authentication cookies.
791 791
  *
@@ -802,8 +802,8 @@  discard block
 block discarded – undo
802 802
  *                         Default is_ssl().
803 803
  * @param string $token    Optional. User's session token to use for this cookie.
804 804
  */
805
-function wp_set_auth_cookie( $user_id, $remember = false, $secure = '', $token = '' ) {
806
-	if ( $remember ) {
805
+function wp_set_auth_cookie($user_id, $remember = false, $secure = '', $token = '') {
806
+	if ($remember) {
807 807
 		/**
808 808
 		 * Filters the duration of the authentication cookie expiration period.
809 809
 		 *
@@ -813,25 +813,25 @@  discard block
 block discarded – undo
813 813
 		 * @param int  $user_id  User ID.
814 814
 		 * @param bool $remember Whether to remember the user login. Default false.
815 815
 		 */
816
-		$expiration = time() + apply_filters( 'auth_cookie_expiration', 14 * DAY_IN_SECONDS, $user_id, $remember );
816
+		$expiration = time() + apply_filters('auth_cookie_expiration', 14 * DAY_IN_SECONDS, $user_id, $remember);
817 817
 
818 818
 		/*
819 819
 		 * Ensure the browser will continue to send the cookie after the expiration time is reached.
820 820
 		 * Needed for the login grace period in wp_validate_auth_cookie().
821 821
 		 */
822
-		$expire = $expiration + ( 12 * HOUR_IN_SECONDS );
822
+		$expire = $expiration + (12 * HOUR_IN_SECONDS);
823 823
 	} else {
824 824
 		/** This filter is documented in wp-includes/pluggable.php */
825
-		$expiration = time() + apply_filters( 'auth_cookie_expiration', 2 * DAY_IN_SECONDS, $user_id, $remember );
825
+		$expiration = time() + apply_filters('auth_cookie_expiration', 2 * DAY_IN_SECONDS, $user_id, $remember);
826 826
 		$expire = 0;
827 827
 	}
828 828
 
829
-	if ( '' === $secure ) {
829
+	if ('' === $secure) {
830 830
 		$secure = is_ssl();
831 831
 	}
832 832
 
833 833
 	// Front-end cookie is secure when the auth cookie is secure and the site's home URL is forced HTTPS.
834
-	$secure_logged_in_cookie = $secure && 'https' === parse_url( get_option( 'home' ), PHP_URL_SCHEME );
834
+	$secure_logged_in_cookie = $secure && 'https' === parse_url(get_option('home'), PHP_URL_SCHEME);
835 835
 
836 836
 	/**
837 837
 	 * Filters whether the connection is secure.
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 	 * @param bool $secure  Whether the connection is secure.
842 842
 	 * @param int  $user_id User ID.
843 843
 	 */
844
-	$secure = apply_filters( 'secure_auth_cookie', $secure, $user_id );
844
+	$secure = apply_filters('secure_auth_cookie', $secure, $user_id);
845 845
 
846 846
 	/**
847 847
 	 * Filters whether to use a secure cookie when logged-in.
@@ -852,9 +852,9 @@  discard block
 block discarded – undo
852 852
 	 * @param int  $user_id                 User ID.
853 853
 	 * @param bool $secure                  Whether the connection is secure.
854 854
 	 */
855
-	$secure_logged_in_cookie = apply_filters( 'secure_logged_in_cookie', $secure_logged_in_cookie, $user_id, $secure );
855
+	$secure_logged_in_cookie = apply_filters('secure_logged_in_cookie', $secure_logged_in_cookie, $user_id, $secure);
856 856
 
857
-	if ( $secure ) {
857
+	if ($secure) {
858 858
 		$auth_cookie_name = SECURE_AUTH_COOKIE;
859 859
 		$scheme = 'secure_auth';
860 860
 	} else {
@@ -862,13 +862,13 @@  discard block
 block discarded – undo
862 862
 		$scheme = 'auth';
863 863
 	}
864 864
 
865
-	if ( '' === $token ) {
866
-		$manager = WP_Session_Tokens::get_instance( $user_id );
867
-		$token   = $manager->create( $expiration );
865
+	if ('' === $token) {
866
+		$manager = WP_Session_Tokens::get_instance($user_id);
867
+		$token   = $manager->create($expiration);
868 868
 	}
869 869
 
870
-	$auth_cookie = wp_generate_auth_cookie( $user_id, $expiration, $scheme, $token );
871
-	$logged_in_cookie = wp_generate_auth_cookie( $user_id, $expiration, 'logged_in', $token );
870
+	$auth_cookie = wp_generate_auth_cookie($user_id, $expiration, $scheme, $token);
871
+	$logged_in_cookie = wp_generate_auth_cookie($user_id, $expiration, 'logged_in', $token);
872 872
 
873 873
 	/**
874 874
 	 * Fires immediately before the authentication cookie is set.
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
 	 * @param int    $user_id     User ID.
884 884
 	 * @param string $scheme      Authentication scheme. Values include 'auth', 'secure_auth', or 'logged_in'.
885 885
 	 */
886
-	do_action( 'set_auth_cookie', $auth_cookie, $expire, $expiration, $user_id, $scheme );
886
+	do_action('set_auth_cookie', $auth_cookie, $expire, $expiration, $user_id, $scheme);
887 887
 
888 888
 	/**
889 889
 	 * Fires immediately before the logged-in authentication cookie is set.
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
 	 * @param int    $user_id          User ID.
899 899
 	 * @param string $scheme           Authentication scheme. Default 'logged_in'.
900 900
 	 */
901
-	do_action( 'set_logged_in_cookie', $logged_in_cookie, $expire, $expiration, $user_id, 'logged_in' );
901
+	do_action('set_logged_in_cookie', $logged_in_cookie, $expire, $expiration, $user_id, 'logged_in');
902 902
 
903 903
 	/**
904 904
 	 * Allows preventing auth cookies from actually being sent to the client.
@@ -907,19 +907,19 @@  discard block
 block discarded – undo
907 907
 	 *
908 908
 	 * @param bool $send Whether to send auth cookies to the client.
909 909
 	 */
910
-	if ( ! apply_filters( 'send_auth_cookies', true ) ) {
910
+	if ( ! apply_filters('send_auth_cookies', true)) {
911 911
 		return;
912 912
 	}
913 913
 
914 914
 	setcookie($auth_cookie_name, $auth_cookie, $expire, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
915 915
 	setcookie($auth_cookie_name, $auth_cookie, $expire, ADMIN_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
916 916
 	setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, COOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true);
917
-	if ( COOKIEPATH != SITECOOKIEPATH )
917
+	if (COOKIEPATH != SITECOOKIEPATH)
918 918
 		setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, SITECOOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true);
919 919
 }
920 920
 endif;
921 921
 
922
-if ( !function_exists('wp_clear_auth_cookie') ) :
922
+if ( ! function_exists('wp_clear_auth_cookie')) :
923 923
 /**
924 924
  * Removes all of the cookies associated with authentication.
925 925
  *
@@ -931,40 +931,40 @@  discard block
 block discarded – undo
931 931
 	 *
932 932
 	 * @since 2.7.0
933 933
 	 */
934
-	do_action( 'clear_auth_cookie' );
934
+	do_action('clear_auth_cookie');
935 935
 
936 936
 	/** This filter is documented in wp-includes/pluggable.php */
937
-	if ( ! apply_filters( 'send_auth_cookies', true ) ) {
937
+	if ( ! apply_filters('send_auth_cookies', true)) {
938 938
 		return;
939 939
 	}
940 940
 
941 941
 	// Auth cookies
942
-	setcookie( AUTH_COOKIE,        ' ', time() - YEAR_IN_SECONDS, ADMIN_COOKIE_PATH,   COOKIE_DOMAIN );
943
-	setcookie( SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, ADMIN_COOKIE_PATH,   COOKIE_DOMAIN );
944
-	setcookie( AUTH_COOKIE,        ' ', time() - YEAR_IN_SECONDS, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN );
945
-	setcookie( SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN );
946
-	setcookie( LOGGED_IN_COOKIE,   ' ', time() - YEAR_IN_SECONDS, COOKIEPATH,          COOKIE_DOMAIN );
947
-	setcookie( LOGGED_IN_COOKIE,   ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH,      COOKIE_DOMAIN );
942
+	setcookie(AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, ADMIN_COOKIE_PATH, COOKIE_DOMAIN);
943
+	setcookie(SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, ADMIN_COOKIE_PATH, COOKIE_DOMAIN);
944
+	setcookie(AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN);
945
+	setcookie(SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN);
946
+	setcookie(LOGGED_IN_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN);
947
+	setcookie(LOGGED_IN_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN);
948 948
 
949 949
 	// Settings cookies
950
-	setcookie( 'wp-settings-' . get_current_user_id(),      ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH );
951
-	setcookie( 'wp-settings-time-' . get_current_user_id(), ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH );
950
+	setcookie('wp-settings-'.get_current_user_id(), ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH);
951
+	setcookie('wp-settings-time-'.get_current_user_id(), ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH);
952 952
 
953 953
 	// Old cookies
954
-	setcookie( AUTH_COOKIE,        ' ', time() - YEAR_IN_SECONDS, COOKIEPATH,     COOKIE_DOMAIN );
955
-	setcookie( AUTH_COOKIE,        ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN );
956
-	setcookie( SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH,     COOKIE_DOMAIN );
957
-	setcookie( SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN );
954
+	setcookie(AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN);
955
+	setcookie(AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN);
956
+	setcookie(SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN);
957
+	setcookie(SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN);
958 958
 
959 959
 	// Even older cookies
960
-	setcookie( USER_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH,     COOKIE_DOMAIN );
961
-	setcookie( PASS_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH,     COOKIE_DOMAIN );
962
-	setcookie( USER_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN );
963
-	setcookie( PASS_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN );
960
+	setcookie(USER_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN);
961
+	setcookie(PASS_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN);
962
+	setcookie(USER_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN);
963
+	setcookie(PASS_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN);
964 964
 }
965 965
 endif;
966 966
 
967
-if ( !function_exists('is_user_logged_in') ) :
967
+if ( ! function_exists('is_user_logged_in')) :
968 968
 /**
969 969
  * Checks if the current visitor is a logged in user.
970 970
  *
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
 }
980 980
 endif;
981 981
 
982
-if ( !function_exists('auth_redirect') ) :
982
+if ( ! function_exists('auth_redirect')) :
983 983
 /**
984 984
  * Checks if a user is logged in, if not it redirects them to the login page.
985 985
  *
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
 function auth_redirect() {
989 989
 	// Checks if a user is logged in, if not redirects them to the login page
990 990
 
991
-	$secure = ( is_ssl() || force_ssl_admin() );
991
+	$secure = (is_ssl() || force_ssl_admin());
992 992
 
993 993
 	/**
994 994
 	 * Filters whether to use a secure authentication redirect.
@@ -997,15 +997,15 @@  discard block
 block discarded – undo
997 997
 	 *
998 998
 	 * @param bool $secure Whether to use a secure authentication redirect. Default false.
999 999
 	 */
1000
-	$secure = apply_filters( 'secure_auth_redirect', $secure );
1000
+	$secure = apply_filters('secure_auth_redirect', $secure);
1001 1001
 
1002 1002
 	// If https is required and request is http, redirect
1003
-	if ( $secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin') ) {
1004
-		if ( 0 === strpos( $_SERVER['REQUEST_URI'], 'http' ) ) {
1005
-			wp_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ) );
1003
+	if ($secure && ! is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
1004
+		if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
1005
+			wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
1006 1006
 			exit();
1007 1007
 		} else {
1008
-			wp_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
1008
+			wp_redirect('https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
1009 1009
 			exit();
1010 1010
 		}
1011 1011
 	}
@@ -1017,9 +1017,9 @@  discard block
 block discarded – undo
1017 1017
 	 *
1018 1018
 	 * @param string $scheme Authentication redirect scheme. Default empty.
1019 1019
 	 */
1020
-	$scheme = apply_filters( 'auth_redirect_scheme', '' );
1020
+	$scheme = apply_filters('auth_redirect_scheme', '');
1021 1021
 
1022
-	if ( $user_id = wp_validate_auth_cookie( '',  $scheme) ) {
1022
+	if ($user_id = wp_validate_auth_cookie('', $scheme)) {
1023 1023
 		/**
1024 1024
 		 * Fires before the authentication redirect.
1025 1025
 		 *
@@ -1027,26 +1027,26 @@  discard block
 block discarded – undo
1027 1027
 		 *
1028 1028
 		 * @param int $user_id User ID.
1029 1029
 		 */
1030
-		do_action( 'auth_redirect', $user_id );
1030
+		do_action('auth_redirect', $user_id);
1031 1031
 
1032 1032
 		// If the user wants ssl but the session is not ssl, redirect.
1033
-		if ( !$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin') ) {
1034
-			if ( 0 === strpos( $_SERVER['REQUEST_URI'], 'http' ) ) {
1035
-				wp_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ) );
1033
+		if ( ! $secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin')) {
1034
+			if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
1035
+				wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https'));
1036 1036
 				exit();
1037 1037
 			} else {
1038
-				wp_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
1038
+				wp_redirect('https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
1039 1039
 				exit();
1040 1040
 			}
1041 1041
 		}
1042 1042
 
1043
-		return;  // The cookie is good so we're done
1043
+		return; // The cookie is good so we're done
1044 1044
 	}
1045 1045
 
1046 1046
 	// The cookie is no good so force login
1047 1047
 	nocache_headers();
1048 1048
 
1049
-	$redirect = ( strpos( $_SERVER['REQUEST_URI'], '/options.php' ) && wp_get_referer() ) ? wp_get_referer() : set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
1049
+	$redirect = (strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer()) ? wp_get_referer() : set_url_scheme('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
1050 1050
 
1051 1051
 	$login_url = wp_login_url($redirect, true);
1052 1052
 
@@ -1055,7 +1055,7 @@  discard block
 block discarded – undo
1055 1055
 }
1056 1056
 endif;
1057 1057
 
1058
-if ( !function_exists('check_admin_referer') ) :
1058
+if ( ! function_exists('check_admin_referer')) :
1059 1059
 /**
1060 1060
  * Makes sure that a user was referred from another admin page.
1061 1061
  *
@@ -1069,9 +1069,9 @@  discard block
 block discarded – undo
1069 1069
  * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
1070 1070
  *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
1071 1071
  */
1072
-function check_admin_referer( $action = -1, $query_arg = '_wpnonce' ) {
1072
+function check_admin_referer($action = -1, $query_arg = '_wpnonce') {
1073 1073
 	if ( -1 == $action )
1074
-		_doing_it_wrong( __FUNCTION__, __( 'You should specify a nonce action to be verified by using the first parameter.' ), '3.2.0' );
1074
+		_doing_it_wrong(__FUNCTION__, __('You should specify a nonce action to be verified by using the first parameter.'), '3.2.0');
1075 1075
 
1076 1076
 	$adminurl = strtolower(admin_url());
1077 1077
 	$referer = strtolower(wp_get_referer());
@@ -1086,10 +1086,10 @@  discard block
 block discarded – undo
1086 1086
 	 * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
1087 1087
 	 *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
1088 1088
 	 */
1089
-	do_action( 'check_admin_referer', $action, $result );
1089
+	do_action('check_admin_referer', $action, $result);
1090 1090
 
1091
-	if ( ! $result && ! ( -1 == $action && strpos( $referer, $adminurl ) === 0 ) ) {
1092
-		wp_nonce_ays( $action );
1091
+	if ( ! $result && ! ( -1 == $action && strpos($referer, $adminurl) === 0 )) {
1092
+		wp_nonce_ays($action);
1093 1093
 		die();
1094 1094
 	}
1095 1095
 
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
 }
1098 1098
 endif;
1099 1099
 
1100
-if ( !function_exists('check_ajax_referer') ) :
1100
+if ( ! function_exists('check_ajax_referer')) :
1101 1101
 /**
1102 1102
  * Verifies the Ajax request to prevent processing requests external of the blog.
1103 1103
  *
@@ -1112,21 +1112,21 @@  discard block
 block discarded – undo
1112 1112
  * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
1113 1113
  *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
1114 1114
  */
1115
-function check_ajax_referer( $action = -1, $query_arg = false, $die = true ) {
1115
+function check_ajax_referer($action = -1, $query_arg = false, $die = true) {
1116 1116
 	if ( -1 == $action ) {
1117
-		_doing_it_wrong( __FUNCTION__, __( 'You should specify a nonce action to be verified by using the first parameter.' ), '4.7' );
1117
+		_doing_it_wrong(__FUNCTION__, __('You should specify a nonce action to be verified by using the first parameter.'), '4.7');
1118 1118
 	}
1119 1119
 
1120 1120
 	$nonce = '';
1121 1121
 
1122
-	if ( $query_arg && isset( $_REQUEST[ $query_arg ] ) )
1123
-		$nonce = $_REQUEST[ $query_arg ];
1124
-	elseif ( isset( $_REQUEST['_ajax_nonce'] ) )
1122
+	if ($query_arg && isset($_REQUEST[$query_arg]))
1123
+		$nonce = $_REQUEST[$query_arg];
1124
+	elseif (isset($_REQUEST['_ajax_nonce']))
1125 1125
 		$nonce = $_REQUEST['_ajax_nonce'];
1126
-	elseif ( isset( $_REQUEST['_wpnonce'] ) )
1126
+	elseif (isset($_REQUEST['_wpnonce']))
1127 1127
 		$nonce = $_REQUEST['_wpnonce'];
1128 1128
 
1129
-	$result = wp_verify_nonce( $nonce, $action );
1129
+	$result = wp_verify_nonce($nonce, $action);
1130 1130
 
1131 1131
 	/**
1132 1132
 	 * Fires once the Ajax request has been validated or not.
@@ -1137,13 +1137,13 @@  discard block
 block discarded – undo
1137 1137
 	 * @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
1138 1138
 	 *                          0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
1139 1139
 	 */
1140
-	do_action( 'check_ajax_referer', $action, $result );
1140
+	do_action('check_ajax_referer', $action, $result);
1141 1141
 
1142
-	if ( $die && false === $result ) {
1143
-		if ( wp_doing_ajax() ) {
1142
+	if ($die && false === $result) {
1143
+		if (wp_doing_ajax()) {
1144 1144
 			wp_die( -1, 403 );
1145 1145
 		} else {
1146
-			die( '-1' );
1146
+			die('-1');
1147 1147
 		}
1148 1148
 	}
1149 1149
 
@@ -1151,7 +1151,7 @@  discard block
 block discarded – undo
1151 1151
 }
1152 1152
 endif;
1153 1153
 
1154
-if ( !function_exists('wp_redirect') ) :
1154
+if ( ! function_exists('wp_redirect')) :
1155 1155
 /**
1156 1156
  * Redirects to another page.
1157 1157
  *
@@ -1187,7 +1187,7 @@  discard block
 block discarded – undo
1187 1187
 	 * @param string $location The path to redirect to.
1188 1188
 	 * @param int    $status   Status code to use.
1189 1189
 	 */
1190
-	$location = apply_filters( 'wp_redirect', $location, $status );
1190
+	$location = apply_filters('wp_redirect', $location, $status);
1191 1191
 
1192 1192
 	/**
1193 1193
 	 * Filters the redirect status code.
@@ -1197,14 +1197,14 @@  discard block
 block discarded – undo
1197 1197
 	 * @param int    $status   Status code to use.
1198 1198
 	 * @param string $location The path to redirect to.
1199 1199
 	 */
1200
-	$status = apply_filters( 'wp_redirect_status', $status, $location );
1200
+	$status = apply_filters('wp_redirect_status', $status, $location);
1201 1201
 
1202
-	if ( ! $location )
1202
+	if ( ! $location)
1203 1203
 		return false;
1204 1204
 
1205 1205
 	$location = wp_sanitize_redirect($location);
1206 1206
 
1207
-	if ( !$is_IIS && PHP_SAPI != 'cgi-fcgi' )
1207
+	if ( ! $is_IIS && PHP_SAPI != 'cgi-fcgi')
1208 1208
 		status_header($status); // This causes problems on IIS and some FastCGI setups
1209 1209
 
1210 1210
 	header("Location: $location", true, $status);
@@ -1213,7 +1213,7 @@  discard block
 block discarded – undo
1213 1213
 }
1214 1214
 endif;
1215 1215
 
1216
-if ( !function_exists('wp_sanitize_redirect') ) :
1216
+if ( ! function_exists('wp_sanitize_redirect')) :
1217 1217
 /**
1218 1218
  * Sanitizes a URL for use in a redirect.
1219 1219
  *
@@ -1235,13 +1235,13 @@  discard block
 block discarded – undo
1235 1235
 			|   \xF4[\x80-\x8F][\x80-\xBF]{2}
1236 1236
 		){1,40}                              # ...one or more times
1237 1237
 		)/x';
1238
-	$location = preg_replace_callback( $regex, '_wp_sanitize_utf8_in_redirect', $location );
1238
+	$location = preg_replace_callback($regex, '_wp_sanitize_utf8_in_redirect', $location);
1239 1239
 	$location = preg_replace('|[^a-z0-9-~+_.?#=&;,/:%!*\[\]()@]|i', '', $location);
1240 1240
 	$location = wp_kses_no_null($location);
1241 1241
 
1242 1242
 	// remove %0d and %0a from location
1243 1243
 	$strip = array('%0d', '%0a', '%0D', '%0A');
1244
-	return _deep_replace( $strip, $location );
1244
+	return _deep_replace($strip, $location);
1245 1245
 }
1246 1246
 
1247 1247
 /**
@@ -1256,12 +1256,12 @@  discard block
 block discarded – undo
1256 1256
  * @param array $matches RegEx matches against the redirect location.
1257 1257
  * @return string URL-encoded version of the first RegEx match.
1258 1258
  */
1259
-function _wp_sanitize_utf8_in_redirect( $matches ) {
1260
-	return urlencode( $matches[0] );
1259
+function _wp_sanitize_utf8_in_redirect($matches) {
1260
+	return urlencode($matches[0]);
1261 1261
 }
1262 1262
 endif;
1263 1263
 
1264
-if ( !function_exists('wp_safe_redirect') ) :
1264
+if ( ! function_exists('wp_safe_redirect')) :
1265 1265
 /**
1266 1266
  * Performs a safe (local) redirect, using wp_redirect().
1267 1267
  *
@@ -1291,13 +1291,13 @@  discard block
 block discarded – undo
1291 1291
 	 * @param string $fallback_url The fallback URL to use by default.
1292 1292
 	 * @param int    $status       The redirect status.
1293 1293
 	 */
1294
-	$location = wp_validate_redirect( $location, apply_filters( 'wp_safe_redirect_fallback', admin_url(), $status ) );
1294
+	$location = wp_validate_redirect($location, apply_filters('wp_safe_redirect_fallback', admin_url(), $status));
1295 1295
 
1296 1296
 	wp_redirect($location, $status);
1297 1297
 }
1298 1298
 endif;
1299 1299
 
1300
-if ( !function_exists('wp_validate_redirect') ) :
1300
+if ( ! function_exists('wp_validate_redirect')) :
1301 1301
 /**
1302 1302
  * Validates a URL for use in a redirect.
1303 1303
  *
@@ -1314,33 +1314,33 @@  discard block
 block discarded – undo
1314 1314
  * @return string redirect-sanitized URL
1315 1315
  **/
1316 1316
 function wp_validate_redirect($location, $default = '') {
1317
-	$location = trim( $location, " \t\n\r\0\x08\x0B" );
1317
+	$location = trim($location, " \t\n\r\0\x08\x0B");
1318 1318
 	// browsers will assume 'http' is your protocol, and will obey a redirect to a URL starting with '//'
1319
-	if ( substr($location, 0, 2) == '//' )
1320
-		$location = 'http:' . $location;
1319
+	if (substr($location, 0, 2) == '//')
1320
+		$location = 'http:'.$location;
1321 1321
 
1322 1322
 	// In php 5 parse_url may fail if the URL query part contains http://, bug #38143
1323
-	$test = ( $cut = strpos($location, '?') ) ? substr( $location, 0, $cut ) : $location;
1323
+	$test = ($cut = strpos($location, '?')) ? substr($location, 0, $cut) : $location;
1324 1324
 
1325 1325
 	// @-operator is used to prevent possible warnings in PHP < 5.3.3.
1326 1326
 	$lp = @parse_url($test);
1327 1327
 
1328 1328
 	// Give up if malformed URL
1329
-	if ( false === $lp )
1329
+	if (false === $lp)
1330 1330
 		return $default;
1331 1331
 
1332 1332
 	// Allow only http and https schemes. No data:, etc.
1333
-	if ( isset($lp['scheme']) && !('http' == $lp['scheme'] || 'https' == $lp['scheme']) )
1333
+	if (isset($lp['scheme']) && ! ('http' == $lp['scheme'] || 'https' == $lp['scheme']))
1334 1334
 		return $default;
1335 1335
 
1336 1336
 	// Reject if certain components are set but host is not. This catches urls like https:host.com for which parse_url does not set the host field.
1337
-	if ( ! isset( $lp['host'] ) && ( isset( $lp['scheme'] ) || isset( $lp['user'] ) || isset( $lp['pass'] ) || isset( $lp['port'] ) ) ) {
1337
+	if ( ! isset($lp['host']) && (isset($lp['scheme']) || isset($lp['user']) || isset($lp['pass']) || isset($lp['port']))) {
1338 1338
 		return $default;
1339 1339
 	}
1340 1340
 
1341 1341
 	// Reject malformed components parse_url() can return on odd inputs.
1342
-	foreach ( array( 'user', 'pass', 'host' ) as $component ) {
1343
-		if ( isset( $lp[ $component ] ) && strpbrk( $lp[ $component ], ':/?#@' ) ) {
1342
+	foreach (array('user', 'pass', 'host') as $component) {
1343
+		if (isset($lp[$component]) && strpbrk($lp[$component], ':/?#@')) {
1344 1344
 			return $default;
1345 1345
 		}
1346 1346
 	}
@@ -1355,16 +1355,16 @@  discard block
 block discarded – undo
1355 1355
 	 * @param array       $hosts An array of allowed hosts.
1356 1356
 	 * @param bool|string $host  The parsed host; empty if not isset.
1357 1357
 	 */
1358
-	$allowed_hosts = (array) apply_filters( 'allowed_redirect_hosts', array($wpp['host']), isset($lp['host']) ? $lp['host'] : '' );
1358
+	$allowed_hosts = (array) apply_filters('allowed_redirect_hosts', array($wpp['host']), isset($lp['host']) ? $lp['host'] : '');
1359 1359
 
1360
-	if ( isset($lp['host']) && ( !in_array($lp['host'], $allowed_hosts) && $lp['host'] != strtolower($wpp['host'])) )
1360
+	if (isset($lp['host']) && ( ! in_array($lp['host'], $allowed_hosts) && $lp['host'] != strtolower($wpp['host'])))
1361 1361
 		$location = $default;
1362 1362
 
1363 1363
 	return $location;
1364 1364
 }
1365 1365
 endif;
1366 1366
 
1367
-if ( ! function_exists('wp_notify_postauthor') ) :
1367
+if ( ! function_exists('wp_notify_postauthor')) :
1368 1368
 /**
1369 1369
  * Notify an author (and/or others) of a comment/trackback/pingback on a post.
1370 1370
  *
@@ -1374,21 +1374,21 @@  discard block
 block discarded – undo
1374 1374
  * @param string          $deprecated Not used
1375 1375
  * @return bool True on completion. False if no email addresses were specified.
1376 1376
  */
1377
-function wp_notify_postauthor( $comment_id, $deprecated = null ) {
1378
-	if ( null !== $deprecated ) {
1379
-		_deprecated_argument( __FUNCTION__, '3.8.0' );
1377
+function wp_notify_postauthor($comment_id, $deprecated = null) {
1378
+	if (null !== $deprecated) {
1379
+		_deprecated_argument(__FUNCTION__, '3.8.0');
1380 1380
 	}
1381 1381
 
1382
-	$comment = get_comment( $comment_id );
1383
-	if ( empty( $comment ) || empty( $comment->comment_post_ID ) )
1382
+	$comment = get_comment($comment_id);
1383
+	if (empty($comment) || empty($comment->comment_post_ID))
1384 1384
 		return false;
1385 1385
 
1386
-	$post    = get_post( $comment->comment_post_ID );
1387
-	$author  = get_userdata( $post->post_author );
1386
+	$post    = get_post($comment->comment_post_ID);
1387
+	$author  = get_userdata($post->post_author);
1388 1388
 
1389 1389
 	// Who to notify? By default, just the post author, but others can be added.
1390 1390
 	$emails = array();
1391
-	if ( $author ) {
1391
+	if ($author) {
1392 1392
 		$emails[] = $author->user_email;
1393 1393
 	}
1394 1394
 
@@ -1403,16 +1403,16 @@  discard block
 block discarded – undo
1403 1403
 	 * @param array $emails     An array of email addresses to receive a comment notification.
1404 1404
 	 * @param int   $comment_id The comment ID.
1405 1405
 	 */
1406
-	$emails = apply_filters( 'comment_notification_recipients', $emails, $comment->comment_ID );
1407
-	$emails = array_filter( $emails );
1406
+	$emails = apply_filters('comment_notification_recipients', $emails, $comment->comment_ID);
1407
+	$emails = array_filter($emails);
1408 1408
 
1409 1409
 	// If there are no addresses to send the comment to, bail.
1410
-	if ( ! count( $emails ) ) {
1410
+	if ( ! count($emails)) {
1411 1411
 		return false;
1412 1412
 	}
1413 1413
 
1414 1414
 	// Facilitate unsetting below without knowing the keys.
1415
-	$emails = array_flip( $emails );
1415
+	$emails = array_flip($emails);
1416 1416
 
1417 1417
 	/**
1418 1418
 	 * Filters whether to notify comment authors of their comments on their own posts.
@@ -1426,103 +1426,103 @@  discard block
 block discarded – undo
1426 1426
 	 *                         Default false.
1427 1427
 	 * @param int  $comment_id The comment ID.
1428 1428
 	 */
1429
-	$notify_author = apply_filters( 'comment_notification_notify_author', false, $comment->comment_ID );
1429
+	$notify_author = apply_filters('comment_notification_notify_author', false, $comment->comment_ID);
1430 1430
 
1431 1431
 	// The comment was left by the author
1432
-	if ( $author && ! $notify_author && $comment->user_id == $post->post_author ) {
1433
-		unset( $emails[ $author->user_email ] );
1432
+	if ($author && ! $notify_author && $comment->user_id == $post->post_author) {
1433
+		unset($emails[$author->user_email]);
1434 1434
 	}
1435 1435
 
1436 1436
 	// The author moderated a comment on their own post
1437
-	if ( $author && ! $notify_author && $post->post_author == get_current_user_id() ) {
1438
-		unset( $emails[ $author->user_email ] );
1437
+	if ($author && ! $notify_author && $post->post_author == get_current_user_id()) {
1438
+		unset($emails[$author->user_email]);
1439 1439
 	}
1440 1440
 
1441 1441
 	// The post author is no longer a member of the blog
1442
-	if ( $author && ! $notify_author && ! user_can( $post->post_author, 'read_post', $post->ID ) ) {
1443
-		unset( $emails[ $author->user_email ] );
1442
+	if ($author && ! $notify_author && ! user_can($post->post_author, 'read_post', $post->ID)) {
1443
+		unset($emails[$author->user_email]);
1444 1444
 	}
1445 1445
 
1446 1446
 	// If there's no email to send the comment to, bail, otherwise flip array back around for use below
1447
-	if ( ! count( $emails ) ) {
1447
+	if ( ! count($emails)) {
1448 1448
 		return false;
1449 1449
 	} else {
1450
-		$emails = array_flip( $emails );
1450
+		$emails = array_flip($emails);
1451 1451
 	}
1452 1452
 
1453
-	$switched_locale = switch_to_locale( get_locale() );
1453
+	$switched_locale = switch_to_locale(get_locale());
1454 1454
 
1455 1455
 	$comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
1456 1456
 
1457 1457
 	// The blogname option is escaped with esc_html on the way into the database in sanitize_option
1458 1458
 	// we want to reverse this for the plain text arena of emails.
1459 1459
 	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
1460
-	$comment_content = wp_specialchars_decode( $comment->comment_content );
1460
+	$comment_content = wp_specialchars_decode($comment->comment_content);
1461 1461
 
1462
-	switch ( $comment->comment_type ) {
1462
+	switch ($comment->comment_type) {
1463 1463
 		case 'trackback':
1464 1464
 			/* translators: 1: Post title */
1465
-			$notify_message  = sprintf( __( 'New trackback on your post "%s"' ), $post->post_title ) . "\r\n";
1465
+			$notify_message  = sprintf(__('New trackback on your post "%s"'), $post->post_title)."\r\n";
1466 1466
 			/* translators: 1: Trackback/pingback website name, 2: website IP, 3: website hostname */
1467
-			$notify_message .= sprintf( __('Website: %1$s (IP: %2$s, %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
1468
-			$notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
1469
-			$notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
1470
-			$notify_message .= __( 'You can see all trackbacks on this post here:' ) . "\r\n";
1467
+			$notify_message .= sprintf(__('Website: %1$s (IP: %2$s, %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain)."\r\n";
1468
+			$notify_message .= sprintf(__('URL: %s'), $comment->comment_author_url)."\r\n";
1469
+			$notify_message .= sprintf(__('Comment: %s'), "\r\n".$comment_content)."\r\n\r\n";
1470
+			$notify_message .= __('You can see all trackbacks on this post here:')."\r\n";
1471 1471
 			/* translators: 1: blog name, 2: post title */
1472
-			$subject = sprintf( __('[%1$s] Trackback: "%2$s"'), $blogname, $post->post_title );
1472
+			$subject = sprintf(__('[%1$s] Trackback: "%2$s"'), $blogname, $post->post_title);
1473 1473
 			break;
1474 1474
 		case 'pingback':
1475 1475
 			/* translators: 1: Post title */
1476
-			$notify_message  = sprintf( __( 'New pingback on your post "%s"' ), $post->post_title ) . "\r\n";
1476
+			$notify_message  = sprintf(__('New pingback on your post "%s"'), $post->post_title)."\r\n";
1477 1477
 			/* translators: 1: Trackback/pingback website name, 2: website IP, 3: website hostname */
1478
-			$notify_message .= sprintf( __('Website: %1$s (IP: %2$s, %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
1479
-			$notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
1480
-			$notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
1481
-			$notify_message .= __( 'You can see all pingbacks on this post here:' ) . "\r\n";
1478
+			$notify_message .= sprintf(__('Website: %1$s (IP: %2$s, %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain)."\r\n";
1479
+			$notify_message .= sprintf(__('URL: %s'), $comment->comment_author_url)."\r\n";
1480
+			$notify_message .= sprintf(__('Comment: %s'), "\r\n".$comment_content)."\r\n\r\n";
1481
+			$notify_message .= __('You can see all pingbacks on this post here:')."\r\n";
1482 1482
 			/* translators: 1: blog name, 2: post title */
1483
-			$subject = sprintf( __('[%1$s] Pingback: "%2$s"'), $blogname, $post->post_title );
1483
+			$subject = sprintf(__('[%1$s] Pingback: "%2$s"'), $blogname, $post->post_title);
1484 1484
 			break;
1485 1485
 		default: // Comments
1486
-			$notify_message  = sprintf( __( 'New comment on your post "%s"' ), $post->post_title ) . "\r\n";
1486
+			$notify_message  = sprintf(__('New comment on your post "%s"'), $post->post_title)."\r\n";
1487 1487
 			/* translators: 1: comment author, 2: author IP, 3: author domain */
1488
-			$notify_message .= sprintf( __( 'Author: %1$s (IP: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
1489
-			$notify_message .= sprintf( __( 'Email: %s' ), $comment->comment_author_email ) . "\r\n";
1490
-			$notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
1491
-			$notify_message .= sprintf( __('Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
1492
-			$notify_message .= __( 'You can see all comments on this post here:' ) . "\r\n";
1488
+			$notify_message .= sprintf(__('Author: %1$s (IP: %2$s, %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain)."\r\n";
1489
+			$notify_message .= sprintf(__('Email: %s'), $comment->comment_author_email)."\r\n";
1490
+			$notify_message .= sprintf(__('URL: %s'), $comment->comment_author_url)."\r\n";
1491
+			$notify_message .= sprintf(__('Comment: %s'), "\r\n".$comment_content)."\r\n\r\n";
1492
+			$notify_message .= __('You can see all comments on this post here:')."\r\n";
1493 1493
 			/* translators: 1: blog name, 2: post title */
1494
-			$subject = sprintf( __('[%1$s] Comment: "%2$s"'), $blogname, $post->post_title );
1494
+			$subject = sprintf(__('[%1$s] Comment: "%2$s"'), $blogname, $post->post_title);
1495 1495
 			break;
1496 1496
 	}
1497
-	$notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n";
1498
-	$notify_message .= sprintf( __('Permalink: %s'), get_comment_link( $comment ) ) . "\r\n";
1497
+	$notify_message .= get_permalink($comment->comment_post_ID)."#comments\r\n\r\n";
1498
+	$notify_message .= sprintf(__('Permalink: %s'), get_comment_link($comment))."\r\n";
1499 1499
 
1500
-	if ( user_can( $post->post_author, 'edit_comment', $comment->comment_ID ) ) {
1501
-		if ( EMPTY_TRASH_DAYS ) {
1502
-			$notify_message .= sprintf( __( 'Trash it: %s' ), admin_url( "comment.php?action=trash&c={$comment->comment_ID}#wpbody-content" ) ) . "\r\n";
1500
+	if (user_can($post->post_author, 'edit_comment', $comment->comment_ID)) {
1501
+		if (EMPTY_TRASH_DAYS) {
1502
+			$notify_message .= sprintf(__('Trash it: %s'), admin_url("comment.php?action=trash&c={$comment->comment_ID}#wpbody-content"))."\r\n";
1503 1503
 		} else {
1504
-			$notify_message .= sprintf( __( 'Delete it: %s' ), admin_url( "comment.php?action=delete&c={$comment->comment_ID}#wpbody-content" ) ) . "\r\n";
1504
+			$notify_message .= sprintf(__('Delete it: %s'), admin_url("comment.php?action=delete&c={$comment->comment_ID}#wpbody-content"))."\r\n";
1505 1505
 		}
1506
-		$notify_message .= sprintf( __( 'Spam it: %s' ), admin_url( "comment.php?action=spam&c={$comment->comment_ID}#wpbody-content" ) ) . "\r\n";
1506
+		$notify_message .= sprintf(__('Spam it: %s'), admin_url("comment.php?action=spam&c={$comment->comment_ID}#wpbody-content"))."\r\n";
1507 1507
 	}
1508 1508
 
1509
-	$wp_email = 'wordpress@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME']));
1509
+	$wp_email = 'wordpress@'.preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME']));
1510 1510
 
1511
-	if ( '' == $comment->comment_author ) {
1511
+	if ('' == $comment->comment_author) {
1512 1512
 		$from = "From: \"$blogname\" <$wp_email>";
1513
-		if ( '' != $comment->comment_author_email )
1513
+		if ('' != $comment->comment_author_email)
1514 1514
 			$reply_to = "Reply-To: $comment->comment_author_email";
1515 1515
 	} else {
1516 1516
 		$from = "From: \"$comment->comment_author\" <$wp_email>";
1517
-		if ( '' != $comment->comment_author_email )
1517
+		if ('' != $comment->comment_author_email)
1518 1518
 			$reply_to = "Reply-To: \"$comment->comment_author_email\" <$comment->comment_author_email>";
1519 1519
 	}
1520 1520
 
1521 1521
 	$message_headers = "$from\n"
1522
-		. "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
1522
+		. "Content-Type: text/plain; charset=\"".get_option('blog_charset')."\"\n";
1523 1523
 
1524
-	if ( isset($reply_to) )
1525
-		$message_headers .= $reply_to . "\n";
1524
+	if (isset($reply_to))
1525
+		$message_headers .= $reply_to."\n";
1526 1526
 
1527 1527
 	/**
1528 1528
 	 * Filters the comment notification email text.
@@ -1532,7 +1532,7 @@  discard block
 block discarded – undo
1532 1532
 	 * @param string $notify_message The comment notification email text.
1533 1533
 	 * @param int    $comment_id     Comment ID.
1534 1534
 	 */
1535
-	$notify_message = apply_filters( 'comment_notification_text', $notify_message, $comment->comment_ID );
1535
+	$notify_message = apply_filters('comment_notification_text', $notify_message, $comment->comment_ID);
1536 1536
 
1537 1537
 	/**
1538 1538
 	 * Filters the comment notification email subject.
@@ -1542,7 +1542,7 @@  discard block
 block discarded – undo
1542 1542
 	 * @param string $subject    The comment notification email subject.
1543 1543
 	 * @param int    $comment_id Comment ID.
1544 1544
 	 */
1545
-	$subject = apply_filters( 'comment_notification_subject', $subject, $comment->comment_ID );
1545
+	$subject = apply_filters('comment_notification_subject', $subject, $comment->comment_ID);
1546 1546
 
1547 1547
 	/**
1548 1548
 	 * Filters the comment notification email headers.
@@ -1552,13 +1552,13 @@  discard block
 block discarded – undo
1552 1552
 	 * @param string $message_headers Headers for the comment notification email.
1553 1553
 	 * @param int    $comment_id      Comment ID.
1554 1554
 	 */
1555
-	$message_headers = apply_filters( 'comment_notification_headers', $message_headers, $comment->comment_ID );
1555
+	$message_headers = apply_filters('comment_notification_headers', $message_headers, $comment->comment_ID);
1556 1556
 
1557
-	foreach ( $emails as $email ) {
1558
-		@wp_mail( $email, wp_specialchars_decode( $subject ), $notify_message, $message_headers );
1557
+	foreach ($emails as $email) {
1558
+		@wp_mail($email, wp_specialchars_decode($subject), $notify_message, $message_headers);
1559 1559
 	}
1560 1560
 
1561
-	if ( $switched_locale ) {
1561
+	if ($switched_locale) {
1562 1562
 		restore_previous_locale();
1563 1563
 	}
1564 1564
 
@@ -1566,7 +1566,7 @@  discard block
 block discarded – undo
1566 1566
 }
1567 1567
 endif;
1568 1568
 
1569
-if ( !function_exists('wp_notify_moderator') ) :
1569
+if ( ! function_exists('wp_notify_moderator')) :
1570 1570
 /**
1571 1571
  * Notifies the moderator of the site about a new comment that is awaiting approval.
1572 1572
  *
@@ -1583,7 +1583,7 @@  discard block
 block discarded – undo
1583 1583
 function wp_notify_moderator($comment_id) {
1584 1584
 	global $wpdb;
1585 1585
 
1586
-	$maybe_notify = get_option( 'moderation_notify' );
1586
+	$maybe_notify = get_option('moderation_notify');
1587 1587
 
1588 1588
 	/**
1589 1589
 	 * Filters whether to send the site moderator email notifications, overriding the site setting.
@@ -1593,23 +1593,23 @@  discard block
 block discarded – undo
1593 1593
 	 * @param bool $maybe_notify Whether to notify blog moderator.
1594 1594
 	 * @param int  $comment_ID   The id of the comment for the notification.
1595 1595
 	 */
1596
-	$maybe_notify = apply_filters( 'notify_moderator', $maybe_notify, $comment_id );
1596
+	$maybe_notify = apply_filters('notify_moderator', $maybe_notify, $comment_id);
1597 1597
 
1598
-	if ( ! $maybe_notify ) {
1598
+	if ( ! $maybe_notify) {
1599 1599
 		return true;
1600 1600
 	}
1601 1601
 
1602 1602
 	$comment = get_comment($comment_id);
1603 1603
 	$post = get_post($comment->comment_post_ID);
1604
-	$user = get_userdata( $post->post_author );
1604
+	$user = get_userdata($post->post_author);
1605 1605
 	// Send to the administration and to the post author if the author can modify the comment.
1606
-	$emails = array( get_option( 'admin_email' ) );
1607
-	if ( $user && user_can( $user->ID, 'edit_comment', $comment_id ) && ! empty( $user->user_email ) ) {
1608
-		if ( 0 !== strcasecmp( $user->user_email, get_option( 'admin_email' ) ) )
1606
+	$emails = array(get_option('admin_email'));
1607
+	if ($user && user_can($user->ID, 'edit_comment', $comment_id) && ! empty($user->user_email)) {
1608
+		if (0 !== strcasecmp($user->user_email, get_option('admin_email')))
1609 1609
 			$emails[] = $user->user_email;
1610 1610
 	}
1611 1611
 
1612
-	$switched_locale = switch_to_locale( get_locale() );
1612
+	$switched_locale = switch_to_locale(get_locale());
1613 1613
 
1614 1614
 	$comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
1615 1615
 	$comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'");
@@ -1617,65 +1617,65 @@  discard block
 block discarded – undo
1617 1617
 	// The blogname option is escaped with esc_html on the way into the database in sanitize_option
1618 1618
 	// we want to reverse this for the plain text arena of emails.
1619 1619
 	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
1620
-	$comment_content = wp_specialchars_decode( $comment->comment_content );
1620
+	$comment_content = wp_specialchars_decode($comment->comment_content);
1621 1621
 
1622
-	switch ( $comment->comment_type ) {
1622
+	switch ($comment->comment_type) {
1623 1623
 		case 'trackback':
1624 1624
 			/* translators: 1: Post title */
1625
-			$notify_message  = sprintf( __('A new trackback on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
1626
-			$notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
1625
+			$notify_message  = sprintf(__('A new trackback on the post "%s" is waiting for your approval'), $post->post_title)."\r\n";
1626
+			$notify_message .= get_permalink($comment->comment_post_ID)."\r\n\r\n";
1627 1627
 			/* translators: 1: Trackback/pingback website name, 2: website IP, 3: website hostname */
1628
-			$notify_message .= sprintf( __( 'Website: %1$s (IP: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
1628
+			$notify_message .= sprintf(__('Website: %1$s (IP: %2$s, %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain)."\r\n";
1629 1629
 			/* translators: 1: Trackback/pingback/comment author URL */
1630
-			$notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
1631
-			$notify_message .= __('Trackback excerpt: ') . "\r\n" . $comment_content . "\r\n\r\n";
1630
+			$notify_message .= sprintf(__('URL: %s'), $comment->comment_author_url)."\r\n";
1631
+			$notify_message .= __('Trackback excerpt: ')."\r\n".$comment_content."\r\n\r\n";
1632 1632
 			break;
1633 1633
 		case 'pingback':
1634 1634
 			/* translators: 1: Post title */
1635
-			$notify_message  = sprintf( __('A new pingback on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
1636
-			$notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
1635
+			$notify_message  = sprintf(__('A new pingback on the post "%s" is waiting for your approval'), $post->post_title)."\r\n";
1636
+			$notify_message .= get_permalink($comment->comment_post_ID)."\r\n\r\n";
1637 1637
 			/* translators: 1: Trackback/pingback website name, 2: website IP, 3: website hostname */
1638
-			$notify_message .= sprintf( __( 'Website: %1$s (IP: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
1638
+			$notify_message .= sprintf(__('Website: %1$s (IP: %2$s, %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain)."\r\n";
1639 1639
 			/* translators: 1: Trackback/pingback/comment author URL */
1640
-			$notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
1641
-			$notify_message .= __('Pingback excerpt: ') . "\r\n" . $comment_content . "\r\n\r\n";
1640
+			$notify_message .= sprintf(__('URL: %s'), $comment->comment_author_url)."\r\n";
1641
+			$notify_message .= __('Pingback excerpt: ')."\r\n".$comment_content."\r\n\r\n";
1642 1642
 			break;
1643 1643
 		default: // Comments
1644 1644
 			/* translators: 1: Post title */
1645
-			$notify_message  = sprintf( __('A new comment on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
1646
-			$notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
1645
+			$notify_message  = sprintf(__('A new comment on the post "%s" is waiting for your approval'), $post->post_title)."\r\n";
1646
+			$notify_message .= get_permalink($comment->comment_post_ID)."\r\n\r\n";
1647 1647
 			/* translators: 1: Comment author name, 2: comment author's IP, 3: comment author IP's hostname */
1648
-			$notify_message .= sprintf( __( 'Author: %1$s (IP: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
1648
+			$notify_message .= sprintf(__('Author: %1$s (IP: %2$s, %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain)."\r\n";
1649 1649
 			/* translators: 1: Comment author URL */
1650
-			$notify_message .= sprintf( __( 'Email: %s' ), $comment->comment_author_email ) . "\r\n";
1650
+			$notify_message .= sprintf(__('Email: %s'), $comment->comment_author_email)."\r\n";
1651 1651
 			/* translators: 1: Trackback/pingback/comment author URL */
1652
-			$notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
1652
+			$notify_message .= sprintf(__('URL: %s'), $comment->comment_author_url)."\r\n";
1653 1653
 			/* translators: 1: Comment text */
1654
-			$notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
1654
+			$notify_message .= sprintf(__('Comment: %s'), "\r\n".$comment_content)."\r\n\r\n";
1655 1655
 			break;
1656 1656
 	}
1657 1657
 
1658 1658
 	/* translators: Comment moderation. 1: Comment action URL */
1659
-	$notify_message .= sprintf( __( 'Approve it: %s' ), admin_url( "comment.php?action=approve&c={$comment_id}#wpbody-content" ) ) . "\r\n";
1659
+	$notify_message .= sprintf(__('Approve it: %s'), admin_url("comment.php?action=approve&c={$comment_id}#wpbody-content"))."\r\n";
1660 1660
 
1661
-	if ( EMPTY_TRASH_DAYS ) {
1661
+	if (EMPTY_TRASH_DAYS) {
1662 1662
 		/* translators: Comment moderation. 1: Comment action URL */
1663
-		$notify_message .= sprintf( __( 'Trash it: %s' ), admin_url( "comment.php?action=trash&c={$comment_id}#wpbody-content" ) ) . "\r\n";
1663
+		$notify_message .= sprintf(__('Trash it: %s'), admin_url("comment.php?action=trash&c={$comment_id}#wpbody-content"))."\r\n";
1664 1664
 	} else {
1665 1665
 		/* translators: Comment moderation. 1: Comment action URL */
1666
-		$notify_message .= sprintf( __( 'Delete it: %s' ), admin_url( "comment.php?action=delete&c={$comment_id}#wpbody-content" ) ) . "\r\n";
1666
+		$notify_message .= sprintf(__('Delete it: %s'), admin_url("comment.php?action=delete&c={$comment_id}#wpbody-content"))."\r\n";
1667 1667
 	}
1668 1668
 
1669 1669
 	/* translators: Comment moderation. 1: Comment action URL */
1670
-	$notify_message .= sprintf( __( 'Spam it: %s' ), admin_url( "comment.php?action=spam&c={$comment_id}#wpbody-content" ) ) . "\r\n";
1670
+	$notify_message .= sprintf(__('Spam it: %s'), admin_url("comment.php?action=spam&c={$comment_id}#wpbody-content"))."\r\n";
1671 1671
 
1672 1672
 	/* translators: Comment moderation. 1: Number of comments awaiting approval */
1673
-	$notify_message .= sprintf( _n('Currently %s comment is waiting for approval. Please visit the moderation panel:',
1674
- 		'Currently %s comments are waiting for approval. Please visit the moderation panel:', $comments_waiting), number_format_i18n($comments_waiting) ) . "\r\n";
1675
-	$notify_message .= admin_url( "edit-comments.php?comment_status=moderated#wpbody-content" ) . "\r\n";
1673
+	$notify_message .= sprintf(_n('Currently %s comment is waiting for approval. Please visit the moderation panel:',
1674
+ 		'Currently %s comments are waiting for approval. Please visit the moderation panel:', $comments_waiting), number_format_i18n($comments_waiting))."\r\n";
1675
+	$notify_message .= admin_url("edit-comments.php?comment_status=moderated#wpbody-content")."\r\n";
1676 1676
 
1677 1677
 	/* translators: Comment moderation notification email subject. 1: Site name, 2: Post title */
1678
-	$subject = sprintf( __('[%1$s] Please moderate: "%2$s"'), $blogname, $post->post_title );
1678
+	$subject = sprintf(__('[%1$s] Please moderate: "%2$s"'), $blogname, $post->post_title);
1679 1679
 	$message_headers = '';
1680 1680
 
1681 1681
 	/**
@@ -1686,7 +1686,7 @@  discard block
 block discarded – undo
1686 1686
 	 * @param array $emails     List of email addresses to notify for comment moderation.
1687 1687
 	 * @param int   $comment_id Comment ID.
1688 1688
 	 */
1689
-	$emails = apply_filters( 'comment_moderation_recipients', $emails, $comment_id );
1689
+	$emails = apply_filters('comment_moderation_recipients', $emails, $comment_id);
1690 1690
 
1691 1691
 	/**
1692 1692
 	 * Filters the comment moderation email text.
@@ -1696,7 +1696,7 @@  discard block
 block discarded – undo
1696 1696
 	 * @param string $notify_message Text of the comment moderation email.
1697 1697
 	 * @param int    $comment_id     Comment ID.
1698 1698
 	 */
1699
-	$notify_message = apply_filters( 'comment_moderation_text', $notify_message, $comment_id );
1699
+	$notify_message = apply_filters('comment_moderation_text', $notify_message, $comment_id);
1700 1700
 
1701 1701
 	/**
1702 1702
 	 * Filters the comment moderation email subject.
@@ -1706,7 +1706,7 @@  discard block
 block discarded – undo
1706 1706
 	 * @param string $subject    Subject of the comment moderation email.
1707 1707
 	 * @param int    $comment_id Comment ID.
1708 1708
 	 */
1709
-	$subject = apply_filters( 'comment_moderation_subject', $subject, $comment_id );
1709
+	$subject = apply_filters('comment_moderation_subject', $subject, $comment_id);
1710 1710
 
1711 1711
 	/**
1712 1712
 	 * Filters the comment moderation email headers.
@@ -1716,13 +1716,13 @@  discard block
 block discarded – undo
1716 1716
 	 * @param string $message_headers Headers for the comment moderation email.
1717 1717
 	 * @param int    $comment_id      Comment ID.
1718 1718
 	 */
1719
-	$message_headers = apply_filters( 'comment_moderation_headers', $message_headers, $comment_id );
1719
+	$message_headers = apply_filters('comment_moderation_headers', $message_headers, $comment_id);
1720 1720
 
1721
-	foreach ( $emails as $email ) {
1722
-		@wp_mail( $email, wp_specialchars_decode( $subject ), $notify_message, $message_headers );
1721
+	foreach ($emails as $email) {
1722
+		@wp_mail($email, wp_specialchars_decode($subject), $notify_message, $message_headers);
1723 1723
 	}
1724 1724
 
1725
-	if ( $switched_locale ) {
1725
+	if ($switched_locale) {
1726 1726
 		restore_previous_locale();
1727 1727
 	}
1728 1728
 
@@ -1730,7 +1730,7 @@  discard block
 block discarded – undo
1730 1730
 }
1731 1731
 endif;
1732 1732
 
1733
-if ( !function_exists('wp_password_change_notification') ) :
1733
+if ( ! function_exists('wp_password_change_notification')) :
1734 1734
 /**
1735 1735
  * Notify the blog admin of a user changing password, normally via email.
1736 1736
  *
@@ -1738,22 +1738,22 @@  discard block
 block discarded – undo
1738 1738
  *
1739 1739
  * @param WP_User $user User object.
1740 1740
  */
1741
-function wp_password_change_notification( $user ) {
1741
+function wp_password_change_notification($user) {
1742 1742
 	// send a copy of password change notification to the admin
1743 1743
 	// but check to see if it's the admin whose password we're changing, and skip this
1744
-	if ( 0 !== strcasecmp( $user->user_email, get_option( 'admin_email' ) ) ) {
1744
+	if (0 !== strcasecmp($user->user_email, get_option('admin_email'))) {
1745 1745
 		/* translators: %s: user name */
1746
-		$message = sprintf( __( 'Password changed for user: %s' ), $user->user_login ) . "\r\n";
1746
+		$message = sprintf(__('Password changed for user: %s'), $user->user_login)."\r\n";
1747 1747
 		// The blogname option is escaped with esc_html on the way into the database in sanitize_option
1748 1748
 		// we want to reverse this for the plain text arena of emails.
1749 1749
 		$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
1750 1750
 		/* translators: %s: site title */
1751
-		wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Password Changed' ), $blogname ), $message );
1751
+		wp_mail(get_option('admin_email'), sprintf(__('[%s] Password Changed'), $blogname), $message);
1752 1752
 	}
1753 1753
 }
1754 1754
 endif;
1755 1755
 
1756
-if ( !function_exists('wp_new_user_notification') ) :
1756
+if ( ! function_exists('wp_new_user_notification')) :
1757 1757
 /**
1758 1758
  * Email login credentials to a newly-registered user.
1759 1759
  *
@@ -1772,67 +1772,67 @@  discard block
 block discarded – undo
1772 1772
  * @param string $notify     Optional. Type of notification that should happen. Accepts 'admin' or an empty
1773 1773
  *                           string (admin only), 'user', or 'both' (admin and user). Default empty.
1774 1774
  */
1775
-function wp_new_user_notification( $user_id, $deprecated = null, $notify = '' ) {
1776
-	if ( $deprecated !== null ) {
1777
-		_deprecated_argument( __FUNCTION__, '4.3.1' );
1775
+function wp_new_user_notification($user_id, $deprecated = null, $notify = '') {
1776
+	if ($deprecated !== null) {
1777
+		_deprecated_argument(__FUNCTION__, '4.3.1');
1778 1778
 	}
1779 1779
 
1780 1780
 	global $wpdb, $wp_hasher;
1781
-	$user = get_userdata( $user_id );
1781
+	$user = get_userdata($user_id);
1782 1782
 
1783 1783
 	// The blogname option is escaped with esc_html on the way into the database in sanitize_option
1784 1784
 	// we want to reverse this for the plain text arena of emails.
1785 1785
 	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
1786 1786
 
1787
-	if ( 'user' !== $notify ) {
1788
-		$switched_locale = switch_to_locale( get_locale() );
1789
-		$message  = sprintf( __( 'New user registration on your site %s:' ), $blogname ) . "\r\n\r\n";
1790
-		$message .= sprintf( __( 'Username: %s' ), $user->user_login ) . "\r\n\r\n";
1791
-		$message .= sprintf( __( 'Email: %s' ), $user->user_email ) . "\r\n";
1787
+	if ('user' !== $notify) {
1788
+		$switched_locale = switch_to_locale(get_locale());
1789
+		$message  = sprintf(__('New user registration on your site %s:'), $blogname)."\r\n\r\n";
1790
+		$message .= sprintf(__('Username: %s'), $user->user_login)."\r\n\r\n";
1791
+		$message .= sprintf(__('Email: %s'), $user->user_email)."\r\n";
1792 1792
 
1793
-		@wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] New User Registration' ), $blogname ), $message );
1793
+		@wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);
1794 1794
 
1795
-		if ( $switched_locale ) {
1795
+		if ($switched_locale) {
1796 1796
 			restore_previous_locale();
1797 1797
 		}
1798 1798
 	}
1799 1799
 
1800 1800
 	// `$deprecated was pre-4.3 `$plaintext_pass`. An empty `$plaintext_pass` didn't sent a user notification.
1801
-	if ( 'admin' === $notify || ( empty( $deprecated ) && empty( $notify ) ) ) {
1801
+	if ('admin' === $notify || (empty($deprecated) && empty($notify))) {
1802 1802
 		return;
1803 1803
 	}
1804 1804
 
1805 1805
 	// Generate something random for a password reset key.
1806
-	$key = wp_generate_password( 20, false );
1806
+	$key = wp_generate_password(20, false);
1807 1807
 
1808 1808
 	/** This action is documented in wp-login.php */
1809
-	do_action( 'retrieve_password_key', $user->user_login, $key );
1809
+	do_action('retrieve_password_key', $user->user_login, $key);
1810 1810
 
1811 1811
 	// Now insert the key, hashed, into the DB.
1812
-	if ( empty( $wp_hasher ) ) {
1813
-		require_once ABSPATH . WPINC . '/class-phpass.php';
1814
-		$wp_hasher = new PasswordHash( 8, true );
1812
+	if (empty($wp_hasher)) {
1813
+		require_once ABSPATH.WPINC.'/class-phpass.php';
1814
+		$wp_hasher = new PasswordHash(8, true);
1815 1815
 	}
1816
-	$hashed = time() . ':' . $wp_hasher->HashPassword( $key );
1817
-	$wpdb->update( $wpdb->users, array( 'user_activation_key' => $hashed ), array( 'user_login' => $user->user_login ) );
1816
+	$hashed = time().':'.$wp_hasher->HashPassword($key);
1817
+	$wpdb->update($wpdb->users, array('user_activation_key' => $hashed), array('user_login' => $user->user_login));
1818 1818
 
1819
-	$switched_locale = switch_to_locale( get_user_locale( $user ) );
1819
+	$switched_locale = switch_to_locale(get_user_locale($user));
1820 1820
 
1821
-	$message = sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n";
1822
-	$message .= __('To set your password, visit the following address:') . "\r\n\r\n";
1823
-	$message .= '<' . network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user->user_login), 'login') . ">\r\n\r\n";
1821
+	$message = sprintf(__('Username: %s'), $user->user_login)."\r\n\r\n";
1822
+	$message .= __('To set your password, visit the following address:')."\r\n\r\n";
1823
+	$message .= '<'.network_site_url("wp-login.php?action=rp&key=$key&login=".rawurlencode($user->user_login), 'login').">\r\n\r\n";
1824 1824
 
1825
-	$message .= wp_login_url() . "\r\n";
1825
+	$message .= wp_login_url()."\r\n";
1826 1826
 
1827 1827
 	wp_mail($user->user_email, sprintf(__('[%s] Your username and password info'), $blogname), $message);
1828 1828
 
1829
-	if ( $switched_locale ) {
1829
+	if ($switched_locale) {
1830 1830
 		restore_previous_locale();
1831 1831
 	}
1832 1832
 }
1833 1833
 endif;
1834 1834
 
1835
-if ( !function_exists('wp_nonce_tick') ) :
1835
+if ( ! function_exists('wp_nonce_tick')) :
1836 1836
 /**
1837 1837
  * Get the time-dependent variable for nonce creation.
1838 1838
  *
@@ -1851,13 +1851,13 @@  discard block
 block discarded – undo
1851 1851
 	 *
1852 1852
 	 * @param int $lifespan Lifespan of nonces in seconds. Default 86,400 seconds, or one day.
1853 1853
 	 */
1854
-	$nonce_life = apply_filters( 'nonce_life', DAY_IN_SECONDS );
1854
+	$nonce_life = apply_filters('nonce_life', DAY_IN_SECONDS);
1855 1855
 
1856
-	return ceil(time() / ( $nonce_life / 2 ));
1856
+	return ceil(time() / ($nonce_life / 2));
1857 1857
 }
1858 1858
 endif;
1859 1859
 
1860
-if ( !function_exists('wp_verify_nonce') ) :
1860
+if ( ! function_exists('wp_verify_nonce')) :
1861 1861
 /**
1862 1862
  * Verify that correct nonce was used with time limit.
1863 1863
  *
@@ -1871,11 +1871,11 @@  discard block
 block discarded – undo
1871 1871
  * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
1872 1872
  *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
1873 1873
  */
1874
-function wp_verify_nonce( $nonce, $action = -1 ) {
1874
+function wp_verify_nonce($nonce, $action = -1) {
1875 1875
 	$nonce = (string) $nonce;
1876 1876
 	$user = wp_get_current_user();
1877 1877
 	$uid = (int) $user->ID;
1878
-	if ( ! $uid ) {
1878
+	if ( ! $uid) {
1879 1879
 		/**
1880 1880
 		 * Filters whether the user who generated the nonce is logged out.
1881 1881
 		 *
@@ -1884,10 +1884,10 @@  discard block
 block discarded – undo
1884 1884
 		 * @param int    $uid    ID of the nonce-owning user.
1885 1885
 		 * @param string $action The nonce action.
1886 1886
 		 */
1887
-		$uid = apply_filters( 'nonce_user_logged_out', $uid, $action );
1887
+		$uid = apply_filters('nonce_user_logged_out', $uid, $action);
1888 1888
 	}
1889 1889
 
1890
-	if ( empty( $nonce ) ) {
1890
+	if (empty($nonce)) {
1891 1891
 		return false;
1892 1892
 	}
1893 1893
 
@@ -1895,14 +1895,14 @@  discard block
 block discarded – undo
1895 1895
 	$i = wp_nonce_tick();
1896 1896
 
1897 1897
 	// Nonce generated 0-12 hours ago
1898
-	$expected = substr( wp_hash( $i . '|' . $action . '|' . $uid . '|' . $token, 'nonce'), -12, 10 );
1899
-	if ( hash_equals( $expected, $nonce ) ) {
1898
+	$expected = substr(wp_hash($i.'|'.$action.'|'.$uid.'|'.$token, 'nonce'), -12, 10);
1899
+	if (hash_equals($expected, $nonce)) {
1900 1900
 		return 1;
1901 1901
 	}
1902 1902
 
1903 1903
 	// Nonce generated 12-24 hours ago
1904
-	$expected = substr( wp_hash( ( $i - 1 ) . '|' . $action . '|' . $uid . '|' . $token, 'nonce' ), -12, 10 );
1905
-	if ( hash_equals( $expected, $nonce ) ) {
1904
+	$expected = substr(wp_hash(($i - 1).'|'.$action.'|'.$uid.'|'.$token, 'nonce'), -12, 10);
1905
+	if (hash_equals($expected, $nonce)) {
1906 1906
 		return 2;
1907 1907
 	}
1908 1908
 
@@ -1916,14 +1916,14 @@  discard block
 block discarded – undo
1916 1916
 	 * @param WP_User    $user   The current user object.
1917 1917
 	 * @param string     $token  The user's session token.
1918 1918
 	 */
1919
-	do_action( 'wp_verify_nonce_failed', $nonce, $action, $user, $token );
1919
+	do_action('wp_verify_nonce_failed', $nonce, $action, $user, $token);
1920 1920
 
1921 1921
 	// Invalid nonce
1922 1922
 	return false;
1923 1923
 }
1924 1924
 endif;
1925 1925
 
1926
-if ( !function_exists('wp_create_nonce') ) :
1926
+if ( ! function_exists('wp_create_nonce')) :
1927 1927
 /**
1928 1928
  * Creates a cryptographic token tied to a specific action, user, user session,
1929 1929
  * and window of time.
@@ -1937,19 +1937,19 @@  discard block
 block discarded – undo
1937 1937
 function wp_create_nonce($action = -1) {
1938 1938
 	$user = wp_get_current_user();
1939 1939
 	$uid = (int) $user->ID;
1940
-	if ( ! $uid ) {
1940
+	if ( ! $uid) {
1941 1941
 		/** This filter is documented in wp-includes/pluggable.php */
1942
-		$uid = apply_filters( 'nonce_user_logged_out', $uid, $action );
1942
+		$uid = apply_filters('nonce_user_logged_out', $uid, $action);
1943 1943
 	}
1944 1944
 
1945 1945
 	$token = wp_get_session_token();
1946 1946
 	$i = wp_nonce_tick();
1947 1947
 
1948
-	return substr( wp_hash( $i . '|' . $action . '|' . $uid . '|' . $token, 'nonce' ), -12, 10 );
1948
+	return substr(wp_hash($i.'|'.$action.'|'.$uid.'|'.$token, 'nonce'), -12, 10);
1949 1949
 }
1950 1950
 endif;
1951 1951
 
1952
-if ( !function_exists('wp_salt') ) :
1952
+if ( ! function_exists('wp_salt')) :
1953 1953
 /**
1954 1954
  * Get salt to add to hashes.
1955 1955
  *
@@ -1985,9 +1985,9 @@  discard block
 block discarded – undo
1985 1985
  * @param string $scheme Authentication scheme (auth, secure_auth, logged_in, nonce)
1986 1986
  * @return string Salt value
1987 1987
  */
1988
-function wp_salt( $scheme = 'auth' ) {
1988
+function wp_salt($scheme = 'auth') {
1989 1989
 	static $cached_salts = array();
1990
-	if ( isset( $cached_salts[ $scheme ] ) ) {
1990
+	if (isset($cached_salts[$scheme])) {
1991 1991
 		/**
1992 1992
 		 * Filters the WordPress salt.
1993 1993
 		 *
@@ -1997,19 +1997,19 @@  discard block
 block discarded – undo
1997 1997
 		 * @param string $scheme      Authentication scheme. Values include 'auth',
1998 1998
 		 *                            'secure_auth', 'logged_in', and 'nonce'.
1999 1999
 		 */
2000
-		return apply_filters( 'salt', $cached_salts[ $scheme ], $scheme );
2000
+		return apply_filters('salt', $cached_salts[$scheme], $scheme);
2001 2001
 	}
2002 2002
 
2003 2003
 	static $duplicated_keys;
2004
-	if ( null === $duplicated_keys ) {
2005
-		$duplicated_keys = array( 'put your unique phrase here' => true );
2006
-		foreach ( array( 'AUTH', 'SECURE_AUTH', 'LOGGED_IN', 'NONCE', 'SECRET' ) as $first ) {
2007
-			foreach ( array( 'KEY', 'SALT' ) as $second ) {
2008
-				if ( ! defined( "{$first}_{$second}" ) ) {
2004
+	if (null === $duplicated_keys) {
2005
+		$duplicated_keys = array('put your unique phrase here' => true);
2006
+		foreach (array('AUTH', 'SECURE_AUTH', 'LOGGED_IN', 'NONCE', 'SECRET') as $first) {
2007
+			foreach (array('KEY', 'SALT') as $second) {
2008
+				if ( ! defined("{$first}_{$second}")) {
2009 2009
 					continue;
2010 2010
 				}
2011
-				$value = constant( "{$first}_{$second}" );
2012
-				$duplicated_keys[ $value ] = isset( $duplicated_keys[ $value ] );
2011
+				$value = constant("{$first}_{$second}");
2012
+				$duplicated_keys[$value] = isset($duplicated_keys[$value]);
2013 2013
 			}
2014 2014
 		}
2015 2015
 	}
@@ -2018,45 +2018,45 @@  discard block
 block discarded – undo
2018 2018
 		'key' => '',
2019 2019
 		'salt' => ''
2020 2020
 	);
2021
-	if ( defined( 'SECRET_KEY' ) && SECRET_KEY && empty( $duplicated_keys[ SECRET_KEY ] ) ) {
2021
+	if (defined('SECRET_KEY') && SECRET_KEY && empty($duplicated_keys[SECRET_KEY])) {
2022 2022
 		$values['key'] = SECRET_KEY;
2023 2023
 	}
2024
-	if ( 'auth' == $scheme && defined( 'SECRET_SALT' ) && SECRET_SALT && empty( $duplicated_keys[ SECRET_SALT ] ) ) {
2024
+	if ('auth' == $scheme && defined('SECRET_SALT') && SECRET_SALT && empty($duplicated_keys[SECRET_SALT])) {
2025 2025
 		$values['salt'] = SECRET_SALT;
2026 2026
 	}
2027 2027
 
2028
-	if ( in_array( $scheme, array( 'auth', 'secure_auth', 'logged_in', 'nonce' ) ) ) {
2029
-		foreach ( array( 'key', 'salt' ) as $type ) {
2030
-			$const = strtoupper( "{$scheme}_{$type}" );
2031
-			if ( defined( $const ) && constant( $const ) && empty( $duplicated_keys[ constant( $const ) ] ) ) {
2032
-				$values[ $type ] = constant( $const );
2033
-			} elseif ( ! $values[ $type ] ) {
2034
-				$values[ $type ] = get_site_option( "{$scheme}_{$type}" );
2035
-				if ( ! $values[ $type ] ) {
2036
-					$values[ $type ] = wp_generate_password( 64, true, true );
2037
-					update_site_option( "{$scheme}_{$type}", $values[ $type ] );
2028
+	if (in_array($scheme, array('auth', 'secure_auth', 'logged_in', 'nonce'))) {
2029
+		foreach (array('key', 'salt') as $type) {
2030
+			$const = strtoupper("{$scheme}_{$type}");
2031
+			if (defined($const) && constant($const) && empty($duplicated_keys[constant($const)])) {
2032
+				$values[$type] = constant($const);
2033
+			} elseif ( ! $values[$type]) {
2034
+				$values[$type] = get_site_option("{$scheme}_{$type}");
2035
+				if ( ! $values[$type]) {
2036
+					$values[$type] = wp_generate_password(64, true, true);
2037
+					update_site_option("{$scheme}_{$type}", $values[$type]);
2038 2038
 				}
2039 2039
 			}
2040 2040
 		}
2041 2041
 	} else {
2042
-		if ( ! $values['key'] ) {
2043
-			$values['key'] = get_site_option( 'secret_key' );
2044
-			if ( ! $values['key'] ) {
2045
-				$values['key'] = wp_generate_password( 64, true, true );
2046
-				update_site_option( 'secret_key', $values['key'] );
2042
+		if ( ! $values['key']) {
2043
+			$values['key'] = get_site_option('secret_key');
2044
+			if ( ! $values['key']) {
2045
+				$values['key'] = wp_generate_password(64, true, true);
2046
+				update_site_option('secret_key', $values['key']);
2047 2047
 			}
2048 2048
 		}
2049
-		$values['salt'] = hash_hmac( 'md5', $scheme, $values['key'] );
2049
+		$values['salt'] = hash_hmac('md5', $scheme, $values['key']);
2050 2050
 	}
2051 2051
 
2052
-	$cached_salts[ $scheme ] = $values['key'] . $values['salt'];
2052
+	$cached_salts[$scheme] = $values['key'].$values['salt'];
2053 2053
 
2054 2054
 	/** This filter is documented in wp-includes/pluggable.php */
2055
-	return apply_filters( 'salt', $cached_salts[ $scheme ], $scheme );
2055
+	return apply_filters('salt', $cached_salts[$scheme], $scheme);
2056 2056
 }
2057 2057
 endif;
2058 2058
 
2059
-if ( !function_exists('wp_hash') ) :
2059
+if ( ! function_exists('wp_hash')) :
2060 2060
 /**
2061 2061
  * Get hash of given string.
2062 2062
  *
@@ -2073,7 +2073,7 @@  discard block
 block discarded – undo
2073 2073
 }
2074 2074
 endif;
2075 2075
 
2076
-if ( !function_exists('wp_hash_password') ) :
2076
+if ( ! function_exists('wp_hash_password')) :
2077 2077
 /**
2078 2078
  * Create a hash (encrypt) of a plain text password.
2079 2079
  *
@@ -2090,17 +2090,17 @@  discard block
 block discarded – undo
2090 2090
 function wp_hash_password($password) {
2091 2091
 	global $wp_hasher;
2092 2092
 
2093
-	if ( empty($wp_hasher) ) {
2094
-		require_once( ABSPATH . WPINC . '/class-phpass.php');
2093
+	if (empty($wp_hasher)) {
2094
+		require_once(ABSPATH.WPINC.'/class-phpass.php');
2095 2095
 		// By default, use the portable hash from phpass
2096 2096
 		$wp_hasher = new PasswordHash(8, true);
2097 2097
 	}
2098 2098
 
2099
-	return $wp_hasher->HashPassword( trim( $password ) );
2099
+	return $wp_hasher->HashPassword(trim($password));
2100 2100
 }
2101 2101
 endif;
2102 2102
 
2103
-if ( !function_exists('wp_check_password') ) :
2103
+if ( ! function_exists('wp_check_password')) :
2104 2104
 /**
2105 2105
  * Checks the plaintext password against the encrypted Password.
2106 2106
  *
@@ -2127,9 +2127,9 @@  discard block
 block discarded – undo
2127 2127
 	global $wp_hasher;
2128 2128
 
2129 2129
 	// If the hash is still md5...
2130
-	if ( strlen($hash) <= 32 ) {
2131
-		$check = hash_equals( $hash, md5( $password ) );
2132
-		if ( $check && $user_id ) {
2130
+	if (strlen($hash) <= 32) {
2131
+		$check = hash_equals($hash, md5($password));
2132
+		if ($check && $user_id) {
2133 2133
 			// Rehash using new hash.
2134 2134
 			wp_set_password($password, $user_id);
2135 2135
 			$hash = wp_hash_password($password);
@@ -2145,13 +2145,13 @@  discard block
 block discarded – undo
2145 2145
 		 * @param string     $hash     The hashed password.
2146 2146
 		 * @param string|int $user_id  User ID. Can be empty.
2147 2147
 		 */
2148
-		return apply_filters( 'check_password', $check, $password, $hash, $user_id );
2148
+		return apply_filters('check_password', $check, $password, $hash, $user_id);
2149 2149
 	}
2150 2150
 
2151 2151
 	// If the stored hash is longer than an MD5, presume the
2152 2152
 	// new style phpass portable hash.
2153
-	if ( empty($wp_hasher) ) {
2154
-		require_once( ABSPATH . WPINC . '/class-phpass.php');
2153
+	if (empty($wp_hasher)) {
2154
+		require_once(ABSPATH.WPINC.'/class-phpass.php');
2155 2155
 		// By default, use the portable hash from phpass
2156 2156
 		$wp_hasher = new PasswordHash(8, true);
2157 2157
 	}
@@ -2159,11 +2159,11 @@  discard block
 block discarded – undo
2159 2159
 	$check = $wp_hasher->CheckPassword($password, $hash);
2160 2160
 
2161 2161
 	/** This filter is documented in wp-includes/pluggable.php */
2162
-	return apply_filters( 'check_password', $check, $password, $hash, $user_id );
2162
+	return apply_filters('check_password', $check, $password, $hash, $user_id);
2163 2163
 }
2164 2164
 endif;
2165 2165
 
2166
-if ( !function_exists('wp_generate_password') ) :
2166
+if ( ! function_exists('wp_generate_password')) :
2167 2167
 /**
2168 2168
  * Generates a random password drawn from the defined set of characters.
2169 2169
  *
@@ -2176,15 +2176,15 @@  discard block
 block discarded – undo
2176 2176
  *                                  Used when generating secret keys and salts. Default false.
2177 2177
  * @return string The random password.
2178 2178
  */
2179
-function wp_generate_password( $length = 12, $special_chars = true, $extra_special_chars = false ) {
2179
+function wp_generate_password($length = 12, $special_chars = true, $extra_special_chars = false) {
2180 2180
 	$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
2181
-	if ( $special_chars )
2181
+	if ($special_chars)
2182 2182
 		$chars .= '!@#$%^&*()';
2183
-	if ( $extra_special_chars )
2183
+	if ($extra_special_chars)
2184 2184
 		$chars .= '-_ []{}<>~`+=,.;:/?|';
2185 2185
 
2186 2186
 	$password = '';
2187
-	for ( $i = 0; $i < $length; $i++ ) {
2187
+	for ($i = 0; $i < $length; $i++) {
2188 2188
 		$password .= substr($chars, wp_rand(0, strlen($chars) - 1), 1);
2189 2189
 	}
2190 2190
 
@@ -2195,11 +2195,11 @@  discard block
 block discarded – undo
2195 2195
 	 *
2196 2196
 	 * @param string $password The generated password.
2197 2197
 	 */
2198
-	return apply_filters( 'random_password', $password );
2198
+	return apply_filters('random_password', $password);
2199 2199
 }
2200 2200
 endif;
2201 2201
 
2202
-if ( !function_exists('wp_rand') ) :
2202
+if ( ! function_exists('wp_rand')) :
2203 2203
 /**
2204 2204
  * Generates a random number
2205 2205
  *
@@ -2214,7 +2214,7 @@  discard block
 block discarded – undo
2214 2214
  * @param int $max Upper limit for the generated number
2215 2215
  * @return int A random number between min and max
2216 2216
  */
2217
-function wp_rand( $min = 0, $max = 0 ) {
2217
+function wp_rand($min = 0, $max = 0) {
2218 2218
 	global $rnd_value;
2219 2219
 
2220 2220
 	// Some misconfigured 32bit environments (Entropy PHP, for example) truncate integers larger than PHP_INT_MAX to PHP_INT_MAX rather than overflowing them to floats.
@@ -2226,38 +2226,38 @@  discard block
 block discarded – undo
2226 2226
 
2227 2227
 	// Use PHP's CSPRNG, or a compatible method
2228 2228
 	static $use_random_int_functionality = true;
2229
-	if ( $use_random_int_functionality ) {
2229
+	if ($use_random_int_functionality) {
2230 2230
 		try {
2231
-			$_max = ( 0 != $max ) ? $max : $max_random_number;
2231
+			$_max = (0 != $max) ? $max : $max_random_number;
2232 2232
 			// wp_rand() can accept arguments in either order, PHP cannot.
2233
-			$_max = max( $min, $_max );
2234
-			$_min = min( $min, $_max );
2235
-			$val = random_int( $_min, $_max );
2236
-			if ( false !== $val ) {
2237
-				return absint( $val );
2233
+			$_max = max($min, $_max);
2234
+			$_min = min($min, $_max);
2235
+			$val = random_int($_min, $_max);
2236
+			if (false !== $val) {
2237
+				return absint($val);
2238 2238
 			} else {
2239 2239
 				$use_random_int_functionality = false;
2240 2240
 			}
2241
-		} catch ( Error $e ) {
2241
+		} catch (Error $e) {
2242 2242
 			$use_random_int_functionality = false;
2243
-		} catch ( Exception $e ) {
2243
+		} catch (Exception $e) {
2244 2244
 			$use_random_int_functionality = false;
2245 2245
 		}
2246 2246
 	}
2247 2247
 
2248 2248
 	// Reset $rnd_value after 14 uses
2249 2249
 	// 32(md5) + 40(sha1) + 40(sha1) / 8 = 14 random numbers from $rnd_value
2250
-	if ( strlen($rnd_value) < 8 ) {
2251
-		if ( defined( 'WP_SETUP_CONFIG' ) )
2250
+	if (strlen($rnd_value) < 8) {
2251
+		if (defined('WP_SETUP_CONFIG'))
2252 2252
 			static $seed = '';
2253 2253
 		else
2254 2254
 			$seed = get_transient('random_seed');
2255
-		$rnd_value = md5( uniqid(microtime() . mt_rand(), true ) . $seed );
2255
+		$rnd_value = md5(uniqid(microtime().mt_rand(), true).$seed);
2256 2256
 		$rnd_value .= sha1($rnd_value);
2257
-		$rnd_value .= sha1($rnd_value . $seed);
2258
-		$seed = md5($seed . $rnd_value);
2259
-		if ( ! defined( 'WP_SETUP_CONFIG' ) && ! defined( 'WP_INSTALLING' ) ) {
2260
-			set_transient( 'random_seed', $seed );
2257
+		$rnd_value .= sha1($rnd_value.$seed);
2258
+		$seed = md5($seed.$rnd_value);
2259
+		if ( ! defined('WP_SETUP_CONFIG') && ! defined('WP_INSTALLING')) {
2260
+			set_transient('random_seed', $seed);
2261 2261
 		}
2262 2262
 	}
2263 2263
 
@@ -2270,14 +2270,14 @@  discard block
 block discarded – undo
2270 2270
 	$value = abs(hexdec($value));
2271 2271
 
2272 2272
 	// Reduce the value to be within the min - max range
2273
-	if ( $max != 0 )
2274
-		$value = $min + ( $max - $min + 1 ) * $value / ( $max_random_number + 1 );
2273
+	if ($max != 0)
2274
+		$value = $min + ($max - $min + 1) * $value / ($max_random_number + 1);
2275 2275
 
2276 2276
 	return abs(intval($value));
2277 2277
 }
2278 2278
 endif;
2279 2279
 
2280
-if ( !function_exists('wp_set_password') ) :
2280
+if ( ! function_exists('wp_set_password')) :
2281 2281
 /**
2282 2282
  * Updates the user's password with a new encrypted one.
2283 2283
  *
@@ -2295,17 +2295,17 @@  discard block
 block discarded – undo
2295 2295
  * @param string $password The plaintext new user password
2296 2296
  * @param int    $user_id  User ID
2297 2297
  */
2298
-function wp_set_password( $password, $user_id ) {
2298
+function wp_set_password($password, $user_id) {
2299 2299
 	global $wpdb;
2300 2300
 
2301
-	$hash = wp_hash_password( $password );
2302
-	$wpdb->update($wpdb->users, array('user_pass' => $hash, 'user_activation_key' => ''), array('ID' => $user_id) );
2301
+	$hash = wp_hash_password($password);
2302
+	$wpdb->update($wpdb->users, array('user_pass' => $hash, 'user_activation_key' => ''), array('ID' => $user_id));
2303 2303
 
2304 2304
 	wp_cache_delete($user_id, 'users');
2305 2305
 }
2306 2306
 endif;
2307 2307
 
2308
-if ( !function_exists( 'get_avatar' ) ) :
2308
+if ( ! function_exists('get_avatar')) :
2309 2309
 /**
2310 2310
  * Retrieve the avatar `<img>` tag for a user, email address, MD5 hash, comment, or post.
2311 2311
  *
@@ -2340,15 +2340,15 @@  discard block
 block discarded – undo
2340 2340
  * }
2341 2341
  * @return false|string `<img>` tag for the user's avatar. False on failure.
2342 2342
  */
2343
-function get_avatar( $id_or_email, $size = 96, $default = '', $alt = '', $args = null ) {
2343
+function get_avatar($id_or_email, $size = 96, $default = '', $alt = '', $args = null) {
2344 2344
 	$defaults = array(
2345 2345
 		// get_avatar_data() args.
2346 2346
 		'size'          => 96,
2347 2347
 		'height'        => null,
2348 2348
 		'width'         => null,
2349
-		'default'       => get_option( 'avatar_default', 'mystery' ),
2349
+		'default'       => get_option('avatar_default', 'mystery'),
2350 2350
 		'force_default' => false,
2351
-		'rating'        => get_option( 'avatar_rating' ),
2351
+		'rating'        => get_option('avatar_rating'),
2352 2352
 		'scheme'        => null,
2353 2353
 		'alt'           => '',
2354 2354
 		'class'         => null,
@@ -2356,7 +2356,7 @@  discard block
 block discarded – undo
2356 2356
 		'extra_attr'    => '',
2357 2357
 	);
2358 2358
 
2359
-	if ( empty( $args ) ) {
2359
+	if (empty($args)) {
2360 2360
 		$args = array();
2361 2361
 	}
2362 2362
 
@@ -2364,17 +2364,17 @@  discard block
 block discarded – undo
2364 2364
 	$args['default'] = $default;
2365 2365
 	$args['alt']     = $alt;
2366 2366
 
2367
-	$args = wp_parse_args( $args, $defaults );
2367
+	$args = wp_parse_args($args, $defaults);
2368 2368
 
2369
-	if ( empty( $args['height'] ) ) {
2369
+	if (empty($args['height'])) {
2370 2370
 		$args['height'] = $args['size'];
2371 2371
 	}
2372
-	if ( empty( $args['width'] ) ) {
2372
+	if (empty($args['width'])) {
2373 2373
 		$args['width'] = $args['size'];
2374 2374
 	}
2375 2375
 
2376
-	if ( is_object( $id_or_email ) && isset( $id_or_email->comment_ID ) ) {
2377
-		$id_or_email = get_comment( $id_or_email );
2376
+	if (is_object($id_or_email) && isset($id_or_email->comment_ID)) {
2377
+		$id_or_email = get_comment($id_or_email);
2378 2378
 	}
2379 2379
 
2380 2380
 	/**
@@ -2390,36 +2390,36 @@  discard block
 block discarded – undo
2390 2390
 	 *                            user email, WP_User object, WP_Post object, or WP_Comment object.
2391 2391
 	 * @param array  $args        Arguments passed to get_avatar_url(), after processing.
2392 2392
 	 */
2393
-	$avatar = apply_filters( 'pre_get_avatar', null, $id_or_email, $args );
2393
+	$avatar = apply_filters('pre_get_avatar', null, $id_or_email, $args);
2394 2394
 
2395
-	if ( ! is_null( $avatar ) ) {
2395
+	if ( ! is_null($avatar)) {
2396 2396
 		/** This filter is documented in wp-includes/pluggable.php */
2397
-		return apply_filters( 'get_avatar', $avatar, $id_or_email, $args['size'], $args['default'], $args['alt'], $args );
2397
+		return apply_filters('get_avatar', $avatar, $id_or_email, $args['size'], $args['default'], $args['alt'], $args);
2398 2398
 	}
2399 2399
 
2400
-	if ( ! $args['force_display'] && ! get_option( 'show_avatars' ) ) {
2400
+	if ( ! $args['force_display'] && ! get_option('show_avatars')) {
2401 2401
 		return false;
2402 2402
 	}
2403 2403
 
2404
-	$url2x = get_avatar_url( $id_or_email, array_merge( $args, array( 'size' => $args['size'] * 2 ) ) );
2404
+	$url2x = get_avatar_url($id_or_email, array_merge($args, array('size' => $args['size'] * 2)));
2405 2405
 
2406
-	$args = get_avatar_data( $id_or_email, $args );
2406
+	$args = get_avatar_data($id_or_email, $args);
2407 2407
 
2408 2408
 	$url = $args['url'];
2409 2409
 
2410
-	if ( ! $url || is_wp_error( $url ) ) {
2410
+	if ( ! $url || is_wp_error($url)) {
2411 2411
 		return false;
2412 2412
 	}
2413 2413
 
2414
-	$class = array( 'avatar', 'avatar-' . (int) $args['size'], 'photo' );
2414
+	$class = array('avatar', 'avatar-'.(int) $args['size'], 'photo');
2415 2415
 
2416
-	if ( ! $args['found_avatar'] || $args['force_default'] ) {
2416
+	if ( ! $args['found_avatar'] || $args['force_default']) {
2417 2417
 		$class[] = 'avatar-default';
2418 2418
 	}
2419 2419
 
2420
-	if ( $args['class'] ) {
2421
-		if ( is_array( $args['class'] ) ) {
2422
-			$class = array_merge( $class, $args['class'] );
2420
+	if ($args['class']) {
2421
+		if (is_array($args['class'])) {
2422
+			$class = array_merge($class, $args['class']);
2423 2423
 		} else {
2424 2424
 			$class[] = $args['class'];
2425 2425
 		}
@@ -2427,10 +2427,10 @@  discard block
 block discarded – undo
2427 2427
 
2428 2428
 	$avatar = sprintf(
2429 2429
 		"<img alt='%s' src='%s' srcset='%s' class='%s' height='%d' width='%d' %s/>",
2430
-		esc_attr( $args['alt'] ),
2431
-		esc_url( $url ),
2432
-		esc_attr( "$url2x 2x" ),
2433
-		esc_attr( join( ' ', $class ) ),
2430
+		esc_attr($args['alt']),
2431
+		esc_url($url),
2432
+		esc_attr("$url2x 2x"),
2433
+		esc_attr(join(' ', $class)),
2434 2434
 		(int) $args['height'],
2435 2435
 		(int) $args['width'],
2436 2436
 		$args['extra_attr']
@@ -2452,11 +2452,11 @@  discard block
 block discarded – undo
2452 2452
 	 * @param string $alt         Alternative text to use in the avatar image tag. Default empty.
2453 2453
 	 * @param array  $args        Arguments passed to get_avatar_data(), after processing.
2454 2454
 	 */
2455
-	return apply_filters( 'get_avatar', $avatar, $id_or_email, $args['size'], $args['default'], $args['alt'], $args );
2455
+	return apply_filters('get_avatar', $avatar, $id_or_email, $args['size'], $args['default'], $args['alt'], $args);
2456 2456
 }
2457 2457
 endif;
2458 2458
 
2459
-if ( !function_exists( 'wp_text_diff' ) ) :
2459
+if ( ! function_exists('wp_text_diff')) :
2460 2460
 /**
2461 2461
  * Displays a human readable HTML representation of the difference between two strings.
2462 2462
  *
@@ -2484,12 +2484,12 @@  discard block
 block discarded – undo
2484 2484
  * @param string|array $args         Optional. Change 'title', 'title_left', and 'title_right' defaults.
2485 2485
  * @return string Empty string if strings are equivalent or HTML with differences.
2486 2486
  */
2487
-function wp_text_diff( $left_string, $right_string, $args = null ) {
2488
-	$defaults = array( 'title' => '', 'title_left' => '', 'title_right' => '' );
2489
-	$args = wp_parse_args( $args, $defaults );
2487
+function wp_text_diff($left_string, $right_string, $args = null) {
2488
+	$defaults = array('title' => '', 'title_left' => '', 'title_right' => '');
2489
+	$args = wp_parse_args($args, $defaults);
2490 2490
 
2491
-	if ( ! class_exists( 'WP_Text_Diff_Renderer_Table', false ) )
2492
-		require( ABSPATH . WPINC . '/wp-diff.php' );
2491
+	if ( ! class_exists('WP_Text_Diff_Renderer_Table', false))
2492
+		require(ABSPATH.WPINC.'/wp-diff.php');
2493 2493
 
2494 2494
 	$left_string  = normalize_whitespace($left_string);
2495 2495
 	$right_string = normalize_whitespace($right_string);
@@ -2497,31 +2497,31 @@  discard block
 block discarded – undo
2497 2497
 	$left_lines  = explode("\n", $left_string);
2498 2498
 	$right_lines = explode("\n", $right_string);
2499 2499
 	$text_diff = new Text_Diff($left_lines, $right_lines);
2500
-	$renderer  = new WP_Text_Diff_Renderer_Table( $args );
2500
+	$renderer  = new WP_Text_Diff_Renderer_Table($args);
2501 2501
 	$diff = $renderer->render($text_diff);
2502 2502
 
2503
-	if ( !$diff )
2503
+	if ( ! $diff)
2504 2504
 		return '';
2505 2505
 
2506
-	$r  = "<table class='diff'>\n";
2506
+	$r = "<table class='diff'>\n";
2507 2507
 
2508
-	if ( ! empty( $args[ 'show_split_view' ] ) ) {
2508
+	if ( ! empty($args['show_split_view'])) {
2509 2509
 		$r .= "<col class='content diffsplit left' /><col class='content diffsplit middle' /><col class='content diffsplit right' />";
2510 2510
 	} else {
2511 2511
 		$r .= "<col class='content' />";
2512 2512
 	}
2513 2513
 
2514
-	if ( $args['title'] || $args['title_left'] || $args['title_right'] )
2514
+	if ($args['title'] || $args['title_left'] || $args['title_right'])
2515 2515
 		$r .= "<thead>";
2516
-	if ( $args['title'] )
2516
+	if ($args['title'])
2517 2517
 		$r .= "<tr class='diff-title'><th colspan='4'>$args[title]</th></tr>\n";
2518
-	if ( $args['title_left'] || $args['title_right'] ) {
2518
+	if ($args['title_left'] || $args['title_right']) {
2519 2519
 		$r .= "<tr class='diff-sub-title'>\n";
2520 2520
 		$r .= "\t<td></td><th>$args[title_left]</th>\n";
2521 2521
 		$r .= "\t<td></td><th>$args[title_right]</th>\n";
2522 2522
 		$r .= "</tr>\n";
2523 2523
 	}
2524
-	if ( $args['title'] || $args['title_left'] || $args['title_right'] )
2524
+	if ($args['title'] || $args['title_left'] || $args['title_right'])
2525 2525
 		$r .= "</thead>\n";
2526 2526
 
2527 2527
 	$r .= "<tbody>\n$diff\n</tbody>\n";
Please login to merge, or discard this patch.
Braces   +101 added lines, -69 removed lines patch added patch discarded remove patch
@@ -98,8 +98,9 @@  discard block
 block discarded – undo
98 98
 function get_user_by( $field, $value ) {
99 99
 	$userdata = WP_User::get_data_by( $field, $value );
100 100
 
101
-	if ( !$userdata )
102
-		return false;
101
+	if ( !$userdata ) {
102
+			return false;
103
+	}
103 104
 
104 105
 	$user = new WP_User;
105 106
 	$user->init( $userdata );
@@ -123,8 +124,9 @@  discard block
 block discarded – undo
123 124
 
124 125
 	$clean = _get_non_cached_ids( $user_ids, 'users' );
125 126
 
126
-	if ( empty( $clean ) )
127
-		return;
127
+	if ( empty( $clean ) ) {
128
+			return;
129
+	}
128 130
 
129 131
 	$list = implode( ',', $clean );
130 132
 
@@ -315,8 +317,9 @@  discard block
 block discarded – undo
315 317
 
316 318
 	// From email and name
317 319
 	// If we don't have a name from the input headers
318
-	if ( !isset( $from_name ) )
319
-		$from_name = 'WordPress';
320
+	if ( !isset( $from_name ) ) {
321
+			$from_name = 'WordPress';
322
+	}
320 323
 
321 324
 	/* If we don't have an email from the input headers default to wordpress@$sitename
322 325
 	 * Some hosts will block outgoing mail from this address if it doesn't exist but
@@ -414,8 +417,9 @@  discard block
 block discarded – undo
414 417
 
415 418
 	// Set Content-Type and charset
416 419
 	// If we don't have a content-type from the input headers
417
-	if ( !isset( $content_type ) )
418
-		$content_type = 'text/plain';
420
+	if ( !isset( $content_type ) ) {
421
+			$content_type = 'text/plain';
422
+	}
419 423
 
420 424
 	/**
421 425
 	 * Filters the wp_mail() content type.
@@ -429,12 +433,14 @@  discard block
 block discarded – undo
429 433
 	$phpmailer->ContentType = $content_type;
430 434
 
431 435
 	// Set whether it's plaintext, depending on $content_type
432
-	if ( 'text/html' == $content_type )
433
-		$phpmailer->isHTML( true );
436
+	if ( 'text/html' == $content_type ) {
437
+			$phpmailer->isHTML( true );
438
+	}
434 439
 
435 440
 	// If we don't have a charset from the input headers
436
-	if ( !isset( $charset ) )
437
-		$charset = get_bloginfo( 'charset' );
441
+	if ( !isset( $charset ) ) {
442
+			$charset = get_bloginfo( 'charset' );
443
+	}
438 444
 
439 445
 	// Set the content-type and charset
440 446
 
@@ -453,8 +459,9 @@  discard block
 block discarded – undo
453 459
 			$phpmailer->addCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) );
454 460
 		}
455 461
 
456
-		if ( false !== stripos( $content_type, 'multipart' ) && ! empty($boundary) )
457
-			$phpmailer->addCustomHeader( sprintf( "Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary ) );
462
+		if ( false !== stripos( $content_type, 'multipart' ) && ! empty($boundary) ) {
463
+					$phpmailer->addCustomHeader( sprintf( "Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary ) );
464
+		}
458 465
 	}
459 466
 
460 467
 	if ( !empty( $attachments ) ) {
@@ -769,8 +776,9 @@  discard block
 block discarded – undo
769 776
 				}
770 777
 	    }
771 778
 
772
-		if ( empty($_COOKIE[$cookie_name]) )
773
-			return false;
779
+		if ( empty($_COOKIE[$cookie_name]) ) {
780
+					return false;
781
+		}
774 782
 		$cookie = $_COOKIE[$cookie_name];
775 783
 	}
776 784
 
@@ -914,9 +922,10 @@  discard block
 block discarded – undo
914 922
 	setcookie($auth_cookie_name, $auth_cookie, $expire, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
915 923
 	setcookie($auth_cookie_name, $auth_cookie, $expire, ADMIN_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
916 924
 	setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, COOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true);
917
-	if ( COOKIEPATH != SITECOOKIEPATH )
918
-		setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, SITECOOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true);
919
-}
925
+	if ( COOKIEPATH != SITECOOKIEPATH ) {
926
+			setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, SITECOOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true);
927
+	}
928
+	}
920 929
 endif;
921 930
 
922 931
 if ( !function_exists('wp_clear_auth_cookie') ) :
@@ -1070,8 +1079,9 @@  discard block
 block discarded – undo
1070 1079
  *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
1071 1080
  */
1072 1081
 function check_admin_referer( $action = -1, $query_arg = '_wpnonce' ) {
1073
-	if ( -1 == $action )
1074
-		_doing_it_wrong( __FUNCTION__, __( 'You should specify a nonce action to be verified by using the first parameter.' ), '3.2.0' );
1082
+	if ( -1 == $action ) {
1083
+			_doing_it_wrong( __FUNCTION__, __( 'You should specify a nonce action to be verified by using the first parameter.' ), '3.2.0' );
1084
+	}
1075 1085
 
1076 1086
 	$adminurl = strtolower(admin_url());
1077 1087
 	$referer = strtolower(wp_get_referer());
@@ -1119,12 +1129,13 @@  discard block
 block discarded – undo
1119 1129
 
1120 1130
 	$nonce = '';
1121 1131
 
1122
-	if ( $query_arg && isset( $_REQUEST[ $query_arg ] ) )
1123
-		$nonce = $_REQUEST[ $query_arg ];
1124
-	elseif ( isset( $_REQUEST['_ajax_nonce'] ) )
1125
-		$nonce = $_REQUEST['_ajax_nonce'];
1126
-	elseif ( isset( $_REQUEST['_wpnonce'] ) )
1127
-		$nonce = $_REQUEST['_wpnonce'];
1132
+	if ( $query_arg && isset( $_REQUEST[ $query_arg ] ) ) {
1133
+			$nonce = $_REQUEST[ $query_arg ];
1134
+	} elseif ( isset( $_REQUEST['_ajax_nonce'] ) ) {
1135
+			$nonce = $_REQUEST['_ajax_nonce'];
1136
+	} elseif ( isset( $_REQUEST['_wpnonce'] ) ) {
1137
+			$nonce = $_REQUEST['_wpnonce'];
1138
+	}
1128 1139
 
1129 1140
 	$result = wp_verify_nonce( $nonce, $action );
1130 1141
 
@@ -1199,13 +1210,16 @@  discard block
 block discarded – undo
1199 1210
 	 */
1200 1211
 	$status = apply_filters( 'wp_redirect_status', $status, $location );
1201 1212
 
1202
-	if ( ! $location )
1203
-		return false;
1213
+	if ( ! $location ) {
1214
+			return false;
1215
+	}
1204 1216
 
1205 1217
 	$location = wp_sanitize_redirect($location);
1206 1218
 
1207
-	if ( !$is_IIS && PHP_SAPI != 'cgi-fcgi' )
1208
-		status_header($status); // This causes problems on IIS and some FastCGI setups
1219
+	if ( !$is_IIS && PHP_SAPI != 'cgi-fcgi' ) {
1220
+			status_header($status);
1221
+	}
1222
+	// This causes problems on IIS and some FastCGI setups
1209 1223
 
1210 1224
 	header("Location: $location", true, $status);
1211 1225
 
@@ -1316,8 +1330,9 @@  discard block
 block discarded – undo
1316 1330
 function wp_validate_redirect($location, $default = '') {
1317 1331
 	$location = trim( $location, " \t\n\r\0\x08\x0B" );
1318 1332
 	// browsers will assume 'http' is your protocol, and will obey a redirect to a URL starting with '//'
1319
-	if ( substr($location, 0, 2) == '//' )
1320
-		$location = 'http:' . $location;
1333
+	if ( substr($location, 0, 2) == '//' ) {
1334
+			$location = 'http:' . $location;
1335
+	}
1321 1336
 
1322 1337
 	// In php 5 parse_url may fail if the URL query part contains http://, bug #38143
1323 1338
 	$test = ( $cut = strpos($location, '?') ) ? substr( $location, 0, $cut ) : $location;
@@ -1326,12 +1341,14 @@  discard block
 block discarded – undo
1326 1341
 	$lp = @parse_url($test);
1327 1342
 
1328 1343
 	// Give up if malformed URL
1329
-	if ( false === $lp )
1330
-		return $default;
1344
+	if ( false === $lp ) {
1345
+			return $default;
1346
+	}
1331 1347
 
1332 1348
 	// Allow only http and https schemes. No data:, etc.
1333
-	if ( isset($lp['scheme']) && !('http' == $lp['scheme'] || 'https' == $lp['scheme']) )
1334
-		return $default;
1349
+	if ( isset($lp['scheme']) && !('http' == $lp['scheme'] || 'https' == $lp['scheme']) ) {
1350
+			return $default;
1351
+	}
1335 1352
 
1336 1353
 	// Reject if certain components are set but host is not. This catches urls like https:host.com for which parse_url does not set the host field.
1337 1354
 	if ( ! isset( $lp['host'] ) && ( isset( $lp['scheme'] ) || isset( $lp['user'] ) || isset( $lp['pass'] ) || isset( $lp['port'] ) ) ) {
@@ -1357,8 +1374,9 @@  discard block
 block discarded – undo
1357 1374
 	 */
1358 1375
 	$allowed_hosts = (array) apply_filters( 'allowed_redirect_hosts', array($wpp['host']), isset($lp['host']) ? $lp['host'] : '' );
1359 1376
 
1360
-	if ( isset($lp['host']) && ( !in_array($lp['host'], $allowed_hosts) && $lp['host'] != strtolower($wpp['host'])) )
1361
-		$location = $default;
1377
+	if ( isset($lp['host']) && ( !in_array($lp['host'], $allowed_hosts) && $lp['host'] != strtolower($wpp['host'])) ) {
1378
+			$location = $default;
1379
+	}
1362 1380
 
1363 1381
 	return $location;
1364 1382
 }
@@ -1380,8 +1398,9 @@  discard block
 block discarded – undo
1380 1398
 	}
1381 1399
 
1382 1400
 	$comment = get_comment( $comment_id );
1383
-	if ( empty( $comment ) || empty( $comment->comment_post_ID ) )
1384
-		return false;
1401
+	if ( empty( $comment ) || empty( $comment->comment_post_ID ) ) {
1402
+			return false;
1403
+	}
1385 1404
 
1386 1405
 	$post    = get_post( $comment->comment_post_ID );
1387 1406
 	$author  = get_userdata( $post->post_author );
@@ -1510,19 +1529,22 @@  discard block
 block discarded – undo
1510 1529
 
1511 1530
 	if ( '' == $comment->comment_author ) {
1512 1531
 		$from = "From: \"$blogname\" <$wp_email>";
1513
-		if ( '' != $comment->comment_author_email )
1514
-			$reply_to = "Reply-To: $comment->comment_author_email";
1532
+		if ( '' != $comment->comment_author_email ) {
1533
+					$reply_to = "Reply-To: $comment->comment_author_email";
1534
+		}
1515 1535
 	} else {
1516 1536
 		$from = "From: \"$comment->comment_author\" <$wp_email>";
1517
-		if ( '' != $comment->comment_author_email )
1518
-			$reply_to = "Reply-To: \"$comment->comment_author_email\" <$comment->comment_author_email>";
1537
+		if ( '' != $comment->comment_author_email ) {
1538
+					$reply_to = "Reply-To: \"$comment->comment_author_email\" <$comment->comment_author_email>";
1539
+		}
1519 1540
 	}
1520 1541
 
1521 1542
 	$message_headers = "$from\n"
1522 1543
 		. "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
1523 1544
 
1524
-	if ( isset($reply_to) )
1525
-		$message_headers .= $reply_to . "\n";
1545
+	if ( isset($reply_to) ) {
1546
+			$message_headers .= $reply_to . "\n";
1547
+	}
1526 1548
 
1527 1549
 	/**
1528 1550
 	 * Filters the comment notification email text.
@@ -1605,8 +1627,9 @@  discard block
 block discarded – undo
1605 1627
 	// Send to the administration and to the post author if the author can modify the comment.
1606 1628
 	$emails = array( get_option( 'admin_email' ) );
1607 1629
 	if ( $user && user_can( $user->ID, 'edit_comment', $comment_id ) && ! empty( $user->user_email ) ) {
1608
-		if ( 0 !== strcasecmp( $user->user_email, get_option( 'admin_email' ) ) )
1609
-			$emails[] = $user->user_email;
1630
+		if ( 0 !== strcasecmp( $user->user_email, get_option( 'admin_email' ) ) ) {
1631
+					$emails[] = $user->user_email;
1632
+		}
1610 1633
 	}
1611 1634
 
1612 1635
 	$switched_locale = switch_to_locale( get_locale() );
@@ -2178,10 +2201,12 @@  discard block
 block discarded – undo
2178 2201
  */
2179 2202
 function wp_generate_password( $length = 12, $special_chars = true, $extra_special_chars = false ) {
2180 2203
 	$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
2181
-	if ( $special_chars )
2182
-		$chars .= '!@#$%^&*()';
2183
-	if ( $extra_special_chars )
2184
-		$chars .= '-_ []{}<>~`+=,.;:/?|';
2204
+	if ( $special_chars ) {
2205
+			$chars .= '!@#$%^&*()';
2206
+	}
2207
+	if ( $extra_special_chars ) {
2208
+			$chars .= '-_ []{}<>~`+=,.;:/?|';
2209
+	}
2185 2210
 
2186 2211
 	$password = '';
2187 2212
 	for ( $i = 0; $i < $length; $i++ ) {
@@ -2248,10 +2273,11 @@  discard block
 block discarded – undo
2248 2273
 	// Reset $rnd_value after 14 uses
2249 2274
 	// 32(md5) + 40(sha1) + 40(sha1) / 8 = 14 random numbers from $rnd_value
2250 2275
 	if ( strlen($rnd_value) < 8 ) {
2251
-		if ( defined( 'WP_SETUP_CONFIG' ) )
2252
-			static $seed = '';
2253
-		else
2254
-			$seed = get_transient('random_seed');
2276
+		if ( defined( 'WP_SETUP_CONFIG' ) ) {
2277
+					static $seed = '';
2278
+		} else {
2279
+					$seed = get_transient('random_seed');
2280
+		}
2255 2281
 		$rnd_value = md5( uniqid(microtime() . mt_rand(), true ) . $seed );
2256 2282
 		$rnd_value .= sha1($rnd_value);
2257 2283
 		$rnd_value .= sha1($rnd_value . $seed);
@@ -2270,8 +2296,9 @@  discard block
 block discarded – undo
2270 2296
 	$value = abs(hexdec($value));
2271 2297
 
2272 2298
 	// Reduce the value to be within the min - max range
2273
-	if ( $max != 0 )
2274
-		$value = $min + ( $max - $min + 1 ) * $value / ( $max_random_number + 1 );
2299
+	if ( $max != 0 ) {
2300
+			$value = $min + ( $max - $min + 1 ) * $value / ( $max_random_number + 1 );
2301
+	}
2275 2302
 
2276 2303
 	return abs(intval($value));
2277 2304
 }
@@ -2488,8 +2515,9 @@  discard block
 block discarded – undo
2488 2515
 	$defaults = array( 'title' => '', 'title_left' => '', 'title_right' => '' );
2489 2516
 	$args = wp_parse_args( $args, $defaults );
2490 2517
 
2491
-	if ( ! class_exists( 'WP_Text_Diff_Renderer_Table', false ) )
2492
-		require( ABSPATH . WPINC . '/wp-diff.php' );
2518
+	if ( ! class_exists( 'WP_Text_Diff_Renderer_Table', false ) ) {
2519
+			require( ABSPATH . WPINC . '/wp-diff.php' );
2520
+	}
2493 2521
 
2494 2522
 	$left_string  = normalize_whitespace($left_string);
2495 2523
 	$right_string = normalize_whitespace($right_string);
@@ -2500,8 +2528,9 @@  discard block
 block discarded – undo
2500 2528
 	$renderer  = new WP_Text_Diff_Renderer_Table( $args );
2501 2529
 	$diff = $renderer->render($text_diff);
2502 2530
 
2503
-	if ( !$diff )
2504
-		return '';
2531
+	if ( !$diff ) {
2532
+			return '';
2533
+	}
2505 2534
 
2506 2535
 	$r  = "<table class='diff'>\n";
2507 2536
 
@@ -2511,18 +2540,21 @@  discard block
 block discarded – undo
2511 2540
 		$r .= "<col class='content' />";
2512 2541
 	}
2513 2542
 
2514
-	if ( $args['title'] || $args['title_left'] || $args['title_right'] )
2515
-		$r .= "<thead>";
2516
-	if ( $args['title'] )
2517
-		$r .= "<tr class='diff-title'><th colspan='4'>$args[title]</th></tr>\n";
2543
+	if ( $args['title'] || $args['title_left'] || $args['title_right'] ) {
2544
+			$r .= "<thead>";
2545
+	}
2546
+	if ( $args['title'] ) {
2547
+			$r .= "<tr class='diff-title'><th colspan='4'>$args[title]</th></tr>\n";
2548
+	}
2518 2549
 	if ( $args['title_left'] || $args['title_right'] ) {
2519 2550
 		$r .= "<tr class='diff-sub-title'>\n";
2520 2551
 		$r .= "\t<td></td><th>$args[title_left]</th>\n";
2521 2552
 		$r .= "\t<td></td><th>$args[title_right]</th>\n";
2522 2553
 		$r .= "</tr>\n";
2523 2554
 	}
2524
-	if ( $args['title'] || $args['title_left'] || $args['title_right'] )
2525
-		$r .= "</thead>\n";
2555
+	if ( $args['title'] || $args['title_left'] || $args['title_right'] ) {
2556
+			$r .= "</thead>\n";
2557
+	}
2526 2558
 
2527 2559
 	$r .= "<tbody>\n$diff\n</tbody>\n";
2528 2560
 	$r .= "</table>";
Please login to merge, or discard this patch.
src/wp-includes/pomo/po.php 3 patches
Doc Comments   +7 added lines, -2 removed lines patch added patch discarded remove patch
@@ -87,6 +87,7 @@  discard block
 block discarded – undo
87 87
 	 * Text to include as a comment before the start of the PO contents
88 88
 	 *
89 89
 	 * Doesn't need to include # in the beginning of lines, these are added automatically
90
+	 * @param string $text
90 91
 	 */
91 92
 	function set_comment_before_headers( $text ) {
92 93
 		$this->comments_before_headers = $text;
@@ -196,6 +197,7 @@  discard block
 block discarded – undo
196 197
 	 *
197 198
 	 * @static
198 199
 	 * @param Translation_Entry &$entry the entry to convert to po string
200
+	 * @param Translation_Entry $entry
199 201
 	 * @return false|string PO-style formatted string for the entry or
200 202
 	 * 	false if the entry is empty
201 203
 	 */
@@ -223,6 +225,9 @@  discard block
 block discarded – undo
223 225
 		return implode("\n", $po);
224 226
 	}
225 227
 
228
+	/**
229
+	 * @return string
230
+	 */
226 231
 	public static function match_begin_and_end_newlines( $translation, $original ) {
227 232
 		if ( '' === $translation ) {
228 233
 			return $translation;
@@ -395,7 +400,7 @@  discard block
 block discarded – undo
395 400
 	 *
396 401
 	 * @param     resource $f
397 402
 	 * @param     string   $action
398
-	 * @return boolean
403
+	 * @return boolean|string
399 404
 	 */
400 405
 	function read_line($f, $action = 'read') {
401 406
 		static $last_line = '';
@@ -435,7 +440,7 @@  discard block
 block discarded – undo
435 440
 
436 441
 	/**
437 442
 	 * @param string $s
438
-	 * @return sring
443
+	 * @return string
439 444
 	 */
440 445
 	public static function trim_quotes($s) {
441 446
 		if ( substr($s, 0, 1) == '"') $s = substr($s, 1);
Please login to merge, or discard this patch.
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -7,9 +7,9 @@  discard block
 block discarded – undo
7 7
  * @subpackage po
8 8
  */
9 9
 
10
-require_once dirname(__FILE__) . '/translations.php';
10
+require_once dirname(__FILE__).'/translations.php';
11 11
 
12
-if ( ! defined( 'PO_MAX_LINE_LEN' ) ) {
12
+if ( ! defined('PO_MAX_LINE_LEN')) {
13 13
 	define('PO_MAX_LINE_LEN', 79);
14 14
 }
15 15
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 /**
19 19
  * Routines for working with PO files
20 20
  */
21
-if ( ! class_exists( 'PO', false ) ):
21
+if ( ! class_exists('PO', false)):
22 22
 class PO extends Gettext_Translations {
23 23
 
24 24
 	var $comments_before_headers = '';
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 	 */
31 31
 	function export_headers() {
32 32
 		$header_string = '';
33
-		foreach($this->headers as $header => $value) {
34
-			$header_string.= "$header: $value\n";
33
+		foreach ($this->headers as $header => $value) {
34
+			$header_string .= "$header: $value\n";
35 35
 		}
36 36
 		$poified = PO::poify($header_string);
37 37
 		if ($this->comments_before_headers)
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * Doesn't need to include # in the beginning of lines, these are added automatically
90 90
 	 */
91
-	function set_comment_before_headers( $text ) {
91
+	function set_comment_before_headers($text) {
92 92
 		$this->comments_before_headers = $text;
93 93
 	}
94 94
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 		$po = $quote.implode("${slash}n$quote$newline$quote", explode($newline, $string)).$quote;
116 116
 		// add empty string on first line for readbility
117 117
 		if (false !== strpos($string, $newline) &&
118
-				(substr_count($string, $newline) > 1 || !($newline === substr($string, -strlen($newline))))) {
118
+				(substr_count($string, $newline) > 1 || ! ($newline === substr($string, -strlen($newline))))) {
119 119
 			$po = "$quote$quote$newline$po";
120 120
 		}
121 121
 		// remove empty strings
@@ -136,24 +136,24 @@  discard block
 block discarded – undo
136 136
 		$lines = array_map(array('PO', 'trim_quotes'), $lines);
137 137
 		$unpoified = '';
138 138
 		$previous_is_backslash = false;
139
-		foreach($lines as $line) {
139
+		foreach ($lines as $line) {
140 140
 			preg_match_all('/./u', $line, $chars);
141 141
 			$chars = $chars[0];
142
-			foreach($chars as $char) {
143
-				if (!$previous_is_backslash) {
142
+			foreach ($chars as $char) {
143
+				if ( ! $previous_is_backslash) {
144 144
 					if ('\\' == $char)
145 145
 						$previous_is_backslash = true;
146 146
 					else
147 147
 						$unpoified .= $char;
148 148
 				} else {
149 149
 					$previous_is_backslash = false;
150
-					$unpoified .= isset($escapes[$char])? $escapes[$char] : $char;
150
+					$unpoified .= isset($escapes[$char]) ? $escapes[$char] : $char;
151 151
 				}
152 152
 			}
153 153
 		}
154 154
 
155 155
 		// Standardise the line endings on imported content, technically PO files shouldn't contain \r
156
-		$unpoified = str_replace( array( "\r\n", "\r" ), "\n", $unpoified );
156
+		$unpoified = str_replace(array("\r\n", "\r"), "\n", $unpoified);
157 157
 
158 158
 		return $unpoified;
159 159
 	}
@@ -177,10 +177,10 @@  discard block
 block discarded – undo
177 177
 			$append = "\n";
178 178
 		}
179 179
 		foreach ($lines as &$line) {
180
-			$line = $with . $line;
180
+			$line = $with.$line;
181 181
 		}
182 182
 		unset($line);
183
-		return implode("\n", $lines) . $append;
183
+		return implode("\n", $lines).$append;
184 184
 	}
185 185
 
186 186
 	/**
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	 * @param string $char character to denote a special PO comment,
193 193
 	 * 	like :, default is a space
194 194
 	 */
195
-	public static function comment_block($text, $char=' ') {
195
+	public static function comment_block($text, $char = ' ') {
196 196
 		$text = wordwrap($text, PO_MAX_LINE_LEN - 3);
197 197
 		return PO::prepend_each_line($text, "#$char ");
198 198
 	}
@@ -206,53 +206,53 @@  discard block
 block discarded – undo
206 206
 	 * 	false if the entry is empty
207 207
 	 */
208 208
 	public static function export_entry(&$entry) {
209
-		if ( null === $entry->singular || '' === $entry->singular ) return false;
209
+		if (null === $entry->singular || '' === $entry->singular) return false;
210 210
 		$po = array();
211
-		if (!empty($entry->translator_comments)) $po[] = PO::comment_block($entry->translator_comments);
212
-		if (!empty($entry->extracted_comments)) $po[] = PO::comment_block($entry->extracted_comments, '.');
213
-		if (!empty($entry->references)) $po[] = PO::comment_block(implode(' ', $entry->references), ':');
214
-		if (!empty($entry->flags)) $po[] = PO::comment_block(implode(", ", $entry->flags), ',');
211
+		if ( ! empty($entry->translator_comments)) $po[] = PO::comment_block($entry->translator_comments);
212
+		if ( ! empty($entry->extracted_comments)) $po[] = PO::comment_block($entry->extracted_comments, '.');
213
+		if ( ! empty($entry->references)) $po[] = PO::comment_block(implode(' ', $entry->references), ':');
214
+		if ( ! empty($entry->flags)) $po[] = PO::comment_block(implode(", ", $entry->flags), ',');
215 215
 		if ($entry->context) $po[] = 'msgctxt '.PO::poify($entry->context);
216 216
 		$po[] = 'msgid '.PO::poify($entry->singular);
217
-		if (!$entry->is_plural) {
218
-			$translation = empty($entry->translations)? '' : $entry->translations[0];
219
-			$translation = PO::match_begin_and_end_newlines( $translation, $entry->singular );
217
+		if ( ! $entry->is_plural) {
218
+			$translation = empty($entry->translations) ? '' : $entry->translations[0];
219
+			$translation = PO::match_begin_and_end_newlines($translation, $entry->singular);
220 220
 			$po[] = 'msgstr '.PO::poify($translation);
221 221
 		} else {
222 222
 			$po[] = 'msgid_plural '.PO::poify($entry->plural);
223
-			$translations = empty($entry->translations)? array('', '') : $entry->translations;
224
-			foreach($translations as $i => $translation) {
225
-				$translation = PO::match_begin_and_end_newlines( $translation, $entry->plural );
223
+			$translations = empty($entry->translations) ? array('', '') : $entry->translations;
224
+			foreach ($translations as $i => $translation) {
225
+				$translation = PO::match_begin_and_end_newlines($translation, $entry->plural);
226 226
 				$po[] = "msgstr[$i] ".PO::poify($translation);
227 227
 			}
228 228
 		}
229 229
 		return implode("\n", $po);
230 230
 	}
231 231
 
232
-	public static function match_begin_and_end_newlines( $translation, $original ) {
233
-		if ( '' === $translation ) {
232
+	public static function match_begin_and_end_newlines($translation, $original) {
233
+		if ('' === $translation) {
234 234
 			return $translation;
235 235
 		}
236 236
 
237
-		$original_begin = "\n" === substr( $original, 0, 1 );
238
-		$original_end = "\n" === substr( $original, -1 );
239
-		$translation_begin = "\n" === substr( $translation, 0, 1 );
240
-		$translation_end = "\n" === substr( $translation, -1 );
237
+		$original_begin = "\n" === substr($original, 0, 1);
238
+		$original_end = "\n" === substr($original, -1);
239
+		$translation_begin = "\n" === substr($translation, 0, 1);
240
+		$translation_end = "\n" === substr($translation, -1);
241 241
 
242
-		if ( $original_begin ) {
243
-			if ( ! $translation_begin ) {
244
-				$translation = "\n" . $translation;
242
+		if ($original_begin) {
243
+			if ( ! $translation_begin) {
244
+				$translation = "\n".$translation;
245 245
 			}
246
-		} elseif ( $translation_begin ) {
247
-			$translation = ltrim( $translation, "\n" );
246
+		} elseif ($translation_begin) {
247
+			$translation = ltrim($translation, "\n");
248 248
 		}
249 249
 
250
-		if ( $original_end ) {
251
-			if ( ! $translation_end ) {
250
+		if ($original_end) {
251
+			if ( ! $translation_end) {
252 252
 				$translation .= "\n";
253 253
 			}
254
-		} elseif ( $translation_end ) {
255
-			$translation = rtrim( $translation, "\n" );
254
+		} elseif ($translation_end) {
255
+			$translation = rtrim($translation, "\n");
256 256
 		}
257 257
 
258 258
 		return $translation;
@@ -264,11 +264,11 @@  discard block
 block discarded – undo
264 264
 	 */
265 265
 	function import_from_file($filename) {
266 266
 		$f = fopen($filename, 'r');
267
-		if (!$f) return false;
267
+		if ( ! $f) return false;
268 268
 		$lineno = 0;
269 269
 		while (true) {
270 270
 			$res = $this->read_entry($f, $lineno);
271
-			if (!$res) break;
271
+			if ( ! $res) break;
272 272
 			if ($res['entry']->singular == '') {
273 273
 				$this->set_headers($this->make_headers($res['entry']->translations[0]));
274 274
 			} else {
@@ -276,10 +276,10 @@  discard block
 block discarded – undo
276 276
 			}
277 277
 		}
278 278
 		PO::read_line($f, 'clear');
279
-		if ( false === $res ) {
279
+		if (false === $res) {
280 280
 			return false;
281 281
 		}
282
-		if ( ! $this->headers && ! $this->entries ) {
282
+		if ( ! $this->headers && ! $this->entries) {
283 283
 			return false;
284 284
 		}
285 285
 		return true;
@@ -308,11 +308,11 @@  discard block
 block discarded – undo
308 308
 		while (true) {
309 309
 			$lineno++;
310 310
 			$line = PO::read_line($f);
311
-			if (!$line)  {
311
+			if ( ! $line) {
312 312
 				if (feof($f)) {
313 313
 					if (self::is_final($context))
314 314
 						break;
315
-					elseif (!$context) // we haven't read a line and eof came
315
+					elseif ( ! $context) // we haven't read a line and eof came
316 316
 						return null;
317 317
 					else
318 318
 						return false;
@@ -399,13 +399,13 @@  discard block
 block discarded – undo
399 399
 		}
400 400
 
401 401
 		$have_translations = false;
402
-		foreach ( $entry->translations as $t ) {
403
-			if ( $t || ('0' === $t) ) {
402
+		foreach ($entry->translations as $t) {
403
+			if ($t || ('0' === $t)) {
404 404
 				$have_translations = true;
405 405
 				break;
406 406
 			}
407 407
 		}
408
-		if ( false === $have_translations ) {
408
+		if (false === $have_translations) {
409 409
 			$entry->translations = array();
410 410
 		}
411 411
 
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 			$use_last_line = true;
432 432
 			return true;
433 433
 		}
434
-		$line = $use_last_line? $last_line : fgets($f);
435
-		$line = ( "\r\n" == substr( $line, -2 ) ) ? rtrim( $line, "\r\n" ) . "\n" : $line;
434
+		$line = $use_last_line ? $last_line : fgets($f);
435
+		$line = ("\r\n" == substr($line, -2)) ? rtrim($line, "\r\n")."\n" : $line;
436 436
 		$last_line = $line;
437 437
 		$use_last_line = false;
438 438
 		return $line;
@@ -448,11 +448,11 @@  discard block
 block discarded – undo
448 448
 		if ('#:' == $first_two) {
449 449
 			$entry->references = array_merge($entry->references, preg_split('/\s+/', $comment));
450 450
 		} elseif ('#.' == $first_two) {
451
-			$entry->extracted_comments = trim($entry->extracted_comments . "\n" . $comment);
451
+			$entry->extracted_comments = trim($entry->extracted_comments."\n".$comment);
452 452
 		} elseif ('#,' == $first_two) {
453 453
 			$entry->flags = array_merge($entry->flags, preg_split('/,\s*/', $comment));
454 454
 		} else {
455
-			$entry->translator_comments = trim($entry->translator_comments . "\n" . $comment);
455
+			$entry->translator_comments = trim($entry->translator_comments."\n".$comment);
456 456
 		}
457 457
 	}
458 458
 
@@ -461,8 +461,8 @@  discard block
 block discarded – undo
461 461
 	 * @return sring
462 462
 	 */
463 463
 	public static function trim_quotes($s) {
464
-		if ( substr($s, 0, 1) == '"') $s = substr($s, 1);
465
-		if ( substr($s, -1, 1) == '"') $s = substr($s, 0, -1);
464
+		if (substr($s, 0, 1) == '"') $s = substr($s, 1);
465
+		if (substr($s, -1, 1) == '"') $s = substr($s, 0, -1);
466 466
 		return $s;
467 467
 	}
468 468
 }
Please login to merge, or discard this patch.
Braces   +56 added lines, -26 removed lines patch added patch discarded remove patch
@@ -34,10 +34,11 @@  discard block
 block discarded – undo
34 34
 			$header_string.= "$header: $value\n";
35 35
 		}
36 36
 		$poified = PO::poify($header_string);
37
-		if ($this->comments_before_headers)
38
-			$before_headers = $this->prepend_each_line(rtrim($this->comments_before_headers)."\n", '# ');
39
-		else
40
-			$before_headers = '';
37
+		if ($this->comments_before_headers) {
38
+					$before_headers = $this->prepend_each_line(rtrim($this->comments_before_headers)."\n", '# ');
39
+		} else {
40
+					$before_headers = '';
41
+		}
41 42
 		return rtrim("{$before_headers}msgid \"\"\nmsgstr $poified");
42 43
 	}
43 44
 
@@ -76,10 +77,14 @@  discard block
 block discarded – undo
76 77
 	 */
77 78
 	function export_to_file($filename, $include_headers = true) {
78 79
 		$fh = fopen($filename, 'w');
79
-		if (false === $fh) return false;
80
+		if (false === $fh) {
81
+			return false;
82
+		}
80 83
 		$export = $this->export($include_headers);
81 84
 		$res = fwrite($fh, $export);
82
-		if (false === $res) return false;
85
+		if (false === $res) {
86
+			return false;
87
+		}
83 88
 		return fclose($fh);
84 89
 	}
85 90
 
@@ -141,10 +146,11 @@  discard block
 block discarded – undo
141 146
 			$chars = $chars[0];
142 147
 			foreach($chars as $char) {
143 148
 				if (!$previous_is_backslash) {
144
-					if ('\\' == $char)
145
-						$previous_is_backslash = true;
146
-					else
147
-						$unpoified .= $char;
149
+					if ('\\' == $char) {
150
+											$previous_is_backslash = true;
151
+					} else {
152
+											$unpoified .= $char;
153
+					}
148 154
 				} else {
149 155
 					$previous_is_backslash = false;
150 156
 					$unpoified .= isset($escapes[$char])? $escapes[$char] : $char;
@@ -206,13 +212,25 @@  discard block
 block discarded – undo
206 212
 	 * 	false if the entry is empty
207 213
 	 */
208 214
 	public static function export_entry(&$entry) {
209
-		if ( null === $entry->singular || '' === $entry->singular ) return false;
215
+		if ( null === $entry->singular || '' === $entry->singular ) {
216
+			return false;
217
+		}
210 218
 		$po = array();
211
-		if (!empty($entry->translator_comments)) $po[] = PO::comment_block($entry->translator_comments);
212
-		if (!empty($entry->extracted_comments)) $po[] = PO::comment_block($entry->extracted_comments, '.');
213
-		if (!empty($entry->references)) $po[] = PO::comment_block(implode(' ', $entry->references), ':');
214
-		if (!empty($entry->flags)) $po[] = PO::comment_block(implode(", ", $entry->flags), ',');
215
-		if ($entry->context) $po[] = 'msgctxt '.PO::poify($entry->context);
219
+		if (!empty($entry->translator_comments)) {
220
+			$po[] = PO::comment_block($entry->translator_comments);
221
+		}
222
+		if (!empty($entry->extracted_comments)) {
223
+			$po[] = PO::comment_block($entry->extracted_comments, '.');
224
+		}
225
+		if (!empty($entry->references)) {
226
+			$po[] = PO::comment_block(implode(' ', $entry->references), ':');
227
+		}
228
+		if (!empty($entry->flags)) {
229
+			$po[] = PO::comment_block(implode(", ", $entry->flags), ',');
230
+		}
231
+		if ($entry->context) {
232
+			$po[] = 'msgctxt '.PO::poify($entry->context);
233
+		}
216 234
 		$po[] = 'msgid '.PO::poify($entry->singular);
217 235
 		if (!$entry->is_plural) {
218 236
 			$translation = empty($entry->translations)? '' : $entry->translations[0];
@@ -264,11 +282,15 @@  discard block
 block discarded – undo
264 282
 	 */
265 283
 	function import_from_file($filename) {
266 284
 		$f = fopen($filename, 'r');
267
-		if (!$f) return false;
285
+		if (!$f) {
286
+			return false;
287
+		}
268 288
 		$lineno = 0;
269 289
 		while (true) {
270 290
 			$res = $this->read_entry($f, $lineno);
271
-			if (!$res) break;
291
+			if (!$res) {
292
+				break;
293
+			}
272 294
 			if ($res['entry']->singular == '') {
273 295
 				$this->set_headers($this->make_headers($res['entry']->translations[0]));
274 296
 			} else {
@@ -310,17 +332,21 @@  discard block
 block discarded – undo
310 332
 			$line = PO::read_line($f);
311 333
 			if (!$line)  {
312 334
 				if (feof($f)) {
313
-					if (self::is_final($context))
314
-						break;
315
-					elseif (!$context) // we haven't read a line and eof came
335
+					if (self::is_final($context)) {
336
+											break;
337
+					} elseif (!$context) {
338
+						// we haven't read a line and eof came
316 339
 						return null;
317
-					else
318
-						return false;
340
+					} else {
341
+											return false;
342
+					}
319 343
 				} else {
320 344
 					return false;
321 345
 				}
322 346
 			}
323
-			if ($line == "\n") continue;
347
+			if ($line == "\n") {
348
+				continue;
349
+			}
324 350
 			$line = trim($line);
325 351
 			if (preg_match('/^#/', $line, $m)) {
326 352
 				// the comment is the start of a new entry
@@ -461,8 +487,12 @@  discard block
 block discarded – undo
461 487
 	 * @return sring
462 488
 	 */
463 489
 	public static function trim_quotes($s) {
464
-		if ( substr($s, 0, 1) == '"') $s = substr($s, 1);
465
-		if ( substr($s, -1, 1) == '"') $s = substr($s, 0, -1);
490
+		if ( substr($s, 0, 1) == '"') {
491
+			$s = substr($s, 1);
492
+		}
493
+		if ( substr($s, -1, 1) == '"') {
494
+			$s = substr($s, 0, -1);
495
+		}
466 496
 		return $s;
467 497
 	}
468 498
 }
Please login to merge, or discard this patch.
src/wp-includes/post-thumbnail-template.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@
 block discarded – undo
53 53
  *
54 54
  * @see get_the_post_thumbnail()
55 55
  *
56
- * @param string|array $size Optional. Image size to use. Accepts any valid image size, or
56
+ * @param string $size Optional. Image size to use. Accepts any valid image size, or
57 57
  *                           an array of width and height values in pixels (in that order).
58 58
  *                           Default 'post-thumbnail'.
59 59
  * @param string|array $attr Optional. Query string or array of attributes. Default empty.
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -18,8 +18,8 @@  discard block
 block discarded – undo
18 18
  * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global `$post`.
19 19
  * @return bool Whether the post has an image attached.
20 20
  */
21
-function has_post_thumbnail( $post = null ) {
22
-	return (bool) get_post_thumbnail_id( $post );
21
+function has_post_thumbnail($post = null) {
22
+	return (bool) get_post_thumbnail_id($post);
23 23
 }
24 24
 
25 25
 /**
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
  * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global `$post`.
32 32
  * @return string|int Post thumbnail ID or empty string.
33 33
  */
34
-function get_post_thumbnail_id( $post = null ) {
35
-	$post = get_post( $post );
36
-	if ( ! $post ) {
34
+function get_post_thumbnail_id($post = null) {
35
+	$post = get_post($post);
36
+	if ( ! $post) {
37 37
 		return '';
38 38
 	}
39
-	return get_post_meta( $post->ID, '_thumbnail_id', true );
39
+	return get_post_meta($post->ID, '_thumbnail_id', true);
40 40
 }
41 41
 
42 42
 /**
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
  *                           Default 'post-thumbnail'.
59 59
  * @param string|array $attr Optional. Query string or array of attributes. Default empty.
60 60
  */
61
-function the_post_thumbnail( $size = 'post-thumbnail', $attr = '' ) {
62
-	echo get_the_post_thumbnail( null, $size, $attr );
61
+function the_post_thumbnail($size = 'post-thumbnail', $attr = '') {
62
+	echo get_the_post_thumbnail(null, $size, $attr);
63 63
 }
64 64
 
65 65
 /**
@@ -71,21 +71,21 @@  discard block
 block discarded – undo
71 71
  *
72 72
  * @param WP_Query $wp_query Optional. A WP_Query instance. Defaults to the $wp_query global.
73 73
  */
74
-function update_post_thumbnail_cache( $wp_query = null ) {
75
-	if ( ! $wp_query )
74
+function update_post_thumbnail_cache($wp_query = null) {
75
+	if ( ! $wp_query)
76 76
 		$wp_query = $GLOBALS['wp_query'];
77 77
 
78
-	if ( $wp_query->thumbnails_cached )
78
+	if ($wp_query->thumbnails_cached)
79 79
 		return;
80 80
 
81 81
 	$thumb_ids = array();
82
-	foreach ( $wp_query->posts as $post ) {
83
-		if ( $id = get_post_thumbnail_id( $post->ID ) )
82
+	foreach ($wp_query->posts as $post) {
83
+		if ($id = get_post_thumbnail_id($post->ID))
84 84
 			$thumb_ids[] = $id;
85 85
 	}
86 86
 
87
-	if ( ! empty ( $thumb_ids ) ) {
88
-		_prime_post_caches( $thumb_ids, false, true );
87
+	if ( ! empty ($thumb_ids)) {
88
+		_prime_post_caches($thumb_ids, false, true);
89 89
 	}
90 90
 
91 91
 	$wp_query->thumbnails_cached = true;
@@ -111,12 +111,12 @@  discard block
 block discarded – undo
111 111
  * @param string|array $attr Optional. Query string or array of attributes. Default empty.
112 112
  * @return string The post thumbnail image tag.
113 113
  */
114
-function get_the_post_thumbnail( $post = null, $size = 'post-thumbnail', $attr = '' ) {
115
-	$post = get_post( $post );
116
-	if ( ! $post ) {
114
+function get_the_post_thumbnail($post = null, $size = 'post-thumbnail', $attr = '') {
115
+	$post = get_post($post);
116
+	if ( ! $post) {
117 117
 		return '';
118 118
 	}
119
-	$post_thumbnail_id = get_post_thumbnail_id( $post );
119
+	$post_thumbnail_id = get_post_thumbnail_id($post);
120 120
 
121 121
 	/**
122 122
 	 * Filters the post thumbnail size.
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
 	 * @param string|array $size The post thumbnail size. Image size or array of width and height
127 127
 	 *                           values (in that order). Default 'post-thumbnail'.
128 128
 	 */
129
-	$size = apply_filters( 'post_thumbnail_size', $size );
129
+	$size = apply_filters('post_thumbnail_size', $size);
130 130
 
131
-	if ( $post_thumbnail_id ) {
131
+	if ($post_thumbnail_id) {
132 132
 
133 133
 		/**
134 134
 		 * Fires before fetching the post thumbnail HTML.
@@ -142,10 +142,10 @@  discard block
 block discarded – undo
142 142
 		 * @param string|array $size              The post thumbnail size. Image size or array of width
143 143
 		 *                                        and height values (in that order). Default 'post-thumbnail'.
144 144
 		 */
145
-		do_action( 'begin_fetch_post_thumbnail_html', $post->ID, $post_thumbnail_id, $size );
146
-		if ( in_the_loop() )
145
+		do_action('begin_fetch_post_thumbnail_html', $post->ID, $post_thumbnail_id, $size);
146
+		if (in_the_loop())
147 147
 			update_post_thumbnail_cache();
148
-		$html = wp_get_attachment_image( $post_thumbnail_id, $size, false, $attr );
148
+		$html = wp_get_attachment_image($post_thumbnail_id, $size, false, $attr);
149 149
 
150 150
 		/**
151 151
 		 * Fires after fetching the post thumbnail HTML.
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 		 * @param string|array $size              The post thumbnail size. Image size or array of width
158 158
 		 *                                        and height values (in that order). Default 'post-thumbnail'.
159 159
 		 */
160
-		do_action( 'end_fetch_post_thumbnail_html', $post->ID, $post_thumbnail_id, $size );
160
+		do_action('end_fetch_post_thumbnail_html', $post->ID, $post_thumbnail_id, $size);
161 161
 
162 162
 	} else {
163 163
 		$html = '';
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	 *                                        values (in that order). Default 'post-thumbnail'.
175 175
 	 * @param string       $attr              Query string of attributes.
176 176
 	 */
177
-	return apply_filters( 'post_thumbnail_html', $html, $post->ID, $post_thumbnail_id, $size, $attr );
177
+	return apply_filters('post_thumbnail_html', $html, $post->ID, $post_thumbnail_id, $size, $attr);
178 178
 }
179 179
 
180 180
 /**
@@ -187,12 +187,12 @@  discard block
 block discarded – undo
187 187
  *                           array of height and width dimensions. Default 'post-thumbnail'.
188 188
  * @return string|false Post thumbnail URL or false if no URL is available.
189 189
  */
190
-function get_the_post_thumbnail_url( $post = null, $size = 'post-thumbnail' ) {
191
-	$post_thumbnail_id = get_post_thumbnail_id( $post );
192
-	if ( ! $post_thumbnail_id ) {
190
+function get_the_post_thumbnail_url($post = null, $size = 'post-thumbnail') {
191
+	$post_thumbnail_id = get_post_thumbnail_id($post);
192
+	if ( ! $post_thumbnail_id) {
193 193
 		return false;
194 194
 	}
195
-	return wp_get_attachment_image_url( $post_thumbnail_id, $size );
195
+	return wp_get_attachment_image_url($post_thumbnail_id, $size);
196 196
 }
197 197
 
198 198
 /**
@@ -204,10 +204,10 @@  discard block
 block discarded – undo
204 204
  *                           or an array of width and height values in pixels (in that order).
205 205
  *                           Default 'post-thumbnail'.
206 206
  */
207
-function the_post_thumbnail_url( $size = 'post-thumbnail' ) {
208
-	$url = get_the_post_thumbnail_url( null, $size );
209
-	if ( $url ) {
210
-		echo esc_url( $url );
207
+function the_post_thumbnail_url($size = 'post-thumbnail') {
208
+	$url = get_the_post_thumbnail_url(null, $size);
209
+	if ($url) {
210
+		echo esc_url($url);
211 211
 	}
212 212
 }
213 213
 
@@ -219,15 +219,15 @@  discard block
 block discarded – undo
219 219
  * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global `$post`.
220 220
  * @return string Post thumbnail caption.
221 221
  */
222
-function get_the_post_thumbnail_caption( $post = null ) {
223
-	$post_thumbnail_id = get_post_thumbnail_id( $post );
224
-	if ( ! $post_thumbnail_id ) {
222
+function get_the_post_thumbnail_caption($post = null) {
223
+	$post_thumbnail_id = get_post_thumbnail_id($post);
224
+	if ( ! $post_thumbnail_id) {
225 225
 		return '';
226 226
 	}
227 227
 
228
-	$caption = wp_get_attachment_caption( $post_thumbnail_id );
228
+	$caption = wp_get_attachment_caption($post_thumbnail_id);
229 229
 
230
-	if ( ! $caption ) {
230
+	if ( ! $caption) {
231 231
 		$caption = '';
232 232
 	}
233 233
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
  *
242 242
  * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global `$post`.
243 243
  */
244
-function the_post_thumbnail_caption( $post = null ) {
244
+function the_post_thumbnail_caption($post = null) {
245 245
 	/**
246 246
 	 * Filters the displayed post thumbnail caption.
247 247
 	 *
@@ -249,5 +249,5 @@  discard block
 block discarded – undo
249 249
 	 *
250 250
 	 * @param string $caption Caption for the given attachment.
251 251
 	 */
252
-	echo apply_filters( 'the_post_thumbnail_caption', get_the_post_thumbnail_caption( $post ) );
252
+	echo apply_filters('the_post_thumbnail_caption', get_the_post_thumbnail_caption($post));
253 253
 }
Please login to merge, or discard this patch.
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -72,16 +72,19 @@  discard block
 block discarded – undo
72 72
  * @param WP_Query $wp_query Optional. A WP_Query instance. Defaults to the $wp_query global.
73 73
  */
74 74
 function update_post_thumbnail_cache( $wp_query = null ) {
75
-	if ( ! $wp_query )
76
-		$wp_query = $GLOBALS['wp_query'];
75
+	if ( ! $wp_query ) {
76
+			$wp_query = $GLOBALS['wp_query'];
77
+	}
77 78
 
78
-	if ( $wp_query->thumbnails_cached )
79
-		return;
79
+	if ( $wp_query->thumbnails_cached ) {
80
+			return;
81
+	}
80 82
 
81 83
 	$thumb_ids = array();
82 84
 	foreach ( $wp_query->posts as $post ) {
83
-		if ( $id = get_post_thumbnail_id( $post->ID ) )
84
-			$thumb_ids[] = $id;
85
+		if ( $id = get_post_thumbnail_id( $post->ID ) ) {
86
+					$thumb_ids[] = $id;
87
+		}
85 88
 	}
86 89
 
87 90
 	if ( ! empty ( $thumb_ids ) ) {
@@ -143,8 +146,9 @@  discard block
 block discarded – undo
143 146
 		 *                                        and height values (in that order). Default 'post-thumbnail'.
144 147
 		 */
145 148
 		do_action( 'begin_fetch_post_thumbnail_html', $post->ID, $post_thumbnail_id, $size );
146
-		if ( in_the_loop() )
147
-			update_post_thumbnail_cache();
149
+		if ( in_the_loop() ) {
150
+					update_post_thumbnail_cache();
151
+		}
148 152
 		$html = wp_get_attachment_image( $post_thumbnail_id, $size, false, $attr );
149 153
 
150 154
 		/**
Please login to merge, or discard this patch.
src/wp-includes/random_compat/random.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -199,6 +199,7 @@
 block discarded – undo
199 199
             /**
200 200
              * We don't have any more options, so let's throw an exception right now
201 201
              * and hope the developer won't let it fail silently.
202
+             * @param integer $length
202 203
              */
203 204
             function random_bytes($length)
204 205
             {
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
  * SOFTWARE.
30 30
  */
31 31
 
32
-if (!defined('PHP_VERSION_ID')) {
32
+if ( ! defined('PHP_VERSION_ID')) {
33 33
     // This constant was introduced in PHP 5.2.7
34 34
     $RandomCompatversion = explode('.', PHP_VERSION);
35 35
     define(
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 
44 44
 if (PHP_VERSION_ID < 70000) {
45 45
 
46
-    if (!defined('RANDOM_COMPAT_READ_BUFFER')) {
46
+    if ( ! defined('RANDOM_COMPAT_READ_BUFFER')) {
47 47
         define('RANDOM_COMPAT_READ_BUFFER', 8);
48 48
     }
49 49
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     require_once $RandomCompatDIR.'/cast_to_int.php';
54 54
     require_once $RandomCompatDIR.'/error_polyfill.php';
55 55
 
56
-    if (!function_exists('random_bytes')) {
56
+    if ( ! function_exists('random_bytes')) {
57 57
         /**
58 58
          * PHP 5.2.0 - 5.6.x way to implement random_bytes()
59 59
          *
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
             $RandomCompatUrandom = true;
88 88
             $RandomCompat_basedir = ini_get('open_basedir');
89 89
 
90
-            if (!empty($RandomCompat_basedir)) {
90
+            if ( ! empty($RandomCompat_basedir)) {
91 91
                 $RandomCompat_open_basedir = explode(
92 92
                     PATH_SEPARATOR,
93 93
                     strtolower($RandomCompat_basedir)
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
             }
101 101
 
102 102
             if (
103
-                !function_exists('random_bytes')
103
+                ! function_exists('random_bytes')
104 104
                 &&
105 105
                 $RandomCompatUrandom
106 106
                 &&
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
          * mcrypt_create_iv()
125 125
          */
126 126
         if (
127
-            !function_exists('random_bytes')
127
+            ! function_exists('random_bytes')
128 128
             &&
129 129
             PHP_VERSION_ID >= 50307
130 130
             &&
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
         }
143 143
 
144 144
         if (
145
-            !function_exists('random_bytes')
145
+            ! function_exists('random_bytes')
146 146
             &&
147 147
             extension_loaded('com_dotnet')
148 148
             &&
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
                 strtolower(ini_get('disable_classes'))
154 154
             );
155 155
 
156
-            if (!in_array('com', $RandomCompat_disabled_classes)) {
156
+            if ( ! in_array('com', $RandomCompat_disabled_classes)) {
157 157
                 try {
158 158
                     $RandomCompatCOMtest = new COM('CAPICOM.Utilities.1');
159 159
                     if (method_exists($RandomCompatCOMtest, 'GetRandom')) {
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
                 PHP_VERSION_ID >= 50401
185 185
             )
186 186
             &&
187
-            !function_exists('random_bytes')
187
+            ! function_exists('random_bytes')
188 188
             &&
189 189
             extension_loaded('openssl')
190 190
         ) {
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
         /**
196 196
          * throw new Exception
197 197
          */
198
-        if (!function_exists('random_bytes')) {
198
+        if ( ! function_exists('random_bytes')) {
199 199
             /**
200 200
              * We don't have any more options, so let's throw an exception right now
201 201
              * and hope the developer won't let it fail silently.
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
         }
210 210
     }
211 211
 
212
-    if (!function_exists('random_int')) {
212
+    if ( ! function_exists('random_int')) {
213 213
         require_once $RandomCompatDIR.'/random_int.php';
214 214
     }
215 215
 
Please login to merge, or discard this patch.
Indentation   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -30,188 +30,188 @@
 block discarded – undo
30 30
  */
31 31
 
32 32
 if (!defined('PHP_VERSION_ID')) {
33
-    // This constant was introduced in PHP 5.2.7
34
-    $RandomCompatversion = explode('.', PHP_VERSION);
35
-    define(
36
-        'PHP_VERSION_ID',
37
-        $RandomCompatversion[0] * 10000
38
-        + $RandomCompatversion[1] * 100
39
-        + $RandomCompatversion[2]
40
-    );
41
-    $RandomCompatversion = null;
33
+	// This constant was introduced in PHP 5.2.7
34
+	$RandomCompatversion = explode('.', PHP_VERSION);
35
+	define(
36
+		'PHP_VERSION_ID',
37
+		$RandomCompatversion[0] * 10000
38
+		+ $RandomCompatversion[1] * 100
39
+		+ $RandomCompatversion[2]
40
+	);
41
+	$RandomCompatversion = null;
42 42
 }
43 43
 
44 44
 if (PHP_VERSION_ID < 70000) {
45 45
 
46
-    if (!defined('RANDOM_COMPAT_READ_BUFFER')) {
47
-        define('RANDOM_COMPAT_READ_BUFFER', 8);
48
-    }
49
-
50
-    $RandomCompatDIR = dirname(__FILE__);
51
-
52
-    require_once $RandomCompatDIR.'/byte_safe_strings.php';
53
-    require_once $RandomCompatDIR.'/cast_to_int.php';
54
-    require_once $RandomCompatDIR.'/error_polyfill.php';
55
-
56
-    if (!function_exists('random_bytes')) {
57
-        /**
58
-         * PHP 5.2.0 - 5.6.x way to implement random_bytes()
59
-         *
60
-         * We use conditional statements here to define the function in accordance
61
-         * to the operating environment. It's a micro-optimization.
62
-         *
63
-         * In order of preference:
64
-         *   1. Use libsodium if available.
65
-         *   2. fread() /dev/urandom if available (never on Windows)
66
-         *   3. mcrypt_create_iv($bytes, MCRYPT_DEV_URANDOM)
67
-         *   4. COM('CAPICOM.Utilities.1')->GetRandom()
68
-         *   5. openssl_random_pseudo_bytes() (absolute last resort)
69
-         *
70
-         * See ERRATA.md for our reasoning behind this particular order
71
-         */
72
-        if (extension_loaded('libsodium')) {
73
-            // See random_bytes_libsodium.php
74
-            if (PHP_VERSION_ID >= 50300 && function_exists('\\Sodium\\randombytes_buf')) {
75
-                require_once $RandomCompatDIR.'/random_bytes_libsodium.php';
76
-            } elseif (method_exists('Sodium', 'randombytes_buf')) {
77
-                require_once $RandomCompatDIR.'/random_bytes_libsodium_legacy.php';
78
-            }
79
-        }
80
-
81
-        /**
82
-         * Reading directly from /dev/urandom:
83
-         */
84
-        if (DIRECTORY_SEPARATOR === '/') {
85
-            // DIRECTORY_SEPARATOR === '/' on Unix-like OSes -- this is a fast
86
-            // way to exclude Windows.
87
-            $RandomCompatUrandom = true;
88
-            $RandomCompat_basedir = ini_get('open_basedir');
89
-
90
-            if (!empty($RandomCompat_basedir)) {
91
-                $RandomCompat_open_basedir = explode(
92
-                    PATH_SEPARATOR,
93
-                    strtolower($RandomCompat_basedir)
94
-                );
95
-                $RandomCompatUrandom = in_array(
96
-                    '/dev',
97
-                    $RandomCompat_open_basedir
98
-                );
99
-                $RandomCompat_open_basedir = null;
100
-            }
101
-
102
-            if (
103
-                !function_exists('random_bytes')
104
-                &&
105
-                $RandomCompatUrandom
106
-                &&
107
-                @is_readable('/dev/urandom')
108
-            ) {
109
-                // Error suppression on is_readable() in case of an open_basedir
110
-                // or safe_mode failure. All we care about is whether or not we
111
-                // can read it at this point. If the PHP environment is going to
112
-                // panic over trying to see if the file can be read in the first
113
-                // place, that is not helpful to us here.
114
-
115
-                // See random_bytes_dev_urandom.php
116
-                require_once $RandomCompatDIR.'/random_bytes_dev_urandom.php';
117
-            }
118
-            // Unset variables after use
119
-            $RandomCompat_basedir = null;
120
-            $RandomCompatUrandom = null;
121
-        }
122
-
123
-        /**
124
-         * mcrypt_create_iv()
125
-         */
126
-        if (
127
-            !function_exists('random_bytes')
128
-            &&
129
-            PHP_VERSION_ID >= 50307
130
-            &&
131
-            extension_loaded('mcrypt')
132
-        ) {
133
-            // Prevent this code from hanging indefinitely on non-Windows;
134
-            // see https://bugs.php.net/bug.php?id=69833
135
-            if (
136
-                DIRECTORY_SEPARATOR !== '/' ||
137
-                (PHP_VERSION_ID <= 50609 || PHP_VERSION_ID >= 50613)
138
-            ) {
139
-                // See random_bytes_mcrypt.php
140
-                require_once $RandomCompatDIR.'/random_bytes_mcrypt.php';
141
-            }
142
-        }
143
-
144
-        if (
145
-            !function_exists('random_bytes')
146
-            &&
147
-            extension_loaded('com_dotnet')
148
-            &&
149
-            class_exists('COM')
150
-        ) {
151
-            $RandomCompat_disabled_classes = preg_split(
152
-                '#\s*,\s*#',
153
-                strtolower(ini_get('disable_classes'))
154
-            );
155
-
156
-            if (!in_array('com', $RandomCompat_disabled_classes)) {
157
-                try {
158
-                    $RandomCompatCOMtest = new COM('CAPICOM.Utilities.1');
159
-                    if (method_exists($RandomCompatCOMtest, 'GetRandom')) {
160
-                        // See random_bytes_com_dotnet.php
161
-                        require_once $RandomCompatDIR.'/random_bytes_com_dotnet.php';
162
-                    }
163
-                } catch (com_exception $e) {
164
-                    // Don't try to use it.
165
-                }
166
-            }
167
-            $RandomCompat_disabled_classes = null;
168
-            $RandomCompatCOMtest = null;
169
-        }
170
-
171
-        /**
172
-         * openssl_random_pseudo_bytes()
173
-         */
174
-        if (
175
-            (
176
-                // Unix-like with PHP >= 5.3.0 or
177
-                (
178
-                    DIRECTORY_SEPARATOR === '/'
179
-                    &&
180
-                    PHP_VERSION_ID >= 50300
181
-                )
182
-                ||
183
-                // Windows with PHP >= 5.4.1
184
-                PHP_VERSION_ID >= 50401
185
-            )
186
-            &&
187
-            !function_exists('random_bytes')
188
-            &&
189
-            extension_loaded('openssl')
190
-        ) {
191
-            // See random_bytes_openssl.php
192
-            require_once $RandomCompatDIR.'/random_bytes_openssl.php';
193
-        }
194
-
195
-        /**
196
-         * throw new Exception
197
-         */
198
-        if (!function_exists('random_bytes')) {
199
-            /**
200
-             * We don't have any more options, so let's throw an exception right now
201
-             * and hope the developer won't let it fail silently.
202
-             */
203
-            function random_bytes($length)
204
-            {
205
-                throw new Exception(
206
-                    'There is no suitable CSPRNG installed on your system'
207
-                );
208
-            }
209
-        }
210
-    }
211
-
212
-    if (!function_exists('random_int')) {
213
-        require_once $RandomCompatDIR.'/random_int.php';
214
-    }
215
-
216
-    $RandomCompatDIR = null;
46
+	if (!defined('RANDOM_COMPAT_READ_BUFFER')) {
47
+		define('RANDOM_COMPAT_READ_BUFFER', 8);
48
+	}
49
+
50
+	$RandomCompatDIR = dirname(__FILE__);
51
+
52
+	require_once $RandomCompatDIR.'/byte_safe_strings.php';
53
+	require_once $RandomCompatDIR.'/cast_to_int.php';
54
+	require_once $RandomCompatDIR.'/error_polyfill.php';
55
+
56
+	if (!function_exists('random_bytes')) {
57
+		/**
58
+		 * PHP 5.2.0 - 5.6.x way to implement random_bytes()
59
+		 *
60
+		 * We use conditional statements here to define the function in accordance
61
+		 * to the operating environment. It's a micro-optimization.
62
+		 *
63
+		 * In order of preference:
64
+		 *   1. Use libsodium if available.
65
+		 *   2. fread() /dev/urandom if available (never on Windows)
66
+		 *   3. mcrypt_create_iv($bytes, MCRYPT_DEV_URANDOM)
67
+		 *   4. COM('CAPICOM.Utilities.1')->GetRandom()
68
+		 *   5. openssl_random_pseudo_bytes() (absolute last resort)
69
+		 *
70
+		 * See ERRATA.md for our reasoning behind this particular order
71
+		 */
72
+		if (extension_loaded('libsodium')) {
73
+			// See random_bytes_libsodium.php
74
+			if (PHP_VERSION_ID >= 50300 && function_exists('\\Sodium\\randombytes_buf')) {
75
+				require_once $RandomCompatDIR.'/random_bytes_libsodium.php';
76
+			} elseif (method_exists('Sodium', 'randombytes_buf')) {
77
+				require_once $RandomCompatDIR.'/random_bytes_libsodium_legacy.php';
78
+			}
79
+		}
80
+
81
+		/**
82
+		 * Reading directly from /dev/urandom:
83
+		 */
84
+		if (DIRECTORY_SEPARATOR === '/') {
85
+			// DIRECTORY_SEPARATOR === '/' on Unix-like OSes -- this is a fast
86
+			// way to exclude Windows.
87
+			$RandomCompatUrandom = true;
88
+			$RandomCompat_basedir = ini_get('open_basedir');
89
+
90
+			if (!empty($RandomCompat_basedir)) {
91
+				$RandomCompat_open_basedir = explode(
92
+					PATH_SEPARATOR,
93
+					strtolower($RandomCompat_basedir)
94
+				);
95
+				$RandomCompatUrandom = in_array(
96
+					'/dev',
97
+					$RandomCompat_open_basedir
98
+				);
99
+				$RandomCompat_open_basedir = null;
100
+			}
101
+
102
+			if (
103
+				!function_exists('random_bytes')
104
+				&&
105
+				$RandomCompatUrandom
106
+				&&
107
+				@is_readable('/dev/urandom')
108
+			) {
109
+				// Error suppression on is_readable() in case of an open_basedir
110
+				// or safe_mode failure. All we care about is whether or not we
111
+				// can read it at this point. If the PHP environment is going to
112
+				// panic over trying to see if the file can be read in the first
113
+				// place, that is not helpful to us here.
114
+
115
+				// See random_bytes_dev_urandom.php
116
+				require_once $RandomCompatDIR.'/random_bytes_dev_urandom.php';
117
+			}
118
+			// Unset variables after use
119
+			$RandomCompat_basedir = null;
120
+			$RandomCompatUrandom = null;
121
+		}
122
+
123
+		/**
124
+		 * mcrypt_create_iv()
125
+		 */
126
+		if (
127
+			!function_exists('random_bytes')
128
+			&&
129
+			PHP_VERSION_ID >= 50307
130
+			&&
131
+			extension_loaded('mcrypt')
132
+		) {
133
+			// Prevent this code from hanging indefinitely on non-Windows;
134
+			// see https://bugs.php.net/bug.php?id=69833
135
+			if (
136
+				DIRECTORY_SEPARATOR !== '/' ||
137
+				(PHP_VERSION_ID <= 50609 || PHP_VERSION_ID >= 50613)
138
+			) {
139
+				// See random_bytes_mcrypt.php
140
+				require_once $RandomCompatDIR.'/random_bytes_mcrypt.php';
141
+			}
142
+		}
143
+
144
+		if (
145
+			!function_exists('random_bytes')
146
+			&&
147
+			extension_loaded('com_dotnet')
148
+			&&
149
+			class_exists('COM')
150
+		) {
151
+			$RandomCompat_disabled_classes = preg_split(
152
+				'#\s*,\s*#',
153
+				strtolower(ini_get('disable_classes'))
154
+			);
155
+
156
+			if (!in_array('com', $RandomCompat_disabled_classes)) {
157
+				try {
158
+					$RandomCompatCOMtest = new COM('CAPICOM.Utilities.1');
159
+					if (method_exists($RandomCompatCOMtest, 'GetRandom')) {
160
+						// See random_bytes_com_dotnet.php
161
+						require_once $RandomCompatDIR.'/random_bytes_com_dotnet.php';
162
+					}
163
+				} catch (com_exception $e) {
164
+					// Don't try to use it.
165
+				}
166
+			}
167
+			$RandomCompat_disabled_classes = null;
168
+			$RandomCompatCOMtest = null;
169
+		}
170
+
171
+		/**
172
+		 * openssl_random_pseudo_bytes()
173
+		 */
174
+		if (
175
+			(
176
+				// Unix-like with PHP >= 5.3.0 or
177
+				(
178
+					DIRECTORY_SEPARATOR === '/'
179
+					&&
180
+					PHP_VERSION_ID >= 50300
181
+				)
182
+				||
183
+				// Windows with PHP >= 5.4.1
184
+				PHP_VERSION_ID >= 50401
185
+			)
186
+			&&
187
+			!function_exists('random_bytes')
188
+			&&
189
+			extension_loaded('openssl')
190
+		) {
191
+			// See random_bytes_openssl.php
192
+			require_once $RandomCompatDIR.'/random_bytes_openssl.php';
193
+		}
194
+
195
+		/**
196
+		 * throw new Exception
197
+		 */
198
+		if (!function_exists('random_bytes')) {
199
+			/**
200
+			 * We don't have any more options, so let's throw an exception right now
201
+			 * and hope the developer won't let it fail silently.
202
+			 */
203
+			function random_bytes($length)
204
+			{
205
+				throw new Exception(
206
+					'There is no suitable CSPRNG installed on your system'
207
+				);
208
+			}
209
+		}
210
+	}
211
+
212
+	if (!function_exists('random_int')) {
213
+		require_once $RandomCompatDIR.'/random_int.php';
214
+	}
215
+
216
+	$RandomCompatDIR = null;
217 217
 }
Please login to merge, or discard this patch.