Completed
Push — master ( d488ab...6453e7 )
by Stephen
53:31
created
src/wp-includes/class-wp-customize-manager.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -174,7 +174,7 @@
 block discarded – undo
174 174
 	 *
175 175
 	 * @since 3.4.0
176 176
 	 *
177
-	 * @param mixed $ajax_message AJAX return
177
+	 * @param integer $ajax_message AJAX return
178 178
 	 * @param mixed $message UI message
179 179
 	 */
180 180
 	protected function wp_die( $ajax_message, $message = null ) {
Please login to merge, or discard this patch.
Spacing   +365 added lines, -365 removed lines patch added patch discarded remove patch
@@ -106,39 +106,39 @@  discard block
 block discarded – undo
106 106
 	 * @since 3.4.0
107 107
 	 */
108 108
 	public function __construct() {
109
-		require_once( ABSPATH . WPINC . '/class-wp-customize-setting.php' );
110
-		require_once( ABSPATH . WPINC . '/class-wp-customize-panel.php' );
111
-		require_once( ABSPATH . WPINC . '/class-wp-customize-section.php' );
112
-		require_once( ABSPATH . WPINC . '/class-wp-customize-control.php' );
113
-		require_once( ABSPATH . WPINC . '/class-wp-customize-widgets.php' );
114
-		require_once( ABSPATH . WPINC . '/class-wp-customize-nav-menus.php' );
109
+		require_once(ABSPATH.WPINC.'/class-wp-customize-setting.php');
110
+		require_once(ABSPATH.WPINC.'/class-wp-customize-panel.php');
111
+		require_once(ABSPATH.WPINC.'/class-wp-customize-section.php');
112
+		require_once(ABSPATH.WPINC.'/class-wp-customize-control.php');
113
+		require_once(ABSPATH.WPINC.'/class-wp-customize-widgets.php');
114
+		require_once(ABSPATH.WPINC.'/class-wp-customize-nav-menus.php');
115 115
 
116
-		$this->widgets = new WP_Customize_Widgets( $this );
117
-		$this->nav_menus = new WP_Customize_Nav_Menus( $this );
116
+		$this->widgets = new WP_Customize_Widgets($this);
117
+		$this->nav_menus = new WP_Customize_Nav_Menus($this);
118 118
 
119
-		add_filter( 'wp_die_handler', array( $this, 'wp_die_handler' ) );
119
+		add_filter('wp_die_handler', array($this, 'wp_die_handler'));
120 120
 
121
-		add_action( 'setup_theme', array( $this, 'setup_theme' ) );
122
-		add_action( 'wp_loaded',   array( $this, 'wp_loaded' ) );
121
+		add_action('setup_theme', array($this, 'setup_theme'));
122
+		add_action('wp_loaded', array($this, 'wp_loaded'));
123 123
 
124 124
 		// Run wp_redirect_status late to make sure we override the status last.
125
-		add_action( 'wp_redirect_status', array( $this, 'wp_redirect_status' ), 1000 );
125
+		add_action('wp_redirect_status', array($this, 'wp_redirect_status'), 1000);
126 126
 
127 127
 		// Do not spawn cron (especially the alternate cron) while running the Customizer.
128
-		remove_action( 'init', 'wp_cron' );
128
+		remove_action('init', 'wp_cron');
129 129
 
130 130
 		// Do not run update checks when rendering the controls.
131
-		remove_action( 'admin_init', '_maybe_update_core' );
132
-		remove_action( 'admin_init', '_maybe_update_plugins' );
133
-		remove_action( 'admin_init', '_maybe_update_themes' );
131
+		remove_action('admin_init', '_maybe_update_core');
132
+		remove_action('admin_init', '_maybe_update_plugins');
133
+		remove_action('admin_init', '_maybe_update_themes');
134 134
 
135
-		add_action( 'wp_ajax_customize_save',           array( $this, 'save' ) );
136
-		add_action( 'wp_ajax_customize_refresh_nonces', array( $this, 'refresh_nonces' ) );
135
+		add_action('wp_ajax_customize_save', array($this, 'save'));
136
+		add_action('wp_ajax_customize_refresh_nonces', array($this, 'refresh_nonces'));
137 137
 
138
-		add_action( 'customize_register',                 array( $this, 'register_controls' ) );
139
-		add_action( 'customize_register',                 array( $this, 'register_dynamic_settings' ), 11 ); // allow code to create settings first
140
-		add_action( 'customize_controls_init',            array( $this, 'prepare_controls' ) );
141
-		add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_control_scripts' ) );
138
+		add_action('customize_register', array($this, 'register_controls'));
139
+		add_action('customize_register', array($this, 'register_dynamic_settings'), 11); // allow code to create settings first
140
+		add_action('customize_controls_init', array($this, 'prepare_controls'));
141
+		add_action('customize_controls_enqueue_scripts', array($this, 'enqueue_control_scripts'));
142 142
 	}
143 143
 
144 144
 	/**
@@ -151,20 +151,20 @@  discard block
 block discarded – undo
151 151
 	 * @param string|null $action Whether the supplied AJAX action is being run.
152 152
 	 * @return bool True if it's an AJAX request, false otherwise.
153 153
 	 */
154
-	public function doing_ajax( $action = null ) {
155
-		$doing_ajax = ( defined( 'DOING_AJAX' ) && DOING_AJAX );
156
-		if ( ! $doing_ajax ) {
154
+	public function doing_ajax($action = null) {
155
+		$doing_ajax = (defined('DOING_AJAX') && DOING_AJAX);
156
+		if ( ! $doing_ajax) {
157 157
 			return false;
158 158
 		}
159 159
 
160
-		if ( ! $action ) {
160
+		if ( ! $action) {
161 161
 			return true;
162 162
 		} else {
163 163
 			/*
164 164
 			 * Note: we can't just use doing_action( "wp_ajax_{$action}" ) because we need
165 165
 			 * to check before admin-ajax.php gets to that point.
166 166
 			 */
167
-			return isset( $_REQUEST['action'] ) && wp_unslash( $_REQUEST['action'] ) === $action;
167
+			return isset($_REQUEST['action']) && wp_unslash($_REQUEST['action']) === $action;
168 168
 		}
169 169
 	}
170 170
 
@@ -177,16 +177,16 @@  discard block
 block discarded – undo
177 177
 	 * @param mixed $ajax_message AJAX return
178 178
 	 * @param mixed $message UI message
179 179
 	 */
180
-	protected function wp_die( $ajax_message, $message = null ) {
181
-		if ( $this->doing_ajax() || isset( $_POST['customized'] ) ) {
182
-			wp_die( $ajax_message );
180
+	protected function wp_die($ajax_message, $message = null) {
181
+		if ($this->doing_ajax() || isset($_POST['customized'])) {
182
+			wp_die($ajax_message);
183 183
 		}
184 184
 
185
-		if ( ! $message ) {
186
-			$message = __( 'Cheatin’ uh?' );
185
+		if ( ! $message) {
186
+			$message = __('Cheatin’ uh?');
187 187
 		}
188 188
 
189
-		wp_die( $message );
189
+		wp_die($message);
190 190
 	}
191 191
 
192 192
 	/**
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	 * @return string
198 198
 	 */
199 199
 	public function wp_die_handler() {
200
-		if ( $this->doing_ajax() || isset( $_POST['customized'] ) ) {
200
+		if ($this->doing_ajax() || isset($_POST['customized'])) {
201 201
 			return '_ajax_wp_die_handler';
202 202
 		}
203 203
 
@@ -214,40 +214,40 @@  discard block
 block discarded – undo
214 214
 	public function setup_theme() {
215 215
 		send_origin_headers();
216 216
 
217
-		$doing_ajax_or_is_customized = ( $this->doing_ajax() || isset( $_POST['customized'] ) );
218
-		if ( is_admin() && ! $doing_ajax_or_is_customized ) {
217
+		$doing_ajax_or_is_customized = ($this->doing_ajax() || isset($_POST['customized']));
218
+		if (is_admin() && ! $doing_ajax_or_is_customized) {
219 219
 			auth_redirect();
220
-		} elseif ( $doing_ajax_or_is_customized && ! is_user_logged_in() ) {
221
-			$this->wp_die( 0 );
220
+		} elseif ($doing_ajax_or_is_customized && ! is_user_logged_in()) {
221
+			$this->wp_die(0);
222 222
 		}
223 223
 
224
-		show_admin_bar( false );
224
+		show_admin_bar(false);
225 225
 
226
-		if ( ! current_user_can( 'customize' ) ) {
226
+		if ( ! current_user_can('customize')) {
227 227
 			$this->wp_die( -1 );
228 228
 		}
229 229
 
230 230
 		$this->original_stylesheet = get_stylesheet();
231 231
 
232
-		$this->theme = wp_get_theme( isset( $_REQUEST['theme'] ) ? $_REQUEST['theme'] : null );
232
+		$this->theme = wp_get_theme(isset($_REQUEST['theme']) ? $_REQUEST['theme'] : null);
233 233
 
234
-		if ( $this->is_theme_active() ) {
234
+		if ($this->is_theme_active()) {
235 235
 			// Once the theme is loaded, we'll validate it.
236
-			add_action( 'after_setup_theme', array( $this, 'after_setup_theme' ) );
236
+			add_action('after_setup_theme', array($this, 'after_setup_theme'));
237 237
 		} else {
238 238
 			// If the requested theme is not the active theme and the user doesn't have the
239 239
 			// switch_themes cap, bail.
240
-			if ( ! current_user_can( 'switch_themes' ) ) {
240
+			if ( ! current_user_can('switch_themes')) {
241 241
 				$this->wp_die( -1 );
242 242
 			}
243 243
 
244 244
 			// If the theme has errors while loading, bail.
245
-			if ( $this->theme()->errors() ) {
245
+			if ($this->theme()->errors()) {
246 246
 				$this->wp_die( -1 );
247 247
 			}
248 248
 
249 249
 			// If the theme isn't allowed per multisite settings, bail.
250
-			if ( ! $this->theme()->is_allowed() ) {
250
+			if ( ! $this->theme()->is_allowed()) {
251 251
 				$this->wp_die( -1 );
252 252
 			}
253 253
 		}
@@ -261,9 +261,9 @@  discard block
 block discarded – undo
261 261
 	 * @since 3.4.0
262 262
 	 */
263 263
 	public function after_setup_theme() {
264
-		$doing_ajax_or_is_customized = ( $this->doing_ajax() || isset( $_SERVER['customized'] ) );
265
-		if ( ! $doing_ajax_or_is_customized && ! validate_current_theme() ) {
266
-			wp_redirect( 'themes.php?broken=true' );
264
+		$doing_ajax_or_is_customized = ($this->doing_ajax() || isset($_SERVER['customized']));
265
+		if ( ! $doing_ajax_or_is_customized && ! validate_current_theme()) {
266
+			wp_redirect('themes.php?broken=true');
267 267
 			exit;
268 268
 		}
269 269
 	}
@@ -276,24 +276,24 @@  discard block
 block discarded – undo
276 276
 	 */
277 277
 	public function start_previewing_theme() {
278 278
 		// Bail if we're already previewing.
279
-		if ( $this->is_preview() ) {
279
+		if ($this->is_preview()) {
280 280
 			return;
281 281
 		}
282 282
 
283 283
 		$this->previewing = true;
284 284
 
285
-		if ( ! $this->is_theme_active() ) {
286
-			add_filter( 'template', array( $this, 'get_template' ) );
287
-			add_filter( 'stylesheet', array( $this, 'get_stylesheet' ) );
288
-			add_filter( 'pre_option_current_theme', array( $this, 'current_theme' ) );
285
+		if ( ! $this->is_theme_active()) {
286
+			add_filter('template', array($this, 'get_template'));
287
+			add_filter('stylesheet', array($this, 'get_stylesheet'));
288
+			add_filter('pre_option_current_theme', array($this, 'current_theme'));
289 289
 
290 290
 			// @link: https://core.trac.wordpress.org/ticket/20027
291
-			add_filter( 'pre_option_stylesheet', array( $this, 'get_stylesheet' ) );
292
-			add_filter( 'pre_option_template', array( $this, 'get_template' ) );
291
+			add_filter('pre_option_stylesheet', array($this, 'get_stylesheet'));
292
+			add_filter('pre_option_template', array($this, 'get_template'));
293 293
 
294 294
 			// Handle custom theme roots.
295
-			add_filter( 'pre_option_stylesheet_root', array( $this, 'get_stylesheet_root' ) );
296
-			add_filter( 'pre_option_template_root', array( $this, 'get_template_root' ) );
295
+			add_filter('pre_option_stylesheet_root', array($this, 'get_stylesheet_root'));
296
+			add_filter('pre_option_template_root', array($this, 'get_template_root'));
297 297
 		}
298 298
 
299 299
 		/**
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 		 *
304 304
 		 * @param WP_Customize_Manager $this WP_Customize_Manager instance.
305 305
 		 */
306
-		do_action( 'start_previewing_theme', $this );
306
+		do_action('start_previewing_theme', $this);
307 307
 	}
308 308
 
309 309
 	/**
@@ -314,24 +314,24 @@  discard block
 block discarded – undo
314 314
 	 * @since 3.4.0
315 315
 	 */
316 316
 	public function stop_previewing_theme() {
317
-		if ( ! $this->is_preview() ) {
317
+		if ( ! $this->is_preview()) {
318 318
 			return;
319 319
 		}
320 320
 
321 321
 		$this->previewing = false;
322 322
 
323
-		if ( ! $this->is_theme_active() ) {
324
-			remove_filter( 'template', array( $this, 'get_template' ) );
325
-			remove_filter( 'stylesheet', array( $this, 'get_stylesheet' ) );
326
-			remove_filter( 'pre_option_current_theme', array( $this, 'current_theme' ) );
323
+		if ( ! $this->is_theme_active()) {
324
+			remove_filter('template', array($this, 'get_template'));
325
+			remove_filter('stylesheet', array($this, 'get_stylesheet'));
326
+			remove_filter('pre_option_current_theme', array($this, 'current_theme'));
327 327
 
328 328
 			// @link: https://core.trac.wordpress.org/ticket/20027
329
-			remove_filter( 'pre_option_stylesheet', array( $this, 'get_stylesheet' ) );
330
-			remove_filter( 'pre_option_template', array( $this, 'get_template' ) );
329
+			remove_filter('pre_option_stylesheet', array($this, 'get_stylesheet'));
330
+			remove_filter('pre_option_template', array($this, 'get_template'));
331 331
 
332 332
 			// Handle custom theme roots.
333
-			remove_filter( 'pre_option_stylesheet_root', array( $this, 'get_stylesheet_root' ) );
334
-			remove_filter( 'pre_option_template_root', array( $this, 'get_template_root' ) );
333
+			remove_filter('pre_option_stylesheet_root', array($this, 'get_stylesheet_root'));
334
+			remove_filter('pre_option_template_root', array($this, 'get_template_root'));
335 335
 		}
336 336
 
337 337
 		/**
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 		 *
342 342
 		 * @param WP_Customize_Manager $this WP_Customize_Manager instance.
343 343
 		 */
344
-		do_action( 'stop_previewing_theme', $this );
344
+		do_action('stop_previewing_theme', $this);
345 345
 	}
346 346
 
347 347
 	/**
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 	 * @return WP_Theme
353 353
 	 */
354 354
 	public function theme() {
355
-		if ( ! $this->theme ) {
355
+		if ( ! $this->theme) {
356 356
 			$this->theme = wp_get_theme();
357 357
 		}
358 358
 		return $this->theme;
@@ -439,9 +439,9 @@  discard block
 block discarded – undo
439 439
 		 *
440 440
 		 * @param WP_Customize_Manager $this WP_Customize_Manager instance.
441 441
 		 */
442
-		do_action( 'customize_register', $this );
442
+		do_action('customize_register', $this);
443 443
 
444
-		if ( $this->is_preview() && ! is_admin() )
444
+		if ($this->is_preview() && ! is_admin())
445 445
 			$this->customize_preview_init();
446 446
 	}
447 447
 
@@ -456,8 +456,8 @@  discard block
 block discarded – undo
456 456
 	 * @param $status
457 457
 	 * @return int
458 458
 	 */
459
-	public function wp_redirect_status( $status ) {
460
-		if ( $this->is_preview() && ! is_admin() )
459
+	public function wp_redirect_status($status) {
460
+		if ($this->is_preview() && ! is_admin())
461 461
 			return 200;
462 462
 
463 463
 		return $status;
@@ -472,15 +472,15 @@  discard block
 block discarded – undo
472 472
 	 * @return array
473 473
 	 */
474 474
 	public function unsanitized_post_values() {
475
-		if ( ! isset( $this->_post_values ) ) {
476
-			if ( isset( $_POST['customized'] ) ) {
477
-				$this->_post_values = json_decode( wp_unslash( $_POST['customized'] ), true );
475
+		if ( ! isset($this->_post_values)) {
476
+			if (isset($_POST['customized'])) {
477
+				$this->_post_values = json_decode(wp_unslash($_POST['customized']), true);
478 478
 			}
479
-			if ( empty( $this->_post_values ) ) { // if not isset or if JSON error
479
+			if (empty($this->_post_values)) { // if not isset or if JSON error
480 480
 				$this->_post_values = array();
481 481
 			}
482 482
 		}
483
-		if ( empty( $this->_post_values ) ) {
483
+		if (empty($this->_post_values)) {
484 484
 			return array();
485 485
 		} else {
486 486
 			return $this->_post_values;
@@ -497,10 +497,10 @@  discard block
 block discarded – undo
497 497
 	 * @param mixed $default value returned $setting has no post value (added in 4.2.0).
498 498
 	 * @return string|mixed $post_value Sanitized value or the $default provided
499 499
 	 */
500
-	public function post_value( $setting, $default = null ) {
500
+	public function post_value($setting, $default = null) {
501 501
 		$post_values = $this->unsanitized_post_values();
502
-		if ( array_key_exists( $setting->id, $post_values ) ) {
503
-			return $setting->sanitize( $post_values[ $setting->id ] );
502
+		if (array_key_exists($setting->id, $post_values)) {
503
+			return $setting->sanitize($post_values[$setting->id]);
504 504
 		} else {
505 505
 			return $default;
506 506
 		}
@@ -515,9 +515,9 @@  discard block
 block discarded – undo
515 515
 	 * @param string $setting_id ID for the WP_Customize_Setting instance.
516 516
 	 * @param mixed  $value      Post value.
517 517
 	 */
518
-	public function set_post_value( $setting_id, $value ) {
518
+	public function set_post_value($setting_id, $value) {
519 519
 		$this->unsanitized_post_values();
520
-		$this->_post_values[ $setting_id ] = $value;
520
+		$this->_post_values[$setting_id] = $value;
521 521
 	}
522 522
 
523 523
 	/**
@@ -526,20 +526,20 @@  discard block
 block discarded – undo
526 526
 	 * @since 3.4.0
527 527
 	 */
528 528
 	public function customize_preview_init() {
529
-		$this->nonce_tick = check_ajax_referer( 'preview-customize_' . $this->get_stylesheet(), 'nonce' );
529
+		$this->nonce_tick = check_ajax_referer('preview-customize_'.$this->get_stylesheet(), 'nonce');
530 530
 
531 531
 		$this->prepare_controls();
532 532
 
533
-		wp_enqueue_script( 'customize-preview' );
534
-		add_action( 'wp', array( $this, 'customize_preview_override_404_status' ) );
535
-		add_action( 'wp_head', array( $this, 'customize_preview_base' ) );
536
-		add_action( 'wp_head', array( $this, 'customize_preview_html5' ) );
537
-		add_action( 'wp_head', array( $this, 'customize_preview_loading_style' ) );
538
-		add_action( 'wp_footer', array( $this, 'customize_preview_settings' ), 20 );
539
-		add_action( 'shutdown', array( $this, 'customize_preview_signature' ), 1000 );
540
-		add_filter( 'wp_die_handler', array( $this, 'remove_preview_signature' ) );
533
+		wp_enqueue_script('customize-preview');
534
+		add_action('wp', array($this, 'customize_preview_override_404_status'));
535
+		add_action('wp_head', array($this, 'customize_preview_base'));
536
+		add_action('wp_head', array($this, 'customize_preview_html5'));
537
+		add_action('wp_head', array($this, 'customize_preview_loading_style'));
538
+		add_action('wp_footer', array($this, 'customize_preview_settings'), 20);
539
+		add_action('shutdown', array($this, 'customize_preview_signature'), 1000);
540
+		add_filter('wp_die_handler', array($this, 'remove_preview_signature'));
541 541
 
542
-		foreach ( $this->settings as $setting ) {
542
+		foreach ($this->settings as $setting) {
543 543
 			$setting->preview();
544 544
 		}
545 545
 
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
 		 *
552 552
 		 * @param WP_Customize_Manager $this WP_Customize_Manager instance.
553 553
 		 */
554
-		do_action( 'customize_preview_init', $this );
554
+		do_action('customize_preview_init', $this);
555 555
 	}
556 556
 
557 557
 	/**
@@ -562,8 +562,8 @@  discard block
 block discarded – undo
562 562
 	 * @access public
563 563
 	 */
564 564
 	public function customize_preview_override_404_status() {
565
-		if ( is_404() ) {
566
-			status_header( 200 );
565
+		if (is_404()) {
566
+			status_header(200);
567 567
 		}
568 568
 	}
569 569
 
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 	 * @since 3.4.0
574 574
 	 */
575 575
 	public function customize_preview_base() {
576
-		?><base href="<?php echo home_url( '/' ); ?>" /><?php
576
+		?><base href="<?php echo home_url('/'); ?>" /><?php
577 577
 	}
578 578
 
579 579
 	/**
@@ -622,51 +622,51 @@  discard block
 block discarded – undo
622 622
 	public function customize_preview_settings() {
623 623
 		$settings = array(
624 624
 			'values'  => array(),
625
-			'channel' => wp_unslash( $_POST['customize_messenger_channel'] ),
625
+			'channel' => wp_unslash($_POST['customize_messenger_channel']),
626 626
 			'activePanels' => array(),
627 627
 			'activeSections' => array(),
628 628
 			'activeControls' => array(),
629 629
 			'l10n' => array(
630
-				'loading'  => __( 'Loading ...' ),
630
+				'loading'  => __('Loading ...'),
631 631
 			),
632 632
 		);
633 633
 
634
-		if ( 2 == $this->nonce_tick ) {
634
+		if (2 == $this->nonce_tick) {
635 635
 			$settings['nonce'] = array(
636
-				'save' => wp_create_nonce( 'save-customize_' . $this->get_stylesheet() ),
637
-				'preview' => wp_create_nonce( 'preview-customize_' . $this->get_stylesheet() )
636
+				'save' => wp_create_nonce('save-customize_'.$this->get_stylesheet()),
637
+				'preview' => wp_create_nonce('preview-customize_'.$this->get_stylesheet())
638 638
 			);
639 639
 		}
640 640
 
641
-		foreach ( $this->settings as $id => $setting ) {
642
-			if ( $setting->check_capabilities() ) {
643
-				$settings['values'][ $id ] = $setting->js_value();
641
+		foreach ($this->settings as $id => $setting) {
642
+			if ($setting->check_capabilities()) {
643
+				$settings['values'][$id] = $setting->js_value();
644 644
 			}
645 645
 		}
646
-		foreach ( $this->panels as $panel_id => $panel ) {
647
-			if ( $panel->check_capabilities() ) {
648
-				$settings['activePanels'][ $panel_id ] = $panel->active();
649
-				foreach ( $panel->sections as $section_id => $section ) {
650
-					if ( $section->check_capabilities() ) {
651
-						$settings['activeSections'][ $section_id ] = $section->active();
646
+		foreach ($this->panels as $panel_id => $panel) {
647
+			if ($panel->check_capabilities()) {
648
+				$settings['activePanels'][$panel_id] = $panel->active();
649
+				foreach ($panel->sections as $section_id => $section) {
650
+					if ($section->check_capabilities()) {
651
+						$settings['activeSections'][$section_id] = $section->active();
652 652
 					}
653 653
 				}
654 654
 			}
655 655
 		}
656
-		foreach ( $this->sections as $id => $section ) {
657
-			if ( $section->check_capabilities() ) {
658
-				$settings['activeSections'][ $id ] = $section->active();
656
+		foreach ($this->sections as $id => $section) {
657
+			if ($section->check_capabilities()) {
658
+				$settings['activeSections'][$id] = $section->active();
659 659
 			}
660 660
 		}
661
-		foreach ( $this->controls as $id => $control ) {
662
-			if ( $control->check_capabilities() ) {
663
-				$settings['activeControls'][ $id ] = $control->active();
661
+		foreach ($this->controls as $id => $control) {
662
+			if ($control->check_capabilities()) {
663
+				$settings['activeControls'][$id] = $control->active();
664 664
 			}
665 665
 		}
666 666
 
667 667
 		?>
668 668
 		<script type="text/javascript">
669
-			var _wpCustomizeSettings = <?php echo wp_json_encode( $settings ); ?>;
669
+			var _wpCustomizeSettings = <?php echo wp_json_encode($settings); ?>;
670 670
 		</script>
671 671
 		<?php
672 672
 	}
@@ -687,8 +687,8 @@  discard block
 block discarded – undo
687 687
 	 *
688 688
 	 * @return mixed
689 689
 	 */
690
-	public function remove_preview_signature( $return = null ) {
691
-		remove_action( 'shutdown', array( $this, 'customize_preview_signature' ), 1000 );
690
+	public function remove_preview_signature($return = null) {
691
+		remove_action('shutdown', array($this, 'customize_preview_signature'), 1000);
692 692
 
693 693
 		return $return;
694 694
 	}
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 	 * @return string Theme root.
735 735
 	 */
736 736
 	public function get_template_root() {
737
-		return get_raw_theme_root( $this->get_template(), true );
737
+		return get_raw_theme_root($this->get_template(), true);
738 738
 	}
739 739
 
740 740
 	/**
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
 	 * @return string Theme root.
746 746
 	 */
747 747
 	public function get_stylesheet_root() {
748
-		return get_raw_theme_root( $this->get_stylesheet(), true );
748
+		return get_raw_theme_root($this->get_stylesheet(), true);
749 749
 	}
750 750
 
751 751
 	/**
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 	 * @param $current_theme {@internal Parameter is not used}
757 757
 	 * @return string Theme name.
758 758
 	 */
759
-	public function current_theme( $current_theme ) {
759
+	public function current_theme($current_theme) {
760 760
 		return $this->theme()->display('Name');
761 761
 	}
762 762
 
@@ -766,22 +766,22 @@  discard block
 block discarded – undo
766 766
 	 * @since 3.4.0
767 767
 	 */
768 768
 	public function save() {
769
-		if ( ! $this->is_preview() ) {
770
-			wp_send_json_error( 'not_preview' );
769
+		if ( ! $this->is_preview()) {
770
+			wp_send_json_error('not_preview');
771 771
 		}
772 772
 
773
-		$action = 'save-customize_' . $this->get_stylesheet();
774
-		if ( ! check_ajax_referer( $action, 'nonce', false ) ) {
775
-			wp_send_json_error( 'invalid_nonce' );
773
+		$action = 'save-customize_'.$this->get_stylesheet();
774
+		if ( ! check_ajax_referer($action, 'nonce', false)) {
775
+			wp_send_json_error('invalid_nonce');
776 776
 		}
777 777
 
778 778
 		// Do we have to switch themes?
779
-		if ( ! $this->is_theme_active() ) {
779
+		if ( ! $this->is_theme_active()) {
780 780
 			// Temporarily stop previewing the theme to allow switch_themes()
781 781
 			// to operate properly.
782 782
 			$this->stop_previewing_theme();
783
-			switch_theme( $this->get_stylesheet() );
784
-			update_option( 'theme_switched_via_customizer', true );
783
+			switch_theme($this->get_stylesheet());
784
+			update_option('theme_switched_via_customizer', true);
785 785
 			$this->start_previewing_theme();
786 786
 		}
787 787
 
@@ -793,9 +793,9 @@  discard block
 block discarded – undo
793 793
 		 *
794 794
 		 * @param WP_Customize_Manager $this WP_Customize_Manager instance.
795 795
 		 */
796
-		do_action( 'customize_save', $this );
796
+		do_action('customize_save', $this);
797 797
 
798
-		foreach ( $this->settings as $setting ) {
798
+		foreach ($this->settings as $setting) {
799 799
 			$setting->save();
800 800
 		}
801 801
 
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
 		 *
807 807
 		 * @param WP_Customize_Manager $this WP_Customize_Manager instance.
808 808
 		 */
809
-		do_action( 'customize_save_after', $this );
809
+		do_action('customize_save_after', $this);
810 810
 
811 811
 		/**
812 812
 		 * Filter response data for a successful customize_save AJAX request.
@@ -819,8 +819,8 @@  discard block
 block discarded – undo
819 819
 		 *                                   event on `wp.customize`.
820 820
 		 * @param WP_Customize_Manager $this WP_Customize_Manager instance.
821 821
 		 */
822
-		$response = apply_filters( 'customize_save_response', array(), $this );
823
-		wp_send_json_success( $response );
822
+		$response = apply_filters('customize_save_response', array(), $this);
823
+		wp_send_json_success($response);
824 824
 	}
825 825
 
826 826
 	/**
@@ -829,13 +829,13 @@  discard block
 block discarded – undo
829 829
 	 * @since 4.2.0
830 830
 	 */
831 831
 	public function refresh_nonces() {
832
-		if ( ! $this->is_preview() ) {
833
-			wp_send_json_error( 'not_preview' );
832
+		if ( ! $this->is_preview()) {
833
+			wp_send_json_error('not_preview');
834 834
 		}
835 835
 
836 836
 		$nonces = array(
837
-			'save'    => wp_create_nonce( 'save-customize_' . $this->get_stylesheet() ),
838
-			'preview' => wp_create_nonce( 'preview-customize_' . $this->get_stylesheet() ),
837
+			'save'    => wp_create_nonce('save-customize_'.$this->get_stylesheet()),
838
+			'preview' => wp_create_nonce('preview-customize_'.$this->get_stylesheet()),
839 839
 		);
840 840
 
841 841
 		/**
@@ -847,8 +847,8 @@  discard block
 block discarded – undo
847 847
 		 *                                     preview actions.
848 848
 		 * @param WP_Customize_Manager $this   WP_Customize_Manager instance.
849 849
 		 */
850
-		$nonces = apply_filters( 'customize_refresh_nonces', $nonces, $this );
851
-		wp_send_json_success( $nonces );
850
+		$nonces = apply_filters('customize_refresh_nonces', $nonces, $this);
851
+		wp_send_json_success($nonces);
852 852
 	}
853 853
 
854 854
 	/**
@@ -860,13 +860,13 @@  discard block
 block discarded – undo
860 860
 	 * @param array $args                     Setting arguments; passed to WP_Customize_Setting
861 861
 	 *                                        constructor.
862 862
 	 */
863
-	public function add_setting( $id, $args = array() ) {
864
-		if ( $id instanceof WP_Customize_Setting ) {
863
+	public function add_setting($id, $args = array()) {
864
+		if ($id instanceof WP_Customize_Setting) {
865 865
 			$setting = $id;
866 866
 		} else {
867
-			$setting = new WP_Customize_Setting( $this, $id, $args );
867
+			$setting = new WP_Customize_Setting($this, $id, $args);
868 868
 		}
869
-		$this->settings[ $setting->id ] = $setting;
869
+		$this->settings[$setting->id] = $setting;
870 870
 	}
871 871
 
872 872
 	/**
@@ -883,11 +883,11 @@  discard block
 block discarded – undo
883 883
 	 * @param array $setting_ids The setting IDs to add.
884 884
 	 * @return WP_Customize_Setting The settings added.
885 885
 	 */
886
-	public function add_dynamic_settings( $setting_ids ) {
886
+	public function add_dynamic_settings($setting_ids) {
887 887
 		$new_settings = array();
888
-		foreach ( $setting_ids as $setting_id ) {
888
+		foreach ($setting_ids as $setting_id) {
889 889
 			// Skip settings already created
890
-			if ( $this->get_setting( $setting_id ) ) {
890
+			if ($this->get_setting($setting_id)) {
891 891
 				continue;
892 892
 			}
893 893
 
@@ -906,8 +906,8 @@  discard block
 block discarded – undo
906 906
 			 * @param false|array $setting_args The arguments to the WP_Customize_Setting constructor.
907 907
 			 * @param string      $setting_id   ID for dynamic setting, usually coming from `$_POST['customized']`.
908 908
 			 */
909
-			$setting_args = apply_filters( 'customize_dynamic_setting_args', $setting_args, $setting_id );
910
-			if ( false === $setting_args ) {
909
+			$setting_args = apply_filters('customize_dynamic_setting_args', $setting_args, $setting_id);
910
+			if (false === $setting_args) {
911 911
 				continue;
912 912
 			}
913 913
 
@@ -920,11 +920,11 @@  discard block
 block discarded – undo
920 920
 			 * @param string $setting_id    ID for dynamic setting, usually coming from `$_POST['customized']`.
921 921
 			 * @param array  $setting_args  WP_Customize_Setting or a subclass.
922 922
 			 */
923
-			$setting_class = apply_filters( 'customize_dynamic_setting_class', $setting_class, $setting_id, $setting_args );
923
+			$setting_class = apply_filters('customize_dynamic_setting_class', $setting_class, $setting_id, $setting_args);
924 924
 
925
-			$setting = new $setting_class( $this, $setting_id, $setting_args );
925
+			$setting = new $setting_class($this, $setting_id, $setting_args);
926 926
 
927
-			$this->add_setting( $setting );
927
+			$this->add_setting($setting);
928 928
 			$new_settings[] = $setting;
929 929
 		}
930 930
 		return $new_settings;
@@ -938,9 +938,9 @@  discard block
 block discarded – undo
938 938
 	 * @param string $id Customize Setting ID.
939 939
 	 * @return WP_Customize_Setting|void The setting, if set.
940 940
 	 */
941
-	public function get_setting( $id ) {
942
-		if ( isset( $this->settings[ $id ] ) ) {
943
-			return $this->settings[ $id ];
941
+	public function get_setting($id) {
942
+		if (isset($this->settings[$id])) {
943
+			return $this->settings[$id];
944 944
 		}
945 945
 	}
946 946
 
@@ -951,8 +951,8 @@  discard block
 block discarded – undo
951 951
 	 *
952 952
 	 * @param string $id Customize Setting ID.
953 953
 	 */
954
-	public function remove_setting( $id ) {
955
-		unset( $this->settings[ $id ] );
954
+	public function remove_setting($id) {
955
+		unset($this->settings[$id]);
956 956
 	}
957 957
 
958 958
 	/**
@@ -964,14 +964,14 @@  discard block
 block discarded – undo
964 964
 	 * @param WP_Customize_Panel|string $id   Customize Panel object, or Panel ID.
965 965
 	 * @param array                     $args Optional. Panel arguments. Default empty array.
966 966
 	 */
967
-	public function add_panel( $id, $args = array() ) {
968
-		if ( $id instanceof WP_Customize_Panel ) {
967
+	public function add_panel($id, $args = array()) {
968
+		if ($id instanceof WP_Customize_Panel) {
969 969
 			$panel = $id;
970 970
 		} else {
971
-			$panel = new WP_Customize_Panel( $this, $id, $args );
971
+			$panel = new WP_Customize_Panel($this, $id, $args);
972 972
 		}
973 973
 
974
-		$this->panels[ $panel->id ] = $panel;
974
+		$this->panels[$panel->id] = $panel;
975 975
 	}
976 976
 
977 977
 	/**
@@ -983,9 +983,9 @@  discard block
 block discarded – undo
983 983
 	 * @param string $id Panel ID to get.
984 984
 	 * @return WP_Customize_Panel|void Requested panel instance, if set.
985 985
 	 */
986
-	public function get_panel( $id ) {
987
-		if ( isset( $this->panels[ $id ] ) ) {
988
-			return $this->panels[ $id ];
986
+	public function get_panel($id) {
987
+		if (isset($this->panels[$id])) {
988
+			return $this->panels[$id];
989 989
 		}
990 990
 	}
991 991
 
@@ -997,8 +997,8 @@  discard block
 block discarded – undo
997 997
 	 *
998 998
 	 * @param string $id Panel ID to remove.
999 999
 	 */
1000
-	public function remove_panel( $id ) {
1001
-		unset( $this->panels[ $id ] );
1000
+	public function remove_panel($id) {
1001
+		unset($this->panels[$id]);
1002 1002
 	}
1003 1003
 
1004 1004
 	/**
@@ -1013,7 +1013,7 @@  discard block
 block discarded – undo
1013 1013
 	 *
1014 1014
 	 * @param string $panel Name of a custom panel which is a subclass of WP_Customize_Panel.
1015 1015
 	 */
1016
-	public function register_panel_type( $panel ) {
1016
+	public function register_panel_type($panel) {
1017 1017
 		$this->registered_panel_types[] = $panel;
1018 1018
 	}
1019 1019
 
@@ -1024,8 +1024,8 @@  discard block
 block discarded – undo
1024 1024
 	 * @access public
1025 1025
 	 */
1026 1026
 	public function render_panel_templates() {
1027
-		foreach ( $this->registered_panel_types as $panel_type ) {
1028
-			$panel = new $panel_type( $this, 'temp', array() );
1027
+		foreach ($this->registered_panel_types as $panel_type) {
1028
+			$panel = new $panel_type($this, 'temp', array());
1029 1029
 			$panel->print_template();
1030 1030
 		}
1031 1031
 	}
@@ -1038,13 +1038,13 @@  discard block
 block discarded – undo
1038 1038
 	 * @param WP_Customize_Section|string $id   Customize Section object, or Section ID.
1039 1039
 	 * @param array                       $args Section arguments.
1040 1040
 	 */
1041
-	public function add_section( $id, $args = array() ) {
1042
-		if ( $id instanceof WP_Customize_Section ) {
1041
+	public function add_section($id, $args = array()) {
1042
+		if ($id instanceof WP_Customize_Section) {
1043 1043
 			$section = $id;
1044 1044
 		} else {
1045
-			$section = new WP_Customize_Section( $this, $id, $args );
1045
+			$section = new WP_Customize_Section($this, $id, $args);
1046 1046
 		}
1047
-		$this->sections[ $section->id ] = $section;
1047
+		$this->sections[$section->id] = $section;
1048 1048
 	}
1049 1049
 
1050 1050
 	/**
@@ -1055,9 +1055,9 @@  discard block
 block discarded – undo
1055 1055
 	 * @param string $id Section ID.
1056 1056
 	 * @return WP_Customize_Section|void The section, if set.
1057 1057
 	 */
1058
-	public function get_section( $id ) {
1059
-		if ( isset( $this->sections[ $id ] ) )
1060
-			return $this->sections[ $id ];
1058
+	public function get_section($id) {
1059
+		if (isset($this->sections[$id]))
1060
+			return $this->sections[$id];
1061 1061
 	}
1062 1062
 
1063 1063
 	/**
@@ -1067,8 +1067,8 @@  discard block
 block discarded – undo
1067 1067
 	 *
1068 1068
 	 * @param string $id Section ID.
1069 1069
 	 */
1070
-	public function remove_section( $id ) {
1071
-		unset( $this->sections[ $id ] );
1070
+	public function remove_section($id) {
1071
+		unset($this->sections[$id]);
1072 1072
 	}
1073 1073
 
1074 1074
 	/**
@@ -1083,7 +1083,7 @@  discard block
 block discarded – undo
1083 1083
 	 *
1084 1084
 	 * @param string $section Name of a custom section which is a subclass of WP_Customize_Section.
1085 1085
 	 */
1086
-	public function register_section_type( $section ) {
1086
+	public function register_section_type($section) {
1087 1087
 		$this->registered_section_types[] = $section;
1088 1088
 	}
1089 1089
 
@@ -1094,8 +1094,8 @@  discard block
 block discarded – undo
1094 1094
 	 * @access public
1095 1095
 	 */
1096 1096
 	public function render_section_templates() {
1097
-		foreach ( $this->registered_section_types as $section_type ) {
1098
-			$section = new $section_type( $this, 'temp', array() );
1097
+		foreach ($this->registered_section_types as $section_type) {
1098
+			$section = new $section_type($this, 'temp', array());
1099 1099
 			$section->print_template();
1100 1100
 		}
1101 1101
 	}
@@ -1109,13 +1109,13 @@  discard block
 block discarded – undo
1109 1109
 	 * @param array                       $args Control arguments; passed to WP_Customize_Control
1110 1110
 	 *                                          constructor.
1111 1111
 	 */
1112
-	public function add_control( $id, $args = array() ) {
1113
-		if ( $id instanceof WP_Customize_Control ) {
1112
+	public function add_control($id, $args = array()) {
1113
+		if ($id instanceof WP_Customize_Control) {
1114 1114
 			$control = $id;
1115 1115
 		} else {
1116
-			$control = new WP_Customize_Control( $this, $id, $args );
1116
+			$control = new WP_Customize_Control($this, $id, $args);
1117 1117
 		}
1118
-		$this->controls[ $control->id ] = $control;
1118
+		$this->controls[$control->id] = $control;
1119 1119
 	}
1120 1120
 
1121 1121
 	/**
@@ -1126,9 +1126,9 @@  discard block
 block discarded – undo
1126 1126
 	 * @param string $id ID of the control.
1127 1127
 	 * @return WP_Customize_Control|void The control object, if set.
1128 1128
 	 */
1129
-	public function get_control( $id ) {
1130
-		if ( isset( $this->controls[ $id ] ) )
1131
-			return $this->controls[ $id ];
1129
+	public function get_control($id) {
1130
+		if (isset($this->controls[$id]))
1131
+			return $this->controls[$id];
1132 1132
 	}
1133 1133
 
1134 1134
 	/**
@@ -1138,8 +1138,8 @@  discard block
 block discarded – undo
1138 1138
 	 *
1139 1139
 	 * @param string $id ID of the control.
1140 1140
 	 */
1141
-	public function remove_control( $id ) {
1142
-		unset( $this->controls[ $id ] );
1141
+	public function remove_control($id) {
1142
+		unset($this->controls[$id]);
1143 1143
 	}
1144 1144
 
1145 1145
 	/**
@@ -1153,7 +1153,7 @@  discard block
 block discarded – undo
1153 1153
 	 * @param string $control Name of a custom control which is a subclass of
1154 1154
 	 *                        {@see WP_Customize_Control}.
1155 1155
 	 */
1156
-	public function register_control_type( $control ) {
1156
+	public function register_control_type($control) {
1157 1157
 		$this->registered_control_types[] = $control;
1158 1158
 	}
1159 1159
 
@@ -1164,8 +1164,8 @@  discard block
 block discarded – undo
1164 1164
 	 * @access public
1165 1165
 	 */
1166 1166
 	public function render_control_templates() {
1167
-		foreach ( $this->registered_control_types as $control_type ) {
1168
-			$control = new $control_type( $this, 'temp', array() );
1167
+		foreach ($this->registered_control_types as $control_type) {
1168
+			$control = new $control_type($this, 'temp', array());
1169 1169
 			$control->print_template();
1170 1170
 		}
1171 1171
 	}
@@ -1179,8 +1179,8 @@  discard block
 block discarded – undo
1179 1179
 	 * @param WP_Customize_Panel|WP_Customize_Section|WP_Customize_Control $b Object B.
1180 1180
 	 * @return int
1181 1181
 	 */
1182
-	protected function _cmp_priority( $a, $b ) {
1183
-		if ( $a->priority === $b->priority ) {
1182
+	protected function _cmp_priority($a, $b) {
1183
+		if ($a->priority === $b->priority) {
1184 1184
 			return $a->instance_number - $a->instance_number;
1185 1185
 		} else {
1186 1186
 			return $a->priority - $b->priority;
@@ -1199,58 +1199,58 @@  discard block
 block discarded – undo
1199 1199
 	public function prepare_controls() {
1200 1200
 
1201 1201
 		$controls = array();
1202
-		uasort( $this->controls, array( $this, '_cmp_priority' ) );
1202
+		uasort($this->controls, array($this, '_cmp_priority'));
1203 1203
 
1204
-		foreach ( $this->controls as $id => $control ) {
1205
-			if ( ! isset( $this->sections[ $control->section ] ) || ! $control->check_capabilities() ) {
1204
+		foreach ($this->controls as $id => $control) {
1205
+			if ( ! isset($this->sections[$control->section]) || ! $control->check_capabilities()) {
1206 1206
 				continue;
1207 1207
 			}
1208 1208
 
1209
-			$this->sections[ $control->section ]->controls[] = $control;
1210
-			$controls[ $id ] = $control;
1209
+			$this->sections[$control->section]->controls[] = $control;
1210
+			$controls[$id] = $control;
1211 1211
 		}
1212 1212
 		$this->controls = $controls;
1213 1213
 
1214 1214
 		// Prepare sections.
1215
-		uasort( $this->sections, array( $this, '_cmp_priority' ) );
1215
+		uasort($this->sections, array($this, '_cmp_priority'));
1216 1216
 		$sections = array();
1217 1217
 
1218
-		foreach ( $this->sections as $section ) {
1219
-			if ( ! $section->check_capabilities() ) {
1218
+		foreach ($this->sections as $section) {
1219
+			if ( ! $section->check_capabilities()) {
1220 1220
 				continue;
1221 1221
 			}
1222 1222
 
1223
-			usort( $section->controls, array( $this, '_cmp_priority' ) );
1223
+			usort($section->controls, array($this, '_cmp_priority'));
1224 1224
 
1225
-			if ( ! $section->panel ) {
1225
+			if ( ! $section->panel) {
1226 1226
 				// Top-level section.
1227
-				$sections[ $section->id ] = $section;
1227
+				$sections[$section->id] = $section;
1228 1228
 			} else {
1229 1229
 				// This section belongs to a panel.
1230
-				if ( isset( $this->panels [ $section->panel ] ) ) {
1231
-					$this->panels[ $section->panel ]->sections[ $section->id ] = $section;
1230
+				if (isset($this->panels [$section->panel])) {
1231
+					$this->panels[$section->panel]->sections[$section->id] = $section;
1232 1232
 				}
1233 1233
 			}
1234 1234
 		}
1235 1235
 		$this->sections = $sections;
1236 1236
 
1237 1237
 		// Prepare panels.
1238
-		uasort( $this->panels, array( $this, '_cmp_priority' ) );
1238
+		uasort($this->panels, array($this, '_cmp_priority'));
1239 1239
 		$panels = array();
1240 1240
 
1241
-		foreach ( $this->panels as $panel ) {
1242
-			if ( ! $panel->check_capabilities() ) {
1241
+		foreach ($this->panels as $panel) {
1242
+			if ( ! $panel->check_capabilities()) {
1243 1243
 				continue;
1244 1244
 			}
1245 1245
 
1246
-			uasort( $panel->sections, array( $this, '_cmp_priority' ) );
1247
-			$panels[ $panel->id ] = $panel;
1246
+			uasort($panel->sections, array($this, '_cmp_priority'));
1247
+			$panels[$panel->id] = $panel;
1248 1248
 		}
1249 1249
 		$this->panels = $panels;
1250 1250
 
1251 1251
 		// Sort panels and top-level sections together.
1252
-		$this->containers = array_merge( $this->panels, $this->sections );
1253
-		uasort( $this->containers, array( $this, '_cmp_priority' ) );
1252
+		$this->containers = array_merge($this->panels, $this->sections);
1253
+		uasort($this->containers, array($this, '_cmp_priority'));
1254 1254
 	}
1255 1255
 
1256 1256
 	/**
@@ -1259,7 +1259,7 @@  discard block
 block discarded – undo
1259 1259
 	 * @since 3.4.0
1260 1260
 	 */
1261 1261
 	public function enqueue_control_scripts() {
1262
-		foreach ( $this->controls as $control ) {
1262
+		foreach ($this->controls as $control) {
1263 1263
 			$control->enqueue();
1264 1264
 		}
1265 1265
 	}
@@ -1272,198 +1272,198 @@  discard block
 block discarded – undo
1272 1272
 	public function register_controls() {
1273 1273
 
1274 1274
 		/* Panel, Section, and Control Types */
1275
-		$this->register_panel_type( 'WP_Customize_Panel' );
1276
-		$this->register_section_type( 'WP_Customize_Section' );
1277
-		$this->register_section_type( 'WP_Customize_Sidebar_Section' );
1278
-		$this->register_control_type( 'WP_Customize_Color_Control' );
1279
-		$this->register_control_type( 'WP_Customize_Media_Control' );
1280
-		$this->register_control_type( 'WP_Customize_Upload_Control' );
1281
-		$this->register_control_type( 'WP_Customize_Image_Control' );
1282
-		$this->register_control_type( 'WP_Customize_Background_Image_Control' );
1283
-		$this->register_control_type( 'WP_Customize_Cropped_Image_Control' );
1284
-		$this->register_control_type( 'WP_Customize_Site_Icon_Control' );
1285
-		$this->register_control_type( 'WP_Customize_Theme_Control' );
1275
+		$this->register_panel_type('WP_Customize_Panel');
1276
+		$this->register_section_type('WP_Customize_Section');
1277
+		$this->register_section_type('WP_Customize_Sidebar_Section');
1278
+		$this->register_control_type('WP_Customize_Color_Control');
1279
+		$this->register_control_type('WP_Customize_Media_Control');
1280
+		$this->register_control_type('WP_Customize_Upload_Control');
1281
+		$this->register_control_type('WP_Customize_Image_Control');
1282
+		$this->register_control_type('WP_Customize_Background_Image_Control');
1283
+		$this->register_control_type('WP_Customize_Cropped_Image_Control');
1284
+		$this->register_control_type('WP_Customize_Site_Icon_Control');
1285
+		$this->register_control_type('WP_Customize_Theme_Control');
1286 1286
 
1287 1287
 		/* Themes */
1288 1288
 
1289
-		$this->add_section( new WP_Customize_Themes_Section( $this, 'themes', array(
1290
-			'title'      => $this->theme()->display( 'Name' ),
1289
+		$this->add_section(new WP_Customize_Themes_Section($this, 'themes', array(
1290
+			'title'      => $this->theme()->display('Name'),
1291 1291
 			'capability' => 'switch_themes',
1292 1292
 			'priority'   => 0,
1293
-		) ) );
1293
+		)));
1294 1294
 
1295 1295
 		// Themes Setting (unused - the theme is considerably more fundamental to the Customizer experience).
1296
-		$this->add_setting( new WP_Customize_Filter_Setting( $this, 'active_theme', array(
1296
+		$this->add_setting(new WP_Customize_Filter_Setting($this, 'active_theme', array(
1297 1297
 			'capability' => 'switch_themes',
1298
-		) ) );
1298
+		)));
1299 1299
 
1300
-		require_once( ABSPATH . 'wp-admin/includes/theme.php' );
1300
+		require_once(ABSPATH.'wp-admin/includes/theme.php');
1301 1301
 
1302 1302
 		// Theme Controls.
1303 1303
 
1304 1304
 		// Add a control for the active/original theme.
1305
-		if ( ! $this->is_theme_active() ) {
1306
-			$themes = wp_prepare_themes_for_js( array( wp_get_theme( $this->original_stylesheet ) ) );
1307
-			$active_theme = current( $themes );
1305
+		if ( ! $this->is_theme_active()) {
1306
+			$themes = wp_prepare_themes_for_js(array(wp_get_theme($this->original_stylesheet)));
1307
+			$active_theme = current($themes);
1308 1308
 			$active_theme['isActiveTheme'] = true;
1309
-			$this->add_control( new WP_Customize_Theme_Control( $this, $active_theme['id'], array(
1309
+			$this->add_control(new WP_Customize_Theme_Control($this, $active_theme['id'], array(
1310 1310
 				'theme'    => $active_theme,
1311 1311
 				'section'  => 'themes',
1312 1312
 				'settings' => 'active_theme',
1313
-			) ) );
1313
+			)));
1314 1314
 		}
1315 1315
 
1316 1316
 		$themes = wp_prepare_themes_for_js();
1317
-		foreach ( $themes as $theme ) {
1318
-			if ( $theme['active'] || $theme['id'] === $this->original_stylesheet ) {
1317
+		foreach ($themes as $theme) {
1318
+			if ($theme['active'] || $theme['id'] === $this->original_stylesheet) {
1319 1319
 				continue;
1320 1320
 			}
1321 1321
 
1322
-			$theme_id = 'theme_' . $theme['id'];
1322
+			$theme_id = 'theme_'.$theme['id'];
1323 1323
 			$theme['isActiveTheme'] = false;
1324
-			$this->add_control( new WP_Customize_Theme_Control( $this, $theme_id, array(
1324
+			$this->add_control(new WP_Customize_Theme_Control($this, $theme_id, array(
1325 1325
 				'theme'    => $theme,
1326 1326
 				'section'  => 'themes',
1327 1327
 				'settings' => 'active_theme',
1328
-			) ) );
1328
+			)));
1329 1329
 		}
1330 1330
 
1331 1331
 		/* Site Identity */
1332 1332
 
1333
-		$this->add_section( 'title_tagline', array(
1334
-			'title'    => __( 'Site Identity' ),
1333
+		$this->add_section('title_tagline', array(
1334
+			'title'    => __('Site Identity'),
1335 1335
 			'priority' => 20,
1336
-		) );
1336
+		));
1337 1337
 
1338
-		$this->add_setting( 'blogname', array(
1339
-			'default'    => get_option( 'blogname' ),
1338
+		$this->add_setting('blogname', array(
1339
+			'default'    => get_option('blogname'),
1340 1340
 			'type'       => 'option',
1341 1341
 			'capability' => 'manage_options',
1342
-		) );
1342
+		));
1343 1343
 
1344
-		$this->add_control( 'blogname', array(
1345
-			'label'      => __( 'Site Title' ),
1344
+		$this->add_control('blogname', array(
1345
+			'label'      => __('Site Title'),
1346 1346
 			'section'    => 'title_tagline',
1347
-		) );
1347
+		));
1348 1348
 
1349
-		$this->add_setting( 'blogdescription', array(
1350
-			'default'    => get_option( 'blogdescription' ),
1349
+		$this->add_setting('blogdescription', array(
1350
+			'default'    => get_option('blogdescription'),
1351 1351
 			'type'       => 'option',
1352 1352
 			'capability' => 'manage_options',
1353
-		) );
1353
+		));
1354 1354
 
1355
-		$this->add_control( 'blogdescription', array(
1356
-			'label'      => __( 'Tagline' ),
1355
+		$this->add_control('blogdescription', array(
1356
+			'label'      => __('Tagline'),
1357 1357
 			'section'    => 'title_tagline',
1358
-		) );
1358
+		));
1359 1359
 
1360
-		$this->add_setting( 'site_icon', array(
1360
+		$this->add_setting('site_icon', array(
1361 1361
 			'type'       => 'option',
1362 1362
 			'capability' => 'manage_options',
1363 1363
 			'transport'  => 'postMessage', // Previewed with JS in the Customizer controls window.
1364
-		) );
1364
+		));
1365 1365
 
1366
-		$this->add_control( new WP_Customize_Site_Icon_Control( $this, 'site_icon', array(
1367
-			'label'       => __( 'Site Icon' ),
1368
-			'description' => __( 'The Site Icon is used as a browser and app icon for your site. Icons must be square, and at least 512px wide and tall.' ),
1366
+		$this->add_control(new WP_Customize_Site_Icon_Control($this, 'site_icon', array(
1367
+			'label'       => __('Site Icon'),
1368
+			'description' => __('The Site Icon is used as a browser and app icon for your site. Icons must be square, and at least 512px wide and tall.'),
1369 1369
 			'section'     => 'title_tagline',
1370 1370
 			'priority'    => 60,
1371 1371
 			'height'      => 512,
1372 1372
 			'width'       => 512,
1373
-		) ) );
1373
+		)));
1374 1374
 
1375 1375
 		/* Colors */
1376 1376
 
1377
-		$this->add_section( 'colors', array(
1378
-			'title'          => __( 'Colors' ),
1377
+		$this->add_section('colors', array(
1378
+			'title'          => __('Colors'),
1379 1379
 			'priority'       => 40,
1380
-		) );
1380
+		));
1381 1381
 
1382
-		$this->add_setting( 'header_textcolor', array(
1383
-			'theme_supports' => array( 'custom-header', 'header-text' ),
1384
-			'default'        => get_theme_support( 'custom-header', 'default-text-color' ),
1382
+		$this->add_setting('header_textcolor', array(
1383
+			'theme_supports' => array('custom-header', 'header-text'),
1384
+			'default'        => get_theme_support('custom-header', 'default-text-color'),
1385 1385
 
1386
-			'sanitize_callback'    => array( $this, '_sanitize_header_textcolor' ),
1386
+			'sanitize_callback'    => array($this, '_sanitize_header_textcolor'),
1387 1387
 			'sanitize_js_callback' => 'maybe_hash_hex_color',
1388
-		) );
1388
+		));
1389 1389
 
1390 1390
 		// Input type: checkbox
1391 1391
 		// With custom value
1392
-		$this->add_control( 'display_header_text', array(
1392
+		$this->add_control('display_header_text', array(
1393 1393
 			'settings' => 'header_textcolor',
1394
-			'label'    => __( 'Display Header Text' ),
1394
+			'label'    => __('Display Header Text'),
1395 1395
 			'section'  => 'title_tagline',
1396 1396
 			'type'     => 'checkbox',
1397 1397
 			'priority' => 40,
1398
-		) );
1398
+		));
1399 1399
 
1400
-		$this->add_control( new WP_Customize_Color_Control( $this, 'header_textcolor', array(
1401
-			'label'   => __( 'Header Text Color' ),
1400
+		$this->add_control(new WP_Customize_Color_Control($this, 'header_textcolor', array(
1401
+			'label'   => __('Header Text Color'),
1402 1402
 			'section' => 'colors',
1403
-		) ) );
1403
+		)));
1404 1404
 
1405 1405
 		// Input type: Color
1406 1406
 		// With sanitize_callback
1407
-		$this->add_setting( 'background_color', array(
1408
-			'default'        => get_theme_support( 'custom-background', 'default-color' ),
1407
+		$this->add_setting('background_color', array(
1408
+			'default'        => get_theme_support('custom-background', 'default-color'),
1409 1409
 			'theme_supports' => 'custom-background',
1410 1410
 
1411 1411
 			'sanitize_callback'    => 'sanitize_hex_color_no_hash',
1412 1412
 			'sanitize_js_callback' => 'maybe_hash_hex_color',
1413
-		) );
1413
+		));
1414 1414
 
1415
-		$this->add_control( new WP_Customize_Color_Control( $this, 'background_color', array(
1416
-			'label'   => __( 'Background Color' ),
1415
+		$this->add_control(new WP_Customize_Color_Control($this, 'background_color', array(
1416
+			'label'   => __('Background Color'),
1417 1417
 			'section' => 'colors',
1418
-		) ) );
1418
+		)));
1419 1419
 
1420 1420
 
1421 1421
 		/* Custom Header */
1422 1422
 
1423
-		$this->add_section( 'header_image', array(
1424
-			'title'          => __( 'Header Image' ),
1423
+		$this->add_section('header_image', array(
1424
+			'title'          => __('Header Image'),
1425 1425
 			'theme_supports' => 'custom-header',
1426 1426
 			'priority'       => 60,
1427
-		) );
1427
+		));
1428 1428
 
1429
-		$this->add_setting( new WP_Customize_Filter_Setting( $this, 'header_image', array(
1430
-			'default'        => get_theme_support( 'custom-header', 'default-image' ),
1429
+		$this->add_setting(new WP_Customize_Filter_Setting($this, 'header_image', array(
1430
+			'default'        => get_theme_support('custom-header', 'default-image'),
1431 1431
 			'theme_supports' => 'custom-header',
1432
-		) ) );
1432
+		)));
1433 1433
 
1434
-		$this->add_setting( new WP_Customize_Header_Image_Setting( $this, 'header_image_data', array(
1434
+		$this->add_setting(new WP_Customize_Header_Image_Setting($this, 'header_image_data', array(
1435 1435
 			// 'default'        => get_theme_support( 'custom-header', 'default-image' ),
1436 1436
 			'theme_supports' => 'custom-header',
1437
-		) ) );
1437
+		)));
1438 1438
 
1439
-		$this->add_control( new WP_Customize_Header_Image_Control( $this ) );
1439
+		$this->add_control(new WP_Customize_Header_Image_Control($this));
1440 1440
 
1441 1441
 		/* Custom Background */
1442 1442
 
1443
-		$this->add_section( 'background_image', array(
1444
-			'title'          => __( 'Background Image' ),
1443
+		$this->add_section('background_image', array(
1444
+			'title'          => __('Background Image'),
1445 1445
 			'theme_supports' => 'custom-background',
1446 1446
 			'priority'       => 80,
1447
-		) );
1447
+		));
1448 1448
 
1449
-		$this->add_setting( 'background_image', array(
1450
-			'default'        => get_theme_support( 'custom-background', 'default-image' ),
1449
+		$this->add_setting('background_image', array(
1450
+			'default'        => get_theme_support('custom-background', 'default-image'),
1451 1451
 			'theme_supports' => 'custom-background',
1452
-		) );
1452
+		));
1453 1453
 
1454
-		$this->add_setting( new WP_Customize_Background_Image_Setting( $this, 'background_image_thumb', array(
1454
+		$this->add_setting(new WP_Customize_Background_Image_Setting($this, 'background_image_thumb', array(
1455 1455
 			'theme_supports' => 'custom-background',
1456
-		) ) );
1456
+		)));
1457 1457
 
1458
-		$this->add_control( new WP_Customize_Background_Image_Control( $this ) );
1458
+		$this->add_control(new WP_Customize_Background_Image_Control($this));
1459 1459
 
1460
-		$this->add_setting( 'background_repeat', array(
1461
-			'default'        => get_theme_support( 'custom-background', 'default-repeat' ),
1460
+		$this->add_setting('background_repeat', array(
1461
+			'default'        => get_theme_support('custom-background', 'default-repeat'),
1462 1462
 			'theme_supports' => 'custom-background',
1463
-		) );
1463
+		));
1464 1464
 
1465
-		$this->add_control( 'background_repeat', array(
1466
-			'label'      => __( 'Background Repeat' ),
1465
+		$this->add_control('background_repeat', array(
1466
+			'label'      => __('Background Repeat'),
1467 1467
 			'section'    => 'background_image',
1468 1468
 			'type'       => 'radio',
1469 1469
 			'choices'    => array(
@@ -1472,15 +1472,15 @@  discard block
 block discarded – undo
1472 1472
 				'repeat-x'   => __('Tile Horizontally'),
1473 1473
 				'repeat-y'   => __('Tile Vertically'),
1474 1474
 			),
1475
-		) );
1475
+		));
1476 1476
 
1477
-		$this->add_setting( 'background_position_x', array(
1478
-			'default'        => get_theme_support( 'custom-background', 'default-position-x' ),
1477
+		$this->add_setting('background_position_x', array(
1478
+			'default'        => get_theme_support('custom-background', 'default-position-x'),
1479 1479
 			'theme_supports' => 'custom-background',
1480
-		) );
1480
+		));
1481 1481
 
1482
-		$this->add_control( 'background_position_x', array(
1483
-			'label'      => __( 'Background Position' ),
1482
+		$this->add_control('background_position_x', array(
1483
+			'label'      => __('Background Position'),
1484 1484
 			'section'    => 'background_image',
1485 1485
 			'type'       => 'radio',
1486 1486
 			'choices'    => array(
@@ -1488,28 +1488,28 @@  discard block
 block discarded – undo
1488 1488
 				'center'     => __('Center'),
1489 1489
 				'right'      => __('Right'),
1490 1490
 			),
1491
-		) );
1491
+		));
1492 1492
 
1493
-		$this->add_setting( 'background_attachment', array(
1494
-			'default'        => get_theme_support( 'custom-background', 'default-attachment' ),
1493
+		$this->add_setting('background_attachment', array(
1494
+			'default'        => get_theme_support('custom-background', 'default-attachment'),
1495 1495
 			'theme_supports' => 'custom-background',
1496
-		) );
1496
+		));
1497 1497
 
1498
-		$this->add_control( 'background_attachment', array(
1499
-			'label'      => __( 'Background Attachment' ),
1498
+		$this->add_control('background_attachment', array(
1499
+			'label'      => __('Background Attachment'),
1500 1500
 			'section'    => 'background_image',
1501 1501
 			'type'       => 'radio',
1502 1502
 			'choices'    => array(
1503 1503
 				'scroll'     => __('Scroll'),
1504 1504
 				'fixed'      => __('Fixed'),
1505 1505
 			),
1506
-		) );
1506
+		));
1507 1507
 
1508 1508
 		// If the theme is using the default background callback, we can update
1509 1509
 		// the background CSS using postMessage.
1510
-		if ( get_theme_support( 'custom-background', 'wp-head-callback' ) === '_custom_background_cb' ) {
1511
-			foreach ( array( 'color', 'image', 'position_x', 'repeat', 'attachment' ) as $prop ) {
1512
-				$this->get_setting( 'background_' . $prop )->transport = 'postMessage';
1510
+		if (get_theme_support('custom-background', 'wp-head-callback') === '_custom_background_cb') {
1511
+			foreach (array('color', 'image', 'position_x', 'repeat', 'attachment') as $prop) {
1512
+				$this->get_setting('background_'.$prop)->transport = 'postMessage';
1513 1513
 			}
1514 1514
 		}
1515 1515
 
@@ -1517,54 +1517,54 @@  discard block
 block discarded – undo
1517 1517
 		// #WP19627
1518 1518
 
1519 1519
 		// Replicate behavior from options-reading.php and hide front page options if there are no pages
1520
-		if ( get_pages() ) {
1521
-			$this->add_section( 'static_front_page', array(
1522
-				'title'          => __( 'Static Front Page' ),
1520
+		if (get_pages()) {
1521
+			$this->add_section('static_front_page', array(
1522
+				'title'          => __('Static Front Page'),
1523 1523
 			//	'theme_supports' => 'static-front-page',
1524 1524
 				'priority'       => 120,
1525
-				'description'    => __( 'Your theme supports a static front page.' ),
1526
-			) );
1525
+				'description'    => __('Your theme supports a static front page.'),
1526
+			));
1527 1527
 
1528
-			$this->add_setting( 'show_on_front', array(
1529
-				'default'        => get_option( 'show_on_front' ),
1528
+			$this->add_setting('show_on_front', array(
1529
+				'default'        => get_option('show_on_front'),
1530 1530
 				'capability'     => 'manage_options',
1531 1531
 				'type'           => 'option',
1532 1532
 			//	'theme_supports' => 'static-front-page',
1533
-			) );
1533
+			));
1534 1534
 
1535
-			$this->add_control( 'show_on_front', array(
1536
-				'label'   => __( 'Front page displays' ),
1535
+			$this->add_control('show_on_front', array(
1536
+				'label'   => __('Front page displays'),
1537 1537
 				'section' => 'static_front_page',
1538 1538
 				'type'    => 'radio',
1539 1539
 				'choices' => array(
1540
-					'posts' => __( 'Your latest posts' ),
1541
-					'page'  => __( 'A static page' ),
1540
+					'posts' => __('Your latest posts'),
1541
+					'page'  => __('A static page'),
1542 1542
 				),
1543
-			) );
1543
+			));
1544 1544
 
1545
-			$this->add_setting( 'page_on_front', array(
1545
+			$this->add_setting('page_on_front', array(
1546 1546
 				'type'       => 'option',
1547 1547
 				'capability' => 'manage_options',
1548 1548
 			//	'theme_supports' => 'static-front-page',
1549
-			) );
1549
+			));
1550 1550
 
1551
-			$this->add_control( 'page_on_front', array(
1552
-				'label'      => __( 'Front page' ),
1551
+			$this->add_control('page_on_front', array(
1552
+				'label'      => __('Front page'),
1553 1553
 				'section'    => 'static_front_page',
1554 1554
 				'type'       => 'dropdown-pages',
1555
-			) );
1555
+			));
1556 1556
 
1557
-			$this->add_setting( 'page_for_posts', array(
1557
+			$this->add_setting('page_for_posts', array(
1558 1558
 				'type'           => 'option',
1559 1559
 				'capability'     => 'manage_options',
1560 1560
 			//	'theme_supports' => 'static-front-page',
1561
-			) );
1561
+			));
1562 1562
 
1563
-			$this->add_control( 'page_for_posts', array(
1564
-				'label'      => __( 'Posts page' ),
1563
+			$this->add_control('page_for_posts', array(
1564
+				'label'      => __('Posts page'),
1565 1565
 				'section'    => 'static_front_page',
1566 1566
 				'type'       => 'dropdown-pages',
1567
-			) );
1567
+			));
1568 1568
 		}
1569 1569
 	}
1570 1570
 
@@ -1577,7 +1577,7 @@  discard block
 block discarded – undo
1577 1577
 	 * @see add_dynamic_settings()
1578 1578
 	 */
1579 1579
 	public function register_dynamic_settings() {
1580
-		$this->add_dynamic_settings( array_keys( $this->unsanitized_post_values() ) );
1580
+		$this->add_dynamic_settings(array_keys($this->unsanitized_post_values()));
1581 1581
 	}
1582 1582
 
1583 1583
 	/**
@@ -1591,13 +1591,13 @@  discard block
 block discarded – undo
1591 1591
 	 * @param string $color
1592 1592
 	 * @return mixed
1593 1593
 	 */
1594
-	public function _sanitize_header_textcolor( $color ) {
1595
-		if ( 'blank' === $color )
1594
+	public function _sanitize_header_textcolor($color) {
1595
+		if ('blank' === $color)
1596 1596
 			return 'blank';
1597 1597
 
1598
-		$color = sanitize_hex_color_no_hash( $color );
1599
-		if ( empty( $color ) )
1600
-			$color = get_theme_support( 'custom-header', 'default-text-color' );
1598
+		$color = sanitize_hex_color_no_hash($color);
1599
+		if (empty($color))
1600
+			$color = get_theme_support('custom-header', 'default-text-color');
1601 1601
 
1602 1602
 		return $color;
1603 1603
 	}
@@ -1614,12 +1614,12 @@  discard block
 block discarded – undo
1614 1614
  * @param string $color
1615 1615
  * @return string|void
1616 1616
  */
1617
-function sanitize_hex_color( $color ) {
1618
-	if ( '' === $color )
1617
+function sanitize_hex_color($color) {
1618
+	if ('' === $color)
1619 1619
 		return '';
1620 1620
 
1621 1621
 	// 3 or 6 hex digits, or the empty string.
1622
-	if ( preg_match('|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) )
1622
+	if (preg_match('|^#([A-Fa-f0-9]{3}){1,2}$|', $color))
1623 1623
 		return $color;
1624 1624
 }
1625 1625
 
@@ -1637,13 +1637,13 @@  discard block
 block discarded – undo
1637 1637
  * @param string $color
1638 1638
  * @return string|null
1639 1639
  */
1640
-function sanitize_hex_color_no_hash( $color ) {
1641
-	$color = ltrim( $color, '#' );
1640
+function sanitize_hex_color_no_hash($color) {
1641
+	$color = ltrim($color, '#');
1642 1642
 
1643
-	if ( '' === $color )
1643
+	if ('' === $color)
1644 1644
 		return '';
1645 1645
 
1646
-	return sanitize_hex_color( '#' . $color ) ? $color : null;
1646
+	return sanitize_hex_color('#'.$color) ? $color : null;
1647 1647
 }
1648 1648
 
1649 1649
 /**
@@ -1657,9 +1657,9 @@  discard block
 block discarded – undo
1657 1657
  * @param string $color
1658 1658
  * @return string
1659 1659
  */
1660
-function maybe_hash_hex_color( $color ) {
1661
-	if ( $unhashed = sanitize_hex_color_no_hash( $color ) )
1662
-		return '#' . $unhashed;
1660
+function maybe_hash_hex_color($color) {
1661
+	if ($unhashed = sanitize_hex_color_no_hash($color))
1662
+		return '#'.$unhashed;
1663 1663
 
1664 1664
 	return $color;
1665 1665
 }
Please login to merge, or discard this patch.
Braces   +31 added lines, -21 removed lines patch added patch discarded remove patch
@@ -441,8 +441,9 @@  discard block
 block discarded – undo
441 441
 		 */
442 442
 		do_action( 'customize_register', $this );
443 443
 
444
-		if ( $this->is_preview() && ! is_admin() )
445
-			$this->customize_preview_init();
444
+		if ( $this->is_preview() && ! is_admin() ) {
445
+					$this->customize_preview_init();
446
+		}
446 447
 	}
447 448
 
448 449
 	/**
@@ -457,8 +458,9 @@  discard block
 block discarded – undo
457 458
 	 * @return int
458 459
 	 */
459 460
 	public function wp_redirect_status( $status ) {
460
-		if ( $this->is_preview() && ! is_admin() )
461
-			return 200;
461
+		if ( $this->is_preview() && ! is_admin() ) {
462
+					return 200;
463
+		}
462 464
 
463 465
 		return $status;
464 466
 	}
@@ -1056,8 +1058,9 @@  discard block
 block discarded – undo
1056 1058
 	 * @return WP_Customize_Section|void The section, if set.
1057 1059
 	 */
1058 1060
 	public function get_section( $id ) {
1059
-		if ( isset( $this->sections[ $id ] ) )
1060
-			return $this->sections[ $id ];
1061
+		if ( isset( $this->sections[ $id ] ) ) {
1062
+					return $this->sections[ $id ];
1063
+		}
1061 1064
 	}
1062 1065
 
1063 1066
 	/**
@@ -1127,8 +1130,9 @@  discard block
 block discarded – undo
1127 1130
 	 * @return WP_Customize_Control|void The control object, if set.
1128 1131
 	 */
1129 1132
 	public function get_control( $id ) {
1130
-		if ( isset( $this->controls[ $id ] ) )
1131
-			return $this->controls[ $id ];
1133
+		if ( isset( $this->controls[ $id ] ) ) {
1134
+					return $this->controls[ $id ];
1135
+		}
1132 1136
 	}
1133 1137
 
1134 1138
 	/**
@@ -1592,12 +1596,14 @@  discard block
 block discarded – undo
1592 1596
 	 * @return mixed
1593 1597
 	 */
1594 1598
 	public function _sanitize_header_textcolor( $color ) {
1595
-		if ( 'blank' === $color )
1596
-			return 'blank';
1599
+		if ( 'blank' === $color ) {
1600
+					return 'blank';
1601
+		}
1597 1602
 
1598 1603
 		$color = sanitize_hex_color_no_hash( $color );
1599
-		if ( empty( $color ) )
1600
-			$color = get_theme_support( 'custom-header', 'default-text-color' );
1604
+		if ( empty( $color ) ) {
1605
+					$color = get_theme_support( 'custom-header', 'default-text-color' );
1606
+		}
1601 1607
 
1602 1608
 		return $color;
1603 1609
 	}
@@ -1615,13 +1621,15 @@  discard block
 block discarded – undo
1615 1621
  * @return string|void
1616 1622
  */
1617 1623
 function sanitize_hex_color( $color ) {
1618
-	if ( '' === $color )
1619
-		return '';
1624
+	if ( '' === $color ) {
1625
+			return '';
1626
+	}
1620 1627
 
1621 1628
 	// 3 or 6 hex digits, or the empty string.
1622
-	if ( preg_match('|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) )
1623
-		return $color;
1624
-}
1629
+	if ( preg_match('|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) {
1630
+			return $color;
1631
+	}
1632
+	}
1625 1633
 
1626 1634
 /**
1627 1635
  * Sanitizes a hex color without a hash. Use sanitize_hex_color() when possible.
@@ -1640,8 +1648,9 @@  discard block
 block discarded – undo
1640 1648
 function sanitize_hex_color_no_hash( $color ) {
1641 1649
 	$color = ltrim( $color, '#' );
1642 1650
 
1643
-	if ( '' === $color )
1644
-		return '';
1651
+	if ( '' === $color ) {
1652
+			return '';
1653
+	}
1645 1654
 
1646 1655
 	return sanitize_hex_color( '#' . $color ) ? $color : null;
1647 1656
 }
@@ -1658,8 +1667,9 @@  discard block
 block discarded – undo
1658 1667
  * @return string
1659 1668
  */
1660 1669
 function maybe_hash_hex_color( $color ) {
1661
-	if ( $unhashed = sanitize_hex_color_no_hash( $color ) )
1662
-		return '#' . $unhashed;
1670
+	if ( $unhashed = sanitize_hex_color_no_hash( $color ) ) {
1671
+			return '#' . $unhashed;
1672
+	}
1663 1673
 
1664 1674
 	return $color;
1665 1675
 }
Please login to merge, or discard this patch.
src/wp-includes/class-wp-customize-nav-menus.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 * @since 4.3.0
43 43
 	 * @access public
44 44
 	 *
45
-	 * @param object $manager An instance of the WP_Customize_Manager class.
45
+	 * @param WP_Customize_Manager $manager An instance of the WP_Customize_Manager class.
46 46
 	 */
47 47
 	public function __construct( $manager ) {
48 48
 		$this->previewed_menus = array();
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
 	 *
877 877
 	 * @param string $nav_menu_content The HTML content for the navigation menu.
878 878
 	 * @param object $args             An object containing wp_nav_menu() arguments.
879
-	 * @return null
879
+	 * @return string
880 880
 	 */
881 881
 	public function filter_wp_nav_menu( $nav_menu_content, $args ) {
882 882
 		if ( ! empty( $args->can_partial_refresh ) && ! empty( $args->instance_number ) ) {
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * WordPress Customize Nav Menus classes
4
- *
5
- * @package WordPress
6
- * @subpackage Customize
7
- * @since 4.3.0
8
- */
3
+	 * WordPress Customize Nav Menus classes
4
+	 *
5
+	 * @package WordPress
6
+	 * @subpackage Customize
7
+	 * @since 4.3.0
8
+	 */
9 9
 
10 10
 /**
11 11
  * Customize Nav Menus class.
Please login to merge, or discard this patch.
Spacing   +273 added lines, -273 removed lines patch added patch discarded remove patch
@@ -44,22 +44,22 @@  discard block
 block discarded – undo
44 44
 	 *
45 45
 	 * @param object $manager An instance of the WP_Customize_Manager class.
46 46
 	 */
47
-	public function __construct( $manager ) {
47
+	public function __construct($manager) {
48 48
 		$this->previewed_menus = array();
49 49
 		$this->manager         = $manager;
50 50
 
51
-		add_action( 'wp_ajax_load-available-menu-items-customizer', array( $this, 'ajax_load_available_items' ) );
52
-		add_action( 'wp_ajax_search-available-menu-items-customizer', array( $this, 'ajax_search_available_items' ) );
53
-		add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
51
+		add_action('wp_ajax_load-available-menu-items-customizer', array($this, 'ajax_load_available_items'));
52
+		add_action('wp_ajax_search-available-menu-items-customizer', array($this, 'ajax_search_available_items'));
53
+		add_action('customize_controls_enqueue_scripts', array($this, 'enqueue_scripts'));
54 54
 
55 55
 		// Needs to run after core Navigation section is set up.
56
-		add_action( 'customize_register', array( $this, 'customize_register' ), 11 );
56
+		add_action('customize_register', array($this, 'customize_register'), 11);
57 57
 
58
-		add_filter( 'customize_dynamic_setting_args', array( $this, 'filter_dynamic_setting_args' ), 10, 2 );
59
-		add_filter( 'customize_dynamic_setting_class', array( $this, 'filter_dynamic_setting_class' ), 10, 3 );
60
-		add_action( 'customize_controls_print_footer_scripts', array( $this, 'print_templates' ) );
61
-		add_action( 'customize_controls_print_footer_scripts', array( $this, 'available_items_template' ) );
62
-		add_action( 'customize_preview_init', array( $this, 'customize_preview_init' ) );
58
+		add_filter('customize_dynamic_setting_args', array($this, 'filter_dynamic_setting_args'), 10, 2);
59
+		add_filter('customize_dynamic_setting_class', array($this, 'filter_dynamic_setting_class'), 10, 3);
60
+		add_action('customize_controls_print_footer_scripts', array($this, 'print_templates'));
61
+		add_action('customize_controls_print_footer_scripts', array($this, 'available_items_template'));
62
+		add_action('customize_preview_init', array($this, 'customize_preview_init'));
63 63
 	}
64 64
 
65 65
 	/**
@@ -69,25 +69,25 @@  discard block
 block discarded – undo
69 69
 	 * @access public
70 70
 	 */
71 71
 	public function ajax_load_available_items() {
72
-		check_ajax_referer( 'customize-menus', 'customize-menus-nonce' );
72
+		check_ajax_referer('customize-menus', 'customize-menus-nonce');
73 73
 
74
-		if ( ! current_user_can( 'edit_theme_options' ) ) {
74
+		if ( ! current_user_can('edit_theme_options')) {
75 75
 			wp_die( -1 );
76 76
 		}
77 77
 
78
-		if ( empty( $_POST['type'] ) || empty( $_POST['object'] ) ) {
79
-			wp_send_json_error( 'nav_menus_missing_type_or_object_parameter' );
78
+		if (empty($_POST['type']) || empty($_POST['object'])) {
79
+			wp_send_json_error('nav_menus_missing_type_or_object_parameter');
80 80
 		}
81 81
 
82
-		$type = sanitize_key( $_POST['type'] );
83
-		$object = sanitize_key( $_POST['object'] );
84
-		$page = empty( $_POST['page'] ) ? 0 : absint( $_POST['page'] );
85
-		$items = $this->load_available_items_query( $type, $object, $page );
82
+		$type = sanitize_key($_POST['type']);
83
+		$object = sanitize_key($_POST['object']);
84
+		$page = empty($_POST['page']) ? 0 : absint($_POST['page']);
85
+		$items = $this->load_available_items_query($type, $object, $page);
86 86
 
87
-		if ( is_wp_error( $items ) ) {
88
-			wp_send_json_error( $items->get_error_code() );
87
+		if (is_wp_error($items)) {
88
+			wp_send_json_error($items->get_error_code());
89 89
 		} else {
90
-			wp_send_json_success( array( 'items' => $items ) );
90
+			wp_send_json_success(array('items' => $items));
91 91
 		}
92 92
 	}
93 93
 
@@ -103,51 +103,51 @@  discard block
 block discarded – undo
103 103
 	 * @param int    $page   Optional. The page number used to generate the query offset. Default is '0'.
104 104
 	 * @return WP_Error|array Returns either a WP_Error object or an array of menu items.
105 105
 	 */
106
-	public function load_available_items_query( $type = 'post_type', $object = 'page', $page = 0 ) {
106
+	public function load_available_items_query($type = 'post_type', $object = 'page', $page = 0) {
107 107
 		$items = array();
108 108
 
109
-		if ( 'post_type' === $type ) {
110
-			if ( ! get_post_type_object( $object ) ) {
111
-				return new WP_Error( 'nav_menus_invalid_post_type' );
109
+		if ('post_type' === $type) {
110
+			if ( ! get_post_type_object($object)) {
111
+				return new WP_Error('nav_menus_invalid_post_type');
112 112
 			}
113 113
 
114
-			if ( 0 === $page && 'page' === $object ) {
114
+			if (0 === $page && 'page' === $object) {
115 115
 				// Add "Home" link. Treat as a page, but switch to custom on add.
116 116
 				$items[] = array(
117 117
 					'id'         => 'home',
118
-					'title'      => _x( 'Home', 'nav menu home label' ),
118
+					'title'      => _x('Home', 'nav menu home label'),
119 119
 					'type'       => 'custom',
120
-					'type_label' => __( 'Custom Link' ),
120
+					'type_label' => __('Custom Link'),
121 121
 					'object'     => '',
122 122
 					'url'        => home_url(),
123 123
 				);
124 124
 			}
125 125
 
126
-			$posts = get_posts( array(
126
+			$posts = get_posts(array(
127 127
 				'numberposts' => 10,
128 128
 				'offset'      => 10 * $page,
129 129
 				'orderby'     => 'date',
130 130
 				'order'       => 'DESC',
131 131
 				'post_type'   => $object,
132
-			) );
133
-			foreach ( $posts as $post ) {
132
+			));
133
+			foreach ($posts as $post) {
134 134
 				$post_title = $post->post_title;
135
-				if ( '' === $post_title ) {
135
+				if ('' === $post_title) {
136 136
 					/* translators: %d: ID of a post */
137
-					$post_title = sprintf( __( '#%d (no title)' ), $post->ID );
137
+					$post_title = sprintf(__('#%d (no title)'), $post->ID);
138 138
 				}
139 139
 				$items[] = array(
140 140
 					'id'         => "post-{$post->ID}",
141
-					'title'      => html_entity_decode( $post_title, ENT_QUOTES, get_bloginfo( 'charset' ) ),
141
+					'title'      => html_entity_decode($post_title, ENT_QUOTES, get_bloginfo('charset')),
142 142
 					'type'       => 'post_type',
143
-					'type_label' => get_post_type_object( $post->post_type )->labels->singular_name,
143
+					'type_label' => get_post_type_object($post->post_type)->labels->singular_name,
144 144
 					'object'     => $post->post_type,
145
-					'object_id'  => intval( $post->ID ),
146
-					'url'        => get_permalink( intval( $post->ID ) ),
145
+					'object_id'  => intval($post->ID),
146
+					'url'        => get_permalink(intval($post->ID)),
147 147
 				);
148 148
 			}
149
-		} elseif ( 'taxonomy' === $type ) {
150
-			$terms = get_terms( $object, array(
149
+		} elseif ('taxonomy' === $type) {
150
+			$terms = get_terms($object, array(
151 151
 				'child_of'     => 0,
152 152
 				'exclude'      => '',
153 153
 				'hide_empty'   => false,
@@ -158,20 +158,20 @@  discard block
 block discarded – undo
158 158
 				'order'        => 'DESC',
159 159
 				'orderby'      => 'count',
160 160
 				'pad_counts'   => false,
161
-			) );
162
-			if ( is_wp_error( $terms ) ) {
161
+			));
162
+			if (is_wp_error($terms)) {
163 163
 				return $terms;
164 164
 			}
165 165
 
166
-			foreach ( $terms as $term ) {
166
+			foreach ($terms as $term) {
167 167
 				$items[] = array(
168 168
 					'id'         => "term-{$term->term_id}",
169
-					'title'      => html_entity_decode( $term->name, ENT_QUOTES, get_bloginfo( 'charset' ) ),
169
+					'title'      => html_entity_decode($term->name, ENT_QUOTES, get_bloginfo('charset')),
170 170
 					'type'       => 'taxonomy',
171
-					'type_label' => get_taxonomy( $term->taxonomy )->labels->singular_name,
171
+					'type_label' => get_taxonomy($term->taxonomy)->labels->singular_name,
172 172
 					'object'     => $term->taxonomy,
173
-					'object_id'  => intval( $term->term_id ),
174
-					'url'        => get_term_link( intval( $term->term_id ), $term->taxonomy ),
173
+					'object_id'  => intval($term->term_id),
174
+					'url'        => get_term_link(intval($term->term_id), $term->taxonomy),
175 175
 				);
176 176
 			}
177 177
 		}
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 		 * @param string $object The object name.
187 187
 		 * @param int    $page   The current page number.
188 188
 		 */
189
-		$items = apply_filters( 'customize_nav_menu_available_items', $items, $type, $object, $page );
189
+		$items = apply_filters('customize_nav_menu_available_items', $items, $type, $object, $page);
190 190
 
191 191
 		return $items;
192 192
 	}
@@ -198,28 +198,28 @@  discard block
 block discarded – undo
198 198
 	 * @access public
199 199
 	 */
200 200
 	public function ajax_search_available_items() {
201
-		check_ajax_referer( 'customize-menus', 'customize-menus-nonce' );
201
+		check_ajax_referer('customize-menus', 'customize-menus-nonce');
202 202
 
203
-		if ( ! current_user_can( 'edit_theme_options' ) ) {
203
+		if ( ! current_user_can('edit_theme_options')) {
204 204
 			wp_die( -1 );
205 205
 		}
206 206
 
207
-		if ( empty( $_POST['search'] ) ) {
208
-			wp_send_json_error( 'nav_menus_missing_search_parameter' );
207
+		if (empty($_POST['search'])) {
208
+			wp_send_json_error('nav_menus_missing_search_parameter');
209 209
 		}
210 210
 
211
-		$p = isset( $_POST['page'] ) ? absint( $_POST['page'] ) : 0;
212
-		if ( $p < 1 ) {
211
+		$p = isset($_POST['page']) ? absint($_POST['page']) : 0;
212
+		if ($p < 1) {
213 213
 			$p = 1;
214 214
 		}
215 215
 
216
-		$s = sanitize_text_field( wp_unslash( $_POST['search'] ) );
217
-		$items = $this->search_available_items_query( array( 'pagenum' => $p, 's' => $s ) );
216
+		$s = sanitize_text_field(wp_unslash($_POST['search']));
217
+		$items = $this->search_available_items_query(array('pagenum' => $p, 's' => $s));
218 218
 
219
-		if ( empty( $items ) ) {
220
-			wp_send_json_error( array( 'message' => __( 'No results found.' ) ) );
219
+		if (empty($items)) {
220
+			wp_send_json_error(array('message' => __('No results found.')));
221 221
 		} else {
222
-			wp_send_json_success( array( 'items' => $items ) );
222
+			wp_send_json_success(array('items' => $items));
223 223
 		}
224 224
 	}
225 225
 
@@ -234,12 +234,12 @@  discard block
 block discarded – undo
234 234
 	 * @param array $args Optional. Accepts 'pagenum' and 's' (search) arguments.
235 235
 	 * @return array Menu items.
236 236
 	 */
237
-	public function search_available_items_query( $args = array() ) {
237
+	public function search_available_items_query($args = array()) {
238 238
 		$items = array();
239 239
 
240
-		$post_type_objects = get_post_types( array( 'show_in_nav_menus' => true ), 'objects' );
240
+		$post_type_objects = get_post_types(array('show_in_nav_menus' => true), 'objects');
241 241
 		$query = array(
242
-			'post_type'              => array_keys( $post_type_objects ),
242
+			'post_type'              => array_keys($post_type_objects),
243 243
 			'suppress_filters'       => true,
244 244
 			'update_post_term_cache' => false,
245 245
 			'update_post_meta_cache' => false,
@@ -247,55 +247,55 @@  discard block
 block discarded – undo
247 247
 			'posts_per_page'         => 20,
248 248
 		);
249 249
 
250
-		$args['pagenum'] = isset( $args['pagenum'] ) ? absint( $args['pagenum'] ) : 1;
251
-		$query['offset'] = $args['pagenum'] > 1 ? $query['posts_per_page'] * ( $args['pagenum'] - 1 ) : 0;
250
+		$args['pagenum'] = isset($args['pagenum']) ? absint($args['pagenum']) : 1;
251
+		$query['offset'] = $args['pagenum'] > 1 ? $query['posts_per_page'] * ($args['pagenum'] - 1) : 0;
252 252
 
253
-		if ( isset( $args['s'] ) ) {
253
+		if (isset($args['s'])) {
254 254
 			$query['s'] = $args['s'];
255 255
 		}
256 256
 
257 257
 		// Query posts.
258
-		$get_posts = new WP_Query( $query );
258
+		$get_posts = new WP_Query($query);
259 259
 
260 260
 		// Check if any posts were found.
261
-		if ( $get_posts->post_count ) {
262
-			foreach ( $get_posts->posts as $post ) {
261
+		if ($get_posts->post_count) {
262
+			foreach ($get_posts->posts as $post) {
263 263
 				$post_title = $post->post_title;
264
-				if ( '' === $post_title ) {
264
+				if ('' === $post_title) {
265 265
 					/* translators: %d: ID of a post */
266
-					$post_title = sprintf( __( '#%d (no title)' ), $post->ID );
266
+					$post_title = sprintf(__('#%d (no title)'), $post->ID);
267 267
 				}
268 268
 				$items[] = array(
269
-					'id'         => 'post-' . $post->ID,
270
-					'title'      => html_entity_decode( $post_title, ENT_QUOTES, get_bloginfo( 'charset' ) ),
269
+					'id'         => 'post-'.$post->ID,
270
+					'title'      => html_entity_decode($post_title, ENT_QUOTES, get_bloginfo('charset')),
271 271
 					'type'       => 'post_type',
272
-					'type_label' => $post_type_objects[ $post->post_type ]->labels->singular_name,
272
+					'type_label' => $post_type_objects[$post->post_type]->labels->singular_name,
273 273
 					'object'     => $post->post_type,
274
-					'object_id'  => intval( $post->ID ),
275
-					'url'        => get_permalink( intval( $post->ID ) ),
274
+					'object_id'  => intval($post->ID),
275
+					'url'        => get_permalink(intval($post->ID)),
276 276
 				);
277 277
 			}
278 278
 		}
279 279
 
280 280
 		// Query taxonomy terms.
281
-		$taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'names' );
282
-		$terms = get_terms( $taxonomies, array(
281
+		$taxonomies = get_taxonomies(array('show_in_nav_menus' => true), 'names');
282
+		$terms = get_terms($taxonomies, array(
283 283
 			'name__like' => $args['s'],
284 284
 			'number'     => 20,
285 285
 			'offset'     => 20 * ($args['pagenum'] - 1),
286
-		) );
286
+		));
287 287
 
288 288
 		// Check if any taxonomies were found.
289
-		if ( ! empty( $terms ) ) {
290
-			foreach ( $terms as $term ) {
289
+		if ( ! empty($terms)) {
290
+			foreach ($terms as $term) {
291 291
 				$items[] = array(
292
-					'id'         => 'term-' . $term->term_id,
293
-					'title'      => html_entity_decode( $term->name, ENT_QUOTES, get_bloginfo( 'charset' ) ),
292
+					'id'         => 'term-'.$term->term_id,
293
+					'title'      => html_entity_decode($term->name, ENT_QUOTES, get_bloginfo('charset')),
294 294
 					'type'       => 'taxonomy',
295
-					'type_label' => get_taxonomy( $term->taxonomy )->labels->singular_name,
295
+					'type_label' => get_taxonomy($term->taxonomy)->labels->singular_name,
296 296
 					'object'     => $term->taxonomy,
297
-					'object_id'  => intval( $term->term_id ),
298
-					'url'        => get_term_link( intval( $term->term_id ), $term->taxonomy ),
297
+					'object_id'  => intval($term->term_id),
298
+					'url'        => get_term_link(intval($term->term_id), $term->taxonomy),
299 299
 				);
300 300
 			}
301 301
 		}
@@ -310,47 +310,47 @@  discard block
 block discarded – undo
310 310
 	 * @access public
311 311
 	 */
312 312
 	public function enqueue_scripts() {
313
-		wp_enqueue_style( 'customize-nav-menus' );
314
-		wp_enqueue_script( 'customize-nav-menus' );
313
+		wp_enqueue_style('customize-nav-menus');
314
+		wp_enqueue_script('customize-nav-menus');
315 315
 
316
-		$temp_nav_menu_setting      = new WP_Customize_Nav_Menu_Setting( $this->manager, 'nav_menu[-1]' );
317
-		$temp_nav_menu_item_setting = new WP_Customize_Nav_Menu_Item_Setting( $this->manager, 'nav_menu_item[-1]' );
316
+		$temp_nav_menu_setting      = new WP_Customize_Nav_Menu_Setting($this->manager, 'nav_menu[-1]');
317
+		$temp_nav_menu_item_setting = new WP_Customize_Nav_Menu_Item_Setting($this->manager, 'nav_menu_item[-1]');
318 318
 
319 319
 		// Pass data to JS.
320 320
 		$settings = array(
321
-			'nonce'                => wp_create_nonce( 'customize-menus' ),
321
+			'nonce'                => wp_create_nonce('customize-menus'),
322 322
 			'allMenus'             => wp_get_nav_menus(),
323 323
 			'itemTypes'            => $this->available_item_types(),
324 324
 			'l10n'                 => array(
325
-				'untitled'          => _x( '(no label)', 'missing menu item navigation label' ),
326
-				'unnamed'           => _x( '(unnamed)', 'Missing menu name.' ),
327
-				'custom_label'      => __( 'Custom Link' ),
325
+				'untitled'          => _x('(no label)', 'missing menu item navigation label'),
326
+				'unnamed'           => _x('(unnamed)', 'Missing menu name.'),
327
+				'custom_label'      => __('Custom Link'),
328 328
 				/* translators: %s: Current menu location */
329
-				'menuLocation'      => __( '(Currently set to: %s)' ),
330
-				'menuNameLabel'     => __( 'Menu Name' ),
331
-				'itemAdded'         => __( 'Menu item added' ),
332
-				'itemDeleted'       => __( 'Menu item deleted' ),
333
-				'menuAdded'         => __( 'Menu created' ),
334
-				'menuDeleted'       => __( 'Menu deleted' ),
335
-				'movedUp'           => __( 'Menu item moved up' ),
336
-				'movedDown'         => __( 'Menu item moved down' ),
337
-				'movedLeft'         => __( 'Menu item moved out of submenu' ),
338
-				'movedRight'        => __( 'Menu item is now a sub-item' ),
329
+				'menuLocation'      => __('(Currently set to: %s)'),
330
+				'menuNameLabel'     => __('Menu Name'),
331
+				'itemAdded'         => __('Menu item added'),
332
+				'itemDeleted'       => __('Menu item deleted'),
333
+				'menuAdded'         => __('Menu created'),
334
+				'menuDeleted'       => __('Menu deleted'),
335
+				'movedUp'           => __('Menu item moved up'),
336
+				'movedDown'         => __('Menu item moved down'),
337
+				'movedLeft'         => __('Menu item moved out of submenu'),
338
+				'movedRight'        => __('Menu item is now a sub-item'),
339 339
 				/* translators: &#9656; is the unicode right-pointing triangle, and %s is the section title in the Customizer */
340
-				'customizingMenus'  => sprintf( __( 'Customizing &#9656; %s' ), esc_html( $this->manager->get_panel( 'nav_menus' )->title ) ),
340
+				'customizingMenus'  => sprintf(__('Customizing &#9656; %s'), esc_html($this->manager->get_panel('nav_menus')->title)),
341 341
 				/* translators: %s: title of menu item which is invalid */
342
-				'invalidTitleTpl'   => __( '%s (Invalid)' ),
342
+				'invalidTitleTpl'   => __('%s (Invalid)'),
343 343
 				/* translators: %s: title of menu item in draft status */
344
-				'pendingTitleTpl'   => __( '%s (Pending)' ),
345
-				'taxonomyTermLabel' => __( 'Taxonomy' ),
346
-				'postTypeLabel'     => __( 'Post Type' ),
347
-				'itemsFound'        => __( 'Number of items found: %d' ),
348
-				'itemsFoundMore'    => __( 'Additional items found: %d' ),
349
-				'itemsLoadingMore'  => __( 'Loading more results... please wait.' ),
350
-				'reorderModeOn'     => __( 'Reorder mode enabled' ),
351
-				'reorderModeOff'    => __( 'Reorder mode closed' ),
352
-				'reorderLabelOn'    => esc_attr__( 'Reorder menu items' ),
353
-				'reorderLabelOff'   => esc_attr__( 'Close reorder mode' ),
344
+				'pendingTitleTpl'   => __('%s (Pending)'),
345
+				'taxonomyTermLabel' => __('Taxonomy'),
346
+				'postTypeLabel'     => __('Post Type'),
347
+				'itemsFound'        => __('Number of items found: %d'),
348
+				'itemsFoundMore'    => __('Additional items found: %d'),
349
+				'itemsLoadingMore'  => __('Loading more results... please wait.'),
350
+				'reorderModeOn'     => __('Reorder mode enabled'),
351
+				'reorderModeOff'    => __('Reorder mode closed'),
352
+				'reorderLabelOn'    => esc_attr__('Reorder menu items'),
353
+				'reorderLabelOff'   => esc_attr__('Close reorder mode'),
354 354
 			),
355 355
 			'menuItemTransport'    => 'postMessage',
356 356
 			'phpIntMax'            => PHP_INT_MAX,
@@ -360,29 +360,29 @@  discard block
 block discarded – undo
360 360
 			),
361 361
 		);
362 362
 
363
-		$data = sprintf( 'var _wpCustomizeNavMenusSettings = %s;', wp_json_encode( $settings ) );
364
-		wp_scripts()->add_data( 'customize-nav-menus', 'data', $data );
363
+		$data = sprintf('var _wpCustomizeNavMenusSettings = %s;', wp_json_encode($settings));
364
+		wp_scripts()->add_data('customize-nav-menus', 'data', $data);
365 365
 
366 366
 		// This is copied from nav-menus.php, and it has an unfortunate object name of `menus`.
367 367
 		$nav_menus_l10n = array(
368 368
 			'oneThemeLocationNoMenus' => null,
369
-			'moveUp'       => __( 'Move up one' ),
370
-			'moveDown'     => __( 'Move down one' ),
371
-			'moveToTop'    => __( 'Move to the top' ),
369
+			'moveUp'       => __('Move up one'),
370
+			'moveDown'     => __('Move down one'),
371
+			'moveToTop'    => __('Move to the top'),
372 372
 			/* translators: %s: previous item name */
373
-			'moveUnder'    => __( 'Move under %s' ),
373
+			'moveUnder'    => __('Move under %s'),
374 374
 			/* translators: %s: previous item name */
375
-			'moveOutFrom'  => __( 'Move out from under %s' ),
375
+			'moveOutFrom'  => __('Move out from under %s'),
376 376
 			/* translators: %s: previous item name */
377
-			'under'        => __( 'Under %s' ),
377
+			'under'        => __('Under %s'),
378 378
 			/* translators: %s: previous item name */
379
-			'outFrom'      => __( 'Out from under %s' ),
379
+			'outFrom'      => __('Out from under %s'),
380 380
 			/* translators: 1: item name, 2: item position, 3: total number of items */
381
-			'menuFocus'    => __( '%1$s. Menu item %2$d of %3$d.' ),
381
+			'menuFocus'    => __('%1$s. Menu item %2$d of %3$d.'),
382 382
 			/* translators: 1: item name, 2: item position, 3: parent item name */
383
-			'subMenuFocus' => __( '%1$s. Sub item number %2$d under %3$s.' ),
383
+			'subMenuFocus' => __('%1$s. Sub item number %2$d under %3$s.'),
384 384
 		);
385
-		wp_localize_script( 'nav-menu', 'menus', $nav_menus_l10n );
385
+		wp_localize_script('nav-menu', 'menus', $nav_menus_l10n);
386 386
 	}
387 387
 
388 388
 	/**
@@ -399,12 +399,12 @@  discard block
 block discarded – undo
399 399
 	 * @param string      $setting_id   ID for dynamic setting, usually coming from `$_POST['customized']`.
400 400
 	 * @return array|false
401 401
 	 */
402
-	public function filter_dynamic_setting_args( $setting_args, $setting_id ) {
403
-		if ( preg_match( WP_Customize_Nav_Menu_Setting::ID_PATTERN, $setting_id ) ) {
402
+	public function filter_dynamic_setting_args($setting_args, $setting_id) {
403
+		if (preg_match(WP_Customize_Nav_Menu_Setting::ID_PATTERN, $setting_id)) {
404 404
 			$setting_args = array(
405 405
 				'type' => WP_Customize_Nav_Menu_Setting::TYPE,
406 406
 			);
407
-		} elseif ( preg_match( WP_Customize_Nav_Menu_Item_Setting::ID_PATTERN, $setting_id ) ) {
407
+		} elseif (preg_match(WP_Customize_Nav_Menu_Item_Setting::ID_PATTERN, $setting_id)) {
408 408
 			$setting_args = array(
409 409
 				'type' => WP_Customize_Nav_Menu_Item_Setting::TYPE,
410 410
 			);
@@ -423,12 +423,12 @@  discard block
 block discarded – undo
423 423
 	 * @param array  $setting_args  WP_Customize_Setting or a subclass.
424 424
 	 * @return string
425 425
 	 */
426
-	public function filter_dynamic_setting_class( $setting_class, $setting_id, $setting_args ) {
427
-		unset( $setting_id );
426
+	public function filter_dynamic_setting_class($setting_class, $setting_id, $setting_args) {
427
+		unset($setting_id);
428 428
 
429
-		if ( ! empty( $setting_args['type'] ) && WP_Customize_Nav_Menu_Setting::TYPE === $setting_args['type'] ) {
429
+		if ( ! empty($setting_args['type']) && WP_Customize_Nav_Menu_Setting::TYPE === $setting_args['type']) {
430 430
 			$setting_class = 'WP_Customize_Nav_Menu_Setting';
431
-		} elseif ( ! empty( $setting_args['type'] ) && WP_Customize_Nav_Menu_Item_Setting::TYPE === $setting_args['type'] ) {
431
+		} elseif ( ! empty($setting_args['type']) && WP_Customize_Nav_Menu_Item_Setting::TYPE === $setting_args['type']) {
432 432
 			$setting_class = 'WP_Customize_Nav_Menu_Item_Setting';
433 433
 		}
434 434
 		return $setting_class;
@@ -443,141 +443,141 @@  discard block
 block discarded – undo
443 443
 	public function customize_register() {
444 444
 
445 445
 		// Require JS-rendered control types.
446
-		$this->manager->register_panel_type( 'WP_Customize_Nav_Menus_Panel' );
447
-		$this->manager->register_control_type( 'WP_Customize_Nav_Menu_Control' );
448
-		$this->manager->register_control_type( 'WP_Customize_Nav_Menu_Name_Control' );
449
-		$this->manager->register_control_type( 'WP_Customize_Nav_Menu_Auto_Add_Control' );
450
-		$this->manager->register_control_type( 'WP_Customize_Nav_Menu_Item_Control' );
446
+		$this->manager->register_panel_type('WP_Customize_Nav_Menus_Panel');
447
+		$this->manager->register_control_type('WP_Customize_Nav_Menu_Control');
448
+		$this->manager->register_control_type('WP_Customize_Nav_Menu_Name_Control');
449
+		$this->manager->register_control_type('WP_Customize_Nav_Menu_Auto_Add_Control');
450
+		$this->manager->register_control_type('WP_Customize_Nav_Menu_Item_Control');
451 451
 
452 452
 		// Create a panel for Menus.
453
-		$description = '<p>' . __( 'This panel is used for managing navigation menus for content you have already published on your site. You can create menus and add items for existing content such as pages, posts, categories, tags, formats, or custom links.' ) . '</p>';
454
-		if ( current_theme_supports( 'widgets' ) ) {
455
-			$description .= '<p>' . sprintf( __( 'Menus can be displayed in locations defined by your theme or in <a href="%s">widget areas</a> by adding a &#8220;Custom Menu&#8221; widget.' ), "javascript:wp.customize.panel( 'widgets' ).focus();" ) . '</p>';
453
+		$description = '<p>'.__('This panel is used for managing navigation menus for content you have already published on your site. You can create menus and add items for existing content such as pages, posts, categories, tags, formats, or custom links.').'</p>';
454
+		if (current_theme_supports('widgets')) {
455
+			$description .= '<p>'.sprintf(__('Menus can be displayed in locations defined by your theme or in <a href="%s">widget areas</a> by adding a &#8220;Custom Menu&#8221; widget.'), "javascript:wp.customize.panel( 'widgets' ).focus();").'</p>';
456 456
 		} else {
457
-			$description .= '<p>' . __( 'Menus can be displayed in locations defined by your theme.' ) . '</p>';
457
+			$description .= '<p>'.__('Menus can be displayed in locations defined by your theme.').'</p>';
458 458
 		}
459
-		$this->manager->add_panel( new WP_Customize_Nav_Menus_Panel( $this->manager, 'nav_menus', array(
460
-			'title'       => __( 'Menus' ),
459
+		$this->manager->add_panel(new WP_Customize_Nav_Menus_Panel($this->manager, 'nav_menus', array(
460
+			'title'       => __('Menus'),
461 461
 			'description' => $description,
462 462
 			'priority'    => 100,
463 463
 			// 'theme_supports' => 'menus|widgets', @todo allow multiple theme supports
464
-		) ) );
464
+		)));
465 465
 		$menus = wp_get_nav_menus();
466 466
 
467 467
 		// Menu loactions.
468 468
 		$locations     = get_registered_nav_menus();
469
-		$num_locations = count( array_keys( $locations ) );
470
-		$description   = '<p>' . sprintf( _n( 'Your theme contains %s menu location. Select which menu you would like to use.', 'Your theme contains %s menu locations. Select which menu appears in each location.', $num_locations ), number_format_i18n( $num_locations ) );
471
-		$description  .= '</p><p>' . __( 'You can also place menus in widget areas with the Custom Menu widget.' ) . '</p>';
469
+		$num_locations = count(array_keys($locations));
470
+		$description   = '<p>'.sprintf(_n('Your theme contains %s menu location. Select which menu you would like to use.', 'Your theme contains %s menu locations. Select which menu appears in each location.', $num_locations), number_format_i18n($num_locations));
471
+		$description  .= '</p><p>'.__('You can also place menus in widget areas with the Custom Menu widget.').'</p>';
472 472
 
473
-		$this->manager->add_section( 'menu_locations', array(
474
-			'title'       => __( 'Menu Locations' ),
473
+		$this->manager->add_section('menu_locations', array(
474
+			'title'       => __('Menu Locations'),
475 475
 			'panel'       => 'nav_menus',
476 476
 			'priority'    => 5,
477 477
 			'description' => $description,
478
-		) );
478
+		));
479 479
 
480
-		$choices = array( '0' => __( '&mdash; Select &mdash;' ) );
481
-		foreach ( $menus as $menu ) {
482
-			$choices[ $menu->term_id ] = wp_html_excerpt( $menu->name, 40, '&hellip;' );
480
+		$choices = array('0' => __('&mdash; Select &mdash;'));
481
+		foreach ($menus as $menu) {
482
+			$choices[$menu->term_id] = wp_html_excerpt($menu->name, 40, '&hellip;');
483 483
 		}
484 484
 
485
-		foreach ( $locations as $location => $description ) {
485
+		foreach ($locations as $location => $description) {
486 486
 			$setting_id = "nav_menu_locations[{$location}]";
487 487
 
488
-			$setting = $this->manager->get_setting( $setting_id );
489
-			if ( $setting ) {
488
+			$setting = $this->manager->get_setting($setting_id);
489
+			if ($setting) {
490 490
 				$setting->transport = 'postMessage';
491
-				remove_filter( "customize_sanitize_{$setting_id}", 'absint' );
492
-				add_filter( "customize_sanitize_{$setting_id}", array( $this, 'intval_base10' ) );
491
+				remove_filter("customize_sanitize_{$setting_id}", 'absint');
492
+				add_filter("customize_sanitize_{$setting_id}", array($this, 'intval_base10'));
493 493
 			} else {
494
-				$this->manager->add_setting( $setting_id, array(
495
-					'sanitize_callback' => array( $this, 'intval_base10' ),
494
+				$this->manager->add_setting($setting_id, array(
495
+					'sanitize_callback' => array($this, 'intval_base10'),
496 496
 					'theme_supports'    => 'menus',
497 497
 					'type'              => 'theme_mod',
498 498
 					'transport'         => 'postMessage',
499 499
 					'default'           => 0,
500
-				) );
500
+				));
501 501
 			}
502 502
 
503
-			$this->manager->add_control( new WP_Customize_Nav_Menu_Location_Control( $this->manager, $setting_id, array(
503
+			$this->manager->add_control(new WP_Customize_Nav_Menu_Location_Control($this->manager, $setting_id, array(
504 504
 				'label'       => $description,
505 505
 				'location_id' => $location,
506 506
 				'section'     => 'menu_locations',
507 507
 				'choices'     => $choices,
508
-			) ) );
508
+			)));
509 509
 		}
510 510
 
511 511
 		// Register each menu as a Customizer section, and add each menu item to each menu.
512
-		foreach ( $menus as $menu ) {
512
+		foreach ($menus as $menu) {
513 513
 			$menu_id = $menu->term_id;
514 514
 
515 515
 			// Create a section for each menu.
516
-			$section_id = 'nav_menu[' . $menu_id . ']';
517
-			$this->manager->add_section( new WP_Customize_Nav_Menu_Section( $this->manager, $section_id, array(
518
-				'title'     => html_entity_decode( $menu->name, ENT_QUOTES, get_bloginfo( 'charset' ) ),
516
+			$section_id = 'nav_menu['.$menu_id.']';
517
+			$this->manager->add_section(new WP_Customize_Nav_Menu_Section($this->manager, $section_id, array(
518
+				'title'     => html_entity_decode($menu->name, ENT_QUOTES, get_bloginfo('charset')),
519 519
 				'priority'  => 10,
520 520
 				'panel'     => 'nav_menus',
521
-			) ) );
521
+			)));
522 522
 
523
-			$nav_menu_setting_id = 'nav_menu[' . $menu_id . ']';
524
-			$this->manager->add_setting( new WP_Customize_Nav_Menu_Setting( $this->manager, $nav_menu_setting_id ) );
523
+			$nav_menu_setting_id = 'nav_menu['.$menu_id.']';
524
+			$this->manager->add_setting(new WP_Customize_Nav_Menu_Setting($this->manager, $nav_menu_setting_id));
525 525
 
526 526
 			// Add the menu contents.
527
-			$menu_items = (array) wp_get_nav_menu_items( $menu_id );
527
+			$menu_items = (array) wp_get_nav_menu_items($menu_id);
528 528
 
529
-			foreach ( array_values( $menu_items ) as $i => $item ) {
529
+			foreach (array_values($menu_items) as $i => $item) {
530 530
 
531 531
 				// Create a setting for each menu item (which doesn't actually manage data, currently).
532
-				$menu_item_setting_id = 'nav_menu_item[' . $item->ID . ']';
532
+				$menu_item_setting_id = 'nav_menu_item['.$item->ID.']';
533 533
 
534 534
 				$value = (array) $item;
535 535
 				$value['nav_menu_term_id'] = $menu_id;
536
-				$this->manager->add_setting( new WP_Customize_Nav_Menu_Item_Setting( $this->manager, $menu_item_setting_id, array(
536
+				$this->manager->add_setting(new WP_Customize_Nav_Menu_Item_Setting($this->manager, $menu_item_setting_id, array(
537 537
 					'value' => $value,
538
-				) ) );
538
+				)));
539 539
 
540 540
 				// Create a control for each menu item.
541
-				$this->manager->add_control( new WP_Customize_Nav_Menu_Item_Control( $this->manager, $menu_item_setting_id, array(
541
+				$this->manager->add_control(new WP_Customize_Nav_Menu_Item_Control($this->manager, $menu_item_setting_id, array(
542 542
 					'label'    => $item->title,
543 543
 					'section'  => $section_id,
544 544
 					'priority' => 10 + $i,
545
-				) ) );
545
+				)));
546 546
 			}
547 547
 
548 548
 			// Note: other controls inside of this section get added dynamically in JS via the MenuSection.ready() function.
549 549
 		}
550 550
 
551 551
 		// Add the add-new-menu section and controls.
552
-		$this->manager->add_section( new WP_Customize_New_Menu_Section( $this->manager, 'add_menu', array(
553
-			'title'    => __( 'Add a Menu' ),
552
+		$this->manager->add_section(new WP_Customize_New_Menu_Section($this->manager, 'add_menu', array(
553
+			'title'    => __('Add a Menu'),
554 554
 			'panel'    => 'nav_menus',
555 555
 			'priority' => 999,
556
-		) ) );
556
+		)));
557 557
 
558
-		$this->manager->add_setting( 'new_menu_name', array(
558
+		$this->manager->add_setting('new_menu_name', array(
559 559
 			'type'      => 'new_menu',
560 560
 			'default'   => '',
561 561
 			'transport' => 'postMessage',
562
-		) );
562
+		));
563 563
 
564
-		$this->manager->add_control( 'new_menu_name', array(
564
+		$this->manager->add_control('new_menu_name', array(
565 565
 			'label'       => '',
566 566
 			'section'     => 'add_menu',
567 567
 			'type'        => 'text',
568 568
 			'input_attrs' => array(
569 569
 				'class'       => 'menu-name-field',
570
-				'placeholder' => __( 'New menu name' ),
570
+				'placeholder' => __('New menu name'),
571 571
 			),
572
-		) );
572
+		));
573 573
 
574
-		$this->manager->add_setting( 'create_new_menu', array(
574
+		$this->manager->add_setting('create_new_menu', array(
575 575
 			'type' => 'new_menu',
576
-		) );
576
+		));
577 577
 
578
-		$this->manager->add_control( new WP_Customize_New_Menu_Control( $this->manager, 'create_new_menu', array(
578
+		$this->manager->add_control(new WP_Customize_New_Menu_Control($this->manager, 'create_new_menu', array(
579 579
 			'section' => 'add_menu',
580
-		) ) );
580
+		)));
581 581
 	}
582 582
 
583 583
 	/**
@@ -592,8 +592,8 @@  discard block
 block discarded – undo
592 592
 	 * @param mixed $value Number to convert.
593 593
 	 * @return int Integer.
594 594
 	 */
595
-	public function intval_base10( $value ) {
596
-		return intval( $value, 10 );
595
+	public function intval_base10($value) {
596
+		return intval($value, 10);
597 597
 	}
598 598
 
599 599
 	/**
@@ -607,9 +607,9 @@  discard block
 block discarded – undo
607 607
 	public function available_item_types() {
608 608
 		$item_types = array();
609 609
 
610
-		$post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'objects' );
611
-		if ( $post_types ) {
612
-			foreach ( $post_types as $slug => $post_type ) {
610
+		$post_types = get_post_types(array('show_in_nav_menus' => true), 'objects');
611
+		if ($post_types) {
612
+			foreach ($post_types as $slug => $post_type) {
613 613
 				$item_types[] = array(
614 614
 					'title'  => $post_type->labels->singular_name,
615 615
 					'type'   => 'post_type',
@@ -618,10 +618,10 @@  discard block
 block discarded – undo
618 618
 			}
619 619
 		}
620 620
 
621
-		$taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'objects' );
622
-		if ( $taxonomies ) {
623
-			foreach ( $taxonomies as $slug => $taxonomy ) {
624
-				if ( 'post_format' === $taxonomy && ! current_theme_supports( 'post-formats' ) ) {
621
+		$taxonomies = get_taxonomies(array('show_in_nav_menus' => true), 'objects');
622
+		if ($taxonomies) {
623
+			foreach ($taxonomies as $slug => $taxonomy) {
624
+				if ('post_format' === $taxonomy && ! current_theme_supports('post-formats')) {
625 625
 					continue;
626 626
 				}
627 627
 				$item_types[] = array(
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
 		 *
640 640
 		 * @param array $item_types Custom menu item types.
641 641
 		 */
642
-		$item_types = apply_filters( 'customize_nav_menu_available_item_types', $item_types );
642
+		$item_types = apply_filters('customize_nav_menu_available_item_types', $item_types);
643 643
 
644 644
 		return $item_types;
645 645
 	}
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
 						<button type="button" class="not-a-button item-add">
666 666
 							<span class="screen-reader-text"><?php
667 667
 								/* translators: 1: Title of a menu item, 2: Type of a menu item */
668
-								printf( __( 'Add to menu: %1$s (%2$s)' ), '{{ data.title || wp.customize.Menus.data.l10n.untitled }}', '{{ data.type_label }}' );
668
+								printf(__('Add to menu: %1$s (%2$s)'), '{{ data.title || wp.customize.Menus.data.l10n.untitled }}', '{{ data.type_label }}');
669 669
 							?></span>
670 670
 						</button>
671 671
 					</div>
@@ -678,10 +678,10 @@  discard block
 block discarded – undo
678 678
 				<?php
679 679
 				printf(
680 680
 					'<button type="button" class="menus-move-up">%1$s</button><button type="button" class="menus-move-down">%2$s</button><button type="button" class="menus-move-left">%3$s</button><button type="button" class="menus-move-right">%4$s</button>',
681
-					__( 'Move up' ),
682
-					__( 'Move down' ),
683
-					__( 'Move one level up' ),
684
-					__( 'Move one level down' )
681
+					__('Move up'),
682
+					__('Move down'),
683
+					__('Move one level up'),
684
+					__('Move one level down')
685 685
 				);
686 686
 				?>
687 687
 			</div>
@@ -700,33 +700,33 @@  discard block
 block discarded – undo
700 700
 		<div id="available-menu-items" class="accordion-container">
701 701
 			<div class="customize-section-title">
702 702
 				<button type="button" class="customize-section-back" tabindex="-1">
703
-					<span class="screen-reader-text"><?php _e( 'Back' ); ?></span>
703
+					<span class="screen-reader-text"><?php _e('Back'); ?></span>
704 704
 				</button>
705 705
 				<h3>
706 706
 					<span class="customize-action">
707 707
 						<?php
708 708
 							/* translators: &#9656; is the unicode right-pointing triangle, and %s is the section title in the Customizer */
709
-							printf( __( 'Customizing &#9656; %s' ), esc_html( $this->manager->get_panel( 'nav_menus' )->title ) );
709
+							printf(__('Customizing &#9656; %s'), esc_html($this->manager->get_panel('nav_menus')->title));
710 710
 						?>
711 711
 					</span>
712
-					<?php _e( 'Add Menu Items' ); ?>
712
+					<?php _e('Add Menu Items'); ?>
713 713
 				</h3>
714 714
 			</div>
715 715
 			<div id="available-menu-items-search" class="accordion-section cannot-expand">
716 716
 				<div class="accordion-section-title">
717
-					<label class="screen-reader-text" for="menu-items-search"><?php _e( 'Search Menu Items' ); ?></label>
718
-					<input type="text" id="menu-items-search" placeholder="<?php esc_attr_e( 'Search menu items&hellip;' ) ?>" aria-describedby="menu-items-search-desc" />
719
-					<p class="screen-reader-text" id="menu-items-search-desc"><?php _e( 'The search results will be updated as you type.' ); ?></p>
717
+					<label class="screen-reader-text" for="menu-items-search"><?php _e('Search Menu Items'); ?></label>
718
+					<input type="text" id="menu-items-search" placeholder="<?php esc_attr_e('Search menu items&hellip;') ?>" aria-describedby="menu-items-search-desc" />
719
+					<p class="screen-reader-text" id="menu-items-search-desc"><?php _e('The search results will be updated as you type.'); ?></p>
720 720
 					<span class="spinner"></span>
721
-					<span class="clear-results"><span class="screen-reader-text"><?php _e( 'Clear Results' ); ?></span></span>
721
+					<span class="clear-results"><span class="screen-reader-text"><?php _e('Clear Results'); ?></span></span>
722 722
 				</div>
723 723
 				<ul class="accordion-section-content" data-type="search"></ul>
724 724
 			</div>
725 725
 			<div id="new-custom-menu-item" class="accordion-section">
726 726
 				<h4 class="accordion-section-title" role="presentation">
727
-					<?php _e( 'Custom Links' ); ?>
727
+					<?php _e('Custom Links'); ?>
728 728
 					<button type="button" class="not-a-button" aria-expanded="false">
729
-						<span class="screen-reader-text"><?php _e( 'Toggle section: Custom Links' ); ?></span>
729
+						<span class="screen-reader-text"><?php _e('Toggle section: Custom Links'); ?></span>
730 730
 						<span class="toggle-indicator" aria-hidden="true"></span>
731 731
 					</button>
732 732
 				</h4>
@@ -734,19 +734,19 @@  discard block
 block discarded – undo
734 734
 					<input type="hidden" value="custom" id="custom-menu-item-type" name="menu-item[-1][menu-item-type]" />
735 735
 					<p id="menu-item-url-wrap">
736 736
 						<label class="howto" for="custom-menu-item-url">
737
-							<span><?php _e( 'URL' ); ?></span>
737
+							<span><?php _e('URL'); ?></span>
738 738
 							<input id="custom-menu-item-url" name="menu-item[-1][menu-item-url]" type="text" class="code menu-item-textbox" value="http://">
739 739
 						</label>
740 740
 					</p>
741 741
 					<p id="menu-item-name-wrap">
742 742
 						<label class="howto" for="custom-menu-item-name">
743
-							<span><?php _e( 'Link Text' ); ?></span>
743
+							<span><?php _e('Link Text'); ?></span>
744 744
 							<input id="custom-menu-item-name" name="menu-item[-1][menu-item-title]" type="text" class="regular-text menu-item-textbox">
745 745
 						</label>
746 746
 					</p>
747 747
 					<p class="button-controls">
748 748
 						<span class="add-to-menu">
749
-							<input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" name="add-custom-menu-item" id="custom-menu-item-submit">
749
+							<input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-custom-menu-item" id="custom-menu-item-submit">
750 750
 							<span class="spinner"></span>
751 751
 						</span>
752 752
 					</p>
@@ -754,22 +754,22 @@  discard block
 block discarded – undo
754 754
 			</div>
755 755
 			<?php
756 756
 			// Containers for per-post-type item browsing; items added with JS.
757
-			foreach ( $this->available_item_types() as $available_item_type ) {
758
-				$id = sprintf( 'available-menu-items-%s-%s', $available_item_type['type'], $available_item_type['object'] );
757
+			foreach ($this->available_item_types() as $available_item_type) {
758
+				$id = sprintf('available-menu-items-%s-%s', $available_item_type['type'], $available_item_type['object']);
759 759
 				?>
760
-				<div id="<?php echo esc_attr( $id ); ?>" class="accordion-section">
760
+				<div id="<?php echo esc_attr($id); ?>" class="accordion-section">
761 761
 					<h4 class="accordion-section-title" role="presentation">
762
-						<?php echo esc_html( $available_item_type['title'] ); ?>
762
+						<?php echo esc_html($available_item_type['title']); ?>
763 763
 						<span class="spinner"></span>
764
-						<span class="no-items"><?php _e( 'No items' ); ?></span>
764
+						<span class="no-items"><?php _e('No items'); ?></span>
765 765
 						<button type="button" class="not-a-button" aria-expanded="false">
766 766
 							<span class="screen-reader-text"><?php
767 767
 							/* translators: %s: Title of a section with menu items */
768
-							printf( __( 'Toggle section: %s' ), esc_html( $available_item_type['title'] ) ); ?></span>
768
+							printf(__('Toggle section: %s'), esc_html($available_item_type['title'])); ?></span>
769 769
 							<span class="toggle-indicator" aria-hidden="true"></span>
770 770
 						</button>
771 771
 					</h4>
772
-					<ul class="accordion-section-content" data-type="<?php echo esc_attr( $available_item_type['type'] ); ?>" data-object="<?php echo esc_attr( $available_item_type['object'] ); ?>"></ul>
772
+					<ul class="accordion-section-content" data-type="<?php echo esc_attr($available_item_type['type']); ?>" data-object="<?php echo esc_attr($available_item_type['object']); ?>"></ul>
773 773
 				</div>
774 774
 				<?php
775 775
 			}
@@ -808,12 +808,12 @@  discard block
 block discarded – undo
808 808
 	 * @access public
809 809
 	 */
810 810
 	public function customize_preview_init() {
811
-		add_action( 'template_redirect', array( $this, 'render_menu' ) );
812
-		add_action( 'wp_enqueue_scripts', array( $this, 'customize_preview_enqueue_deps' ) );
811
+		add_action('template_redirect', array($this, 'render_menu'));
812
+		add_action('wp_enqueue_scripts', array($this, 'customize_preview_enqueue_deps'));
813 813
 
814
-		if ( ! isset( $_REQUEST[ self::RENDER_QUERY_VAR ] ) ) {
815
-			add_filter( 'wp_nav_menu_args', array( $this, 'filter_wp_nav_menu_args' ), 1000 );
816
-			add_filter( 'wp_nav_menu', array( $this, 'filter_wp_nav_menu' ), 10, 2 );
814
+		if ( ! isset($_REQUEST[self::RENDER_QUERY_VAR])) {
815
+			add_filter('wp_nav_menu_args', array($this, 'filter_wp_nav_menu_args'), 1000);
816
+			add_filter('wp_nav_menu', array($this, 'filter_wp_nav_menu'), 10, 2);
817 817
 		}
818 818
 	}
819 819
 
@@ -828,41 +828,41 @@  discard block
 block discarded – undo
828 828
 	 * @param array $args An array containing wp_nav_menu() arguments.
829 829
 	 * @return array Arguments.
830 830
 	 */
831
-	public function filter_wp_nav_menu_args( $args ) {
831
+	public function filter_wp_nav_menu_args($args) {
832 832
 		$this->preview_nav_menu_instance_number += 1;
833 833
 		$args['instance_number'] = $this->preview_nav_menu_instance_number;
834 834
 
835 835
 		$can_partial_refresh = (
836
-			! empty( $args['echo'] )
836
+			! empty($args['echo'])
837 837
 			&&
838
-			( empty( $args['fallback_cb'] ) || is_string( $args['fallback_cb'] ) )
838
+			(empty($args['fallback_cb']) || is_string($args['fallback_cb']))
839 839
 			&&
840
-			( empty( $args['walker'] ) || is_string( $args['walker'] ) )
840
+			(empty($args['walker']) || is_string($args['walker']))
841 841
 			&&
842 842
 			(
843
-				! empty( $args['theme_location'] )
843
+				! empty($args['theme_location'])
844 844
 				||
845
-				( ! empty( $args['menu'] ) && ( is_numeric( $args['menu'] ) || is_object( $args['menu'] ) ) )
845
+				( ! empty($args['menu']) && (is_numeric($args['menu']) || is_object($args['menu'])))
846 846
 			)
847 847
 		);
848 848
 		$args['can_partial_refresh'] = $can_partial_refresh;
849 849
 
850 850
 		$hashed_args = $args;
851 851
 
852
-		if ( ! $can_partial_refresh ) {
852
+		if ( ! $can_partial_refresh) {
853 853
 			$hashed_args['fallback_cb'] = '';
854 854
 			$hashed_args['walker'] = '';
855 855
 		}
856 856
 
857 857
 		// Replace object menu arg with a term_id menu arg, as this exports better to JS and is easier to compare hashes.
858
-		if ( ! empty( $hashed_args['menu'] ) && is_object( $hashed_args['menu'] ) ) {
858
+		if ( ! empty($hashed_args['menu']) && is_object($hashed_args['menu'])) {
859 859
 			$hashed_args['menu'] = $hashed_args['menu']->term_id;
860 860
 		}
861 861
 
862
-		ksort( $hashed_args );
863
-		$hashed_args['args_hash'] = $this->hash_nav_menu_args( $hashed_args );
862
+		ksort($hashed_args);
863
+		$hashed_args['args_hash'] = $this->hash_nav_menu_args($hashed_args);
864 864
 
865
-		$this->preview_nav_menu_instance_args[ $this->preview_nav_menu_instance_number ] = $hashed_args;
865
+		$this->preview_nav_menu_instance_args[$this->preview_nav_menu_instance_number] = $hashed_args;
866 866
 		return $args;
867 867
 	}
868 868
 
@@ -878,11 +878,11 @@  discard block
 block discarded – undo
878 878
 	 * @param object $args             An object containing wp_nav_menu() arguments.
879 879
 	 * @return null
880 880
 	 */
881
-	public function filter_wp_nav_menu( $nav_menu_content, $args ) {
882
-		if ( ! empty( $args->can_partial_refresh ) && ! empty( $args->instance_number ) ) {
881
+	public function filter_wp_nav_menu($nav_menu_content, $args) {
882
+		if ( ! empty($args->can_partial_refresh) && ! empty($args->instance_number)) {
883 883
 			$nav_menu_content = preg_replace(
884 884
 				'/(?<=class=")/',
885
-				sprintf( 'partial-refreshable-nav-menu partial-refreshable-nav-menu-%1$d ', $args->instance_number ),
885
+				sprintf('partial-refreshable-nav-menu partial-refreshable-nav-menu-%1$d ', $args->instance_number),
886 886
 				$nav_menu_content,
887 887
 				1 // Only update the class on the first element found, the menu container.
888 888
 			);
@@ -900,8 +900,8 @@  discard block
 block discarded – undo
900 900
 	 * @param array $args The arguments to hash.
901 901
 	 * @return string
902 902
 	 */
903
-	public function hash_nav_menu_args( $args ) {
904
-		return wp_hash( wp_create_nonce( self::RENDER_AJAX_ACTION ) . serialize( $args ) );
903
+	public function hash_nav_menu_args($args) {
904
+		return wp_hash(wp_create_nonce(self::RENDER_AJAX_ACTION).serialize($args));
905 905
 	}
906 906
 
907 907
 	/**
@@ -911,10 +911,10 @@  discard block
 block discarded – undo
911 911
 	 * @access public
912 912
 	 */
913 913
 	public function customize_preview_enqueue_deps() {
914
-		wp_enqueue_script( 'customize-preview-nav-menus' );
915
-		wp_enqueue_style( 'customize-preview' );
914
+		wp_enqueue_script('customize-preview-nav-menus');
915
+		wp_enqueue_style('customize-preview');
916 916
 
917
-		add_action( 'wp_print_footer_scripts', array( $this, 'export_preview_data' ) );
917
+		add_action('wp_print_footer_scripts', array($this, 'export_preview_data'));
918 918
 	}
919 919
 
920 920
 	/**
@@ -928,22 +928,22 @@  discard block
 block discarded – undo
928 928
 		// Why not wp_localize_script? Because we're not localizing, and it forces values into strings.
929 929
 		$exports = array(
930 930
 			'renderQueryVar'        => self::RENDER_QUERY_VAR,
931
-			'renderNonceValue'      => wp_create_nonce( self::RENDER_AJAX_ACTION ),
931
+			'renderNonceValue'      => wp_create_nonce(self::RENDER_AJAX_ACTION),
932 932
 			'renderNoncePostKey'    => self::RENDER_NONCE_POST_KEY,
933 933
 			'requestUri'            => '/',
934 934
 			'theme'                 => array(
935 935
 				'stylesheet' => $this->manager->get_stylesheet(),
936 936
 				'active'     => $this->manager->is_theme_active(),
937 937
 			),
938
-			'previewCustomizeNonce' => wp_create_nonce( 'preview-customize_' . $this->manager->get_stylesheet() ),
938
+			'previewCustomizeNonce' => wp_create_nonce('preview-customize_'.$this->manager->get_stylesheet()),
939 939
 			'navMenuInstanceArgs'   => $this->preview_nav_menu_instance_args,
940 940
 		);
941 941
 
942
-		if ( ! empty( $_SERVER['REQUEST_URI'] ) ) {
943
-			$exports['requestUri'] = esc_url_raw( home_url( wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
942
+		if ( ! empty($_SERVER['REQUEST_URI'])) {
943
+			$exports['requestUri'] = esc_url_raw(home_url(wp_unslash($_SERVER['REQUEST_URI'])));
944 944
 		}
945 945
 
946
-		printf( '<script>var _wpCustomizePreviewNavMenusExports = %s;</script>', wp_json_encode( $exports ) );
946
+		printf('<script>var _wpCustomizePreviewNavMenusExports = %s;</script>', wp_json_encode($exports));
947 947
 	}
948 948
 
949 949
 	/**
@@ -955,47 +955,47 @@  discard block
 block discarded – undo
955 955
 	 * @see wp_nav_menu()
956 956
 	 */
957 957
 	public function render_menu() {
958
-		if ( empty( $_POST[ self::RENDER_QUERY_VAR ] ) ) {
958
+		if (empty($_POST[self::RENDER_QUERY_VAR])) {
959 959
 			return;
960 960
 		}
961 961
 
962 962
 		$this->manager->remove_preview_signature();
963 963
 
964
-		if ( empty( $_POST[ self::RENDER_NONCE_POST_KEY ] ) ) {
965
-			wp_send_json_error( 'missing_nonce_param' );
964
+		if (empty($_POST[self::RENDER_NONCE_POST_KEY])) {
965
+			wp_send_json_error('missing_nonce_param');
966 966
 		}
967 967
 
968
-		if ( ! is_customize_preview() ) {
969
-			wp_send_json_error( 'expected_customize_preview' );
968
+		if ( ! is_customize_preview()) {
969
+			wp_send_json_error('expected_customize_preview');
970 970
 		}
971 971
 
972
-		if ( ! check_ajax_referer( self::RENDER_AJAX_ACTION, self::RENDER_NONCE_POST_KEY, false ) ) {
973
-			wp_send_json_error( 'nonce_check_fail' );
972
+		if ( ! check_ajax_referer(self::RENDER_AJAX_ACTION, self::RENDER_NONCE_POST_KEY, false)) {
973
+			wp_send_json_error('nonce_check_fail');
974 974
 		}
975 975
 
976
-		if ( ! current_user_can( 'edit_theme_options' ) ) {
977
-			wp_send_json_error( 'unauthorized' );
976
+		if ( ! current_user_can('edit_theme_options')) {
977
+			wp_send_json_error('unauthorized');
978 978
 		}
979 979
 
980
-		if ( ! isset( $_POST['wp_nav_menu_args'] ) ) {
981
-			wp_send_json_error( 'missing_param' );
980
+		if ( ! isset($_POST['wp_nav_menu_args'])) {
981
+			wp_send_json_error('missing_param');
982 982
 		}
983 983
 
984
-		if ( ! isset( $_POST['wp_nav_menu_args_hash'] ) ) {
985
-			wp_send_json_error( 'missing_param' );
984
+		if ( ! isset($_POST['wp_nav_menu_args_hash'])) {
985
+			wp_send_json_error('missing_param');
986 986
 		}
987 987
 
988
-		$wp_nav_menu_args = json_decode( wp_unslash( $_POST['wp_nav_menu_args'] ), true );
989
-		if ( ! is_array( $wp_nav_menu_args ) ) {
990
-			wp_send_json_error( 'wp_nav_menu_args_not_array' );
988
+		$wp_nav_menu_args = json_decode(wp_unslash($_POST['wp_nav_menu_args']), true);
989
+		if ( ! is_array($wp_nav_menu_args)) {
990
+			wp_send_json_error('wp_nav_menu_args_not_array');
991 991
 		}
992 992
 
993
-		$wp_nav_menu_args_hash = sanitize_text_field( wp_unslash( $_POST['wp_nav_menu_args_hash'] ) );
994
-		if ( ! hash_equals( $this->hash_nav_menu_args( $wp_nav_menu_args ), $wp_nav_menu_args_hash ) ) {
995
-			wp_send_json_error( 'wp_nav_menu_args_hash_mismatch' );
993
+		$wp_nav_menu_args_hash = sanitize_text_field(wp_unslash($_POST['wp_nav_menu_args_hash']));
994
+		if ( ! hash_equals($this->hash_nav_menu_args($wp_nav_menu_args), $wp_nav_menu_args_hash)) {
995
+			wp_send_json_error('wp_nav_menu_args_hash_mismatch');
996 996
 		}
997 997
 
998 998
 		$wp_nav_menu_args['echo'] = false;
999
-		wp_send_json_success( wp_nav_menu( $wp_nav_menu_args ) );
999
+		wp_send_json_success(wp_nav_menu($wp_nav_menu_args));
1000 1000
 	}
1001 1001
 }
Please login to merge, or discard this patch.
src/wp-includes/class-wp-customize-section.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -209,7 +209,7 @@
 block discarded – undo
209 209
 	 * @since 4.1.0
210 210
 	 * @access public
211 211
 	 *
212
-	 * @return true Always true.
212
+	 * @return boolean Always true.
213 213
 	 */
214 214
 	public function active_callback() {
215 215
 		return true;
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * WordPress Customize Section classes
4
- *
5
- * @package WordPress
6
- * @subpackage Customize
7
- * @since 3.4.0
8
- */
3
+	 * WordPress Customize Section classes
4
+	 *
5
+	 * @package WordPress
6
+	 * @subpackage Customize
7
+	 * @since 3.4.0
8
+	 */
9 9
 
10 10
 /**
11 11
  * Customize Section class.
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 	 * @see WP_Customize_Manager::render_template()
325 325
 	 */
326 326
 	public function print_template() {
327
-        ?>
327
+		?>
328 328
 		<script type="text/html" id="tmpl-customize-section-<?php echo $this->type; ?>">
329 329
 			<?php $this->render_template(); ?>
330 330
 		</script>
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -156,18 +156,18 @@  discard block
 block discarded – undo
156 156
 	 * @param string               $id      An specific ID of the section.
157 157
 	 * @param array                $args    Section arguments.
158 158
 	 */
159
-	public function __construct( $manager, $id, $args = array() ) {
160
-		$keys = array_keys( get_object_vars( $this ) );
161
-		foreach ( $keys as $key ) {
162
-			if ( isset( $args[ $key ] ) ) {
163
-				$this->$key = $args[ $key ];
159
+	public function __construct($manager, $id, $args = array()) {
160
+		$keys = array_keys(get_object_vars($this));
161
+		foreach ($keys as $key) {
162
+			if (isset($args[$key])) {
163
+				$this->$key = $args[$key];
164 164
 			}
165 165
 		}
166 166
 
167 167
 		$this->manager = $manager;
168 168
 		$this->id = $id;
169
-		if ( empty( $this->active_callback ) ) {
170
-			$this->active_callback = array( $this, 'active_callback' );
169
+		if (empty($this->active_callback)) {
170
+			$this->active_callback = array($this, 'active_callback');
171 171
 		}
172 172
 		self::$instance_count += 1;
173 173
 		$this->instance_number = self::$instance_count;
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 	 */
186 186
 	final public function active() {
187 187
 		$section = $this;
188
-		$active = call_user_func( $this->active_callback, $this );
188
+		$active = call_user_func($this->active_callback, $this);
189 189
 
190 190
 		/**
191 191
 		 * Filter response of {@see WP_Customize_Section::active()}.
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 		 * @param bool                 $active  Whether the Customizer section is active.
196 196
 		 * @param WP_Customize_Section $section {@see WP_Customize_Section} instance.
197 197
 		 */
198
-		$active = apply_filters( 'customize_section_active', $active, $section );
198
+		$active = apply_filters('customize_section_active', $active, $section);
199 199
 
200 200
 		return $active;
201 201
 	}
@@ -223,17 +223,17 @@  discard block
 block discarded – undo
223 223
 	 * @return array The array to be exported to the client as JSON.
224 224
 	 */
225 225
 	public function json() {
226
-		$array = wp_array_slice_assoc( (array) $this, array( 'id', 'description', 'priority', 'panel', 'type' ) );
227
-		$array['title'] = html_entity_decode( $this->title, ENT_QUOTES, get_bloginfo( 'charset' ) );
226
+		$array = wp_array_slice_assoc((array) $this, array('id', 'description', 'priority', 'panel', 'type'));
227
+		$array['title'] = html_entity_decode($this->title, ENT_QUOTES, get_bloginfo('charset'));
228 228
 		$array['content'] = $this->get_content();
229 229
 		$array['active'] = $this->active();
230 230
 		$array['instanceNumber'] = $this->instance_number;
231 231
 
232
-		if ( $this->panel ) {
232
+		if ($this->panel) {
233 233
 			/* translators: &#9656; is the unicode right-pointing triangle, and %s is the section title in the Customizer */
234
-			$array['customizeAction'] = sprintf( __( 'Customizing &#9656; %s' ), esc_html( $this->manager->get_panel( $this->panel )->title ) );
234
+			$array['customizeAction'] = sprintf(__('Customizing &#9656; %s'), esc_html($this->manager->get_panel($this->panel)->title));
235 235
 		} else {
236
-			$array['customizeAction'] = __( 'Customizing' );
236
+			$array['customizeAction'] = __('Customizing');
237 237
 		}
238 238
 
239 239
 		return $array;
@@ -248,11 +248,11 @@  discard block
 block discarded – undo
248 248
 	 * @return bool False if theme doesn't support the section or user doesn't have the capability.
249 249
 	 */
250 250
 	final public function check_capabilities() {
251
-		if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) ) {
251
+		if ($this->capability && ! call_user_func_array('current_user_can', (array) $this->capability)) {
252 252
 			return false;
253 253
 		}
254 254
 
255
-		if ( $this->theme_supports && ! call_user_func_array( 'current_theme_supports', (array) $this->theme_supports ) ) {
255
+		if ($this->theme_supports && ! call_user_func_array('current_theme_supports', (array) $this->theme_supports)) {
256 256
 			return false;
257 257
 		}
258 258
 
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	final public function get_content() {
270 270
 		ob_start();
271 271
 		$this->maybe_render();
272
-		return trim( ob_get_clean() );
272
+		return trim(ob_get_clean());
273 273
 	}
274 274
 
275 275
 	/**
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	 * @since 3.4.0
279 279
 	 */
280 280
 	final public function maybe_render() {
281
-		if ( ! $this->check_capabilities() ) {
281
+		if ( ! $this->check_capabilities()) {
282 282
 			return;
283 283
 		}
284 284
 
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 		 *
290 290
 		 * @param WP_Customize_Section $this WP_Customize_Section instance.
291 291
 		 */
292
-		do_action( 'customize_render_section', $this );
292
+		do_action('customize_render_section', $this);
293 293
 		/**
294 294
 		 * Fires before rendering a specific Customizer section.
295 295
 		 *
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 		 *
299 299
 		 * @since 3.4.0
300 300
 		 */
301
-		do_action( "customize_render_section_{$this->id}" );
301
+		do_action("customize_render_section_{$this->id}");
302 302
 
303 303
 		$this->render();
304 304
 	}
@@ -347,13 +347,13 @@  discard block
 block discarded – undo
347 347
 		<li id="accordion-section-{{ data.id }}" class="accordion-section control-section control-section-{{ data.type }}">
348 348
 			<h3 class="accordion-section-title" tabindex="0">
349 349
 				{{ data.title }}
350
-				<span class="screen-reader-text"><?php _e( 'Press return or enter to open' ); ?></span>
350
+				<span class="screen-reader-text"><?php _e('Press return or enter to open'); ?></span>
351 351
 			</h3>
352 352
 			<ul class="accordion-section-content">
353 353
 				<li class="customize-section-description-container">
354 354
 					<div class="customize-section-title">
355 355
 						<button class="customize-section-back" tabindex="-1">
356
-							<span class="screen-reader-text"><?php _e( 'Back' ); ?></span>
356
+							<span class="screen-reader-text"><?php _e('Back'); ?></span>
357 357
 						</button>
358 358
 						<h3>
359 359
 							<span class="customize-action">
@@ -401,44 +401,44 @@  discard block
 block discarded – undo
401 401
 	 * @access protected
402 402
 	 */
403 403
 	protected function render() {
404
-		$classes = 'accordion-section control-section control-section-' . $this->type;
404
+		$classes = 'accordion-section control-section control-section-'.$this->type;
405 405
 		?>
406
-		<li id="accordion-section-<?php echo esc_attr( $this->id ); ?>" class="<?php echo esc_attr( $classes ); ?>">
406
+		<li id="accordion-section-<?php echo esc_attr($this->id); ?>" class="<?php echo esc_attr($classes); ?>">
407 407
 			<h3 class="accordion-section-title">
408 408
 				<?php
409
-				if ( $this->manager->is_theme_active() ) {
410
-					echo '<span class="customize-action">' . __( 'Active theme' ) . '</span> ' . $this->title;
409
+				if ($this->manager->is_theme_active()) {
410
+					echo '<span class="customize-action">'.__('Active theme').'</span> '.$this->title;
411 411
 				} else {
412
-					echo '<span class="customize-action">' . __( 'Previewing theme' ) . '</span> ' . $this->title;
412
+					echo '<span class="customize-action">'.__('Previewing theme').'</span> '.$this->title;
413 413
 				}
414 414
 				?>
415 415
 
416
-				<button type="button" class="button change-theme" tabindex="0"><?php _ex( 'Change', 'theme' ); ?></button>
416
+				<button type="button" class="button change-theme" tabindex="0"><?php _ex('Change', 'theme'); ?></button>
417 417
 			</h3>
418 418
 			<div class="customize-themes-panel control-panel-content themes-php">
419 419
 				<h3 class="accordion-section-title customize-section-title">
420
-					<span class="customize-action"><?php _e( 'Customizing' ); ?></span>
421
-					<?php _e( 'Themes' ); ?>
422
-					<span class="title-count theme-count"><?php echo count( $this->controls ) + 1 /* Active theme */; ?></span>
420
+					<span class="customize-action"><?php _e('Customizing'); ?></span>
421
+					<?php _e('Themes'); ?>
422
+					<span class="title-count theme-count"><?php echo count($this->controls) + 1 /* Active theme */; ?></span>
423 423
 				</h3>
424 424
 				<h3 class="accordion-section-title customize-section-title">
425 425
 					<?php
426
-					if ( $this->manager->is_theme_active() ) {
427
-						echo '<span class="customize-action">' . __( 'Active theme' ) . '</span> ' . $this->title;
426
+					if ($this->manager->is_theme_active()) {
427
+						echo '<span class="customize-action">'.__('Active theme').'</span> '.$this->title;
428 428
 					} else {
429
-						echo '<span class="customize-action">' . __( 'Previewing theme' ) . '</span> ' . $this->title;
429
+						echo '<span class="customize-action">'.__('Previewing theme').'</span> '.$this->title;
430 430
 					}
431 431
 					?>
432
-					<button type="button" class="button customize-theme"><?php _e( 'Customize' ); ?></button>
432
+					<button type="button" class="button customize-theme"><?php _e('Customize'); ?></button>
433 433
 				</h3>
434 434
 
435
-				<div class="theme-overlay" tabindex="0" role="dialog" aria-label="<?php esc_attr_e( 'Theme Details' ); ?>"></div>
435
+				<div class="theme-overlay" tabindex="0" role="dialog" aria-label="<?php esc_attr_e('Theme Details'); ?>"></div>
436 436
 
437 437
 				<div id="customize-container"></div>
438
-				<?php if ( count( $this->controls ) > 4 ) : ?>
438
+				<?php if (count($this->controls) > 4) : ?>
439 439
 					<p><label for="themes-filter">
440
-						<span class="screen-reader-text"><?php _e( 'Search installed themes...' ); ?></span>
441
-						<input type="text" id="themes-filter" placeholder="<?php esc_attr_e( 'Search installed themes...' ); ?>" />
440
+						<span class="screen-reader-text"><?php _e('Search installed themes...'); ?></span>
441
+						<input type="text" id="themes-filter" placeholder="<?php esc_attr_e('Search installed themes...'); ?>" />
442 442
 					</label></p>
443 443
 				<?php endif; ?>
444 444
 				<div class="theme-browser rendered">
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
 	 * @return bool Whether sidebar is rendered.
500 500
 	 */
501 501
 	public function active_callback() {
502
-		return $this->manager->widgets->is_sidebar_rendered( $this->sidebar_id );
502
+		return $this->manager->widgets->is_sidebar_rendered($this->sidebar_id);
503 503
 	}
504 504
 }
505 505
 
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
 	 */
533 533
 	public function json() {
534 534
 		$exported = parent::json();
535
-		$exported['menu_id'] = intval( preg_replace( '/^nav_menu\[(\d+)\]/', '$1', $this->id ) );
535
+		$exported['menu_id'] = intval(preg_replace('/^nav_menu\[(\d+)\]/', '$1', $this->id));
536 536
 
537 537
 		return $exported;
538 538
 	}
@@ -566,9 +566,9 @@  discard block
 block discarded – undo
566 566
 	 */
567 567
 	protected function render() {
568 568
 		?>
569
-		<li id="accordion-section-<?php echo esc_attr( $this->id ); ?>" class="accordion-section-new-menu">
569
+		<li id="accordion-section-<?php echo esc_attr($this->id); ?>" class="accordion-section-new-menu">
570 570
 			<button type="button" class="button-secondary add-new-menu-item add-menu-toggle" aria-expanded="false">
571
-				<?php echo esc_html( $this->title ); ?>
571
+				<?php echo esc_html($this->title); ?>
572 572
 			</button>
573 573
 			<ul class="new-menu-section-content"></ul>
574 574
 		</li>
Please login to merge, or discard this patch.
src/wp-includes/class-wp-customize-setting.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 	 *
264 264
 	 * @since 3.4.0
265 265
 	 *
266
-	 * @param mixed $default A default value which is used as a fallback. Default is null.
266
+	 * @param stdClass $default A default value which is used as a fallback. Default is null.
267 267
 	 * @return mixed The default value on failure, otherwise the sanitized value.
268 268
 	 */
269 269
 	final public function post_value( $default = null ) {
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 	 * @since 3.4.0
299 299
 	 *
300 300
 	 * @param mixed $value The value to update.
301
-	 * @return mixed The result of saving the value.
301
+	 * @return null|boolean The result of saving the value.
302 302
 	 */
303 303
 	protected function update( $value ) {
304 304
 		switch( $this->type ) {
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 	 * @since 3.4.0
353 353
 	 *
354 354
 	 * @param mixed $value The value to update.
355
-	 * @return bool The result of saving the value.
355
+	 * @return boolean|null The result of saving the value.
356 356
 	 */
357 357
 	protected function _update_option( $value ) {
358 358
 		// Handle non-array option.
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 	 *
535 535
 	 * @param $root
536 536
 	 * @param $keys
537
-	 * @param mixed $default A default value which is used as a fallback. Default is null.
537
+	 * @param string $default A default value which is used as a fallback. Default is null.
538 538
 	 * @return mixed The requested value or the default value.
539 539
 	 */
540 540
 	final protected function multidimensional_get( $root, $keys, $default = null ) {
Please login to merge, or discard this patch.
Spacing   +343 added lines, -343 removed lines patch added patch discarded remove patch
@@ -88,30 +88,30 @@  discard block
 block discarded – undo
88 88
 	 *                                      theme mod or option name.
89 89
 	 * @param array                $args    Setting arguments.
90 90
 	 */
91
-	public function __construct( $manager, $id, $args = array() ) {
92
-		$keys = array_keys( get_object_vars( $this ) );
93
-		foreach ( $keys as $key ) {
94
-			if ( isset( $args[ $key ] ) )
95
-				$this->$key = $args[ $key ];
91
+	public function __construct($manager, $id, $args = array()) {
92
+		$keys = array_keys(get_object_vars($this));
93
+		foreach ($keys as $key) {
94
+			if (isset($args[$key]))
95
+				$this->$key = $args[$key];
96 96
 		}
97 97
 
98 98
 		$this->manager = $manager;
99 99
 		$this->id = $id;
100 100
 
101 101
 		// Parse the ID for array keys.
102
-		$this->id_data[ 'keys' ] = preg_split( '/\[/', str_replace( ']', '', $this->id ) );
103
-		$this->id_data[ 'base' ] = array_shift( $this->id_data[ 'keys' ] );
102
+		$this->id_data['keys'] = preg_split('/\[/', str_replace(']', '', $this->id));
103
+		$this->id_data['base'] = array_shift($this->id_data['keys']);
104 104
 
105 105
 		// Rebuild the ID.
106
-		$this->id = $this->id_data[ 'base' ];
107
-		if ( ! empty( $this->id_data[ 'keys' ] ) )
108
-			$this->id .= '[' . implode( '][', $this->id_data[ 'keys' ] ) . ']';
106
+		$this->id = $this->id_data['base'];
107
+		if ( ! empty($this->id_data['keys']))
108
+			$this->id .= '['.implode('][', $this->id_data['keys']).']';
109 109
 
110
-		if ( $this->sanitize_callback )
111
-			add_filter( "customize_sanitize_{$this->id}", $this->sanitize_callback, 10, 2 );
110
+		if ($this->sanitize_callback)
111
+			add_filter("customize_sanitize_{$this->id}", $this->sanitize_callback, 10, 2);
112 112
 
113
-		if ( $this->sanitize_js_callback )
114
-			add_filter( "customize_sanitize_js_{$this->id}", $this->sanitize_js_callback, 10, 2 );
113
+		if ($this->sanitize_js_callback)
114
+			add_filter("customize_sanitize_js_{$this->id}", $this->sanitize_js_callback, 10, 2);
115 115
 	}
116 116
 
117 117
 	/**
@@ -132,10 +132,10 @@  discard block
 block discarded – undo
132 132
 	 * @return bool If preview() has been called.
133 133
 	 */
134 134
 	public function is_current_blog_previewed() {
135
-		if ( ! isset( $this->_previewed_blog_id ) ) {
135
+		if ( ! isset($this->_previewed_blog_id)) {
136 136
 			return false;
137 137
 		}
138
-		return ( get_current_blog_id() === $this->_previewed_blog_id );
138
+		return (get_current_blog_id() === $this->_previewed_blog_id);
139 139
 	}
140 140
 
141 141
 	/**
@@ -153,23 +153,23 @@  discard block
 block discarded – undo
153 153
 	 * @since 3.4.0
154 154
 	 */
155 155
 	public function preview() {
156
-		if ( ! isset( $this->_original_value ) ) {
156
+		if ( ! isset($this->_original_value)) {
157 157
 			$this->_original_value = $this->value();
158 158
 		}
159
-		if ( ! isset( $this->_previewed_blog_id ) ) {
159
+		if ( ! isset($this->_previewed_blog_id)) {
160 160
 			$this->_previewed_blog_id = get_current_blog_id();
161 161
 		}
162 162
 
163
-		switch( $this->type ) {
163
+		switch ($this->type) {
164 164
 			case 'theme_mod' :
165
-				add_filter( 'theme_mod_' . $this->id_data[ 'base' ], array( $this, '_preview_filter' ) );
165
+				add_filter('theme_mod_'.$this->id_data['base'], array($this, '_preview_filter'));
166 166
 				break;
167 167
 			case 'option' :
168
-				if ( empty( $this->id_data[ 'keys' ] ) )
169
-					add_filter( 'pre_option_' . $this->id_data[ 'base' ], array( $this, '_preview_filter' ) );
168
+				if (empty($this->id_data['keys']))
169
+					add_filter('pre_option_'.$this->id_data['base'], array($this, '_preview_filter'));
170 170
 				else {
171
-					add_filter( 'option_' . $this->id_data[ 'base' ], array( $this, '_preview_filter' ) );
172
-					add_filter( 'default_option_' . $this->id_data[ 'base' ], array( $this, '_preview_filter' ) );
171
+					add_filter('option_'.$this->id_data['base'], array($this, '_preview_filter'));
172
+					add_filter('default_option_'.$this->id_data['base'], array($this, '_preview_filter'));
173 173
 				}
174 174
 				break;
175 175
 			default :
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 				 *
185 185
 				 * @param WP_Customize_Setting $this {@see WP_Customize_Setting} instance.
186 186
 				 */
187
-				do_action( "customize_preview_{$this->id}", $this );
187
+				do_action("customize_preview_{$this->id}", $this);
188 188
 
189 189
 				/**
190 190
 				 * Fires when the {@see WP_Customize_Setting::preview()} method is called for settings
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 				 *
197 197
 				 * @param WP_Customize_Setting $this {@see WP_Customize_Setting} instance.
198 198
 				 */
199
-				do_action( "customize_preview_{$this->type}", $this );
199
+				do_action("customize_preview_{$this->type}", $this);
200 200
 		}
201 201
 	}
202 202
 
@@ -213,20 +213,20 @@  discard block
 block discarded – undo
213 213
 	 * @param mixed $original Old value.
214 214
 	 * @return mixed New or old value.
215 215
 	 */
216
-	public function _preview_filter( $original ) {
217
-		if ( ! $this->is_current_blog_previewed() ) {
216
+	public function _preview_filter($original) {
217
+		if ( ! $this->is_current_blog_previewed()) {
218 218
 			return $original;
219 219
 		}
220 220
 
221 221
 		$undefined = new stdClass(); // symbol hack
222
-		$post_value = $this->post_value( $undefined );
223
-		if ( $undefined === $post_value ) {
222
+		$post_value = $this->post_value($undefined);
223
+		if ($undefined === $post_value) {
224 224
 			$value = $this->_original_value;
225 225
 		} else {
226 226
 			$value = $post_value;
227 227
 		}
228 228
 
229
-		return $this->multidimensional_replace( $original, $this->id_data['keys'], $value );
229
+		return $this->multidimensional_replace($original, $this->id_data['keys'], $value);
230 230
 	}
231 231
 
232 232
 	/**
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 	final public function save() {
241 241
 		$value = $this->post_value();
242 242
 
243
-		if ( ! $this->check_capabilities() || ! isset( $value ) )
243
+		if ( ! $this->check_capabilities() || ! isset($value))
244 244
 			return false;
245 245
 
246 246
 		/**
@@ -253,9 +253,9 @@  discard block
 block discarded – undo
253 253
 		 *
254 254
 		 * @param WP_Customize_Setting $this {@see WP_Customize_Setting} instance.
255 255
 		 */
256
-		do_action( 'customize_save_' . $this->id_data[ 'base' ], $this );
256
+		do_action('customize_save_'.$this->id_data['base'], $this);
257 257
 
258
-		$this->update( $value );
258
+		$this->update($value);
259 259
 	}
260 260
 
261 261
 	/**
@@ -266,8 +266,8 @@  discard block
 block discarded – undo
266 266
 	 * @param mixed $default A default value which is used as a fallback. Default is null.
267 267
 	 * @return mixed The default value on failure, otherwise the sanitized value.
268 268
 	 */
269
-	final public function post_value( $default = null ) {
270
-		return $this->manager->post_value( $this, $default );
269
+	final public function post_value($default = null) {
270
+		return $this->manager->post_value($this, $default);
271 271
 	}
272 272
 
273 273
 	/**
@@ -278,8 +278,8 @@  discard block
 block discarded – undo
278 278
 	 * @param string|array $value The value to sanitize.
279 279
 	 * @return string|array|null Null if an input isn't valid, otherwise the sanitized value.
280 280
 	 */
281
-	public function sanitize( $value ) {
282
-		$value = wp_unslash( $value );
281
+	public function sanitize($value) {
282
+		$value = wp_unslash($value);
283 283
 
284 284
 		/**
285 285
 		 * Filter a Customize setting value in un-slashed form.
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 		 * @param mixed                $value Value of the setting.
290 290
 		 * @param WP_Customize_Setting $this  WP_Customize_Setting instance.
291 291
 		 */
292
-		return apply_filters( "customize_sanitize_{$this->id}", $value, $this );
292
+		return apply_filters("customize_sanitize_{$this->id}", $value, $this);
293 293
 	}
294 294
 
295 295
 	/**
@@ -300,13 +300,13 @@  discard block
 block discarded – undo
300 300
 	 * @param mixed $value The value to update.
301 301
 	 * @return mixed The result of saving the value.
302 302
 	 */
303
-	protected function update( $value ) {
304
-		switch( $this->type ) {
303
+	protected function update($value) {
304
+		switch ($this->type) {
305 305
 			case 'theme_mod' :
306
-				return $this->_update_theme_mod( $value );
306
+				return $this->_update_theme_mod($value);
307 307
 
308 308
 			case 'option' :
309
-				return $this->_update_option( $value );
309
+				return $this->_update_option($value);
310 310
 
311 311
 			default :
312 312
 
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 				 * @param mixed                $value Value of the setting.
322 322
 				 * @param WP_Customize_Setting $this  WP_Customize_Setting instance.
323 323
 				 */
324
-				return do_action( 'customize_update_' . $this->type, $value, $this );
324
+				return do_action('customize_update_'.$this->type, $value, $this);
325 325
 		}
326 326
 	}
327 327
 
@@ -332,17 +332,17 @@  discard block
 block discarded – undo
332 332
 	 *
333 333
 	 * @param mixed $value The value to update.
334 334
 	 */
335
-	protected function _update_theme_mod( $value ) {
335
+	protected function _update_theme_mod($value) {
336 336
 		// Handle non-array theme mod.
337
-		if ( empty( $this->id_data[ 'keys' ] ) ) {
338
-			set_theme_mod( $this->id_data[ 'base' ], $value );
337
+		if (empty($this->id_data['keys'])) {
338
+			set_theme_mod($this->id_data['base'], $value);
339 339
 			return;
340 340
 		}
341 341
 		// Handle array-based theme mod.
342
-		$mods = get_theme_mod( $this->id_data[ 'base' ] );
343
-		$mods = $this->multidimensional_replace( $mods, $this->id_data[ 'keys' ], $value );
344
-		if ( isset( $mods ) ) {
345
-			set_theme_mod( $this->id_data[ 'base' ], $mods );
342
+		$mods = get_theme_mod($this->id_data['base']);
343
+		$mods = $this->multidimensional_replace($mods, $this->id_data['keys'], $value);
344
+		if (isset($mods)) {
345
+			set_theme_mod($this->id_data['base'], $mods);
346 346
 		}
347 347
 	}
348 348
 
@@ -354,16 +354,16 @@  discard block
 block discarded – undo
354 354
 	 * @param mixed $value The value to update.
355 355
 	 * @return bool The result of saving the value.
356 356
 	 */
357
-	protected function _update_option( $value ) {
357
+	protected function _update_option($value) {
358 358
 		// Handle non-array option.
359
-		if ( empty( $this->id_data[ 'keys' ] ) )
360
-			return update_option( $this->id_data[ 'base' ], $value );
359
+		if (empty($this->id_data['keys']))
360
+			return update_option($this->id_data['base'], $value);
361 361
 
362 362
 		// Handle array-based options.
363
-		$options = get_option( $this->id_data[ 'base' ] );
364
-		$options = $this->multidimensional_replace( $options, $this->id_data[ 'keys' ], $value );
365
-		if ( isset( $options ) )
366
-			return update_option( $this->id_data[ 'base' ], $options );
363
+		$options = get_option($this->id_data['base']);
364
+		$options = $this->multidimensional_replace($options, $this->id_data['keys'], $value);
365
+		if (isset($options))
366
+			return update_option($this->id_data['base'], $options);
367 367
 	}
368 368
 
369 369
 	/**
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 	 */
376 376
 	public function value() {
377 377
 		// Get the callback that corresponds to the setting type.
378
-		switch( $this->type ) {
378
+		switch ($this->type) {
379 379
 			case 'theme_mod' :
380 380
 				$function = 'get_theme_mod';
381 381
 				break;
@@ -397,16 +397,16 @@  discard block
 block discarded – undo
397 397
 				 *
398 398
 				 * @param mixed $default The setting default value. Default empty.
399 399
 				 */
400
-				return apply_filters( 'customize_value_' . $this->id_data[ 'base' ], $this->default );
400
+				return apply_filters('customize_value_'.$this->id_data['base'], $this->default);
401 401
 		}
402 402
 
403 403
 		// Handle non-array value
404
-		if ( empty( $this->id_data[ 'keys' ] ) )
405
-			return $function( $this->id_data[ 'base' ], $this->default );
404
+		if (empty($this->id_data['keys']))
405
+			return $function($this->id_data['base'], $this->default);
406 406
 
407 407
 		// Handle array-based value
408
-		$values = $function( $this->id_data[ 'base' ] );
409
-		return $this->multidimensional_get( $values, $this->id_data[ 'keys' ], $this->default );
408
+		$values = $function($this->id_data['base']);
409
+		return $this->multidimensional_get($values, $this->id_data['keys'], $this->default);
410 410
 	}
411 411
 
412 412
 	/**
@@ -428,10 +428,10 @@  discard block
 block discarded – undo
428 428
 		 * @param mixed                $value The setting value.
429 429
 		 * @param WP_Customize_Setting $this  {@see WP_Customize_Setting} instance.
430 430
 		 */
431
-		$value = apply_filters( "customize_sanitize_js_{$this->id}", $this->value(), $this );
431
+		$value = apply_filters("customize_sanitize_js_{$this->id}", $this->value(), $this);
432 432
 
433
-		if ( is_string( $value ) )
434
-			return html_entity_decode( $value, ENT_QUOTES, 'UTF-8');
433
+		if (is_string($value))
434
+			return html_entity_decode($value, ENT_QUOTES, 'UTF-8');
435 435
 
436 436
 		return $value;
437 437
 	}
@@ -444,10 +444,10 @@  discard block
 block discarded – undo
444 444
 	 * @return bool False if theme doesn't support the setting or user can't change setting, otherwise true.
445 445
 	 */
446 446
 	final public function check_capabilities() {
447
-		if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) )
447
+		if ($this->capability && ! call_user_func_array('current_user_can', (array) $this->capability))
448 448
 			return false;
449 449
 
450
-		if ( $this->theme_supports && ! call_user_func_array( 'current_theme_supports', (array) $this->theme_supports ) )
450
+		if ($this->theme_supports && ! call_user_func_array('current_theme_supports', (array) $this->theme_supports))
451 451
 			return false;
452 452
 
453 453
 		return true;
@@ -463,37 +463,37 @@  discard block
 block discarded – undo
463 463
 	 * @param bool $create Default is false.
464 464
 	 * @return array|void Keys are 'root', 'node', and 'key'.
465 465
 	 */
466
-	final protected function multidimensional( &$root, $keys, $create = false ) {
467
-		if ( $create && empty( $root ) )
466
+	final protected function multidimensional(&$root, $keys, $create = false) {
467
+		if ($create && empty($root))
468 468
 			$root = array();
469 469
 
470
-		if ( ! isset( $root ) || empty( $keys ) )
470
+		if ( ! isset($root) || empty($keys))
471 471
 			return;
472 472
 
473
-		$last = array_pop( $keys );
473
+		$last = array_pop($keys);
474 474
 		$node = &$root;
475 475
 
476
-		foreach ( $keys as $key ) {
477
-			if ( $create && ! isset( $node[ $key ] ) )
478
-				$node[ $key ] = array();
476
+		foreach ($keys as $key) {
477
+			if ($create && ! isset($node[$key]))
478
+				$node[$key] = array();
479 479
 
480
-			if ( ! is_array( $node ) || ! isset( $node[ $key ] ) )
480
+			if ( ! is_array($node) || ! isset($node[$key]))
481 481
 				return;
482 482
 
483
-			$node = &$node[ $key ];
483
+			$node = &$node[$key];
484 484
 		}
485 485
 
486
-		if ( $create ) {
487
-			if ( ! is_array( $node ) ) {
486
+		if ($create) {
487
+			if ( ! is_array($node)) {
488 488
 				// account for an array overriding a string or object value
489 489
 				$node = array();
490 490
 			}
491
-			if ( ! isset( $node[ $last ] ) ) {
492
-				$node[ $last ] = array();
491
+			if ( ! isset($node[$last])) {
492
+				$node[$last] = array();
493 493
 			}
494 494
 		}
495 495
 
496
-		if ( ! isset( $node[ $last ] ) )
496
+		if ( ! isset($node[$last]))
497 497
 			return;
498 498
 
499 499
 		return array(
@@ -513,16 +513,16 @@  discard block
 block discarded – undo
513 513
 	 * @param mixed $value The value to update.
514 514
 	 * @return
515 515
 	 */
516
-	final protected function multidimensional_replace( $root, $keys, $value ) {
517
-		if ( ! isset( $value ) )
516
+	final protected function multidimensional_replace($root, $keys, $value) {
517
+		if ( ! isset($value))
518 518
 			return $root;
519
-		elseif ( empty( $keys ) ) // If there are no keys, we're replacing the root.
519
+		elseif (empty($keys)) // If there are no keys, we're replacing the root.
520 520
 			return $value;
521 521
 
522
-		$result = $this->multidimensional( $root, $keys, true );
522
+		$result = $this->multidimensional($root, $keys, true);
523 523
 
524
-		if ( isset( $result ) )
525
-			$result['node'][ $result['key'] ] = $value;
524
+		if (isset($result))
525
+			$result['node'][$result['key']] = $value;
526 526
 
527 527
 		return $root;
528 528
 	}
@@ -537,12 +537,12 @@  discard block
 block discarded – undo
537 537
 	 * @param mixed $default A default value which is used as a fallback. Default is null.
538 538
 	 * @return mixed The requested value or the default value.
539 539
 	 */
540
-	final protected function multidimensional_get( $root, $keys, $default = null ) {
541
-		if ( empty( $keys ) ) // If there are no keys, test the root.
542
-			return isset( $root ) ? $root : $default;
540
+	final protected function multidimensional_get($root, $keys, $default = null) {
541
+		if (empty($keys)) // If there are no keys, test the root.
542
+			return isset($root) ? $root : $default;
543 543
 
544
-		$result = $this->multidimensional( $root, $keys );
545
-		return isset( $result ) ? $result['node'][ $result['key'] ] : $default;
544
+		$result = $this->multidimensional($root, $keys);
545
+		return isset($result) ? $result['node'][$result['key']] : $default;
546 546
 	}
547 547
 
548 548
 	/**
@@ -554,9 +554,9 @@  discard block
 block discarded – undo
554 554
 	 * @param $keys
555 555
 	 * @return bool True if value is set, false if not.
556 556
 	 */
557
-	final protected function multidimensional_isset( $root, $keys ) {
558
-		$result = $this->multidimensional_get( $root, $keys );
559
-		return isset( $result );
557
+	final protected function multidimensional_isset($root, $keys) {
558
+		$result = $this->multidimensional_get($root, $keys);
559
+		return isset($result);
560 560
 	}
561 561
 }
562 562
 
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 	/**
575 575
 	 * @since 3.4.0
576 576
 	 */
577
-	public function update( $value ) {}
577
+	public function update($value) {}
578 578
 }
579 579
 
580 580
 /**
@@ -596,18 +596,18 @@  discard block
 block discarded – undo
596 596
 	 *
597 597
 	 * @param $value
598 598
 	 */
599
-	public function update( $value ) {
599
+	public function update($value) {
600 600
 		global $custom_image_header;
601 601
 
602 602
 		// If the value doesn't exist (removed or random),
603 603
 		// use the header_image value.
604
-		if ( ! $value )
604
+		if ( ! $value)
605 605
 			$value = $this->manager->get_setting('header_image')->post_value();
606 606
 
607
-		if ( is_array( $value ) && isset( $value['choice'] ) )
608
-			$custom_image_header->set_header_image( $value['choice'] );
607
+		if (is_array($value) && isset($value['choice']))
608
+			$custom_image_header->set_header_image($value['choice']);
609 609
 		else
610
-			$custom_image_header->set_header_image( $value );
610
+			$custom_image_header->set_header_image($value);
611 611
 	}
612 612
 }
613 613
 
@@ -626,8 +626,8 @@  discard block
 block discarded – undo
626 626
 	 *
627 627
 	 * @param $value
628 628
 	 */
629
-	public function update( $value ) {
630
-		remove_theme_mod( 'background_image_thumb' );
629
+	public function update($value) {
630
+		remove_theme_mod('background_image_thumb');
631 631
 	}
632 632
 }
633 633
 
@@ -803,25 +803,25 @@  discard block
 block discarded – undo
803 803
 	 *
804 804
 	 * @throws Exception If $id is not valid for this setting type.
805 805
 	 */
806
-	public function __construct( WP_Customize_Manager $manager, $id, array $args = array() ) {
807
-		if ( empty( $manager->nav_menus ) ) {
808
-			throw new Exception( 'Expected WP_Customize_Manager::$nav_menus to be set.' );
806
+	public function __construct(WP_Customize_Manager $manager, $id, array $args = array()) {
807
+		if (empty($manager->nav_menus)) {
808
+			throw new Exception('Expected WP_Customize_Manager::$nav_menus to be set.');
809 809
 		}
810 810
 
811
-		if ( ! preg_match( self::ID_PATTERN, $id, $matches ) ) {
812
-			throw new Exception( "Illegal widget setting ID: $id" );
811
+		if ( ! preg_match(self::ID_PATTERN, $id, $matches)) {
812
+			throw new Exception("Illegal widget setting ID: $id");
813 813
 		}
814 814
 
815
-		$this->post_id = intval( $matches['id'] );
816
-		add_action( 'wp_update_nav_menu_item', array( $this, 'flush_cached_value' ), 10, 2 );
815
+		$this->post_id = intval($matches['id']);
816
+		add_action('wp_update_nav_menu_item', array($this, 'flush_cached_value'), 10, 2);
817 817
 
818
-		parent::__construct( $manager, $id, $args );
818
+		parent::__construct($manager, $id, $args);
819 819
 
820 820
 		// Ensure that an initially-supplied value is valid.
821
-		if ( isset( $this->value ) ) {
821
+		if (isset($this->value)) {
822 822
 			$this->populate_value();
823
-			foreach ( array_diff( array_keys( $this->default ), array_keys( $this->value ) ) as $missing ) {
824
-				throw new Exception( "Supplied nav_menu_item value missing property: $missing" );
823
+			foreach (array_diff(array_keys($this->default), array_keys($this->value)) as $missing) {
824
+				throw new Exception("Supplied nav_menu_item value missing property: $missing");
825 825
 			}
826 826
 		}
827 827
 
@@ -836,9 +836,9 @@  discard block
 block discarded – undo
836 836
 	 * @param int $menu_id       The term ID for the menu.
837 837
 	 * @param int $menu_item_id  The post ID for the menu item.
838 838
 	 */
839
-	public function flush_cached_value( $menu_id, $menu_item_id ) {
840
-		unset( $menu_id );
841
-		if ( $menu_item_id === $this->post_id ) {
839
+	public function flush_cached_value($menu_id, $menu_item_id) {
840
+		unset($menu_id);
841
+		if ($menu_item_id === $this->post_id) {
842 842
 			$this->value = null;
843 843
 		}
844 844
 	}
@@ -854,29 +854,29 @@  discard block
 block discarded – undo
854 854
 	 * @return array|false Instance data array, or false if the item is marked for deletion.
855 855
 	 */
856 856
 	public function value() {
857
-		if ( $this->is_previewed && $this->_previewed_blog_id === get_current_blog_id() ) {
857
+		if ($this->is_previewed && $this->_previewed_blog_id === get_current_blog_id()) {
858 858
 			$undefined  = new stdClass(); // Symbol.
859
-			$post_value = $this->post_value( $undefined );
859
+			$post_value = $this->post_value($undefined);
860 860
 
861
-			if ( $undefined === $post_value ) {
861
+			if ($undefined === $post_value) {
862 862
 				$value = $this->_original_value;
863 863
 			} else {
864 864
 				$value = $post_value;
865 865
 			}
866
-		} else if ( isset( $this->value ) ) {
866
+		} else if (isset($this->value)) {
867 867
 			$value = $this->value;
868 868
 		} else {
869 869
 			$value = false;
870 870
 
871 871
 			// Note that a ID of less than one indicates a nav_menu not yet inserted.
872
-			if ( $this->post_id > 0 ) {
873
-				$post = get_post( $this->post_id );
874
-				if ( $post && self::POST_TYPE === $post->post_type ) {
875
-					$value = (array) wp_setup_nav_menu_item( $post );
872
+			if ($this->post_id > 0) {
873
+				$post = get_post($this->post_id);
874
+				if ($post && self::POST_TYPE === $post->post_type) {
875
+					$value = (array) wp_setup_nav_menu_item($post);
876 876
 				}
877 877
 			}
878 878
 
879
-			if ( ! is_array( $value ) ) {
879
+			if ( ! is_array($value)) {
880 880
 				$value = $this->default;
881 881
 			}
882 882
 
@@ -900,46 +900,46 @@  discard block
 block discarded – undo
900 900
 	 * @see WP_Customize_Nav_Menu_Item_Setting::value()
901 901
 	 */
902 902
 	protected function populate_value() {
903
-		if ( ! is_array( $this->value ) ) {
903
+		if ( ! is_array($this->value)) {
904 904
 			return;
905 905
 		}
906 906
 
907
-		if ( isset( $this->value['menu_order'] ) ) {
907
+		if (isset($this->value['menu_order'])) {
908 908
 			$this->value['position'] = $this->value['menu_order'];
909
-			unset( $this->value['menu_order'] );
909
+			unset($this->value['menu_order']);
910 910
 		}
911
-		if ( isset( $this->value['post_status'] ) ) {
911
+		if (isset($this->value['post_status'])) {
912 912
 			$this->value['status'] = $this->value['post_status'];
913
-			unset( $this->value['post_status'] );
913
+			unset($this->value['post_status']);
914 914
 		}
915 915
 
916
-		if ( ! isset( $this->value['original_title'] ) ) {
916
+		if ( ! isset($this->value['original_title'])) {
917 917
 			$original_title = '';
918
-			if ( 'post_type' === $this->value['type'] ) {
919
-				$original_title = get_the_title( $this->value['object_id'] );
920
-			} elseif ( 'taxonomy' === $this->value['type'] ) {
921
-				$original_title = get_term_field( 'name', $this->value['object_id'], $this->value['object'], 'raw' );
922
-				if ( is_wp_error( $original_title ) ) {
918
+			if ('post_type' === $this->value['type']) {
919
+				$original_title = get_the_title($this->value['object_id']);
920
+			} elseif ('taxonomy' === $this->value['type']) {
921
+				$original_title = get_term_field('name', $this->value['object_id'], $this->value['object'], 'raw');
922
+				if (is_wp_error($original_title)) {
923 923
 					$original_title = '';
924 924
 				}
925 925
 			}
926
-			$this->value['original_title'] = html_entity_decode( $original_title, ENT_QUOTES, get_bloginfo( 'charset' ) );
926
+			$this->value['original_title'] = html_entity_decode($original_title, ENT_QUOTES, get_bloginfo('charset'));
927 927
 		}
928 928
 
929
-		if ( ! isset( $this->value['nav_menu_term_id'] ) && $this->post_id > 0 ) {
930
-			$menus = wp_get_post_terms( $this->post_id, WP_Customize_Nav_Menu_Setting::TAXONOMY, array(
929
+		if ( ! isset($this->value['nav_menu_term_id']) && $this->post_id > 0) {
930
+			$menus = wp_get_post_terms($this->post_id, WP_Customize_Nav_Menu_Setting::TAXONOMY, array(
931 931
 				'fields' => 'ids',
932
-			) );
933
-			if ( ! empty( $menus ) ) {
934
-				$this->value['nav_menu_term_id'] = array_shift( $menus );
932
+			));
933
+			if ( ! empty($menus)) {
934
+				$this->value['nav_menu_term_id'] = array_shift($menus);
935 935
 			} else {
936 936
 				$this->value['nav_menu_term_id'] = 0;
937 937
 			}
938 938
 		}
939 939
 
940
-		foreach ( array( 'object_id', 'menu_item_parent', 'nav_menu_term_id' ) as $key ) {
941
-			if ( ! is_int( $this->value[ $key ] ) ) {
942
-				$this->value[ $key ] = intval( $this->value[ $key ] );
940
+		foreach (array('object_id', 'menu_item_parent', 'nav_menu_term_id') as $key) {
941
+			if ( ! is_int($this->value[$key])) {
942
+				$this->value[$key] = intval($this->value[$key]);
943 943
 			}
944 944
 		}
945 945
 
@@ -969,8 +969,8 @@  discard block
 block discarded – undo
969 969
 			'post_type',
970 970
 			'to_ping',
971 971
 		);
972
-		foreach ( $irrelevant_properties as $property ) {
973
-			unset( $this->value[ $property ] );
972
+		foreach ($irrelevant_properties as $property) {
973
+			unset($this->value[$property]);
974 974
 		}
975 975
 	}
976 976
 
@@ -983,7 +983,7 @@  discard block
 block discarded – undo
983 983
 	 * @see WP_Customize_Manager::post_value()
984 984
 	 */
985 985
 	public function preview() {
986
-		if ( $this->is_previewed ) {
986
+		if ($this->is_previewed) {
987 987
 			return;
988 988
 		}
989 989
 
@@ -992,11 +992,11 @@  discard block
 block discarded – undo
992 992
 		$this->original_nav_menu_term_id = $this->_original_value['nav_menu_term_id'];
993 993
 		$this->_previewed_blog_id        = get_current_blog_id();
994 994
 
995
-		add_filter( 'wp_get_nav_menu_items', array( $this, 'filter_wp_get_nav_menu_items' ), 10, 3 );
995
+		add_filter('wp_get_nav_menu_items', array($this, 'filter_wp_get_nav_menu_items'), 10, 3);
996 996
 
997
-		$sort_callback = array( __CLASS__, 'sort_wp_get_nav_menu_items' );
998
-		if ( ! has_filter( 'wp_get_nav_menu_items', $sort_callback ) ) {
999
-			add_filter( 'wp_get_nav_menu_items', array( __CLASS__, 'sort_wp_get_nav_menu_items' ), 1000, 3 );
997
+		$sort_callback = array(__CLASS__, 'sort_wp_get_nav_menu_items');
998
+		if ( ! has_filter('wp_get_nav_menu_items', $sort_callback)) {
999
+			add_filter('wp_get_nav_menu_items', array(__CLASS__, 'sort_wp_get_nav_menu_items'), 1000, 3);
1000 1000
 		}
1001 1001
 
1002 1002
 		// @todo Add get_post_metadata filters for plugins to add their data.
@@ -1015,17 +1015,17 @@  discard block
 block discarded – undo
1015 1015
 	 * @param array  $args  An array of arguments used to retrieve menu item objects.
1016 1016
 	 * @return array Array of menu items,
1017 1017
 	 */
1018
-	public function filter_wp_get_nav_menu_items( $items, $menu, $args ) {
1018
+	public function filter_wp_get_nav_menu_items($items, $menu, $args) {
1019 1019
 		$this_item = $this->value();
1020 1020
 		$current_nav_menu_term_id = $this_item['nav_menu_term_id'];
1021
-		unset( $this_item['nav_menu_term_id'] );
1021
+		unset($this_item['nav_menu_term_id']);
1022 1022
 
1023 1023
 		$should_filter = (
1024 1024
 			$menu->term_id === $this->original_nav_menu_term_id
1025 1025
 			||
1026 1026
 			$menu->term_id === $current_nav_menu_term_id
1027 1027
 		);
1028
-		if ( ! $should_filter ) {
1028
+		if ( ! $should_filter) {
1029 1029
 			return $items;
1030 1030
 		}
1031 1031
 
@@ -1039,10 +1039,10 @@  discard block
 block discarded – undo
1039 1039
 				$current_nav_menu_term_id !== $this->original_nav_menu_term_id
1040 1040
 			)
1041 1041
 		);
1042
-		if ( $should_remove ) {
1042
+		if ($should_remove) {
1043 1043
 			$filtered_items = array();
1044
-			foreach ( $items as $item ) {
1045
-				if ( $item->db_id !== $this->post_id ) {
1044
+			foreach ($items as $item) {
1045
+				if ($item->db_id !== $this->post_id) {
1046 1046
 					$filtered_items[] = $item;
1047 1047
 				}
1048 1048
 			}
@@ -1051,14 +1051,14 @@  discard block
 block discarded – undo
1051 1051
 
1052 1052
 		$mutated = false;
1053 1053
 		$should_update = (
1054
-			is_array( $this_item )
1054
+			is_array($this_item)
1055 1055
 			&&
1056 1056
 			$current_nav_menu_term_id === $menu->term_id
1057 1057
 		);
1058
-		if ( $should_update ) {
1059
-			foreach ( $items as $item ) {
1060
-				if ( $item->db_id === $this->post_id ) {
1061
-					foreach ( get_object_vars( $this->value_as_wp_post_nav_menu_item() ) as $key => $value ) {
1058
+		if ($should_update) {
1059
+			foreach ($items as $item) {
1060
+				if ($item->db_id === $this->post_id) {
1061
+					foreach (get_object_vars($this->value_as_wp_post_nav_menu_item()) as $key => $value) {
1062 1062
 						$item->$key = $value;
1063 1063
 					}
1064 1064
 					$mutated = true;
@@ -1066,7 +1066,7 @@  discard block
 block discarded – undo
1066 1066
 			}
1067 1067
 
1068 1068
 			// Not found so we have to append it..
1069
-			if ( ! $mutated ) {
1069
+			if ( ! $mutated) {
1070 1070
 				$items[] = $this->value_as_wp_post_nav_menu_item();
1071 1071
 			}
1072 1072
 		}
@@ -1088,22 +1088,22 @@  discard block
 block discarded – undo
1088 1088
 	 * @param array  $args  An array of arguments used to retrieve menu item objects.
1089 1089
 	 * @return array Array of menu items,
1090 1090
 	 */
1091
-	public static function sort_wp_get_nav_menu_items( $items, $menu, $args ) {
1091
+	public static function sort_wp_get_nav_menu_items($items, $menu, $args) {
1092 1092
 		// @todo We should probably re-apply some constraints imposed by $args.
1093
-		unset( $args['include'] );
1093
+		unset($args['include']);
1094 1094
 
1095 1095
 		// Remove invalid items only in frontend.
1096
-		if ( ! is_admin() ) {
1097
-			$items = array_filter( $items, '_is_valid_nav_menu_item' );
1096
+		if ( ! is_admin()) {
1097
+			$items = array_filter($items, '_is_valid_nav_menu_item');
1098 1098
 		}
1099 1099
 
1100
-		if ( ARRAY_A === $args['output'] ) {
1100
+		if (ARRAY_A === $args['output']) {
1101 1101
 			$GLOBALS['_menu_item_sort_prop'] = $args['output_key'];
1102
-			usort( $items, '_sort_nav_menu_items' );
1102
+			usort($items, '_sort_nav_menu_items');
1103 1103
 			$i = 1;
1104 1104
 
1105
-			foreach ( $items as $k => $item ) {
1106
-				$items[ $k ]->{$args['output_key']} = $i++;
1105
+			foreach ($items as $k => $item) {
1106
+				$items[$k]->{$args['output_key']} = $i++;
1107 1107
 			}
1108 1108
 		}
1109 1109
 
@@ -1120,44 +1120,44 @@  discard block
 block discarded – undo
1120 1120
 	 */
1121 1121
 	public function value_as_wp_post_nav_menu_item() {
1122 1122
 		$item = (object) $this->value();
1123
-		unset( $item->nav_menu_term_id );
1123
+		unset($item->nav_menu_term_id);
1124 1124
 
1125 1125
 		$item->post_status = $item->status;
1126
-		unset( $item->status );
1126
+		unset($item->status);
1127 1127
 
1128 1128
 		$item->post_type = 'nav_menu_item';
1129 1129
 		$item->menu_order = $item->position;
1130
-		unset( $item->position );
1130
+		unset($item->position);
1131 1131
 
1132
-		if ( $item->title ) {
1132
+		if ($item->title) {
1133 1133
 			$item->post_title = $item->title;
1134 1134
 		}
1135 1135
 
1136 1136
 		$item->ID = $this->post_id;
1137 1137
 		$item->db_id = $this->post_id;
1138
-		$post = new WP_Post( (object) $item );
1138
+		$post = new WP_Post((object) $item);
1139 1139
 
1140
-		if ( empty( $post->post_author ) ) {
1140
+		if (empty($post->post_author)) {
1141 1141
 			$post->post_author = get_current_user_id();
1142 1142
 		}
1143 1143
 
1144
-		if ( ! isset( $post->type_label ) ) {
1145
-			if ( 'post_type' === $post->type ) {
1146
-				$object = get_post_type_object( $post->object );
1147
-				if ( $object ) {
1144
+		if ( ! isset($post->type_label)) {
1145
+			if ('post_type' === $post->type) {
1146
+				$object = get_post_type_object($post->object);
1147
+				if ($object) {
1148 1148
 					$post->type_label = $object->labels->singular_name;
1149 1149
 				} else {
1150 1150
 					$post->type_label = $post->object;
1151 1151
 				}
1152
-			} elseif ( 'taxonomy' == $post->type ) {
1153
-				$object = get_taxonomy( $post->object );
1154
-				if ( $object ) {
1152
+			} elseif ('taxonomy' == $post->type) {
1153
+				$object = get_taxonomy($post->object);
1154
+				if ($object) {
1155 1155
 					$post->type_label = $object->labels->singular_name;
1156 1156
 				} else {
1157 1157
 					$post->type_label = $post->object;
1158 1158
 				}
1159 1159
 			} else {
1160
-				$post->type_label = __( 'Custom Link' );
1160
+				$post->type_label = __('Custom Link');
1161 1161
 			}
1162 1162
 		}
1163 1163
 
@@ -1177,14 +1177,14 @@  discard block
 block discarded – undo
1177 1177
 	 * @return array|false|null Null if an input isn't valid. False if it is marked for deletion.
1178 1178
 	 *                          Otherwise the sanitized value.
1179 1179
 	 */
1180
-	public function sanitize( $menu_item_value ) {
1180
+	public function sanitize($menu_item_value) {
1181 1181
 		// Menu is marked for deletion.
1182
-		if ( false === $menu_item_value ) {
1182
+		if (false === $menu_item_value) {
1183 1183
 			return $menu_item_value;
1184 1184
 		}
1185 1185
 
1186 1186
 		// Invalid.
1187
-		if ( ! is_array( $menu_item_value ) ) {
1187
+		if ( ! is_array($menu_item_value)) {
1188 1188
 			return null;
1189 1189
 		}
1190 1190
 
@@ -1205,39 +1205,39 @@  discard block
 block discarded – undo
1205 1205
 			'original_title'   => '',
1206 1206
 			'nav_menu_term_id' => 0,
1207 1207
 		);
1208
-		$menu_item_value = array_merge( $default, $menu_item_value );
1209
-		$menu_item_value = wp_array_slice_assoc( $menu_item_value, array_keys( $default ) );
1210
-		$menu_item_value['position'] = max( 0, intval( $menu_item_value['position'] ) );
1208
+		$menu_item_value = array_merge($default, $menu_item_value);
1209
+		$menu_item_value = wp_array_slice_assoc($menu_item_value, array_keys($default));
1210
+		$menu_item_value['position'] = max(0, intval($menu_item_value['position']));
1211 1211
 
1212
-		foreach ( array( 'object_id', 'menu_item_parent', 'nav_menu_term_id' ) as $key ) {
1212
+		foreach (array('object_id', 'menu_item_parent', 'nav_menu_term_id') as $key) {
1213 1213
 			// Note we need to allow negative-integer IDs for previewed objects not inserted yet.
1214
-			$menu_item_value[ $key ] = intval( $menu_item_value[ $key ] );
1214
+			$menu_item_value[$key] = intval($menu_item_value[$key]);
1215 1215
 		}
1216 1216
 
1217
-		foreach ( array( 'type', 'object', 'target' ) as $key ) {
1218
-			$menu_item_value[ $key ] = sanitize_key( $menu_item_value[ $key ] );
1217
+		foreach (array('type', 'object', 'target') as $key) {
1218
+			$menu_item_value[$key] = sanitize_key($menu_item_value[$key]);
1219 1219
 		}
1220 1220
 
1221
-		foreach ( array( 'xfn', 'classes' ) as $key ) {
1222
-			$value = $menu_item_value[ $key ];
1223
-			if ( ! is_array( $value ) ) {
1224
-				$value = explode( ' ', $value );
1221
+		foreach (array('xfn', 'classes') as $key) {
1222
+			$value = $menu_item_value[$key];
1223
+			if ( ! is_array($value)) {
1224
+				$value = explode(' ', $value);
1225 1225
 			}
1226
-			$menu_item_value[ $key ] = implode( ' ', array_map( 'sanitize_html_class', $value ) );
1226
+			$menu_item_value[$key] = implode(' ', array_map('sanitize_html_class', $value));
1227 1227
 		}
1228 1228
 
1229
-		foreach ( array( 'title', 'attr_title', 'description', 'original_title' ) as $key ) {
1229
+		foreach (array('title', 'attr_title', 'description', 'original_title') as $key) {
1230 1230
 			// @todo Should esc_attr() the attr_title as well?
1231
-			$menu_item_value[ $key ] = sanitize_text_field( $menu_item_value[ $key ] );
1231
+			$menu_item_value[$key] = sanitize_text_field($menu_item_value[$key]);
1232 1232
 		}
1233 1233
 
1234
-		$menu_item_value['url'] = esc_url_raw( $menu_item_value['url'] );
1235
-		if ( ! get_post_status_object( $menu_item_value['status'] ) ) {
1234
+		$menu_item_value['url'] = esc_url_raw($menu_item_value['url']);
1235
+		if ( ! get_post_status_object($menu_item_value['status'])) {
1236 1236
 			$menu_item_value['status'] = 'publish';
1237 1237
 		}
1238 1238
 
1239 1239
 		/** This filter is documented in wp-includes/class-wp-customize-setting.php */
1240
-		return apply_filters( "customize_sanitize_{$this->id}", $menu_item_value, $this );
1240
+		return apply_filters("customize_sanitize_{$this->id}", $menu_item_value, $this);
1241 1241
 	}
1242 1242
 
1243 1243
 	/**
@@ -1259,29 +1259,29 @@  discard block
 block discarded – undo
1259 1259
 	 *                           should consist of.
1260 1260
 	 * @return null|void
1261 1261
 	 */
1262
-	protected function update( $value ) {
1263
-		if ( $this->is_updated ) {
1262
+	protected function update($value) {
1263
+		if ($this->is_updated) {
1264 1264
 			return;
1265 1265
 		}
1266 1266
 
1267 1267
 		$this->is_updated = true;
1268
-		$is_placeholder   = ( $this->post_id < 0 );
1269
-		$is_delete        = ( false === $value );
1268
+		$is_placeholder   = ($this->post_id < 0);
1269
+		$is_delete        = (false === $value);
1270 1270
 
1271 1271
 		// Update the cached value.
1272 1272
 		$this->value = $value;
1273 1273
 
1274
-		add_filter( 'customize_save_response', array( $this, 'amend_customize_save_response' ) );
1274
+		add_filter('customize_save_response', array($this, 'amend_customize_save_response'));
1275 1275
 
1276
-		if ( $is_delete ) {
1276
+		if ($is_delete) {
1277 1277
 			// If the current setting post is a placeholder, a delete request is a no-op.
1278
-			if ( $is_placeholder ) {
1278
+			if ($is_placeholder) {
1279 1279
 				$this->update_status = 'deleted';
1280 1280
 			} else {
1281
-				$r = wp_delete_post( $this->post_id, true );
1281
+				$r = wp_delete_post($this->post_id, true);
1282 1282
 
1283
-				if ( false === $r ) {
1284
-					$this->update_error  = new WP_Error( 'delete_failure' );
1283
+				if (false === $r) {
1284
+					$this->update_error  = new WP_Error('delete_failure');
1285 1285
 					$this->update_status = 'error';
1286 1286
 				} else {
1287 1287
 					$this->update_status = 'deleted';
@@ -1291,25 +1291,25 @@  discard block
 block discarded – undo
1291 1291
 		} else {
1292 1292
 
1293 1293
 			// Handle saving menu items for menus that are being newly-created.
1294
-			if ( $value['nav_menu_term_id'] < 0 ) {
1295
-				$nav_menu_setting_id = sprintf( 'nav_menu[%s]', $value['nav_menu_term_id'] );
1296
-				$nav_menu_setting    = $this->manager->get_setting( $nav_menu_setting_id );
1294
+			if ($value['nav_menu_term_id'] < 0) {
1295
+				$nav_menu_setting_id = sprintf('nav_menu[%s]', $value['nav_menu_term_id']);
1296
+				$nav_menu_setting    = $this->manager->get_setting($nav_menu_setting_id);
1297 1297
 
1298
-				if ( ! $nav_menu_setting || ! ( $nav_menu_setting instanceof WP_Customize_Nav_Menu_Setting ) ) {
1298
+				if ( ! $nav_menu_setting || ! ($nav_menu_setting instanceof WP_Customize_Nav_Menu_Setting)) {
1299 1299
 					$this->update_status = 'error';
1300
-					$this->update_error  = new WP_Error( 'unexpected_nav_menu_setting' );
1300
+					$this->update_error  = new WP_Error('unexpected_nav_menu_setting');
1301 1301
 					return;
1302 1302
 				}
1303 1303
 
1304
-				if ( false === $nav_menu_setting->save() ) {
1304
+				if (false === $nav_menu_setting->save()) {
1305 1305
 					$this->update_status = 'error';
1306
-					$this->update_error  = new WP_Error( 'nav_menu_setting_failure' );
1306
+					$this->update_error  = new WP_Error('nav_menu_setting_failure');
1307 1307
 					return;
1308 1308
 				}
1309 1309
 
1310
-				if ( $nav_menu_setting->previous_term_id !== intval( $value['nav_menu_term_id'] ) ) {
1310
+				if ($nav_menu_setting->previous_term_id !== intval($value['nav_menu_term_id'])) {
1311 1311
 					$this->update_status = 'error';
1312
-					$this->update_error  = new WP_Error( 'unexpected_previous_term_id' );
1312
+					$this->update_error  = new WP_Error('unexpected_previous_term_id');
1313 1313
 					return;
1314 1314
 				}
1315 1315
 
@@ -1317,25 +1317,25 @@  discard block
 block discarded – undo
1317 1317
 			}
1318 1318
 
1319 1319
 			// Handle saving a nav menu item that is a child of a nav menu item being newly-created.
1320
-			if ( $value['menu_item_parent'] < 0 ) {
1321
-				$parent_nav_menu_item_setting_id = sprintf( 'nav_menu_item[%s]', $value['menu_item_parent'] );
1322
-				$parent_nav_menu_item_setting    = $this->manager->get_setting( $parent_nav_menu_item_setting_id );
1320
+			if ($value['menu_item_parent'] < 0) {
1321
+				$parent_nav_menu_item_setting_id = sprintf('nav_menu_item[%s]', $value['menu_item_parent']);
1322
+				$parent_nav_menu_item_setting    = $this->manager->get_setting($parent_nav_menu_item_setting_id);
1323 1323
 
1324
-				if ( ! $parent_nav_menu_item_setting || ! ( $parent_nav_menu_item_setting instanceof WP_Customize_Nav_Menu_Item_Setting ) ) {
1324
+				if ( ! $parent_nav_menu_item_setting || ! ($parent_nav_menu_item_setting instanceof WP_Customize_Nav_Menu_Item_Setting)) {
1325 1325
 					$this->update_status = 'error';
1326
-					$this->update_error  = new WP_Error( 'unexpected_nav_menu_item_setting' );
1326
+					$this->update_error  = new WP_Error('unexpected_nav_menu_item_setting');
1327 1327
 					return;
1328 1328
 				}
1329 1329
 
1330
-				if ( false === $parent_nav_menu_item_setting->save() ) {
1330
+				if (false === $parent_nav_menu_item_setting->save()) {
1331 1331
 					$this->update_status = 'error';
1332
-					$this->update_error  = new WP_Error( 'nav_menu_item_setting_failure' );
1332
+					$this->update_error  = new WP_Error('nav_menu_item_setting_failure');
1333 1333
 					return;
1334 1334
 				}
1335 1335
 
1336
-				if ( $parent_nav_menu_item_setting->previous_post_id !== intval( $value['menu_item_parent'] ) ) {
1336
+				if ($parent_nav_menu_item_setting->previous_post_id !== intval($value['menu_item_parent'])) {
1337 1337
 					$this->update_status = 'error';
1338
-					$this->update_error  = new WP_Error( 'unexpected_previous_post_id' );
1338
+					$this->update_error  = new WP_Error('unexpected_previous_post_id');
1339 1339
 					return;
1340 1340
 				}
1341 1341
 
@@ -1365,11 +1365,11 @@  discard block
 block discarded – undo
1365 1365
 				$menu_item_data
1366 1366
 			);
1367 1367
 
1368
-			if ( is_wp_error( $r ) ) {
1368
+			if (is_wp_error($r)) {
1369 1369
 				$this->update_status = 'error';
1370 1370
 				$this->update_error = $r;
1371 1371
 			} else {
1372
-				if ( $is_placeholder ) {
1372
+				if ($is_placeholder) {
1373 1373
 					$this->previous_post_id = $this->post_id;
1374 1374
 					$this->post_id = $r;
1375 1375
 					$this->update_status = 'inserted';
@@ -1392,8 +1392,8 @@  discard block
 block discarded – undo
1392 1392
 	 * @param array $data Additional information passed back to the 'saved' event on `wp.customize`.
1393 1393
 	 * @return array Save response data.
1394 1394
 	 */
1395
-	public function amend_customize_save_response( $data ) {
1396
-		if ( ! isset( $data['nav_menu_item_updates'] ) ) {
1395
+	public function amend_customize_save_response($data) {
1396
+		if ( ! isset($data['nav_menu_item_updates'])) {
1397 1397
 			$data['nav_menu_item_updates'] = array();
1398 1398
 		}
1399 1399
 
@@ -1548,18 +1548,18 @@  discard block
 block discarded – undo
1548 1548
 	 *
1549 1549
 	 * @throws Exception If $id is not valid for this setting type.
1550 1550
 	 */
1551
-	public function __construct( WP_Customize_Manager $manager, $id, array $args = array() ) {
1552
-		if ( empty( $manager->nav_menus ) ) {
1553
-			throw new Exception( 'Expected WP_Customize_Manager::$nav_menus to be set.' );
1551
+	public function __construct(WP_Customize_Manager $manager, $id, array $args = array()) {
1552
+		if (empty($manager->nav_menus)) {
1553
+			throw new Exception('Expected WP_Customize_Manager::$nav_menus to be set.');
1554 1554
 		}
1555 1555
 
1556
-		if ( ! preg_match( self::ID_PATTERN, $id, $matches ) ) {
1557
-			throw new Exception( "Illegal widget setting ID: $id" );
1556
+		if ( ! preg_match(self::ID_PATTERN, $id, $matches)) {
1557
+			throw new Exception("Illegal widget setting ID: $id");
1558 1558
 		}
1559 1559
 
1560
-		$this->term_id = intval( $matches['id'] );
1560
+		$this->term_id = intval($matches['id']);
1561 1561
 
1562
-		parent::__construct( $manager, $id, $args );
1562
+		parent::__construct($manager, $id, $args);
1563 1563
 	}
1564 1564
 
1565 1565
 	/**
@@ -1573,11 +1573,11 @@  discard block
 block discarded – undo
1573 1573
 	 * @return array Instance data.
1574 1574
 	 */
1575 1575
 	public function value() {
1576
-		if ( $this->is_previewed && $this->_previewed_blog_id === get_current_blog_id() ) {
1576
+		if ($this->is_previewed && $this->_previewed_blog_id === get_current_blog_id()) {
1577 1577
 			$undefined  = new stdClass(); // Symbol.
1578
-			$post_value = $this->post_value( $undefined );
1578
+			$post_value = $this->post_value($undefined);
1579 1579
 
1580
-			if ( $undefined === $post_value ) {
1580
+			if ($undefined === $post_value) {
1581 1581
 				$value = $this->_original_value;
1582 1582
 			} else {
1583 1583
 				$value = $post_value;
@@ -1586,22 +1586,22 @@  discard block
 block discarded – undo
1586 1586
 			$value = false;
1587 1587
 
1588 1588
 			// Note that a term_id of less than one indicates a nav_menu not yet inserted.
1589
-			if ( $this->term_id > 0 ) {
1590
-				$term = wp_get_nav_menu_object( $this->term_id );
1589
+			if ($this->term_id > 0) {
1590
+				$term = wp_get_nav_menu_object($this->term_id);
1591 1591
 
1592
-				if ( $term ) {
1593
-					$value = wp_array_slice_assoc( (array) $term, array_keys( $this->default ) );
1592
+				if ($term) {
1593
+					$value = wp_array_slice_assoc((array) $term, array_keys($this->default));
1594 1594
 
1595
-					$nav_menu_options  = (array) get_option( 'nav_menu_options', array() );
1595
+					$nav_menu_options  = (array) get_option('nav_menu_options', array());
1596 1596
 					$value['auto_add'] = false;
1597 1597
 
1598
-					if ( isset( $nav_menu_options['auto_add'] ) && is_array( $nav_menu_options['auto_add'] ) ) {
1599
-						$value['auto_add'] = in_array( $term->term_id, $nav_menu_options['auto_add'] );
1598
+					if (isset($nav_menu_options['auto_add']) && is_array($nav_menu_options['auto_add'])) {
1599
+						$value['auto_add'] = in_array($term->term_id, $nav_menu_options['auto_add']);
1600 1600
 					}
1601 1601
 				}
1602 1602
 			}
1603 1603
 
1604
-			if ( ! is_array( $value ) ) {
1604
+			if ( ! is_array($value)) {
1605 1605
 				$value = $this->default;
1606 1606
 			}
1607 1607
 		}
@@ -1617,7 +1617,7 @@  discard block
 block discarded – undo
1617 1617
 	 * @see WP_Customize_Manager::post_value()
1618 1618
 	 */
1619 1619
 	public function preview() {
1620
-		if ( $this->is_previewed ) {
1620
+		if ($this->is_previewed) {
1621 1621
 			return;
1622 1622
 		}
1623 1623
 
@@ -1625,10 +1625,10 @@  discard block
 block discarded – undo
1625 1625
 		$this->_original_value    = $this->value();
1626 1626
 		$this->_previewed_blog_id = get_current_blog_id();
1627 1627
 
1628
-		add_filter( 'wp_get_nav_menus', array( $this, 'filter_wp_get_nav_menus' ), 10, 2 );
1629
-		add_filter( 'wp_get_nav_menu_object', array( $this, 'filter_wp_get_nav_menu_object' ), 10, 2 );
1630
-		add_filter( 'default_option_nav_menu_options', array( $this, 'filter_nav_menu_options' ) );
1631
-		add_filter( 'option_nav_menu_options', array( $this, 'filter_nav_menu_options' ) );
1628
+		add_filter('wp_get_nav_menus', array($this, 'filter_wp_get_nav_menus'), 10, 2);
1629
+		add_filter('wp_get_nav_menu_object', array($this, 'filter_wp_get_nav_menu_object'), 10, 2);
1630
+		add_filter('default_option_nav_menu_options', array($this, 'filter_nav_menu_options'));
1631
+		add_filter('option_nav_menu_options', array($this, 'filter_nav_menu_options'));
1632 1632
 	}
1633 1633
 
1634 1634
 	/**
@@ -1643,47 +1643,47 @@  discard block
 block discarded – undo
1643 1643
 	 * @param array $args  An array of arguments used to retrieve menu objects.
1644 1644
 	 * @return array
1645 1645
 	 */
1646
-	public function filter_wp_get_nav_menus( $menus, $args ) {
1647
-		if ( get_current_blog_id() !== $this->_previewed_blog_id ) {
1646
+	public function filter_wp_get_nav_menus($menus, $args) {
1647
+		if (get_current_blog_id() !== $this->_previewed_blog_id) {
1648 1648
 			return $menus;
1649 1649
 		}
1650 1650
 
1651 1651
 		$setting_value = $this->value();
1652
-		$is_delete = ( false === $setting_value );
1652
+		$is_delete = (false === $setting_value);
1653 1653
 		$index = -1;
1654 1654
 
1655 1655
 		// Find the existing menu item's position in the list.
1656
-		foreach ( $menus as $i => $menu ) {
1657
-			if ( (int) $this->term_id === (int) $menu->term_id || (int) $this->previous_term_id === (int) $menu->term_id ) {
1656
+		foreach ($menus as $i => $menu) {
1657
+			if ((int) $this->term_id === (int) $menu->term_id || (int) $this->previous_term_id === (int) $menu->term_id) {
1658 1658
 				$index = $i;
1659 1659
 				break;
1660 1660
 			}
1661 1661
 		}
1662 1662
 
1663
-		if ( $is_delete ) {
1663
+		if ($is_delete) {
1664 1664
 			// Handle deleted menu by removing it from the list.
1665 1665
 			if ( -1 !== $index ) {
1666
-				array_splice( $menus, $index, 1 );
1666
+				array_splice($menus, $index, 1);
1667 1667
 			}
1668 1668
 		} else {
1669 1669
 			// Handle menus being updated or inserted.
1670
-			$menu_obj = (object) array_merge( array(
1670
+			$menu_obj = (object) array_merge(array(
1671 1671
 				'term_id'          => $this->term_id,
1672 1672
 				'term_taxonomy_id' => $this->term_id,
1673
-				'slug'             => sanitize_title( $setting_value['name'] ),
1673
+				'slug'             => sanitize_title($setting_value['name']),
1674 1674
 				'count'            => 0,
1675 1675
 				'term_group'       => 0,
1676 1676
 				'taxonomy'         => self::TAXONOMY,
1677 1677
 				'filter'           => 'raw',
1678
-			), $setting_value );
1678
+			), $setting_value);
1679 1679
 
1680
-			array_splice( $menus, $index, ( -1 === $index ? 0 : 1 ), array( $menu_obj ) );
1680
+			array_splice($menus, $index, ( -1 === $index ? 0 : 1 ), array($menu_obj));
1681 1681
 		}
1682 1682
 
1683 1683
 		// Make sure the menu objects get re-sorted after an update/insert.
1684
-		if ( ! $is_delete && ! empty( $args['orderby'] ) ) {
1684
+		if ( ! $is_delete && ! empty($args['orderby'])) {
1685 1685
 			$this->_current_menus_sort_orderby = $args['orderby'];
1686
-			usort( $menus, array( $this, '_sort_menus_by_orderby' ) );
1686
+			usort($menus, array($this, '_sort_menus_by_orderby'));
1687 1687
 		}
1688 1688
 		// @todo add support for $args['hide_empty'] === true
1689 1689
 
@@ -1715,9 +1715,9 @@  discard block
 block discarded – undo
1715 1715
 	 *
1716 1716
 	 * @see WP_Customize_Nav_Menu_Setting::filter_wp_get_nav_menus()
1717 1717
 	 */
1718
-	protected function _sort_menus_by_orderby( $menu1, $menu2 ) {
1718
+	protected function _sort_menus_by_orderby($menu1, $menu2) {
1719 1719
 		$key = $this->_current_menus_sort_orderby;
1720
-		return strcmp( $menu1->$key, $menu2->$key );
1720
+		return strcmp($menu1->$key, $menu2->$key);
1721 1721
 	}
1722 1722
 
1723 1723
 	/**
@@ -1734,39 +1734,39 @@  discard block
 block discarded – undo
1734 1734
 	 * @param string      $menu_id  ID of the nav_menu term. Requests by slug or name will be ignored.
1735 1735
 	 * @return object|null
1736 1736
 	 */
1737
-	public function filter_wp_get_nav_menu_object( $menu_obj, $menu_id ) {
1737
+	public function filter_wp_get_nav_menu_object($menu_obj, $menu_id) {
1738 1738
 		$ok = (
1739 1739
 			get_current_blog_id() === $this->_previewed_blog_id
1740 1740
 			&&
1741
-			is_int( $menu_id )
1741
+			is_int($menu_id)
1742 1742
 			&&
1743 1743
 			$menu_id === $this->term_id
1744 1744
 		);
1745
-		if ( ! $ok ) {
1745
+		if ( ! $ok) {
1746 1746
 			return $menu_obj;
1747 1747
 		}
1748 1748
 
1749 1749
 		$setting_value = $this->value();
1750 1750
 
1751 1751
 		// Handle deleted menus.
1752
-		if ( false === $setting_value ) {
1752
+		if (false === $setting_value) {
1753 1753
 			return false;
1754 1754
 		}
1755 1755
 
1756 1756
 		// Handle sanitization failure by preventing short-circuiting.
1757
-		if ( null === $setting_value ) {
1757
+		if (null === $setting_value) {
1758 1758
 			return $menu_obj;
1759 1759
 		}
1760 1760
 
1761
-		$menu_obj = (object) array_merge( array(
1761
+		$menu_obj = (object) array_merge(array(
1762 1762
 				'term_id'          => $this->term_id,
1763 1763
 				'term_taxonomy_id' => $this->term_id,
1764
-				'slug'             => sanitize_title( $setting_value['name'] ),
1764
+				'slug'             => sanitize_title($setting_value['name']),
1765 1765
 				'count'            => 0,
1766 1766
 				'term_group'       => 0,
1767 1767
 				'taxonomy'         => self::TAXONOMY,
1768 1768
 				'filter'           => 'raw',
1769
-			), $setting_value );
1769
+			), $setting_value);
1770 1770
 
1771 1771
 		return $menu_obj;
1772 1772
 	}
@@ -1780,8 +1780,8 @@  discard block
 block discarded – undo
1780 1780
 	 * @param array $nav_menu_options Nav menu options including auto_add.
1781 1781
 	 * @return array (Kaybe) modified nav menu options.
1782 1782
 	 */
1783
-	public function filter_nav_menu_options( $nav_menu_options ) {
1784
-		if ( $this->_previewed_blog_id !== get_current_blog_id() ) {
1783
+	public function filter_nav_menu_options($nav_menu_options) {
1784
+		if ($this->_previewed_blog_id !== get_current_blog_id()) {
1785 1785
 			return $nav_menu_options;
1786 1786
 		}
1787 1787
 
@@ -1808,14 +1808,14 @@  discard block
 block discarded – undo
1808 1808
 	 * @return array|false|null Null if an input isn't valid. False if it is marked for deletion.
1809 1809
 	 *                          Otherwise the sanitized value.
1810 1810
 	 */
1811
-	public function sanitize( $value ) {
1811
+	public function sanitize($value) {
1812 1812
 		// Menu is marked for deletion.
1813
-		if ( false === $value ) {
1813
+		if (false === $value) {
1814 1814
 			return $value;
1815 1815
 		}
1816 1816
 
1817 1817
 		// Invalid.
1818
-		if ( ! is_array( $value ) ) {
1818
+		if ( ! is_array($value)) {
1819 1819
 			return null;
1820 1820
 		}
1821 1821
 
@@ -1825,20 +1825,20 @@  discard block
 block discarded – undo
1825 1825
 			'parent'      => 0,
1826 1826
 			'auto_add'    => false,
1827 1827
 		);
1828
-		$value = array_merge( $default, $value );
1829
-		$value = wp_array_slice_assoc( $value, array_keys( $default ) );
1828
+		$value = array_merge($default, $value);
1829
+		$value = wp_array_slice_assoc($value, array_keys($default));
1830 1830
 
1831
-		$value['name']        = trim( esc_html( $value['name'] ) ); // This sanitization code is used in wp-admin/nav-menus.php.
1832
-		$value['description'] = sanitize_text_field( $value['description'] );
1833
-		$value['parent']      = max( 0, intval( $value['parent'] ) );
1834
-		$value['auto_add']    = ! empty( $value['auto_add'] );
1831
+		$value['name']        = trim(esc_html($value['name'])); // This sanitization code is used in wp-admin/nav-menus.php.
1832
+		$value['description'] = sanitize_text_field($value['description']);
1833
+		$value['parent']      = max(0, intval($value['parent']));
1834
+		$value['auto_add']    = ! empty($value['auto_add']);
1835 1835
 
1836
-		if ( '' === $value['name'] ) {
1837
-			$value['name'] = _x( '(unnamed)', 'Missing menu name.' );
1836
+		if ('' === $value['name']) {
1837
+			$value['name'] = _x('(unnamed)', 'Missing menu name.');
1838 1838
 		}
1839 1839
 
1840 1840
 		/** This filter is documented in wp-includes/class-wp-customize-setting.php */
1841
-		return apply_filters( "customize_sanitize_{$this->id}", $value, $this );
1841
+		return apply_filters("customize_sanitize_{$this->id}", $value, $this);
1842 1842
 	}
1843 1843
 
1844 1844
 	/**
@@ -1877,26 +1877,26 @@  discard block
 block discarded – undo
1877 1877
 	 * }
1878 1878
 	 * @return null|void
1879 1879
 	 */
1880
-	protected function update( $value ) {
1881
-		if ( $this->is_updated ) {
1880
+	protected function update($value) {
1881
+		if ($this->is_updated) {
1882 1882
 			return;
1883 1883
 		}
1884 1884
 
1885 1885
 		$this->is_updated = true;
1886
-		$is_placeholder   = ( $this->term_id < 0 );
1887
-		$is_delete        = ( false === $value );
1886
+		$is_placeholder   = ($this->term_id < 0);
1887
+		$is_delete        = (false === $value);
1888 1888
 
1889
-		add_filter( 'customize_save_response', array( $this, 'amend_customize_save_response' ) );
1889
+		add_filter('customize_save_response', array($this, 'amend_customize_save_response'));
1890 1890
 
1891 1891
 		$auto_add = null;
1892
-		if ( $is_delete ) {
1892
+		if ($is_delete) {
1893 1893
 			// If the current setting term is a placeholder, a delete request is a no-op.
1894
-			if ( $is_placeholder ) {
1894
+			if ($is_placeholder) {
1895 1895
 				$this->update_status = 'deleted';
1896 1896
 			} else {
1897
-				$r = wp_delete_nav_menu( $this->term_id );
1897
+				$r = wp_delete_nav_menu($this->term_id);
1898 1898
 
1899
-				if ( is_wp_error( $r ) ) {
1899
+				if (is_wp_error($r)) {
1900 1900
 					$this->update_status = 'error';
1901 1901
 					$this->update_error  = $r;
1902 1902
 				} else {
@@ -1906,25 +1906,25 @@  discard block
 block discarded – undo
1906 1906
 			}
1907 1907
 		} else {
1908 1908
 			// Insert or update menu.
1909
-			$menu_data = wp_array_slice_assoc( $value, array( 'description', 'parent' ) );
1909
+			$menu_data = wp_array_slice_assoc($value, array('description', 'parent'));
1910 1910
 			$menu_data['menu-name'] = $value['name'];
1911 1911
 
1912 1912
 			$menu_id = $is_placeholder ? 0 : $this->term_id;
1913
-			$r = wp_update_nav_menu_object( $menu_id, $menu_data );
1913
+			$r = wp_update_nav_menu_object($menu_id, $menu_data);
1914 1914
 			$original_name = $menu_data['menu-name'];
1915 1915
 			$name_conflict_suffix = 1;
1916
-			while ( is_wp_error( $r ) && 'menu_exists' === $r->get_error_code() ) {
1916
+			while (is_wp_error($r) && 'menu_exists' === $r->get_error_code()) {
1917 1917
 				$name_conflict_suffix += 1;
1918 1918
 				/* translators: 1: original menu name, 2: duplicate count */
1919
-				$menu_data['menu-name'] = sprintf( __( '%1$s (%2$d)' ), $original_name, $name_conflict_suffix );
1920
-				$r = wp_update_nav_menu_object( $menu_id, $menu_data );
1919
+				$menu_data['menu-name'] = sprintf(__('%1$s (%2$d)'), $original_name, $name_conflict_suffix);
1920
+				$r = wp_update_nav_menu_object($menu_id, $menu_data);
1921 1921
 			}
1922 1922
 
1923
-			if ( is_wp_error( $r ) ) {
1923
+			if (is_wp_error($r)) {
1924 1924
 				$this->update_status = 'error';
1925 1925
 				$this->update_error  = $r;
1926 1926
 			} else {
1927
-				if ( $is_placeholder ) {
1927
+				if ($is_placeholder) {
1928 1928
 					$this->previous_term_id = $this->term_id;
1929 1929
 					$this->term_id          = $r;
1930 1930
 					$this->update_status    = 'inserted';
@@ -1936,47 +1936,47 @@  discard block
 block discarded – undo
1936 1936
 			}
1937 1937
 		}
1938 1938
 
1939
-		if ( null !== $auto_add ) {
1939
+		if (null !== $auto_add) {
1940 1940
 			$nav_menu_options = $this->filter_nav_menu_options_value(
1941
-				(array) get_option( 'nav_menu_options', array() ),
1941
+				(array) get_option('nav_menu_options', array()),
1942 1942
 				$this->term_id,
1943 1943
 				$auto_add
1944 1944
 			);
1945
-			update_option( 'nav_menu_options', $nav_menu_options );
1945
+			update_option('nav_menu_options', $nav_menu_options);
1946 1946
 		}
1947 1947
 
1948
-		if ( 'inserted' === $this->update_status ) {
1948
+		if ('inserted' === $this->update_status) {
1949 1949
 			// Make sure that new menus assigned to nav menu locations use their new IDs.
1950
-			foreach ( $this->manager->settings() as $setting ) {
1951
-				if ( ! preg_match( '/^nav_menu_locations\[/', $setting->id ) ) {
1950
+			foreach ($this->manager->settings() as $setting) {
1951
+				if ( ! preg_match('/^nav_menu_locations\[/', $setting->id)) {
1952 1952
 					continue;
1953 1953
 				}
1954 1954
 
1955
-				$post_value = $setting->post_value( null );
1956
-				if ( ! is_null( $post_value ) && $this->previous_term_id === intval( $post_value ) ) {
1957
-					$this->manager->set_post_value( $setting->id, $this->term_id );
1955
+				$post_value = $setting->post_value(null);
1956
+				if ( ! is_null($post_value) && $this->previous_term_id === intval($post_value)) {
1957
+					$this->manager->set_post_value($setting->id, $this->term_id);
1958 1958
 					$setting->save();
1959 1959
 				}
1960 1960
 			}
1961 1961
 
1962 1962
 			// Make sure that any nav_menu widgets referencing the placeholder nav menu get updated and sent back to client.
1963
-			foreach ( array_keys( $this->manager->unsanitized_post_values() ) as $setting_id ) {
1964
-				$nav_menu_widget_setting = $this->manager->get_setting( $setting_id );
1965
-				if ( ! $nav_menu_widget_setting || ! preg_match( '/^widget_nav_menu\[/', $nav_menu_widget_setting->id ) ) {
1963
+			foreach (array_keys($this->manager->unsanitized_post_values()) as $setting_id) {
1964
+				$nav_menu_widget_setting = $this->manager->get_setting($setting_id);
1965
+				if ( ! $nav_menu_widget_setting || ! preg_match('/^widget_nav_menu\[/', $nav_menu_widget_setting->id)) {
1966 1966
 					continue;
1967 1967
 				}
1968 1968
 
1969 1969
 				$widget_instance = $nav_menu_widget_setting->post_value(); // Note that this calls WP_Customize_Widgets::sanitize_widget_instance().
1970
-				if ( empty( $widget_instance['nav_menu'] ) || intval( $widget_instance['nav_menu'] ) !== $this->previous_term_id ) {
1970
+				if (empty($widget_instance['nav_menu']) || intval($widget_instance['nav_menu']) !== $this->previous_term_id) {
1971 1971
 					continue;
1972 1972
 				}
1973 1973
 
1974 1974
 				$widget_instance['nav_menu'] = $this->term_id;
1975
-				$updated_widget_instance = $this->manager->widgets->sanitize_widget_js_instance( $widget_instance );
1976
-				$this->manager->set_post_value( $nav_menu_widget_setting->id, $updated_widget_instance );
1975
+				$updated_widget_instance = $this->manager->widgets->sanitize_widget_js_instance($widget_instance);
1976
+				$this->manager->set_post_value($nav_menu_widget_setting->id, $updated_widget_instance);
1977 1977
 				$nav_menu_widget_setting->save();
1978 1978
 
1979
-				$this->_widget_nav_menu_updates[ $nav_menu_widget_setting->id ] = $updated_widget_instance;
1979
+				$this->_widget_nav_menu_updates[$nav_menu_widget_setting->id] = $updated_widget_instance;
1980 1980
 			}
1981 1981
 		}
1982 1982
 	}
@@ -1995,17 +1995,17 @@  discard block
 block discarded – undo
1995 1995
 	 * @param bool  $auto_add         Whether to auto-add or not.
1996 1996
 	 * @return array (Maybe) modified nav_menu_otions array.
1997 1997
 	 */
1998
-	protected function filter_nav_menu_options_value( $nav_menu_options, $menu_id, $auto_add ) {
1998
+	protected function filter_nav_menu_options_value($nav_menu_options, $menu_id, $auto_add) {
1999 1999
 		$nav_menu_options = (array) $nav_menu_options;
2000
-		if ( ! isset( $nav_menu_options['auto_add'] ) ) {
2000
+		if ( ! isset($nav_menu_options['auto_add'])) {
2001 2001
 			$nav_menu_options['auto_add'] = array();
2002 2002
 		}
2003 2003
 
2004
-		$i = array_search( $menu_id, $nav_menu_options['auto_add'] );
2005
-		if ( $auto_add && false === $i ) {
2006
-			array_push( $nav_menu_options['auto_add'], $this->term_id );
2007
-		} elseif ( ! $auto_add && false !== $i ) {
2008
-			array_splice( $nav_menu_options['auto_add'], $i, 1 );
2004
+		$i = array_search($menu_id, $nav_menu_options['auto_add']);
2005
+		if ($auto_add && false === $i) {
2006
+			array_push($nav_menu_options['auto_add'], $this->term_id);
2007
+		} elseif ( ! $auto_add && false !== $i) {
2008
+			array_splice($nav_menu_options['auto_add'], $i, 1);
2009 2009
 		}
2010 2010
 
2011 2011
 		return $nav_menu_options;
@@ -2022,11 +2022,11 @@  discard block
 block discarded – undo
2022 2022
 	 * @param array $data Additional information passed back to the 'saved' event on `wp.customize`.
2023 2023
 	 * @return array Export data.
2024 2024
 	 */
2025
-	public function amend_customize_save_response( $data ) {
2026
-		if ( ! isset( $data['nav_menu_updates'] ) ) {
2025
+	public function amend_customize_save_response($data) {
2026
+		if ( ! isset($data['nav_menu_updates'])) {
2027 2027
 			$data['nav_menu_updates'] = array();
2028 2028
 		}
2029
-		if ( ! isset( $data['widget_nav_menu_updates'] ) ) {
2029
+		if ( ! isset($data['widget_nav_menu_updates'])) {
2030 2030
 			$data['widget_nav_menu_updates'] = array();
2031 2031
 		}
2032 2032
 
Please login to merge, or discard this patch.
Braces   +70 added lines, -47 removed lines patch added patch discarded remove patch
@@ -91,8 +91,9 @@  discard block
 block discarded – undo
91 91
 	public function __construct( $manager, $id, $args = array() ) {
92 92
 		$keys = array_keys( get_object_vars( $this ) );
93 93
 		foreach ( $keys as $key ) {
94
-			if ( isset( $args[ $key ] ) )
95
-				$this->$key = $args[ $key ];
94
+			if ( isset( $args[ $key ] ) ) {
95
+							$this->$key = $args[ $key ];
96
+			}
96 97
 		}
97 98
 
98 99
 		$this->manager = $manager;
@@ -104,14 +105,17 @@  discard block
 block discarded – undo
104 105
 
105 106
 		// Rebuild the ID.
106 107
 		$this->id = $this->id_data[ 'base' ];
107
-		if ( ! empty( $this->id_data[ 'keys' ] ) )
108
-			$this->id .= '[' . implode( '][', $this->id_data[ 'keys' ] ) . ']';
108
+		if ( ! empty( $this->id_data[ 'keys' ] ) ) {
109
+					$this->id .= '[' . implode( '][', $this->id_data[ 'keys' ] ) . ']';
110
+		}
109 111
 
110
-		if ( $this->sanitize_callback )
111
-			add_filter( "customize_sanitize_{$this->id}", $this->sanitize_callback, 10, 2 );
112
+		if ( $this->sanitize_callback ) {
113
+					add_filter( "customize_sanitize_{$this->id}", $this->sanitize_callback, 10, 2 );
114
+		}
112 115
 
113
-		if ( $this->sanitize_js_callback )
114
-			add_filter( "customize_sanitize_js_{$this->id}", $this->sanitize_js_callback, 10, 2 );
116
+		if ( $this->sanitize_js_callback ) {
117
+					add_filter( "customize_sanitize_js_{$this->id}", $this->sanitize_js_callback, 10, 2 );
118
+		}
115 119
 	}
116 120
 
117 121
 	/**
@@ -165,9 +169,9 @@  discard block
 block discarded – undo
165 169
 				add_filter( 'theme_mod_' . $this->id_data[ 'base' ], array( $this, '_preview_filter' ) );
166 170
 				break;
167 171
 			case 'option' :
168
-				if ( empty( $this->id_data[ 'keys' ] ) )
169
-					add_filter( 'pre_option_' . $this->id_data[ 'base' ], array( $this, '_preview_filter' ) );
170
-				else {
172
+				if ( empty( $this->id_data[ 'keys' ] ) ) {
173
+									add_filter( 'pre_option_' . $this->id_data[ 'base' ], array( $this, '_preview_filter' ) );
174
+				} else {
171 175
 					add_filter( 'option_' . $this->id_data[ 'base' ], array( $this, '_preview_filter' ) );
172 176
 					add_filter( 'default_option_' . $this->id_data[ 'base' ], array( $this, '_preview_filter' ) );
173 177
 				}
@@ -240,8 +244,9 @@  discard block
 block discarded – undo
240 244
 	final public function save() {
241 245
 		$value = $this->post_value();
242 246
 
243
-		if ( ! $this->check_capabilities() || ! isset( $value ) )
244
-			return false;
247
+		if ( ! $this->check_capabilities() || ! isset( $value ) ) {
248
+					return false;
249
+		}
245 250
 
246 251
 		/**
247 252
 		 * Fires when the WP_Customize_Setting::save() method is called.
@@ -356,14 +361,16 @@  discard block
 block discarded – undo
356 361
 	 */
357 362
 	protected function _update_option( $value ) {
358 363
 		// Handle non-array option.
359
-		if ( empty( $this->id_data[ 'keys' ] ) )
360
-			return update_option( $this->id_data[ 'base' ], $value );
364
+		if ( empty( $this->id_data[ 'keys' ] ) ) {
365
+					return update_option( $this->id_data[ 'base' ], $value );
366
+		}
361 367
 
362 368
 		// Handle array-based options.
363 369
 		$options = get_option( $this->id_data[ 'base' ] );
364 370
 		$options = $this->multidimensional_replace( $options, $this->id_data[ 'keys' ], $value );
365
-		if ( isset( $options ) )
366
-			return update_option( $this->id_data[ 'base' ], $options );
371
+		if ( isset( $options ) ) {
372
+					return update_option( $this->id_data[ 'base' ], $options );
373
+		}
367 374
 	}
368 375
 
369 376
 	/**
@@ -401,8 +408,9 @@  discard block
 block discarded – undo
401 408
 		}
402 409
 
403 410
 		// Handle non-array value
404
-		if ( empty( $this->id_data[ 'keys' ] ) )
405
-			return $function( $this->id_data[ 'base' ], $this->default );
411
+		if ( empty( $this->id_data[ 'keys' ] ) ) {
412
+					return $function( $this->id_data[ 'base' ], $this->default );
413
+		}
406 414
 
407 415
 		// Handle array-based value
408 416
 		$values = $function( $this->id_data[ 'base' ] );
@@ -430,8 +438,9 @@  discard block
 block discarded – undo
430 438
 		 */
431 439
 		$value = apply_filters( "customize_sanitize_js_{$this->id}", $this->value(), $this );
432 440
 
433
-		if ( is_string( $value ) )
434
-			return html_entity_decode( $value, ENT_QUOTES, 'UTF-8');
441
+		if ( is_string( $value ) ) {
442
+					return html_entity_decode( $value, ENT_QUOTES, 'UTF-8');
443
+		}
435 444
 
436 445
 		return $value;
437 446
 	}
@@ -444,11 +453,13 @@  discard block
 block discarded – undo
444 453
 	 * @return bool False if theme doesn't support the setting or user can't change setting, otherwise true.
445 454
 	 */
446 455
 	final public function check_capabilities() {
447
-		if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) )
448
-			return false;
456
+		if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) ) {
457
+					return false;
458
+		}
449 459
 
450
-		if ( $this->theme_supports && ! call_user_func_array( 'current_theme_supports', (array) $this->theme_supports ) )
451
-			return false;
460
+		if ( $this->theme_supports && ! call_user_func_array( 'current_theme_supports', (array) $this->theme_supports ) ) {
461
+					return false;
462
+		}
452 463
 
453 464
 		return true;
454 465
 	}
@@ -464,21 +475,25 @@  discard block
 block discarded – undo
464 475
 	 * @return array|void Keys are 'root', 'node', and 'key'.
465 476
 	 */
466 477
 	final protected function multidimensional( &$root, $keys, $create = false ) {
467
-		if ( $create && empty( $root ) )
468
-			$root = array();
478
+		if ( $create && empty( $root ) ) {
479
+					$root = array();
480
+		}
469 481
 
470
-		if ( ! isset( $root ) || empty( $keys ) )
471
-			return;
482
+		if ( ! isset( $root ) || empty( $keys ) ) {
483
+					return;
484
+		}
472 485
 
473 486
 		$last = array_pop( $keys );
474 487
 		$node = &$root;
475 488
 
476 489
 		foreach ( $keys as $key ) {
477
-			if ( $create && ! isset( $node[ $key ] ) )
478
-				$node[ $key ] = array();
490
+			if ( $create && ! isset( $node[ $key ] ) ) {
491
+							$node[ $key ] = array();
492
+			}
479 493
 
480
-			if ( ! is_array( $node ) || ! isset( $node[ $key ] ) )
481
-				return;
494
+			if ( ! is_array( $node ) || ! isset( $node[ $key ] ) ) {
495
+							return;
496
+			}
482 497
 
483 498
 			$node = &$node[ $key ];
484 499
 		}
@@ -493,8 +508,9 @@  discard block
 block discarded – undo
493 508
 			}
494 509
 		}
495 510
 
496
-		if ( ! isset( $node[ $last ] ) )
497
-			return;
511
+		if ( ! isset( $node[ $last ] ) ) {
512
+					return;
513
+		}
498 514
 
499 515
 		return array(
500 516
 			'root' => &$root,
@@ -514,15 +530,18 @@  discard block
 block discarded – undo
514 530
 	 * @return
515 531
 	 */
516 532
 	final protected function multidimensional_replace( $root, $keys, $value ) {
517
-		if ( ! isset( $value ) )
518
-			return $root;
519
-		elseif ( empty( $keys ) ) // If there are no keys, we're replacing the root.
533
+		if ( ! isset( $value ) ) {
534
+					return $root;
535
+		} elseif ( empty( $keys ) ) {
536
+			// If there are no keys, we're replacing the root.
520 537
 			return $value;
538
+		}
521 539
 
522 540
 		$result = $this->multidimensional( $root, $keys, true );
523 541
 
524
-		if ( isset( $result ) )
525
-			$result['node'][ $result['key'] ] = $value;
542
+		if ( isset( $result ) ) {
543
+					$result['node'][ $result['key'] ] = $value;
544
+		}
526 545
 
527 546
 		return $root;
528 547
 	}
@@ -538,8 +557,10 @@  discard block
 block discarded – undo
538 557
 	 * @return mixed The requested value or the default value.
539 558
 	 */
540 559
 	final protected function multidimensional_get( $root, $keys, $default = null ) {
541
-		if ( empty( $keys ) ) // If there are no keys, test the root.
560
+		if ( empty( $keys ) ) {
561
+			// If there are no keys, test the root.
542 562
 			return isset( $root ) ? $root : $default;
563
+		}
543 564
 
544 565
 		$result = $this->multidimensional( $root, $keys );
545 566
 		return isset( $result ) ? $result['node'][ $result['key'] ] : $default;
@@ -601,13 +622,15 @@  discard block
 block discarded – undo
601 622
 
602 623
 		// If the value doesn't exist (removed or random),
603 624
 		// use the header_image value.
604
-		if ( ! $value )
605
-			$value = $this->manager->get_setting('header_image')->post_value();
625
+		if ( ! $value ) {
626
+					$value = $this->manager->get_setting('header_image')->post_value();
627
+		}
606 628
 
607
-		if ( is_array( $value ) && isset( $value['choice'] ) )
608
-			$custom_image_header->set_header_image( $value['choice'] );
609
-		else
610
-			$custom_image_header->set_header_image( $value );
629
+		if ( is_array( $value ) && isset( $value['choice'] ) ) {
630
+					$custom_image_header->set_header_image( $value['choice'] );
631
+		} else {
632
+					$custom_image_header->set_header_image( $value );
633
+		}
611 634
 	}
612 635
 }
613 636
 
Please login to merge, or discard this patch.
src/wp-includes/class-wp-customize-widgets.php 3 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -164,7 +164,6 @@  discard block
 block discarded – undo
164 164
 	 * @since 4.2.0
165 165
 	 * @access public
166 166
 	 *
167
-	 * @param false|array $setting_args The arguments to the WP_Customize_Setting constructor.
168 167
 	 * @param string      $setting_id   ID for dynamic setting, usually coming from `$_POST['customized']`.
169 168
 	 * @return false|array Setting arguments, false otherwise.
170 169
 	 */
@@ -184,7 +183,7 @@  discard block
 block discarded – undo
184 183
 	 *
185 184
 	 * @param string $name    Post value.
186 185
 	 * @param mixed  $default Default post value.
187
-	 * @return mixed Unslashed post value or default value.
186
+	 * @return string Unslashed post value or default value.
188 187
 	 */
189 188
 	protected function get_post_value( $name, $default = null ) {
190 189
 		if ( ! isset( $_POST[ $name ] ) ) {
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * WordPress Customize Widgets classes
4
- *
5
- * @package WordPress
6
- * @subpackage Customize
7
- * @since 3.9.0
8
- */
3
+	 * WordPress Customize Widgets classes
4
+	 *
5
+	 * @package WordPress
6
+	 * @subpackage Customize
7
+	 * @since 3.9.0
8
+	 */
9 9
 
10 10
 /**
11 11
  * Customize Widgets class.
@@ -1000,7 +1000,7 @@  discard block
 block discarded – undo
1000 1000
 	 *
1001 1001
 	 * @since 3.9.0
1002 1002
 	 * @access public
1003
-     *
1003
+	 *
1004 1004
 	 * @global array $wp_registered_sidebars
1005 1005
 	 * @global array $wp_registered_widgets
1006 1006
 	 */
Please login to merge, or discard this patch.
Spacing   +321 added lines, -321 removed lines patch added patch discarded remove patch
@@ -81,25 +81,25 @@  discard block
 block discarded – undo
81 81
 	 *
82 82
 	 * @param WP_Customize_Manager $manager Customize manager bootstrap instance.
83 83
 	 */
84
-	public function __construct( $manager ) {
84
+	public function __construct($manager) {
85 85
 		$this->manager = $manager;
86 86
 
87
-		add_filter( 'customize_dynamic_setting_args',          array( $this, 'filter_customize_dynamic_setting_args' ), 10, 2 );
88
-		add_action( 'after_setup_theme',                       array( $this, 'register_settings' ) );
89
-		add_action( 'wp_loaded',                               array( $this, 'override_sidebars_widgets_for_theme_switch' ) );
90
-		add_action( 'customize_controls_init',                 array( $this, 'customize_controls_init' ) );
91
-		add_action( 'customize_register',                      array( $this, 'schedule_customize_register' ), 1 );
92
-		add_action( 'customize_controls_enqueue_scripts',      array( $this, 'enqueue_scripts' ) );
93
-		add_action( 'customize_controls_print_styles',         array( $this, 'print_styles' ) );
94
-		add_action( 'customize_controls_print_scripts',        array( $this, 'print_scripts' ) );
95
-		add_action( 'customize_controls_print_footer_scripts', array( $this, 'print_footer_scripts' ) );
96
-		add_action( 'customize_controls_print_footer_scripts', array( $this, 'output_widget_control_templates' ) );
97
-		add_action( 'customize_preview_init',                  array( $this, 'customize_preview_init' ) );
98
-		add_filter( 'customize_refresh_nonces',                array( $this, 'refresh_nonces' ) );
99
-
100
-		add_action( 'dynamic_sidebar',                         array( $this, 'tally_rendered_widgets' ) );
101
-		add_filter( 'is_active_sidebar',                       array( $this, 'tally_sidebars_via_is_active_sidebar_calls' ), 10, 2 );
102
-		add_filter( 'dynamic_sidebar_has_widgets',             array( $this, 'tally_sidebars_via_dynamic_sidebar_calls' ), 10, 2 );
87
+		add_filter('customize_dynamic_setting_args', array($this, 'filter_customize_dynamic_setting_args'), 10, 2);
88
+		add_action('after_setup_theme', array($this, 'register_settings'));
89
+		add_action('wp_loaded', array($this, 'override_sidebars_widgets_for_theme_switch'));
90
+		add_action('customize_controls_init', array($this, 'customize_controls_init'));
91
+		add_action('customize_register', array($this, 'schedule_customize_register'), 1);
92
+		add_action('customize_controls_enqueue_scripts', array($this, 'enqueue_scripts'));
93
+		add_action('customize_controls_print_styles', array($this, 'print_styles'));
94
+		add_action('customize_controls_print_scripts', array($this, 'print_scripts'));
95
+		add_action('customize_controls_print_footer_scripts', array($this, 'print_footer_scripts'));
96
+		add_action('customize_controls_print_footer_scripts', array($this, 'output_widget_control_templates'));
97
+		add_action('customize_preview_init', array($this, 'customize_preview_init'));
98
+		add_filter('customize_refresh_nonces', array($this, 'refresh_nonces'));
99
+
100
+		add_action('dynamic_sidebar', array($this, 'tally_rendered_widgets'));
101
+		add_filter('is_active_sidebar', array($this, 'tally_sidebars_via_is_active_sidebar_calls'), 10, 2);
102
+		add_filter('dynamic_sidebar_has_widgets', array($this, 'tally_sidebars_via_dynamic_sidebar_calls'), 10, 2);
103 103
 	}
104 104
 
105 105
 	/**
@@ -113,14 +113,14 @@  discard block
 block discarded – undo
113 113
 	 * @param $setting_id Setting ID.
114 114
 	 * @return string|void Setting type.
115 115
 	 */
116
-	protected function get_setting_type( $setting_id ) {
116
+	protected function get_setting_type($setting_id) {
117 117
 		static $cache = array();
118
-		if ( isset( $cache[ $setting_id ] ) ) {
119
-			return $cache[ $setting_id ];
118
+		if (isset($cache[$setting_id])) {
119
+			return $cache[$setting_id];
120 120
 		}
121
-		foreach ( $this->setting_id_patterns as $type => $pattern ) {
122
-			if ( preg_match( $pattern, $setting_id ) ) {
123
-				$cache[ $setting_id ] = $type;
121
+		foreach ($this->setting_id_patterns as $type => $pattern) {
122
+			if (preg_match($pattern, $setting_id)) {
123
+				$cache[$setting_id] = $type;
124 124
 				return $type;
125 125
 			}
126 126
 		}
@@ -134,25 +134,25 @@  discard block
 block discarded – undo
134 134
 	 */
135 135
 	public function register_settings() {
136 136
 		$widget_setting_ids = array();
137
-		$incoming_setting_ids = array_keys( $this->manager->unsanitized_post_values() );
138
-		foreach ( $incoming_setting_ids as $setting_id ) {
139
-			if ( ! is_null( $this->get_setting_type( $setting_id ) ) ) {
137
+		$incoming_setting_ids = array_keys($this->manager->unsanitized_post_values());
138
+		foreach ($incoming_setting_ids as $setting_id) {
139
+			if ( ! is_null($this->get_setting_type($setting_id))) {
140 140
 				$widget_setting_ids[] = $setting_id;
141 141
 			}
142 142
 		}
143
-		if ( $this->manager->doing_ajax( 'update-widget' ) && isset( $_REQUEST['widget-id'] ) ) {
144
-			$widget_setting_ids[] = $this->get_setting_id( wp_unslash( $_REQUEST['widget-id'] ) );
143
+		if ($this->manager->doing_ajax('update-widget') && isset($_REQUEST['widget-id'])) {
144
+			$widget_setting_ids[] = $this->get_setting_id(wp_unslash($_REQUEST['widget-id']));
145 145
 		}
146 146
 
147
-		$settings = $this->manager->add_dynamic_settings( array_unique( $widget_setting_ids ) );
147
+		$settings = $this->manager->add_dynamic_settings(array_unique($widget_setting_ids));
148 148
 
149 149
 		/*
150 150
 		 * Preview settings right away so that widgets and sidebars will get registered properly.
151 151
 		 * But don't do this if a customize_save because this will cause WP to think there is nothing
152 152
 		 * changed that needs to be saved.
153 153
 		 */
154
-		if ( ! $this->manager->doing_ajax( 'customize_save' ) ) {
155
-			foreach ( $settings as $setting ) {
154
+		if ( ! $this->manager->doing_ajax('customize_save')) {
155
+			foreach ($settings as $setting) {
156 156
 				$setting->preview();
157 157
 			}
158 158
 		}
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
 	 * @param string      $setting_id   ID for dynamic setting, usually coming from `$_POST['customized']`.
169 169
 	 * @return false|array Setting arguments, false otherwise.
170 170
 	 */
171
-	public function filter_customize_dynamic_setting_args( $args, $setting_id ) {
172
-		if ( $this->get_setting_type( $setting_id ) ) {
173
-			$args = $this->get_setting_args( $setting_id );
171
+	public function filter_customize_dynamic_setting_args($args, $setting_id) {
172
+		if ($this->get_setting_type($setting_id)) {
173
+			$args = $this->get_setting_args($setting_id);
174 174
 		}
175 175
 		return $args;
176 176
 	}
@@ -186,12 +186,12 @@  discard block
 block discarded – undo
186 186
 	 * @param mixed  $default Default post value.
187 187
 	 * @return mixed Unslashed post value or default value.
188 188
 	 */
189
-	protected function get_post_value( $name, $default = null ) {
190
-		if ( ! isset( $_POST[ $name ] ) ) {
189
+	protected function get_post_value($name, $default = null) {
190
+		if ( ! isset($_POST[$name])) {
191 191
 			return $default;
192 192
 		}
193 193
 
194
-		return wp_unslash( $_POST[ $name ] );
194
+		return wp_unslash($_POST[$name]);
195 195
 	}
196 196
 
197 197
 	/**
@@ -212,19 +212,19 @@  discard block
 block discarded – undo
212 212
 	public function override_sidebars_widgets_for_theme_switch() {
213 213
 		global $sidebars_widgets;
214 214
 
215
-		if ( $this->manager->doing_ajax() || $this->manager->is_theme_active() ) {
215
+		if ($this->manager->doing_ajax() || $this->manager->is_theme_active()) {
216 216
 			return;
217 217
 		}
218 218
 
219 219
 		$this->old_sidebars_widgets = wp_get_sidebars_widgets();
220
-		add_filter( 'customize_value_old_sidebars_widgets_data', array( $this, 'filter_customize_value_old_sidebars_widgets_data' ) );
220
+		add_filter('customize_value_old_sidebars_widgets_data', array($this, 'filter_customize_value_old_sidebars_widgets_data'));
221 221
 
222 222
 		// retrieve_widgets() looks at the global $sidebars_widgets
223 223
 		$sidebars_widgets = $this->old_sidebars_widgets;
224
-		$sidebars_widgets = retrieve_widgets( 'customize' );
225
-		add_filter( 'option_sidebars_widgets', array( $this, 'filter_option_sidebars_widgets_for_theme_switch' ), 1 );
224
+		$sidebars_widgets = retrieve_widgets('customize');
225
+		add_filter('option_sidebars_widgets', array($this, 'filter_option_sidebars_widgets_for_theme_switch'), 1);
226 226
 		// reset global cache var used by wp_get_sidebars_widgets()
227
-		unset( $GLOBALS['_wp_sidebars_widgets'] );
227
+		unset($GLOBALS['_wp_sidebars_widgets']);
228 228
 	}
229 229
 
230 230
 	/**
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 * @param array $old_sidebars_widgets
244 244
 	 * @return array
245 245
 	 */
246
-	public function filter_customize_value_old_sidebars_widgets_data( $old_sidebars_widgets ) {
246
+	public function filter_customize_value_old_sidebars_widgets_data($old_sidebars_widgets) {
247 247
 		return $this->old_sidebars_widgets;
248 248
 	}
249 249
 
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 	 * @param array $sidebars_widgets
264 264
 	 * @return array
265 265
 	 */
266
-	public function filter_option_sidebars_widgets_for_theme_switch( $sidebars_widgets ) {
266
+	public function filter_option_sidebars_widgets_for_theme_switch($sidebars_widgets) {
267 267
 		$sidebars_widgets = $GLOBALS['sidebars_widgets'];
268 268
 		$sidebars_widgets['array_version'] = 3;
269 269
 		return $sidebars_widgets;
@@ -279,13 +279,13 @@  discard block
 block discarded – undo
279 279
 	 */
280 280
 	public function customize_controls_init() {
281 281
 		/** This action is documented in wp-admin/includes/ajax-actions.php */
282
-		do_action( 'load-widgets.php' );
282
+		do_action('load-widgets.php');
283 283
 
284 284
 		/** This action is documented in wp-admin/includes/ajax-actions.php */
285
-		do_action( 'widgets.php' );
285
+		do_action('widgets.php');
286 286
 
287 287
 		/** This action is documented in wp-admin/widgets.php */
288
-		do_action( 'sidebar_admin_setup' );
288
+		do_action('sidebar_admin_setup');
289 289
 	}
290 290
 
291 291
 	/**
@@ -299,10 +299,10 @@  discard block
 block discarded – undo
299 299
 	 * @access public
300 300
 	 */
301 301
 	public function schedule_customize_register() {
302
-		if ( is_admin() ) {
302
+		if (is_admin()) {
303 303
 			$this->customize_register();
304 304
 		} else {
305
-			add_action( 'wp', array( $this, 'customize_register' ) );
305
+			add_action('wp', array($this, 'customize_register'));
306 306
 		}
307 307
 	}
308 308
 
@@ -320,8 +320,8 @@  discard block
 block discarded – undo
320 320
 		global $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_sidebars;
321 321
 
322 322
 		$sidebars_widgets = array_merge(
323
-			array( 'wp_inactive_widgets' => array() ),
324
-			array_fill_keys( array_keys( $wp_registered_sidebars ), array() ),
323
+			array('wp_inactive_widgets' => array()),
324
+			array_fill_keys(array_keys($wp_registered_sidebars), array()),
325 325
 			wp_get_sidebars_widgets()
326 326
 		);
327 327
 
@@ -332,11 +332,11 @@  discard block
 block discarded – undo
332 332
 		 * inactive, and orphaned since a widget may get suppressed from a sidebar
333 333
 		 * via a plugin (like Widget Visibility).
334 334
 		 */
335
-		foreach ( array_keys( $wp_registered_widgets ) as $widget_id ) {
336
-			$setting_id   = $this->get_setting_id( $widget_id );
337
-			$setting_args = $this->get_setting_args( $setting_id );
338
-			if ( ! $this->manager->get_setting( $setting_id ) ) {
339
-				$this->manager->add_setting( $setting_id, $setting_args );
335
+		foreach (array_keys($wp_registered_widgets) as $widget_id) {
336
+			$setting_id   = $this->get_setting_id($widget_id);
337
+			$setting_args = $this->get_setting_args($setting_id);
338
+			if ( ! $this->manager->get_setting($setting_id)) {
339
+				$this->manager->add_setting($setting_id, $setting_args);
340 340
 			}
341 341
 			$new_setting_ids[] = $setting_id;
342 342
 		}
@@ -345,50 +345,50 @@  discard block
 block discarded – undo
345 345
 		 * Add a setting which will be supplied for the theme's sidebars_widgets
346 346
 		 * theme_mod when the the theme is switched.
347 347
 		 */
348
-		if ( ! $this->manager->is_theme_active() ) {
348
+		if ( ! $this->manager->is_theme_active()) {
349 349
 			$setting_id = 'old_sidebars_widgets_data';
350
-			$setting_args = $this->get_setting_args( $setting_id, array(
350
+			$setting_args = $this->get_setting_args($setting_id, array(
351 351
 				'type' => 'global_variable',
352 352
 				'dirty' => true,
353
-			) );
354
-			$this->manager->add_setting( $setting_id, $setting_args );
353
+			));
354
+			$this->manager->add_setting($setting_id, $setting_args);
355 355
 		}
356 356
 
357
-		$this->manager->add_panel( 'widgets', array(
358
-			'title'       => __( 'Widgets' ),
359
-			'description' => __( 'Widgets are independent sections of content that can be placed into widgetized areas provided by your theme (commonly called sidebars).' ),
357
+		$this->manager->add_panel('widgets', array(
358
+			'title'       => __('Widgets'),
359
+			'description' => __('Widgets are independent sections of content that can be placed into widgetized areas provided by your theme (commonly called sidebars).'),
360 360
 			'priority'    => 110,
361
-		) );
361
+		));
362 362
 
363
-		foreach ( $sidebars_widgets as $sidebar_id => $sidebar_widget_ids ) {
364
-			if ( empty( $sidebar_widget_ids ) ) {
363
+		foreach ($sidebars_widgets as $sidebar_id => $sidebar_widget_ids) {
364
+			if (empty($sidebar_widget_ids)) {
365 365
 				$sidebar_widget_ids = array();
366 366
 			}
367 367
 
368
-			$is_registered_sidebar = isset( $wp_registered_sidebars[ $sidebar_id ] );
369
-			$is_inactive_widgets   = ( 'wp_inactive_widgets' === $sidebar_id );
370
-			$is_active_sidebar     = ( $is_registered_sidebar && ! $is_inactive_widgets );
368
+			$is_registered_sidebar = isset($wp_registered_sidebars[$sidebar_id]);
369
+			$is_inactive_widgets   = ('wp_inactive_widgets' === $sidebar_id);
370
+			$is_active_sidebar     = ($is_registered_sidebar && ! $is_inactive_widgets);
371 371
 
372 372
 			// Add setting for managing the sidebar's widgets.
373
-			if ( $is_registered_sidebar || $is_inactive_widgets ) {
374
-				$setting_id   = sprintf( 'sidebars_widgets[%s]', $sidebar_id );
375
-				$setting_args = $this->get_setting_args( $setting_id );
376
-				if ( ! $this->manager->get_setting( $setting_id ) ) {
377
-					if ( ! $this->manager->is_theme_active() ) {
373
+			if ($is_registered_sidebar || $is_inactive_widgets) {
374
+				$setting_id   = sprintf('sidebars_widgets[%s]', $sidebar_id);
375
+				$setting_args = $this->get_setting_args($setting_id);
376
+				if ( ! $this->manager->get_setting($setting_id)) {
377
+					if ( ! $this->manager->is_theme_active()) {
378 378
 						$setting_args['dirty'] = true;
379 379
 					}
380
-					$this->manager->add_setting( $setting_id, $setting_args );
380
+					$this->manager->add_setting($setting_id, $setting_args);
381 381
 				}
382 382
 				$new_setting_ids[] = $setting_id;
383 383
 
384 384
 				// Add section to contain controls.
385
-				$section_id = sprintf( 'sidebar-widgets-%s', $sidebar_id );
386
-				if ( $is_active_sidebar ) {
385
+				$section_id = sprintf('sidebar-widgets-%s', $sidebar_id);
386
+				if ($is_active_sidebar) {
387 387
 
388 388
 					$section_args = array(
389
-						'title' => $wp_registered_sidebars[ $sidebar_id ]['name'],
390
-						'description' => $wp_registered_sidebars[ $sidebar_id ]['description'],
391
-						'priority' => array_search( $sidebar_id, array_keys( $wp_registered_sidebars ) ),
389
+						'title' => $wp_registered_sidebars[$sidebar_id]['name'],
390
+						'description' => $wp_registered_sidebars[$sidebar_id]['description'],
391
+						'priority' => array_search($sidebar_id, array_keys($wp_registered_sidebars)),
392 392
 						'panel' => 'widgets',
393 393
 						'sidebar_id' => $sidebar_id,
394 394
 					);
@@ -402,35 +402,35 @@  discard block
 block discarded – undo
402 402
 					 * @param string     $section_id   Customizer section ID.
403 403
 					 * @param int|string $sidebar_id   Sidebar ID.
404 404
 					 */
405
-					$section_args = apply_filters( 'customizer_widgets_section_args', $section_args, $section_id, $sidebar_id );
405
+					$section_args = apply_filters('customizer_widgets_section_args', $section_args, $section_id, $sidebar_id);
406 406
 
407
-					$section = new WP_Customize_Sidebar_Section( $this->manager, $section_id, $section_args );
408
-					$this->manager->add_section( $section );
407
+					$section = new WP_Customize_Sidebar_Section($this->manager, $section_id, $section_args);
408
+					$this->manager->add_section($section);
409 409
 
410
-					$control = new WP_Widget_Area_Customize_Control( $this->manager, $setting_id, array(
410
+					$control = new WP_Widget_Area_Customize_Control($this->manager, $setting_id, array(
411 411
 						'section'    => $section_id,
412 412
 						'sidebar_id' => $sidebar_id,
413
-						'priority'   => count( $sidebar_widget_ids ), // place 'Add Widget' and 'Reorder' buttons at end.
414
-					) );
413
+						'priority'   => count($sidebar_widget_ids), // place 'Add Widget' and 'Reorder' buttons at end.
414
+					));
415 415
 					$new_setting_ids[] = $setting_id;
416 416
 
417
-					$this->manager->add_control( $control );
417
+					$this->manager->add_control($control);
418 418
 				}
419 419
 			}
420 420
 
421 421
 			// Add a control for each active widget (located in a sidebar).
422
-			foreach ( $sidebar_widget_ids as $i => $widget_id ) {
422
+			foreach ($sidebar_widget_ids as $i => $widget_id) {
423 423
 
424 424
 				// Skip widgets that may have gone away due to a plugin being deactivated.
425
-				if ( ! $is_active_sidebar || ! isset( $wp_registered_widgets[$widget_id] ) ) {
425
+				if ( ! $is_active_sidebar || ! isset($wp_registered_widgets[$widget_id])) {
426 426
 					continue;
427 427
 				}
428 428
 
429 429
 				$registered_widget = $wp_registered_widgets[$widget_id];
430
-				$setting_id        = $this->get_setting_id( $widget_id );
430
+				$setting_id        = $this->get_setting_id($widget_id);
431 431
 				$id_base           = $wp_registered_widget_controls[$widget_id]['id_base'];
432 432
 
433
-				$control = new WP_Widget_Form_Customize_Control( $this->manager, $setting_id, array(
433
+				$control = new WP_Widget_Form_Customize_Control($this->manager, $setting_id, array(
434 434
 					'label'          => $registered_widget['name'],
435 435
 					'section'        => $section_id,
436 436
 					'sidebar_id'     => $sidebar_id,
@@ -439,19 +439,19 @@  discard block
 block discarded – undo
439 439
 					'priority'       => $i,
440 440
 					'width'          => $wp_registered_widget_controls[$widget_id]['width'],
441 441
 					'height'         => $wp_registered_widget_controls[$widget_id]['height'],
442
-					'is_wide'        => $this->is_wide_widget( $widget_id ),
443
-				) );
444
-				$this->manager->add_control( $control );
442
+					'is_wide'        => $this->is_wide_widget($widget_id),
443
+				));
444
+				$this->manager->add_control($control);
445 445
 			}
446 446
 		}
447 447
 
448
-		if ( ! $this->manager->doing_ajax( 'customize_save' ) ) {
449
-			foreach ( $new_setting_ids as $new_setting_id ) {
450
-				$this->manager->get_setting( $new_setting_id )->preview();
448
+		if ( ! $this->manager->doing_ajax('customize_save')) {
449
+			foreach ($new_setting_ids as $new_setting_id) {
450
+				$this->manager->get_setting($new_setting_id)->preview();
451 451
 			}
452 452
 		}
453 453
 
454
-		add_filter( 'sidebars_widgets', array( $this, 'preview_sidebars_widgets' ), 1 );
454
+		add_filter('sidebars_widgets', array($this, 'preview_sidebars_widgets'), 1);
455 455
 	}
456 456
 
457 457
 	/**
@@ -463,12 +463,12 @@  discard block
 block discarded – undo
463 463
 	 * @param string $widget_id Widget ID.
464 464
 	 * @return string Maybe-parsed widget ID.
465 465
 	 */
466
-	public function get_setting_id( $widget_id ) {
467
-		$parsed_widget_id = $this->parse_widget_id( $widget_id );
468
-		$setting_id       = sprintf( 'widget_%s', $parsed_widget_id['id_base'] );
466
+	public function get_setting_id($widget_id) {
467
+		$parsed_widget_id = $this->parse_widget_id($widget_id);
468
+		$setting_id       = sprintf('widget_%s', $parsed_widget_id['id_base']);
469 469
 
470
-		if ( ! is_null( $parsed_widget_id['number'] ) ) {
471
-			$setting_id .= sprintf( '[%d]', $parsed_widget_id['number'] );
470
+		if ( ! is_null($parsed_widget_id['number'])) {
471
+			$setting_id .= sprintf('[%d]', $parsed_widget_id['number']);
472 472
 		}
473 473
 		return $setting_id;
474 474
 	}
@@ -491,13 +491,13 @@  discard block
 block discarded – undo
491 491
 	 * @param string $widget_id Widget ID.
492 492
 	 * @return bool Whether or not the widget is a "wide" widget.
493 493
 	 */
494
-	public function is_wide_widget( $widget_id ) {
494
+	public function is_wide_widget($widget_id) {
495 495
 		global $wp_registered_widget_controls;
496 496
 
497
-		$parsed_widget_id = $this->parse_widget_id( $widget_id );
497
+		$parsed_widget_id = $this->parse_widget_id($widget_id);
498 498
 		$width            = $wp_registered_widget_controls[$widget_id]['width'];
499
-		$is_core          = in_array( $parsed_widget_id['id_base'], $this->core_widget_id_bases );
500
-		$is_wide          = ( $width > 250 && ! $is_core );
499
+		$is_core          = in_array($parsed_widget_id['id_base'], $this->core_widget_id_bases);
500
+		$is_wide          = ($width > 250 && ! $is_core);
501 501
 
502 502
 		/**
503 503
 		 * Filter whether the given widget is considered "wide".
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
 		 * @param bool   $is_wide   Whether the widget is wide, Default false.
508 508
 		 * @param string $widget_id Widget ID.
509 509
 		 */
510
-		return apply_filters( 'is_wide_widget_in_customizer', $is_wide, $widget_id );
510
+		return apply_filters('is_wide_widget_in_customizer', $is_wide, $widget_id);
511 511
 	}
512 512
 
513 513
 	/**
@@ -519,15 +519,15 @@  discard block
 block discarded – undo
519 519
 	 * @param string $widget_id Widget ID.
520 520
 	 * @return array Array containing a widget's id_base and number components.
521 521
 	 */
522
-	public function parse_widget_id( $widget_id ) {
522
+	public function parse_widget_id($widget_id) {
523 523
 		$parsed = array(
524 524
 			'number' => null,
525 525
 			'id_base' => null,
526 526
 		);
527 527
 
528
-		if ( preg_match( '/^(.+)-(\d+)$/', $widget_id, $matches ) ) {
528
+		if (preg_match('/^(.+)-(\d+)$/', $widget_id, $matches)) {
529 529
 			$parsed['id_base'] = $matches[1];
530
-			$parsed['number']  = intval( $matches[2] );
530
+			$parsed['number']  = intval($matches[2]);
531 531
 		} else {
532 532
 			// likely an old single widget
533 533
 			$parsed['id_base'] = $widget_id;
@@ -545,15 +545,15 @@  discard block
 block discarded – undo
545 545
 	 * @return WP_Error|array Array containing a widget's id_base and number components,
546 546
 	 *                        or a WP_Error object.
547 547
 	 */
548
-	public function parse_widget_setting_id( $setting_id ) {
549
-		if ( ! preg_match( '/^(widget_(.+?))(?:\[(\d+)\])?$/', $setting_id, $matches ) ) {
550
-			return new WP_Error( 'widget_setting_invalid_id' );
548
+	public function parse_widget_setting_id($setting_id) {
549
+		if ( ! preg_match('/^(widget_(.+?))(?:\[(\d+)\])?$/', $setting_id, $matches)) {
550
+			return new WP_Error('widget_setting_invalid_id');
551 551
 		}
552 552
 
553 553
 		$id_base = $matches[2];
554
-		$number  = isset( $matches[3] ) ? intval( $matches[3] ) : null;
554
+		$number  = isset($matches[3]) ? intval($matches[3]) : null;
555 555
 
556
-		return compact( 'id_base', 'number' );
556
+		return compact('id_base', 'number');
557 557
 	}
558 558
 
559 559
 	/**
@@ -565,10 +565,10 @@  discard block
 block discarded – undo
565 565
 	 */
566 566
 	public function print_styles() {
567 567
 		/** This action is documented in wp-admin/admin-header.php */
568
-		do_action( 'admin_print_styles-widgets.php' );
568
+		do_action('admin_print_styles-widgets.php');
569 569
 
570 570
 		/** This action is documented in wp-admin/admin-header.php */
571
-		do_action( 'admin_print_styles' );
571
+		do_action('admin_print_styles');
572 572
 	}
573 573
 
574 574
 	/**
@@ -580,10 +580,10 @@  discard block
 block discarded – undo
580 580
 	 */
581 581
 	public function print_scripts() {
582 582
 		/** This action is documented in wp-admin/admin-header.php */
583
-		do_action( 'admin_print_scripts-widgets.php' );
583
+		do_action('admin_print_scripts-widgets.php');
584 584
 
585 585
 		/** This action is documented in wp-admin/admin-header.php */
586
-		do_action( 'admin_print_scripts' );
586
+		do_action('admin_print_scripts');
587 587
 	}
588 588
 
589 589
 	/**
@@ -599,11 +599,11 @@  discard block
 block discarded – undo
599 599
 	public function enqueue_scripts() {
600 600
 		global $wp_scripts, $wp_registered_sidebars, $wp_registered_widgets;
601 601
 
602
-		wp_enqueue_style( 'customize-widgets' );
603
-		wp_enqueue_script( 'customize-widgets' );
602
+		wp_enqueue_style('customize-widgets');
603
+		wp_enqueue_script('customize-widgets');
604 604
 
605 605
 		/** This action is documented in wp-admin/admin-header.php */
606
-		do_action( 'admin_enqueue_scripts', 'widgets.php' );
606
+		do_action('admin_enqueue_scripts', 'widgets.php');
607 607
 
608 608
 		/*
609 609
 		 * Export available widgets with control_tpl removed from model
@@ -611,23 +611,23 @@  discard block
 block discarded – undo
611 611
 		 */
612 612
 		$available_widgets = array();
613 613
 
614
-		foreach ( $this->get_available_widgets() as $available_widget ) {
615
-			unset( $available_widget['control_tpl'] );
614
+		foreach ($this->get_available_widgets() as $available_widget) {
615
+			unset($available_widget['control_tpl']);
616 616
 			$available_widgets[] = $available_widget;
617 617
 		}
618 618
 
619 619
 		$widget_reorder_nav_tpl = sprintf(
620 620
 			'<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>',
621
-			__( 'Move to another area&hellip;' ),
622
-			__( 'Move down' ),
623
-			__( 'Move up' )
621
+			__('Move to another area&hellip;'),
622
+			__('Move down'),
623
+			__('Move up')
624 624
 		);
625 625
 
626 626
 		$move_widget_area_tpl = str_replace(
627
-			array( '{description}', '{btn}' ),
627
+			array('{description}', '{btn}'),
628 628
 			array(
629
-				__( 'Select an area to move this widget into:' ),
630
-				_x( 'Move', 'Move widget' ),
629
+				__('Select an area to move this widget into:'),
630
+				_x('Move', 'Move widget'),
631 631
 			),
632 632
 			'<div class="move-widget-area">
633 633
 				<p class="description">{description}</p>
@@ -643,18 +643,18 @@  discard block
 block discarded – undo
643 643
 		);
644 644
 
645 645
 		$settings = array(
646
-			'nonce'                => wp_create_nonce( 'update-widget' ),
647
-			'registeredSidebars'   => array_values( $wp_registered_sidebars ),
646
+			'nonce'                => wp_create_nonce('update-widget'),
647
+			'registeredSidebars'   => array_values($wp_registered_sidebars),
648 648
 			'registeredWidgets'    => $wp_registered_widgets,
649 649
 			'availableWidgets'     => $available_widgets, // @todo Merge this with registered_widgets
650 650
 			'l10n' => array(
651
-				'saveBtnLabel'     => __( 'Apply' ),
652
-				'saveBtnTooltip'   => __( 'Save and preview changes before publishing them.' ),
653
-				'removeBtnLabel'   => __( 'Remove' ),
654
-				'removeBtnTooltip' => __( 'Trash widget by moving it to the inactive widgets sidebar.' ),
655
-				'error'            => __( 'An error has occurred. Please reload the page and try again.' ),
656
-				'widgetMovedUp'    => __( 'Widget moved up' ),
657
-				'widgetMovedDown'  => __( 'Widget moved down' ),
651
+				'saveBtnLabel'     => __('Apply'),
652
+				'saveBtnTooltip'   => __('Save and preview changes before publishing them.'),
653
+				'removeBtnLabel'   => __('Remove'),
654
+				'removeBtnTooltip' => __('Trash widget by moving it to the inactive widgets sidebar.'),
655
+				'error'            => __('An error has occurred. Please reload the page and try again.'),
656
+				'widgetMovedUp'    => __('Widget moved up'),
657
+				'widgetMovedDown'  => __('Widget moved down'),
658 658
 			),
659 659
 			'tpl' => array(
660 660
 				'widgetReorderNav' => $widget_reorder_nav_tpl,
@@ -662,14 +662,14 @@  discard block
 block discarded – undo
662 662
 			),
663 663
 		);
664 664
 
665
-		foreach ( $settings['registeredWidgets'] as &$registered_widget ) {
666
-			unset( $registered_widget['callback'] ); // may not be JSON-serializeable
665
+		foreach ($settings['registeredWidgets'] as &$registered_widget) {
666
+			unset($registered_widget['callback']); // may not be JSON-serializeable
667 667
 		}
668 668
 
669 669
 		$wp_scripts->add_data(
670 670
 			'customize-widgets',
671 671
 			'data',
672
-			sprintf( 'var _wpCustomizeWidgetsSettings = %s;', wp_json_encode( $settings ) )
672
+			sprintf('var _wpCustomizeWidgetsSettings = %s;', wp_json_encode($settings))
673 673
 		);
674 674
 	}
675 675
 
@@ -685,23 +685,23 @@  discard block
 block discarded – undo
685 685
 		<div id="available-widgets">
686 686
 			<div class="customize-section-title">
687 687
 				<button class="customize-section-back" tabindex="-1">
688
-					<span class="screen-reader-text"><?php _e( 'Back' ); ?></span>
688
+					<span class="screen-reader-text"><?php _e('Back'); ?></span>
689 689
 				</button>
690 690
 				<h3>
691 691
 					<span class="customize-action"><?php
692 692
 						/* translators: &#9656; is the unicode right-pointing triangle, and %s is the section title in the Customizer */
693
-						echo sprintf( __( 'Customizing &#9656; %s' ), esc_html( $this->manager->get_panel( 'widgets' )->title ) );
693
+						echo sprintf(__('Customizing &#9656; %s'), esc_html($this->manager->get_panel('widgets')->title));
694 694
 					?></span>
695
-					<?php _e( 'Add a Widget' ); ?>
695
+					<?php _e('Add a Widget'); ?>
696 696
 				</h3>
697 697
 			</div>
698 698
 			<div id="available-widgets-filter">
699
-				<label class="screen-reader-text" for="widgets-search"><?php _e( 'Search Widgets' ); ?></label>
700
-				<input type="search" id="widgets-search" placeholder="<?php esc_attr_e( 'Search widgets&hellip;' ) ?>" />
699
+				<label class="screen-reader-text" for="widgets-search"><?php _e('Search Widgets'); ?></label>
700
+				<input type="search" id="widgets-search" placeholder="<?php esc_attr_e('Search widgets&hellip;') ?>" />
701 701
 			</div>
702 702
 			<div id="available-widgets-list">
703
-			<?php foreach ( $this->get_available_widgets() as $available_widget ): ?>
704
-				<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">
703
+			<?php foreach ($this->get_available_widgets() as $available_widget): ?>
704
+				<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">
705 705
 					<?php echo $available_widget['control_tpl']; ?>
706 706
 				</div>
707 707
 			<?php endforeach; ?>
@@ -720,10 +720,10 @@  discard block
 block discarded – undo
720 720
 	 */
721 721
 	public function print_footer_scripts() {
722 722
 		/** This action is documented in wp-admin/admin-footer.php */
723
-		do_action( 'admin_print_footer_scripts' );
723
+		do_action('admin_print_footer_scripts');
724 724
 
725 725
 		/** This action is documented in wp-admin/admin-footer.php */
726
-		do_action( 'admin_footer-widgets.php' );
726
+		do_action('admin_footer-widgets.php');
727 727
 	}
728 728
 
729 729
 	/**
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
 	 * @param array  $overrides Array of setting overrides.
737 737
 	 * @return array Possibly modified setting arguments.
738 738
 	 */
739
-	public function get_setting_args( $id, $overrides = array() ) {
739
+	public function get_setting_args($id, $overrides = array()) {
740 740
 		$args = array(
741 741
 			'type'       => 'option',
742 742
 			'capability' => 'edit_theme_options',
@@ -744,15 +744,15 @@  discard block
 block discarded – undo
744 744
 			'default'    => array(),
745 745
 		);
746 746
 
747
-		if ( preg_match( $this->setting_id_patterns['sidebar_widgets'], $id, $matches ) ) {
748
-			$args['sanitize_callback'] = array( $this, 'sanitize_sidebar_widgets' );
749
-			$args['sanitize_js_callback'] = array( $this, 'sanitize_sidebar_widgets_js_instance' );
750
-		} elseif ( preg_match( $this->setting_id_patterns['widget_instance'], $id, $matches ) ) {
751
-			$args['sanitize_callback'] = array( $this, 'sanitize_widget_instance' );
752
-			$args['sanitize_js_callback'] = array( $this, 'sanitize_widget_js_instance' );
747
+		if (preg_match($this->setting_id_patterns['sidebar_widgets'], $id, $matches)) {
748
+			$args['sanitize_callback'] = array($this, 'sanitize_sidebar_widgets');
749
+			$args['sanitize_js_callback'] = array($this, 'sanitize_sidebar_widgets_js_instance');
750
+		} elseif (preg_match($this->setting_id_patterns['widget_instance'], $id, $matches)) {
751
+			$args['sanitize_callback'] = array($this, 'sanitize_widget_instance');
752
+			$args['sanitize_js_callback'] = array($this, 'sanitize_widget_js_instance');
753 753
 		}
754 754
 
755
-		$args = array_merge( $args, $overrides );
755
+		$args = array_merge($args, $overrides);
756 756
 
757 757
 		/**
758 758
 		 * Filter the common arguments supplied when constructing a Customizer setting.
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 		 * @param array  $args Array of Customizer setting arguments.
765 765
 		 * @param string $id   Widget setting ID.
766 766
 		 */
767
-		return apply_filters( 'widget_customizer_setting_args', $args, $id );
767
+		return apply_filters('widget_customizer_setting_args', $args, $id);
768 768
 	}
769 769
 
770 770
 	/**
@@ -778,11 +778,11 @@  discard block
 block discarded – undo
778 778
 	 * @param array $widget_ids Array of widget IDs.
779 779
 	 * @return array Array of sanitized widget IDs.
780 780
 	 */
781
-	public function sanitize_sidebar_widgets( $widget_ids ) {
782
-		$widget_ids = array_map( 'strval', (array) $widget_ids );
781
+	public function sanitize_sidebar_widgets($widget_ids) {
782
+		$widget_ids = array_map('strval', (array) $widget_ids);
783 783
 		$sanitized_widget_ids = array();
784
-		foreach ( $widget_ids as $widget_id ) {
785
-			$sanitized_widget_ids[] = preg_replace( '/[^a-z0-9_\-]/', '', $widget_id );
784
+		foreach ($widget_ids as $widget_id) {
785
+			$sanitized_widget_ids[] = preg_replace('/[^a-z0-9_\-]/', '', $widget_id);
786 786
 		}
787 787
 		return $sanitized_widget_ids;
788 788
 	}
@@ -803,31 +803,31 @@  discard block
 block discarded – undo
803 803
 	 */
804 804
 	public function get_available_widgets() {
805 805
 		static $available_widgets = array();
806
-		if ( ! empty( $available_widgets ) ) {
806
+		if ( ! empty($available_widgets)) {
807 807
 			return $available_widgets;
808 808
 		}
809 809
 
810 810
 		global $wp_registered_widgets, $wp_registered_widget_controls;
811
-		require_once ABSPATH . '/wp-admin/includes/widgets.php'; // for next_widget_id_number()
811
+		require_once ABSPATH.'/wp-admin/includes/widgets.php'; // for next_widget_id_number()
812 812
 
813 813
 		$sort = $wp_registered_widgets;
814
-		usort( $sort, array( $this, '_sort_name_callback' ) );
814
+		usort($sort, array($this, '_sort_name_callback'));
815 815
 		$done = array();
816 816
 
817
-		foreach ( $sort as $widget ) {
818
-			if ( in_array( $widget['callback'], $done, true ) ) { // We already showed this multi-widget
817
+		foreach ($sort as $widget) {
818
+			if (in_array($widget['callback'], $done, true)) { // We already showed this multi-widget
819 819
 				continue;
820 820
 			}
821 821
 
822
-			$sidebar = is_active_widget( $widget['callback'], $widget['id'], false, false );
822
+			$sidebar = is_active_widget($widget['callback'], $widget['id'], false, false);
823 823
 			$done[]  = $widget['callback'];
824 824
 
825
-			if ( ! isset( $widget['params'][0] ) ) {
825
+			if ( ! isset($widget['params'][0])) {
826 826
 				$widget['params'][0] = array();
827 827
 			}
828 828
 
829 829
 			$available_widget = $widget;
830
-			unset( $available_widget['callback'] ); // not serializable to JSON
830
+			unset($available_widget['callback']); // not serializable to JSON
831 831
 
832 832
 			$args = array(
833 833
 				'widget_id'   => $widget['id'],
@@ -836,37 +836,37 @@  discard block
 block discarded – undo
836 836
 			);
837 837
 
838 838
 			$is_disabled     = false;
839
-			$is_multi_widget = ( isset( $wp_registered_widget_controls[$widget['id']]['id_base'] ) && isset( $widget['params'][0]['number'] ) );
840
-			if ( $is_multi_widget ) {
839
+			$is_multi_widget = (isset($wp_registered_widget_controls[$widget['id']]['id_base']) && isset($widget['params'][0]['number']));
840
+			if ($is_multi_widget) {
841 841
 				$id_base            = $wp_registered_widget_controls[$widget['id']]['id_base'];
842 842
 				$args['_temp_id']   = "$id_base-__i__";
843
-				$args['_multi_num'] = next_widget_id_number( $id_base );
843
+				$args['_multi_num'] = next_widget_id_number($id_base);
844 844
 				$args['_add']       = 'multi';
845 845
 			} else {
846 846
 				$args['_add'] = 'single';
847 847
 
848
-				if ( $sidebar && 'wp_inactive_widgets' !== $sidebar ) {
848
+				if ($sidebar && 'wp_inactive_widgets' !== $sidebar) {
849 849
 					$is_disabled = true;
850 850
 				}
851 851
 				$id_base = $widget['id'];
852 852
 			}
853 853
 
854
-			$list_widget_controls_args = wp_list_widget_controls_dynamic_sidebar( array( 0 => $args, 1 => $widget['params'][0] ) );
855
-			$control_tpl = $this->get_widget_control( $list_widget_controls_args );
854
+			$list_widget_controls_args = wp_list_widget_controls_dynamic_sidebar(array(0 => $args, 1 => $widget['params'][0]));
855
+			$control_tpl = $this->get_widget_control($list_widget_controls_args);
856 856
 
857 857
 			// The properties here are mapped to the Backbone Widget model.
858
-			$available_widget = array_merge( $available_widget, array(
859
-				'temp_id'      => isset( $args['_temp_id'] ) ? $args['_temp_id'] : null,
858
+			$available_widget = array_merge($available_widget, array(
859
+				'temp_id'      => isset($args['_temp_id']) ? $args['_temp_id'] : null,
860 860
 				'is_multi'     => $is_multi_widget,
861 861
 				'control_tpl'  => $control_tpl,
862
-				'multi_number' => ( $args['_add'] === 'multi' ) ? $args['_multi_num'] : false,
862
+				'multi_number' => ($args['_add'] === 'multi') ? $args['_multi_num'] : false,
863 863
 				'is_disabled'  => $is_disabled,
864 864
 				'id_base'      => $id_base,
865 865
 				'transport'    => 'refresh',
866 866
 				'width'        => $wp_registered_widget_controls[$widget['id']]['width'],
867 867
 				'height'       => $wp_registered_widget_controls[$widget['id']]['height'],
868
-				'is_wide'      => $this->is_wide_widget( $widget['id'] ),
869
-			) );
868
+				'is_wide'      => $this->is_wide_widget($widget['id']),
869
+			));
870 870
 
871 871
 			$available_widgets[] = $available_widget;
872 872
 		}
@@ -884,8 +884,8 @@  discard block
 block discarded – undo
884 884
 	 * @param array $widget_b The second widget to compare.
885 885
 	 * @return int Reorder position for the current widget comparison.
886 886
 	 */
887
-	protected function _sort_name_callback( $widget_a, $widget_b ) {
888
-		return strnatcasecmp( $widget_a['name'], $widget_b['name'] );
887
+	protected function _sort_name_callback($widget_a, $widget_b) {
888
+		return strnatcasecmp($widget_a['name'], $widget_b['name']);
889 889
 	}
890 890
 
891 891
 	/**
@@ -897,10 +897,10 @@  discard block
 block discarded – undo
897 897
 	 * @param array $args Widget control arguments.
898 898
 	 * @return string Widget control form HTML markup.
899 899
 	 */
900
-	public function get_widget_control( $args ) {
900
+	public function get_widget_control($args) {
901 901
 		ob_start();
902 902
 
903
-		call_user_func_array( 'wp_widget_control', $args );
903
+		call_user_func_array('wp_widget_control', $args);
904 904
 		$replacements = array(
905 905
 			'<form method="post">' => '<div class="form">',
906 906
 			'</form>' => '</div><!-- .form -->',
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
 
909 909
 		$control_tpl = ob_get_clean();
910 910
 
911
-		$control_tpl = str_replace( array_keys( $replacements ), array_values( $replacements ), $control_tpl );
911
+		$control_tpl = str_replace(array_keys($replacements), array_values($replacements), $control_tpl);
912 912
 
913 913
 		return $control_tpl;
914 914
 	}
@@ -920,9 +920,9 @@  discard block
 block discarded – undo
920 920
 	 * @access public
921 921
 	 */
922 922
 	public function customize_preview_init() {
923
-		add_action( 'wp_enqueue_scripts', array( $this, 'customize_preview_enqueue' ) );
924
-		add_action( 'wp_print_styles',    array( $this, 'print_preview_css' ), 1 );
925
-		add_action( 'wp_footer',          array( $this, 'export_preview_data' ), 20 );
923
+		add_action('wp_enqueue_scripts', array($this, 'customize_preview_enqueue'));
924
+		add_action('wp_print_styles', array($this, 'print_preview_css'), 1);
925
+		add_action('wp_footer', array($this, 'export_preview_data'), 20);
926 926
 	}
927 927
 
928 928
 	/**
@@ -934,8 +934,8 @@  discard block
 block discarded – undo
934 934
 	 * @param  array $nonces Array of nonces.
935 935
 	 * @return array $nonces Array of nonces.
936 936
 	 */
937
-	public function refresh_nonces( $nonces ) {
938
-		$nonces['update-widget'] = wp_create_nonce( 'update-widget' );
937
+	public function refresh_nonces($nonces) {
938
+		$nonces['update-widget'] = wp_create_nonce('update-widget');
939 939
 		return $nonces;
940 940
 	}
941 941
 
@@ -954,10 +954,10 @@  discard block
 block discarded – undo
954 954
 	 * @param array $sidebars_widgets List of widgets for the current sidebar.
955 955
 	 * @return array
956 956
 	 */
957
-	public function preview_sidebars_widgets( $sidebars_widgets ) {
958
-		$sidebars_widgets = get_option( 'sidebars_widgets' );
957
+	public function preview_sidebars_widgets($sidebars_widgets) {
958
+		$sidebars_widgets = get_option('sidebars_widgets');
959 959
 
960
-		unset( $sidebars_widgets['array_version'] );
960
+		unset($sidebars_widgets['array_version']);
961 961
 		return $sidebars_widgets;
962 962
 	}
963 963
 
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
 	 * @access public
969 969
 	 */
970 970
 	public function customize_preview_enqueue() {
971
-		wp_enqueue_script( 'customize-preview-widgets' );
971
+		wp_enqueue_script('customize-preview-widgets');
972 972
 	}
973 973
 
974 974
 	/**
@@ -1008,21 +1008,21 @@  discard block
 block discarded – undo
1008 1008
 		global $wp_registered_sidebars, $wp_registered_widgets;
1009 1009
 		// Prepare Customizer settings to pass to JavaScript.
1010 1010
 		$settings = array(
1011
-			'renderedSidebars'   => array_fill_keys( array_unique( $this->rendered_sidebars ), true ),
1012
-			'renderedWidgets'    => array_fill_keys( array_keys( $this->rendered_widgets ), true ),
1013
-			'registeredSidebars' => array_values( $wp_registered_sidebars ),
1011
+			'renderedSidebars'   => array_fill_keys(array_unique($this->rendered_sidebars), true),
1012
+			'renderedWidgets'    => array_fill_keys(array_keys($this->rendered_widgets), true),
1013
+			'registeredSidebars' => array_values($wp_registered_sidebars),
1014 1014
 			'registeredWidgets'  => $wp_registered_widgets,
1015 1015
 			'l10n'               => array(
1016
-				'widgetTooltip' => __( 'Shift-click to edit this widget.' ),
1016
+				'widgetTooltip' => __('Shift-click to edit this widget.'),
1017 1017
 			),
1018 1018
 		);
1019
-		foreach ( $settings['registeredWidgets'] as &$registered_widget ) {
1020
-			unset( $registered_widget['callback'] ); // may not be JSON-serializeable
1019
+		foreach ($settings['registeredWidgets'] as &$registered_widget) {
1020
+			unset($registered_widget['callback']); // may not be JSON-serializeable
1021 1021
 		}
1022 1022
 
1023 1023
 		?>
1024 1024
 		<script type="text/javascript">
1025
-			var _wpWidgetCustomizerPreviewSettings = <?php echo wp_json_encode( $settings ); ?>;
1025
+			var _wpWidgetCustomizerPreviewSettings = <?php echo wp_json_encode($settings); ?>;
1026 1026
 		</script>
1027 1027
 		<?php
1028 1028
 	}
@@ -1035,8 +1035,8 @@  discard block
 block discarded – undo
1035 1035
 	 *
1036 1036
 	 * @param array $widget Rendered widget to tally.
1037 1037
 	 */
1038
-	public function tally_rendered_widgets( $widget ) {
1039
-		$this->rendered_widgets[ $widget['id'] ] = true;
1038
+	public function tally_rendered_widgets($widget) {
1039
+		$this->rendered_widgets[$widget['id']] = true;
1040 1040
 	}
1041 1041
 
1042 1042
 	/**
@@ -1048,8 +1048,8 @@  discard block
 block discarded – undo
1048 1048
 	 * @param string $widget_id Widget ID to check.
1049 1049
 	 * @return bool Whether the widget is rendered.
1050 1050
 	 */
1051
-	public function is_widget_rendered( $widget_id ) {
1052
-		return in_array( $widget_id, $this->rendered_widgets );
1051
+	public function is_widget_rendered($widget_id) {
1052
+		return in_array($widget_id, $this->rendered_widgets);
1053 1053
 	}
1054 1054
 
1055 1055
 	/**
@@ -1061,8 +1061,8 @@  discard block
 block discarded – undo
1061 1061
 	 * @param string $sidebar_id Sidebar ID to check.
1062 1062
 	 * @return bool Whether the sidebar is rendered.
1063 1063
 	 */
1064
-	public function is_sidebar_rendered( $sidebar_id ) {
1065
-		return in_array( $sidebar_id, $this->rendered_sidebars );
1064
+	public function is_sidebar_rendered($sidebar_id) {
1065
+		return in_array($sidebar_id, $this->rendered_sidebars);
1066 1066
 	}
1067 1067
 
1068 1068
 	/**
@@ -1082,8 +1082,8 @@  discard block
 block discarded – undo
1082 1082
 	 * @param string $sidebar_id Sidebar ID.
1083 1083
 	 * @return bool
1084 1084
 	 */
1085
-	public function tally_sidebars_via_is_active_sidebar_calls( $is_active, $sidebar_id ) {
1086
-		if ( isset( $GLOBALS['wp_registered_sidebars'][$sidebar_id] ) ) {
1085
+	public function tally_sidebars_via_is_active_sidebar_calls($is_active, $sidebar_id) {
1086
+		if (isset($GLOBALS['wp_registered_sidebars'][$sidebar_id])) {
1087 1087
 			$this->rendered_sidebars[] = $sidebar_id;
1088 1088
 		}
1089 1089
 		/*
@@ -1110,8 +1110,8 @@  discard block
 block discarded – undo
1110 1110
 	 * @param string $sidebar_id  Sidebar ID.
1111 1111
 	 * @return bool
1112 1112
 	 */
1113
-	public function tally_sidebars_via_dynamic_sidebar_calls( $has_widgets, $sidebar_id ) {
1114
-		if ( isset( $GLOBALS['wp_registered_sidebars'][$sidebar_id] ) ) {
1113
+	public function tally_sidebars_via_dynamic_sidebar_calls($has_widgets, $sidebar_id) {
1114
+		if (isset($GLOBALS['wp_registered_sidebars'][$sidebar_id])) {
1115 1115
 			$this->rendered_sidebars[] = $sidebar_id;
1116 1116
 		}
1117 1117
 
@@ -1135,8 +1135,8 @@  discard block
 block discarded – undo
1135 1135
 	 * @param string $serialized_instance Widget instance.
1136 1136
 	 * @return string MAC for serialized widget instance.
1137 1137
 	 */
1138
-	protected function get_instance_hash_key( $serialized_instance ) {
1139
-		return wp_hash( $serialized_instance );
1138
+	protected function get_instance_hash_key($serialized_instance) {
1139
+		return wp_hash($serialized_instance);
1140 1140
 	}
1141 1141
 
1142 1142
 	/**
@@ -1151,29 +1151,29 @@  discard block
 block discarded – undo
1151 1151
 	 * @param array $value Widget instance to sanitize.
1152 1152
 	 * @return array|void Sanitized widget instance.
1153 1153
 	 */
1154
-	public function sanitize_widget_instance( $value ) {
1155
-		if ( $value === array() ) {
1154
+	public function sanitize_widget_instance($value) {
1155
+		if ($value === array()) {
1156 1156
 			return $value;
1157 1157
 		}
1158 1158
 
1159
-		if ( empty( $value['is_widget_customizer_js_value'] )
1160
-			|| empty( $value['instance_hash_key'] )
1161
-			|| empty( $value['encoded_serialized_instance'] ) )
1159
+		if (empty($value['is_widget_customizer_js_value'])
1160
+			|| empty($value['instance_hash_key'])
1161
+			|| empty($value['encoded_serialized_instance']))
1162 1162
 		{
1163 1163
 			return;
1164 1164
 		}
1165 1165
 
1166
-		$decoded = base64_decode( $value['encoded_serialized_instance'], true );
1167
-		if ( false === $decoded ) {
1166
+		$decoded = base64_decode($value['encoded_serialized_instance'], true);
1167
+		if (false === $decoded) {
1168 1168
 			return;
1169 1169
 		}
1170 1170
 
1171
-		if ( ! hash_equals( $this->get_instance_hash_key( $decoded ), $value['instance_hash_key'] ) ) {
1171
+		if ( ! hash_equals($this->get_instance_hash_key($decoded), $value['instance_hash_key'])) {
1172 1172
 			return;
1173 1173
 		}
1174 1174
 
1175
-		$instance = unserialize( $decoded );
1176
-		if ( false === $instance ) {
1175
+		$instance = unserialize($decoded);
1176
+		if (false === $instance) {
1177 1177
 			return;
1178 1178
 		}
1179 1179
 
@@ -1189,15 +1189,15 @@  discard block
 block discarded – undo
1189 1189
 	 * @param array $value Widget instance to convert to JSON.
1190 1190
 	 * @return array JSON-converted widget instance.
1191 1191
 	 */
1192
-	public function sanitize_widget_js_instance( $value ) {
1193
-		if ( empty( $value['is_widget_customizer_js_value'] ) ) {
1194
-			$serialized = serialize( $value );
1192
+	public function sanitize_widget_js_instance($value) {
1193
+		if (empty($value['is_widget_customizer_js_value'])) {
1194
+			$serialized = serialize($value);
1195 1195
 
1196 1196
 			$value = array(
1197
-				'encoded_serialized_instance'   => base64_encode( $serialized ),
1198
-				'title'                         => empty( $value['title'] ) ? '' : $value['title'],
1197
+				'encoded_serialized_instance'   => base64_encode($serialized),
1198
+				'title'                         => empty($value['title']) ? '' : $value['title'],
1199 1199
 				'is_widget_customizer_js_value' => true,
1200
-				'instance_hash_key'             => $this->get_instance_hash_key( $serialized ),
1200
+				'instance_hash_key'             => $this->get_instance_hash_key($serialized),
1201 1201
 			);
1202 1202
 		}
1203 1203
 		return $value;
@@ -1217,9 +1217,9 @@  discard block
 block discarded – undo
1217 1217
 	 * @param array $widget_ids List of widget IDs.
1218 1218
 	 * @return array Parsed list of widget IDs.
1219 1219
 	 */
1220
-	public function sanitize_sidebar_widgets_js_instance( $widget_ids ) {
1220
+	public function sanitize_sidebar_widgets_js_instance($widget_ids) {
1221 1221
 		global $wp_registered_widgets;
1222
-		$widget_ids = array_values( array_intersect( $widget_ids, array_keys( $wp_registered_widgets ) ) );
1222
+		$widget_ids = array_values(array_intersect($widget_ids, array_keys($wp_registered_widgets)));
1223 1223
 		return $widget_ids;
1224 1224
 	}
1225 1225
 
@@ -1238,93 +1238,93 @@  discard block
 block discarded – undo
1238 1238
 	 * @return WP_Error|array Array containing the updated widget information.
1239 1239
 	 *                        A WP_Error object, otherwise.
1240 1240
 	 */
1241
-	public function call_widget_update( $widget_id ) {
1241
+	public function call_widget_update($widget_id) {
1242 1242
 		global $wp_registered_widget_updates, $wp_registered_widget_controls;
1243 1243
 
1244
-		$setting_id = $this->get_setting_id( $widget_id );
1244
+		$setting_id = $this->get_setting_id($widget_id);
1245 1245
 
1246 1246
 		/*
1247 1247
 		 * Make sure that other setting changes have previewed since this widget
1248 1248
 		 * may depend on them (e.g. Menus being present for Custom Menu widget).
1249 1249
 		 */
1250
-		if ( ! did_action( 'customize_preview_init' ) ) {
1251
-			foreach ( $this->manager->settings() as $setting ) {
1252
-				if ( $setting->id !== $setting_id ) {
1250
+		if ( ! did_action('customize_preview_init')) {
1251
+			foreach ($this->manager->settings() as $setting) {
1252
+				if ($setting->id !== $setting_id) {
1253 1253
 					$setting->preview();
1254 1254
 				}
1255 1255
 			}
1256 1256
 		}
1257 1257
 
1258 1258
 		$this->start_capturing_option_updates();
1259
-		$parsed_id   = $this->parse_widget_id( $widget_id );
1260
-		$option_name = 'widget_' . $parsed_id['id_base'];
1259
+		$parsed_id   = $this->parse_widget_id($widget_id);
1260
+		$option_name = 'widget_'.$parsed_id['id_base'];
1261 1261
 
1262 1262
 		/*
1263 1263
 		 * If a previously-sanitized instance is provided, populate the input vars
1264 1264
 		 * with its values so that the widget update callback will read this instance
1265 1265
 		 */
1266 1266
 		$added_input_vars = array();
1267
-		if ( ! empty( $_POST['sanitized_widget_setting'] ) ) {
1268
-			$sanitized_widget_setting = json_decode( $this->get_post_value( 'sanitized_widget_setting' ), true );
1269
-			if ( false === $sanitized_widget_setting ) {
1267
+		if ( ! empty($_POST['sanitized_widget_setting'])) {
1268
+			$sanitized_widget_setting = json_decode($this->get_post_value('sanitized_widget_setting'), true);
1269
+			if (false === $sanitized_widget_setting) {
1270 1270
 				$this->stop_capturing_option_updates();
1271
-				return new WP_Error( 'widget_setting_malformed' );
1271
+				return new WP_Error('widget_setting_malformed');
1272 1272
 			}
1273 1273
 
1274
-			$instance = $this->sanitize_widget_instance( $sanitized_widget_setting );
1275
-			if ( is_null( $instance ) ) {
1274
+			$instance = $this->sanitize_widget_instance($sanitized_widget_setting);
1275
+			if (is_null($instance)) {
1276 1276
 				$this->stop_capturing_option_updates();
1277
-				return new WP_Error( 'widget_setting_unsanitized' );
1277
+				return new WP_Error('widget_setting_unsanitized');
1278 1278
 			}
1279 1279
 
1280
-			if ( ! is_null( $parsed_id['number'] ) ) {
1280
+			if ( ! is_null($parsed_id['number'])) {
1281 1281
 				$value = array();
1282 1282
 				$value[$parsed_id['number']] = $instance;
1283
-				$key = 'widget-' . $parsed_id['id_base'];
1284
-				$_REQUEST[$key] = $_POST[$key] = wp_slash( $value );
1283
+				$key = 'widget-'.$parsed_id['id_base'];
1284
+				$_REQUEST[$key] = $_POST[$key] = wp_slash($value);
1285 1285
 				$added_input_vars[] = $key;
1286 1286
 			} else {
1287
-				foreach ( $instance as $key => $value ) {
1288
-					$_REQUEST[$key] = $_POST[$key] = wp_slash( $value );
1287
+				foreach ($instance as $key => $value) {
1288
+					$_REQUEST[$key] = $_POST[$key] = wp_slash($value);
1289 1289
 					$added_input_vars[] = $key;
1290 1290
 				}
1291 1291
 			}
1292 1292
 		}
1293 1293
 
1294 1294
 		// Invoke the widget update callback.
1295
-		foreach ( (array) $wp_registered_widget_updates as $name => $control ) {
1296
-			if ( $name === $parsed_id['id_base'] && is_callable( $control['callback'] ) ) {
1295
+		foreach ((array) $wp_registered_widget_updates as $name => $control) {
1296
+			if ($name === $parsed_id['id_base'] && is_callable($control['callback'])) {
1297 1297
 				ob_start();
1298
-				call_user_func_array( $control['callback'], $control['params'] );
1298
+				call_user_func_array($control['callback'], $control['params']);
1299 1299
 				ob_end_clean();
1300 1300
 				break;
1301 1301
 			}
1302 1302
 		}
1303 1303
 
1304 1304
 		// Clean up any input vars that were manually added
1305
-		foreach ( $added_input_vars as $key ) {
1306
-			unset( $_POST[ $key ] );
1307
-			unset( $_REQUEST[ $key ] );
1305
+		foreach ($added_input_vars as $key) {
1306
+			unset($_POST[$key]);
1307
+			unset($_REQUEST[$key]);
1308 1308
 		}
1309 1309
 
1310 1310
 		// Make sure the expected option was updated.
1311
-		if ( 0 !== $this->count_captured_options() ) {
1312
-			if ( $this->count_captured_options() > 1 ) {
1311
+		if (0 !== $this->count_captured_options()) {
1312
+			if ($this->count_captured_options() > 1) {
1313 1313
 				$this->stop_capturing_option_updates();
1314
-				return new WP_Error( 'widget_setting_too_many_options' );
1314
+				return new WP_Error('widget_setting_too_many_options');
1315 1315
 			}
1316 1316
 
1317
-			$updated_option_name = key( $this->get_captured_options() );
1318
-			if ( $updated_option_name !== $option_name ) {
1317
+			$updated_option_name = key($this->get_captured_options());
1318
+			if ($updated_option_name !== $option_name) {
1319 1319
 				$this->stop_capturing_option_updates();
1320
-				return new WP_Error( 'widget_setting_unexpected_option' );
1320
+				return new WP_Error('widget_setting_unexpected_option');
1321 1321
 			}
1322 1322
 		}
1323 1323
 
1324 1324
 		// Obtain the widget instance.
1325
-		$option = $this->get_captured_option( $option_name );
1326
-		if ( null !== $parsed_id['number'] ) {
1327
-			$instance = $option[ $parsed_id['number'] ];
1325
+		$option = $this->get_captured_option($option_name);
1326
+		if (null !== $parsed_id['number']) {
1327
+			$instance = $option[$parsed_id['number']];
1328 1328
 		} else {
1329 1329
 			$instance = $option;
1330 1330
 		}
@@ -1335,19 +1335,19 @@  discard block
 block discarded – undo
1335 1335
 		 * in place from WP_Customize_Setting::preview() will use this value
1336 1336
 		 * instead of the default widget instance value (an empty array).
1337 1337
 		 */
1338
-		$this->manager->set_post_value( $setting_id, $instance );
1338
+		$this->manager->set_post_value($setting_id, $instance);
1339 1339
 
1340 1340
 		// Obtain the widget control with the updated instance in place.
1341 1341
 		ob_start();
1342
-		$form = $wp_registered_widget_controls[ $widget_id ];
1343
-		if ( $form ) {
1344
-			call_user_func_array( $form['callback'], $form['params'] );
1342
+		$form = $wp_registered_widget_controls[$widget_id];
1343
+		if ($form) {
1344
+			call_user_func_array($form['callback'], $form['params']);
1345 1345
 		}
1346 1346
 		$form = ob_get_clean();
1347 1347
 
1348 1348
 		$this->stop_capturing_option_updates();
1349 1349
 
1350
-		return compact( 'instance', 'form' );
1350
+		return compact('instance', 'form');
1351 1351
 	}
1352 1352
 
1353 1353
 	/**
@@ -1366,53 +1366,53 @@  discard block
 block discarded – undo
1366 1366
 	 */
1367 1367
 	public function wp_ajax_update_widget() {
1368 1368
 
1369
-		if ( ! is_user_logged_in() ) {
1370
-			wp_die( 0 );
1369
+		if ( ! is_user_logged_in()) {
1370
+			wp_die(0);
1371 1371
 		}
1372 1372
 
1373
-		check_ajax_referer( 'update-widget', 'nonce' );
1373
+		check_ajax_referer('update-widget', 'nonce');
1374 1374
 
1375
-		if ( ! current_user_can( 'edit_theme_options' ) ) {
1375
+		if ( ! current_user_can('edit_theme_options')) {
1376 1376
 			wp_die( -1 );
1377 1377
 		}
1378 1378
 
1379
-		if ( empty( $_POST['widget-id'] ) ) {
1380
-			wp_send_json_error( 'missing_widget-id' );
1379
+		if (empty($_POST['widget-id'])) {
1380
+			wp_send_json_error('missing_widget-id');
1381 1381
 		}
1382 1382
 
1383 1383
 		/** This action is documented in wp-admin/includes/ajax-actions.php */
1384
-		do_action( 'load-widgets.php' );
1384
+		do_action('load-widgets.php');
1385 1385
 
1386 1386
 		/** This action is documented in wp-admin/includes/ajax-actions.php */
1387
-		do_action( 'widgets.php' );
1387
+		do_action('widgets.php');
1388 1388
 
1389 1389
 		/** This action is documented in wp-admin/widgets.php */
1390
-		do_action( 'sidebar_admin_setup' );
1390
+		do_action('sidebar_admin_setup');
1391 1391
 
1392
-		$widget_id = $this->get_post_value( 'widget-id' );
1393
-		$parsed_id = $this->parse_widget_id( $widget_id );
1392
+		$widget_id = $this->get_post_value('widget-id');
1393
+		$parsed_id = $this->parse_widget_id($widget_id);
1394 1394
 		$id_base = $parsed_id['id_base'];
1395 1395
 
1396 1396
 		$is_updating_widget_template = (
1397
-			isset( $_POST[ 'widget-' . $id_base ] )
1397
+			isset($_POST['widget-'.$id_base])
1398 1398
 			&&
1399
-			is_array( $_POST[ 'widget-' . $id_base ] )
1399
+			is_array($_POST['widget-'.$id_base])
1400 1400
 			&&
1401
-			preg_match( '/__i__|%i%/', key( $_POST[ 'widget-' . $id_base ] ) )
1401
+			preg_match('/__i__|%i%/', key($_POST['widget-'.$id_base]))
1402 1402
 		);
1403
-		if ( $is_updating_widget_template ) {
1404
-			wp_send_json_error( 'template_widget_not_updatable' );
1403
+		if ($is_updating_widget_template) {
1404
+			wp_send_json_error('template_widget_not_updatable');
1405 1405
 		}
1406 1406
 
1407
-		$updated_widget = $this->call_widget_update( $widget_id ); // => {instance,form}
1408
-		if ( is_wp_error( $updated_widget ) ) {
1409
-			wp_send_json_error( $updated_widget->get_error_code() );
1407
+		$updated_widget = $this->call_widget_update($widget_id); // => {instance,form}
1408
+		if (is_wp_error($updated_widget)) {
1409
+			wp_send_json_error($updated_widget->get_error_code());
1410 1410
 		}
1411 1411
 
1412 1412
 		$form = $updated_widget['form'];
1413
-		$instance = $this->sanitize_widget_js_instance( $updated_widget['instance'] );
1413
+		$instance = $this->sanitize_widget_js_instance($updated_widget['instance']);
1414 1414
 
1415
-		wp_send_json_success( compact( 'form', 'instance' ) );
1415
+		wp_send_json_success(compact('form', 'instance'));
1416 1416
 	}
1417 1417
 
1418 1418
 	/***************************************************************************
@@ -1446,8 +1446,8 @@  discard block
 block discarded – undo
1446 1446
 	 * @param string $option_name Option name.
1447 1447
 	 * @return bool Whether the option capture is ignored.
1448 1448
 	 */
1449
-	protected function is_option_capture_ignored( $option_name ) {
1450
-		return ( 0 === strpos( $option_name, '_transient_' ) );
1449
+	protected function is_option_capture_ignored($option_name) {
1450
+		return (0 === strpos($option_name, '_transient_'));
1451 1451
 	}
1452 1452
 
1453 1453
 	/**
@@ -1472,9 +1472,9 @@  discard block
 block discarded – undo
1472 1472
 	 * @param mixed  $default     Optional. Default value to return if the option does not exist.
1473 1473
 	 * @return mixed Value set for the option.
1474 1474
 	 */
1475
-	protected function get_captured_option( $option_name, $default = false ) {
1476
-		if ( array_key_exists( $option_name, $this->_captured_options ) ) {
1477
-			$value = $this->_captured_options[ $option_name ];
1475
+	protected function get_captured_option($option_name, $default = false) {
1476
+		if (array_key_exists($option_name, $this->_captured_options)) {
1477
+			$value = $this->_captured_options[$option_name];
1478 1478
 		} else {
1479 1479
 			$value = $default;
1480 1480
 		}
@@ -1490,7 +1490,7 @@  discard block
 block discarded – undo
1490 1490
 	 * @return int Number of updated options.
1491 1491
 	 */
1492 1492
 	protected function count_captured_options() {
1493
-		return count( $this->_captured_options );
1493
+		return count($this->_captured_options);
1494 1494
 	}
1495 1495
 
1496 1496
 	/**
@@ -1500,13 +1500,13 @@  discard block
 block discarded – undo
1500 1500
 	 * @access protected
1501 1501
 	 */
1502 1502
 	protected function start_capturing_option_updates() {
1503
-		if ( $this->_is_capturing_option_updates ) {
1503
+		if ($this->_is_capturing_option_updates) {
1504 1504
 			return;
1505 1505
 		}
1506 1506
 
1507 1507
 		$this->_is_capturing_option_updates = true;
1508 1508
 
1509
-		add_filter( 'pre_update_option', array( $this, 'capture_filter_pre_update_option' ), 10, 3 );
1509
+		add_filter('pre_update_option', array($this, 'capture_filter_pre_update_option'), 10, 3);
1510 1510
 	}
1511 1511
 
1512 1512
 	/**
@@ -1520,16 +1520,16 @@  discard block
 block discarded – undo
1520 1520
 	 * @param mixed  $old_value   The old option value.
1521 1521
 	 * @return mixed Filtered option value.
1522 1522
 	 */
1523
-	public function capture_filter_pre_update_option( $new_value, $option_name, $old_value ) {
1524
-		if ( $this->is_option_capture_ignored( $option_name ) ) {
1523
+	public function capture_filter_pre_update_option($new_value, $option_name, $old_value) {
1524
+		if ($this->is_option_capture_ignored($option_name)) {
1525 1525
 			return;
1526 1526
 		}
1527 1527
 
1528
-		if ( ! isset( $this->_captured_options[ $option_name ] ) ) {
1529
-			add_filter( "pre_option_{$option_name}", array( $this, 'capture_filter_pre_get_option' ) );
1528
+		if ( ! isset($this->_captured_options[$option_name])) {
1529
+			add_filter("pre_option_{$option_name}", array($this, 'capture_filter_pre_get_option'));
1530 1530
 		}
1531 1531
 
1532
-		$this->_captured_options[ $option_name ] = $new_value;
1532
+		$this->_captured_options[$option_name] = $new_value;
1533 1533
 
1534 1534
 		return $old_value;
1535 1535
 	}
@@ -1543,14 +1543,14 @@  discard block
 block discarded – undo
1543 1543
 	 * @param mixed $value Value to return instead of the option value.
1544 1544
 	 * @return mixed Filtered option value.
1545 1545
 	 */
1546
-	public function capture_filter_pre_get_option( $value ) {
1547
-		$option_name = preg_replace( '/^pre_option_/', '', current_filter() );
1546
+	public function capture_filter_pre_get_option($value) {
1547
+		$option_name = preg_replace('/^pre_option_/', '', current_filter());
1548 1548
 
1549
-		if ( isset( $this->_captured_options[ $option_name ] ) ) {
1550
-			$value = $this->_captured_options[ $option_name ];
1549
+		if (isset($this->_captured_options[$option_name])) {
1550
+			$value = $this->_captured_options[$option_name];
1551 1551
 
1552 1552
 			/** This filter is documented in wp-includes/option.php */
1553
-			$value = apply_filters( 'option_' . $option_name, $value );
1553
+			$value = apply_filters('option_'.$option_name, $value);
1554 1554
 		}
1555 1555
 
1556 1556
 		return $value;
@@ -1563,14 +1563,14 @@  discard block
 block discarded – undo
1563 1563
 	 * @access protected
1564 1564
 	 */
1565 1565
 	protected function stop_capturing_option_updates() {
1566
-		if ( ! $this->_is_capturing_option_updates ) {
1566
+		if ( ! $this->_is_capturing_option_updates) {
1567 1567
 			return;
1568 1568
 		}
1569 1569
 
1570
-		remove_filter( 'pre_update_option', array( $this, 'capture_filter_pre_update_option' ), 10, 3 );
1570
+		remove_filter('pre_update_option', array($this, 'capture_filter_pre_update_option'), 10, 3);
1571 1571
 
1572
-		foreach ( array_keys( $this->_captured_options ) as $option_name ) {
1573
-			remove_filter( "pre_option_{$option_name}", array( $this, 'capture_filter_pre_get_option' ) );
1572
+		foreach (array_keys($this->_captured_options) as $option_name) {
1573
+			remove_filter("pre_option_{$option_name}", array($this, 'capture_filter_pre_get_option'));
1574 1574
 		}
1575 1575
 
1576 1576
 		$this->_captured_options = array();
@@ -1582,7 +1582,7 @@  discard block
 block discarded – undo
1582 1582
 	 * @deprecated 4.2.0 Deprecated in favor of customize_dynamic_setting_args filter.
1583 1583
 	 */
1584 1584
 	public function setup_widget_addition_previews() {
1585
-		_deprecated_function( __METHOD__, '4.2.0' );
1585
+		_deprecated_function(__METHOD__, '4.2.0');
1586 1586
 	}
1587 1587
 
1588 1588
 	/**
@@ -1590,7 +1590,7 @@  discard block
 block discarded – undo
1590 1590
 	 * @deprecated 4.2.0 Deprecated in favor of customize_dynamic_setting_args filter.
1591 1591
 	 */
1592 1592
 	public function prepreview_added_sidebars_widgets() {
1593
-		_deprecated_function( __METHOD__, '4.2.0' );
1593
+		_deprecated_function(__METHOD__, '4.2.0');
1594 1594
 	}
1595 1595
 
1596 1596
 	/**
@@ -1598,7 +1598,7 @@  discard block
 block discarded – undo
1598 1598
 	 * @deprecated 4.2.0 Deprecated in favor of customize_dynamic_setting_args filter.
1599 1599
 	 */
1600 1600
 	public function prepreview_added_widget_instance() {
1601
-		_deprecated_function( __METHOD__, '4.2.0' );
1601
+		_deprecated_function(__METHOD__, '4.2.0');
1602 1602
 	}
1603 1603
 
1604 1604
 	/**
@@ -1606,6 +1606,6 @@  discard block
 block discarded – undo
1606 1606
 	 * @deprecated 4.2.0 Deprecated in favor of customize_dynamic_setting_args filter.
1607 1607
 	 */
1608 1608
 	public function remove_prepreview_filters() {
1609
-		_deprecated_function( __METHOD__, '4.2.0' );
1609
+		_deprecated_function(__METHOD__, '4.2.0');
1610 1610
 	}
1611 1611
 }
Please login to merge, or discard this patch.
src/wp-includes/class-wp-image-editor-gd.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@
 block discarded – undo
135 135
 	 *
136 136
 	 * @param int $width
137 137
 	 * @param int $height
138
-	 * @return true
138
+	 * @return boolean
139 139
 	 */
140 140
 	protected function update_size( $width = false, $height = false ) {
141 141
 		if ( ! $width )
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * WordPress GD Image Editor
4
- *
5
- * @package WordPress
6
- * @subpackage Image_Editor
7
- */
3
+	 * WordPress GD Image Editor
4
+	 *
5
+	 * @package WordPress
6
+	 * @subpackage Image_Editor
7
+	 */
8 8
 
9 9
 /**
10 10
  * WordPress Image Editor Class for Image Manipulation through GD
Please login to merge, or discard this patch.
Spacing   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
 	protected $image;
25 25
 
26 26
 	public function __destruct() {
27
-		if ( $this->image ) {
27
+		if ($this->image) {
28 28
 			// we don't need the original in memory anymore
29
-			imagedestroy( $this->image );
29
+			imagedestroy($this->image);
30 30
 		}
31 31
 	}
32 32
 
@@ -41,14 +41,14 @@  discard block
 block discarded – undo
41 41
 	 * @param array $args
42 42
 	 * @return bool
43 43
 	 */
44
-	public static function test( $args = array() ) {
45
-		if ( ! extension_loaded('gd') || ! function_exists('gd_info') )
44
+	public static function test($args = array()) {
45
+		if ( ! extension_loaded('gd') || ! function_exists('gd_info'))
46 46
 			return false;
47 47
 
48 48
 		// On some setups GD library does not provide imagerotate() - Ticket #11536
49
-		if ( isset( $args['methods'] ) &&
50
-			 in_array( 'rotate', $args['methods'] ) &&
51
-			 ! function_exists('imagerotate') ){
49
+		if (isset($args['methods']) &&
50
+			 in_array('rotate', $args['methods']) &&
51
+			 ! function_exists('imagerotate')) {
52 52
 
53 53
 				return false;
54 54
 		}
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
 	 * @param string $mime_type
68 68
 	 * @return bool
69 69
 	 */
70
-	public static function supports_mime_type( $mime_type ) {
70
+	public static function supports_mime_type($mime_type) {
71 71
 		$image_types = imagetypes();
72
-		switch( $mime_type ) {
72
+		switch ($mime_type) {
73 73
 			case 'image/jpeg':
74 74
 				return ($image_types & IMG_JPG) != 0;
75 75
 			case 'image/png':
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
90 90
 	 * @return bool|WP_Error True if loaded successfully; WP_Error on failure.
91 91
 	 */
92 92
 	public function load() {
93
-		if ( $this->image )
93
+		if ($this->image)
94 94
 			return true;
95 95
 
96
-		if ( ! is_file( $this->file ) && ! preg_match( '|^https?://|', $this->file ) )
97
-			return new WP_Error( 'error_loading_image', __('File doesn&#8217;t exist?'), $this->file );
96
+		if ( ! is_file($this->file) && ! preg_match('|^https?://|', $this->file))
97
+			return new WP_Error('error_loading_image', __('File doesn&#8217;t exist?'), $this->file);
98 98
 
99 99
 		/**
100 100
 		 * Filter the memory limit allocated for image manipulation.
@@ -105,23 +105,23 @@  discard block
 block discarded – undo
105 105
 		 *                          Accepts an integer (bytes), or a shorthand string notation, such as '256M'.
106 106
 		 */
107 107
 		// Set artificially high because GD uses uncompressed images in memory
108
-		@ini_set( 'memory_limit', apply_filters( 'image_memory_limit', WP_MAX_MEMORY_LIMIT ) );
108
+		@ini_set('memory_limit', apply_filters('image_memory_limit', WP_MAX_MEMORY_LIMIT));
109 109
 
110
-		$this->image = @imagecreatefromstring( file_get_contents( $this->file ) );
110
+		$this->image = @imagecreatefromstring(file_get_contents($this->file));
111 111
 
112
-		if ( ! is_resource( $this->image ) )
113
-			return new WP_Error( 'invalid_image', __('File is not an image.'), $this->file );
112
+		if ( ! is_resource($this->image))
113
+			return new WP_Error('invalid_image', __('File is not an image.'), $this->file);
114 114
 
115
-		$size = @getimagesize( $this->file );
116
-		if ( ! $size )
117
-			return new WP_Error( 'invalid_image', __('Could not read image size.'), $this->file );
115
+		$size = @getimagesize($this->file);
116
+		if ( ! $size)
117
+			return new WP_Error('invalid_image', __('Could not read image size.'), $this->file);
118 118
 
119
-		if ( function_exists( 'imagealphablending' ) && function_exists( 'imagesavealpha' ) ) {
120
-			imagealphablending( $this->image, false );
121
-			imagesavealpha( $this->image, true );
119
+		if (function_exists('imagealphablending') && function_exists('imagesavealpha')) {
120
+			imagealphablending($this->image, false);
121
+			imagesavealpha($this->image, true);
122 122
 		}
123 123
 
124
-		$this->update_size( $size[0], $size[1] );
124
+		$this->update_size($size[0], $size[1]);
125 125
 		$this->mime_type = $size['mime'];
126 126
 
127 127
 		return $this->set_quality();
@@ -137,14 +137,14 @@  discard block
 block discarded – undo
137 137
 	 * @param int $height
138 138
 	 * @return true
139 139
 	 */
140
-	protected function update_size( $width = false, $height = false ) {
141
-		if ( ! $width )
142
-			$width = imagesx( $this->image );
140
+	protected function update_size($width = false, $height = false) {
141
+		if ( ! $width)
142
+			$width = imagesx($this->image);
143 143
 
144
-		if ( ! $height )
145
-			$height = imagesy( $this->image );
144
+		if ( ! $height)
145
+			$height = imagesy($this->image);
146 146
 
147
-		return parent::update_size( $width, $height );
147
+		return parent::update_size($width, $height);
148 148
 	}
149 149
 
150 150
 	/**
@@ -163,21 +163,21 @@  discard block
 block discarded – undo
163 163
 	 * @param  bool     $crop
164 164
 	 * @return true|WP_Error
165 165
 	 */
166
-	public function resize( $max_w, $max_h, $crop = false ) {
167
-		if ( ( $this->size['width'] == $max_w ) && ( $this->size['height'] == $max_h ) )
166
+	public function resize($max_w, $max_h, $crop = false) {
167
+		if (($this->size['width'] == $max_w) && ($this->size['height'] == $max_h))
168 168
 			return true;
169 169
 
170
-		$resized = $this->_resize( $max_w, $max_h, $crop );
170
+		$resized = $this->_resize($max_w, $max_h, $crop);
171 171
 
172
-		if ( is_resource( $resized ) ) {
173
-			imagedestroy( $this->image );
172
+		if (is_resource($resized)) {
173
+			imagedestroy($this->image);
174 174
 			$this->image = $resized;
175 175
 			return true;
176 176
 
177
-		} elseif ( is_wp_error( $resized ) )
177
+		} elseif (is_wp_error($resized))
178 178
 			return $resized;
179 179
 
180
-		return new WP_Error( 'image_resize_error', __('Image resize failed.'), $this->file );
180
+		return new WP_Error('image_resize_error', __('Image resize failed.'), $this->file);
181 181
 	}
182 182
 
183 183
 	/**
@@ -187,22 +187,22 @@  discard block
 block discarded – undo
187 187
 	 * @param bool|array $crop
188 188
 	 * @return resource|WP_Error
189 189
 	 */
190
-	protected function _resize( $max_w, $max_h, $crop = false ) {
191
-		$dims = image_resize_dimensions( $this->size['width'], $this->size['height'], $max_w, $max_h, $crop );
192
-		if ( ! $dims ) {
193
-			return new WP_Error( 'error_getting_dimensions', __('Could not calculate resized image dimensions'), $this->file );
190
+	protected function _resize($max_w, $max_h, $crop = false) {
191
+		$dims = image_resize_dimensions($this->size['width'], $this->size['height'], $max_w, $max_h, $crop);
192
+		if ( ! $dims) {
193
+			return new WP_Error('error_getting_dimensions', __('Could not calculate resized image dimensions'), $this->file);
194 194
 		}
195
-		list( $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ) = $dims;
195
+		list($dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) = $dims;
196 196
 
197
-		$resized = wp_imagecreatetruecolor( $dst_w, $dst_h );
198
-		imagecopyresampled( $resized, $this->image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h );
197
+		$resized = wp_imagecreatetruecolor($dst_w, $dst_h);
198
+		imagecopyresampled($resized, $this->image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
199 199
 
200
-		if ( is_resource( $resized ) ) {
201
-			$this->update_size( $dst_w, $dst_h );
200
+		if (is_resource($resized)) {
201
+			$this->update_size($dst_w, $dst_h);
202 202
 			return $resized;
203 203
 		}
204 204
 
205
-		return new WP_Error( 'image_resize_error', __('Image resize failed.'), $this->file );
205
+		return new WP_Error('image_resize_error', __('Image resize failed.'), $this->file);
206 206
 	}
207 207
 
208 208
 	/**
@@ -226,36 +226,36 @@  discard block
 block discarded – undo
226 226
 	 * }
227 227
 	 * @return array An array of resized images' metadata by size.
228 228
 	 */
229
-	public function multi_resize( $sizes ) {
229
+	public function multi_resize($sizes) {
230 230
 		$metadata = array();
231 231
 		$orig_size = $this->size;
232 232
 
233
-		foreach ( $sizes as $size => $size_data ) {
234
-			if ( ! isset( $size_data['width'] ) && ! isset( $size_data['height'] ) ) {
233
+		foreach ($sizes as $size => $size_data) {
234
+			if ( ! isset($size_data['width']) && ! isset($size_data['height'])) {
235 235
 				continue;
236 236
 			}
237 237
 
238
-			if ( ! isset( $size_data['width'] ) ) {
238
+			if ( ! isset($size_data['width'])) {
239 239
 				$size_data['width'] = null;
240 240
 			}
241
-			if ( ! isset( $size_data['height'] ) ) {
241
+			if ( ! isset($size_data['height'])) {
242 242
 				$size_data['height'] = null;
243 243
 			}
244 244
 
245
-			if ( ! isset( $size_data['crop'] ) ) {
245
+			if ( ! isset($size_data['crop'])) {
246 246
 				$size_data['crop'] = false;
247 247
 			}
248 248
 
249
-			$image = $this->_resize( $size_data['width'], $size_data['height'], $size_data['crop'] );
250
-			$duplicate = ( ( $orig_size['width'] == $size_data['width'] ) && ( $orig_size['height'] == $size_data['height'] ) );
249
+			$image = $this->_resize($size_data['width'], $size_data['height'], $size_data['crop']);
250
+			$duplicate = (($orig_size['width'] == $size_data['width']) && ($orig_size['height'] == $size_data['height']));
251 251
 
252
-			if ( ! is_wp_error( $image ) && ! $duplicate ) {
253
-				$resized = $this->_save( $image );
252
+			if ( ! is_wp_error($image) && ! $duplicate) {
253
+				$resized = $this->_save($image);
254 254
 
255
-				imagedestroy( $image );
255
+				imagedestroy($image);
256 256
 
257
-				if ( ! is_wp_error( $resized ) && $resized ) {
258
-					unset( $resized['path'] );
257
+				if ( ! is_wp_error($resized) && $resized) {
258
+					unset($resized['path']);
259 259
 					$metadata[$size] = $resized;
260 260
 				}
261 261
 			}
@@ -281,34 +281,34 @@  discard block
 block discarded – undo
281 281
 	 * @param bool $src_abs Optional. If the source crop points are absolute.
282 282
 	 * @return bool|WP_Error
283 283
 	 */
284
-	public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ) {
284
+	public function crop($src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false) {
285 285
 		// If destination width/height isn't specified, use same as
286 286
 		// width/height from source.
287
-		if ( ! $dst_w )
287
+		if ( ! $dst_w)
288 288
 			$dst_w = $src_w;
289
-		if ( ! $dst_h )
289
+		if ( ! $dst_h)
290 290
 			$dst_h = $src_h;
291 291
 
292
-		$dst = wp_imagecreatetruecolor( $dst_w, $dst_h );
292
+		$dst = wp_imagecreatetruecolor($dst_w, $dst_h);
293 293
 
294
-		if ( $src_abs ) {
294
+		if ($src_abs) {
295 295
 			$src_w -= $src_x;
296 296
 			$src_h -= $src_y;
297 297
 		}
298 298
 
299
-		if ( function_exists( 'imageantialias' ) )
300
-			imageantialias( $dst, true );
299
+		if (function_exists('imageantialias'))
300
+			imageantialias($dst, true);
301 301
 
302
-		imagecopyresampled( $dst, $this->image, 0, 0, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h );
302
+		imagecopyresampled($dst, $this->image, 0, 0, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
303 303
 
304
-		if ( is_resource( $dst ) ) {
305
-			imagedestroy( $this->image );
304
+		if (is_resource($dst)) {
305
+			imagedestroy($this->image);
306 306
 			$this->image = $dst;
307 307
 			$this->update_size();
308 308
 			return true;
309 309
 		}
310 310
 
311
-		return new WP_Error( 'image_crop_error', __('Image crop failed.'), $this->file );
311
+		return new WP_Error('image_crop_error', __('Image crop failed.'), $this->file);
312 312
 	}
313 313
 
314 314
 	/**
@@ -321,21 +321,21 @@  discard block
 block discarded – undo
321 321
 	 * @param float $angle
322 322
 	 * @return true|WP_Error
323 323
 	 */
324
-	public function rotate( $angle ) {
325
-		if ( function_exists('imagerotate') ) {
326
-			$transparency = imagecolorallocatealpha( $this->image, 255, 255, 255, 127 );
327
-			$rotated = imagerotate( $this->image, $angle, $transparency );
328
-
329
-			if ( is_resource( $rotated ) ) {
330
-				imagealphablending( $rotated, true );
331
-				imagesavealpha( $rotated, true );
332
-				imagedestroy( $this->image );
324
+	public function rotate($angle) {
325
+		if (function_exists('imagerotate')) {
326
+			$transparency = imagecolorallocatealpha($this->image, 255, 255, 255, 127);
327
+			$rotated = imagerotate($this->image, $angle, $transparency);
328
+
329
+			if (is_resource($rotated)) {
330
+				imagealphablending($rotated, true);
331
+				imagesavealpha($rotated, true);
332
+				imagedestroy($this->image);
333 333
 				$this->image = $rotated;
334 334
 				$this->update_size();
335 335
 				return true;
336 336
 			}
337 337
 		}
338
-		return new WP_Error( 'image_rotate_error', __('Image rotate failed.'), $this->file );
338
+		return new WP_Error('image_rotate_error', __('Image rotate failed.'), $this->file);
339 339
 	}
340 340
 
341 341
 	/**
@@ -348,24 +348,24 @@  discard block
 block discarded – undo
348 348
 	 * @param bool $vert Flip along Vertical Axis
349 349
 	 * @return true|WP_Error
350 350
 	 */
351
-	public function flip( $horz, $vert ) {
351
+	public function flip($horz, $vert) {
352 352
 		$w = $this->size['width'];
353 353
 		$h = $this->size['height'];
354
-		$dst = wp_imagecreatetruecolor( $w, $h );
354
+		$dst = wp_imagecreatetruecolor($w, $h);
355 355
 
356
-		if ( is_resource( $dst ) ) {
356
+		if (is_resource($dst)) {
357 357
 			$sx = $vert ? ($w - 1) : 0;
358 358
 			$sy = $horz ? ($h - 1) : 0;
359 359
 			$sw = $vert ? -$w : $w;
360 360
 			$sh = $horz ? -$h : $h;
361 361
 
362
-			if ( imagecopyresampled( $dst, $this->image, 0, 0, $sx, $sy, $w, $h, $sw, $sh ) ) {
363
-				imagedestroy( $this->image );
362
+			if (imagecopyresampled($dst, $this->image, 0, 0, $sx, $sy, $w, $h, $sw, $sh)) {
363
+				imagedestroy($this->image);
364 364
 				$this->image = $dst;
365 365
 				return true;
366 366
 			}
367 367
 		}
368
-		return new WP_Error( 'image_flip_error', __('Image flip failed.'), $this->file );
368
+		return new WP_Error('image_flip_error', __('Image flip failed.'), $this->file);
369 369
 	}
370 370
 
371 371
 	/**
@@ -378,10 +378,10 @@  discard block
 block discarded – undo
378 378
 	 * @param string|null $mime_type
379 379
 	 * @return array|WP_Error {'path'=>string, 'file'=>string, 'width'=>int, 'height'=>int, 'mime-type'=>string}
380 380
 	 */
381
-	public function save( $filename = null, $mime_type = null ) {
382
-		$saved = $this->_save( $this->image, $filename, $mime_type );
381
+	public function save($filename = null, $mime_type = null) {
382
+		$saved = $this->_save($this->image, $filename, $mime_type);
383 383
 
384
-		if ( ! is_wp_error( $saved ) ) {
384
+		if ( ! is_wp_error($saved)) {
385 385
 			$this->file = $saved['path'];
386 386
 			$this->mime_type = $saved['mime-type'];
387 387
 		}
@@ -395,36 +395,36 @@  discard block
 block discarded – undo
395 395
 	 * @param string|null $mime_type
396 396
 	 * @return WP_Error|array
397 397
 	 */
398
-	protected function _save( $image, $filename = null, $mime_type = null ) {
399
-		list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type );
398
+	protected function _save($image, $filename = null, $mime_type = null) {
399
+		list($filename, $extension, $mime_type) = $this->get_output_format($filename, $mime_type);
400 400
 
401
-		if ( ! $filename )
402
-			$filename = $this->generate_filename( null, null, $extension );
401
+		if ( ! $filename)
402
+			$filename = $this->generate_filename(null, null, $extension);
403 403
 
404
-		if ( 'image/gif' == $mime_type ) {
405
-			if ( ! $this->make_image( $filename, 'imagegif', array( $image, $filename ) ) )
406
-				return new WP_Error( 'image_save_error', __('Image Editor Save Failed') );
404
+		if ('image/gif' == $mime_type) {
405
+			if ( ! $this->make_image($filename, 'imagegif', array($image, $filename)))
406
+				return new WP_Error('image_save_error', __('Image Editor Save Failed'));
407 407
 		}
408
-		elseif ( 'image/png' == $mime_type ) {
408
+		elseif ('image/png' == $mime_type) {
409 409
 			// convert from full colors to index colors, like original PNG.
410
-			if ( function_exists('imageistruecolor') && ! imageistruecolor( $image ) )
411
-				imagetruecolortopalette( $image, false, imagecolorstotal( $image ) );
410
+			if (function_exists('imageistruecolor') && ! imageistruecolor($image))
411
+				imagetruecolortopalette($image, false, imagecolorstotal($image));
412 412
 
413
-			if ( ! $this->make_image( $filename, 'imagepng', array( $image, $filename ) ) )
414
-				return new WP_Error( 'image_save_error', __('Image Editor Save Failed') );
413
+			if ( ! $this->make_image($filename, 'imagepng', array($image, $filename)))
414
+				return new WP_Error('image_save_error', __('Image Editor Save Failed'));
415 415
 		}
416
-		elseif ( 'image/jpeg' == $mime_type ) {
417
-			if ( ! $this->make_image( $filename, 'imagejpeg', array( $image, $filename, $this->get_quality() ) ) )
418
-				return new WP_Error( 'image_save_error', __('Image Editor Save Failed') );
416
+		elseif ('image/jpeg' == $mime_type) {
417
+			if ( ! $this->make_image($filename, 'imagejpeg', array($image, $filename, $this->get_quality())))
418
+				return new WP_Error('image_save_error', __('Image Editor Save Failed'));
419 419
 		}
420 420
 		else {
421
-			return new WP_Error( 'image_save_error', __('Image Editor Save Failed') );
421
+			return new WP_Error('image_save_error', __('Image Editor Save Failed'));
422 422
 		}
423 423
 
424 424
 		// Set correct file permissions
425
-		$stat = stat( dirname( $filename ) );
425
+		$stat = stat(dirname($filename));
426 426
 		$perms = $stat['mode'] & 0000666; //same permissions as parent folder, strip off the executable bits
427
-		@ chmod( $filename, $perms );
427
+		@ chmod($filename, $perms);
428 428
 
429 429
 		/**
430 430
 		 * Filter the name of the saved image file.
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 		 */
436 436
 		return array(
437 437
 			'path'      => $filename,
438
-			'file'      => wp_basename( apply_filters( 'image_make_intermediate_size', $filename ) ),
438
+			'file'      => wp_basename(apply_filters('image_make_intermediate_size', $filename)),
439 439
 			'width'     => $this->size['width'],
440 440
 			'height'    => $this->size['height'],
441 441
 			'mime-type' => $mime_type,
@@ -451,19 +451,19 @@  discard block
 block discarded – undo
451 451
 	 * @param string $mime_type
452 452
 	 * @return bool
453 453
 	 */
454
-	public function stream( $mime_type = null ) {
455
-		list( $filename, $extension, $mime_type ) = $this->get_output_format( null, $mime_type );
454
+	public function stream($mime_type = null) {
455
+		list($filename, $extension, $mime_type) = $this->get_output_format(null, $mime_type);
456 456
 
457
-		switch ( $mime_type ) {
457
+		switch ($mime_type) {
458 458
 			case 'image/png':
459
-				header( 'Content-Type: image/png' );
460
-				return imagepng( $this->image );
459
+				header('Content-Type: image/png');
460
+				return imagepng($this->image);
461 461
 			case 'image/gif':
462
-				header( 'Content-Type: image/gif' );
463
-				return imagegif( $this->image );
462
+				header('Content-Type: image/gif');
463
+				return imagegif($this->image);
464 464
 			default:
465
-				header( 'Content-Type: image/jpeg' );
466
-				return imagejpeg( $this->image, null, $this->get_quality() );
465
+				header('Content-Type: image/jpeg');
466
+				return imagejpeg($this->image, null, $this->get_quality());
467 467
 		}
468 468
 	}
469 469
 
@@ -478,10 +478,10 @@  discard block
 block discarded – undo
478 478
 	 * @param array $arguments
479 479
 	 * @return bool
480 480
 	 */
481
-	protected function make_image( $filename, $function, $arguments ) {
482
-		if ( wp_is_stream( $filename ) )
481
+	protected function make_image($filename, $function, $arguments) {
482
+		if (wp_is_stream($filename))
483 483
 			$arguments[1] = null;
484 484
 
485
-		return parent::make_image( $filename, $function, $arguments );
485
+		return parent::make_image($filename, $function, $arguments);
486 486
 	}
487 487
 }
Please login to merge, or discard this patch.
Braces   +57 added lines, -42 removed lines patch added patch discarded remove patch
@@ -42,8 +42,9 @@  discard block
 block discarded – undo
42 42
 	 * @return bool
43 43
 	 */
44 44
 	public static function test( $args = array() ) {
45
-		if ( ! extension_loaded('gd') || ! function_exists('gd_info') )
46
-			return false;
45
+		if ( ! extension_loaded('gd') || ! function_exists('gd_info') ) {
46
+					return false;
47
+		}
47 48
 
48 49
 		// On some setups GD library does not provide imagerotate() - Ticket #11536
49 50
 		if ( isset( $args['methods'] ) &&
@@ -90,11 +91,13 @@  discard block
 block discarded – undo
90 91
 	 * @return bool|WP_Error True if loaded successfully; WP_Error on failure.
91 92
 	 */
92 93
 	public function load() {
93
-		if ( $this->image )
94
-			return true;
94
+		if ( $this->image ) {
95
+					return true;
96
+		}
95 97
 
96
-		if ( ! is_file( $this->file ) && ! preg_match( '|^https?://|', $this->file ) )
97
-			return new WP_Error( 'error_loading_image', __('File doesn&#8217;t exist?'), $this->file );
98
+		if ( ! is_file( $this->file ) && ! preg_match( '|^https?://|', $this->file ) ) {
99
+					return new WP_Error( 'error_loading_image', __('File doesn&#8217;t exist?'), $this->file );
100
+		}
98 101
 
99 102
 		/**
100 103
 		 * Filter the memory limit allocated for image manipulation.
@@ -109,12 +112,14 @@  discard block
 block discarded – undo
109 112
 
110 113
 		$this->image = @imagecreatefromstring( file_get_contents( $this->file ) );
111 114
 
112
-		if ( ! is_resource( $this->image ) )
113
-			return new WP_Error( 'invalid_image', __('File is not an image.'), $this->file );
115
+		if ( ! is_resource( $this->image ) ) {
116
+					return new WP_Error( 'invalid_image', __('File is not an image.'), $this->file );
117
+		}
114 118
 
115 119
 		$size = @getimagesize( $this->file );
116
-		if ( ! $size )
117
-			return new WP_Error( 'invalid_image', __('Could not read image size.'), $this->file );
120
+		if ( ! $size ) {
121
+					return new WP_Error( 'invalid_image', __('Could not read image size.'), $this->file );
122
+		}
118 123
 
119 124
 		if ( function_exists( 'imagealphablending' ) && function_exists( 'imagesavealpha' ) ) {
120 125
 			imagealphablending( $this->image, false );
@@ -138,11 +143,13 @@  discard block
 block discarded – undo
138 143
 	 * @return true
139 144
 	 */
140 145
 	protected function update_size( $width = false, $height = false ) {
141
-		if ( ! $width )
142
-			$width = imagesx( $this->image );
146
+		if ( ! $width ) {
147
+					$width = imagesx( $this->image );
148
+		}
143 149
 
144
-		if ( ! $height )
145
-			$height = imagesy( $this->image );
150
+		if ( ! $height ) {
151
+					$height = imagesy( $this->image );
152
+		}
146 153
 
147 154
 		return parent::update_size( $width, $height );
148 155
 	}
@@ -164,8 +171,9 @@  discard block
 block discarded – undo
164 171
 	 * @return true|WP_Error
165 172
 	 */
166 173
 	public function resize( $max_w, $max_h, $crop = false ) {
167
-		if ( ( $this->size['width'] == $max_w ) && ( $this->size['height'] == $max_h ) )
168
-			return true;
174
+		if ( ( $this->size['width'] == $max_w ) && ( $this->size['height'] == $max_h ) ) {
175
+					return true;
176
+		}
169 177
 
170 178
 		$resized = $this->_resize( $max_w, $max_h, $crop );
171 179
 
@@ -174,8 +182,9 @@  discard block
 block discarded – undo
174 182
 			$this->image = $resized;
175 183
 			return true;
176 184
 
177
-		} elseif ( is_wp_error( $resized ) )
178
-			return $resized;
185
+		} elseif ( is_wp_error( $resized ) ) {
186
+					return $resized;
187
+		}
179 188
 
180 189
 		return new WP_Error( 'image_resize_error', __('Image resize failed.'), $this->file );
181 190
 	}
@@ -284,10 +293,12 @@  discard block
 block discarded – undo
284 293
 	public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ) {
285 294
 		// If destination width/height isn't specified, use same as
286 295
 		// width/height from source.
287
-		if ( ! $dst_w )
288
-			$dst_w = $src_w;
289
-		if ( ! $dst_h )
290
-			$dst_h = $src_h;
296
+		if ( ! $dst_w ) {
297
+					$dst_w = $src_w;
298
+		}
299
+		if ( ! $dst_h ) {
300
+					$dst_h = $src_h;
301
+		}
291 302
 
292 303
 		$dst = wp_imagecreatetruecolor( $dst_w, $dst_h );
293 304
 
@@ -296,8 +307,9 @@  discard block
 block discarded – undo
296 307
 			$src_h -= $src_y;
297 308
 		}
298 309
 
299
-		if ( function_exists( 'imageantialias' ) )
300
-			imageantialias( $dst, true );
310
+		if ( function_exists( 'imageantialias' ) ) {
311
+					imageantialias( $dst, true );
312
+		}
301 313
 
302 314
 		imagecopyresampled( $dst, $this->image, 0, 0, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h );
303 315
 
@@ -398,26 +410,28 @@  discard block
 block discarded – undo
398 410
 	protected function _save( $image, $filename = null, $mime_type = null ) {
399 411
 		list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type );
400 412
 
401
-		if ( ! $filename )
402
-			$filename = $this->generate_filename( null, null, $extension );
413
+		if ( ! $filename ) {
414
+					$filename = $this->generate_filename( null, null, $extension );
415
+		}
403 416
 
404 417
 		if ( 'image/gif' == $mime_type ) {
405
-			if ( ! $this->make_image( $filename, 'imagegif', array( $image, $filename ) ) )
406
-				return new WP_Error( 'image_save_error', __('Image Editor Save Failed') );
407
-		}
408
-		elseif ( 'image/png' == $mime_type ) {
418
+			if ( ! $this->make_image( $filename, 'imagegif', array( $image, $filename ) ) ) {
419
+							return new WP_Error( 'image_save_error', __('Image Editor Save Failed') );
420
+			}
421
+		} elseif ( 'image/png' == $mime_type ) {
409 422
 			// convert from full colors to index colors, like original PNG.
410
-			if ( function_exists('imageistruecolor') && ! imageistruecolor( $image ) )
411
-				imagetruecolortopalette( $image, false, imagecolorstotal( $image ) );
423
+			if ( function_exists('imageistruecolor') && ! imageistruecolor( $image ) ) {
424
+							imagetruecolortopalette( $image, false, imagecolorstotal( $image ) );
425
+			}
412 426
 
413
-			if ( ! $this->make_image( $filename, 'imagepng', array( $image, $filename ) ) )
414
-				return new WP_Error( 'image_save_error', __('Image Editor Save Failed') );
415
-		}
416
-		elseif ( 'image/jpeg' == $mime_type ) {
417
-			if ( ! $this->make_image( $filename, 'imagejpeg', array( $image, $filename, $this->get_quality() ) ) )
418
-				return new WP_Error( 'image_save_error', __('Image Editor Save Failed') );
419
-		}
420
-		else {
427
+			if ( ! $this->make_image( $filename, 'imagepng', array( $image, $filename ) ) ) {
428
+							return new WP_Error( 'image_save_error', __('Image Editor Save Failed') );
429
+			}
430
+		} elseif ( 'image/jpeg' == $mime_type ) {
431
+			if ( ! $this->make_image( $filename, 'imagejpeg', array( $image, $filename, $this->get_quality() ) ) ) {
432
+							return new WP_Error( 'image_save_error', __('Image Editor Save Failed') );
433
+			}
434
+		} else {
421 435
 			return new WP_Error( 'image_save_error', __('Image Editor Save Failed') );
422 436
 		}
423 437
 
@@ -479,8 +493,9 @@  discard block
 block discarded – undo
479 493
 	 * @return bool
480 494
 	 */
481 495
 	protected function make_image( $filename, $function, $arguments ) {
482
-		if ( wp_is_stream( $filename ) )
483
-			$arguments[1] = null;
496
+		if ( wp_is_stream( $filename ) ) {
497
+					$arguments[1] = null;
498
+		}
484 499
 
485 500
 		return parent::make_image( $filename, $function, $arguments );
486 501
 	}
Please login to merge, or discard this patch.
src/wp-includes/class-wp-image-editor.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	 *
198 198
 	 * @param int $width
199 199
 	 * @param int $height
200
-	 * @return true
200
+	 * @return boolean
201 201
 	 */
202 202
 	protected function update_size( $width = null, $height = null ) {
203 203
 		$this->size = array(
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 	 * @since 4.0.0
214 214
 	 * @access public
215 215
 	 *
216
-	 * @return int $quality Compression Quality. Range: [1,100]
216
+	 * @return boolean $quality Compression Quality. Range: [1,100]
217 217
 	 */
218 218
 	public function get_quality() {
219 219
 		if ( ! $this->quality ) {
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Base WordPress Image Editor
4
- *
5
- * @package WordPress
6
- * @subpackage Image_Editor
7
- */
3
+	 * Base WordPress Image Editor
4
+	 *
5
+	 * @package WordPress
6
+	 * @subpackage Image_Editor
7
+	 */
8 8
 
9 9
 /**
10 10
  * Base image editor class from which implementations extend
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	/**
23 23
 	 * Each instance handles a single file.
24 24
 	 */
25
-	public function __construct( $file ) {
25
+	public function __construct($file) {
26 26
 		$this->file = $file;
27 27
 	}
28 28
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 * @param array $args
40 40
 	 * @return bool
41 41
 	 */
42
-	public static function test( $args = array() ) {
42
+	public static function test($args = array()) {
43 43
 		return false;
44 44
 	}
45 45
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * @param string $mime_type
57 57
 	 * @return bool
58 58
 	 */
59
-	public static function supports_mime_type( $mime_type ) {
59
+	public static function supports_mime_type($mime_type) {
60 60
 		return false;
61 61
 	}
62 62
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	 * @param string $mime_type
83 83
 	 * @return array|WP_Error {'path'=>string, 'file'=>string, 'width'=>int, 'height'=>int, 'mime-type'=>string}
84 84
 	 */
85
-	abstract public function save( $destfilename = null, $mime_type = null );
85
+	abstract public function save($destfilename = null, $mime_type = null);
86 86
 
87 87
 	/**
88 88
 	 * Resizes current image.
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 * @param  bool     $crop
101 101
 	 * @return bool|WP_Error
102 102
 	 */
103
-	abstract public function resize( $max_w, $max_h, $crop = false );
103
+	abstract public function resize($max_w, $max_h, $crop = false);
104 104
 
105 105
 	/**
106 106
 	 * Resize multiple images from a single source.
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	 * }
121 121
 	 * @return array An array of resized images metadata by size.
122 122
 	 */
123
-	abstract public function multi_resize( $sizes );
123
+	abstract public function multi_resize($sizes);
124 124
 
125 125
 	/**
126 126
 	 * Crops Image.
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 * @param bool $src_abs Optional. If the source crop points are absolute.
139 139
 	 * @return bool|WP_Error
140 140
 	 */
141
-	abstract public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false );
141
+	abstract public function crop($src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false);
142 142
 
143 143
 	/**
144 144
 	 * Rotates current image counter-clockwise by $angle.
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 * @param float $angle
151 151
 	 * @return bool|WP_Error
152 152
 	 */
153
-	abstract public function rotate( $angle );
153
+	abstract public function rotate($angle);
154 154
 
155 155
 	/**
156 156
 	 * Flips current image.
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 	 * @param bool $vert Flip along Vertical Axis
164 164
 	 * @return bool|WP_Error
165 165
 	 */
166
-	abstract public function flip( $horz, $vert );
166
+	abstract public function flip($horz, $vert);
167 167
 
168 168
 	/**
169 169
 	 * Streams current image to browser.
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	 * @param string $mime_type
176 176
 	 * @return bool|WP_Error
177 177
 	 */
178
-	abstract public function stream( $mime_type = null );
178
+	abstract public function stream($mime_type = null);
179 179
 
180 180
 	/**
181 181
 	 * Gets dimensions of image.
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 	 * @param int $height
200 200
 	 * @return true
201 201
 	 */
202
-	protected function update_size( $width = null, $height = null ) {
202
+	protected function update_size($width = null, $height = null) {
203 203
 		$this->size = array(
204 204
 			'width' => (int) $width,
205 205
 			'height' => (int) $height
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	 * @return int $quality Compression Quality. Range: [1,100]
217 217
 	 */
218 218
 	public function get_quality() {
219
-		if ( ! $this->quality ) {
219
+		if ( ! $this->quality) {
220 220
 			$this->set_quality();
221 221
 		}
222 222
 
@@ -232,8 +232,8 @@  discard block
 block discarded – undo
232 232
 	 * @param int $quality Compression Quality. Range: [1,100]
233 233
 	 * @return true|WP_Error True if set successfully; WP_Error on failure.
234 234
 	 */
235
-	public function set_quality( $quality = null ) {
236
-		if ( null === $quality ) {
235
+	public function set_quality($quality = null) {
236
+		if (null === $quality) {
237 237
 			/**
238 238
 			 * Filter the default image compression quality setting.
239 239
 			 *
@@ -247,9 +247,9 @@  discard block
 block discarded – undo
247 247
 			 * @param int    $quality   Quality level between 1 (low) and 100 (high).
248 248
 			 * @param string $mime_type Image mime type.
249 249
 			 */
250
-			$quality = apply_filters( 'wp_editor_set_quality', $this->default_quality, $this->mime_type );
250
+			$quality = apply_filters('wp_editor_set_quality', $this->default_quality, $this->mime_type);
251 251
 
252
-			if ( 'image/jpeg' == $this->mime_type ) {
252
+			if ('image/jpeg' == $this->mime_type) {
253 253
 				/**
254 254
 				 * Filter the JPEG compression quality for backward-compatibility.
255 255
 				 *
@@ -266,24 +266,24 @@  discard block
 block discarded – undo
266 266
 				 * @param int    $quality Quality level between 0 (low) and 100 (high) of the JPEG.
267 267
 				 * @param string $context Context of the filter.
268 268
 				 */
269
-				$quality = apply_filters( 'jpeg_quality', $quality, 'image_resize' );
269
+				$quality = apply_filters('jpeg_quality', $quality, 'image_resize');
270 270
 			}
271 271
 
272
-			if ( $quality < 0 || $quality > 100 ) {
272
+			if ($quality < 0 || $quality > 100) {
273 273
 				$quality = $this->default_quality;
274 274
 			}
275 275
 		}
276 276
 
277 277
 		// Allow 0, but squash to 1 due to identical images in GD, and for backwards compatibility.
278
-		if ( 0 === $quality ) {
278
+		if (0 === $quality) {
279 279
 			$quality = 1;
280 280
 		}
281 281
 
282
-		if ( ( $quality >= 1 ) && ( $quality <= 100 ) ) {
282
+		if (($quality >= 1) && ($quality <= 100)) {
283 283
 			$this->quality = $quality;
284 284
 			return true;
285 285
 		} else {
286
-			return new WP_Error( 'invalid_image_quality', __('Attempted to set image quality outside of the range [1,100].') );
286
+			return new WP_Error('invalid_image_quality', __('Attempted to set image quality outside of the range [1,100].'));
287 287
 		}
288 288
 	}
289 289
 
@@ -302,34 +302,34 @@  discard block
 block discarded – undo
302 302
 	 * @param string $mime_type
303 303
 	 * @return array { filename|null, extension, mime-type }
304 304
 	 */
305
-	protected function get_output_format( $filename = null, $mime_type = null ) {
305
+	protected function get_output_format($filename = null, $mime_type = null) {
306 306
 		$new_ext = null;
307 307
 
308 308
 		// By default, assume specified type takes priority
309
-		if ( $mime_type ) {
310
-			$new_ext = $this->get_extension( $mime_type );
309
+		if ($mime_type) {
310
+			$new_ext = $this->get_extension($mime_type);
311 311
 		}
312 312
 
313
-		if ( $filename ) {
314
-			$file_ext = strtolower( pathinfo( $filename, PATHINFO_EXTENSION ) );
315
-			$file_mime = $this->get_mime_type( $file_ext );
313
+		if ($filename) {
314
+			$file_ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
315
+			$file_mime = $this->get_mime_type($file_ext);
316 316
 		}
317 317
 		else {
318 318
 			// If no file specified, grab editor's current extension and mime-type.
319
-			$file_ext = strtolower( pathinfo( $this->file, PATHINFO_EXTENSION ) );
319
+			$file_ext = strtolower(pathinfo($this->file, PATHINFO_EXTENSION));
320 320
 			$file_mime = $this->mime_type;
321 321
 		}
322 322
 
323 323
 		// Check to see if specified mime-type is the same as type implied by
324 324
 		// file extension.  If so, prefer extension from file.
325
-		if ( ! $mime_type || ( $file_mime == $mime_type ) ) {
325
+		if ( ! $mime_type || ($file_mime == $mime_type)) {
326 326
 			$mime_type = $file_mime;
327 327
 			$new_ext = $file_ext;
328 328
 		}
329 329
 
330 330
 		// Double-check that the mime-type selected is supported by the editor.
331 331
 		// If not, choose a default instead.
332
-		if ( ! $this->supports_mime_type( $mime_type ) ) {
332
+		if ( ! $this->supports_mime_type($mime_type)) {
333 333
 			/**
334 334
 			 * Filter default mime type prior to getting the file extension.
335 335
 			 *
@@ -339,22 +339,22 @@  discard block
 block discarded – undo
339 339
 			 *
340 340
 			 * @param string $mime_type Mime type string.
341 341
 			 */
342
-			$mime_type = apply_filters( 'image_editor_default_mime_type', $this->default_mime_type );
343
-			$new_ext = $this->get_extension( $mime_type );
342
+			$mime_type = apply_filters('image_editor_default_mime_type', $this->default_mime_type);
343
+			$new_ext = $this->get_extension($mime_type);
344 344
 		}
345 345
 
346
-		if ( $filename ) {
346
+		if ($filename) {
347 347
 			$ext = '';
348
-			$info = pathinfo( $filename );
348
+			$info = pathinfo($filename);
349 349
 			$dir  = $info['dirname'];
350 350
 
351
-			if ( isset( $info['extension'] ) )
351
+			if (isset($info['extension']))
352 352
 				$ext = $info['extension'];
353 353
 
354
-			$filename = trailingslashit( $dir ) . wp_basename( $filename, ".$ext" ) . ".{$new_ext}";
354
+			$filename = trailingslashit($dir).wp_basename($filename, ".$ext").".{$new_ext}";
355 355
 		}
356 356
 
357
-		return array( $filename, $new_ext, $mime_type );
357
+		return array($filename, $new_ext, $mime_type);
358 358
 	}
359 359
 
360 360
 	/**
@@ -368,22 +368,22 @@  discard block
 block discarded – undo
368 368
 	 * @param string $extension
369 369
 	 * @return string filename
370 370
 	 */
371
-	public function generate_filename( $suffix = null, $dest_path = null, $extension = null ) {
371
+	public function generate_filename($suffix = null, $dest_path = null, $extension = null) {
372 372
 		// $suffix will be appended to the destination filename, just before the extension
373
-		if ( ! $suffix )
373
+		if ( ! $suffix)
374 374
 			$suffix = $this->get_suffix();
375 375
 
376
-		$info = pathinfo( $this->file );
376
+		$info = pathinfo($this->file);
377 377
 		$dir  = $info['dirname'];
378 378
 		$ext  = $info['extension'];
379 379
 
380
-		$name = wp_basename( $this->file, ".$ext" );
381
-		$new_ext = strtolower( $extension ? $extension : $ext );
380
+		$name = wp_basename($this->file, ".$ext");
381
+		$new_ext = strtolower($extension ? $extension : $ext);
382 382
 
383
-		if ( ! is_null( $dest_path ) && $_dest_path = realpath( $dest_path ) )
383
+		if ( ! is_null($dest_path) && $_dest_path = realpath($dest_path))
384 384
 			$dir = $_dest_path;
385 385
 
386
-		return trailingslashit( $dir ) . "{$name}-{$suffix}.{$new_ext}";
386
+		return trailingslashit($dir)."{$name}-{$suffix}.{$new_ext}";
387 387
 	}
388 388
 
389 389
 	/**
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 	 * @return false|string suffix
396 396
 	 */
397 397
 	public function get_suffix() {
398
-		if ( ! $this->get_size() )
398
+		if ( ! $this->get_size())
399 399
 			return false;
400 400
 
401 401
 		return "{$this->size['width']}x{$this->size['height']}";
@@ -412,29 +412,29 @@  discard block
 block discarded – undo
412 412
 	 * @param array $arguments
413 413
 	 * @return bool
414 414
 	 */
415
-	protected function make_image( $filename, $function, $arguments ) {
416
-		if ( $stream = wp_is_stream( $filename ) ) {
415
+	protected function make_image($filename, $function, $arguments) {
416
+		if ($stream = wp_is_stream($filename)) {
417 417
 			ob_start();
418 418
 		} else {
419 419
 			// The directory containing the original file may no longer exist when using a replication plugin.
420
-			wp_mkdir_p( dirname( $filename ) );
420
+			wp_mkdir_p(dirname($filename));
421 421
 		}
422 422
 
423
-		$result = call_user_func_array( $function, $arguments );
423
+		$result = call_user_func_array($function, $arguments);
424 424
 
425
-		if ( $result && $stream ) {
425
+		if ($result && $stream) {
426 426
 			$contents = ob_get_contents();
427 427
 
428
-			$fp = fopen( $filename, 'w' );
428
+			$fp = fopen($filename, 'w');
429 429
 
430
-			if ( ! $fp )
430
+			if ( ! $fp)
431 431
 				return false;
432 432
 
433
-			fwrite( $fp, $contents );
434
-			fclose( $fp );
433
+			fwrite($fp, $contents);
434
+			fclose($fp);
435 435
 		}
436 436
 
437
-		if ( $stream ) {
437
+		if ($stream) {
438 438
 			ob_end_clean();
439 439
 		}
440 440
 
@@ -453,15 +453,15 @@  discard block
 block discarded – undo
453 453
 	 * @param string $extension
454 454
 	 * @return string|false
455 455
 	 */
456
-	protected static function get_mime_type( $extension = null ) {
457
-		if ( ! $extension )
456
+	protected static function get_mime_type($extension = null) {
457
+		if ( ! $extension)
458 458
 			return false;
459 459
 
460 460
 		$mime_types = wp_get_mime_types();
461
-		$extensions = array_keys( $mime_types );
461
+		$extensions = array_keys($mime_types);
462 462
 
463
-		foreach( $extensions as $_extension ) {
464
-			if ( preg_match( "/{$extension}/i", $_extension ) ) {
463
+		foreach ($extensions as $_extension) {
464
+			if (preg_match("/{$extension}/i", $_extension)) {
465 465
 				return $mime_types[$_extension];
466 466
 			}
467 467
 		}
@@ -481,10 +481,10 @@  discard block
 block discarded – undo
481 481
 	 * @param string $mime_type
482 482
 	 * @return string|false
483 483
 	 */
484
-	protected static function get_extension( $mime_type = null ) {
485
-		$extensions = explode( '|', array_search( $mime_type, wp_get_mime_types() ) );
484
+	protected static function get_extension($mime_type = null) {
485
+		$extensions = explode('|', array_search($mime_type, wp_get_mime_types()));
486 486
 
487
-		if ( empty( $extensions[0] ) )
487
+		if (empty($extensions[0]))
488 488
 			return false;
489 489
 
490 490
 		return $extensions[0];
Please login to merge, or discard this patch.
Braces   +22 added lines, -16 removed lines patch added patch discarded remove patch
@@ -313,8 +313,7 @@  discard block
 block discarded – undo
313 313
 		if ( $filename ) {
314 314
 			$file_ext = strtolower( pathinfo( $filename, PATHINFO_EXTENSION ) );
315 315
 			$file_mime = $this->get_mime_type( $file_ext );
316
-		}
317
-		else {
316
+		} else {
318 317
 			// If no file specified, grab editor's current extension and mime-type.
319 318
 			$file_ext = strtolower( pathinfo( $this->file, PATHINFO_EXTENSION ) );
320 319
 			$file_mime = $this->mime_type;
@@ -348,8 +347,9 @@  discard block
 block discarded – undo
348 347
 			$info = pathinfo( $filename );
349 348
 			$dir  = $info['dirname'];
350 349
 
351
-			if ( isset( $info['extension'] ) )
352
-				$ext = $info['extension'];
350
+			if ( isset( $info['extension'] ) ) {
351
+							$ext = $info['extension'];
352
+			}
353 353
 
354 354
 			$filename = trailingslashit( $dir ) . wp_basename( $filename, ".$ext" ) . ".{$new_ext}";
355 355
 		}
@@ -370,8 +370,9 @@  discard block
 block discarded – undo
370 370
 	 */
371 371
 	public function generate_filename( $suffix = null, $dest_path = null, $extension = null ) {
372 372
 		// $suffix will be appended to the destination filename, just before the extension
373
-		if ( ! $suffix )
374
-			$suffix = $this->get_suffix();
373
+		if ( ! $suffix ) {
374
+					$suffix = $this->get_suffix();
375
+		}
375 376
 
376 377
 		$info = pathinfo( $this->file );
377 378
 		$dir  = $info['dirname'];
@@ -380,8 +381,9 @@  discard block
 block discarded – undo
380 381
 		$name = wp_basename( $this->file, ".$ext" );
381 382
 		$new_ext = strtolower( $extension ? $extension : $ext );
382 383
 
383
-		if ( ! is_null( $dest_path ) && $_dest_path = realpath( $dest_path ) )
384
-			$dir = $_dest_path;
384
+		if ( ! is_null( $dest_path ) && $_dest_path = realpath( $dest_path ) ) {
385
+					$dir = $_dest_path;
386
+		}
385 387
 
386 388
 		return trailingslashit( $dir ) . "{$name}-{$suffix}.{$new_ext}";
387 389
 	}
@@ -395,8 +397,9 @@  discard block
 block discarded – undo
395 397
 	 * @return false|string suffix
396 398
 	 */
397 399
 	public function get_suffix() {
398
-		if ( ! $this->get_size() )
399
-			return false;
400
+		if ( ! $this->get_size() ) {
401
+					return false;
402
+		}
400 403
 
401 404
 		return "{$this->size['width']}x{$this->size['height']}";
402 405
 	}
@@ -427,8 +430,9 @@  discard block
 block discarded – undo
427 430
 
428 431
 			$fp = fopen( $filename, 'w' );
429 432
 
430
-			if ( ! $fp )
431
-				return false;
433
+			if ( ! $fp ) {
434
+							return false;
435
+			}
432 436
 
433 437
 			fwrite( $fp, $contents );
434 438
 			fclose( $fp );
@@ -454,8 +458,9 @@  discard block
 block discarded – undo
454 458
 	 * @return string|false
455 459
 	 */
456 460
 	protected static function get_mime_type( $extension = null ) {
457
-		if ( ! $extension )
458
-			return false;
461
+		if ( ! $extension ) {
462
+					return false;
463
+		}
459 464
 
460 465
 		$mime_types = wp_get_mime_types();
461 466
 		$extensions = array_keys( $mime_types );
@@ -484,8 +489,9 @@  discard block
 block discarded – undo
484 489
 	protected static function get_extension( $mime_type = null ) {
485 490
 		$extensions = explode( '|', array_search( $mime_type, wp_get_mime_types() ) );
486 491
 
487
-		if ( empty( $extensions[0] ) )
488
-			return false;
492
+		if ( empty( $extensions[0] ) ) {
493
+					return false;
494
+		}
489 495
 
490 496
 		return $extensions[0];
491 497
 	}
Please login to merge, or discard this patch.
src/wp-includes/class-wp-theme.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -953,7 +953,7 @@
 block discarded – undo
953 953
 	 * @since 3.4.0
954 954
 	 * @access public
955 955
 	 *
956
-	 * @param mixed $type Optional. Array of extensions to return. Defaults to all files (null).
956
+	 * @param string $type Optional. Array of extensions to return. Defaults to all files (null).
957 957
 	 * @param int $depth Optional. How deep to search for files. Defaults to a flat scan (0 depth). -1 depth is infinite.
958 958
 	 * @param bool $search_parent Optional. Whether to return parent files. Defaults to false.
959 959
 	 * @return array Array of files, keyed by the path to the file relative to the theme's directory, with the values
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * WP_Theme Class
4
- *
5
- * @package WordPress
6
- * @subpackage Theme
7
- */
3
+	 * WP_Theme Class
4
+	 *
5
+	 * @package WordPress
6
+	 * @subpackage Theme
7
+	 */
8 8
 
9 9
 final class WP_Theme implements ArrayAccess {
10 10
 
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
 	/**
685 685
 	 * Mark up a theme header.
686 686
 	 *
687
-     * @since 3.4.0
687
+	 * @since 3.4.0
688 688
 	 * @access private
689 689
 	 *
690 690
 	 * @staticvar string $comma
Please login to merge, or discard this patch.
Spacing   +257 added lines, -257 removed lines patch added patch discarded remove patch
@@ -186,19 +186,19 @@  discard block
 block discarded – undo
186 186
 	 * @param string $theme_root Theme root.
187 187
 	 * @param WP_Error|void $_child If this theme is a parent theme, the child may be passed for validation purposes.
188 188
 	 */
189
-	public function __construct( $theme_dir, $theme_root, $_child = null ) {
189
+	public function __construct($theme_dir, $theme_root, $_child = null) {
190 190
 		global $wp_theme_directories;
191 191
 
192 192
 		// Initialize caching on first run.
193
-		if ( ! isset( self::$persistently_cache ) ) {
193
+		if ( ! isset(self::$persistently_cache)) {
194 194
 			/** This action is documented in wp-includes/theme.php */
195
-			self::$persistently_cache = apply_filters( 'wp_cache_themes_persistently', false, 'WP_Theme' );
196
-			if ( self::$persistently_cache ) {
197
-				wp_cache_add_global_groups( 'themes' );
198
-				if ( is_int( self::$persistently_cache ) )
195
+			self::$persistently_cache = apply_filters('wp_cache_themes_persistently', false, 'WP_Theme');
196
+			if (self::$persistently_cache) {
197
+				wp_cache_add_global_groups('themes');
198
+				if (is_int(self::$persistently_cache))
199 199
 					self::$cache_expiration = self::$persistently_cache;
200 200
 			} else {
201
-				wp_cache_add_non_persistent_groups( 'themes' );
201
+				wp_cache_add_non_persistent_groups('themes');
202 202
 			}
203 203
 		}
204 204
 
@@ -206,107 +206,107 @@  discard block
 block discarded – undo
206 206
 		$this->stylesheet = $theme_dir;
207 207
 
208 208
 		// Correct a situation where the theme is 'some-directory/some-theme' but 'some-directory' was passed in as part of the theme root instead.
209
-		if ( ! in_array( $theme_root, (array) $wp_theme_directories ) && in_array( dirname( $theme_root ), (array) $wp_theme_directories ) ) {
210
-			$this->stylesheet = basename( $this->theme_root ) . '/' . $this->stylesheet;
211
-			$this->theme_root = dirname( $theme_root );
209
+		if ( ! in_array($theme_root, (array) $wp_theme_directories) && in_array(dirname($theme_root), (array) $wp_theme_directories)) {
210
+			$this->stylesheet = basename($this->theme_root).'/'.$this->stylesheet;
211
+			$this->theme_root = dirname($theme_root);
212 212
 		}
213 213
 
214
-		$this->cache_hash = md5( $this->theme_root . '/' . $this->stylesheet );
215
-		$theme_file = $this->stylesheet . '/style.css';
214
+		$this->cache_hash = md5($this->theme_root.'/'.$this->stylesheet);
215
+		$theme_file = $this->stylesheet.'/style.css';
216 216
 
217
-		$cache = $this->cache_get( 'theme' );
217
+		$cache = $this->cache_get('theme');
218 218
 
219
-		if ( is_array( $cache ) ) {
220
-			foreach ( array( 'errors', 'headers', 'template' ) as $key ) {
221
-				if ( isset( $cache[ $key ] ) )
222
-					$this->$key = $cache[ $key ];
219
+		if (is_array($cache)) {
220
+			foreach (array('errors', 'headers', 'template') as $key) {
221
+				if (isset($cache[$key]))
222
+					$this->$key = $cache[$key];
223 223
 			}
224
-			if ( $this->errors )
224
+			if ($this->errors)
225 225
 				return;
226
-			if ( isset( $cache['theme_root_template'] ) )
226
+			if (isset($cache['theme_root_template']))
227 227
 				$theme_root_template = $cache['theme_root_template'];
228
-		} elseif ( ! file_exists( $this->theme_root . '/' . $theme_file ) ) {
228
+		} elseif ( ! file_exists($this->theme_root.'/'.$theme_file)) {
229 229
 			$this->headers['Name'] = $this->stylesheet;
230
-			if ( ! file_exists( $this->theme_root . '/' . $this->stylesheet ) )
231
-				$this->errors = new WP_Error( 'theme_not_found', sprintf( __( 'The theme directory "%s" does not exist.' ), $this->stylesheet ) );
230
+			if ( ! file_exists($this->theme_root.'/'.$this->stylesheet))
231
+				$this->errors = new WP_Error('theme_not_found', sprintf(__('The theme directory "%s" does not exist.'), $this->stylesheet));
232 232
 			else
233
-				$this->errors = new WP_Error( 'theme_no_stylesheet', __( 'Stylesheet is missing.' ) );
233
+				$this->errors = new WP_Error('theme_no_stylesheet', __('Stylesheet is missing.'));
234 234
 			$this->template = $this->stylesheet;
235
-			$this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) );
236
-			if ( ! file_exists( $this->theme_root ) ) // Don't cache this one.
237
-				$this->errors->add( 'theme_root_missing', __( 'ERROR: The themes directory is either empty or doesn&#8217;t exist. Please check your installation.' ) );
235
+			$this->cache_add('theme', array('headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template));
236
+			if ( ! file_exists($this->theme_root)) // Don't cache this one.
237
+				$this->errors->add('theme_root_missing', __('ERROR: The themes directory is either empty or doesn&#8217;t exist. Please check your installation.'));
238 238
 			return;
239
-		} elseif ( ! is_readable( $this->theme_root . '/' . $theme_file ) ) {
239
+		} elseif ( ! is_readable($this->theme_root.'/'.$theme_file)) {
240 240
 			$this->headers['Name'] = $this->stylesheet;
241
-			$this->errors = new WP_Error( 'theme_stylesheet_not_readable', __( 'Stylesheet is not readable.' ) );
241
+			$this->errors = new WP_Error('theme_stylesheet_not_readable', __('Stylesheet is not readable.'));
242 242
 			$this->template = $this->stylesheet;
243
-			$this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) );
243
+			$this->cache_add('theme', array('headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template));
244 244
 			return;
245 245
 		} else {
246
-			$this->headers = get_file_data( $this->theme_root . '/' . $theme_file, self::$file_headers, 'theme' );
246
+			$this->headers = get_file_data($this->theme_root.'/'.$theme_file, self::$file_headers, 'theme');
247 247
 			// Default themes always trump their pretenders.
248 248
 			// Properly identify default themes that are inside a directory within wp-content/themes.
249
-			if ( $default_theme_slug = array_search( $this->headers['Name'], self::$default_themes ) ) {
250
-				if ( basename( $this->stylesheet ) != $default_theme_slug )
251
-					$this->headers['Name'] .= '/' . $this->stylesheet;
249
+			if ($default_theme_slug = array_search($this->headers['Name'], self::$default_themes)) {
250
+				if (basename($this->stylesheet) != $default_theme_slug)
251
+					$this->headers['Name'] .= '/'.$this->stylesheet;
252 252
 			}
253 253
 		}
254 254
 
255 255
 		// (If template is set from cache [and there are no errors], we know it's good.)
256
-		if ( ! $this->template && ! ( $this->template = $this->headers['Template'] ) ) {
256
+		if ( ! $this->template && ! ($this->template = $this->headers['Template'])) {
257 257
 			$this->template = $this->stylesheet;
258
-			if ( ! file_exists( $this->theme_root . '/' . $this->stylesheet . '/index.php' ) ) {
259
-				$this->errors = new WP_Error( 'theme_no_index', __( 'Template is missing.' ) );
260
-				$this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) );
258
+			if ( ! file_exists($this->theme_root.'/'.$this->stylesheet.'/index.php')) {
259
+				$this->errors = new WP_Error('theme_no_index', __('Template is missing.'));
260
+				$this->cache_add('theme', array('headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template));
261 261
 				return;
262 262
 			}
263 263
 		}
264 264
 
265 265
 		// If we got our data from cache, we can assume that 'template' is pointing to the right place.
266
-		if ( ! is_array( $cache ) && $this->template != $this->stylesheet && ! file_exists( $this->theme_root . '/' . $this->template . '/index.php' ) ) {
266
+		if ( ! is_array($cache) && $this->template != $this->stylesheet && ! file_exists($this->theme_root.'/'.$this->template.'/index.php')) {
267 267
 			// If we're in a directory of themes inside /themes, look for the parent nearby.
268 268
 			// wp-content/themes/directory-of-themes/*
269
-			$parent_dir = dirname( $this->stylesheet );
270
-			if ( '.' != $parent_dir && file_exists( $this->theme_root . '/' . $parent_dir . '/' . $this->template . '/index.php' ) ) {
271
-				$this->template = $parent_dir . '/' . $this->template;
272
-			} elseif ( ( $directories = search_theme_directories() ) && isset( $directories[ $this->template ] ) ) {
269
+			$parent_dir = dirname($this->stylesheet);
270
+			if ('.' != $parent_dir && file_exists($this->theme_root.'/'.$parent_dir.'/'.$this->template.'/index.php')) {
271
+				$this->template = $parent_dir.'/'.$this->template;
272
+			} elseif (($directories = search_theme_directories()) && isset($directories[$this->template])) {
273 273
 				// Look for the template in the search_theme_directories() results, in case it is in another theme root.
274 274
 				// We don't look into directories of themes, just the theme root.
275
-				$theme_root_template = $directories[ $this->template ]['theme_root'];
275
+				$theme_root_template = $directories[$this->template]['theme_root'];
276 276
 			} else {
277 277
 				// Parent theme is missing.
278
-				$this->errors = new WP_Error( 'theme_no_parent', sprintf( __( 'The parent theme is missing. Please install the "%s" parent theme.' ), $this->template ) );
279
-				$this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) );
280
-				$this->parent = new WP_Theme( $this->template, $this->theme_root, $this );
278
+				$this->errors = new WP_Error('theme_no_parent', sprintf(__('The parent theme is missing. Please install the "%s" parent theme.'), $this->template));
279
+				$this->cache_add('theme', array('headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template));
280
+				$this->parent = new WP_Theme($this->template, $this->theme_root, $this);
281 281
 				return;
282 282
 			}
283 283
 		}
284 284
 
285 285
 		// Set the parent, if we're a child theme.
286
-		if ( $this->template != $this->stylesheet ) {
286
+		if ($this->template != $this->stylesheet) {
287 287
 			// If we are a parent, then there is a problem. Only two generations allowed! Cancel things out.
288
-			if ( $_child instanceof WP_Theme && $_child->template == $this->stylesheet ) {
288
+			if ($_child instanceof WP_Theme && $_child->template == $this->stylesheet) {
289 289
 				$_child->parent = null;
290
-				$_child->errors = new WP_Error( 'theme_parent_invalid', sprintf( __( 'The "%s" theme is not a valid parent theme.' ), $_child->template ) );
291
-				$_child->cache_add( 'theme', array( 'headers' => $_child->headers, 'errors' => $_child->errors, 'stylesheet' => $_child->stylesheet, 'template' => $_child->template ) );
290
+				$_child->errors = new WP_Error('theme_parent_invalid', sprintf(__('The "%s" theme is not a valid parent theme.'), $_child->template));
291
+				$_child->cache_add('theme', array('headers' => $_child->headers, 'errors' => $_child->errors, 'stylesheet' => $_child->stylesheet, 'template' => $_child->template));
292 292
 				// The two themes actually reference each other with the Template header.
293
-				if ( $_child->stylesheet == $this->template ) {
294
-					$this->errors = new WP_Error( 'theme_parent_invalid', sprintf( __( 'The "%s" theme is not a valid parent theme.' ), $this->template ) );
295
-					$this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) );
293
+				if ($_child->stylesheet == $this->template) {
294
+					$this->errors = new WP_Error('theme_parent_invalid', sprintf(__('The "%s" theme is not a valid parent theme.'), $this->template));
295
+					$this->cache_add('theme', array('headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template));
296 296
 				}
297 297
 				return;
298 298
 			}
299 299
 			// Set the parent. Pass the current instance so we can do the crazy checks above and assess errors.
300
-			$this->parent = new WP_Theme( $this->template, isset( $theme_root_template ) ? $theme_root_template : $this->theme_root, $this );
300
+			$this->parent = new WP_Theme($this->template, isset($theme_root_template) ? $theme_root_template : $this->theme_root, $this);
301 301
 		}
302 302
 
303 303
 		// We're good. If we didn't retrieve from cache, set it.
304
-		if ( ! is_array( $cache ) ) {
305
-			$cache = array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template );
304
+		if ( ! is_array($cache)) {
305
+			$cache = array('headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template);
306 306
 			// If the parent theme is in another root, we'll want to cache this. Avoids an entire branch of filesystem calls above.
307
-			if ( isset( $theme_root_template ) )
307
+			if (isset($theme_root_template))
308 308
 				$cache['theme_root_template'] = $theme_root_template;
309
-			$this->cache_add( 'theme', $cache );
309
+			$this->cache_add('theme', $cache);
310 310
 		}
311 311
 	}
312 312
 
@@ -326,13 +326,13 @@  discard block
 block discarded – undo
326 326
 	 *
327 327
 	 * @return bool
328 328
 	 */
329
-	public function __isset( $offset ) {
329
+	public function __isset($offset) {
330 330
 		static $properties = array(
331 331
 			'name', 'title', 'version', 'parent_theme', 'template_dir', 'stylesheet_dir', 'template', 'stylesheet',
332 332
 			'screenshot', 'description', 'author', 'tags', 'theme_root', 'theme_root_uri',
333 333
 		);
334 334
 
335
-		return in_array( $offset, $properties );
335
+		return in_array($offset, $properties);
336 336
 	}
337 337
 
338 338
 	/**
@@ -340,8 +340,8 @@  discard block
 block discarded – undo
340 340
 	 *
341 341
 	 * @return mixed
342 342
 	 */
343
-	public function __get( $offset ) {
344
-		switch ( $offset ) {
343
+	public function __get($offset) {
344
+		switch ($offset) {
345 345
 			case 'name' :
346 346
 			case 'title' :
347 347
 				return $this->get('Name');
@@ -358,21 +358,21 @@  discard block
 block discarded – undo
358 358
 			case 'stylesheet' :
359 359
 				return $this->get_stylesheet();
360 360
 			case 'screenshot' :
361
-				return $this->get_screenshot( 'relative' );
361
+				return $this->get_screenshot('relative');
362 362
 			// 'author' and 'description' did not previously return translated data.
363 363
 			case 'description' :
364 364
 				return $this->display('Description');
365 365
 			case 'author' :
366 366
 				return $this->display('Author');
367 367
 			case 'tags' :
368
-				return $this->get( 'Tags' );
368
+				return $this->get('Tags');
369 369
 			case 'theme_root' :
370 370
 				return $this->get_theme_root();
371 371
 			case 'theme_root_uri' :
372 372
 				return $this->get_theme_root_uri();
373 373
 			// For cases where the array was converted to an object.
374 374
 			default :
375
-				return $this->offsetGet( $offset );
375
+				return $this->offsetGet($offset);
376 376
 		}
377 377
 	}
378 378
 
@@ -382,14 +382,14 @@  discard block
 block discarded – undo
382 382
 	 * @param mixed $offset
383 383
 	 * @param mixed $value
384 384
 	 */
385
-	public function offsetSet( $offset, $value ) {}
385
+	public function offsetSet($offset, $value) {}
386 386
 
387 387
 	/**
388 388
 	 * Method to implement ArrayAccess for keys formerly returned by get_themes()
389 389
 	 *
390 390
 	 * @param mixed $offset
391 391
 	 */
392
-	public function offsetUnset( $offset ) {}
392
+	public function offsetUnset($offset) {}
393 393
 
394 394
 	/**
395 395
 	 * Method to implement ArrayAccess for keys formerly returned by get_themes()
@@ -399,14 +399,14 @@  discard block
 block discarded – undo
399 399
 	 * @param mixed $offset
400 400
 	 * @return bool
401 401
 	 */
402
-	public function offsetExists( $offset ) {
402
+	public function offsetExists($offset) {
403 403
 		static $keys = array(
404 404
 			'Name', 'Version', 'Status', 'Title', 'Author', 'Author Name', 'Author URI', 'Description',
405 405
 			'Template', 'Stylesheet', 'Template Files', 'Stylesheet Files', 'Template Dir', 'Stylesheet Dir',
406 406
 			'Screenshot', 'Tags', 'Theme Root', 'Theme Root URI', 'Parent Theme',
407 407
 		);
408 408
 
409
-		return in_array( $offset, $keys );
409
+		return in_array($offset, $keys);
410 410
 	}
411 411
 
412 412
 	/**
@@ -422,38 +422,38 @@  discard block
 block discarded – undo
422 422
 	 * @param mixed $offset
423 423
 	 * @return mixed
424 424
 	 */
425
-	public function offsetGet( $offset ) {
426
-		switch ( $offset ) {
425
+	public function offsetGet($offset) {
426
+		switch ($offset) {
427 427
 			case 'Name' :
428 428
 			case 'Title' :
429 429
 				// See note above about using translated data. get() is not ideal.
430 430
 				// It is only for backwards compatibility. Use display().
431 431
 				return $this->get('Name');
432 432
 			case 'Author' :
433
-				return $this->display( 'Author');
433
+				return $this->display('Author');
434 434
 			case 'Author Name' :
435
-				return $this->display( 'Author', false);
435
+				return $this->display('Author', false);
436 436
 			case 'Author URI' :
437 437
 				return $this->display('AuthorURI');
438 438
 			case 'Description' :
439
-				return $this->display( 'Description');
439
+				return $this->display('Description');
440 440
 			case 'Version' :
441 441
 			case 'Status' :
442
-				return $this->get( $offset );
442
+				return $this->get($offset);
443 443
 			case 'Template' :
444 444
 				return $this->get_template();
445 445
 			case 'Stylesheet' :
446 446
 				return $this->get_stylesheet();
447 447
 			case 'Template Files' :
448
-				return $this->get_files( 'php', 1, true );
448
+				return $this->get_files('php', 1, true);
449 449
 			case 'Stylesheet Files' :
450
-				return $this->get_files( 'css', 0, false );
450
+				return $this->get_files('css', 0, false);
451 451
 			case 'Template Dir' :
452 452
 				return $this->get_template_directory();
453 453
 			case 'Stylesheet Dir' :
454 454
 				return $this->get_stylesheet_directory();
455 455
 			case 'Screenshot' :
456
-				return $this->get_screenshot( 'relative' );
456
+				return $this->get_screenshot('relative');
457 457
 			case 'Tags' :
458 458
 				return $this->get('Tags');
459 459
 			case 'Theme Root' :
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 	 * @return WP_Error|false WP_Error if there are errors, or false.
477 477
 	 */
478 478
 	public function errors() {
479
-		return is_wp_error( $this->errors ) ? $this->errors : false;
479
+		return is_wp_error($this->errors) ? $this->errors : false;
480 480
 	}
481 481
 
482 482
 	/**
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 	 * @return bool Whether the theme exists.
492 492
 	 */
493 493
 	public function exists() {
494
-		return ! ( $this->errors() && in_array( 'theme_not_found', $this->errors()->get_error_codes() ) );
494
+		return ! ($this->errors() && in_array('theme_not_found', $this->errors()->get_error_codes()));
495 495
 	}
496 496
 
497 497
 	/**
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
 	 * @return WP_Theme|false Parent theme, or false if the current theme is not a child theme.
504 504
 	 */
505 505
 	public function parent() {
506
-		return isset( $this->parent ) ? $this->parent : false;
506
+		return isset($this->parent) ? $this->parent : false;
507 507
 	}
508 508
 
509 509
 	/**
@@ -518,8 +518,8 @@  discard block
 block discarded – undo
518 518
 	 * @param string $data Data to store
519 519
 	 * @return bool Return value from wp_cache_add()
520 520
 	 */
521
-	private function cache_add( $key, $data ) {
522
-		return wp_cache_add( $key . '-' . $this->cache_hash, $data, 'themes', self::$cache_expiration );
521
+	private function cache_add($key, $data) {
522
+		return wp_cache_add($key.'-'.$this->cache_hash, $data, 'themes', self::$cache_expiration);
523 523
 	}
524 524
 
525 525
 	/**
@@ -533,8 +533,8 @@  discard block
 block discarded – undo
533 533
 	 * @param string $key Type of data to retrieve (theme, screenshot, headers, page_templates)
534 534
 	 * @return mixed Retrieved data
535 535
 	 */
536
-	private function cache_get( $key ) {
537
-		return wp_cache_get( $key . '-' . $this->cache_hash, 'themes' );
536
+	private function cache_get($key) {
537
+		return wp_cache_get($key.'-'.$this->cache_hash, 'themes');
538 538
 	}
539 539
 
540 540
 	/**
@@ -544,11 +544,11 @@  discard block
 block discarded – undo
544 544
 	 * @access public
545 545
 	 */
546 546
 	public function cache_delete() {
547
-		foreach ( array( 'theme', 'screenshot', 'headers', 'page_templates' ) as $key )
548
-			wp_cache_delete( $key . '-' . $this->cache_hash, 'themes' );
547
+		foreach (array('theme', 'screenshot', 'headers', 'page_templates') as $key)
548
+			wp_cache_delete($key.'-'.$this->cache_hash, 'themes');
549 549
 		$this->template = $this->textdomain_loaded = $this->theme_root_uri = $this->parent = $this->errors = $this->headers_sanitized = $this->name_translated = null;
550 550
 		$this->headers = array();
551
-		$this->__construct( $this->stylesheet, $this->theme_root );
551
+		$this->__construct($this->stylesheet, $this->theme_root);
552 552
 	}
553 553
 
554 554
 	/**
@@ -568,29 +568,29 @@  discard block
 block discarded – undo
568 568
 	 * @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags.
569 569
 	 * @return string|false String on success, false on failure.
570 570
 	 */
571
-	public function get( $header ) {
572
-		if ( ! isset( $this->headers[ $header ] ) )
571
+	public function get($header) {
572
+		if ( ! isset($this->headers[$header]))
573 573
 			return false;
574 574
 
575
-		if ( ! isset( $this->headers_sanitized ) ) {
576
-			$this->headers_sanitized = $this->cache_get( 'headers' );
577
-			if ( ! is_array( $this->headers_sanitized ) )
575
+		if ( ! isset($this->headers_sanitized)) {
576
+			$this->headers_sanitized = $this->cache_get('headers');
577
+			if ( ! is_array($this->headers_sanitized))
578 578
 				$this->headers_sanitized = array();
579 579
 		}
580 580
 
581
-		if ( isset( $this->headers_sanitized[ $header ] ) )
582
-			return $this->headers_sanitized[ $header ];
581
+		if (isset($this->headers_sanitized[$header]))
582
+			return $this->headers_sanitized[$header];
583 583
 
584 584
 		// If themes are a persistent group, sanitize everything and cache it. One cache add is better than many cache sets.
585
-		if ( self::$persistently_cache ) {
586
-			foreach ( array_keys( $this->headers ) as $_header )
587
-				$this->headers_sanitized[ $_header ] = $this->sanitize_header( $_header, $this->headers[ $_header ] );
588
-			$this->cache_add( 'headers', $this->headers_sanitized );
585
+		if (self::$persistently_cache) {
586
+			foreach (array_keys($this->headers) as $_header)
587
+				$this->headers_sanitized[$_header] = $this->sanitize_header($_header, $this->headers[$_header]);
588
+			$this->cache_add('headers', $this->headers_sanitized);
589 589
 		} else {
590
-			$this->headers_sanitized[ $header ] = $this->sanitize_header( $header, $this->headers[ $header ] );
590
+			$this->headers_sanitized[$header] = $this->sanitize_header($header, $this->headers[$header]);
591 591
 		}
592 592
 
593
-		return $this->headers_sanitized[ $header ];
593
+		return $this->headers_sanitized[$header];
594 594
 	}
595 595
 
596 596
 	/**
@@ -604,20 +604,20 @@  discard block
 block discarded – undo
604 604
 	 * @param bool $translate Optional. Whether to translate the header. Defaults to true.
605 605
 	 * @return string|false Processed header, false on failure.
606 606
 	 */
607
-	public function display( $header, $markup = true, $translate = true ) {
608
-		$value = $this->get( $header );
609
-		if ( false === $value ) {
607
+	public function display($header, $markup = true, $translate = true) {
608
+		$value = $this->get($header);
609
+		if (false === $value) {
610 610
 			return false;
611 611
 		}
612 612
 
613
-		if ( $translate && ( empty( $value ) || ! $this->load_textdomain() ) )
613
+		if ($translate && (empty($value) || ! $this->load_textdomain()))
614 614
 			$translate = false;
615 615
 
616
-		if ( $translate )
617
-			$value = $this->translate_header( $header, $value );
616
+		if ($translate)
617
+			$value = $this->translate_header($header, $value);
618 618
 
619
-		if ( $markup )
620
-			$value = $this->markup_header( $header, $value, $translate );
619
+		if ($markup)
620
+			$value = $this->markup_header($header, $value, $translate);
621 621
 
622 622
 		return $value;
623 623
 	}
@@ -635,46 +635,46 @@  discard block
 block discarded – undo
635 635
 	 * @param string $value Value to sanitize.
636 636
 	 * @return mixed
637 637
 	 */
638
-	private function sanitize_header( $header, $value ) {
639
-		switch ( $header ) {
638
+	private function sanitize_header($header, $value) {
639
+		switch ($header) {
640 640
 			case 'Status' :
641
-				if ( ! $value ) {
641
+				if ( ! $value) {
642 642
 					$value = 'publish';
643 643
 					break;
644 644
 				}
645 645
 				// Fall through otherwise.
646 646
 			case 'Name' :
647 647
 				static $header_tags = array(
648
-					'abbr'    => array( 'title' => true ),
649
-					'acronym' => array( 'title' => true ),
648
+					'abbr'    => array('title' => true),
649
+					'acronym' => array('title' => true),
650 650
 					'code'    => true,
651 651
 					'em'      => true,
652 652
 					'strong'  => true,
653 653
 				);
654
-				$value = wp_kses( $value, $header_tags );
654
+				$value = wp_kses($value, $header_tags);
655 655
 				break;
656 656
 			case 'Author' :
657 657
 				// There shouldn't be anchor tags in Author, but some themes like to be challenging.
658 658
 			case 'Description' :
659 659
 				static $header_tags_with_a = array(
660
-					'a'       => array( 'href' => true, 'title' => true ),
661
-					'abbr'    => array( 'title' => true ),
662
-					'acronym' => array( 'title' => true ),
660
+					'a'       => array('href' => true, 'title' => true),
661
+					'abbr'    => array('title' => true),
662
+					'acronym' => array('title' => true),
663 663
 					'code'    => true,
664 664
 					'em'      => true,
665 665
 					'strong'  => true,
666 666
 				);
667
-				$value = wp_kses( $value, $header_tags_with_a );
667
+				$value = wp_kses($value, $header_tags_with_a);
668 668
 				break;
669 669
 			case 'ThemeURI' :
670 670
 			case 'AuthorURI' :
671
-				$value = esc_url_raw( $value );
671
+				$value = esc_url_raw($value);
672 672
 				break;
673 673
 			case 'Tags' :
674
-				$value = array_filter( array_map( 'trim', explode( ',', strip_tags( $value ) ) ) );
674
+				$value = array_filter(array_map('trim', explode(',', strip_tags($value))));
675 675
 				break;
676 676
 			case 'Version' :
677
-				$value = strip_tags( $value );
677
+				$value = strip_tags($value);
678 678
 				break;
679 679
 		}
680 680
 
@@ -694,33 +694,33 @@  discard block
 block discarded – undo
694 694
 	 * @param string $translate Whether the header has been translated.
695 695
 	 * @return string Value, marked up.
696 696
 	 */
697
-	private function markup_header( $header, $value, $translate ) {
698
-		switch ( $header ) {
697
+	private function markup_header($header, $value, $translate) {
698
+		switch ($header) {
699 699
 			case 'Name' :
700
-				if ( empty( $value ) )
700
+				if (empty($value))
701 701
 					$value = $this->get_stylesheet();
702 702
 				break;
703 703
 			case 'Description' :
704
-				$value = wptexturize( $value );
704
+				$value = wptexturize($value);
705 705
 				break;
706 706
 			case 'Author' :
707
-				if ( $this->get('AuthorURI') ) {
708
-					$value = sprintf( '<a href="%1$s">%2$s</a>', $this->display( 'AuthorURI', true, $translate ), $value );
709
-				} elseif ( ! $value ) {
710
-					$value = __( 'Anonymous' );
707
+				if ($this->get('AuthorURI')) {
708
+					$value = sprintf('<a href="%1$s">%2$s</a>', $this->display('AuthorURI', true, $translate), $value);
709
+				} elseif ( ! $value) {
710
+					$value = __('Anonymous');
711 711
 				}
712 712
 				break;
713 713
 			case 'Tags' :
714 714
 				static $comma = null;
715
-				if ( ! isset( $comma ) ) {
715
+				if ( ! isset($comma)) {
716 716
 					/* translators: used between list items, there is a space after the comma */
717
-					$comma = __( ', ' );
717
+					$comma = __(', ');
718 718
 				}
719
-				$value = implode( $comma, $value );
719
+				$value = implode($comma, $value);
720 720
 				break;
721 721
 			case 'ThemeURI' :
722 722
 			case 'AuthorURI' :
723
-				$value = esc_url( $value );
723
+				$value = esc_url($value);
724 724
 				break;
725 725
 		}
726 726
 
@@ -739,38 +739,38 @@  discard block
 block discarded – undo
739 739
 	 * @param string $value Value to translate.
740 740
 	 * @return string Translated value.
741 741
 	 */
742
-	private function translate_header( $header, $value ) {
743
-		switch ( $header ) {
742
+	private function translate_header($header, $value) {
743
+		switch ($header) {
744 744
 			case 'Name' :
745 745
 				// Cached for sorting reasons.
746
-				if ( isset( $this->name_translated ) )
746
+				if (isset($this->name_translated))
747 747
 					return $this->name_translated;
748
-				$this->name_translated = translate( $value, $this->get('TextDomain' ) );
748
+				$this->name_translated = translate($value, $this->get('TextDomain'));
749 749
 				return $this->name_translated;
750 750
 			case 'Tags' :
751
-				if ( empty( $value ) || ! function_exists( 'get_theme_feature_list' ) )
751
+				if (empty($value) || ! function_exists('get_theme_feature_list'))
752 752
 					return $value;
753 753
 
754 754
 				static $tags_list;
755
-				if ( ! isset( $tags_list ) ) {
755
+				if ( ! isset($tags_list)) {
756 756
 					$tags_list = array();
757
-					$feature_list = get_theme_feature_list( false ); // No API
758
-					foreach ( $feature_list as $tags )
757
+					$feature_list = get_theme_feature_list(false); // No API
758
+					foreach ($feature_list as $tags)
759 759
 						$tags_list += $tags;
760 760
 				}
761 761
 
762
-				foreach ( $value as &$tag ) {
763
-					if ( isset( $tags_list[ $tag ] ) ) {
764
-						$tag = $tags_list[ $tag ];
765
-					} elseif ( isset( self::$tag_map[ $tag ] ) ) {
766
-						$tag = $tags_list[ self::$tag_map[ $tag ] ];
762
+				foreach ($value as &$tag) {
763
+					if (isset($tags_list[$tag])) {
764
+						$tag = $tags_list[$tag];
765
+					} elseif (isset(self::$tag_map[$tag])) {
766
+						$tag = $tags_list[self::$tag_map[$tag]];
767 767
 					}
768 768
 				}
769 769
 
770 770
 				return $value;
771 771
 
772 772
 			default :
773
-				$value = translate( $value, $this->get('TextDomain') );
773
+				$value = translate($value, $this->get('TextDomain'));
774 774
 		}
775 775
 		return $value;
776 776
 	}
@@ -817,10 +817,10 @@  discard block
 block discarded – undo
817 817
 	 * @return string Absolute path of the stylesheet directory.
818 818
 	 */
819 819
 	public function get_stylesheet_directory() {
820
-		if ( $this->errors() && in_array( 'theme_root_missing', $this->errors()->get_error_codes() ) )
820
+		if ($this->errors() && in_array('theme_root_missing', $this->errors()->get_error_codes()))
821 821
 			return '';
822 822
 
823
-		return $this->theme_root . '/' . $this->stylesheet;
823
+		return $this->theme_root.'/'.$this->stylesheet;
824 824
 	}
825 825
 
826 826
 	/**
@@ -835,12 +835,12 @@  discard block
 block discarded – undo
835 835
 	 * @return string Absolute path of the template directory.
836 836
 	 */
837 837
 	public function get_template_directory() {
838
-		if ( $this->parent() )
838
+		if ($this->parent())
839 839
 			$theme_root = $this->parent()->theme_root;
840 840
 		else
841 841
 			$theme_root = $this->theme_root;
842 842
 
843
-		return $theme_root . '/' . $this->template;
843
+		return $theme_root.'/'.$this->template;
844 844
 	}
845 845
 
846 846
 	/**
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
 	 * @return string URL to the stylesheet directory.
856 856
 	 */
857 857
 	public function get_stylesheet_directory_uri() {
858
-		return $this->get_theme_root_uri() . '/' . str_replace( '%2F', '/', rawurlencode( $this->stylesheet ) );
858
+		return $this->get_theme_root_uri().'/'.str_replace('%2F', '/', rawurlencode($this->stylesheet));
859 859
 	}
860 860
 
861 861
 	/**
@@ -870,12 +870,12 @@  discard block
 block discarded – undo
870 870
 	 * @return string URL to the template directory.
871 871
 	 */
872 872
 	public function get_template_directory_uri() {
873
-		if ( $this->parent() )
873
+		if ($this->parent())
874 874
 			$theme_root_uri = $this->parent()->get_theme_root_uri();
875 875
 		else
876 876
 			$theme_root_uri = $this->get_theme_root_uri();
877 877
 
878
-		return $theme_root_uri . '/' . str_replace( '%2F', '/', rawurlencode( $this->template ) );
878
+		return $theme_root_uri.'/'.str_replace('%2F', '/', rawurlencode($this->template));
879 879
 	}
880 880
 
881 881
 	/**
@@ -905,8 +905,8 @@  discard block
 block discarded – undo
905 905
 	 * @return string Theme root URI.
906 906
 	 */
907 907
 	public function get_theme_root_uri() {
908
-		if ( ! isset( $this->theme_root_uri ) )
909
-			$this->theme_root_uri = get_theme_root_uri( $this->stylesheet, $this->theme_root );
908
+		if ( ! isset($this->theme_root_uri))
909
+			$this->theme_root_uri = get_theme_root_uri($this->stylesheet, $this->theme_root);
910 910
 		return $this->theme_root_uri;
911 911
 	}
912 912
 
@@ -924,26 +924,26 @@  discard block
 block discarded – undo
924 924
 	 * @param string $uri Type of URL to return, either 'relative' or an absolute URI. Defaults to absolute URI.
925 925
 	 * @return string|false Screenshot file. False if the theme does not have a screenshot.
926 926
 	 */
927
-	public function get_screenshot( $uri = 'uri' ) {
928
-		$screenshot = $this->cache_get( 'screenshot' );
929
-		if ( $screenshot ) {
930
-			if ( 'relative' == $uri )
927
+	public function get_screenshot($uri = 'uri') {
928
+		$screenshot = $this->cache_get('screenshot');
929
+		if ($screenshot) {
930
+			if ('relative' == $uri)
931 931
 				return $screenshot;
932
-			return $this->get_stylesheet_directory_uri() . '/' . $screenshot;
933
-		} elseif ( 0 === $screenshot ) {
932
+			return $this->get_stylesheet_directory_uri().'/'.$screenshot;
933
+		} elseif (0 === $screenshot) {
934 934
 			return false;
935 935
 		}
936 936
 
937
-		foreach ( array( 'png', 'gif', 'jpg', 'jpeg' ) as $ext ) {
938
-			if ( file_exists( $this->get_stylesheet_directory() . "/screenshot.$ext" ) ) {
939
-				$this->cache_add( 'screenshot', 'screenshot.' . $ext );
940
-				if ( 'relative' == $uri )
941
-					return 'screenshot.' . $ext;
942
-				return $this->get_stylesheet_directory_uri() . '/' . 'screenshot.' . $ext;
937
+		foreach (array('png', 'gif', 'jpg', 'jpeg') as $ext) {
938
+			if (file_exists($this->get_stylesheet_directory()."/screenshot.$ext")) {
939
+				$this->cache_add('screenshot', 'screenshot.'.$ext);
940
+				if ('relative' == $uri)
941
+					return 'screenshot.'.$ext;
942
+				return $this->get_stylesheet_directory_uri().'/'.'screenshot.'.$ext;
943 943
 			}
944 944
 		}
945 945
 
946
-		$this->cache_add( 'screenshot', 0 );
946
+		$this->cache_add('screenshot', 0);
947 947
 		return false;
948 948
 	}
949 949
 
@@ -959,11 +959,11 @@  discard block
 block discarded – undo
959 959
 	 * @return array Array of files, keyed by the path to the file relative to the theme's directory, with the values
960 960
 	 * 	             being absolute paths.
961 961
 	 */
962
-	public function get_files( $type = null, $depth = 0, $search_parent = false ) {
963
-		$files = (array) self::scandir( $this->get_stylesheet_directory(), $type, $depth );
962
+	public function get_files($type = null, $depth = 0, $search_parent = false) {
963
+		$files = (array) self::scandir($this->get_stylesheet_directory(), $type, $depth);
964 964
 
965
-		if ( $search_parent && $this->parent() )
966
-			$files += (array) self::scandir( $this->get_template_directory(), $type, $depth );
965
+		if ($search_parent && $this->parent())
966
+			$files += (array) self::scandir($this->get_template_directory(), $type, $depth);
967 967
 
968 968
 		return $files;
969 969
 	}
@@ -977,35 +977,35 @@  discard block
 block discarded – undo
977 977
 	 * @param WP_Post|null $post Optional. The post being edited, provided for context.
978 978
 	 * @return array Array of page templates, keyed by filename, with the value of the translated header name.
979 979
 	 */
980
-	public function get_page_templates( $post = null ) {
980
+	public function get_page_templates($post = null) {
981 981
 		// If you screw up your current theme and we invalidate your parent, most things still work. Let it slide.
982
-		if ( $this->errors() && $this->errors()->get_error_codes() !== array( 'theme_parent_invalid' ) )
982
+		if ($this->errors() && $this->errors()->get_error_codes() !== array('theme_parent_invalid'))
983 983
 			return array();
984 984
 
985
-		$page_templates = $this->cache_get( 'page_templates' );
985
+		$page_templates = $this->cache_get('page_templates');
986 986
 
987
-		if ( ! is_array( $page_templates ) ) {
987
+		if ( ! is_array($page_templates)) {
988 988
 			$page_templates = array();
989 989
 
990
-			$files = (array) $this->get_files( 'php', 1 );
990
+			$files = (array) $this->get_files('php', 1);
991 991
 
992
-			foreach ( $files as $file => $full_path ) {
993
-				if ( ! preg_match( '|Template Name:(.*)$|mi', file_get_contents( $full_path ), $header ) )
992
+			foreach ($files as $file => $full_path) {
993
+				if ( ! preg_match('|Template Name:(.*)$|mi', file_get_contents($full_path), $header))
994 994
 					continue;
995
-				$page_templates[ $file ] = _cleanup_header_comment( $header[1] );
995
+				$page_templates[$file] = _cleanup_header_comment($header[1]);
996 996
 			}
997 997
 
998
-			$this->cache_add( 'page_templates', $page_templates );
998
+			$this->cache_add('page_templates', $page_templates);
999 999
 		}
1000 1000
 
1001
-		if ( $this->load_textdomain() ) {
1002
-			foreach ( $page_templates as &$page_template ) {
1003
-				$page_template = $this->translate_header( 'Template Name', $page_template );
1001
+		if ($this->load_textdomain()) {
1002
+			foreach ($page_templates as &$page_template) {
1003
+				$page_template = $this->translate_header('Template Name', $page_template);
1004 1004
 			}
1005 1005
 		}
1006 1006
 
1007
-		if ( $this->parent() )
1008
-			$page_templates += $this->parent()->get_page_templates( $post );
1007
+		if ($this->parent())
1008
+			$page_templates += $this->parent()->get_page_templates($post);
1009 1009
 
1010 1010
 		/**
1011 1011
 		 * Filter list of page templates for a theme.
@@ -1019,9 +1019,9 @@  discard block
 block discarded – undo
1019 1019
 		 * @param WP_Theme     $this           The theme object.
1020 1020
 		 * @param WP_Post|null $post           The post being edited, provided for context, or null.
1021 1021
 		 */
1022
-		$return = apply_filters( 'theme_page_templates', $page_templates, $this, $post );
1022
+		$return = apply_filters('theme_page_templates', $page_templates, $this, $post);
1023 1023
 
1024
-		return array_intersect_assoc( $return, $page_templates );
1024
+		return array_intersect_assoc($return, $page_templates);
1025 1025
 	}
1026 1026
 
1027 1027
 	/**
@@ -1043,32 +1043,32 @@  discard block
 block discarded – undo
1043 1043
 	 * @return array|false Array of files, keyed by the path to the file relative to the `$path` directory prepended
1044 1044
 	 *                     with `$relative_path`, with the values being absolute paths. False otherwise.
1045 1045
 	 */
1046
-	private static function scandir( $path, $extensions = null, $depth = 0, $relative_path = '' ) {
1047
-		if ( ! is_dir( $path ) )
1046
+	private static function scandir($path, $extensions = null, $depth = 0, $relative_path = '') {
1047
+		if ( ! is_dir($path))
1048 1048
 			return false;
1049 1049
 
1050
-		if ( $extensions ) {
1050
+		if ($extensions) {
1051 1051
 			$extensions = (array) $extensions;
1052
-			$_extensions = implode( '|', $extensions );
1052
+			$_extensions = implode('|', $extensions);
1053 1053
 		}
1054 1054
 
1055
-		$relative_path = trailingslashit( $relative_path );
1056
-		if ( '/' == $relative_path )
1055
+		$relative_path = trailingslashit($relative_path);
1056
+		if ('/' == $relative_path)
1057 1057
 			$relative_path = '';
1058 1058
 
1059
-		$results = scandir( $path );
1059
+		$results = scandir($path);
1060 1060
 		$files = array();
1061 1061
 
1062
-		foreach ( $results as $result ) {
1063
-			if ( '.' == $result[0] )
1062
+		foreach ($results as $result) {
1063
+			if ('.' == $result[0])
1064 1064
 				continue;
1065
-			if ( is_dir( $path . '/' . $result ) ) {
1066
-				if ( ! $depth || 'CVS' == $result )
1065
+			if (is_dir($path.'/'.$result)) {
1066
+				if ( ! $depth || 'CVS' == $result)
1067 1067
 					continue;
1068
-				$found = self::scandir( $path . '/' . $result, $extensions, $depth - 1 , $relative_path . $result );
1069
-				$files = array_merge_recursive( $files, $found );
1070
-			} elseif ( ! $extensions || preg_match( '~\.(' . $_extensions . ')$~', $result ) ) {
1071
-				$files[ $relative_path . $result ] = $path . '/' . $result;
1068
+				$found = self::scandir($path.'/'.$result, $extensions, $depth - 1, $relative_path.$result);
1069
+				$files = array_merge_recursive($files, $found);
1070
+			} elseif ( ! $extensions || preg_match('~\.('.$_extensions.')$~', $result)) {
1071
+				$files[$relative_path.$result] = $path.'/'.$result;
1072 1072
 			}
1073 1073
 		}
1074 1074
 
@@ -1088,27 +1088,27 @@  discard block
 block discarded – undo
1088 1088
 	 * 	False if no textdomain was specified in the file headers, or if the domain could not be loaded.
1089 1089
 	 */
1090 1090
 	public function load_textdomain() {
1091
-		if ( isset( $this->textdomain_loaded ) )
1091
+		if (isset($this->textdomain_loaded))
1092 1092
 			return $this->textdomain_loaded;
1093 1093
 
1094 1094
 		$textdomain = $this->get('TextDomain');
1095
-		if ( ! $textdomain ) {
1095
+		if ( ! $textdomain) {
1096 1096
 			$this->textdomain_loaded = false;
1097 1097
 			return false;
1098 1098
 		}
1099 1099
 
1100
-		if ( is_textdomain_loaded( $textdomain ) ) {
1100
+		if (is_textdomain_loaded($textdomain)) {
1101 1101
 			$this->textdomain_loaded = true;
1102 1102
 			return true;
1103 1103
 		}
1104 1104
 
1105 1105
 		$path = $this->get_stylesheet_directory();
1106
-		if ( $domainpath = $this->get('DomainPath') )
1106
+		if ($domainpath = $this->get('DomainPath'))
1107 1107
 			$path .= $domainpath;
1108 1108
 		else
1109 1109
 			$path .= '/languages';
1110 1110
 
1111
-		$this->textdomain_loaded = load_theme_textdomain( $textdomain, $path );
1111
+		$this->textdomain_loaded = load_theme_textdomain($textdomain, $path);
1112 1112
 		return $this->textdomain_loaded;
1113 1113
 	}
1114 1114
 
@@ -1123,19 +1123,19 @@  discard block
 block discarded – undo
1123 1123
 	 * @param int $blog_id Optional. Ignored if only network-wide settings are checked. Defaults to current blog.
1124 1124
 	 * @return bool Whether the theme is allowed for the network. Returns true in single-site.
1125 1125
 	 */
1126
-	public function is_allowed( $check = 'both', $blog_id = null ) {
1127
-		if ( ! is_multisite() )
1126
+	public function is_allowed($check = 'both', $blog_id = null) {
1127
+		if ( ! is_multisite())
1128 1128
 			return true;
1129 1129
 
1130
-		if ( 'both' == $check || 'network' == $check ) {
1130
+		if ('both' == $check || 'network' == $check) {
1131 1131
 			$allowed = self::get_allowed_on_network();
1132
-			if ( ! empty( $allowed[ $this->get_stylesheet() ] ) )
1132
+			if ( ! empty($allowed[$this->get_stylesheet()]))
1133 1133
 				return true;
1134 1134
 		}
1135 1135
 
1136
-		if ( 'both' == $check || 'site' == $check ) {
1137
-			$allowed = self::get_allowed_on_site( $blog_id );
1138
-			if ( ! empty( $allowed[ $this->get_stylesheet() ] ) )
1136
+		if ('both' == $check || 'site' == $check) {
1137
+			$allowed = self::get_allowed_on_site($blog_id);
1138
+			if ( ! empty($allowed[$this->get_stylesheet()]))
1139 1139
 				return true;
1140 1140
 		}
1141 1141
 
@@ -1153,7 +1153,7 @@  discard block
 block discarded – undo
1153 1153
 	 * @param int $blog_id Optional. Defaults to current blog.
1154 1154
 	 * @return array Array of stylesheet names.
1155 1155
 	 */
1156
-	public static function get_allowed( $blog_id = null ) {
1156
+	public static function get_allowed($blog_id = null) {
1157 1157
 		/**
1158 1158
 		 * Filter the array of themes allowed on the site or network.
1159 1159
 		 *
@@ -1161,8 +1161,8 @@  discard block
 block discarded – undo
1161 1161
 		 *
1162 1162
 		 * @param array $allowed_themes An array of theme stylesheet names.
1163 1163
 		 */
1164
-		$network = (array) apply_filters( 'allowed_themes', self::get_allowed_on_network() );
1165
-		return $network + self::get_allowed_on_site( $blog_id );
1164
+		$network = (array) apply_filters('allowed_themes', self::get_allowed_on_network());
1165
+		return $network + self::get_allowed_on_site($blog_id);
1166 1166
 	}
1167 1167
 
1168 1168
 	/**
@@ -1179,8 +1179,8 @@  discard block
 block discarded – undo
1179 1179
 	 */
1180 1180
 	public static function get_allowed_on_network() {
1181 1181
 		static $allowed_themes;
1182
-		if ( ! isset( $allowed_themes ) )
1183
-			$allowed_themes = (array) get_site_option( 'allowedthemes' );
1182
+		if ( ! isset($allowed_themes))
1183
+			$allowed_themes = (array) get_site_option('allowedthemes');
1184 1184
 		return $allowed_themes;
1185 1185
 	}
1186 1186
 
@@ -1197,62 +1197,62 @@  discard block
 block discarded – undo
1197 1197
 	 * @param int $blog_id Optional. Defaults to current blog.
1198 1198
 	 * @return array Array of stylesheet names.
1199 1199
 	 */
1200
-	public static function get_allowed_on_site( $blog_id = null ) {
1200
+	public static function get_allowed_on_site($blog_id = null) {
1201 1201
 		static $allowed_themes = array();
1202 1202
 
1203
-		if ( ! $blog_id || ! is_multisite() )
1203
+		if ( ! $blog_id || ! is_multisite())
1204 1204
 			$blog_id = get_current_blog_id();
1205 1205
 
1206
-		if ( isset( $allowed_themes[ $blog_id ] ) )
1207
-			return $allowed_themes[ $blog_id ];
1206
+		if (isset($allowed_themes[$blog_id]))
1207
+			return $allowed_themes[$blog_id];
1208 1208
 
1209 1209
 		$current = $blog_id == get_current_blog_id();
1210 1210
 
1211
-		if ( $current ) {
1212
-			$allowed_themes[ $blog_id ] = get_option( 'allowedthemes' );
1211
+		if ($current) {
1212
+			$allowed_themes[$blog_id] = get_option('allowedthemes');
1213 1213
 		} else {
1214
-			switch_to_blog( $blog_id );
1215
-			$allowed_themes[ $blog_id ] = get_option( 'allowedthemes' );
1214
+			switch_to_blog($blog_id);
1215
+			$allowed_themes[$blog_id] = get_option('allowedthemes');
1216 1216
 			restore_current_blog();
1217 1217
 		}
1218 1218
 
1219 1219
 		// This is all super old MU back compat joy.
1220 1220
 		// 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name.
1221
-		if ( false === $allowed_themes[ $blog_id ] ) {
1222
-			if ( $current ) {
1223
-				$allowed_themes[ $blog_id ] = get_option( 'allowed_themes' );
1221
+		if (false === $allowed_themes[$blog_id]) {
1222
+			if ($current) {
1223
+				$allowed_themes[$blog_id] = get_option('allowed_themes');
1224 1224
 			} else {
1225
-				switch_to_blog( $blog_id );
1226
-				$allowed_themes[ $blog_id ] = get_option( 'allowed_themes' );
1225
+				switch_to_blog($blog_id);
1226
+				$allowed_themes[$blog_id] = get_option('allowed_themes');
1227 1227
 				restore_current_blog();
1228 1228
 			}
1229 1229
 
1230
-			if ( ! is_array( $allowed_themes[ $blog_id ] ) || empty( $allowed_themes[ $blog_id ] ) ) {
1231
-				$allowed_themes[ $blog_id ] = array();
1230
+			if ( ! is_array($allowed_themes[$blog_id]) || empty($allowed_themes[$blog_id])) {
1231
+				$allowed_themes[$blog_id] = array();
1232 1232
 			} else {
1233 1233
 				$converted = array();
1234 1234
 				$themes = wp_get_themes();
1235
-				foreach ( $themes as $stylesheet => $theme_data ) {
1236
-					if ( isset( $allowed_themes[ $blog_id ][ $theme_data->get('Name') ] ) )
1237
-						$converted[ $stylesheet ] = true;
1235
+				foreach ($themes as $stylesheet => $theme_data) {
1236
+					if (isset($allowed_themes[$blog_id][$theme_data->get('Name')]))
1237
+						$converted[$stylesheet] = true;
1238 1238
 				}
1239
-				$allowed_themes[ $blog_id ] = $converted;
1239
+				$allowed_themes[$blog_id] = $converted;
1240 1240
 			}
1241 1241
 			// Set the option so we never have to go through this pain again.
1242
-			if ( is_admin() && $allowed_themes[ $blog_id ] ) {
1243
-				if ( $current ) {
1244
-					update_option( 'allowedthemes', $allowed_themes[ $blog_id ] );
1245
-					delete_option( 'allowed_themes' );
1242
+			if (is_admin() && $allowed_themes[$blog_id]) {
1243
+				if ($current) {
1244
+					update_option('allowedthemes', $allowed_themes[$blog_id]);
1245
+					delete_option('allowed_themes');
1246 1246
 				} else {
1247
-					switch_to_blog( $blog_id );
1248
-					update_option( 'allowedthemes', $allowed_themes[ $blog_id ] );
1249
-					delete_option( 'allowed_themes' );
1247
+					switch_to_blog($blog_id);
1248
+					update_option('allowedthemes', $allowed_themes[$blog_id]);
1249
+					delete_option('allowed_themes');
1250 1250
 					restore_current_blog();
1251 1251
 				}
1252 1252
 			}
1253 1253
 		}
1254 1254
 
1255
-		return (array) $allowed_themes[ $blog_id ];
1255
+		return (array) $allowed_themes[$blog_id];
1256 1256
 	}
1257 1257
 
1258 1258
 	/**
@@ -1263,11 +1263,11 @@  discard block
 block discarded – undo
1263 1263
 	 * @static
1264 1264
 	 * @access public
1265 1265
 	 */
1266
-	public static function sort_by_name( &$themes ) {
1267
-		if ( 0 === strpos( get_locale(), 'en_' ) ) {
1268
-			uasort( $themes, array( 'WP_Theme', '_name_sort' ) );
1266
+	public static function sort_by_name(&$themes) {
1267
+		if (0 === strpos(get_locale(), 'en_')) {
1268
+			uasort($themes, array('WP_Theme', '_name_sort'));
1269 1269
 		} else {
1270
-			uasort( $themes, array( 'WP_Theme', '_name_sort_i18n' ) );
1270
+			uasort($themes, array('WP_Theme', '_name_sort_i18n'));
1271 1271
 		}
1272 1272
 	}
1273 1273
 
@@ -1284,8 +1284,8 @@  discard block
 block discarded – undo
1284 1284
 	 *
1285 1285
 	 * @return int
1286 1286
 	 */
1287
-	private static function _name_sort( $a, $b ) {
1288
-		return strnatcasecmp( $a->headers['Name'], $b->headers['Name'] );
1287
+	private static function _name_sort($a, $b) {
1288
+		return strnatcasecmp($a->headers['Name'], $b->headers['Name']);
1289 1289
 	}
1290 1290
 
1291 1291
 	/**
@@ -1298,8 +1298,8 @@  discard block
 block discarded – undo
1298 1298
 	 *
1299 1299
 	 * @return int
1300 1300
 	 */
1301
-	private static function _name_sort_i18n( $a, $b ) {
1301
+	private static function _name_sort_i18n($a, $b) {
1302 1302
 		// Don't mark up; Do translate.
1303
-		return strnatcasecmp( $a->display( 'Name', false, true ), $b->display( 'Name', false, true ) );
1303
+		return strnatcasecmp($a->display('Name', false, true), $b->display('Name', false, true));
1304 1304
 	}
1305 1305
 }
Please login to merge, or discard this patch.
Braces   +137 added lines, -93 removed lines patch added patch discarded remove patch
@@ -195,8 +195,9 @@  discard block
 block discarded – undo
195 195
 			self::$persistently_cache = apply_filters( 'wp_cache_themes_persistently', false, 'WP_Theme' );
196 196
 			if ( self::$persistently_cache ) {
197 197
 				wp_cache_add_global_groups( 'themes' );
198
-				if ( is_int( self::$persistently_cache ) )
199
-					self::$cache_expiration = self::$persistently_cache;
198
+				if ( is_int( self::$persistently_cache ) ) {
199
+									self::$cache_expiration = self::$persistently_cache;
200
+				}
200 201
 			} else {
201 202
 				wp_cache_add_non_persistent_groups( 'themes' );
202 203
 			}
@@ -218,23 +219,29 @@  discard block
 block discarded – undo
218 219
 
219 220
 		if ( is_array( $cache ) ) {
220 221
 			foreach ( array( 'errors', 'headers', 'template' ) as $key ) {
221
-				if ( isset( $cache[ $key ] ) )
222
-					$this->$key = $cache[ $key ];
222
+				if ( isset( $cache[ $key ] ) ) {
223
+									$this->$key = $cache[ $key ];
224
+				}
225
+			}
226
+			if ( $this->errors ) {
227
+							return;
228
+			}
229
+			if ( isset( $cache['theme_root_template'] ) ) {
230
+							$theme_root_template = $cache['theme_root_template'];
223 231
 			}
224
-			if ( $this->errors )
225
-				return;
226
-			if ( isset( $cache['theme_root_template'] ) )
227
-				$theme_root_template = $cache['theme_root_template'];
228 232
 		} elseif ( ! file_exists( $this->theme_root . '/' . $theme_file ) ) {
229 233
 			$this->headers['Name'] = $this->stylesheet;
230
-			if ( ! file_exists( $this->theme_root . '/' . $this->stylesheet ) )
231
-				$this->errors = new WP_Error( 'theme_not_found', sprintf( __( 'The theme directory "%s" does not exist.' ), $this->stylesheet ) );
232
-			else
233
-				$this->errors = new WP_Error( 'theme_no_stylesheet', __( 'Stylesheet is missing.' ) );
234
+			if ( ! file_exists( $this->theme_root . '/' . $this->stylesheet ) ) {
235
+							$this->errors = new WP_Error( 'theme_not_found', sprintf( __( 'The theme directory "%s" does not exist.' ), $this->stylesheet ) );
236
+			} else {
237
+							$this->errors = new WP_Error( 'theme_no_stylesheet', __( 'Stylesheet is missing.' ) );
238
+			}
234 239
 			$this->template = $this->stylesheet;
235 240
 			$this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) );
236
-			if ( ! file_exists( $this->theme_root ) ) // Don't cache this one.
241
+			if ( ! file_exists( $this->theme_root ) ) {
242
+				// Don't cache this one.
237 243
 				$this->errors->add( 'theme_root_missing', __( 'ERROR: The themes directory is either empty or doesn&#8217;t exist. Please check your installation.' ) );
244
+			}
238 245
 			return;
239 246
 		} elseif ( ! is_readable( $this->theme_root . '/' . $theme_file ) ) {
240 247
 			$this->headers['Name'] = $this->stylesheet;
@@ -247,8 +254,9 @@  discard block
 block discarded – undo
247 254
 			// Default themes always trump their pretenders.
248 255
 			// Properly identify default themes that are inside a directory within wp-content/themes.
249 256
 			if ( $default_theme_slug = array_search( $this->headers['Name'], self::$default_themes ) ) {
250
-				if ( basename( $this->stylesheet ) != $default_theme_slug )
251
-					$this->headers['Name'] .= '/' . $this->stylesheet;
257
+				if ( basename( $this->stylesheet ) != $default_theme_slug ) {
258
+									$this->headers['Name'] .= '/' . $this->stylesheet;
259
+				}
252 260
 			}
253 261
 		}
254 262
 
@@ -304,8 +312,9 @@  discard block
 block discarded – undo
304 312
 		if ( ! is_array( $cache ) ) {
305 313
 			$cache = array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template );
306 314
 			// If the parent theme is in another root, we'll want to cache this. Avoids an entire branch of filesystem calls above.
307
-			if ( isset( $theme_root_template ) )
308
-				$cache['theme_root_template'] = $theme_root_template;
315
+			if ( isset( $theme_root_template ) ) {
316
+							$cache['theme_root_template'] = $theme_root_template;
317
+			}
309 318
 			$this->cache_add( 'theme', $cache );
310 319
 		}
311 320
 	}
@@ -544,8 +553,9 @@  discard block
 block discarded – undo
544 553
 	 * @access public
545 554
 	 */
546 555
 	public function cache_delete() {
547
-		foreach ( array( 'theme', 'screenshot', 'headers', 'page_templates' ) as $key )
548
-			wp_cache_delete( $key . '-' . $this->cache_hash, 'themes' );
556
+		foreach ( array( 'theme', 'screenshot', 'headers', 'page_templates' ) as $key ) {
557
+					wp_cache_delete( $key . '-' . $this->cache_hash, 'themes' );
558
+		}
549 559
 		$this->template = $this->textdomain_loaded = $this->theme_root_uri = $this->parent = $this->errors = $this->headers_sanitized = $this->name_translated = null;
550 560
 		$this->headers = array();
551 561
 		$this->__construct( $this->stylesheet, $this->theme_root );
@@ -569,22 +579,26 @@  discard block
 block discarded – undo
569 579
 	 * @return string|false String on success, false on failure.
570 580
 	 */
571 581
 	public function get( $header ) {
572
-		if ( ! isset( $this->headers[ $header ] ) )
573
-			return false;
582
+		if ( ! isset( $this->headers[ $header ] ) ) {
583
+					return false;
584
+		}
574 585
 
575 586
 		if ( ! isset( $this->headers_sanitized ) ) {
576 587
 			$this->headers_sanitized = $this->cache_get( 'headers' );
577
-			if ( ! is_array( $this->headers_sanitized ) )
578
-				$this->headers_sanitized = array();
588
+			if ( ! is_array( $this->headers_sanitized ) ) {
589
+							$this->headers_sanitized = array();
590
+			}
579 591
 		}
580 592
 
581
-		if ( isset( $this->headers_sanitized[ $header ] ) )
582
-			return $this->headers_sanitized[ $header ];
593
+		if ( isset( $this->headers_sanitized[ $header ] ) ) {
594
+					return $this->headers_sanitized[ $header ];
595
+		}
583 596
 
584 597
 		// If themes are a persistent group, sanitize everything and cache it. One cache add is better than many cache sets.
585 598
 		if ( self::$persistently_cache ) {
586
-			foreach ( array_keys( $this->headers ) as $_header )
587
-				$this->headers_sanitized[ $_header ] = $this->sanitize_header( $_header, $this->headers[ $_header ] );
599
+			foreach ( array_keys( $this->headers ) as $_header ) {
600
+							$this->headers_sanitized[ $_header ] = $this->sanitize_header( $_header, $this->headers[ $_header ] );
601
+			}
588 602
 			$this->cache_add( 'headers', $this->headers_sanitized );
589 603
 		} else {
590 604
 			$this->headers_sanitized[ $header ] = $this->sanitize_header( $header, $this->headers[ $header ] );
@@ -610,14 +624,17 @@  discard block
 block discarded – undo
610 624
 			return false;
611 625
 		}
612 626
 
613
-		if ( $translate && ( empty( $value ) || ! $this->load_textdomain() ) )
614
-			$translate = false;
627
+		if ( $translate && ( empty( $value ) || ! $this->load_textdomain() ) ) {
628
+					$translate = false;
629
+		}
615 630
 
616
-		if ( $translate )
617
-			$value = $this->translate_header( $header, $value );
631
+		if ( $translate ) {
632
+					$value = $this->translate_header( $header, $value );
633
+		}
618 634
 
619
-		if ( $markup )
620
-			$value = $this->markup_header( $header, $value, $translate );
635
+		if ( $markup ) {
636
+					$value = $this->markup_header( $header, $value, $translate );
637
+		}
621 638
 
622 639
 		return $value;
623 640
 	}
@@ -697,8 +714,9 @@  discard block
 block discarded – undo
697 714
 	private function markup_header( $header, $value, $translate ) {
698 715
 		switch ( $header ) {
699 716
 			case 'Name' :
700
-				if ( empty( $value ) )
701
-					$value = $this->get_stylesheet();
717
+				if ( empty( $value ) ) {
718
+									$value = $this->get_stylesheet();
719
+				}
702 720
 				break;
703 721
 			case 'Description' :
704 722
 				$value = wptexturize( $value );
@@ -743,20 +761,23 @@  discard block
 block discarded – undo
743 761
 		switch ( $header ) {
744 762
 			case 'Name' :
745 763
 				// Cached for sorting reasons.
746
-				if ( isset( $this->name_translated ) )
747
-					return $this->name_translated;
764
+				if ( isset( $this->name_translated ) ) {
765
+									return $this->name_translated;
766
+				}
748 767
 				$this->name_translated = translate( $value, $this->get('TextDomain' ) );
749 768
 				return $this->name_translated;
750 769
 			case 'Tags' :
751
-				if ( empty( $value ) || ! function_exists( 'get_theme_feature_list' ) )
752
-					return $value;
770
+				if ( empty( $value ) || ! function_exists( 'get_theme_feature_list' ) ) {
771
+									return $value;
772
+				}
753 773
 
754 774
 				static $tags_list;
755 775
 				if ( ! isset( $tags_list ) ) {
756 776
 					$tags_list = array();
757 777
 					$feature_list = get_theme_feature_list( false ); // No API
758
-					foreach ( $feature_list as $tags )
759
-						$tags_list += $tags;
778
+					foreach ( $feature_list as $tags ) {
779
+											$tags_list += $tags;
780
+					}
760 781
 				}
761 782
 
762 783
 				foreach ( $value as &$tag ) {
@@ -817,8 +838,9 @@  discard block
 block discarded – undo
817 838
 	 * @return string Absolute path of the stylesheet directory.
818 839
 	 */
819 840
 	public function get_stylesheet_directory() {
820
-		if ( $this->errors() && in_array( 'theme_root_missing', $this->errors()->get_error_codes() ) )
821
-			return '';
841
+		if ( $this->errors() && in_array( 'theme_root_missing', $this->errors()->get_error_codes() ) ) {
842
+					return '';
843
+		}
822 844
 
823 845
 		return $this->theme_root . '/' . $this->stylesheet;
824 846
 	}
@@ -835,10 +857,11 @@  discard block
 block discarded – undo
835 857
 	 * @return string Absolute path of the template directory.
836 858
 	 */
837 859
 	public function get_template_directory() {
838
-		if ( $this->parent() )
839
-			$theme_root = $this->parent()->theme_root;
840
-		else
841
-			$theme_root = $this->theme_root;
860
+		if ( $this->parent() ) {
861
+					$theme_root = $this->parent()->theme_root;
862
+		} else {
863
+					$theme_root = $this->theme_root;
864
+		}
842 865
 
843 866
 		return $theme_root . '/' . $this->template;
844 867
 	}
@@ -870,10 +893,11 @@  discard block
 block discarded – undo
870 893
 	 * @return string URL to the template directory.
871 894
 	 */
872 895
 	public function get_template_directory_uri() {
873
-		if ( $this->parent() )
874
-			$theme_root_uri = $this->parent()->get_theme_root_uri();
875
-		else
876
-			$theme_root_uri = $this->get_theme_root_uri();
896
+		if ( $this->parent() ) {
897
+					$theme_root_uri = $this->parent()->get_theme_root_uri();
898
+		} else {
899
+					$theme_root_uri = $this->get_theme_root_uri();
900
+		}
877 901
 
878 902
 		return $theme_root_uri . '/' . str_replace( '%2F', '/', rawurlencode( $this->template ) );
879 903
 	}
@@ -905,8 +929,9 @@  discard block
 block discarded – undo
905 929
 	 * @return string Theme root URI.
906 930
 	 */
907 931
 	public function get_theme_root_uri() {
908
-		if ( ! isset( $this->theme_root_uri ) )
909
-			$this->theme_root_uri = get_theme_root_uri( $this->stylesheet, $this->theme_root );
932
+		if ( ! isset( $this->theme_root_uri ) ) {
933
+					$this->theme_root_uri = get_theme_root_uri( $this->stylesheet, $this->theme_root );
934
+		}
910 935
 		return $this->theme_root_uri;
911 936
 	}
912 937
 
@@ -927,8 +952,9 @@  discard block
 block discarded – undo
927 952
 	public function get_screenshot( $uri = 'uri' ) {
928 953
 		$screenshot = $this->cache_get( 'screenshot' );
929 954
 		if ( $screenshot ) {
930
-			if ( 'relative' == $uri )
931
-				return $screenshot;
955
+			if ( 'relative' == $uri ) {
956
+							return $screenshot;
957
+			}
932 958
 			return $this->get_stylesheet_directory_uri() . '/' . $screenshot;
933 959
 		} elseif ( 0 === $screenshot ) {
934 960
 			return false;
@@ -937,8 +963,9 @@  discard block
 block discarded – undo
937 963
 		foreach ( array( 'png', 'gif', 'jpg', 'jpeg' ) as $ext ) {
938 964
 			if ( file_exists( $this->get_stylesheet_directory() . "/screenshot.$ext" ) ) {
939 965
 				$this->cache_add( 'screenshot', 'screenshot.' . $ext );
940
-				if ( 'relative' == $uri )
941
-					return 'screenshot.' . $ext;
966
+				if ( 'relative' == $uri ) {
967
+									return 'screenshot.' . $ext;
968
+				}
942 969
 				return $this->get_stylesheet_directory_uri() . '/' . 'screenshot.' . $ext;
943 970
 			}
944 971
 		}
@@ -962,8 +989,9 @@  discard block
 block discarded – undo
962 989
 	public function get_files( $type = null, $depth = 0, $search_parent = false ) {
963 990
 		$files = (array) self::scandir( $this->get_stylesheet_directory(), $type, $depth );
964 991
 
965
-		if ( $search_parent && $this->parent() )
966
-			$files += (array) self::scandir( $this->get_template_directory(), $type, $depth );
992
+		if ( $search_parent && $this->parent() ) {
993
+					$files += (array) self::scandir( $this->get_template_directory(), $type, $depth );
994
+		}
967 995
 
968 996
 		return $files;
969 997
 	}
@@ -979,8 +1007,9 @@  discard block
 block discarded – undo
979 1007
 	 */
980 1008
 	public function get_page_templates( $post = null ) {
981 1009
 		// If you screw up your current theme and we invalidate your parent, most things still work. Let it slide.
982
-		if ( $this->errors() && $this->errors()->get_error_codes() !== array( 'theme_parent_invalid' ) )
983
-			return array();
1010
+		if ( $this->errors() && $this->errors()->get_error_codes() !== array( 'theme_parent_invalid' ) ) {
1011
+					return array();
1012
+		}
984 1013
 
985 1014
 		$page_templates = $this->cache_get( 'page_templates' );
986 1015
 
@@ -990,8 +1019,9 @@  discard block
 block discarded – undo
990 1019
 			$files = (array) $this->get_files( 'php', 1 );
991 1020
 
992 1021
 			foreach ( $files as $file => $full_path ) {
993
-				if ( ! preg_match( '|Template Name:(.*)$|mi', file_get_contents( $full_path ), $header ) )
994
-					continue;
1022
+				if ( ! preg_match( '|Template Name:(.*)$|mi', file_get_contents( $full_path ), $header ) ) {
1023
+									continue;
1024
+				}
995 1025
 				$page_templates[ $file ] = _cleanup_header_comment( $header[1] );
996 1026
 			}
997 1027
 
@@ -1004,8 +1034,9 @@  discard block
 block discarded – undo
1004 1034
 			}
1005 1035
 		}
1006 1036
 
1007
-		if ( $this->parent() )
1008
-			$page_templates += $this->parent()->get_page_templates( $post );
1037
+		if ( $this->parent() ) {
1038
+					$page_templates += $this->parent()->get_page_templates( $post );
1039
+		}
1009 1040
 
1010 1041
 		/**
1011 1042
 		 * Filter list of page templates for a theme.
@@ -1044,8 +1075,9 @@  discard block
 block discarded – undo
1044 1075
 	 *                     with `$relative_path`, with the values being absolute paths. False otherwise.
1045 1076
 	 */
1046 1077
 	private static function scandir( $path, $extensions = null, $depth = 0, $relative_path = '' ) {
1047
-		if ( ! is_dir( $path ) )
1048
-			return false;
1078
+		if ( ! is_dir( $path ) ) {
1079
+					return false;
1080
+		}
1049 1081
 
1050 1082
 		if ( $extensions ) {
1051 1083
 			$extensions = (array) $extensions;
@@ -1053,18 +1085,21 @@  discard block
 block discarded – undo
1053 1085
 		}
1054 1086
 
1055 1087
 		$relative_path = trailingslashit( $relative_path );
1056
-		if ( '/' == $relative_path )
1057
-			$relative_path = '';
1088
+		if ( '/' == $relative_path ) {
1089
+					$relative_path = '';
1090
+		}
1058 1091
 
1059 1092
 		$results = scandir( $path );
1060 1093
 		$files = array();
1061 1094
 
1062 1095
 		foreach ( $results as $result ) {
1063
-			if ( '.' == $result[0] )
1064
-				continue;
1096
+			if ( '.' == $result[0] ) {
1097
+							continue;
1098
+			}
1065 1099
 			if ( is_dir( $path . '/' . $result ) ) {
1066
-				if ( ! $depth || 'CVS' == $result )
1067
-					continue;
1100
+				if ( ! $depth || 'CVS' == $result ) {
1101
+									continue;
1102
+				}
1068 1103
 				$found = self::scandir( $path . '/' . $result, $extensions, $depth - 1 , $relative_path . $result );
1069 1104
 				$files = array_merge_recursive( $files, $found );
1070 1105
 			} elseif ( ! $extensions || preg_match( '~\.(' . $_extensions . ')$~', $result ) ) {
@@ -1088,8 +1123,9 @@  discard block
 block discarded – undo
1088 1123
 	 * 	False if no textdomain was specified in the file headers, or if the domain could not be loaded.
1089 1124
 	 */
1090 1125
 	public function load_textdomain() {
1091
-		if ( isset( $this->textdomain_loaded ) )
1092
-			return $this->textdomain_loaded;
1126
+		if ( isset( $this->textdomain_loaded ) ) {
1127
+					return $this->textdomain_loaded;
1128
+		}
1093 1129
 
1094 1130
 		$textdomain = $this->get('TextDomain');
1095 1131
 		if ( ! $textdomain ) {
@@ -1103,10 +1139,11 @@  discard block
 block discarded – undo
1103 1139
 		}
1104 1140
 
1105 1141
 		$path = $this->get_stylesheet_directory();
1106
-		if ( $domainpath = $this->get('DomainPath') )
1107
-			$path .= $domainpath;
1108
-		else
1109
-			$path .= '/languages';
1142
+		if ( $domainpath = $this->get('DomainPath') ) {
1143
+					$path .= $domainpath;
1144
+		} else {
1145
+					$path .= '/languages';
1146
+		}
1110 1147
 
1111 1148
 		$this->textdomain_loaded = load_theme_textdomain( $textdomain, $path );
1112 1149
 		return $this->textdomain_loaded;
@@ -1124,19 +1161,22 @@  discard block
 block discarded – undo
1124 1161
 	 * @return bool Whether the theme is allowed for the network. Returns true in single-site.
1125 1162
 	 */
1126 1163
 	public function is_allowed( $check = 'both', $blog_id = null ) {
1127
-		if ( ! is_multisite() )
1128
-			return true;
1164
+		if ( ! is_multisite() ) {
1165
+					return true;
1166
+		}
1129 1167
 
1130 1168
 		if ( 'both' == $check || 'network' == $check ) {
1131 1169
 			$allowed = self::get_allowed_on_network();
1132
-			if ( ! empty( $allowed[ $this->get_stylesheet() ] ) )
1133
-				return true;
1170
+			if ( ! empty( $allowed[ $this->get_stylesheet() ] ) ) {
1171
+							return true;
1172
+			}
1134 1173
 		}
1135 1174
 
1136 1175
 		if ( 'both' == $check || 'site' == $check ) {
1137 1176
 			$allowed = self::get_allowed_on_site( $blog_id );
1138
-			if ( ! empty( $allowed[ $this->get_stylesheet() ] ) )
1139
-				return true;
1177
+			if ( ! empty( $allowed[ $this->get_stylesheet() ] ) ) {
1178
+							return true;
1179
+			}
1140 1180
 		}
1141 1181
 
1142 1182
 		return false;
@@ -1179,8 +1219,9 @@  discard block
 block discarded – undo
1179 1219
 	 */
1180 1220
 	public static function get_allowed_on_network() {
1181 1221
 		static $allowed_themes;
1182
-		if ( ! isset( $allowed_themes ) )
1183
-			$allowed_themes = (array) get_site_option( 'allowedthemes' );
1222
+		if ( ! isset( $allowed_themes ) ) {
1223
+					$allowed_themes = (array) get_site_option( 'allowedthemes' );
1224
+		}
1184 1225
 		return $allowed_themes;
1185 1226
 	}
1186 1227
 
@@ -1200,11 +1241,13 @@  discard block
 block discarded – undo
1200 1241
 	public static function get_allowed_on_site( $blog_id = null ) {
1201 1242
 		static $allowed_themes = array();
1202 1243
 
1203
-		if ( ! $blog_id || ! is_multisite() )
1204
-			$blog_id = get_current_blog_id();
1244
+		if ( ! $blog_id || ! is_multisite() ) {
1245
+					$blog_id = get_current_blog_id();
1246
+		}
1205 1247
 
1206
-		if ( isset( $allowed_themes[ $blog_id ] ) )
1207
-			return $allowed_themes[ $blog_id ];
1248
+		if ( isset( $allowed_themes[ $blog_id ] ) ) {
1249
+					return $allowed_themes[ $blog_id ];
1250
+		}
1208 1251
 
1209 1252
 		$current = $blog_id == get_current_blog_id();
1210 1253
 
@@ -1233,8 +1276,9 @@  discard block
 block discarded – undo
1233 1276
 				$converted = array();
1234 1277
 				$themes = wp_get_themes();
1235 1278
 				foreach ( $themes as $stylesheet => $theme_data ) {
1236
-					if ( isset( $allowed_themes[ $blog_id ][ $theme_data->get('Name') ] ) )
1237
-						$converted[ $stylesheet ] = true;
1279
+					if ( isset( $allowed_themes[ $blog_id ][ $theme_data->get('Name') ] ) ) {
1280
+											$converted[ $stylesheet ] = true;
1281
+					}
1238 1282
 				}
1239 1283
 				$allowed_themes[ $blog_id ] = $converted;
1240 1284
 			}
Please login to merge, or discard this patch.
src/wp-includes/class-wp.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -699,7 +699,7 @@
 block discarded – undo
699 699
 	 * @access public
700 700
 	 *
701 701
 	 * @param string $subject subject
702
-	 * @param array  $matches data used for substitution
702
+	 * @param string[]  $matches data used for substitution
703 703
 	 * @return string
704 704
 	 */
705 705
 	public static function apply($subject, $matches) {
Please login to merge, or discard this patch.
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * WordPress environment setup class.
4
- *
5
- * @package WordPress
6
- * @since 2.0.0
7
- */
3
+	 * WordPress environment setup class.
4
+	 *
5
+	 * @package WordPress
6
+	 * @since 2.0.0
7
+	 */
8 8
 class WP {
9 9
 	/**
10 10
 	 * Public query variables.
@@ -557,17 +557,17 @@  discard block
 block discarded – undo
557 557
  	}
558 558
 
559 559
  	/**
560
-	 * Set the Headers for 404, if nothing is found for requested URL.
561
-	 *
562
-	 * Issue a 404 if a request doesn't match any posts and doesn't match
563
-	 * any object (e.g. an existing-but-empty category, tag, author) and a 404 was not already
564
-	 * issued, and if the request was not a search or the homepage.
565
-	 *
566
-	 * Otherwise, issue a 200.
567
-	 *
568
-	 * @since 2.0.0
569
-	 *
570
-	 * @global WP_Query $wp_query
560
+ 	 * Set the Headers for 404, if nothing is found for requested URL.
561
+ 	 *
562
+ 	 * Issue a 404 if a request doesn't match any posts and doesn't match
563
+ 	 * any object (e.g. an existing-but-empty category, tag, author) and a 404 was not already
564
+ 	 * issued, and if the request was not a search or the homepage.
565
+ 	 *
566
+ 	 * Otherwise, issue a 200.
567
+ 	 *
568
+ 	 * @since 2.0.0
569
+ 	 *
570
+ 	 * @global WP_Query $wp_query
571 571
  	 */
572 572
 	public function handle_404() {
573 573
 		global $wp_query;
Please login to merge, or discard this patch.
Spacing   +123 added lines, -124 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	 * @since 2.0.0
26 26
 	 * @var array
27 27
 	 */
28
-	public $private_query_vars = array( 'offset', 'posts_per_page', 'posts_per_archive_page', 'showposts', 'nopaging', 'post_type', 'post_status', 'category__in', 'category__not_in', 'category__and', 'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and', 'tag_id', 'post_mime_type', 'perm', 'comments_per_page', 'post__in', 'post__not_in', 'post_parent', 'post_parent__in', 'post_parent__not_in' );
28
+	public $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'showposts', 'nopaging', 'post_type', 'post_status', 'category__in', 'category__not_in', 'category__and', 'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and', 'tag_id', 'post_mime_type', 'perm', 'comments_per_page', 'post__in', 'post__not_in', 'post_parent', 'post_parent__in', 'post_parent__not_in');
29 29
 
30 30
 	/**
31 31
 	 * Extra query variables set by the user.
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 * @param string $qv Query variable name.
92 92
 	 */
93 93
 	public function add_query_var($qv) {
94
-		if ( !in_array($qv, $this->public_query_vars) )
94
+		if ( ! in_array($qv, $this->public_query_vars))
95 95
 			$this->public_query_vars[] = $qv;
96 96
 	}
97 97
 
@@ -131,35 +131,35 @@  discard block
 block discarded – undo
131 131
 		 * @param WP           $this             Current WordPress environment instance.
132 132
 		 * @param array|string $extra_query_vars Extra passed query variables.
133 133
 		 */
134
-		if ( ! apply_filters( 'do_parse_request', true, $this, $extra_query_vars ) )
134
+		if ( ! apply_filters('do_parse_request', true, $this, $extra_query_vars))
135 135
 			return;
136 136
 
137 137
 		$this->query_vars = array();
138 138
 		$post_type_query_vars = array();
139 139
 
140
-		if ( is_array( $extra_query_vars ) ) {
140
+		if (is_array($extra_query_vars)) {
141 141
 			$this->extra_query_vars = & $extra_query_vars;
142
-		} elseif ( ! empty( $extra_query_vars ) ) {
143
-			parse_str( $extra_query_vars, $this->extra_query_vars );
142
+		} elseif ( ! empty($extra_query_vars)) {
143
+			parse_str($extra_query_vars, $this->extra_query_vars);
144 144
 		}
145 145
 		// Process PATH_INFO, REQUEST_URI, and 404 for permalinks.
146 146
 
147 147
 		// Fetch the rewrite rules.
148 148
 		$rewrite = $wp_rewrite->wp_rewrite_rules();
149 149
 
150
-		if ( ! empty($rewrite) ) {
150
+		if ( ! empty($rewrite)) {
151 151
 			// If we match a rewrite rule, this will be cleared.
152 152
 			$error = '404';
153 153
 			$this->did_permalink = true;
154 154
 
155
-			$pathinfo = isset( $_SERVER['PATH_INFO'] ) ? $_SERVER['PATH_INFO'] : '';
156
-			list( $pathinfo ) = explode( '?', $pathinfo );
157
-			$pathinfo = str_replace( "%", "%25", $pathinfo );
155
+			$pathinfo = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : '';
156
+			list($pathinfo) = explode('?', $pathinfo);
157
+			$pathinfo = str_replace("%", "%25", $pathinfo);
158 158
 
159
-			list( $req_uri ) = explode( '?', $_SERVER['REQUEST_URI'] );
159
+			list($req_uri) = explode('?', $_SERVER['REQUEST_URI']);
160 160
 			$self = $_SERVER['PHP_SELF'];
161
-			$home_path = trim( parse_url( home_url(), PHP_URL_PATH ), '/' );
162
-			$home_path_regex = sprintf( '|^%s|i', preg_quote( $home_path, '|' ) );
161
+			$home_path = trim(parse_url(home_url(), PHP_URL_PATH), '/');
162
+			$home_path_regex = sprintf('|^%s|i', preg_quote($home_path, '|'));
163 163
 
164 164
 			// Trim path info from the end and the leading home path from the
165 165
 			// front. For path info requests, this leaves us with the requesting
@@ -167,22 +167,22 @@  discard block
 block discarded – undo
167 167
 			// requested permalink.
168 168
 			$req_uri = str_replace($pathinfo, '', $req_uri);
169 169
 			$req_uri = trim($req_uri, '/');
170
-			$req_uri = preg_replace( $home_path_regex, '', $req_uri );
170
+			$req_uri = preg_replace($home_path_regex, '', $req_uri);
171 171
 			$req_uri = trim($req_uri, '/');
172 172
 			$pathinfo = trim($pathinfo, '/');
173
-			$pathinfo = preg_replace( $home_path_regex, '', $pathinfo );
173
+			$pathinfo = preg_replace($home_path_regex, '', $pathinfo);
174 174
 			$pathinfo = trim($pathinfo, '/');
175 175
 			$self = trim($self, '/');
176
-			$self = preg_replace( $home_path_regex, '', $self );
176
+			$self = preg_replace($home_path_regex, '', $self);
177 177
 			$self = trim($self, '/');
178 178
 
179 179
 			// The requested permalink is in $pathinfo for path info requests and
180 180
 			//  $req_uri for other requests.
181
-			if ( ! empty($pathinfo) && !preg_match('|^.*' . $wp_rewrite->index . '$|', $pathinfo) ) {
181
+			if ( ! empty($pathinfo) && ! preg_match('|^.*'.$wp_rewrite->index.'$|', $pathinfo)) {
182 182
 				$request = $pathinfo;
183 183
 			} else {
184 184
 				// If the request uri is the index, blank it out so that we don't try to match it against a rule.
185
-				if ( $req_uri == $wp_rewrite->index )
185
+				if ($req_uri == $wp_rewrite->index)
186 186
 					$req_uri = '';
187 187
 				$request = $req_uri;
188 188
 			}
@@ -191,25 +191,25 @@  discard block
 block discarded – undo
191 191
 
192 192
 			// Look for matches.
193 193
 			$request_match = $request;
194
-			if ( empty( $request_match ) ) {
194
+			if (empty($request_match)) {
195 195
 				// An empty request could only match against ^$ regex
196
-				if ( isset( $rewrite['$'] ) ) {
196
+				if (isset($rewrite['$'])) {
197 197
 					$this->matched_rule = '$';
198 198
 					$query = $rewrite['$'];
199 199
 					$matches = array('');
200 200
 				}
201 201
 			} else {
202
-				foreach ( (array) $rewrite as $match => $query ) {
202
+				foreach ((array) $rewrite as $match => $query) {
203 203
 					// If the requesting file is the anchor of the match, prepend it to the path info.
204
-					if ( ! empty($req_uri) && strpos($match, $req_uri) === 0 && $req_uri != $request )
205
-						$request_match = $req_uri . '/' . $request;
204
+					if ( ! empty($req_uri) && strpos($match, $req_uri) === 0 && $req_uri != $request)
205
+						$request_match = $req_uri.'/'.$request;
206 206
 
207
-					if ( preg_match("#^$match#", $request_match, $matches) ||
208
-						preg_match("#^$match#", urldecode($request_match), $matches) ) {
207
+					if (preg_match("#^$match#", $request_match, $matches) ||
208
+						preg_match("#^$match#", urldecode($request_match), $matches)) {
209 209
 
210
-						if ( $wp_rewrite->use_verbose_page_rules && preg_match( '/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch ) ) {
210
+						if ($wp_rewrite->use_verbose_page_rules && preg_match('/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch)) {
211 211
 							// This is a verbose page match, let's check to be sure about it.
212
-							if ( ! get_page_by_path( $matches[ $varmatch[1] ] ) )
212
+							if ( ! get_page_by_path($matches[$varmatch[1]]))
213 213
 						 		continue;
214 214
 						}
215 215
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 				}
221 221
 			}
222 222
 
223
-			if ( isset( $this->matched_rule ) ) {
223
+			if (isset($this->matched_rule)) {
224 224
 				// Trim the query of everything up to the '?'.
225 225
 				$query = preg_replace("!^.+\?!", '', $query);
226 226
 
@@ -233,16 +233,16 @@  discard block
 block discarded – undo
233 233
 				parse_str($query, $perma_query_vars);
234 234
 
235 235
 				// If we're processing a 404 request, clear the error var since we found something.
236
-				if ( '404' == $error )
237
-					unset( $error, $_GET['error'] );
236
+				if ('404' == $error)
237
+					unset($error, $_GET['error']);
238 238
 			}
239 239
 
240 240
 			// If req_uri is empty or if it is a request for ourself, unset error.
241
-			if ( empty($request) || $req_uri == $self || strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false ) {
242
-				unset( $error, $_GET['error'] );
241
+			if (empty($request) || $req_uri == $self || strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false) {
242
+				unset($error, $_GET['error']);
243 243
 
244
-				if ( isset($perma_query_vars) && strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false )
245
-					unset( $perma_query_vars );
244
+				if (isset($perma_query_vars) && strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false)
245
+					unset($perma_query_vars);
246 246
 
247 247
 				$this->did_permalink = false;
248 248
 			}
@@ -259,34 +259,34 @@  discard block
 block discarded – undo
259 259
 		 *
260 260
 		 * @param array $public_query_vars The array of whitelisted query variables.
261 261
 		 */
262
-		$this->public_query_vars = apply_filters( 'query_vars', $this->public_query_vars );
262
+		$this->public_query_vars = apply_filters('query_vars', $this->public_query_vars);
263 263
 
264
-		foreach ( get_post_types( array(), 'objects' ) as $post_type => $t )
265
-			if ( $t->query_var )
264
+		foreach (get_post_types(array(), 'objects') as $post_type => $t)
265
+			if ($t->query_var)
266 266
 				$post_type_query_vars[$t->query_var] = $post_type;
267 267
 
268
-		foreach ( $this->public_query_vars as $wpvar ) {
269
-			if ( isset( $this->extra_query_vars[$wpvar] ) )
268
+		foreach ($this->public_query_vars as $wpvar) {
269
+			if (isset($this->extra_query_vars[$wpvar]))
270 270
 				$this->query_vars[$wpvar] = $this->extra_query_vars[$wpvar];
271
-			elseif ( isset( $_POST[$wpvar] ) )
271
+			elseif (isset($_POST[$wpvar]))
272 272
 				$this->query_vars[$wpvar] = $_POST[$wpvar];
273
-			elseif ( isset( $_GET[$wpvar] ) )
273
+			elseif (isset($_GET[$wpvar]))
274 274
 				$this->query_vars[$wpvar] = $_GET[$wpvar];
275
-			elseif ( isset( $perma_query_vars[$wpvar] ) )
275
+			elseif (isset($perma_query_vars[$wpvar]))
276 276
 				$this->query_vars[$wpvar] = $perma_query_vars[$wpvar];
277 277
 
278
-			if ( !empty( $this->query_vars[$wpvar] ) ) {
279
-				if ( ! is_array( $this->query_vars[$wpvar] ) ) {
278
+			if ( ! empty($this->query_vars[$wpvar])) {
279
+				if ( ! is_array($this->query_vars[$wpvar])) {
280 280
 					$this->query_vars[$wpvar] = (string) $this->query_vars[$wpvar];
281 281
 				} else {
282
-					foreach ( $this->query_vars[$wpvar] as $vkey => $v ) {
283
-						if ( !is_object( $v ) ) {
282
+					foreach ($this->query_vars[$wpvar] as $vkey => $v) {
283
+						if ( ! is_object($v)) {
284 284
 							$this->query_vars[$wpvar][$vkey] = (string) $v;
285 285
 						}
286 286
 					}
287 287
 				}
288 288
 
289
-				if ( isset($post_type_query_vars[$wpvar] ) ) {
289
+				if (isset($post_type_query_vars[$wpvar])) {
290 290
 					$this->query_vars['post_type'] = $post_type_query_vars[$wpvar];
291 291
 					$this->query_vars['name'] = $this->query_vars[$wpvar];
292 292
 				}
@@ -294,30 +294,30 @@  discard block
 block discarded – undo
294 294
 		}
295 295
 
296 296
 		// Convert urldecoded spaces back into +
297
-		foreach ( get_taxonomies( array() , 'objects' ) as $taxonomy => $t )
298
-			if ( $t->query_var && isset( $this->query_vars[$t->query_var] ) )
299
-				$this->query_vars[$t->query_var] = str_replace( ' ', '+', $this->query_vars[$t->query_var] );
297
+		foreach (get_taxonomies(array(), 'objects') as $taxonomy => $t)
298
+			if ($t->query_var && isset($this->query_vars[$t->query_var]))
299
+				$this->query_vars[$t->query_var] = str_replace(' ', '+', $this->query_vars[$t->query_var]);
300 300
 
301 301
 		// Limit publicly queried post_types to those that are publicly_queryable
302
-		if ( isset( $this->query_vars['post_type']) ) {
303
-			$queryable_post_types = get_post_types( array('publicly_queryable' => true) );
304
-			if ( ! is_array( $this->query_vars['post_type'] ) ) {
305
-				if ( ! in_array( $this->query_vars['post_type'], $queryable_post_types ) )
306
-					unset( $this->query_vars['post_type'] );
302
+		if (isset($this->query_vars['post_type'])) {
303
+			$queryable_post_types = get_post_types(array('publicly_queryable' => true));
304
+			if ( ! is_array($this->query_vars['post_type'])) {
305
+				if ( ! in_array($this->query_vars['post_type'], $queryable_post_types))
306
+					unset($this->query_vars['post_type']);
307 307
 			} else {
308
-				$this->query_vars['post_type'] = array_intersect( $this->query_vars['post_type'], $queryable_post_types );
308
+				$this->query_vars['post_type'] = array_intersect($this->query_vars['post_type'], $queryable_post_types);
309 309
 			}
310 310
 		}
311 311
 
312 312
 		// Resolve conflicts between posts with numeric slugs and date archive queries.
313
-		$this->query_vars = wp_resolve_numeric_slug_conflicts( $this->query_vars );
313
+		$this->query_vars = wp_resolve_numeric_slug_conflicts($this->query_vars);
314 314
 
315
-		foreach ( (array) $this->private_query_vars as $var) {
316
-			if ( isset($this->extra_query_vars[$var]) )
315
+		foreach ((array) $this->private_query_vars as $var) {
316
+			if (isset($this->extra_query_vars[$var]))
317 317
 				$this->query_vars[$var] = $this->extra_query_vars[$var];
318 318
 		}
319 319
 
320
-		if ( isset($error) )
320
+		if (isset($error))
321 321
 			$this->query_vars['error'] = $error;
322 322
 
323 323
 		/**
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 		 *
328 328
 		 * @param array $query_vars The array of requested query variables.
329 329
 		 */
330
-		$this->query_vars = apply_filters( 'request', $this->query_vars );
330
+		$this->query_vars = apply_filters('request', $this->query_vars);
331 331
 
332 332
 		/**
333 333
 		 * Fires once all query variables for the current request have been parsed.
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 		 *
337 337
 		 * @param WP &$this Current WordPress environment instance (passed by reference).
338 338
 		 */
339
-		do_action_ref_array( 'parse_request', array( &$this ) );
339
+		do_action_ref_array('parse_request', array(&$this));
340 340
 	}
341 341
 
342 342
 	/**
@@ -352,50 +352,50 @@  discard block
 block discarded – undo
352 352
 		$status = null;
353 353
 		$exit_required = false;
354 354
 
355
-		if ( is_user_logged_in() )
355
+		if (is_user_logged_in())
356 356
 			$headers = array_merge($headers, wp_get_nocache_headers());
357
-		if ( ! empty( $this->query_vars['error'] ) ) {
357
+		if ( ! empty($this->query_vars['error'])) {
358 358
 			$status = (int) $this->query_vars['error'];
359
-			if ( 404 === $status ) {
360
-				if ( ! is_user_logged_in() )
359
+			if (404 === $status) {
360
+				if ( ! is_user_logged_in())
361 361
 					$headers = array_merge($headers, wp_get_nocache_headers());
362
-				$headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset');
363
-			} elseif ( in_array( $status, array( 403, 500, 502, 503 ) ) ) {
362
+				$headers['Content-Type'] = get_option('html_type').'; charset='.get_option('blog_charset');
363
+			} elseif (in_array($status, array(403, 500, 502, 503))) {
364 364
 				$exit_required = true;
365 365
 			}
366
-		} elseif ( empty( $this->query_vars['feed'] ) ) {
367
-			$headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset');
366
+		} elseif (empty($this->query_vars['feed'])) {
367
+			$headers['Content-Type'] = get_option('html_type').'; charset='.get_option('blog_charset');
368 368
 		} else {
369 369
 			// Set the correct content type for feeds
370 370
 			$type = $this->query_vars['feed'];
371
-			if ( 'feed' == $this->query_vars['feed'] ) {
371
+			if ('feed' == $this->query_vars['feed']) {
372 372
 				$type = get_default_feed();
373 373
 			}
374
-			$headers['Content-Type'] = feed_content_type( $type ) . '; charset=' . get_option( 'blog_charset' );
374
+			$headers['Content-Type'] = feed_content_type($type).'; charset='.get_option('blog_charset');
375 375
 
376 376
 			// We're showing a feed, so WP is indeed the only thing that last changed
377
-			if ( !empty($this->query_vars['withcomments'])
378
-				|| false !== strpos( $this->query_vars['feed'], 'comments-' )
379
-				|| ( empty($this->query_vars['withoutcomments'])
380
-					&& ( !empty($this->query_vars['p'])
381
-						|| !empty($this->query_vars['name'])
382
-						|| !empty($this->query_vars['page_id'])
383
-						|| !empty($this->query_vars['pagename'])
384
-						|| !empty($this->query_vars['attachment'])
385
-						|| !empty($this->query_vars['attachment_id'])
377
+			if ( ! empty($this->query_vars['withcomments'])
378
+				|| false !== strpos($this->query_vars['feed'], 'comments-')
379
+				|| (empty($this->query_vars['withoutcomments'])
380
+					&& ( ! empty($this->query_vars['p'])
381
+						|| ! empty($this->query_vars['name'])
382
+						|| ! empty($this->query_vars['page_id'])
383
+						|| ! empty($this->query_vars['pagename'])
384
+						|| ! empty($this->query_vars['attachment'])
385
+						|| ! empty($this->query_vars['attachment_id'])
386 386
 					)
387 387
 				)
388 388
 			)
389 389
 				$wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0).' GMT';
390 390
 			else
391 391
 				$wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT';
392
-			$wp_etag = '"' . md5($wp_last_modified) . '"';
392
+			$wp_etag = '"'.md5($wp_last_modified).'"';
393 393
 			$headers['Last-Modified'] = $wp_last_modified;
394 394
 			$headers['ETag'] = $wp_etag;
395 395
 
396 396
 			// Support for Conditional GET
397 397
 			if (isset($_SERVER['HTTP_IF_NONE_MATCH']))
398
-				$client_etag = wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] );
398
+				$client_etag = wp_unslash($_SERVER['HTTP_IF_NONE_MATCH']);
399 399
 			else $client_etag = false;
400 400
 
401 401
 			$client_last_modified = empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? '' : trim($_SERVER['HTTP_IF_MODIFIED_SINCE']);
@@ -405,9 +405,8 @@  discard block
 block discarded – undo
405 405
 			// Make a timestamp for our most recent modification...
406 406
 			$wp_modified_timestamp = strtotime($wp_last_modified);
407 407
 
408
-			if ( ($client_last_modified && $client_etag) ?
409
-					 (($client_modified_timestamp >= $wp_modified_timestamp) && ($client_etag == $wp_etag)) :
410
-					 (($client_modified_timestamp >= $wp_modified_timestamp) || ($client_etag == $wp_etag)) ) {
408
+			if (($client_last_modified && $client_etag) ?
409
+					 (($client_modified_timestamp >= $wp_modified_timestamp) && ($client_etag == $wp_etag)) : (($client_modified_timestamp >= $wp_modified_timestamp) || ($client_etag == $wp_etag))) {
411 410
 				$status = 304;
412 411
 				$exit_required = true;
413 412
 			}
@@ -421,23 +420,23 @@  discard block
 block discarded – undo
421 420
 		 * @param array $headers The list of headers to be sent.
422 421
 		 * @param WP    $this    Current WordPress environment instance.
423 422
 		 */
424
-		$headers = apply_filters( 'wp_headers', $headers, $this );
423
+		$headers = apply_filters('wp_headers', $headers, $this);
425 424
 
426
-		if ( ! empty( $status ) )
427
-			status_header( $status );
425
+		if ( ! empty($status))
426
+			status_header($status);
428 427
 
429 428
 		// If Last-Modified is set to false, it should not be sent (no-cache situation).
430
-		if ( isset( $headers['Last-Modified'] ) && false === $headers['Last-Modified'] ) {
431
-			unset( $headers['Last-Modified'] );
429
+		if (isset($headers['Last-Modified']) && false === $headers['Last-Modified']) {
430
+			unset($headers['Last-Modified']);
432 431
 
433 432
 			// In PHP 5.3+, make sure we are not sending a Last-Modified header.
434
-			if ( function_exists( 'header_remove' ) ) {
435
-				@header_remove( 'Last-Modified' );
433
+			if (function_exists('header_remove')) {
434
+				@header_remove('Last-Modified');
436 435
 			} else {
437 436
 				// In PHP 5.2, send an empty Last-Modified header, but only as a
438 437
 				// last resort to override a header already sent. #WP23021
439
-				foreach ( headers_list() as $header ) {
440
-					if ( 0 === stripos( $header, 'Last-Modified' ) ) {
438
+				foreach (headers_list() as $header) {
439
+					if (0 === stripos($header, 'Last-Modified')) {
441 440
 						$headers['Last-Modified'] = '';
442 441
 						break;
443 442
 					}
@@ -445,10 +444,10 @@  discard block
 block discarded – undo
445 444
 			}
446 445
 		}
447 446
 
448
-		foreach( (array) $headers as $name => $field_value )
447
+		foreach ((array) $headers as $name => $field_value)
449 448
 			@header("{$name}: {$field_value}");
450 449
 
451
-		if ( $exit_required )
450
+		if ($exit_required)
452 451
 			exit();
453 452
 
454 453
 		/**
@@ -458,7 +457,7 @@  discard block
 block discarded – undo
458 457
 		 *
459 458
 		 * @param WP &$this Current WordPress environment instance (passed by reference).
460 459
 		 */
461
-		do_action_ref_array( 'send_headers', array( &$this ) );
460
+		do_action_ref_array('send_headers', array(&$this));
462 461
 	}
463 462
 
464 463
 	/**
@@ -471,16 +470,16 @@  discard block
 block discarded – undo
471 470
 	 */
472 471
 	public function build_query_string() {
473 472
 		$this->query_string = '';
474
-		foreach ( (array) array_keys($this->query_vars) as $wpvar) {
475
-			if ( '' != $this->query_vars[$wpvar] ) {
473
+		foreach ((array) array_keys($this->query_vars) as $wpvar) {
474
+			if ('' != $this->query_vars[$wpvar]) {
476 475
 				$this->query_string .= (strlen($this->query_string) < 1) ? '' : '&';
477
-				if ( !is_scalar($this->query_vars[$wpvar]) ) // Discard non-scalars.
476
+				if ( ! is_scalar($this->query_vars[$wpvar])) // Discard non-scalars.
478 477
 					continue;
479
-				$this->query_string .= $wpvar . '=' . rawurlencode($this->query_vars[$wpvar]);
478
+				$this->query_string .= $wpvar.'='.rawurlencode($this->query_vars[$wpvar]);
480 479
 			}
481 480
 		}
482 481
 
483
-		if ( has_filter( 'query_string' ) ) {  // Don't bother filtering and parsing if no plugins are hooked in.
482
+		if (has_filter('query_string')) {  // Don't bother filtering and parsing if no plugins are hooked in.
484 483
 			/**
485 484
 			 * Filter the query string before parsing.
486 485
 			 *
@@ -489,7 +488,7 @@  discard block
 block discarded – undo
489 488
 			 *
490 489
 			 * @param string $query_string The query string to modify.
491 490
 			 */
492
-			$this->query_string = apply_filters( 'query_string', $this->query_string );
491
+			$this->query_string = apply_filters('query_string', $this->query_string);
493 492
 			parse_str($this->query_string, $this->query_vars);
494 493
 		}
495 494
 	}
@@ -516,22 +515,22 @@  discard block
 block discarded – undo
516 515
 		global $wp_query;
517 516
 
518 517
 		// Extract updated query vars back into global namespace.
519
-		foreach ( (array) $wp_query->query_vars as $key => $value ) {
520
-			$GLOBALS[ $key ] = $value;
518
+		foreach ((array) $wp_query->query_vars as $key => $value) {
519
+			$GLOBALS[$key] = $value;
521 520
 		}
522 521
 
523 522
 		$GLOBALS['query_string'] = $this->query_string;
524 523
 		$GLOBALS['posts'] = & $wp_query->posts;
525
-		$GLOBALS['post'] = isset( $wp_query->post ) ? $wp_query->post : null;
524
+		$GLOBALS['post'] = isset($wp_query->post) ? $wp_query->post : null;
526 525
 		$GLOBALS['request'] = $wp_query->request;
527 526
 
528
-		if ( $wp_query->is_single() || $wp_query->is_page() ) {
527
+		if ($wp_query->is_single() || $wp_query->is_page()) {
529 528
 			$GLOBALS['more']   = 1;
530 529
 			$GLOBALS['single'] = 1;
531 530
 		}
532 531
 
533
-		if ( $wp_query->is_author() && isset( $wp_query->post ) )
534
-			$GLOBALS['authordata'] = get_userdata( $wp_query->post->post_author );
532
+		if ($wp_query->is_author() && isset($wp_query->post))
533
+			$GLOBALS['authordata'] = get_userdata($wp_query->post->post_author);
535 534
 	}
536 535
 
537 536
 	/**
@@ -573,41 +572,41 @@  discard block
 block discarded – undo
573 572
 		global $wp_query;
574 573
 
575 574
 		// If we've already issued a 404, bail.
576
-		if ( is_404() )
575
+		if (is_404())
577 576
 			return;
578 577
 
579 578
 		// Never 404 for the admin, robots, or if we found posts.
580
-		if ( is_admin() || is_robots() || $wp_query->posts ) {
581
-			status_header( 200 );
579
+		if (is_admin() || is_robots() || $wp_query->posts) {
580
+			status_header(200);
582 581
 			return;
583 582
 		}
584 583
 
585 584
 		// We will 404 for paged queries, as no posts were found.
586
-		if ( ! is_paged() ) {
585
+		if ( ! is_paged()) {
587 586
 
588 587
 			// Don't 404 for authors without posts as long as they matched an author on this site.
589
-			$author = get_query_var( 'author' );
590
-			if ( is_author() && is_numeric( $author ) && $author > 0 && is_user_member_of_blog( $author ) ) {
591
-				status_header( 200 );
588
+			$author = get_query_var('author');
589
+			if (is_author() && is_numeric($author) && $author > 0 && is_user_member_of_blog($author)) {
590
+				status_header(200);
592 591
 				return;
593 592
 			}
594 593
 
595 594
 			// Don't 404 for these queries if they matched an object.
596
-			if ( ( is_tag() || is_category() || is_tax() || is_post_type_archive() ) && get_queried_object() ) {
597
-				status_header( 200 );
595
+			if ((is_tag() || is_category() || is_tax() || is_post_type_archive()) && get_queried_object()) {
596
+				status_header(200);
598 597
 				return;
599 598
 			}
600 599
 
601 600
 			// Don't 404 for these queries either.
602
-			if ( is_home() || is_search() || is_feed() ) {
603
-				status_header( 200 );
601
+			if (is_home() || is_search() || is_feed()) {
602
+				status_header(200);
604 603
 				return;
605 604
 			}
606 605
 		}
607 606
 
608 607
 		// Guess it's time to 404.
609 608
 		$wp_query->set_404();
610
-		status_header( 404 );
609
+		status_header(404);
611 610
 		nocache_headers();
612 611
 	}
613 612
 
@@ -637,7 +636,7 @@  discard block
 block discarded – undo
637 636
 		 *
638 637
 		 * @param WP &$this Current WordPress environment instance (passed by reference).
639 638
 		 */
640
-		do_action_ref_array( 'wp', array( &$this ) );
639
+		do_action_ref_array('wp', array(&$this));
641 640
 	}
642 641
 }
643 642
 
@@ -727,6 +726,6 @@  discard block
 block discarded – undo
727 726
 	 */
728 727
 	public function callback($matches) {
729 728
 		$index = intval(substr($matches[0], 9, -1));
730
-		return ( isset( $this->_matches[$index] ) ? urlencode($this->_matches[$index]) : '' );
729
+		return (isset($this->_matches[$index]) ? urlencode($this->_matches[$index]) : '');
731 730
 	}
732 731
 }
Please login to merge, or discard this patch.
Braces   +79 added lines, -54 removed lines patch added patch discarded remove patch
@@ -91,8 +91,9 @@  discard block
 block discarded – undo
91 91
 	 * @param string $qv Query variable name.
92 92
 	 */
93 93
 	public function add_query_var($qv) {
94
-		if ( !in_array($qv, $this->public_query_vars) )
95
-			$this->public_query_vars[] = $qv;
94
+		if ( !in_array($qv, $this->public_query_vars) ) {
95
+					$this->public_query_vars[] = $qv;
96
+		}
96 97
 	}
97 98
 
98 99
 	/**
@@ -131,8 +132,9 @@  discard block
 block discarded – undo
131 132
 		 * @param WP           $this             Current WordPress environment instance.
132 133
 		 * @param array|string $extra_query_vars Extra passed query variables.
133 134
 		 */
134
-		if ( ! apply_filters( 'do_parse_request', true, $this, $extra_query_vars ) )
135
-			return;
135
+		if ( ! apply_filters( 'do_parse_request', true, $this, $extra_query_vars ) ) {
136
+					return;
137
+		}
136 138
 
137 139
 		$this->query_vars = array();
138 140
 		$post_type_query_vars = array();
@@ -182,8 +184,9 @@  discard block
 block discarded – undo
182 184
 				$request = $pathinfo;
183 185
 			} else {
184 186
 				// If the request uri is the index, blank it out so that we don't try to match it against a rule.
185
-				if ( $req_uri == $wp_rewrite->index )
186
-					$req_uri = '';
187
+				if ( $req_uri == $wp_rewrite->index ) {
188
+									$req_uri = '';
189
+				}
187 190
 				$request = $req_uri;
188 191
 			}
189 192
 
@@ -201,16 +204,18 @@  discard block
 block discarded – undo
201 204
 			} else {
202 205
 				foreach ( (array) $rewrite as $match => $query ) {
203 206
 					// If the requesting file is the anchor of the match, prepend it to the path info.
204
-					if ( ! empty($req_uri) && strpos($match, $req_uri) === 0 && $req_uri != $request )
205
-						$request_match = $req_uri . '/' . $request;
207
+					if ( ! empty($req_uri) && strpos($match, $req_uri) === 0 && $req_uri != $request ) {
208
+											$request_match = $req_uri . '/' . $request;
209
+					}
206 210
 
207 211
 					if ( preg_match("#^$match#", $request_match, $matches) ||
208 212
 						preg_match("#^$match#", urldecode($request_match), $matches) ) {
209 213
 
210 214
 						if ( $wp_rewrite->use_verbose_page_rules && preg_match( '/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch ) ) {
211 215
 							// This is a verbose page match, let's check to be sure about it.
212
-							if ( ! get_page_by_path( $matches[ $varmatch[1] ] ) )
213
-						 		continue;
216
+							if ( ! get_page_by_path( $matches[ $varmatch[1] ] ) ) {
217
+													 		continue;
218
+							}
214 219
 						}
215 220
 
216 221
 						// Got a match.
@@ -233,16 +238,18 @@  discard block
 block discarded – undo
233 238
 				parse_str($query, $perma_query_vars);
234 239
 
235 240
 				// If we're processing a 404 request, clear the error var since we found something.
236
-				if ( '404' == $error )
237
-					unset( $error, $_GET['error'] );
241
+				if ( '404' == $error ) {
242
+									unset( $error, $_GET['error'] );
243
+				}
238 244
 			}
239 245
 
240 246
 			// If req_uri is empty or if it is a request for ourself, unset error.
241 247
 			if ( empty($request) || $req_uri == $self || strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false ) {
242 248
 				unset( $error, $_GET['error'] );
243 249
 
244
-				if ( isset($perma_query_vars) && strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false )
245
-					unset( $perma_query_vars );
250
+				if ( isset($perma_query_vars) && strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false ) {
251
+									unset( $perma_query_vars );
252
+				}
246 253
 
247 254
 				$this->did_permalink = false;
248 255
 			}
@@ -261,19 +268,21 @@  discard block
 block discarded – undo
261 268
 		 */
262 269
 		$this->public_query_vars = apply_filters( 'query_vars', $this->public_query_vars );
263 270
 
264
-		foreach ( get_post_types( array(), 'objects' ) as $post_type => $t )
265
-			if ( $t->query_var )
271
+		foreach ( get_post_types( array(), 'objects' ) as $post_type => $t ) {
272
+					if ( $t->query_var )
266 273
 				$post_type_query_vars[$t->query_var] = $post_type;
274
+		}
267 275
 
268 276
 		foreach ( $this->public_query_vars as $wpvar ) {
269
-			if ( isset( $this->extra_query_vars[$wpvar] ) )
270
-				$this->query_vars[$wpvar] = $this->extra_query_vars[$wpvar];
271
-			elseif ( isset( $_POST[$wpvar] ) )
272
-				$this->query_vars[$wpvar] = $_POST[$wpvar];
273
-			elseif ( isset( $_GET[$wpvar] ) )
274
-				$this->query_vars[$wpvar] = $_GET[$wpvar];
275
-			elseif ( isset( $perma_query_vars[$wpvar] ) )
276
-				$this->query_vars[$wpvar] = $perma_query_vars[$wpvar];
277
+			if ( isset( $this->extra_query_vars[$wpvar] ) ) {
278
+							$this->query_vars[$wpvar] = $this->extra_query_vars[$wpvar];
279
+			} elseif ( isset( $_POST[$wpvar] ) ) {
280
+							$this->query_vars[$wpvar] = $_POST[$wpvar];
281
+			} elseif ( isset( $_GET[$wpvar] ) ) {
282
+							$this->query_vars[$wpvar] = $_GET[$wpvar];
283
+			} elseif ( isset( $perma_query_vars[$wpvar] ) ) {
284
+							$this->query_vars[$wpvar] = $perma_query_vars[$wpvar];
285
+			}
277 286
 
278 287
 			if ( !empty( $this->query_vars[$wpvar] ) ) {
279 288
 				if ( ! is_array( $this->query_vars[$wpvar] ) ) {
@@ -294,16 +303,18 @@  discard block
 block discarded – undo
294 303
 		}
295 304
 
296 305
 		// Convert urldecoded spaces back into +
297
-		foreach ( get_taxonomies( array() , 'objects' ) as $taxonomy => $t )
298
-			if ( $t->query_var && isset( $this->query_vars[$t->query_var] ) )
306
+		foreach ( get_taxonomies( array() , 'objects' ) as $taxonomy => $t ) {
307
+					if ( $t->query_var && isset( $this->query_vars[$t->query_var] ) )
299 308
 				$this->query_vars[$t->query_var] = str_replace( ' ', '+', $this->query_vars[$t->query_var] );
309
+		}
300 310
 
301 311
 		// Limit publicly queried post_types to those that are publicly_queryable
302 312
 		if ( isset( $this->query_vars['post_type']) ) {
303 313
 			$queryable_post_types = get_post_types( array('publicly_queryable' => true) );
304 314
 			if ( ! is_array( $this->query_vars['post_type'] ) ) {
305
-				if ( ! in_array( $this->query_vars['post_type'], $queryable_post_types ) )
306
-					unset( $this->query_vars['post_type'] );
315
+				if ( ! in_array( $this->query_vars['post_type'], $queryable_post_types ) ) {
316
+									unset( $this->query_vars['post_type'] );
317
+				}
307 318
 			} else {
308 319
 				$this->query_vars['post_type'] = array_intersect( $this->query_vars['post_type'], $queryable_post_types );
309 320
 			}
@@ -313,12 +324,14 @@  discard block
 block discarded – undo
313 324
 		$this->query_vars = wp_resolve_numeric_slug_conflicts( $this->query_vars );
314 325
 
315 326
 		foreach ( (array) $this->private_query_vars as $var) {
316
-			if ( isset($this->extra_query_vars[$var]) )
317
-				$this->query_vars[$var] = $this->extra_query_vars[$var];
327
+			if ( isset($this->extra_query_vars[$var]) ) {
328
+							$this->query_vars[$var] = $this->extra_query_vars[$var];
329
+			}
318 330
 		}
319 331
 
320
-		if ( isset($error) )
321
-			$this->query_vars['error'] = $error;
332
+		if ( isset($error) ) {
333
+					$this->query_vars['error'] = $error;
334
+		}
322 335
 
323 336
 		/**
324 337
 		 * Filter the array of parsed query variables.
@@ -352,13 +365,15 @@  discard block
 block discarded – undo
352 365
 		$status = null;
353 366
 		$exit_required = false;
354 367
 
355
-		if ( is_user_logged_in() )
356
-			$headers = array_merge($headers, wp_get_nocache_headers());
368
+		if ( is_user_logged_in() ) {
369
+					$headers = array_merge($headers, wp_get_nocache_headers());
370
+		}
357 371
 		if ( ! empty( $this->query_vars['error'] ) ) {
358 372
 			$status = (int) $this->query_vars['error'];
359 373
 			if ( 404 === $status ) {
360
-				if ( ! is_user_logged_in() )
361
-					$headers = array_merge($headers, wp_get_nocache_headers());
374
+				if ( ! is_user_logged_in() ) {
375
+									$headers = array_merge($headers, wp_get_nocache_headers());
376
+				}
362 377
 				$headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset');
363 378
 			} elseif ( in_array( $status, array( 403, 500, 502, 503 ) ) ) {
364 379
 				$exit_required = true;
@@ -385,18 +400,21 @@  discard block
 block discarded – undo
385 400
 						|| !empty($this->query_vars['attachment_id'])
386 401
 					)
387 402
 				)
388
-			)
389
-				$wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0).' GMT';
390
-			else
391
-				$wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT';
403
+			) {
404
+							$wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0).' GMT';
405
+			} else {
406
+							$wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT';
407
+			}
392 408
 			$wp_etag = '"' . md5($wp_last_modified) . '"';
393 409
 			$headers['Last-Modified'] = $wp_last_modified;
394 410
 			$headers['ETag'] = $wp_etag;
395 411
 
396 412
 			// Support for Conditional GET
397
-			if (isset($_SERVER['HTTP_IF_NONE_MATCH']))
398
-				$client_etag = wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] );
399
-			else $client_etag = false;
413
+			if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
414
+							$client_etag = wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] );
415
+			} else {
416
+				$client_etag = false;
417
+			}
400 418
 
401 419
 			$client_last_modified = empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? '' : trim($_SERVER['HTTP_IF_MODIFIED_SINCE']);
402 420
 			// If string is empty, return 0. If not, attempt to parse into a timestamp
@@ -423,8 +441,9 @@  discard block
 block discarded – undo
423 441
 		 */
424 442
 		$headers = apply_filters( 'wp_headers', $headers, $this );
425 443
 
426
-		if ( ! empty( $status ) )
427
-			status_header( $status );
444
+		if ( ! empty( $status ) ) {
445
+					status_header( $status );
446
+		}
428 447
 
429 448
 		// If Last-Modified is set to false, it should not be sent (no-cache situation).
430 449
 		if ( isset( $headers['Last-Modified'] ) && false === $headers['Last-Modified'] ) {
@@ -445,11 +464,13 @@  discard block
 block discarded – undo
445 464
 			}
446 465
 		}
447 466
 
448
-		foreach( (array) $headers as $name => $field_value )
449
-			@header("{$name}: {$field_value}");
467
+		foreach( (array) $headers as $name => $field_value ) {
468
+					@header("{$name}: {$field_value}");
469
+		}
450 470
 
451
-		if ( $exit_required )
452
-			exit();
471
+		if ( $exit_required ) {
472
+					exit();
473
+		}
453 474
 
454 475
 		/**
455 476
 		 * Fires once the requested HTTP headers for caching, content type, etc. have been sent.
@@ -474,8 +495,10 @@  discard block
 block discarded – undo
474 495
 		foreach ( (array) array_keys($this->query_vars) as $wpvar) {
475 496
 			if ( '' != $this->query_vars[$wpvar] ) {
476 497
 				$this->query_string .= (strlen($this->query_string) < 1) ? '' : '&';
477
-				if ( !is_scalar($this->query_vars[$wpvar]) ) // Discard non-scalars.
498
+				if ( !is_scalar($this->query_vars[$wpvar]) ) {
499
+					// Discard non-scalars.
478 500
 					continue;
501
+				}
479 502
 				$this->query_string .= $wpvar . '=' . rawurlencode($this->query_vars[$wpvar]);
480 503
 			}
481 504
 		}
@@ -530,8 +553,9 @@  discard block
 block discarded – undo
530 553
 			$GLOBALS['single'] = 1;
531 554
 		}
532 555
 
533
-		if ( $wp_query->is_author() && isset( $wp_query->post ) )
534
-			$GLOBALS['authordata'] = get_userdata( $wp_query->post->post_author );
556
+		if ( $wp_query->is_author() && isset( $wp_query->post ) ) {
557
+					$GLOBALS['authordata'] = get_userdata( $wp_query->post->post_author );
558
+		}
535 559
 	}
536 560
 
537 561
 	/**
@@ -573,8 +597,9 @@  discard block
 block discarded – undo
573 597
 		global $wp_query;
574 598
 
575 599
 		// If we've already issued a 404, bail.
576
-		if ( is_404() )
577
-			return;
600
+		if ( is_404() ) {
601
+					return;
602
+		}
578 603
 
579 604
 		// Never 404 for the admin, robots, or if we found posts.
580 605
 		if ( is_admin() || is_robots() || $wp_query->posts ) {
Please login to merge, or discard this patch.