Completed
Push — master ( a7cd2a...eabd6c )
by Stephen
38:42
created
src/wp-includes/template.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
  * @since 1.5.0
18 18
  *
19 19
  * @param string $type      Filename without extension.
20
- * @param array  $templates An optional list of template candidates
20
+ * @param string[]  $templates An optional list of template candidates
21 21
  * @return string Full path to template file.
22 22
  */
23 23
 function get_query_template( $type, $templates = array() ) {
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@  discard block
 block discarded – undo
20 20
  * @param array  $templates An optional list of template candidates
21 21
  * @return string Full path to template file.
22 22
  */
23
-function get_query_template( $type, $templates = array() ) {
24
-	$type = preg_replace( '|[^a-z0-9-]+|', '', $type );
23
+function get_query_template($type, $templates = array()) {
24
+	$type = preg_replace('|[^a-z0-9-]+|', '', $type);
25 25
 
26
-	if ( empty( $templates ) )
26
+	if (empty($templates))
27 27
 		$templates = array("{$type}.php");
28 28
 
29
-	$template = locate_template( $templates );
29
+	$template = locate_template($templates);
30 30
 
31 31
 	/**
32 32
 	 * Filter the path of the queried template by type.
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @param string $template Path to the template. See locate_template().
44 44
 	 */
45
-	return apply_filters( "{$type}_template", $template );
45
+	return apply_filters("{$type}_template", $template);
46 46
 }
47 47
 
48 48
 /**
@@ -90,17 +90,17 @@  discard block
 block discarded – undo
90 90
  * @return string Full path to archive template file.
91 91
  */
92 92
 function get_archive_template() {
93
-	$post_types = array_filter( (array) get_query_var( 'post_type' ) );
93
+	$post_types = array_filter((array) get_query_var('post_type'));
94 94
 
95 95
 	$templates = array();
96 96
 
97
-	if ( count( $post_types ) == 1 ) {
98
-		$post_type = reset( $post_types );
97
+	if (count($post_types) == 1) {
98
+		$post_type = reset($post_types);
99 99
 		$templates[] = "archive-{$post_type}.php";
100 100
 	}
101 101
 	$templates[] = 'archive.php';
102 102
 
103
-	return get_query_template( 'archive', $templates );
103
+	return get_query_template('archive', $templates);
104 104
 }
105 105
 
106 106
 /**
@@ -116,12 +116,12 @@  discard block
 block discarded – undo
116 116
  * @return string Full path to archive template file.
117 117
  */
118 118
 function get_post_type_archive_template() {
119
-	$post_type = get_query_var( 'post_type' );
120
-	if ( is_array( $post_type ) )
121
-		$post_type = reset( $post_type );
119
+	$post_type = get_query_var('post_type');
120
+	if (is_array($post_type))
121
+		$post_type = reset($post_type);
122 122
 
123
-	$obj = get_post_type_object( $post_type );
124
-	if ( ! $obj->has_archive )
123
+	$obj = get_post_type_object($post_type);
124
+	if ( ! $obj->has_archive)
125 125
 		return '';
126 126
 
127 127
 	return get_archive_template();
@@ -144,13 +144,13 @@  discard block
 block discarded – undo
144 144
 
145 145
 	$templates = array();
146 146
 
147
-	if ( $author instanceof WP_User ) {
147
+	if ($author instanceof WP_User) {
148 148
 		$templates[] = "author-{$author->user_nicename}.php";
149 149
 		$templates[] = "author-{$author->ID}.php";
150 150
 	}
151 151
 	$templates[] = 'author.php';
152 152
 
153
-	return get_query_template( 'author', $templates );
153
+	return get_query_template('author', $templates);
154 154
 }
155 155
 
156 156
 /**
@@ -174,13 +174,13 @@  discard block
 block discarded – undo
174 174
 
175 175
 	$templates = array();
176 176
 
177
-	if ( ! empty( $category->slug ) ) {
177
+	if ( ! empty($category->slug)) {
178 178
 		$templates[] = "category-{$category->slug}.php";
179 179
 		$templates[] = "category-{$category->term_id}.php";
180 180
 	}
181 181
 	$templates[] = 'category.php';
182 182
 
183
-	return get_query_template( 'category', $templates );
183
+	return get_query_template('category', $templates);
184 184
 }
185 185
 
186 186
 /**
@@ -204,13 +204,13 @@  discard block
 block discarded – undo
204 204
 
205 205
 	$templates = array();
206 206
 
207
-	if ( ! empty( $tag->slug ) ) {
207
+	if ( ! empty($tag->slug)) {
208 208
 		$templates[] = "tag-{$tag->slug}.php";
209 209
 		$templates[] = "tag-{$tag->term_id}.php";
210 210
 	}
211 211
 	$templates[] = 'tag.php';
212 212
 
213
-	return get_query_template( 'tag', $templates );
213
+	return get_query_template('tag', $templates);
214 214
 }
215 215
 
216 216
 /**
@@ -239,14 +239,14 @@  discard block
 block discarded – undo
239 239
 
240 240
 	$templates = array();
241 241
 
242
-	if ( ! empty( $term->slug ) ) {
242
+	if ( ! empty($term->slug)) {
243 243
 		$taxonomy = $term->taxonomy;
244 244
 		$templates[] = "taxonomy-$taxonomy-{$term->slug}.php";
245 245
 		$templates[] = "taxonomy-$taxonomy.php";
246 246
 	}
247 247
 	$templates[] = 'taxonomy.php';
248 248
 
249
-	return get_query_template( 'taxonomy', $templates );
249
+	return get_query_template('taxonomy', $templates);
250 250
 }
251 251
 
252 252
 /**
@@ -281,9 +281,9 @@  discard block
 block discarded – undo
281 281
  * @return string Full path to home template file.
282 282
  */
283 283
 function get_home_template() {
284
-	$templates = array( 'home.php', 'index.php' );
284
+	$templates = array('home.php', 'index.php');
285 285
 
286
-	return get_query_template( 'home', $templates );
286
+	return get_query_template('home', $templates);
287 287
 }
288 288
 
289 289
 /**
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 function get_front_page_template() {
302 302
 	$templates = array('front-page.php');
303 303
 
304
-	return get_query_template( 'front_page', $templates );
304
+	return get_query_template('front_page', $templates);
305 305
 }
306 306
 
307 307
 /**
@@ -325,23 +325,23 @@  discard block
 block discarded – undo
325 325
 	$template = get_page_template_slug();
326 326
 	$pagename = get_query_var('pagename');
327 327
 
328
-	if ( ! $pagename && $id ) {
328
+	if ( ! $pagename && $id) {
329 329
 		// If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object
330 330
 		$post = get_queried_object();
331
-		if ( $post )
331
+		if ($post)
332 332
 			$pagename = $post->post_name;
333 333
 	}
334 334
 
335 335
 	$templates = array();
336
-	if ( $template && 0 === validate_file( $template ) )
336
+	if ($template && 0 === validate_file($template))
337 337
 		$templates[] = $template;
338
-	if ( $pagename )
338
+	if ($pagename)
339 339
 		$templates[] = "page-$pagename.php";
340
-	if ( $id )
340
+	if ($id)
341 341
 		$templates[] = "page-$id.php";
342 342
 	$templates[] = 'page.php';
343 343
 
344
-	return get_query_template( 'page', $templates );
344
+	return get_query_template('page', $templates);
345 345
 }
346 346
 
347 347
 /**
@@ -394,14 +394,14 @@  discard block
 block discarded – undo
394 394
 
395 395
 	$templates = array();
396 396
 
397
-	if ( ! empty( $object->post_type ) ) {
397
+	if ( ! empty($object->post_type)) {
398 398
 		$templates[] = "single-{$object->post_type}-{$object->post_name}.php";
399 399
 		$templates[] = "single-{$object->post_type}.php";
400 400
 	}
401 401
 
402 402
 	$templates[] = "single.php";
403 403
 
404
-	return get_query_template( 'single', $templates );
404
+	return get_query_template('single', $templates);
405 405
 }
406 406
 
407 407
 /**
@@ -423,9 +423,9 @@  discard block
 block discarded – undo
423 423
 
424 424
 	$templates = array();
425 425
 
426
-	if ( ! empty( $object->post_type ) ) {
427
-		$post_format = get_post_format( $object );
428
-		if ( $post_format ) {
426
+	if ( ! empty($object->post_type)) {
427
+		$post_format = get_post_format($object);
428
+		if ($post_format) {
429 429
 			$templates[] = "embed-{$object->post_type}-{$post_format}.php";
430 430
 		}
431 431
 		$templates[] = "embed-{$object->post_type}.php";
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 
434 434
 	$templates[] = "embed.php";
435 435
 
436
-	return get_query_template( 'embed', $templates );
436
+	return get_query_template('embed', $templates);
437 437
 }
438 438
 
439 439
 /**
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
  * @return string Full path to singular template file
450 450
  */
451 451
 function get_singular_template() {
452
-	return get_query_template( 'singular' );
452
+	return get_query_template('singular');
453 453
 }
454 454
 
455 455
 /**
@@ -479,14 +479,14 @@  discard block
 block discarded – undo
479 479
 
480 480
 	$templates = array();
481 481
 
482
-	if ( $attachment ) {
483
-		if ( false !== strpos( $attachment->post_mime_type, '/' ) ) {
484
-			list( $type, $subtype ) = explode( '/', $attachment->post_mime_type );
482
+	if ($attachment) {
483
+		if (false !== strpos($attachment->post_mime_type, '/')) {
484
+			list($type, $subtype) = explode('/', $attachment->post_mime_type);
485 485
 		} else {
486
-			list( $type, $subtype ) = array( $attachment->post_mime_type, '' );
486
+			list($type, $subtype) = array($attachment->post_mime_type, '');
487 487
 		}
488 488
 
489
-		if ( ! empty( $subtype ) ) {
489
+		if ( ! empty($subtype)) {
490 490
 			$templates[] = "{$type}-{$subtype}.php";
491 491
 			$templates[] = "{$subtype}.php";
492 492
 		}
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 	}
495 495
 	$templates[] = 'attachment.php';
496 496
 
497
-	return get_query_template( 'attachment', $templates );
497
+	return get_query_template('attachment', $templates);
498 498
 }
499 499
 
500 500
 /**
@@ -510,25 +510,25 @@  discard block
 block discarded – undo
510 510
  * @param bool         $require_once   Whether to require_once or require. Default true. Has no effect if $load is false.
511 511
  * @return string The template filename if one is located.
512 512
  */
513
-function locate_template($template_names, $load = false, $require_once = true ) {
513
+function locate_template($template_names, $load = false, $require_once = true) {
514 514
 	$located = '';
515
-	foreach ( (array) $template_names as $template_name ) {
516
-		if ( !$template_name )
515
+	foreach ((array) $template_names as $template_name) {
516
+		if ( ! $template_name)
517 517
 			continue;
518
-		if ( file_exists(STYLESHEETPATH . '/' . $template_name)) {
519
-			$located = STYLESHEETPATH . '/' . $template_name;
518
+		if (file_exists(STYLESHEETPATH.'/'.$template_name)) {
519
+			$located = STYLESHEETPATH.'/'.$template_name;
520 520
 			break;
521
-		} elseif ( file_exists(TEMPLATEPATH . '/' . $template_name) ) {
522
-			$located = TEMPLATEPATH . '/' . $template_name;
521
+		} elseif (file_exists(TEMPLATEPATH.'/'.$template_name)) {
522
+			$located = TEMPLATEPATH.'/'.$template_name;
523 523
 			break;
524
-		} elseif ( file_exists( ABSPATH . WPINC . '/theme-compat/' . $template_name ) ) {
525
-			$located = ABSPATH . WPINC . '/theme-compat/' . $template_name;
524
+		} elseif (file_exists(ABSPATH.WPINC.'/theme-compat/'.$template_name)) {
525
+			$located = ABSPATH.WPINC.'/theme-compat/'.$template_name;
526 526
 			break;
527 527
 		}
528 528
 	}
529 529
 
530
-	if ( $load && '' != $located )
531
-		load_template( $located, $require_once );
530
+	if ($load && '' != $located)
531
+		load_template($located, $require_once);
532 532
 
533 533
 	return $located;
534 534
 }
@@ -557,21 +557,21 @@  discard block
 block discarded – undo
557 557
  * @param string $_template_file Path to template file.
558 558
  * @param bool   $require_once   Whether to require_once or require. Default true.
559 559
  */
560
-function load_template( $_template_file, $require_once = true ) {
560
+function load_template($_template_file, $require_once = true) {
561 561
 	global $posts, $post, $wp_did_header, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID;
562 562
 
563
-	if ( is_array( $wp_query->query_vars ) ) {
564
-		extract( $wp_query->query_vars, EXTR_SKIP );
563
+	if (is_array($wp_query->query_vars)) {
564
+		extract($wp_query->query_vars, EXTR_SKIP);
565 565
 	}
566 566
 
567
-	if ( isset( $s ) ) {
568
-		$s = esc_attr( $s );
567
+	if (isset($s)) {
568
+		$s = esc_attr($s);
569 569
 	}
570 570
 
571
-	if ( $require_once ) {
572
-		require_once( $_template_file );
571
+	if ($require_once) {
572
+		require_once($_template_file);
573 573
 	} else {
574
-		require( $_template_file );
574
+		require($_template_file);
575 575
 	}
576 576
 }
577 577
 
Please login to merge, or discard this patch.
Braces   +27 added lines, -18 removed lines patch added patch discarded remove patch
@@ -23,8 +23,9 @@  discard block
 block discarded – undo
23 23
 function get_query_template( $type, $templates = array() ) {
24 24
 	$type = preg_replace( '|[^a-z0-9-]+|', '', $type );
25 25
 
26
-	if ( empty( $templates ) )
27
-		$templates = array("{$type}.php");
26
+	if ( empty( $templates ) ) {
27
+			$templates = array("{$type}.php");
28
+	}
28 29
 
29 30
 	$template = locate_template( $templates );
30 31
 
@@ -117,12 +118,14 @@  discard block
 block discarded – undo
117 118
  */
118 119
 function get_post_type_archive_template() {
119 120
 	$post_type = get_query_var( 'post_type' );
120
-	if ( is_array( $post_type ) )
121
-		$post_type = reset( $post_type );
121
+	if ( is_array( $post_type ) ) {
122
+			$post_type = reset( $post_type );
123
+	}
122 124
 
123 125
 	$obj = get_post_type_object( $post_type );
124
-	if ( ! $obj->has_archive )
125
-		return '';
126
+	if ( ! $obj->has_archive ) {
127
+			return '';
128
+	}
126 129
 
127 130
 	return get_archive_template();
128 131
 }
@@ -328,17 +331,21 @@  discard block
 block discarded – undo
328 331
 	if ( ! $pagename && $id ) {
329 332
 		// If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object
330 333
 		$post = get_queried_object();
331
-		if ( $post )
332
-			$pagename = $post->post_name;
334
+		if ( $post ) {
335
+					$pagename = $post->post_name;
336
+		}
333 337
 	}
334 338
 
335 339
 	$templates = array();
336
-	if ( $template && 0 === validate_file( $template ) )
337
-		$templates[] = $template;
338
-	if ( $pagename )
339
-		$templates[] = "page-$pagename.php";
340
-	if ( $id )
341
-		$templates[] = "page-$id.php";
340
+	if ( $template && 0 === validate_file( $template ) ) {
341
+			$templates[] = $template;
342
+	}
343
+	if ( $pagename ) {
344
+			$templates[] = "page-$pagename.php";
345
+	}
346
+	if ( $id ) {
347
+			$templates[] = "page-$id.php";
348
+	}
342 349
 	$templates[] = 'page.php';
343 350
 
344 351
 	return get_query_template( 'page', $templates );
@@ -513,8 +520,9 @@  discard block
 block discarded – undo
513 520
 function locate_template($template_names, $load = false, $require_once = true ) {
514 521
 	$located = '';
515 522
 	foreach ( (array) $template_names as $template_name ) {
516
-		if ( !$template_name )
517
-			continue;
523
+		if ( !$template_name ) {
524
+					continue;
525
+		}
518 526
 		if ( file_exists(STYLESHEETPATH . '/' . $template_name)) {
519 527
 			$located = STYLESHEETPATH . '/' . $template_name;
520 528
 			break;
@@ -527,8 +535,9 @@  discard block
 block discarded – undo
527 535
 		}
528 536
 	}
529 537
 
530
-	if ( $load && '' != $located )
531
-		load_template( $located, $require_once );
538
+	if ( $load && '' != $located ) {
539
+			load_template( $located, $require_once );
540
+	}
532 541
 
533 542
 	return $located;
534 543
 }
Please login to merge, or discard this patch.
src/wp-includes/Text/Diff/Engine/native.php 3 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -145,6 +145,7 @@  discard block
 block discarded – undo
145 145
      * the two files do not match, and likewise that the last lines do not
146 146
      * match.  The caller must trim matching lines from the beginning and end
147 147
      * of the portions it is going to specify.
148
+     * @param double $nchunks
148 149
      */
149 150
     function _diag ($xoff, $xlim, $yoff, $ylim, $nchunks)
150 151
     {
@@ -265,6 +266,10 @@  discard block
 block discarded – undo
265 266
      *
266 267
      * Note that XLIM, YLIM are exclusive bounds.  All line numbers are
267 268
      * origin-0 and discarded lines are not counted.
269
+     * @param integer $xoff
270
+     * @param integer $xlim
271
+     * @param integer $yoff
272
+     * @param integer $ylim
268 273
      */
269 274
     function _compareseq ($xoff, $xlim, $yoff, $ylim)
270 275
     {
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
             // Skip matching "snake".
100 100
             $copy = array();
101 101
             while ($xi < $n_from && $yi < $n_to
102
-                   && !$this->xchanged[$xi] && !$this->ychanged[$yi]) {
102
+                   && ! $this->xchanged[$xi] && ! $this->ychanged[$yi]) {
103 103
                 $copy[] = $from_lines[$xi++];
104 104
                 ++$yi;
105 105
             }
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
      * match.  The caller must trim matching lines from the beginning and end
147 147
      * of the portions it is going to specify.
148 148
      */
149
-    function _diag ($xoff, $xlim, $yoff, $ylim, $nchunks)
149
+    function _diag($xoff, $xlim, $yoff, $ylim, $nchunks)
150 150
     {
151 151
         $flip = false;
152 152
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
         }
170 170
 
171 171
         $this->lcs = 0;
172
-        $this->seq[0]= $yoff - 1;
172
+        $this->seq[0] = $yoff - 1;
173 173
         $this->in_seq = array();
174 174
         $ymids[0] = array();
175 175
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
                 }
183 183
             }
184 184
 
185
-            $x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $chunk) / $nchunks);
185
+            $x1 = $xoff + (int) (($numer + ($xlim - $xoff) * $chunk) / $nchunks);
186 186
             for (; $x < $x1; $x++) {
187 187
                 $line = $flip ? $this->yv[$x] : $this->xv[$x];
188 188
                 if (empty($ymatches[$line])) {
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
         $seps[] = $flip ? array($yoff, $xoff) : array($xoff, $yoff);
219 219
         $ymid = $ymids[$this->lcs];
220 220
         for ($n = 0; $n < $nchunks - 1; $n++) {
221
-            $x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $n) / $nchunks);
221
+            $x1 = $xoff + (int) (($numer + ($xlim - $xoff) * $n) / $nchunks);
222 222
             $y1 = $ymid[$n] + 1;
223 223
             $seps[] = $flip ? array($y1, $x1) : array($x1, $y1);
224 224
         }
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 
239 239
         $beg = 1;
240 240
         while ($beg < $end) {
241
-            $mid = (int)(($beg + $end) / 2);
241
+            $mid = (int) (($beg + $end) / 2);
242 242
             if ($ypos > $this->seq[$mid]) {
243 243
                 $beg = $mid + 1;
244 244
             } else {
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
      * Note that XLIM, YLIM are exclusive bounds.  All line numbers are
267 267
      * origin-0 and discarded lines are not counted.
268 268
      */
269
-    function _compareseq ($xoff, $xlim, $yoff, $ylim)
269
+    function _compareseq($xoff, $xlim, $yoff, $ylim)
270 270
     {
271 271
         /* Slide down the bottom initial diagonal. */
272 272
         while ($xoff < $xlim && $yoff < $ylim
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
             reset($seps);
308 308
             $pt1 = $seps[0];
309 309
             while ($pt2 = next($seps)) {
310
-                $this->_compareseq ($pt1[0], $pt2[0], $pt1[1], $pt2[1]);
310
+                $this->_compareseq($pt1[0], $pt2[0], $pt1[1], $pt2[1]);
311 311
                 $pt1 = $pt2;
312 312
             }
313 313
         }
Please login to merge, or discard this patch.
Indentation   +375 added lines, -375 removed lines patch added patch discarded remove patch
@@ -28,314 +28,314 @@  discard block
 block discarded – undo
28 28
  */
29 29
 class Text_Diff_Engine_native {
30 30
 
31
-    function diff($from_lines, $to_lines)
32
-    {
33
-        array_walk($from_lines, array('Text_Diff', 'trimNewlines'));
34
-        array_walk($to_lines, array('Text_Diff', 'trimNewlines'));
35
-
36
-        $n_from = count($from_lines);
37
-        $n_to = count($to_lines);
38
-
39
-        $this->xchanged = $this->ychanged = array();
40
-        $this->xv = $this->yv = array();
41
-        $this->xind = $this->yind = array();
42
-        unset($this->seq);
43
-        unset($this->in_seq);
44
-        unset($this->lcs);
45
-
46
-        // Skip leading common lines.
47
-        for ($skip = 0; $skip < $n_from && $skip < $n_to; $skip++) {
48
-            if ($from_lines[$skip] !== $to_lines[$skip]) {
49
-                break;
50
-            }
51
-            $this->xchanged[$skip] = $this->ychanged[$skip] = false;
52
-        }
53
-
54
-        // Skip trailing common lines.
55
-        $xi = $n_from; $yi = $n_to;
56
-        for ($endskip = 0; --$xi > $skip && --$yi > $skip; $endskip++) {
57
-            if ($from_lines[$xi] !== $to_lines[$yi]) {
58
-                break;
59
-            }
60
-            $this->xchanged[$xi] = $this->ychanged[$yi] = false;
61
-        }
62
-
63
-        // Ignore lines which do not exist in both files.
64
-        for ($xi = $skip; $xi < $n_from - $endskip; $xi++) {
65
-            $xhash[$from_lines[$xi]] = 1;
66
-        }
67
-        for ($yi = $skip; $yi < $n_to - $endskip; $yi++) {
68
-            $line = $to_lines[$yi];
69
-            if (($this->ychanged[$yi] = empty($xhash[$line]))) {
70
-                continue;
71
-            }
72
-            $yhash[$line] = 1;
73
-            $this->yv[] = $line;
74
-            $this->yind[] = $yi;
75
-        }
76
-        for ($xi = $skip; $xi < $n_from - $endskip; $xi++) {
77
-            $line = $from_lines[$xi];
78
-            if (($this->xchanged[$xi] = empty($yhash[$line]))) {
79
-                continue;
80
-            }
81
-            $this->xv[] = $line;
82
-            $this->xind[] = $xi;
83
-        }
84
-
85
-        // Find the LCS.
86
-        $this->_compareseq(0, count($this->xv), 0, count($this->yv));
87
-
88
-        // Merge edits when possible.
89
-        $this->_shiftBoundaries($from_lines, $this->xchanged, $this->ychanged);
90
-        $this->_shiftBoundaries($to_lines, $this->ychanged, $this->xchanged);
91
-
92
-        // Compute the edit operations.
93
-        $edits = array();
94
-        $xi = $yi = 0;
95
-        while ($xi < $n_from || $yi < $n_to) {
96
-            assert($yi < $n_to || $this->xchanged[$xi]);
97
-            assert($xi < $n_from || $this->ychanged[$yi]);
98
-
99
-            // Skip matching "snake".
100
-            $copy = array();
101
-            while ($xi < $n_from && $yi < $n_to
102
-                   && !$this->xchanged[$xi] && !$this->ychanged[$yi]) {
103
-                $copy[] = $from_lines[$xi++];
104
-                ++$yi;
105
-            }
106
-            if ($copy) {
107
-                $edits[] = new Text_Diff_Op_copy($copy);
108
-            }
109
-
110
-            // Find deletes & adds.
111
-            $delete = array();
112
-            while ($xi < $n_from && $this->xchanged[$xi]) {
113
-                $delete[] = $from_lines[$xi++];
114
-            }
115
-
116
-            $add = array();
117
-            while ($yi < $n_to && $this->ychanged[$yi]) {
118
-                $add[] = $to_lines[$yi++];
119
-            }
120
-
121
-            if ($delete && $add) {
122
-                $edits[] = new Text_Diff_Op_change($delete, $add);
123
-            } elseif ($delete) {
124
-                $edits[] = new Text_Diff_Op_delete($delete);
125
-            } elseif ($add) {
126
-                $edits[] = new Text_Diff_Op_add($add);
127
-            }
128
-        }
129
-
130
-        return $edits;
131
-    }
132
-
133
-    /**
134
-     * Divides the Largest Common Subsequence (LCS) of the sequences (XOFF,
135
-     * XLIM) and (YOFF, YLIM) into NCHUNKS approximately equally sized
136
-     * segments.
137
-     *
138
-     * Returns (LCS, PTS).  LCS is the length of the LCS. PTS is an array of
139
-     * NCHUNKS+1 (X, Y) indexes giving the diving points between sub
140
-     * sequences.  The first sub-sequence is contained in (X0, X1), (Y0, Y1),
141
-     * the second in (X1, X2), (Y1, Y2) and so on.  Note that (X0, Y0) ==
142
-     * (XOFF, YOFF) and (X[NCHUNKS], Y[NCHUNKS]) == (XLIM, YLIM).
143
-     *
144
-     * This function assumes that the first lines of the specified portions of
145
-     * the two files do not match, and likewise that the last lines do not
146
-     * match.  The caller must trim matching lines from the beginning and end
147
-     * of the portions it is going to specify.
148
-     */
149
-    function _diag ($xoff, $xlim, $yoff, $ylim, $nchunks)
150
-    {
151
-        $flip = false;
152
-
153
-        if ($xlim - $xoff > $ylim - $yoff) {
154
-            /* Things seems faster (I'm not sure I understand why) when the
31
+	function diff($from_lines, $to_lines)
32
+	{
33
+		array_walk($from_lines, array('Text_Diff', 'trimNewlines'));
34
+		array_walk($to_lines, array('Text_Diff', 'trimNewlines'));
35
+
36
+		$n_from = count($from_lines);
37
+		$n_to = count($to_lines);
38
+
39
+		$this->xchanged = $this->ychanged = array();
40
+		$this->xv = $this->yv = array();
41
+		$this->xind = $this->yind = array();
42
+		unset($this->seq);
43
+		unset($this->in_seq);
44
+		unset($this->lcs);
45
+
46
+		// Skip leading common lines.
47
+		for ($skip = 0; $skip < $n_from && $skip < $n_to; $skip++) {
48
+			if ($from_lines[$skip] !== $to_lines[$skip]) {
49
+				break;
50
+			}
51
+			$this->xchanged[$skip] = $this->ychanged[$skip] = false;
52
+		}
53
+
54
+		// Skip trailing common lines.
55
+		$xi = $n_from; $yi = $n_to;
56
+		for ($endskip = 0; --$xi > $skip && --$yi > $skip; $endskip++) {
57
+			if ($from_lines[$xi] !== $to_lines[$yi]) {
58
+				break;
59
+			}
60
+			$this->xchanged[$xi] = $this->ychanged[$yi] = false;
61
+		}
62
+
63
+		// Ignore lines which do not exist in both files.
64
+		for ($xi = $skip; $xi < $n_from - $endskip; $xi++) {
65
+			$xhash[$from_lines[$xi]] = 1;
66
+		}
67
+		for ($yi = $skip; $yi < $n_to - $endskip; $yi++) {
68
+			$line = $to_lines[$yi];
69
+			if (($this->ychanged[$yi] = empty($xhash[$line]))) {
70
+				continue;
71
+			}
72
+			$yhash[$line] = 1;
73
+			$this->yv[] = $line;
74
+			$this->yind[] = $yi;
75
+		}
76
+		for ($xi = $skip; $xi < $n_from - $endskip; $xi++) {
77
+			$line = $from_lines[$xi];
78
+			if (($this->xchanged[$xi] = empty($yhash[$line]))) {
79
+				continue;
80
+			}
81
+			$this->xv[] = $line;
82
+			$this->xind[] = $xi;
83
+		}
84
+
85
+		// Find the LCS.
86
+		$this->_compareseq(0, count($this->xv), 0, count($this->yv));
87
+
88
+		// Merge edits when possible.
89
+		$this->_shiftBoundaries($from_lines, $this->xchanged, $this->ychanged);
90
+		$this->_shiftBoundaries($to_lines, $this->ychanged, $this->xchanged);
91
+
92
+		// Compute the edit operations.
93
+		$edits = array();
94
+		$xi = $yi = 0;
95
+		while ($xi < $n_from || $yi < $n_to) {
96
+			assert($yi < $n_to || $this->xchanged[$xi]);
97
+			assert($xi < $n_from || $this->ychanged[$yi]);
98
+
99
+			// Skip matching "snake".
100
+			$copy = array();
101
+			while ($xi < $n_from && $yi < $n_to
102
+				   && !$this->xchanged[$xi] && !$this->ychanged[$yi]) {
103
+				$copy[] = $from_lines[$xi++];
104
+				++$yi;
105
+			}
106
+			if ($copy) {
107
+				$edits[] = new Text_Diff_Op_copy($copy);
108
+			}
109
+
110
+			// Find deletes & adds.
111
+			$delete = array();
112
+			while ($xi < $n_from && $this->xchanged[$xi]) {
113
+				$delete[] = $from_lines[$xi++];
114
+			}
115
+
116
+			$add = array();
117
+			while ($yi < $n_to && $this->ychanged[$yi]) {
118
+				$add[] = $to_lines[$yi++];
119
+			}
120
+
121
+			if ($delete && $add) {
122
+				$edits[] = new Text_Diff_Op_change($delete, $add);
123
+			} elseif ($delete) {
124
+				$edits[] = new Text_Diff_Op_delete($delete);
125
+			} elseif ($add) {
126
+				$edits[] = new Text_Diff_Op_add($add);
127
+			}
128
+		}
129
+
130
+		return $edits;
131
+	}
132
+
133
+	/**
134
+	 * Divides the Largest Common Subsequence (LCS) of the sequences (XOFF,
135
+	 * XLIM) and (YOFF, YLIM) into NCHUNKS approximately equally sized
136
+	 * segments.
137
+	 *
138
+	 * Returns (LCS, PTS).  LCS is the length of the LCS. PTS is an array of
139
+	 * NCHUNKS+1 (X, Y) indexes giving the diving points between sub
140
+	 * sequences.  The first sub-sequence is contained in (X0, X1), (Y0, Y1),
141
+	 * the second in (X1, X2), (Y1, Y2) and so on.  Note that (X0, Y0) ==
142
+	 * (XOFF, YOFF) and (X[NCHUNKS], Y[NCHUNKS]) == (XLIM, YLIM).
143
+	 *
144
+	 * This function assumes that the first lines of the specified portions of
145
+	 * the two files do not match, and likewise that the last lines do not
146
+	 * match.  The caller must trim matching lines from the beginning and end
147
+	 * of the portions it is going to specify.
148
+	 */
149
+	function _diag ($xoff, $xlim, $yoff, $ylim, $nchunks)
150
+	{
151
+		$flip = false;
152
+
153
+		if ($xlim - $xoff > $ylim - $yoff) {
154
+			/* Things seems faster (I'm not sure I understand why) when the
155 155
              * shortest sequence is in X. */
156
-            $flip = true;
157
-            list ($xoff, $xlim, $yoff, $ylim)
158
-                = array($yoff, $ylim, $xoff, $xlim);
159
-        }
160
-
161
-        if ($flip) {
162
-            for ($i = $ylim - 1; $i >= $yoff; $i--) {
163
-                $ymatches[$this->xv[$i]][] = $i;
164
-            }
165
-        } else {
166
-            for ($i = $ylim - 1; $i >= $yoff; $i--) {
167
-                $ymatches[$this->yv[$i]][] = $i;
168
-            }
169
-        }
170
-
171
-        $this->lcs = 0;
172
-        $this->seq[0]= $yoff - 1;
173
-        $this->in_seq = array();
174
-        $ymids[0] = array();
175
-
176
-        $numer = $xlim - $xoff + $nchunks - 1;
177
-        $x = $xoff;
178
-        for ($chunk = 0; $chunk < $nchunks; $chunk++) {
179
-            if ($chunk > 0) {
180
-                for ($i = 0; $i <= $this->lcs; $i++) {
181
-                    $ymids[$i][$chunk - 1] = $this->seq[$i];
182
-                }
183
-            }
184
-
185
-            $x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $chunk) / $nchunks);
186
-            for (; $x < $x1; $x++) {
187
-                $line = $flip ? $this->yv[$x] : $this->xv[$x];
188
-                if (empty($ymatches[$line])) {
189
-                    continue;
190
-                }
191
-                $matches = $ymatches[$line];
192
-                reset($matches);
193
-                while (list(, $y) = each($matches)) {
194
-                    if (empty($this->in_seq[$y])) {
195
-                        $k = $this->_lcsPos($y);
196
-                        assert($k > 0);
197
-                        $ymids[$k] = $ymids[$k - 1];
198
-                        break;
199
-                    }
200
-                }
201
-                while (list(, $y) = each($matches)) {
202
-                    if ($y > $this->seq[$k - 1]) {
203
-                        assert($y <= $this->seq[$k]);
204
-                        /* Optimization: this is a common case: next match is
156
+			$flip = true;
157
+			list ($xoff, $xlim, $yoff, $ylim)
158
+				= array($yoff, $ylim, $xoff, $xlim);
159
+		}
160
+
161
+		if ($flip) {
162
+			for ($i = $ylim - 1; $i >= $yoff; $i--) {
163
+				$ymatches[$this->xv[$i]][] = $i;
164
+			}
165
+		} else {
166
+			for ($i = $ylim - 1; $i >= $yoff; $i--) {
167
+				$ymatches[$this->yv[$i]][] = $i;
168
+			}
169
+		}
170
+
171
+		$this->lcs = 0;
172
+		$this->seq[0]= $yoff - 1;
173
+		$this->in_seq = array();
174
+		$ymids[0] = array();
175
+
176
+		$numer = $xlim - $xoff + $nchunks - 1;
177
+		$x = $xoff;
178
+		for ($chunk = 0; $chunk < $nchunks; $chunk++) {
179
+			if ($chunk > 0) {
180
+				for ($i = 0; $i <= $this->lcs; $i++) {
181
+					$ymids[$i][$chunk - 1] = $this->seq[$i];
182
+				}
183
+			}
184
+
185
+			$x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $chunk) / $nchunks);
186
+			for (; $x < $x1; $x++) {
187
+				$line = $flip ? $this->yv[$x] : $this->xv[$x];
188
+				if (empty($ymatches[$line])) {
189
+					continue;
190
+				}
191
+				$matches = $ymatches[$line];
192
+				reset($matches);
193
+				while (list(, $y) = each($matches)) {
194
+					if (empty($this->in_seq[$y])) {
195
+						$k = $this->_lcsPos($y);
196
+						assert($k > 0);
197
+						$ymids[$k] = $ymids[$k - 1];
198
+						break;
199
+					}
200
+				}
201
+				while (list(, $y) = each($matches)) {
202
+					if ($y > $this->seq[$k - 1]) {
203
+						assert($y <= $this->seq[$k]);
204
+						/* Optimization: this is a common case: next match is
205 205
                          * just replacing previous match. */
206
-                        $this->in_seq[$this->seq[$k]] = false;
207
-                        $this->seq[$k] = $y;
208
-                        $this->in_seq[$y] = 1;
209
-                    } elseif (empty($this->in_seq[$y])) {
210
-                        $k = $this->_lcsPos($y);
211
-                        assert($k > 0);
212
-                        $ymids[$k] = $ymids[$k - 1];
213
-                    }
214
-                }
215
-            }
216
-        }
217
-
218
-        $seps[] = $flip ? array($yoff, $xoff) : array($xoff, $yoff);
219
-        $ymid = $ymids[$this->lcs];
220
-        for ($n = 0; $n < $nchunks - 1; $n++) {
221
-            $x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $n) / $nchunks);
222
-            $y1 = $ymid[$n] + 1;
223
-            $seps[] = $flip ? array($y1, $x1) : array($x1, $y1);
224
-        }
225
-        $seps[] = $flip ? array($ylim, $xlim) : array($xlim, $ylim);
226
-
227
-        return array($this->lcs, $seps);
228
-    }
229
-
230
-    function _lcsPos($ypos)
231
-    {
232
-        $end = $this->lcs;
233
-        if ($end == 0 || $ypos > $this->seq[$end]) {
234
-            $this->seq[++$this->lcs] = $ypos;
235
-            $this->in_seq[$ypos] = 1;
236
-            return $this->lcs;
237
-        }
238
-
239
-        $beg = 1;
240
-        while ($beg < $end) {
241
-            $mid = (int)(($beg + $end) / 2);
242
-            if ($ypos > $this->seq[$mid]) {
243
-                $beg = $mid + 1;
244
-            } else {
245
-                $end = $mid;
246
-            }
247
-        }
248
-
249
-        assert($ypos != $this->seq[$end]);
250
-
251
-        $this->in_seq[$this->seq[$end]] = false;
252
-        $this->seq[$end] = $ypos;
253
-        $this->in_seq[$ypos] = 1;
254
-        return $end;
255
-    }
256
-
257
-    /**
258
-     * Finds LCS of two sequences.
259
-     *
260
-     * The results are recorded in the vectors $this->{x,y}changed[], by
261
-     * storing a 1 in the element for each line that is an insertion or
262
-     * deletion (ie. is not in the LCS).
263
-     *
264
-     * The subsequence of file 0 is (XOFF, XLIM) and likewise for file 1.
265
-     *
266
-     * Note that XLIM, YLIM are exclusive bounds.  All line numbers are
267
-     * origin-0 and discarded lines are not counted.
268
-     */
269
-    function _compareseq ($xoff, $xlim, $yoff, $ylim)
270
-    {
271
-        /* Slide down the bottom initial diagonal. */
272
-        while ($xoff < $xlim && $yoff < $ylim
273
-               && $this->xv[$xoff] == $this->yv[$yoff]) {
274
-            ++$xoff;
275
-            ++$yoff;
276
-        }
277
-
278
-        /* Slide up the top initial diagonal. */
279
-        while ($xlim > $xoff && $ylim > $yoff
280
-               && $this->xv[$xlim - 1] == $this->yv[$ylim - 1]) {
281
-            --$xlim;
282
-            --$ylim;
283
-        }
284
-
285
-        if ($xoff == $xlim || $yoff == $ylim) {
286
-            $lcs = 0;
287
-        } else {
288
-            /* This is ad hoc but seems to work well.  $nchunks =
206
+						$this->in_seq[$this->seq[$k]] = false;
207
+						$this->seq[$k] = $y;
208
+						$this->in_seq[$y] = 1;
209
+					} elseif (empty($this->in_seq[$y])) {
210
+						$k = $this->_lcsPos($y);
211
+						assert($k > 0);
212
+						$ymids[$k] = $ymids[$k - 1];
213
+					}
214
+				}
215
+			}
216
+		}
217
+
218
+		$seps[] = $flip ? array($yoff, $xoff) : array($xoff, $yoff);
219
+		$ymid = $ymids[$this->lcs];
220
+		for ($n = 0; $n < $nchunks - 1; $n++) {
221
+			$x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $n) / $nchunks);
222
+			$y1 = $ymid[$n] + 1;
223
+			$seps[] = $flip ? array($y1, $x1) : array($x1, $y1);
224
+		}
225
+		$seps[] = $flip ? array($ylim, $xlim) : array($xlim, $ylim);
226
+
227
+		return array($this->lcs, $seps);
228
+	}
229
+
230
+	function _lcsPos($ypos)
231
+	{
232
+		$end = $this->lcs;
233
+		if ($end == 0 || $ypos > $this->seq[$end]) {
234
+			$this->seq[++$this->lcs] = $ypos;
235
+			$this->in_seq[$ypos] = 1;
236
+			return $this->lcs;
237
+		}
238
+
239
+		$beg = 1;
240
+		while ($beg < $end) {
241
+			$mid = (int)(($beg + $end) / 2);
242
+			if ($ypos > $this->seq[$mid]) {
243
+				$beg = $mid + 1;
244
+			} else {
245
+				$end = $mid;
246
+			}
247
+		}
248
+
249
+		assert($ypos != $this->seq[$end]);
250
+
251
+		$this->in_seq[$this->seq[$end]] = false;
252
+		$this->seq[$end] = $ypos;
253
+		$this->in_seq[$ypos] = 1;
254
+		return $end;
255
+	}
256
+
257
+	/**
258
+	 * Finds LCS of two sequences.
259
+	 *
260
+	 * The results are recorded in the vectors $this->{x,y}changed[], by
261
+	 * storing a 1 in the element for each line that is an insertion or
262
+	 * deletion (ie. is not in the LCS).
263
+	 *
264
+	 * The subsequence of file 0 is (XOFF, XLIM) and likewise for file 1.
265
+	 *
266
+	 * Note that XLIM, YLIM are exclusive bounds.  All line numbers are
267
+	 * origin-0 and discarded lines are not counted.
268
+	 */
269
+	function _compareseq ($xoff, $xlim, $yoff, $ylim)
270
+	{
271
+		/* Slide down the bottom initial diagonal. */
272
+		while ($xoff < $xlim && $yoff < $ylim
273
+			   && $this->xv[$xoff] == $this->yv[$yoff]) {
274
+			++$xoff;
275
+			++$yoff;
276
+		}
277
+
278
+		/* Slide up the top initial diagonal. */
279
+		while ($xlim > $xoff && $ylim > $yoff
280
+			   && $this->xv[$xlim - 1] == $this->yv[$ylim - 1]) {
281
+			--$xlim;
282
+			--$ylim;
283
+		}
284
+
285
+		if ($xoff == $xlim || $yoff == $ylim) {
286
+			$lcs = 0;
287
+		} else {
288
+			/* This is ad hoc but seems to work well.  $nchunks =
289 289
              * sqrt(min($xlim - $xoff, $ylim - $yoff) / 2.5); $nchunks =
290 290
              * max(2,min(8,(int)$nchunks)); */
291
-            $nchunks = min(7, $xlim - $xoff, $ylim - $yoff) + 1;
292
-            list($lcs, $seps)
293
-                = $this->_diag($xoff, $xlim, $yoff, $ylim, $nchunks);
294
-        }
291
+			$nchunks = min(7, $xlim - $xoff, $ylim - $yoff) + 1;
292
+			list($lcs, $seps)
293
+				= $this->_diag($xoff, $xlim, $yoff, $ylim, $nchunks);
294
+		}
295 295
 
296
-        if ($lcs == 0) {
297
-            /* X and Y sequences have no common subsequence: mark all
296
+		if ($lcs == 0) {
297
+			/* X and Y sequences have no common subsequence: mark all
298 298
              * changed. */
299
-            while ($yoff < $ylim) {
300
-                $this->ychanged[$this->yind[$yoff++]] = 1;
301
-            }
302
-            while ($xoff < $xlim) {
303
-                $this->xchanged[$this->xind[$xoff++]] = 1;
304
-            }
305
-        } else {
306
-            /* Use the partitions to split this problem into subproblems. */
307
-            reset($seps);
308
-            $pt1 = $seps[0];
309
-            while ($pt2 = next($seps)) {
310
-                $this->_compareseq ($pt1[0], $pt2[0], $pt1[1], $pt2[1]);
311
-                $pt1 = $pt2;
312
-            }
313
-        }
314
-    }
315
-
316
-    /**
317
-     * Adjusts inserts/deletes of identical lines to join changes as much as
318
-     * possible.
319
-     *
320
-     * We do something when a run of changed lines include a line at one end
321
-     * and has an excluded, identical line at the other.  We are free to
322
-     * choose which identical line is included.  `compareseq' usually chooses
323
-     * the one at the beginning, but usually it is cleaner to consider the
324
-     * following identical line to be the "change".
325
-     *
326
-     * This is extracted verbatim from analyze.c (GNU diffutils-2.7).
327
-     */
328
-    function _shiftBoundaries($lines, &$changed, $other_changed)
329
-    {
330
-        $i = 0;
331
-        $j = 0;
332
-
333
-        assert('count($lines) == count($changed)');
334
-        $len = count($lines);
335
-        $other_len = count($other_changed);
336
-
337
-        while (1) {
338
-            /* Scan forward to find the beginning of another run of
299
+			while ($yoff < $ylim) {
300
+				$this->ychanged[$this->yind[$yoff++]] = 1;
301
+			}
302
+			while ($xoff < $xlim) {
303
+				$this->xchanged[$this->xind[$xoff++]] = 1;
304
+			}
305
+		} else {
306
+			/* Use the partitions to split this problem into subproblems. */
307
+			reset($seps);
308
+			$pt1 = $seps[0];
309
+			while ($pt2 = next($seps)) {
310
+				$this->_compareseq ($pt1[0], $pt2[0], $pt1[1], $pt2[1]);
311
+				$pt1 = $pt2;
312
+			}
313
+		}
314
+	}
315
+
316
+	/**
317
+	 * Adjusts inserts/deletes of identical lines to join changes as much as
318
+	 * possible.
319
+	 *
320
+	 * We do something when a run of changed lines include a line at one end
321
+	 * and has an excluded, identical line at the other.  We are free to
322
+	 * choose which identical line is included.  `compareseq' usually chooses
323
+	 * the one at the beginning, but usually it is cleaner to consider the
324
+	 * following identical line to be the "change".
325
+	 *
326
+	 * This is extracted verbatim from analyze.c (GNU diffutils-2.7).
327
+	 */
328
+	function _shiftBoundaries($lines, &$changed, $other_changed)
329
+	{
330
+		$i = 0;
331
+		$j = 0;
332
+
333
+		assert('count($lines) == count($changed)');
334
+		$len = count($lines);
335
+		$other_len = count($other_changed);
336
+
337
+		while (1) {
338
+			/* Scan forward to find the beginning of another run of
339 339
              * changes. Also keep track of the corresponding point in the
340 340
              * other file.
341 341
              *
@@ -346,91 +346,91 @@  discard block
 block discarded – undo
346 346
              *
347 347
              * Furthermore, $j is always kept so that $j == $other_len or
348 348
              * $other_changed[$j] == false. */
349
-            while ($j < $other_len && $other_changed[$j]) {
350
-                $j++;
351
-            }
352
-
353
-            while ($i < $len && ! $changed[$i]) {
354
-                assert('$j < $other_len && ! $other_changed[$j]');
355
-                $i++; $j++;
356
-                while ($j < $other_len && $other_changed[$j]) {
357
-                    $j++;
358
-                }
359
-            }
360
-
361
-            if ($i == $len) {
362
-                break;
363
-            }
364
-
365
-            $start = $i;
366
-
367
-            /* Find the end of this run of changes. */
368
-            while (++$i < $len && $changed[$i]) {
369
-                continue;
370
-            }
371
-
372
-            do {
373
-                /* Record the length of this run of changes, so that we can
349
+			while ($j < $other_len && $other_changed[$j]) {
350
+				$j++;
351
+			}
352
+
353
+			while ($i < $len && ! $changed[$i]) {
354
+				assert('$j < $other_len && ! $other_changed[$j]');
355
+				$i++; $j++;
356
+				while ($j < $other_len && $other_changed[$j]) {
357
+					$j++;
358
+				}
359
+			}
360
+
361
+			if ($i == $len) {
362
+				break;
363
+			}
364
+
365
+			$start = $i;
366
+
367
+			/* Find the end of this run of changes. */
368
+			while (++$i < $len && $changed[$i]) {
369
+				continue;
370
+			}
371
+
372
+			do {
373
+				/* Record the length of this run of changes, so that we can
374 374
                  * later determine whether the run has grown. */
375
-                $runlength = $i - $start;
375
+				$runlength = $i - $start;
376 376
 
377
-                /* Move the changed region back, so long as the previous
377
+				/* Move the changed region back, so long as the previous
378 378
                  * unchanged line matches the last changed one.  This merges
379 379
                  * with previous changed regions. */
380
-                while ($start > 0 && $lines[$start - 1] == $lines[$i - 1]) {
381
-                    $changed[--$start] = 1;
382
-                    $changed[--$i] = false;
383
-                    while ($start > 0 && $changed[$start - 1]) {
384
-                        $start--;
385
-                    }
386
-                    assert('$j > 0');
387
-                    while ($other_changed[--$j]) {
388
-                        continue;
389
-                    }
390
-                    assert('$j >= 0 && !$other_changed[$j]');
391
-                }
392
-
393
-                /* Set CORRESPONDING to the end of the changed run, at the
380
+				while ($start > 0 && $lines[$start - 1] == $lines[$i - 1]) {
381
+					$changed[--$start] = 1;
382
+					$changed[--$i] = false;
383
+					while ($start > 0 && $changed[$start - 1]) {
384
+						$start--;
385
+					}
386
+					assert('$j > 0');
387
+					while ($other_changed[--$j]) {
388
+						continue;
389
+					}
390
+					assert('$j >= 0 && !$other_changed[$j]');
391
+				}
392
+
393
+				/* Set CORRESPONDING to the end of the changed run, at the
394 394
                  * last point where it corresponds to a changed run in the
395 395
                  * other file. CORRESPONDING == LEN means no such point has
396 396
                  * been found. */
397
-                $corresponding = $j < $other_len ? $i : $len;
397
+				$corresponding = $j < $other_len ? $i : $len;
398 398
 
399
-                /* Move the changed region forward, so long as the first
399
+				/* Move the changed region forward, so long as the first
400 400
                  * changed line matches the following unchanged one.  This
401 401
                  * merges with following changed regions.  Do this second, so
402 402
                  * that if there are no merges, the changed region is moved
403 403
                  * forward as far as possible. */
404
-                while ($i < $len && $lines[$start] == $lines[$i]) {
405
-                    $changed[$start++] = false;
406
-                    $changed[$i++] = 1;
407
-                    while ($i < $len && $changed[$i]) {
408
-                        $i++;
409
-                    }
410
-
411
-                    assert('$j < $other_len && ! $other_changed[$j]');
412
-                    $j++;
413
-                    if ($j < $other_len && $other_changed[$j]) {
414
-                        $corresponding = $i;
415
-                        while ($j < $other_len && $other_changed[$j]) {
416
-                            $j++;
417
-                        }
418
-                    }
419
-                }
420
-            } while ($runlength != $i - $start);
421
-
422
-            /* If possible, move the fully-merged run of changes back to a
404
+				while ($i < $len && $lines[$start] == $lines[$i]) {
405
+					$changed[$start++] = false;
406
+					$changed[$i++] = 1;
407
+					while ($i < $len && $changed[$i]) {
408
+						$i++;
409
+					}
410
+
411
+					assert('$j < $other_len && ! $other_changed[$j]');
412
+					$j++;
413
+					if ($j < $other_len && $other_changed[$j]) {
414
+						$corresponding = $i;
415
+						while ($j < $other_len && $other_changed[$j]) {
416
+							$j++;
417
+						}
418
+					}
419
+				}
420
+			} while ($runlength != $i - $start);
421
+
422
+			/* If possible, move the fully-merged run of changes back to a
423 423
              * corresponding run in the other file. */
424
-            while ($corresponding < $i) {
425
-                $changed[--$start] = 1;
426
-                $changed[--$i] = 0;
427
-                assert('$j > 0');
428
-                while ($other_changed[--$j]) {
429
-                    continue;
430
-                }
431
-                assert('$j >= 0 && !$other_changed[$j]');
432
-            }
433
-        }
434
-    }
424
+			while ($corresponding < $i) {
425
+				$changed[--$start] = 1;
426
+				$changed[--$i] = 0;
427
+				assert('$j > 0');
428
+				while ($other_changed[--$j]) {
429
+					continue;
430
+				}
431
+				assert('$j >= 0 && !$other_changed[$j]');
432
+			}
433
+		}
434
+	}
435 435
 
436 436
 }
Please login to merge, or discard this patch.
src/wp-includes/Text/Diff/Renderer.php 4 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -148,6 +148,12 @@  discard block
 block discarded – undo
148 148
         return $output . $this->_endDiff();
149 149
     }
150 150
 
151
+    /**
152
+     * @param integer $xbeg
153
+     * @param integer $xlen
154
+     * @param integer $ybeg
155
+     * @param integer $ylen
156
+     */
151 157
     function _block($xbeg, $xlen, $ybeg, $ylen, &$edits)
152 158
     {
153 159
         $output = $this->_startBlock($this->_blockHeader($xbeg, $xlen, $ybeg, $ylen));
@@ -204,6 +210,9 @@  discard block
 block discarded – undo
204 210
         return $xbeg . ($xlen ? ($ylen ? 'c' : 'd') : 'a') . $ybeg;
205 211
     }
206 212
 
213
+    /**
214
+     * @param string $header
215
+     */
207 216
     function _startBlock($header)
208 217
     {
209 218
         return $header . "\n";
Please login to merge, or discard this patch.
Indentation   +211 added lines, -211 removed lines patch added patch discarded remove patch
@@ -14,34 +14,34 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class Text_Diff_Renderer {
16 16
 
17
-    /**
18
-     * Number of leading context "lines" to preserve.
19
-     *
20
-     * This should be left at zero for this class, but subclasses may want to
21
-     * set this to other values.
22
-     */
23
-    var $_leading_context_lines = 0;
24
-
25
-    /**
26
-     * Number of trailing context "lines" to preserve.
27
-     *
28
-     * This should be left at zero for this class, but subclasses may want to
29
-     * set this to other values.
30
-     */
31
-    var $_trailing_context_lines = 0;
32
-
33
-    /**
34
-     * Constructor.
35
-     */
36
-    function __construct( $params = array() )
37
-    {
38
-        foreach ($params as $param => $value) {
39
-            $v = '_' . $param;
40
-            if (isset($this->$v)) {
41
-                $this->$v = $value;
42
-            }
43
-        }
44
-    }
17
+	/**
18
+	 * Number of leading context "lines" to preserve.
19
+	 *
20
+	 * This should be left at zero for this class, but subclasses may want to
21
+	 * set this to other values.
22
+	 */
23
+	var $_leading_context_lines = 0;
24
+
25
+	/**
26
+	 * Number of trailing context "lines" to preserve.
27
+	 *
28
+	 * This should be left at zero for this class, but subclasses may want to
29
+	 * set this to other values.
30
+	 */
31
+	var $_trailing_context_lines = 0;
32
+
33
+	/**
34
+	 * Constructor.
35
+	 */
36
+	function __construct( $params = array() )
37
+	{
38
+		foreach ($params as $param => $value) {
39
+			$v = '_' . $param;
40
+			if (isset($this->$v)) {
41
+				$this->$v = $value;
42
+			}
43
+		}
44
+	}
45 45
 
46 46
 	/**
47 47
 	 * PHP4 constructor.
@@ -50,193 +50,193 @@  discard block
 block discarded – undo
50 50
 		self::__construct( $params );
51 51
 	}
52 52
 
53
-    /**
54
-     * Get any renderer parameters.
55
-     *
56
-     * @return array  All parameters of this renderer object.
57
-     */
58
-    function getParams()
59
-    {
60
-        $params = array();
61
-        foreach (get_object_vars($this) as $k => $v) {
62
-            if ($k[0] == '_') {
63
-                $params[substr($k, 1)] = $v;
64
-            }
65
-        }
66
-
67
-        return $params;
68
-    }
69
-
70
-    /**
71
-     * Renders a diff.
72
-     *
73
-     * @param Text_Diff $diff  A Text_Diff object.
74
-     *
75
-     * @return string  The formatted output.
76
-     */
77
-    function render($diff)
78
-    {
79
-        $xi = $yi = 1;
80
-        $block = false;
81
-        $context = array();
82
-
83
-        $nlead = $this->_leading_context_lines;
84
-        $ntrail = $this->_trailing_context_lines;
85
-
86
-        $output = $this->_startDiff();
87
-
88
-        $diffs = $diff->getDiff();
89
-        foreach ($diffs as $i => $edit) {
90
-            /* If these are unchanged (copied) lines, and we want to keep
53
+	/**
54
+	 * Get any renderer parameters.
55
+	 *
56
+	 * @return array  All parameters of this renderer object.
57
+	 */
58
+	function getParams()
59
+	{
60
+		$params = array();
61
+		foreach (get_object_vars($this) as $k => $v) {
62
+			if ($k[0] == '_') {
63
+				$params[substr($k, 1)] = $v;
64
+			}
65
+		}
66
+
67
+		return $params;
68
+	}
69
+
70
+	/**
71
+	 * Renders a diff.
72
+	 *
73
+	 * @param Text_Diff $diff  A Text_Diff object.
74
+	 *
75
+	 * @return string  The formatted output.
76
+	 */
77
+	function render($diff)
78
+	{
79
+		$xi = $yi = 1;
80
+		$block = false;
81
+		$context = array();
82
+
83
+		$nlead = $this->_leading_context_lines;
84
+		$ntrail = $this->_trailing_context_lines;
85
+
86
+		$output = $this->_startDiff();
87
+
88
+		$diffs = $diff->getDiff();
89
+		foreach ($diffs as $i => $edit) {
90
+			/* If these are unchanged (copied) lines, and we want to keep
91 91
              * leading or trailing context lines, extract them from the copy
92 92
              * block. */
93
-            if (is_a($edit, 'Text_Diff_Op_copy')) {
94
-                /* Do we have any diff blocks yet? */
95
-                if (is_array($block)) {
96
-                    /* How many lines to keep as context from the copy
93
+			if (is_a($edit, 'Text_Diff_Op_copy')) {
94
+				/* Do we have any diff blocks yet? */
95
+				if (is_array($block)) {
96
+					/* How many lines to keep as context from the copy
97 97
                      * block. */
98
-                    $keep = $i == count($diffs) - 1 ? $ntrail : $nlead + $ntrail;
99
-                    if (count($edit->orig) <= $keep) {
100
-                        /* We have less lines in the block than we want for
98
+					$keep = $i == count($diffs) - 1 ? $ntrail : $nlead + $ntrail;
99
+					if (count($edit->orig) <= $keep) {
100
+						/* We have less lines in the block than we want for
101 101
                          * context => keep the whole block. */
102
-                        $block[] = $edit;
103
-                    } else {
104
-                        if ($ntrail) {
105
-                            /* Create a new block with as many lines as we need
102
+						$block[] = $edit;
103
+					} else {
104
+						if ($ntrail) {
105
+							/* Create a new block with as many lines as we need
106 106
                              * for the trailing context. */
107
-                            $context = array_slice($edit->orig, 0, $ntrail);
108
-                            $block[] = new Text_Diff_Op_copy($context);
109
-                        }
110
-                        /* @todo */
111
-                        $output .= $this->_block($x0, $ntrail + $xi - $x0,
112
-                                                 $y0, $ntrail + $yi - $y0,
113
-                                                 $block);
114
-                        $block = false;
115
-                    }
116
-                }
117
-                /* Keep the copy block as the context for the next block. */
118
-                $context = $edit->orig;
119
-            } else {
120
-                /* Don't we have any diff blocks yet? */
121
-                if (!is_array($block)) {
122
-                    /* Extract context lines from the preceding copy block. */
123
-                    $context = array_slice($context, count($context) - $nlead);
124
-                    $x0 = $xi - count($context);
125
-                    $y0 = $yi - count($context);
126
-                    $block = array();
127
-                    if ($context) {
128
-                        $block[] = new Text_Diff_Op_copy($context);
129
-                    }
130
-                }
131
-                $block[] = $edit;
132
-            }
133
-
134
-            if ($edit->orig) {
135
-                $xi += count($edit->orig);
136
-            }
137
-            if ($edit->final) {
138
-                $yi += count($edit->final);
139
-            }
140
-        }
141
-
142
-        if (is_array($block)) {
143
-            $output .= $this->_block($x0, $xi - $x0,
144
-                                     $y0, $yi - $y0,
145
-                                     $block);
146
-        }
147
-
148
-        return $output . $this->_endDiff();
149
-    }
150
-
151
-    function _block($xbeg, $xlen, $ybeg, $ylen, &$edits)
152
-    {
153
-        $output = $this->_startBlock($this->_blockHeader($xbeg, $xlen, $ybeg, $ylen));
154
-
155
-        foreach ($edits as $edit) {
156
-            switch (strtolower(get_class($edit))) {
157
-            case 'text_diff_op_copy':
158
-                $output .= $this->_context($edit->orig);
159
-                break;
160
-
161
-            case 'text_diff_op_add':
162
-                $output .= $this->_added($edit->final);
163
-                break;
164
-
165
-            case 'text_diff_op_delete':
166
-                $output .= $this->_deleted($edit->orig);
167
-                break;
168
-
169
-            case 'text_diff_op_change':
170
-                $output .= $this->_changed($edit->orig, $edit->final);
171
-                break;
172
-            }
173
-        }
174
-
175
-        return $output . $this->_endBlock();
176
-    }
177
-
178
-    function _startDiff()
179
-    {
180
-        return '';
181
-    }
182
-
183
-    function _endDiff()
184
-    {
185
-        return '';
186
-    }
187
-
188
-    function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
189
-    {
190
-        if ($xlen > 1) {
191
-            $xbeg .= ',' . ($xbeg + $xlen - 1);
192
-        }
193
-        if ($ylen > 1) {
194
-            $ybeg .= ',' . ($ybeg + $ylen - 1);
195
-        }
196
-
197
-        // this matches the GNU Diff behaviour
198
-        if ($xlen && !$ylen) {
199
-            $ybeg--;
200
-        } elseif (!$xlen) {
201
-            $xbeg--;
202
-        }
203
-
204
-        return $xbeg . ($xlen ? ($ylen ? 'c' : 'd') : 'a') . $ybeg;
205
-    }
206
-
207
-    function _startBlock($header)
208
-    {
209
-        return $header . "\n";
210
-    }
211
-
212
-    function _endBlock()
213
-    {
214
-        return '';
215
-    }
216
-
217
-    function _lines($lines, $prefix = ' ')
218
-    {
219
-        return $prefix . implode("\n$prefix", $lines) . "\n";
220
-    }
221
-
222
-    function _context($lines)
223
-    {
224
-        return $this->_lines($lines, '  ');
225
-    }
226
-
227
-    function _added($lines)
228
-    {
229
-        return $this->_lines($lines, '> ');
230
-    }
231
-
232
-    function _deleted($lines)
233
-    {
234
-        return $this->_lines($lines, '< ');
235
-    }
236
-
237
-    function _changed($orig, $final)
238
-    {
239
-        return $this->_deleted($orig) . "---\n" . $this->_added($final);
240
-    }
107
+							$context = array_slice($edit->orig, 0, $ntrail);
108
+							$block[] = new Text_Diff_Op_copy($context);
109
+						}
110
+						/* @todo */
111
+						$output .= $this->_block($x0, $ntrail + $xi - $x0,
112
+												 $y0, $ntrail + $yi - $y0,
113
+												 $block);
114
+						$block = false;
115
+					}
116
+				}
117
+				/* Keep the copy block as the context for the next block. */
118
+				$context = $edit->orig;
119
+			} else {
120
+				/* Don't we have any diff blocks yet? */
121
+				if (!is_array($block)) {
122
+					/* Extract context lines from the preceding copy block. */
123
+					$context = array_slice($context, count($context) - $nlead);
124
+					$x0 = $xi - count($context);
125
+					$y0 = $yi - count($context);
126
+					$block = array();
127
+					if ($context) {
128
+						$block[] = new Text_Diff_Op_copy($context);
129
+					}
130
+				}
131
+				$block[] = $edit;
132
+			}
133
+
134
+			if ($edit->orig) {
135
+				$xi += count($edit->orig);
136
+			}
137
+			if ($edit->final) {
138
+				$yi += count($edit->final);
139
+			}
140
+		}
141
+
142
+		if (is_array($block)) {
143
+			$output .= $this->_block($x0, $xi - $x0,
144
+									 $y0, $yi - $y0,
145
+									 $block);
146
+		}
147
+
148
+		return $output . $this->_endDiff();
149
+	}
150
+
151
+	function _block($xbeg, $xlen, $ybeg, $ylen, &$edits)
152
+	{
153
+		$output = $this->_startBlock($this->_blockHeader($xbeg, $xlen, $ybeg, $ylen));
154
+
155
+		foreach ($edits as $edit) {
156
+			switch (strtolower(get_class($edit))) {
157
+			case 'text_diff_op_copy':
158
+				$output .= $this->_context($edit->orig);
159
+				break;
160
+
161
+			case 'text_diff_op_add':
162
+				$output .= $this->_added($edit->final);
163
+				break;
164
+
165
+			case 'text_diff_op_delete':
166
+				$output .= $this->_deleted($edit->orig);
167
+				break;
168
+
169
+			case 'text_diff_op_change':
170
+				$output .= $this->_changed($edit->orig, $edit->final);
171
+				break;
172
+			}
173
+		}
174
+
175
+		return $output . $this->_endBlock();
176
+	}
177
+
178
+	function _startDiff()
179
+	{
180
+		return '';
181
+	}
182
+
183
+	function _endDiff()
184
+	{
185
+		return '';
186
+	}
187
+
188
+	function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
189
+	{
190
+		if ($xlen > 1) {
191
+			$xbeg .= ',' . ($xbeg + $xlen - 1);
192
+		}
193
+		if ($ylen > 1) {
194
+			$ybeg .= ',' . ($ybeg + $ylen - 1);
195
+		}
196
+
197
+		// this matches the GNU Diff behaviour
198
+		if ($xlen && !$ylen) {
199
+			$ybeg--;
200
+		} elseif (!$xlen) {
201
+			$xbeg--;
202
+		}
203
+
204
+		return $xbeg . ($xlen ? ($ylen ? 'c' : 'd') : 'a') . $ybeg;
205
+	}
206
+
207
+	function _startBlock($header)
208
+	{
209
+		return $header . "\n";
210
+	}
211
+
212
+	function _endBlock()
213
+	{
214
+		return '';
215
+	}
216
+
217
+	function _lines($lines, $prefix = ' ')
218
+	{
219
+		return $prefix . implode("\n$prefix", $lines) . "\n";
220
+	}
221
+
222
+	function _context($lines)
223
+	{
224
+		return $this->_lines($lines, '  ');
225
+	}
226
+
227
+	function _added($lines)
228
+	{
229
+		return $this->_lines($lines, '> ');
230
+	}
231
+
232
+	function _deleted($lines)
233
+	{
234
+		return $this->_lines($lines, '< ');
235
+	}
236
+
237
+	function _changed($orig, $final)
238
+	{
239
+		return $this->_deleted($orig) . "---\n" . $this->_added($final);
240
+	}
241 241
 
242 242
 }
Please login to merge, or discard this patch.
Switch Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -154,21 +154,21 @@
 block discarded – undo
154 154
 
155 155
         foreach ($edits as $edit) {
156 156
             switch (strtolower(get_class($edit))) {
157
-            case 'text_diff_op_copy':
158
-                $output .= $this->_context($edit->orig);
159
-                break;
157
+            	case 'text_diff_op_copy':
158
+                	$output .= $this->_context($edit->orig);
159
+                	break;
160 160
 
161
-            case 'text_diff_op_add':
162
-                $output .= $this->_added($edit->final);
163
-                break;
161
+            	case 'text_diff_op_add':
162
+                	$output .= $this->_added($edit->final);
163
+                	break;
164 164
 
165
-            case 'text_diff_op_delete':
166
-                $output .= $this->_deleted($edit->orig);
167
-                break;
165
+            	case 'text_diff_op_delete':
166
+                	$output .= $this->_deleted($edit->orig);
167
+                	break;
168 168
 
169
-            case 'text_diff_op_change':
170
-                $output .= $this->_changed($edit->orig, $edit->final);
171
-                break;
169
+            	case 'text_diff_op_change':
170
+                	$output .= $this->_changed($edit->orig, $edit->final);
171
+                	break;
172 172
             }
173 173
         }
174 174
 
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -33,10 +33,10 @@  discard block
 block discarded – undo
33 33
     /**
34 34
      * Constructor.
35 35
      */
36
-    function __construct( $params = array() )
36
+    function __construct($params = array())
37 37
     {
38 38
         foreach ($params as $param => $value) {
39
-            $v = '_' . $param;
39
+            $v = '_'.$param;
40 40
             if (isset($this->$v)) {
41 41
                 $this->$v = $value;
42 42
             }
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 	/**
47 47
 	 * PHP4 constructor.
48 48
 	 */
49
-	public function Text_Diff_Renderer( $params = array() ) {
50
-		self::__construct( $params );
49
+	public function Text_Diff_Renderer($params = array()) {
50
+		self::__construct($params);
51 51
 	}
52 52
 
53 53
     /**
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
                 $context = $edit->orig;
119 119
             } else {
120 120
                 /* Don't we have any diff blocks yet? */
121
-                if (!is_array($block)) {
121
+                if ( ! is_array($block)) {
122 122
                     /* Extract context lines from the preceding copy block. */
123 123
                     $context = array_slice($context, count($context) - $nlead);
124 124
                     $x0 = $xi - count($context);
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
                                      $block);
146 146
         }
147 147
 
148
-        return $output . $this->_endDiff();
148
+        return $output.$this->_endDiff();
149 149
     }
150 150
 
151 151
     function _block($xbeg, $xlen, $ybeg, $ylen, &$edits)
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
             }
173 173
         }
174 174
 
175
-        return $output . $this->_endBlock();
175
+        return $output.$this->_endBlock();
176 176
     }
177 177
 
178 178
     function _startDiff()
@@ -188,25 +188,25 @@  discard block
 block discarded – undo
188 188
     function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
189 189
     {
190 190
         if ($xlen > 1) {
191
-            $xbeg .= ',' . ($xbeg + $xlen - 1);
191
+            $xbeg .= ','.($xbeg + $xlen - 1);
192 192
         }
193 193
         if ($ylen > 1) {
194
-            $ybeg .= ',' . ($ybeg + $ylen - 1);
194
+            $ybeg .= ','.($ybeg + $ylen - 1);
195 195
         }
196 196
 
197 197
         // this matches the GNU Diff behaviour
198
-        if ($xlen && !$ylen) {
198
+        if ($xlen && ! $ylen) {
199 199
             $ybeg--;
200
-        } elseif (!$xlen) {
200
+        } elseif ( ! $xlen) {
201 201
             $xbeg--;
202 202
         }
203 203
 
204
-        return $xbeg . ($xlen ? ($ylen ? 'c' : 'd') : 'a') . $ybeg;
204
+        return $xbeg.($xlen ? ($ylen ? 'c' : 'd') : 'a').$ybeg;
205 205
     }
206 206
 
207 207
     function _startBlock($header)
208 208
     {
209
-        return $header . "\n";
209
+        return $header."\n";
210 210
     }
211 211
 
212 212
     function _endBlock()
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 
217 217
     function _lines($lines, $prefix = ' ')
218 218
     {
219
-        return $prefix . implode("\n$prefix", $lines) . "\n";
219
+        return $prefix.implode("\n$prefix", $lines)."\n";
220 220
     }
221 221
 
222 222
     function _context($lines)
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 
237 237
     function _changed($orig, $final)
238 238
     {
239
-        return $this->_deleted($orig) . "---\n" . $this->_added($final);
239
+        return $this->_deleted($orig)."---\n".$this->_added($final);
240 240
     }
241 241
 
242 242
 }
Please login to merge, or discard this patch.
src/wp-includes/Text/Diff/Renderer/inline.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -100,6 +100,9 @@  discard block
 block discarded – undo
100 100
         return $header;
101 101
     }
102 102
 
103
+    /**
104
+     * @param string[] $lines
105
+     */
103 106
     function _lines($lines, $prefix = ' ', $encode = true)
104 107
     {
105 108
         if ($encode) {
@@ -178,6 +181,9 @@  discard block
 block discarded – undo
178 181
         return str_replace($nl, "\n", $renderer->render($diff)) . "\n";
179 182
     }
180 183
 
184
+    /**
185
+     * @param string $string
186
+     */
181 187
     function _splitOnWords($string, $newlineEscape = "\n")
182 188
     {
183 189
         // Ignore \0; otherwise the while loop will never finish.
Please login to merge, or discard this patch.
Indentation   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -26,181 +26,181 @@
 block discarded – undo
26 26
  */
27 27
 class Text_Diff_Renderer_inline extends Text_Diff_Renderer {
28 28
 
29
-    /**
30
-     * Number of leading context "lines" to preserve.
31
-     *
32
-     * @var integer
33
-     */
34
-    var $_leading_context_lines = 10000;
35
-
36
-    /**
37
-     * Number of trailing context "lines" to preserve.
38
-     *
39
-     * @var integer
40
-     */
41
-    var $_trailing_context_lines = 10000;
42
-
43
-    /**
44
-     * Prefix for inserted text.
45
-     *
46
-     * @var string
47
-     */
48
-    var $_ins_prefix = '<ins>';
49
-
50
-    /**
51
-     * Suffix for inserted text.
52
-     *
53
-     * @var string
54
-     */
55
-    var $_ins_suffix = '</ins>';
56
-
57
-    /**
58
-     * Prefix for deleted text.
59
-     *
60
-     * @var string
61
-     */
62
-    var $_del_prefix = '<del>';
63
-
64
-    /**
65
-     * Suffix for deleted text.
66
-     *
67
-     * @var string
68
-     */
69
-    var $_del_suffix = '</del>';
70
-
71
-    /**
72
-     * Header for each change block.
73
-     *
74
-     * @var string
75
-     */
76
-    var $_block_header = '';
77
-
78
-    /**
79
-     * Whether to split down to character-level.
80
-     *
81
-     * @var boolean
82
-     */
83
-    var $_split_characters = false;
84
-
85
-    /**
86
-     * What are we currently splitting on? Used to recurse to show word-level
87
-     * or character-level changes.
88
-     *
89
-     * @var string
90
-     */
91
-    var $_split_level = 'lines';
92
-
93
-    function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
94
-    {
95
-        return $this->_block_header;
96
-    }
97
-
98
-    function _startBlock($header)
99
-    {
100
-        return $header;
101
-    }
102
-
103
-    function _lines($lines, $prefix = ' ', $encode = true)
104
-    {
105
-        if ($encode) {
106
-            array_walk($lines, array(&$this, '_encode'));
107
-        }
108
-
109
-        if ($this->_split_level == 'lines') {
110
-            return implode("\n", $lines) . "\n";
111
-        } else {
112
-            return implode('', $lines);
113
-        }
114
-    }
115
-
116
-    function _added($lines)
117
-    {
118
-        array_walk($lines, array(&$this, '_encode'));
119
-        $lines[0] = $this->_ins_prefix . $lines[0];
120
-        $lines[count($lines) - 1] .= $this->_ins_suffix;
121
-        return $this->_lines($lines, ' ', false);
122
-    }
123
-
124
-    function _deleted($lines, $words = false)
125
-    {
126
-        array_walk($lines, array(&$this, '_encode'));
127
-        $lines[0] = $this->_del_prefix . $lines[0];
128
-        $lines[count($lines) - 1] .= $this->_del_suffix;
129
-        return $this->_lines($lines, ' ', false);
130
-    }
131
-
132
-    function _changed($orig, $final)
133
-    {
134
-        /* If we've already split on characters, just display. */
135
-        if ($this->_split_level == 'characters') {
136
-            return $this->_deleted($orig)
137
-                . $this->_added($final);
138
-        }
139
-
140
-        /* If we've already split on words, just display. */
141
-        if ($this->_split_level == 'words') {
142
-            $prefix = '';
143
-            while ($orig[0] !== false && $final[0] !== false &&
144
-                   substr($orig[0], 0, 1) == ' ' &&
145
-                   substr($final[0], 0, 1) == ' ') {
146
-                $prefix .= substr($orig[0], 0, 1);
147
-                $orig[0] = substr($orig[0], 1);
148
-                $final[0] = substr($final[0], 1);
149
-            }
150
-            return $prefix . $this->_deleted($orig) . $this->_added($final);
151
-        }
152
-
153
-        $text1 = implode("\n", $orig);
154
-        $text2 = implode("\n", $final);
155
-
156
-        /* Non-printing newline marker. */
157
-        $nl = "\0";
158
-
159
-        if ($this->_split_characters) {
160
-            $diff = new Text_Diff('native',
161
-                                  array(preg_split('//', $text1),
162
-                                        preg_split('//', $text2)));
163
-        } else {
164
-            /* We want to split on word boundaries, but we need to preserve
29
+	/**
30
+	 * Number of leading context "lines" to preserve.
31
+	 *
32
+	 * @var integer
33
+	 */
34
+	var $_leading_context_lines = 10000;
35
+
36
+	/**
37
+	 * Number of trailing context "lines" to preserve.
38
+	 *
39
+	 * @var integer
40
+	 */
41
+	var $_trailing_context_lines = 10000;
42
+
43
+	/**
44
+	 * Prefix for inserted text.
45
+	 *
46
+	 * @var string
47
+	 */
48
+	var $_ins_prefix = '<ins>';
49
+
50
+	/**
51
+	 * Suffix for inserted text.
52
+	 *
53
+	 * @var string
54
+	 */
55
+	var $_ins_suffix = '</ins>';
56
+
57
+	/**
58
+	 * Prefix for deleted text.
59
+	 *
60
+	 * @var string
61
+	 */
62
+	var $_del_prefix = '<del>';
63
+
64
+	/**
65
+	 * Suffix for deleted text.
66
+	 *
67
+	 * @var string
68
+	 */
69
+	var $_del_suffix = '</del>';
70
+
71
+	/**
72
+	 * Header for each change block.
73
+	 *
74
+	 * @var string
75
+	 */
76
+	var $_block_header = '';
77
+
78
+	/**
79
+	 * Whether to split down to character-level.
80
+	 *
81
+	 * @var boolean
82
+	 */
83
+	var $_split_characters = false;
84
+
85
+	/**
86
+	 * What are we currently splitting on? Used to recurse to show word-level
87
+	 * or character-level changes.
88
+	 *
89
+	 * @var string
90
+	 */
91
+	var $_split_level = 'lines';
92
+
93
+	function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
94
+	{
95
+		return $this->_block_header;
96
+	}
97
+
98
+	function _startBlock($header)
99
+	{
100
+		return $header;
101
+	}
102
+
103
+	function _lines($lines, $prefix = ' ', $encode = true)
104
+	{
105
+		if ($encode) {
106
+			array_walk($lines, array(&$this, '_encode'));
107
+		}
108
+
109
+		if ($this->_split_level == 'lines') {
110
+			return implode("\n", $lines) . "\n";
111
+		} else {
112
+			return implode('', $lines);
113
+		}
114
+	}
115
+
116
+	function _added($lines)
117
+	{
118
+		array_walk($lines, array(&$this, '_encode'));
119
+		$lines[0] = $this->_ins_prefix . $lines[0];
120
+		$lines[count($lines) - 1] .= $this->_ins_suffix;
121
+		return $this->_lines($lines, ' ', false);
122
+	}
123
+
124
+	function _deleted($lines, $words = false)
125
+	{
126
+		array_walk($lines, array(&$this, '_encode'));
127
+		$lines[0] = $this->_del_prefix . $lines[0];
128
+		$lines[count($lines) - 1] .= $this->_del_suffix;
129
+		return $this->_lines($lines, ' ', false);
130
+	}
131
+
132
+	function _changed($orig, $final)
133
+	{
134
+		/* If we've already split on characters, just display. */
135
+		if ($this->_split_level == 'characters') {
136
+			return $this->_deleted($orig)
137
+				. $this->_added($final);
138
+		}
139
+
140
+		/* If we've already split on words, just display. */
141
+		if ($this->_split_level == 'words') {
142
+			$prefix = '';
143
+			while ($orig[0] !== false && $final[0] !== false &&
144
+				   substr($orig[0], 0, 1) == ' ' &&
145
+				   substr($final[0], 0, 1) == ' ') {
146
+				$prefix .= substr($orig[0], 0, 1);
147
+				$orig[0] = substr($orig[0], 1);
148
+				$final[0] = substr($final[0], 1);
149
+			}
150
+			return $prefix . $this->_deleted($orig) . $this->_added($final);
151
+		}
152
+
153
+		$text1 = implode("\n", $orig);
154
+		$text2 = implode("\n", $final);
155
+
156
+		/* Non-printing newline marker. */
157
+		$nl = "\0";
158
+
159
+		if ($this->_split_characters) {
160
+			$diff = new Text_Diff('native',
161
+								  array(preg_split('//', $text1),
162
+										preg_split('//', $text2)));
163
+		} else {
164
+			/* We want to split on word boundaries, but we need to preserve
165 165
              * whitespace as well. Therefore we split on words, but include
166 166
              * all blocks of whitespace in the wordlist. */
167
-            $diff = new Text_Diff('native',
168
-                                  array($this->_splitOnWords($text1, $nl),
169
-                                        $this->_splitOnWords($text2, $nl)));
170
-        }
171
-
172
-        /* Get the diff in inline format. */
173
-        $renderer = new Text_Diff_Renderer_inline
174
-            (array_merge($this->getParams(),
175
-                         array('split_level' => $this->_split_characters ? 'characters' : 'words')));
176
-
177
-        /* Run the diff and get the output. */
178
-        return str_replace($nl, "\n", $renderer->render($diff)) . "\n";
179
-    }
180
-
181
-    function _splitOnWords($string, $newlineEscape = "\n")
182
-    {
183
-        // Ignore \0; otherwise the while loop will never finish.
184
-        $string = str_replace("\0", '', $string);
185
-
186
-        $words = array();
187
-        $length = strlen($string);
188
-        $pos = 0;
189
-
190
-        while ($pos < $length) {
191
-            // Eat a word with any preceding whitespace.
192
-            $spaces = strspn(substr($string, $pos), " \n");
193
-            $nextpos = strcspn(substr($string, $pos + $spaces), " \n");
194
-            $words[] = str_replace("\n", $newlineEscape, substr($string, $pos, $spaces + $nextpos));
195
-            $pos += $spaces + $nextpos;
196
-        }
197
-
198
-        return $words;
199
-    }
200
-
201
-    function _encode(&$string)
202
-    {
203
-        $string = htmlspecialchars($string);
204
-    }
167
+			$diff = new Text_Diff('native',
168
+								  array($this->_splitOnWords($text1, $nl),
169
+										$this->_splitOnWords($text2, $nl)));
170
+		}
171
+
172
+		/* Get the diff in inline format. */
173
+		$renderer = new Text_Diff_Renderer_inline
174
+			(array_merge($this->getParams(),
175
+						 array('split_level' => $this->_split_characters ? 'characters' : 'words')));
176
+
177
+		/* Run the diff and get the output. */
178
+		return str_replace($nl, "\n", $renderer->render($diff)) . "\n";
179
+	}
180
+
181
+	function _splitOnWords($string, $newlineEscape = "\n")
182
+	{
183
+		// Ignore \0; otherwise the while loop will never finish.
184
+		$string = str_replace("\0", '', $string);
185
+
186
+		$words = array();
187
+		$length = strlen($string);
188
+		$pos = 0;
189
+
190
+		while ($pos < $length) {
191
+			// Eat a word with any preceding whitespace.
192
+			$spaces = strspn(substr($string, $pos), " \n");
193
+			$nextpos = strcspn(substr($string, $pos + $spaces), " \n");
194
+			$words[] = str_replace("\n", $newlineEscape, substr($string, $pos, $spaces + $nextpos));
195
+			$pos += $spaces + $nextpos;
196
+		}
197
+
198
+		return $words;
199
+	}
200
+
201
+	function _encode(&$string)
202
+	{
203
+		$string = htmlspecialchars($string);
204
+	}
205 205
 
206 206
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 /** Text_Diff_Renderer */
15 15
 
16 16
 // WP #7391
17
-require_once dirname(dirname(__FILE__)) . '/Renderer.php';
17
+require_once dirname(dirname(__FILE__)).'/Renderer.php';
18 18
 
19 19
 /**
20 20
  * "Inline" diff renderer.
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
         }
108 108
 
109 109
         if ($this->_split_level == 'lines') {
110
-            return implode("\n", $lines) . "\n";
110
+            return implode("\n", $lines)."\n";
111 111
         } else {
112 112
             return implode('', $lines);
113 113
         }
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
     function _added($lines)
117 117
     {
118 118
         array_walk($lines, array(&$this, '_encode'));
119
-        $lines[0] = $this->_ins_prefix . $lines[0];
119
+        $lines[0] = $this->_ins_prefix.$lines[0];
120 120
         $lines[count($lines) - 1] .= $this->_ins_suffix;
121 121
         return $this->_lines($lines, ' ', false);
122 122
     }
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
     function _deleted($lines, $words = false)
125 125
     {
126 126
         array_walk($lines, array(&$this, '_encode'));
127
-        $lines[0] = $this->_del_prefix . $lines[0];
127
+        $lines[0] = $this->_del_prefix.$lines[0];
128 128
         $lines[count($lines) - 1] .= $this->_del_suffix;
129 129
         return $this->_lines($lines, ' ', false);
130 130
     }
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
                 $orig[0] = substr($orig[0], 1);
148 148
                 $final[0] = substr($final[0], 1);
149 149
             }
150
-            return $prefix . $this->_deleted($orig) . $this->_added($final);
150
+            return $prefix.$this->_deleted($orig).$this->_added($final);
151 151
         }
152 152
 
153 153
         $text1 = implode("\n", $orig);
@@ -170,12 +170,11 @@  discard block
 block discarded – undo
170 170
         }
171 171
 
172 172
         /* Get the diff in inline format. */
173
-        $renderer = new Text_Diff_Renderer_inline
174
-            (array_merge($this->getParams(),
173
+        $renderer = new Text_Diff_Renderer_inline(array_merge($this->getParams(),
175 174
                          array('split_level' => $this->_split_characters ? 'characters' : 'words')));
176 175
 
177 176
         /* Run the diff and get the output. */
178
-        return str_replace($nl, "\n", $renderer->render($diff)) . "\n";
177
+        return str_replace($nl, "\n", $renderer->render($diff))."\n";
179 178
     }
180 179
 
181 180
     function _splitOnWords($string, $newlineEscape = "\n")
Please login to merge, or discard this patch.
src/wp-includes/theme.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1309,7 +1309,7 @@
 block discarded – undo
1309 1309
  *
1310 1310
  * @global array $editor_styles
1311 1311
  *
1312
- * @param array|string $stylesheet Optional. Stylesheet name or array thereof, relative to theme root.
1312
+ * @param string[] $stylesheet Optional. Stylesheet name or array thereof, relative to theme root.
1313 1313
  * 	                               Defaults to 'editor-style.css'
1314 1314
  */
1315 1315
 function add_editor_style( $stylesheet = 'editor-style.css' ) {
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
- * Theme, template, and stylesheet functions.
4
- *
5
- * @package WordPress
6
- * @subpackage Theme
7
- */
3
+	 * Theme, template, and stylesheet functions.
4
+	 *
5
+	 * @package WordPress
6
+	 * @subpackage Theme
7
+	 */
8 8
 
9 9
 /**
10 10
  * Returns an array of WP_Theme objects based on the arguments.
Please login to merge, or discard this patch.
Spacing   +486 added lines, -486 removed lines patch added patch discarded remove patch
@@ -27,55 +27,55 @@  discard block
 block discarded – undo
27 27
  *                      synonymous for the current blog.
28 28
  * @return array Array of WP_Theme objects.
29 29
  */
30
-function wp_get_themes( $args = array() ) {
30
+function wp_get_themes($args = array()) {
31 31
 	global $wp_theme_directories;
32 32
 
33
-	$defaults = array( 'errors' => false, 'allowed' => null, 'blog_id' => 0 );
34
-	$args = wp_parse_args( $args, $defaults );
33
+	$defaults = array('errors' => false, 'allowed' => null, 'blog_id' => 0);
34
+	$args = wp_parse_args($args, $defaults);
35 35
 
36 36
 	$theme_directories = search_theme_directories();
37 37
 
38
-	if ( count( $wp_theme_directories ) > 1 ) {
38
+	if (count($wp_theme_directories) > 1) {
39 39
 		// Make sure the current theme wins out, in case search_theme_directories() picks the wrong
40 40
 		// one in the case of a conflict. (Normally, last registered theme root wins.)
41 41
 		$current_theme = get_stylesheet();
42
-		if ( isset( $theme_directories[ $current_theme ] ) ) {
43
-			$root_of_current_theme = get_raw_theme_root( $current_theme );
44
-			if ( ! in_array( $root_of_current_theme, $wp_theme_directories ) )
45
-				$root_of_current_theme = WP_CONTENT_DIR . $root_of_current_theme;
46
-			$theme_directories[ $current_theme ]['theme_root'] = $root_of_current_theme;
42
+		if (isset($theme_directories[$current_theme])) {
43
+			$root_of_current_theme = get_raw_theme_root($current_theme);
44
+			if ( ! in_array($root_of_current_theme, $wp_theme_directories))
45
+				$root_of_current_theme = WP_CONTENT_DIR.$root_of_current_theme;
46
+			$theme_directories[$current_theme]['theme_root'] = $root_of_current_theme;
47 47
 		}
48 48
 	}
49 49
 
50
-	if ( empty( $theme_directories ) )
50
+	if (empty($theme_directories))
51 51
 		return array();
52 52
 
53
-	if ( is_multisite() && null !== $args['allowed'] ) {
53
+	if (is_multisite() && null !== $args['allowed']) {
54 54
 		$allowed = $args['allowed'];
55
-		if ( 'network' === $allowed )
56
-			$theme_directories = array_intersect_key( $theme_directories, WP_Theme::get_allowed_on_network() );
57
-		elseif ( 'site' === $allowed )
58
-			$theme_directories = array_intersect_key( $theme_directories, WP_Theme::get_allowed_on_site( $args['blog_id'] ) );
59
-		elseif ( $allowed )
60
-			$theme_directories = array_intersect_key( $theme_directories, WP_Theme::get_allowed( $args['blog_id'] ) );
55
+		if ('network' === $allowed)
56
+			$theme_directories = array_intersect_key($theme_directories, WP_Theme::get_allowed_on_network());
57
+		elseif ('site' === $allowed)
58
+			$theme_directories = array_intersect_key($theme_directories, WP_Theme::get_allowed_on_site($args['blog_id']));
59
+		elseif ($allowed)
60
+			$theme_directories = array_intersect_key($theme_directories, WP_Theme::get_allowed($args['blog_id']));
61 61
 		else
62
-			$theme_directories = array_diff_key( $theme_directories, WP_Theme::get_allowed( $args['blog_id'] ) );
62
+			$theme_directories = array_diff_key($theme_directories, WP_Theme::get_allowed($args['blog_id']));
63 63
 	}
64 64
 
65 65
 	$themes = array();
66 66
 	static $_themes = array();
67 67
 
68
-	foreach ( $theme_directories as $theme => $theme_root ) {
69
-		if ( isset( $_themes[ $theme_root['theme_root'] . '/' . $theme ] ) )
70
-			$themes[ $theme ] = $_themes[ $theme_root['theme_root'] . '/' . $theme ];
68
+	foreach ($theme_directories as $theme => $theme_root) {
69
+		if (isset($_themes[$theme_root['theme_root'].'/'.$theme]))
70
+			$themes[$theme] = $_themes[$theme_root['theme_root'].'/'.$theme];
71 71
 		else
72
-			$themes[ $theme ] = $_themes[ $theme_root['theme_root'] . '/' . $theme ] = new WP_Theme( $theme, $theme_root['theme_root'] );
72
+			$themes[$theme] = $_themes[$theme_root['theme_root'].'/'.$theme] = new WP_Theme($theme, $theme_root['theme_root']);
73 73
 	}
74 74
 
75
-	if ( null !== $args['errors'] ) {
76
-		foreach ( $themes as $theme => $wp_theme ) {
77
-			if ( $wp_theme->errors() != $args['errors'] )
78
-				unset( $themes[ $theme ] );
75
+	if (null !== $args['errors']) {
76
+		foreach ($themes as $theme => $wp_theme) {
77
+			if ($wp_theme->errors() != $args['errors'])
78
+				unset($themes[$theme]);
79 79
 		}
80 80
 	}
81 81
 
@@ -94,21 +94,21 @@  discard block
 block discarded – undo
94 94
  * 	                         is used to calculate the theme root for the $stylesheet provided (or current theme).
95 95
  * @return WP_Theme Theme object. Be sure to check the object's exists() method if you need to confirm the theme's existence.
96 96
  */
97
-function wp_get_theme( $stylesheet = null, $theme_root = null ) {
97
+function wp_get_theme($stylesheet = null, $theme_root = null) {
98 98
 	global $wp_theme_directories;
99 99
 
100
-	if ( empty( $stylesheet ) )
100
+	if (empty($stylesheet))
101 101
 		$stylesheet = get_stylesheet();
102 102
 
103
-	if ( empty( $theme_root ) ) {
104
-		$theme_root = get_raw_theme_root( $stylesheet );
105
-		if ( false === $theme_root )
106
-			$theme_root = WP_CONTENT_DIR . '/themes';
107
-		elseif ( ! in_array( $theme_root, (array) $wp_theme_directories ) )
108
-			$theme_root = WP_CONTENT_DIR . $theme_root;
103
+	if (empty($theme_root)) {
104
+		$theme_root = get_raw_theme_root($stylesheet);
105
+		if (false === $theme_root)
106
+			$theme_root = WP_CONTENT_DIR.'/themes';
107
+		elseif ( ! in_array($theme_root, (array) $wp_theme_directories))
108
+			$theme_root = WP_CONTENT_DIR.$theme_root;
109 109
 	}
110 110
 
111
-	return new WP_Theme( $stylesheet, $theme_root );
111
+	return new WP_Theme($stylesheet, $theme_root);
112 112
 }
113 113
 
114 114
 /**
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
  * @since 3.5.0
118 118
  * @param bool $clear_update_cache Whether to clear the Theme updates cache
119 119
  */
120
-function wp_clean_themes_cache( $clear_update_cache = true ) {
121
-	if ( $clear_update_cache )
122
-		delete_site_transient( 'update_themes' );
123
-	search_theme_directories( true );
124
-	foreach ( wp_get_themes( array( 'errors' => null ) ) as $theme )
120
+function wp_clean_themes_cache($clear_update_cache = true) {
121
+	if ($clear_update_cache)
122
+		delete_site_transient('update_themes');
123
+	search_theme_directories(true);
124
+	foreach (wp_get_themes(array('errors' => null)) as $theme)
125 125
 		$theme->cache_delete();
126 126
 }
127 127
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
  * @return bool true if a child theme is in use, false otherwise.
134 134
  **/
135 135
 function is_child_theme() {
136
-	return ( TEMPLATEPATH !== STYLESHEETPATH );
136
+	return (TEMPLATEPATH !== STYLESHEETPATH);
137 137
 }
138 138
 
139 139
 /**
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 *
158 158
 	 * @param string $stylesheet Name of the current stylesheet.
159 159
 	 */
160
-	return apply_filters( 'stylesheet', get_option( 'stylesheet' ) );
160
+	return apply_filters('stylesheet', get_option('stylesheet'));
161 161
 }
162 162
 
163 163
 /**
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
  */
170 170
 function get_stylesheet_directory() {
171 171
 	$stylesheet = get_stylesheet();
172
-	$theme_root = get_theme_root( $stylesheet );
172
+	$theme_root = get_theme_root($stylesheet);
173 173
 	$stylesheet_dir = "$theme_root/$stylesheet";
174 174
 
175 175
 	/**
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 * @param string $stylesheet     Directory name of the current theme.
182 182
 	 * @param string $theme_root     Absolute path to themes directory.
183 183
 	 */
184
-	return apply_filters( 'stylesheet_directory', $stylesheet_dir, $stylesheet, $theme_root );
184
+	return apply_filters('stylesheet_directory', $stylesheet_dir, $stylesheet, $theme_root);
185 185
 }
186 186
 
187 187
 /**
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
  * @return string
193 193
  */
194 194
 function get_stylesheet_directory_uri() {
195
-	$stylesheet = str_replace( '%2F', '/', rawurlencode( get_stylesheet() ) );
196
-	$theme_root_uri = get_theme_root_uri( $stylesheet );
195
+	$stylesheet = str_replace('%2F', '/', rawurlencode(get_stylesheet()));
196
+	$theme_root_uri = get_theme_root_uri($stylesheet);
197 197
 	$stylesheet_dir_uri = "$theme_root_uri/$stylesheet";
198 198
 
199 199
 	/**
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 	 * @param string $stylesheet         Name of the activated theme's directory.
206 206
 	 * @param string $theme_root_uri     Themes root URI.
207 207
 	 */
208
-	return apply_filters( 'stylesheet_directory_uri', $stylesheet_dir_uri, $stylesheet, $theme_root_uri );
208
+	return apply_filters('stylesheet_directory_uri', $stylesheet_dir_uri, $stylesheet, $theme_root_uri);
209 209
 }
210 210
 
211 211
 /**
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
  */
221 221
 function get_stylesheet_uri() {
222 222
 	$stylesheet_dir_uri = get_stylesheet_directory_uri();
223
-	$stylesheet_uri = $stylesheet_dir_uri . '/style.css';
223
+	$stylesheet_uri = $stylesheet_dir_uri.'/style.css';
224 224
 	/**
225 225
 	 * Filter the URI of the current theme stylesheet.
226 226
 	 *
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 	 * @param string $stylesheet_uri     Stylesheet URI for the current theme/child theme.
230 230
 	 * @param string $stylesheet_dir_uri Stylesheet directory URI for the current theme/child theme.
231 231
 	 */
232
-	return apply_filters( 'stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri );
232
+	return apply_filters('stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri);
233 233
 }
234 234
 
235 235
 /**
@@ -257,9 +257,9 @@  discard block
 block discarded – undo
257 257
 	$stylesheet_dir_uri = get_stylesheet_directory_uri();
258 258
 	$dir = get_stylesheet_directory();
259 259
 	$locale = get_locale();
260
-	if ( file_exists("$dir/$locale.css") )
260
+	if (file_exists("$dir/$locale.css"))
261 261
 		$stylesheet_uri = "$stylesheet_dir_uri/$locale.css";
262
-	elseif ( !empty($wp_locale->text_direction) && file_exists("$dir/{$wp_locale->text_direction}.css") )
262
+	elseif ( ! empty($wp_locale->text_direction) && file_exists("$dir/{$wp_locale->text_direction}.css"))
263 263
 		$stylesheet_uri = "$stylesheet_dir_uri/{$wp_locale->text_direction}.css";
264 264
 	else
265 265
 		$stylesheet_uri = '';
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	 * @param string $stylesheet_uri     Localized stylesheet URI.
272 272
 	 * @param string $stylesheet_dir_uri Stylesheet directory URI.
273 273
 	 */
274
-	return apply_filters( 'locale_stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri );
274
+	return apply_filters('locale_stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri);
275 275
 }
276 276
 
277 277
 /**
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	 *
290 290
 	 * @param string $template Current theme's directory name.
291 291
 	 */
292
-	return apply_filters( 'template', get_option( 'template' ) );
292
+	return apply_filters('template', get_option('template'));
293 293
 }
294 294
 
295 295
 /**
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
  */
302 302
 function get_template_directory() {
303 303
 	$template = get_template();
304
-	$theme_root = get_theme_root( $template );
304
+	$theme_root = get_theme_root($template);
305 305
 	$template_dir = "$theme_root/$template";
306 306
 
307 307
 	/**
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 	 * @param string $template     Directory name of the current theme.
314 314
 	 * @param string $theme_root   Absolute path to the themes directory.
315 315
 	 */
316
-	return apply_filters( 'template_directory', $template_dir, $template, $theme_root );
316
+	return apply_filters('template_directory', $template_dir, $template, $theme_root);
317 317
 }
318 318
 
319 319
 /**
@@ -324,8 +324,8 @@  discard block
 block discarded – undo
324 324
  * @return string Template directory URI.
325 325
  */
326 326
 function get_template_directory_uri() {
327
-	$template = str_replace( '%2F', '/', rawurlencode( get_template() ) );
328
-	$theme_root_uri = get_theme_root_uri( $template );
327
+	$template = str_replace('%2F', '/', rawurlencode(get_template()));
328
+	$theme_root_uri = get_theme_root_uri($template);
329 329
 	$template_dir_uri = "$theme_root_uri/$template";
330 330
 
331 331
 	/**
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 	 * @param string $template         Directory name of the current theme.
338 338
 	 * @param string $theme_root_uri   The themes root URI.
339 339
 	 */
340
-	return apply_filters( 'template_directory_uri', $template_dir_uri, $template, $theme_root_uri );
340
+	return apply_filters('template_directory_uri', $template_dir_uri, $template, $theme_root_uri);
341 341
 }
342 342
 
343 343
 /**
@@ -352,13 +352,13 @@  discard block
 block discarded – undo
352 352
 function get_theme_roots() {
353 353
 	global $wp_theme_directories;
354 354
 
355
-	if ( count($wp_theme_directories) <= 1 )
355
+	if (count($wp_theme_directories) <= 1)
356 356
 		return '/themes';
357 357
 
358
-	$theme_roots = get_site_transient( 'theme_roots' );
359
-	if ( false === $theme_roots ) {
360
-		search_theme_directories( true ); // Regenerate the transient.
361
-		$theme_roots = get_site_transient( 'theme_roots' );
358
+	$theme_roots = get_site_transient('theme_roots');
359
+	if (false === $theme_roots) {
360
+		search_theme_directories(true); // Regenerate the transient.
361
+		$theme_roots = get_site_transient('theme_roots');
362 362
 	}
363 363
 	return $theme_roots;
364 364
 }
@@ -373,24 +373,24 @@  discard block
 block discarded – undo
373 373
  * @param string $directory Either the full filesystem path to a theme folder or a folder within WP_CONTENT_DIR
374 374
  * @return bool
375 375
  */
376
-function register_theme_directory( $directory ) {
376
+function register_theme_directory($directory) {
377 377
 	global $wp_theme_directories;
378 378
 
379
-	if ( ! file_exists( $directory ) ) {
379
+	if ( ! file_exists($directory)) {
380 380
 		// Try prepending as the theme directory could be relative to the content directory
381
-		$directory = WP_CONTENT_DIR . '/' . $directory;
381
+		$directory = WP_CONTENT_DIR.'/'.$directory;
382 382
 		// If this directory does not exist, return and do not register
383
-		if ( ! file_exists( $directory ) ) {
383
+		if ( ! file_exists($directory)) {
384 384
 			return false;
385 385
 		}
386 386
 	}
387 387
 
388
-	if ( ! is_array( $wp_theme_directories ) ) {
388
+	if ( ! is_array($wp_theme_directories)) {
389 389
 		$wp_theme_directories = array();
390 390
 	}
391 391
 
392
-	$untrailed = untrailingslashit( $directory );
393
-	if ( ! empty( $untrailed ) && ! in_array( $untrailed, $wp_theme_directories ) ) {
392
+	$untrailed = untrailingslashit($directory);
393
+	if ( ! empty($untrailed) && ! in_array($untrailed, $wp_theme_directories)) {
394 394
 		$wp_theme_directories[] = $untrailed;
395 395
 	}
396 396
 
@@ -408,14 +408,14 @@  discard block
 block discarded – undo
408 408
  * @param bool $force Optional. Whether to force a new directory scan. Defaults to false.
409 409
  * @return array|false Valid themes found
410 410
  */
411
-function search_theme_directories( $force = false ) {
411
+function search_theme_directories($force = false) {
412 412
 	global $wp_theme_directories;
413 413
 	static $found_themes = null;
414 414
 
415
-	if ( empty( $wp_theme_directories ) )
415
+	if (empty($wp_theme_directories))
416 416
 		return false;
417 417
 
418
-	if ( ! $force && isset( $found_themes ) )
418
+	if ( ! $force && isset($found_themes))
419 419
 		return $found_themes;
420 420
 
421 421
 	$found_themes = array();
@@ -426,11 +426,11 @@  discard block
 block discarded – undo
426 426
 	// Set up maybe-relative, maybe-absolute array of theme directories.
427 427
 	// We always want to return absolute, but we need to cache relative
428 428
 	// to use in get_theme_root().
429
-	foreach ( $wp_theme_directories as $theme_root ) {
430
-		if ( 0 === strpos( $theme_root, WP_CONTENT_DIR ) )
431
-			$relative_theme_roots[ str_replace( WP_CONTENT_DIR, '', $theme_root ) ] = $theme_root;
429
+	foreach ($wp_theme_directories as $theme_root) {
430
+		if (0 === strpos($theme_root, WP_CONTENT_DIR))
431
+			$relative_theme_roots[str_replace(WP_CONTENT_DIR, '', $theme_root)] = $theme_root;
432 432
 		else
433
-			$relative_theme_roots[ $theme_root ] = $theme_root;
433
+			$relative_theme_roots[$theme_root] = $theme_root;
434 434
 	}
435 435
 
436 436
 	/**
@@ -441,87 +441,87 @@  discard block
 block discarded – undo
441 441
 	 * @param bool   $cache_expiration Whether to get the cache of the theme directories. Default false.
442 442
 	 * @param string $cache_directory  Directory to be searched for the cache.
443 443
 	 */
444
-	if ( $cache_expiration = apply_filters( 'wp_cache_themes_persistently', false, 'search_theme_directories' ) ) {
445
-		$cached_roots = get_site_transient( 'theme_roots' );
446
-		if ( is_array( $cached_roots ) ) {
447
-			foreach ( $cached_roots as $theme_dir => $theme_root ) {
444
+	if ($cache_expiration = apply_filters('wp_cache_themes_persistently', false, 'search_theme_directories')) {
445
+		$cached_roots = get_site_transient('theme_roots');
446
+		if (is_array($cached_roots)) {
447
+			foreach ($cached_roots as $theme_dir => $theme_root) {
448 448
 				// A cached theme root is no longer around, so skip it.
449
-				if ( ! isset( $relative_theme_roots[ $theme_root ] ) )
449
+				if ( ! isset($relative_theme_roots[$theme_root]))
450 450
 					continue;
451
-				$found_themes[ $theme_dir ] = array(
452
-					'theme_file' => $theme_dir . '/style.css',
453
-					'theme_root' => $relative_theme_roots[ $theme_root ], // Convert relative to absolute.
451
+				$found_themes[$theme_dir] = array(
452
+					'theme_file' => $theme_dir.'/style.css',
453
+					'theme_root' => $relative_theme_roots[$theme_root], // Convert relative to absolute.
454 454
 				);
455 455
 			}
456 456
 			return $found_themes;
457 457
 		}
458
-		if ( ! is_int( $cache_expiration ) )
458
+		if ( ! is_int($cache_expiration))
459 459
 			$cache_expiration = 1800; // half hour
460 460
 	} else {
461 461
 		$cache_expiration = 1800; // half hour
462 462
 	}
463 463
 
464 464
 	/* Loop the registered theme directories and extract all themes */
465
-	foreach ( $wp_theme_directories as $theme_root ) {
465
+	foreach ($wp_theme_directories as $theme_root) {
466 466
 
467 467
 		// Start with directories in the root of the current theme directory.
468
-		$dirs = @ scandir( $theme_root );
469
-		if ( ! $dirs ) {
470
-			trigger_error( "$theme_root is not readable", E_USER_NOTICE );
468
+		$dirs = @ scandir($theme_root);
469
+		if ( ! $dirs) {
470
+			trigger_error("$theme_root is not readable", E_USER_NOTICE);
471 471
 			continue;
472 472
 		}
473
-		foreach ( $dirs as $dir ) {
474
-			if ( ! is_dir( $theme_root . '/' . $dir ) || $dir[0] == '.' || $dir == 'CVS' )
473
+		foreach ($dirs as $dir) {
474
+			if ( ! is_dir($theme_root.'/'.$dir) || $dir[0] == '.' || $dir == 'CVS')
475 475
 				continue;
476
-			if ( file_exists( $theme_root . '/' . $dir . '/style.css' ) ) {
476
+			if (file_exists($theme_root.'/'.$dir.'/style.css')) {
477 477
 				// wp-content/themes/a-single-theme
478 478
 				// wp-content/themes is $theme_root, a-single-theme is $dir
479
-				$found_themes[ $dir ] = array(
480
-					'theme_file' => $dir . '/style.css',
479
+				$found_themes[$dir] = array(
480
+					'theme_file' => $dir.'/style.css',
481 481
 					'theme_root' => $theme_root,
482 482
 				);
483 483
 			} else {
484 484
 				$found_theme = false;
485 485
 				// wp-content/themes/a-folder-of-themes/*
486 486
 				// wp-content/themes is $theme_root, a-folder-of-themes is $dir, then themes are $sub_dirs
487
-				$sub_dirs = @ scandir( $theme_root . '/' . $dir );
488
-				if ( ! $sub_dirs ) {
489
-					trigger_error( "$theme_root/$dir is not readable", E_USER_NOTICE );
487
+				$sub_dirs = @ scandir($theme_root.'/'.$dir);
488
+				if ( ! $sub_dirs) {
489
+					trigger_error("$theme_root/$dir is not readable", E_USER_NOTICE);
490 490
 					continue;
491 491
 				}
492
-				foreach ( $sub_dirs as $sub_dir ) {
493
-					if ( ! is_dir( $theme_root . '/' . $dir . '/' . $sub_dir ) || $dir[0] == '.' || $dir == 'CVS' )
492
+				foreach ($sub_dirs as $sub_dir) {
493
+					if ( ! is_dir($theme_root.'/'.$dir.'/'.$sub_dir) || $dir[0] == '.' || $dir == 'CVS')
494 494
 						continue;
495
-					if ( ! file_exists( $theme_root . '/' . $dir . '/' . $sub_dir . '/style.css' ) )
495
+					if ( ! file_exists($theme_root.'/'.$dir.'/'.$sub_dir.'/style.css'))
496 496
 						continue;
497
-					$found_themes[ $dir . '/' . $sub_dir ] = array(
498
-						'theme_file' => $dir . '/' . $sub_dir . '/style.css',
497
+					$found_themes[$dir.'/'.$sub_dir] = array(
498
+						'theme_file' => $dir.'/'.$sub_dir.'/style.css',
499 499
 						'theme_root' => $theme_root,
500 500
 					);
501 501
 					$found_theme = true;
502 502
 				}
503 503
 				// Never mind the above, it's just a theme missing a style.css.
504 504
 				// Return it; WP_Theme will catch the error.
505
-				if ( ! $found_theme )
506
-					$found_themes[ $dir ] = array(
507
-						'theme_file' => $dir . '/style.css',
505
+				if ( ! $found_theme)
506
+					$found_themes[$dir] = array(
507
+						'theme_file' => $dir.'/style.css',
508 508
 						'theme_root' => $theme_root,
509 509
 					);
510 510
 			}
511 511
 		}
512 512
 	}
513 513
 
514
-	asort( $found_themes );
514
+	asort($found_themes);
515 515
 
516 516
 	$theme_roots = array();
517
-	$relative_theme_roots = array_flip( $relative_theme_roots );
517
+	$relative_theme_roots = array_flip($relative_theme_roots);
518 518
 
519
-	foreach ( $found_themes as $theme_dir => $theme_data ) {
520
-		$theme_roots[ $theme_dir ] = $relative_theme_roots[ $theme_data['theme_root'] ]; // Convert absolute to relative.
519
+	foreach ($found_themes as $theme_dir => $theme_data) {
520
+		$theme_roots[$theme_dir] = $relative_theme_roots[$theme_data['theme_root']]; // Convert absolute to relative.
521 521
 	}
522 522
 
523
-	if ( $theme_roots != get_site_transient( 'theme_roots' ) )
524
-		set_site_transient( 'theme_roots', $theme_roots, $cache_expiration );
523
+	if ($theme_roots != get_site_transient('theme_roots'))
524
+		set_site_transient('theme_roots', $theme_roots, $cache_expiration);
525 525
 
526 526
 	return $found_themes;
527 527
 }
@@ -538,16 +538,16 @@  discard block
 block discarded – undo
538 538
  * @param string $stylesheet_or_template The stylesheet or template name of the theme
539 539
  * @return string Theme path.
540 540
  */
541
-function get_theme_root( $stylesheet_or_template = false ) {
541
+function get_theme_root($stylesheet_or_template = false) {
542 542
 	global $wp_theme_directories;
543 543
 
544
-	if ( $stylesheet_or_template && $theme_root = get_raw_theme_root( $stylesheet_or_template ) ) {
544
+	if ($stylesheet_or_template && $theme_root = get_raw_theme_root($stylesheet_or_template)) {
545 545
 		// Always prepend WP_CONTENT_DIR unless the root currently registered as a theme directory.
546 546
 		// This gives relative theme roots the benefit of the doubt when things go haywire.
547
-		if ( ! in_array( $theme_root, (array) $wp_theme_directories ) )
548
-			$theme_root = WP_CONTENT_DIR . $theme_root;
547
+		if ( ! in_array($theme_root, (array) $wp_theme_directories))
548
+			$theme_root = WP_CONTENT_DIR.$theme_root;
549 549
 	} else {
550
-		$theme_root = WP_CONTENT_DIR . '/themes';
550
+		$theme_root = WP_CONTENT_DIR.'/themes';
551 551
 	}
552 552
 
553 553
 	/**
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 	 *
558 558
 	 * @param string $theme_root Absolute path to themes directory.
559 559
 	 */
560
-	return apply_filters( 'theme_root', $theme_root );
560
+	return apply_filters('theme_root', $theme_root);
561 561
 }
562 562
 
563 563
 /**
@@ -575,28 +575,28 @@  discard block
 block discarded – undo
575 575
  * 	                                     the need for a get_raw_theme_root() call.
576 576
  * @return string Themes URI.
577 577
  */
578
-function get_theme_root_uri( $stylesheet_or_template = false, $theme_root = false ) {
578
+function get_theme_root_uri($stylesheet_or_template = false, $theme_root = false) {
579 579
 	global $wp_theme_directories;
580 580
 
581
-	if ( $stylesheet_or_template && ! $theme_root )
582
-		$theme_root = get_raw_theme_root( $stylesheet_or_template );
581
+	if ($stylesheet_or_template && ! $theme_root)
582
+		$theme_root = get_raw_theme_root($stylesheet_or_template);
583 583
 
584
-	if ( $stylesheet_or_template && $theme_root ) {
585
-		if ( in_array( $theme_root, (array) $wp_theme_directories ) ) {
584
+	if ($stylesheet_or_template && $theme_root) {
585
+		if (in_array($theme_root, (array) $wp_theme_directories)) {
586 586
 			// Absolute path. Make an educated guess. YMMV -- but note the filter below.
587
-			if ( 0 === strpos( $theme_root, WP_CONTENT_DIR ) )
588
-				$theme_root_uri = content_url( str_replace( WP_CONTENT_DIR, '', $theme_root ) );
589
-			elseif ( 0 === strpos( $theme_root, ABSPATH ) )
590
-				$theme_root_uri = site_url( str_replace( ABSPATH, '', $theme_root ) );
591
-			elseif ( 0 === strpos( $theme_root, WP_PLUGIN_DIR ) || 0 === strpos( $theme_root, WPMU_PLUGIN_DIR ) )
592
-				$theme_root_uri = plugins_url( basename( $theme_root ), $theme_root );
587
+			if (0 === strpos($theme_root, WP_CONTENT_DIR))
588
+				$theme_root_uri = content_url(str_replace(WP_CONTENT_DIR, '', $theme_root));
589
+			elseif (0 === strpos($theme_root, ABSPATH))
590
+				$theme_root_uri = site_url(str_replace(ABSPATH, '', $theme_root));
591
+			elseif (0 === strpos($theme_root, WP_PLUGIN_DIR) || 0 === strpos($theme_root, WPMU_PLUGIN_DIR))
592
+				$theme_root_uri = plugins_url(basename($theme_root), $theme_root);
593 593
 			else
594 594
 				$theme_root_uri = $theme_root;
595 595
 		} else {
596
-			$theme_root_uri = content_url( $theme_root );
596
+			$theme_root_uri = content_url($theme_root);
597 597
 		}
598 598
 	} else {
599
-		$theme_root_uri = content_url( 'themes' );
599
+		$theme_root_uri = content_url('themes');
600 600
 	}
601 601
 
602 602
 	/**
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 	 * @param string $siteurl                WordPress web address which is set in General Options.
609 609
 	 * @param string $stylesheet_or_template Stylesheet or template name of the theme.
610 610
 	 */
611
-	return apply_filters( 'theme_root_uri', $theme_root_uri, get_option( 'siteurl' ), $stylesheet_or_template );
611
+	return apply_filters('theme_root_uri', $theme_root_uri, get_option('siteurl'), $stylesheet_or_template);
612 612
 }
613 613
 
614 614
 /**
@@ -623,25 +623,25 @@  discard block
 block discarded – undo
623 623
  *                                       Defaults to false, meaning the cache is used.
624 624
  * @return string Theme root
625 625
  */
626
-function get_raw_theme_root( $stylesheet_or_template, $skip_cache = false ) {
626
+function get_raw_theme_root($stylesheet_or_template, $skip_cache = false) {
627 627
 	global $wp_theme_directories;
628 628
 
629
-	if ( count($wp_theme_directories) <= 1 )
629
+	if (count($wp_theme_directories) <= 1)
630 630
 		return '/themes';
631 631
 
632 632
 	$theme_root = false;
633 633
 
634 634
 	// If requesting the root for the current theme, consult options to avoid calling get_theme_roots()
635
-	if ( ! $skip_cache ) {
636
-		if ( get_option('stylesheet') == $stylesheet_or_template )
635
+	if ( ! $skip_cache) {
636
+		if (get_option('stylesheet') == $stylesheet_or_template)
637 637
 			$theme_root = get_option('stylesheet_root');
638
-		elseif ( get_option('template') == $stylesheet_or_template )
638
+		elseif (get_option('template') == $stylesheet_or_template)
639 639
 			$theme_root = get_option('template_root');
640 640
 	}
641 641
 
642
-	if ( empty($theme_root) ) {
642
+	if (empty($theme_root)) {
643 643
 		$theme_roots = get_theme_roots();
644
-		if ( !empty($theme_roots[$stylesheet_or_template]) )
644
+		if ( ! empty($theme_roots[$stylesheet_or_template]))
645 645
 			$theme_root = $theme_roots[$stylesheet_or_template];
646 646
 	}
647 647
 
@@ -655,9 +655,9 @@  discard block
 block discarded – undo
655 655
  */
656 656
 function locale_stylesheet() {
657 657
 	$stylesheet = get_locale_stylesheet_uri();
658
-	if ( empty($stylesheet) )
658
+	if (empty($stylesheet))
659 659
 		return;
660
-	echo '<link rel="stylesheet" href="' . $stylesheet . '" type="text/css" media="screen" />';
660
+	echo '<link rel="stylesheet" href="'.$stylesheet.'" type="text/css" media="screen" />';
661 661
 }
662 662
 
663 663
 /**
@@ -674,71 +674,71 @@  discard block
 block discarded – undo
674 674
  *
675 675
  * @param string $stylesheet Stylesheet name
676 676
  */
677
-function switch_theme( $stylesheet ) {
677
+function switch_theme($stylesheet) {
678 678
 	global $wp_theme_directories, $wp_customize, $sidebars_widgets;
679 679
 
680 680
 	$_sidebars_widgets = null;
681
-	if ( 'wp_ajax_customize_save' === current_action() ) {
682
-		$_sidebars_widgets = $wp_customize->post_value( $wp_customize->get_setting( 'old_sidebars_widgets_data' ) );
683
-	} elseif ( is_array( $sidebars_widgets ) ) {
681
+	if ('wp_ajax_customize_save' === current_action()) {
682
+		$_sidebars_widgets = $wp_customize->post_value($wp_customize->get_setting('old_sidebars_widgets_data'));
683
+	} elseif (is_array($sidebars_widgets)) {
684 684
 		$_sidebars_widgets = $sidebars_widgets;
685 685
 	}
686 686
 
687
-	if ( is_array( $_sidebars_widgets ) ) {
688
-		set_theme_mod( 'sidebars_widgets', array( 'time' => time(), 'data' => $_sidebars_widgets ) );
687
+	if (is_array($_sidebars_widgets)) {
688
+		set_theme_mod('sidebars_widgets', array('time' => time(), 'data' => $_sidebars_widgets));
689 689
 	}
690 690
 
691
-	$nav_menu_locations = get_theme_mod( 'nav_menu_locations' );
691
+	$nav_menu_locations = get_theme_mod('nav_menu_locations');
692 692
 
693
-	if ( func_num_args() > 1 ) {
694
-		$stylesheet = func_get_arg( 1 );
693
+	if (func_num_args() > 1) {
694
+		$stylesheet = func_get_arg(1);
695 695
 	}
696 696
 
697 697
 	$old_theme = wp_get_theme();
698
-	$new_theme = wp_get_theme( $stylesheet );
698
+	$new_theme = wp_get_theme($stylesheet);
699 699
 	$template  = $new_theme->get_template();
700 700
 
701
-	update_option( 'template', $template );
702
-	update_option( 'stylesheet', $stylesheet );
701
+	update_option('template', $template);
702
+	update_option('stylesheet', $stylesheet);
703 703
 
704
-	if ( count( $wp_theme_directories ) > 1 ) {
705
-		update_option( 'template_root', get_raw_theme_root( $template, true ) );
706
-		update_option( 'stylesheet_root', get_raw_theme_root( $stylesheet, true ) );
704
+	if (count($wp_theme_directories) > 1) {
705
+		update_option('template_root', get_raw_theme_root($template, true));
706
+		update_option('stylesheet_root', get_raw_theme_root($stylesheet, true));
707 707
 	} else {
708
-		delete_option( 'template_root' );
709
-		delete_option( 'stylesheet_root' );
708
+		delete_option('template_root');
709
+		delete_option('stylesheet_root');
710 710
 	}
711 711
 
712
-	$new_name  = $new_theme->get('Name');
712
+	$new_name = $new_theme->get('Name');
713 713
 
714
-	update_option( 'current_theme', $new_name );
714
+	update_option('current_theme', $new_name);
715 715
 
716 716
 	// Migrate from the old mods_{name} option to theme_mods_{slug}.
717
-	if ( is_admin() && false === get_option( 'theme_mods_' . $stylesheet ) ) {
718
-		$default_theme_mods = (array) get_option( 'mods_' . $new_name );
719
-		if ( ! empty( $nav_menu_locations ) && empty( $default_theme_mods['nav_menu_locations'] ) ) {
717
+	if (is_admin() && false === get_option('theme_mods_'.$stylesheet)) {
718
+		$default_theme_mods = (array) get_option('mods_'.$new_name);
719
+		if ( ! empty($nav_menu_locations) && empty($default_theme_mods['nav_menu_locations'])) {
720 720
 			$default_theme_mods['nav_menu_locations'] = $nav_menu_locations;
721 721
 		}
722
-		add_option( "theme_mods_$stylesheet", $default_theme_mods );
722
+		add_option("theme_mods_$stylesheet", $default_theme_mods);
723 723
 	} else {
724 724
 		/*
725 725
 		 * Since retrieve_widgets() is called when initializing a theme in the Customizer,
726 726
 		 * we need to remove the theme mods to avoid overwriting changes made via
727 727
 		 * the Customizer when accessing wp-admin/widgets.php.
728 728
 		 */
729
-		if ( 'wp_ajax_customize_save' === current_action() ) {
730
-			remove_theme_mod( 'sidebars_widgets' );
729
+		if ('wp_ajax_customize_save' === current_action()) {
730
+			remove_theme_mod('sidebars_widgets');
731 731
 		}
732 732
 
733
-		if ( ! empty( $nav_menu_locations ) ) {
734
-			$nav_mods = get_theme_mod( 'nav_menu_locations' );
735
-			if ( empty( $nav_mods ) ) {
736
-				set_theme_mod( 'nav_menu_locations', $nav_menu_locations );
733
+		if ( ! empty($nav_menu_locations)) {
734
+			$nav_mods = get_theme_mod('nav_menu_locations');
735
+			if (empty($nav_mods)) {
736
+				set_theme_mod('nav_menu_locations', $nav_menu_locations);
737 737
 			}
738 738
 		}
739 739
 	}
740 740
 
741
-	update_option( 'theme_switched', $old_theme->get_stylesheet() );
741
+	update_option('theme_switched', $old_theme->get_stylesheet());
742 742
 
743 743
 	/**
744 744
 	 * Fires after the theme is switched.
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
 	 * @param WP_Theme $new_theme WP_Theme instance of the new theme.
751 751
 	 * @param WP_Theme $old_theme WP_Theme instance of the old theme.
752 752
 	 */
753
-	do_action( 'switch_theme', $new_name, $new_theme, $old_theme );
753
+	do_action('switch_theme', $new_name, $new_theme, $old_theme);
754 754
 }
755 755
 
756 756
 /**
@@ -776,23 +776,23 @@  discard block
 block discarded – undo
776 776
 	 *
777 777
 	 * @param bool $validate Whether to validate the current theme. Default true.
778 778
 	 */
779
-	if ( wp_installing() || ! apply_filters( 'validate_current_theme', true ) )
779
+	if (wp_installing() || ! apply_filters('validate_current_theme', true))
780 780
 		return true;
781 781
 
782
-	if ( ! file_exists( get_template_directory() . '/index.php' ) ) {
782
+	if ( ! file_exists(get_template_directory().'/index.php')) {
783 783
 		// Invalid.
784
-	} elseif ( ! file_exists( get_template_directory() . '/style.css' ) ) {
784
+	} elseif ( ! file_exists(get_template_directory().'/style.css')) {
785 785
 		// Invalid.
786
-	} elseif ( is_child_theme() && ! file_exists( get_stylesheet_directory() . '/style.css' ) ) {
786
+	} elseif (is_child_theme() && ! file_exists(get_stylesheet_directory().'/style.css')) {
787 787
 		// Invalid.
788 788
 	} else {
789 789
 		// Valid.
790 790
 		return true;
791 791
 	}
792 792
 
793
-	$default = wp_get_theme( WP_DEFAULT_THEME );
794
-	if ( $default->exists() ) {
795
-		switch_theme( WP_DEFAULT_THEME );
793
+	$default = wp_get_theme(WP_DEFAULT_THEME);
794
+	if ($default->exists()) {
795
+		switch_theme(WP_DEFAULT_THEME);
796 796
 		return false;
797 797
 	}
798 798
 
@@ -806,11 +806,11 @@  discard block
 block discarded – undo
806 806
 	 * if it turns out there is no default theme installed. (That's `false`.)
807 807
 	 */
808 808
 	$default = WP_Theme::get_core_default_theme();
809
-	if ( false === $default || get_stylesheet() == $default->get_stylesheet() ) {
809
+	if (false === $default || get_stylesheet() == $default->get_stylesheet()) {
810 810
 		return true;
811 811
 	}
812 812
 
813
-	switch_theme( $default->get_stylesheet() );
813
+	switch_theme($default->get_stylesheet());
814 814
 	return false;
815 815
 }
816 816
 
@@ -822,16 +822,16 @@  discard block
 block discarded – undo
822 822
  * @return array|void Theme modifications.
823 823
  */
824 824
 function get_theme_mods() {
825
-	$theme_slug = get_option( 'stylesheet' );
826
-	$mods = get_option( "theme_mods_$theme_slug" );
827
-	if ( false === $mods ) {
828
-		$theme_name = get_option( 'current_theme' );
829
-		if ( false === $theme_name )
825
+	$theme_slug = get_option('stylesheet');
826
+	$mods = get_option("theme_mods_$theme_slug");
827
+	if (false === $mods) {
828
+		$theme_name = get_option('current_theme');
829
+		if (false === $theme_name)
830 830
 			$theme_name = wp_get_theme()->get('Name');
831
-		$mods = get_option( "mods_$theme_name" ); // Deprecated location.
832
-		if ( is_admin() && false !== $mods ) {
833
-			update_option( "theme_mods_$theme_slug", $mods );
834
-			delete_option( "mods_$theme_name" );
831
+		$mods = get_option("mods_$theme_name"); // Deprecated location.
832
+		if (is_admin() && false !== $mods) {
833
+			update_option("theme_mods_$theme_slug", $mods);
834
+			delete_option("mods_$theme_name");
835 835
 		}
836 836
 	}
837 837
 	return $mods;
@@ -851,10 +851,10 @@  discard block
 block discarded – undo
851 851
  * @param bool|string $default
852 852
  * @return string
853 853
  */
854
-function get_theme_mod( $name, $default = false ) {
854
+function get_theme_mod($name, $default = false) {
855 855
 	$mods = get_theme_mods();
856 856
 
857
-	if ( isset( $mods[$name] ) ) {
857
+	if (isset($mods[$name])) {
858 858
 		/**
859 859
 		 * Filter the theme modification, or 'theme_mod', value.
860 860
 		 *
@@ -867,14 +867,14 @@  discard block
 block discarded – undo
867 867
 		 *
868 868
 		 * @param string $current_mod The value of the current theme modification.
869 869
 		 */
870
-		return apply_filters( "theme_mod_{$name}", $mods[$name] );
870
+		return apply_filters("theme_mod_{$name}", $mods[$name]);
871 871
 	}
872 872
 
873
-	if ( is_string( $default ) )
874
-		$default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() );
873
+	if (is_string($default))
874
+		$default = sprintf($default, get_template_directory_uri(), get_stylesheet_directory_uri());
875 875
 
876 876
 	/** This filter is documented in wp-includes/theme.php */
877
-	return apply_filters( "theme_mod_{$name}", $default );
877
+	return apply_filters("theme_mod_{$name}", $default);
878 878
 }
879 879
 
880 880
 /**
@@ -885,9 +885,9 @@  discard block
 block discarded – undo
885 885
  * @param string $name  Theme modification name.
886 886
  * @param mixed  $value Theme modification value.
887 887
  */
888
-function set_theme_mod( $name, $value ) {
888
+function set_theme_mod($name, $value) {
889 889
 	$mods = get_theme_mods();
890
-	$old_value = isset( $mods[ $name ] ) ? $mods[ $name ] : false;
890
+	$old_value = isset($mods[$name]) ? $mods[$name] : false;
891 891
 
892 892
 	/**
893 893
 	 * Filter the theme mod value on save.
@@ -901,10 +901,10 @@  discard block
 block discarded – undo
901 901
 	 * @param string $value     The new value of the theme mod.
902 902
 	 * @param string $old_value The current value of the theme mod.
903 903
 	 */
904
-	$mods[ $name ] = apply_filters( "pre_set_theme_mod_$name", $value, $old_value );
904
+	$mods[$name] = apply_filters("pre_set_theme_mod_$name", $value, $old_value);
905 905
 
906
-	$theme = get_option( 'stylesheet' );
907
-	update_option( "theme_mods_$theme", $mods );
906
+	$theme = get_option('stylesheet');
907
+	update_option("theme_mods_$theme", $mods);
908 908
 }
909 909
 
910 910
 /**
@@ -917,20 +917,20 @@  discard block
 block discarded – undo
917 917
  *
918 918
  * @param string $name Theme modification name.
919 919
  */
920
-function remove_theme_mod( $name ) {
920
+function remove_theme_mod($name) {
921 921
 	$mods = get_theme_mods();
922 922
 
923
-	if ( ! isset( $mods[ $name ] ) )
923
+	if ( ! isset($mods[$name]))
924 924
 		return;
925 925
 
926
-	unset( $mods[ $name ] );
926
+	unset($mods[$name]);
927 927
 
928
-	if ( empty( $mods ) ) {
928
+	if (empty($mods)) {
929 929
 		remove_theme_mods();
930 930
 		return;
931 931
 	}
932
-	$theme = get_option( 'stylesheet' );
933
-	update_option( "theme_mods_$theme", $mods );
932
+	$theme = get_option('stylesheet');
933
+	update_option("theme_mods_$theme", $mods);
934 934
 }
935 935
 
936 936
 /**
@@ -939,13 +939,13 @@  discard block
 block discarded – undo
939 939
  * @since 2.1.0
940 940
  */
941 941
 function remove_theme_mods() {
942
-	delete_option( 'theme_mods_' . get_option( 'stylesheet' ) );
942
+	delete_option('theme_mods_'.get_option('stylesheet'));
943 943
 
944 944
 	// Old style.
945
-	$theme_name = get_option( 'current_theme' );
946
-	if ( false === $theme_name )
945
+	$theme_name = get_option('current_theme');
946
+	if (false === $theme_name)
947 947
 		$theme_name = wp_get_theme()->get('Name');
948
-	delete_option( 'mods_' . $theme_name );
948
+	delete_option('mods_'.$theme_name);
949 949
 }
950 950
 
951 951
 /**
@@ -956,7 +956,7 @@  discard block
 block discarded – undo
956 956
  * @return string
957 957
  */
958 958
 function get_header_textcolor() {
959
-	return get_theme_mod('header_textcolor', get_theme_support( 'custom-header', 'default-text-color' ) );
959
+	return get_theme_mod('header_textcolor', get_theme_support('custom-header', 'default-text-color'));
960 960
 }
961 961
 
962 962
 /**
@@ -976,10 +976,10 @@  discard block
 block discarded – undo
976 976
  * @return bool
977 977
  */
978 978
 function display_header_text() {
979
-	if ( ! current_theme_supports( 'custom-header', 'header-text' ) )
979
+	if ( ! current_theme_supports('custom-header', 'header-text'))
980 980
 		return false;
981 981
 
982
-	$text_color = get_theme_mod( 'header_textcolor', get_theme_support( 'custom-header', 'default-text-color' ) );
982
+	$text_color = get_theme_mod('header_textcolor', get_theme_support('custom-header', 'default-text-color'));
983 983
 	return 'blank' !== $text_color;
984 984
 }
985 985
 
@@ -1004,15 +1004,15 @@  discard block
 block discarded – undo
1004 1004
  * @return string|false
1005 1005
  */
1006 1006
 function get_header_image() {
1007
-	$url = get_theme_mod( 'header_image', get_theme_support( 'custom-header', 'default-image' ) );
1007
+	$url = get_theme_mod('header_image', get_theme_support('custom-header', 'default-image'));
1008 1008
 
1009
-	if ( 'remove-header' == $url )
1009
+	if ('remove-header' == $url)
1010 1010
 		return false;
1011 1011
 
1012
-	if ( is_random_header_image() )
1012
+	if (is_random_header_image())
1013 1013
 		$url = get_random_header_image();
1014 1014
 
1015
-	return esc_url_raw( set_url_scheme( $url ) );
1015
+	return esc_url_raw(set_url_scheme($url));
1016 1016
 }
1017 1017
 
1018 1018
 /**
@@ -1024,15 +1024,15 @@  discard block
 block discarded – undo
1024 1024
  *                              to override the default attributes. Default empty.
1025 1025
  * @return string HTML image element markup or empty string on failure.
1026 1026
  */
1027
-function get_header_image_tag( $attr = array() ) {
1027
+function get_header_image_tag($attr = array()) {
1028 1028
 	$header = get_custom_header();
1029 1029
 
1030
-	if ( empty( $header->url ) ) {
1030
+	if (empty($header->url)) {
1031 1031
 		return '';
1032 1032
 	}
1033 1033
 
1034
-	$width = absint( $header->width );
1035
-	$height = absint( $header->height );
1034
+	$width = absint($header->width);
1035
+	$height = absint($header->height);
1036 1036
 
1037 1037
 	$attr = wp_parse_args(
1038 1038
 		$attr,
@@ -1040,31 +1040,31 @@  discard block
 block discarded – undo
1040 1040
 			'src' => $header->url,
1041 1041
 			'width' => $width,
1042 1042
 			'height' => $height,
1043
-			'alt' => get_bloginfo( 'name' ),
1043
+			'alt' => get_bloginfo('name'),
1044 1044
 		)
1045 1045
 	);
1046 1046
 
1047 1047
 	// Generate 'srcset' and 'sizes' if not already present.
1048
-	if ( empty( $attr['srcset'] ) && ! empty( $header->attachment_id ) ) {
1049
-		$image_meta = get_post_meta( $header->attachment_id, '_wp_attachment_metadata', true );
1050
-		$size_array = array( $width, $height );
1048
+	if (empty($attr['srcset']) && ! empty($header->attachment_id)) {
1049
+		$image_meta = get_post_meta($header->attachment_id, '_wp_attachment_metadata', true);
1050
+		$size_array = array($width, $height);
1051 1051
 
1052
-		if ( is_array( $image_meta ) ) {
1053
-			$srcset = wp_calculate_image_srcset( $size_array, $header->url, $image_meta, $header->attachment_id );
1054
-			$sizes = ! empty( $attr['sizes'] ) ? $attr['sizes'] : wp_calculate_image_sizes( $size_array, $header->url, $image_meta, $header->attachment_id );
1052
+		if (is_array($image_meta)) {
1053
+			$srcset = wp_calculate_image_srcset($size_array, $header->url, $image_meta, $header->attachment_id);
1054
+			$sizes = ! empty($attr['sizes']) ? $attr['sizes'] : wp_calculate_image_sizes($size_array, $header->url, $image_meta, $header->attachment_id);
1055 1055
 
1056
-			if ( $srcset && $sizes ) {
1056
+			if ($srcset && $sizes) {
1057 1057
 				$attr['srcset'] = $srcset;
1058 1058
 				$attr['sizes'] = $sizes;
1059 1059
 			}
1060 1060
 		}
1061 1061
 	}
1062 1062
 
1063
-	$attr = array_map( 'esc_attr', $attr );
1063
+	$attr = array_map('esc_attr', $attr);
1064 1064
 	$html = '<img';
1065 1065
 
1066
-	foreach ( $attr as $name => $value ) {
1067
-		$html .= ' ' . $name . '="' . $value . '"';
1066
+	foreach ($attr as $name => $value) {
1067
+		$html .= ' '.$name.'="'.$value.'"';
1068 1068
 	}
1069 1069
 
1070 1070
 	$html .= ' />';
@@ -1078,7 +1078,7 @@  discard block
 block discarded – undo
1078 1078
 	 * @param object $header The custom header object returned by 'get_custom_header()'.
1079 1079
 	 * @param array  $attr   Array of the attributes for the image tag.
1080 1080
 	 */
1081
-	return apply_filters( 'get_header_image_tag', $html, $header, $attr );
1081
+	return apply_filters('get_header_image_tag', $html, $header, $attr);
1082 1082
 }
1083 1083
 
1084 1084
 /**
@@ -1088,8 +1088,8 @@  discard block
 block discarded – undo
1088 1088
  *
1089 1089
  * @param array $attr Optional. Attributes for the image markup. Default empty.
1090 1090
  */
1091
-function the_header_image_tag( $attr = array() ) {
1092
-	echo get_header_image_tag( $attr );
1091
+function the_header_image_tag($attr = array()) {
1092
+	echo get_header_image_tag($attr);
1093 1093
 }
1094 1094
 
1095 1095
 /**
@@ -1107,29 +1107,29 @@  discard block
 block discarded – undo
1107 1107
 function _get_random_header_data() {
1108 1108
 	static $_wp_random_header = null;
1109 1109
 
1110
-	if ( empty( $_wp_random_header ) ) {
1110
+	if (empty($_wp_random_header)) {
1111 1111
 		global $_wp_default_headers;
1112
-		$header_image_mod = get_theme_mod( 'header_image', '' );
1112
+		$header_image_mod = get_theme_mod('header_image', '');
1113 1113
 		$headers = array();
1114 1114
 
1115
-		if ( 'random-uploaded-image' == $header_image_mod )
1115
+		if ('random-uploaded-image' == $header_image_mod)
1116 1116
 			$headers = get_uploaded_header_images();
1117
-		elseif ( ! empty( $_wp_default_headers ) ) {
1118
-			if ( 'random-default-image' == $header_image_mod ) {
1117
+		elseif ( ! empty($_wp_default_headers)) {
1118
+			if ('random-default-image' == $header_image_mod) {
1119 1119
 				$headers = $_wp_default_headers;
1120 1120
 			} else {
1121
-				if ( current_theme_supports( 'custom-header', 'random-default' ) )
1121
+				if (current_theme_supports('custom-header', 'random-default'))
1122 1122
 					$headers = $_wp_default_headers;
1123 1123
 			}
1124 1124
 		}
1125 1125
 
1126
-		if ( empty( $headers ) )
1126
+		if (empty($headers))
1127 1127
 			return new stdClass;
1128 1128
 
1129
-		$_wp_random_header = (object) $headers[ array_rand( $headers ) ];
1129
+		$_wp_random_header = (object) $headers[array_rand($headers)];
1130 1130
 
1131
-		$_wp_random_header->url =  sprintf( $_wp_random_header->url, get_template_directory_uri(), get_stylesheet_directory_uri() );
1132
-		$_wp_random_header->thumbnail_url =  sprintf( $_wp_random_header->thumbnail_url, get_template_directory_uri(), get_stylesheet_directory_uri() );
1131
+		$_wp_random_header->url = sprintf($_wp_random_header->url, get_template_directory_uri(), get_stylesheet_directory_uri());
1132
+		$_wp_random_header->thumbnail_url = sprintf($_wp_random_header->thumbnail_url, get_template_directory_uri(), get_stylesheet_directory_uri());
1133 1133
 	}
1134 1134
 	return $_wp_random_header;
1135 1135
 }
@@ -1143,7 +1143,7 @@  discard block
 block discarded – undo
1143 1143
  */
1144 1144
 function get_random_header_image() {
1145 1145
 	$random_image = _get_random_header_data();
1146
-	if ( empty( $random_image->url ) )
1146
+	if (empty($random_image->url))
1147 1147
 		return '';
1148 1148
 	return $random_image->url;
1149 1149
 }
@@ -1160,16 +1160,16 @@  discard block
 block discarded – undo
1160 1160
  * @param string $type The random pool to use. any|default|uploaded
1161 1161
  * @return bool
1162 1162
  */
1163
-function is_random_header_image( $type = 'any' ) {
1164
-	$header_image_mod = get_theme_mod( 'header_image', get_theme_support( 'custom-header', 'default-image' ) );
1163
+function is_random_header_image($type = 'any') {
1164
+	$header_image_mod = get_theme_mod('header_image', get_theme_support('custom-header', 'default-image'));
1165 1165
 
1166
-	if ( 'any' == $type ) {
1167
-		if ( 'random-default-image' == $header_image_mod || 'random-uploaded-image' == $header_image_mod || ( '' != get_random_header_image() && empty( $header_image_mod ) ) )
1166
+	if ('any' == $type) {
1167
+		if ('random-default-image' == $header_image_mod || 'random-uploaded-image' == $header_image_mod || ('' != get_random_header_image() && empty($header_image_mod)))
1168 1168
 			return true;
1169 1169
 	} else {
1170
-		if ( "random-$type-image" == $header_image_mod )
1170
+		if ("random-$type-image" == $header_image_mod)
1171 1171
 			return true;
1172
-		elseif ( 'default' == $type && empty( $header_image_mod ) && '' != get_random_header_image() )
1172
+		elseif ('default' == $type && empty($header_image_mod) && '' != get_random_header_image())
1173 1173
 			return true;
1174 1174
 	}
1175 1175
 
@@ -1183,8 +1183,8 @@  discard block
 block discarded – undo
1183 1183
  */
1184 1184
 function header_image() {
1185 1185
 	$image = get_header_image();
1186
-	if ( $image ) {
1187
-		echo esc_url( $image );
1186
+	if ($image) {
1187
+		echo esc_url($image);
1188 1188
 	}
1189 1189
 }
1190 1190
 
@@ -1199,25 +1199,25 @@  discard block
 block discarded – undo
1199 1199
 	$header_images = array();
1200 1200
 
1201 1201
 	// @todo caching
1202
-	$headers = get_posts( array( 'post_type' => 'attachment', 'meta_key' => '_wp_attachment_is_custom_header', 'meta_value' => get_option('stylesheet'), 'orderby' => 'none', 'nopaging' => true ) );
1202
+	$headers = get_posts(array('post_type' => 'attachment', 'meta_key' => '_wp_attachment_is_custom_header', 'meta_value' => get_option('stylesheet'), 'orderby' => 'none', 'nopaging' => true));
1203 1203
 
1204
-	if ( empty( $headers ) )
1204
+	if (empty($headers))
1205 1205
 		return array();
1206 1206
 
1207
-	foreach ( (array) $headers as $header ) {
1208
-		$url = esc_url_raw( wp_get_attachment_url( $header->ID ) );
1209
-		$header_data = wp_get_attachment_metadata( $header->ID );
1207
+	foreach ((array) $headers as $header) {
1208
+		$url = esc_url_raw(wp_get_attachment_url($header->ID));
1209
+		$header_data = wp_get_attachment_metadata($header->ID);
1210 1210
 		$header_index = $header->ID;
1211 1211
 
1212 1212
 		$header_images[$header_index] = array();
1213 1213
 		$header_images[$header_index]['attachment_id'] = $header->ID;
1214
-		$header_images[$header_index]['url'] =  $url;
1214
+		$header_images[$header_index]['url'] = $url;
1215 1215
 		$header_images[$header_index]['thumbnail_url'] = $url;
1216
-		$header_images[$header_index]['alt_text'] = get_post_meta( $header->ID, '_wp_attachment_image_alt', true );
1216
+		$header_images[$header_index]['alt_text'] = get_post_meta($header->ID, '_wp_attachment_image_alt', true);
1217 1217
 
1218
-		if ( isset( $header_data['width'] ) )
1218
+		if (isset($header_data['width']))
1219 1219
 			$header_images[$header_index]['width'] = $header_data['width'];
1220
-		if ( isset( $header_data['height'] ) )
1220
+		if (isset($header_data['height']))
1221 1221
 			$header_images[$header_index]['height'] = $header_data['height'];
1222 1222
 	}
1223 1223
 
@@ -1236,21 +1236,21 @@  discard block
 block discarded – undo
1236 1236
 function get_custom_header() {
1237 1237
 	global $_wp_default_headers;
1238 1238
 
1239
-	if ( is_random_header_image() ) {
1239
+	if (is_random_header_image()) {
1240 1240
 		$data = _get_random_header_data();
1241 1241
 	} else {
1242
-		$data = get_theme_mod( 'header_image_data' );
1243
-		if ( ! $data && current_theme_supports( 'custom-header', 'default-image' ) ) {
1244
-			$directory_args = array( get_template_directory_uri(), get_stylesheet_directory_uri() );
1242
+		$data = get_theme_mod('header_image_data');
1243
+		if ( ! $data && current_theme_supports('custom-header', 'default-image')) {
1244
+			$directory_args = array(get_template_directory_uri(), get_stylesheet_directory_uri());
1245 1245
 			$data = array();
1246
-			$data['url'] = $data['thumbnail_url'] = vsprintf( get_theme_support( 'custom-header', 'default-image' ), $directory_args );
1247
-			if ( ! empty( $_wp_default_headers ) ) {
1248
-				foreach ( (array) $_wp_default_headers as $default_header ) {
1249
-					$url = vsprintf( $default_header['url'], $directory_args );
1250
-					if ( $data['url'] == $url ) {
1246
+			$data['url'] = $data['thumbnail_url'] = vsprintf(get_theme_support('custom-header', 'default-image'), $directory_args);
1247
+			if ( ! empty($_wp_default_headers)) {
1248
+				foreach ((array) $_wp_default_headers as $default_header) {
1249
+					$url = vsprintf($default_header['url'], $directory_args);
1250
+					if ($data['url'] == $url) {
1251 1251
 						$data = $default_header;
1252 1252
 						$data['url'] = $url;
1253
-						$data['thumbnail_url'] = vsprintf( $data['thumbnail_url'], $directory_args );
1253
+						$data['thumbnail_url'] = vsprintf($data['thumbnail_url'], $directory_args);
1254 1254
 						break;
1255 1255
 					}
1256 1256
 				}
@@ -1261,10 +1261,10 @@  discard block
 block discarded – undo
1261 1261
 	$default = array(
1262 1262
 		'url'           => '',
1263 1263
 		'thumbnail_url' => '',
1264
-		'width'         => get_theme_support( 'custom-header', 'width' ),
1265
-		'height'        => get_theme_support( 'custom-header', 'height' ),
1264
+		'width'         => get_theme_support('custom-header', 'width'),
1265
+		'height'        => get_theme_support('custom-header', 'height'),
1266 1266
 	);
1267
-	return (object) wp_parse_args( $data, $default );
1267
+	return (object) wp_parse_args($data, $default);
1268 1268
 }
1269 1269
 
1270 1270
 /**
@@ -1276,10 +1276,10 @@  discard block
 block discarded – undo
1276 1276
  *
1277 1277
  * @param array $headers Array of headers keyed by a string id. The ids point to arrays containing 'url', 'thumbnail_url', and 'description' keys.
1278 1278
  */
1279
-function register_default_headers( $headers ) {
1279
+function register_default_headers($headers) {
1280 1280
 	global $_wp_default_headers;
1281 1281
 
1282
-	$_wp_default_headers = array_merge( (array) $_wp_default_headers, (array) $headers );
1282
+	$_wp_default_headers = array_merge((array) $_wp_default_headers, (array) $headers);
1283 1283
 }
1284 1284
 
1285 1285
 /**
@@ -1297,12 +1297,12 @@  discard block
 block discarded – undo
1297 1297
  * @return bool|void A single header returns true on success, false on failure.
1298 1298
  *                   There is currently no return value for multiple headers.
1299 1299
  */
1300
-function unregister_default_headers( $header ) {
1300
+function unregister_default_headers($header) {
1301 1301
 	global $_wp_default_headers;
1302
-	if ( is_array( $header ) ) {
1303
-		array_map( 'unregister_default_headers', $header );
1304
-	} elseif ( isset( $_wp_default_headers[ $header ] ) ) {
1305
-		unset( $_wp_default_headers[ $header ] );
1302
+	if (is_array($header)) {
1303
+		array_map('unregister_default_headers', $header);
1304
+	} elseif (isset($_wp_default_headers[$header])) {
1305
+		unset($_wp_default_headers[$header]);
1306 1306
 		return true;
1307 1307
 	} else {
1308 1308
 		return false;
@@ -1317,7 +1317,7 @@  discard block
 block discarded – undo
1317 1317
  * @return string
1318 1318
  */
1319 1319
 function get_background_image() {
1320
-	return get_theme_mod('background_image', get_theme_support( 'custom-background', 'default-image' ) );
1320
+	return get_theme_mod('background_image', get_theme_support('custom-background', 'default-image'));
1321 1321
 }
1322 1322
 
1323 1323
 /**
@@ -1337,7 +1337,7 @@  discard block
 block discarded – undo
1337 1337
  * @return string
1338 1338
  */
1339 1339
 function get_background_color() {
1340
-	return get_theme_mod('background_color', get_theme_support( 'custom-background', 'default-color' ) );
1340
+	return get_theme_mod('background_color', get_theme_support('custom-background', 'default-color'));
1341 1341
 }
1342 1342
 
1343 1343
 /**
@@ -1357,44 +1357,44 @@  discard block
 block discarded – undo
1357 1357
  */
1358 1358
 function _custom_background_cb() {
1359 1359
 	// $background is the saved custom image, or the default image.
1360
-	$background = set_url_scheme( get_background_image() );
1360
+	$background = set_url_scheme(get_background_image());
1361 1361
 
1362 1362
 	// $color is the saved custom color.
1363 1363
 	// A default has to be specified in style.css. It will not be printed here.
1364 1364
 	$color = get_background_color();
1365 1365
 
1366
-	if ( $color === get_theme_support( 'custom-background', 'default-color' ) ) {
1366
+	if ($color === get_theme_support('custom-background', 'default-color')) {
1367 1367
 		$color = false;
1368 1368
 	}
1369 1369
 
1370
-	if ( ! $background && ! $color )
1370
+	if ( ! $background && ! $color)
1371 1371
 		return;
1372 1372
 
1373 1373
 	$style = $color ? "background-color: #$color;" : '';
1374 1374
 
1375
-	if ( $background ) {
1375
+	if ($background) {
1376 1376
 		$image = " background-image: url('$background');";
1377 1377
 
1378
-		$repeat = get_theme_mod( 'background_repeat', get_theme_support( 'custom-background', 'default-repeat' ) );
1379
-		if ( ! in_array( $repeat, array( 'no-repeat', 'repeat-x', 'repeat-y', 'repeat' ) ) )
1378
+		$repeat = get_theme_mod('background_repeat', get_theme_support('custom-background', 'default-repeat'));
1379
+		if ( ! in_array($repeat, array('no-repeat', 'repeat-x', 'repeat-y', 'repeat')))
1380 1380
 			$repeat = 'repeat';
1381 1381
 		$repeat = " background-repeat: $repeat;";
1382 1382
 
1383
-		$position = get_theme_mod( 'background_position_x', get_theme_support( 'custom-background', 'default-position-x' ) );
1384
-		if ( ! in_array( $position, array( 'center', 'right', 'left' ) ) )
1383
+		$position = get_theme_mod('background_position_x', get_theme_support('custom-background', 'default-position-x'));
1384
+		if ( ! in_array($position, array('center', 'right', 'left')))
1385 1385
 			$position = 'left';
1386 1386
 		$position = " background-position: top $position;";
1387 1387
 
1388
-		$attachment = get_theme_mod( 'background_attachment', get_theme_support( 'custom-background', 'default-attachment' ) );
1389
-		if ( ! in_array( $attachment, array( 'fixed', 'scroll' ) ) )
1388
+		$attachment = get_theme_mod('background_attachment', get_theme_support('custom-background', 'default-attachment'));
1389
+		if ( ! in_array($attachment, array('fixed', 'scroll')))
1390 1390
 			$attachment = 'scroll';
1391 1391
 		$attachment = " background-attachment: $attachment;";
1392 1392
 
1393
-		$style .= $image . $repeat . $position . $attachment;
1393
+		$style .= $image.$repeat.$position.$attachment;
1394 1394
 	}
1395 1395
 ?>
1396 1396
 <style type="text/css" id="custom-background-css">
1397
-body.custom-background { <?php echo trim( $style ); ?> }
1397
+body.custom-background { <?php echo trim($style); ?> }
1398 1398
 </style>
1399 1399
 <?php
1400 1400
 }
@@ -1421,21 +1421,21 @@  discard block
 block discarded – undo
1421 1421
  * @param array|string $stylesheet Optional. Stylesheet name or array thereof, relative to theme root.
1422 1422
  * 	                               Defaults to 'editor-style.css'
1423 1423
  */
1424
-function add_editor_style( $stylesheet = 'editor-style.css' ) {
1425
-	add_theme_support( 'editor-style' );
1424
+function add_editor_style($stylesheet = 'editor-style.css') {
1425
+	add_theme_support('editor-style');
1426 1426
 
1427
-	if ( ! is_admin() )
1427
+	if ( ! is_admin())
1428 1428
 		return;
1429 1429
 
1430 1430
 	global $editor_styles;
1431 1431
 	$editor_styles = (array) $editor_styles;
1432 1432
 	$stylesheet    = (array) $stylesheet;
1433
-	if ( is_rtl() ) {
1433
+	if (is_rtl()) {
1434 1434
 		$rtl_stylesheet = str_replace('.css', '-rtl.css', $stylesheet[0]);
1435 1435
 		$stylesheet[] = $rtl_stylesheet;
1436 1436
 	}
1437 1437
 
1438
-	$editor_styles = array_merge( $editor_styles, $stylesheet );
1438
+	$editor_styles = array_merge($editor_styles, $stylesheet);
1439 1439
 }
1440 1440
 
1441 1441
 /**
@@ -1448,10 +1448,10 @@  discard block
 block discarded – undo
1448 1448
  * @return bool True on success, false if there were no stylesheets to remove.
1449 1449
  */
1450 1450
 function remove_editor_styles() {
1451
-	if ( ! current_theme_supports( 'editor-style' ) )
1451
+	if ( ! current_theme_supports('editor-style'))
1452 1452
 		return false;
1453
-	_remove_theme_support( 'editor-style' );
1454
-	if ( is_admin() )
1453
+	_remove_theme_support('editor-style');
1454
+	if (is_admin())
1455 1455
 		$GLOBALS['editor_styles'] = array();
1456 1456
 	return true;
1457 1457
 }
@@ -1468,35 +1468,35 @@  discard block
 block discarded – undo
1468 1468
 function get_editor_stylesheets() {
1469 1469
 	$stylesheets = array();
1470 1470
 	// load editor_style.css if the current theme supports it
1471
-	if ( ! empty( $GLOBALS['editor_styles'] ) && is_array( $GLOBALS['editor_styles'] ) ) {
1471
+	if ( ! empty($GLOBALS['editor_styles']) && is_array($GLOBALS['editor_styles'])) {
1472 1472
 		$editor_styles = $GLOBALS['editor_styles'];
1473 1473
 
1474
-		$editor_styles = array_unique( array_filter( $editor_styles ) );
1474
+		$editor_styles = array_unique(array_filter($editor_styles));
1475 1475
 		$style_uri = get_stylesheet_directory_uri();
1476 1476
 		$style_dir = get_stylesheet_directory();
1477 1477
 
1478 1478
 		// Support externally referenced styles (like, say, fonts).
1479
-		foreach ( $editor_styles as $key => $file ) {
1480
-			if ( preg_match( '~^(https?:)?//~', $file ) ) {
1481
-				$stylesheets[] = esc_url_raw( $file );
1482
-				unset( $editor_styles[ $key ] );
1479
+		foreach ($editor_styles as $key => $file) {
1480
+			if (preg_match('~^(https?:)?//~', $file)) {
1481
+				$stylesheets[] = esc_url_raw($file);
1482
+				unset($editor_styles[$key]);
1483 1483
 			}
1484 1484
 		}
1485 1485
 
1486 1486
 		// Look in a parent theme first, that way child theme CSS overrides.
1487
-		if ( is_child_theme() ) {
1487
+		if (is_child_theme()) {
1488 1488
 			$template_uri = get_template_directory_uri();
1489 1489
 			$template_dir = get_template_directory();
1490 1490
 
1491
-			foreach ( $editor_styles as $key => $file ) {
1492
-				if ( $file && file_exists( "$template_dir/$file" ) ) {
1491
+			foreach ($editor_styles as $key => $file) {
1492
+				if ($file && file_exists("$template_dir/$file")) {
1493 1493
 					$stylesheets[] = "$template_uri/$file";
1494 1494
 				}
1495 1495
 			}
1496 1496
 		}
1497 1497
 
1498
-		foreach ( $editor_styles as $file ) {
1499
-			if ( $file && file_exists( "$style_dir/$file" ) ) {
1498
+		foreach ($editor_styles as $file) {
1499
+			if ($file && file_exists("$style_dir/$file")) {
1500 1500
 				$stylesheets[] = "$style_uri/$file";
1501 1501
 			}
1502 1502
 		}
@@ -1509,7 +1509,7 @@  discard block
 block discarded – undo
1509 1509
 	 *
1510 1510
 	 * @param array $stylesheets Array of stylesheets to be applied to the editor.
1511 1511
 	 */
1512
-	return apply_filters( 'editor_stylesheets', $stylesheets );
1512
+	return apply_filters('editor_stylesheets', $stylesheets);
1513 1513
 }
1514 1514
 
1515 1515
 /**
@@ -1526,45 +1526,45 @@  discard block
 block discarded – undo
1526 1526
  * @param string $feature The feature being added.
1527 1527
  * @return void|bool False on failure, void otherwise.
1528 1528
  */
1529
-function add_theme_support( $feature ) {
1529
+function add_theme_support($feature) {
1530 1530
 	global $_wp_theme_features;
1531 1531
 
1532
-	if ( func_num_args() == 1 )
1532
+	if (func_num_args() == 1)
1533 1533
 		$args = true;
1534 1534
 	else
1535
-		$args = array_slice( func_get_args(), 1 );
1535
+		$args = array_slice(func_get_args(), 1);
1536 1536
 
1537
-	switch ( $feature ) {
1537
+	switch ($feature) {
1538 1538
 		case 'post-formats' :
1539
-			if ( is_array( $args[0] ) ) {
1539
+			if (is_array($args[0])) {
1540 1540
 				$post_formats = get_post_format_slugs();
1541
-				unset( $post_formats['standard'] );
1541
+				unset($post_formats['standard']);
1542 1542
 
1543
-				$args[0] = array_intersect( $args[0], array_keys( $post_formats ) );
1543
+				$args[0] = array_intersect($args[0], array_keys($post_formats));
1544 1544
 			}
1545 1545
 			break;
1546 1546
 
1547 1547
 		case 'html5' :
1548 1548
 			// You can't just pass 'html5', you need to pass an array of types.
1549
-			if ( empty( $args[0] ) ) {
1549
+			if (empty($args[0])) {
1550 1550
 				// Build an array of types for back-compat.
1551
-				$args = array( 0 => array( 'comment-list', 'comment-form', 'search-form' ) );
1552
-			} elseif ( ! is_array( $args[0] ) ) {
1553
-				_doing_it_wrong( "add_theme_support( 'html5' )", __( 'You need to pass an array of types.' ), '3.6.1' );
1551
+				$args = array(0 => array('comment-list', 'comment-form', 'search-form'));
1552
+			} elseif ( ! is_array($args[0])) {
1553
+				_doing_it_wrong("add_theme_support( 'html5' )", __('You need to pass an array of types.'), '3.6.1');
1554 1554
 				return false;
1555 1555
 			}
1556 1556
 
1557 1557
 			// Calling 'html5' again merges, rather than overwrites.
1558
-			if ( isset( $_wp_theme_features['html5'] ) )
1559
-				$args[0] = array_merge( $_wp_theme_features['html5'][0], $args[0] );
1558
+			if (isset($_wp_theme_features['html5']))
1559
+				$args[0] = array_merge($_wp_theme_features['html5'][0], $args[0]);
1560 1560
 			break;
1561 1561
 
1562 1562
 		case 'custom-header-uploads' :
1563
-			return add_theme_support( 'custom-header', array( 'uploads' => true ) );
1563
+			return add_theme_support('custom-header', array('uploads' => true));
1564 1564
 
1565 1565
 		case 'custom-header' :
1566
-			if ( ! is_array( $args ) )
1567
-				$args = array( 0 => array() );
1566
+			if ( ! is_array($args))
1567
+				$args = array(0 => array());
1568 1568
 
1569 1569
 			$defaults = array(
1570 1570
 				'default-image' => '',
@@ -1581,18 +1581,18 @@  discard block
 block discarded – undo
1581 1581
 				'admin-preview-callback' => '',
1582 1582
 			);
1583 1583
 
1584
-			$jit = isset( $args[0]['__jit'] );
1585
-			unset( $args[0]['__jit'] );
1584
+			$jit = isset($args[0]['__jit']);
1585
+			unset($args[0]['__jit']);
1586 1586
 
1587 1587
 			// Merge in data from previous add_theme_support() calls.
1588 1588
 			// The first value registered wins. (A child theme is set up first.)
1589
-			if ( isset( $_wp_theme_features['custom-header'] ) )
1590
-				$args[0] = wp_parse_args( $_wp_theme_features['custom-header'][0], $args[0] );
1589
+			if (isset($_wp_theme_features['custom-header']))
1590
+				$args[0] = wp_parse_args($_wp_theme_features['custom-header'][0], $args[0]);
1591 1591
 
1592 1592
 			// Load in the defaults at the end, as we need to insure first one wins.
1593 1593
 			// This will cause all constants to be defined, as each arg will then be set to the default.
1594
-			if ( $jit )
1595
-				$args[0] = wp_parse_args( $args[0], $defaults );
1594
+			if ($jit)
1595
+				$args[0] = wp_parse_args($args[0], $defaults);
1596 1596
 
1597 1597
 			// If a constant was defined, use that value. Otherwise, define the constant to ensure
1598 1598
 			// the constant is always accurate (and is not defined later,  overriding our value).
@@ -1600,48 +1600,48 @@  discard block
 block discarded – undo
1600 1600
 			// Once we get to wp_loaded (just-in-time), define any constants we haven't already.
1601 1601
 			// Constants are lame. Don't reference them. This is just for backwards compatibility.
1602 1602
 
1603
-			if ( defined( 'NO_HEADER_TEXT' ) )
1603
+			if (defined('NO_HEADER_TEXT'))
1604 1604
 				$args[0]['header-text'] = ! NO_HEADER_TEXT;
1605
-			elseif ( isset( $args[0]['header-text'] ) )
1606
-				define( 'NO_HEADER_TEXT', empty( $args[0]['header-text'] ) );
1605
+			elseif (isset($args[0]['header-text']))
1606
+				define('NO_HEADER_TEXT', empty($args[0]['header-text']));
1607 1607
 
1608
-			if ( defined( 'HEADER_IMAGE_WIDTH' ) )
1608
+			if (defined('HEADER_IMAGE_WIDTH'))
1609 1609
 				$args[0]['width'] = (int) HEADER_IMAGE_WIDTH;
1610
-			elseif ( isset( $args[0]['width'] ) )
1611
-				define( 'HEADER_IMAGE_WIDTH', (int) $args[0]['width'] );
1610
+			elseif (isset($args[0]['width']))
1611
+				define('HEADER_IMAGE_WIDTH', (int) $args[0]['width']);
1612 1612
 
1613
-			if ( defined( 'HEADER_IMAGE_HEIGHT' ) )
1613
+			if (defined('HEADER_IMAGE_HEIGHT'))
1614 1614
 				$args[0]['height'] = (int) HEADER_IMAGE_HEIGHT;
1615
-			elseif ( isset( $args[0]['height'] ) )
1616
-				define( 'HEADER_IMAGE_HEIGHT', (int) $args[0]['height'] );
1615
+			elseif (isset($args[0]['height']))
1616
+				define('HEADER_IMAGE_HEIGHT', (int) $args[0]['height']);
1617 1617
 
1618
-			if ( defined( 'HEADER_TEXTCOLOR' ) )
1618
+			if (defined('HEADER_TEXTCOLOR'))
1619 1619
 				$args[0]['default-text-color'] = HEADER_TEXTCOLOR;
1620
-			elseif ( isset( $args[0]['default-text-color'] ) )
1621
-				define( 'HEADER_TEXTCOLOR', $args[0]['default-text-color'] );
1620
+			elseif (isset($args[0]['default-text-color']))
1621
+				define('HEADER_TEXTCOLOR', $args[0]['default-text-color']);
1622 1622
 
1623
-			if ( defined( 'HEADER_IMAGE' ) )
1623
+			if (defined('HEADER_IMAGE'))
1624 1624
 				$args[0]['default-image'] = HEADER_IMAGE;
1625
-			elseif ( isset( $args[0]['default-image'] ) )
1626
-				define( 'HEADER_IMAGE', $args[0]['default-image'] );
1625
+			elseif (isset($args[0]['default-image']))
1626
+				define('HEADER_IMAGE', $args[0]['default-image']);
1627 1627
 
1628
-			if ( $jit && ! empty( $args[0]['default-image'] ) )
1628
+			if ($jit && ! empty($args[0]['default-image']))
1629 1629
 				$args[0]['random-default'] = false;
1630 1630
 
1631 1631
 			// If headers are supported, and we still don't have a defined width or height,
1632 1632
 			// we have implicit flex sizes.
1633
-			if ( $jit ) {
1634
-				if ( empty( $args[0]['width'] ) && empty( $args[0]['flex-width'] ) )
1633
+			if ($jit) {
1634
+				if (empty($args[0]['width']) && empty($args[0]['flex-width']))
1635 1635
 					$args[0]['flex-width'] = true;
1636
-				if ( empty( $args[0]['height'] ) && empty( $args[0]['flex-height'] ) )
1636
+				if (empty($args[0]['height']) && empty($args[0]['flex-height']))
1637 1637
 					$args[0]['flex-height'] = true;
1638 1638
 			}
1639 1639
 
1640 1640
 			break;
1641 1641
 
1642 1642
 		case 'custom-background' :
1643
-			if ( ! is_array( $args ) )
1644
-				$args = array( 0 => array() );
1643
+			if ( ! is_array($args))
1644
+				$args = array(0 => array());
1645 1645
 
1646 1646
 			$defaults = array(
1647 1647
 				'default-image'          => '',
@@ -1654,41 +1654,41 @@  discard block
 block discarded – undo
1654 1654
 				'admin-preview-callback' => '',
1655 1655
 			);
1656 1656
 
1657
-			$jit = isset( $args[0]['__jit'] );
1658
-			unset( $args[0]['__jit'] );
1657
+			$jit = isset($args[0]['__jit']);
1658
+			unset($args[0]['__jit']);
1659 1659
 
1660 1660
 			// Merge in data from previous add_theme_support() calls. The first value registered wins.
1661
-			if ( isset( $_wp_theme_features['custom-background'] ) )
1662
-				$args[0] = wp_parse_args( $_wp_theme_features['custom-background'][0], $args[0] );
1661
+			if (isset($_wp_theme_features['custom-background']))
1662
+				$args[0] = wp_parse_args($_wp_theme_features['custom-background'][0], $args[0]);
1663 1663
 
1664
-			if ( $jit )
1665
-				$args[0] = wp_parse_args( $args[0], $defaults );
1664
+			if ($jit)
1665
+				$args[0] = wp_parse_args($args[0], $defaults);
1666 1666
 
1667
-			if ( defined( 'BACKGROUND_COLOR' ) )
1667
+			if (defined('BACKGROUND_COLOR'))
1668 1668
 				$args[0]['default-color'] = BACKGROUND_COLOR;
1669
-			elseif ( isset( $args[0]['default-color'] ) || $jit )
1670
-				define( 'BACKGROUND_COLOR', $args[0]['default-color'] );
1669
+			elseif (isset($args[0]['default-color']) || $jit)
1670
+				define('BACKGROUND_COLOR', $args[0]['default-color']);
1671 1671
 
1672
-			if ( defined( 'BACKGROUND_IMAGE' ) )
1672
+			if (defined('BACKGROUND_IMAGE'))
1673 1673
 				$args[0]['default-image'] = BACKGROUND_IMAGE;
1674
-			elseif ( isset( $args[0]['default-image'] ) || $jit )
1675
-				define( 'BACKGROUND_IMAGE', $args[0]['default-image'] );
1674
+			elseif (isset($args[0]['default-image']) || $jit)
1675
+				define('BACKGROUND_IMAGE', $args[0]['default-image']);
1676 1676
 
1677 1677
 			break;
1678 1678
 
1679 1679
 		// Ensure that 'title-tag' is accessible in the admin.
1680 1680
 		case 'title-tag' :
1681 1681
 			// Can be called in functions.php but must happen before wp_loaded, i.e. not in header.php.
1682
-			if ( did_action( 'wp_loaded' ) ) {
1682
+			if (did_action('wp_loaded')) {
1683 1683
 				/* translators: 1: Theme support 2: hook name */
1684
-				_doing_it_wrong( "add_theme_support( 'title-tag' )", sprintf( __( 'Theme support for %1$s should be registered before the %2$s hook.' ),
1685
-					'<code>title-tag</code>', '<code>wp_loaded</code>' ), '4.1' );
1684
+				_doing_it_wrong("add_theme_support( 'title-tag' )", sprintf(__('Theme support for %1$s should be registered before the %2$s hook.'),
1685
+					'<code>title-tag</code>', '<code>wp_loaded</code>'), '4.1');
1686 1686
 
1687 1687
 				return false;
1688 1688
 			}
1689 1689
 	}
1690 1690
 
1691
-	$_wp_theme_features[ $feature ] = $args;
1691
+	$_wp_theme_features[$feature] = $args;
1692 1692
 }
1693 1693
 
1694 1694
 /**
@@ -1703,30 +1703,30 @@  discard block
 block discarded – undo
1703 1703
 function _custom_header_background_just_in_time() {
1704 1704
 	global $custom_image_header, $custom_background;
1705 1705
 
1706
-	if ( current_theme_supports( 'custom-header' ) ) {
1706
+	if (current_theme_supports('custom-header')) {
1707 1707
 		// In case any constants were defined after an add_custom_image_header() call, re-run.
1708
-		add_theme_support( 'custom-header', array( '__jit' => true ) );
1708
+		add_theme_support('custom-header', array('__jit' => true));
1709 1709
 
1710
-		$args = get_theme_support( 'custom-header' );
1711
-		if ( $args[0]['wp-head-callback'] )
1712
-			add_action( 'wp_head', $args[0]['wp-head-callback'] );
1710
+		$args = get_theme_support('custom-header');
1711
+		if ($args[0]['wp-head-callback'])
1712
+			add_action('wp_head', $args[0]['wp-head-callback']);
1713 1713
 
1714
-		if ( is_admin() ) {
1715
-			require_once( ABSPATH . 'wp-admin/custom-header.php' );
1716
-			$custom_image_header = new Custom_Image_Header( $args[0]['admin-head-callback'], $args[0]['admin-preview-callback'] );
1714
+		if (is_admin()) {
1715
+			require_once(ABSPATH.'wp-admin/custom-header.php');
1716
+			$custom_image_header = new Custom_Image_Header($args[0]['admin-head-callback'], $args[0]['admin-preview-callback']);
1717 1717
 		}
1718 1718
 	}
1719 1719
 
1720
-	if ( current_theme_supports( 'custom-background' ) ) {
1720
+	if (current_theme_supports('custom-background')) {
1721 1721
 		// In case any constants were defined after an add_custom_background() call, re-run.
1722
-		add_theme_support( 'custom-background', array( '__jit' => true ) );
1722
+		add_theme_support('custom-background', array('__jit' => true));
1723 1723
 
1724
-		$args = get_theme_support( 'custom-background' );
1725
-		add_action( 'wp_head', $args[0]['wp-head-callback'] );
1724
+		$args = get_theme_support('custom-background');
1725
+		add_action('wp_head', $args[0]['wp-head-callback']);
1726 1726
 
1727
-		if ( is_admin() ) {
1728
-			require_once( ABSPATH . 'wp-admin/custom-background.php' );
1729
-			$custom_background = new Custom_Background( $args[0]['admin-head-callback'], $args[0]['admin-preview-callback'] );
1727
+		if (is_admin()) {
1728
+			require_once(ABSPATH.'wp-admin/custom-background.php');
1729
+			$custom_background = new Custom_Background($args[0]['admin-head-callback'], $args[0]['admin-preview-callback']);
1730 1730
 		}
1731 1731
 	}
1732 1732
 }
@@ -1738,10 +1738,10 @@  discard block
 block discarded – undo
1738 1738
  * @access private
1739 1739
  */
1740 1740
 function _custom_logo_header_styles() {
1741
-	if ( ! current_theme_supports( 'custom-header', 'header-text' ) && get_theme_support( 'custom-logo', 'header-text' ) && ! get_theme_mod( 'header_text', true ) ) {
1742
-		$classes = (array) get_theme_support( 'custom-logo', 'header-text' );
1743
-		$classes = array_map( 'sanitize_html_class', $classes );
1744
-		$classes = '.' . implode( ', .', $classes );
1741
+	if ( ! current_theme_supports('custom-header', 'header-text') && get_theme_support('custom-logo', 'header-text') && ! get_theme_mod('header_text', true)) {
1742
+		$classes = (array) get_theme_support('custom-logo', 'header-text');
1743
+		$classes = array_map('sanitize_html_class', $classes);
1744
+		$classes = '.'.implode(', .', $classes);
1745 1745
 
1746 1746
 		?>
1747 1747
 		<!-- Custom Logo: hide header text -->
@@ -1765,25 +1765,25 @@  discard block
 block discarded – undo
1765 1765
  * @param string $feature the feature to check
1766 1766
  * @return mixed The array of extra arguments or the value for the registered feature.
1767 1767
  */
1768
-function get_theme_support( $feature ) {
1768
+function get_theme_support($feature) {
1769 1769
 	global $_wp_theme_features;
1770
-	if ( ! isset( $_wp_theme_features[ $feature ] ) )
1770
+	if ( ! isset($_wp_theme_features[$feature]))
1771 1771
 		return false;
1772 1772
 
1773
-	if ( func_num_args() <= 1 )
1774
-		return $_wp_theme_features[ $feature ];
1773
+	if (func_num_args() <= 1)
1774
+		return $_wp_theme_features[$feature];
1775 1775
 
1776
-	$args = array_slice( func_get_args(), 1 );
1777
-	switch ( $feature ) {
1776
+	$args = array_slice(func_get_args(), 1);
1777
+	switch ($feature) {
1778 1778
 		case 'custom-logo' :
1779 1779
 		case 'custom-header' :
1780 1780
 		case 'custom-background' :
1781
-			if ( isset( $_wp_theme_features[ $feature ][0][ $args[0] ] ) )
1782
-				return $_wp_theme_features[ $feature ][0][ $args[0] ];
1781
+			if (isset($_wp_theme_features[$feature][0][$args[0]]))
1782
+				return $_wp_theme_features[$feature][0][$args[0]];
1783 1783
 			return false;
1784 1784
 
1785 1785
 		default :
1786
-			return $_wp_theme_features[ $feature ];
1786
+			return $_wp_theme_features[$feature];
1787 1787
 	}
1788 1788
 }
1789 1789
 
@@ -1798,12 +1798,12 @@  discard block
 block discarded – undo
1798 1798
  * @param string $feature the feature being added
1799 1799
  * @return bool|void Whether feature was removed.
1800 1800
  */
1801
-function remove_theme_support( $feature ) {
1801
+function remove_theme_support($feature) {
1802 1802
 	// Blacklist: for internal registrations not used directly by themes.
1803
-	if ( in_array( $feature, array( 'editor-style', 'widgets', 'menus' ) ) )
1803
+	if (in_array($feature, array('editor-style', 'widgets', 'menus')))
1804 1804
 		return false;
1805 1805
 
1806
-	return _remove_theme_support( $feature );
1806
+	return _remove_theme_support($feature);
1807 1807
 }
1808 1808
 
1809 1809
 /**
@@ -1818,42 +1818,42 @@  discard block
 block discarded – undo
1818 1818
  *
1819 1819
  * @param string $feature
1820 1820
  */
1821
-function _remove_theme_support( $feature ) {
1821
+function _remove_theme_support($feature) {
1822 1822
 	global $_wp_theme_features;
1823 1823
 
1824
-	switch ( $feature ) {
1824
+	switch ($feature) {
1825 1825
 		case 'custom-header-uploads' :
1826
-			if ( ! isset( $_wp_theme_features['custom-header'] ) )
1826
+			if ( ! isset($_wp_theme_features['custom-header']))
1827 1827
 				return false;
1828
-			add_theme_support( 'custom-header', array( 'uploads' => false ) );
1828
+			add_theme_support('custom-header', array('uploads' => false));
1829 1829
 			return; // Do not continue - custom-header-uploads no longer exists.
1830 1830
 	}
1831 1831
 
1832
-	if ( ! isset( $_wp_theme_features[ $feature ] ) )
1832
+	if ( ! isset($_wp_theme_features[$feature]))
1833 1833
 		return false;
1834 1834
 
1835
-	switch ( $feature ) {
1835
+	switch ($feature) {
1836 1836
 		case 'custom-header' :
1837
-			if ( ! did_action( 'wp_loaded' ) )
1837
+			if ( ! did_action('wp_loaded'))
1838 1838
 				break;
1839
-			$support = get_theme_support( 'custom-header' );
1840
-			if ( $support[0]['wp-head-callback'] )
1841
-				remove_action( 'wp_head', $support[0]['wp-head-callback'] );
1842
-			remove_action( 'admin_menu', array( $GLOBALS['custom_image_header'], 'init' ) );
1843
-			unset( $GLOBALS['custom_image_header'] );
1839
+			$support = get_theme_support('custom-header');
1840
+			if ($support[0]['wp-head-callback'])
1841
+				remove_action('wp_head', $support[0]['wp-head-callback']);
1842
+			remove_action('admin_menu', array($GLOBALS['custom_image_header'], 'init'));
1843
+			unset($GLOBALS['custom_image_header']);
1844 1844
 			break;
1845 1845
 
1846 1846
 		case 'custom-background' :
1847
-			if ( ! did_action( 'wp_loaded' ) )
1847
+			if ( ! did_action('wp_loaded'))
1848 1848
 				break;
1849
-			$support = get_theme_support( 'custom-background' );
1850
-			remove_action( 'wp_head', $support[0]['wp-head-callback'] );
1851
-			remove_action( 'admin_menu', array( $GLOBALS['custom_background'], 'init' ) );
1852
-			unset( $GLOBALS['custom_background'] );
1849
+			$support = get_theme_support('custom-background');
1850
+			remove_action('wp_head', $support[0]['wp-head-callback']);
1851
+			remove_action('admin_menu', array($GLOBALS['custom_background'], 'init'));
1852
+			unset($GLOBALS['custom_background']);
1853 1853
 			break;
1854 1854
 	}
1855 1855
 
1856
-	unset( $_wp_theme_features[ $feature ] );
1856
+	unset($_wp_theme_features[$feature]);
1857 1857
 	return true;
1858 1858
 }
1859 1859
 
@@ -1867,30 +1867,30 @@  discard block
 block discarded – undo
1867 1867
  * @param string $feature the feature being checked
1868 1868
  * @return bool
1869 1869
  */
1870
-function current_theme_supports( $feature ) {
1870
+function current_theme_supports($feature) {
1871 1871
 	global $_wp_theme_features;
1872 1872
 
1873
-	if ( 'custom-header-uploads' == $feature )
1874
-		return current_theme_supports( 'custom-header', 'uploads' );
1873
+	if ('custom-header-uploads' == $feature)
1874
+		return current_theme_supports('custom-header', 'uploads');
1875 1875
 
1876
-	if ( !isset( $_wp_theme_features[$feature] ) )
1876
+	if ( ! isset($_wp_theme_features[$feature]))
1877 1877
 		return false;
1878 1878
 
1879 1879
 	// If no args passed then no extra checks need be performed
1880
-	if ( func_num_args() <= 1 )
1880
+	if (func_num_args() <= 1)
1881 1881
 		return true;
1882 1882
 
1883
-	$args = array_slice( func_get_args(), 1 );
1883
+	$args = array_slice(func_get_args(), 1);
1884 1884
 
1885
-	switch ( $feature ) {
1885
+	switch ($feature) {
1886 1886
 		case 'post-thumbnails':
1887 1887
 			// post-thumbnails can be registered for only certain content/post types by passing
1888 1888
 			// an array of types to add_theme_support(). If no array was passed, then
1889 1889
 			// any type is accepted
1890
-			if ( true === $_wp_theme_features[$feature] )  // Registered for all types
1890
+			if (true === $_wp_theme_features[$feature])  // Registered for all types
1891 1891
 				return true;
1892 1892
 			$content_type = $args[0];
1893
-			return in_array( $content_type, $_wp_theme_features[$feature][0] );
1893
+			return in_array($content_type, $_wp_theme_features[$feature][0]);
1894 1894
 
1895 1895
 		case 'html5':
1896 1896
 		case 'post-formats':
@@ -1900,13 +1900,13 @@  discard block
 block discarded – undo
1900 1900
 			// Specific areas of HTML5 support *must* be passed via an array to add_theme_support()
1901 1901
 
1902 1902
 			$type = $args[0];
1903
-			return in_array( $type, $_wp_theme_features[$feature][0] );
1903
+			return in_array($type, $_wp_theme_features[$feature][0]);
1904 1904
 
1905 1905
 		case 'custom-logo':
1906 1906
 		case 'custom-header':
1907 1907
 		case 'custom-background':
1908 1908
 			// Specific capabilities can be registered by passing an array to add_theme_support().
1909
-			return ( isset( $_wp_theme_features[ $feature ][0][ $args[0] ] ) && $_wp_theme_features[ $feature ][0][ $args[0] ] );
1909
+			return (isset($_wp_theme_features[$feature][0][$args[0]]) && $_wp_theme_features[$feature][0][$args[0]]);
1910 1910
 	}
1911 1911
 
1912 1912
 	/**
@@ -1922,7 +1922,7 @@  discard block
 block discarded – undo
1922 1922
 	 * @param array  $args    Array of arguments for the feature.
1923 1923
 	 * @param string $feature The theme feature.
1924 1924
 	 */
1925
-	return apply_filters( "current_theme_supports-{$feature}", true, $args, $_wp_theme_features[$feature] );
1925
+	return apply_filters("current_theme_supports-{$feature}", true, $args, $_wp_theme_features[$feature]);
1926 1926
 }
1927 1927
 
1928 1928
 /**
@@ -1934,9 +1934,9 @@  discard block
 block discarded – undo
1934 1934
  * @param string $include Path to the file.
1935 1935
  * @return bool True if the current theme supports the supplied feature, false otherwise.
1936 1936
  */
1937
-function require_if_theme_supports( $feature, $include ) {
1938
-	if ( current_theme_supports( $feature ) ) {
1939
-		require ( $include );
1937
+function require_if_theme_supports($feature, $include) {
1938
+	if (current_theme_supports($feature)) {
1939
+		require ($include);
1940 1940
 		return true;
1941 1941
 	}
1942 1942
 	return false;
@@ -1955,24 +1955,24 @@  discard block
 block discarded – undo
1955 1955
  *
1956 1956
  * @param int $id The attachment id.
1957 1957
  */
1958
-function _delete_attachment_theme_mod( $id ) {
1959
-	$attachment_image = wp_get_attachment_url( $id );
1958
+function _delete_attachment_theme_mod($id) {
1959
+	$attachment_image = wp_get_attachment_url($id);
1960 1960
 	$header_image     = get_header_image();
1961 1961
 	$background_image = get_background_image();
1962
-	$custom_logo_id   = get_theme_mod( 'custom_logo' );
1962
+	$custom_logo_id   = get_theme_mod('custom_logo');
1963 1963
 
1964
-	if ( $custom_logo_id && $custom_logo_id == $id ) {
1965
-		remove_theme_mod( 'custom_logo' );
1966
-		remove_theme_mod( 'header_text' );
1964
+	if ($custom_logo_id && $custom_logo_id == $id) {
1965
+		remove_theme_mod('custom_logo');
1966
+		remove_theme_mod('header_text');
1967 1967
 	}
1968 1968
 
1969
-	if ( $header_image && $header_image == $attachment_image ) {
1970
-		remove_theme_mod( 'header_image' );
1971
-		remove_theme_mod( 'header_image_data' );
1969
+	if ($header_image && $header_image == $attachment_image) {
1970
+		remove_theme_mod('header_image');
1971
+		remove_theme_mod('header_image_data');
1972 1972
 	}
1973 1973
 
1974
-	if ( $background_image && $background_image == $attachment_image ) {
1975
-		remove_theme_mod( 'background_image' );
1974
+	if ($background_image && $background_image == $attachment_image) {
1975
+		remove_theme_mod('background_image');
1976 1976
 	}
1977 1977
 }
1978 1978
 
@@ -1982,16 +1982,16 @@  discard block
 block discarded – undo
1982 1982
  * @since 3.3.0
1983 1983
  */
1984 1984
 function check_theme_switched() {
1985
-	if ( $stylesheet = get_option( 'theme_switched' ) ) {
1986
-		$old_theme = wp_get_theme( $stylesheet );
1985
+	if ($stylesheet = get_option('theme_switched')) {
1986
+		$old_theme = wp_get_theme($stylesheet);
1987 1987
 
1988 1988
 		// Prevent retrieve_widgets() from running since Customizer already called it up front
1989
-		if ( get_option( 'theme_switched_via_customizer' ) ) {
1990
-			remove_action( 'after_switch_theme', '_wp_sidebars_changed' );
1991
-			update_option( 'theme_switched_via_customizer', false );
1989
+		if (get_option('theme_switched_via_customizer')) {
1990
+			remove_action('after_switch_theme', '_wp_sidebars_changed');
1991
+			update_option('theme_switched_via_customizer', false);
1992 1992
 		}
1993 1993
 
1994
-		if ( $old_theme->exists() ) {
1994
+		if ($old_theme->exists()) {
1995 1995
 			/**
1996 1996
 			 * Fires on the first WP load after a theme switch if the old theme still exists.
1997 1997
 			 *
@@ -2005,14 +2005,14 @@  discard block
 block discarded – undo
2005 2005
 			 * @param string   $old_name  Old theme name.
2006 2006
 			 * @param WP_Theme $old_theme WP_Theme instance of the old theme.
2007 2007
 			 */
2008
-			do_action( 'after_switch_theme', $old_theme->get( 'Name' ), $old_theme );
2008
+			do_action('after_switch_theme', $old_theme->get('Name'), $old_theme);
2009 2009
 		} else {
2010 2010
 			/** This action is documented in wp-includes/theme.php */
2011
-			do_action( 'after_switch_theme', $stylesheet );
2011
+			do_action('after_switch_theme', $stylesheet);
2012 2012
 		}
2013 2013
 		flush_rewrite_rules();
2014 2014
 
2015
-		update_option( 'theme_switched', false );
2015
+		update_option('theme_switched', false);
2016 2016
 	}
2017 2017
 }
2018 2018
 
@@ -2030,13 +2030,13 @@  discard block
 block discarded – undo
2030 2030
  * @global WP_Customize_Manager $wp_customize
2031 2031
  */
2032 2032
 function _wp_customize_include() {
2033
-	if ( ! ( ( isset( $_REQUEST['wp_customize'] ) && 'on' == $_REQUEST['wp_customize'] )
2034
-		|| ( is_admin() && 'customize.php' == basename( $_SERVER['PHP_SELF'] ) )
2035
-	) ) {
2033
+	if ( ! ((isset($_REQUEST['wp_customize']) && 'on' == $_REQUEST['wp_customize'])
2034
+		|| (is_admin() && 'customize.php' == basename($_SERVER['PHP_SELF']))
2035
+	)) {
2036 2036
 		return;
2037 2037
 	}
2038 2038
 
2039
-	require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
2039
+	require_once ABSPATH.WPINC.'/class-wp-customize-manager.php';
2040 2040
 	$GLOBALS['wp_customize'] = new WP_Customize_Manager();
2041 2041
 }
2042 2042
 
@@ -2046,33 +2046,33 @@  discard block
 block discarded – undo
2046 2046
  * @since 3.4.0
2047 2047
  */
2048 2048
 function _wp_customize_loader_settings() {
2049
-	$admin_origin = parse_url( admin_url() );
2050
-	$home_origin  = parse_url( home_url() );
2051
-	$cross_domain = ( strtolower( $admin_origin[ 'host' ] ) != strtolower( $home_origin[ 'host' ] ) );
2049
+	$admin_origin = parse_url(admin_url());
2050
+	$home_origin  = parse_url(home_url());
2051
+	$cross_domain = (strtolower($admin_origin['host']) != strtolower($home_origin['host']));
2052 2052
 
2053 2053
 	$browser = array(
2054 2054
 		'mobile' => wp_is_mobile(),
2055
-		'ios'    => wp_is_mobile() && preg_match( '/iPad|iPod|iPhone/', $_SERVER['HTTP_USER_AGENT'] ),
2055
+		'ios'    => wp_is_mobile() && preg_match('/iPad|iPod|iPhone/', $_SERVER['HTTP_USER_AGENT']),
2056 2056
 	);
2057 2057
 
2058 2058
 	$settings = array(
2059
-		'url'           => esc_url( admin_url( 'customize.php' ) ),
2059
+		'url'           => esc_url(admin_url('customize.php')),
2060 2060
 		'isCrossDomain' => $cross_domain,
2061 2061
 		'browser'       => $browser,
2062 2062
 		'l10n'          => array(
2063
-			'saveAlert'       => __( 'The changes you made will be lost if you navigate away from this page.' ),
2064
-			'mainIframeTitle' => __( 'Customizer' ),
2063
+			'saveAlert'       => __('The changes you made will be lost if you navigate away from this page.'),
2064
+			'mainIframeTitle' => __('Customizer'),
2065 2065
 		),
2066 2066
 	);
2067 2067
 
2068
-	$script = 'var _wpCustomizeLoaderSettings = ' . wp_json_encode( $settings ) . ';';
2068
+	$script = 'var _wpCustomizeLoaderSettings = '.wp_json_encode($settings).';';
2069 2069
 
2070 2070
 	$wp_scripts = wp_scripts();
2071
-	$data = $wp_scripts->get_data( 'customize-loader', 'data' );
2072
-	if ( $data )
2071
+	$data = $wp_scripts->get_data('customize-loader', 'data');
2072
+	if ($data)
2073 2073
 		$script = "$data\n$script";
2074 2074
 
2075
-	$wp_scripts->add_data( 'customize-loader', 'data', $script );
2075
+	$wp_scripts->add_data('customize-loader', 'data', $script);
2076 2076
 }
2077 2077
 
2078 2078
 /**
@@ -2084,11 +2084,11 @@  discard block
 block discarded – undo
2084 2084
  * 	                         The theme's stylesheet will be urlencoded if necessary.
2085 2085
  * @return string
2086 2086
  */
2087
-function wp_customize_url( $stylesheet = null ) {
2088
-	$url = admin_url( 'customize.php' );
2089
-	if ( $stylesheet )
2090
-		$url .= '?theme=' . urlencode( $stylesheet );
2091
-	return esc_url( $url );
2087
+function wp_customize_url($stylesheet = null) {
2088
+	$url = admin_url('customize.php');
2089
+	if ($stylesheet)
2090
+		$url .= '?theme='.urlencode($stylesheet);
2091
+	return esc_url($url);
2092 2092
 }
2093 2093
 
2094 2094
 /**
@@ -2107,16 +2107,16 @@  discard block
 block discarded – undo
2107 2107
  * @since 3.4.0
2108 2108
  */
2109 2109
 function wp_customize_support_script() {
2110
-	$admin_origin = parse_url( admin_url() );
2111
-	$home_origin  = parse_url( home_url() );
2112
-	$cross_domain = ( strtolower( $admin_origin[ 'host' ] ) != strtolower( $home_origin[ 'host' ] ) );
2110
+	$admin_origin = parse_url(admin_url());
2111
+	$home_origin  = parse_url(home_url());
2112
+	$cross_domain = (strtolower($admin_origin['host']) != strtolower($home_origin['host']));
2113 2113
 
2114 2114
 	?>
2115 2115
 	<script type="text/javascript">
2116 2116
 		(function() {
2117 2117
 			var request, b = document.body, c = 'className', cs = 'customize-support', rcs = new RegExp('(^|\\s+)(no-)?'+cs+'(\\s+|$)');
2118 2118
 
2119
-<?php		if ( $cross_domain ): ?>
2119
+<?php		if ($cross_domain): ?>
2120 2120
 			request = (function(){ var xhr = new XMLHttpRequest(); return ('withCredentials' in xhr); })();
2121 2121
 <?php		else: ?>
2122 2122
 			request = true;
@@ -2141,5 +2141,5 @@  discard block
 block discarded – undo
2141 2141
 function is_customize_preview() {
2142 2142
 	global $wp_customize;
2143 2143
 
2144
-	return ( $wp_customize instanceof WP_Customize_Manager ) && $wp_customize->is_preview();
2144
+	return ($wp_customize instanceof WP_Customize_Manager) && $wp_customize->is_preview();
2145 2145
 }
Please login to merge, or discard this patch.
Braces   +307 added lines, -217 removed lines patch added patch discarded remove patch
@@ -41,41 +41,46 @@  discard block
 block discarded – undo
41 41
 		$current_theme = get_stylesheet();
42 42
 		if ( isset( $theme_directories[ $current_theme ] ) ) {
43 43
 			$root_of_current_theme = get_raw_theme_root( $current_theme );
44
-			if ( ! in_array( $root_of_current_theme, $wp_theme_directories ) )
45
-				$root_of_current_theme = WP_CONTENT_DIR . $root_of_current_theme;
44
+			if ( ! in_array( $root_of_current_theme, $wp_theme_directories ) ) {
45
+							$root_of_current_theme = WP_CONTENT_DIR . $root_of_current_theme;
46
+			}
46 47
 			$theme_directories[ $current_theme ]['theme_root'] = $root_of_current_theme;
47 48
 		}
48 49
 	}
49 50
 
50
-	if ( empty( $theme_directories ) )
51
-		return array();
51
+	if ( empty( $theme_directories ) ) {
52
+			return array();
53
+	}
52 54
 
53 55
 	if ( is_multisite() && null !== $args['allowed'] ) {
54 56
 		$allowed = $args['allowed'];
55
-		if ( 'network' === $allowed )
56
-			$theme_directories = array_intersect_key( $theme_directories, WP_Theme::get_allowed_on_network() );
57
-		elseif ( 'site' === $allowed )
58
-			$theme_directories = array_intersect_key( $theme_directories, WP_Theme::get_allowed_on_site( $args['blog_id'] ) );
59
-		elseif ( $allowed )
60
-			$theme_directories = array_intersect_key( $theme_directories, WP_Theme::get_allowed( $args['blog_id'] ) );
61
-		else
62
-			$theme_directories = array_diff_key( $theme_directories, WP_Theme::get_allowed( $args['blog_id'] ) );
57
+		if ( 'network' === $allowed ) {
58
+					$theme_directories = array_intersect_key( $theme_directories, WP_Theme::get_allowed_on_network() );
59
+		} elseif ( 'site' === $allowed ) {
60
+					$theme_directories = array_intersect_key( $theme_directories, WP_Theme::get_allowed_on_site( $args['blog_id'] ) );
61
+		} elseif ( $allowed ) {
62
+					$theme_directories = array_intersect_key( $theme_directories, WP_Theme::get_allowed( $args['blog_id'] ) );
63
+		} else {
64
+					$theme_directories = array_diff_key( $theme_directories, WP_Theme::get_allowed( $args['blog_id'] ) );
65
+		}
63 66
 	}
64 67
 
65 68
 	$themes = array();
66 69
 	static $_themes = array();
67 70
 
68 71
 	foreach ( $theme_directories as $theme => $theme_root ) {
69
-		if ( isset( $_themes[ $theme_root['theme_root'] . '/' . $theme ] ) )
70
-			$themes[ $theme ] = $_themes[ $theme_root['theme_root'] . '/' . $theme ];
71
-		else
72
-			$themes[ $theme ] = $_themes[ $theme_root['theme_root'] . '/' . $theme ] = new WP_Theme( $theme, $theme_root['theme_root'] );
72
+		if ( isset( $_themes[ $theme_root['theme_root'] . '/' . $theme ] ) ) {
73
+					$themes[ $theme ] = $_themes[ $theme_root['theme_root'] . '/' . $theme ];
74
+		} else {
75
+					$themes[ $theme ] = $_themes[ $theme_root['theme_root'] . '/' . $theme ] = new WP_Theme( $theme, $theme_root['theme_root'] );
76
+		}
73 77
 	}
74 78
 
75 79
 	if ( null !== $args['errors'] ) {
76 80
 		foreach ( $themes as $theme => $wp_theme ) {
77
-			if ( $wp_theme->errors() != $args['errors'] )
78
-				unset( $themes[ $theme ] );
81
+			if ( $wp_theme->errors() != $args['errors'] ) {
82
+							unset( $themes[ $theme ] );
83
+			}
79 84
 		}
80 85
 	}
81 86
 
@@ -97,15 +102,17 @@  discard block
 block discarded – undo
97 102
 function wp_get_theme( $stylesheet = null, $theme_root = null ) {
98 103
 	global $wp_theme_directories;
99 104
 
100
-	if ( empty( $stylesheet ) )
101
-		$stylesheet = get_stylesheet();
105
+	if ( empty( $stylesheet ) ) {
106
+			$stylesheet = get_stylesheet();
107
+	}
102 108
 
103 109
 	if ( empty( $theme_root ) ) {
104 110
 		$theme_root = get_raw_theme_root( $stylesheet );
105
-		if ( false === $theme_root )
106
-			$theme_root = WP_CONTENT_DIR . '/themes';
107
-		elseif ( ! in_array( $theme_root, (array) $wp_theme_directories ) )
108
-			$theme_root = WP_CONTENT_DIR . $theme_root;
111
+		if ( false === $theme_root ) {
112
+					$theme_root = WP_CONTENT_DIR . '/themes';
113
+		} elseif ( ! in_array( $theme_root, (array) $wp_theme_directories ) ) {
114
+					$theme_root = WP_CONTENT_DIR . $theme_root;
115
+		}
109 116
 	}
110 117
 
111 118
 	return new WP_Theme( $stylesheet, $theme_root );
@@ -118,12 +125,14 @@  discard block
 block discarded – undo
118 125
  * @param bool $clear_update_cache Whether to clear the Theme updates cache
119 126
  */
120 127
 function wp_clean_themes_cache( $clear_update_cache = true ) {
121
-	if ( $clear_update_cache )
122
-		delete_site_transient( 'update_themes' );
128
+	if ( $clear_update_cache ) {
129
+			delete_site_transient( 'update_themes' );
130
+	}
123 131
 	search_theme_directories( true );
124
-	foreach ( wp_get_themes( array( 'errors' => null ) ) as $theme )
125
-		$theme->cache_delete();
126
-}
132
+	foreach ( wp_get_themes( array( 'errors' => null ) ) as $theme ) {
133
+			$theme->cache_delete();
134
+	}
135
+	}
127 136
 
128 137
 /**
129 138
  * Whether a child theme is in use.
@@ -257,12 +266,13 @@  discard block
 block discarded – undo
257 266
 	$stylesheet_dir_uri = get_stylesheet_directory_uri();
258 267
 	$dir = get_stylesheet_directory();
259 268
 	$locale = get_locale();
260
-	if ( file_exists("$dir/$locale.css") )
261
-		$stylesheet_uri = "$stylesheet_dir_uri/$locale.css";
262
-	elseif ( !empty($wp_locale->text_direction) && file_exists("$dir/{$wp_locale->text_direction}.css") )
263
-		$stylesheet_uri = "$stylesheet_dir_uri/{$wp_locale->text_direction}.css";
264
-	else
265
-		$stylesheet_uri = '';
269
+	if ( file_exists("$dir/$locale.css") ) {
270
+			$stylesheet_uri = "$stylesheet_dir_uri/$locale.css";
271
+	} elseif ( !empty($wp_locale->text_direction) && file_exists("$dir/{$wp_locale->text_direction}.css") ) {
272
+			$stylesheet_uri = "$stylesheet_dir_uri/{$wp_locale->text_direction}.css";
273
+	} else {
274
+			$stylesheet_uri = '';
275
+	}
266 276
 	/**
267 277
 	 * Filter the localized stylesheet URI.
268 278
 	 *
@@ -352,8 +362,9 @@  discard block
 block discarded – undo
352 362
 function get_theme_roots() {
353 363
 	global $wp_theme_directories;
354 364
 
355
-	if ( count($wp_theme_directories) <= 1 )
356
-		return '/themes';
365
+	if ( count($wp_theme_directories) <= 1 ) {
366
+			return '/themes';
367
+	}
357 368
 
358 369
 	$theme_roots = get_site_transient( 'theme_roots' );
359 370
 	if ( false === $theme_roots ) {
@@ -412,11 +423,13 @@  discard block
 block discarded – undo
412 423
 	global $wp_theme_directories;
413 424
 	static $found_themes = null;
414 425
 
415
-	if ( empty( $wp_theme_directories ) )
416
-		return false;
426
+	if ( empty( $wp_theme_directories ) ) {
427
+			return false;
428
+	}
417 429
 
418
-	if ( ! $force && isset( $found_themes ) )
419
-		return $found_themes;
430
+	if ( ! $force && isset( $found_themes ) ) {
431
+			return $found_themes;
432
+	}
420 433
 
421 434
 	$found_themes = array();
422 435
 
@@ -427,10 +440,11 @@  discard block
 block discarded – undo
427 440
 	// We always want to return absolute, but we need to cache relative
428 441
 	// to use in get_theme_root().
429 442
 	foreach ( $wp_theme_directories as $theme_root ) {
430
-		if ( 0 === strpos( $theme_root, WP_CONTENT_DIR ) )
431
-			$relative_theme_roots[ str_replace( WP_CONTENT_DIR, '', $theme_root ) ] = $theme_root;
432
-		else
433
-			$relative_theme_roots[ $theme_root ] = $theme_root;
443
+		if ( 0 === strpos( $theme_root, WP_CONTENT_DIR ) ) {
444
+					$relative_theme_roots[ str_replace( WP_CONTENT_DIR, '', $theme_root ) ] = $theme_root;
445
+		} else {
446
+					$relative_theme_roots[ $theme_root ] = $theme_root;
447
+		}
434 448
 	}
435 449
 
436 450
 	/**
@@ -446,8 +460,9 @@  discard block
 block discarded – undo
446 460
 		if ( is_array( $cached_roots ) ) {
447 461
 			foreach ( $cached_roots as $theme_dir => $theme_root ) {
448 462
 				// A cached theme root is no longer around, so skip it.
449
-				if ( ! isset( $relative_theme_roots[ $theme_root ] ) )
450
-					continue;
463
+				if ( ! isset( $relative_theme_roots[ $theme_root ] ) ) {
464
+									continue;
465
+				}
451 466
 				$found_themes[ $theme_dir ] = array(
452 467
 					'theme_file' => $theme_dir . '/style.css',
453 468
 					'theme_root' => $relative_theme_roots[ $theme_root ], // Convert relative to absolute.
@@ -455,8 +470,10 @@  discard block
 block discarded – undo
455 470
 			}
456 471
 			return $found_themes;
457 472
 		}
458
-		if ( ! is_int( $cache_expiration ) )
459
-			$cache_expiration = 1800; // half hour
473
+		if ( ! is_int( $cache_expiration ) ) {
474
+					$cache_expiration = 1800;
475
+		}
476
+		// half hour
460 477
 	} else {
461 478
 		$cache_expiration = 1800; // half hour
462 479
 	}
@@ -471,8 +488,9 @@  discard block
 block discarded – undo
471 488
 			continue;
472 489
 		}
473 490
 		foreach ( $dirs as $dir ) {
474
-			if ( ! is_dir( $theme_root . '/' . $dir ) || $dir[0] == '.' || $dir == 'CVS' )
475
-				continue;
491
+			if ( ! is_dir( $theme_root . '/' . $dir ) || $dir[0] == '.' || $dir == 'CVS' ) {
492
+							continue;
493
+			}
476 494
 			if ( file_exists( $theme_root . '/' . $dir . '/style.css' ) ) {
477 495
 				// wp-content/themes/a-single-theme
478 496
 				// wp-content/themes is $theme_root, a-single-theme is $dir
@@ -490,10 +508,12 @@  discard block
 block discarded – undo
490 508
 					continue;
491 509
 				}
492 510
 				foreach ( $sub_dirs as $sub_dir ) {
493
-					if ( ! is_dir( $theme_root . '/' . $dir . '/' . $sub_dir ) || $dir[0] == '.' || $dir == 'CVS' )
494
-						continue;
495
-					if ( ! file_exists( $theme_root . '/' . $dir . '/' . $sub_dir . '/style.css' ) )
496
-						continue;
511
+					if ( ! is_dir( $theme_root . '/' . $dir . '/' . $sub_dir ) || $dir[0] == '.' || $dir == 'CVS' ) {
512
+											continue;
513
+					}
514
+					if ( ! file_exists( $theme_root . '/' . $dir . '/' . $sub_dir . '/style.css' ) ) {
515
+											continue;
516
+					}
497 517
 					$found_themes[ $dir . '/' . $sub_dir ] = array(
498 518
 						'theme_file' => $dir . '/' . $sub_dir . '/style.css',
499 519
 						'theme_root' => $theme_root,
@@ -502,11 +522,12 @@  discard block
 block discarded – undo
502 522
 				}
503 523
 				// Never mind the above, it's just a theme missing a style.css.
504 524
 				// Return it; WP_Theme will catch the error.
505
-				if ( ! $found_theme )
506
-					$found_themes[ $dir ] = array(
525
+				if ( ! $found_theme ) {
526
+									$found_themes[ $dir ] = array(
507 527
 						'theme_file' => $dir . '/style.css',
508 528
 						'theme_root' => $theme_root,
509 529
 					);
530
+				}
510 531
 			}
511 532
 		}
512 533
 	}
@@ -520,8 +541,9 @@  discard block
 block discarded – undo
520 541
 		$theme_roots[ $theme_dir ] = $relative_theme_roots[ $theme_data['theme_root'] ]; // Convert absolute to relative.
521 542
 	}
522 543
 
523
-	if ( $theme_roots != get_site_transient( 'theme_roots' ) )
524
-		set_site_transient( 'theme_roots', $theme_roots, $cache_expiration );
544
+	if ( $theme_roots != get_site_transient( 'theme_roots' ) ) {
545
+			set_site_transient( 'theme_roots', $theme_roots, $cache_expiration );
546
+	}
525 547
 
526 548
 	return $found_themes;
527 549
 }
@@ -544,8 +566,9 @@  discard block
 block discarded – undo
544 566
 	if ( $stylesheet_or_template && $theme_root = get_raw_theme_root( $stylesheet_or_template ) ) {
545 567
 		// Always prepend WP_CONTENT_DIR unless the root currently registered as a theme directory.
546 568
 		// This gives relative theme roots the benefit of the doubt when things go haywire.
547
-		if ( ! in_array( $theme_root, (array) $wp_theme_directories ) )
548
-			$theme_root = WP_CONTENT_DIR . $theme_root;
569
+		if ( ! in_array( $theme_root, (array) $wp_theme_directories ) ) {
570
+					$theme_root = WP_CONTENT_DIR . $theme_root;
571
+		}
549 572
 	} else {
550 573
 		$theme_root = WP_CONTENT_DIR . '/themes';
551 574
 	}
@@ -578,20 +601,22 @@  discard block
 block discarded – undo
578 601
 function get_theme_root_uri( $stylesheet_or_template = false, $theme_root = false ) {
579 602
 	global $wp_theme_directories;
580 603
 
581
-	if ( $stylesheet_or_template && ! $theme_root )
582
-		$theme_root = get_raw_theme_root( $stylesheet_or_template );
604
+	if ( $stylesheet_or_template && ! $theme_root ) {
605
+			$theme_root = get_raw_theme_root( $stylesheet_or_template );
606
+	}
583 607
 
584 608
 	if ( $stylesheet_or_template && $theme_root ) {
585 609
 		if ( in_array( $theme_root, (array) $wp_theme_directories ) ) {
586 610
 			// Absolute path. Make an educated guess. YMMV -- but note the filter below.
587
-			if ( 0 === strpos( $theme_root, WP_CONTENT_DIR ) )
588
-				$theme_root_uri = content_url( str_replace( WP_CONTENT_DIR, '', $theme_root ) );
589
-			elseif ( 0 === strpos( $theme_root, ABSPATH ) )
590
-				$theme_root_uri = site_url( str_replace( ABSPATH, '', $theme_root ) );
591
-			elseif ( 0 === strpos( $theme_root, WP_PLUGIN_DIR ) || 0 === strpos( $theme_root, WPMU_PLUGIN_DIR ) )
592
-				$theme_root_uri = plugins_url( basename( $theme_root ), $theme_root );
593
-			else
594
-				$theme_root_uri = $theme_root;
611
+			if ( 0 === strpos( $theme_root, WP_CONTENT_DIR ) ) {
612
+							$theme_root_uri = content_url( str_replace( WP_CONTENT_DIR, '', $theme_root ) );
613
+			} elseif ( 0 === strpos( $theme_root, ABSPATH ) ) {
614
+							$theme_root_uri = site_url( str_replace( ABSPATH, '', $theme_root ) );
615
+			} elseif ( 0 === strpos( $theme_root, WP_PLUGIN_DIR ) || 0 === strpos( $theme_root, WPMU_PLUGIN_DIR ) ) {
616
+							$theme_root_uri = plugins_url( basename( $theme_root ), $theme_root );
617
+			} else {
618
+							$theme_root_uri = $theme_root;
619
+			}
595 620
 		} else {
596 621
 			$theme_root_uri = content_url( $theme_root );
597 622
 		}
@@ -626,23 +651,26 @@  discard block
 block discarded – undo
626 651
 function get_raw_theme_root( $stylesheet_or_template, $skip_cache = false ) {
627 652
 	global $wp_theme_directories;
628 653
 
629
-	if ( count($wp_theme_directories) <= 1 )
630
-		return '/themes';
654
+	if ( count($wp_theme_directories) <= 1 ) {
655
+			return '/themes';
656
+	}
631 657
 
632 658
 	$theme_root = false;
633 659
 
634 660
 	// If requesting the root for the current theme, consult options to avoid calling get_theme_roots()
635 661
 	if ( ! $skip_cache ) {
636
-		if ( get_option('stylesheet') == $stylesheet_or_template )
637
-			$theme_root = get_option('stylesheet_root');
638
-		elseif ( get_option('template') == $stylesheet_or_template )
639
-			$theme_root = get_option('template_root');
662
+		if ( get_option('stylesheet') == $stylesheet_or_template ) {
663
+					$theme_root = get_option('stylesheet_root');
664
+		} elseif ( get_option('template') == $stylesheet_or_template ) {
665
+					$theme_root = get_option('template_root');
666
+		}
640 667
 	}
641 668
 
642 669
 	if ( empty($theme_root) ) {
643 670
 		$theme_roots = get_theme_roots();
644
-		if ( !empty($theme_roots[$stylesheet_or_template]) )
645
-			$theme_root = $theme_roots[$stylesheet_or_template];
671
+		if ( !empty($theme_roots[$stylesheet_or_template]) ) {
672
+					$theme_root = $theme_roots[$stylesheet_or_template];
673
+		}
646 674
 	}
647 675
 
648 676
 	return $theme_root;
@@ -655,8 +683,9 @@  discard block
 block discarded – undo
655 683
  */
656 684
 function locale_stylesheet() {
657 685
 	$stylesheet = get_locale_stylesheet_uri();
658
-	if ( empty($stylesheet) )
659
-		return;
686
+	if ( empty($stylesheet) ) {
687
+			return;
688
+	}
660 689
 	echo '<link rel="stylesheet" href="' . $stylesheet . '" type="text/css" media="screen" />';
661 690
 }
662 691
 
@@ -776,8 +805,9 @@  discard block
 block discarded – undo
776 805
 	 *
777 806
 	 * @param bool $validate Whether to validate the current theme. Default true.
778 807
 	 */
779
-	if ( wp_installing() || ! apply_filters( 'validate_current_theme', true ) )
780
-		return true;
808
+	if ( wp_installing() || ! apply_filters( 'validate_current_theme', true ) ) {
809
+			return true;
810
+	}
781 811
 
782 812
 	if ( ! file_exists( get_template_directory() . '/index.php' ) ) {
783 813
 		// Invalid.
@@ -826,8 +856,9 @@  discard block
 block discarded – undo
826 856
 	$mods = get_option( "theme_mods_$theme_slug" );
827 857
 	if ( false === $mods ) {
828 858
 		$theme_name = get_option( 'current_theme' );
829
-		if ( false === $theme_name )
830
-			$theme_name = wp_get_theme()->get('Name');
859
+		if ( false === $theme_name ) {
860
+					$theme_name = wp_get_theme()->get('Name');
861
+		}
831 862
 		$mods = get_option( "mods_$theme_name" ); // Deprecated location.
832 863
 		if ( is_admin() && false !== $mods ) {
833 864
 			update_option( "theme_mods_$theme_slug", $mods );
@@ -870,8 +901,9 @@  discard block
 block discarded – undo
870 901
 		return apply_filters( "theme_mod_{$name}", $mods[$name] );
871 902
 	}
872 903
 
873
-	if ( is_string( $default ) )
874
-		$default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() );
904
+	if ( is_string( $default ) ) {
905
+			$default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() );
906
+	}
875 907
 
876 908
 	/** This filter is documented in wp-includes/theme.php */
877 909
 	return apply_filters( "theme_mod_{$name}", $default );
@@ -920,8 +952,9 @@  discard block
 block discarded – undo
920 952
 function remove_theme_mod( $name ) {
921 953
 	$mods = get_theme_mods();
922 954
 
923
-	if ( ! isset( $mods[ $name ] ) )
924
-		return;
955
+	if ( ! isset( $mods[ $name ] ) ) {
956
+			return;
957
+	}
925 958
 
926 959
 	unset( $mods[ $name ] );
927 960
 
@@ -943,8 +976,9 @@  discard block
 block discarded – undo
943 976
 
944 977
 	// Old style.
945 978
 	$theme_name = get_option( 'current_theme' );
946
-	if ( false === $theme_name )
947
-		$theme_name = wp_get_theme()->get('Name');
979
+	if ( false === $theme_name ) {
980
+			$theme_name = wp_get_theme()->get('Name');
981
+	}
948 982
 	delete_option( 'mods_' . $theme_name );
949 983
 }
950 984
 
@@ -976,8 +1010,9 @@  discard block
 block discarded – undo
976 1010
  * @return bool
977 1011
  */
978 1012
 function display_header_text() {
979
-	if ( ! current_theme_supports( 'custom-header', 'header-text' ) )
980
-		return false;
1013
+	if ( ! current_theme_supports( 'custom-header', 'header-text' ) ) {
1014
+			return false;
1015
+	}
981 1016
 
982 1017
 	$text_color = get_theme_mod( 'header_textcolor', get_theme_support( 'custom-header', 'default-text-color' ) );
983 1018
 	return 'blank' !== $text_color;
@@ -1006,11 +1041,13 @@  discard block
 block discarded – undo
1006 1041
 function get_header_image() {
1007 1042
 	$url = get_theme_mod( 'header_image', get_theme_support( 'custom-header', 'default-image' ) );
1008 1043
 
1009
-	if ( 'remove-header' == $url )
1010
-		return false;
1044
+	if ( 'remove-header' == $url ) {
1045
+			return false;
1046
+	}
1011 1047
 
1012
-	if ( is_random_header_image() )
1013
-		$url = get_random_header_image();
1048
+	if ( is_random_header_image() ) {
1049
+			$url = get_random_header_image();
1050
+	}
1014 1051
 
1015 1052
 	return esc_url_raw( set_url_scheme( $url ) );
1016 1053
 }
@@ -1112,19 +1149,21 @@  discard block
 block discarded – undo
1112 1149
 		$header_image_mod = get_theme_mod( 'header_image', '' );
1113 1150
 		$headers = array();
1114 1151
 
1115
-		if ( 'random-uploaded-image' == $header_image_mod )
1116
-			$headers = get_uploaded_header_images();
1117
-		elseif ( ! empty( $_wp_default_headers ) ) {
1152
+		if ( 'random-uploaded-image' == $header_image_mod ) {
1153
+					$headers = get_uploaded_header_images();
1154
+		} elseif ( ! empty( $_wp_default_headers ) ) {
1118 1155
 			if ( 'random-default-image' == $header_image_mod ) {
1119 1156
 				$headers = $_wp_default_headers;
1120 1157
 			} else {
1121
-				if ( current_theme_supports( 'custom-header', 'random-default' ) )
1122
-					$headers = $_wp_default_headers;
1158
+				if ( current_theme_supports( 'custom-header', 'random-default' ) ) {
1159
+									$headers = $_wp_default_headers;
1160
+				}
1123 1161
 			}
1124 1162
 		}
1125 1163
 
1126
-		if ( empty( $headers ) )
1127
-			return new stdClass;
1164
+		if ( empty( $headers ) ) {
1165
+					return new stdClass;
1166
+		}
1128 1167
 
1129 1168
 		$_wp_random_header = (object) $headers[ array_rand( $headers ) ];
1130 1169
 
@@ -1143,8 +1182,9 @@  discard block
 block discarded – undo
1143 1182
  */
1144 1183
 function get_random_header_image() {
1145 1184
 	$random_image = _get_random_header_data();
1146
-	if ( empty( $random_image->url ) )
1147
-		return '';
1185
+	if ( empty( $random_image->url ) ) {
1186
+			return '';
1187
+	}
1148 1188
 	return $random_image->url;
1149 1189
 }
1150 1190
 
@@ -1164,13 +1204,15 @@  discard block
 block discarded – undo
1164 1204
 	$header_image_mod = get_theme_mod( 'header_image', get_theme_support( 'custom-header', 'default-image' ) );
1165 1205
 
1166 1206
 	if ( 'any' == $type ) {
1167
-		if ( 'random-default-image' == $header_image_mod || 'random-uploaded-image' == $header_image_mod || ( '' != get_random_header_image() && empty( $header_image_mod ) ) )
1168
-			return true;
1207
+		if ( 'random-default-image' == $header_image_mod || 'random-uploaded-image' == $header_image_mod || ( '' != get_random_header_image() && empty( $header_image_mod ) ) ) {
1208
+					return true;
1209
+		}
1169 1210
 	} else {
1170
-		if ( "random-$type-image" == $header_image_mod )
1171
-			return true;
1172
-		elseif ( 'default' == $type && empty( $header_image_mod ) && '' != get_random_header_image() )
1173
-			return true;
1211
+		if ( "random-$type-image" == $header_image_mod ) {
1212
+					return true;
1213
+		} elseif ( 'default' == $type && empty( $header_image_mod ) && '' != get_random_header_image() ) {
1214
+					return true;
1215
+		}
1174 1216
 	}
1175 1217
 
1176 1218
 	return false;
@@ -1201,8 +1243,9 @@  discard block
 block discarded – undo
1201 1243
 	// @todo caching
1202 1244
 	$headers = get_posts( array( 'post_type' => 'attachment', 'meta_key' => '_wp_attachment_is_custom_header', 'meta_value' => get_option('stylesheet'), 'orderby' => 'none', 'nopaging' => true ) );
1203 1245
 
1204
-	if ( empty( $headers ) )
1205
-		return array();
1246
+	if ( empty( $headers ) ) {
1247
+			return array();
1248
+	}
1206 1249
 
1207 1250
 	foreach ( (array) $headers as $header ) {
1208 1251
 		$url = esc_url_raw( wp_get_attachment_url( $header->ID ) );
@@ -1215,10 +1258,12 @@  discard block
 block discarded – undo
1215 1258
 		$header_images[$header_index]['thumbnail_url'] = $url;
1216 1259
 		$header_images[$header_index]['alt_text'] = get_post_meta( $header->ID, '_wp_attachment_image_alt', true );
1217 1260
 
1218
-		if ( isset( $header_data['width'] ) )
1219
-			$header_images[$header_index]['width'] = $header_data['width'];
1220
-		if ( isset( $header_data['height'] ) )
1221
-			$header_images[$header_index]['height'] = $header_data['height'];
1261
+		if ( isset( $header_data['width'] ) ) {
1262
+					$header_images[$header_index]['width'] = $header_data['width'];
1263
+		}
1264
+		if ( isset( $header_data['height'] ) ) {
1265
+					$header_images[$header_index]['height'] = $header_data['height'];
1266
+		}
1222 1267
 	}
1223 1268
 
1224 1269
 	return $header_images;
@@ -1367,8 +1412,9 @@  discard block
 block discarded – undo
1367 1412
 		$color = false;
1368 1413
 	}
1369 1414
 
1370
-	if ( ! $background && ! $color )
1371
-		return;
1415
+	if ( ! $background && ! $color ) {
1416
+			return;
1417
+	}
1372 1418
 
1373 1419
 	$style = $color ? "background-color: #$color;" : '';
1374 1420
 
@@ -1376,18 +1422,21 @@  discard block
 block discarded – undo
1376 1422
 		$image = " background-image: url('$background');";
1377 1423
 
1378 1424
 		$repeat = get_theme_mod( 'background_repeat', get_theme_support( 'custom-background', 'default-repeat' ) );
1379
-		if ( ! in_array( $repeat, array( 'no-repeat', 'repeat-x', 'repeat-y', 'repeat' ) ) )
1380
-			$repeat = 'repeat';
1425
+		if ( ! in_array( $repeat, array( 'no-repeat', 'repeat-x', 'repeat-y', 'repeat' ) ) ) {
1426
+					$repeat = 'repeat';
1427
+		}
1381 1428
 		$repeat = " background-repeat: $repeat;";
1382 1429
 
1383 1430
 		$position = get_theme_mod( 'background_position_x', get_theme_support( 'custom-background', 'default-position-x' ) );
1384
-		if ( ! in_array( $position, array( 'center', 'right', 'left' ) ) )
1385
-			$position = 'left';
1431
+		if ( ! in_array( $position, array( 'center', 'right', 'left' ) ) ) {
1432
+					$position = 'left';
1433
+		}
1386 1434
 		$position = " background-position: top $position;";
1387 1435
 
1388 1436
 		$attachment = get_theme_mod( 'background_attachment', get_theme_support( 'custom-background', 'default-attachment' ) );
1389
-		if ( ! in_array( $attachment, array( 'fixed', 'scroll' ) ) )
1390
-			$attachment = 'scroll';
1437
+		if ( ! in_array( $attachment, array( 'fixed', 'scroll' ) ) ) {
1438
+					$attachment = 'scroll';
1439
+		}
1391 1440
 		$attachment = " background-attachment: $attachment;";
1392 1441
 
1393 1442
 		$style .= $image . $repeat . $position . $attachment;
@@ -1424,8 +1473,9 @@  discard block
 block discarded – undo
1424 1473
 function add_editor_style( $stylesheet = 'editor-style.css' ) {
1425 1474
 	add_theme_support( 'editor-style' );
1426 1475
 
1427
-	if ( ! is_admin() )
1428
-		return;
1476
+	if ( ! is_admin() ) {
1477
+			return;
1478
+	}
1429 1479
 
1430 1480
 	global $editor_styles;
1431 1481
 	$editor_styles = (array) $editor_styles;
@@ -1448,11 +1498,13 @@  discard block
 block discarded – undo
1448 1498
  * @return bool True on success, false if there were no stylesheets to remove.
1449 1499
  */
1450 1500
 function remove_editor_styles() {
1451
-	if ( ! current_theme_supports( 'editor-style' ) )
1452
-		return false;
1501
+	if ( ! current_theme_supports( 'editor-style' ) ) {
1502
+			return false;
1503
+	}
1453 1504
 	_remove_theme_support( 'editor-style' );
1454
-	if ( is_admin() )
1455
-		$GLOBALS['editor_styles'] = array();
1505
+	if ( is_admin() ) {
1506
+			$GLOBALS['editor_styles'] = array();
1507
+	}
1456 1508
 	return true;
1457 1509
 }
1458 1510
 
@@ -1529,10 +1581,11 @@  discard block
 block discarded – undo
1529 1581
 function add_theme_support( $feature ) {
1530 1582
 	global $_wp_theme_features;
1531 1583
 
1532
-	if ( func_num_args() == 1 )
1533
-		$args = true;
1534
-	else
1535
-		$args = array_slice( func_get_args(), 1 );
1584
+	if ( func_num_args() == 1 ) {
1585
+			$args = true;
1586
+	} else {
1587
+			$args = array_slice( func_get_args(), 1 );
1588
+	}
1536 1589
 
1537 1590
 	switch ( $feature ) {
1538 1591
 		case 'post-formats' :
@@ -1555,16 +1608,18 @@  discard block
 block discarded – undo
1555 1608
 			}
1556 1609
 
1557 1610
 			// Calling 'html5' again merges, rather than overwrites.
1558
-			if ( isset( $_wp_theme_features['html5'] ) )
1559
-				$args[0] = array_merge( $_wp_theme_features['html5'][0], $args[0] );
1611
+			if ( isset( $_wp_theme_features['html5'] ) ) {
1612
+							$args[0] = array_merge( $_wp_theme_features['html5'][0], $args[0] );
1613
+			}
1560 1614
 			break;
1561 1615
 
1562 1616
 		case 'custom-header-uploads' :
1563 1617
 			return add_theme_support( 'custom-header', array( 'uploads' => true ) );
1564 1618
 
1565 1619
 		case 'custom-header' :
1566
-			if ( ! is_array( $args ) )
1567
-				$args = array( 0 => array() );
1620
+			if ( ! is_array( $args ) ) {
1621
+							$args = array( 0 => array() );
1622
+			}
1568 1623
 
1569 1624
 			$defaults = array(
1570 1625
 				'default-image' => '',
@@ -1586,13 +1641,15 @@  discard block
 block discarded – undo
1586 1641
 
1587 1642
 			// Merge in data from previous add_theme_support() calls.
1588 1643
 			// The first value registered wins. (A child theme is set up first.)
1589
-			if ( isset( $_wp_theme_features['custom-header'] ) )
1590
-				$args[0] = wp_parse_args( $_wp_theme_features['custom-header'][0], $args[0] );
1644
+			if ( isset( $_wp_theme_features['custom-header'] ) ) {
1645
+							$args[0] = wp_parse_args( $_wp_theme_features['custom-header'][0], $args[0] );
1646
+			}
1591 1647
 
1592 1648
 			// Load in the defaults at the end, as we need to insure first one wins.
1593 1649
 			// This will cause all constants to be defined, as each arg will then be set to the default.
1594
-			if ( $jit )
1595
-				$args[0] = wp_parse_args( $args[0], $defaults );
1650
+			if ( $jit ) {
1651
+							$args[0] = wp_parse_args( $args[0], $defaults );
1652
+			}
1596 1653
 
1597 1654
 			// If a constant was defined, use that value. Otherwise, define the constant to ensure
1598 1655
 			// the constant is always accurate (and is not defined later,  overriding our value).
@@ -1600,48 +1657,57 @@  discard block
 block discarded – undo
1600 1657
 			// Once we get to wp_loaded (just-in-time), define any constants we haven't already.
1601 1658
 			// Constants are lame. Don't reference them. This is just for backwards compatibility.
1602 1659
 
1603
-			if ( defined( 'NO_HEADER_TEXT' ) )
1604
-				$args[0]['header-text'] = ! NO_HEADER_TEXT;
1605
-			elseif ( isset( $args[0]['header-text'] ) )
1606
-				define( 'NO_HEADER_TEXT', empty( $args[0]['header-text'] ) );
1660
+			if ( defined( 'NO_HEADER_TEXT' ) ) {
1661
+							$args[0]['header-text'] = ! NO_HEADER_TEXT;
1662
+			} elseif ( isset( $args[0]['header-text'] ) ) {
1663
+							define( 'NO_HEADER_TEXT', empty( $args[0]['header-text'] ) );
1664
+			}
1607 1665
 
1608
-			if ( defined( 'HEADER_IMAGE_WIDTH' ) )
1609
-				$args[0]['width'] = (int) HEADER_IMAGE_WIDTH;
1610
-			elseif ( isset( $args[0]['width'] ) )
1611
-				define( 'HEADER_IMAGE_WIDTH', (int) $args[0]['width'] );
1666
+			if ( defined( 'HEADER_IMAGE_WIDTH' ) ) {
1667
+							$args[0]['width'] = (int) HEADER_IMAGE_WIDTH;
1668
+			} elseif ( isset( $args[0]['width'] ) ) {
1669
+							define( 'HEADER_IMAGE_WIDTH', (int) $args[0]['width'] );
1670
+			}
1612 1671
 
1613
-			if ( defined( 'HEADER_IMAGE_HEIGHT' ) )
1614
-				$args[0]['height'] = (int) HEADER_IMAGE_HEIGHT;
1615
-			elseif ( isset( $args[0]['height'] ) )
1616
-				define( 'HEADER_IMAGE_HEIGHT', (int) $args[0]['height'] );
1672
+			if ( defined( 'HEADER_IMAGE_HEIGHT' ) ) {
1673
+							$args[0]['height'] = (int) HEADER_IMAGE_HEIGHT;
1674
+			} elseif ( isset( $args[0]['height'] ) ) {
1675
+							define( 'HEADER_IMAGE_HEIGHT', (int) $args[0]['height'] );
1676
+			}
1617 1677
 
1618
-			if ( defined( 'HEADER_TEXTCOLOR' ) )
1619
-				$args[0]['default-text-color'] = HEADER_TEXTCOLOR;
1620
-			elseif ( isset( $args[0]['default-text-color'] ) )
1621
-				define( 'HEADER_TEXTCOLOR', $args[0]['default-text-color'] );
1678
+			if ( defined( 'HEADER_TEXTCOLOR' ) ) {
1679
+							$args[0]['default-text-color'] = HEADER_TEXTCOLOR;
1680
+			} elseif ( isset( $args[0]['default-text-color'] ) ) {
1681
+							define( 'HEADER_TEXTCOLOR', $args[0]['default-text-color'] );
1682
+			}
1622 1683
 
1623
-			if ( defined( 'HEADER_IMAGE' ) )
1624
-				$args[0]['default-image'] = HEADER_IMAGE;
1625
-			elseif ( isset( $args[0]['default-image'] ) )
1626
-				define( 'HEADER_IMAGE', $args[0]['default-image'] );
1684
+			if ( defined( 'HEADER_IMAGE' ) ) {
1685
+							$args[0]['default-image'] = HEADER_IMAGE;
1686
+			} elseif ( isset( $args[0]['default-image'] ) ) {
1687
+							define( 'HEADER_IMAGE', $args[0]['default-image'] );
1688
+			}
1627 1689
 
1628
-			if ( $jit && ! empty( $args[0]['default-image'] ) )
1629
-				$args[0]['random-default'] = false;
1690
+			if ( $jit && ! empty( $args[0]['default-image'] ) ) {
1691
+							$args[0]['random-default'] = false;
1692
+			}
1630 1693
 
1631 1694
 			// If headers are supported, and we still don't have a defined width or height,
1632 1695
 			// we have implicit flex sizes.
1633 1696
 			if ( $jit ) {
1634
-				if ( empty( $args[0]['width'] ) && empty( $args[0]['flex-width'] ) )
1635
-					$args[0]['flex-width'] = true;
1636
-				if ( empty( $args[0]['height'] ) && empty( $args[0]['flex-height'] ) )
1637
-					$args[0]['flex-height'] = true;
1697
+				if ( empty( $args[0]['width'] ) && empty( $args[0]['flex-width'] ) ) {
1698
+									$args[0]['flex-width'] = true;
1699
+				}
1700
+				if ( empty( $args[0]['height'] ) && empty( $args[0]['flex-height'] ) ) {
1701
+									$args[0]['flex-height'] = true;
1702
+				}
1638 1703
 			}
1639 1704
 
1640 1705
 			break;
1641 1706
 
1642 1707
 		case 'custom-background' :
1643
-			if ( ! is_array( $args ) )
1644
-				$args = array( 0 => array() );
1708
+			if ( ! is_array( $args ) ) {
1709
+							$args = array( 0 => array() );
1710
+			}
1645 1711
 
1646 1712
 			$defaults = array(
1647 1713
 				'default-image'          => '',
@@ -1658,21 +1724,25 @@  discard block
 block discarded – undo
1658 1724
 			unset( $args[0]['__jit'] );
1659 1725
 
1660 1726
 			// Merge in data from previous add_theme_support() calls. The first value registered wins.
1661
-			if ( isset( $_wp_theme_features['custom-background'] ) )
1662
-				$args[0] = wp_parse_args( $_wp_theme_features['custom-background'][0], $args[0] );
1727
+			if ( isset( $_wp_theme_features['custom-background'] ) ) {
1728
+							$args[0] = wp_parse_args( $_wp_theme_features['custom-background'][0], $args[0] );
1729
+			}
1663 1730
 
1664
-			if ( $jit )
1665
-				$args[0] = wp_parse_args( $args[0], $defaults );
1731
+			if ( $jit ) {
1732
+							$args[0] = wp_parse_args( $args[0], $defaults );
1733
+			}
1666 1734
 
1667
-			if ( defined( 'BACKGROUND_COLOR' ) )
1668
-				$args[0]['default-color'] = BACKGROUND_COLOR;
1669
-			elseif ( isset( $args[0]['default-color'] ) || $jit )
1670
-				define( 'BACKGROUND_COLOR', $args[0]['default-color'] );
1735
+			if ( defined( 'BACKGROUND_COLOR' ) ) {
1736
+							$args[0]['default-color'] = BACKGROUND_COLOR;
1737
+			} elseif ( isset( $args[0]['default-color'] ) || $jit ) {
1738
+							define( 'BACKGROUND_COLOR', $args[0]['default-color'] );
1739
+			}
1671 1740
 
1672
-			if ( defined( 'BACKGROUND_IMAGE' ) )
1673
-				$args[0]['default-image'] = BACKGROUND_IMAGE;
1674
-			elseif ( isset( $args[0]['default-image'] ) || $jit )
1675
-				define( 'BACKGROUND_IMAGE', $args[0]['default-image'] );
1741
+			if ( defined( 'BACKGROUND_IMAGE' ) ) {
1742
+							$args[0]['default-image'] = BACKGROUND_IMAGE;
1743
+			} elseif ( isset( $args[0]['default-image'] ) || $jit ) {
1744
+							define( 'BACKGROUND_IMAGE', $args[0]['default-image'] );
1745
+			}
1676 1746
 
1677 1747
 			break;
1678 1748
 
@@ -1708,8 +1778,9 @@  discard block
 block discarded – undo
1708 1778
 		add_theme_support( 'custom-header', array( '__jit' => true ) );
1709 1779
 
1710 1780
 		$args = get_theme_support( 'custom-header' );
1711
-		if ( $args[0]['wp-head-callback'] )
1712
-			add_action( 'wp_head', $args[0]['wp-head-callback'] );
1781
+		if ( $args[0]['wp-head-callback'] ) {
1782
+					add_action( 'wp_head', $args[0]['wp-head-callback'] );
1783
+		}
1713 1784
 
1714 1785
 		if ( is_admin() ) {
1715 1786
 			require_once( ABSPATH . 'wp-admin/custom-header.php' );
@@ -1767,19 +1838,22 @@  discard block
 block discarded – undo
1767 1838
  */
1768 1839
 function get_theme_support( $feature ) {
1769 1840
 	global $_wp_theme_features;
1770
-	if ( ! isset( $_wp_theme_features[ $feature ] ) )
1771
-		return false;
1841
+	if ( ! isset( $_wp_theme_features[ $feature ] ) ) {
1842
+			return false;
1843
+	}
1772 1844
 
1773
-	if ( func_num_args() <= 1 )
1774
-		return $_wp_theme_features[ $feature ];
1845
+	if ( func_num_args() <= 1 ) {
1846
+			return $_wp_theme_features[ $feature ];
1847
+	}
1775 1848
 
1776 1849
 	$args = array_slice( func_get_args(), 1 );
1777 1850
 	switch ( $feature ) {
1778 1851
 		case 'custom-logo' :
1779 1852
 		case 'custom-header' :
1780 1853
 		case 'custom-background' :
1781
-			if ( isset( $_wp_theme_features[ $feature ][0][ $args[0] ] ) )
1782
-				return $_wp_theme_features[ $feature ][0][ $args[0] ];
1854
+			if ( isset( $_wp_theme_features[ $feature ][0][ $args[0] ] ) ) {
1855
+							return $_wp_theme_features[ $feature ][0][ $args[0] ];
1856
+			}
1783 1857
 			return false;
1784 1858
 
1785 1859
 		default :
@@ -1800,8 +1874,9 @@  discard block
 block discarded – undo
1800 1874
  */
1801 1875
 function remove_theme_support( $feature ) {
1802 1876
 	// Blacklist: for internal registrations not used directly by themes.
1803
-	if ( in_array( $feature, array( 'editor-style', 'widgets', 'menus' ) ) )
1804
-		return false;
1877
+	if ( in_array( $feature, array( 'editor-style', 'widgets', 'menus' ) ) ) {
1878
+			return false;
1879
+	}
1805 1880
 
1806 1881
 	return _remove_theme_support( $feature );
1807 1882
 }
@@ -1823,29 +1898,34 @@  discard block
 block discarded – undo
1823 1898
 
1824 1899
 	switch ( $feature ) {
1825 1900
 		case 'custom-header-uploads' :
1826
-			if ( ! isset( $_wp_theme_features['custom-header'] ) )
1827
-				return false;
1901
+			if ( ! isset( $_wp_theme_features['custom-header'] ) ) {
1902
+							return false;
1903
+			}
1828 1904
 			add_theme_support( 'custom-header', array( 'uploads' => false ) );
1829 1905
 			return; // Do not continue - custom-header-uploads no longer exists.
1830 1906
 	}
1831 1907
 
1832
-	if ( ! isset( $_wp_theme_features[ $feature ] ) )
1833
-		return false;
1908
+	if ( ! isset( $_wp_theme_features[ $feature ] ) ) {
1909
+			return false;
1910
+	}
1834 1911
 
1835 1912
 	switch ( $feature ) {
1836 1913
 		case 'custom-header' :
1837
-			if ( ! did_action( 'wp_loaded' ) )
1838
-				break;
1914
+			if ( ! did_action( 'wp_loaded' ) ) {
1915
+							break;
1916
+			}
1839 1917
 			$support = get_theme_support( 'custom-header' );
1840
-			if ( $support[0]['wp-head-callback'] )
1841
-				remove_action( 'wp_head', $support[0]['wp-head-callback'] );
1918
+			if ( $support[0]['wp-head-callback'] ) {
1919
+							remove_action( 'wp_head', $support[0]['wp-head-callback'] );
1920
+			}
1842 1921
 			remove_action( 'admin_menu', array( $GLOBALS['custom_image_header'], 'init' ) );
1843 1922
 			unset( $GLOBALS['custom_image_header'] );
1844 1923
 			break;
1845 1924
 
1846 1925
 		case 'custom-background' :
1847
-			if ( ! did_action( 'wp_loaded' ) )
1848
-				break;
1926
+			if ( ! did_action( 'wp_loaded' ) ) {
1927
+							break;
1928
+			}
1849 1929
 			$support = get_theme_support( 'custom-background' );
1850 1930
 			remove_action( 'wp_head', $support[0]['wp-head-callback'] );
1851 1931
 			remove_action( 'admin_menu', array( $GLOBALS['custom_background'], 'init' ) );
@@ -1870,15 +1950,18 @@  discard block
 block discarded – undo
1870 1950
 function current_theme_supports( $feature ) {
1871 1951
 	global $_wp_theme_features;
1872 1952
 
1873
-	if ( 'custom-header-uploads' == $feature )
1874
-		return current_theme_supports( 'custom-header', 'uploads' );
1953
+	if ( 'custom-header-uploads' == $feature ) {
1954
+			return current_theme_supports( 'custom-header', 'uploads' );
1955
+	}
1875 1956
 
1876
-	if ( !isset( $_wp_theme_features[$feature] ) )
1877
-		return false;
1957
+	if ( !isset( $_wp_theme_features[$feature] ) ) {
1958
+			return false;
1959
+	}
1878 1960
 
1879 1961
 	// If no args passed then no extra checks need be performed
1880
-	if ( func_num_args() <= 1 )
1881
-		return true;
1962
+	if ( func_num_args() <= 1 ) {
1963
+			return true;
1964
+	}
1882 1965
 
1883 1966
 	$args = array_slice( func_get_args(), 1 );
1884 1967
 
@@ -1887,8 +1970,10 @@  discard block
 block discarded – undo
1887 1970
 			// post-thumbnails can be registered for only certain content/post types by passing
1888 1971
 			// an array of types to add_theme_support(). If no array was passed, then
1889 1972
 			// any type is accepted
1890
-			if ( true === $_wp_theme_features[$feature] )  // Registered for all types
1973
+			if ( true === $_wp_theme_features[$feature] ) {
1974
+				// Registered for all types
1891 1975
 				return true;
1976
+			}
1892 1977
 			$content_type = $args[0];
1893 1978
 			return in_array( $content_type, $_wp_theme_features[$feature][0] );
1894 1979
 
@@ -2069,8 +2154,9 @@  discard block
 block discarded – undo
2069 2154
 
2070 2155
 	$wp_scripts = wp_scripts();
2071 2156
 	$data = $wp_scripts->get_data( 'customize-loader', 'data' );
2072
-	if ( $data )
2073
-		$script = "$data\n$script";
2157
+	if ( $data ) {
2158
+			$script = "$data\n$script";
2159
+	}
2074 2160
 
2075 2161
 	$wp_scripts->add_data( 'customize-loader', 'data', $script );
2076 2162
 }
@@ -2086,8 +2172,9 @@  discard block
 block discarded – undo
2086 2172
  */
2087 2173
 function wp_customize_url( $stylesheet = null ) {
2088 2174
 	$url = admin_url( 'customize.php' );
2089
-	if ( $stylesheet )
2090
-		$url .= '?theme=' . urlencode( $stylesheet );
2175
+	if ( $stylesheet ) {
2176
+			$url .= '?theme=' . urlencode( $stylesheet );
2177
+	}
2091 2178
 	return esc_url( $url );
2092 2179
 }
2093 2180
 
@@ -2118,9 +2205,12 @@  discard block
 block discarded – undo
2118 2205
 
2119 2206
 <?php		if ( $cross_domain ): ?>
2120 2207
 			request = (function(){ var xhr = new XMLHttpRequest(); return ('withCredentials' in xhr); })();
2121
-<?php		else: ?>
2208
+<?php		else {
2209
+	: ?>
2122 2210
 			request = true;
2123
-<?php		endif; ?>
2211
+<?php		endif;
2212
+}
2213
+?>
2124 2214
 
2125 2215
 			b[c] = b[c].replace( rcs, ' ' );
2126 2216
 			b[c] += ( window.postMessage && request ? ' ' : ' no-' ) + cs;
Please login to merge, or discard this patch.
src/wp-includes/wp-diff.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 	 * @access public
496 496
 	 *
497 497
 	 * @param string $name Property to check if set.
498
-	 * @return bool Whether the property is set.
498
+	 * @return boolean|null Whether the property is set.
499 499
 	 */
500 500
 	public function __isset( $name ) {
501 501
 		if ( in_array( $name, $this->compat_fields ) ) {
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
 	 *
533 533
 	 * @param string $string
534 534
 	 * @param string $newlineEscape
535
-	 * @return string
535
+	 * @return string[]
536 536
 	 */
537 537
 	public function _splitOnWords($string, $newlineEscape = "\n") {
538 538
 		$string = str_replace("\0", '', $string);
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * WordPress Diff bastard child of old MediaWiki Diff Formatter.
4
- *
5
- * Basically all that remains is the table structure and some method names.
6
- *
7
- * @package WordPress
8
- * @subpackage Diff
9
- */
3
+	 * WordPress Diff bastard child of old MediaWiki Diff Formatter.
4
+	 *
5
+	 * Basically all that remains is the table structure and some method names.
6
+	 *
7
+	 * @package WordPress
8
+	 * @subpackage Diff
9
+	 */
10 10
 
11 11
 if ( !class_exists( 'Text_Diff' ) ) {
12 12
 	/** Text_Diff class */
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 				 *
170 170
 				 * @param String $processed_line The processed diffed line.
171 171
 				 * @param String $line           The unprocessed diffed line.
172
-		 		 * @param string null            The line context. Values are 'added', 'deleted' or 'unchanged'.
172
+				 * @param string null            The line context. Values are 'added', 'deleted' or 'unchanged'.
173 173
 				 */
174 174
 				$line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'added' );
175 175
 			}
Please login to merge, or discard this patch.
Braces   +49 added lines, -35 removed lines patch added patch discarded remove patch
@@ -81,8 +81,9 @@  discard block
 block discarded – undo
81 81
 	 */
82 82
 	public function __construct( $params = array() ) {
83 83
 		parent::__construct( $params );
84
-		if ( isset( $params[ 'show_split_view' ] ) )
85
-			$this->_show_split_view = $params[ 'show_split_view' ];
84
+		if ( isset( $params[ 'show_split_view' ] ) ) {
85
+					$this->_show_split_view = $params[ 'show_split_view' ];
86
+		}
86 87
 	}
87 88
 
88 89
 	/**
@@ -280,8 +281,10 @@  discard block
 block discarded – undo
280 281
 					//	we double the length of chars not in those tags.
281 282
 					$stripped_diff = strlen(strip_tags( $diff )) * 2 - $stripped_matches;
282 283
 					$diff_ratio = $stripped_matches / $stripped_diff;
283
-					if ( $diff_ratio > $this->_diff_threshold )
284
-						continue; // Too different. Don't save diffs.
284
+					if ( $diff_ratio > $this->_diff_threshold ) {
285
+											continue;
286
+					}
287
+					// Too different. Don't save diffs.
285 288
 				}
286 289
 
287 290
 				// Un-inline the diffs by removing del or ins
@@ -292,23 +295,26 @@  discard block
 block discarded – undo
292 295
 
293 296
 		foreach ( array_keys($orig_rows) as $row ) {
294 297
 			// Both columns have blanks. Ignore them.
295
-			if ( $orig_rows[$row] < 0 && $final_rows[$row] < 0 )
296
-				continue;
298
+			if ( $orig_rows[$row] < 0 && $final_rows[$row] < 0 ) {
299
+							continue;
300
+			}
297 301
 
298 302
 			// If we have a word based diff, use it. Otherwise, use the normal line.
299
-			if ( isset( $orig_diffs[$orig_rows[$row]] ) )
300
-				$orig_line = $orig_diffs[$orig_rows[$row]];
301
-			elseif ( isset( $orig[$orig_rows[$row]] ) )
302
-				$orig_line = htmlspecialchars($orig[$orig_rows[$row]]);
303
-			else
304
-				$orig_line = '';
305
-
306
-			if ( isset( $final_diffs[$final_rows[$row]] ) )
307
-				$final_line = $final_diffs[$final_rows[$row]];
308
-			elseif ( isset( $final[$final_rows[$row]] ) )
309
-				$final_line = htmlspecialchars($final[$final_rows[$row]]);
310
-			else
311
-				$final_line = '';
303
+			if ( isset( $orig_diffs[$orig_rows[$row]] ) ) {
304
+							$orig_line = $orig_diffs[$orig_rows[$row]];
305
+			} elseif ( isset( $orig[$orig_rows[$row]] ) ) {
306
+							$orig_line = htmlspecialchars($orig[$orig_rows[$row]]);
307
+			} else {
308
+							$orig_line = '';
309
+			}
310
+
311
+			if ( isset( $final_diffs[$final_rows[$row]] ) ) {
312
+							$final_line = $final_diffs[$final_rows[$row]];
313
+			} elseif ( isset( $final[$final_rows[$row]] ) ) {
314
+							$final_line = htmlspecialchars($final[$final_rows[$row]]);
315
+			} else {
316
+							$final_line = '';
317
+			}
312 318
 
313 319
 			if ( $orig_rows[$row] < 0 ) { // Orig is blank. This is really an added row.
314 320
 				$r .= $this->_added( array($final_line), false );
@@ -360,8 +366,9 @@  discard block
 block discarded – undo
360 366
 			$f = (int) $f;
361 367
 
362 368
 			// Already have better matches for these guys
363
-			if ( isset($orig_matches[$o]) && isset($final_matches[$f]) )
364
-				continue;
369
+			if ( isset($orig_matches[$o]) && isset($final_matches[$f]) ) {
370
+							continue;
371
+			}
365 372
 
366 373
 			// First match for these guys. Must be best match
367 374
 			if ( !isset($orig_matches[$o]) && !isset($final_matches[$f]) ) {
@@ -371,12 +378,14 @@  discard block
 block discarded – undo
371 378
 			}
372 379
 
373 380
 			// Best match of this final is already taken?  Must mean this final is a new row.
374
-			if ( isset($orig_matches[$o]) )
375
-				$final_matches[$f] = 'x';
381
+			if ( isset($orig_matches[$o]) ) {
382
+							$final_matches[$f] = 'x';
383
+			}
376 384
 
377 385
 			// Best match of this orig is already taken?  Must mean this orig is a deleted row.
378
-			elseif ( isset($final_matches[$f]) )
379
-				$orig_matches[$o] = 'x';
386
+			elseif ( isset($final_matches[$f]) ) {
387
+							$orig_matches[$o] = 'x';
388
+			}
380 389
 		}
381 390
 
382 391
 		// We read the text in this order
@@ -397,24 +406,28 @@  discard block
 block discarded – undo
397 406
 				array_splice( $final_rows, $orig_pos, 0, -1 );
398 407
 			} elseif ( $final_pos < $orig_pos ) { // This orig's match is up a ways. Pad final with blank rows.
399 408
 				$diff_pos = $final_pos - $orig_pos;
400
-				while ( $diff_pos < 0 )
401
-					array_splice( $final_rows, $orig_pos, 0, $diff_pos++ );
409
+				while ( $diff_pos < 0 ) {
410
+									array_splice( $final_rows, $orig_pos, 0, $diff_pos++ );
411
+				}
402 412
 			} elseif ( $final_pos > $orig_pos ) { // This orig's match is down a ways. Pad orig with blank rows.
403 413
 				$diff_pos = $orig_pos - $final_pos;
404
-				while ( $diff_pos < 0 )
405
-					array_splice( $orig_rows, $orig_pos, 0, $diff_pos++ );
414
+				while ( $diff_pos < 0 ) {
415
+									array_splice( $orig_rows, $orig_pos, 0, $diff_pos++ );
416
+				}
406 417
 			}
407 418
 		}
408 419
 
409 420
 		// Pad the ends with blank rows if the columns aren't the same length
410 421
 		$diff_count = count($orig_rows) - count($final_rows);
411 422
 		if ( $diff_count < 0 ) {
412
-			while ( $diff_count < 0 )
413
-				array_push($orig_rows, $diff_count++);
423
+			while ( $diff_count < 0 ) {
424
+							array_push($orig_rows, $diff_count++);
425
+			}
414 426
 		} elseif ( $diff_count > 0 ) {
415 427
 			$diff_count = -1 * $diff_count;
416
-			while ( $diff_count < 0 )
417
-				array_push($final_rows, $diff_count++);
428
+			while ( $diff_count < 0 ) {
429
+							array_push($final_rows, $diff_count++);
430
+			}
418 431
 		}
419 432
 
420 433
 		return array($orig_matches, $final_matches, $orig_rows, $final_rows);
@@ -438,8 +451,9 @@  discard block
 block discarded – undo
438 451
 		$difference = array_sum( array_map( array($this, 'difference'), $chars1, $chars2 ) );
439 452
 
440 453
 		// $string1 has zero length? Odd. Give huge penalty by not dividing.
441
-		if ( !$string1 )
442
-			return $difference;
454
+		if ( !$string1 ) {
455
+					return $difference;
456
+		}
443 457
 
444 458
 		// Return distance per character (of string1).
445 459
 		return $difference / strlen($string1);
Please login to merge, or discard this patch.
Spacing   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -8,13 +8,13 @@  discard block
 block discarded – undo
8 8
  * @subpackage Diff
9 9
  */
10 10
 
11
-if ( ! class_exists( 'Text_Diff', false ) ) {
11
+if ( ! class_exists('Text_Diff', false)) {
12 12
 	/** Text_Diff class */
13
-	require( dirname(__FILE__).'/Text/Diff.php' );
13
+	require(dirname(__FILE__).'/Text/Diff.php');
14 14
 	/** Text_Diff_Renderer class */
15
-	require( dirname(__FILE__).'/Text/Diff/Renderer.php' );
15
+	require(dirname(__FILE__).'/Text/Diff/Renderer.php');
16 16
 	/** Text_Diff_Renderer_inline class */
17
-	require( dirname(__FILE__).'/Text/Diff/Renderer/inline.php' );
17
+	require(dirname(__FILE__).'/Text/Diff/Renderer/inline.php');
18 18
 }
19 19
 
20 20
 /**
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 * @access public
32 32
 	 * @since 2.6.0
33 33
 	 */
34
-	public $_leading_context_lines  = 10000;
34
+	public $_leading_context_lines = 10000;
35 35
 
36 36
 	/**
37 37
 	 * @see Text_Diff_Renderer::_trailing_context_lines
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	protected $_show_split_view = true;
70 70
 
71
-	protected $compat_fields = array( '_show_split_view', 'inline_diff_renderer', '_diff_threshold' );
71
+	protected $compat_fields = array('_show_split_view', 'inline_diff_renderer', '_diff_threshold');
72 72
 
73 73
 	/**
74 74
 	 * Constructor - Call parent constructor with params array.
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
 	 *
80 80
 	 * @param array $params
81 81
 	 */
82
-	public function __construct( $params = array() ) {
83
-		parent::__construct( $params );
84
-		if ( isset( $params[ 'show_split_view' ] ) )
85
-			$this->_show_split_view = $params[ 'show_split_view' ];
82
+	public function __construct($params = array()) {
83
+		parent::__construct($params);
84
+		if (isset($params['show_split_view']))
85
+			$this->_show_split_view = $params['show_split_view'];
86 86
 	}
87 87
 
88 88
 	/**
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 * @param string $header
92 92
 	 * @return string
93 93
 	 */
94
-	public function _startBlock( $header ) {
94
+	public function _startBlock($header) {
95 95
 		return '';
96 96
 	}
97 97
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 * @param array $lines
102 102
 	 * @param string $prefix
103 103
 	 */
104
-	public function _lines( $lines, $prefix=' ' ) {
104
+	public function _lines($lines, $prefix = ' ') {
105 105
 	}
106 106
 
107 107
 	/**
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 * @param string $line HTML-escape the value.
111 111
 	 * @return string
112 112
 	 */
113
-	public function addedLine( $line ) {
113
+	public function addedLine($line) {
114 114
 		return "<td class='diff-addedline'>{$line}</td>";
115 115
 
116 116
 	}
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 * @param string $line HTML-escape the value.
122 122
 	 * @return string
123 123
 	 */
124
-	public function deletedLine( $line ) {
124
+	public function deletedLine($line) {
125 125
 		return "<td class='diff-deletedline'>{$line}</td>";
126 126
 	}
127 127
 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 * @param string $line HTML-escape the value.
132 132
 	 * @return string
133 133
 	 */
134
-	public function contextLine( $line ) {
134
+	public function contextLine($line) {
135 135
 		return "<td class='diff-context'>{$line}</td>";
136 136
 	}
137 137
 
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
 	 * @param bool $encode
153 153
 	 * @return string
154 154
 	 */
155
-	public function _added( $lines, $encode = true ) {
155
+	public function _added($lines, $encode = true) {
156 156
 		$r = '';
157 157
 		foreach ($lines as $line) {
158
-			if ( $encode ) {
159
-				$processed_line = htmlspecialchars( $line );
158
+			if ($encode) {
159
+				$processed_line = htmlspecialchars($line);
160 160
 
161 161
 				/**
162 162
 				 * Contextually filter a diffed line.
@@ -171,13 +171,13 @@  discard block
 block discarded – undo
171 171
 				 * @param String $line           The unprocessed diffed line.
172 172
 		 		 * @param string null            The line context. Values are 'added', 'deleted' or 'unchanged'.
173 173
 				 */
174
-				$line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'added' );
174
+				$line = apply_filters('process_text_diff_html', $processed_line, $line, 'added');
175 175
 			}
176 176
 
177
-			if ( $this->_show_split_view ) {
178
-				$r .= '<tr>' . $this->emptyLine() . $this->emptyLine() . $this->addedLine( $line ) . "</tr>\n";
177
+			if ($this->_show_split_view) {
178
+				$r .= '<tr>'.$this->emptyLine().$this->emptyLine().$this->addedLine($line)."</tr>\n";
179 179
 			} else {
180
-				$r .= '<tr>' . $this->addedLine( $line ) . "</tr>\n";
180
+				$r .= '<tr>'.$this->addedLine($line)."</tr>\n";
181 181
 			}
182 182
 		}
183 183
 		return $r;
@@ -191,19 +191,19 @@  discard block
 block discarded – undo
191 191
 	 * @param bool $encode
192 192
 	 * @return string
193 193
 	 */
194
-	public function _deleted( $lines, $encode = true ) {
194
+	public function _deleted($lines, $encode = true) {
195 195
 		$r = '';
196 196
 		foreach ($lines as $line) {
197
-			if ( $encode ) {
198
-				$processed_line = htmlspecialchars( $line );
197
+			if ($encode) {
198
+				$processed_line = htmlspecialchars($line);
199 199
 
200 200
 				/** This filter is documented in wp-includes/wp-diff.php */
201
-				$line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'deleted' );
201
+				$line = apply_filters('process_text_diff_html', $processed_line, $line, 'deleted');
202 202
 			}
203
-			if ( $this->_show_split_view ) {
204
-				$r .= '<tr>' . $this->deletedLine( $line ) . $this->emptyLine() . $this->emptyLine() . "</tr>\n";
203
+			if ($this->_show_split_view) {
204
+				$r .= '<tr>'.$this->deletedLine($line).$this->emptyLine().$this->emptyLine()."</tr>\n";
205 205
 			} else {
206
-				$r .= '<tr>' . $this->deletedLine( $line ) . "</tr>\n";
206
+				$r .= '<tr>'.$this->deletedLine($line)."</tr>\n";
207 207
 			}
208 208
 
209 209
 		}
@@ -218,19 +218,19 @@  discard block
 block discarded – undo
218 218
 	 * @param bool $encode
219 219
 	 * @return string
220 220
 	 */
221
-	public function _context( $lines, $encode = true ) {
221
+	public function _context($lines, $encode = true) {
222 222
 		$r = '';
223 223
 		foreach ($lines as $line) {
224
-			if ( $encode ) {
225
-				$processed_line = htmlspecialchars( $line );
224
+			if ($encode) {
225
+				$processed_line = htmlspecialchars($line);
226 226
 
227 227
 				/** This filter is documented in wp-includes/wp-diff.php */
228
-				$line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'unchanged' );
228
+				$line = apply_filters('process_text_diff_html', $processed_line, $line, 'unchanged');
229 229
 			}
230
-			if (  $this->_show_split_view ) {
231
-				$r .= '<tr>' . $this->contextLine( $line ) . $this->emptyLine() . $this->contextLine( $line )  . "</tr>\n";
230
+			if ($this->_show_split_view) {
231
+				$r .= '<tr>'.$this->contextLine($line).$this->emptyLine().$this->contextLine($line)."</tr>\n";
232 232
 			} else {
233
-				$r .= '<tr>' . $this->contextLine( $line ) . "</tr>\n";
233
+				$r .= '<tr>'.$this->contextLine($line)."</tr>\n";
234 234
 			}
235 235
 		}
236 236
 		return $r;
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 	 * @param array $final
250 250
 	 * @return string
251 251
 	 */
252
-	public function _changed( $orig, $final ) {
252
+	public function _changed($orig, $final) {
253 253
 		$r = '';
254 254
 
255 255
 		// Does the aforementioned additional processing
@@ -259,66 +259,66 @@  discard block
 block discarded – undo
259 259
 		// *_rows are column vectors for the orig column and the final column.
260 260
 		//	row >= 0: an indix of the $orig or $final array
261 261
 		//	row  < 0: a blank row for that column
262
-		list($orig_matches, $final_matches, $orig_rows, $final_rows) = $this->interleave_changed_lines( $orig, $final );
262
+		list($orig_matches, $final_matches, $orig_rows, $final_rows) = $this->interleave_changed_lines($orig, $final);
263 263
 
264 264
 		// These will hold the word changes as determined by an inline diff
265 265
 		$orig_diffs  = array();
266 266
 		$final_diffs = array();
267 267
 
268 268
 		// Compute word diffs for each matched pair using the inline diff
269
-		foreach ( $orig_matches as $o => $f ) {
270
-			if ( is_numeric($o) && is_numeric($f) ) {
271
-				$text_diff = new Text_Diff( 'auto', array( array($orig[$o]), array($final[$f]) ) );
269
+		foreach ($orig_matches as $o => $f) {
270
+			if (is_numeric($o) && is_numeric($f)) {
271
+				$text_diff = new Text_Diff('auto', array(array($orig[$o]), array($final[$f])));
272 272
 				$renderer = new $this->inline_diff_renderer;
273
-				$diff = $renderer->render( $text_diff );
273
+				$diff = $renderer->render($text_diff);
274 274
 
275 275
 				// If they're too different, don't include any <ins> or <dels>
276
-				if ( preg_match_all( '!(<ins>.*?</ins>|<del>.*?</del>)!', $diff, $diff_matches ) ) {
276
+				if (preg_match_all('!(<ins>.*?</ins>|<del>.*?</del>)!', $diff, $diff_matches)) {
277 277
 					// length of all text between <ins> or <del>
278
-					$stripped_matches = strlen(strip_tags( join(' ', $diff_matches[0]) ));
278
+					$stripped_matches = strlen(strip_tags(join(' ', $diff_matches[0])));
279 279
 					// since we count lengith of text between <ins> or <del> (instead of picking just one),
280 280
 					//	we double the length of chars not in those tags.
281
-					$stripped_diff = strlen(strip_tags( $diff )) * 2 - $stripped_matches;
281
+					$stripped_diff = strlen(strip_tags($diff)) * 2 - $stripped_matches;
282 282
 					$diff_ratio = $stripped_matches / $stripped_diff;
283
-					if ( $diff_ratio > $this->_diff_threshold )
283
+					if ($diff_ratio > $this->_diff_threshold)
284 284
 						continue; // Too different. Don't save diffs.
285 285
 				}
286 286
 
287 287
 				// Un-inline the diffs by removing del or ins
288
-				$orig_diffs[$o]  = preg_replace( '|<ins>.*?</ins>|', '', $diff );
289
-				$final_diffs[$f] = preg_replace( '|<del>.*?</del>|', '', $diff );
288
+				$orig_diffs[$o]  = preg_replace('|<ins>.*?</ins>|', '', $diff);
289
+				$final_diffs[$f] = preg_replace('|<del>.*?</del>|', '', $diff);
290 290
 			}
291 291
 		}
292 292
 
293
-		foreach ( array_keys($orig_rows) as $row ) {
293
+		foreach (array_keys($orig_rows) as $row) {
294 294
 			// Both columns have blanks. Ignore them.
295
-			if ( $orig_rows[$row] < 0 && $final_rows[$row] < 0 )
295
+			if ($orig_rows[$row] < 0 && $final_rows[$row] < 0)
296 296
 				continue;
297 297
 
298 298
 			// If we have a word based diff, use it. Otherwise, use the normal line.
299
-			if ( isset( $orig_diffs[$orig_rows[$row]] ) )
299
+			if (isset($orig_diffs[$orig_rows[$row]]))
300 300
 				$orig_line = $orig_diffs[$orig_rows[$row]];
301
-			elseif ( isset( $orig[$orig_rows[$row]] ) )
301
+			elseif (isset($orig[$orig_rows[$row]]))
302 302
 				$orig_line = htmlspecialchars($orig[$orig_rows[$row]]);
303 303
 			else
304 304
 				$orig_line = '';
305 305
 
306
-			if ( isset( $final_diffs[$final_rows[$row]] ) )
306
+			if (isset($final_diffs[$final_rows[$row]]))
307 307
 				$final_line = $final_diffs[$final_rows[$row]];
308
-			elseif ( isset( $final[$final_rows[$row]] ) )
308
+			elseif (isset($final[$final_rows[$row]]))
309 309
 				$final_line = htmlspecialchars($final[$final_rows[$row]]);
310 310
 			else
311 311
 				$final_line = '';
312 312
 
313
-			if ( $orig_rows[$row] < 0 ) { // Orig is blank. This is really an added row.
314
-				$r .= $this->_added( array($final_line), false );
315
-			} elseif ( $final_rows[$row] < 0 ) { // Final is blank. This is really a deleted row.
316
-				$r .= $this->_deleted( array($orig_line), false );
313
+			if ($orig_rows[$row] < 0) { // Orig is blank. This is really an added row.
314
+				$r .= $this->_added(array($final_line), false);
315
+			} elseif ($final_rows[$row] < 0) { // Final is blank. This is really a deleted row.
316
+				$r .= $this->_deleted(array($orig_line), false);
317 317
 			} else { // A true changed row.
318
-				if ( $this->_show_split_view ) {
319
-					$r .= '<tr>' . $this->deletedLine( $orig_line ) . $this->emptyLine() . $this->addedLine( $final_line ) . "</tr>\n";
318
+				if ($this->_show_split_view) {
319
+					$r .= '<tr>'.$this->deletedLine($orig_line).$this->emptyLine().$this->addedLine($final_line)."</tr>\n";
320 320
 				} else {
321
-					$r .= '<tr>' . $this->deletedLine( $orig_line ) . "</tr><tr>" . $this->addedLine( $final_line ) . "</tr>\n";
321
+					$r .= '<tr>'.$this->deletedLine($orig_line)."</tr><tr>".$this->addedLine($final_line)."</tr>\n";
322 322
 				}
323 323
 			}
324 324
 		}
@@ -340,13 +340,13 @@  discard block
 block discarded – undo
340 340
 	 * @param array $final
341 341
 	 * @return array
342 342
 	 */
343
-	public function interleave_changed_lines( $orig, $final ) {
343
+	public function interleave_changed_lines($orig, $final) {
344 344
 
345 345
 		// Contains all pairwise string comparisons. Keys are such that this need only be a one dimensional array.
346 346
 		$matches = array();
347
-		foreach ( array_keys($orig) as $o ) {
348
-			foreach ( array_keys($final) as $f ) {
349
-				$matches["$o,$f"] = $this->compute_string_distance( $orig[$o], $final[$f] );
347
+		foreach (array_keys($orig) as $o) {
348
+			foreach (array_keys($final) as $f) {
349
+				$matches["$o,$f"] = $this->compute_string_distance($orig[$o], $final[$f]);
350 350
 			}
351 351
 		}
352 352
 		asort($matches); // Order by string distance.
@@ -354,28 +354,28 @@  discard block
 block discarded – undo
354 354
 		$orig_matches  = array();
355 355
 		$final_matches = array();
356 356
 
357
-		foreach ( $matches as $keys => $difference ) {
357
+		foreach ($matches as $keys => $difference) {
358 358
 			list($o, $f) = explode(',', $keys);
359 359
 			$o = (int) $o;
360 360
 			$f = (int) $f;
361 361
 
362 362
 			// Already have better matches for these guys
363
-			if ( isset($orig_matches[$o]) && isset($final_matches[$f]) )
363
+			if (isset($orig_matches[$o]) && isset($final_matches[$f]))
364 364
 				continue;
365 365
 
366 366
 			// First match for these guys. Must be best match
367
-			if ( !isset($orig_matches[$o]) && !isset($final_matches[$f]) ) {
367
+			if ( ! isset($orig_matches[$o]) && ! isset($final_matches[$f])) {
368 368
 				$orig_matches[$o] = $f;
369 369
 				$final_matches[$f] = $o;
370 370
 				continue;
371 371
 			}
372 372
 
373 373
 			// Best match of this final is already taken?  Must mean this final is a new row.
374
-			if ( isset($orig_matches[$o]) )
374
+			if (isset($orig_matches[$o]))
375 375
 				$final_matches[$f] = 'x';
376 376
 
377 377
 			// Best match of this orig is already taken?  Must mean this orig is a deleted row.
378
-			elseif ( isset($final_matches[$f]) )
378
+			elseif (isset($final_matches[$f]))
379 379
 				$orig_matches[$o] = 'x';
380 380
 		}
381 381
 
@@ -389,31 +389,31 @@  discard block
 block discarded – undo
389 389
 
390 390
 		// Interleaves rows with blanks to keep matches aligned.
391 391
 		// We may end up with some extraneous blank rows, but we'll just ignore them later.
392
-		foreach ( $orig_rows_copy as $orig_row ) {
392
+		foreach ($orig_rows_copy as $orig_row) {
393 393
 			$final_pos = array_search($orig_matches[$orig_row], $final_rows, true);
394 394
 			$orig_pos = (int) array_search($orig_row, $orig_rows, true);
395 395
 
396
-			if ( false === $final_pos ) { // This orig is paired with a blank final.
397
-				array_splice( $final_rows, $orig_pos, 0, -1 );
398
-			} elseif ( $final_pos < $orig_pos ) { // This orig's match is up a ways. Pad final with blank rows.
396
+			if (false === $final_pos) { // This orig is paired with a blank final.
397
+				array_splice($final_rows, $orig_pos, 0, -1);
398
+			} elseif ($final_pos < $orig_pos) { // This orig's match is up a ways. Pad final with blank rows.
399 399
 				$diff_pos = $final_pos - $orig_pos;
400
-				while ( $diff_pos < 0 )
401
-					array_splice( $final_rows, $orig_pos, 0, $diff_pos++ );
402
-			} elseif ( $final_pos > $orig_pos ) { // This orig's match is down a ways. Pad orig with blank rows.
400
+				while ($diff_pos < 0)
401
+					array_splice($final_rows, $orig_pos, 0, $diff_pos++);
402
+			} elseif ($final_pos > $orig_pos) { // This orig's match is down a ways. Pad orig with blank rows.
403 403
 				$diff_pos = $orig_pos - $final_pos;
404
-				while ( $diff_pos < 0 )
405
-					array_splice( $orig_rows, $orig_pos, 0, $diff_pos++ );
404
+				while ($diff_pos < 0)
405
+					array_splice($orig_rows, $orig_pos, 0, $diff_pos++);
406 406
 			}
407 407
 		}
408 408
 
409 409
 		// Pad the ends with blank rows if the columns aren't the same length
410 410
 		$diff_count = count($orig_rows) - count($final_rows);
411
-		if ( $diff_count < 0 ) {
412
-			while ( $diff_count < 0 )
411
+		if ($diff_count < 0) {
412
+			while ($diff_count < 0)
413 413
 				array_push($orig_rows, $diff_count++);
414
-		} elseif ( $diff_count > 0 ) {
414
+		} elseif ($diff_count > 0) {
415 415
 			$diff_count = -1 * $diff_count;
416
-			while ( $diff_count < 0 )
416
+			while ($diff_count < 0)
417 417
 				array_push($final_rows, $diff_count++);
418 418
 		}
419 419
 
@@ -429,16 +429,16 @@  discard block
 block discarded – undo
429 429
 	 * @param string $string2
430 430
 	 * @return int
431 431
 	 */
432
-	public function compute_string_distance( $string1, $string2 ) {
432
+	public function compute_string_distance($string1, $string2) {
433 433
 		// Vectors containing character frequency for all chars in each string
434 434
 		$chars1 = count_chars($string1);
435 435
 		$chars2 = count_chars($string2);
436 436
 
437 437
 		// L1-norm of difference vector.
438
-		$difference = array_sum( array_map( array($this, 'difference'), $chars1, $chars2 ) );
438
+		$difference = array_sum(array_map(array($this, 'difference'), $chars1, $chars2));
439 439
 
440 440
 		// $string1 has zero length? Odd. Give huge penalty by not dividing.
441
-		if ( !$string1 )
441
+		if ( ! $string1)
442 442
 			return $difference;
443 443
 
444 444
 		// Return distance per character (of string1).
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
 	 * @param int $b
454 454
 	 * @return int
455 455
 	 */
456
-	public function difference( $a, $b ) {
457
-		return abs( $a - $b );
456
+	public function difference($a, $b) {
457
+		return abs($a - $b);
458 458
 	}
459 459
 
460 460
 	/**
@@ -466,8 +466,8 @@  discard block
 block discarded – undo
466 466
 	 * @param string $name Property to get.
467 467
 	 * @return mixed Property.
468 468
 	 */
469
-	public function __get( $name ) {
470
-		if ( in_array( $name, $this->compat_fields ) ) {
469
+	public function __get($name) {
470
+		if (in_array($name, $this->compat_fields)) {
471 471
 			return $this->$name;
472 472
 		}
473 473
 	}
@@ -482,8 +482,8 @@  discard block
 block discarded – undo
482 482
 	 * @param mixed  $value Property value.
483 483
 	 * @return mixed Newly-set property.
484 484
 	 */
485
-	public function __set( $name, $value ) {
486
-		if ( in_array( $name, $this->compat_fields ) ) {
485
+	public function __set($name, $value) {
486
+		if (in_array($name, $this->compat_fields)) {
487 487
 			return $this->$name = $value;
488 488
 		}
489 489
 	}
@@ -497,9 +497,9 @@  discard block
 block discarded – undo
497 497
 	 * @param string $name Property to check if set.
498 498
 	 * @return bool Whether the property is set.
499 499
 	 */
500
-	public function __isset( $name ) {
501
-		if ( in_array( $name, $this->compat_fields ) ) {
502
-			return isset( $this->$name );
500
+	public function __isset($name) {
501
+		if (in_array($name, $this->compat_fields)) {
502
+			return isset($this->$name);
503 503
 		}
504 504
 	}
505 505
 
@@ -511,9 +511,9 @@  discard block
 block discarded – undo
511 511
 	 *
512 512
 	 * @param string $name Property to unset.
513 513
 	 */
514
-	public function __unset( $name ) {
515
-		if ( in_array( $name, $this->compat_fields ) ) {
516
-			unset( $this->$name );
514
+	public function __unset($name) {
515
+		if (in_array($name, $this->compat_fields)) {
516
+			unset($this->$name);
517 517
 		}
518 518
 	}
519 519
 }
@@ -536,8 +536,8 @@  discard block
 block discarded – undo
536 536
 	 */
537 537
 	public function _splitOnWords($string, $newlineEscape = "\n") {
538 538
 		$string = str_replace("\0", '', $string);
539
-		$words  = preg_split( '/([^\w])/u', $string, -1, PREG_SPLIT_DELIM_CAPTURE );
540
-		$words  = str_replace( "\n", $newlineEscape, $words );
539
+		$words  = preg_split('/([^\w])/u', $string, -1, PREG_SPLIT_DELIM_CAPTURE);
540
+		$words  = str_replace("\n", $newlineEscape, $words);
541 541
 		return $words;
542 542
 	}
543 543
 
Please login to merge, or discard this patch.
src/wp-trackback.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
  *
21 21
  * @since 0.71
22 22
  *
23
- * @param mixed  $error         Whether there was an error.
23
+ * @param integer  $error         Whether there was an error.
24 24
  *                              Default '0'. Accepts '0' or '1', true or false.
25 25
  * @param string $error_message Error message if an error occurred.
26 26
  */
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -9,8 +9,8 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 if (empty($wp)) {
12
-	require_once( dirname( __FILE__ ) . '/wp-load.php' );
13
-	wp( array( 'tb' => '1' ) );
12
+	require_once(dirname(__FILE__).'/wp-load.php');
13
+	wp(array('tb' => '1'));
14 14
 }
15 15
 
16 16
 /**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  * @param string $error_message Error message if an error occurred.
26 26
  */
27 27
 function trackback_response($error = 0, $error_message = '') {
28
-	header('Content-Type: text/xml; charset=' . get_option('blog_charset') );
28
+	header('Content-Type: text/xml; charset='.get_option('blog_charset'));
29 29
 	if ($error) {
30 30
 		echo '<?xml version="1.0" encoding="utf-8"?'.">\n";
31 31
 		echo "<response>\n";
@@ -44,30 +44,30 @@  discard block
 block discarded – undo
44 44
 // Trackback is done by a POST.
45 45
 $request_array = 'HTTP_POST_VARS';
46 46
 
47
-if ( !isset($_GET['tb_id']) || !$_GET['tb_id'] ) {
47
+if ( ! isset($_GET['tb_id']) || ! $_GET['tb_id']) {
48 48
 	$tb_id = explode('/', $_SERVER['REQUEST_URI']);
49
-	$tb_id = intval( $tb_id[ count($tb_id) - 1 ] );
49
+	$tb_id = intval($tb_id[count($tb_id) - 1]);
50 50
 }
51 51
 
52
-$tb_url  = isset($_POST['url'])     ? $_POST['url']     : '';
52
+$tb_url  = isset($_POST['url']) ? $_POST['url'] : '';
53 53
 $charset = isset($_POST['charset']) ? $_POST['charset'] : '';
54 54
 
55 55
 // These three are stripslashed here so they can be properly escaped after mb_convert_encoding().
56
-$title     = isset($_POST['title'])     ? wp_unslash($_POST['title'])      : '';
57
-$excerpt   = isset($_POST['excerpt'])   ? wp_unslash($_POST['excerpt'])    : '';
58
-$blog_name = isset($_POST['blog_name']) ? wp_unslash($_POST['blog_name'])  : '';
56
+$title     = isset($_POST['title']) ? wp_unslash($_POST['title']) : '';
57
+$excerpt   = isset($_POST['excerpt']) ? wp_unslash($_POST['excerpt']) : '';
58
+$blog_name = isset($_POST['blog_name']) ? wp_unslash($_POST['blog_name']) : '';
59 59
 
60 60
 if ($charset)
61
-	$charset = str_replace( array(',', ' '), '', strtoupper( trim($charset) ) );
61
+	$charset = str_replace(array(',', ' '), '', strtoupper(trim($charset)));
62 62
 else
63 63
 	$charset = 'ASCII, UTF-8, ISO-8859-1, JIS, EUC-JP, SJIS';
64 64
 
65 65
 // No valid uses for UTF-7.
66
-if ( false !== strpos($charset, 'UTF-7') )
66
+if (false !== strpos($charset, 'UTF-7'))
67 67
 	die;
68 68
 
69 69
 // For international trackbacks.
70
-if ( function_exists('mb_convert_encoding') ) {
70
+if (function_exists('mb_convert_encoding')) {
71 71
 	$title     = mb_convert_encoding($title, get_option('blog_charset'), $charset);
72 72
 	$excerpt   = mb_convert_encoding($excerpt, get_option('blog_charset'), $charset);
73 73
 	$blog_name = mb_convert_encoding($blog_name, get_option('blog_charset'), $charset);
@@ -78,10 +78,10 @@  discard block
 block discarded – undo
78 78
 $excerpt   = wp_slash($excerpt);
79 79
 $blog_name = wp_slash($blog_name);
80 80
 
81
-if ( is_single() || is_page() )
81
+if (is_single() || is_page())
82 82
 	$tb_id = $posts[0]->ID;
83 83
 
84
-if ( !isset($tb_id) || !intval( $tb_id ) )
84
+if ( ! isset($tb_id) || ! intval($tb_id))
85 85
 	trackback_response(1, 'I really need an ID for this to work.');
86 86
 
87 87
 if (empty($title) && empty($tb_url) && empty($blog_name)) {
@@ -90,14 +90,14 @@  discard block
 block discarded – undo
90 90
 	exit;
91 91
 }
92 92
 
93
-if ( !empty($tb_url) && !empty($title) ) {
94
-	header('Content-Type: text/xml; charset=' . get_option('blog_charset') );
93
+if ( ! empty($tb_url) && ! empty($title)) {
94
+	header('Content-Type: text/xml; charset='.get_option('blog_charset'));
95 95
 
96
-	if ( !pings_open($tb_id) )
96
+	if ( ! pings_open($tb_id))
97 97
 		trackback_response(1, 'Sorry, trackbacks are closed for this item.');
98 98
 
99
-	$title =  wp_html_excerpt( $title, 250, '&#8230;' );
100
-	$excerpt = wp_html_excerpt( $excerpt, 252, '&#8230;' );
99
+	$title = wp_html_excerpt($title, 250, '&#8230;');
100
+	$excerpt = wp_html_excerpt($excerpt, 252, '&#8230;');
101 101
 
102 102
 	$comment_post_ID = (int) $tb_id;
103 103
 	$comment_author = $blog_name;
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
 	$comment_content = "<strong>$title</strong>\n\n$excerpt";
107 107
 	$comment_type = 'trackback';
108 108
 
109
-	$dupe = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $comment_post_ID, $comment_author_url) );
110
-	if ( $dupe )
109
+	$dupe = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $comment_post_ID, $comment_author_url));
110
+	if ($dupe)
111 111
 		trackback_response(1, 'We already have a ping from that URL for this post.');
112 112
 
113 113
 	$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type');
@@ -122,6 +122,6 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 * @param int $trackback_id Trackback ID.
124 124
 	 */
125
-	do_action( 'trackback_post', $trackback_id );
126
-	trackback_response( 0 );
125
+	do_action('trackback_post', $trackback_id);
126
+	trackback_response(0);
127 127
 }
Please login to merge, or discard this patch.
Braces   +15 added lines, -9 removed lines patch added patch discarded remove patch
@@ -57,14 +57,16 @@  discard block
 block discarded – undo
57 57
 $excerpt   = isset($_POST['excerpt'])   ? wp_unslash($_POST['excerpt'])    : '';
58 58
 $blog_name = isset($_POST['blog_name']) ? wp_unslash($_POST['blog_name'])  : '';
59 59
 
60
-if ($charset)
60
+if ($charset) {
61 61
 	$charset = str_replace( array(',', ' '), '', strtoupper( trim($charset) ) );
62
-else
62
+} else {
63 63
 	$charset = 'ASCII, UTF-8, ISO-8859-1, JIS, EUC-JP, SJIS';
64
+}
64 65
 
65 66
 // No valid uses for UTF-7.
66
-if ( false !== strpos($charset, 'UTF-7') )
67
+if ( false !== strpos($charset, 'UTF-7') ) {
67 68
 	die;
69
+}
68 70
 
69 71
 // For international trackbacks.
70 72
 if ( function_exists('mb_convert_encoding') ) {
@@ -78,11 +80,13 @@  discard block
 block discarded – undo
78 80
 $excerpt   = wp_slash($excerpt);
79 81
 $blog_name = wp_slash($blog_name);
80 82
 
81
-if ( is_single() || is_page() )
83
+if ( is_single() || is_page() ) {
82 84
 	$tb_id = $posts[0]->ID;
85
+}
83 86
 
84
-if ( !isset($tb_id) || !intval( $tb_id ) )
87
+if ( !isset($tb_id) || !intval( $tb_id ) ) {
85 88
 	trackback_response(1, 'I really need an ID for this to work.');
89
+}
86 90
 
87 91
 if (empty($title) && empty($tb_url) && empty($blog_name)) {
88 92
 	// If it doesn't look like a trackback at all.
@@ -93,8 +97,9 @@  discard block
 block discarded – undo
93 97
 if ( !empty($tb_url) && !empty($title) ) {
94 98
 	header('Content-Type: text/xml; charset=' . get_option('blog_charset') );
95 99
 
96
-	if ( !pings_open($tb_id) )
97
-		trackback_response(1, 'Sorry, trackbacks are closed for this item.');
100
+	if ( !pings_open($tb_id) ) {
101
+			trackback_response(1, 'Sorry, trackbacks are closed for this item.');
102
+	}
98 103
 
99 104
 	$title =  wp_html_excerpt( $title, 250, '&#8230;' );
100 105
 	$excerpt = wp_html_excerpt( $excerpt, 252, '&#8230;' );
@@ -107,8 +112,9 @@  discard block
 block discarded – undo
107 112
 	$comment_type = 'trackback';
108 113
 
109 114
 	$dupe = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $comment_post_ID, $comment_author_url) );
110
-	if ( $dupe )
111
-		trackback_response(1, 'We already have a ping from that URL for this post.');
115
+	if ( $dupe ) {
116
+			trackback_response(1, 'We already have a ping from that URL for this post.');
117
+	}
112 118
 
113 119
 	$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type');
114 120
 
Please login to merge, or discard this patch.
tools/i18n/extract.php 4 patches
Doc Comments   +10 added lines patch added patch discarded remove patch
@@ -40,11 +40,17 @@  discard block
 block discarded – undo
40 40
 		return $translations;
41 41
 	}
42 42
 
43
+	/**
44
+	 * @param string $prefix
45
+	 */
43 46
 	function extract_from_file( $file_name, $prefix ) {
44 47
 		$code = file_get_contents( $file_name );
45 48
 		return $this->extract_from_code( $code, $prefix . $file_name );
46 49
 	}
47 50
 
51
+	/**
52
+	 * @param string $path
53
+	 */
48 54
 	function does_file_name_match( $path, $excludes, $includes ) {
49 55
 		if ( $includes ) {
50 56
 			$matched_any_include = false;
@@ -128,6 +134,10 @@  discard block
 block discarded – undo
128 134
 		return $entry;
129 135
 	}
130 136
 
137
+	/**
138
+	 * @param string $code
139
+	 * @param string $file_name
140
+	 */
131 141
 	function extract_from_code( $code, $file_name ) {
132 142
 		$translations = new Translations;
133 143
 		$function_calls = $this->find_function_calls( array_keys( $this->rules ), $code );
Please login to merge, or discard this patch.
Switch Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -75,35 +75,35 @@
 block discarded – undo
75 75
 		for( $i = 0; $i < count( $rule ); ++$i ) {
76 76
 			if ( $rule[$i] && ( !isset( $call['args'][$i] ) || !is_string( $call['args'][$i] ) || '' == $call['args'][$i] ) ) return false;
77 77
 			switch( $rule[$i] ) {
78
-			case 'string':
79
-				if ( $complete ) {
80
-					$multiple[] = $entry;
81
-					$entry = new Translation_Entry;
82
-					$complete = false;
83
-				}
84
-				$entry->singular = $call['args'][$i];
85
-				$complete = true;
86
-				break;
87
-			case 'singular':
88
-				if ( $complete ) {
89
-					$multiple[] = $entry;
90
-					$entry = new Translation_Entry;
91
-					$complete = false;
92
-				}
93
-				$entry->singular = $call['args'][$i];
94
-				$entry->is_plural = true;
95
-				break;
96
-			case 'plural':
97
-				$entry->plural = $call['args'][$i];
98
-				$entry->is_plural = true;
99
-				$complete = true;
100
-				break;
101
-			case 'context':
102
-				$entry->context = $call['args'][$i];
103
-				foreach( $multiple as &$single_entry ) {
104
-					$single_entry->context = $entry->context;
105
-				}
106
-				break;
78
+				case 'string':
79
+					if ( $complete ) {
80
+						$multiple[] = $entry;
81
+						$entry = new Translation_Entry;
82
+						$complete = false;
83
+					}
84
+					$entry->singular = $call['args'][$i];
85
+					$complete = true;
86
+					break;
87
+				case 'singular':
88
+					if ( $complete ) {
89
+						$multiple[] = $entry;
90
+						$entry = new Translation_Entry;
91
+						$complete = false;
92
+					}
93
+					$entry->singular = $call['args'][$i];
94
+					$entry->is_plural = true;
95
+					break;
96
+				case 'plural':
97
+					$entry->plural = $call['args'][$i];
98
+					$entry->is_plural = true;
99
+					$complete = true;
100
+					break;
101
+				case 'context':
102
+					$entry->context = $call['args'][$i];
103
+					foreach( $multiple as &$single_entry ) {
104
+						$single_entry->context = $entry->context;
105
+					}
106
+					break;
107 107
 			}
108 108
 		}
109 109
 		if ( isset( $call['line'] ) && $call['line'] ) {
Please login to merge, or discard this patch.
Braces   +29 added lines, -12 removed lines patch added patch discarded remove patch
@@ -26,7 +26,9 @@  discard block
 block discarded – undo
26 26
 		$translations = new Translations;
27 27
 		$file_names = (array) scandir( '.' );
28 28
 		foreach ( $file_names as $file_name ) {
29
-			if ( '.' == $file_name || '..' == $file_name ) continue;
29
+			if ( '.' == $file_name || '..' == $file_name ) {
30
+				continue;
31
+			}
30 32
 			if ( preg_match( '/\.php$/', $file_name ) && $this->does_file_name_match( $prefix . $file_name, $excludes, $includes ) ) {
31 33
 				$extracted = $this->extract_from_file( $file_name, $prefix );
32 34
 				$translations->merge_originals_with( $extracted );
@@ -54,7 +56,9 @@  discard block
 block discarded – undo
54 56
 					break;
55 57
 				}
56 58
 			}
57
-			if ( !$matched_any_include ) return false;
59
+			if ( !$matched_any_include ) {
60
+				return false;
61
+			}
58 62
 		}
59 63
 		if ( $excludes ) {
60 64
 			foreach( $excludes as $exclude ) {
@@ -68,12 +72,16 @@  discard block
 block discarded – undo
68 72
 
69 73
 	function entry_from_call( $call, $file_name ) {
70 74
 		$rule = isset( $this->rules[$call['name']] )? $this->rules[$call['name']] : null;
71
-		if ( !$rule ) return null;
75
+		if ( !$rule ) {
76
+			return null;
77
+		}
72 78
 		$entry = new Translation_Entry;
73 79
 		$multiple = array();
74 80
 		$complete = false;
75 81
 		for( $i = 0; $i < count( $rule ); ++$i ) {
76
-			if ( $rule[$i] && ( !isset( $call['args'][$i] ) || !is_string( $call['args'][$i] ) || '' == $call['args'][$i] ) ) return false;
82
+			if ( $rule[$i] && ( !isset( $call['args'][$i] ) || !is_string( $call['args'][$i] ) || '' == $call['args'][$i] ) ) {
83
+				return false;
84
+			}
77 85
 			switch( $rule[$i] ) {
78 86
 			case 'string':
79 87
 				if ( $complete ) {
@@ -133,11 +141,12 @@  discard block
 block discarded – undo
133 141
 		$function_calls = $this->find_function_calls( array_keys( $this->rules ), $code );
134 142
 		foreach( $function_calls as $call ) {
135 143
 			$entry = $this->entry_from_call( $call, $file_name );
136
-			if ( is_array( $entry ) )
137
-				foreach( $entry as $single_entry )
144
+			if ( is_array( $entry ) ) {
145
+							foreach( $entry as $single_entry )
138 146
 					$translations->add_entry_or_merge( $single_entry );
139
-			elseif ( $entry)
140
-				$translations->add_entry_or_merge( $entry );
147
+			} elseif ( $entry) {
148
+							$translations->add_entry_or_merge( $entry );
149
+			}
141 150
 		}
142 151
 		return $translations;
143 152
 	}
@@ -155,8 +164,12 @@  discard block
 block discarded – undo
155 164
 		$in_func = false;
156 165
 		foreach( $tokens as $token ) {
157 166
 			$id = $text = null;
158
-			if ( is_array( $token ) ) list( $id, $text, $line ) = $token;
159
-			if ( T_WHITESPACE == $id ) continue;
167
+			if ( is_array( $token ) ) {
168
+				list( $id, $text, $line ) = $token;
169
+			}
170
+			if ( T_WHITESPACE == $id ) {
171
+				continue;
172
+			}
160 173
 			if ( T_STRING == $id && in_array( $text, $function_names ) && !$in_func ) {
161 174
 				$in_func = true;
162 175
 				$paren_level = -1;
@@ -177,7 +190,9 @@  discard block
 block discarded – undo
177 190
 					$latest_comment = $text;
178 191
 				}
179 192
 			}
180
-			if ( !$in_func ) continue;
193
+			if ( !$in_func ) {
194
+				continue;
195
+			}
181 196
 			if ( '(' == $token ) {
182 197
 				$paren_level++;
183 198
 				if ( 0 == $paren_level ) { // start of first argument
@@ -197,7 +212,9 @@  discard block
 block discarded – undo
197 212
 					$in_func = false;
198 213
 					$args[] = $current_argument;
199 214
 					$call = array( 'name' => $func_name, 'args' => $args, 'line' => $func_line );
200
-					if ( $func_comment ) $call['comment'] = $func_comment;
215
+					if ( $func_comment ) {
216
+						$call['comment'] = $func_comment;
217
+					}
201 218
 					$function_calls[] = $call;
202 219
 				}
203 220
 				$paren_level--;
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-$pomo = dirname( dirname( dirname( __FILE__ ) ) ) . '/src/wp-includes/pomo';
2
+$pomo = dirname(dirname(dirname(__FILE__))).'/src/wp-includes/pomo';
3 3
 require_once "$pomo/entry.php";
4 4
 require_once "$pomo/translations.php";
5 5
 
@@ -10,55 +10,55 @@  discard block
 block discarded – undo
10 10
 class StringExtractor {
11 11
 
12 12
 	var $rules = array(
13
-		'__' => array( 'string' ),
14
-		'_e' => array( 'string' ),
15
-		'_n' => array( 'singular', 'plural' ),
13
+		'__' => array('string'),
14
+		'_e' => array('string'),
15
+		'_n' => array('singular', 'plural'),
16 16
 	);
17 17
 	var $comment_prefix = 'translators:';
18 18
 
19
-	function __construct( $rules = array() ) {
19
+	function __construct($rules = array()) {
20 20
 		$this->rules = $rules;
21 21
 	}
22 22
 
23
-	function extract_from_directory( $dir, $excludes = array(), $includes = array(), $prefix = '' ) {
23
+	function extract_from_directory($dir, $excludes = array(), $includes = array(), $prefix = '') {
24 24
 		$old_cwd = getcwd();
25
-		chdir( $dir );
25
+		chdir($dir);
26 26
 		$translations = new Translations;
27
-		$file_names = (array) scandir( '.' );
28
-		foreach ( $file_names as $file_name ) {
29
-			if ( '.' == $file_name || '..' == $file_name ) continue;
30
-			if ( preg_match( '/\.php$/', $file_name ) && $this->does_file_name_match( $prefix . $file_name, $excludes, $includes ) ) {
31
-				$extracted = $this->extract_from_file( $file_name, $prefix );
32
-				$translations->merge_originals_with( $extracted );
27
+		$file_names = (array) scandir('.');
28
+		foreach ($file_names as $file_name) {
29
+			if ('.' == $file_name || '..' == $file_name) continue;
30
+			if (preg_match('/\.php$/', $file_name) && $this->does_file_name_match($prefix.$file_name, $excludes, $includes)) {
31
+				$extracted = $this->extract_from_file($file_name, $prefix);
32
+				$translations->merge_originals_with($extracted);
33 33
 			}
34
-			if ( is_dir( $file_name ) ) {
35
-				$extracted = $this->extract_from_directory( $file_name, $excludes, $includes, $prefix . $file_name . '/' );
36
-				$translations->merge_originals_with( $extracted );
34
+			if (is_dir($file_name)) {
35
+				$extracted = $this->extract_from_directory($file_name, $excludes, $includes, $prefix.$file_name.'/');
36
+				$translations->merge_originals_with($extracted);
37 37
 			}
38 38
 		}
39
-		chdir( $old_cwd );
39
+		chdir($old_cwd);
40 40
 		return $translations;
41 41
 	}
42 42
 
43
-	function extract_from_file( $file_name, $prefix ) {
44
-		$code = file_get_contents( $file_name );
45
-		return $this->extract_from_code( $code, $prefix . $file_name );
43
+	function extract_from_file($file_name, $prefix) {
44
+		$code = file_get_contents($file_name);
45
+		return $this->extract_from_code($code, $prefix.$file_name);
46 46
 	}
47 47
 
48
-	function does_file_name_match( $path, $excludes, $includes ) {
49
-		if ( $includes ) {
48
+	function does_file_name_match($path, $excludes, $includes) {
49
+		if ($includes) {
50 50
 			$matched_any_include = false;
51
-			foreach( $includes as $include ) {
52
-				if ( preg_match( '|^'.$include.'$|', $path ) ) {
51
+			foreach ($includes as $include) {
52
+				if (preg_match('|^'.$include.'$|', $path)) {
53 53
 					$matched_any_include = true;
54 54
 					break;
55 55
 				}
56 56
 			}
57
-			if ( !$matched_any_include ) return false;
57
+			if ( ! $matched_any_include) return false;
58 58
 		}
59
-		if ( $excludes ) {
60
-			foreach( $excludes as $exclude ) {
61
-				if ( preg_match( '|^'.$exclude.'$|', $path ) ) {
59
+		if ($excludes) {
60
+			foreach ($excludes as $exclude) {
61
+				if (preg_match('|^'.$exclude.'$|', $path)) {
62 62
 					return false;
63 63
 				}
64 64
 			}
@@ -66,17 +66,17 @@  discard block
 block discarded – undo
66 66
 		return true;
67 67
 	}
68 68
 
69
-	function entry_from_call( $call, $file_name ) {
70
-		$rule = isset( $this->rules[$call['name']] )? $this->rules[$call['name']] : null;
71
-		if ( !$rule ) return null;
69
+	function entry_from_call($call, $file_name) {
70
+		$rule = isset($this->rules[$call['name']]) ? $this->rules[$call['name']] : null;
71
+		if ( ! $rule) return null;
72 72
 		$entry = new Translation_Entry;
73 73
 		$multiple = array();
74 74
 		$complete = false;
75
-		for( $i = 0; $i < count( $rule ); ++$i ) {
76
-			if ( $rule[$i] && ( !isset( $call['args'][$i] ) || !is_string( $call['args'][$i] ) || '' == $call['args'][$i] ) ) return false;
77
-			switch( $rule[$i] ) {
75
+		for ($i = 0; $i < count($rule); ++$i) {
76
+			if ($rule[$i] && ( ! isset($call['args'][$i]) || ! is_string($call['args'][$i]) || '' == $call['args'][$i])) return false;
77
+			switch ($rule[$i]) {
78 78
 			case 'string':
79
-				if ( $complete ) {
79
+				if ($complete) {
80 80
 					$multiple[] = $entry;
81 81
 					$entry = new Translation_Entry;
82 82
 					$complete = false;
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 				$complete = true;
86 86
 				break;
87 87
 			case 'singular':
88
-				if ( $complete ) {
88
+				if ($complete) {
89 89
 					$multiple[] = $entry;
90 90
 					$entry = new Translation_Entry;
91 91
 					$complete = false;
@@ -100,27 +100,27 @@  discard block
 block discarded – undo
100 100
 				break;
101 101
 			case 'context':
102 102
 				$entry->context = $call['args'][$i];
103
-				foreach( $multiple as &$single_entry ) {
103
+				foreach ($multiple as &$single_entry) {
104 104
 					$single_entry->context = $entry->context;
105 105
 				}
106 106
 				break;
107 107
 			}
108 108
 		}
109
-		if ( isset( $call['line'] ) && $call['line'] ) {
110
-			$references = array( $file_name . ':' . $call['line'] );
109
+		if (isset($call['line']) && $call['line']) {
110
+			$references = array($file_name.':'.$call['line']);
111 111
 			$entry->references = $references;
112
-			foreach( $multiple as &$single_entry ) {
112
+			foreach ($multiple as &$single_entry) {
113 113
 				$single_entry->references = $references;
114 114
 			}
115 115
 		}
116
-		if ( isset( $call['comment'] ) && $call['comment'] ) {
117
-			$comments = rtrim( $call['comment'] ) . "\n";
116
+		if (isset($call['comment']) && $call['comment']) {
117
+			$comments = rtrim($call['comment'])."\n";
118 118
 			$entry->extracted_comments = $comments;
119
-			foreach( $multiple as &$single_entry ) {
119
+			foreach ($multiple as &$single_entry) {
120 120
 				$single_entry->extracted_comments = $comments;
121 121
 			}
122 122
 		}
123
-		if ( $multiple && $entry ) {
123
+		if ($multiple && $entry) {
124 124
 			$multiple[] = $entry;
125 125
 			return $multiple;
126 126
 		}
@@ -128,16 +128,16 @@  discard block
 block discarded – undo
128 128
 		return $entry;
129 129
 	}
130 130
 
131
-	function extract_from_code( $code, $file_name ) {
131
+	function extract_from_code($code, $file_name) {
132 132
 		$translations = new Translations;
133
-		$function_calls = $this->find_function_calls( array_keys( $this->rules ), $code );
134
-		foreach( $function_calls as $call ) {
135
-			$entry = $this->entry_from_call( $call, $file_name );
136
-			if ( is_array( $entry ) )
137
-				foreach( $entry as $single_entry )
138
-					$translations->add_entry_or_merge( $single_entry );
139
-			elseif ( $entry)
140
-				$translations->add_entry_or_merge( $entry );
133
+		$function_calls = $this->find_function_calls(array_keys($this->rules), $code);
134
+		foreach ($function_calls as $call) {
135
+			$entry = $this->entry_from_call($call, $file_name);
136
+			if (is_array($entry))
137
+				foreach ($entry as $single_entry)
138
+					$translations->add_entry_or_merge($single_entry);
139
+			elseif ($entry)
140
+				$translations->add_entry_or_merge($entry);
141 141
 		}
142 142
 		return $translations;
143 143
 	}
@@ -148,70 +148,70 @@  discard block
 block discarded – undo
148 148
 	 *	- args - array for the function arguments. Each string literal is represented by itself, other arguments are represented by null.
149 149
 	 *  - line - line number
150 150
 	 */
151
-	function find_function_calls( $function_names, $code ) {
152
-		$tokens = token_get_all( $code );
151
+	function find_function_calls($function_names, $code) {
152
+		$tokens = token_get_all($code);
153 153
 		$function_calls = array();
154 154
 		$latest_comment = false;
155 155
 		$in_func = false;
156
-		foreach( $tokens as $token ) {
156
+		foreach ($tokens as $token) {
157 157
 			$id = $text = null;
158
-			if ( is_array( $token ) ) list( $id, $text, $line ) = $token;
159
-			if ( T_WHITESPACE == $id ) continue;
160
-			if ( T_STRING == $id && in_array( $text, $function_names ) && !$in_func ) {
158
+			if (is_array($token)) list($id, $text, $line) = $token;
159
+			if (T_WHITESPACE == $id) continue;
160
+			if (T_STRING == $id && in_array($text, $function_names) && ! $in_func) {
161 161
 				$in_func = true;
162 162
 				$paren_level = -1;
163 163
 				$args = array();
164 164
 				$func_name = $text;
165 165
 				$func_line = $line;
166
-				$func_comment = $latest_comment? $latest_comment : '';
166
+				$func_comment = $latest_comment ? $latest_comment : '';
167 167
 
168 168
 				$just_got_into_func = true;
169 169
 				$latest_comment = false;
170 170
 				continue;
171 171
 			}
172
-			if ( T_COMMENT == $id ) {
173
-				$text = preg_replace( '%^\s+\*\s%m', '', $text );
174
-				$text = str_replace( array( "\r\n", "\n" ), ' ', $text );;
175
-				$text = trim( preg_replace( '%^(/\*|//)%', '', preg_replace( '%\*/$%', '', $text ) ) );
176
-				if ( 0 === stripos( $text, $this->comment_prefix ) ) {
172
+			if (T_COMMENT == $id) {
173
+				$text = preg_replace('%^\s+\*\s%m', '', $text);
174
+				$text = str_replace(array("\r\n", "\n"), ' ', $text); ;
175
+				$text = trim(preg_replace('%^(/\*|//)%', '', preg_replace('%\*/$%', '', $text)));
176
+				if (0 === stripos($text, $this->comment_prefix)) {
177 177
 					$latest_comment = $text;
178 178
 				}
179 179
 			}
180
-			if ( !$in_func ) continue;
181
-			if ( '(' == $token ) {
180
+			if ( ! $in_func) continue;
181
+			if ('(' == $token) {
182 182
 				$paren_level++;
183
-				if ( 0 == $paren_level ) { // start of first argument
183
+				if (0 == $paren_level) { // start of first argument
184 184
 					$just_got_into_func = false;
185 185
 					$current_argument = null;
186 186
 					$current_argument_is_just_literal = true;
187 187
 				}
188 188
 				continue;
189 189
 			}
190
-			if ( $just_got_into_func ) {
190
+			if ($just_got_into_func) {
191 191
 				// there wasn't a opening paren just after the function name -- this means it is not a function
192 192
 				$in_func = false;
193 193
 				$just_got_into_func = false;
194 194
 			}
195
-			if ( ')' == $token ) {
196
-				if ( 0 == $paren_level ) {
195
+			if (')' == $token) {
196
+				if (0 == $paren_level) {
197 197
 					$in_func = false;
198 198
 					$args[] = $current_argument;
199
-					$call = array( 'name' => $func_name, 'args' => $args, 'line' => $func_line );
200
-					if ( $func_comment ) $call['comment'] = $func_comment;
199
+					$call = array('name' => $func_name, 'args' => $args, 'line' => $func_line);
200
+					if ($func_comment) $call['comment'] = $func_comment;
201 201
 					$function_calls[] = $call;
202 202
 				}
203 203
 				$paren_level--;
204 204
 				continue;
205 205
 			}
206
-			if ( ',' == $token && 0 == $paren_level ) {
206
+			if (',' == $token && 0 == $paren_level) {
207 207
 				$args[] = $current_argument;
208 208
 				$current_argument = null;
209 209
 				$current_argument_is_just_literal = true;
210 210
 				continue;
211 211
 			}
212
-			if ( T_CONSTANT_ENCAPSED_STRING == $id && $current_argument_is_just_literal ) {
212
+			if (T_CONSTANT_ENCAPSED_STRING == $id && $current_argument_is_just_literal) {
213 213
 				// we can use eval safely, because we are sure $text is just a string literal
214
-				eval('$current_argument = '.$text.';' );
214
+				eval('$current_argument = '.$text.';');
215 215
 				continue;
216 216
 			}
217 217
 			$current_argument_is_just_literal = false;
Please login to merge, or discard this patch.
tools/i18n/not-gettexted.php 4 patches
Doc Comments   +12 added lines patch added patch discarded remove patch
@@ -51,6 +51,9 @@  discard block
 block discarded – undo
51 51
 		return '';
52 52
 	}
53 53
 
54
+	/**
55
+	 * @param string $dir
56
+	 */
54 57
 	function list_php_files($dir) {
55 58
 		$files = array();
56 59
 		$items = scandir( $dir );
@@ -67,16 +70,25 @@  discard block
 block discarded – undo
67 70
 	}
68 71
 
69 72
 
73
+	/**
74
+	 * @param string $global_array_name
75
+	 */
70 76
 	function make_string_aggregator($global_array_name, $filename) {
71 77
 		$a = $global_array_name;
72 78
 		return create_function('$string, $comment_id, $line_number', 'global $'.$a.'; $'.$a.'[] = array($string, $comment_id, '.var_export($filename, true).', $line_number);');
73 79
 	}
74 80
 
81
+	/**
82
+	 * @param string $global_mo_name
83
+	 */
75 84
 	function make_mo_replacer($global_mo_name) {
76 85
 		$m = $global_mo_name;
77 86
 		return create_function('$token, $string', 'global $'.$m.'; return var_export($'.$m.'->translate($string), true);');
78 87
 	}
79 88
 
89
+	/**
90
+	 * @param string $register_action
91
+	 */
80 92
 	function walk_tokens(&$tokens, $string_action, $other_action, $register_action=null) {
81 93
 
82 94
 		$current_comment_id = '';
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,9 +8,9 @@
 block discarded – undo
8 8
  */
9 9
 // see: http://php.net/tokenizer
10 10
 if ( ! defined( 'T_ML_COMMENT' ) )
11
-	    define( 'T_ML_COMMENT', T_COMMENT );
11
+		define( 'T_ML_COMMENT', T_COMMENT );
12 12
 else
13
-	    define( 'T_DOC_COMMENT', T_ML_COMMENT );
13
+		define( 'T_DOC_COMMENT', T_ML_COMMENT );
14 14
 
15 15
 $pomo = dirname( dirname( dirname( __FILE__ ) ) ) . '/src/wp-includes/pomo';
16 16
 require_once "$pomo/po.php";
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
  * @subpackage tools
8 8
  */
9 9
 // see: http://php.net/tokenizer
10
-if ( ! defined( 'T_ML_COMMENT' ) )
11
-	    define( 'T_ML_COMMENT', T_COMMENT );
10
+if ( ! defined('T_ML_COMMENT'))
11
+	    define('T_ML_COMMENT', T_COMMENT);
12 12
 else
13
-	    define( 'T_DOC_COMMENT', T_ML_COMMENT );
13
+	    define('T_DOC_COMMENT', T_ML_COMMENT);
14 14
 
15
-$pomo = dirname( dirname( dirname( __FILE__ ) ) ) . '/src/wp-includes/pomo';
15
+$pomo = dirname(dirname(dirname(__FILE__))).'/src/wp-includes/pomo';
16 16
 require_once "$pomo/po.php";
17 17
 require_once "$pomo/mo.php";
18 18
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	var $STAGE_WHITESPACE_AFTER = 4;
27 27
 	var $STAGE_END_COMMENT = 4;
28 28
 
29
-	var $commands = array('extract' => 'command_extract', 'replace' => 'command_replace' );
29
+	var $commands = array('extract' => 'command_extract', 'replace' => 'command_replace');
30 30
 
31 31
 
32 32
 	function logmsg() {
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
 		if ($this->enable_logging) error_log(implode(' ', $args));
35 35
 	}
36 36
 
37
-	function stderr($msg, $nl=true) {
38
-		fwrite(STDERR, $msg.($nl? "\n" : ""));
37
+	function stderr($msg, $nl = true) {
38
+		fwrite(STDERR, $msg.($nl ? "\n" : ""));
39 39
 	}
40 40
 
41 41
 	function cli_die($msg) {
@@ -43,19 +43,19 @@  discard block
 block discarded – undo
43 43
 		exit(1);
44 44
 	}
45 45
 
46
-	function unchanged_token($token, $s='') {
47
-		return is_array($token)? $token[1] : $token;
46
+	function unchanged_token($token, $s = '') {
47
+		return is_array($token) ? $token[1] : $token;
48 48
 	}
49 49
 
50
-	function ignore_token($token, $s='') {
50
+	function ignore_token($token, $s = '') {
51 51
 		return '';
52 52
 	}
53 53
 
54 54
 	function list_php_files($dir) {
55 55
 		$files = array();
56
-		$items = scandir( $dir );
57
-		foreach ( (array) $items as $item ) {
58
-			$full_item = $dir . '/' . $item;
56
+		$items = scandir($dir);
57
+		foreach ((array) $items as $item) {
58
+			$full_item = $dir.'/'.$item;
59 59
 			if ('.' == $item || '..' == $item)
60 60
 				continue;
61 61
 			if ('.php' == substr($item, -4))
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 		return create_function('$token, $string', 'global $'.$m.'; return var_export($'.$m.'->translate($string), true);');
78 78
 	}
79 79
 
80
-	function walk_tokens(&$tokens, $string_action, $other_action, $register_action=null) {
80
+	function walk_tokens(&$tokens, $string_action, $other_action, $register_action = null) {
81 81
 
82 82
 		$current_comment_id = '';
83 83
 		$current_string = '';
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 		$result = '';
87 87
 		$line = 1;
88 88
 
89
-		foreach($tokens as $token) {
89
+		foreach ($tokens as $token) {
90 90
 			if (is_array($token)) {
91 91
 				list($id, $text) = $token;
92 92
 				$line += substr_count($text, "\n");
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 						$stage = $this->STAGE_END_COMMENT;
103 103
 						$this->logmsg('end comment', $current_comment_id);
104 104
 						$result .= call_user_func($other_action, $token);
105
-						if (!is_null($register_action)) call_user_func($register_action, $current_string, $current_comment_id, $current_string_line);
105
+						if ( ! is_null($register_action)) call_user_func($register_action, $current_string, $current_comment_id, $current_string_line);
106 106
 						continue;
107 107
 					}
108 108
 				} else if (T_CONSTANT_ENCAPSED_STRING == $id) {
@@ -149,21 +149,21 @@  discard block
 block discarded – undo
149 149
 		$global_name = '__entries_'.mt_rand(1, 1000);
150 150
 		$GLOBALS[$global_name] = array();
151 151
 
152
-		foreach($filenames as $filename) {
152
+		foreach ($filenames as $filename) {
153 153
 			$tokens = token_get_all(file_get_contents($filename));
154 154
 			$aggregator = $this->make_string_aggregator($global_name, $filename);
155 155
 			$this->walk_tokens($tokens, array($this, 'ignore_token'), array($this, 'ignore_token'), $aggregator);
156 156
 		}
157 157
 
158
-		$potf = '-' == $pot_filename? STDOUT : @fopen($pot_filename, 'a');
158
+		$potf = '-' == $pot_filename ? STDOUT : @fopen($pot_filename, 'a');
159 159
 		if (false === $potf) {
160 160
 			$this->cli_die("Couldn't open pot file: $pot_filename");
161 161
 		}
162 162
 
163
-		foreach($GLOBALS[$global_name] as $item) {
163
+		foreach ($GLOBALS[$global_name] as $item) {
164 164
 			@list($string, $comment_id, $filename, $line_number) = $item;
165
-			$filename = isset($filename)? preg_replace('|^\./|', '', $filename) : '';
166
-			$ref_line_number = isset($line_number)? ":$line_number" : '';
165
+			$filename = isset($filename) ? preg_replace('|^\./|', '', $filename) : '';
166
+			$ref_line_number = isset($line_number) ? ":$line_number" : '';
167 167
 			$args = array(
168 168
 				'singular' => $string,
169 169
 				'extracted_comments' => "Not gettexted string $comment_id",
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
 		if (false === $res) {
193 193
 			$this->cli_die("Couldn't read MO file '$mo_filename'!");
194 194
 		}
195
-		foreach($filenames as $filename) {
195
+		foreach ($filenames as $filename) {
196 196
 			$source = file_get_contents($filename);
197
-			if ( strlen($source) > 150000 ) continue;
197
+			if (strlen($source) > 150000) continue;
198 198
 			$tokens = token_get_all($source);
199 199
 			$new_file = $this->walk_tokens($tokens, $replacer, array($this, 'unchanged_token'));
200 200
 			$f = fopen($filename, 'w');
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 
215 215
 	function cli() {
216 216
 		global $argv, $commands;
217
-		if (count($argv) < 4 || !in_array($argv[1], array_keys($this->commands))) {
217
+		if (count($argv) < 4 || ! in_array($argv[1], array_keys($this->commands))) {
218 218
 			$this->usage();
219 219
 			exit(1);
220 220
 		}
Please login to merge, or discard this patch.
Braces   +34 added lines, -20 removed lines patch added patch discarded remove patch
@@ -7,10 +7,11 @@  discard block
 block discarded – undo
7 7
  * @subpackage tools
8 8
  */
9 9
 // see: http://php.net/tokenizer
10
-if ( ! defined( 'T_ML_COMMENT' ) )
10
+if ( ! defined( 'T_ML_COMMENT' ) ) {
11 11
 	    define( 'T_ML_COMMENT', T_COMMENT );
12
-else
12
+} else {
13 13
 	    define( 'T_DOC_COMMENT', T_ML_COMMENT );
14
+}
14 15
 
15 16
 $pomo = dirname( dirname( dirname( __FILE__ ) ) ) . '/src/wp-includes/pomo';
16 17
 require_once "$pomo/po.php";
@@ -31,7 +32,9 @@  discard block
 block discarded – undo
31 32
 
32 33
 	function logmsg() {
33 34
 		$args = func_get_args();
34
-		if ($this->enable_logging) error_log(implode(' ', $args));
35
+		if ($this->enable_logging) {
36
+			error_log(implode(' ', $args));
37
+		}
35 38
 	}
36 39
 
37 40
 	function stderr($msg, $nl=true) {
@@ -56,12 +59,15 @@  discard block
 block discarded – undo
56 59
 		$items = scandir( $dir );
57 60
 		foreach ( (array) $items as $item ) {
58 61
 			$full_item = $dir . '/' . $item;
59
-			if ('.' == $item || '..' == $item)
60
-				continue;
61
-			if ('.php' == substr($item, -4))
62
-				$files[] = $full_item;
63
-			if (is_dir($full_item))
64
-				$files += array_merge($files, NotGettexted::list_php_files($full_item, $files));
62
+			if ('.' == $item || '..' == $item) {
63
+							continue;
64
+			}
65
+			if ('.php' == substr($item, -4)) {
66
+							$files[] = $full_item;
67
+			}
68
+			if (is_dir($full_item)) {
69
+							$files += array_merge($files, NotGettexted::list_php_files($full_item, $files));
70
+			}
65 71
 		}
66 72
 		return $files;
67 73
 	}
@@ -102,7 +108,9 @@  discard block
 block discarded – undo
102 108
 						$stage = $this->STAGE_END_COMMENT;
103 109
 						$this->logmsg('end comment', $current_comment_id);
104 110
 						$result .= call_user_func($other_action, $token);
105
-						if (!is_null($register_action)) call_user_func($register_action, $current_string, $current_comment_id, $current_string_line);
111
+						if (!is_null($register_action)) {
112
+							call_user_func($register_action, $current_string, $current_comment_id, $current_string_line);
113
+						}
106 114
 						continue;
107 115
 					}
108 116
 				} else if (T_CONSTANT_ENCAPSED_STRING == $id) {
@@ -141,10 +149,11 @@  discard block
 block discarded – undo
141 149
 	function command_extract() {
142 150
 		$args = func_get_args();
143 151
 		$pot_filename = $args[0];
144
-		if (isset($args[1]) && is_array($args[1]))
145
-			$filenames = $args[1];
146
-		else
147
-			$filenames = array_slice($args, 1);
152
+		if (isset($args[1]) && is_array($args[1])) {
153
+					$filenames = $args[1];
154
+		} else {
155
+					$filenames = array_slice($args, 1);
156
+		}
148 157
 
149 158
 		$global_name = '__entries_'.mt_rand(1, 1000);
150 159
 		$GLOBALS[$global_name] = array();
@@ -172,17 +181,20 @@  discard block
 block discarded – undo
172 181
 			$entry = new Translation_Entry($args);
173 182
 			fwrite($potf, "\n".PO::export_entry($entry)."\n");
174 183
 		}
175
-		if ('-' != $pot_filename) fclose($potf);
184
+		if ('-' != $pot_filename) {
185
+			fclose($potf);
186
+		}
176 187
 		return true;
177 188
 	}
178 189
 
179 190
 	function command_replace() {
180 191
 		$args = func_get_args();
181 192
 		$mo_filename = $args[0];
182
-		if (isset($args[1]) && is_array($args[1]))
183
-			$filenames = $args[1];
184
-		else
185
-			$filenames = array_slice($args, 1);
193
+		if (isset($args[1]) && is_array($args[1])) {
194
+					$filenames = $args[1];
195
+		} else {
196
+					$filenames = array_slice($args, 1);
197
+		}
186 198
 
187 199
 		$global_name = '__mo_'.mt_rand(1, 1000);
188 200
 		$GLOBALS[$global_name] = new MO();
@@ -194,7 +206,9 @@  discard block
 block discarded – undo
194 206
 		}
195 207
 		foreach($filenames as $filename) {
196 208
 			$source = file_get_contents($filename);
197
-			if ( strlen($source) > 150000 ) continue;
209
+			if ( strlen($source) > 150000 ) {
210
+				continue;
211
+			}
198 212
 			$tokens = token_get_all($source);
199 213
 			$new_file = $this->walk_tokens($tokens, $replacer, array($this, 'unchanged_token'));
200 214
 			$f = fopen($filename, 'w');
Please login to merge, or discard this patch.