Completed
Push — master ( a7cd2a...eabd6c )
by Stephen
38:42
created
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   +279 added lines, -279 removed lines patch added patch discarded remove patch
@@ -44,31 +44,31 @@  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 51
 		// Skip useless hooks when the user can't manage nav menus anyway.
52
-		if ( ! current_user_can( 'edit_theme_options' ) ) {
52
+		if ( ! current_user_can('edit_theme_options')) {
53 53
 			return;
54 54
 		}
55 55
 
56
-		add_filter( 'customize_refresh_nonces', array( $this, 'filter_nonces' ) );
57
-		add_action( 'wp_ajax_load-available-menu-items-customizer', array( $this, 'ajax_load_available_items' ) );
58
-		add_action( 'wp_ajax_search-available-menu-items-customizer', array( $this, 'ajax_search_available_items' ) );
59
-		add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
56
+		add_filter('customize_refresh_nonces', array($this, 'filter_nonces'));
57
+		add_action('wp_ajax_load-available-menu-items-customizer', array($this, 'ajax_load_available_items'));
58
+		add_action('wp_ajax_search-available-menu-items-customizer', array($this, 'ajax_search_available_items'));
59
+		add_action('customize_controls_enqueue_scripts', array($this, 'enqueue_scripts'));
60 60
 
61 61
 		// Needs to run after core Navigation section is set up.
62
-		add_action( 'customize_register', array( $this, 'customize_register' ), 11 );
62
+		add_action('customize_register', array($this, 'customize_register'), 11);
63 63
 
64
-		add_filter( 'customize_dynamic_setting_args', array( $this, 'filter_dynamic_setting_args' ), 10, 2 );
65
-		add_filter( 'customize_dynamic_setting_class', array( $this, 'filter_dynamic_setting_class' ), 10, 3 );
66
-		add_action( 'customize_controls_print_footer_scripts', array( $this, 'print_templates' ) );
67
-		add_action( 'customize_controls_print_footer_scripts', array( $this, 'available_items_template' ) );
68
-		add_action( 'customize_preview_init', array( $this, 'customize_preview_init' ) );
64
+		add_filter('customize_dynamic_setting_args', array($this, 'filter_dynamic_setting_args'), 10, 2);
65
+		add_filter('customize_dynamic_setting_class', array($this, 'filter_dynamic_setting_class'), 10, 3);
66
+		add_action('customize_controls_print_footer_scripts', array($this, 'print_templates'));
67
+		add_action('customize_controls_print_footer_scripts', array($this, 'available_items_template'));
68
+		add_action('customize_preview_init', array($this, 'customize_preview_init'));
69 69
 
70 70
 		// Selective Refresh partials.
71
-		add_filter( 'customize_dynamic_partial_args', array( $this, 'customize_dynamic_partial_args' ), 10, 2 );
71
+		add_filter('customize_dynamic_partial_args', array($this, 'customize_dynamic_partial_args'), 10, 2);
72 72
 	}
73 73
 
74 74
 	/**
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
 	 * @param array $nonces Array of nonces.
81 81
 	 * @return array $nonces Modified array of nonces.
82 82
 	 */
83
-	public function filter_nonces( $nonces ) {
84
-		$nonces['customize-menus'] = wp_create_nonce( 'customize-menus' );
83
+	public function filter_nonces($nonces) {
84
+		$nonces['customize-menus'] = wp_create_nonce('customize-menus');
85 85
 		return $nonces;
86 86
 	}
87 87
 
@@ -92,25 +92,25 @@  discard block
 block discarded – undo
92 92
 	 * @access public
93 93
 	 */
94 94
 	public function ajax_load_available_items() {
95
-		check_ajax_referer( 'customize-menus', 'customize-menus-nonce' );
95
+		check_ajax_referer('customize-menus', 'customize-menus-nonce');
96 96
 
97
-		if ( ! current_user_can( 'edit_theme_options' ) ) {
97
+		if ( ! current_user_can('edit_theme_options')) {
98 98
 			wp_die( -1 );
99 99
 		}
100 100
 
101
-		if ( empty( $_POST['type'] ) || empty( $_POST['object'] ) ) {
102
-			wp_send_json_error( 'nav_menus_missing_type_or_object_parameter' );
101
+		if (empty($_POST['type']) || empty($_POST['object'])) {
102
+			wp_send_json_error('nav_menus_missing_type_or_object_parameter');
103 103
 		}
104 104
 
105
-		$type = sanitize_key( $_POST['type'] );
106
-		$object = sanitize_key( $_POST['object'] );
107
-		$page = empty( $_POST['page'] ) ? 0 : absint( $_POST['page'] );
108
-		$items = $this->load_available_items_query( $type, $object, $page );
105
+		$type = sanitize_key($_POST['type']);
106
+		$object = sanitize_key($_POST['object']);
107
+		$page = empty($_POST['page']) ? 0 : absint($_POST['page']);
108
+		$items = $this->load_available_items_query($type, $object, $page);
109 109
 
110
-		if ( is_wp_error( $items ) ) {
111
-			wp_send_json_error( $items->get_error_code() );
110
+		if (is_wp_error($items)) {
111
+			wp_send_json_error($items->get_error_code());
112 112
 		} else {
113
-			wp_send_json_success( array( 'items' => $items ) );
113
+			wp_send_json_success(array('items' => $items));
114 114
 		}
115 115
 	}
116 116
 
@@ -126,62 +126,62 @@  discard block
 block discarded – undo
126 126
 	 * @param int    $page   Optional. The page number used to generate the query offset. Default is '0'.
127 127
 	 * @return WP_Error|array Returns either a WP_Error object or an array of menu items.
128 128
 	 */
129
-	public function load_available_items_query( $type = 'post_type', $object = 'page', $page = 0 ) {
129
+	public function load_available_items_query($type = 'post_type', $object = 'page', $page = 0) {
130 130
 		$items = array();
131 131
 
132
-		if ( 'post_type' === $type ) {
133
-			$post_type = get_post_type_object( $object );
134
-			if ( ! $post_type ) {
135
-				return new WP_Error( 'nav_menus_invalid_post_type' );
132
+		if ('post_type' === $type) {
133
+			$post_type = get_post_type_object($object);
134
+			if ( ! $post_type) {
135
+				return new WP_Error('nav_menus_invalid_post_type');
136 136
 			}
137 137
 
138
-			if ( 0 === $page && 'page' === $object ) {
138
+			if (0 === $page && 'page' === $object) {
139 139
 				// Add "Home" link. Treat as a page, but switch to custom on add.
140 140
 				$items[] = array(
141 141
 					'id'         => 'home',
142
-					'title'      => _x( 'Home', 'nav menu home label' ),
142
+					'title'      => _x('Home', 'nav menu home label'),
143 143
 					'type'       => 'custom',
144
-					'type_label' => __( 'Custom Link' ),
144
+					'type_label' => __('Custom Link'),
145 145
 					'object'     => '',
146 146
 					'url'        => home_url(),
147 147
 				);
148
-			} elseif ( 'post' !== $object && 0 === $page && $post_type->has_archive ) {
148
+			} elseif ('post' !== $object && 0 === $page && $post_type->has_archive) {
149 149
 				// Add a post type archive link.
150 150
 				$items[] = array(
151
-					'id'         => $object . '-archive',
151
+					'id'         => $object.'-archive',
152 152
 					'title'      => $post_type->labels->archives,
153 153
 					'type'       => 'post_type_archive',
154
-					'type_label' => __( 'Post Type Archive' ),
154
+					'type_label' => __('Post Type Archive'),
155 155
 					'object'     => $object,
156
-					'url'        => get_post_type_archive_link( $object ),
156
+					'url'        => get_post_type_archive_link($object),
157 157
 				);
158 158
 			}
159 159
 
160
-			$posts = get_posts( array(
160
+			$posts = get_posts(array(
161 161
 				'numberposts' => 10,
162 162
 				'offset'      => 10 * $page,
163 163
 				'orderby'     => 'date',
164 164
 				'order'       => 'DESC',
165 165
 				'post_type'   => $object,
166
-			) );
167
-			foreach ( $posts as $post ) {
166
+			));
167
+			foreach ($posts as $post) {
168 168
 				$post_title = $post->post_title;
169
-				if ( '' === $post_title ) {
169
+				if ('' === $post_title) {
170 170
 					/* translators: %d: ID of a post */
171
-					$post_title = sprintf( __( '#%d (no title)' ), $post->ID );
171
+					$post_title = sprintf(__('#%d (no title)'), $post->ID);
172 172
 				}
173 173
 				$items[] = array(
174 174
 					'id'         => "post-{$post->ID}",
175
-					'title'      => html_entity_decode( $post_title, ENT_QUOTES, get_bloginfo( 'charset' ) ),
175
+					'title'      => html_entity_decode($post_title, ENT_QUOTES, get_bloginfo('charset')),
176 176
 					'type'       => 'post_type',
177
-					'type_label' => get_post_type_object( $post->post_type )->labels->singular_name,
177
+					'type_label' => get_post_type_object($post->post_type)->labels->singular_name,
178 178
 					'object'     => $post->post_type,
179
-					'object_id'  => intval( $post->ID ),
180
-					'url'        => get_permalink( intval( $post->ID ) ),
179
+					'object_id'  => intval($post->ID),
180
+					'url'        => get_permalink(intval($post->ID)),
181 181
 				);
182 182
 			}
183
-		} elseif ( 'taxonomy' === $type ) {
184
-			$terms = get_terms( $object, array(
183
+		} elseif ('taxonomy' === $type) {
184
+			$terms = get_terms($object, array(
185 185
 				'child_of'     => 0,
186 186
 				'exclude'      => '',
187 187
 				'hide_empty'   => false,
@@ -192,20 +192,20 @@  discard block
 block discarded – undo
192 192
 				'order'        => 'DESC',
193 193
 				'orderby'      => 'count',
194 194
 				'pad_counts'   => false,
195
-			) );
196
-			if ( is_wp_error( $terms ) ) {
195
+			));
196
+			if (is_wp_error($terms)) {
197 197
 				return $terms;
198 198
 			}
199 199
 
200
-			foreach ( $terms as $term ) {
200
+			foreach ($terms as $term) {
201 201
 				$items[] = array(
202 202
 					'id'         => "term-{$term->term_id}",
203
-					'title'      => html_entity_decode( $term->name, ENT_QUOTES, get_bloginfo( 'charset' ) ),
203
+					'title'      => html_entity_decode($term->name, ENT_QUOTES, get_bloginfo('charset')),
204 204
 					'type'       => 'taxonomy',
205
-					'type_label' => get_taxonomy( $term->taxonomy )->labels->singular_name,
205
+					'type_label' => get_taxonomy($term->taxonomy)->labels->singular_name,
206 206
 					'object'     => $term->taxonomy,
207
-					'object_id'  => intval( $term->term_id ),
208
-					'url'        => get_term_link( intval( $term->term_id ), $term->taxonomy ),
207
+					'object_id'  => intval($term->term_id),
208
+					'url'        => get_term_link(intval($term->term_id), $term->taxonomy),
209 209
 				);
210 210
 			}
211 211
 		}
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 		 * @param string $object The object name.
221 221
 		 * @param int    $page   The current page number.
222 222
 		 */
223
-		$items = apply_filters( 'customize_nav_menu_available_items', $items, $type, $object, $page );
223
+		$items = apply_filters('customize_nav_menu_available_items', $items, $type, $object, $page);
224 224
 
225 225
 		return $items;
226 226
 	}
@@ -232,28 +232,28 @@  discard block
 block discarded – undo
232 232
 	 * @access public
233 233
 	 */
234 234
 	public function ajax_search_available_items() {
235
-		check_ajax_referer( 'customize-menus', 'customize-menus-nonce' );
235
+		check_ajax_referer('customize-menus', 'customize-menus-nonce');
236 236
 
237
-		if ( ! current_user_can( 'edit_theme_options' ) ) {
237
+		if ( ! current_user_can('edit_theme_options')) {
238 238
 			wp_die( -1 );
239 239
 		}
240 240
 
241
-		if ( empty( $_POST['search'] ) ) {
242
-			wp_send_json_error( 'nav_menus_missing_search_parameter' );
241
+		if (empty($_POST['search'])) {
242
+			wp_send_json_error('nav_menus_missing_search_parameter');
243 243
 		}
244 244
 
245
-		$p = isset( $_POST['page'] ) ? absint( $_POST['page'] ) : 0;
246
-		if ( $p < 1 ) {
245
+		$p = isset($_POST['page']) ? absint($_POST['page']) : 0;
246
+		if ($p < 1) {
247 247
 			$p = 1;
248 248
 		}
249 249
 
250
-		$s = sanitize_text_field( wp_unslash( $_POST['search'] ) );
251
-		$items = $this->search_available_items_query( array( 'pagenum' => $p, 's' => $s ) );
250
+		$s = sanitize_text_field(wp_unslash($_POST['search']));
251
+		$items = $this->search_available_items_query(array('pagenum' => $p, 's' => $s));
252 252
 
253
-		if ( empty( $items ) ) {
254
-			wp_send_json_error( array( 'message' => __( 'No results found.' ) ) );
253
+		if (empty($items)) {
254
+			wp_send_json_error(array('message' => __('No results found.')));
255 255
 		} else {
256
-			wp_send_json_success( array( 'items' => $items ) );
256
+			wp_send_json_success(array('items' => $items));
257 257
 		}
258 258
 	}
259 259
 
@@ -268,12 +268,12 @@  discard block
 block discarded – undo
268 268
 	 * @param array $args Optional. Accepts 'pagenum' and 's' (search) arguments.
269 269
 	 * @return array Menu items.
270 270
 	 */
271
-	public function search_available_items_query( $args = array() ) {
271
+	public function search_available_items_query($args = array()) {
272 272
 		$items = array();
273 273
 
274
-		$post_type_objects = get_post_types( array( 'show_in_nav_menus' => true ), 'objects' );
274
+		$post_type_objects = get_post_types(array('show_in_nav_menus' => true), 'objects');
275 275
 		$query = array(
276
-			'post_type'              => array_keys( $post_type_objects ),
276
+			'post_type'              => array_keys($post_type_objects),
277 277
 			'suppress_filters'       => true,
278 278
 			'update_post_term_cache' => false,
279 279
 			'update_post_meta_cache' => false,
@@ -281,55 +281,55 @@  discard block
 block discarded – undo
281 281
 			'posts_per_page'         => 20,
282 282
 		);
283 283
 
284
-		$args['pagenum'] = isset( $args['pagenum'] ) ? absint( $args['pagenum'] ) : 1;
285
-		$query['offset'] = $args['pagenum'] > 1 ? $query['posts_per_page'] * ( $args['pagenum'] - 1 ) : 0;
284
+		$args['pagenum'] = isset($args['pagenum']) ? absint($args['pagenum']) : 1;
285
+		$query['offset'] = $args['pagenum'] > 1 ? $query['posts_per_page'] * ($args['pagenum'] - 1) : 0;
286 286
 
287
-		if ( isset( $args['s'] ) ) {
287
+		if (isset($args['s'])) {
288 288
 			$query['s'] = $args['s'];
289 289
 		}
290 290
 
291 291
 		// Query posts.
292
-		$get_posts = new WP_Query( $query );
292
+		$get_posts = new WP_Query($query);
293 293
 
294 294
 		// Check if any posts were found.
295
-		if ( $get_posts->post_count ) {
296
-			foreach ( $get_posts->posts as $post ) {
295
+		if ($get_posts->post_count) {
296
+			foreach ($get_posts->posts as $post) {
297 297
 				$post_title = $post->post_title;
298
-				if ( '' === $post_title ) {
298
+				if ('' === $post_title) {
299 299
 					/* translators: %d: ID of a post */
300
-					$post_title = sprintf( __( '#%d (no title)' ), $post->ID );
300
+					$post_title = sprintf(__('#%d (no title)'), $post->ID);
301 301
 				}
302 302
 				$items[] = array(
303
-					'id'         => 'post-' . $post->ID,
304
-					'title'      => html_entity_decode( $post_title, ENT_QUOTES, get_bloginfo( 'charset' ) ),
303
+					'id'         => 'post-'.$post->ID,
304
+					'title'      => html_entity_decode($post_title, ENT_QUOTES, get_bloginfo('charset')),
305 305
 					'type'       => 'post_type',
306
-					'type_label' => $post_type_objects[ $post->post_type ]->labels->singular_name,
306
+					'type_label' => $post_type_objects[$post->post_type]->labels->singular_name,
307 307
 					'object'     => $post->post_type,
308
-					'object_id'  => intval( $post->ID ),
309
-					'url'        => get_permalink( intval( $post->ID ) ),
308
+					'object_id'  => intval($post->ID),
309
+					'url'        => get_permalink(intval($post->ID)),
310 310
 				);
311 311
 			}
312 312
 		}
313 313
 
314 314
 		// Query taxonomy terms.
315
-		$taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'names' );
316
-		$terms = get_terms( $taxonomies, array(
315
+		$taxonomies = get_taxonomies(array('show_in_nav_menus' => true), 'names');
316
+		$terms = get_terms($taxonomies, array(
317 317
 			'name__like' => $args['s'],
318 318
 			'number'     => 20,
319 319
 			'offset'     => 20 * ($args['pagenum'] - 1),
320
-		) );
320
+		));
321 321
 
322 322
 		// Check if any taxonomies were found.
323
-		if ( ! empty( $terms ) ) {
324
-			foreach ( $terms as $term ) {
323
+		if ( ! empty($terms)) {
324
+			foreach ($terms as $term) {
325 325
 				$items[] = array(
326
-					'id'         => 'term-' . $term->term_id,
327
-					'title'      => html_entity_decode( $term->name, ENT_QUOTES, get_bloginfo( 'charset' ) ),
326
+					'id'         => 'term-'.$term->term_id,
327
+					'title'      => html_entity_decode($term->name, ENT_QUOTES, get_bloginfo('charset')),
328 328
 					'type'       => 'taxonomy',
329
-					'type_label' => get_taxonomy( $term->taxonomy )->labels->singular_name,
329
+					'type_label' => get_taxonomy($term->taxonomy)->labels->singular_name,
330 330
 					'object'     => $term->taxonomy,
331
-					'object_id'  => intval( $term->term_id ),
332
-					'url'        => get_term_link( intval( $term->term_id ), $term->taxonomy ),
331
+					'object_id'  => intval($term->term_id),
332
+					'url'        => get_term_link(intval($term->term_id), $term->taxonomy),
333 333
 				);
334 334
 			}
335 335
 		}
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 		 * @param array $items The array of menu items.
343 343
 		 * @param array $args  Includes 'pagenum' and 's' (search) arguments.
344 344
 		 */
345
-		$items = apply_filters( 'customize_nav_menu_searched_items', $items, $args );
345
+		$items = apply_filters('customize_nav_menu_searched_items', $items, $args);
346 346
 
347 347
 		return $items;
348 348
 	}
@@ -354,46 +354,46 @@  discard block
 block discarded – undo
354 354
 	 * @access public
355 355
 	 */
356 356
 	public function enqueue_scripts() {
357
-		wp_enqueue_style( 'customize-nav-menus' );
358
-		wp_enqueue_script( 'customize-nav-menus' );
357
+		wp_enqueue_style('customize-nav-menus');
358
+		wp_enqueue_script('customize-nav-menus');
359 359
 
360
-		$temp_nav_menu_setting      = new WP_Customize_Nav_Menu_Setting( $this->manager, 'nav_menu[-1]' );
361
-		$temp_nav_menu_item_setting = new WP_Customize_Nav_Menu_Item_Setting( $this->manager, 'nav_menu_item[-1]' );
360
+		$temp_nav_menu_setting      = new WP_Customize_Nav_Menu_Setting($this->manager, 'nav_menu[-1]');
361
+		$temp_nav_menu_item_setting = new WP_Customize_Nav_Menu_Item_Setting($this->manager, 'nav_menu_item[-1]');
362 362
 
363 363
 		// Pass data to JS.
364 364
 		$settings = array(
365 365
 			'allMenus'             => wp_get_nav_menus(),
366 366
 			'itemTypes'            => $this->available_item_types(),
367 367
 			'l10n'                 => array(
368
-				'untitled'          => _x( '(no label)', 'missing menu item navigation label' ),
369
-				'unnamed'           => _x( '(unnamed)', 'Missing menu name.' ),
370
-				'custom_label'      => __( 'Custom Link' ),
368
+				'untitled'          => _x('(no label)', 'missing menu item navigation label'),
369
+				'unnamed'           => _x('(unnamed)', 'Missing menu name.'),
370
+				'custom_label'      => __('Custom Link'),
371 371
 				/* translators: %s: menu location */
372
-				'menuLocation'      => _x( '(Currently set to: %s)', 'menu' ),
373
-				'menuNameLabel'     => __( 'Menu Name' ),
374
-				'itemAdded'         => __( 'Menu item added' ),
375
-				'itemDeleted'       => __( 'Menu item deleted' ),
376
-				'menuAdded'         => __( 'Menu created' ),
377
-				'menuDeleted'       => __( 'Menu deleted' ),
378
-				'movedUp'           => __( 'Menu item moved up' ),
379
-				'movedDown'         => __( 'Menu item moved down' ),
380
-				'movedLeft'         => __( 'Menu item moved out of submenu' ),
381
-				'movedRight'        => __( 'Menu item is now a sub-item' ),
372
+				'menuLocation'      => _x('(Currently set to: %s)', 'menu'),
373
+				'menuNameLabel'     => __('Menu Name'),
374
+				'itemAdded'         => __('Menu item added'),
375
+				'itemDeleted'       => __('Menu item deleted'),
376
+				'menuAdded'         => __('Menu created'),
377
+				'menuDeleted'       => __('Menu deleted'),
378
+				'movedUp'           => __('Menu item moved up'),
379
+				'movedDown'         => __('Menu item moved down'),
380
+				'movedLeft'         => __('Menu item moved out of submenu'),
381
+				'movedRight'        => __('Menu item is now a sub-item'),
382 382
 				/* translators: &#9656; is the unicode right-pointing triangle, and %s is the section title in the Customizer */
383
-				'customizingMenus'  => sprintf( __( 'Customizing &#9656; %s' ), esc_html( $this->manager->get_panel( 'nav_menus' )->title ) ),
383
+				'customizingMenus'  => sprintf(__('Customizing &#9656; %s'), esc_html($this->manager->get_panel('nav_menus')->title)),
384 384
 				/* translators: %s: title of menu item which is invalid */
385
-				'invalidTitleTpl'   => __( '%s (Invalid)' ),
385
+				'invalidTitleTpl'   => __('%s (Invalid)'),
386 386
 				/* translators: %s: title of menu item in draft status */
387
-				'pendingTitleTpl'   => __( '%s (Pending)' ),
388
-				'itemsFound'        => __( 'Number of items found: %d' ),
389
-				'itemsFoundMore'    => __( 'Additional items found: %d' ),
390
-				'itemsLoadingMore'  => __( 'Loading more results... please wait.' ),
391
-				'reorderModeOn'     => __( 'Reorder mode enabled' ),
392
-				'reorderModeOff'    => __( 'Reorder mode closed' ),
393
-				'reorderLabelOn'    => esc_attr__( 'Reorder menu items' ),
394
-				'reorderLabelOff'   => esc_attr__( 'Close reorder mode' ),
387
+				'pendingTitleTpl'   => __('%s (Pending)'),
388
+				'itemsFound'        => __('Number of items found: %d'),
389
+				'itemsFoundMore'    => __('Additional items found: %d'),
390
+				'itemsLoadingMore'  => __('Loading more results... please wait.'),
391
+				'reorderModeOn'     => __('Reorder mode enabled'),
392
+				'reorderModeOff'    => __('Reorder mode closed'),
393
+				'reorderLabelOn'    => esc_attr__('Reorder menu items'),
394
+				'reorderLabelOff'   => esc_attr__('Close reorder mode'),
395 395
 			),
396
-			'settingTransport'     => isset( $this->manager->selective_refresh ) ? 'postMessage' : 'refresh',
396
+			'settingTransport'     => isset($this->manager->selective_refresh) ? 'postMessage' : 'refresh',
397 397
 			'phpIntMax'            => PHP_INT_MAX,
398 398
 			'defaultSettingValues' => array(
399 399
 				'nav_menu'      => $temp_nav_menu_setting->default,
@@ -402,29 +402,29 @@  discard block
 block discarded – undo
402 402
 			'locationSlugMappedToName' => get_registered_nav_menus(),
403 403
 		);
404 404
 
405
-		$data = sprintf( 'var _wpCustomizeNavMenusSettings = %s;', wp_json_encode( $settings ) );
406
-		wp_scripts()->add_data( 'customize-nav-menus', 'data', $data );
405
+		$data = sprintf('var _wpCustomizeNavMenusSettings = %s;', wp_json_encode($settings));
406
+		wp_scripts()->add_data('customize-nav-menus', 'data', $data);
407 407
 
408 408
 		// This is copied from nav-menus.php, and it has an unfortunate object name of `menus`.
409 409
 		$nav_menus_l10n = array(
410 410
 			'oneThemeLocationNoMenus' => null,
411
-			'moveUp'       => __( 'Move up one' ),
412
-			'moveDown'     => __( 'Move down one' ),
413
-			'moveToTop'    => __( 'Move to the top' ),
411
+			'moveUp'       => __('Move up one'),
412
+			'moveDown'     => __('Move down one'),
413
+			'moveToTop'    => __('Move to the top'),
414 414
 			/* translators: %s: previous item name */
415
-			'moveUnder'    => __( 'Move under %s' ),
415
+			'moveUnder'    => __('Move under %s'),
416 416
 			/* translators: %s: previous item name */
417
-			'moveOutFrom'  => __( 'Move out from under %s' ),
417
+			'moveOutFrom'  => __('Move out from under %s'),
418 418
 			/* translators: %s: previous item name */
419
-			'under'        => __( 'Under %s' ),
419
+			'under'        => __('Under %s'),
420 420
 			/* translators: %s: previous item name */
421
-			'outFrom'      => __( 'Out from under %s' ),
421
+			'outFrom'      => __('Out from under %s'),
422 422
 			/* translators: 1: item name, 2: item position, 3: total number of items */
423
-			'menuFocus'    => __( '%1$s. Menu item %2$d of %3$d.' ),
423
+			'menuFocus'    => __('%1$s. Menu item %2$d of %3$d.'),
424 424
 			/* translators: 1: item name, 2: item position, 3: parent item name */
425
-			'subMenuFocus' => __( '%1$s. Sub item number %2$d under %3$s.' ),
425
+			'subMenuFocus' => __('%1$s. Sub item number %2$d under %3$s.'),
426 426
 		);
427
-		wp_localize_script( 'nav-menu', 'menus', $nav_menus_l10n );
427
+		wp_localize_script('nav-menu', 'menus', $nav_menus_l10n);
428 428
 	}
429 429
 
430 430
 	/**
@@ -441,16 +441,16 @@  discard block
 block discarded – undo
441 441
 	 * @param string      $setting_id   ID for dynamic setting, usually coming from `$_POST['customized']`.
442 442
 	 * @return array|false
443 443
 	 */
444
-	public function filter_dynamic_setting_args( $setting_args, $setting_id ) {
445
-		if ( preg_match( WP_Customize_Nav_Menu_Setting::ID_PATTERN, $setting_id ) ) {
444
+	public function filter_dynamic_setting_args($setting_args, $setting_id) {
445
+		if (preg_match(WP_Customize_Nav_Menu_Setting::ID_PATTERN, $setting_id)) {
446 446
 			$setting_args = array(
447 447
 				'type'      => WP_Customize_Nav_Menu_Setting::TYPE,
448
-				'transport' => isset( $this->manager->selective_refresh ) ? 'postMessage' : 'refresh',
448
+				'transport' => isset($this->manager->selective_refresh) ? 'postMessage' : 'refresh',
449 449
 			);
450
-		} elseif ( preg_match( WP_Customize_Nav_Menu_Item_Setting::ID_PATTERN, $setting_id ) ) {
450
+		} elseif (preg_match(WP_Customize_Nav_Menu_Item_Setting::ID_PATTERN, $setting_id)) {
451 451
 			$setting_args = array(
452 452
 				'type'      => WP_Customize_Nav_Menu_Item_Setting::TYPE,
453
-				'transport' => isset( $this->manager->selective_refresh ) ? 'postMessage' : 'refresh',
453
+				'transport' => isset($this->manager->selective_refresh) ? 'postMessage' : 'refresh',
454 454
 			);
455 455
 		}
456 456
 		return $setting_args;
@@ -467,12 +467,12 @@  discard block
 block discarded – undo
467 467
 	 * @param array  $setting_args  WP_Customize_Setting or a subclass.
468 468
 	 * @return string
469 469
 	 */
470
-	public function filter_dynamic_setting_class( $setting_class, $setting_id, $setting_args ) {
471
-		unset( $setting_id );
470
+	public function filter_dynamic_setting_class($setting_class, $setting_id, $setting_args) {
471
+		unset($setting_id);
472 472
 
473
-		if ( ! empty( $setting_args['type'] ) && WP_Customize_Nav_Menu_Setting::TYPE === $setting_args['type'] ) {
473
+		if ( ! empty($setting_args['type']) && WP_Customize_Nav_Menu_Setting::TYPE === $setting_args['type']) {
474 474
 			$setting_class = 'WP_Customize_Nav_Menu_Setting';
475
-		} elseif ( ! empty( $setting_args['type'] ) && WP_Customize_Nav_Menu_Item_Setting::TYPE === $setting_args['type'] ) {
475
+		} elseif ( ! empty($setting_args['type']) && WP_Customize_Nav_Menu_Item_Setting::TYPE === $setting_args['type']) {
476 476
 			$setting_class = 'WP_Customize_Nav_Menu_Item_Setting';
477 477
 		}
478 478
 		return $setting_class;
@@ -487,140 +487,140 @@  discard block
 block discarded – undo
487 487
 	public function customize_register() {
488 488
 
489 489
 		// Require JS-rendered control types.
490
-		$this->manager->register_panel_type( 'WP_Customize_Nav_Menus_Panel' );
491
-		$this->manager->register_control_type( 'WP_Customize_Nav_Menu_Control' );
492
-		$this->manager->register_control_type( 'WP_Customize_Nav_Menu_Name_Control' );
493
-		$this->manager->register_control_type( 'WP_Customize_Nav_Menu_Auto_Add_Control' );
494
-		$this->manager->register_control_type( 'WP_Customize_Nav_Menu_Item_Control' );
490
+		$this->manager->register_panel_type('WP_Customize_Nav_Menus_Panel');
491
+		$this->manager->register_control_type('WP_Customize_Nav_Menu_Control');
492
+		$this->manager->register_control_type('WP_Customize_Nav_Menu_Name_Control');
493
+		$this->manager->register_control_type('WP_Customize_Nav_Menu_Auto_Add_Control');
494
+		$this->manager->register_control_type('WP_Customize_Nav_Menu_Item_Control');
495 495
 
496 496
 		// Create a panel for Menus.
497
-		$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>';
498
-		if ( current_theme_supports( 'widgets' ) ) {
499
-			$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>';
497
+		$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>';
498
+		if (current_theme_supports('widgets')) {
499
+			$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>';
500 500
 		} else {
501
-			$description .= '<p>' . __( 'Menus can be displayed in locations defined by your theme.' ) . '</p>';
501
+			$description .= '<p>'.__('Menus can be displayed in locations defined by your theme.').'</p>';
502 502
 		}
503
-		$this->manager->add_panel( new WP_Customize_Nav_Menus_Panel( $this->manager, 'nav_menus', array(
504
-			'title'       => __( 'Menus' ),
503
+		$this->manager->add_panel(new WP_Customize_Nav_Menus_Panel($this->manager, 'nav_menus', array(
504
+			'title'       => __('Menus'),
505 505
 			'description' => $description,
506 506
 			'priority'    => 100,
507 507
 			// 'theme_supports' => 'menus|widgets', @todo allow multiple theme supports
508
-		) ) );
508
+		)));
509 509
 		$menus = wp_get_nav_menus();
510 510
 
511 511
 		// Menu locations.
512 512
 		$locations     = get_registered_nav_menus();
513
-		$num_locations = count( array_keys( $locations ) );
514
-		if ( 1 == $num_locations ) {
515
-			$description = '<p>' . __( 'Your theme supports one menu. Select which menu you would like to use.' );
513
+		$num_locations = count(array_keys($locations));
514
+		if (1 == $num_locations) {
515
+			$description = '<p>'.__('Your theme supports one menu. Select which menu you would like to use.');
516 516
 		} else {
517
-			$description = '<p>' . sprintf( _n( 'Your theme supports %s menu. Select which menu appears in each location.', 'Your theme supports %s menus. Select which menu appears in each location.', $num_locations ), number_format_i18n( $num_locations ) );
517
+			$description = '<p>'.sprintf(_n('Your theme supports %s menu. Select which menu appears in each location.', 'Your theme supports %s menus. Select which menu appears in each location.', $num_locations), number_format_i18n($num_locations));
518 518
 		}
519
-		$description  .= '</p><p>' . __( 'You can also place menus in widget areas with the Custom Menu widget.' ) . '</p>';
519
+		$description .= '</p><p>'.__('You can also place menus in widget areas with the Custom Menu widget.').'</p>';
520 520
 
521
-		$this->manager->add_section( 'menu_locations', array(
522
-			'title'       => __( 'Menu Locations' ),
521
+		$this->manager->add_section('menu_locations', array(
522
+			'title'       => __('Menu Locations'),
523 523
 			'panel'       => 'nav_menus',
524 524
 			'priority'    => 5,
525 525
 			'description' => $description,
526
-		) );
526
+		));
527 527
 
528
-		$choices = array( '0' => __( '&mdash; Select &mdash;' ) );
529
-		foreach ( $menus as $menu ) {
530
-			$choices[ $menu->term_id ] = wp_html_excerpt( $menu->name, 40, '&hellip;' );
528
+		$choices = array('0' => __('&mdash; Select &mdash;'));
529
+		foreach ($menus as $menu) {
530
+			$choices[$menu->term_id] = wp_html_excerpt($menu->name, 40, '&hellip;');
531 531
 		}
532 532
 
533
-		foreach ( $locations as $location => $description ) {
533
+		foreach ($locations as $location => $description) {
534 534
 			$setting_id = "nav_menu_locations[{$location}]";
535 535
 
536
-			$setting = $this->manager->get_setting( $setting_id );
537
-			if ( $setting ) {
538
-				$setting->transport = isset( $this->manager->selective_refresh ) ? 'postMessage' : 'refresh';
539
-				remove_filter( "customize_sanitize_{$setting_id}", 'absint' );
540
-				add_filter( "customize_sanitize_{$setting_id}", array( $this, 'intval_base10' ) );
536
+			$setting = $this->manager->get_setting($setting_id);
537
+			if ($setting) {
538
+				$setting->transport = isset($this->manager->selective_refresh) ? 'postMessage' : 'refresh';
539
+				remove_filter("customize_sanitize_{$setting_id}", 'absint');
540
+				add_filter("customize_sanitize_{$setting_id}", array($this, 'intval_base10'));
541 541
 			} else {
542
-				$this->manager->add_setting( $setting_id, array(
543
-					'sanitize_callback' => array( $this, 'intval_base10' ),
542
+				$this->manager->add_setting($setting_id, array(
543
+					'sanitize_callback' => array($this, 'intval_base10'),
544 544
 					'theme_supports'    => 'menus',
545 545
 					'type'              => 'theme_mod',
546
-					'transport'         => isset( $this->manager->selective_refresh ) ? 'postMessage' : 'refresh',
546
+					'transport'         => isset($this->manager->selective_refresh) ? 'postMessage' : 'refresh',
547 547
 					'default'           => 0,
548
-				) );
548
+				));
549 549
 			}
550 550
 
551
-			$this->manager->add_control( new WP_Customize_Nav_Menu_Location_Control( $this->manager, $setting_id, array(
551
+			$this->manager->add_control(new WP_Customize_Nav_Menu_Location_Control($this->manager, $setting_id, array(
552 552
 				'label'       => $description,
553 553
 				'location_id' => $location,
554 554
 				'section'     => 'menu_locations',
555 555
 				'choices'     => $choices,
556
-			) ) );
556
+			)));
557 557
 		}
558 558
 
559 559
 		// Register each menu as a Customizer section, and add each menu item to each menu.
560
-		foreach ( $menus as $menu ) {
560
+		foreach ($menus as $menu) {
561 561
 			$menu_id = $menu->term_id;
562 562
 
563 563
 			// Create a section for each menu.
564
-			$section_id = 'nav_menu[' . $menu_id . ']';
565
-			$this->manager->add_section( new WP_Customize_Nav_Menu_Section( $this->manager, $section_id, array(
566
-				'title'     => html_entity_decode( $menu->name, ENT_QUOTES, get_bloginfo( 'charset' ) ),
564
+			$section_id = 'nav_menu['.$menu_id.']';
565
+			$this->manager->add_section(new WP_Customize_Nav_Menu_Section($this->manager, $section_id, array(
566
+				'title'     => html_entity_decode($menu->name, ENT_QUOTES, get_bloginfo('charset')),
567 567
 				'priority'  => 10,
568 568
 				'panel'     => 'nav_menus',
569
-			) ) );
569
+			)));
570 570
 
571
-			$nav_menu_setting_id = 'nav_menu[' . $menu_id . ']';
572
-			$this->manager->add_setting( new WP_Customize_Nav_Menu_Setting( $this->manager, $nav_menu_setting_id, array(
573
-				'transport' => isset( $this->manager->selective_refresh ) ? 'postMessage' : 'refresh',
574
-			) ) );
571
+			$nav_menu_setting_id = 'nav_menu['.$menu_id.']';
572
+			$this->manager->add_setting(new WP_Customize_Nav_Menu_Setting($this->manager, $nav_menu_setting_id, array(
573
+				'transport' => isset($this->manager->selective_refresh) ? 'postMessage' : 'refresh',
574
+			)));
575 575
 
576 576
 			// Add the menu contents.
577
-			$menu_items = (array) wp_get_nav_menu_items( $menu_id );
577
+			$menu_items = (array) wp_get_nav_menu_items($menu_id);
578 578
 
579
-			foreach ( array_values( $menu_items ) as $i => $item ) {
579
+			foreach (array_values($menu_items) as $i => $item) {
580 580
 
581 581
 				// Create a setting for each menu item (which doesn't actually manage data, currently).
582
-				$menu_item_setting_id = 'nav_menu_item[' . $item->ID . ']';
582
+				$menu_item_setting_id = 'nav_menu_item['.$item->ID.']';
583 583
 
584 584
 				$value = (array) $item;
585 585
 				$value['nav_menu_term_id'] = $menu_id;
586
-				$this->manager->add_setting( new WP_Customize_Nav_Menu_Item_Setting( $this->manager, $menu_item_setting_id, array(
586
+				$this->manager->add_setting(new WP_Customize_Nav_Menu_Item_Setting($this->manager, $menu_item_setting_id, array(
587 587
 					'value'     => $value,
588
-					'transport' => isset( $this->manager->selective_refresh ) ? 'postMessage' : 'refresh',
589
-				) ) );
588
+					'transport' => isset($this->manager->selective_refresh) ? 'postMessage' : 'refresh',
589
+				)));
590 590
 
591 591
 				// Create a control for each menu item.
592
-				$this->manager->add_control( new WP_Customize_Nav_Menu_Item_Control( $this->manager, $menu_item_setting_id, array(
592
+				$this->manager->add_control(new WP_Customize_Nav_Menu_Item_Control($this->manager, $menu_item_setting_id, array(
593 593
 					'label'    => $item->title,
594 594
 					'section'  => $section_id,
595 595
 					'priority' => 10 + $i,
596
-				) ) );
596
+				)));
597 597
 			}
598 598
 
599 599
 			// Note: other controls inside of this section get added dynamically in JS via the MenuSection.ready() function.
600 600
 		}
601 601
 
602 602
 		// Add the add-new-menu section and controls.
603
-		$this->manager->add_section( new WP_Customize_New_Menu_Section( $this->manager, 'add_menu', array(
604
-			'title'    => __( 'Add a Menu' ),
603
+		$this->manager->add_section(new WP_Customize_New_Menu_Section($this->manager, 'add_menu', array(
604
+			'title'    => __('Add a Menu'),
605 605
 			'panel'    => 'nav_menus',
606 606
 			'priority' => 999,
607
-		) ) );
607
+		)));
608 608
 
609
-		$this->manager->add_control( 'new_menu_name', array(
609
+		$this->manager->add_control('new_menu_name', array(
610 610
 			'label'       => '',
611 611
 			'section'     => 'add_menu',
612 612
 			'type'        => 'text',
613 613
 			'settings'    => array(),
614 614
 			'input_attrs' => array(
615 615
 				'class'       => 'menu-name-field',
616
-				'placeholder' => __( 'New menu name' ),
616
+				'placeholder' => __('New menu name'),
617 617
 			),
618
-		) );
618
+		));
619 619
 
620
-		$this->manager->add_control( new WP_Customize_New_Menu_Control( $this->manager, 'create_new_menu', array(
620
+		$this->manager->add_control(new WP_Customize_New_Menu_Control($this->manager, 'create_new_menu', array(
621 621
 			'section'  => 'add_menu',
622 622
 			'settings' => array(),
623
-		) ) );
623
+		)));
624 624
 	}
625 625
 
626 626
 	/**
@@ -635,8 +635,8 @@  discard block
 block discarded – undo
635 635
 	 * @param mixed $value Number to convert.
636 636
 	 * @return int Integer.
637 637
 	 */
638
-	public function intval_base10( $value ) {
639
-		return intval( $value, 10 );
638
+	public function intval_base10($value) {
639
+		return intval($value, 10);
640 640
 	}
641 641
 
642 642
 	/**
@@ -650,9 +650,9 @@  discard block
 block discarded – undo
650 650
 	public function available_item_types() {
651 651
 		$item_types = array();
652 652
 
653
-		$post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'objects' );
654
-		if ( $post_types ) {
655
-			foreach ( $post_types as $slug => $post_type ) {
653
+		$post_types = get_post_types(array('show_in_nav_menus' => true), 'objects');
654
+		if ($post_types) {
655
+			foreach ($post_types as $slug => $post_type) {
656 656
 				$item_types[] = array(
657 657
 					'title'  => $post_type->labels->name,
658 658
 					'type'   => 'post_type',
@@ -661,10 +661,10 @@  discard block
 block discarded – undo
661 661
 			}
662 662
 		}
663 663
 
664
-		$taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'objects' );
665
-		if ( $taxonomies ) {
666
-			foreach ( $taxonomies as $slug => $taxonomy ) {
667
-				if ( 'post_format' === $taxonomy && ! current_theme_supports( 'post-formats' ) ) {
664
+		$taxonomies = get_taxonomies(array('show_in_nav_menus' => true), 'objects');
665
+		if ($taxonomies) {
666
+			foreach ($taxonomies as $slug => $taxonomy) {
667
+				if ('post_format' === $taxonomy && ! current_theme_supports('post-formats')) {
668 668
 					continue;
669 669
 				}
670 670
 				$item_types[] = array(
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
 		 *
683 683
 		 * @param array $item_types Custom menu item types.
684 684
 		 */
685
-		$item_types = apply_filters( 'customize_nav_menu_available_item_types', $item_types );
685
+		$item_types = apply_filters('customize_nav_menu_available_item_types', $item_types);
686 686
 
687 687
 		return $item_types;
688 688
 	}
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
 						<button type="button" class="button-link item-add">
709 709
 							<span class="screen-reader-text"><?php
710 710
 								/* translators: 1: Title of a menu item, 2: Type of a menu item */
711
-								printf( __( 'Add to menu: %1$s (%2$s)' ), '{{ data.title || wp.customize.Menus.data.l10n.untitled }}', '{{ data.type_label }}' );
711
+								printf(__('Add to menu: %1$s (%2$s)'), '{{ data.title || wp.customize.Menus.data.l10n.untitled }}', '{{ data.type_label }}');
712 712
 							?></span>
713 713
 						</button>
714 714
 					</div>
@@ -721,10 +721,10 @@  discard block
 block discarded – undo
721 721
 				<?php
722 722
 				printf(
723 723
 					'<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>',
724
-					__( 'Move up' ),
725
-					__( 'Move down' ),
726
-					__( 'Move one level up' ),
727
-					__( 'Move one level down' )
724
+					__('Move up'),
725
+					__('Move down'),
726
+					__('Move one level up'),
727
+					__('Move one level down')
728 728
 				);
729 729
 				?>
730 730
 			</div>
@@ -743,49 +743,49 @@  discard block
 block discarded – undo
743 743
 		<div id="available-menu-items" class="accordion-container">
744 744
 			<div class="customize-section-title">
745 745
 				<button type="button" class="customize-section-back" tabindex="-1">
746
-					<span class="screen-reader-text"><?php _e( 'Back' ); ?></span>
746
+					<span class="screen-reader-text"><?php _e('Back'); ?></span>
747 747
 				</button>
748 748
 				<h3>
749 749
 					<span class="customize-action">
750 750
 						<?php
751 751
 							/* translators: &#9656; is the unicode right-pointing triangle, and %s is the section title in the Customizer */
752
-							printf( __( 'Customizing &#9656; %s' ), esc_html( $this->manager->get_panel( 'nav_menus' )->title ) );
752
+							printf(__('Customizing &#9656; %s'), esc_html($this->manager->get_panel('nav_menus')->title));
753 753
 						?>
754 754
 					</span>
755
-					<?php _e( 'Add Menu Items' ); ?>
755
+					<?php _e('Add Menu Items'); ?>
756 756
 				</h3>
757 757
 			</div>
758 758
 			<div id="available-menu-items-search" class="accordion-section cannot-expand">
759 759
 				<div class="accordion-section-title">
760
-					<label class="screen-reader-text" for="menu-items-search"><?php _e( 'Search Menu Items' ); ?></label>
761
-					<input type="text" id="menu-items-search" placeholder="<?php esc_attr_e( 'Search menu items&hellip;' ) ?>" aria-describedby="menu-items-search-desc" />
762
-					<p class="screen-reader-text" id="menu-items-search-desc"><?php _e( 'The search results will be updated as you type.' ); ?></p>
760
+					<label class="screen-reader-text" for="menu-items-search"><?php _e('Search Menu Items'); ?></label>
761
+					<input type="text" id="menu-items-search" placeholder="<?php esc_attr_e('Search menu items&hellip;') ?>" aria-describedby="menu-items-search-desc" />
762
+					<p class="screen-reader-text" id="menu-items-search-desc"><?php _e('The search results will be updated as you type.'); ?></p>
763 763
 					<span class="spinner"></span>
764
-					<span class="clear-results"><span class="screen-reader-text"><?php _e( 'Clear Results' ); ?></span></span>
764
+					<span class="clear-results"><span class="screen-reader-text"><?php _e('Clear Results'); ?></span></span>
765 765
 				</div>
766 766
 				<ul class="accordion-section-content" data-type="search"></ul>
767 767
 			</div>
768 768
 			<div id="new-custom-menu-item" class="accordion-section">
769 769
 				<h4 class="accordion-section-title" role="presentation">
770
-					<?php _e( 'Custom Links' ); ?>
770
+					<?php _e('Custom Links'); ?>
771 771
 					<button type="button" class="button-link" aria-expanded="false">
772
-						<span class="screen-reader-text"><?php _e( 'Toggle section: Custom Links' ); ?></span>
772
+						<span class="screen-reader-text"><?php _e('Toggle section: Custom Links'); ?></span>
773 773
 						<span class="toggle-indicator" aria-hidden="true"></span>
774 774
 					</button>
775 775
 				</h4>
776 776
 				<div class="accordion-section-content customlinkdiv">
777 777
 					<input type="hidden" value="custom" id="custom-menu-item-type" name="menu-item[-1][menu-item-type]" />
778 778
 					<p id="menu-item-url-wrap" class="wp-clearfix">
779
-						<label class="howto" for="custom-menu-item-url"><?php _e( 'URL' ); ?></label>
779
+						<label class="howto" for="custom-menu-item-url"><?php _e('URL'); ?></label>
780 780
 						<input id="custom-menu-item-url" name="menu-item[-1][menu-item-url]" type="text" class="code menu-item-textbox" value="http://">
781 781
 					</p>
782 782
 					<p id="menu-item-name-wrap" class="wp-clearfix">
783
-						<label class="howto" for="custom-menu-item-name"><?php _e( 'Link Text' ); ?></label>
783
+						<label class="howto" for="custom-menu-item-name"><?php _e('Link Text'); ?></label>
784 784
 						<input id="custom-menu-item-name" name="menu-item[-1][menu-item-title]" type="text" class="regular-text menu-item-textbox">
785 785
 					</p>
786 786
 					<p class="button-controls">
787 787
 						<span class="add-to-menu">
788
-							<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">
788
+							<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">
789 789
 							<span class="spinner"></span>
790 790
 						</span>
791 791
 					</p>
@@ -793,22 +793,22 @@  discard block
 block discarded – undo
793 793
 			</div>
794 794
 			<?php
795 795
 			// Containers for per-post-type item browsing; items added with JS.
796
-			foreach ( $this->available_item_types() as $available_item_type ) {
797
-				$id = sprintf( 'available-menu-items-%s-%s', $available_item_type['type'], $available_item_type['object'] );
796
+			foreach ($this->available_item_types() as $available_item_type) {
797
+				$id = sprintf('available-menu-items-%s-%s', $available_item_type['type'], $available_item_type['object']);
798 798
 				?>
799
-				<div id="<?php echo esc_attr( $id ); ?>" class="accordion-section">
799
+				<div id="<?php echo esc_attr($id); ?>" class="accordion-section">
800 800
 					<h4 class="accordion-section-title" role="presentation">
801
-						<?php echo esc_html( $available_item_type['title'] ); ?>
801
+						<?php echo esc_html($available_item_type['title']); ?>
802 802
 						<span class="spinner"></span>
803
-						<span class="no-items"><?php _e( 'No items' ); ?></span>
803
+						<span class="no-items"><?php _e('No items'); ?></span>
804 804
 						<button type="button" class="button-link" aria-expanded="false">
805 805
 							<span class="screen-reader-text"><?php
806 806
 							/* translators: %s: Title of a section with menu items */
807
-							printf( __( 'Toggle section: %s' ), esc_html( $available_item_type['title'] ) ); ?></span>
807
+							printf(__('Toggle section: %s'), esc_html($available_item_type['title'])); ?></span>
808 808
 							<span class="toggle-indicator" aria-hidden="true"></span>
809 809
 						</button>
810 810
 					</h4>
811
-					<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>
811
+					<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>
812 812
 				</div>
813 813
 				<?php
814 814
 			}
@@ -840,17 +840,17 @@  discard block
 block discarded – undo
840 840
 	 * @param string      $partial_id   Partial ID.
841 841
 	 * @return array Partial args.
842 842
 	 */
843
-	public function customize_dynamic_partial_args( $partial_args, $partial_id ) {
843
+	public function customize_dynamic_partial_args($partial_args, $partial_id) {
844 844
 
845
-		if ( preg_match( '/^nav_menu_instance\[[0-9a-f]{32}\]$/', $partial_id ) ) {
846
-			if ( false === $partial_args ) {
845
+		if (preg_match('/^nav_menu_instance\[[0-9a-f]{32}\]$/', $partial_id)) {
846
+			if (false === $partial_args) {
847 847
 				$partial_args = array();
848 848
 			}
849 849
 			$partial_args = array_merge(
850 850
 				$partial_args,
851 851
 				array(
852 852
 					'type'                => 'nav_menu_instance',
853
-					'render_callback'     => array( $this, 'render_nav_menu_partial' ),
853
+					'render_callback'     => array($this, 'render_nav_menu_partial'),
854 854
 					'container_inclusive' => true,
855 855
 					'settings'            => array(), // Empty because the nav menu instance may relate to a menu or a location.
856 856
 					'capability'          => 'edit_theme_options',
@@ -868,11 +868,11 @@  discard block
 block discarded – undo
868 868
 	 * @access public
869 869
 	 */
870 870
 	public function customize_preview_init() {
871
-		add_action( 'wp_enqueue_scripts', array( $this, 'customize_preview_enqueue_deps' ) );
872
-		add_filter( 'wp_nav_menu_args', array( $this, 'filter_wp_nav_menu_args' ), 1000 );
873
-		add_filter( 'wp_nav_menu', array( $this, 'filter_wp_nav_menu' ), 10, 2 );
874
-		add_filter( 'wp_footer', array( $this, 'export_preview_data' ), 1 );
875
-		add_filter( 'customize_render_partials_response', array( $this, 'export_partial_rendered_nav_menu_instances' ) );
871
+		add_action('wp_enqueue_scripts', array($this, 'customize_preview_enqueue_deps'));
872
+		add_filter('wp_nav_menu_args', array($this, 'filter_wp_nav_menu_args'), 1000);
873
+		add_filter('wp_nav_menu', array($this, 'filter_wp_nav_menu'), 10, 2);
874
+		add_filter('wp_footer', array($this, 'export_preview_data'), 1);
875
+		add_filter('customize_render_partials_response', array($this, 'export_partial_rendered_nav_menu_instances'));
876 876
 	}
877 877
 
878 878
 	/**
@@ -886,7 +886,7 @@  discard block
 block discarded – undo
886 886
 	 * @param array $args An array containing wp_nav_menu() arguments.
887 887
 	 * @return array Arguments.
888 888
 	 */
889
-	public function filter_wp_nav_menu_args( $args ) {
889
+	public function filter_wp_nav_menu_args($args) {
890 890
 		/*
891 891
 		 * The following conditions determine whether or not this instance of
892 892
 		 * wp_nav_menu() can use selective refreshed. A wp_nav_menu() can be
@@ -894,25 +894,25 @@  discard block
 block discarded – undo
894 894
 		 */
895 895
 		$can_partial_refresh = (
896 896
 			// ...if wp_nav_menu() is directly echoing out the menu (and thus isn't manipulating the string after generated),
897
-			! empty( $args['echo'] )
897
+			! empty($args['echo'])
898 898
 			&&
899 899
 			// ...and if the fallback_cb can be serialized to JSON, since it will be included in the placement context data,
900
-			( empty( $args['fallback_cb'] ) || is_string( $args['fallback_cb'] ) )
900
+			(empty($args['fallback_cb']) || is_string($args['fallback_cb']))
901 901
 			&&
902 902
 			// ...and if the walker can also be serialized to JSON, since it will be included in the placement context data as well,
903
-			( empty( $args['walker'] ) || is_string( $args['walker'] ) )
903
+			(empty($args['walker']) || is_string($args['walker']))
904 904
 			// ...and if it has a theme location assigned or an assigned menu to display,
905 905
 			&& (
906
-				! empty( $args['theme_location'] )
906
+				! empty($args['theme_location'])
907 907
 				||
908
-				( ! empty( $args['menu'] ) && ( is_numeric( $args['menu'] ) || is_object( $args['menu'] ) ) )
908
+				( ! empty($args['menu']) && (is_numeric($args['menu']) || is_object($args['menu'])))
909 909
 			)
910 910
 			&&
911 911
 			// ...and if the nav menu would be rendered with a wrapper container element (upon which to attach data-* attributes).
912 912
 			(
913
-				! empty( $args['container'] )
913
+				! empty($args['container'])
914 914
 				||
915
-				( isset( $args['items_wrap'] ) && '<' === substr( $args['items_wrap'], 0, 1 ) )
915
+				(isset($args['items_wrap']) && '<' === substr($args['items_wrap'], 0, 1))
916 916
 			)
917 917
 		);
918 918
 		$args['can_partial_refresh'] = $can_partial_refresh;
@@ -920,7 +920,7 @@  discard block
 block discarded – undo
920 920
 		$exported_args = $args;
921 921
 
922 922
 		// Empty out args which may not be JSON-serializable.
923
-		if ( ! $can_partial_refresh ) {
923
+		if ( ! $can_partial_refresh) {
924 924
 			$exported_args['fallback_cb'] = '';
925 925
 			$exported_args['walker'] = '';
926 926
 		}
@@ -929,15 +929,15 @@  discard block
 block discarded – undo
929 929
 		 * Replace object menu arg with a term_id menu arg, as this exports better
930 930
 		 * to JS and is easier to compare hashes.
931 931
 		 */
932
-		if ( ! empty( $exported_args['menu'] ) && is_object( $exported_args['menu'] ) ) {
932
+		if ( ! empty($exported_args['menu']) && is_object($exported_args['menu'])) {
933 933
 			$exported_args['menu'] = $exported_args['menu']->term_id;
934 934
 		}
935 935
 
936
-		ksort( $exported_args );
937
-		$exported_args['args_hmac'] = $this->hash_nav_menu_args( $exported_args );
936
+		ksort($exported_args);
937
+		$exported_args['args_hmac'] = $this->hash_nav_menu_args($exported_args);
938 938
 
939 939
 		$args['customize_preview_nav_menus_args'] = $exported_args;
940
-		$this->preview_nav_menu_instance_args[ $exported_args['args_hmac'] ] = $exported_args;
940
+		$this->preview_nav_menu_instance_args[$exported_args['args_hmac']] = $exported_args;
941 941
 		return $args;
942 942
 	}
943 943
 
@@ -955,12 +955,12 @@  discard block
 block discarded – undo
955 955
 	 * @param object $args             An object containing wp_nav_menu() arguments.
956 956
 	 * @return null
957 957
 	 */
958
-	public function filter_wp_nav_menu( $nav_menu_content, $args ) {
959
-		if ( isset( $args->customize_preview_nav_menus_args['can_partial_refresh'] ) && $args->customize_preview_nav_menus_args['can_partial_refresh'] ) {
960
-			$attributes = sprintf( ' data-customize-partial-id="%s"', esc_attr( 'nav_menu_instance[' . $args->customize_preview_nav_menus_args['args_hmac'] . ']' ) );
958
+	public function filter_wp_nav_menu($nav_menu_content, $args) {
959
+		if (isset($args->customize_preview_nav_menus_args['can_partial_refresh']) && $args->customize_preview_nav_menus_args['can_partial_refresh']) {
960
+			$attributes = sprintf(' data-customize-partial-id="%s"', esc_attr('nav_menu_instance['.$args->customize_preview_nav_menus_args['args_hmac'].']'));
961 961
 			$attributes .= ' data-customize-partial-type="nav_menu_instance"';
962
-			$attributes .= sprintf( ' data-customize-partial-placement-context="%s"', esc_attr( wp_json_encode( $args->customize_preview_nav_menus_args ) ) );
963
-			$nav_menu_content = preg_replace( '#^(<\w+)#', '$1 ' . $attributes, $nav_menu_content, 1 );
962
+			$attributes .= sprintf(' data-customize-partial-placement-context="%s"', esc_attr(wp_json_encode($args->customize_preview_nav_menus_args)));
963
+			$nav_menu_content = preg_replace('#^(<\w+)#', '$1 '.$attributes, $nav_menu_content, 1);
964 964
 		}
965 965
 		return $nav_menu_content;
966 966
 	}
@@ -977,8 +977,8 @@  discard block
 block discarded – undo
977 977
 	 * @param array $args The arguments to hash.
978 978
 	 * @return string Hashed nav menu arguments.
979 979
 	 */
980
-	public function hash_nav_menu_args( $args ) {
981
-		return wp_hash( serialize( $args ) );
980
+	public function hash_nav_menu_args($args) {
981
+		return wp_hash(serialize($args));
982 982
 	}
983 983
 
984 984
 	/**
@@ -988,13 +988,13 @@  discard block
 block discarded – undo
988 988
 	 * @access public
989 989
 	 */
990 990
 	public function customize_preview_enqueue_deps() {
991
-		if ( isset( $this->manager->selective_refresh ) ) {
991
+		if (isset($this->manager->selective_refresh)) {
992 992
 			$script = wp_scripts()->registered['customize-preview-nav-menus'];
993 993
 			$script->deps[] = 'customize-selective-refresh';
994 994
 		}
995 995
 
996
-		wp_enqueue_script( 'customize-preview-nav-menus' ); // Note that we have overridden this.
997
-		wp_enqueue_style( 'customize-preview' );
996
+		wp_enqueue_script('customize-preview-nav-menus'); // Note that we have overridden this.
997
+		wp_enqueue_style('customize-preview');
998 998
 	}
999 999
 
1000 1000
 	/**
@@ -1009,7 +1009,7 @@  discard block
 block discarded – undo
1009 1009
 		$exports = array(
1010 1010
 			'navMenuInstanceArgs' => $this->preview_nav_menu_instance_args,
1011 1011
 		);
1012
-		printf( '<script>var _wpCustomizePreviewNavMenusExports = %s;</script>', wp_json_encode( $exports ) );
1012
+		printf('<script>var _wpCustomizePreviewNavMenusExports = %s;</script>', wp_json_encode($exports));
1013 1013
 	}
1014 1014
 
1015 1015
 	/**
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
 	 * @param array $response Response.
1022 1022
 	 * @return array Response.
1023 1023
 	 */
1024
-	public function export_partial_rendered_nav_menu_instances( $response ) {
1024
+	public function export_partial_rendered_nav_menu_instances($response) {
1025 1025
 		$response['nav_menu_instance_args'] = $this->preview_nav_menu_instance_args;
1026 1026
 		return $response;
1027 1027
 	}
@@ -1038,25 +1038,25 @@  discard block
 block discarded – undo
1038 1038
 	 * @param array                $nav_menu_args Nav menu args supplied as container context.
1039 1039
 	 * @return string|false
1040 1040
 	 */
1041
-	public function render_nav_menu_partial( $partial, $nav_menu_args ) {
1042
-		unset( $partial );
1041
+	public function render_nav_menu_partial($partial, $nav_menu_args) {
1042
+		unset($partial);
1043 1043
 
1044
-		if ( ! isset( $nav_menu_args['args_hmac'] ) ) {
1044
+		if ( ! isset($nav_menu_args['args_hmac'])) {
1045 1045
 			// Error: missing_args_hmac.
1046 1046
 			return false;
1047 1047
 		}
1048 1048
 
1049 1049
 		$nav_menu_args_hmac = $nav_menu_args['args_hmac'];
1050
-		unset( $nav_menu_args['args_hmac'] );
1050
+		unset($nav_menu_args['args_hmac']);
1051 1051
 
1052
-		ksort( $nav_menu_args );
1053
-		if ( ! hash_equals( $this->hash_nav_menu_args( $nav_menu_args ), $nav_menu_args_hmac ) ) {
1052
+		ksort($nav_menu_args);
1053
+		if ( ! hash_equals($this->hash_nav_menu_args($nav_menu_args), $nav_menu_args_hmac)) {
1054 1054
 			// Error: args_hmac_mismatch.
1055 1055
 			return false;
1056 1056
 		}
1057 1057
 
1058 1058
 		ob_start();
1059
-		wp_nav_menu( $nav_menu_args );
1059
+		wp_nav_menu($nav_menu_args);
1060 1060
 		$content = ob_get_clean();
1061 1061
 
1062 1062
 		return $content;
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   +26 added lines, -26 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 this section' ); ?></span>
350
+				<span class="screen-reader-text"><?php _e('Press return or enter to open this section'); ?></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">
@@ -375,13 +375,13 @@  discard block
 block discarded – undo
375 375
 }
376 376
 
377 377
 /** WP_Customize_Themes_Section class */
378
-require_once( ABSPATH . WPINC . '/customize/class-wp-customize-themes-section.php' );
378
+require_once(ABSPATH.WPINC.'/customize/class-wp-customize-themes-section.php');
379 379
 
380 380
 /** WP_Customize_Sidebar_Section class */
381
-require_once( ABSPATH . WPINC . '/customize/class-wp-customize-sidebar-section.php' );
381
+require_once(ABSPATH.WPINC.'/customize/class-wp-customize-sidebar-section.php');
382 382
 
383 383
 /** WP_Customize_Nav_Menu_Section class */
384
-require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-section.php' );
384
+require_once(ABSPATH.WPINC.'/customize/class-wp-customize-nav-menu-section.php');
385 385
 
386 386
 /** WP_Customize_New_Menu_Section class */
387
-require_once( ABSPATH . WPINC . '/customize/class-wp-customize-new-menu-section.php' );
387
+require_once(ABSPATH.WPINC.'/customize/class-wp-customize-new-menu-section.php');
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.
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.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @param string $file Path to the file to load.
26 26
 	 */
27
-	public function __construct( $file ) {
27
+	public function __construct($file) {
28 28
 		$this->file = $file;
29 29
 	}
30 30
 
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 * @param array $args
42 42
 	 * @return bool
43 43
 	 */
44
-	public static function test( $args = array() ) {
44
+	public static function test($args = array()) {
45 45
 		return false;
46 46
 	}
47 47
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 * @param string $mime_type
59 59
 	 * @return bool
60 60
 	 */
61
-	public static function supports_mime_type( $mime_type ) {
61
+	public static function supports_mime_type($mime_type) {
62 62
 		return false;
63 63
 	}
64 64
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	 * @param string $mime_type
85 85
 	 * @return array|WP_Error {'path'=>string, 'file'=>string, 'width'=>int, 'height'=>int, 'mime-type'=>string}
86 86
 	 */
87
-	abstract public function save( $destfilename = null, $mime_type = null );
87
+	abstract public function save($destfilename = null, $mime_type = null);
88 88
 
89 89
 	/**
90 90
 	 * Resizes current image.
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 * @param  bool     $crop
103 103
 	 * @return bool|WP_Error
104 104
 	 */
105
-	abstract public function resize( $max_w, $max_h, $crop = false );
105
+	abstract public function resize($max_w, $max_h, $crop = false);
106 106
 
107 107
 	/**
108 108
 	 * Resize multiple images from a single source.
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 * }
123 123
 	 * @return array An array of resized images metadata by size.
124 124
 	 */
125
-	abstract public function multi_resize( $sizes );
125
+	abstract public function multi_resize($sizes);
126 126
 
127 127
 	/**
128 128
 	 * Crops Image.
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	 * @param bool $src_abs Optional. If the source crop points are absolute.
141 141
 	 * @return bool|WP_Error
142 142
 	 */
143
-	abstract public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false );
143
+	abstract public function crop($src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false);
144 144
 
145 145
 	/**
146 146
 	 * Rotates current image counter-clockwise by $angle.
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 * @param float $angle
153 153
 	 * @return bool|WP_Error
154 154
 	 */
155
-	abstract public function rotate( $angle );
155
+	abstract public function rotate($angle);
156 156
 
157 157
 	/**
158 158
 	 * Flips current image.
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 * @param bool $vert Flip along Vertical Axis
166 166
 	 * @return bool|WP_Error
167 167
 	 */
168
-	abstract public function flip( $horz, $vert );
168
+	abstract public function flip($horz, $vert);
169 169
 
170 170
 	/**
171 171
 	 * Streams current image to browser.
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 	 * @param string $mime_type
178 178
 	 * @return bool|WP_Error
179 179
 	 */
180
-	abstract public function stream( $mime_type = null );
180
+	abstract public function stream($mime_type = null);
181 181
 
182 182
 	/**
183 183
 	 * Gets dimensions of image.
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 	 * @param int $height
202 202
 	 * @return true
203 203
 	 */
204
-	protected function update_size( $width = null, $height = null ) {
204
+	protected function update_size($width = null, $height = null) {
205 205
 		$this->size = array(
206 206
 			'width' => (int) $width,
207 207
 			'height' => (int) $height
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 	 * @return int $quality Compression Quality. Range: [1,100]
219 219
 	 */
220 220
 	public function get_quality() {
221
-		if ( ! $this->quality ) {
221
+		if ( ! $this->quality) {
222 222
 			$this->set_quality();
223 223
 		}
224 224
 
@@ -234,8 +234,8 @@  discard block
 block discarded – undo
234 234
 	 * @param int $quality Compression Quality. Range: [1,100]
235 235
 	 * @return true|WP_Error True if set successfully; WP_Error on failure.
236 236
 	 */
237
-	public function set_quality( $quality = null ) {
238
-		if ( null === $quality ) {
237
+	public function set_quality($quality = null) {
238
+		if (null === $quality) {
239 239
 			/**
240 240
 			 * Filter the default image compression quality setting.
241 241
 			 *
@@ -249,9 +249,9 @@  discard block
 block discarded – undo
249 249
 			 * @param int    $quality   Quality level between 1 (low) and 100 (high).
250 250
 			 * @param string $mime_type Image mime type.
251 251
 			 */
252
-			$quality = apply_filters( 'wp_editor_set_quality', $this->default_quality, $this->mime_type );
252
+			$quality = apply_filters('wp_editor_set_quality', $this->default_quality, $this->mime_type);
253 253
 
254
-			if ( 'image/jpeg' == $this->mime_type ) {
254
+			if ('image/jpeg' == $this->mime_type) {
255 255
 				/**
256 256
 				 * Filter the JPEG compression quality for backward-compatibility.
257 257
 				 *
@@ -268,24 +268,24 @@  discard block
 block discarded – undo
268 268
 				 * @param int    $quality Quality level between 0 (low) and 100 (high) of the JPEG.
269 269
 				 * @param string $context Context of the filter.
270 270
 				 */
271
-				$quality = apply_filters( 'jpeg_quality', $quality, 'image_resize' );
271
+				$quality = apply_filters('jpeg_quality', $quality, 'image_resize');
272 272
 			}
273 273
 
274
-			if ( $quality < 0 || $quality > 100 ) {
274
+			if ($quality < 0 || $quality > 100) {
275 275
 				$quality = $this->default_quality;
276 276
 			}
277 277
 		}
278 278
 
279 279
 		// Allow 0, but squash to 1 due to identical images in GD, and for backwards compatibility.
280
-		if ( 0 === $quality ) {
280
+		if (0 === $quality) {
281 281
 			$quality = 1;
282 282
 		}
283 283
 
284
-		if ( ( $quality >= 1 ) && ( $quality <= 100 ) ) {
284
+		if (($quality >= 1) && ($quality <= 100)) {
285 285
 			$this->quality = $quality;
286 286
 			return true;
287 287
 		} else {
288
-			return new WP_Error( 'invalid_image_quality', __('Attempted to set image quality outside of the range [1,100].') );
288
+			return new WP_Error('invalid_image_quality', __('Attempted to set image quality outside of the range [1,100].'));
289 289
 		}
290 290
 	}
291 291
 
@@ -304,34 +304,34 @@  discard block
 block discarded – undo
304 304
 	 * @param string $mime_type
305 305
 	 * @return array { filename|null, extension, mime-type }
306 306
 	 */
307
-	protected function get_output_format( $filename = null, $mime_type = null ) {
307
+	protected function get_output_format($filename = null, $mime_type = null) {
308 308
 		$new_ext = null;
309 309
 
310 310
 		// By default, assume specified type takes priority
311
-		if ( $mime_type ) {
312
-			$new_ext = $this->get_extension( $mime_type );
311
+		if ($mime_type) {
312
+			$new_ext = $this->get_extension($mime_type);
313 313
 		}
314 314
 
315
-		if ( $filename ) {
316
-			$file_ext = strtolower( pathinfo( $filename, PATHINFO_EXTENSION ) );
317
-			$file_mime = $this->get_mime_type( $file_ext );
315
+		if ($filename) {
316
+			$file_ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
317
+			$file_mime = $this->get_mime_type($file_ext);
318 318
 		}
319 319
 		else {
320 320
 			// If no file specified, grab editor's current extension and mime-type.
321
-			$file_ext = strtolower( pathinfo( $this->file, PATHINFO_EXTENSION ) );
321
+			$file_ext = strtolower(pathinfo($this->file, PATHINFO_EXTENSION));
322 322
 			$file_mime = $this->mime_type;
323 323
 		}
324 324
 
325 325
 		// Check to see if specified mime-type is the same as type implied by
326 326
 		// file extension.  If so, prefer extension from file.
327
-		if ( ! $mime_type || ( $file_mime == $mime_type ) ) {
327
+		if ( ! $mime_type || ($file_mime == $mime_type)) {
328 328
 			$mime_type = $file_mime;
329 329
 			$new_ext = $file_ext;
330 330
 		}
331 331
 
332 332
 		// Double-check that the mime-type selected is supported by the editor.
333 333
 		// If not, choose a default instead.
334
-		if ( ! $this->supports_mime_type( $mime_type ) ) {
334
+		if ( ! $this->supports_mime_type($mime_type)) {
335 335
 			/**
336 336
 			 * Filter default mime type prior to getting the file extension.
337 337
 			 *
@@ -341,22 +341,22 @@  discard block
 block discarded – undo
341 341
 			 *
342 342
 			 * @param string $mime_type Mime type string.
343 343
 			 */
344
-			$mime_type = apply_filters( 'image_editor_default_mime_type', $this->default_mime_type );
345
-			$new_ext = $this->get_extension( $mime_type );
344
+			$mime_type = apply_filters('image_editor_default_mime_type', $this->default_mime_type);
345
+			$new_ext = $this->get_extension($mime_type);
346 346
 		}
347 347
 
348
-		if ( $filename ) {
348
+		if ($filename) {
349 349
 			$ext = '';
350
-			$info = pathinfo( $filename );
350
+			$info = pathinfo($filename);
351 351
 			$dir  = $info['dirname'];
352 352
 
353
-			if ( isset( $info['extension'] ) )
353
+			if (isset($info['extension']))
354 354
 				$ext = $info['extension'];
355 355
 
356
-			$filename = trailingslashit( $dir ) . wp_basename( $filename, ".$ext" ) . ".{$new_ext}";
356
+			$filename = trailingslashit($dir).wp_basename($filename, ".$ext").".{$new_ext}";
357 357
 		}
358 358
 
359
-		return array( $filename, $new_ext, $mime_type );
359
+		return array($filename, $new_ext, $mime_type);
360 360
 	}
361 361
 
362 362
 	/**
@@ -370,22 +370,22 @@  discard block
 block discarded – undo
370 370
 	 * @param string $extension
371 371
 	 * @return string filename
372 372
 	 */
373
-	public function generate_filename( $suffix = null, $dest_path = null, $extension = null ) {
373
+	public function generate_filename($suffix = null, $dest_path = null, $extension = null) {
374 374
 		// $suffix will be appended to the destination filename, just before the extension
375
-		if ( ! $suffix )
375
+		if ( ! $suffix)
376 376
 			$suffix = $this->get_suffix();
377 377
 
378
-		$info = pathinfo( $this->file );
378
+		$info = pathinfo($this->file);
379 379
 		$dir  = $info['dirname'];
380 380
 		$ext  = $info['extension'];
381 381
 
382
-		$name = wp_basename( $this->file, ".$ext" );
383
-		$new_ext = strtolower( $extension ? $extension : $ext );
382
+		$name = wp_basename($this->file, ".$ext");
383
+		$new_ext = strtolower($extension ? $extension : $ext);
384 384
 
385
-		if ( ! is_null( $dest_path ) && $_dest_path = realpath( $dest_path ) )
385
+		if ( ! is_null($dest_path) && $_dest_path = realpath($dest_path))
386 386
 			$dir = $_dest_path;
387 387
 
388
-		return trailingslashit( $dir ) . "{$name}-{$suffix}.{$new_ext}";
388
+		return trailingslashit($dir)."{$name}-{$suffix}.{$new_ext}";
389 389
 	}
390 390
 
391 391
 	/**
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 	 * @return false|string suffix
398 398
 	 */
399 399
 	public function get_suffix() {
400
-		if ( ! $this->get_size() )
400
+		if ( ! $this->get_size())
401 401
 			return false;
402 402
 
403 403
 		return "{$this->size['width']}x{$this->size['height']}";
@@ -414,29 +414,29 @@  discard block
 block discarded – undo
414 414
 	 * @param array $arguments
415 415
 	 * @return bool
416 416
 	 */
417
-	protected function make_image( $filename, $function, $arguments ) {
418
-		if ( $stream = wp_is_stream( $filename ) ) {
417
+	protected function make_image($filename, $function, $arguments) {
418
+		if ($stream = wp_is_stream($filename)) {
419 419
 			ob_start();
420 420
 		} else {
421 421
 			// The directory containing the original file may no longer exist when using a replication plugin.
422
-			wp_mkdir_p( dirname( $filename ) );
422
+			wp_mkdir_p(dirname($filename));
423 423
 		}
424 424
 
425
-		$result = call_user_func_array( $function, $arguments );
425
+		$result = call_user_func_array($function, $arguments);
426 426
 
427
-		if ( $result && $stream ) {
427
+		if ($result && $stream) {
428 428
 			$contents = ob_get_contents();
429 429
 
430
-			$fp = fopen( $filename, 'w' );
430
+			$fp = fopen($filename, 'w');
431 431
 
432
-			if ( ! $fp )
432
+			if ( ! $fp)
433 433
 				return false;
434 434
 
435
-			fwrite( $fp, $contents );
436
-			fclose( $fp );
435
+			fwrite($fp, $contents);
436
+			fclose($fp);
437 437
 		}
438 438
 
439
-		if ( $stream ) {
439
+		if ($stream) {
440 440
 			ob_end_clean();
441 441
 		}
442 442
 
@@ -455,15 +455,15 @@  discard block
 block discarded – undo
455 455
 	 * @param string $extension
456 456
 	 * @return string|false
457 457
 	 */
458
-	protected static function get_mime_type( $extension = null ) {
459
-		if ( ! $extension )
458
+	protected static function get_mime_type($extension = null) {
459
+		if ( ! $extension)
460 460
 			return false;
461 461
 
462 462
 		$mime_types = wp_get_mime_types();
463
-		$extensions = array_keys( $mime_types );
463
+		$extensions = array_keys($mime_types);
464 464
 
465
-		foreach ( $extensions as $_extension ) {
466
-			if ( preg_match( "/{$extension}/i", $_extension ) ) {
465
+		foreach ($extensions as $_extension) {
466
+			if (preg_match("/{$extension}/i", $_extension)) {
467 467
 				return $mime_types[$_extension];
468 468
 			}
469 469
 		}
@@ -483,10 +483,10 @@  discard block
 block discarded – undo
483 483
 	 * @param string $mime_type
484 484
 	 * @return string|false
485 485
 	 */
486
-	protected static function get_extension( $mime_type = null ) {
487
-		$extensions = explode( '|', array_search( $mime_type, wp_get_mime_types() ) );
486
+	protected static function get_extension($mime_type = null) {
487
+		$extensions = explode('|', array_search($mime_type, wp_get_mime_types()));
488 488
 
489
-		if ( empty( $extensions[0] ) )
489
+		if (empty($extensions[0]))
490 490
 			return false;
491 491
 
492 492
 		return $extensions[0];
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   +21 added lines, -21 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.
@@ -609,22 +609,22 @@  discard block
 block discarded – undo
609 609
  	}
610 610
 
611 611
  	/**
612
-	 * Set the Headers for 404, if nothing is found for requested URL.
613
-	 *
614
-	 * Issue a 404 if a request doesn't match any posts and doesn't match
615
-	 * any object (e.g. an existing-but-empty category, tag, author) and a 404 was not already
616
-	 * issued, and if the request was not a search or the homepage.
617
-	 *
618
-	 * Otherwise, issue a 200.
619
-	 *
620
-	 * This sets headers after posts have been queried. handle_404() really means "handle status."
621
-	 * By inspecting the result of querying posts, seemingly successful requests can be switched to
622
-	 * a 404 so that canonical redirection logic can kick in.
623
-	 *
624
-	 * @since 2.0.0
625
-     * @access public
626
-	 *
627
-	 * @global WP_Query $wp_query
612
+ 	 * Set the Headers for 404, if nothing is found for requested URL.
613
+ 	 *
614
+ 	 * Issue a 404 if a request doesn't match any posts and doesn't match
615
+ 	 * any object (e.g. an existing-but-empty category, tag, author) and a 404 was not already
616
+ 	 * issued, and if the request was not a search or the homepage.
617
+ 	 *
618
+ 	 * Otherwise, issue a 200.
619
+ 	 *
620
+ 	 * This sets headers after posts have been queried. handle_404() really means "handle status."
621
+ 	 * By inspecting the result of querying posts, seemingly successful requests can be switched to
622
+ 	 * a 404 so that canonical redirection logic can kick in.
623
+ 	 *
624
+ 	 * @since 2.0.0
625
+ 	 * @access public
626
+ 	 *
627
+ 	 * @global WP_Query $wp_query
628 628
  	 */
629 629
 	public function handle_404() {
630 630
 		global $wp_query;
Please login to merge, or discard this patch.
Spacing   +142 added lines, -143 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	 * @access public
16 16
 	 * @var array
17 17
 	 */
18
-	public $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term', 'cpage', 'post_type', 'embed' );
18
+	public $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term', 'cpage', 'post_type', 'embed');
19 19
 
20 20
 	/**
21 21
 	 * Private query variables.
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 * @access public
27 27
 	 * @var array
28 28
 	 */
29
-	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', 'title' );
29
+	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', 'title');
30 30
 
31 31
 	/**
32 32
 	 * Extra query variables set by the user.
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 * @param string $qv Query variable name.
101 101
 	 */
102 102
 	public function add_query_var($qv) {
103
-		if ( !in_array($qv, $this->public_query_vars) )
103
+		if ( ! in_array($qv, $this->public_query_vars))
104 104
 			$this->public_query_vars[] = $qv;
105 105
 	}
106 106
 
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 	 *
113 113
 	 * @param string $name Query variable name.
114 114
 	 */
115
-	public function remove_query_var( $name ) {
116
-		$this->public_query_vars = array_diff( $this->public_query_vars, array( $name ) );
115
+	public function remove_query_var($name) {
116
+		$this->public_query_vars = array_diff($this->public_query_vars, array($name));
117 117
 	}
118 118
 
119 119
 	/**
@@ -154,35 +154,35 @@  discard block
 block discarded – undo
154 154
 		 * @param WP           $this             Current WordPress environment instance.
155 155
 		 * @param array|string $extra_query_vars Extra passed query variables.
156 156
 		 */
157
-		if ( ! apply_filters( 'do_parse_request', true, $this, $extra_query_vars ) )
157
+		if ( ! apply_filters('do_parse_request', true, $this, $extra_query_vars))
158 158
 			return;
159 159
 
160 160
 		$this->query_vars = array();
161 161
 		$post_type_query_vars = array();
162 162
 
163
-		if ( is_array( $extra_query_vars ) ) {
163
+		if (is_array($extra_query_vars)) {
164 164
 			$this->extra_query_vars = & $extra_query_vars;
165
-		} elseif ( ! empty( $extra_query_vars ) ) {
166
-			parse_str( $extra_query_vars, $this->extra_query_vars );
165
+		} elseif ( ! empty($extra_query_vars)) {
166
+			parse_str($extra_query_vars, $this->extra_query_vars);
167 167
 		}
168 168
 		// Process PATH_INFO, REQUEST_URI, and 404 for permalinks.
169 169
 
170 170
 		// Fetch the rewrite rules.
171 171
 		$rewrite = $wp_rewrite->wp_rewrite_rules();
172 172
 
173
-		if ( ! empty($rewrite) ) {
173
+		if ( ! empty($rewrite)) {
174 174
 			// If we match a rewrite rule, this will be cleared.
175 175
 			$error = '404';
176 176
 			$this->did_permalink = true;
177 177
 
178
-			$pathinfo = isset( $_SERVER['PATH_INFO'] ) ? $_SERVER['PATH_INFO'] : '';
179
-			list( $pathinfo ) = explode( '?', $pathinfo );
180
-			$pathinfo = str_replace( "%", "%25", $pathinfo );
178
+			$pathinfo = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : '';
179
+			list($pathinfo) = explode('?', $pathinfo);
180
+			$pathinfo = str_replace("%", "%25", $pathinfo);
181 181
 
182
-			list( $req_uri ) = explode( '?', $_SERVER['REQUEST_URI'] );
182
+			list($req_uri) = explode('?', $_SERVER['REQUEST_URI']);
183 183
 			$self = $_SERVER['PHP_SELF'];
184
-			$home_path = trim( parse_url( home_url(), PHP_URL_PATH ), '/' );
185
-			$home_path_regex = sprintf( '|^%s|i', preg_quote( $home_path, '|' ) );
184
+			$home_path = trim(parse_url(home_url(), PHP_URL_PATH), '/');
185
+			$home_path_regex = sprintf('|^%s|i', preg_quote($home_path, '|'));
186 186
 
187 187
 			// Trim path info from the end and the leading home path from the
188 188
 			// front. For path info requests, this leaves us with the requesting
@@ -190,22 +190,22 @@  discard block
 block discarded – undo
190 190
 			// requested permalink.
191 191
 			$req_uri = str_replace($pathinfo, '', $req_uri);
192 192
 			$req_uri = trim($req_uri, '/');
193
-			$req_uri = preg_replace( $home_path_regex, '', $req_uri );
193
+			$req_uri = preg_replace($home_path_regex, '', $req_uri);
194 194
 			$req_uri = trim($req_uri, '/');
195 195
 			$pathinfo = trim($pathinfo, '/');
196
-			$pathinfo = preg_replace( $home_path_regex, '', $pathinfo );
196
+			$pathinfo = preg_replace($home_path_regex, '', $pathinfo);
197 197
 			$pathinfo = trim($pathinfo, '/');
198 198
 			$self = trim($self, '/');
199
-			$self = preg_replace( $home_path_regex, '', $self );
199
+			$self = preg_replace($home_path_regex, '', $self);
200 200
 			$self = trim($self, '/');
201 201
 
202 202
 			// The requested permalink is in $pathinfo for path info requests and
203 203
 			//  $req_uri for other requests.
204
-			if ( ! empty($pathinfo) && !preg_match('|^.*' . $wp_rewrite->index . '$|', $pathinfo) ) {
204
+			if ( ! empty($pathinfo) && ! preg_match('|^.*'.$wp_rewrite->index.'$|', $pathinfo)) {
205 205
 				$request = $pathinfo;
206 206
 			} else {
207 207
 				// If the request uri is the index, blank it out so that we don't try to match it against a rule.
208
-				if ( $req_uri == $wp_rewrite->index )
208
+				if ($req_uri == $wp_rewrite->index)
209 209
 					$req_uri = '';
210 210
 				$request = $req_uri;
211 211
 			}
@@ -214,32 +214,32 @@  discard block
 block discarded – undo
214 214
 
215 215
 			// Look for matches.
216 216
 			$request_match = $request;
217
-			if ( empty( $request_match ) ) {
217
+			if (empty($request_match)) {
218 218
 				// An empty request could only match against ^$ regex
219
-				if ( isset( $rewrite['$'] ) ) {
219
+				if (isset($rewrite['$'])) {
220 220
 					$this->matched_rule = '$';
221 221
 					$query = $rewrite['$'];
222 222
 					$matches = array('');
223 223
 				}
224 224
 			} else {
225
-				foreach ( (array) $rewrite as $match => $query ) {
225
+				foreach ((array) $rewrite as $match => $query) {
226 226
 					// If the requesting file is the anchor of the match, prepend it to the path info.
227
-					if ( ! empty($req_uri) && strpos($match, $req_uri) === 0 && $req_uri != $request )
228
-						$request_match = $req_uri . '/' . $request;
227
+					if ( ! empty($req_uri) && strpos($match, $req_uri) === 0 && $req_uri != $request)
228
+						$request_match = $req_uri.'/'.$request;
229 229
 
230
-					if ( preg_match("#^$match#", $request_match, $matches) ||
231
-						preg_match("#^$match#", urldecode($request_match), $matches) ) {
230
+					if (preg_match("#^$match#", $request_match, $matches) ||
231
+						preg_match("#^$match#", urldecode($request_match), $matches)) {
232 232
 
233
-						if ( $wp_rewrite->use_verbose_page_rules && preg_match( '/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch ) ) {
233
+						if ($wp_rewrite->use_verbose_page_rules && preg_match('/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch)) {
234 234
 							// This is a verbose page match, let's check to be sure about it.
235
-							$page = get_page_by_path( $matches[ $varmatch[1] ] );
236
-							if ( ! $page ) {
235
+							$page = get_page_by_path($matches[$varmatch[1]]);
236
+							if ( ! $page) {
237 237
 						 		continue;
238 238
 							}
239 239
 
240
-							$post_status_obj = get_post_status_object( $page->post_status );
240
+							$post_status_obj = get_post_status_object($page->post_status);
241 241
 							if ( ! $post_status_obj->public && ! $post_status_obj->protected
242
-								&& ! $post_status_obj->private && $post_status_obj->exclude_from_search ) {
242
+								&& ! $post_status_obj->private && $post_status_obj->exclude_from_search) {
243 243
 								continue;
244 244
 							}
245 245
 						}
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 				}
252 252
 			}
253 253
 
254
-			if ( isset( $this->matched_rule ) ) {
254
+			if (isset($this->matched_rule)) {
255 255
 				// Trim the query of everything up to the '?'.
256 256
 				$query = preg_replace("!^.+\?!", '', $query);
257 257
 
@@ -264,16 +264,16 @@  discard block
 block discarded – undo
264 264
 				parse_str($query, $perma_query_vars);
265 265
 
266 266
 				// If we're processing a 404 request, clear the error var since we found something.
267
-				if ( '404' == $error )
268
-					unset( $error, $_GET['error'] );
267
+				if ('404' == $error)
268
+					unset($error, $_GET['error']);
269 269
 			}
270 270
 
271 271
 			// If req_uri is empty or if it is a request for ourself, unset error.
272
-			if ( empty($request) || $req_uri == $self || strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false ) {
273
-				unset( $error, $_GET['error'] );
272
+			if (empty($request) || $req_uri == $self || strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false) {
273
+				unset($error, $_GET['error']);
274 274
 
275
-				if ( isset($perma_query_vars) && strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false )
276
-					unset( $perma_query_vars );
275
+				if (isset($perma_query_vars) && strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false)
276
+					unset($perma_query_vars);
277 277
 
278 278
 				$this->did_permalink = false;
279 279
 			}
@@ -290,36 +290,36 @@  discard block
 block discarded – undo
290 290
 		 *
291 291
 		 * @param array $public_query_vars The array of whitelisted query variables.
292 292
 		 */
293
-		$this->public_query_vars = apply_filters( 'query_vars', $this->public_query_vars );
293
+		$this->public_query_vars = apply_filters('query_vars', $this->public_query_vars);
294 294
 
295
-		foreach ( get_post_types( array(), 'objects' ) as $post_type => $t ) {
296
-			if ( is_post_type_viewable( $t ) && $t->query_var ) {
295
+		foreach (get_post_types(array(), 'objects') as $post_type => $t) {
296
+			if (is_post_type_viewable($t) && $t->query_var) {
297 297
 				$post_type_query_vars[$t->query_var] = $post_type;
298 298
 			}
299 299
 		}
300 300
 
301
-		foreach ( $this->public_query_vars as $wpvar ) {
302
-			if ( isset( $this->extra_query_vars[$wpvar] ) )
301
+		foreach ($this->public_query_vars as $wpvar) {
302
+			if (isset($this->extra_query_vars[$wpvar]))
303 303
 				$this->query_vars[$wpvar] = $this->extra_query_vars[$wpvar];
304
-			elseif ( isset( $_POST[$wpvar] ) )
304
+			elseif (isset($_POST[$wpvar]))
305 305
 				$this->query_vars[$wpvar] = $_POST[$wpvar];
306
-			elseif ( isset( $_GET[$wpvar] ) )
306
+			elseif (isset($_GET[$wpvar]))
307 307
 				$this->query_vars[$wpvar] = $_GET[$wpvar];
308
-			elseif ( isset( $perma_query_vars[$wpvar] ) )
308
+			elseif (isset($perma_query_vars[$wpvar]))
309 309
 				$this->query_vars[$wpvar] = $perma_query_vars[$wpvar];
310 310
 
311
-			if ( !empty( $this->query_vars[$wpvar] ) ) {
312
-				if ( ! is_array( $this->query_vars[$wpvar] ) ) {
311
+			if ( ! empty($this->query_vars[$wpvar])) {
312
+				if ( ! is_array($this->query_vars[$wpvar])) {
313 313
 					$this->query_vars[$wpvar] = (string) $this->query_vars[$wpvar];
314 314
 				} else {
315
-					foreach ( $this->query_vars[$wpvar] as $vkey => $v ) {
316
-						if ( !is_object( $v ) ) {
315
+					foreach ($this->query_vars[$wpvar] as $vkey => $v) {
316
+						if ( ! is_object($v)) {
317 317
 							$this->query_vars[$wpvar][$vkey] = (string) $v;
318 318
 						}
319 319
 					}
320 320
 				}
321 321
 
322
-				if ( isset($post_type_query_vars[$wpvar] ) ) {
322
+				if (isset($post_type_query_vars[$wpvar])) {
323 323
 					$this->query_vars['post_type'] = $post_type_query_vars[$wpvar];
324 324
 					$this->query_vars['name'] = $this->query_vars[$wpvar];
325 325
 				}
@@ -327,43 +327,43 @@  discard block
 block discarded – undo
327 327
 		}
328 328
 
329 329
 		// Convert urldecoded spaces back into +
330
-		foreach ( get_taxonomies( array() , 'objects' ) as $taxonomy => $t )
331
-			if ( $t->query_var && isset( $this->query_vars[$t->query_var] ) )
332
-				$this->query_vars[$t->query_var] = str_replace( ' ', '+', $this->query_vars[$t->query_var] );
330
+		foreach (get_taxonomies(array(), 'objects') as $taxonomy => $t)
331
+			if ($t->query_var && isset($this->query_vars[$t->query_var]))
332
+				$this->query_vars[$t->query_var] = str_replace(' ', '+', $this->query_vars[$t->query_var]);
333 333
 
334 334
 		// Don't allow non-publicly queryable taxonomies to be queried from the front end.
335
-		if ( ! is_admin() ) {
336
-			foreach ( get_taxonomies( array( 'publicly_queryable' => false ), 'objects' ) as $taxonomy => $t ) {
335
+		if ( ! is_admin()) {
336
+			foreach (get_taxonomies(array('publicly_queryable' => false), 'objects') as $taxonomy => $t) {
337 337
 				/*
338 338
 				 * Disallow when set to the 'taxonomy' query var.
339 339
 				 * Non-publicly queryable taxonomies cannot register custom query vars. See register_taxonomy().
340 340
 				 */
341
-				if ( isset( $this->query_vars['taxonomy'] ) && $taxonomy === $this->query_vars['taxonomy'] ) {
342
-					unset( $this->query_vars['taxonomy'], $this->query_vars['term'] );
341
+				if (isset($this->query_vars['taxonomy']) && $taxonomy === $this->query_vars['taxonomy']) {
342
+					unset($this->query_vars['taxonomy'], $this->query_vars['term']);
343 343
 				}
344 344
 			}
345 345
 		}
346 346
 
347 347
 		// Limit publicly queried post_types to those that are publicly_queryable
348
-		if ( isset( $this->query_vars['post_type']) ) {
349
-			$queryable_post_types = get_post_types( array('publicly_queryable' => true) );
350
-			if ( ! is_array( $this->query_vars['post_type'] ) ) {
351
-				if ( ! in_array( $this->query_vars['post_type'], $queryable_post_types ) )
352
-					unset( $this->query_vars['post_type'] );
348
+		if (isset($this->query_vars['post_type'])) {
349
+			$queryable_post_types = get_post_types(array('publicly_queryable' => true));
350
+			if ( ! is_array($this->query_vars['post_type'])) {
351
+				if ( ! in_array($this->query_vars['post_type'], $queryable_post_types))
352
+					unset($this->query_vars['post_type']);
353 353
 			} else {
354
-				$this->query_vars['post_type'] = array_intersect( $this->query_vars['post_type'], $queryable_post_types );
354
+				$this->query_vars['post_type'] = array_intersect($this->query_vars['post_type'], $queryable_post_types);
355 355
 			}
356 356
 		}
357 357
 
358 358
 		// Resolve conflicts between posts with numeric slugs and date archive queries.
359
-		$this->query_vars = wp_resolve_numeric_slug_conflicts( $this->query_vars );
359
+		$this->query_vars = wp_resolve_numeric_slug_conflicts($this->query_vars);
360 360
 
361
-		foreach ( (array) $this->private_query_vars as $var) {
362
-			if ( isset($this->extra_query_vars[$var]) )
361
+		foreach ((array) $this->private_query_vars as $var) {
362
+			if (isset($this->extra_query_vars[$var]))
363 363
 				$this->query_vars[$var] = $this->extra_query_vars[$var];
364 364
 		}
365 365
 
366
-		if ( isset($error) )
366
+		if (isset($error))
367 367
 			$this->query_vars['error'] = $error;
368 368
 
369 369
 		/**
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 		 *
374 374
 		 * @param array $query_vars The array of requested query variables.
375 375
 		 */
376
-		$this->query_vars = apply_filters( 'request', $this->query_vars );
376
+		$this->query_vars = apply_filters('request', $this->query_vars);
377 377
 
378 378
 		/**
379 379
 		 * Fires once all query variables for the current request have been parsed.
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 		 *
383 383
 		 * @param WP &$this Current WordPress environment instance (passed by reference).
384 384
 		 */
385
-		do_action_ref_array( 'parse_request', array( &$this ) );
385
+		do_action_ref_array('parse_request', array(&$this));
386 386
 	}
387 387
 
388 388
 	/**
@@ -400,50 +400,50 @@  discard block
 block discarded – undo
400 400
 		$status = null;
401 401
 		$exit_required = false;
402 402
 
403
-		if ( is_user_logged_in() )
403
+		if (is_user_logged_in())
404 404
 			$headers = array_merge($headers, wp_get_nocache_headers());
405
-		if ( ! empty( $this->query_vars['error'] ) ) {
405
+		if ( ! empty($this->query_vars['error'])) {
406 406
 			$status = (int) $this->query_vars['error'];
407
-			if ( 404 === $status ) {
408
-				if ( ! is_user_logged_in() )
407
+			if (404 === $status) {
408
+				if ( ! is_user_logged_in())
409 409
 					$headers = array_merge($headers, wp_get_nocache_headers());
410
-				$headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset');
411
-			} elseif ( in_array( $status, array( 403, 500, 502, 503 ) ) ) {
410
+				$headers['Content-Type'] = get_option('html_type').'; charset='.get_option('blog_charset');
411
+			} elseif (in_array($status, array(403, 500, 502, 503))) {
412 412
 				$exit_required = true;
413 413
 			}
414
-		} elseif ( empty( $this->query_vars['feed'] ) ) {
415
-			$headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset');
414
+		} elseif (empty($this->query_vars['feed'])) {
415
+			$headers['Content-Type'] = get_option('html_type').'; charset='.get_option('blog_charset');
416 416
 		} else {
417 417
 			// Set the correct content type for feeds
418 418
 			$type = $this->query_vars['feed'];
419
-			if ( 'feed' == $this->query_vars['feed'] ) {
419
+			if ('feed' == $this->query_vars['feed']) {
420 420
 				$type = get_default_feed();
421 421
 			}
422
-			$headers['Content-Type'] = feed_content_type( $type ) . '; charset=' . get_option( 'blog_charset' );
422
+			$headers['Content-Type'] = feed_content_type($type).'; charset='.get_option('blog_charset');
423 423
 
424 424
 			// We're showing a feed, so WP is indeed the only thing that last changed
425
-			if ( !empty($this->query_vars['withcomments'])
426
-				|| false !== strpos( $this->query_vars['feed'], 'comments-' )
427
-				|| ( empty($this->query_vars['withoutcomments'])
428
-					&& ( !empty($this->query_vars['p'])
429
-						|| !empty($this->query_vars['name'])
430
-						|| !empty($this->query_vars['page_id'])
431
-						|| !empty($this->query_vars['pagename'])
432
-						|| !empty($this->query_vars['attachment'])
433
-						|| !empty($this->query_vars['attachment_id'])
425
+			if ( ! empty($this->query_vars['withcomments'])
426
+				|| false !== strpos($this->query_vars['feed'], 'comments-')
427
+				|| (empty($this->query_vars['withoutcomments'])
428
+					&& ( ! empty($this->query_vars['p'])
429
+						|| ! empty($this->query_vars['name'])
430
+						|| ! empty($this->query_vars['page_id'])
431
+						|| ! empty($this->query_vars['pagename'])
432
+						|| ! empty($this->query_vars['attachment'])
433
+						|| ! empty($this->query_vars['attachment_id'])
434 434
 					)
435 435
 				)
436 436
 			)
437 437
 				$wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0).' GMT';
438 438
 			else
439 439
 				$wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT';
440
-			$wp_etag = '"' . md5($wp_last_modified) . '"';
440
+			$wp_etag = '"'.md5($wp_last_modified).'"';
441 441
 			$headers['Last-Modified'] = $wp_last_modified;
442 442
 			$headers['ETag'] = $wp_etag;
443 443
 
444 444
 			// Support for Conditional GET
445 445
 			if (isset($_SERVER['HTTP_IF_NONE_MATCH']))
446
-				$client_etag = wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] );
446
+				$client_etag = wp_unslash($_SERVER['HTTP_IF_NONE_MATCH']);
447 447
 			else $client_etag = false;
448 448
 
449 449
 			$client_last_modified = empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? '' : trim($_SERVER['HTTP_IF_MODIFIED_SINCE']);
@@ -453,9 +453,8 @@  discard block
 block discarded – undo
453 453
 			// Make a timestamp for our most recent modification...
454 454
 			$wp_modified_timestamp = strtotime($wp_last_modified);
455 455
 
456
-			if ( ($client_last_modified && $client_etag) ?
457
-					 (($client_modified_timestamp >= $wp_modified_timestamp) && ($client_etag == $wp_etag)) :
458
-					 (($client_modified_timestamp >= $wp_modified_timestamp) || ($client_etag == $wp_etag)) ) {
456
+			if (($client_last_modified && $client_etag) ?
457
+					 (($client_modified_timestamp >= $wp_modified_timestamp) && ($client_etag == $wp_etag)) : (($client_modified_timestamp >= $wp_modified_timestamp) || ($client_etag == $wp_etag))) {
459 458
 				$status = 304;
460 459
 				$exit_required = true;
461 460
 			}
@@ -469,23 +468,23 @@  discard block
 block discarded – undo
469 468
 		 * @param array $headers The list of headers to be sent.
470 469
 		 * @param WP    $this    Current WordPress environment instance.
471 470
 		 */
472
-		$headers = apply_filters( 'wp_headers', $headers, $this );
471
+		$headers = apply_filters('wp_headers', $headers, $this);
473 472
 
474
-		if ( ! empty( $status ) )
475
-			status_header( $status );
473
+		if ( ! empty($status))
474
+			status_header($status);
476 475
 
477 476
 		// If Last-Modified is set to false, it should not be sent (no-cache situation).
478
-		if ( isset( $headers['Last-Modified'] ) && false === $headers['Last-Modified'] ) {
479
-			unset( $headers['Last-Modified'] );
477
+		if (isset($headers['Last-Modified']) && false === $headers['Last-Modified']) {
478
+			unset($headers['Last-Modified']);
480 479
 
481 480
 			// In PHP 5.3+, make sure we are not sending a Last-Modified header.
482
-			if ( function_exists( 'header_remove' ) ) {
483
-				@header_remove( 'Last-Modified' );
481
+			if (function_exists('header_remove')) {
482
+				@header_remove('Last-Modified');
484 483
 			} else {
485 484
 				// In PHP 5.2, send an empty Last-Modified header, but only as a
486 485
 				// last resort to override a header already sent. #WP23021
487
-				foreach ( headers_list() as $header ) {
488
-					if ( 0 === stripos( $header, 'Last-Modified' ) ) {
486
+				foreach (headers_list() as $header) {
487
+					if (0 === stripos($header, 'Last-Modified')) {
489 488
 						$headers['Last-Modified'] = '';
490 489
 						break;
491 490
 					}
@@ -493,10 +492,10 @@  discard block
 block discarded – undo
493 492
 			}
494 493
 		}
495 494
 
496
-		foreach ( (array) $headers as $name => $field_value )
495
+		foreach ((array) $headers as $name => $field_value)
497 496
 			@header("{$name}: {$field_value}");
498 497
 
499
-		if ( $exit_required )
498
+		if ($exit_required)
500 499
 			exit();
501 500
 
502 501
 		/**
@@ -506,7 +505,7 @@  discard block
 block discarded – undo
506 505
 		 *
507 506
 		 * @param WP &$this Current WordPress environment instance (passed by reference).
508 507
 		 */
509
-		do_action_ref_array( 'send_headers', array( &$this ) );
508
+		do_action_ref_array('send_headers', array(&$this));
510 509
 	}
511 510
 
512 511
 	/**
@@ -520,16 +519,16 @@  discard block
 block discarded – undo
520 519
 	 */
521 520
 	public function build_query_string() {
522 521
 		$this->query_string = '';
523
-		foreach ( (array) array_keys($this->query_vars) as $wpvar) {
524
-			if ( '' != $this->query_vars[$wpvar] ) {
522
+		foreach ((array) array_keys($this->query_vars) as $wpvar) {
523
+			if ('' != $this->query_vars[$wpvar]) {
525 524
 				$this->query_string .= (strlen($this->query_string) < 1) ? '' : '&';
526
-				if ( !is_scalar($this->query_vars[$wpvar]) ) // Discard non-scalars.
525
+				if ( ! is_scalar($this->query_vars[$wpvar])) // Discard non-scalars.
527 526
 					continue;
528
-				$this->query_string .= $wpvar . '=' . rawurlencode($this->query_vars[$wpvar]);
527
+				$this->query_string .= $wpvar.'='.rawurlencode($this->query_vars[$wpvar]);
529 528
 			}
530 529
 		}
531 530
 
532
-		if ( has_filter( 'query_string' ) ) {  // Don't bother filtering and parsing if no plugins are hooked in.
531
+		if (has_filter('query_string')) {  // Don't bother filtering and parsing if no plugins are hooked in.
533 532
 			/**
534 533
 			 * Filter the query string before parsing.
535 534
 			 *
@@ -538,7 +537,7 @@  discard block
 block discarded – undo
538 537
 			 *
539 538
 			 * @param string $query_string The query string to modify.
540 539
 			 */
541
-			$this->query_string = apply_filters( 'query_string', $this->query_string );
540
+			$this->query_string = apply_filters('query_string', $this->query_string);
542 541
 			parse_str($this->query_string, $this->query_vars);
543 542
 		}
544 543
 	}
@@ -566,22 +565,22 @@  discard block
 block discarded – undo
566 565
 		global $wp_query;
567 566
 
568 567
 		// Extract updated query vars back into global namespace.
569
-		foreach ( (array) $wp_query->query_vars as $key => $value ) {
570
-			$GLOBALS[ $key ] = $value;
568
+		foreach ((array) $wp_query->query_vars as $key => $value) {
569
+			$GLOBALS[$key] = $value;
571 570
 		}
572 571
 
573 572
 		$GLOBALS['query_string'] = $this->query_string;
574 573
 		$GLOBALS['posts'] = & $wp_query->posts;
575
-		$GLOBALS['post'] = isset( $wp_query->post ) ? $wp_query->post : null;
574
+		$GLOBALS['post'] = isset($wp_query->post) ? $wp_query->post : null;
576 575
 		$GLOBALS['request'] = $wp_query->request;
577 576
 
578
-		if ( $wp_query->is_single() || $wp_query->is_page() ) {
577
+		if ($wp_query->is_single() || $wp_query->is_page()) {
579 578
 			$GLOBALS['more']   = 1;
580 579
 			$GLOBALS['single'] = 1;
581 580
 		}
582 581
 
583
-		if ( $wp_query->is_author() && isset( $wp_query->post ) )
584
-			$GLOBALS['authordata'] = get_userdata( $wp_query->post->post_author );
582
+		if ($wp_query->is_author() && isset($wp_query->post))
583
+			$GLOBALS['authordata'] = get_userdata($wp_query->post->post_author);
585 584
 	}
586 585
 
587 586
 	/**
@@ -640,70 +639,70 @@  discard block
 block discarded – undo
640 639
 		 * @param bool     $preempt  Whether to short-circuit default header status handling. Default false.
641 640
 		 * @param WP_Query $wp_query WordPress Query object.
642 641
 		 */
643
-		if ( false !== apply_filters( 'pre_handle_404', false, $wp_query ) ) {
642
+		if (false !== apply_filters('pre_handle_404', false, $wp_query)) {
644 643
 			return;
645 644
 		}
646 645
 
647 646
 		// If we've already issued a 404, bail.
648
-		if ( is_404() )
647
+		if (is_404())
649 648
 			return;
650 649
 
651 650
 		// Never 404 for the admin, robots, or if we found posts.
652
-		if ( is_admin() || is_robots() || $wp_query->posts ) {
651
+		if (is_admin() || is_robots() || $wp_query->posts) {
653 652
 
654 653
 			$success = true;
655
-			if ( is_singular() ) {
654
+			if (is_singular()) {
656 655
 				$p = false;
657 656
 
658
-				if ( $wp_query->post instanceof WP_Post ) {
657
+				if ($wp_query->post instanceof WP_Post) {
659 658
 					$p = clone $wp_query->post;
660 659
 				}
661 660
 
662 661
 				// Only set X-Pingback for single posts that allow pings.
663
-				if ( $p && pings_open( $p ) ) {
664
-					@header( 'X-Pingback: ' . get_bloginfo( 'pingback_url' ) );
662
+				if ($p && pings_open($p)) {
663
+					@header('X-Pingback: '.get_bloginfo('pingback_url'));
665 664
 				}
666 665
 
667 666
 				// check for paged content that exceeds the max number of pages
668 667
 				$next = '<!--nextpage-->';
669
-				if ( $p && false !== strpos( $p->post_content, $next ) && ! empty( $this->query_vars['page'] ) ) {
670
-					$page = trim( $this->query_vars['page'], '/' );
671
-					$success = (int) $page <= ( substr_count( $p->post_content, $next ) + 1 );
668
+				if ($p && false !== strpos($p->post_content, $next) && ! empty($this->query_vars['page'])) {
669
+					$page = trim($this->query_vars['page'], '/');
670
+					$success = (int) $page <= (substr_count($p->post_content, $next) + 1);
672 671
 				}
673 672
 			}
674 673
 
675
-			if ( $success ) {
676
-				status_header( 200 );
674
+			if ($success) {
675
+				status_header(200);
677 676
 				return;
678 677
 			}
679 678
 		}
680 679
 
681 680
 		// We will 404 for paged queries, as no posts were found.
682
-		if ( ! is_paged() ) {
681
+		if ( ! is_paged()) {
683 682
 
684 683
 			// Don't 404 for authors without posts as long as they matched an author on this site.
685
-			$author = get_query_var( 'author' );
686
-			if ( is_author() && is_numeric( $author ) && $author > 0 && is_user_member_of_blog( $author ) ) {
687
-				status_header( 200 );
684
+			$author = get_query_var('author');
685
+			if (is_author() && is_numeric($author) && $author > 0 && is_user_member_of_blog($author)) {
686
+				status_header(200);
688 687
 				return;
689 688
 			}
690 689
 
691 690
 			// Don't 404 for these queries if they matched an object.
692
-			if ( ( is_tag() || is_category() || is_tax() || is_post_type_archive() ) && get_queried_object() ) {
693
-				status_header( 200 );
691
+			if ((is_tag() || is_category() || is_tax() || is_post_type_archive()) && get_queried_object()) {
692
+				status_header(200);
694 693
 				return;
695 694
 			}
696 695
 
697 696
 			// Don't 404 for these queries either.
698
-			if ( is_home() || is_search() || is_feed() ) {
699
-				status_header( 200 );
697
+			if (is_home() || is_search() || is_feed()) {
698
+				status_header(200);
700 699
 				return;
701 700
 			}
702 701
 		}
703 702
 
704 703
 		// Guess it's time to 404.
705 704
 		$wp_query->set_404();
706
-		status_header( 404 );
705
+		status_header(404);
707 706
 		nocache_headers();
708 707
 	}
709 708
 
@@ -734,7 +733,7 @@  discard block
 block discarded – undo
734 733
 		 *
735 734
 		 * @param WP &$this Current WordPress environment instance (passed by reference).
736 735
 		 */
737
-		do_action_ref_array( 'wp', array( &$this ) );
736
+		do_action_ref_array('wp', array(&$this));
738 737
 	}
739 738
 }
740 739
 
@@ -824,6 +823,6 @@  discard block
 block discarded – undo
824 823
 	 */
825 824
 	public function callback($matches) {
826 825
 		$index = intval(substr($matches[0], 9, -1));
827
-		return ( isset( $this->_matches[$index] ) ? urlencode($this->_matches[$index]) : '' );
826
+		return (isset($this->_matches[$index]) ? urlencode($this->_matches[$index]) : '');
828 827
 	}
829 828
 }
Please login to merge, or discard this patch.
Braces   +73 added lines, -50 removed lines patch added patch discarded remove patch
@@ -100,8 +100,9 @@  discard block
 block discarded – undo
100 100
 	 * @param string $qv Query variable name.
101 101
 	 */
102 102
 	public function add_query_var($qv) {
103
-		if ( !in_array($qv, $this->public_query_vars) )
104
-			$this->public_query_vars[] = $qv;
103
+		if ( !in_array($qv, $this->public_query_vars) ) {
104
+					$this->public_query_vars[] = $qv;
105
+		}
105 106
 	}
106 107
 
107 108
 	/**
@@ -154,8 +155,9 @@  discard block
 block discarded – undo
154 155
 		 * @param WP           $this             Current WordPress environment instance.
155 156
 		 * @param array|string $extra_query_vars Extra passed query variables.
156 157
 		 */
157
-		if ( ! apply_filters( 'do_parse_request', true, $this, $extra_query_vars ) )
158
-			return;
158
+		if ( ! apply_filters( 'do_parse_request', true, $this, $extra_query_vars ) ) {
159
+					return;
160
+		}
159 161
 
160 162
 		$this->query_vars = array();
161 163
 		$post_type_query_vars = array();
@@ -205,8 +207,9 @@  discard block
 block discarded – undo
205 207
 				$request = $pathinfo;
206 208
 			} else {
207 209
 				// If the request uri is the index, blank it out so that we don't try to match it against a rule.
208
-				if ( $req_uri == $wp_rewrite->index )
209
-					$req_uri = '';
210
+				if ( $req_uri == $wp_rewrite->index ) {
211
+									$req_uri = '';
212
+				}
210 213
 				$request = $req_uri;
211 214
 			}
212 215
 
@@ -224,8 +227,9 @@  discard block
 block discarded – undo
224 227
 			} else {
225 228
 				foreach ( (array) $rewrite as $match => $query ) {
226 229
 					// If the requesting file is the anchor of the match, prepend it to the path info.
227
-					if ( ! empty($req_uri) && strpos($match, $req_uri) === 0 && $req_uri != $request )
228
-						$request_match = $req_uri . '/' . $request;
230
+					if ( ! empty($req_uri) && strpos($match, $req_uri) === 0 && $req_uri != $request ) {
231
+											$request_match = $req_uri . '/' . $request;
232
+					}
229 233
 
230 234
 					if ( preg_match("#^$match#", $request_match, $matches) ||
231 235
 						preg_match("#^$match#", urldecode($request_match), $matches) ) {
@@ -264,16 +268,18 @@  discard block
 block discarded – undo
264 268
 				parse_str($query, $perma_query_vars);
265 269
 
266 270
 				// If we're processing a 404 request, clear the error var since we found something.
267
-				if ( '404' == $error )
268
-					unset( $error, $_GET['error'] );
271
+				if ( '404' == $error ) {
272
+									unset( $error, $_GET['error'] );
273
+				}
269 274
 			}
270 275
 
271 276
 			// If req_uri is empty or if it is a request for ourself, unset error.
272 277
 			if ( empty($request) || $req_uri == $self || strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false ) {
273 278
 				unset( $error, $_GET['error'] );
274 279
 
275
-				if ( isset($perma_query_vars) && strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false )
276
-					unset( $perma_query_vars );
280
+				if ( isset($perma_query_vars) && strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false ) {
281
+									unset( $perma_query_vars );
282
+				}
277 283
 
278 284
 				$this->did_permalink = false;
279 285
 			}
@@ -299,14 +305,15 @@  discard block
 block discarded – undo
299 305
 		}
300 306
 
301 307
 		foreach ( $this->public_query_vars as $wpvar ) {
302
-			if ( isset( $this->extra_query_vars[$wpvar] ) )
303
-				$this->query_vars[$wpvar] = $this->extra_query_vars[$wpvar];
304
-			elseif ( isset( $_POST[$wpvar] ) )
305
-				$this->query_vars[$wpvar] = $_POST[$wpvar];
306
-			elseif ( isset( $_GET[$wpvar] ) )
307
-				$this->query_vars[$wpvar] = $_GET[$wpvar];
308
-			elseif ( isset( $perma_query_vars[$wpvar] ) )
309
-				$this->query_vars[$wpvar] = $perma_query_vars[$wpvar];
308
+			if ( isset( $this->extra_query_vars[$wpvar] ) ) {
309
+							$this->query_vars[$wpvar] = $this->extra_query_vars[$wpvar];
310
+			} elseif ( isset( $_POST[$wpvar] ) ) {
311
+							$this->query_vars[$wpvar] = $_POST[$wpvar];
312
+			} elseif ( isset( $_GET[$wpvar] ) ) {
313
+							$this->query_vars[$wpvar] = $_GET[$wpvar];
314
+			} elseif ( isset( $perma_query_vars[$wpvar] ) ) {
315
+							$this->query_vars[$wpvar] = $perma_query_vars[$wpvar];
316
+			}
310 317
 
311 318
 			if ( !empty( $this->query_vars[$wpvar] ) ) {
312 319
 				if ( ! is_array( $this->query_vars[$wpvar] ) ) {
@@ -327,9 +334,10 @@  discard block
 block discarded – undo
327 334
 		}
328 335
 
329 336
 		// Convert urldecoded spaces back into +
330
-		foreach ( get_taxonomies( array() , 'objects' ) as $taxonomy => $t )
331
-			if ( $t->query_var && isset( $this->query_vars[$t->query_var] ) )
337
+		foreach ( get_taxonomies( array() , 'objects' ) as $taxonomy => $t ) {
338
+					if ( $t->query_var && isset( $this->query_vars[$t->query_var] ) )
332 339
 				$this->query_vars[$t->query_var] = str_replace( ' ', '+', $this->query_vars[$t->query_var] );
340
+		}
333 341
 
334 342
 		// Don't allow non-publicly queryable taxonomies to be queried from the front end.
335 343
 		if ( ! is_admin() ) {
@@ -348,8 +356,9 @@  discard block
 block discarded – undo
348 356
 		if ( isset( $this->query_vars['post_type']) ) {
349 357
 			$queryable_post_types = get_post_types( array('publicly_queryable' => true) );
350 358
 			if ( ! is_array( $this->query_vars['post_type'] ) ) {
351
-				if ( ! in_array( $this->query_vars['post_type'], $queryable_post_types ) )
352
-					unset( $this->query_vars['post_type'] );
359
+				if ( ! in_array( $this->query_vars['post_type'], $queryable_post_types ) ) {
360
+									unset( $this->query_vars['post_type'] );
361
+				}
353 362
 			} else {
354 363
 				$this->query_vars['post_type'] = array_intersect( $this->query_vars['post_type'], $queryable_post_types );
355 364
 			}
@@ -359,12 +368,14 @@  discard block
 block discarded – undo
359 368
 		$this->query_vars = wp_resolve_numeric_slug_conflicts( $this->query_vars );
360 369
 
361 370
 		foreach ( (array) $this->private_query_vars as $var) {
362
-			if ( isset($this->extra_query_vars[$var]) )
363
-				$this->query_vars[$var] = $this->extra_query_vars[$var];
371
+			if ( isset($this->extra_query_vars[$var]) ) {
372
+							$this->query_vars[$var] = $this->extra_query_vars[$var];
373
+			}
364 374
 		}
365 375
 
366
-		if ( isset($error) )
367
-			$this->query_vars['error'] = $error;
376
+		if ( isset($error) ) {
377
+					$this->query_vars['error'] = $error;
378
+		}
368 379
 
369 380
 		/**
370 381
 		 * Filter the array of parsed query variables.
@@ -400,13 +411,15 @@  discard block
 block discarded – undo
400 411
 		$status = null;
401 412
 		$exit_required = false;
402 413
 
403
-		if ( is_user_logged_in() )
404
-			$headers = array_merge($headers, wp_get_nocache_headers());
414
+		if ( is_user_logged_in() ) {
415
+					$headers = array_merge($headers, wp_get_nocache_headers());
416
+		}
405 417
 		if ( ! empty( $this->query_vars['error'] ) ) {
406 418
 			$status = (int) $this->query_vars['error'];
407 419
 			if ( 404 === $status ) {
408
-				if ( ! is_user_logged_in() )
409
-					$headers = array_merge($headers, wp_get_nocache_headers());
420
+				if ( ! is_user_logged_in() ) {
421
+									$headers = array_merge($headers, wp_get_nocache_headers());
422
+				}
410 423
 				$headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset');
411 424
 			} elseif ( in_array( $status, array( 403, 500, 502, 503 ) ) ) {
412 425
 				$exit_required = true;
@@ -433,18 +446,21 @@  discard block
 block discarded – undo
433 446
 						|| !empty($this->query_vars['attachment_id'])
434 447
 					)
435 448
 				)
436
-			)
437
-				$wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0).' GMT';
438
-			else
439
-				$wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT';
449
+			) {
450
+							$wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0).' GMT';
451
+			} else {
452
+							$wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT';
453
+			}
440 454
 			$wp_etag = '"' . md5($wp_last_modified) . '"';
441 455
 			$headers['Last-Modified'] = $wp_last_modified;
442 456
 			$headers['ETag'] = $wp_etag;
443 457
 
444 458
 			// Support for Conditional GET
445
-			if (isset($_SERVER['HTTP_IF_NONE_MATCH']))
446
-				$client_etag = wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] );
447
-			else $client_etag = false;
459
+			if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
460
+							$client_etag = wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] );
461
+			} else {
462
+				$client_etag = false;
463
+			}
448 464
 
449 465
 			$client_last_modified = empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? '' : trim($_SERVER['HTTP_IF_MODIFIED_SINCE']);
450 466
 			// If string is empty, return 0. If not, attempt to parse into a timestamp
@@ -471,8 +487,9 @@  discard block
 block discarded – undo
471 487
 		 */
472 488
 		$headers = apply_filters( 'wp_headers', $headers, $this );
473 489
 
474
-		if ( ! empty( $status ) )
475
-			status_header( $status );
490
+		if ( ! empty( $status ) ) {
491
+					status_header( $status );
492
+		}
476 493
 
477 494
 		// If Last-Modified is set to false, it should not be sent (no-cache situation).
478 495
 		if ( isset( $headers['Last-Modified'] ) && false === $headers['Last-Modified'] ) {
@@ -493,11 +510,13 @@  discard block
 block discarded – undo
493 510
 			}
494 511
 		}
495 512
 
496
-		foreach ( (array) $headers as $name => $field_value )
497
-			@header("{$name}: {$field_value}");
513
+		foreach ( (array) $headers as $name => $field_value ) {
514
+					@header("{$name}: {$field_value}");
515
+		}
498 516
 
499
-		if ( $exit_required )
500
-			exit();
517
+		if ( $exit_required ) {
518
+					exit();
519
+		}
501 520
 
502 521
 		/**
503 522
 		 * Fires once the requested HTTP headers for caching, content type, etc. have been sent.
@@ -523,8 +542,10 @@  discard block
 block discarded – undo
523 542
 		foreach ( (array) array_keys($this->query_vars) as $wpvar) {
524 543
 			if ( '' != $this->query_vars[$wpvar] ) {
525 544
 				$this->query_string .= (strlen($this->query_string) < 1) ? '' : '&';
526
-				if ( !is_scalar($this->query_vars[$wpvar]) ) // Discard non-scalars.
545
+				if ( !is_scalar($this->query_vars[$wpvar]) ) {
546
+					// Discard non-scalars.
527 547
 					continue;
548
+				}
528 549
 				$this->query_string .= $wpvar . '=' . rawurlencode($this->query_vars[$wpvar]);
529 550
 			}
530 551
 		}
@@ -580,8 +601,9 @@  discard block
 block discarded – undo
580 601
 			$GLOBALS['single'] = 1;
581 602
 		}
582 603
 
583
-		if ( $wp_query->is_author() && isset( $wp_query->post ) )
584
-			$GLOBALS['authordata'] = get_userdata( $wp_query->post->post_author );
604
+		if ( $wp_query->is_author() && isset( $wp_query->post ) ) {
605
+					$GLOBALS['authordata'] = get_userdata( $wp_query->post->post_author );
606
+		}
585 607
 	}
586 608
 
587 609
 	/**
@@ -645,8 +667,9 @@  discard block
 block discarded – undo
645 667
 		}
646 668
 
647 669
 		// If we've already issued a 404, bail.
648
-		if ( is_404() )
649
-			return;
670
+		if ( is_404() ) {
671
+					return;
672
+		}
650 673
 
651 674
 		// Never 404 for the admin, robots, or if we found posts.
652 675
 		if ( is_admin() || is_robots() || $wp_query->posts ) {
Please login to merge, or discard this patch.
src/wp-includes/class.wp-dependencies.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	 * @access public
271 271
 	 * @since 2.1.0
272 272
 	 *
273
-	 * @param mixed $handles Item handle and argument (string) or item handles and arguments (array of strings).
273
+	 * @param string $handles Item handle and argument (string) or item handles and arguments (array of strings).
274 274
 	 * @return void
275 275
 	 */
276 276
 	public function remove( $handles ) {
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	 * @access public
290 290
 	 * @since 2.1.0
291 291
 	 *
292
-	 * @param mixed $handles Item handle and argument (string) or item handles and arguments (array of strings).
292
+	 * @param string $handles Item handle and argument (string) or item handles and arguments (array of strings).
293 293
 	 */
294 294
 	public function enqueue( $handles ) {
295 295
 		foreach ( (array) $handles as $handle ) {
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 	 * @access public
312 312
 	 * @since 2.1.0
313 313
 	 *
314
-	 * @param mixed $handles Item handle and argument (string) or item handles and arguments (array of strings).
314
+	 * @param string $handles Item handle and argument (string) or item handles and arguments (array of strings).
315 315
 	 */
316 316
 	public function dequeue( $handles ) {
317 317
 		foreach ( (array) $handles as $handle ) {
Please login to merge, or discard this patch.
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -95,26 +95,26 @@  discard block
 block discarded – undo
95 95
 	 * @param mixed $group   Group level: level (int), no groups (false).
96 96
 	 * @return array Handles of items that have been processed.
97 97
 	 */
98
-	public function do_items( $handles = false, $group = false ) {
98
+	public function do_items($handles = false, $group = false) {
99 99
 		/*
100 100
 		 * If nothing is passed, print the queue. If a string is passed,
101 101
 		 * print that item. If an array is passed, print those items.
102 102
 		 */
103 103
 		$handles = false === $handles ? $this->queue : (array) $handles;
104
-		$this->all_deps( $handles );
104
+		$this->all_deps($handles);
105 105
 
106
-		foreach ( $this->to_do as $key => $handle ) {
107
-			if ( !in_array($handle, $this->done, true) && isset($this->registered[$handle]) ) {
106
+		foreach ($this->to_do as $key => $handle) {
107
+			if ( ! in_array($handle, $this->done, true) && isset($this->registered[$handle])) {
108 108
 				/*
109 109
 				 * Attempt to process the item. If successful,
110 110
 				 * add the handle to the done array.
111 111
 				 *
112 112
 				 * Unset the item from the to_do array.
113 113
 				 */
114
-				if ( $this->do_item( $handle, $group ) )
114
+				if ($this->do_item($handle, $group))
115 115
 					$this->done[] = $handle;
116 116
 
117
-				unset( $this->to_do[$key] );
117
+				unset($this->to_do[$key]);
118 118
 			}
119 119
 		}
120 120
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 * @param string $handle Name of the item. Should be unique.
131 131
 	 * @return bool True on success, false if not set.
132 132
 	 */
133
-	public function do_item( $handle ) {
133
+	public function do_item($handle) {
134 134
 		return isset($this->registered[$handle]);
135 135
 	}
136 136
 
@@ -150,43 +150,43 @@  discard block
 block discarded – undo
150 150
 	 * @param int|false $group     Group level: (int) level, (false) no groups.
151 151
 	 * @return bool True on success, false on failure.
152 152
 	 */
153
-	public function all_deps( $handles, $recursion = false, $group = false ) {
154
-		if ( !$handles = (array) $handles )
153
+	public function all_deps($handles, $recursion = false, $group = false) {
154
+		if ( ! $handles = (array) $handles)
155 155
 			return false;
156 156
 
157
-		foreach ( $handles as $handle ) {
157
+		foreach ($handles as $handle) {
158 158
 			$handle_parts = explode('?', $handle);
159 159
 			$handle = $handle_parts[0];
160 160
 			$queued = in_array($handle, $this->to_do, true);
161 161
 
162
-			if ( in_array($handle, $this->done, true) ) // Already done
162
+			if (in_array($handle, $this->done, true)) // Already done
163 163
 				continue;
164 164
 
165
-			$moved     = $this->set_group( $handle, $recursion, $group );
166
-			$new_group = $this->groups[ $handle ];
165
+			$moved     = $this->set_group($handle, $recursion, $group);
166
+			$new_group = $this->groups[$handle];
167 167
 
168
-			if ( $queued && !$moved ) // already queued and in the right group
168
+			if ($queued && ! $moved) // already queued and in the right group
169 169
 				continue;
170 170
 
171 171
 			$keep_going = true;
172
-			if ( !isset($this->registered[$handle]) )
172
+			if ( ! isset($this->registered[$handle]))
173 173
 				$keep_going = false; // Item doesn't exist.
174
-			elseif ( $this->registered[$handle]->deps && array_diff($this->registered[$handle]->deps, array_keys($this->registered)) )
174
+			elseif ($this->registered[$handle]->deps && array_diff($this->registered[$handle]->deps, array_keys($this->registered)))
175 175
 				$keep_going = false; // Item requires dependencies that don't exist.
176
-			elseif ( $this->registered[$handle]->deps && !$this->all_deps( $this->registered[$handle]->deps, true, $new_group ) )
176
+			elseif ($this->registered[$handle]->deps && ! $this->all_deps($this->registered[$handle]->deps, true, $new_group))
177 177
 				$keep_going = false; // Item requires dependencies that don't exist.
178 178
 
179
-			if ( ! $keep_going ) { // Either item or its dependencies don't exist.
180
-				if ( $recursion )
179
+			if ( ! $keep_going) { // Either item or its dependencies don't exist.
180
+				if ($recursion)
181 181
 					return false; // Abort this branch.
182 182
 				else
183 183
 					continue; // We're at the top level. Move on to the next one.
184 184
 			}
185 185
 
186
-			if ( $queued ) // Already grabbed it and its dependencies.
186
+			if ($queued) // Already grabbed it and its dependencies.
187 187
 				continue;
188 188
 
189
-			if ( isset($handle_parts[1]) )
189
+			if (isset($handle_parts[1]))
190 190
 				$this->args[$handle] = $handle_parts[1];
191 191
 
192 192
 			$this->to_do[] = $handle;
@@ -214,10 +214,10 @@  discard block
 block discarded – undo
214 214
 	 * @param mixed            $args   Optional. Custom property of the item. NOT the class property $args. Examples: $media, $in_footer. 
215 215
 	 * @return bool Whether the item has been registered. True on success, false on failure.
216 216
 	 */
217
-	public function add( $handle, $src, $deps = array(), $ver = false, $args = null ) {
218
-		if ( isset($this->registered[$handle]) )
217
+	public function add($handle, $src, $deps = array(), $ver = false, $args = null) {
218
+		if (isset($this->registered[$handle]))
219 219
 			return false;
220
-		$this->registered[$handle] = new _WP_Dependency( $handle, $src, $deps, $ver, $args );
220
+		$this->registered[$handle] = new _WP_Dependency($handle, $src, $deps, $ver, $args);
221 221
 		return true;
222 222
 	}
223 223
 
@@ -234,11 +234,11 @@  discard block
 block discarded – undo
234 234
 	 * @param mixed  $value  The data value.
235 235
 	 * @return bool True on success, false on failure.
236 236
 	 */
237
-	public function add_data( $handle, $key, $value ) {
238
-		if ( !isset( $this->registered[$handle] ) )
237
+	public function add_data($handle, $key, $value) {
238
+		if ( ! isset($this->registered[$handle]))
239 239
 			return false;
240 240
 
241
-		return $this->registered[$handle]->add_data( $key, $value );
241
+		return $this->registered[$handle]->add_data($key, $value);
242 242
 	}
243 243
 
244 244
 	/**
@@ -253,11 +253,11 @@  discard block
 block discarded – undo
253 253
 	 * @param string $key    The data key.
254 254
 	 * @return mixed Extra item data (string), false otherwise.
255 255
 	 */
256
-	public function get_data( $handle, $key ) {
257
-		if ( !isset( $this->registered[$handle] ) )
256
+	public function get_data($handle, $key) {
257
+		if ( ! isset($this->registered[$handle]))
258 258
 			return false;
259 259
 
260
-		if ( !isset( $this->registered[$handle]->extra[$key] ) )
260
+		if ( ! isset($this->registered[$handle]->extra[$key]))
261 261
 			return false;
262 262
 
263 263
 		return $this->registered[$handle]->extra[$key];
@@ -273,8 +273,8 @@  discard block
 block discarded – undo
273 273
 	 * @param mixed $handles Item handle and argument (string) or item handles and arguments (array of strings).
274 274
 	 * @return void
275 275
 	 */
276
-	public function remove( $handles ) {
277
-		foreach ( (array) $handles as $handle )
276
+	public function remove($handles) {
277
+		foreach ((array) $handles as $handle)
278 278
 			unset($this->registered[$handle]);
279 279
 	}
280 280
 
@@ -292,12 +292,12 @@  discard block
 block discarded – undo
292 292
 	 *
293 293
 	 * @param mixed $handles Item handle and argument (string) or item handles and arguments (array of strings).
294 294
 	 */
295
-	public function enqueue( $handles ) {
296
-		foreach ( (array) $handles as $handle ) {
295
+	public function enqueue($handles) {
296
+		foreach ((array) $handles as $handle) {
297 297
 			$handle = explode('?', $handle);
298
-			if ( !in_array($handle[0], $this->queue) && isset($this->registered[$handle[0]]) ) {
298
+			if ( ! in_array($handle[0], $this->queue) && isset($this->registered[$handle[0]])) {
299 299
 				$this->queue[] = $handle[0];
300
-				if ( isset($handle[1]) )
300
+				if (isset($handle[1]))
301 301
 					$this->args[$handle[0]] = $handle[1];
302 302
 			}
303 303
 		}
@@ -315,11 +315,11 @@  discard block
 block discarded – undo
315 315
 	 *
316 316
 	 * @param mixed $handles Item handle and argument (string) or item handles and arguments (array of strings).
317 317
 	 */
318
-	public function dequeue( $handles ) {
319
-		foreach ( (array) $handles as $handle ) {
318
+	public function dequeue($handles) {
319
+		foreach ((array) $handles as $handle) {
320 320
 			$handle = explode('?', $handle);
321 321
 			$key = array_search($handle[0], $this->queue);
322
-			if ( false !== $key ) {
322
+			if (false !== $key) {
323 323
 				unset($this->queue[$key]);
324 324
 				unset($this->args[$handle[0]]);
325 325
 			}
@@ -335,15 +335,15 @@  discard block
 block discarded – undo
335 335
 	 * @param string $handle Name of the item. Should be unique.
336 336
 	 * @return bool Whether the handle is found after recursively searching the dependency tree.
337 337
 	 */
338
-	protected function recurse_deps( $queue, $handle ) {
339
-		foreach ( $queue as $queued ) {
340
-			if ( ! isset( $this->registered[ $queued ] ) ) {
338
+	protected function recurse_deps($queue, $handle) {
339
+		foreach ($queue as $queued) {
340
+			if ( ! isset($this->registered[$queued])) {
341 341
 				continue;
342 342
 			}
343 343
 
344
-			if ( in_array( $handle, $this->registered[ $queued ]->deps ) ) {
344
+			if (in_array($handle, $this->registered[$queued]->deps)) {
345 345
 				return true;
346
-			} elseif ( $this->recurse_deps( $this->registered[ $queued ]->deps, $handle ) ) {
346
+			} elseif ($this->recurse_deps($this->registered[$queued]->deps, $handle)) {
347 347
 				return true;
348 348
 			}
349 349
 		}
@@ -362,28 +362,28 @@  discard block
 block discarded – undo
362 362
 	 * @param string $list   Property name of list array.
363 363
 	 * @return bool|_WP_Dependency Found, or object Item data.
364 364
 	 */
365
-	public function query( $handle, $list = 'registered' ) {
366
-		switch ( $list ) {
365
+	public function query($handle, $list = 'registered') {
366
+		switch ($list) {
367 367
 			case 'registered' :
368 368
 			case 'scripts': // back compat
369
-				if ( isset( $this->registered[ $handle ] ) )
370
-					return $this->registered[ $handle ];
369
+				if (isset($this->registered[$handle]))
370
+					return $this->registered[$handle];
371 371
 				return false;
372 372
 
373 373
 			case 'enqueued' :
374 374
 			case 'queue' :
375
-				if ( in_array( $handle, $this->queue ) ) {
375
+				if (in_array($handle, $this->queue)) {
376 376
 					return true;
377 377
 				}
378
-				return $this->recurse_deps( $this->queue, $handle );
378
+				return $this->recurse_deps($this->queue, $handle);
379 379
 
380 380
 			case 'to_do' :
381 381
 			case 'to_print': // back compat
382
-				return in_array( $handle, $this->to_do );
382
+				return in_array($handle, $this->to_do);
383 383
 
384 384
 			case 'done' :
385 385
 			case 'printed': // back compat
386
-				return in_array( $handle, $this->done );
386
+				return in_array($handle, $this->done);
387 387
 		}
388 388
 		return false;
389 389
 	}
@@ -399,14 +399,14 @@  discard block
 block discarded – undo
399 399
 	 * @param mixed  $group     Group level.
400 400
 	 * @return bool Not already in the group or a lower group
401 401
 	 */
402
-	public function set_group( $handle, $recursion, $group ) {
402
+	public function set_group($handle, $recursion, $group) {
403 403
 		$group = (int) $group;
404 404
 
405
-		if ( isset( $this->groups[ $handle ] ) && $this->groups[ $handle ] <= $group ) {
405
+		if (isset($this->groups[$handle]) && $this->groups[$handle] <= $group) {
406 406
 			return false;
407 407
 		}
408 408
 
409
-		$this->groups[ $handle ] = $group;
409
+		$this->groups[$handle] = $group;
410 410
 
411 411
 		return true;
412 412
 	}
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 	 * @since 2.6.0
468 468
 	 * @var null
469 469
 	 */
470
-	public $args = null;  // Custom property, such as $in_footer or $media.
470
+	public $args = null; // Custom property, such as $in_footer or $media.
471 471
 
472 472
 	/**
473 473
 	 * Extra data to supply to the handle.
@@ -484,8 +484,8 @@  discard block
 block discarded – undo
484 484
 	 * @since 2.6.0
485 485
 	 */
486 486
 	public function __construct() {
487
-		@list( $this->handle, $this->src, $this->deps, $this->ver, $this->args ) = func_get_args();
488
-		if ( ! is_array($this->deps) )
487
+		@list($this->handle, $this->src, $this->deps, $this->ver, $this->args) = func_get_args();
488
+		if ( ! is_array($this->deps))
489 489
 			$this->deps = array();
490 490
 	}
491 491
 
@@ -499,8 +499,8 @@  discard block
 block discarded – undo
499 499
 	 * @param mixed  $data The data value to add.
500 500
 	 * @return bool False if not scalar, true otherwise.
501 501
 	 */
502
-	public function add_data( $name, $data ) {
503
-		if ( !is_scalar($name) )
502
+	public function add_data($name, $data) {
503
+		if ( ! is_scalar($name))
504 504
 			return false;
505 505
 		$this->extra[$name] = $data;
506 506
 		return true;
Please login to merge, or discard this patch.
Braces   +65 added lines, -37 removed lines patch added patch discarded remove patch
@@ -111,8 +111,9 @@  discard block
 block discarded – undo
111 111
 				 *
112 112
 				 * Unset the item from the to_do array.
113 113
 				 */
114
-				if ( $this->do_item( $handle, $group ) )
115
-					$this->done[] = $handle;
114
+				if ( $this->do_item( $handle, $group ) ) {
115
+									$this->done[] = $handle;
116
+				}
116 117
 
117 118
 				unset( $this->to_do[$key] );
118 119
 			}
@@ -151,43 +152,61 @@  discard block
 block discarded – undo
151 152
 	 * @return bool True on success, false on failure.
152 153
 	 */
153 154
 	public function all_deps( $handles, $recursion = false, $group = false ) {
154
-		if ( !$handles = (array) $handles )
155
-			return false;
155
+		if ( !$handles = (array) $handles ) {
156
+					return false;
157
+		}
156 158
 
157 159
 		foreach ( $handles as $handle ) {
158 160
 			$handle_parts = explode('?', $handle);
159 161
 			$handle = $handle_parts[0];
160 162
 			$queued = in_array($handle, $this->to_do, true);
161 163
 
162
-			if ( in_array($handle, $this->done, true) ) // Already done
164
+			if ( in_array($handle, $this->done, true) ) {
165
+				// Already done
163 166
 				continue;
167
+			}
164 168
 
165 169
 			$moved     = $this->set_group( $handle, $recursion, $group );
166 170
 			$new_group = $this->groups[ $handle ];
167 171
 
168
-			if ( $queued && !$moved ) // already queued and in the right group
172
+			if ( $queued && !$moved ) {
173
+				// already queued and in the right group
169 174
 				continue;
175
+			}
170 176
 
171 177
 			$keep_going = true;
172
-			if ( !isset($this->registered[$handle]) )
173
-				$keep_going = false; // Item doesn't exist.
174
-			elseif ( $this->registered[$handle]->deps && array_diff($this->registered[$handle]->deps, array_keys($this->registered)) )
175
-				$keep_going = false; // Item requires dependencies that don't exist.
176
-			elseif ( $this->registered[$handle]->deps && !$this->all_deps( $this->registered[$handle]->deps, true, $new_group ) )
177
-				$keep_going = false; // Item requires dependencies that don't exist.
178
+			if ( !isset($this->registered[$handle]) ) {
179
+							$keep_going = false;
180
+			}
181
+			// Item doesn't exist.
182
+			elseif ( $this->registered[$handle]->deps && array_diff($this->registered[$handle]->deps, array_keys($this->registered)) ) {
183
+							$keep_going = false;
184
+			}
185
+			// Item requires dependencies that don't exist.
186
+			elseif ( $this->registered[$handle]->deps && !$this->all_deps( $this->registered[$handle]->deps, true, $new_group ) ) {
187
+							$keep_going = false;
188
+			}
189
+			// Item requires dependencies that don't exist.
178 190
 
179 191
 			if ( ! $keep_going ) { // Either item or its dependencies don't exist.
180
-				if ( $recursion )
181
-					return false; // Abort this branch.
182
-				else
183
-					continue; // We're at the top level. Move on to the next one.
192
+				if ( $recursion ) {
193
+									return false;
194
+				}
195
+				// Abort this branch.
196
+				else {
197
+									continue;
198
+				}
199
+				// We're at the top level. Move on to the next one.
184 200
 			}
185 201
 
186
-			if ( $queued ) // Already grabbed it and its dependencies.
202
+			if ( $queued ) {
203
+				// Already grabbed it and its dependencies.
187 204
 				continue;
205
+			}
188 206
 
189
-			if ( isset($handle_parts[1]) )
190
-				$this->args[$handle] = $handle_parts[1];
207
+			if ( isset($handle_parts[1]) ) {
208
+							$this->args[$handle] = $handle_parts[1];
209
+			}
191 210
 
192 211
 			$this->to_do[] = $handle;
193 212
 		}
@@ -215,8 +234,9 @@  discard block
 block discarded – undo
215 234
 	 * @return bool Whether the item has been registered. True on success, false on failure.
216 235
 	 */
217 236
 	public function add( $handle, $src, $deps = array(), $ver = false, $args = null ) {
218
-		if ( isset($this->registered[$handle]) )
219
-			return false;
237
+		if ( isset($this->registered[$handle]) ) {
238
+					return false;
239
+		}
220 240
 		$this->registered[$handle] = new _WP_Dependency( $handle, $src, $deps, $ver, $args );
221 241
 		return true;
222 242
 	}
@@ -235,8 +255,9 @@  discard block
 block discarded – undo
235 255
 	 * @return bool True on success, false on failure.
236 256
 	 */
237 257
 	public function add_data( $handle, $key, $value ) {
238
-		if ( !isset( $this->registered[$handle] ) )
239
-			return false;
258
+		if ( !isset( $this->registered[$handle] ) ) {
259
+					return false;
260
+		}
240 261
 
241 262
 		return $this->registered[$handle]->add_data( $key, $value );
242 263
 	}
@@ -254,11 +275,13 @@  discard block
 block discarded – undo
254 275
 	 * @return mixed Extra item data (string), false otherwise.
255 276
 	 */
256 277
 	public function get_data( $handle, $key ) {
257
-		if ( !isset( $this->registered[$handle] ) )
258
-			return false;
278
+		if ( !isset( $this->registered[$handle] ) ) {
279
+					return false;
280
+		}
259 281
 
260
-		if ( !isset( $this->registered[$handle]->extra[$key] ) )
261
-			return false;
282
+		if ( !isset( $this->registered[$handle]->extra[$key] ) ) {
283
+					return false;
284
+		}
262 285
 
263 286
 		return $this->registered[$handle]->extra[$key];
264 287
 	}
@@ -274,8 +297,9 @@  discard block
 block discarded – undo
274 297
 	 * @return void
275 298
 	 */
276 299
 	public function remove( $handles ) {
277
-		foreach ( (array) $handles as $handle )
278
-			unset($this->registered[$handle]);
300
+		foreach ( (array) $handles as $handle ) {
301
+					unset($this->registered[$handle]);
302
+		}
279 303
 	}
280 304
 
281 305
 	/**
@@ -297,8 +321,9 @@  discard block
 block discarded – undo
297 321
 			$handle = explode('?', $handle);
298 322
 			if ( !in_array($handle[0], $this->queue) && isset($this->registered[$handle[0]]) ) {
299 323
 				$this->queue[] = $handle[0];
300
-				if ( isset($handle[1]) )
301
-					$this->args[$handle[0]] = $handle[1];
324
+				if ( isset($handle[1]) ) {
325
+									$this->args[$handle[0]] = $handle[1];
326
+				}
302 327
 			}
303 328
 		}
304 329
 	}
@@ -366,8 +391,9 @@  discard block
 block discarded – undo
366 391
 		switch ( $list ) {
367 392
 			case 'registered' :
368 393
 			case 'scripts': // back compat
369
-				if ( isset( $this->registered[ $handle ] ) )
370
-					return $this->registered[ $handle ];
394
+				if ( isset( $this->registered[ $handle ] ) ) {
395
+									return $this->registered[ $handle ];
396
+				}
371 397
 				return false;
372 398
 
373 399
 			case 'enqueued' :
@@ -485,8 +511,9 @@  discard block
 block discarded – undo
485 511
 	 */
486 512
 	public function __construct() {
487 513
 		@list( $this->handle, $this->src, $this->deps, $this->ver, $this->args ) = func_get_args();
488
-		if ( ! is_array($this->deps) )
489
-			$this->deps = array();
514
+		if ( ! is_array($this->deps) ) {
515
+					$this->deps = array();
516
+		}
490 517
 	}
491 518
 
492 519
 	/**
@@ -500,8 +527,9 @@  discard block
 block discarded – undo
500 527
 	 * @return bool False if not scalar, true otherwise.
501 528
 	 */
502 529
 	public function add_data( $name, $data ) {
503
-		if ( !is_scalar($name) )
504
-			return false;
530
+		if ( !is_scalar($name) ) {
531
+					return false;
532
+		}
505 533
 		$this->extra[$name] = $data;
506 534
 		return true;
507 535
 	}
Please login to merge, or discard this patch.
src/wp-includes/date.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
 	 *
800 800
 	 * @param string $compare The compare operator to use
801 801
 	 * @param string|array $value The value
802
-	 * @return string|false|int The value to be used in SQL or false on error.
802
+	 * @return string The value to be used in SQL or false on error.
803 803
 	 */
804 804
 	public function build_value( $compare, $value ) {
805 805
 		if ( ! isset( $value ) )
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
 	 *                                     of $datetime that are arrays, or string values that are a
863 863
 	 *                                     subset of MySQL date format ('Y', 'Y-m', 'Y-m-d', 'Y-m-d H:i').
864 864
 	 *                                     Default: false.
865
-	 * @return string|false A MySQL format date/time or false on failure
865
+	 * @return string A MySQL format date/time or false on failure
866 866
 	 */
867 867
 	public function build_mysql_datetime( $datetime, $default_to_max = false ) {
868 868
 		$now = current_time( 'timestamp' );
Please login to merge, or discard this patch.
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,19 +1,19 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Class for generating SQL clauses that filter a primary query according to date.
4
- *
5
- * `WP_Date_Query` is a helper that allows primary query classes, such as {@see WP_Query},
6
- * to filter their results by date columns, by generating `WHERE` subclauses to be attached
7
- * to the primary SQL query string.
8
- *
9
- * Attempting to filter by an invalid date value (eg month=13) will generate SQL that will
10
- * return no results. In these cases, a _doing_it_wrong() error notice is also thrown.
11
- * See {@link WP_Date_Query::validate_date_values()}.
12
- *
13
- * @link https://codex.wordpress.org/Function_Reference/WP_Query Codex page.
14
- *
15
- * @since 3.7.0
16
- */
3
+	 * Class for generating SQL clauses that filter a primary query according to date.
4
+	 *
5
+	 * `WP_Date_Query` is a helper that allows primary query classes, such as {@see WP_Query},
6
+	 * to filter their results by date columns, by generating `WHERE` subclauses to be attached
7
+	 * to the primary SQL query string.
8
+	 *
9
+	 * Attempting to filter by an invalid date value (eg month=13) will generate SQL that will
10
+	 * return no results. In these cases, a _doing_it_wrong() error notice is also thrown.
11
+	 * See {@link WP_Date_Query::validate_date_values()}.
12
+	 *
13
+	 * @link https://codex.wordpress.org/Function_Reference/WP_Query Codex page.
14
+	 *
15
+	 * @since 3.7.0
16
+	 */
17 17
 class WP_Date_Query {
18 18
 	/**
19 19
 	 * Array of date queries.
Please login to merge, or discard this patch.
Braces   +60 added lines, -40 removed lines patch added patch discarded remove patch
@@ -270,8 +270,9 @@  discard block
 block discarded – undo
270 270
 	 * @return string The comparison operator.
271 271
 	 */
272 272
 	public function get_compare( $query ) {
273
-		if ( ! empty( $query['compare'] ) && in_array( $query['compare'], array( '=', '!=', '>', '>=', '<', '<=', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) )
274
-			return strtoupper( $query['compare'] );
273
+		if ( ! empty( $query['compare'] ) && in_array( $query['compare'], array( '=', '!=', '>', '>=', '<', '<=', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) {
274
+					return strtoupper( $query['compare'] );
275
+		}
275 276
 
276 277
 		return $this->compare;
277 278
 	}
@@ -735,16 +736,19 @@  discard block
 block discarded – undo
735 736
 		}
736 737
 
737 738
 		// Range queries.
738
-		if ( ! empty( $query['after'] ) )
739
-			$where_parts[] = $wpdb->prepare( "$column $gt %s", $this->build_mysql_datetime( $query['after'], ! $inclusive ) );
739
+		if ( ! empty( $query['after'] ) ) {
740
+					$where_parts[] = $wpdb->prepare( "$column $gt %s", $this->build_mysql_datetime( $query['after'], ! $inclusive ) );
741
+		}
740 742
 
741
-		if ( ! empty( $query['before'] ) )
742
-			$where_parts[] = $wpdb->prepare( "$column $lt %s", $this->build_mysql_datetime( $query['before'], $inclusive ) );
743
+		if ( ! empty( $query['before'] ) ) {
744
+					$where_parts[] = $wpdb->prepare( "$column $lt %s", $this->build_mysql_datetime( $query['before'], $inclusive ) );
745
+		}
743 746
 
744 747
 		// Specific value queries.
745 748
 
746
-		if ( isset( $query['year'] ) && $value = $this->build_value( $compare, $query['year'] ) )
747
-			$where_parts[] = "YEAR( $column ) $compare $value";
749
+		if ( isset( $query['year'] ) && $value = $this->build_value( $compare, $query['year'] ) ) {
750
+					$where_parts[] = "YEAR( $column ) $compare $value";
751
+		}
748 752
 
749 753
 		if ( isset( $query['month'] ) && $value = $this->build_value( $compare, $query['month'] ) ) {
750 754
 			$where_parts[] = "MONTH( $column ) $compare $value";
@@ -756,17 +760,21 @@  discard block
 block discarded – undo
756 760
 		} elseif ( isset( $query['w'] ) && false !== ( $value = $this->build_value( $compare, $query['w'] ) ) ) {
757 761
 			$where_parts[] = _wp_mysql_week( $column ) . " $compare $value";
758 762
 		}
759
-		if ( isset( $query['dayofyear'] ) && $value = $this->build_value( $compare, $query['dayofyear'] ) )
760
-			$where_parts[] = "DAYOFYEAR( $column ) $compare $value";
763
+		if ( isset( $query['dayofyear'] ) && $value = $this->build_value( $compare, $query['dayofyear'] ) ) {
764
+					$where_parts[] = "DAYOFYEAR( $column ) $compare $value";
765
+		}
761 766
 
762
-		if ( isset( $query['day'] ) && $value = $this->build_value( $compare, $query['day'] ) )
763
-			$where_parts[] = "DAYOFMONTH( $column ) $compare $value";
767
+		if ( isset( $query['day'] ) && $value = $this->build_value( $compare, $query['day'] ) ) {
768
+					$where_parts[] = "DAYOFMONTH( $column ) $compare $value";
769
+		}
764 770
 
765
-		if ( isset( $query['dayofweek'] ) && $value = $this->build_value( $compare, $query['dayofweek'] ) )
766
-			$where_parts[] = "DAYOFWEEK( $column ) $compare $value";
771
+		if ( isset( $query['dayofweek'] ) && $value = $this->build_value( $compare, $query['dayofweek'] ) ) {
772
+					$where_parts[] = "DAYOFWEEK( $column ) $compare $value";
773
+		}
767 774
 
768
-		if ( isset( $query['dayofweek_iso'] ) && $value = $this->build_value( $compare, $query['dayofweek_iso'] ) )
769
-			$where_parts[] = "WEEKDAY( $column ) + 1 $compare $value";
775
+		if ( isset( $query['dayofweek_iso'] ) && $value = $this->build_value( $compare, $query['dayofweek_iso'] ) ) {
776
+					$where_parts[] = "WEEKDAY( $column ) + 1 $compare $value";
777
+		}
770 778
 
771 779
 		if ( isset( $query['hour'] ) || isset( $query['minute'] ) || isset( $query['second'] ) ) {
772 780
 			// Avoid notices.
@@ -802,8 +810,9 @@  discard block
 block discarded – undo
802 810
 	 * @return string|false|int The value to be used in SQL or false on error.
803 811
 	 */
804 812
 	public function build_value( $compare, $value ) {
805
-		if ( ! isset( $value ) )
806
-			return false;
813
+		if ( ! isset( $value ) ) {
814
+					return false;
815
+		}
807 816
 
808 817
 		switch ( $compare ) {
809 818
 			case 'IN':
@@ -914,23 +923,29 @@  discard block
 block discarded – undo
914 923
 
915 924
 		$datetime = array_map( 'absint', $datetime );
916 925
 
917
-		if ( ! isset( $datetime['year'] ) )
918
-			$datetime['year'] = gmdate( 'Y', $now );
926
+		if ( ! isset( $datetime['year'] ) ) {
927
+					$datetime['year'] = gmdate( 'Y', $now );
928
+		}
919 929
 
920
-		if ( ! isset( $datetime['month'] ) )
921
-			$datetime['month'] = ( $default_to_max ) ? 12 : 1;
930
+		if ( ! isset( $datetime['month'] ) ) {
931
+					$datetime['month'] = ( $default_to_max ) ? 12 : 1;
932
+		}
922 933
 
923
-		if ( ! isset( $datetime['day'] ) )
924
-			$datetime['day'] = ( $default_to_max ) ? (int) date( 't', mktime( 0, 0, 0, $datetime['month'], 1, $datetime['year'] ) ) : 1;
934
+		if ( ! isset( $datetime['day'] ) ) {
935
+					$datetime['day'] = ( $default_to_max ) ? (int) date( 't', mktime( 0, 0, 0, $datetime['month'], 1, $datetime['year'] ) ) : 1;
936
+		}
925 937
 
926
-		if ( ! isset( $datetime['hour'] ) )
927
-			$datetime['hour'] = ( $default_to_max ) ? 23 : 0;
938
+		if ( ! isset( $datetime['hour'] ) ) {
939
+					$datetime['hour'] = ( $default_to_max ) ? 23 : 0;
940
+		}
928 941
 
929
-		if ( ! isset( $datetime['minute'] ) )
930
-			$datetime['minute'] = ( $default_to_max ) ? 59 : 0;
942
+		if ( ! isset( $datetime['minute'] ) ) {
943
+					$datetime['minute'] = ( $default_to_max ) ? 59 : 0;
944
+		}
931 945
 
932
-		if ( ! isset( $datetime['second'] ) )
933
-			$datetime['second'] = ( $default_to_max ) ? 59 : 0;
946
+		if ( ! isset( $datetime['second'] ) ) {
947
+					$datetime['second'] = ( $default_to_max ) ? 59 : 0;
948
+		}
934 949
 
935 950
 		return sprintf( '%04d-%02d-%02d %02d:%02d:%02d', $datetime['year'], $datetime['month'], $datetime['day'], $datetime['hour'], $datetime['minute'], $datetime['second'] );
936 951
 	}
@@ -956,21 +971,25 @@  discard block
 block discarded – undo
956 971
 		global $wpdb;
957 972
 
958 973
 		// Have to have at least one
959
-		if ( ! isset( $hour ) && ! isset( $minute ) && ! isset( $second ) )
960
-			return false;
974
+		if ( ! isset( $hour ) && ! isset( $minute ) && ! isset( $second ) ) {
975
+					return false;
976
+		}
961 977
 
962 978
 		// Complex combined queries aren't supported for multi-value queries
963 979
 		if ( in_array( $compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) {
964 980
 			$return = array();
965 981
 
966
-			if ( isset( $hour ) && false !== ( $value = $this->build_value( $compare, $hour ) ) )
967
-				$return[] = "HOUR( $column ) $compare $value";
982
+			if ( isset( $hour ) && false !== ( $value = $this->build_value( $compare, $hour ) ) ) {
983
+							$return[] = "HOUR( $column ) $compare $value";
984
+			}
968 985
 
969
-			if ( isset( $minute ) && false !== ( $value = $this->build_value( $compare, $minute ) ) )
970
-				$return[] = "MINUTE( $column ) $compare $value";
986
+			if ( isset( $minute ) && false !== ( $value = $this->build_value( $compare, $minute ) ) ) {
987
+							$return[] = "MINUTE( $column ) $compare $value";
988
+			}
971 989
 
972
-			if ( isset( $second ) && false !== ( $value = $this->build_value( $compare, $second ) ) )
973
-				$return[] = "SECOND( $column ) $compare $value";
990
+			if ( isset( $second ) && false !== ( $value = $this->build_value( $compare, $second ) ) ) {
991
+							$return[] = "SECOND( $column ) $compare $value";
992
+			}
974 993
 
975 994
 			return implode( ' AND ', $return );
976 995
 		}
@@ -985,8 +1004,9 @@  discard block
 block discarded – undo
985 1004
 		}
986 1005
 
987 1006
 		// Single units were already handled. Since hour & second isn't allowed, minute must to be set.
988
-		if ( ! isset( $minute ) )
989
-			return false;
1007
+		if ( ! isset( $minute ) ) {
1008
+					return false;
1009
+		}
990 1010
 
991 1011
 		$format = $time = '';
992 1012
 
Please login to merge, or discard this patch.
Spacing   +197 added lines, -197 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 * @access public
61 61
 	 * @var array
62 62
 	 */
63
-	public $time_keys = array( 'after', 'before', 'year', 'month', 'monthnum', 'week', 'w', 'dayofyear', 'day', 'dayofweek', 'dayofweek_iso', 'hour', 'minute', 'second' );
63
+	public $time_keys = array('after', 'before', 'year', 'month', 'monthnum', 'week', 'w', 'dayofyear', 'day', 'dayofweek', 'dayofweek_iso', 'hour', 'minute', 'second');
64 64
 
65 65
 	/**
66 66
 	 * Constructor.
@@ -150,38 +150,38 @@  discard block
 block discarded – undo
150 150
 	 *                              Accepts 'post_date', 'post_date_gmt', 'post_modified', 'post_modified_gmt',
151 151
 	 *                              'comment_date', 'comment_date_gmt'.
152 152
 	 */
153
-	public function __construct( $date_query, $default_column = 'post_date' ) {
153
+	public function __construct($date_query, $default_column = 'post_date') {
154 154
 
155
-		if ( isset( $date_query['relation'] ) && 'OR' === strtoupper( $date_query['relation'] ) ) {
155
+		if (isset($date_query['relation']) && 'OR' === strtoupper($date_query['relation'])) {
156 156
 			$this->relation = 'OR';
157 157
 		} else {
158 158
 			$this->relation = 'AND';
159 159
 		}
160 160
 
161
-		if ( ! is_array( $date_query ) ) {
161
+		if ( ! is_array($date_query)) {
162 162
 			return;
163 163
 		}
164 164
 
165 165
 		// Support for passing time-based keys in the top level of the $date_query array.
166
-		if ( ! isset( $date_query[0] ) && ! empty( $date_query ) ) {
167
-			$date_query = array( $date_query );
166
+		if ( ! isset($date_query[0]) && ! empty($date_query)) {
167
+			$date_query = array($date_query);
168 168
 		}
169 169
 
170
-		if ( empty( $date_query ) ) {
170
+		if (empty($date_query)) {
171 171
 			return;
172 172
 		}
173 173
 
174
-		if ( ! empty( $date_query['column'] ) ) {
175
-			$date_query['column'] = esc_sql( $date_query['column'] );
174
+		if ( ! empty($date_query['column'])) {
175
+			$date_query['column'] = esc_sql($date_query['column']);
176 176
 		} else {
177
-			$date_query['column'] = esc_sql( $default_column );
177
+			$date_query['column'] = esc_sql($default_column);
178 178
 		}
179 179
 
180
-		$this->column = $this->validate_column( $this->column );
180
+		$this->column = $this->validate_column($this->column);
181 181
 
182
-		$this->compare = $this->get_compare( $date_query );
182
+		$this->compare = $this->get_compare($date_query);
183 183
 
184
-		$this->queries = $this->sanitize_query( $date_query );
184
+		$this->queries = $this->sanitize_query($date_query);
185 185
 	}
186 186
 
187 187
 	/**
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 	 *
200 200
 	 * @return array Sanitized queries.
201 201
 	 */
202
-	public function sanitize_query( $queries, $parent_query = null ) {
202
+	public function sanitize_query($queries, $parent_query = null) {
203 203
 		$cleaned_query = array();
204 204
 
205 205
 		$defaults = array(
@@ -209,37 +209,37 @@  discard block
 block discarded – undo
209 209
 		);
210 210
 
211 211
 		// Numeric keys should always have array values.
212
-		foreach ( $queries as $qkey => $qvalue ) {
213
-			if ( is_numeric( $qkey ) && ! is_array( $qvalue ) ) {
214
-				unset( $queries[ $qkey ] );
212
+		foreach ($queries as $qkey => $qvalue) {
213
+			if (is_numeric($qkey) && ! is_array($qvalue)) {
214
+				unset($queries[$qkey]);
215 215
 			}
216 216
 		}
217 217
 
218 218
 		// Each query should have a value for each default key. Inherit from the parent when possible.
219
-		foreach ( $defaults as $dkey => $dvalue ) {
220
-			if ( isset( $queries[ $dkey ] ) ) {
219
+		foreach ($defaults as $dkey => $dvalue) {
220
+			if (isset($queries[$dkey])) {
221 221
 				continue;
222 222
 			}
223 223
 
224
-			if ( isset( $parent_query[ $dkey ] ) ) {
225
-				$queries[ $dkey ] = $parent_query[ $dkey ];
224
+			if (isset($parent_query[$dkey])) {
225
+				$queries[$dkey] = $parent_query[$dkey];
226 226
 			} else {
227
-				$queries[ $dkey ] = $dvalue;
227
+				$queries[$dkey] = $dvalue;
228 228
 			}
229 229
 		}
230 230
 
231 231
 		// Validate the dates passed in the query.
232
-		if ( $this->is_first_order_clause( $queries ) ) {
233
-			$this->validate_date_values( $queries );
232
+		if ($this->is_first_order_clause($queries)) {
233
+			$this->validate_date_values($queries);
234 234
 		}
235 235
 
236
-		foreach ( $queries as $key => $q ) {
237
-			if ( ! is_array( $q ) || in_array( $key, $this->time_keys, true ) ) {
236
+		foreach ($queries as $key => $q) {
237
+			if ( ! is_array($q) || in_array($key, $this->time_keys, true)) {
238 238
 				// This is a first-order query. Trust the values and sanitize when building SQL.
239
-				$cleaned_query[ $key ] = $q;
239
+				$cleaned_query[$key] = $q;
240 240
 			} else {
241 241
 				// Any array without a time key is another query, so we recurse.
242
-				$cleaned_query[] = $this->sanitize_query( $q, $queries );
242
+				$cleaned_query[] = $this->sanitize_query($q, $queries);
243 243
 			}
244 244
 		}
245 245
 
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
 	 * @param  array $query Query clause.
256 256
 	 * @return bool True if this is a first-order clause.
257 257
 	 */
258
-	protected function is_first_order_clause( $query ) {
259
-		$time_keys = array_intersect( $this->time_keys, array_keys( $query ) );
260
-		return ! empty( $time_keys );
258
+	protected function is_first_order_clause($query) {
259
+		$time_keys = array_intersect($this->time_keys, array_keys($query));
260
+		return ! empty($time_keys);
261 261
 	}
262 262
 
263 263
 	/**
@@ -269,9 +269,9 @@  discard block
 block discarded – undo
269 269
 	 * @param array $query A date query or a date subquery.
270 270
 	 * @return string The comparison operator.
271 271
 	 */
272
-	public function get_compare( $query ) {
273
-		if ( ! empty( $query['compare'] ) && in_array( $query['compare'], array( '=', '!=', '>', '>=', '<', '<=', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) )
274
-			return strtoupper( $query['compare'] );
272
+	public function get_compare($query) {
273
+		if ( ! empty($query['compare']) && in_array($query['compare'], array('=', '!=', '>', '>=', '<', '<=', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN')))
274
+			return strtoupper($query['compare']);
275 275
 
276 276
 		return $this->compare;
277 277
 	}
@@ -289,8 +289,8 @@  discard block
 block discarded – undo
289 289
 	 * @param  array $date_query The date_query array.
290 290
 	 * @return bool  True if all values in the query are valid, false if one or more fail.
291 291
 	 */
292
-	public function validate_date_values( $date_query = array() ) {
293
-		if ( empty( $date_query ) ) {
292
+	public function validate_date_values($date_query = array()) {
293
+		if (empty($date_query)) {
294 294
 			return false;
295 295
 		}
296 296
 
@@ -301,30 +301,30 @@  discard block
 block discarded – undo
301 301
 		 * validation routine continue to be sure that all invalid
302 302
 		 * values generate errors too.
303 303
 		 */
304
-		if ( array_key_exists( 'before', $date_query ) && is_array( $date_query['before'] ) ){
305
-			$valid = $this->validate_date_values( $date_query['before'] );
304
+		if (array_key_exists('before', $date_query) && is_array($date_query['before'])) {
305
+			$valid = $this->validate_date_values($date_query['before']);
306 306
 		}
307 307
 
308
-		if ( array_key_exists( 'after', $date_query ) && is_array( $date_query['after'] ) ){
309
-			$valid = $this->validate_date_values( $date_query['after'] );
308
+		if (array_key_exists('after', $date_query) && is_array($date_query['after'])) {
309
+			$valid = $this->validate_date_values($date_query['after']);
310 310
 		}
311 311
 
312 312
 		// Array containing all min-max checks.
313 313
 		$min_max_checks = array();
314 314
 
315 315
 		// Days per year.
316
-		if ( array_key_exists( 'year', $date_query ) ) {
316
+		if (array_key_exists('year', $date_query)) {
317 317
 			/*
318 318
 			 * If a year exists in the date query, we can use it to get the days.
319 319
 			 * If multiple years are provided (as in a BETWEEN), use the first one.
320 320
 			 */
321
-			if ( is_array( $date_query['year'] ) ) {
322
-				$_year = reset( $date_query['year'] );
321
+			if (is_array($date_query['year'])) {
322
+				$_year = reset($date_query['year']);
323 323
 			} else {
324 324
 				$_year = $date_query['year'];
325 325
 			}
326 326
 
327
-			$max_days_of_year = date( 'z', mktime( 0, 0, 0, 12, 31, $_year ) ) + 1;
327
+			$max_days_of_year = date('z', mktime(0, 0, 0, 12, 31, $_year)) + 1;
328 328
 		} else {
329 329
 			// otherwise we use the max of 366 (leap-year)
330 330
 			$max_days_of_year = 366;
@@ -354,12 +354,12 @@  discard block
 block discarded – undo
354 354
 		);
355 355
 
356 356
 		// Weeks per year.
357
-		if ( isset( $_year ) ) {
357
+		if (isset($_year)) {
358 358
 			/*
359 359
 			 * If we have a specific year, use it to calculate number of weeks.
360 360
 			 * Note: the number of weeks in a year is the date in which Dec 28 appears.
361 361
 			 */
362
-			$week_count = date( 'W', mktime( 0, 0, 0, 12, 28, $_year ) );
362
+			$week_count = date('W', mktime(0, 0, 0, 12, 28, $_year));
363 363
 
364 364
 		} else {
365 365
 			// Otherwise set the week-count to a maximum of 53.
@@ -396,26 +396,26 @@  discard block
 block discarded – undo
396 396
 		);
397 397
 
398 398
 		// Concatenate and throw a notice for each invalid value.
399
-		foreach ( $min_max_checks as $key => $check ) {
400
-			if ( ! array_key_exists( $key, $date_query ) ) {
399
+		foreach ($min_max_checks as $key => $check) {
400
+			if ( ! array_key_exists($key, $date_query)) {
401 401
 				continue;
402 402
 			}
403 403
 
404 404
 			// Throw a notice for each failing value.
405
-			foreach ( (array) $date_query[ $key ] as $_value ) {
405
+			foreach ((array) $date_query[$key] as $_value) {
406 406
 				$is_between = $_value >= $check['min'] && $_value <= $check['max'];
407 407
 
408
-				if ( ! is_numeric( $_value ) || ! $is_between ) {
408
+				if ( ! is_numeric($_value) || ! $is_between) {
409 409
 					$error = sprintf(
410 410
 						/* translators: Date query invalid date message: 1: invalid value, 2: type of value, 3: minimum valid value, 4: maximum valid value */
411
-						__( 'Invalid value %1$s for %2$s. Expected value should be between %3$s and %4$s.' ),
412
-						'<code>' . esc_html( $_value ) . '</code>',
413
-						'<code>' . esc_html( $key ) . '</code>',
414
-						'<code>' . esc_html( $check['min'] ) . '</code>',
415
-						'<code>' . esc_html( $check['max'] ) . '</code>'
411
+						__('Invalid value %1$s for %2$s. Expected value should be between %3$s and %4$s.'),
412
+						'<code>'.esc_html($_value).'</code>',
413
+						'<code>'.esc_html($key).'</code>',
414
+						'<code>'.esc_html($check['min']).'</code>',
415
+						'<code>'.esc_html($check['max']).'</code>'
416 416
 					);
417 417
 
418
-					_doing_it_wrong( __CLASS__, $error, '4.1.0' );
418
+					_doing_it_wrong(__CLASS__, $error, '4.1.0');
419 419
 
420 420
 					$valid = false;
421 421
 				}
@@ -423,49 +423,49 @@  discard block
 block discarded – undo
423 423
 		}
424 424
 
425 425
 		// If we already have invalid date messages, don't bother running through checkdate().
426
-		if ( ! $valid ) {
426
+		if ( ! $valid) {
427 427
 			return $valid;
428 428
 		}
429 429
 
430 430
 		$day_month_year_error_msg = '';
431 431
 
432
-		$day_exists   = array_key_exists( 'day', $date_query ) && is_numeric( $date_query['day'] );
433
-		$month_exists = array_key_exists( 'month', $date_query ) && is_numeric( $date_query['month'] );
434
-		$year_exists  = array_key_exists( 'year', $date_query ) && is_numeric( $date_query['year'] );
432
+		$day_exists   = array_key_exists('day', $date_query) && is_numeric($date_query['day']);
433
+		$month_exists = array_key_exists('month', $date_query) && is_numeric($date_query['month']);
434
+		$year_exists  = array_key_exists('year', $date_query) && is_numeric($date_query['year']);
435 435
 
436
-		if ( $day_exists && $month_exists && $year_exists ) {
436
+		if ($day_exists && $month_exists && $year_exists) {
437 437
 			// 1. Checking day, month, year combination.
438
-			if ( ! wp_checkdate( $date_query['month'], $date_query['day'], $date_query['year'], sprintf( '%s-%s-%s', $date_query['year'], $date_query['month'], $date_query['day'] ) ) ) {
438
+			if ( ! wp_checkdate($date_query['month'], $date_query['day'], $date_query['year'], sprintf('%s-%s-%s', $date_query['year'], $date_query['month'], $date_query['day']))) {
439 439
 				/* translators: 1: year, 2: month, 3: day of month */
440 440
 				$day_month_year_error_msg = sprintf(
441
-					__( 'The following values do not describe a valid date: year %1$s, month %2$s, day %3$s.' ),
442
-					'<code>' . esc_html( $date_query['year'] ) . '</code>',
443
-					'<code>' . esc_html( $date_query['month'] ) . '</code>',
444
-					'<code>' . esc_html( $date_query['day'] ) . '</code>'
441
+					__('The following values do not describe a valid date: year %1$s, month %2$s, day %3$s.'),
442
+					'<code>'.esc_html($date_query['year']).'</code>',
443
+					'<code>'.esc_html($date_query['month']).'</code>',
444
+					'<code>'.esc_html($date_query['day']).'</code>'
445 445
 				);
446 446
 
447 447
 				$valid = false;
448 448
 			}
449 449
 
450
-		} elseif ( $day_exists && $month_exists ) {
450
+		} elseif ($day_exists && $month_exists) {
451 451
 			/*
452 452
 			 * 2. checking day, month combination
453 453
 			 * We use 2012 because, as a leap year, it's the most permissive.
454 454
 			 */
455
-			if ( ! wp_checkdate( $date_query['month'], $date_query['day'], 2012, sprintf( '2012-%s-%s', $date_query['month'], $date_query['day'] ) ) ) {
455
+			if ( ! wp_checkdate($date_query['month'], $date_query['day'], 2012, sprintf('2012-%s-%s', $date_query['month'], $date_query['day']))) {
456 456
 				/* translators: 1: month, 2: day of month */
457 457
 				$day_month_year_error_msg = sprintf(
458
-					__( 'The following values do not describe a valid date: month %1$s, day %2$s.' ),
459
-					'<code>' . esc_html( $date_query['month'] ) . '</code>',
460
-					'<code>' . esc_html( $date_query['day'] ) . '</code>'
458
+					__('The following values do not describe a valid date: month %1$s, day %2$s.'),
459
+					'<code>'.esc_html($date_query['month']).'</code>',
460
+					'<code>'.esc_html($date_query['day']).'</code>'
461 461
 				);
462 462
 
463 463
 				$valid = false;
464 464
 			}
465 465
 		}
466 466
 
467
-		if ( ! empty( $day_month_year_error_msg ) ) {
468
-			_doing_it_wrong( __CLASS__, $day_month_year_error_msg, '4.1.0' );
467
+		if ( ! empty($day_month_year_error_msg)) {
468
+			_doing_it_wrong(__CLASS__, $day_month_year_error_msg, '4.1.0');
469 469
 		}
470 470
 
471 471
 		return $valid;
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 	 * @param string $column The user-supplied column name.
486 486
 	 * @return string A validated column name value.
487 487
 	 */
488
-	public function validate_column( $column ) {
488
+	public function validate_column($column) {
489 489
 		global $wpdb;
490 490
 
491 491
 		$valid_columns = array(
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 		);
496 496
 
497 497
 		// Attempt to detect a table prefix.
498
-		if ( false === strpos( $column, '.' ) ) {
498
+		if (false === strpos($column, '.')) {
499 499
 			/**
500 500
 			 * Filter the list of valid date query columns.
501 501
 			 *
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
 			 *                             'post_modified_gmt', 'comment_date', 'comment_date_gmt',
508 508
 			 *	                           'user_registered'
509 509
 			 */
510
-			if ( ! in_array( $column, apply_filters( 'date_query_valid_columns', $valid_columns ) ) ) {
510
+			if ( ! in_array($column, apply_filters('date_query_valid_columns', $valid_columns))) {
511 511
 				$column = 'post_date';
512 512
 			}
513 513
 
@@ -528,9 +528,9 @@  discard block
 block discarded – undo
528 528
 			);
529 529
 
530 530
 			// If it's a known column name, add the appropriate table prefix.
531
-			foreach ( $known_columns as $table_name => $table_columns ) {
532
-				if ( in_array( $column, $table_columns ) ) {
533
-					$column = $table_name . '.' . $column;
531
+			foreach ($known_columns as $table_name => $table_columns) {
532
+				if (in_array($column, $table_columns)) {
533
+					$column = $table_name.'.'.$column;
534 534
 					break;
535 535
 				}
536 536
 			}
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 		}
539 539
 
540 540
 		// Remove unsafe characters.
541
-		return preg_replace( '/[^a-zA-Z0-9_$\.]/', '', $column );
541
+		return preg_replace('/[^a-zA-Z0-9_$\.]/', '', $column);
542 542
 	}
543 543
 
544 544
 	/**
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 		 * @param string        $where WHERE clause of the date query.
563 563
 		 * @param WP_Date_Query $this  The WP_Date_Query instance.
564 564
 		 */
565
-		return apply_filters( 'get_date_sql', $where, $this );
565
+		return apply_filters('get_date_sql', $where, $this);
566 566
 	}
567 567
 
568 568
 	/**
@@ -582,10 +582,10 @@  discard block
 block discarded – undo
582 582
 	 * }
583 583
 	 */
584 584
 	protected function get_sql_clauses() {
585
-		$sql = $this->get_sql_for_query( $this->queries );
585
+		$sql = $this->get_sql_for_query($this->queries);
586 586
 
587
-		if ( ! empty( $sql['where'] ) ) {
588
-			$sql['where'] = ' AND ' . $sql['where'];
587
+		if ( ! empty($sql['where'])) {
588
+			$sql['where'] = ' AND '.$sql['where'];
589 589
 		}
590 590
 
591 591
 		return $sql;
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
 	 *     @type string $where SQL fragment to append to the main WHERE clause.
611 611
 	 * }
612 612
 	 */
613
-	protected function get_sql_for_query( $query, $depth = 0 ) {
613
+	protected function get_sql_for_query($query, $depth = 0) {
614 614
 		$sql_chunks = array(
615 615
 			'join'  => array(),
616 616
 			'where' => array(),
@@ -622,32 +622,32 @@  discard block
 block discarded – undo
622 622
 		);
623 623
 
624 624
 		$indent = '';
625
-		for ( $i = 0; $i < $depth; $i++ ) {
625
+		for ($i = 0; $i < $depth; $i++) {
626 626
 			$indent .= "  ";
627 627
 		}
628 628
 
629
-		foreach ( $query as $key => $clause ) {
630
-			if ( 'relation' === $key ) {
629
+		foreach ($query as $key => $clause) {
630
+			if ('relation' === $key) {
631 631
 				$relation = $query['relation'];
632
-			} elseif ( is_array( $clause ) ) {
632
+			} elseif (is_array($clause)) {
633 633
 
634 634
 				// This is a first-order clause.
635
-				if ( $this->is_first_order_clause( $clause ) ) {
636
-					$clause_sql = $this->get_sql_for_clause( $clause, $query );
635
+				if ($this->is_first_order_clause($clause)) {
636
+					$clause_sql = $this->get_sql_for_clause($clause, $query);
637 637
 
638
-					$where_count = count( $clause_sql['where'] );
639
-					if ( ! $where_count ) {
638
+					$where_count = count($clause_sql['where']);
639
+					if ( ! $where_count) {
640 640
 						$sql_chunks['where'][] = '';
641
-					} elseif ( 1 === $where_count ) {
641
+					} elseif (1 === $where_count) {
642 642
 						$sql_chunks['where'][] = $clause_sql['where'][0];
643 643
 					} else {
644
-						$sql_chunks['where'][] = '( ' . implode( ' AND ', $clause_sql['where'] ) . ' )';
644
+						$sql_chunks['where'][] = '( '.implode(' AND ', $clause_sql['where']).' )';
645 645
 					}
646 646
 
647
-					$sql_chunks['join'] = array_merge( $sql_chunks['join'], $clause_sql['join'] );
647
+					$sql_chunks['join'] = array_merge($sql_chunks['join'], $clause_sql['join']);
648 648
 				// This is a subquery, so we recurse.
649 649
 				} else {
650
-					$clause_sql = $this->get_sql_for_query( $clause, $depth + 1 );
650
+					$clause_sql = $this->get_sql_for_query($clause, $depth + 1);
651 651
 
652 652
 					$sql_chunks['where'][] = $clause_sql['where'];
653 653
 					$sql_chunks['join'][]  = $clause_sql['join'];
@@ -656,21 +656,21 @@  discard block
 block discarded – undo
656 656
 		}
657 657
 
658 658
 		// Filter to remove empties.
659
-		$sql_chunks['join']  = array_filter( $sql_chunks['join'] );
660
-		$sql_chunks['where'] = array_filter( $sql_chunks['where'] );
659
+		$sql_chunks['join']  = array_filter($sql_chunks['join']);
660
+		$sql_chunks['where'] = array_filter($sql_chunks['where']);
661 661
 
662
-		if ( empty( $relation ) ) {
662
+		if (empty($relation)) {
663 663
 			$relation = 'AND';
664 664
 		}
665 665
 
666 666
 		// Filter duplicate JOIN clauses and combine into a single string.
667
-		if ( ! empty( $sql_chunks['join'] ) ) {
668
-			$sql['join'] = implode( ' ', array_unique( $sql_chunks['join'] ) );
667
+		if ( ! empty($sql_chunks['join'])) {
668
+			$sql['join'] = implode(' ', array_unique($sql_chunks['join']));
669 669
 		}
670 670
 
671 671
 		// Generate a single WHERE clause with proper brackets and indentation.
672
-		if ( ! empty( $sql_chunks['where'] ) ) {
673
-			$sql['where'] = '( ' . "\n  " . $indent . implode( ' ' . "\n  " . $indent . $relation . ' ' . "\n  " . $indent, $sql_chunks['where'] ) . "\n" . $indent . ')';
672
+		if ( ! empty($sql_chunks['where'])) {
673
+			$sql['where'] = '( '."\n  ".$indent.implode(' '."\n  ".$indent.$relation.' '."\n  ".$indent, $sql_chunks['where'])."\n".$indent.')';
674 674
 		}
675 675
 
676 676
 		return $sql;
@@ -693,8 +693,8 @@  discard block
 block discarded – undo
693 693
 	 *     @type string $where SQL fragment to append to the main WHERE clause.
694 694
 	 * }
695 695
 	 */
696
-	protected function get_sql_for_subquery( $query ) {
697
-		return $this->get_sql_for_clause( $query, '' );
696
+	protected function get_sql_for_subquery($query) {
697
+		return $this->get_sql_for_clause($query, '');
698 698
 	}
699 699
 
700 700
 	/**
@@ -712,72 +712,72 @@  discard block
 block discarded – undo
712 712
 	 *     @type string $where SQL fragment to append to the main WHERE clause.
713 713
 	 * }
714 714
 	 */
715
-	protected function get_sql_for_clause( $query, $parent_query ) {
715
+	protected function get_sql_for_clause($query, $parent_query) {
716 716
 		global $wpdb;
717 717
 
718 718
 		// The sub-parts of a $where part.
719 719
 		$where_parts = array();
720 720
 
721
-		$column = ( ! empty( $query['column'] ) ) ? esc_sql( $query['column'] ) : $this->column;
721
+		$column = ( ! empty($query['column'])) ? esc_sql($query['column']) : $this->column;
722 722
 
723
-		$column = $this->validate_column( $column );
723
+		$column = $this->validate_column($column);
724 724
 
725
-		$compare = $this->get_compare( $query );
725
+		$compare = $this->get_compare($query);
726 726
 
727
-		$inclusive = ! empty( $query['inclusive'] );
727
+		$inclusive = ! empty($query['inclusive']);
728 728
 
729 729
 		// Assign greater- and less-than values.
730 730
 		$lt = '<';
731 731
 		$gt = '>';
732 732
 
733
-		if ( $inclusive ) {
733
+		if ($inclusive) {
734 734
 			$lt .= '=';
735 735
 			$gt .= '=';
736 736
 		}
737 737
 
738 738
 		// Range queries.
739
-		if ( ! empty( $query['after'] ) )
740
-			$where_parts[] = $wpdb->prepare( "$column $gt %s", $this->build_mysql_datetime( $query['after'], ! $inclusive ) );
739
+		if ( ! empty($query['after']))
740
+			$where_parts[] = $wpdb->prepare("$column $gt %s", $this->build_mysql_datetime($query['after'], ! $inclusive));
741 741
 
742
-		if ( ! empty( $query['before'] ) )
743
-			$where_parts[] = $wpdb->prepare( "$column $lt %s", $this->build_mysql_datetime( $query['before'], $inclusive ) );
742
+		if ( ! empty($query['before']))
743
+			$where_parts[] = $wpdb->prepare("$column $lt %s", $this->build_mysql_datetime($query['before'], $inclusive));
744 744
 
745 745
 		// Specific value queries.
746 746
 
747
-		if ( isset( $query['year'] ) && $value = $this->build_value( $compare, $query['year'] ) )
747
+		if (isset($query['year']) && $value = $this->build_value($compare, $query['year']))
748 748
 			$where_parts[] = "YEAR( $column ) $compare $value";
749 749
 
750
-		if ( isset( $query['month'] ) && $value = $this->build_value( $compare, $query['month'] ) ) {
750
+		if (isset($query['month']) && $value = $this->build_value($compare, $query['month'])) {
751 751
 			$where_parts[] = "MONTH( $column ) $compare $value";
752
-		} elseif ( isset( $query['monthnum'] ) && $value = $this->build_value( $compare, $query['monthnum'] ) ) {
752
+		} elseif (isset($query['monthnum']) && $value = $this->build_value($compare, $query['monthnum'])) {
753 753
 			$where_parts[] = "MONTH( $column ) $compare $value";
754 754
 		}
755
-		if ( isset( $query['week'] ) && false !== ( $value = $this->build_value( $compare, $query['week'] ) ) ) {
756
-			$where_parts[] = _wp_mysql_week( $column ) . " $compare $value";
757
-		} elseif ( isset( $query['w'] ) && false !== ( $value = $this->build_value( $compare, $query['w'] ) ) ) {
758
-			$where_parts[] = _wp_mysql_week( $column ) . " $compare $value";
755
+		if (isset($query['week']) && false !== ($value = $this->build_value($compare, $query['week']))) {
756
+			$where_parts[] = _wp_mysql_week($column)." $compare $value";
757
+		} elseif (isset($query['w']) && false !== ($value = $this->build_value($compare, $query['w']))) {
758
+			$where_parts[] = _wp_mysql_week($column)." $compare $value";
759 759
 		}
760
-		if ( isset( $query['dayofyear'] ) && $value = $this->build_value( $compare, $query['dayofyear'] ) )
760
+		if (isset($query['dayofyear']) && $value = $this->build_value($compare, $query['dayofyear']))
761 761
 			$where_parts[] = "DAYOFYEAR( $column ) $compare $value";
762 762
 
763
-		if ( isset( $query['day'] ) && $value = $this->build_value( $compare, $query['day'] ) )
763
+		if (isset($query['day']) && $value = $this->build_value($compare, $query['day']))
764 764
 			$where_parts[] = "DAYOFMONTH( $column ) $compare $value";
765 765
 
766
-		if ( isset( $query['dayofweek'] ) && $value = $this->build_value( $compare, $query['dayofweek'] ) )
766
+		if (isset($query['dayofweek']) && $value = $this->build_value($compare, $query['dayofweek']))
767 767
 			$where_parts[] = "DAYOFWEEK( $column ) $compare $value";
768 768
 
769
-		if ( isset( $query['dayofweek_iso'] ) && $value = $this->build_value( $compare, $query['dayofweek_iso'] ) )
769
+		if (isset($query['dayofweek_iso']) && $value = $this->build_value($compare, $query['dayofweek_iso']))
770 770
 			$where_parts[] = "WEEKDAY( $column ) + 1 $compare $value";
771 771
 
772
-		if ( isset( $query['hour'] ) || isset( $query['minute'] ) || isset( $query['second'] ) ) {
772
+		if (isset($query['hour']) || isset($query['minute']) || isset($query['second'])) {
773 773
 			// Avoid notices.
774
-			foreach ( array( 'hour', 'minute', 'second' ) as $unit ) {
775
-				if ( ! isset( $query[ $unit ] ) ) {
776
-					$query[ $unit ] = null;
774
+			foreach (array('hour', 'minute', 'second') as $unit) {
775
+				if ( ! isset($query[$unit])) {
776
+					$query[$unit] = null;
777 777
 				}
778 778
 			}
779 779
 
780
-			if ( $time_query = $this->build_time_query( $column, $compare, $query['hour'], $query['minute'], $query['second'] ) ) {
780
+			if ($time_query = $this->build_time_query($column, $compare, $query['hour'], $query['minute'], $query['second'])) {
781 781
 				$where_parts[] = $time_query;
782 782
 			}
783 783
 		}
@@ -802,45 +802,45 @@  discard block
 block discarded – undo
802 802
 	 * @param string|array $value The value
803 803
 	 * @return string|false|int The value to be used in SQL or false on error.
804 804
 	 */
805
-	public function build_value( $compare, $value ) {
806
-		if ( ! isset( $value ) )
805
+	public function build_value($compare, $value) {
806
+		if ( ! isset($value))
807 807
 			return false;
808 808
 
809
-		switch ( $compare ) {
809
+		switch ($compare) {
810 810
 			case 'IN':
811 811
 			case 'NOT IN':
812 812
 				$value = (array) $value;
813 813
 
814 814
 				// Remove non-numeric values.
815
-				$value = array_filter( $value, 'is_numeric' );
815
+				$value = array_filter($value, 'is_numeric');
816 816
 
817
-				if ( empty( $value ) ) {
817
+				if (empty($value)) {
818 818
 					return false;
819 819
 				}
820 820
 
821
-				return '(' . implode( ',', array_map( 'intval', $value ) ) . ')';
821
+				return '('.implode(',', array_map('intval', $value)).')';
822 822
 
823 823
 			case 'BETWEEN':
824 824
 			case 'NOT BETWEEN':
825
-				if ( ! is_array( $value ) || 2 != count( $value ) ) {
826
-					$value = array( $value, $value );
825
+				if ( ! is_array($value) || 2 != count($value)) {
826
+					$value = array($value, $value);
827 827
 				} else {
828
-					$value = array_values( $value );
828
+					$value = array_values($value);
829 829
 				}
830 830
 
831 831
 				// If either value is non-numeric, bail.
832
-				foreach ( $value as $v ) {
833
-					if ( ! is_numeric( $v ) ) {
832
+				foreach ($value as $v) {
833
+					if ( ! is_numeric($v)) {
834 834
 						return false;
835 835
 					}
836 836
 				}
837 837
 
838
-				$value = array_map( 'intval', $value );
838
+				$value = array_map('intval', $value);
839 839
 
840
-				return $value[0] . ' AND ' . $value[1];
840
+				return $value[0].' AND '.$value[1];
841 841
 
842 842
 			default;
843
-				if ( ! is_numeric( $value ) ) {
843
+				if ( ! is_numeric($value)) {
844 844
 					return false;
845 845
 				}
846 846
 
@@ -865,75 +865,75 @@  discard block
 block discarded – undo
865 865
 	 *                                     Default: false.
866 866
 	 * @return string|false A MySQL format date/time or false on failure
867 867
 	 */
868
-	public function build_mysql_datetime( $datetime, $default_to_max = false ) {
869
-		$now = current_time( 'timestamp' );
868
+	public function build_mysql_datetime($datetime, $default_to_max = false) {
869
+		$now = current_time('timestamp');
870 870
 
871
-		if ( ! is_array( $datetime ) ) {
871
+		if ( ! is_array($datetime)) {
872 872
 
873 873
 			/*
874 874
 			 * Try to parse some common date formats, so we can detect
875 875
 			 * the level of precision and support the 'inclusive' parameter.
876 876
 			 */
877
-			if ( preg_match( '/^(\d{4})$/', $datetime, $matches ) ) {
877
+			if (preg_match('/^(\d{4})$/', $datetime, $matches)) {
878 878
 				// Y
879 879
 				$datetime = array(
880
-					'year' => intval( $matches[1] ),
880
+					'year' => intval($matches[1]),
881 881
 				);
882 882
 
883
-			} elseif ( preg_match( '/^(\d{4})\-(\d{2})$/', $datetime, $matches ) ) {
883
+			} elseif (preg_match('/^(\d{4})\-(\d{2})$/', $datetime, $matches)) {
884 884
 				// Y-m
885 885
 				$datetime = array(
886
-					'year'  => intval( $matches[1] ),
887
-					'month' => intval( $matches[2] ),
886
+					'year'  => intval($matches[1]),
887
+					'month' => intval($matches[2]),
888 888
 				);
889 889
 
890
-			} elseif ( preg_match( '/^(\d{4})\-(\d{2})\-(\d{2})$/', $datetime, $matches ) ) {
890
+			} elseif (preg_match('/^(\d{4})\-(\d{2})\-(\d{2})$/', $datetime, $matches)) {
891 891
 				// Y-m-d
892 892
 				$datetime = array(
893
-					'year'  => intval( $matches[1] ),
894
-					'month' => intval( $matches[2] ),
895
-					'day'   => intval( $matches[3] ),
893
+					'year'  => intval($matches[1]),
894
+					'month' => intval($matches[2]),
895
+					'day'   => intval($matches[3]),
896 896
 				);
897 897
 
898
-			} elseif ( preg_match( '/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2})$/', $datetime, $matches ) ) {
898
+			} elseif (preg_match('/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2})$/', $datetime, $matches)) {
899 899
 				// Y-m-d H:i
900 900
 				$datetime = array(
901
-					'year'   => intval( $matches[1] ),
902
-					'month'  => intval( $matches[2] ),
903
-					'day'    => intval( $matches[3] ),
904
-					'hour'   => intval( $matches[4] ),
905
-					'minute' => intval( $matches[5] ),
901
+					'year'   => intval($matches[1]),
902
+					'month'  => intval($matches[2]),
903
+					'day'    => intval($matches[3]),
904
+					'hour'   => intval($matches[4]),
905
+					'minute' => intval($matches[5]),
906 906
 				);
907 907
 			}
908 908
 
909 909
 			// If no match is found, we don't support default_to_max.
910
-			if ( ! is_array( $datetime ) ) {
910
+			if ( ! is_array($datetime)) {
911 911
 				// @todo Timezone issues here possibly
912
-				return gmdate( 'Y-m-d H:i:s', strtotime( $datetime, $now ) );
912
+				return gmdate('Y-m-d H:i:s', strtotime($datetime, $now));
913 913
 			}
914 914
 		}
915 915
 
916
-		$datetime = array_map( 'absint', $datetime );
916
+		$datetime = array_map('absint', $datetime);
917 917
 
918
-		if ( ! isset( $datetime['year'] ) )
919
-			$datetime['year'] = gmdate( 'Y', $now );
918
+		if ( ! isset($datetime['year']))
919
+			$datetime['year'] = gmdate('Y', $now);
920 920
 
921
-		if ( ! isset( $datetime['month'] ) )
922
-			$datetime['month'] = ( $default_to_max ) ? 12 : 1;
921
+		if ( ! isset($datetime['month']))
922
+			$datetime['month'] = ($default_to_max) ? 12 : 1;
923 923
 
924
-		if ( ! isset( $datetime['day'] ) )
925
-			$datetime['day'] = ( $default_to_max ) ? (int) date( 't', mktime( 0, 0, 0, $datetime['month'], 1, $datetime['year'] ) ) : 1;
924
+		if ( ! isset($datetime['day']))
925
+			$datetime['day'] = ($default_to_max) ? (int) date('t', mktime(0, 0, 0, $datetime['month'], 1, $datetime['year'])) : 1;
926 926
 
927
-		if ( ! isset( $datetime['hour'] ) )
928
-			$datetime['hour'] = ( $default_to_max ) ? 23 : 0;
927
+		if ( ! isset($datetime['hour']))
928
+			$datetime['hour'] = ($default_to_max) ? 23 : 0;
929 929
 
930
-		if ( ! isset( $datetime['minute'] ) )
931
-			$datetime['minute'] = ( $default_to_max ) ? 59 : 0;
930
+		if ( ! isset($datetime['minute']))
931
+			$datetime['minute'] = ($default_to_max) ? 59 : 0;
932 932
 
933
-		if ( ! isset( $datetime['second'] ) )
934
-			$datetime['second'] = ( $default_to_max ) ? 59 : 0;
933
+		if ( ! isset($datetime['second']))
934
+			$datetime['second'] = ($default_to_max) ? 59 : 0;
935 935
 
936
-		return sprintf( '%04d-%02d-%02d %02d:%02d:%02d', $datetime['year'], $datetime['month'], $datetime['day'], $datetime['hour'], $datetime['minute'], $datetime['second'] );
936
+		return sprintf('%04d-%02d-%02d %02d:%02d:%02d', $datetime['year'], $datetime['month'], $datetime['day'], $datetime['hour'], $datetime['minute'], $datetime['second']);
937 937
 	}
938 938
 
939 939
 	/**
@@ -953,48 +953,48 @@  discard block
 block discarded – undo
953 953
 	 * @param int|null $second Optional. A second value (0-59).
954 954
 	 * @return string|false A query part or false on failure.
955 955
 	 */
956
-	public function build_time_query( $column, $compare, $hour = null, $minute = null, $second = null ) {
956
+	public function build_time_query($column, $compare, $hour = null, $minute = null, $second = null) {
957 957
 		global $wpdb;
958 958
 
959 959
 		// Have to have at least one
960
-		if ( ! isset( $hour ) && ! isset( $minute ) && ! isset( $second ) )
960
+		if ( ! isset($hour) && ! isset($minute) && ! isset($second))
961 961
 			return false;
962 962
 
963 963
 		// Complex combined queries aren't supported for multi-value queries
964
-		if ( in_array( $compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) {
964
+		if (in_array($compare, array('IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'))) {
965 965
 			$return = array();
966 966
 
967
-			if ( isset( $hour ) && false !== ( $value = $this->build_value( $compare, $hour ) ) )
967
+			if (isset($hour) && false !== ($value = $this->build_value($compare, $hour)))
968 968
 				$return[] = "HOUR( $column ) $compare $value";
969 969
 
970
-			if ( isset( $minute ) && false !== ( $value = $this->build_value( $compare, $minute ) ) )
970
+			if (isset($minute) && false !== ($value = $this->build_value($compare, $minute)))
971 971
 				$return[] = "MINUTE( $column ) $compare $value";
972 972
 
973
-			if ( isset( $second ) && false !== ( $value = $this->build_value( $compare, $second ) ) )
973
+			if (isset($second) && false !== ($value = $this->build_value($compare, $second)))
974 974
 				$return[] = "SECOND( $column ) $compare $value";
975 975
 
976
-			return implode( ' AND ', $return );
976
+			return implode(' AND ', $return);
977 977
 		}
978 978
 
979 979
 		// Cases where just one unit is set
980
-		if ( isset( $hour ) && ! isset( $minute ) && ! isset( $second ) && false !== ( $value = $this->build_value( $compare, $hour ) ) ) {
980
+		if (isset($hour) && ! isset($minute) && ! isset($second) && false !== ($value = $this->build_value($compare, $hour))) {
981 981
 			return "HOUR( $column ) $compare $value";
982
-		} elseif ( ! isset( $hour ) && isset( $minute ) && ! isset( $second ) && false !== ( $value = $this->build_value( $compare, $minute ) ) ) {
982
+		} elseif ( ! isset($hour) && isset($minute) && ! isset($second) && false !== ($value = $this->build_value($compare, $minute))) {
983 983
 			return "MINUTE( $column ) $compare $value";
984
-		} elseif ( ! isset( $hour ) && ! isset( $minute ) && isset( $second ) && false !== ( $value = $this->build_value( $compare, $second ) ) ) {
984
+		} elseif ( ! isset($hour) && ! isset($minute) && isset($second) && false !== ($value = $this->build_value($compare, $second))) {
985 985
 			return "SECOND( $column ) $compare $value";
986 986
 		}
987 987
 
988 988
 		// Single units were already handled. Since hour & second isn't allowed, minute must to be set.
989
-		if ( ! isset( $minute ) )
989
+		if ( ! isset($minute))
990 990
 			return false;
991 991
 
992 992
 		$format = $time = '';
993 993
 
994 994
 		// Hour
995
-		if ( null !== $hour ) {
995
+		if (null !== $hour) {
996 996
 			$format .= '%H.';
997
-			$time   .= sprintf( '%02d', $hour ) . '.';
997
+			$time   .= sprintf('%02d', $hour).'.';
998 998
 		} else {
999 999
 			$format .= '0.';
1000 1000
 			$time   .= '0.';
@@ -1002,13 +1002,13 @@  discard block
 block discarded – undo
1002 1002
 
1003 1003
 		// Minute
1004 1004
 		$format .= '%i';
1005
-		$time   .= sprintf( '%02d', $minute );
1005
+		$time   .= sprintf('%02d', $minute);
1006 1006
 
1007
-		if ( isset( $second ) ) {
1007
+		if (isset($second)) {
1008 1008
 			$format .= '%s';
1009
-			$time   .= sprintf( '%02d', $second );
1009
+			$time   .= sprintf('%02d', $second);
1010 1010
 		}
1011 1011
 
1012
-		return $wpdb->prepare( "DATE_FORMAT( $column, %s ) $compare %f", $format, $time );
1012
+		return $wpdb->prepare("DATE_FORMAT( $column, %s ) $compare %f", $format, $time);
1013 1013
 	}
1014 1014
 }
Please login to merge, or discard this patch.
src/wp-includes/feed.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -524,7 +524,7 @@
 block discarded – undo
524 524
  * @since 2.5.0
525 525
  *
526 526
  * @param string $data Input string
527
- * @return array array(type, value)
527
+ * @return string[] array(type, value)
528 528
  */
529 529
 function prep_atom_text_construct($data) {
530 530
 	if (strpos($data, '<') === false && strpos($data, '&') === false) {
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * WordPress Feed API
4
- *
5
- * Many of the functions used in here belong in The Loop, or The Loop for the
6
- * Feeds.
7
- *
8
- * @package WordPress
9
- * @subpackage Feed
10
- */
3
+	 * WordPress Feed API
4
+	 *
5
+	 * Many of the functions used in here belong in The Loop, or The Loop for the
6
+	 * Feeds.
7
+	 *
8
+	 * @package WordPress
9
+	 * @subpackage Feed
10
+	 */
11 11
 
12 12
 /**
13 13
  * RSS container for the bloginfo function.
Please login to merge, or discard this patch.
Braces   +42 added lines, -28 removed lines patch added patch discarded remove patch
@@ -179,8 +179,9 @@  discard block
 block discarded – undo
179 179
  * @return string The filtered content.
180 180
  */
181 181
 function get_the_content_feed($feed_type = null) {
182
-	if ( !$feed_type )
183
-		$feed_type = get_default_feed();
182
+	if ( !$feed_type ) {
183
+			$feed_type = get_default_feed();
184
+	}
184 185
 
185 186
 	/** This filter is documented in wp-includes/post-template.php */
186 187
 	$content = apply_filters( 'the_content', get_the_content() );
@@ -281,8 +282,9 @@  discard block
 block discarded – undo
281 282
 function get_comment_guid($comment_id = null) {
282 283
 	$comment = get_comment($comment_id);
283 284
 
284
-	if ( !is_object($comment) )
285
-		return false;
285
+	if ( !is_object($comment) ) {
286
+			return false;
287
+	}
286 288
 
287 289
 	return get_the_guid($comment->comment_post_ID) . '#comment-' . $comment->comment_ID;
288 290
 }
@@ -365,34 +367,41 @@  discard block
 block discarded – undo
365 367
  * @return string All of the post categories for displaying in the feed.
366 368
  */
367 369
 function get_the_category_rss($type = null) {
368
-	if ( empty($type) )
369
-		$type = get_default_feed();
370
+	if ( empty($type) ) {
371
+			$type = get_default_feed();
372
+	}
370 373
 	$categories = get_the_category();
371 374
 	$tags = get_the_tags();
372 375
 	$the_list = '';
373 376
 	$cat_names = array();
374 377
 
375 378
 	$filter = 'rss';
376
-	if ( 'atom' == $type )
377
-		$filter = 'raw';
379
+	if ( 'atom' == $type ) {
380
+			$filter = 'raw';
381
+	}
378 382
 
379
-	if ( !empty($categories) ) foreach ( (array) $categories as $category ) {
383
+	if ( !empty($categories) ) {
384
+		foreach ( (array) $categories as $category ) {
380 385
 		$cat_names[] = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter);
381 386
 	}
387
+	}
382 388
 
383
-	if ( !empty($tags) ) foreach ( (array) $tags as $tag ) {
389
+	if ( !empty($tags) ) {
390
+		foreach ( (array) $tags as $tag ) {
384 391
 		$cat_names[] = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter);
385 392
 	}
393
+	}
386 394
 
387 395
 	$cat_names = array_unique($cat_names);
388 396
 
389 397
 	foreach ( $cat_names as $cat_name ) {
390
-		if ( 'rdf' == $type )
391
-			$the_list .= "\t\t<dc:subject><![CDATA[$cat_name]]></dc:subject>\n";
392
-		elseif ( 'atom' == $type )
393
-			$the_list .= sprintf( '<category scheme="%1$s" term="%2$s" />', esc_attr( get_bloginfo_rss( 'url' ) ), esc_attr( $cat_name ) );
394
-		else
395
-			$the_list .= "\t\t<category><![CDATA[" . @html_entity_decode( $cat_name, ENT_COMPAT, get_option('blog_charset') ) . "]]></category>\n";
398
+		if ( 'rdf' == $type ) {
399
+					$the_list .= "\t\t<dc:subject><![CDATA[$cat_name]]></dc:subject>\n";
400
+		} elseif ( 'atom' == $type ) {
401
+					$the_list .= sprintf( '<category scheme="%1$s" term="%2$s" />', esc_attr( get_bloginfo_rss( 'url' ) ), esc_attr( $cat_name ) );
402
+		} else {
403
+					$the_list .= "\t\t<category><![CDATA[" . @html_entity_decode( $cat_name, ENT_COMPAT, get_option('blog_charset') ) . "]]></category>\n";
404
+		}
396 405
 	}
397 406
 
398 407
 	/**
@@ -428,10 +437,11 @@  discard block
 block discarded – undo
428 437
  */
429 438
 function html_type_rss() {
430 439
 	$type = get_bloginfo('html_type');
431
-	if (strpos($type, 'xhtml') !== false)
432
-		$type = 'xhtml';
433
-	else
434
-		$type = 'html';
440
+	if (strpos($type, 'xhtml') !== false) {
441
+			$type = 'xhtml';
442
+	} else {
443
+			$type = 'html';
444
+	}
435 445
 	echo $type;
436 446
 }
437 447
 
@@ -450,8 +460,9 @@  discard block
 block discarded – undo
450 460
  * @since 1.5.0
451 461
  */
452 462
 function rss_enclosure() {
453
-	if ( post_password_required() )
454
-		return;
463
+	if ( post_password_required() ) {
464
+			return;
465
+	}
455 466
 
456 467
 	foreach ( (array) get_post_custom() as $key => $val) {
457 468
 		if ($key == 'enclosure') {
@@ -489,8 +500,9 @@  discard block
 block discarded – undo
489 500
  * @since 2.2.0
490 501
  */
491 502
 function atom_enclosure() {
492
-	if ( post_password_required() )
493
-		return;
503
+	if ( post_password_required() ) {
504
+			return;
505
+	}
494 506
 
495 507
 	foreach ( (array) get_post_custom() as $key => $val ) {
496 508
 		if ($key == 'enclosure') {
@@ -618,8 +630,9 @@  discard block
 block discarded – undo
618 630
  * @since 2.8.0
619 631
  */
620 632
 function feed_content_type( $type = '' ) {
621
-	if ( empty($type) )
622
-		$type = get_default_feed();
633
+	if ( empty($type) ) {
634
+			$type = get_default_feed();
635
+	}
623 636
 
624 637
 	$types = array(
625 638
 		'rss'  => 'application/rss+xml',
@@ -683,8 +696,9 @@  discard block
 block discarded – undo
683 696
 	$feed->set_output_encoding( get_option( 'blog_charset' ) );
684 697
 	$feed->handle_content_type();
685 698
 
686
-	if ( $feed->error() )
687
-		return new WP_Error( 'simplepie-error', $feed->error() );
699
+	if ( $feed->error() ) {
700
+			return new WP_Error( 'simplepie-error', $feed->error() );
701
+	}
688 702
 
689 703
 	return $feed;
690 704
 }
Please login to merge, or discard this patch.
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 * @param string $info Converted string value of the blog information.
36 36
 	 * @param string $show The type of blog information to retrieve.
37 37
 	 */
38
-	return apply_filters( 'get_bloginfo_rss', convert_chars( $info ), $show );
38
+	return apply_filters('get_bloginfo_rss', convert_chars($info), $show);
39 39
 }
40 40
 
41 41
 /**
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	 * @param string $rss_container RSS container for the blog information.
62 62
 	 * @param string $show          The type of blog information to retrieve.
63 63
 	 */
64
-	echo apply_filters( 'bloginfo_rss', get_bloginfo_rss( $show ), $show );
64
+	echo apply_filters('bloginfo_rss', get_bloginfo_rss($show), $show);
65 65
 }
66 66
 
67 67
 /**
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 * @param string $feed_type Type of default feed. Possible values include 'rss2', 'atom'.
84 84
 	 *                          Default 'rss2'.
85 85
 	 */
86
-	$default_feed = apply_filters( 'default_feed', 'rss2' );
86
+	$default_feed = apply_filters('default_feed', 'rss2');
87 87
 	return 'rss' == $default_feed ? 'rss2' : $default_feed;
88 88
 }
89 89
 
@@ -96,10 +96,10 @@  discard block
 block discarded – undo
96 96
  * @param string $deprecated Unused..
97 97
  * @return string The document title.
98 98
  */
99
-function get_wp_title_rss( $deprecated = '&#8211;' ) {
100
-	if ( '&#8211;' !== $deprecated ) {
99
+function get_wp_title_rss($deprecated = '&#8211;') {
100
+	if ('&#8211;' !== $deprecated) {
101 101
 		/* translators: %s: 'document_title_separator' filter name */
102
-		_deprecated_argument( __FUNCTION__, '4.4.0', sprintf( __( 'Use the %s filter instead.' ), '<code>document_title_separator</code>' ) );
102
+		_deprecated_argument(__FUNCTION__, '4.4.0', sprintf(__('Use the %s filter instead.'), '<code>document_title_separator</code>'));
103 103
 	}
104 104
 
105 105
 	/**
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 * @param string $title      The current blog title.
112 112
 	 * @param string $deprecated Unused.
113 113
 	 */
114
-	return apply_filters( 'get_wp_title_rss', wp_get_document_title(), $deprecated );
114
+	return apply_filters('get_wp_title_rss', wp_get_document_title(), $deprecated);
115 115
 }
116 116
 
117 117
 /**
@@ -122,10 +122,10 @@  discard block
 block discarded – undo
122 122
  *
123 123
  * @param string $deprecated Unused.
124 124
  */
125
-function wp_title_rss( $deprecated = '&#8211;' ) {
126
-	if ( '&#8211;' !== $deprecated ) {
125
+function wp_title_rss($deprecated = '&#8211;') {
126
+	if ('&#8211;' !== $deprecated) {
127 127
 		/* translators: %s: 'document_title_separator' filter name */
128
-		_deprecated_argument( __FUNCTION__, '4.4.0', sprintf( __( 'Use the %s filter instead.' ), '<code>document_title_separator</code>' ) );
128
+		_deprecated_argument(__FUNCTION__, '4.4.0', sprintf(__('Use the %s filter instead.'), '<code>document_title_separator</code>'));
129 129
 	}
130 130
 
131 131
 	/**
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 	 * @param string $wp_title_rss The current blog title.
140 140
 	 * @param string $deprecated   Unused.
141 141
 	 */
142
-	echo apply_filters( 'wp_title_rss', get_wp_title_rss(), $deprecated );
142
+	echo apply_filters('wp_title_rss', get_wp_title_rss(), $deprecated);
143 143
 }
144 144
 
145 145
 /**
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 	 *
160 160
 	 * @param string $title The current post title.
161 161
 	 */
162
-	$title = apply_filters( 'the_title_rss', $title );
162
+	$title = apply_filters('the_title_rss', $title);
163 163
 	return $title;
164 164
 }
165 165
 
@@ -182,11 +182,11 @@  discard block
 block discarded – undo
182 182
  * @return string The filtered content.
183 183
  */
184 184
 function get_the_content_feed($feed_type = null) {
185
-	if ( !$feed_type )
185
+	if ( ! $feed_type)
186 186
 		$feed_type = get_default_feed();
187 187
 
188 188
 	/** This filter is documented in wp-includes/post-template.php */
189
-	$content = apply_filters( 'the_content', get_the_content() );
189
+	$content = apply_filters('the_content', get_the_content());
190 190
 	$content = str_replace(']]>', ']]&gt;', $content);
191 191
 	/**
192 192
 	 * Filter the post content for use in feeds.
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	 * @param string $feed_type Type of feed. Possible values include 'rss2', 'atom'.
198 198
 	 *                          Default 'rss2'.
199 199
 	 */
200
-	return apply_filters( 'the_content_feed', $content, $feed_type );
200
+	return apply_filters('the_content_feed', $content, $feed_type);
201 201
 }
202 202
 
203 203
 /**
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 	 *
226 226
 	 * @param string $output The current post excerpt.
227 227
 	 */
228
-	echo apply_filters( 'the_excerpt_rss', $output );
228
+	echo apply_filters('the_excerpt_rss', $output);
229 229
 }
230 230
 
231 231
 /**
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	 *
242 242
 	 * @param string $post_permalink The current post permalink.
243 243
 	 */
244
-	echo esc_url( apply_filters( 'the_permalink_rss', get_permalink() ) );
244
+	echo esc_url(apply_filters('the_permalink_rss', get_permalink()));
245 245
 }
246 246
 
247 247
 /**
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 	 * @param string $comment_permalink The current comment permalink with
260 260
 	 *                                  '#comments' appended.
261 261
 	 */
262
-	echo esc_url( apply_filters( 'comments_link_feed', get_comments_link() ) );
262
+	echo esc_url(apply_filters('comments_link_feed', get_comments_link()));
263 263
 }
264 264
 
265 265
 /**
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
  * @param int|WP_Comment $comment_id Optional comment object or id. Defaults to global comment object.
271 271
  */
272 272
 function comment_guid($comment_id = null) {
273
-	echo esc_url( get_comment_guid($comment_id) );
273
+	echo esc_url(get_comment_guid($comment_id));
274 274
 }
275 275
 
276 276
 /**
@@ -284,10 +284,10 @@  discard block
 block discarded – undo
284 284
 function get_comment_guid($comment_id = null) {
285 285
 	$comment = get_comment($comment_id);
286 286
 
287
-	if ( !is_object($comment) )
287
+	if ( ! is_object($comment))
288 288
 		return false;
289 289
 
290
-	return get_the_guid($comment->comment_post_ID) . '#comment-' . $comment->comment_ID;
290
+	return get_the_guid($comment->comment_post_ID).'#comment-'.$comment->comment_ID;
291 291
 }
292 292
 
293 293
 /**
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
  *
299 299
  * @param int|WP_Comment $comment Optional. Comment object or id. Defaults to global comment object.
300 300
  */
301
-function comment_link( $comment = null ) {
301
+function comment_link($comment = null) {
302 302
 	/**
303 303
 	 * Filter the current comment's permalink.
304 304
 	 *
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 	 *
309 309
 	 * @param string $comment_permalink The current comment permalink.
310 310
 	 */
311
-	echo esc_url( apply_filters( 'comment_link', get_comment_link( $comment ) ) );
311
+	echo esc_url(apply_filters('comment_link', get_comment_link($comment)));
312 312
 }
313 313
 
314 314
 /**
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 	 *
329 329
 	 * @param string $comment_author The current comment author.
330 330
 	 */
331
-	return apply_filters( 'comment_author_rss', get_comment_author() );
331
+	return apply_filters('comment_author_rss', get_comment_author());
332 332
 }
333 333
 
334 334
 /**
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 	 *
355 355
 	 * @param string $comment_text The content of the current comment.
356 356
 	 */
357
-	$comment_text = apply_filters( 'comment_text_rss', $comment_text );
357
+	$comment_text = apply_filters('comment_text_rss', $comment_text);
358 358
 	echo $comment_text;
359 359
 }
360 360
 
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
  * @return string All of the post categories for displaying in the feed.
372 372
  */
373 373
 function get_the_category_rss($type = null) {
374
-	if ( empty($type) )
374
+	if (empty($type))
375 375
 		$type = get_default_feed();
376 376
 	$categories = get_the_category();
377 377
 	$tags = get_the_tags();
@@ -379,26 +379,26 @@  discard block
 block discarded – undo
379 379
 	$cat_names = array();
380 380
 
381 381
 	$filter = 'rss';
382
-	if ( 'atom' == $type )
382
+	if ('atom' == $type)
383 383
 		$filter = 'raw';
384 384
 
385
-	if ( !empty($categories) ) foreach ( (array) $categories as $category ) {
385
+	if ( ! empty($categories)) foreach ((array) $categories as $category) {
386 386
 		$cat_names[] = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter);
387 387
 	}
388 388
 
389
-	if ( !empty($tags) ) foreach ( (array) $tags as $tag ) {
389
+	if ( ! empty($tags)) foreach ((array) $tags as $tag) {
390 390
 		$cat_names[] = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter);
391 391
 	}
392 392
 
393 393
 	$cat_names = array_unique($cat_names);
394 394
 
395
-	foreach ( $cat_names as $cat_name ) {
396
-		if ( 'rdf' == $type )
395
+	foreach ($cat_names as $cat_name) {
396
+		if ('rdf' == $type)
397 397
 			$the_list .= "\t\t<dc:subject><![CDATA[$cat_name]]></dc:subject>\n";
398
-		elseif ( 'atom' == $type )
399
-			$the_list .= sprintf( '<category scheme="%1$s" term="%2$s" />', esc_attr( get_bloginfo_rss( 'url' ) ), esc_attr( $cat_name ) );
398
+		elseif ('atom' == $type)
399
+			$the_list .= sprintf('<category scheme="%1$s" term="%2$s" />', esc_attr(get_bloginfo_rss('url')), esc_attr($cat_name));
400 400
 		else
401
-			$the_list .= "\t\t<category><![CDATA[" . @html_entity_decode( $cat_name, ENT_COMPAT, get_option('blog_charset') ) . "]]></category>\n";
401
+			$the_list .= "\t\t<category><![CDATA[".@html_entity_decode($cat_name, ENT_COMPAT, get_option('blog_charset'))."]]></category>\n";
402 402
 	}
403 403
 
404 404
 	/**
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 	 * @param string $type     Type of feed. Possible values include 'rss2', 'atom'.
411 411
 	 *                         Default 'rss2'.
412 412
 	 */
413
-	return apply_filters( 'the_category_rss', $the_list, $type );
413
+	return apply_filters('the_category_rss', $the_list, $type);
414 414
 }
415 415
 
416 416
 /**
@@ -456,16 +456,16 @@  discard block
 block discarded – undo
456 456
  * @since 1.5.0
457 457
  */
458 458
 function rss_enclosure() {
459
-	if ( post_password_required() )
459
+	if (post_password_required())
460 460
 		return;
461 461
 
462
-	foreach ( (array) get_post_custom() as $key => $val) {
462
+	foreach ((array) get_post_custom() as $key => $val) {
463 463
 		if ($key == 'enclosure') {
464
-			foreach ( (array) $val as $enc ) {
464
+			foreach ((array) $val as $enc) {
465 465
 				$enclosure = explode("\n", $enc);
466 466
 
467 467
 				// only get the first element, e.g. audio/mpeg from 'audio/mpeg mpga mp2 mp3'
468
-				$t = preg_split('/[ \t]/', trim($enclosure[2]) );
468
+				$t = preg_split('/[ \t]/', trim($enclosure[2]));
469 469
 				$type = $t[0];
470 470
 
471 471
 				/**
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 				 *
476 476
 				 * @param string $html_link_tag The HTML link tag with a URI and other attributes.
477 477
 				 */
478
-				echo apply_filters( 'rss_enclosure', '<enclosure url="' . trim( htmlspecialchars( $enclosure[0] ) ) . '" length="' . trim( $enclosure[1] ) . '" type="' . $type . '" />' . "\n" );
478
+				echo apply_filters('rss_enclosure', '<enclosure url="'.trim(htmlspecialchars($enclosure[0])).'" length="'.trim($enclosure[1]).'" type="'.$type.'" />'."\n");
479 479
 			}
480 480
 		}
481 481
 	}
@@ -495,12 +495,12 @@  discard block
 block discarded – undo
495 495
  * @since 2.2.0
496 496
  */
497 497
 function atom_enclosure() {
498
-	if ( post_password_required() )
498
+	if (post_password_required())
499 499
 		return;
500 500
 
501
-	foreach ( (array) get_post_custom() as $key => $val ) {
501
+	foreach ((array) get_post_custom() as $key => $val) {
502 502
 		if ($key == 'enclosure') {
503
-			foreach ( (array) $val as $enc ) {
503
+			foreach ((array) $val as $enc) {
504 504
 				$enclosure = explode("\n", $enc);
505 505
 				/**
506 506
 				 * Filter the atom enclosure HTML link tag for the current post.
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 				 *
510 510
 				 * @param string $html_link_tag The HTML link tag with a URI and other attributes.
511 511
 				 */
512
-				echo apply_filters( 'atom_enclosure', '<link href="' . trim( htmlspecialchars( $enclosure[0] ) ) . '" rel="enclosure" length="' . trim( $enclosure[1] ) . '" type="' . trim( $enclosure[2] ) . '" />' . "\n" );
512
+				echo apply_filters('atom_enclosure', '<link href="'.trim(htmlspecialchars($enclosure[0])).'" rel="enclosure" length="'.trim($enclosure[1]).'" type="'.trim($enclosure[2]).'" />'."\n");
513 513
 			}
514 514
 		}
515 515
 	}
@@ -538,11 +538,11 @@  discard block
 block discarded – undo
538 538
 	}
539 539
 
540 540
 	$parser = xml_parser_create();
541
-	xml_parse($parser, '<div>' . $data . '</div>', true);
541
+	xml_parse($parser, '<div>'.$data.'</div>', true);
542 542
 	$code = xml_get_error_code($parser);
543 543
 	xml_parser_free($parser);
544 544
 
545
-	if (!$code) {
545
+	if ( ! $code) {
546 546
 		if (strpos($data, '<') === false) {
547 547
 			return array('text', $data);
548 548
 		} else {
@@ -566,8 +566,8 @@  discard block
 block discarded – undo
566 566
  * @see get_site_icon_url()
567 567
  */
568 568
 function atom_site_icon() {
569
-	$url = get_site_icon_url( 32 );
570
-	if ( $url ) {
569
+	$url = get_site_icon_url(32);
570
+	if ($url) {
571 571
 		echo "<icon>$url</icon>\n";
572 572
 	}
573 573
 }
@@ -579,17 +579,17 @@  discard block
 block discarded – undo
579 579
  */
580 580
 function rss2_site_icon() {
581 581
 	$rss_title = get_wp_title_rss();
582
-	if ( empty( $rss_title ) ) {
583
-		$rss_title = get_bloginfo_rss( 'name' );
582
+	if (empty($rss_title)) {
583
+		$rss_title = get_bloginfo_rss('name');
584 584
 	}
585 585
 
586
-	$url = get_site_icon_url( 32 );
587
-	if ( $url ) {
586
+	$url = get_site_icon_url(32);
587
+	if ($url) {
588 588
 		echo '
589 589
 <image>
590
-	<url>' . convert_chars( $url ) . '</url>
591
-	<title>' . $rss_title . '</title>
592
-	<link>' . get_bloginfo_rss( 'url' ) . '</link>
590
+	<url>' . convert_chars($url).'</url>
591
+	<title>' . $rss_title.'</title>
592
+	<link>' . get_bloginfo_rss('url').'</link>
593 593
 	<width>32</width>
594 594
 	<height>32</height>
595 595
 </image> ' . "\n";
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 	 *
616 616
 	 * @param string $feed_link The link for the feed with set URL scheme.
617 617
 	 */
618
-	echo esc_url( apply_filters( 'self_link', set_url_scheme( 'http://' . $host['host'] . wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) );
618
+	echo esc_url(apply_filters('self_link', set_url_scheme('http://'.$host['host'].wp_unslash($_SERVER['REQUEST_URI']))));
619 619
 }
620 620
 
621 621
 /**
@@ -625,8 +625,8 @@  discard block
 block discarded – undo
625 625
  *
626 626
  * @param string $type Type of feed. Possible values include 'rss', rss2', 'atom', and 'rdf'.
627 627
  */
628
-function feed_content_type( $type = '' ) {
629
-	if ( empty($type) )
628
+function feed_content_type($type = '') {
629
+	if (empty($type))
630 630
 		$type = get_default_feed();
631 631
 
632 632
 	$types = array(
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
 		'rdf'  => 'application/rdf+xml'
637 637
 	);
638 638
 
639
-	$content_type = ( !empty($types[$type]) ) ? $types[$type] : 'application/octet-stream';
639
+	$content_type = ( ! empty($types[$type])) ? $types[$type] : 'application/octet-stream';
640 640
 
641 641
 	/**
642 642
 	 * Filter the content type for a specific feed type.
@@ -646,7 +646,7 @@  discard block
 block discarded – undo
646 646
 	 * @param string $content_type Content type indicating the type of data that a feed contains.
647 647
 	 * @param string $type         Type of feed. Possible values include 'rss', rss2', 'atom', and 'rdf'.
648 648
 	 */
649
-	return apply_filters( 'feed_content_type', $content_type, $type );
649
+	return apply_filters('feed_content_type', $content_type, $type);
650 650
 }
651 651
 
652 652
 /**
@@ -660,22 +660,22 @@  discard block
 block discarded – undo
660 660
  *
661 661
  * @return WP_Error|SimplePie WP_Error object on failure or SimplePie object on success
662 662
  */
663
-function fetch_feed( $url ) {
664
-	require_once( ABSPATH . WPINC . '/class-feed.php' );
663
+function fetch_feed($url) {
664
+	require_once(ABSPATH.WPINC.'/class-feed.php');
665 665
 
666 666
 	$feed = new SimplePie();
667 667
 
668
-	$feed->set_sanitize_class( 'WP_SimplePie_Sanitize_KSES' );
668
+	$feed->set_sanitize_class('WP_SimplePie_Sanitize_KSES');
669 669
 	// We must manually overwrite $feed->sanitize because SimplePie's
670 670
 	// constructor sets it before we have a chance to set the sanitization class
671 671
 	$feed->sanitize = new WP_SimplePie_Sanitize_KSES();
672 672
 
673
-	$feed->set_cache_class( 'WP_Feed_Cache' );
674
-	$feed->set_file_class( 'WP_SimplePie_File' );
673
+	$feed->set_cache_class('WP_Feed_Cache');
674
+	$feed->set_file_class('WP_SimplePie_File');
675 675
 
676
-	$feed->set_feed_url( $url );
676
+	$feed->set_feed_url($url);
677 677
 	/** This filter is documented in wp-includes/class-feed.php */
678
-	$feed->set_cache_duration( apply_filters( 'wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url ) );
678
+	$feed->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url));
679 679
 	/**
680 680
 	 * Fires just before processing the SimplePie feed object.
681 681
 	 *
@@ -684,13 +684,13 @@  discard block
 block discarded – undo
684 684
 	 * @param object &$feed SimplePie feed object, passed by reference.
685 685
 	 * @param mixed  $url   URL of feed to retrieve. If an array of URLs, the feeds are merged.
686 686
 	 */
687
-	do_action_ref_array( 'wp_feed_options', array( &$feed, $url ) );
687
+	do_action_ref_array('wp_feed_options', array(&$feed, $url));
688 688
 	$feed->init();
689
-	$feed->set_output_encoding( get_option( 'blog_charset' ) );
689
+	$feed->set_output_encoding(get_option('blog_charset'));
690 690
 	$feed->handle_content_type();
691 691
 
692
-	if ( $feed->error() )
693
-		return new WP_Error( 'simplepie-error', $feed->error() );
692
+	if ($feed->error())
693
+		return new WP_Error('simplepie-error', $feed->error());
694 694
 
695 695
 	return $feed;
696 696
 }
Please login to merge, or discard this patch.
src/wp-includes/ID3/getid3.lib.php 3 patches
Doc Comments   +59 added lines patch added patch discarded remove patch
@@ -99,6 +99,9 @@  discard block
 block discarded – undo
99 99
 	}
100 100
 
101 101
 
102
+	/**
103
+	 * @param string $binarynumerator
104
+	 */
102 105
 	public static function DecimalBinary2Float($binarynumerator) {
103 106
 		$numerator   = self::Bin2Dec($binarynumerator);
104 107
 		$denominator = self::Bin2Dec('1'.str_repeat('0', strlen($binarynumerator)));
@@ -106,6 +109,9 @@  discard block
 block discarded – undo
106 109
 	}
107 110
 
108 111
 
112
+	/**
113
+	 * @param string $binarypointnumber
114
+	 */
109 115
 	public static function NormalizeBinaryPoint($binarypointnumber, $maxbits=52) {
110 116
 		// http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/binary.html
111 117
 		if (strpos($binarypointnumber, '.') === false) {
@@ -177,6 +183,9 @@  discard block
 block discarded – undo
177 183
 	}
178 184
 
179 185
 
186
+	/**
187
+	 * @param string $byteword
188
+	 */
180 189
 	public static function LittleEndian2Float($byteword) {
181 190
 		return self::BigEndian2Float(strrev($byteword));
182 191
 	}
@@ -366,6 +375,9 @@  discard block
 block discarded – undo
366 375
 	}
367 376
 
368 377
 
378
+	/**
379
+	 * @param integer $number
380
+	 */
369 381
 	public static function LittleEndian2String($number, $minbytes=1, $synchsafe=false) {
370 382
 		$intstring = '';
371 383
 		while ($number > 0) {
@@ -458,16 +470,25 @@  discard block
 block discarded – undo
458 470
 	}
459 471
 
460 472
 
473
+	/**
474
+	 * @param string $rawdata
475
+	 */
461 476
 	public static function FixedPoint8_8($rawdata) {
462 477
 		return self::BigEndian2Int(substr($rawdata, 0, 1)) + (float) (self::BigEndian2Int(substr($rawdata, 1, 1)) / pow(2, 8));
463 478
 	}
464 479
 
465 480
 
481
+	/**
482
+	 * @param string $rawdata
483
+	 */
466 484
 	public static function FixedPoint16_16($rawdata) {
467 485
 		return self::BigEndian2Int(substr($rawdata, 0, 2)) + (float) (self::BigEndian2Int(substr($rawdata, 2, 2)) / pow(2, 16));
468 486
 	}
469 487
 
470 488
 
489
+	/**
490
+	 * @param string $rawdata
491
+	 */
471 492
 	public static function FixedPoint2_30($rawdata) {
472 493
 		$binarystring = self::BigEndian2Bin($rawdata);
473 494
 		return self::Bin2Dec(substr($binarystring, 0, 2)) + (float) (self::Bin2Dec(substr($binarystring, 2, 30)) / pow(2, 30));
@@ -531,6 +552,9 @@  discard block
 block discarded – undo
531 552
 		return false;
532 553
 	}
533 554
 
555
+	/**
556
+	 * @param SimpleXMLElement $XMLobject
557
+	 */
534 558
 	public static function SimpleXMLelement2array($XMLobject) {
535 559
 		if (!is_object($XMLobject) && !is_array($XMLobject)) {
536 560
 			return $XMLobject;
@@ -631,6 +655,9 @@  discard block
 block discarded – undo
631 655
 		return $result;
632 656
 	}
633 657
 
658
+	/**
659
+	 * @param string $filename_dest
660
+	 */
634 661
 	public static function CopyFileParts($filename_source, $filename_dest, $offset, $length) {
635 662
 		if (!self::intValueSupported($offset + $length)) {
636 663
 			throw new Exception('cannot copy file portion, it extends beyond the '.round(PHP_INT_MAX / 1073741824).'GB limit');
@@ -863,6 +890,10 @@  discard block
 block discarded – undo
863 890
 	}
864 891
 
865 892
 	// UTF-16BE => UTF-8
893
+
894
+	/**
895
+	 * @param string $string
896
+	 */
866 897
 	public static function iconv_fallback_utf16be_utf8($string) {
867 898
 		if (substr($string, 0, 2) == "\xFE\xFF") {
868 899
 			// strip BOM
@@ -877,6 +908,10 @@  discard block
 block discarded – undo
877 908
 	}
878 909
 
879 910
 	// UTF-16LE => UTF-8
911
+
912
+	/**
913
+	 * @param string $string
914
+	 */
880 915
 	public static function iconv_fallback_utf16le_utf8($string) {
881 916
 		if (substr($string, 0, 2) == "\xFF\xFE") {
882 917
 			// strip BOM
@@ -891,6 +926,10 @@  discard block
 block discarded – undo
891 926
 	}
892 927
 
893 928
 	// UTF-16BE => ISO-8859-1
929
+
930
+	/**
931
+	 * @param string $string
932
+	 */
894 933
 	public static function iconv_fallback_utf16be_iso88591($string) {
895 934
 		if (substr($string, 0, 2) == "\xFE\xFF") {
896 935
 			// strip BOM
@@ -905,6 +944,10 @@  discard block
 block discarded – undo
905 944
 	}
906 945
 
907 946
 	// UTF-16LE => ISO-8859-1
947
+
948
+	/**
949
+	 * @param string $string
950
+	 */
908 951
 	public static function iconv_fallback_utf16le_iso88591($string) {
909 952
 		if (substr($string, 0, 2) == "\xFF\xFE") {
910 953
 			// strip BOM
@@ -940,6 +983,9 @@  discard block
 block discarded – undo
940 983
 		return $string;
941 984
 	}
942 985
 
986
+	/**
987
+	 * @return string
988
+	 */
943 989
 	public static function iconv_fallback($in_charset, $out_charset, $string) {
944 990
 
945 991
 		if ($in_charset == $out_charset) {
@@ -1271,6 +1317,12 @@  discard block
 block discarded – undo
1271 1317
 	}
1272 1318
 
1273 1319
 
1320
+	/**
1321
+	 * @param integer $begin
1322
+	 * @param integer $end
1323
+	 * @param string $file
1324
+	 * @param string $name
1325
+	 */
1274 1326
 	public static function EmbeddedLookup($key, $begin, $end, $file, $name) {
1275 1327
 
1276 1328
 		// Cached
@@ -1317,6 +1369,10 @@  discard block
 block discarded – undo
1317 1369
 		return (isset($cache[$file][$name][$key]) ? $cache[$file][$name][$key] : '');
1318 1370
 	}
1319 1371
 
1372
+	/**
1373
+	 * @param string $filename
1374
+	 * @param string $sourcefile
1375
+	 */
1320 1376
 	public static function IncludeDependency($filename, $sourcefile, $DieOnFailure=false) {
1321 1377
 		global $GETID3_ERRORARRAY;
1322 1378
 
@@ -1341,6 +1397,9 @@  discard block
 block discarded – undo
1341 1397
 		return trim($string, "\x00");
1342 1398
 	}
1343 1399
 
1400
+	/**
1401
+	 * @param string $path
1402
+	 */
1344 1403
 	public static function getFileSizeSyscall($path) {
1345 1404
 		$filesize = false;
1346 1405
 
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1367,11 +1367,11 @@
 block discarded – undo
1367 1367
 
1368 1368
 
1369 1369
 	/**
1370
-	* Workaround for Bug #37268 (https://bugs.php.net/bug.php?id=37268)
1371
-	* @param string $path A path.
1372
-	* @param string $suffix If the name component ends in suffix this will also be cut off.
1373
-	* @return string
1374
-	*/
1370
+	 * Workaround for Bug #37268 (https://bugs.php.net/bug.php?id=37268)
1371
+	 * @param string $path A path.
1372
+	 * @param string $suffix If the name component ends in suffix this will also be cut off.
1373
+	 * @return string
1374
+	 */
1375 1375
 	public static function mb_basename($path, $suffix = null) {
1376 1376
 		$splited = preg_split('#/#', rtrim($path, '/ '));
1377 1377
 		return substr(basename('X'.$splited[count($splited) - 1], $suffix), 1);
Please login to merge, or discard this patch.
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 class getid3_lib
16 16
 {
17 17
 
18
-	public static function PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8') {
18
+	public static function PrintHexBytes($string, $hex = true, $spaces = true, $htmlencoding = 'UTF-8') {
19 19
 		$returnstring = '';
20 20
 		for ($i = 0; $i < strlen($string); $i++) {
21 21
 			if ($hex) {
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 				$returnstring .= ' ';
28 28
 			}
29 29
 		}
30
-		if (!empty($htmlencoding)) {
30
+		if ( ! empty($htmlencoding)) {
31 31
 			if ($htmlencoding === true) {
32 32
 				$htmlencoding = 'UTF-8'; // prior to getID3 v1.9.0 the function's 4th parameter was boolean
33 33
 			}
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	}
54 54
 
55 55
 
56
-	public static function safe_inc(&$variable, $increment=1) {
56
+	public static function safe_inc(&$variable, $increment = 1) {
57 57
 		if (isset($variable)) {
58 58
 			$variable += $increment;
59 59
 		} else {
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 		static $hasINT64 = null;
83 83
 		if ($hasINT64 === null) { // 10x faster than is_null()
84 84
 			$hasINT64 = is_int(pow(2, 31)); // 32-bit int are limited to (2^31)-1
85
-			if (!$hasINT64 && !defined('PHP_INT_MIN')) {
85
+			if ( ! $hasINT64 && ! defined('PHP_INT_MIN')) {
86 86
 				define('PHP_INT_MIN', ~PHP_INT_MAX);
87 87
 			}
88 88
 		}
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	}
107 107
 
108 108
 
109
-	public static function NormalizeBinaryPoint($binarypointnumber, $maxbits=52) {
109
+	public static function NormalizeBinaryPoint($binarypointnumber, $maxbits = 52) {
110 110
 		// http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/binary.html
111 111
 		if (strpos($binarypointnumber, '.') === false) {
112 112
 			$binarypointnumber = '0.'.$binarypointnumber;
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 		// http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee.html
189 189
 
190 190
 		$bitword = self::BigEndian2Bin($byteword);
191
-		if (!$bitword) {
191
+		if ( ! $bitword) {
192 192
 			return 0;
193 193
 		}
194 194
 		$signbit = $bitword{0};
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	}
261 261
 
262 262
 
263
-	public static function BigEndian2Int($byteword, $synchsafe=false, $signed=false) {
263
+	public static function BigEndian2Int($byteword, $synchsafe = false, $signed = false) {
264 264
 		$intvalue = 0;
265 265
 		$bytewordlen = strlen($byteword);
266 266
 		if ($bytewordlen == 0) {
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 				$intvalue += ord($byteword{$i}) * pow(256, ($bytewordlen - 1 - $i));
275 275
 			}
276 276
 		}
277
-		if ($signed && !$synchsafe) {
277
+		if ($signed && ! $synchsafe) {
278 278
 			// synchsafe ints are not allowed to be signed
279 279
 			if ($bytewordlen <= PHP_INT_SIZE) {
280 280
 				$signMaskBit = 0x80 << (8 * ($bytewordlen - 1));
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	}
290 290
 
291 291
 
292
-	public static function LittleEndian2Int($byteword, $signed=false) {
292
+	public static function LittleEndian2Int($byteword, $signed = false) {
293 293
 		return self::BigEndian2Int(strrev($byteword), false, $signed);
294 294
 	}
295 295
 
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 	}
305 305
 
306 306
 
307
-	public static function BigEndian2String($number, $minbytes=1, $synchsafe=false, $signed=false) {
307
+	public static function BigEndian2String($number, $minbytes = 1, $synchsafe = false, $signed = false) {
308 308
 		if ($number < 0) {
309 309
 			throw new Exception('ERROR: self::BigEndian2String() does not support negative numbers');
310 310
 		}
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 	}
340 340
 
341 341
 
342
-	public static function Bin2Dec($binstring, $signed=false) {
342
+	public static function Bin2Dec($binstring, $signed = false) {
343 343
 		$signmult = 1;
344 344
 		if ($signed) {
345 345
 			if ($binstring{0} == '1') {
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 	}
367 367
 
368 368
 
369
-	public static function LittleEndian2String($number, $minbytes=1, $synchsafe=false) {
369
+	public static function LittleEndian2String($number, $minbytes = 1, $synchsafe = false) {
370 370
 		$intstring = '';
371 371
 		while ($number > 0) {
372 372
 			if ($synchsafe) {
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 	public static function array_merge_clobber($array1, $array2) {
385 385
 		// written by kcØhireability*com
386 386
 		// taken from http://www.php.net/manual/en/function.array-merge-recursive.php
387
-		if (!is_array($array1) || !is_array($array2)) {
387
+		if ( ! is_array($array1) || ! is_array($array2)) {
388 388
 			return false;
389 389
 		}
390 390
 		$newarray = $array1;
@@ -400,14 +400,14 @@  discard block
 block discarded – undo
400 400
 
401 401
 
402 402
 	public static function array_merge_noclobber($array1, $array2) {
403
-		if (!is_array($array1) || !is_array($array2)) {
403
+		if ( ! is_array($array1) || ! is_array($array2)) {
404 404
 			return false;
405 405
 		}
406 406
 		$newarray = $array1;
407 407
 		foreach ($array2 as $key => $val) {
408 408
 			if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) {
409 409
 				$newarray[$key] = self::array_merge_noclobber($newarray[$key], $val);
410
-			} elseif (!isset($newarray[$key])) {
410
+			} elseif ( ! isset($newarray[$key])) {
411 411
 				$newarray[$key] = $val;
412 412
 			}
413 413
 		}
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 		return true;
426 426
 	}
427 427
 
428
-	public static function fileextension($filename, $numextensions=1) {
428
+	public static function fileextension($filename, $numextensions = 1) {
429 429
 		if (strstr($filename, '.')) {
430 430
 			$reversedfilename = strrev($filename);
431 431
 			$offset = 0;
@@ -444,9 +444,9 @@  discard block
 block discarded – undo
444 444
 	public static function PlaytimeString($seconds) {
445 445
 		$sign = (($seconds < 0) ? '-' : '');
446 446
 		$seconds = round(abs($seconds));
447
-		$H = (int) floor( $seconds                            / 3600);
448
-		$M = (int) floor(($seconds - (3600 * $H)            ) /   60);
449
-		$S = (int) round( $seconds - (3600 * $H) - (60 * $M)        );
447
+		$H = (int) floor($seconds / 3600);
448
+		$M = (int) floor(($seconds - (3600 * $H)) / 60);
449
+		$S = (int) round($seconds - (3600 * $H) - (60 * $M));
450 450
 		return $sign.($H ? $H.':' : '').($H ? str_pad($M, 2, '0', STR_PAD_LEFT) : intval($M)).':'.str_pad($S, 2, 0, STR_PAD_LEFT);
451 451
 	}
452 452
 
@@ -490,11 +490,11 @@  discard block
 block discarded – undo
490 490
 		return $ReturnedArray;
491 491
 	}
492 492
 
493
-	public static function array_max($arraydata, $returnkey=false) {
493
+	public static function array_max($arraydata, $returnkey = false) {
494 494
 		$maxvalue = false;
495 495
 		$maxkey = false;
496 496
 		foreach ($arraydata as $key => $value) {
497
-			if (!is_array($value)) {
497
+			if ( ! is_array($value)) {
498 498
 				if ($value > $maxvalue) {
499 499
 					$maxvalue = $value;
500 500
 					$maxkey = $key;
@@ -504,11 +504,11 @@  discard block
 block discarded – undo
504 504
 		return ($returnkey ? $maxkey : $maxvalue);
505 505
 	}
506 506
 
507
-	public static function array_min($arraydata, $returnkey=false) {
507
+	public static function array_min($arraydata, $returnkey = false) {
508 508
 		$minvalue = false;
509 509
 		$minkey = false;
510 510
 		foreach ($arraydata as $key => $value) {
511
-			if (!is_array($value)) {
511
+			if ( ! is_array($value)) {
512 512
 				if ($value > $minvalue) {
513 513
 					$minvalue = $value;
514 514
 					$minkey = $key;
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
 	}
533 533
 
534 534
 	public static function SimpleXMLelement2array($XMLobject) {
535
-		if (!is_object($XMLobject) && !is_array($XMLobject)) {
535
+		if ( ! is_object($XMLobject) && ! is_array($XMLobject)) {
536 536
 			return $XMLobject;
537 537
 		}
538 538
 		$XMLarray = (is_object($XMLobject) ? get_object_vars($XMLobject) : $XMLobject);
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 	// self::md5_data() - returns md5sum for a file from startuing position to absolute end position
548 548
 	public static function hash_data($file, $offset, $end, $algorithm) {
549 549
 		static $tempdir = '';
550
-		if (!self::intValueSupported($end)) {
550
+		if ( ! self::intValueSupported($end)) {
551 551
 			return false;
552 552
 		}
553 553
 		switch ($algorithm) {
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
 
582 582
 				$RequiredFiles = array('cygwin1.dll', 'head.exe', 'tail.exe', $windows_call);
583 583
 				foreach ($RequiredFiles as $required_file) {
584
-					if (!is_readable(GETID3_HELPERAPPSDIR.$required_file)) {
584
+					if ( ! is_readable(GETID3_HELPERAPPSDIR.$required_file)) {
585 585
 						// helper apps not available - fall back to old method
586 586
 						break 2;
587 587
 					}
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
 	}
633 633
 
634 634
 	public static function CopyFileParts($filename_source, $filename_dest, $offset, $length) {
635
-		if (!self::intValueSupported($offset + $length)) {
635
+		if ( ! self::intValueSupported($offset + $length)) {
636 636
 			throw new Exception('cannot copy file portion, it extends beyond the '.round(PHP_INT_MAX / 1073741824).'GB limit');
637 637
 		}
638 638
 		if (is_readable($filename_source) && is_file($filename_source) && ($fp_src = fopen($filename_source, 'rb'))) {
@@ -664,25 +664,25 @@  discard block
 block discarded – undo
664 664
 			$newcharstring = chr($charval);
665 665
 		} elseif ($charval < 2048) {
666 666
 			// 110bbbbb 10bbbbbb
667
-			$newcharstring  = chr(($charval >>   6) | 0xC0);
667
+			$newcharstring  = chr(($charval >> 6) | 0xC0);
668 668
 			$newcharstring .= chr(($charval & 0x3F) | 0x80);
669 669
 		} elseif ($charval < 65536) {
670 670
 			// 1110bbbb 10bbbbbb 10bbbbbb
671
-			$newcharstring  = chr(($charval >>  12) | 0xE0);
672
-			$newcharstring .= chr(($charval >>   6) | 0xC0);
671
+			$newcharstring  = chr(($charval >> 12) | 0xE0);
672
+			$newcharstring .= chr(($charval >> 6) | 0xC0);
673 673
 			$newcharstring .= chr(($charval & 0x3F) | 0x80);
674 674
 		} else {
675 675
 			// 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
676
-			$newcharstring  = chr(($charval >>  18) | 0xF0);
677
-			$newcharstring .= chr(($charval >>  12) | 0xC0);
678
-			$newcharstring .= chr(($charval >>   6) | 0xC0);
676
+			$newcharstring  = chr(($charval >> 18) | 0xF0);
677
+			$newcharstring .= chr(($charval >> 12) | 0xC0);
678
+			$newcharstring .= chr(($charval >> 6) | 0xC0);
679 679
 			$newcharstring .= chr(($charval & 0x3F) | 0x80);
680 680
 		}
681 681
 		return $newcharstring;
682 682
 	}
683 683
 
684 684
 	// ISO-8859-1 => UTF-8
685
-	public static function iconv_fallback_iso88591_utf8($string, $bom=false) {
685
+	public static function iconv_fallback_iso88591_utf8($string, $bom = false) {
686 686
 		if (function_exists('utf8_encode')) {
687 687
 			return utf8_encode($string);
688 688
 		}
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
 	}
700 700
 
701 701
 	// ISO-8859-1 => UTF-16BE
702
-	public static function iconv_fallback_iso88591_utf16be($string, $bom=false) {
702
+	public static function iconv_fallback_iso88591_utf16be($string, $bom = false) {
703 703
 		$newcharstring = '';
704 704
 		if ($bom) {
705 705
 			$newcharstring .= "\xFE\xFF";
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
 	}
712 712
 
713 713
 	// ISO-8859-1 => UTF-16LE
714
-	public static function iconv_fallback_iso88591_utf16le($string, $bom=false) {
714
+	public static function iconv_fallback_iso88591_utf16le($string, $bom = false) {
715 715
 		$newcharstring = '';
716 716
 		if ($bom) {
717 717
 			$newcharstring .= "\xFF\xFE";
@@ -741,18 +741,18 @@  discard block
 block discarded – undo
741 741
 				// 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
742 742
 				$charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
743 743
 						   ((ord($string{($offset + 1)}) & 0x3F) << 12) &
744
-						   ((ord($string{($offset + 2)}) & 0x3F) <<  6) &
744
+						   ((ord($string{($offset + 2)}) & 0x3F) << 6) &
745 745
 							(ord($string{($offset + 3)}) & 0x3F);
746 746
 				$offset += 4;
747 747
 			} elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
748 748
 				// 1110bbbb 10bbbbbb 10bbbbbb
749 749
 				$charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
750
-						   ((ord($string{($offset + 1)}) & 0x3F) <<  6) &
750
+						   ((ord($string{($offset + 1)}) & 0x3F) << 6) &
751 751
 							(ord($string{($offset + 2)}) & 0x3F);
752 752
 				$offset += 3;
753 753
 			} elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
754 754
 				// 110bbbbb 10bbbbbb
755
-				$charval = ((ord($string{($offset + 0)}) & 0x1F) <<  6) &
755
+				$charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
756 756
 							(ord($string{($offset + 1)}) & 0x3F);
757 757
 				$offset += 2;
758 758
 			} elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
 	}
773 773
 
774 774
 	// UTF-8 => UTF-16BE
775
-	public static function iconv_fallback_utf8_utf16be($string, $bom=false) {
775
+	public static function iconv_fallback_utf8_utf16be($string, $bom = false) {
776 776
 		$newcharstring = '';
777 777
 		if ($bom) {
778 778
 			$newcharstring .= "\xFE\xFF";
@@ -784,18 +784,18 @@  discard block
 block discarded – undo
784 784
 				// 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
785 785
 				$charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
786 786
 						   ((ord($string{($offset + 1)}) & 0x3F) << 12) &
787
-						   ((ord($string{($offset + 2)}) & 0x3F) <<  6) &
787
+						   ((ord($string{($offset + 2)}) & 0x3F) << 6) &
788 788
 							(ord($string{($offset + 3)}) & 0x3F);
789 789
 				$offset += 4;
790 790
 			} elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
791 791
 				// 1110bbbb 10bbbbbb 10bbbbbb
792 792
 				$charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
793
-						   ((ord($string{($offset + 1)}) & 0x3F) <<  6) &
793
+						   ((ord($string{($offset + 1)}) & 0x3F) << 6) &
794 794
 							(ord($string{($offset + 2)}) & 0x3F);
795 795
 				$offset += 3;
796 796
 			} elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
797 797
 				// 110bbbbb 10bbbbbb
798
-				$charval = ((ord($string{($offset + 0)}) & 0x1F) <<  6) &
798
+				$charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
799 799
 							(ord($string{($offset + 1)}) & 0x3F);
800 800
 				$offset += 2;
801 801
 			} elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
 	}
816 816
 
817 817
 	// UTF-8 => UTF-16LE
818
-	public static function iconv_fallback_utf8_utf16le($string, $bom=false) {
818
+	public static function iconv_fallback_utf8_utf16le($string, $bom = false) {
819 819
 		$newcharstring = '';
820 820
 		if ($bom) {
821 821
 			$newcharstring .= "\xFF\xFE";
@@ -827,18 +827,18 @@  discard block
 block discarded – undo
827 827
 				// 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
828 828
 				$charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
829 829
 						   ((ord($string{($offset + 1)}) & 0x3F) << 12) &
830
-						   ((ord($string{($offset + 2)}) & 0x3F) <<  6) &
830
+						   ((ord($string{($offset + 2)}) & 0x3F) << 6) &
831 831
 							(ord($string{($offset + 3)}) & 0x3F);
832 832
 				$offset += 4;
833 833
 			} elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
834 834
 				// 1110bbbb 10bbbbbb 10bbbbbb
835 835
 				$charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
836
-						   ((ord($string{($offset + 1)}) & 0x3F) <<  6) &
836
+						   ((ord($string{($offset + 1)}) & 0x3F) << 6) &
837 837
 							(ord($string{($offset + 2)}) & 0x3F);
838 838
 				$offset += 3;
839 839
 			} elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
840 840
 				// 110bbbbb 10bbbbbb
841
-				$charval = ((ord($string{($offset + 0)}) & 0x1F) <<  6) &
841
+				$charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
842 842
 							(ord($string{($offset + 1)}) & 0x3F);
843 843
 				$offset += 2;
844 844
 			} elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
 		throw new Exception('PHP does not have iconv() support - cannot convert from '.$in_charset.' to '.$out_charset);
989 989
 	}
990 990
 
991
-	public static function recursiveMultiByteCharString2HTML($data, $charset='ISO-8859-1') {
991
+	public static function recursiveMultiByteCharString2HTML($data, $charset = 'ISO-8859-1') {
992 992
 		if (is_string($data)) {
993 993
 			return self::MultiByteCharString2HTML($data, $charset);
994 994
 		} elseif (is_array($data)) {
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
 		return $data;
1003 1003
 	}
1004 1004
 
1005
-	public static function MultiByteCharString2HTML($string, $charset='ISO-8859-1') {
1005
+	public static function MultiByteCharString2HTML($string, $charset = 'ISO-8859-1') {
1006 1006
 		$string = (string) $string; // in case trying to pass a numeric (float, int) string, would otherwise return an empty string
1007 1007
 		$HTMLstring = '';
1008 1008
 
@@ -1044,16 +1044,16 @@  discard block
 block discarded – undo
1044 1044
 					$charval = 0;
1045 1045
 					if ($char_ord_val < 0x80) {
1046 1046
 						$charval = $char_ord_val;
1047
-					} elseif ((($char_ord_val & 0xF0) >> 4) == 0x0F  &&  $i+3 < $strlen) {
1047
+					} elseif ((($char_ord_val & 0xF0) >> 4) == 0x0F && $i + 3 < $strlen) {
1048 1048
 						$charval  = (($char_ord_val & 0x07) << 18);
1049 1049
 						$charval += ((ord($string{++$i}) & 0x3F) << 12);
1050 1050
 						$charval += ((ord($string{++$i}) & 0x3F) << 6);
1051
-						$charval +=  (ord($string{++$i}) & 0x3F);
1052
-					} elseif ((($char_ord_val & 0xE0) >> 5) == 0x07  &&  $i+2 < $strlen) {
1051
+						$charval += (ord($string{++$i}) & 0x3F);
1052
+					} elseif ((($char_ord_val & 0xE0) >> 5) == 0x07 && $i + 2 < $strlen) {
1053 1053
 						$charval  = (($char_ord_val & 0x0F) << 12);
1054 1054
 						$charval += ((ord($string{++$i}) & 0x3F) << 6);
1055
-						$charval +=  (ord($string{++$i}) & 0x3F);
1056
-					} elseif ((($char_ord_val & 0xC0) >> 6) == 0x03  &&  $i+1 < $strlen) {
1055
+						$charval += (ord($string{++$i}) & 0x3F);
1056
+					} elseif ((($char_ord_val & 0xC0) >> 6) == 0x03 && $i + 1 < $strlen) {
1057 1057
 						$charval  = (($char_ord_val & 0x1F) << 6);
1058 1058
 						$charval += (ord($string{++$i}) & 0x3F);
1059 1059
 					}
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
 	}
1151 1151
 
1152 1152
 
1153
-	public static function GetDataImageSize($imgData, &$imageinfo=array()) {
1153
+	public static function GetDataImageSize($imgData, &$imageinfo = array()) {
1154 1154
 		static $tempdir = '';
1155 1155
 		if (empty($tempdir)) {
1156 1156
 			// yes this is ugly, feel free to suggest a better way
@@ -1202,11 +1202,11 @@  discard block
 block discarded – undo
1202 1202
 	public static function CopyTagsToComments(&$ThisFileInfo) {
1203 1203
 
1204 1204
 		// Copy all entries from ['tags'] into common ['comments']
1205
-		if (!empty($ThisFileInfo['tags'])) {
1205
+		if ( ! empty($ThisFileInfo['tags'])) {
1206 1206
 			foreach ($ThisFileInfo['tags'] as $tagtype => $tagarray) {
1207 1207
 				foreach ($tagarray as $tagname => $tagdata) {
1208 1208
 					foreach ($tagdata as $key => $value) {
1209
-						if (!empty($value)) {
1209
+						if ( ! empty($value)) {
1210 1210
 							if (empty($ThisFileInfo['comments'][$tagname])) {
1211 1211
 
1212 1212
 								// fall through and append value
@@ -1222,7 +1222,7 @@  discard block
 block discarded – undo
1222 1222
 									}
1223 1223
 								}
1224 1224
 
1225
-							} elseif (!is_array($value)) {
1225
+							} elseif ( ! is_array($value)) {
1226 1226
 
1227 1227
 								$newvaluelength = strlen(trim($value));
1228 1228
 								foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) {
@@ -1235,9 +1235,9 @@  discard block
 block discarded – undo
1235 1235
 								}
1236 1236
 
1237 1237
 							}
1238
-							if (is_array($value) || empty($ThisFileInfo['comments'][$tagname]) || !in_array(trim($value), $ThisFileInfo['comments'][$tagname])) {
1238
+							if (is_array($value) || empty($ThisFileInfo['comments'][$tagname]) || ! in_array(trim($value), $ThisFileInfo['comments'][$tagname])) {
1239 1239
 								$value = (is_string($value) ? trim($value) : $value);
1240
-								if (!is_numeric($key)) {
1240
+								if ( ! is_numeric($key)) {
1241 1241
 									$ThisFileInfo['comments'][$tagname][$key] = $value;
1242 1242
 								} else {
1243 1243
 									$ThisFileInfo['comments'][$tagname][]     = $value;
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
 			}
1250 1250
 
1251 1251
 			// Copy to ['comments_html']
1252
-			if (!empty($ThisFileInfo['comments'])) {
1252
+			if ( ! empty($ThisFileInfo['comments'])) {
1253 1253
 				foreach ($ThisFileInfo['comments'] as $field => $values) {
1254 1254
 					if ($field == 'picture') {
1255 1255
 						// pictures can take up a lot of space, and we don't need multiple copies of them
@@ -1317,7 +1317,7 @@  discard block
 block discarded – undo
1317 1317
 		return (isset($cache[$file][$name][$key]) ? $cache[$file][$name][$key] : '');
1318 1318
 	}
1319 1319
 
1320
-	public static function IncludeDependency($filename, $sourcefile, $DieOnFailure=false) {
1320
+	public static function IncludeDependency($filename, $sourcefile, $DieOnFailure = false) {
1321 1321
 		global $GETID3_ERRORARRAY;
1322 1322
 
1323 1323
 		if (file_exists($filename)) {
Please login to merge, or discard this patch.
src/wp-includes/ID3/getid3.php 4 patches
Doc Comments   +39 added lines patch added patch discarded remove patch
@@ -335,6 +335,10 @@  discard block
 block discarded – undo
335 335
 	}
336 336
 
337 337
 	// public: analyze file
338
+
339
+	/**
340
+	 * @param string $filename
341
+	 */
338 342
 	public function analyze($filename) {
339 343
 		try {
340 344
 			if (!$this->openfile($filename)) {
@@ -486,6 +490,10 @@  discard block
 block discarded – undo
486 490
 
487 491
 
488 492
 	// private: error handling
493
+
494
+	/**
495
+	 * @param string $message
496
+	 */
489 497
 	public function error($message) {
490 498
 		$this->CleanUp();
491 499
 		if (!isset($this->info['error'])) {
@@ -1097,6 +1105,9 @@  discard block
 block discarded – undo
1097 1105
 
1098 1106
 
1099 1107
 
1108
+	/**
1109
+	 * @param string $filedata
1110
+	 */
1100 1111
 	public function GetFileFormat(&$filedata, $filename='') {
1101 1112
 		// this function will determine the format of a file based on usually
1102 1113
 		// the first 2-4 bytes of the file (8 bytes for PNG, 16 bytes for JPG,
@@ -1136,6 +1147,10 @@  discard block
 block discarded – undo
1136 1147
 
1137 1148
 
1138 1149
 	// converts array to $encoding charset from $this->encoding
1150
+
1151
+	/**
1152
+	 * @param string $encoding
1153
+	 */
1139 1154
 	public function CharConvert(&$array, $encoding) {
1140 1155
 
1141 1156
 		// identical encoding - end here
@@ -1280,6 +1295,9 @@  discard block
 block discarded – undo
1280 1295
 		return true;
1281 1296
 	}
1282 1297
 
1298
+	/**
1299
+	 * @param string $algorithm
1300
+	 */
1283 1301
 	public function getHashdata($algorithm) {
1284 1302
 		switch ($algorithm) {
1285 1303
 			case 'md5':
@@ -1573,6 +1591,9 @@  discard block
 block discarded – undo
1573 1591
 		return tempnam($this->tempdir, 'gI3');
1574 1592
 	}
1575 1593
 
1594
+	/**
1595
+	 * @param string $name
1596
+	 */
1576 1597
 	public function include_module($name) {
1577 1598
 		//if (!file_exists($this->include_path.'module.'.$name.'.php')) {
1578 1599
 		if (!file_exists(GETID3_INCLUDEPATH.'module.'.$name.'.php')) {
@@ -1600,6 +1621,9 @@  discard block
 block discarded – undo
1600 1621
 	private $dependency_to = null;
1601 1622
 
1602 1623
 
1624
+	/**
1625
+	 * @param string $call_module
1626
+	 */
1603 1627
 	public function __construct(getID3 $getid3, $call_module=null) {
1604 1628
 		$this->getid3 = $getid3;
1605 1629
 
@@ -1664,6 +1688,9 @@  discard block
 block discarded – undo
1664 1688
 		return fread($this->getid3->fp, $bytes);
1665 1689
 	}
1666 1690
 
1691
+	/**
1692
+	 * @param integer $whence
1693
+	 */
1667 1694
 	protected function fseek($bytes, $whence=SEEK_SET) {
1668 1695
 		if ($this->data_string_flag) {
1669 1696
 			switch ($whence) {
@@ -1701,20 +1728,32 @@  discard block
 block discarded – undo
1701 1728
 		return feof($this->getid3->fp);
1702 1729
 	}
1703 1730
 
1731
+	/**
1732
+	 * @param string $module
1733
+	 */
1704 1734
 	final protected function isDependencyFor($module) {
1705 1735
 		return $this->dependency_to == $module;
1706 1736
 	}
1707 1737
 
1738
+	/**
1739
+	 * @param string $text
1740
+	 */
1708 1741
 	protected function error($text) {
1709 1742
 		$this->getid3->info['error'][] = $text;
1710 1743
 
1711 1744
 		return false;
1712 1745
 	}
1713 1746
 
1747
+	/**
1748
+	 * @param string $text
1749
+	 */
1714 1750
 	protected function warning($text) {
1715 1751
 		return $this->getid3->warning($text);
1716 1752
 	}
1717 1753
 
1754
+	/**
1755
+	 * @param string $text
1756
+	 */
1718 1757
 	protected function notice($text) {
1719 1758
 		// does nothing for now
1720 1759
 	}
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1588,8 +1588,8 @@
 block discarded – undo
1588 1588
 abstract class getid3_handler {
1589 1589
 
1590 1590
 	/**
1591
-	* @var getID3
1592
-	*/
1591
+	 * @var getID3
1592
+	 */
1593 1593
 	protected $getid3;                       // pointer
1594 1594
 
1595 1595
 	protected $data_string_flag     = false; // analyzing filepointer or string
Please login to merge, or discard this patch.
Spacing   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -11,24 +11,24 @@  discard block
 block discarded – undo
11 11
 /////////////////////////////////////////////////////////////////
12 12
 
13 13
 // define a constant rather than looking up every time it is needed
14
-if (!defined('GETID3_OS_ISWINDOWS')) {
14
+if ( ! defined('GETID3_OS_ISWINDOWS')) {
15 15
 	define('GETID3_OS_ISWINDOWS', (stripos(PHP_OS, 'WIN') === 0));
16 16
 }
17 17
 // Get base path of getID3() - ONCE
18
-if (!defined('GETID3_INCLUDEPATH')) {
18
+if ( ! defined('GETID3_INCLUDEPATH')) {
19 19
 	define('GETID3_INCLUDEPATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
20 20
 }
21 21
 // Workaround Bug #39923 (https://bugs.php.net/bug.php?id=39923)
22
-if (!defined('IMG_JPG') && defined('IMAGETYPE_JPEG')) {
22
+if ( ! defined('IMG_JPG') && defined('IMAGETYPE_JPEG')) {
23 23
 	define('IMG_JPG', IMAGETYPE_JPEG);
24 24
 }
25 25
 
26 26
 // attempt to define temp dir as something flexible but reliable
27 27
 $temp_dir = ini_get('upload_tmp_dir');
28
-if ($temp_dir && (!is_dir($temp_dir) || !is_readable($temp_dir))) {
28
+if ($temp_dir && ( ! is_dir($temp_dir) || ! is_readable($temp_dir))) {
29 29
 	$temp_dir = '';
30 30
 }
31
-if (!$temp_dir && function_exists('sys_get_temp_dir')) { // sys_get_temp_dir added in PHP v5.2.1
31
+if ( ! $temp_dir && function_exists('sys_get_temp_dir')) { // sys_get_temp_dir added in PHP v5.2.1
32 32
 	// sys_get_temp_dir() may give inaccessible temp dir, e.g. with open_basedir on virtual hosts
33 33
 	$temp_dir = sys_get_temp_dir();
34 34
 }
@@ -52,16 +52,16 @@  discard block
 block discarded – undo
52 52
 			break;
53 53
 		}
54 54
 	}
55
-	if (!$found_valid_tempdir) {
55
+	if ( ! $found_valid_tempdir) {
56 56
 		$temp_dir = '';
57 57
 	}
58 58
 	unset($open_basedirs, $found_valid_tempdir, $basedir);
59 59
 }
60
-if (!$temp_dir) {
60
+if ( ! $temp_dir) {
61 61
 	$temp_dir = '*'; // invalid directory name should force tempnam() to use system default temp dir
62 62
 }
63 63
 // $temp_dir = '/something/else/';  // feel free to override temp dir here if it works better for your system
64
-if (!defined('GETID3_TEMP_DIR')) {
64
+if ( ! defined('GETID3_TEMP_DIR')) {
65 65
 	define('GETID3_TEMP_DIR', $temp_dir);
66 66
 }
67 67
 unset($open_basedir, $temp_dir);
@@ -72,19 +72,19 @@  discard block
 block discarded – undo
72 72
 class getID3
73 73
 {
74 74
 	// public: Settings
75
-	public $encoding        = 'UTF-8';        // CASE SENSITIVE! - i.e. (must be supported by iconv()). Examples:  ISO-8859-1  UTF-8  UTF-16  UTF-16BE
76
-	public $encoding_id3v1  = 'ISO-8859-1';   // Should always be 'ISO-8859-1', but some tags may be written in other encodings such as 'EUC-CN' or 'CP1252'
75
+	public $encoding        = 'UTF-8'; // CASE SENSITIVE! - i.e. (must be supported by iconv()). Examples:  ISO-8859-1  UTF-8  UTF-16  UTF-16BE
76
+	public $encoding_id3v1  = 'ISO-8859-1'; // Should always be 'ISO-8859-1', but some tags may be written in other encodings such as 'EUC-CN' or 'CP1252'
77 77
 
78 78
 	// public: Optional tag checks - disable for speed.
79
-	public $option_tag_id3v1         = true;  // Read and process ID3v1 tags
80
-	public $option_tag_id3v2         = true;  // Read and process ID3v2 tags
81
-	public $option_tag_lyrics3       = true;  // Read and process Lyrics3 tags
82
-	public $option_tag_apetag        = true;  // Read and process APE tags
83
-	public $option_tags_process      = true;  // Copy tags to root key 'tags' and encode to $this->encoding
84
-	public $option_tags_html         = true;  // Copy tags to root key 'tags_html' properly translated from various encodings to HTML entities
79
+	public $option_tag_id3v1         = true; // Read and process ID3v1 tags
80
+	public $option_tag_id3v2         = true; // Read and process ID3v2 tags
81
+	public $option_tag_lyrics3       = true; // Read and process Lyrics3 tags
82
+	public $option_tag_apetag        = true; // Read and process APE tags
83
+	public $option_tags_process      = true; // Copy tags to root key 'tags' and encode to $this->encoding
84
+	public $option_tags_html         = true; // Copy tags to root key 'tags_html' properly translated from various encodings to HTML entities
85 85
 
86 86
 	// public: Optional tag/comment calucations
87
-	public $option_extra_info        = true;  // Calculate additional info such as bitrate, channelmode etc
87
+	public $option_extra_info        = true; // Calculate additional info such as bitrate, channelmode etc
88 88
 
89 89
 	// public: Optional handling of embedded attachments (e.g. images)
90 90
 	public $option_save_attachments  = true; // defaults to true (ATTACHMENTS_INLINE) for backward compatibility
@@ -93,15 +93,15 @@  discard block
 block discarded – undo
93 93
 	public $option_md5_data          = false; // Get MD5 sum of data part - slow
94 94
 	public $option_md5_data_source   = false; // Use MD5 of source file if availble - only FLAC and OptimFROG
95 95
 	public $option_sha1_data         = false; // Get SHA1 sum of data part - slow
96
-	public $option_max_2gb_check     = null;  // Check whether file is larger than 2GB and thus not supported by 32-bit PHP (null: auto-detect based on PHP_INT_MAX)
96
+	public $option_max_2gb_check     = null; // Check whether file is larger than 2GB and thus not supported by 32-bit PHP (null: auto-detect based on PHP_INT_MAX)
97 97
 
98 98
 	// public: Read buffer size in bytes
99 99
 	public $option_fread_buffer_size = 32768;
100 100
 
101 101
 	// Public variables
102
-	public $filename;                         // Filename of file being analysed.
103
-	public $fp;                               // Filepointer to file being analysed.
104
-	public $info;                             // Result array.
102
+	public $filename; // Filename of file being analysed.
103
+	public $fp; // Filepointer to file being analysed.
104
+	public $info; // Result array.
105 105
 	public $tempdir = GETID3_TEMP_DIR;
106 106
 	public $memory_limit = 0;
107 107
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		}
160 160
 
161 161
 		// Load support library
162
-		if (!include_once(GETID3_INCLUDEPATH.'getid3.lib.php')) {
162
+		if ( ! include_once(GETID3_INCLUDEPATH.'getid3.lib.php')) {
163 163
 			$this->startup_error .= 'getid3.lib.php is missing or corrupt';
164 164
 		}
165 165
 
@@ -174,18 +174,18 @@  discard block
 block discarded – undo
174 174
 		// This path cannot contain spaces, but the below code will attempt to get the
175 175
 		//   8.3-equivalent path automatically
176 176
 		// IMPORTANT: This path must include the trailing slash
177
-		if (GETID3_OS_ISWINDOWS && !defined('GETID3_HELPERAPPSDIR')) {
177
+		if (GETID3_OS_ISWINDOWS && ! defined('GETID3_HELPERAPPSDIR')) {
178 178
 
179 179
 			$helperappsdir = GETID3_INCLUDEPATH.'..'.DIRECTORY_SEPARATOR.'helperapps'; // must not have any space in this path
180 180
 
181
-			if (!is_dir($helperappsdir)) {
181
+			if ( ! is_dir($helperappsdir)) {
182 182
 				$this->startup_warning .= '"'.$helperappsdir.'" cannot be defined as GETID3_HELPERAPPSDIR because it does not exist';
183 183
 			} elseif (strpos(realpath($helperappsdir), ' ') !== false) {
184 184
 				$DirPieces = explode(DIRECTORY_SEPARATOR, realpath($helperappsdir));
185 185
 				$path_so_far = array();
186 186
 				foreach ($DirPieces as $key => $value) {
187 187
 					if (strpos($value, ' ') !== false) {
188
-						if (!empty($path_so_far)) {
188
+						if ( ! empty($path_so_far)) {
189 189
 							$commandline = 'dir /x '.escapeshellarg(implode(DIRECTORY_SEPARATOR, $path_so_far));
190 190
 							$dir_listing = `$commandline`;
191 191
 							$lines = explode("\n", $dir_listing);
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 
224 224
 	// public: setOption
225 225
 	public function setOption($optArray) {
226
-		if (!is_array($optArray) || empty($optArray)) {
226
+		if ( ! is_array($optArray) || empty($optArray)) {
227 227
 			return false;
228 228
 		}
229 229
 		foreach ($optArray as $opt => $val) {
@@ -238,10 +238,10 @@  discard block
 block discarded – undo
238 238
 
239 239
 	public function openfile($filename) {
240 240
 		try {
241
-			if (!empty($this->startup_error)) {
241
+			if ( ! empty($this->startup_error)) {
242 242
 				throw new getid3_exception($this->startup_error);
243 243
 			}
244
-			if (!empty($this->startup_warning)) {
244
+			if ( ! empty($this->startup_warning)) {
245 245
 				$this->warning($this->startup_warning);
246 246
 			}
247 247
 
@@ -265,13 +265,13 @@  discard block
 block discarded – undo
265 265
 				// great
266 266
 			} else {
267 267
 				$errormessagelist = array();
268
-				if (!is_readable($filename)) {
268
+				if ( ! is_readable($filename)) {
269 269
 					$errormessagelist[] = '!is_readable';
270 270
 				}
271
-				if (!is_file($filename)) {
271
+				if ( ! is_file($filename)) {
272 272
 					$errormessagelist[] = '!is_file';
273 273
 				}
274
-				if (!file_exists($filename)) {
274
+				if ( ! file_exists($filename)) {
275 275
 					$errormessagelist[] = '!file_exists';
276 276
 				}
277 277
 				if (empty($errormessagelist)) {
@@ -317,14 +317,14 @@  discard block
 block discarded – undo
317 317
 			// set more parameters
318 318
 			$this->info['avdataoffset']        = 0;
319 319
 			$this->info['avdataend']           = $this->info['filesize'];
320
-			$this->info['fileformat']          = '';                // filled in later
321
-			$this->info['audio']['dataformat'] = '';                // filled in later, unset if not used
322
-			$this->info['video']['dataformat'] = '';                // filled in later, unset if not used
323
-			$this->info['tags']                = array();           // filled in later, unset if not used
324
-			$this->info['error']               = array();           // filled in later, unset if not used
325
-			$this->info['warning']             = array();           // filled in later, unset if not used
326
-			$this->info['comments']            = array();           // filled in later, unset if not used
327
-			$this->info['encoding']            = $this->encoding;   // required by id3v2 and iso modules - can be unset at the end if desired
320
+			$this->info['fileformat']          = ''; // filled in later
321
+			$this->info['audio']['dataformat'] = ''; // filled in later, unset if not used
322
+			$this->info['video']['dataformat'] = ''; // filled in later, unset if not used
323
+			$this->info['tags']                = array(); // filled in later, unset if not used
324
+			$this->info['error']               = array(); // filled in later, unset if not used
325
+			$this->info['warning']             = array(); // filled in later, unset if not used
326
+			$this->info['comments']            = array(); // filled in later, unset if not used
327
+			$this->info['encoding']            = $this->encoding; // required by id3v2 and iso modules - can be unset at the end if desired
328 328
 
329 329
 			return true;
330 330
 
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 	// public: analyze file
338 338
 	public function analyze($filename) {
339 339
 		try {
340
-			if (!$this->openfile($filename)) {
340
+			if ( ! $this->openfile($filename)) {
341 341
 				return $this->info;
342 342
 			}
343 343
 
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 			}
367 367
 
368 368
 			// ID3v2 detection (NOT parsing), even if ($this->option_tag_id3v2 == false) done to make fileformat easier
369
-			if (!$this->option_tag_id3v2) {
369
+			if ( ! $this->option_tag_id3v2) {
370 370
 				fseek($this->fp, 0);
371 371
 				$header = fread($this->fp, 10);
372 372
 				if ((substr($header, 0, 3) == 'ID3') && (strlen($header) == 10)) {
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 			$determined_format = $this->GetFileFormat($formattest, $filename);
386 386
 
387 387
 			// unable to determine file format
388
-			if (!$determined_format) {
388
+			if ( ! $determined_format) {
389 389
 				fclose($this->fp);
390 390
 				return $this->error('unable to determine file format');
391 391
 			}
@@ -414,14 +414,14 @@  discard block
 block discarded – undo
414 414
 			$this->info['mime_type'] = $determined_format['mime_type'];
415 415
 
416 416
 			// supported format signature pattern detected, but module deleted
417
-			if (!file_exists(GETID3_INCLUDEPATH.$determined_format['include'])) {
417
+			if ( ! file_exists(GETID3_INCLUDEPATH.$determined_format['include'])) {
418 418
 				fclose($this->fp);
419 419
 				return $this->error('Format not supported, module "'.$determined_format['include'].'" was removed.');
420 420
 			}
421 421
 
422 422
 			// module requires iconv support
423 423
 			// Check encoding/iconv support
424
-			if (!empty($determined_format['iconv_req']) && !function_exists('iconv') && !in_array($this->encoding, array('ISO-8859-1', 'UTF-8', 'UTF-16LE', 'UTF-16BE', 'UTF-16'))) {
424
+			if ( ! empty($determined_format['iconv_req']) && ! function_exists('iconv') && ! in_array($this->encoding, array('ISO-8859-1', 'UTF-8', 'UTF-16LE', 'UTF-16BE', 'UTF-16'))) {
425 425
 				$errormessage = 'iconv() support is required for this module ('.$determined_format['include'].') for encodings other than ISO-8859-1, UTF-8, UTF-16LE, UTF16-BE, UTF-16. ';
426 426
 				if (GETID3_OS_ISWINDOWS) {
427 427
 					$errormessage .= 'PHP does not have iconv() support. Please enable php_iconv.dll in php.ini, and copy iconv.dll from c:/php/dlls to c:/windows/system32';
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 
437 437
 			// instantiate module class
438 438
 			$class_name = 'getid3_'.$determined_format['module'];
439
-			if (!class_exists($class_name)) {
439
+			if ( ! class_exists($class_name)) {
440 440
 				return $this->error('Format not supported, module "'.$determined_format['include'].'" is corrupt.');
441 441
 			}
442 442
 			$class = new $class_name($this);
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 			// get the MD5 sum of the audio/video portion of the file - without ID3/APE/Lyrics3/etc header/footer tags
464 464
 			if ($this->option_md5_data) {
465 465
 				// do not calc md5_data if md5_data_source is present - set by flac only - future MPC/SV8 too
466
-				if (!$this->option_md5_data_source || empty($this->info['md5_data_source'])) {
466
+				if ( ! $this->option_md5_data_source || empty($this->info['md5_data_source'])) {
467 467
 					$this->getHashdata('md5');
468 468
 				}
469 469
 			}
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 	// private: error handling
489 489
 	public function error($message) {
490 490
 		$this->CleanUp();
491
-		if (!isset($this->info['error'])) {
491
+		if ( ! isset($this->info['error'])) {
492 492
 			$this->info['error'] = array();
493 493
 		}
494 494
 		$this->info['error'][] = $message;
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 		}
519 519
 
520 520
 		// remove empty root keys
521
-		if (!empty($this->info)) {
521
+		if ( ! empty($this->info)) {
522 522
 			foreach ($this->info as $key => $value) {
523 523
 				if (empty($this->info[$key]) && ($this->info[$key] !== 0) && ($this->info[$key] !== '0')) {
524 524
 					unset($this->info[$key]);
@@ -537,10 +537,10 @@  discard block
 block discarded – undo
537 537
 		}
538 538
 
539 539
 		// remove possible duplicated identical entries
540
-		if (!empty($this->info['error'])) {
540
+		if ( ! empty($this->info['error'])) {
541 541
 			$this->info['error'] = array_values(array_unique($this->info['error']));
542 542
 		}
543
-		if (!empty($this->info['warning'])) {
543
+		if ( ! empty($this->info['warning'])) {
544 544
 			$this->info['warning'] = array_values(array_unique($this->info['warning']));
545 545
 		}
546 546
 
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 
765 765
 				// TTA  - audio       - TTA Lossless Audio Compressor (http://tta.corecodec.org)
766 766
 				'tta'  => array(
767
-							'pattern'   => '^TTA',  // could also be '^TTA(\x01|\x02|\x03|2|1)'
767
+							'pattern'   => '^TTA', // could also be '^TTA(\x01|\x02|\x03|2|1)'
768 768
 							'group'     => 'audio',
769 769
 							'module'    => 'tta',
770 770
 							'mime_type' => 'application/octet-stream',
@@ -1052,7 +1052,7 @@  discard block
 block discarded – undo
1052 1052
 				// Misc other formats
1053 1053
 
1054 1054
 				// PAR2 - data        - Parity Volume Set Specification 2.0
1055
-				'par2' => array (
1055
+				'par2' => array(
1056 1056
 							'pattern'   => '^PAR2\x00PKT',
1057 1057
 							'group'     => 'misc',
1058 1058
 							'module'    => 'par2',
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
 
1098 1098
 
1099 1099
 
1100
-	public function GetFileFormat(&$filedata, $filename='') {
1100
+	public function GetFileFormat(&$filedata, $filename = '') {
1101 1101
 		// this function will determine the format of a file based on usually
1102 1102
 		// the first 2-4 bytes of the file (8 bytes for PNG, 16 bytes for JPG,
1103 1103
 		// and in the case of ISO CD image, 6 bytes offset 32kb from the start
@@ -1107,7 +1107,7 @@  discard block
 block discarded – undo
1107 1107
 		foreach ($this->GetFileFormatArray() as $format_name => $info) {
1108 1108
 			// The /s switch on preg_match() forces preg_match() NOT to treat
1109 1109
 			// newline (0x0A) characters as special chars but do a binary match
1110
-			if (!empty($info['pattern']) && preg_match('#'.$info['pattern'].'#s', $filedata)) {
1110
+			if ( ! empty($info['pattern']) && preg_match('#'.$info['pattern'].'#s', $filedata)) {
1111 1111
 				$info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
1112 1112
 				return $info;
1113 1113
 			}
@@ -1127,7 +1127,7 @@  discard block
 block discarded – undo
1127 1127
 			// and verify there's at least one instance of "TRACK xx AUDIO" in the file
1128 1128
 			$GetFileFormatArray = $this->GetFileFormatArray();
1129 1129
 			$info = $GetFileFormatArray['cue'];
1130
-			$info['include']   = 'module.'.$info['group'].'.'.$info['module'].'.php';
1130
+			$info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
1131 1131
 			return $info;
1132 1132
 		}
1133 1133
 
@@ -1165,26 +1165,26 @@  discard block
 block discarded – undo
1165 1165
 		static $tags;
1166 1166
 		if (empty($tags)) {
1167 1167
 			$tags = array(
1168
-				'asf'       => array('asf'           , 'UTF-16LE'),
1169
-				'midi'      => array('midi'          , 'ISO-8859-1'),
1170
-				'nsv'       => array('nsv'           , 'ISO-8859-1'),
1171
-				'ogg'       => array('vorbiscomment' , 'UTF-8'),
1172
-				'png'       => array('png'           , 'UTF-8'),
1173
-				'tiff'      => array('tiff'          , 'ISO-8859-1'),
1174
-				'quicktime' => array('quicktime'     , 'UTF-8'),
1175
-				'real'      => array('real'          , 'ISO-8859-1'),
1176
-				'vqf'       => array('vqf'           , 'ISO-8859-1'),
1177
-				'zip'       => array('zip'           , 'ISO-8859-1'),
1178
-				'riff'      => array('riff'          , 'ISO-8859-1'),
1179
-				'lyrics3'   => array('lyrics3'       , 'ISO-8859-1'),
1180
-				'id3v1'     => array('id3v1'         , $this->encoding_id3v1),
1181
-				'id3v2'     => array('id3v2'         , 'UTF-8'), // not according to the specs (every frame can have a different encoding), but getID3() force-converts all encodings to UTF-8
1182
-				'ape'       => array('ape'           , 'UTF-8'),
1183
-				'cue'       => array('cue'           , 'ISO-8859-1'),
1184
-				'matroska'  => array('matroska'      , 'UTF-8'),
1185
-				'flac'      => array('vorbiscomment' , 'UTF-8'),
1186
-				'divxtag'   => array('divx'          , 'ISO-8859-1'),
1187
-				'iptc'      => array('iptc'          , 'ISO-8859-1'),
1168
+				'asf'       => array('asf', 'UTF-16LE'),
1169
+				'midi'      => array('midi', 'ISO-8859-1'),
1170
+				'nsv'       => array('nsv', 'ISO-8859-1'),
1171
+				'ogg'       => array('vorbiscomment', 'UTF-8'),
1172
+				'png'       => array('png', 'UTF-8'),
1173
+				'tiff'      => array('tiff', 'ISO-8859-1'),
1174
+				'quicktime' => array('quicktime', 'UTF-8'),
1175
+				'real'      => array('real', 'ISO-8859-1'),
1176
+				'vqf'       => array('vqf', 'ISO-8859-1'),
1177
+				'zip'       => array('zip', 'ISO-8859-1'),
1178
+				'riff'      => array('riff', 'ISO-8859-1'),
1179
+				'lyrics3'   => array('lyrics3', 'ISO-8859-1'),
1180
+				'id3v1'     => array('id3v1', $this->encoding_id3v1),
1181
+				'id3v2'     => array('id3v2', 'UTF-8'), // not according to the specs (every frame can have a different encoding), but getID3() force-converts all encodings to UTF-8
1182
+				'ape'       => array('ape', 'UTF-8'),
1183
+				'cue'       => array('cue', 'ISO-8859-1'),
1184
+				'matroska'  => array('matroska', 'UTF-8'),
1185
+				'flac'      => array('vorbiscomment', 'UTF-8'),
1186
+				'divxtag'   => array('divx', 'ISO-8859-1'),
1187
+				'iptc'      => array('iptc', 'ISO-8859-1'),
1188 1188
 			);
1189 1189
 		}
1190 1190
 
@@ -1193,19 +1193,19 @@  discard block
 block discarded – undo
1193 1193
 			list($tag_name, $encoding) = $tagname_encoding_array;
1194 1194
 
1195 1195
 			// fill in default encoding type if not already present
1196
-			if (isset($this->info[$comment_name]) && !isset($this->info[$comment_name]['encoding'])) {
1196
+			if (isset($this->info[$comment_name]) && ! isset($this->info[$comment_name]['encoding'])) {
1197 1197
 				$this->info[$comment_name]['encoding'] = $encoding;
1198 1198
 			}
1199 1199
 
1200 1200
 			// copy comments if key name set
1201
-			if (!empty($this->info[$comment_name]['comments'])) {
1201
+			if ( ! empty($this->info[$comment_name]['comments'])) {
1202 1202
 				foreach ($this->info[$comment_name]['comments'] as $tag_key => $valuearray) {
1203 1203
 					foreach ($valuearray as $key => $value) {
1204 1204
 						if (is_string($value)) {
1205 1205
 							$value = trim($value, " \r\n\t"); // do not trim nulls from $value!! Unicode characters will get mangled if trailing nulls are removed!
1206 1206
 						}
1207 1207
 						if ($value) {
1208
-							if (!is_numeric($key)) {
1208
+							if ( ! is_numeric($key)) {
1209 1209
 								$this->info['tags'][trim($tag_name)][trim($tag_key)][$key] = $value;
1210 1210
 							} else {
1211 1211
 								$this->info['tags'][trim($tag_name)][trim($tag_key)][]     = $value;
@@ -1217,7 +1217,7 @@  discard block
 block discarded – undo
1217 1217
 					}
1218 1218
 				}
1219 1219
 
1220
-				if (!isset($this->info['tags'][$tag_name])) {
1220
+				if ( ! isset($this->info['tags'][$tag_name])) {
1221 1221
 					// comments are set but contain nothing but empty strings, so skip
1222 1222
 					continue;
1223 1223
 				}
@@ -1228,14 +1228,14 @@  discard block
 block discarded – undo
1228 1228
 					}
1229 1229
 				}
1230 1230
 
1231
-				$this->CharConvert($this->info['tags'][$tag_name], $encoding);           // only copy gets converted!
1231
+				$this->CharConvert($this->info['tags'][$tag_name], $encoding); // only copy gets converted!
1232 1232
 			}
1233 1233
 
1234 1234
 		}
1235 1235
 
1236 1236
 		// pictures can take up a lot of space, and we don't need multiple copies of them
1237 1237
 		// let there be a single copy in [comments][picture], and not elsewhere
1238
-		if (!empty($this->info['tags'])) {
1238
+		if ( ! empty($this->info['tags'])) {
1239 1239
 			$unset_keys = array('tags', 'tags_html');
1240 1240
 			foreach ($this->info['tags'] as $tagtype => $tagarray) {
1241 1241
 				foreach ($tagarray as $tagname => $tagdata) {
@@ -1291,7 +1291,7 @@  discard block
 block discarded – undo
1291 1291
 				break;
1292 1292
 		}
1293 1293
 
1294
-		if (!empty($this->info['fileformat']) && !empty($this->info['dataformat']) && ($this->info['fileformat'] == 'ogg') && ($this->info['audio']['dataformat'] == 'vorbis')) {
1294
+		if ( ! empty($this->info['fileformat']) && ! empty($this->info['dataformat']) && ($this->info['fileformat'] == 'ogg') && ($this->info['audio']['dataformat'] == 'vorbis')) {
1295 1295
 
1296 1296
 			// We cannot get an identical md5_data value for Ogg files where the comments
1297 1297
 			// span more than 1 Ogg page (compared to the same audio data with smaller
@@ -1350,7 +1350,7 @@  discard block
 block discarded – undo
1350 1350
 
1351 1351
 				}
1352 1352
 
1353
-				if (!empty($VorbisCommentError)) {
1353
+				if ( ! empty($VorbisCommentError)) {
1354 1354
 
1355 1355
 					$this->info['warning'][]         = 'Failed making system call to vorbiscomment(.exe) - '.$algorithm.'_data will be incorrect. If vorbiscomment is unavailable, please download from http://www.vorbis.com/download.psp and put in the getID3() directory. Error returned: '.$VorbisCommentError;
1356 1356
 					$this->info[$algorithm.'_data']  = false;
@@ -1380,7 +1380,7 @@  discard block
 block discarded – undo
1380 1380
 
1381 1381
 		} else {
1382 1382
 
1383
-			if (!empty($this->info['avdataoffset']) || (isset($this->info['avdataend']) && ($this->info['avdataend'] < $this->info['filesize']))) {
1383
+			if ( ! empty($this->info['avdataoffset']) || (isset($this->info['avdataend']) && ($this->info['avdataend'] < $this->info['filesize']))) {
1384 1384
 
1385 1385
 				// get hash from part of file
1386 1386
 				$this->info[$algorithm.'_data'] = getid3_lib::hash_data($this->info['filenamepath'], $this->info['avdataoffset'], $this->info['avdataend'], $algorithm);
@@ -1407,7 +1407,7 @@  discard block
 block discarded – undo
1407 1407
 	public function ChannelsBitratePlaytimeCalculations() {
1408 1408
 
1409 1409
 		// set channelmode on audio
1410
-		if (!empty($this->info['audio']['channelmode']) || !isset($this->info['audio']['channels'])) {
1410
+		if ( ! empty($this->info['audio']['channelmode']) || ! isset($this->info['audio']['channels'])) {
1411 1411
 			// ignore
1412 1412
 		} elseif ($this->info['audio']['channels'] == 1) {
1413 1413
 			$this->info['audio']['channelmode'] = 'mono';
@@ -1429,7 +1429,7 @@  discard block
 block discarded – undo
1429 1429
 		//}
1430 1430
 
1431 1431
 		// video bitrate undetermined, but calculable
1432
-		if (isset($this->info['video']['dataformat']) && $this->info['video']['dataformat'] && (!isset($this->info['video']['bitrate']) || ($this->info['video']['bitrate'] == 0))) {
1432
+		if (isset($this->info['video']['dataformat']) && $this->info['video']['dataformat'] && ( ! isset($this->info['video']['bitrate']) || ($this->info['video']['bitrate'] == 0))) {
1433 1433
 			// if video bitrate not set
1434 1434
 			if (isset($this->info['audio']['bitrate']) && ($this->info['audio']['bitrate'] > 0) && ($this->info['audio']['bitrate'] == $this->info['bitrate'])) {
1435 1435
 				// AND if audio bitrate is set to same as overall bitrate
@@ -1445,11 +1445,11 @@  discard block
 block discarded – undo
1445 1445
 			}
1446 1446
 		}
1447 1447
 
1448
-		if ((!isset($this->info['playtime_seconds']) || ($this->info['playtime_seconds'] <= 0)) && !empty($this->info['bitrate'])) {
1448
+		if (( ! isset($this->info['playtime_seconds']) || ($this->info['playtime_seconds'] <= 0)) && ! empty($this->info['bitrate'])) {
1449 1449
 			$this->info['playtime_seconds'] = (($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['bitrate'];
1450 1450
 		}
1451 1451
 
1452
-		if (!isset($this->info['bitrate']) && !empty($this->info['playtime_seconds'])) {
1452
+		if ( ! isset($this->info['bitrate']) && ! empty($this->info['playtime_seconds'])) {
1453 1453
 			$this->info['bitrate'] = (($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['playtime_seconds'];
1454 1454
 		}
1455 1455
 		if (isset($this->info['bitrate']) && empty($this->info['audio']['bitrate']) && empty($this->info['video']['bitrate'])) {
@@ -1463,7 +1463,7 @@  discard block
 block discarded – undo
1463 1463
 		}
1464 1464
 
1465 1465
 		// Set playtime string
1466
-		if (!empty($this->info['playtime_seconds']) && empty($this->info['playtime_string'])) {
1466
+		if ( ! empty($this->info['playtime_seconds']) && empty($this->info['playtime_string'])) {
1467 1467
 			$this->info['playtime_string'] = getid3_lib::PlaytimeString($this->info['playtime_seconds']);
1468 1468
 		}
1469 1469
 	}
@@ -1493,17 +1493,17 @@  discard block
 block discarded – undo
1493 1493
 				break;
1494 1494
 
1495 1495
 			default:
1496
-				if (!empty($this->info['video']['frame_rate'])) {
1496
+				if ( ! empty($this->info['video']['frame_rate'])) {
1497 1497
 					$FrameRate = $this->info['video']['frame_rate'];
1498 1498
 				} else {
1499 1499
 					return false;
1500 1500
 				}
1501
-				if (!empty($this->info['playtime_seconds'])) {
1501
+				if ( ! empty($this->info['playtime_seconds'])) {
1502 1502
 					$PlaytimeSeconds = $this->info['playtime_seconds'];
1503 1503
 				} else {
1504 1504
 					return false;
1505 1505
 				}
1506
-				if (!empty($this->info['video']['bitrate'])) {
1506
+				if ( ! empty($this->info['video']['bitrate'])) {
1507 1507
 					$BitrateCompressed = $this->info['video']['bitrate'];
1508 1508
 				} else {
1509 1509
 					return false;
@@ -1518,15 +1518,15 @@  discard block
 block discarded – undo
1518 1518
 
1519 1519
 
1520 1520
 	public function CalculateCompressionRatioAudio() {
1521
-		if (empty($this->info['audio']['bitrate']) || empty($this->info['audio']['channels']) || empty($this->info['audio']['sample_rate']) || !is_numeric($this->info['audio']['sample_rate'])) {
1521
+		if (empty($this->info['audio']['bitrate']) || empty($this->info['audio']['channels']) || empty($this->info['audio']['sample_rate']) || ! is_numeric($this->info['audio']['sample_rate'])) {
1522 1522
 			return false;
1523 1523
 		}
1524
-		$this->info['audio']['compression_ratio'] = $this->info['audio']['bitrate'] / ($this->info['audio']['channels'] * $this->info['audio']['sample_rate'] * (!empty($this->info['audio']['bits_per_sample']) ? $this->info['audio']['bits_per_sample'] : 16));
1524
+		$this->info['audio']['compression_ratio'] = $this->info['audio']['bitrate'] / ($this->info['audio']['channels'] * $this->info['audio']['sample_rate'] * ( ! empty($this->info['audio']['bits_per_sample']) ? $this->info['audio']['bits_per_sample'] : 16));
1525 1525
 
1526
-		if (!empty($this->info['audio']['streams'])) {
1526
+		if ( ! empty($this->info['audio']['streams'])) {
1527 1527
 			foreach ($this->info['audio']['streams'] as $streamnumber => $streamdata) {
1528
-				if (!empty($streamdata['bitrate']) && !empty($streamdata['channels']) && !empty($streamdata['sample_rate'])) {
1529
-					$this->info['audio']['streams'][$streamnumber]['compression_ratio'] = $streamdata['bitrate'] / ($streamdata['channels'] * $streamdata['sample_rate'] * (!empty($streamdata['bits_per_sample']) ? $streamdata['bits_per_sample'] : 16));
1528
+				if ( ! empty($streamdata['bitrate']) && ! empty($streamdata['channels']) && ! empty($streamdata['sample_rate'])) {
1529
+					$this->info['audio']['streams'][$streamnumber]['compression_ratio'] = $streamdata['bitrate'] / ($streamdata['channels'] * $streamdata['sample_rate'] * ( ! empty($streamdata['bits_per_sample']) ? $streamdata['bits_per_sample'] : 16));
1530 1530
 				}
1531 1531
 			}
1532 1532
 		}
@@ -1536,7 +1536,7 @@  discard block
 block discarded – undo
1536 1536
 
1537 1537
 	public function CalculateReplayGain() {
1538 1538
 		if (isset($this->info['replay_gain'])) {
1539
-			if (!isset($this->info['replay_gain']['reference_volume'])) {
1539
+			if ( ! isset($this->info['replay_gain']['reference_volume'])) {
1540 1540
 				$this->info['replay_gain']['reference_volume'] = (double) 89.0;
1541 1541
 			}
1542 1542
 			if (isset($this->info['replay_gain']['track']['adjustment'])) {
@@ -1557,8 +1557,8 @@  discard block
 block discarded – undo
1557 1557
 	}
1558 1558
 
1559 1559
 	public function ProcessAudioStreams() {
1560
-		if (!empty($this->info['audio']['bitrate']) || !empty($this->info['audio']['channels']) || !empty($this->info['audio']['sample_rate'])) {
1561
-			if (!isset($this->info['audio']['streams'])) {
1560
+		if ( ! empty($this->info['audio']['bitrate']) || ! empty($this->info['audio']['channels']) || ! empty($this->info['audio']['sample_rate'])) {
1561
+			if ( ! isset($this->info['audio']['streams'])) {
1562 1562
 				foreach ($this->info['audio'] as $key => $value) {
1563 1563
 					if ($key != 'streams') {
1564 1564
 						$this->info['audio']['streams'][0][$key] = $value;
@@ -1575,7 +1575,7 @@  discard block
 block discarded – undo
1575 1575
 
1576 1576
 	public function include_module($name) {
1577 1577
 		//if (!file_exists($this->include_path.'module.'.$name.'.php')) {
1578
-		if (!file_exists(GETID3_INCLUDEPATH.'module.'.$name.'.php')) {
1578
+		if ( ! file_exists(GETID3_INCLUDEPATH.'module.'.$name.'.php')) {
1579 1579
 			throw new getid3_exception('Required module.'.$name.'.php is missing.');
1580 1580
 		}
1581 1581
 		include_once(GETID3_INCLUDEPATH.'module.'.$name.'.php');
@@ -1590,17 +1590,17 @@  discard block
 block discarded – undo
1590 1590
 	/**
1591 1591
 	* @var getID3
1592 1592
 	*/
1593
-	protected $getid3;                       // pointer
1593
+	protected $getid3; // pointer
1594 1594
 
1595 1595
 	protected $data_string_flag     = false; // analyzing filepointer or string
1596
-	protected $data_string          = '';    // string to analyze
1597
-	protected $data_string_position = 0;     // seek position in string
1598
-	protected $data_string_length   = 0;     // string length
1596
+	protected $data_string          = ''; // string to analyze
1597
+	protected $data_string_position = 0; // seek position in string
1598
+	protected $data_string_length   = 0; // string length
1599 1599
 
1600 1600
 	private $dependency_to = null;
1601 1601
 
1602 1602
 
1603
-	public function __construct(getID3 $getid3, $call_module=null) {
1603
+	public function __construct(getID3 $getid3, $call_module = null) {
1604 1604
 		$this->getid3 = $getid3;
1605 1605
 
1606 1606
 		if ($call_module) {
@@ -1658,13 +1658,13 @@  discard block
 block discarded – undo
1658 1658
 			return substr($this->data_string, $this->data_string_position - $bytes, $bytes);
1659 1659
 		}
1660 1660
 		$pos = $this->ftell() + $bytes;
1661
-		if (!getid3_lib::intValueSupported($pos)) {
1661
+		if ( ! getid3_lib::intValueSupported($pos)) {
1662 1662
 			throw new getid3_exception('cannot fread('.$bytes.' from '.$this->ftell().') because beyond PHP filesystem limit', 10);
1663 1663
 		}
1664 1664
 		return fread($this->getid3->fp, $bytes);
1665 1665
 	}
1666 1666
 
1667
-	protected function fseek($bytes, $whence=SEEK_SET) {
1667
+	protected function fseek($bytes, $whence = SEEK_SET) {
1668 1668
 		if ($this->data_string_flag) {
1669 1669
 			switch ($whence) {
1670 1670
 				case SEEK_SET:
@@ -1687,7 +1687,7 @@  discard block
 block discarded – undo
1687 1687
 			} elseif ($whence == SEEK_END) {
1688 1688
 				$pos = $this->getid3->info['filesize'] + $bytes;
1689 1689
 			}
1690
-			if (!getid3_lib::intValueSupported($pos)) {
1690
+			if ( ! getid3_lib::intValueSupported($pos)) {
1691 1691
 				throw new getid3_exception('cannot fseek('.$pos.') because beyond PHP filesystem limit', 10);
1692 1692
 			}
1693 1693
 		}
@@ -1719,7 +1719,7 @@  discard block
 block discarded – undo
1719 1719
 		// does nothing for now
1720 1720
 	}
1721 1721
 
1722
-	public function saveAttachment($name, $offset, $length, $image_mime=null) {
1722
+	public function saveAttachment($name, $offset, $length, $image_mime = null) {
1723 1723
 		try {
1724 1724
 
1725 1725
 			// do not extract at all
@@ -1741,7 +1741,7 @@  discard block
 block discarded – undo
1741 1741
 
1742 1742
 				// set up destination path
1743 1743
 				$dir = rtrim(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $this->getid3->option_save_attachments), DIRECTORY_SEPARATOR);
1744
-				if (!is_dir($dir) || !is_writable($dir)) { // check supplied directory
1744
+				if ( ! is_dir($dir) || ! is_writable($dir)) { // check supplied directory
1745 1745
 					throw new Exception('supplied path ('.$dir.') does not exist, or is not writable');
1746 1746
 				}
1747 1747
 				$dest = $dir.DIRECTORY_SEPARATOR.$name.($image_mime ? '.'.getid3_lib::ImageExtFromMime($image_mime) : '');
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -350,8 +350,7 @@
 block discarded – undo
350 350
 						$tag_class = 'getid3_'.$tag_name;
351 351
 						$tag = new $tag_class($this);
352 352
 						$tag->Analyze();
353
-					}
354
-					catch (getid3_exception $e) {
353
+					} catch (getid3_exception $e) {
355 354
 						throw $e;
356 355
 					}
357 356
 				}
Please login to merge, or discard this patch.