Completed
Push — master ( fdb3a7...cde0c6 )
by Stephen
20:18
created
src/wp-includes/SimplePie/Item.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
 	 * @since 1.0
861 861
 	 *
862 862
 	 * @param string $date_format Supports any PHP date format from {@see http://php.net/strftime} (empty for the raw data)
863
-	 * @return int|string|null
863
+	 * @return string|null
864 864
 	 */
865 865
 	public function get_local_date($date_format = '%c')
866 866
 	{
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
 	 *
884 884
 	 * @see get_date
885 885
 	 * @param string $date_format Supports any PHP date format from {@see http://php.net/date}
886
-	 * @return int|string|null
886
+	 * @return null|string
887 887
 	 */
888 888
 	public function get_gmdate($date_format = 'j F Y, g:i a')
889 889
 	{
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
 	 *
902 902
 	 * @see get_updated_date
903 903
 	 * @param string $date_format Supports any PHP date format from {@see http://php.net/date}
904
-	 * @return int|string|null
904
+	 * @return null|string
905 905
 	 */
906 906
 	public function get_updated_gmdate($date_format = 'j F Y, g:i a')
907 907
 	{
@@ -2893,7 +2893,7 @@  discard block
 block discarded – undo
2893 2893
 	 * @since 1.0
2894 2894
 	 * @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo
2895 2895
 	 * @link http://www.georss.org/ GeoRSS
2896
-	 * @return string|null
2896
+	 * @return double|null
2897 2897
 	 */
2898 2898
 	public function get_latitude()
2899 2899
 	{
@@ -2921,7 +2921,7 @@  discard block
 block discarded – undo
2921 2921
 	 * @since 1.0
2922 2922
 	 * @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo
2923 2923
 	 * @link http://www.georss.org/ GeoRSS
2924
-	 * @return string|null
2924
+	 * @return double|null
2925 2925
 	 */
2926 2926
 	public function get_longitude()
2927 2927
 	{
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 */
123 123
 	public function __destruct()
124 124
 	{
125
-		if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode'))
125
+		if ((version_compare(PHP_VERSION, '5.3', '<') || ! gc_enabled()) && ! ini_get('zend.ze1_compatibility_mode'))
126 126
 		{
127 127
 			unset($this->feed);
128 128
 		}
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 	 */
213 213
 	public function get_id($hash = false)
214 214
 	{
215
-		if (!$hash)
215
+		if ( ! $hash)
216 216
 		{
217 217
 			if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'id'))
218 218
 			{
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 		}
250 250
 		if ($this->get_permalink() !== null || $this->get_title() !== null)
251 251
 		{
252
-			return md5($this->get_permalink() . $this->get_title());
252
+			return md5($this->get_permalink().$this->get_title());
253 253
 		}
254 254
 		else
255 255
 		{
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 	 */
268 268
 	public function get_title()
269 269
 	{
270
-		if (!isset($this->data['title']))
270
+		if ( ! isset($this->data['title']))
271 271
 		{
272 272
 			if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title'))
273 273
 			{
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML);
360 360
 		}
361 361
 
362
-		elseif (!$description_only)
362
+		elseif ( ! $description_only)
363 363
 		{
364 364
 			return $this->get_content(true);
365 365
 		}
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 		{
398 398
 			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
399 399
 		}
400
-		elseif (!$content_only)
400
+		elseif ( ! $content_only)
401 401
 		{
402 402
 			return $this->get_description(true);
403 403
 		}
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
 			$categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
483 483
 		}
484 484
 
485
-		if (!empty($categories))
485
+		if ( ! empty($categories))
486 486
 		{
487 487
 			return array_unique($categories);
488 488
 		}
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
 			}
589 589
 		}
590 590
 
591
-		if (!empty($contributors))
591
+		if ( ! empty($contributors))
592 592
 		{
593 593
 			return array_unique($contributors);
594 594
 		}
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
 			$authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
671 671
 		}
672 672
 
673
-		if (!empty($authors))
673
+		if ( ! empty($authors))
674 674
 		{
675 675
 			return array_unique($authors);
676 676
 		}
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 	 */
733 733
 	public function get_date($date_format = 'j F Y, g:i a')
734 734
 	{
735
-		if (!isset($this->data['date']))
735
+		if ( ! isset($this->data['date']))
736 736
 		{
737 737
 			if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'published'))
738 738
 			{
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
 				$this->data['date']['raw'] = $return[0]['data'];
768 768
 			}
769 769
 
770
-			if (!empty($this->data['date']['raw']))
770
+			if ( ! empty($this->data['date']['raw']))
771 771
 			{
772 772
 				$parser = $this->registry->call('Parse_Date', 'get');
773 773
 				$this->data['date']['parsed'] = $parser->parse($this->data['date']['raw']);
@@ -811,14 +811,14 @@  discard block
 block discarded – undo
811 811
 	 */
812 812
 	public function get_updated_date($date_format = 'j F Y, g:i a')
813 813
 	{
814
-		if (!isset($this->data['updated']))
814
+		if ( ! isset($this->data['updated']))
815 815
 		{
816 816
 			if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated'))
817 817
 			{
818 818
 				$this->data['updated']['raw'] = $return[0]['data'];
819 819
 			}
820 820
 
821
-			if (!empty($this->data['updated']['raw']))
821
+			if ( ! empty($this->data['updated']['raw']))
822 822
 			{
823 823
 				$parser = $this->registry->call('Parse_Date', 'get');
824 824
 				$this->data['updated']['parsed'] = $parser->parse($this->data['date']['raw']);
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
 	 */
865 865
 	public function get_local_date($date_format = '%c')
866 866
 	{
867
-		if (!$date_format)
867
+		if ( ! $date_format)
868 868
 		{
869 869
 			return $this->sanitize($this->get_date(''), SIMPLEPIE_CONSTRUCT_TEXT);
870 870
 		}
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
 	 */
975 975
 	public function get_links($rel = 'alternate')
976 976
 	{
977
-		if (!isset($this->data['links']))
977
+		if ( ! isset($this->data['links']))
978 978
 		{
979 979
 			$this->data['links'] = array();
980 980
 			foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link)
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
 			}
1009 1009
 			if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid'))
1010 1010
 			{
1011
-				if (!isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) === 'true')
1011
+				if ( ! isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) === 'true')
1012 1012
 				{
1013 1013
 					$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
1014 1014
 				}
@@ -1019,19 +1019,19 @@  discard block
 block discarded – undo
1019 1019
 			{
1020 1020
 				if ($this->registry->call('Misc', 'is_isegment_nz_nc', array($key)))
1021 1021
 				{
1022
-					if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]))
1022
+					if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key]))
1023 1023
 					{
1024
-						$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]);
1025
-						$this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key];
1024
+						$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key]);
1025
+						$this->data['links'][$key] = & $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key];
1026 1026
 					}
1027 1027
 					else
1028 1028
 					{
1029
-						$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
1029
+						$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key] = & $this->data['links'][$key];
1030 1030
 					}
1031 1031
 				}
1032 1032
 				elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
1033 1033
 				{
1034
-					$this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
1034
+					$this->data['links'][substr($key, 41)] = & $this->data['links'][$key];
1035 1035
 				}
1036 1036
 				$this->data['links'][$key] = array_unique($this->data['links'][$key]);
1037 1037
 			}
@@ -1085,7 +1085,7 @@  discard block
 block discarded – undo
1085 1085
 	 */
1086 1086
 	public function get_enclosures()
1087 1087
 	{
1088
-		if (!isset($this->data['enclosures']))
1088
+		if ( ! isset($this->data['enclosures']))
1089 1089
 		{
1090 1090
 			$this->data['enclosures'] = array();
1091 1091
 
@@ -1732,7 +1732,7 @@  discard block
 block discarded – undo
1732 1732
 			// If we have media:group tags, loop through them.
1733 1733
 			foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group') as $group)
1734 1734
 			{
1735
-				if(isset($group['child']) && isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content']))
1735
+				if (isset($group['child']) && isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content']))
1736 1736
 				{
1737 1737
 					// If we have media:content tags, loop through them.
1738 1738
 					foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
@@ -2762,7 +2762,7 @@  discard block
 block discarded – undo
2762 2762
 
2763 2763
 			foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link)
2764 2764
 			{
2765
-				if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure')
2765
+				if (isset($link['attribs']['']['href']) && ! empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure')
2766 2766
 				{
2767 2767
 					// Attributes
2768 2768
 					$bitrate = null;
@@ -2797,7 +2797,7 @@  discard block
 block discarded – undo
2797 2797
 
2798 2798
 			foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link)
2799 2799
 			{
2800
-				if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure')
2800
+				if (isset($link['attribs']['']['href']) && ! empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure')
2801 2801
 				{
2802 2802
 					// Attributes
2803 2803
 					$bitrate = null;
@@ -2873,7 +2873,7 @@  discard block
 block discarded – undo
2873 2873
 
2874 2874
 			$this->data['enclosures'] = array_values(array_unique($this->data['enclosures']));
2875 2875
 		}
2876
-		if (!empty($this->data['enclosures']))
2876
+		if ( ! empty($this->data['enclosures']))
2877 2877
 		{
2878 2878
 			return $this->data['enclosures'];
2879 2879
 		}
Please login to merge, or discard this patch.
Braces   +147 added lines, -295 removed lines patch added patch discarded remove patch
@@ -147,8 +147,7 @@  discard block
 block discarded – undo
147 147
 		if (isset($this->data['child'][$namespace][$tag]))
148 148
 		{
149 149
 			return $this->data['child'][$namespace][$tag];
150
-		}
151
-		else
150
+		} else
152 151
 		{
153 152
 			return null;
154 153
 		}
@@ -217,32 +216,25 @@  discard block
 block discarded – undo
217 216
 			if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'id'))
218 217
 			{
219 218
 				return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
220
-			}
221
-			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'id'))
219
+			} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'id'))
222 220
 			{
223 221
 				return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
224
-			}
225
-			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid'))
222
+			} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid'))
226 223
 			{
227 224
 				return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
228
-			}
229
-			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'identifier'))
225
+			} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'identifier'))
230 226
 			{
231 227
 				return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
232
-			}
233
-			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'identifier'))
228
+			} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'identifier'))
234 229
 			{
235 230
 				return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
236
-			}
237
-			elseif (isset($this->data['attribs'][SIMPLEPIE_NAMESPACE_RDF]['about']))
231
+			} elseif (isset($this->data['attribs'][SIMPLEPIE_NAMESPACE_RDF]['about']))
238 232
 			{
239 233
 				return $this->sanitize($this->data['attribs'][SIMPLEPIE_NAMESPACE_RDF]['about'], SIMPLEPIE_CONSTRUCT_TEXT);
240
-			}
241
-			elseif (($return = $this->get_permalink()) !== null)
234
+			} elseif (($return = $this->get_permalink()) !== null)
242 235
 			{
243 236
 				return $return;
244
-			}
245
-			elseif (($return = $this->get_title()) !== null)
237
+			} elseif (($return = $this->get_title()) !== null)
246 238
 			{
247 239
 				return $return;
248 240
 			}
@@ -250,8 +242,7 @@  discard block
 block discarded – undo
250 242
 		if ($this->get_permalink() !== null || $this->get_title() !== null)
251 243
 		{
252 244
 			return md5($this->get_permalink() . $this->get_title());
253
-		}
254
-		else
245
+		} else
255 246
 		{
256 247
 			return md5(serialize($this->data));
257 248
 		}
@@ -272,32 +263,25 @@  discard block
 block discarded – undo
272 263
 			if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title'))
273 264
 			{
274 265
 				$this->data['title'] = $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
275
-			}
276
-			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title'))
266
+			} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title'))
277 267
 			{
278 268
 				$this->data['title'] = $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
279
-			}
280
-			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
269
+			} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
281 270
 			{
282 271
 				$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
283
-			}
284
-			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
272
+			} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
285 273
 			{
286 274
 				$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
287
-			}
288
-			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title'))
275
+			} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title'))
289 276
 			{
290 277
 				$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
291
-			}
292
-			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
278
+			} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
293 279
 			{
294 280
 				$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
295
-			}
296
-			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
281
+			} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
297 282
 			{
298 283
 				$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
299
-			}
300
-			else
284
+			} else
301 285
 			{
302 286
 				$this->data['title'] = null;
303 287
 			}
@@ -325,45 +309,34 @@  discard block
 block discarded – undo
325 309
 		if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary'))
326 310
 		{
327 311
 			return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
328
-		}
329
-		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'summary'))
312
+		} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'summary'))
330 313
 		{
331 314
 			return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
332
-		}
333
-		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description'))
315
+		} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description'))
334 316
 		{
335 317
 			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
336
-		}
337
-		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description'))
318
+		} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description'))
338 319
 		{
339 320
 			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
340
-		}
341
-		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description'))
321
+		} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description'))
342 322
 		{
343 323
 			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
344
-		}
345
-		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description'))
324
+		} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description'))
346 325
 		{
347 326
 			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
348
-		}
349
-		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary'))
327
+		} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary'))
350 328
 		{
351 329
 			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
352
-		}
353
-		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle'))
330
+		} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle'))
354 331
 		{
355 332
 			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
356
-		}
357
-		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description'))
333
+		} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description'))
358 334
 		{
359 335
 			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML);
360
-		}
361
-
362
-		elseif (!$description_only)
336
+		} elseif (!$description_only)
363 337
 		{
364 338
 			return $this->get_content(true);
365
-		}
366
-		else
339
+		} else
367 340
 		{
368 341
 			return null;
369 342
 		}
@@ -388,20 +361,16 @@  discard block
 block discarded – undo
388 361
 		if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'content'))
389 362
 		{
390 363
 			return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_content_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
391
-		}
392
-		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'content'))
364
+		} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'content'))
393 365
 		{
394 366
 			return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
395
-		}
396
-		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT, 'encoded'))
367
+		} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT, 'encoded'))
397 368
 		{
398 369
 			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
399
-		}
400
-		elseif (!$content_only)
370
+		} elseif (!$content_only)
401 371
 		{
402 372
 			return $this->get_description(true);
403
-		}
404
-		else
373
+		} else
405 374
 		{
406 375
 			return null;
407 376
 		}
@@ -420,8 +389,7 @@  discard block
 block discarded – undo
420 389
 		if (isset($categories[$key]))
421 390
 		{
422 391
 			return $categories[$key];
423
-		}
424
-		else
392
+		} else
425 393
 		{
426 394
 			return null;
427 395
 		}
@@ -466,8 +434,7 @@  discard block
 block discarded – undo
466 434
 			if (isset($category['attribs']['']['domain']))
467 435
 			{
468 436
 				$scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT);
469
-			}
470
-			else
437
+			} else
471 438
 			{
472 439
 				$scheme = null;
473 440
 			}
@@ -485,8 +452,7 @@  discard block
 block discarded – undo
485 452
 		if (!empty($categories))
486 453
 		{
487 454
 			return array_unique($categories);
488
-		}
489
-		else
455
+		} else
490 456
 		{
491 457
 			return null;
492 458
 		}
@@ -505,8 +471,7 @@  discard block
 block discarded – undo
505 471
 		if (isset($authors[$key]))
506 472
 		{
507 473
 			return $authors[$key];
508
-		}
509
-		else
474
+		} else
510 475
 		{
511 476
 			return null;
512 477
 		}
@@ -525,8 +490,7 @@  discard block
 block discarded – undo
525 490
 		if (isset($contributors[$key]))
526 491
 		{
527 492
 			return $contributors[$key];
528
-		}
529
-		else
493
+		} else
530 494
 		{
531 495
 			return null;
532 496
 		}
@@ -591,8 +555,7 @@  discard block
 block discarded – undo
591 555
 		if (!empty($contributors))
592 556
 		{
593 557
 			return array_unique($contributors);
594
-		}
595
-		else
558
+		} else
596 559
 		{
597 560
 			return null;
598 561
 		}
@@ -673,16 +636,13 @@  discard block
 block discarded – undo
673 636
 		if (!empty($authors))
674 637
 		{
675 638
 			return array_unique($authors);
676
-		}
677
-		elseif (($source = $this->get_source()) && ($authors = $source->get_authors()))
639
+		} elseif (($source = $this->get_source()) && ($authors = $source->get_authors()))
678 640
 		{
679 641
 			return $authors;
680
-		}
681
-		elseif ($authors = $this->feed->get_authors())
642
+		} elseif ($authors = $this->feed->get_authors())
682 643
 		{
683 644
 			return $authors;
684
-		}
685
-		else
645
+		} else
686 646
 		{
687 647
 			return null;
688 648
 		}
@@ -701,16 +661,13 @@  discard block
 block discarded – undo
701 661
 		if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights'))
702 662
 		{
703 663
 			return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
704
-		}
705
-		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights'))
664
+		} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights'))
706 665
 		{
707 666
 			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
708
-		}
709
-		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights'))
667
+		} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights'))
710 668
 		{
711 669
 			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
712
-		}
713
-		else
670
+		} else
714 671
 		{
715 672
 			return null;
716 673
 		}
@@ -737,32 +694,25 @@  discard block
 block discarded – undo
737 694
 			if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'published'))
738 695
 			{
739 696
 				$this->data['date']['raw'] = $return[0]['data'];
740
-			}
741
-			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated'))
697
+			} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated'))
742 698
 			{
743 699
 				$this->data['date']['raw'] = $return[0]['data'];
744
-			}
745
-			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'issued'))
700
+			} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'issued'))
746 701
 			{
747 702
 				$this->data['date']['raw'] = $return[0]['data'];
748
-			}
749
-			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'created'))
703
+			} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'created'))
750 704
 			{
751 705
 				$this->data['date']['raw'] = $return[0]['data'];
752
-			}
753
-			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'modified'))
706
+			} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'modified'))
754 707
 			{
755 708
 				$this->data['date']['raw'] = $return[0]['data'];
756
-			}
757
-			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'pubDate'))
709
+			} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'pubDate'))
758 710
 			{
759 711
 				$this->data['date']['raw'] = $return[0]['data'];
760
-			}
761
-			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'date'))
712
+			} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'date'))
762 713
 			{
763 714
 				$this->data['date']['raw'] = $return[0]['data'];
764
-			}
765
-			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'date'))
715
+			} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'date'))
766 716
 			{
767 717
 				$this->data['date']['raw'] = $return[0]['data'];
768 718
 			}
@@ -771,8 +721,7 @@  discard block
 block discarded – undo
771 721
 			{
772 722
 				$parser = $this->registry->call('Parse_Date', 'get');
773 723
 				$this->data['date']['parsed'] = $parser->parse($this->data['date']['raw']);
774
-			}
775
-			else
724
+			} else
776 725
 			{
777 726
 				$this->data['date'] = null;
778 727
 			}
@@ -791,8 +740,7 @@  discard block
 block discarded – undo
791 740
 				default:
792 741
 					return date($date_format, $this->data['date']['parsed']);
793 742
 			}
794
-		}
795
-		else
743
+		} else
796 744
 		{
797 745
 			return null;
798 746
 		}
@@ -822,8 +770,7 @@  discard block
 block discarded – undo
822 770
 			{
823 771
 				$parser = $this->registry->call('Parse_Date', 'get');
824 772
 				$this->data['updated']['parsed'] = $parser->parse($this->data['date']['raw']);
825
-			}
826
-			else
773
+			} else
827 774
 			{
828 775
 				$this->data['updated'] = null;
829 776
 			}
@@ -842,8 +789,7 @@  discard block
 block discarded – undo
842 789
 				default:
843 790
 					return date($date_format, $this->data['updated']['parsed']);
844 791
 			}
845
-		}
846
-		else
792
+		} else
847 793
 		{
848 794
 			return null;
849 795
 		}
@@ -867,12 +813,10 @@  discard block
 block discarded – undo
867 813
 		if (!$date_format)
868 814
 		{
869 815
 			return $this->sanitize($this->get_date(''), SIMPLEPIE_CONSTRUCT_TEXT);
870
-		}
871
-		elseif (($date = $this->get_date('U')) !== null && $date !== false)
816
+		} elseif (($date = $this->get_date('U')) !== null && $date !== false)
872 817
 		{
873 818
 			return strftime($date_format, $date);
874
-		}
875
-		else
819
+		} else
876 820
 		{
877 821
 			return null;
878 822
 		}
@@ -931,12 +875,10 @@  discard block
 block discarded – undo
931 875
 		if ($link !== null)
932 876
 		{
933 877
 			return $link;
934
-		}
935
-		elseif ($enclosure !== null)
878
+		} elseif ($enclosure !== null)
936 879
 		{
937 880
 			return $enclosure->get_link();
938
-		}
939
-		else
881
+		} else
940 882
 		{
941 883
 			return null;
942 884
 		}
@@ -956,8 +898,7 @@  discard block
 block discarded – undo
956 898
 		if ($links[$key] !== null)
957 899
 		{
958 900
 			return $links[$key];
959
-		}
960
-		else
901
+		} else
961 902
 		{
962 903
 			return null;
963 904
 		}
@@ -1023,13 +964,11 @@  discard block
 block discarded – undo
1023 964
 					{
1024 965
 						$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]);
1025 966
 						$this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key];
1026
-					}
1027
-					else
967
+					} else
1028 968
 					{
1029 969
 						$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
1030 970
 					}
1031
-				}
1032
-				elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
971
+				} elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
1033 972
 				{
1034 973
 					$this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
1035 974
 				}
@@ -1039,8 +978,7 @@  discard block
 block discarded – undo
1039 978
 		if (isset($this->data['links'][$rel]))
1040 979
 		{
1041 980
 			return $this->data['links'][$rel];
1042
-		}
1043
-		else
981
+		} else
1044 982
 		{
1045 983
 			return null;
1046 984
 		}
@@ -1062,8 +1000,7 @@  discard block
 block discarded – undo
1062 1000
 		if (isset($enclosures[$key]))
1063 1001
 		{
1064 1002
 			return $enclosures[$key];
1065
-		}
1066
-		else
1003
+		} else
1067 1004
 		{
1068 1005
 			return null;
1069 1006
 		}
@@ -1139,8 +1076,7 @@  discard block
 block discarded – undo
1139 1076
 					}
1140 1077
 					$captions_parent[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text));
1141 1078
 				}
1142
-			}
1143
-			elseif ($captions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text'))
1079
+			} elseif ($captions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text'))
1144 1080
 			{
1145 1081
 				foreach ($captions as $caption)
1146 1082
 				{
@@ -1190,8 +1126,7 @@  discard block
 block discarded – undo
1190 1126
 				if (isset($category['attribs']['']['scheme']))
1191 1127
 				{
1192 1128
 					$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
1193
-				}
1194
-				else
1129
+				} else
1195 1130
 				{
1196 1131
 					$scheme = 'http://search.yahoo.com/mrss/category_schema';
1197 1132
 				}
@@ -1213,8 +1148,7 @@  discard block
 block discarded – undo
1213 1148
 				if (isset($category['attribs']['']['scheme']))
1214 1149
 				{
1215 1150
 					$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
1216
-				}
1217
-				else
1151
+				} else
1218 1152
 				{
1219 1153
 					$scheme = 'http://search.yahoo.com/mrss/category_schema';
1220 1154
 				}
@@ -1266,8 +1200,7 @@  discard block
 block discarded – undo
1266 1200
 					$copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1267 1201
 				}
1268 1202
 				$copyrights_parent = $this->registry->create('Copyright', array($copyright_url, $copyright_label));
1269
-			}
1270
-			elseif ($copyright = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright'))
1203
+			} elseif ($copyright = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright'))
1271 1204
 			{
1272 1205
 				$copyright_url = null;
1273 1206
 				$copyright_label = null;
@@ -1297,8 +1230,7 @@  discard block
 block discarded – undo
1297 1230
 					if (isset($credit['attribs']['']['scheme']))
1298 1231
 					{
1299 1232
 						$credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
1300
-					}
1301
-					else
1233
+					} else
1302 1234
 					{
1303 1235
 						$credit_scheme = 'urn:ebu';
1304 1236
 					}
@@ -1308,8 +1240,7 @@  discard block
 block discarded – undo
1308 1240
 					}
1309 1241
 					$credits_parent[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name));
1310 1242
 				}
1311
-			}
1312
-			elseif ($credits = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit'))
1243
+			} elseif ($credits = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit'))
1313 1244
 			{
1314 1245
 				foreach ($credits as $credit)
1315 1246
 				{
@@ -1323,8 +1254,7 @@  discard block
 block discarded – undo
1323 1254
 					if (isset($credit['attribs']['']['scheme']))
1324 1255
 					{
1325 1256
 						$credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
1326
-					}
1327
-					else
1257
+					} else
1328 1258
 					{
1329 1259
 						$credit_scheme = 'urn:ebu';
1330 1260
 					}
@@ -1347,8 +1277,7 @@  discard block
 block discarded – undo
1347 1277
 				{
1348 1278
 					$description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1349 1279
 				}
1350
-			}
1351
-			elseif ($description_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description'))
1280
+			} elseif ($description_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description'))
1352 1281
 			{
1353 1282
 				if (isset($description_parent[0]['data']))
1354 1283
 				{
@@ -1398,15 +1327,13 @@  discard block
 block discarded – undo
1398 1327
 					if (isset($hash['attribs']['']['algo']))
1399 1328
 					{
1400 1329
 						$algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
1401
-					}
1402
-					else
1330
+					} else
1403 1331
 					{
1404 1332
 						$algo = 'md5';
1405 1333
 					}
1406 1334
 					$hashes_parent[] = $algo.':'.$value;
1407 1335
 				}
1408
-			}
1409
-			elseif ($hashes_iterator = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash'))
1336
+			} elseif ($hashes_iterator = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash'))
1410 1337
 			{
1411 1338
 				foreach ($hashes_iterator as $hash)
1412 1339
 				{
@@ -1419,8 +1346,7 @@  discard block
 block discarded – undo
1419 1346
 					if (isset($hash['attribs']['']['algo']))
1420 1347
 					{
1421 1348
 						$algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
1422
-					}
1423
-					else
1349
+					} else
1424 1350
 					{
1425 1351
 						$algo = 'md5';
1426 1352
 					}
@@ -1444,8 +1370,7 @@  discard block
 block discarded – undo
1444 1370
 					}
1445 1371
 				}
1446 1372
 				unset($temp);
1447
-			}
1448
-			elseif ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords'))
1373
+			} elseif ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords'))
1449 1374
 			{
1450 1375
 				if (isset($keywords[0]['data']))
1451 1376
 				{
@@ -1456,8 +1381,7 @@  discard block
 block discarded – undo
1456 1381
 					}
1457 1382
 				}
1458 1383
 				unset($temp);
1459
-			}
1460
-			elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords'))
1384
+			} elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords'))
1461 1385
 			{
1462 1386
 				if (isset($keywords[0]['data']))
1463 1387
 				{
@@ -1468,8 +1392,7 @@  discard block
 block discarded – undo
1468 1392
 					}
1469 1393
 				}
1470 1394
 				unset($temp);
1471
-			}
1472
-			elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords'))
1395
+			} elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords'))
1473 1396
 			{
1474 1397
 				if (isset($keywords[0]['data']))
1475 1398
 				{
@@ -1493,8 +1416,7 @@  discard block
 block discarded – undo
1493 1416
 				{
1494 1417
 					$player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
1495 1418
 				}
1496
-			}
1497
-			elseif ($player_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player'))
1419
+			} elseif ($player_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player'))
1498 1420
 			{
1499 1421
 				if (isset($player_parent[0]['attribs']['']['url']))
1500 1422
 				{
@@ -1512,8 +1434,7 @@  discard block
 block discarded – undo
1512 1434
 					if (isset($rating['attribs']['']['scheme']))
1513 1435
 					{
1514 1436
 						$rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
1515
-					}
1516
-					else
1437
+					} else
1517 1438
 					{
1518 1439
 						$rating_scheme = 'urn:simple';
1519 1440
 					}
@@ -1523,8 +1444,7 @@  discard block
 block discarded – undo
1523 1444
 					}
1524 1445
 					$ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value));
1525 1446
 				}
1526
-			}
1527
-			elseif ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit'))
1447
+			} elseif ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit'))
1528 1448
 			{
1529 1449
 				foreach ($ratings as $rating)
1530 1450
 				{
@@ -1536,8 +1456,7 @@  discard block
 block discarded – undo
1536 1456
 					}
1537 1457
 					$ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value));
1538 1458
 				}
1539
-			}
1540
-			elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating'))
1459
+			} elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating'))
1541 1460
 			{
1542 1461
 				foreach ($ratings as $rating)
1543 1462
 				{
@@ -1546,8 +1465,7 @@  discard block
 block discarded – undo
1546 1465
 					if (isset($rating['attribs']['']['scheme']))
1547 1466
 					{
1548 1467
 						$rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
1549
-					}
1550
-					else
1468
+					} else
1551 1469
 					{
1552 1470
 						$rating_scheme = 'urn:simple';
1553 1471
 					}
@@ -1557,8 +1475,7 @@  discard block
 block discarded – undo
1557 1475
 					}
1558 1476
 					$ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value));
1559 1477
 				}
1560
-			}
1561
-			elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit'))
1478
+			} elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit'))
1562 1479
 			{
1563 1480
 				foreach ($ratings as $rating)
1564 1481
 				{
@@ -1598,8 +1515,7 @@  discard block
 block discarded – undo
1598 1515
 					}
1599 1516
 					$restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
1600 1517
 				}
1601
-			}
1602
-			elseif ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block'))
1518
+			} elseif ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block'))
1603 1519
 			{
1604 1520
 				foreach ($restrictions as $restriction)
1605 1521
 				{
@@ -1612,8 +1528,7 @@  discard block
 block discarded – undo
1612 1528
 					}
1613 1529
 					$restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
1614 1530
 				}
1615
-			}
1616
-			elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction'))
1531
+			} elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction'))
1617 1532
 			{
1618 1533
 				foreach ($restrictions as $restriction)
1619 1534
 				{
@@ -1634,8 +1549,7 @@  discard block
 block discarded – undo
1634 1549
 					}
1635 1550
 					$restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
1636 1551
 				}
1637
-			}
1638
-			elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block'))
1552
+			} elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block'))
1639 1553
 			{
1640 1554
 				foreach ($restrictions as $restriction)
1641 1555
 				{
@@ -1652,8 +1566,7 @@  discard block
 block discarded – undo
1652 1566
 			if (is_array($restrictions_parent))
1653 1567
 			{
1654 1568
 				$restrictions_parent = array_values(array_unique($restrictions_parent));
1655
-			}
1656
-			else
1569
+			} else
1657 1570
 			{
1658 1571
 				$restrictions_parent = array(new SimplePie_Restriction('allow', null, 'default'));
1659 1572
 			}
@@ -1668,8 +1581,7 @@  discard block
 block discarded – undo
1668 1581
 						$thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
1669 1582
 					}
1670 1583
 				}
1671
-			}
1672
-			elseif ($thumbnails = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail'))
1584
+			} elseif ($thumbnails = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail'))
1673 1585
 			{
1674 1586
 				foreach ($thumbnails as $thumbnail)
1675 1587
 				{
@@ -1687,8 +1599,7 @@  discard block
 block discarded – undo
1687 1599
 				{
1688 1600
 					$title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1689 1601
 				}
1690
-			}
1691
-			elseif ($title_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title'))
1602
+			} elseif ($title_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title'))
1692 1603
 			{
1693 1604
 				if (isset($title_parent[0]['data']))
1694 1605
 				{
@@ -1781,8 +1692,7 @@  discard block
 block discarded – undo
1781 1692
 							if (isset($content['attribs']['']['duration']))
1782 1693
 							{
1783 1694
 								$duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT);
1784
-							}
1785
-							else
1695
+							} else
1786 1696
 							{
1787 1697
 								$duration = $duration_parent;
1788 1698
 							}
@@ -1862,8 +1772,7 @@  discard block
 block discarded – undo
1862 1772
 								{
1863 1773
 									$captions = array_values(array_unique($captions));
1864 1774
 								}
1865
-							}
1866
-							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
1775
+							} elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
1867 1776
 							{
1868 1777
 								foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
1869 1778
 								{
@@ -1898,8 +1807,7 @@  discard block
 block discarded – undo
1898 1807
 								{
1899 1808
 									$captions = array_values(array_unique($captions));
1900 1809
 								}
1901
-							}
1902
-							else
1810
+							} else
1903 1811
 							{
1904 1812
 								$captions = $captions_parent;
1905 1813
 							}
@@ -1919,8 +1827,7 @@  discard block
 block discarded – undo
1919 1827
 									if (isset($category['attribs']['']['scheme']))
1920 1828
 									{
1921 1829
 										$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
1922
-									}
1923
-									else
1830
+									} else
1924 1831
 									{
1925 1832
 										$scheme = 'http://search.yahoo.com/mrss/category_schema';
1926 1833
 									}
@@ -1945,8 +1852,7 @@  discard block
 block discarded – undo
1945 1852
 									if (isset($category['attribs']['']['scheme']))
1946 1853
 									{
1947 1854
 										$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
1948
-									}
1949
-									else
1855
+									} else
1950 1856
 									{
1951 1857
 										$scheme = 'http://search.yahoo.com/mrss/category_schema';
1952 1858
 									}
@@ -1960,12 +1866,10 @@  discard block
 block discarded – undo
1960 1866
 							if (is_array($categories) && is_array($categories_parent))
1961 1867
 							{
1962 1868
 								$categories = array_values(array_unique(array_merge($categories, $categories_parent)));
1963
-							}
1964
-							elseif (is_array($categories))
1869
+							} elseif (is_array($categories))
1965 1870
 							{
1966 1871
 								$categories = array_values(array_unique($categories));
1967
-							}
1968
-							elseif (is_array($categories_parent))
1872
+							} elseif (is_array($categories_parent))
1969 1873
 							{
1970 1874
 								$categories = array_values(array_unique($categories_parent));
1971 1875
 							}
@@ -1984,8 +1888,7 @@  discard block
 block discarded – undo
1984 1888
 									$copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1985 1889
 								}
1986 1890
 								$copyrights = $this->registry->create('Copyright', array($copyright_url, $copyright_label));
1987
-							}
1988
-							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
1891
+							} elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
1989 1892
 							{
1990 1893
 								$copyright_url = null;
1991 1894
 								$copyright_label = null;
@@ -1998,8 +1901,7 @@  discard block
 block discarded – undo
1998 1901
 									$copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1999 1902
 								}
2000 1903
 								$copyrights = $this->registry->create('Copyright', array($copyright_url, $copyright_label));
2001
-							}
2002
-							else
1904
+							} else
2003 1905
 							{
2004 1906
 								$copyrights = $copyrights_parent;
2005 1907
 							}
@@ -2019,8 +1921,7 @@  discard block
 block discarded – undo
2019 1921
 									if (isset($credit['attribs']['']['scheme']))
2020 1922
 									{
2021 1923
 										$credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
2022
-									}
2023
-									else
1924
+									} else
2024 1925
 									{
2025 1926
 										$credit_scheme = 'urn:ebu';
2026 1927
 									}
@@ -2034,8 +1935,7 @@  discard block
 block discarded – undo
2034 1935
 								{
2035 1936
 									$credits = array_values(array_unique($credits));
2036 1937
 								}
2037
-							}
2038
-							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
1938
+							} elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
2039 1939
 							{
2040 1940
 								foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
2041 1941
 								{
@@ -2049,8 +1949,7 @@  discard block
 block discarded – undo
2049 1949
 									if (isset($credit['attribs']['']['scheme']))
2050 1950
 									{
2051 1951
 										$credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
2052
-									}
2053
-									else
1952
+									} else
2054 1953
 									{
2055 1954
 										$credit_scheme = 'urn:ebu';
2056 1955
 									}
@@ -2064,8 +1963,7 @@  discard block
 block discarded – undo
2064 1963
 								{
2065 1964
 									$credits = array_values(array_unique($credits));
2066 1965
 								}
2067
-							}
2068
-							else
1966
+							} else
2069 1967
 							{
2070 1968
 								$credits = $credits_parent;
2071 1969
 							}
@@ -2074,12 +1972,10 @@  discard block
 block discarded – undo
2074 1972
 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
2075 1973
 							{
2076 1974
 								$description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2077
-							}
2078
-							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
1975
+							} elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
2079 1976
 							{
2080 1977
 								$description = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2081
-							}
2082
-							else
1978
+							} else
2083 1979
 							{
2084 1980
 								$description = $description_parent;
2085 1981
 							}
@@ -2098,8 +1994,7 @@  discard block
 block discarded – undo
2098 1994
 									if (isset($hash['attribs']['']['algo']))
2099 1995
 									{
2100 1996
 										$algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
2101
-									}
2102
-									else
1997
+									} else
2103 1998
 									{
2104 1999
 										$algo = 'md5';
2105 2000
 									}
@@ -2109,8 +2004,7 @@  discard block
 block discarded – undo
2109 2004
 								{
2110 2005
 									$hashes = array_values(array_unique($hashes));
2111 2006
 								}
2112
-							}
2113
-							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
2007
+							} elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
2114 2008
 							{
2115 2009
 								foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
2116 2010
 								{
@@ -2123,8 +2017,7 @@  discard block
 block discarded – undo
2123 2017
 									if (isset($hash['attribs']['']['algo']))
2124 2018
 									{
2125 2019
 										$algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
2126
-									}
2127
-									else
2020
+									} else
2128 2021
 									{
2129 2022
 										$algo = 'md5';
2130 2023
 									}
@@ -2134,8 +2027,7 @@  discard block
 block discarded – undo
2134 2027
 								{
2135 2028
 									$hashes = array_values(array_unique($hashes));
2136 2029
 								}
2137
-							}
2138
-							else
2030
+							} else
2139 2031
 							{
2140 2032
 								$hashes = $hashes_parent;
2141 2033
 							}
@@ -2156,8 +2048,7 @@  discard block
 block discarded – undo
2156 2048
 								{
2157 2049
 									$keywords = array_values(array_unique($keywords));
2158 2050
 								}
2159
-							}
2160
-							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
2051
+							} elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
2161 2052
 							{
2162 2053
 								if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
2163 2054
 								{
@@ -2172,8 +2063,7 @@  discard block
 block discarded – undo
2172 2063
 								{
2173 2064
 									$keywords = array_values(array_unique($keywords));
2174 2065
 								}
2175
-							}
2176
-							else
2066
+							} else
2177 2067
 							{
2178 2068
 								$keywords = $keywords_parent;
2179 2069
 							}
@@ -2182,12 +2072,10 @@  discard block
 block discarded – undo
2182 2072
 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
2183 2073
 							{
2184 2074
 								$player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
2185
-							}
2186
-							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
2075
+							} elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
2187 2076
 							{
2188 2077
 								$player = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
2189
-							}
2190
-							else
2078
+							} else
2191 2079
 							{
2192 2080
 								$player = $player_parent;
2193 2081
 							}
@@ -2202,8 +2090,7 @@  discard block
 block discarded – undo
2202 2090
 									if (isset($rating['attribs']['']['scheme']))
2203 2091
 									{
2204 2092
 										$rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
2205
-									}
2206
-									else
2093
+									} else
2207 2094
 									{
2208 2095
 										$rating_scheme = 'urn:simple';
2209 2096
 									}
@@ -2217,8 +2104,7 @@  discard block
 block discarded – undo
2217 2104
 								{
2218 2105
 									$ratings = array_values(array_unique($ratings));
2219 2106
 								}
2220
-							}
2221
-							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
2107
+							} elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
2222 2108
 							{
2223 2109
 								foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
2224 2110
 								{
@@ -2227,8 +2113,7 @@  discard block
 block discarded – undo
2227 2113
 									if (isset($rating['attribs']['']['scheme']))
2228 2114
 									{
2229 2115
 										$rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
2230
-									}
2231
-									else
2116
+									} else
2232 2117
 									{
2233 2118
 										$rating_scheme = 'urn:simple';
2234 2119
 									}
@@ -2242,8 +2127,7 @@  discard block
 block discarded – undo
2242 2127
 								{
2243 2128
 									$ratings = array_values(array_unique($ratings));
2244 2129
 								}
2245
-							}
2246
-							else
2130
+							} else
2247 2131
 							{
2248 2132
 								$ratings = $ratings_parent;
2249 2133
 							}
@@ -2274,8 +2158,7 @@  discard block
 block discarded – undo
2274 2158
 								{
2275 2159
 									$restrictions = array_values(array_unique($restrictions));
2276 2160
 								}
2277
-							}
2278
-							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
2161
+							} elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
2279 2162
 							{
2280 2163
 								foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
2281 2164
 								{
@@ -2300,8 +2183,7 @@  discard block
 block discarded – undo
2300 2183
 								{
2301 2184
 									$restrictions = array_values(array_unique($restrictions));
2302 2185
 								}
2303
-							}
2304
-							else
2186
+							} else
2305 2187
 							{
2306 2188
 								$restrictions = $restrictions_parent;
2307 2189
 							}
@@ -2317,8 +2199,7 @@  discard block
 block discarded – undo
2317 2199
 								{
2318 2200
 									$thumbnails = array_values(array_unique($thumbnails));
2319 2201
 								}
2320
-							}
2321
-							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
2202
+							} elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
2322 2203
 							{
2323 2204
 								foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
2324 2205
 								{
@@ -2328,8 +2209,7 @@  discard block
 block discarded – undo
2328 2209
 								{
2329 2210
 									$thumbnails = array_values(array_unique($thumbnails));
2330 2211
 								}
2331
-							}
2332
-							else
2212
+							} else
2333 2213
 							{
2334 2214
 								$thumbnails = $thumbnails_parent;
2335 2215
 							}
@@ -2338,12 +2218,10 @@  discard block
 block discarded – undo
2338 2218
 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
2339 2219
 							{
2340 2220
 								$title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2341
-							}
2342
-							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
2221
+							} elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
2343 2222
 							{
2344 2223
 								$title = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2345
-							}
2346
-							else
2224
+							} else
2347 2225
 							{
2348 2226
 								$title = $title_parent;
2349 2227
 							}
@@ -2403,8 +2281,7 @@  discard block
 block discarded – undo
2403 2281
 						if (isset($content['attribs']['']['duration']))
2404 2282
 						{
2405 2283
 							$duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT);
2406
-						}
2407
-						else
2284
+						} else
2408 2285
 						{
2409 2286
 							$duration = $duration_parent;
2410 2287
 						}
@@ -2486,8 +2363,7 @@  discard block
 block discarded – undo
2486 2363
 							{
2487 2364
 								$captions = array_values(array_unique($captions));
2488 2365
 							}
2489
-						}
2490
-						else
2366
+						} else
2491 2367
 						{
2492 2368
 							$captions = $captions_parent;
2493 2369
 						}
@@ -2507,8 +2383,7 @@  discard block
 block discarded – undo
2507 2383
 								if (isset($category['attribs']['']['scheme']))
2508 2384
 								{
2509 2385
 									$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
2510
-								}
2511
-								else
2386
+								} else
2512 2387
 								{
2513 2388
 									$scheme = 'http://search.yahoo.com/mrss/category_schema';
2514 2389
 								}
@@ -2522,16 +2397,13 @@  discard block
 block discarded – undo
2522 2397
 						if (is_array($categories) && is_array($categories_parent))
2523 2398
 						{
2524 2399
 							$categories = array_values(array_unique(array_merge($categories, $categories_parent)));
2525
-						}
2526
-						elseif (is_array($categories))
2400
+						} elseif (is_array($categories))
2527 2401
 						{
2528 2402
 							$categories = array_values(array_unique($categories));
2529
-						}
2530
-						elseif (is_array($categories_parent))
2403
+						} elseif (is_array($categories_parent))
2531 2404
 						{
2532 2405
 							$categories = array_values(array_unique($categories_parent));
2533
-						}
2534
-						else
2406
+						} else
2535 2407
 						{
2536 2408
 							$categories = null;
2537 2409
 						}
@@ -2550,8 +2422,7 @@  discard block
 block discarded – undo
2550 2422
 								$copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2551 2423
 							}
2552 2424
 							$copyrights = $this->registry->create('Copyright', array($copyright_url, $copyright_label));
2553
-						}
2554
-						else
2425
+						} else
2555 2426
 						{
2556 2427
 							$copyrights = $copyrights_parent;
2557 2428
 						}
@@ -2571,8 +2442,7 @@  discard block
 block discarded – undo
2571 2442
 								if (isset($credit['attribs']['']['scheme']))
2572 2443
 								{
2573 2444
 									$credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
2574
-								}
2575
-								else
2445
+								} else
2576 2446
 								{
2577 2447
 									$credit_scheme = 'urn:ebu';
2578 2448
 								}
@@ -2586,8 +2456,7 @@  discard block
 block discarded – undo
2586 2456
 							{
2587 2457
 								$credits = array_values(array_unique($credits));
2588 2458
 							}
2589
-						}
2590
-						else
2459
+						} else
2591 2460
 						{
2592 2461
 							$credits = $credits_parent;
2593 2462
 						}
@@ -2596,8 +2465,7 @@  discard block
 block discarded – undo
2596 2465
 						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
2597 2466
 						{
2598 2467
 							$description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2599
-						}
2600
-						else
2468
+						} else
2601 2469
 						{
2602 2470
 							$description = $description_parent;
2603 2471
 						}
@@ -2616,8 +2484,7 @@  discard block
 block discarded – undo
2616 2484
 								if (isset($hash['attribs']['']['algo']))
2617 2485
 								{
2618 2486
 									$algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
2619
-								}
2620
-								else
2487
+								} else
2621 2488
 								{
2622 2489
 									$algo = 'md5';
2623 2490
 								}
@@ -2627,8 +2494,7 @@  discard block
 block discarded – undo
2627 2494
 							{
2628 2495
 								$hashes = array_values(array_unique($hashes));
2629 2496
 							}
2630
-						}
2631
-						else
2497
+						} else
2632 2498
 						{
2633 2499
 							$hashes = $hashes_parent;
2634 2500
 						}
@@ -2649,8 +2515,7 @@  discard block
 block discarded – undo
2649 2515
 							{
2650 2516
 								$keywords = array_values(array_unique($keywords));
2651 2517
 							}
2652
-						}
2653
-						else
2518
+						} else
2654 2519
 						{
2655 2520
 							$keywords = $keywords_parent;
2656 2521
 						}
@@ -2659,8 +2524,7 @@  discard block
 block discarded – undo
2659 2524
 						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
2660 2525
 						{
2661 2526
 							$player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
2662
-						}
2663
-						else
2527
+						} else
2664 2528
 						{
2665 2529
 							$player = $player_parent;
2666 2530
 						}
@@ -2675,8 +2539,7 @@  discard block
 block discarded – undo
2675 2539
 								if (isset($rating['attribs']['']['scheme']))
2676 2540
 								{
2677 2541
 									$rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
2678
-								}
2679
-								else
2542
+								} else
2680 2543
 								{
2681 2544
 									$rating_scheme = 'urn:simple';
2682 2545
 								}
@@ -2690,8 +2553,7 @@  discard block
 block discarded – undo
2690 2553
 							{
2691 2554
 								$ratings = array_values(array_unique($ratings));
2692 2555
 							}
2693
-						}
2694
-						else
2556
+						} else
2695 2557
 						{
2696 2558
 							$ratings = $ratings_parent;
2697 2559
 						}
@@ -2722,8 +2584,7 @@  discard block
 block discarded – undo
2722 2584
 							{
2723 2585
 								$restrictions = array_values(array_unique($restrictions));
2724 2586
 							}
2725
-						}
2726
-						else
2587
+						} else
2727 2588
 						{
2728 2589
 							$restrictions = $restrictions_parent;
2729 2590
 						}
@@ -2739,8 +2600,7 @@  discard block
 block discarded – undo
2739 2600
 							{
2740 2601
 								$thumbnails = array_values(array_unique($thumbnails));
2741 2602
 							}
2742
-						}
2743
-						else
2603
+						} else
2744 2604
 						{
2745 2605
 							$thumbnails = $thumbnails_parent;
2746 2606
 						}
@@ -2749,8 +2609,7 @@  discard block
 block discarded – undo
2749 2609
 						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
2750 2610
 						{
2751 2611
 							$title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2752
-						}
2753
-						else
2612
+						} else
2754 2613
 						{
2755 2614
 							$title = $title_parent;
2756 2615
 						}
@@ -2876,8 +2735,7 @@  discard block
 block discarded – undo
2876 2735
 		if (!empty($this->data['enclosures']))
2877 2736
 		{
2878 2737
 			return $this->data['enclosures'];
2879
-		}
2880
-		else
2738
+		} else
2881 2739
 		{
2882 2740
 			return null;
2883 2741
 		}
@@ -2900,12 +2758,10 @@  discard block
 block discarded – undo
2900 2758
 		if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
2901 2759
 		{
2902 2760
 			return (float) $return[0]['data'];
2903
-		}
2904
-		elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
2761
+		} elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
2905 2762
 		{
2906 2763
 			return (float) $match[1];
2907
-		}
2908
-		else
2764
+		} else
2909 2765
 		{
2910 2766
 			return null;
2911 2767
 		}
@@ -2928,16 +2784,13 @@  discard block
 block discarded – undo
2928 2784
 		if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long'))
2929 2785
 		{
2930 2786
 			return (float) $return[0]['data'];
2931
-		}
2932
-		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon'))
2787
+		} elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon'))
2933 2788
 		{
2934 2789
 			return (float) $return[0]['data'];
2935
-		}
2936
-		elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
2790
+		} elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
2937 2791
 		{
2938 2792
 			return (float) $match[2];
2939
-		}
2940
-		else
2793
+		} else
2941 2794
 		{
2942 2795
 			return null;
2943 2796
 		}
@@ -2954,8 +2807,7 @@  discard block
 block discarded – undo
2954 2807
 		if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'source'))
2955 2808
 		{
2956 2809
 			return $this->registry->create('Source', array($this, $return[0]));
2957
-		}
2958
-		else
2810
+		} else
2959 2811
 		{
2960 2812
 			return null;
2961 2813
 		}
Please login to merge, or discard this patch.
src/wp-includes/SimplePie/Locator.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -210,6 +210,9 @@
 block discarded – undo
210 210
 		}
211 211
 	}
212 212
 
213
+	/**
214
+	 * @param string $name
215
+	 */
213 216
 	protected function search_elements_by_tag($name, &$done, $feeds)
214 217
 	{
215 218
 		if ($this->dom === null)
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 		$feeds = array_merge($feeds, $this->search_elements_by_tag('a', $done, $feeds));
201 201
 		$feeds = array_merge($feeds, $this->search_elements_by_tag('area', $done, $feeds));
202 202
 
203
-		if (!empty($feeds))
203
+		if ( ! empty($feeds))
204 204
 		{
205 205
 			return array_values($feeds);
206 206
 		}
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 					continue;
243 243
 				}
244 244
 
245
-				if (!in_array($href, $done) && in_array('feed', $rel) || (in_array('alternate', $rel) && !in_array('stylesheet', $rel) && $link->hasAttribute('type') && in_array(strtolower($this->registry->call('Misc', 'parse_mime', array($link->getAttribute('type')))), array('application/rss+xml', 'application/atom+xml'))) && !isset($feeds[$href]))
245
+				if ( ! in_array($href, $done) && in_array('feed', $rel) || (in_array('alternate', $rel) && ! in_array('stylesheet', $rel) && $link->hasAttribute('type') && in_array(strtolower($this->registry->call('Misc', 'parse_mime', array($link->getAttribute('type')))), array('application/rss+xml', 'application/atom+xml'))) && ! isset($feeds[$href]))
246 246
 				{
247 247
 					$this->checked_feeds++;
248 248
 					$headers = array(
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 		}
306 306
 		$this->local = array_unique($this->local);
307 307
 		$this->elsewhere = array_unique($this->elsewhere);
308
-		if (!empty($this->local) || !empty($this->elsewhere))
308
+		if ( ! empty($this->local) || ! empty($this->elsewhere))
309 309
 		{
310 310
 			return true;
311 311
 		}
Please login to merge, or discard this patch.
Braces   +10 added lines, -20 removed lines patch added patch discarded remove patch
@@ -79,8 +79,7 @@  discard block
 block discarded – undo
79 79
 			set_error_handler(array('SimplePie_Misc', 'silence_errors'));
80 80
 			$this->dom->loadHTML($this->file->body);
81 81
 			restore_error_handler();
82
-		}
83
-		else
82
+		} else
84 83
 		{
85 84
 			$this->dom = null;
86 85
 		}
@@ -151,17 +150,14 @@  discard block
 block discarded – undo
151 150
 			if (in_array($sniffed, array('application/rss+xml', 'application/rdf+xml', 'text/rdf', 'application/atom+xml', 'text/xml', 'application/xml')))
152 151
 			{
153 152
 				return true;
154
-			}
155
-			else
153
+			} else
156 154
 			{
157 155
 				return false;
158 156
 			}
159
-		}
160
-		elseif ($file->method & SIMPLEPIE_FILE_SOURCE_LOCAL)
157
+		} elseif ($file->method & SIMPLEPIE_FILE_SOURCE_LOCAL)
161 158
 		{
162 159
 			return true;
163
-		}
164
-		else
160
+		} else
165 161
 		{
166 162
 			return false;
167 163
 		}
@@ -203,8 +199,7 @@  discard block
 block discarded – undo
203 199
 		if (!empty($feeds))
204 200
 		{
205 201
 			return array_values($feeds);
206
-		}
207
-		else
202
+		} else
208 203
 		{
209 204
 			return null;
210 205
 		}
@@ -232,8 +227,7 @@  discard block
 block discarded – undo
232 227
 				if ($this->base_location < $line)
233 228
 				{
234 229
 					$href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->base));
235
-				}
236
-				else
230
+				} else
237 231
 				{
238 232
 					$href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->http_base));
239 233
 				}
@@ -280,8 +274,7 @@  discard block
 block discarded – undo
280 274
 					if (method_exists($link, 'getLineNo') && $this->base_location < $link->getLineNo())
281 275
 					{
282 276
 						$href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->base));
283
-					}
284
-					else
277
+					} else
285 278
 					{
286 279
 						$href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->http_base));
287 280
 					}
@@ -295,8 +288,7 @@  discard block
 block discarded – undo
295 288
 					if ($parsed['authority'] === '' || $parsed['authority'] === $current['authority'])
296 289
 					{
297 290
 						$this->local[] = $href;
298
-					}
299
-					else
291
+					} else
300 292
 					{
301 293
 						$this->elsewhere[] = $href;
302 294
 					}
@@ -331,8 +323,7 @@  discard block
 block discarded – undo
331 323
 				if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed))
332 324
 				{
333 325
 					return $feed;
334
-				}
335
-				else
326
+				} else
336 327
 				{
337 328
 					unset($array[$key]);
338 329
 				}
@@ -359,8 +350,7 @@  discard block
 block discarded – undo
359 350
 				if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed))
360 351
 				{
361 352
 					return $feed;
362
-				}
363
-				else
353
+				} else
364 354
 				{
365 355
 					unset($array[$key]);
366 356
 				}
Please login to merge, or discard this patch.
src/wp-includes/SimplePie/Misc.php 3 patches
Doc Comments   +17 added lines, -2 removed lines patch added patch discarded remove patch
@@ -49,6 +49,9 @@  discard block
 block discarded – undo
49 49
  */
50 50
 class SimplePie_Misc
51 51
 {
52
+	/**
53
+	 * @param integer $seconds
54
+	 */
52 55
 	public static function time_hms($seconds)
53 56
 	{
54 57
 		$time = '';
@@ -329,6 +332,11 @@  discard block
 block discarded – undo
329 332
 		}
330 333
 	}
331 334
 
335
+	/**
336
+	 * @param string $data
337
+	 * @param string $input
338
+	 * @param string $output
339
+	 */
332 340
 	protected static function change_encoding_mbstring($data, $input, $output)
333 341
 	{
334 342
 		if ($input === 'windows-949')
@@ -367,6 +375,11 @@  discard block
 block discarded – undo
367 375
 		return false;
368 376
 	}
369 377
 
378
+	/**
379
+	 * @param string $data
380
+	 * @param string $input
381
+	 * @param string $output
382
+	 */
370 383
 	protected static function change_encoding_iconv($data, $input, $output)
371 384
 	{
372 385
 		return @iconv($input, $output, $data);
@@ -1696,6 +1709,9 @@  discard block
 block discarded – undo
1696 1709
 		}
1697 1710
 	}
1698 1711
 
1712
+	/**
1713
+	 * @return string
1714
+	 */
1699 1715
 	public static function get_curl_version()
1700 1716
 	{
1701 1717
 		if (is_array($curl = curl_version()))
@@ -1763,7 +1779,6 @@  discard block
 block discarded – undo
1763 1779
 	/**
1764 1780
 	 * Remove RFC822 comments
1765 1781
 	 *
1766
-	 * @param string $data Data to strip comments from
1767 1782
 	 * @return string Comment stripped string
1768 1783
 	 */
1769 1784
 	public static function uncomment_rfc822($string)
@@ -2019,7 +2034,7 @@  discard block
 block discarded – undo
2019 2034
 	 * @todo Add support for EBCDIC
2020 2035
 	 * @param string $data XML data
2021 2036
 	 * @param SimplePie_Registry $registry Class registry
2022
-	 * @return array Possible encodings
2037
+	 * @return string[] Possible encodings
2023 2038
 	 */
2024 2039
 	public static function xml_encoding($data, $registry)
2025 2040
 	{
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
 		$seconds = $remainder % 60;
65 65
 		if ($minutes < 10 && $hours > 0)
66 66
 		{
67
-			$minutes = '0' . $minutes;
67
+			$minutes = '0'.$minutes;
68 68
 		}
69 69
 		if ($seconds < 10)
70 70
 		{
71
-			$seconds = '0' . $seconds;
71
+			$seconds = '0'.$seconds;
72 72
 		}
73 73
 
74 74
 		$time .= $minutes.':';
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	{
100 100
 		$return = array();
101 101
 		$name = preg_quote($realname, '/');
102
-		if (preg_match_all("/<($name)" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . "(>(.*)<\/$name>|(\/)?>)/siU", $string, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE))
102
+		if (preg_match_all("/<($name)".SIMPLEPIE_PCRE_HTML_ATTRIBUTE."(>(.*)<\/$name>|(\/)?>)/siU", $string, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE))
103 103
 		{
104 104
 			for ($i = 0, $total_matches = count($matches); $i < $total_matches; $i++)
105 105
 			{
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 					$return[$i]['content'] = $matches[$i][4][0];
117 117
 				}
118 118
 				$return[$i]['attribs'] = array();
119
-				if (isset($matches[$i][2][0]) && preg_match_all('/[\x09\x0A\x0B\x0C\x0D\x20]+([^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*)(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"([^"]*)"|\'([^\']*)\'|([^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?/', ' ' . $matches[$i][2][0] . ' ', $attribs, PREG_SET_ORDER))
119
+				if (isset($matches[$i][2][0]) && preg_match_all('/[\x09\x0A\x0B\x0C\x0D\x20]+([^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*)(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"([^"]*)"|\'([^\']*)\'|([^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?/', ' '.$matches[$i][2][0].' ', $attribs, PREG_SET_ORDER))
120 120
 				{
121 121
 					for ($j = 0, $total_attribs = count($attribs); $j < $total_attribs; $j++)
122 122
 					{
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 		foreach ($element['attribs'] as $key => $value)
139 139
 		{
140 140
 			$key = strtolower($key);
141
-			$full .= " $key=\"" . htmlspecialchars($value['data']) . '"';
141
+			$full .= " $key=\"".htmlspecialchars($value['data']).'"';
142 142
 		}
143 143
 		if ($element['self_closing'])
144 144
 		{
@@ -172,13 +172,13 @@  discard block
 block discarded – undo
172 172
 			}
173 173
 
174 174
 			$log_error = true;
175
-			if (!function_exists('error_log'))
175
+			if ( ! function_exists('error_log'))
176 176
 			{
177 177
 				$log_error = false;
178 178
 			}
179 179
 
180 180
 			$log_file = @ini_get('error_log');
181
-			if (!empty($log_file) && ('syslog' !== $log_file) && !@is_writable($log_file))
181
+			if ( ! empty($log_file) && ('syslog' !== $log_file) && ! @is_writable($log_file))
182 182
 			{
183 183
 				$log_error = false;
184 184
 			}
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 			return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['authority'], $parsed['path'], $parsed['query'], $parsed['fragment']), $http);
202 202
 		}
203 203
 
204
-		if ($parsed['scheme'] === '' && $parsed['authority'] === '' && !file_exists($url))
204
+		if ($parsed['scheme'] === '' && $parsed['authority'] === '' && ! file_exists($url))
205 205
 		{
206 206
 			return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['path'], '', $parsed['query'], $parsed['fragment']), $http);
207 207
 		}
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 		if ($input === 'US-ASCII')
298 298
 		{
299 299
 			static $non_ascii_octects = '';
300
-			if (!$non_ascii_octects)
300
+			if ( ! $non_ascii_octects)
301 301
 			{
302 302
 				for ($i = 0x80; $i <= 0xFF; $i++)
303 303
 				{
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 		{
354 354
 			return false;
355 355
 		}
356
-		if (!in_array($input, mb_list_encodings()))
356
+		if ( ! in_array($input, mb_list_encodings()))
357 357
 		{
358 358
 			return false;
359 359
 		}
@@ -1738,7 +1738,7 @@  discard block
 block discarded – undo
1738 1738
 				$data = '';
1739 1739
 			}
1740 1740
 		}
1741
-		return $output . $data;
1741
+		return $output.$data;
1742 1742
 	}
1743 1743
 
1744 1744
 	public static function parse_date($dt)
@@ -1965,15 +1965,15 @@  discard block
 block discarded – undo
1965 1965
 		}
1966 1966
 		else if ($codepoint <= 0x7ff)
1967 1967
 		{
1968
-			return chr(0xc0 | ($codepoint >> 6)) . chr(0x80 | ($codepoint & 0x3f));
1968
+			return chr(0xc0 | ($codepoint >> 6)).chr(0x80 | ($codepoint & 0x3f));
1969 1969
 		}
1970 1970
 		else if ($codepoint <= 0xffff)
1971 1971
 		{
1972
-			return chr(0xe0 | ($codepoint >> 12)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f));
1972
+			return chr(0xe0 | ($codepoint >> 12)).chr(0x80 | (($codepoint >> 6) & 0x3f)).chr(0x80 | ($codepoint & 0x3f));
1973 1973
 		}
1974 1974
 		else if ($codepoint <= 0x10ffff)
1975 1975
 		{
1976
-			return chr(0xf0 | ($codepoint >> 18)) . chr(0x80 | (($codepoint >> 12) & 0x3f)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f));
1976
+			return chr(0xf0 | ($codepoint >> 18)).chr(0x80 | (($codepoint >> 12) & 0x3f)).chr(0x80 | (($codepoint >> 6) & 0x3f)).chr(0x80 | ($codepoint & 0x3f));
1977 1977
 		}
1978 1978
 		else
1979 1979
 		{
@@ -2129,7 +2129,7 @@  discard block
 block discarded – undo
2129 2129
 		}
2130 2130
 		header('Content-type: text/javascript; charset: UTF-8');
2131 2131
 		header('Cache-Control: must-revalidate');
2132
-		header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days
2132
+		header('Expires: '.gmdate('D, d M Y H:i:s', time() + 604800).' GMT'); // 7 days
2133 2133
 		?>
2134 2134
 function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) {
2135 2135
 	if (placeholder != '') {
@@ -2163,14 +2163,14 @@  discard block
 block discarded – undo
2163 2163
 	public static function get_build()
2164 2164
 	{
2165 2165
 		$root = dirname(dirname(__FILE__));
2166
-		if (file_exists($root . '/.git/index'))
2166
+		if (file_exists($root.'/.git/index'))
2167 2167
 		{
2168
-			return filemtime($root . '/.git/index');
2168
+			return filemtime($root.'/.git/index');
2169 2169
 		}
2170
-		elseif (file_exists($root . '/SimplePie'))
2170
+		elseif (file_exists($root.'/SimplePie'))
2171 2171
 		{
2172 2172
 			$time = 0;
2173
-			foreach (glob($root . '/SimplePie/*.php') as $file)
2173
+			foreach (glob($root.'/SimplePie/*.php') as $file)
2174 2174
 			{
2175 2175
 				if (($mtime = filemtime($file)) > $time)
2176 2176
 				{
@@ -2179,9 +2179,9 @@  discard block
 block discarded – undo
2179 2179
 			}
2180 2180
 			return $time;
2181 2181
 		}
2182
-		elseif (file_exists(dirname(__FILE__) . '/Core.php'))
2182
+		elseif (file_exists(dirname(__FILE__).'/Core.php'))
2183 2183
 		{
2184
-			return filemtime(dirname(__FILE__) . '/Core.php');
2184
+			return filemtime(dirname(__FILE__).'/Core.php');
2185 2185
 		}
2186 2186
 		else
2187 2187
 		{
@@ -2194,11 +2194,11 @@  discard block
 block discarded – undo
2194 2194
 	 */
2195 2195
 	public static function debug(&$sp)
2196 2196
 	{
2197
-		$info = 'SimplePie ' . SIMPLEPIE_VERSION . ' Build ' . SIMPLEPIE_BUILD . "\n";
2198
-		$info .= 'PHP ' . PHP_VERSION . "\n";
2197
+		$info = 'SimplePie '.SIMPLEPIE_VERSION.' Build '.SIMPLEPIE_BUILD."\n";
2198
+		$info .= 'PHP '.PHP_VERSION."\n";
2199 2199
 		if ($sp->error() !== null)
2200 2200
 		{
2201
-			$info .= 'Error occurred: ' . $sp->error() . "\n";
2201
+			$info .= 'Error occurred: '.$sp->error()."\n";
2202 2202
 		}
2203 2203
 		else
2204 2204
 		{
@@ -2214,20 +2214,20 @@  discard block
 block discarded – undo
2214 2214
 				switch ($ext)
2215 2215
 				{
2216 2216
 					case 'pcre':
2217
-						$info .= '      Version ' . PCRE_VERSION . "\n";
2217
+						$info .= '      Version '.PCRE_VERSION."\n";
2218 2218
 						break;
2219 2219
 					case 'curl':
2220 2220
 						$version = curl_version();
2221
-						$info .= '      Version ' . $version['version'] . "\n";
2221
+						$info .= '      Version '.$version['version']."\n";
2222 2222
 						break;
2223 2223
 					case 'mbstring':
2224
-						$info .= '      Overloading: ' . mb_get_info('func_overload') . "\n";
2224
+						$info .= '      Overloading: '.mb_get_info('func_overload')."\n";
2225 2225
 						break;
2226 2226
 					case 'iconv':
2227
-						$info .= '      Version ' . ICONV_VERSION . "\n";
2227
+						$info .= '      Version '.ICONV_VERSION."\n";
2228 2228
 						break;
2229 2229
 					case 'xml':
2230
-						$info .= '      Version ' . LIBXML_DOTTED_VERSION . "\n";
2230
+						$info .= '      Version '.LIBXML_DOTTED_VERSION."\n";
2231 2231
 						break;
2232 2232
 				}
2233 2233
 			}
Please login to merge, or discard this patch.
Braces   +29 added lines, -58 removed lines patch added patch discarded remove patch
@@ -109,8 +109,7 @@  discard block
 block discarded – undo
109 109
 				if (strlen($matches[$i][3][0]) <= 2)
110 110
 				{
111 111
 					$return[$i]['self_closing'] = true;
112
-				}
113
-				else
112
+				} else
114 113
 				{
115 114
 					$return[$i]['self_closing'] = false;
116 115
 					$return[$i]['content'] = $matches[$i][4][0];
@@ -143,8 +142,7 @@  discard block
 block discarded – undo
143 142
 		if ($element['self_closing'])
144 143
 		{
145 144
 			$full .= ' />';
146
-		}
147
-		else
145
+		} else
148 146
 		{
149 147
 			$full .= ">$element[content]</$element[tag]>";
150 148
 		}
@@ -209,16 +207,13 @@  discard block
 block discarded – undo
209 207
 		if ($http === 2 && $parsed['scheme'] !== '')
210 208
 		{
211 209
 			return "feed:$url";
212
-		}
213
-		elseif ($http === 3 && strtolower($parsed['scheme']) === 'http')
210
+		} elseif ($http === 3 && strtolower($parsed['scheme']) === 'http')
214 211
 		{
215 212
 			return substr_replace($url, 'podcast', 0, 4);
216
-		}
217
-		elseif ($http === 4 && strtolower($parsed['scheme']) === 'http')
213
+		} elseif ($http === 4 && strtolower($parsed['scheme']) === 'http')
218 214
 		{
219 215
 			return substr_replace($url, 'itpc', 0, 4);
220
-		}
221
-		else
216
+		} else
222 217
 		{
223 218
 			return $url;
224 219
 		}
@@ -259,8 +254,7 @@  discard block
 block discarded – undo
259 254
 		if ($integer >= 0x41 && $integer <= 0x5A || $integer >= 0x61 && $integer <= 0x7A || $integer >= 0x30 && $integer <= 0x39 || $integer === 0x2D || $integer === 0x2E || $integer === 0x5F || $integer === 0x7E)
260 255
 		{
261 256
 			return chr($integer);
262
-		}
263
-		else
257
+		} else
264 258
 		{
265 259
 			return strtoupper($match[0]);
266 260
 		}
@@ -1701,16 +1695,13 @@  discard block
 block discarded – undo
1701 1695
 		if (is_array($curl = curl_version()))
1702 1696
 		{
1703 1697
 			$curl = $curl['version'];
1704
-		}
1705
-		elseif (substr($curl, 0, 5) === 'curl/')
1698
+		} elseif (substr($curl, 0, 5) === 'curl/')
1706 1699
 		{
1707 1700
 			$curl = substr($curl, 5, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 5));
1708
-		}
1709
-		elseif (substr($curl, 0, 8) === 'libcurl/')
1701
+		} elseif (substr($curl, 0, 8) === 'libcurl/')
1710 1702
 		{
1711 1703
 			$curl = substr($curl, 8, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 8));
1712
-		}
1713
-		else
1704
+		} else
1714 1705
 		{
1715 1706
 			$curl = 0;
1716 1707
 		}
@@ -1732,8 +1723,7 @@  discard block
 block discarded – undo
1732 1723
 			if (($end = strpos($data, '-->', $start)) !== false)
1733 1724
 			{
1734 1725
 				$data = substr_replace($data, '', 0, $end + 3);
1735
-			}
1736
-			else
1726
+			} else
1737 1727
 			{
1738 1728
 				$data = '';
1739 1729
 			}
@@ -1789,8 +1779,7 @@  discard block
 block discarded – undo
1789 1779
 					{
1790 1780
 						$position++;
1791 1781
 						continue;
1792
-					}
1793
-					elseif (isset($string[$position]))
1782
+					} elseif (isset($string[$position]))
1794 1783
 					{
1795 1784
 						switch ($string[$position])
1796 1785
 						{
@@ -1803,14 +1792,12 @@  discard block
 block discarded – undo
1803 1792
 								break;
1804 1793
 						}
1805 1794
 						$position++;
1806
-					}
1807
-					else
1795
+					} else
1808 1796
 					{
1809 1797
 						break;
1810 1798
 					}
1811 1799
 				}
1812
-			}
1813
-			else
1800
+			} else
1814 1801
 			{
1815 1802
 				$output .= '(';
1816 1803
 			}
@@ -1825,8 +1812,7 @@  discard block
 block discarded – undo
1825 1812
 		if (($pos = strpos($mime, ';')) === false)
1826 1813
 		{
1827 1814
 			return trim($mime);
1828
-		}
1829
-		else
1815
+		} else
1830 1816
 		{
1831 1817
 			return trim(substr($mime, 0, $pos));
1832 1818
 		}
@@ -1837,8 +1823,7 @@  discard block
 block discarded – undo
1837 1823
 		if (isset($attribs['']['mode']) && strtolower(trim($attribs['']['mode']) === 'base64'))
1838 1824
 		{
1839 1825
 			$mode = SIMPLEPIE_CONSTRUCT_BASE64;
1840
-		}
1841
-		else
1826
+		} else
1842 1827
 		{
1843 1828
 			$mode = SIMPLEPIE_CONSTRUCT_NONE;
1844 1829
 		}
@@ -1861,8 +1846,7 @@  discard block
 block discarded – undo
1861 1846
 				default:
1862 1847
 					return SIMPLEPIE_CONSTRUCT_NONE | $mode;
1863 1848
 			}
1864
-		}
1865
-		else
1849
+		} else
1866 1850
 		{
1867 1851
 			return SIMPLEPIE_CONSTRUCT_TEXT | $mode;
1868 1852
 		}
@@ -1909,13 +1893,11 @@  discard block
 block discarded – undo
1909 1893
 			if (in_array(substr($type, -4), array('+xml', '/xml')) || substr($type, 0, 5) === 'text/')
1910 1894
 			{
1911 1895
 				return SIMPLEPIE_CONSTRUCT_NONE;
1912
-			}
1913
-			else
1896
+			} else
1914 1897
 			{
1915 1898
 				return SIMPLEPIE_CONSTRUCT_BASE64;
1916 1899
 			}
1917
-		}
1918
-		else
1900
+		} else
1919 1901
 		{
1920 1902
 			return SIMPLEPIE_CONSTRUCT_TEXT;
1921 1903
 		}
@@ -1958,24 +1940,19 @@  discard block
 block discarded – undo
1958 1940
 		if ($codepoint < 0)
1959 1941
 		{
1960 1942
 			return false;
1961
-		}
1962
-		else if ($codepoint <= 0x7f)
1943
+		} else if ($codepoint <= 0x7f)
1963 1944
 		{
1964 1945
 			return chr($codepoint);
1965
-		}
1966
-		else if ($codepoint <= 0x7ff)
1946
+		} else if ($codepoint <= 0x7ff)
1967 1947
 		{
1968 1948
 			return chr(0xc0 | ($codepoint >> 6)) . chr(0x80 | ($codepoint & 0x3f));
1969
-		}
1970
-		else if ($codepoint <= 0xffff)
1949
+		} else if ($codepoint <= 0xffff)
1971 1950
 		{
1972 1951
 			return chr(0xe0 | ($codepoint >> 12)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f));
1973
-		}
1974
-		else if ($codepoint <= 0x10ffff)
1952
+		} else if ($codepoint <= 0x10ffff)
1975 1953
 		{
1976 1954
 			return chr(0xf0 | ($codepoint >> 18)) . chr(0x80 | (($codepoint >> 12) & 0x3f)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f));
1977
-		}
1978
-		else
1955
+		} else
1979 1956
 		{
1980 1957
 			// U+FFFD REPLACEMENT CHARACTER
1981 1958
 			return "\xEF\xBF\xBD";
@@ -2003,8 +1980,7 @@  discard block
 block discarded – undo
2003 1980
 			{
2004 1981
 				list($name, $value) = explode('=', $section, 2);
2005 1982
 				$return[urldecode($name)][] = urldecode($value);
2006
-			}
2007
-			else
1983
+			} else
2008 1984
 			{
2009 1985
 				$return[urldecode($section)][] = null;
2010 1986
 			}
@@ -2166,8 +2142,7 @@  discard block
 block discarded – undo
2166 2142
 		if (file_exists($root . '/.git/index'))
2167 2143
 		{
2168 2144
 			return filemtime($root . '/.git/index');
2169
-		}
2170
-		elseif (file_exists($root . '/SimplePie'))
2145
+		} elseif (file_exists($root . '/SimplePie'))
2171 2146
 		{
2172 2147
 			$time = 0;
2173 2148
 			foreach (glob($root . '/SimplePie/*.php') as $file)
@@ -2178,12 +2153,10 @@  discard block
 block discarded – undo
2178 2153
 				}
2179 2154
 			}
2180 2155
 			return $time;
2181
-		}
2182
-		elseif (file_exists(dirname(__FILE__) . '/Core.php'))
2156
+		} elseif (file_exists(dirname(__FILE__) . '/Core.php'))
2183 2157
 		{
2184 2158
 			return filemtime(dirname(__FILE__) . '/Core.php');
2185
-		}
2186
-		else
2159
+		} else
2187 2160
 		{
2188 2161
 			return filemtime(__FILE__);
2189 2162
 		}
@@ -2199,8 +2172,7 @@  discard block
 block discarded – undo
2199 2172
 		if ($sp->error() !== null)
2200 2173
 		{
2201 2174
 			$info .= 'Error occurred: ' . $sp->error() . "\n";
2202
-		}
2203
-		else
2175
+		} else
2204 2176
 		{
2205 2177
 			$info .= "No error found.\n";
2206 2178
 		}
@@ -2230,8 +2202,7 @@  discard block
 block discarded – undo
2230 2202
 						$info .= '      Version ' . LIBXML_DOTTED_VERSION . "\n";
2231 2203
 						break;
2232 2204
 				}
2233
-			}
2234
-			else
2205
+			} else
2235 2206
 			{
2236 2207
 				$info .= "    $ext not loaded\n";
2237 2208
 			}
Please login to merge, or discard this patch.
src/wp-includes/SimplePie/Net/IPv6.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -190,7 +190,7 @@
 block discarded – undo
190 190
 	 *           0:0:0:0:0:FFFF:129.144.52.38
191 191
 	 *
192 192
 	 * @param string $ip An IPv6 address
193
-	 * @return array [0] contains the IPv6 represented part, and [1] the IPv4 represented part
193
+	 * @return string[] [0] contains the IPv6 represented part, and [1] the IPv4 represented part
194 194
 	 */
195 195
 	private static function split_v6_v4($ip)
196 196
 	{
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@
 block discarded – undo
123 123
 			// xxx::xxx
124 124
 			else
125 125
 			{
126
-				$fill = ':' . str_repeat('0:', 6 - $c2 - $c1);
126
+				$fill = ':'.str_repeat('0:', 6 - $c2 - $c1);
127 127
 				$ip = str_replace('::', $fill, $ip);
128 128
 			}
129 129
 		}
Please login to merge, or discard this patch.
Braces   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -86,16 +86,14 @@  discard block
 block discarded – undo
86 86
 			if ($ip1 === '')
87 87
 			{
88 88
 				$c1 = -1;
89
-			}
90
-			else
89
+			} else
91 90
 			{
92 91
 				$c1 = substr_count($ip1, ':');
93 92
 			}
94 93
 			if ($ip2 === '')
95 94
 			{
96 95
 				$c2 = -1;
97
-			}
98
-			else
96
+			} else
99 97
 			{
100 98
 				$c2 = substr_count($ip2, ':');
101 99
 			}
@@ -173,8 +171,7 @@  discard block
 block discarded – undo
173 171
 		if ($ip_parts[1] !== '')
174 172
 		{
175 173
 			return implode(':', $ip_parts);
176
-		}
177
-		else
174
+		} else
178 175
 		{
179 176
 			return $ip_parts[0];
180 177
 		}
@@ -200,8 +197,7 @@  discard block
 block discarded – undo
200 197
 			$ipv6_part = substr($ip, 0, $pos);
201 198
 			$ipv4_part = substr($ip, $pos + 1);
202 199
 			return array($ipv6_part, $ipv4_part);
203
-		}
204
-		else
200
+		} else
205 201
 		{
206 202
 			return array($ip, '');
207 203
 		}
@@ -226,35 +222,39 @@  discard block
 block discarded – undo
226 222
 			foreach ($ipv6 as $ipv6_part)
227 223
 			{
228 224
 				// The section can't be empty
229
-				if ($ipv6_part === '')
230
-					return false;
225
+				if ($ipv6_part === '') {
226
+									return false;
227
+				}
231 228
 
232 229
 				// Nor can it be over four characters
233
-				if (strlen($ipv6_part) > 4)
234
-					return false;
230
+				if (strlen($ipv6_part) > 4) {
231
+									return false;
232
+				}
235 233
 
236 234
 				// Remove leading zeros (this is safe because of the above)
237 235
 				$ipv6_part = ltrim($ipv6_part, '0');
238
-				if ($ipv6_part === '')
239
-					$ipv6_part = '0';
236
+				if ($ipv6_part === '') {
237
+									$ipv6_part = '0';
238
+				}
240 239
 
241 240
 				// Check the value is valid
242 241
 				$value = hexdec($ipv6_part);
243
-				if (dechex($value) !== strtolower($ipv6_part) || $value < 0 || $value > 0xFFFF)
244
-					return false;
242
+				if (dechex($value) !== strtolower($ipv6_part) || $value < 0 || $value > 0xFFFF) {
243
+									return false;
244
+				}
245 245
 			}
246 246
 			if (count($ipv4) === 4)
247 247
 			{
248 248
 				foreach ($ipv4 as $ipv4_part)
249 249
 				{
250 250
 					$value = (int) $ipv4_part;
251
-					if ((string) $value !== $ipv4_part || $value < 0 || $value > 0xFF)
252
-						return false;
251
+					if ((string) $value !== $ipv4_part || $value < 0 || $value > 0xFF) {
252
+											return false;
253
+					}
253 254
 				}
254 255
 			}
255 256
 			return true;
256
-		}
257
-		else
257
+		} else
258 258
 		{
259 259
 			return false;
260 260
 		}
Please login to merge, or discard this patch.
src/wp-includes/SimplePie/Parse/Date.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -704,7 +704,6 @@
 block discarded – undo
704 704
 	 * Remove RFC822 comments
705 705
 	 *
706 706
 	 * @access protected
707
-	 * @param string $data Data to strip comments from
708 707
 	 * @return string Comment stripped string
709 708
 	 */
710 709
 	public function remove_rfc2822_comments($string)
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -541,11 +541,11 @@  discard block
 block discarded – undo
541 541
 	 */
542 542
 	public function __construct()
543 543
 	{
544
-		$this->day_pcre = '(' . implode(array_keys($this->day), '|') . ')';
545
-		$this->month_pcre = '(' . implode(array_keys($this->month), '|') . ')';
544
+		$this->day_pcre = '('.implode(array_keys($this->day), '|').')';
545
+		$this->month_pcre = '('.implode(array_keys($this->month), '|').')';
546 546
 
547 547
 		static $cache;
548
-		if (!isset($cache[get_class($this)]))
548
+		if ( ! isset($cache[get_class($this)]))
549 549
 		{
550 550
 			$all_methods = get_class_methods($this);
551 551
 
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 	public static function get()
573 573
 	{
574 574
 		static $object;
575
-		if (!$object)
575
+		if ( ! $object)
576 576
 		{
577 577
 			$object = new SimplePie_Parse_Date;
578 578
 		}
@@ -638,13 +638,13 @@  discard block
 block discarded – undo
638 638
 	public function date_w3cdtf($date)
639 639
 	{
640 640
 		static $pcre;
641
-		if (!$pcre)
641
+		if ( ! $pcre)
642 642
 		{
643 643
 			$year = '([0-9]{4})';
644 644
 			$month = $day = $hour = $minute = $second = '([0-9]{2})';
645 645
 			$decimal = '([0-9]*)';
646 646
 			$zone = '(?:(Z)|([+\-])([0-9]{1,2}):?([0-9]{1,2}))';
647
-			$pcre = '/^' . $year . '(?:-?' . $month . '(?:-?' . $day . '(?:[Tt\x09\x20]+' . $hour . '(?::?' . $minute . '(?::?' . $second . '(?:.' . $decimal . ')?)?)?' . $zone . ')?)?)?$/';
647
+			$pcre = '/^'.$year.'(?:-?'.$month.'(?:-?'.$day.'(?:[Tt\x09\x20]+'.$hour.'(?::?'.$minute.'(?::?'.$second.'(?:.'.$decimal.')?)?)?'.$zone.')?)?)?$/';
648 648
 		}
649 649
 		if (preg_match($pcre, $date, $match))
650 650
 		{
@@ -770,11 +770,11 @@  discard block
 block discarded – undo
770 770
 	public function date_rfc2822($date)
771 771
 	{
772 772
 		static $pcre;
773
-		if (!$pcre)
773
+		if ( ! $pcre)
774 774
 		{
775 775
 			$wsp = '[\x09\x20]';
776
-			$fws = '(?:' . $wsp . '+|' . $wsp . '*(?:\x0D\x0A' . $wsp . '+)+)';
777
-			$optional_fws = $fws . '?';
776
+			$fws = '(?:'.$wsp.'+|'.$wsp.'*(?:\x0D\x0A'.$wsp.'+)+)';
777
+			$optional_fws = $fws.'?';
778 778
 			$day_name = $this->day_pcre;
779 779
 			$month = $this->month_pcre;
780 780
 			$day = '([0-9]{1,2})';
@@ -782,8 +782,8 @@  discard block
 block discarded – undo
782 782
 			$year = '([0-9]{2,4})';
783 783
 			$num_zone = '([+\-])([0-9]{2})([0-9]{2})';
784 784
 			$character_zone = '([A-Z]{1,5})';
785
-			$zone = '(?:' . $num_zone . '|' . $character_zone . ')';
786
-			$pcre = '/(?:' . $optional_fws . $day_name . $optional_fws . ',)?' . $optional_fws . $day . $fws . $month . $fws . $year . $fws . $hour . $optional_fws . ':' . $optional_fws . $minute . '(?:' . $optional_fws . ':' . $optional_fws . $second . ')?' . $fws . $zone . '/i';
785
+			$zone = '(?:'.$num_zone.'|'.$character_zone.')';
786
+			$pcre = '/(?:'.$optional_fws.$day_name.$optional_fws.',)?'.$optional_fws.$day.$fws.$month.$fws.$year.$fws.$hour.$optional_fws.':'.$optional_fws.$minute.'(?:'.$optional_fws.':'.$optional_fws.$second.')?'.$fws.$zone.'/i';
787 787
 		}
788 788
 		if (preg_match($pcre, $this->remove_rfc2822_comments($date), $match))
789 789
 		{
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
 	public function date_rfc850($date)
864 864
 	{
865 865
 		static $pcre;
866
-		if (!$pcre)
866
+		if ( ! $pcre)
867 867
 		{
868 868
 			$space = '[\x09\x20]+';
869 869
 			$day_name = $this->day_pcre;
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
 			$day = '([0-9]{1,2})';
872 872
 			$year = $hour = $minute = $second = '([0-9]{2})';
873 873
 			$zone = '([A-Z]{1,5})';
874
-			$pcre = '/^' . $day_name . ',' . $space . $day . '-' . $month . '-' . $year . $space . $hour . ':' . $minute . ':' . $second . $space . $zone . '$/i';
874
+			$pcre = '/^'.$day_name.','.$space.$day.'-'.$month.'-'.$year.$space.$hour.':'.$minute.':'.$second.$space.$zone.'$/i';
875 875
 		}
876 876
 		if (preg_match($pcre, $date, $match))
877 877
 		{
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
 	public function date_asctime($date)
929 929
 	{
930 930
 		static $pcre;
931
-		if (!$pcre)
931
+		if ( ! $pcre)
932 932
 		{
933 933
 			$space = '[\x09\x20]+';
934 934
 			$wday_name = $this->day_pcre;
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
 			$hour = $sec = $min = '([0-9]{2})';
938 938
 			$year = '([0-9]{4})';
939 939
 			$terminator = '\x0A?\x00?';
940
-			$pcre = '/^' . $wday_name . $space . $mon_name . $space . $day . $space . $hour . ':' . $min . ':' . $sec . $space . $year . $terminator . '$/i';
940
+			$pcre = '/^'.$wday_name.$space.$mon_name.$space.$day.$space.$hour.':'.$min.':'.$sec.$space.$year.$terminator.'$/i';
941 941
 		}
942 942
 		if (preg_match($pcre, $date, $match))
943 943
 		{
Please login to merge, or discard this patch.
Braces   +13 added lines, -26 removed lines patch added patch discarded remove patch
@@ -620,8 +620,7 @@  discard block
 block discarded – undo
620 620
 		if (is_callable($callback))
621 621
 		{
622 622
 			$this->user[] = $callback;
623
-		}
624
-		else
623
+		} else
625 624
 		{
626 625
 			trigger_error('User-supplied function must be a valid callback', E_USER_WARNING);
627 626
 		}
@@ -683,8 +682,7 @@  discard block
 block discarded – undo
683 682
 				{
684 683
 					$timezone = 0 - $timezone;
685 684
 				}
686
-			}
687
-			else
685
+			} else
688 686
 			{
689 687
 				$timezone = 0;
690 688
 			}
@@ -693,8 +691,7 @@  discard block
 block discarded – undo
693 691
 			$second = round($match[6] + $match[7] / pow(10, strlen($match[7])));
694 692
 
695 693
 			return gmmktime($match[4], $match[5], $second, $match[2], $match[3], $match[1]) - $timezone;
696
-		}
697
-		else
694
+		} else
698 695
 		{
699 696
 			return false;
700 697
 		}
@@ -730,8 +727,7 @@  discard block
 block discarded – undo
730 727
 					{
731 728
 						$position++;
732 729
 						continue;
733
-					}
734
-					elseif (isset($string[$position]))
730
+					} elseif (isset($string[$position]))
735 731
 					{
736 732
 						switch ($string[$position])
737 733
 						{
@@ -744,14 +740,12 @@  discard block
 block discarded – undo
744 740
 								break;
745 741
 						}
746 742
 						$position++;
747
-					}
748
-					else
743
+					} else
749 744
 					{
750 745
 						break;
751 746
 					}
752 747
 				}
753
-			}
754
-			else
748
+			} else
755 749
 			{
756 750
 				$output .= '(';
757 751
 			}
@@ -830,8 +824,7 @@  discard block
 block discarded – undo
830 824
 			if ($match[4] < 50)
831 825
 			{
832 826
 				$match[4] += 2000;
833
-			}
834
-			elseif ($match[4] < 1000)
827
+			} elseif ($match[4] < 1000)
835 828
 			{
836 829
 				$match[4] += 1900;
837 830
 			}
@@ -840,15 +833,13 @@  discard block
 block discarded – undo
840 833
 			if ($match[7] !== '')
841 834
 			{
842 835
 				$second = $match[7];
843
-			}
844
-			else
836
+			} else
845 837
 			{
846 838
 				$second = 0;
847 839
 			}
848 840
 
849 841
 			return gmmktime($match[5], $match[6], $second, $month, $match[2], $match[4]) - $timezone;
850
-		}
851
-		else
842
+		} else
852 843
 		{
853 844
 			return false;
854 845
 		}
@@ -905,15 +896,13 @@  discard block
 block discarded – undo
905 896
 			if ($match[4] < 50)
906 897
 			{
907 898
 				$match[4] += 2000;
908
-			}
909
-			else
899
+			} else
910 900
 			{
911 901
 				$match[4] += 1900;
912 902
 			}
913 903
 
914 904
 			return gmmktime($match[5], $match[6], $match[7], $month, $match[2], $match[4]) - $timezone;
915
-		}
916
-		else
905
+		} else
917 906
 		{
918 907
 			return false;
919 908
 		}
@@ -954,8 +943,7 @@  discard block
 block discarded – undo
954 943
 
955 944
 			$month = $this->month[strtolower($match[2])];
956 945
 			return gmmktime($match[4], $match[5], $match[6], $month, $match[3], $match[7]);
957
-		}
958
-		else
946
+		} else
959 947
 		{
960 948
 			return false;
961 949
 		}
@@ -973,8 +961,7 @@  discard block
 block discarded – undo
973 961
 		if ($strtotime === -1 || $strtotime === false)
974 962
 		{
975 963
 			return false;
976
-		}
977
-		else
964
+		} else
978 965
 		{
979 966
 			return $strtotime;
980 967
 		}
Please login to merge, or discard this patch.
src/wp-includes/SimplePie/Parser.php 3 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -265,6 +265,9 @@  discard block
 block discarded – undo
265 265
 		return $this->data;
266 266
 	}
267 267
 
268
+	/**
269
+	 * @param string $tag
270
+	 */
268 271
 	public function tag_open($parser, $tag, $attributes)
269 272
 	{
270 273
 		list($this->namespace[], $this->element[]) = $this->split_ns($tag);
@@ -332,6 +335,9 @@  discard block
 block discarded – undo
332 335
 		}
333 336
 	}
334 337
 
338
+	/**
339
+	 * @param string $cdata
340
+	 */
335 341
 	public function cdata($parser, $cdata)
336 342
 	{
337 343
 		if ($this->current_xhtml_construct >= 0)
@@ -344,6 +350,9 @@  discard block
 block discarded – undo
344 350
 		}
345 351
 	}
346 352
 
353
+	/**
354
+	 * @param string $tag
355
+	 */
347 356
 	public function tag_close($parser, $tag)
348 357
 	{
349 358
 		if ($this->current_xhtml_construct >= 0)
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 			if ($declaration->parse())
121 121
 			{
122 122
 				$data = substr($data, $pos + 2);
123
-				$data = '<?xml version="' . $declaration->version . '" encoding="' . $encoding . '" standalone="' . (($declaration->standalone) ? 'yes' : 'no') . '"?>' . $data;
123
+				$data = '<?xml version="'.$declaration->version.'" encoding="'.$encoding.'" standalone="'.(($declaration->standalone) ? 'yes' : 'no').'"?>'.$data;
124 124
 			}
125 125
 			else
126 126
 			{
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 			xml_set_element_handler($xml, 'tag_open', 'tag_close');
152 152
 
153 153
 			// Parse!
154
-			if (!xml_parse($xml, $data, true))
154
+			if ( ! xml_parse($xml, $data, true))
155 155
 			{
156 156
 				$this->error_code = xml_get_error_code($xml);
157 157
 				$this->error_string = xml_error_string($this->error_code);
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 					case constant('XMLReader::END_ELEMENT'):
177 177
 						if ($xml->namespaceURI !== '')
178 178
 						{
179
-							$tagName = $xml->namespaceURI . $this->separator . $xml->localName;
179
+							$tagName = $xml->namespaceURI.$this->separator.$xml->localName;
180 180
 						}
181 181
 						else
182 182
 						{
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 						$empty = $xml->isEmptyElement;
189 189
 						if ($xml->namespaceURI !== '')
190 190
 						{
191
-							$tagName = $xml->namespaceURI . $this->separator . $xml->localName;
191
+							$tagName = $xml->namespaceURI.$this->separator.$xml->localName;
192 192
 						}
193 193
 						else
194 194
 						{
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 						{
200 200
 							if ($xml->namespaceURI !== '')
201 201
 							{
202
-								$attrName = $xml->namespaceURI . $this->separator . $xml->localName;
202
+								$attrName = $xml->namespaceURI.$this->separator.$xml->localName;
203 203
 							}
204 204
 							else
205 205
 							{
@@ -305,12 +305,12 @@  discard block
 block discarded – undo
305 305
 			$this->current_xhtml_construct++;
306 306
 			if (end($this->namespace) === SIMPLEPIE_NAMESPACE_XHTML)
307 307
 			{
308
-				$this->data['data'] .= '<' . end($this->element);
308
+				$this->data['data'] .= '<'.end($this->element);
309 309
 				if (isset($attribs['']))
310 310
 				{
311 311
 					foreach ($attribs[''] as $name => $value)
312 312
 					{
313
-						$this->data['data'] .= ' ' . $name . '="' . htmlspecialchars($value, ENT_COMPAT, $this->encoding) . '"';
313
+						$this->data['data'] .= ' '.$name.'="'.htmlspecialchars($value, ENT_COMPAT, $this->encoding).'"';
314 314
 					}
315 315
 				}
316 316
 				$this->data['data'] .= '>';
@@ -318,8 +318,8 @@  discard block
 block discarded – undo
318 318
 		}
319 319
 		else
320 320
 		{
321
-			$this->datas[] =& $this->data;
322
-			$this->data =& $this->data['child'][end($this->namespace)][end($this->element)][];
321
+			$this->datas[] = & $this->data;
322
+			$this->data = & $this->data['child'][end($this->namespace)][end($this->element)][];
323 323
 			$this->data = array('data' => '', 'attribs' => $attribs, 'xml_base' => end($this->xml_base), 'xml_base_explicit' => end($this->xml_base_explicit), 'xml_lang' => end($this->xml_lang));
324 324
 			if ((end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_03 && in_array(end($this->element), array('title', 'tagline', 'copyright', 'info', 'summary', 'content')) && isset($attribs['']['mode']) && $attribs['']['mode'] === 'xml')
325 325
 			|| (end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_10 && in_array(end($this->element), array('rights', 'subtitle', 'summary', 'info', 'title', 'content')) && isset($attribs['']['type']) && $attribs['']['type'] === 'xhtml')
@@ -349,14 +349,14 @@  discard block
 block discarded – undo
349 349
 		if ($this->current_xhtml_construct >= 0)
350 350
 		{
351 351
 			$this->current_xhtml_construct--;
352
-			if (end($this->namespace) === SIMPLEPIE_NAMESPACE_XHTML && !in_array(end($this->element), array('area', 'base', 'basefont', 'br', 'col', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param')))
352
+			if (end($this->namespace) === SIMPLEPIE_NAMESPACE_XHTML && ! in_array(end($this->element), array('area', 'base', 'basefont', 'br', 'col', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param')))
353 353
 			{
354
-				$this->data['data'] .= '</' . end($this->element) . '>';
354
+				$this->data['data'] .= '</'.end($this->element).'>';
355 355
 			}
356 356
 		}
357 357
 		if ($this->current_xhtml_construct === -1)
358 358
 		{
359
-			$this->data =& $this->datas[count($this->datas) - 1];
359
+			$this->data = & $this->datas[count($this->datas) - 1];
360 360
 			array_pop($this->datas);
361 361
 		}
362 362
 
@@ -370,12 +370,12 @@  discard block
 block discarded – undo
370 370
 	public function split_ns($string)
371 371
 	{
372 372
 		static $cache = array();
373
-		if (!isset($cache[$string]))
373
+		if ( ! isset($cache[$string]))
374 374
 		{
375 375
 			if ($pos = strpos($string, $this->separator))
376 376
 			{
377 377
 				static $separator_length;
378
-				if (!$separator_length)
378
+				if ( ! $separator_length)
379 379
 				{
380 380
 					$separator_length = strlen($this->separator);
381 381
 				}
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 					$namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG2 ||
392 392
 					$namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG3 ||
393 393
 					$namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG4 ||
394
-					$namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG5 )
394
+					$namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG5)
395 395
 				{
396 396
 					$namespace = SIMPLEPIE_NAMESPACE_MEDIARSS;
397 397
 				}
Please login to merge, or discard this patch.
Braces   +12 added lines, -24 removed lines patch added patch discarded remove patch
@@ -81,8 +81,7 @@  discard block
 block discarded – undo
81 81
 		if (strtoupper($encoding) === 'US-ASCII')
82 82
 		{
83 83
 			$this->encoding = 'UTF-8';
84
-		}
85
-		else
84
+		} else
86 85
 		{
87 86
 			$this->encoding = $encoding;
88 87
 		}
@@ -121,8 +120,7 @@  discard block
 block discarded – undo
121 120
 			{
122 121
 				$data = substr($data, $pos + 2);
123 122
 				$data = '<?xml version="' . $declaration->version . '" encoding="' . $encoding . '" standalone="' . (($declaration->standalone) ? 'yes' : 'no') . '"?>' . $data;
124
-			}
125
-			else
123
+			} else
126 124
 			{
127 125
 				$this->error_string = 'SimplePie bug! Please report this!';
128 126
 				return false;
@@ -162,8 +160,7 @@  discard block
 block discarded – undo
162 160
 			$this->current_byte = xml_get_current_byte_index($xml);
163 161
 			xml_parser_free($xml);
164 162
 			return $return;
165
-		}
166
-		else
163
+		} else
167 164
 		{
168 165
 			libxml_clear_errors();
169 166
 			$xml = new XMLReader();
@@ -177,8 +174,7 @@  discard block
 block discarded – undo
177 174
 						if ($xml->namespaceURI !== '')
178 175
 						{
179 176
 							$tagName = $xml->namespaceURI . $this->separator . $xml->localName;
180
-						}
181
-						else
177
+						} else
182 178
 						{
183 179
 							$tagName = $xml->localName;
184 180
 						}
@@ -189,8 +185,7 @@  discard block
 block discarded – undo
189 185
 						if ($xml->namespaceURI !== '')
190 186
 						{
191 187
 							$tagName = $xml->namespaceURI . $this->separator . $xml->localName;
192
-						}
193
-						else
188
+						} else
194 189
 						{
195 190
 							$tagName = $xml->localName;
196 191
 						}
@@ -200,8 +195,7 @@  discard block
 block discarded – undo
200 195
 							if ($xml->namespaceURI !== '')
201 196
 							{
202 197
 								$attrName = $xml->namespaceURI . $this->separator . $xml->localName;
203
-							}
204
-							else
198
+							} else
205 199
 							{
206 200
 								$attrName = $xml->localName;
207 201
 							}
@@ -227,8 +221,7 @@  discard block
 block discarded – undo
227 221
 				$this->current_line = $error->line;
228 222
 				$this->current_column = $error->column;
229 223
 				return false;
230
-			}
231
-			else
224
+			} else
232 225
 			{
233 226
 				return true;
234 227
 			}
@@ -284,8 +277,7 @@  discard block
 block discarded – undo
284 277
 				$this->xml_base[] = $base;
285 278
 				$this->xml_base_explicit[] = true;
286 279
 			}
287
-		}
288
-		else
280
+		} else
289 281
 		{
290 282
 			$this->xml_base[] = end($this->xml_base);
291 283
 			$this->xml_base_explicit[] = end($this->xml_base_explicit);
@@ -294,8 +286,7 @@  discard block
 block discarded – undo
294 286
 		if (isset($attribs[SIMPLEPIE_NAMESPACE_XML]['lang']))
295 287
 		{
296 288
 			$this->xml_lang[] = $attribs[SIMPLEPIE_NAMESPACE_XML]['lang'];
297
-		}
298
-		else
289
+		} else
299 290
 		{
300 291
 			$this->xml_lang[] = end($this->xml_lang);
301 292
 		}
@@ -315,8 +306,7 @@  discard block
 block discarded – undo
315 306
 				}
316 307
 				$this->data['data'] .= '>';
317 308
 			}
318
-		}
319
-		else
309
+		} else
320 310
 		{
321 311
 			$this->datas[] =& $this->data;
322 312
 			$this->data =& $this->data['child'][end($this->namespace)][end($this->element)][];
@@ -337,8 +327,7 @@  discard block
 block discarded – undo
337 327
 		if ($this->current_xhtml_construct >= 0)
338 328
 		{
339 329
 			$this->data['data'] .= htmlspecialchars($cdata, ENT_QUOTES, $this->encoding);
340
-		}
341
-		else
330
+		} else
342 331
 		{
343 332
 			$this->data['data'] .= $cdata;
344 333
 		}
@@ -396,8 +385,7 @@  discard block
 block discarded – undo
396 385
 					$namespace = SIMPLEPIE_NAMESPACE_MEDIARSS;
397 386
 				}
398 387
 				$cache[$string] = array($namespace, $local_name);
399
-			}
400
-			else
388
+			} else
401 389
 			{
402 390
 				$cache[$string] = array('', $string);
403 391
 			}
Please login to merge, or discard this patch.
src/wp-includes/taxonomy.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
  * @global WP    $wp            WP instance.
329 329
  *
330 330
  * @param string       $taxonomy    Taxonomy key, must not exceed 32 characters.
331
- * @param array|string $object_type Name of the object type for the taxonomy object.
331
+ * @param string $object_type Name of the object type for the taxonomy object.
332 332
  * @param array|string $args        See optional args description above.
333 333
  * @return WP_Error|void WP_Error, if errors.
334 334
  */
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
  * @global wpdb $wpdb WordPress database abstraction object.
599 599
  *
600 600
  * @param int|array    $term_ids   Term id or array of term ids of terms that will be used.
601
- * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names.
601
+ * @param string $taxonomies String of taxonomy name or Array of string values of taxonomy names.
602 602
  * @param array|string $args       Change the order of the object_ids, either ASC or DESC.
603 603
  * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success.
604 604
  *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
@@ -3730,7 +3730,7 @@  discard block
 block discarded – undo
3730 3730
  *
3731 3731
  * @param array  $terms    The term_taxonomy_id of terms to update.
3732 3732
  * @param string $taxonomy The context of the term.
3733
- * @return true Always true when complete.
3733
+ * @return boolean Always true when complete.
3734 3734
  */
3735 3735
 function wp_update_term_count_now( $terms, $taxonomy ) {
3736 3736
 	$terms = array_map('intval', $terms);
@@ -4714,7 +4714,7 @@  discard block
 block discarded – undo
4714 4714
  *
4715 4715
  * @since 2.5.0
4716 4716
  *
4717
- * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
4717
+ * @param integer $post Optional. Post ID or WP_Post object. Default is global $post.
4718 4718
  * @param array $args {
4719 4719
  *     Optional. Arguments about how to format the list of taxonomies. Default empty array.
4720 4720
  *
@@ -4776,7 +4776,7 @@  discard block
 block discarded – undo
4776 4776
  *
4777 4777
  * @since 2.5.0
4778 4778
  *
4779
- * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
4779
+ * @param integer $post Optional. Post ID or WP_Post object. Default is global $post.
4780 4780
  * @return array
4781 4781
  */
4782 4782
 function get_post_taxonomies( $post = 0 ) {
Please login to merge, or discard this patch.
Spacing   +900 added lines, -900 removed lines patch added patch discarded remove patch
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
 function create_initial_taxonomies() {
25 25
 	global $wp_rewrite;
26 26
 
27
-	if ( ! did_action( 'init' ) ) {
28
-		$rewrite = array( 'category' => false, 'post_tag' => false, 'post_format' => false );
27
+	if ( ! did_action('init')) {
28
+		$rewrite = array('category' => false, 'post_tag' => false, 'post_format' => false);
29 29
 	} else {
30 30
 
31 31
 		/**
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 		 *
36 36
 		 * @param string $context Context of the rewrite base. Default 'type'.
37 37
 		 */
38
-		$post_format_base = apply_filters( 'post_format_rewrite_base', 'type' );
38
+		$post_format_base = apply_filters('post_format_rewrite_base', 'type');
39 39
 		$rewrite = array(
40 40
 			'category' => array(
41 41
 				'hierarchical' => true,
@@ -49,11 +49,11 @@  discard block
 block discarded – undo
49 49
 				'with_front' => ! get_option('tag_base') || $wp_rewrite->using_index_permalinks(),
50 50
 				'ep_mask' => EP_TAGS,
51 51
 			),
52
-			'post_format' => $post_format_base ? array( 'slug' => $post_format_base ) : false,
52
+			'post_format' => $post_format_base ? array('slug' => $post_format_base) : false,
53 53
 		);
54 54
 	}
55 55
 
56
-	register_taxonomy( 'category', 'post', array(
56
+	register_taxonomy('category', 'post', array(
57 57
 		'hierarchical' => true,
58 58
 		'query_var' => 'category_name',
59 59
 		'rewrite' => $rewrite['category'],
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
 		'show_ui' => true,
62 62
 		'show_admin_column' => true,
63 63
 		'_builtin' => true,
64
-	) );
64
+	));
65 65
 
66
-	register_taxonomy( 'post_tag', 'post', array(
66
+	register_taxonomy('post_tag', 'post', array(
67 67
 	 	'hierarchical' => false,
68 68
 		'query_var' => 'tag',
69 69
 		'rewrite' => $rewrite['post_tag'],
@@ -71,34 +71,34 @@  discard block
 block discarded – undo
71 71
 		'show_ui' => true,
72 72
 		'show_admin_column' => true,
73 73
 		'_builtin' => true,
74
-	) );
74
+	));
75 75
 
76
-	register_taxonomy( 'nav_menu', 'nav_menu_item', array(
76
+	register_taxonomy('nav_menu', 'nav_menu_item', array(
77 77
 		'public' => false,
78 78
 		'hierarchical' => false,
79 79
 		'labels' => array(
80
-			'name' => __( 'Navigation Menus' ),
81
-			'singular_name' => __( 'Navigation Menu' ),
80
+			'name' => __('Navigation Menus'),
81
+			'singular_name' => __('Navigation Menu'),
82 82
 		),
83 83
 		'query_var' => false,
84 84
 		'rewrite' => false,
85 85
 		'show_ui' => false,
86 86
 		'_builtin' => true,
87 87
 		'show_in_nav_menus' => false,
88
-	) );
88
+	));
89 89
 
90
-	register_taxonomy( 'link_category', 'link', array(
90
+	register_taxonomy('link_category', 'link', array(
91 91
 		'hierarchical' => false,
92 92
 		'labels' => array(
93
-			'name' => __( 'Link Categories' ),
94
-			'singular_name' => __( 'Link Category' ),
95
-			'search_items' => __( 'Search Link Categories' ),
93
+			'name' => __('Link Categories'),
94
+			'singular_name' => __('Link Category'),
95
+			'search_items' => __('Search Link Categories'),
96 96
 			'popular_items' => null,
97
-			'all_items' => __( 'All Link Categories' ),
98
-			'edit_item' => __( 'Edit Link Category' ),
99
-			'update_item' => __( 'Update Link Category' ),
100
-			'add_new_item' => __( 'Add New Link Category' ),
101
-			'new_item_name' => __( 'New Link Category Name' ),
97
+			'all_items' => __('All Link Categories'),
98
+			'edit_item' => __('Edit Link Category'),
99
+			'update_item' => __('Update Link Category'),
100
+			'add_new_item' => __('Add New Link Category'),
101
+			'new_item_name' => __('New Link Category Name'),
102 102
 			'separate_items_with_commas' => null,
103 103
 			'add_or_remove_items' => null,
104 104
 			'choose_from_most_used' => null,
@@ -114,21 +114,21 @@  discard block
 block discarded – undo
114 114
 		'public' => false,
115 115
 		'show_ui' => true,
116 116
 		'_builtin' => true,
117
-	) );
117
+	));
118 118
 
119
-	register_taxonomy( 'post_format', 'post', array(
119
+	register_taxonomy('post_format', 'post', array(
120 120
 		'public' => true,
121 121
 		'hierarchical' => false,
122 122
 		'labels' => array(
123
-			'name' => _x( 'Format', 'post format' ),
124
-			'singular_name' => _x( 'Format', 'post format' ),
123
+			'name' => _x('Format', 'post format'),
124
+			'singular_name' => _x('Format', 'post format'),
125 125
 		),
126 126
 		'query_var' => true,
127 127
 		'rewrite' => $rewrite['post_format'],
128 128
 		'show_ui' => false,
129 129
 		'_builtin' => true,
130
-		'show_in_nav_menus' => current_theme_supports( 'post-formats' ),
131
-	) );
130
+		'show_in_nav_menus' => current_theme_supports('post-formats'),
131
+	));
132 132
 }
133 133
 
134 134
 /**
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
  *                         Default 'and'.
148 148
  * @return array A list of taxonomy names or objects.
149 149
  */
150
-function get_taxonomies( $args = array(), $output = 'names', $operator = 'and' ) {
150
+function get_taxonomies($args = array(), $output = 'names', $operator = 'and') {
151 151
 	global $wp_taxonomies;
152 152
 
153 153
 	$field = ('names' == $output) ? 'name' : false;
@@ -176,11 +176,11 @@  discard block
 block discarded – undo
176 176
  *                                     taxonomy 'names' or 'objects'. Default 'names'.
177 177
  * @return array The names of all taxonomy of $object_type.
178 178
  */
179
-function get_object_taxonomies( $object, $output = 'names' ) {
179
+function get_object_taxonomies($object, $output = 'names') {
180 180
 	global $wp_taxonomies;
181 181
 
182
-	if ( is_object($object) ) {
183
-		if ( $object->post_type == 'attachment' )
182
+	if (is_object($object)) {
183
+		if ($object->post_type == 'attachment')
184 184
 			return get_attachment_taxonomies($object);
185 185
 		$object = $object->post_type;
186 186
 	}
@@ -188,12 +188,12 @@  discard block
 block discarded – undo
188 188
 	$object = (array) $object;
189 189
 
190 190
 	$taxonomies = array();
191
-	foreach ( (array) $wp_taxonomies as $tax_name => $tax_obj ) {
192
-		if ( array_intersect($object, (array) $tax_obj->object_type) ) {
193
-			if ( 'names' == $output )
191
+	foreach ((array) $wp_taxonomies as $tax_name => $tax_obj) {
192
+		if (array_intersect($object, (array) $tax_obj->object_type)) {
193
+			if ('names' == $output)
194 194
 				$taxonomies[] = $tax_name;
195 195
 			else
196
-				$taxonomies[ $tax_name ] = $tax_obj;
196
+				$taxonomies[$tax_name] = $tax_obj;
197 197
 		}
198 198
 	}
199 199
 
@@ -213,10 +213,10 @@  discard block
 block discarded – undo
213 213
  * @param string $taxonomy Name of taxonomy object to return.
214 214
  * @return object|false The Taxonomy Object or false if $taxonomy doesn't exist.
215 215
  */
216
-function get_taxonomy( $taxonomy ) {
216
+function get_taxonomy($taxonomy) {
217 217
 	global $wp_taxonomies;
218 218
 
219
-	if ( ! taxonomy_exists( $taxonomy ) )
219
+	if ( ! taxonomy_exists($taxonomy))
220 220
 		return false;
221 221
 
222 222
 	return $wp_taxonomies[$taxonomy];
@@ -234,10 +234,10 @@  discard block
 block discarded – undo
234 234
  * @param string $taxonomy Name of taxonomy object.
235 235
  * @return bool Whether the taxonomy exists.
236 236
  */
237
-function taxonomy_exists( $taxonomy ) {
237
+function taxonomy_exists($taxonomy) {
238 238
 	global $wp_taxonomies;
239 239
 
240
-	return isset( $wp_taxonomies[$taxonomy] );
240
+	return isset($wp_taxonomies[$taxonomy]);
241 241
 }
242 242
 
243 243
 /**
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
  * @return bool Whether the taxonomy is hierarchical.
255 255
  */
256 256
 function is_taxonomy_hierarchical($taxonomy) {
257
-	if ( ! taxonomy_exists($taxonomy) )
257
+	if ( ! taxonomy_exists($taxonomy))
258 258
 		return false;
259 259
 
260 260
 	$taxonomy = get_taxonomy($taxonomy);
@@ -348,13 +348,13 @@  discard block
 block discarded – undo
348 348
  * }
349 349
  * @return WP_Error|void WP_Error, if errors.
350 350
  */
351
-function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
351
+function register_taxonomy($taxonomy, $object_type, $args = array()) {
352 352
 	global $wp_taxonomies, $wp;
353 353
 
354
-	if ( ! is_array( $wp_taxonomies ) )
354
+	if ( ! is_array($wp_taxonomies))
355 355
 		$wp_taxonomies = array();
356 356
 
357
-	$args = wp_parse_args( $args );
357
+	$args = wp_parse_args($args);
358 358
 
359 359
 	/**
360 360
 	 * Filters the arguments for registering a taxonomy.
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 	 * @param string $taxonomy    Taxonomy key.
366 366
 	 * @param array  $object_type Array of names of object types for the taxonomy.
367 367
 	 */
368
-	$args = apply_filters( 'register_taxonomy_args', $args, $taxonomy, (array) $object_type );
368
+	$args = apply_filters('register_taxonomy_args', $args, $taxonomy, (array) $object_type);
369 369
 
370 370
 	$defaults = array(
371 371
 		'labels'                => array(),
@@ -386,67 +386,67 @@  discard block
 block discarded – undo
386 386
 		'update_count_callback' => '',
387 387
 		'_builtin'              => false,
388 388
 	);
389
-	$args = array_merge( $defaults, $args );
389
+	$args = array_merge($defaults, $args);
390 390
 
391
-	if ( empty( $taxonomy ) || strlen( $taxonomy ) > 32 ) {
392
-		_doing_it_wrong( __FUNCTION__, __( 'Taxonomy names must be between 1 and 32 characters in length.' ), '4.2.0' );
393
-		return new WP_Error( 'taxonomy_length_invalid', __( 'Taxonomy names must be between 1 and 32 characters in length.' ) );
391
+	if (empty($taxonomy) || strlen($taxonomy) > 32) {
392
+		_doing_it_wrong(__FUNCTION__, __('Taxonomy names must be between 1 and 32 characters in length.'), '4.2.0');
393
+		return new WP_Error('taxonomy_length_invalid', __('Taxonomy names must be between 1 and 32 characters in length.'));
394 394
 	}
395 395
 
396 396
 	// If not set, default to the setting for public.
397
-	if ( null === $args['publicly_queryable'] ) {
397
+	if (null === $args['publicly_queryable']) {
398 398
 		$args['publicly_queryable'] = $args['public'];
399 399
 	}
400 400
 
401 401
 	// Non-publicly queryable taxonomies should not register query vars, except in the admin.
402
-	if ( false !== $args['query_var'] && ( is_admin() || false !== $args['publicly_queryable'] ) && ! empty( $wp ) ) {
403
-		if ( true === $args['query_var'] )
402
+	if (false !== $args['query_var'] && (is_admin() || false !== $args['publicly_queryable']) && ! empty($wp)) {
403
+		if (true === $args['query_var'])
404 404
 			$args['query_var'] = $taxonomy;
405 405
 		else
406
-			$args['query_var'] = sanitize_title_with_dashes( $args['query_var'] );
407
-		$wp->add_query_var( $args['query_var'] );
406
+			$args['query_var'] = sanitize_title_with_dashes($args['query_var']);
407
+		$wp->add_query_var($args['query_var']);
408 408
 	} else {
409 409
 		// Force query_var to false for non-public taxonomies.
410 410
 		$args['query_var'] = false;
411 411
 	}
412 412
 
413
-	if ( false !== $args['rewrite'] && ( is_admin() || '' != get_option( 'permalink_structure' ) ) ) {
414
-		$args['rewrite'] = wp_parse_args( $args['rewrite'], array(
413
+	if (false !== $args['rewrite'] && (is_admin() || '' != get_option('permalink_structure'))) {
414
+		$args['rewrite'] = wp_parse_args($args['rewrite'], array(
415 415
 			'with_front' => true,
416 416
 			'hierarchical' => false,
417 417
 			'ep_mask' => EP_NONE,
418
-		) );
418
+		));
419 419
 
420
-		if ( empty( $args['rewrite']['slug'] ) )
421
-			$args['rewrite']['slug'] = sanitize_title_with_dashes( $taxonomy );
420
+		if (empty($args['rewrite']['slug']))
421
+			$args['rewrite']['slug'] = sanitize_title_with_dashes($taxonomy);
422 422
 
423
-		if ( $args['hierarchical'] && $args['rewrite']['hierarchical'] )
423
+		if ($args['hierarchical'] && $args['rewrite']['hierarchical'])
424 424
 			$tag = '(.+?)';
425 425
 		else
426 426
 			$tag = '([^/]+)';
427 427
 
428
-		add_rewrite_tag( "%$taxonomy%", $tag, $args['query_var'] ? "{$args['query_var']}=" : "taxonomy=$taxonomy&term=" );
429
-		add_permastruct( $taxonomy, "{$args['rewrite']['slug']}/%$taxonomy%", $args['rewrite'] );
428
+		add_rewrite_tag("%$taxonomy%", $tag, $args['query_var'] ? "{$args['query_var']}=" : "taxonomy=$taxonomy&term=");
429
+		add_permastruct($taxonomy, "{$args['rewrite']['slug']}/%$taxonomy%", $args['rewrite']);
430 430
 	}
431 431
 
432 432
 	// If not set, default to the setting for public.
433
-	if ( null === $args['show_ui'] )
433
+	if (null === $args['show_ui'])
434 434
 		$args['show_ui'] = $args['public'];
435 435
 
436 436
 	// If not set, default to the setting for show_ui.
437
-	if ( null === $args['show_in_menu' ] || ! $args['show_ui'] )
438
-		$args['show_in_menu' ] = $args['show_ui'];
437
+	if (null === $args['show_in_menu'] || ! $args['show_ui'])
438
+		$args['show_in_menu'] = $args['show_ui'];
439 439
 
440 440
 	// If not set, default to the setting for public.
441
-	if ( null === $args['show_in_nav_menus'] )
441
+	if (null === $args['show_in_nav_menus'])
442 442
 		$args['show_in_nav_menus'] = $args['public'];
443 443
 
444 444
 	// If not set, default to the setting for show_ui.
445
-	if ( null === $args['show_tagcloud'] )
445
+	if (null === $args['show_tagcloud'])
446 446
 		$args['show_tagcloud'] = $args['show_ui'];
447 447
 
448 448
 	// If not set, default to the setting for show_ui.
449
-	if ( null === $args['show_in_quick_edit'] ) {
449
+	if (null === $args['show_in_quick_edit']) {
450 450
 		$args['show_in_quick_edit'] = $args['show_ui'];
451 451
 	}
452 452
 
@@ -456,27 +456,27 @@  discard block
 block discarded – undo
456 456
 		'delete_terms' => 'manage_categories',
457 457
 		'assign_terms' => 'edit_posts',
458 458
 	);
459
-	$args['cap'] = (object) array_merge( $default_caps, $args['capabilities'] );
460
-	unset( $args['capabilities'] );
459
+	$args['cap'] = (object) array_merge($default_caps, $args['capabilities']);
460
+	unset($args['capabilities']);
461 461
 
462 462
 	$args['name'] = $taxonomy;
463
-	$args['object_type'] = array_unique( (array) $object_type );
463
+	$args['object_type'] = array_unique((array) $object_type);
464 464
 
465
-	$args['labels'] = get_taxonomy_labels( (object) $args );
465
+	$args['labels'] = get_taxonomy_labels((object) $args);
466 466
 	$args['label'] = $args['labels']->name;
467 467
 
468 468
 	// If not set, use the default meta box
469
-	if ( null === $args['meta_box_cb'] ) {
470
-		if ( $args['hierarchical'] )
469
+	if (null === $args['meta_box_cb']) {
470
+		if ($args['hierarchical'])
471 471
 			$args['meta_box_cb'] = 'post_categories_meta_box';
472 472
 		else
473 473
 			$args['meta_box_cb'] = 'post_tags_meta_box';
474 474
 	}
475 475
 
476
-	$wp_taxonomies[ $taxonomy ] = (object) $args;
476
+	$wp_taxonomies[$taxonomy] = (object) $args;
477 477
 
478 478
 	// Register callback handling for meta box.
479
- 	add_filter( 'wp_ajax_add-' . $taxonomy, '_wp_ajax_add_hierarchical_term' );
479
+ 	add_filter('wp_ajax_add-'.$taxonomy, '_wp_ajax_add_hierarchical_term');
480 480
 
481 481
 	/**
482 482
 	 * Fires after a taxonomy is registered.
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 	 * @param array|string $object_type Object type or array of object types.
488 488
 	 * @param array        $args        Array of taxonomy registration arguments.
489 489
 	 */
490
-	do_action( 'registered_taxonomy', $taxonomy, $object_type, $args );
490
+	do_action('registered_taxonomy', $taxonomy, $object_type, $args);
491 491
 }
492 492
 
493 493
 /**
@@ -503,36 +503,36 @@  discard block
 block discarded – undo
503 503
  * @param string $taxonomy Taxonomy name.
504 504
  * @return bool|WP_Error True on success, WP_Error on failure or if the taxonomy doesn't exist.
505 505
  */
506
-function unregister_taxonomy( $taxonomy ) {
507
-	if ( ! taxonomy_exists( $taxonomy ) ) {
508
-		return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) );
506
+function unregister_taxonomy($taxonomy) {
507
+	if ( ! taxonomy_exists($taxonomy)) {
508
+		return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.'));
509 509
 	}
510 510
 
511
-	$taxonomy_args = get_taxonomy( $taxonomy );
511
+	$taxonomy_args = get_taxonomy($taxonomy);
512 512
 
513 513
 	// Do not allow unregistering internal taxonomies.
514
-	if ( $taxonomy_args->_builtin ) {
515
-		return new WP_Error( 'invalid_taxonomy', __( 'Unregistering a built-in taxonomy is not allowed' ) );
514
+	if ($taxonomy_args->_builtin) {
515
+		return new WP_Error('invalid_taxonomy', __('Unregistering a built-in taxonomy is not allowed'));
516 516
 	}
517 517
 
518 518
 	global $wp, $wp_taxonomies;
519 519
 
520 520
 	// Remove query var.
521
-	if ( false !== $taxonomy_args->query_var ) {
522
-		$wp->remove_query_var( $taxonomy_args->query_var );
521
+	if (false !== $taxonomy_args->query_var) {
522
+		$wp->remove_query_var($taxonomy_args->query_var);
523 523
 	}
524 524
 
525 525
 	// Remove rewrite tags and permastructs.
526
-	if ( false !== $taxonomy_args->rewrite ) {
527
-		remove_rewrite_tag( "%$taxonomy%" );
528
-		remove_permastruct( $taxonomy );
526
+	if (false !== $taxonomy_args->rewrite) {
527
+		remove_rewrite_tag("%$taxonomy%");
528
+		remove_permastruct($taxonomy);
529 529
 	}
530 530
 
531 531
 	// Unregister callback handling for meta box.
532
-	remove_filter( 'wp_ajax_add-' . $taxonomy, '_wp_ajax_add_hierarchical_term' );
532
+	remove_filter('wp_ajax_add-'.$taxonomy, '_wp_ajax_add_hierarchical_term');
533 533
 
534 534
 	// Remove the taxonomy.
535
-	unset( $wp_taxonomies[ $taxonomy ] );
535
+	unset($wp_taxonomies[$taxonomy]);
536 536
 
537 537
 	/**
538 538
 	 * Fires after a taxonomy is unregistered.
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 	 *
542 542
 	 * @param string $taxonomy Taxonomy name.
543 543
 	 */
544
-	do_action( 'unregistered_taxonomy', $taxonomy );
544
+	do_action('unregistered_taxonomy', $taxonomy);
545 545
 
546 546
 	return true;
547 547
 }
@@ -582,39 +582,39 @@  discard block
 block discarded – undo
582 582
  * @param object $tax Taxonomy object.
583 583
  * @return object object with all the labels as member variables.
584 584
  */
585
-function get_taxonomy_labels( $tax ) {
585
+function get_taxonomy_labels($tax) {
586 586
 	$tax->labels = (array) $tax->labels;
587 587
 
588
-	if ( isset( $tax->helps ) && empty( $tax->labels['separate_items_with_commas'] ) )
588
+	if (isset($tax->helps) && empty($tax->labels['separate_items_with_commas']))
589 589
 		$tax->labels['separate_items_with_commas'] = $tax->helps;
590 590
 
591
-	if ( isset( $tax->no_tagcloud ) && empty( $tax->labels['not_found'] ) )
591
+	if (isset($tax->no_tagcloud) && empty($tax->labels['not_found']))
592 592
 		$tax->labels['not_found'] = $tax->no_tagcloud;
593 593
 
594 594
 	$nohier_vs_hier_defaults = array(
595
-		'name' => array( _x( 'Tags', 'taxonomy general name' ), _x( 'Categories', 'taxonomy general name' ) ),
596
-		'singular_name' => array( _x( 'Tag', 'taxonomy singular name' ), _x( 'Category', 'taxonomy singular name' ) ),
597
-		'search_items' => array( __( 'Search Tags' ), __( 'Search Categories' ) ),
598
-		'popular_items' => array( __( 'Popular Tags' ), null ),
599
-		'all_items' => array( __( 'All Tags' ), __( 'All Categories' ) ),
600
-		'parent_item' => array( null, __( 'Parent Category' ) ),
601
-		'parent_item_colon' => array( null, __( 'Parent Category:' ) ),
602
-		'edit_item' => array( __( 'Edit Tag' ), __( 'Edit Category' ) ),
603
-		'view_item' => array( __( 'View Tag' ), __( 'View Category' ) ),
604
-		'update_item' => array( __( 'Update Tag' ), __( 'Update Category' ) ),
605
-		'add_new_item' => array( __( 'Add New Tag' ), __( 'Add New Category' ) ),
606
-		'new_item_name' => array( __( 'New Tag Name' ), __( 'New Category Name' ) ),
607
-		'separate_items_with_commas' => array( __( 'Separate tags with commas' ), null ),
608
-		'add_or_remove_items' => array( __( 'Add or remove tags' ), null ),
609
-		'choose_from_most_used' => array( __( 'Choose from the most used tags' ), null ),
610
-		'not_found' => array( __( 'No tags found.' ), __( 'No categories found.' ) ),
611
-		'no_terms' => array( __( 'No tags' ), __( 'No categories' ) ),
612
-		'items_list_navigation' => array( __( 'Tags list navigation' ), __( 'Categories list navigation' ) ),
613
-		'items_list' => array( __( 'Tags list' ), __( 'Categories list' ) ),
595
+		'name' => array(_x('Tags', 'taxonomy general name'), _x('Categories', 'taxonomy general name')),
596
+		'singular_name' => array(_x('Tag', 'taxonomy singular name'), _x('Category', 'taxonomy singular name')),
597
+		'search_items' => array(__('Search Tags'), __('Search Categories')),
598
+		'popular_items' => array(__('Popular Tags'), null),
599
+		'all_items' => array(__('All Tags'), __('All Categories')),
600
+		'parent_item' => array(null, __('Parent Category')),
601
+		'parent_item_colon' => array(null, __('Parent Category:')),
602
+		'edit_item' => array(__('Edit Tag'), __('Edit Category')),
603
+		'view_item' => array(__('View Tag'), __('View Category')),
604
+		'update_item' => array(__('Update Tag'), __('Update Category')),
605
+		'add_new_item' => array(__('Add New Tag'), __('Add New Category')),
606
+		'new_item_name' => array(__('New Tag Name'), __('New Category Name')),
607
+		'separate_items_with_commas' => array(__('Separate tags with commas'), null),
608
+		'add_or_remove_items' => array(__('Add or remove tags'), null),
609
+		'choose_from_most_used' => array(__('Choose from the most used tags'), null),
610
+		'not_found' => array(__('No tags found.'), __('No categories found.')),
611
+		'no_terms' => array(__('No tags'), __('No categories')),
612
+		'items_list_navigation' => array(__('Tags list navigation'), __('Categories list navigation')),
613
+		'items_list' => array(__('Tags list'), __('Categories list')),
614 614
 	);
615 615
 	$nohier_vs_hier_defaults['menu_name'] = $nohier_vs_hier_defaults['name'];
616 616
 
617
-	$labels = _get_custom_object_labels( $tax, $nohier_vs_hier_defaults );
617
+	$labels = _get_custom_object_labels($tax, $nohier_vs_hier_defaults);
618 618
 
619 619
 	$taxonomy = $tax->name;
620 620
 
@@ -631,10 +631,10 @@  discard block
 block discarded – undo
631 631
 	 *
632 632
 	 * @param object $labels Object with labels for the taxonomy as member variables.
633 633
 	 */
634
-	$labels = apply_filters( "taxonomy_labels_{$taxonomy}", $labels );
634
+	$labels = apply_filters("taxonomy_labels_{$taxonomy}", $labels);
635 635
 
636 636
 	// Ensure that the filtered labels contain all required default values.
637
-	$labels = (object) array_merge( (array) $default_labels, (array) $labels );
637
+	$labels = (object) array_merge((array) $default_labels, (array) $labels);
638 638
 
639 639
 	return $labels;
640 640
 }
@@ -650,20 +650,20 @@  discard block
 block discarded – undo
650 650
  * @param string $object_type Name of the object type.
651 651
  * @return bool True if successful, false if not.
652 652
  */
653
-function register_taxonomy_for_object_type( $taxonomy, $object_type) {
653
+function register_taxonomy_for_object_type($taxonomy, $object_type) {
654 654
 	global $wp_taxonomies;
655 655
 
656
-	if ( !isset($wp_taxonomies[$taxonomy]) )
656
+	if ( ! isset($wp_taxonomies[$taxonomy]))
657 657
 		return false;
658 658
 
659
-	if ( ! get_post_type_object($object_type) )
659
+	if ( ! get_post_type_object($object_type))
660 660
 		return false;
661 661
 
662
-	if ( ! in_array( $object_type, $wp_taxonomies[$taxonomy]->object_type ) )
662
+	if ( ! in_array($object_type, $wp_taxonomies[$taxonomy]->object_type))
663 663
 		$wp_taxonomies[$taxonomy]->object_type[] = $object_type;
664 664
 
665 665
 	// Filter out empties.
666
-	$wp_taxonomies[ $taxonomy ]->object_type = array_filter( $wp_taxonomies[ $taxonomy ]->object_type );
666
+	$wp_taxonomies[$taxonomy]->object_type = array_filter($wp_taxonomies[$taxonomy]->object_type);
667 667
 
668 668
 	return true;
669 669
 }
@@ -679,20 +679,20 @@  discard block
 block discarded – undo
679 679
  * @param string $object_type Name of the object type.
680 680
  * @return bool True if successful, false if not.
681 681
  */
682
-function unregister_taxonomy_for_object_type( $taxonomy, $object_type ) {
682
+function unregister_taxonomy_for_object_type($taxonomy, $object_type) {
683 683
 	global $wp_taxonomies;
684 684
 
685
-	if ( ! isset( $wp_taxonomies[ $taxonomy ] ) )
685
+	if ( ! isset($wp_taxonomies[$taxonomy]))
686 686
 		return false;
687 687
 
688
-	if ( ! get_post_type_object( $object_type ) )
688
+	if ( ! get_post_type_object($object_type))
689 689
 		return false;
690 690
 
691
-	$key = array_search( $object_type, $wp_taxonomies[ $taxonomy ]->object_type, true );
692
-	if ( false === $key )
691
+	$key = array_search($object_type, $wp_taxonomies[$taxonomy]->object_type, true);
692
+	if (false === $key)
693 693
 		return false;
694 694
 
695
-	unset( $wp_taxonomies[ $taxonomy ]->object_type[ $key ] );
695
+	unset($wp_taxonomies[$taxonomy]->object_type[$key]);
696 696
 	return true;
697 697
 }
698 698
 
@@ -725,34 +725,34 @@  discard block
 block discarded – undo
725 725
  * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success.
726 726
  *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
727 727
  */
728
-function get_objects_in_term( $term_ids, $taxonomies, $args = array() ) {
728
+function get_objects_in_term($term_ids, $taxonomies, $args = array()) {
729 729
 	global $wpdb;
730 730
 
731
-	if ( ! is_array( $term_ids ) ) {
732
-		$term_ids = array( $term_ids );
731
+	if ( ! is_array($term_ids)) {
732
+		$term_ids = array($term_ids);
733 733
 	}
734
-	if ( ! is_array( $taxonomies ) ) {
735
-		$taxonomies = array( $taxonomies );
734
+	if ( ! is_array($taxonomies)) {
735
+		$taxonomies = array($taxonomies);
736 736
 	}
737
-	foreach ( (array) $taxonomies as $taxonomy ) {
738
-		if ( ! taxonomy_exists( $taxonomy ) ) {
739
-			return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) );
737
+	foreach ((array) $taxonomies as $taxonomy) {
738
+		if ( ! taxonomy_exists($taxonomy)) {
739
+			return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.'));
740 740
 		}
741 741
 	}
742 742
 
743
-	$defaults = array( 'order' => 'ASC' );
744
-	$args = wp_parse_args( $args, $defaults );
743
+	$defaults = array('order' => 'ASC');
744
+	$args = wp_parse_args($args, $defaults);
745 745
 
746
-	$order = ( 'desc' == strtolower( $args['order'] ) ) ? 'DESC' : 'ASC';
746
+	$order = ('desc' == strtolower($args['order'])) ? 'DESC' : 'ASC';
747 747
 
748
-	$term_ids = array_map('intval', $term_ids );
748
+	$term_ids = array_map('intval', $term_ids);
749 749
 
750
-	$taxonomies = "'" . implode( "', '", array_map( 'esc_sql', $taxonomies ) ) . "'";
751
-	$term_ids = "'" . implode( "', '", $term_ids ) . "'";
750
+	$taxonomies = "'".implode("', '", array_map('esc_sql', $taxonomies))."'";
751
+	$term_ids = "'".implode("', '", $term_ids)."'";
752 752
 
753 753
 	$object_ids = $wpdb->get_col("SELECT tr.object_id FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ($taxonomies) AND tt.term_id IN ($term_ids) ORDER BY tr.object_id $order");
754 754
 
755
-	if ( ! $object_ids ){
755
+	if ( ! $object_ids) {
756 756
 		return array();
757 757
 	}
758 758
 	return $object_ids;
@@ -770,9 +770,9 @@  discard block
 block discarded – undo
770 770
  * @param string $primary_id_column
771 771
  * @return array
772 772
  */
773
-function get_tax_sql( $tax_query, $primary_table, $primary_id_column ) {
774
-	$tax_query_obj = new WP_Tax_Query( $tax_query );
775
-	return $tax_query_obj->get_sql( $primary_table, $primary_id_column );
773
+function get_tax_sql($tax_query, $primary_table, $primary_id_column) {
774
+	$tax_query_obj = new WP_Tax_Query($tax_query);
775
+	return $tax_query_obj->get_sql($primary_table, $primary_id_column);
776 776
 }
777 777
 
778 778
 /**
@@ -820,31 +820,31 @@  discard block
 block discarded – undo
820 820
  *                                     a WP_Term instance is returned. If taxonomy does not exist, a WP_Error is
821 821
  *                                     returned. Returns null for miscellaneous failure.
822 822
  */
823
-function get_term( $term, $taxonomy = '', $output = OBJECT, $filter = 'raw' ) {
824
-	if ( empty( $term ) ) {
825
-		return new WP_Error( 'invalid_term', __( 'Empty Term' ) );
823
+function get_term($term, $taxonomy = '', $output = OBJECT, $filter = 'raw') {
824
+	if (empty($term)) {
825
+		return new WP_Error('invalid_term', __('Empty Term'));
826 826
 	}
827 827
 
828
-	if ( $taxonomy && ! taxonomy_exists( $taxonomy ) ) {
829
-		return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) );
828
+	if ($taxonomy && ! taxonomy_exists($taxonomy)) {
829
+		return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.'));
830 830
 	}
831 831
 
832
-	if ( $term instanceof WP_Term ) {
832
+	if ($term instanceof WP_Term) {
833 833
 		$_term = $term;
834
-	} elseif ( is_object( $term ) ) {
835
-		if ( empty( $term->filter ) || 'raw' === $term->filter ) {
836
-			$_term = sanitize_term( $term, $taxonomy, 'raw' );
837
-			$_term = new WP_Term( $_term );
834
+	} elseif (is_object($term)) {
835
+		if (empty($term->filter) || 'raw' === $term->filter) {
836
+			$_term = sanitize_term($term, $taxonomy, 'raw');
837
+			$_term = new WP_Term($_term);
838 838
 		} else {
839
-			$_term = WP_Term::get_instance( $term->term_id );
839
+			$_term = WP_Term::get_instance($term->term_id);
840 840
 		}
841 841
 	} else {
842
-		$_term = WP_Term::get_instance( $term, $taxonomy );
842
+		$_term = WP_Term::get_instance($term, $taxonomy);
843 843
 	}
844 844
 
845
-	if ( is_wp_error( $_term ) ) {
845
+	if (is_wp_error($_term)) {
846 846
 		return $_term;
847
-	} elseif ( ! $_term ) {
847
+	} elseif ( ! $_term) {
848 848
 		return null;
849 849
 	}
850 850
 
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
 	 * @param int|WP_Term $_term    Term object or ID.
858 858
 	 * @param string      $taxonomy The taxonomy slug.
859 859
 	 */
860
-	$_term = apply_filters( 'get_term', $_term, $taxonomy );
860
+	$_term = apply_filters('get_term', $_term, $taxonomy);
861 861
 
862 862
 	/**
863 863
 	 * Filters a taxonomy.
@@ -871,20 +871,20 @@  discard block
 block discarded – undo
871 871
 	 * @param int|WP_Term $_term    Term object or ID.
872 872
 	 * @param string      $taxonomy The taxonomy slug.
873 873
 	 */
874
-	$_term = apply_filters( "get_$taxonomy", $_term, $taxonomy );
874
+	$_term = apply_filters("get_$taxonomy", $_term, $taxonomy);
875 875
 
876 876
 	// Bail if a filter callback has changed the type of the `$_term` object.
877
-	if ( ! ( $_term instanceof WP_Term ) ) {
877
+	if ( ! ($_term instanceof WP_Term)) {
878 878
 		return $_term;
879 879
 	}
880 880
 
881 881
 	// Sanitize term, according to the specified filter.
882
-	$_term->filter( $filter );
882
+	$_term->filter($filter);
883 883
 
884
-	if ( $output == ARRAY_A ) {
884
+	if ($output == ARRAY_A) {
885 885
 		return $_term->to_array();
886
-	} elseif ( $output == ARRAY_N ) {
887
-		return array_values( $_term->to_array() );
886
+	} elseif ($output == ARRAY_N) {
887
+		return array_values($_term->to_array());
888 888
 	}
889 889
 
890 890
 	return $_term;
@@ -926,51 +926,51 @@  discard block
 block discarded – undo
926 926
  * @return WP_Term|bool WP_Term instance on success. Will return false if `$taxonomy` does not exist
927 927
  *                      or `$term` was not found.
928 928
  */
929
-function get_term_by( $field, $value, $taxonomy = '', $output = OBJECT, $filter = 'raw' ) {
929
+function get_term_by($field, $value, $taxonomy = '', $output = OBJECT, $filter = 'raw') {
930 930
 	global $wpdb;
931 931
 
932 932
 	// 'term_taxonomy_id' lookups don't require taxonomy checks.
933
-	if ( 'term_taxonomy_id' !== $field && ! taxonomy_exists( $taxonomy ) ) {
933
+	if ('term_taxonomy_id' !== $field && ! taxonomy_exists($taxonomy)) {
934 934
 		return false;
935 935
 	}
936 936
 
937
-	$tax_clause = $wpdb->prepare( "AND tt.taxonomy = %s", $taxonomy );
937
+	$tax_clause = $wpdb->prepare("AND tt.taxonomy = %s", $taxonomy);
938 938
 
939
-	if ( 'slug' == $field ) {
939
+	if ('slug' == $field) {
940 940
 		$_field = 't.slug';
941 941
 		$value = sanitize_title($value);
942
-		if ( empty($value) )
942
+		if (empty($value))
943 943
 			return false;
944
-	} elseif ( 'name' == $field ) {
944
+	} elseif ('name' == $field) {
945 945
 		// Assume already escaped
946 946
 		$value = wp_unslash($value);
947 947
 		$_field = 't.name';
948
-	} elseif ( 'term_taxonomy_id' == $field ) {
948
+	} elseif ('term_taxonomy_id' == $field) {
949 949
 		$value = (int) $value;
950 950
 		$_field = 'tt.term_taxonomy_id';
951 951
 
952 952
 		// No `taxonomy` clause when searching by 'term_taxonomy_id'.
953 953
 		$tax_clause = '';
954 954
 	} else {
955
-		$term = get_term( (int) $value, $taxonomy, $output, $filter );
956
-		if ( is_wp_error( $term ) || is_null( $term ) ) {
955
+		$term = get_term((int) $value, $taxonomy, $output, $filter);
956
+		if (is_wp_error($term) || is_null($term)) {
957 957
 			$term = false;
958 958
 		}
959 959
 		return $term;
960 960
 	}
961 961
 
962
-	$term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE $_field = %s", $value ) . " $tax_clause LIMIT 1" );
963
-	if ( ! $term )
962
+	$term = $wpdb->get_row($wpdb->prepare("SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE $_field = %s", $value)." $tax_clause LIMIT 1");
963
+	if ( ! $term)
964 964
 		return false;
965 965
 
966 966
 	// In the case of 'term_taxonomy_id', override the provided `$taxonomy` with whatever we find in the db.
967
-	if ( 'term_taxonomy_id' === $field ) {
967
+	if ('term_taxonomy_id' === $field) {
968 968
 		$taxonomy = $term->taxonomy;
969 969
 	}
970 970
 
971
-	wp_cache_add( $term->term_id, $term, 'terms' );
971
+	wp_cache_add($term->term_id, $term, 'terms');
972 972
 
973
-	return get_term( $term, $taxonomy, $output, $filter );
973
+	return get_term($term, $taxonomy, $output, $filter);
974 974
 }
975 975
 
976 976
 /**
@@ -987,26 +987,26 @@  discard block
 block discarded – undo
987 987
  * @param string $taxonomy Taxonomy Name.
988 988
  * @return array|WP_Error List of Term IDs. WP_Error returned if `$taxonomy` does not exist.
989 989
  */
990
-function get_term_children( $term_id, $taxonomy ) {
991
-	if ( ! taxonomy_exists( $taxonomy ) ) {
992
-		return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) );
990
+function get_term_children($term_id, $taxonomy) {
991
+	if ( ! taxonomy_exists($taxonomy)) {
992
+		return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.'));
993 993
 	}
994 994
 
995
-	$term_id = intval( $term_id );
995
+	$term_id = intval($term_id);
996 996
 
997 997
 	$terms = _get_term_hierarchy($taxonomy);
998 998
 
999
-	if ( ! isset($terms[$term_id]) )
999
+	if ( ! isset($terms[$term_id]))
1000 1000
 		return array();
1001 1001
 
1002 1002
 	$children = $terms[$term_id];
1003 1003
 
1004
-	foreach ( (array) $terms[$term_id] as $child ) {
1005
-		if ( $term_id == $child ) {
1004
+	foreach ((array) $terms[$term_id] as $child) {
1005
+		if ($term_id == $child) {
1006 1006
 			continue;
1007 1007
 		}
1008 1008
 
1009
-		if ( isset($terms[$child]) )
1009
+		if (isset($terms[$child]))
1010 1010
 			$children = array_merge($children, get_term_children($child, $taxonomy));
1011 1011
 	}
1012 1012
 
@@ -1029,18 +1029,18 @@  discard block
 block discarded – undo
1029 1029
  * @param string      $context  Optional, default is display. Look at sanitize_term_field() for available options.
1030 1030
  * @return string|int|null|WP_Error Will return an empty string if $term is not an object or if $field is not set in $term.
1031 1031
  */
1032
-function get_term_field( $field, $term, $taxonomy = '', $context = 'display' ) {
1033
-	$term = get_term( $term, $taxonomy );
1034
-	if ( is_wp_error($term) )
1032
+function get_term_field($field, $term, $taxonomy = '', $context = 'display') {
1033
+	$term = get_term($term, $taxonomy);
1034
+	if (is_wp_error($term))
1035 1035
 		return $term;
1036 1036
 
1037
-	if ( !is_object($term) )
1037
+	if ( ! is_object($term))
1038 1038
 		return '';
1039 1039
 
1040
-	if ( !isset($term->$field) )
1040
+	if ( ! isset($term->$field))
1041 1041
 		return '';
1042 1042
 
1043
-	return sanitize_term_field( $field, $term->$field, $term->term_id, $term->taxonomy, $context );
1043
+	return sanitize_term_field($field, $term->$field, $term->term_id, $term->taxonomy, $context);
1044 1044
 }
1045 1045
 
1046 1046
 /**
@@ -1055,13 +1055,13 @@  discard block
 block discarded – undo
1055 1055
  * @param string     $taxonomy Taxonomy name.
1056 1056
  * @return string|int|null|WP_Error Will return empty string if $term is not an object.
1057 1057
  */
1058
-function get_term_to_edit( $id, $taxonomy ) {
1059
-	$term = get_term( $id, $taxonomy );
1058
+function get_term_to_edit($id, $taxonomy) {
1059
+	$term = get_term($id, $taxonomy);
1060 1060
 
1061
-	if ( is_wp_error($term) )
1061
+	if (is_wp_error($term))
1062 1062
 		return $term;
1063 1063
 
1064
-	if ( !is_object($term) )
1064
+	if ( ! is_object($term))
1065 1065
 		return '';
1066 1066
 
1067 1067
 	return sanitize_term($term, $taxonomy, 'edit');
@@ -1179,7 +1179,7 @@  discard block
 block discarded – undo
1179 1179
  * @return array|int|WP_Error List of WP_Term instances and their children. Will return WP_Error, if any of $taxonomies
1180 1180
  *                            do not exist.
1181 1181
  */
1182
-function get_terms( $args = array(), $deprecated = '' ) {
1182
+function get_terms($args = array(), $deprecated = '') {
1183 1183
 	global $wpdb;
1184 1184
 
1185 1185
 	$term_query = new WP_Term_Query();
@@ -1191,33 +1191,33 @@  discard block
 block discarded – undo
1191 1191
 	 * (a) a second non-empty parameter is passed, or
1192 1192
 	 * (b) the first parameter shares no keys with the default array (ie, it's a list of taxonomies)
1193 1193
 	 */
1194
-	$_args = wp_parse_args( $args );
1195
-	$key_intersect  = array_intersect_key( $term_query->query_var_defaults, (array) $_args );
1196
-	$do_legacy_args = $deprecated || empty( $key_intersect );
1194
+	$_args = wp_parse_args($args);
1195
+	$key_intersect  = array_intersect_key($term_query->query_var_defaults, (array) $_args);
1196
+	$do_legacy_args = $deprecated || empty($key_intersect);
1197 1197
 
1198
-	if ( $do_legacy_args ) {
1198
+	if ($do_legacy_args) {
1199 1199
 		$taxonomies = (array) $args;
1200
-		$args = wp_parse_args( $deprecated );
1200
+		$args = wp_parse_args($deprecated);
1201 1201
 		$args['taxonomy'] = $taxonomies;
1202 1202
 	} else {
1203
-		$args = wp_parse_args( $args );
1204
-		if ( isset( $args['taxonomy'] ) && null !== $args['taxonomy'] ) {
1203
+		$args = wp_parse_args($args);
1204
+		if (isset($args['taxonomy']) && null !== $args['taxonomy']) {
1205 1205
 			$args['taxonomy'] = (array) $args['taxonomy'];
1206 1206
 		}
1207 1207
 	}
1208 1208
 
1209
-	if ( ! empty( $args['taxonomy'] ) ) {
1210
-		foreach ( $args['taxonomy'] as $taxonomy ) {
1211
-			if ( ! taxonomy_exists( $taxonomy ) ) {
1212
-				return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) );
1209
+	if ( ! empty($args['taxonomy'])) {
1210
+		foreach ($args['taxonomy'] as $taxonomy) {
1211
+			if ( ! taxonomy_exists($taxonomy)) {
1212
+				return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.'));
1213 1213
 			}
1214 1214
 		}
1215 1215
 	}
1216 1216
 
1217
-	$terms = $term_query->query( $args );
1217
+	$terms = $term_query->query($args);
1218 1218
 
1219 1219
 	// Count queries are not filtered, for legacy reasons.
1220
-	if ( ! is_array( $terms ) ) {
1220
+	if ( ! is_array($terms)) {
1221 1221
 		return $terms;
1222 1222
 	}
1223 1223
 
@@ -1232,7 +1232,7 @@  discard block
 block discarded – undo
1232 1232
 	 * @param array         $args       An array of get_terms() arguments.
1233 1233
 	 * @param WP_Term_Query $term_query The WP_Term_Query object.
1234 1234
 	 */
1235
-	return apply_filters( 'get_terms', $terms, $term_query->query_vars['taxonomy'], $term_query->query_vars, $term_query );
1235
+	return apply_filters('get_terms', $terms, $term_query->query_vars['taxonomy'], $term_query->query_vars, $term_query);
1236 1236
 }
1237 1237
 
1238 1238
 /**
@@ -1248,21 +1248,21 @@  discard block
 block discarded – undo
1248 1248
  * @return int|WP_Error|bool Meta ID on success. WP_Error when term_id is ambiguous between taxonomies.
1249 1249
  *                           False on failure.
1250 1250
  */
1251
-function add_term_meta( $term_id, $meta_key, $meta_value, $unique = false ) {
1251
+function add_term_meta($term_id, $meta_key, $meta_value, $unique = false) {
1252 1252
 	// Bail if term meta table is not installed.
1253
-	if ( get_option( 'db_version' ) < 34370 ) {
1253
+	if (get_option('db_version') < 34370) {
1254 1254
 		return false;
1255 1255
 	}
1256 1256
 
1257
-	if ( wp_term_is_shared( $term_id ) ) {
1258
-		return new WP_Error( 'ambiguous_term_id', __( 'Term meta cannot be added to terms that are shared between taxonomies.'), $term_id );
1257
+	if (wp_term_is_shared($term_id)) {
1258
+		return new WP_Error('ambiguous_term_id', __('Term meta cannot be added to terms that are shared between taxonomies.'), $term_id);
1259 1259
 	}
1260 1260
 
1261
-	$added = add_metadata( 'term', $term_id, $meta_key, $meta_value, $unique );
1261
+	$added = add_metadata('term', $term_id, $meta_key, $meta_value, $unique);
1262 1262
 
1263 1263
 	// Bust term query cache.
1264
-	if ( $added ) {
1265
-		wp_cache_set( 'last_changed', microtime(), 'terms' );
1264
+	if ($added) {
1265
+		wp_cache_set('last_changed', microtime(), 'terms');
1266 1266
 	}
1267 1267
 
1268 1268
 	return $added;
@@ -1278,17 +1278,17 @@  discard block
 block discarded – undo
1278 1278
  * @param mixed  $meta_value Optional. Metadata value. If provided, rows will only be removed that match the value.
1279 1279
  * @return bool True on success, false on failure.
1280 1280
  */
1281
-function delete_term_meta( $term_id, $meta_key, $meta_value = '' ) {
1281
+function delete_term_meta($term_id, $meta_key, $meta_value = '') {
1282 1282
 	// Bail if term meta table is not installed.
1283
-	if ( get_option( 'db_version' ) < 34370 ) {
1283
+	if (get_option('db_version') < 34370) {
1284 1284
 		return false;
1285 1285
 	}
1286 1286
 
1287
-	$deleted = delete_metadata( 'term', $term_id, $meta_key, $meta_value );
1287
+	$deleted = delete_metadata('term', $term_id, $meta_key, $meta_value);
1288 1288
 
1289 1289
 	// Bust term query cache.
1290
-	if ( $deleted ) {
1291
-		wp_cache_set( 'last_changed', microtime(), 'terms' );
1290
+	if ($deleted) {
1291
+		wp_cache_set('last_changed', microtime(), 'terms');
1292 1292
 	}
1293 1293
 
1294 1294
 	return $deleted;
@@ -1305,13 +1305,13 @@  discard block
 block discarded – undo
1305 1305
  *                        `$term_id`/`$key` pair will be returned. Default: false.
1306 1306
  * @return mixed If `$single` is false, an array of metadata values. If `$single` is true, a single metadata value.
1307 1307
  */
1308
-function get_term_meta( $term_id, $key = '', $single = false ) {
1308
+function get_term_meta($term_id, $key = '', $single = false) {
1309 1309
 	// Bail if term meta table is not installed.
1310
-	if ( get_option( 'db_version' ) < 34370 ) {
1310
+	if (get_option('db_version') < 34370) {
1311 1311
 		return false;
1312 1312
 	}
1313 1313
 
1314
-	return get_metadata( 'term', $term_id, $key, $single );
1314
+	return get_metadata('term', $term_id, $key, $single);
1315 1315
 }
1316 1316
 
1317 1317
 /**
@@ -1330,21 +1330,21 @@  discard block
 block discarded – undo
1330 1330
  * @return int|WP_Error|bool Meta ID if the key didn't previously exist. True on successful update.
1331 1331
  *                           WP_Error when term_id is ambiguous between taxonomies. False on failure.
1332 1332
  */
1333
-function update_term_meta( $term_id, $meta_key, $meta_value, $prev_value = '' ) {
1333
+function update_term_meta($term_id, $meta_key, $meta_value, $prev_value = '') {
1334 1334
 	// Bail if term meta table is not installed.
1335
-	if ( get_option( 'db_version' ) < 34370 ) {
1335
+	if (get_option('db_version') < 34370) {
1336 1336
 		return false;
1337 1337
 	}
1338 1338
 
1339
-	if ( wp_term_is_shared( $term_id ) ) {
1340
-		return new WP_Error( 'ambiguous_term_id', __( 'Term meta cannot be added to terms that are shared between taxonomies.'), $term_id );
1339
+	if (wp_term_is_shared($term_id)) {
1340
+		return new WP_Error('ambiguous_term_id', __('Term meta cannot be added to terms that are shared between taxonomies.'), $term_id);
1341 1341
 	}
1342 1342
 
1343
-	$updated = update_metadata( 'term', $term_id, $meta_key, $meta_value, $prev_value );
1343
+	$updated = update_metadata('term', $term_id, $meta_key, $meta_value, $prev_value);
1344 1344
 
1345 1345
 	// Bust term query cache.
1346
-	if ( $updated ) {
1347
-		wp_cache_set( 'last_changed', microtime(), 'terms' );
1346
+	if ($updated) {
1347
+		wp_cache_set('last_changed', microtime(), 'terms');
1348 1348
 	}
1349 1349
 
1350 1350
 	return $updated;
@@ -1361,13 +1361,13 @@  discard block
 block discarded – undo
1361 1361
  * @param array $term_ids List of term IDs.
1362 1362
  * @return array|false Returns false if there is nothing to update. Returns an array of metadata on success.
1363 1363
  */
1364
-function update_termmeta_cache( $term_ids ) {
1364
+function update_termmeta_cache($term_ids) {
1365 1365
 	// Bail if term meta table is not installed.
1366
-	if ( get_option( 'db_version' ) < 34370 ) {
1366
+	if (get_option('db_version') < 34370) {
1367 1367
 		return;
1368 1368
 	}
1369 1369
 
1370
-	return update_meta_cache( 'term', $term_ids );
1370
+	return update_meta_cache('term', $term_ids);
1371 1371
 }
1372 1372
 
1373 1373
 /**
@@ -1387,24 +1387,24 @@  discard block
 block discarded – undo
1387 1387
  *               an array of the term ID and the term taxonomy ID the taxonomy
1388 1388
  *               is specified and the pairing exists.
1389 1389
  */
1390
-function term_exists( $term, $taxonomy = '', $parent = null ) {
1390
+function term_exists($term, $taxonomy = '', $parent = null) {
1391 1391
 	global $wpdb;
1392 1392
 
1393 1393
 	$select = "SELECT term_id FROM $wpdb->terms as t WHERE ";
1394 1394
 	$tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE ";
1395 1395
 
1396
-	if ( is_int($term) ) {
1397
-		if ( 0 == $term )
1396
+	if (is_int($term)) {
1397
+		if (0 == $term)
1398 1398
 			return 0;
1399 1399
 		$where = 't.term_id = %d';
1400
-		if ( !empty($taxonomy) )
1401
-			return $wpdb->get_row( $wpdb->prepare( $tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy ), ARRAY_A );
1400
+		if ( ! empty($taxonomy))
1401
+			return $wpdb->get_row($wpdb->prepare($tax_select.$where." AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1402 1402
 		else
1403
-			return $wpdb->get_var( $wpdb->prepare( $select . $where, $term ) );
1403
+			return $wpdb->get_var($wpdb->prepare($select.$where, $term));
1404 1404
 	}
1405 1405
 
1406
-	$term = trim( wp_unslash( $term ) );
1407
-	$slug = sanitize_title( $term );
1406
+	$term = trim(wp_unslash($term));
1407
+	$slug = sanitize_title($term);
1408 1408
 
1409 1409
 	$where = 't.slug = %s';
1410 1410
 	$else_where = 't.name = %s';
@@ -1412,8 +1412,8 @@  discard block
 block discarded – undo
1412 1412
 	$else_where_fields = array($term);
1413 1413
 	$orderby = 'ORDER BY t.term_id ASC';
1414 1414
 	$limit = 'LIMIT 1';
1415
-	if ( !empty($taxonomy) ) {
1416
-		if ( is_numeric( $parent ) ) {
1415
+	if ( ! empty($taxonomy)) {
1416
+		if (is_numeric($parent)) {
1417 1417
 			$parent = (int) $parent;
1418 1418
 			$where_fields[] = $parent;
1419 1419
 			$else_where_fields[] = $parent;
@@ -1424,16 +1424,16 @@  discard block
 block discarded – undo
1424 1424
 		$where_fields[] = $taxonomy;
1425 1425
 		$else_where_fields[] = $taxonomy;
1426 1426
 
1427
-		if ( $result = $wpdb->get_row( $wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s $orderby $limit", $where_fields), ARRAY_A) )
1427
+		if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s $orderby $limit", $where_fields), ARRAY_A))
1428 1428
 			return $result;
1429 1429
 
1430
-		return $wpdb->get_row( $wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $else_where AND tt.taxonomy = %s $orderby $limit", $else_where_fields), ARRAY_A);
1430
+		return $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $else_where AND tt.taxonomy = %s $orderby $limit", $else_where_fields), ARRAY_A);
1431 1431
 	}
1432 1432
 
1433
-	if ( $result = $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where $orderby $limit", $where_fields) ) )
1433
+	if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where $orderby $limit", $where_fields)))
1434 1434
 		return $result;
1435 1435
 
1436
-	return $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $else_where $orderby $limit", $else_where_fields) );
1436
+	return $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $else_where $orderby $limit", $else_where_fields));
1437 1437
 }
1438 1438
 
1439 1439
 /**
@@ -1448,18 +1448,18 @@  discard block
 block discarded – undo
1448 1448
  * @param string     $taxonomy Taxonomy name that $term1 and `$term2` belong to.
1449 1449
  * @return bool Whether `$term2` is a child of `$term1`.
1450 1450
  */
1451
-function term_is_ancestor_of( $term1, $term2, $taxonomy ) {
1452
-	if ( ! isset( $term1->term_id ) )
1453
-		$term1 = get_term( $term1, $taxonomy );
1454
-	if ( ! isset( $term2->parent ) )
1455
-		$term2 = get_term( $term2, $taxonomy );
1451
+function term_is_ancestor_of($term1, $term2, $taxonomy) {
1452
+	if ( ! isset($term1->term_id))
1453
+		$term1 = get_term($term1, $taxonomy);
1454
+	if ( ! isset($term2->parent))
1455
+		$term2 = get_term($term2, $taxonomy);
1456 1456
 
1457
-	if ( empty( $term1->term_id ) || empty( $term2->parent ) )
1457
+	if (empty($term1->term_id) || empty($term2->parent))
1458 1458
 		return false;
1459
-	if ( $term2->parent == $term1->term_id )
1459
+	if ($term2->parent == $term1->term_id)
1460 1460
 		return true;
1461 1461
 
1462
-	return term_is_ancestor_of( $term1, get_term( $term2->parent, $taxonomy ), $taxonomy );
1462
+	return term_is_ancestor_of($term1, get_term($term2->parent, $taxonomy), $taxonomy);
1463 1463
 }
1464 1464
 
1465 1465
 /**
@@ -1480,23 +1480,23 @@  discard block
 block discarded – undo
1480 1480
  * @return array|object Term with all fields sanitized.
1481 1481
  */
1482 1482
 function sanitize_term($term, $taxonomy, $context = 'display') {
1483
-	$fields = array( 'term_id', 'name', 'description', 'slug', 'count', 'parent', 'term_group', 'term_taxonomy_id', 'object_id' );
1483
+	$fields = array('term_id', 'name', 'description', 'slug', 'count', 'parent', 'term_group', 'term_taxonomy_id', 'object_id');
1484 1484
 
1485
-	$do_object = is_object( $term );
1485
+	$do_object = is_object($term);
1486 1486
 
1487 1487
 	$term_id = $do_object ? $term->term_id : (isset($term['term_id']) ? $term['term_id'] : 0);
1488 1488
 
1489
-	foreach ( (array) $fields as $field ) {
1490
-		if ( $do_object ) {
1491
-			if ( isset($term->$field) )
1489
+	foreach ((array) $fields as $field) {
1490
+		if ($do_object) {
1491
+			if (isset($term->$field))
1492 1492
 				$term->$field = sanitize_term_field($field, $term->$field, $term_id, $taxonomy, $context);
1493 1493
 		} else {
1494
-			if ( isset($term[$field]) )
1494
+			if (isset($term[$field]))
1495 1495
 				$term[$field] = sanitize_term_field($field, $term[$field], $term_id, $taxonomy, $context);
1496 1496
 		}
1497 1497
 	}
1498 1498
 
1499
-	if ( $do_object )
1499
+	if ($do_object)
1500 1500
 		$term->filter = $context;
1501 1501
 	else
1502 1502
 		$term['filter'] = $context;
@@ -1528,17 +1528,17 @@  discard block
 block discarded – undo
1528 1528
  * @return mixed Sanitized field.
1529 1529
  */
1530 1530
 function sanitize_term_field($field, $value, $term_id, $taxonomy, $context) {
1531
-	$int_fields = array( 'parent', 'term_id', 'count', 'term_group', 'term_taxonomy_id', 'object_id' );
1532
-	if ( in_array( $field, $int_fields ) ) {
1531
+	$int_fields = array('parent', 'term_id', 'count', 'term_group', 'term_taxonomy_id', 'object_id');
1532
+	if (in_array($field, $int_fields)) {
1533 1533
 		$value = (int) $value;
1534
-		if ( $value < 0 )
1534
+		if ($value < 0)
1535 1535
 			$value = 0;
1536 1536
 	}
1537 1537
 
1538
-	if ( 'raw' == $context )
1538
+	if ('raw' == $context)
1539 1539
 		return $value;
1540 1540
 
1541
-	if ( 'edit' == $context ) {
1541
+	if ('edit' == $context) {
1542 1542
 
1543 1543
 		/**
1544 1544
 		 * Filters a term field to edit before it is sanitized.
@@ -1551,7 +1551,7 @@  discard block
 block discarded – undo
1551 1551
 		 * @param int   $term_id   Term ID.
1552 1552
 		 * @param string $taxonomy Taxonomy slug.
1553 1553
 		 */
1554
-		$value = apply_filters( "edit_term_{$field}", $value, $term_id, $taxonomy );
1554
+		$value = apply_filters("edit_term_{$field}", $value, $term_id, $taxonomy);
1555 1555
 
1556 1556
 		/**
1557 1557
 		 * Filters the taxonomy field to edit before it is sanitized.
@@ -1564,13 +1564,13 @@  discard block
 block discarded – undo
1564 1564
 		 * @param mixed $value   Value of the taxonomy field to edit.
1565 1565
 		 * @param int   $term_id Term ID.
1566 1566
 		 */
1567
-		$value = apply_filters( "edit_{$taxonomy}_{$field}", $value, $term_id );
1567
+		$value = apply_filters("edit_{$taxonomy}_{$field}", $value, $term_id);
1568 1568
 
1569
-		if ( 'description' == $field )
1569
+		if ('description' == $field)
1570 1570
 			$value = esc_html($value); // textarea_escaped
1571 1571
 		else
1572 1572
 			$value = esc_attr($value);
1573
-	} elseif ( 'db' == $context ) {
1573
+	} elseif ('db' == $context) {
1574 1574
 
1575 1575
 		/**
1576 1576
 		 * Filters a term field value before it is sanitized.
@@ -1582,7 +1582,7 @@  discard block
 block discarded – undo
1582 1582
 		 * @param mixed  $value    Value of the term field.
1583 1583
 		 * @param string $taxonomy Taxonomy slug.
1584 1584
 		 */
1585
-		$value = apply_filters( "pre_term_{$field}", $value, $taxonomy );
1585
+		$value = apply_filters("pre_term_{$field}", $value, $taxonomy);
1586 1586
 
1587 1587
 		/**
1588 1588
 		 * Filters a taxonomy field before it is sanitized.
@@ -1594,10 +1594,10 @@  discard block
 block discarded – undo
1594 1594
 		 *
1595 1595
 		 * @param mixed $value Value of the taxonomy field.
1596 1596
 		 */
1597
-		$value = apply_filters( "pre_{$taxonomy}_{$field}", $value );
1597
+		$value = apply_filters("pre_{$taxonomy}_{$field}", $value);
1598 1598
 
1599 1599
 		// Back compat filters
1600
-		if ( 'slug' == $field ) {
1600
+		if ('slug' == $field) {
1601 1601
 			/**
1602 1602
 			 * Filters the category nicename before it is sanitized.
1603 1603
 			 *
@@ -1607,10 +1607,10 @@  discard block
 block discarded – undo
1607 1607
 			 *
1608 1608
 			 * @param string $value The category nicename.
1609 1609
 			 */
1610
-			$value = apply_filters( 'pre_category_nicename', $value );
1610
+			$value = apply_filters('pre_category_nicename', $value);
1611 1611
 		}
1612 1612
 
1613
-	} elseif ( 'rss' == $context ) {
1613
+	} elseif ('rss' == $context) {
1614 1614
 
1615 1615
 		/**
1616 1616
 		 * Filters the term field for use in RSS.
@@ -1622,7 +1622,7 @@  discard block
 block discarded – undo
1622 1622
 		 * @param mixed  $value    Value of the term field.
1623 1623
 		 * @param string $taxonomy Taxonomy slug.
1624 1624
 		 */
1625
-		$value = apply_filters( "term_{$field}_rss", $value, $taxonomy );
1625
+		$value = apply_filters("term_{$field}_rss", $value, $taxonomy);
1626 1626
 
1627 1627
 		/**
1628 1628
 		 * Filters the taxonomy field for use in RSS.
@@ -1634,7 +1634,7 @@  discard block
 block discarded – undo
1634 1634
 		 *
1635 1635
 		 * @param mixed $value Value of the taxonomy field.
1636 1636
 		 */
1637
-		$value = apply_filters( "{$taxonomy}_{$field}_rss", $value );
1637
+		$value = apply_filters("{$taxonomy}_{$field}_rss", $value);
1638 1638
 	} else {
1639 1639
 		// Use display filters by default.
1640 1640
 
@@ -1650,7 +1650,7 @@  discard block
 block discarded – undo
1650 1650
 		 * @param string $taxonomy Taxonomy slug.
1651 1651
 		 * @param string $context  Context to retrieve the term field value.
1652 1652
 		 */
1653
-		$value = apply_filters( "term_{$field}", $value, $term_id, $taxonomy, $context );
1653
+		$value = apply_filters("term_{$field}", $value, $term_id, $taxonomy, $context);
1654 1654
 
1655 1655
 		/**
1656 1656
 		 * Filters the taxonomy field sanitized for display.
@@ -1664,12 +1664,12 @@  discard block
 block discarded – undo
1664 1664
 		 * @param int    $term_id Term ID.
1665 1665
 		 * @param string $context Context to retrieve the taxonomy field value.
1666 1666
 		 */
1667
-		$value = apply_filters( "{$taxonomy}_{$field}", $value, $term_id, $context );
1667
+		$value = apply_filters("{$taxonomy}_{$field}", $value, $term_id, $context);
1668 1668
 	}
1669 1669
 
1670
-	if ( 'attribute' == $context ) {
1670
+	if ('attribute' == $context) {
1671 1671
 		$value = esc_attr($value);
1672
-	} elseif ( 'js' == $context ) {
1672
+	} elseif ('js' == $context) {
1673 1673
 		$value = esc_js($value);
1674 1674
 	}
1675 1675
 	return $value;
@@ -1687,12 +1687,12 @@  discard block
 block discarded – undo
1687 1687
  *                               Default empty array.
1688 1688
  * @return array|int|WP_Error Number of terms in that taxonomy or WP_Error if the taxonomy does not exist.
1689 1689
  */
1690
-function wp_count_terms( $taxonomy, $args = array() ) {
1690
+function wp_count_terms($taxonomy, $args = array()) {
1691 1691
 	$defaults = array('hide_empty' => false);
1692 1692
 	$args = wp_parse_args($args, $defaults);
1693 1693
 
1694 1694
 	// backward compatibility
1695
-	if ( isset($args['ignore_empty']) ) {
1695
+	if (isset($args['ignore_empty'])) {
1696 1696
 		$args['hide_empty'] = $args['ignore_empty'];
1697 1697
 		unset($args['ignore_empty']);
1698 1698
 	}
@@ -1714,16 +1714,16 @@  discard block
 block discarded – undo
1714 1714
  * @param int          $object_id  The term Object Id that refers to the term.
1715 1715
  * @param string|array $taxonomies List of Taxonomy Names or single Taxonomy name.
1716 1716
  */
1717
-function wp_delete_object_term_relationships( $object_id, $taxonomies ) {
1717
+function wp_delete_object_term_relationships($object_id, $taxonomies) {
1718 1718
 	$object_id = (int) $object_id;
1719 1719
 
1720
-	if ( !is_array($taxonomies) )
1720
+	if ( ! is_array($taxonomies))
1721 1721
 		$taxonomies = array($taxonomies);
1722 1722
 
1723
-	foreach ( (array) $taxonomies as $taxonomy ) {
1724
-		$term_ids = wp_get_object_terms( $object_id, $taxonomy, array( 'fields' => 'ids' ) );
1725
-		$term_ids = array_map( 'intval', $term_ids );
1726
-		wp_remove_object_terms( $object_id, $term_ids, $taxonomy );
1723
+	foreach ((array) $taxonomies as $taxonomy) {
1724
+		$term_ids = wp_get_object_terms($object_id, $taxonomy, array('fields' => 'ids'));
1725
+		$term_ids = array_map('intval', $term_ids);
1726
+		wp_remove_object_terms($object_id, $term_ids, $taxonomy);
1727 1727
 	}
1728 1728
 }
1729 1729
 
@@ -1754,36 +1754,36 @@  discard block
 block discarded – undo
1754 1754
  * @return bool|int|WP_Error True on success, false if term does not exist. Zero on attempted
1755 1755
  *                           deletion of default Category. WP_Error if the taxonomy does not exist.
1756 1756
  */
1757
-function wp_delete_term( $term, $taxonomy, $args = array() ) {
1757
+function wp_delete_term($term, $taxonomy, $args = array()) {
1758 1758
 	global $wpdb;
1759 1759
 
1760 1760
 	$term = (int) $term;
1761 1761
 
1762
-	if ( ! $ids = term_exists($term, $taxonomy) )
1762
+	if ( ! $ids = term_exists($term, $taxonomy))
1763 1763
 		return false;
1764
-	if ( is_wp_error( $ids ) )
1764
+	if (is_wp_error($ids))
1765 1765
 		return $ids;
1766 1766
 
1767 1767
 	$tt_id = $ids['term_taxonomy_id'];
1768 1768
 
1769 1769
 	$defaults = array();
1770 1770
 
1771
-	if ( 'category' == $taxonomy ) {
1772
-		$defaults['default'] = get_option( 'default_category' );
1773
-		if ( $defaults['default'] == $term )
1771
+	if ('category' == $taxonomy) {
1772
+		$defaults['default'] = get_option('default_category');
1773
+		if ($defaults['default'] == $term)
1774 1774
 			return 0; // Don't delete the default category
1775 1775
 	}
1776 1776
 
1777 1777
 	$args = wp_parse_args($args, $defaults);
1778 1778
 
1779
-	if ( isset( $args['default'] ) ) {
1779
+	if (isset($args['default'])) {
1780 1780
 		$default = (int) $args['default'];
1781
-		if ( ! term_exists( $default, $taxonomy ) ) {
1782
-			unset( $default );
1781
+		if ( ! term_exists($default, $taxonomy)) {
1782
+			unset($default);
1783 1783
 		}
1784 1784
 	}
1785 1785
 
1786
-	if ( isset( $args['force_default'] ) ) {
1786
+	if (isset($args['force_default'])) {
1787 1787
 		$force_default = $args['force_default'];
1788 1788
 	}
1789 1789
 
@@ -1795,17 +1795,17 @@  discard block
 block discarded – undo
1795 1795
 	 * @param int    $term     Term ID.
1796 1796
 	 * @param string $taxonomy Taxonomy Name.
1797 1797
 	 */
1798
-	do_action( 'pre_delete_term', $term, $taxonomy );
1798
+	do_action('pre_delete_term', $term, $taxonomy);
1799 1799
 
1800 1800
 	// Update children to point to new parent
1801
-	if ( is_taxonomy_hierarchical($taxonomy) ) {
1801
+	if (is_taxonomy_hierarchical($taxonomy)) {
1802 1802
 		$term_obj = get_term($term, $taxonomy);
1803
-		if ( is_wp_error( $term_obj ) )
1803
+		if (is_wp_error($term_obj))
1804 1804
 			return $term_obj;
1805 1805
 		$parent = $term_obj->parent;
1806 1806
 
1807
-		$edit_ids = $wpdb->get_results( "SELECT term_id, term_taxonomy_id FROM $wpdb->term_taxonomy WHERE `parent` = " . (int)$term_obj->term_id );
1808
-		$edit_tt_ids = wp_list_pluck( $edit_ids, 'term_taxonomy_id' );
1807
+		$edit_ids = $wpdb->get_results("SELECT term_id, term_taxonomy_id FROM $wpdb->term_taxonomy WHERE `parent` = ".(int) $term_obj->term_id);
1808
+		$edit_tt_ids = wp_list_pluck($edit_ids, 'term_taxonomy_id');
1809 1809
 
1810 1810
 		/**
1811 1811
 		 * Fires immediately before a term to delete's children are reassigned a parent.
@@ -1814,13 +1814,13 @@  discard block
 block discarded – undo
1814 1814
 		 *
1815 1815
 		 * @param array $edit_tt_ids An array of term taxonomy IDs for the given term.
1816 1816
 		 */
1817
-		do_action( 'edit_term_taxonomies', $edit_tt_ids );
1817
+		do_action('edit_term_taxonomies', $edit_tt_ids);
1818 1818
 
1819
-		$wpdb->update( $wpdb->term_taxonomy, compact( 'parent' ), array( 'parent' => $term_obj->term_id) + compact( 'taxonomy' ) );
1819
+		$wpdb->update($wpdb->term_taxonomy, compact('parent'), array('parent' => $term_obj->term_id) + compact('taxonomy'));
1820 1820
 
1821 1821
 		// Clean the cache for all child terms.
1822
-		$edit_term_ids = wp_list_pluck( $edit_ids, 'term_id' );
1823
-		clean_term_cache( $edit_term_ids, $taxonomy );
1822
+		$edit_term_ids = wp_list_pluck($edit_ids, 'term_id');
1823
+		clean_term_cache($edit_term_ids, $taxonomy);
1824 1824
 
1825 1825
 		/**
1826 1826
 		 * Fires immediately after a term to delete's children are reassigned a parent.
@@ -1829,17 +1829,17 @@  discard block
 block discarded – undo
1829 1829
 		 *
1830 1830
 		 * @param array $edit_tt_ids An array of term taxonomy IDs for the given term.
1831 1831
 		 */
1832
-		do_action( 'edited_term_taxonomies', $edit_tt_ids );
1832
+		do_action('edited_term_taxonomies', $edit_tt_ids);
1833 1833
 	}
1834 1834
 
1835 1835
 	// Get the term before deleting it or its term relationships so we can pass to actions below.
1836
-	$deleted_term = get_term( $term, $taxonomy );
1836
+	$deleted_term = get_term($term, $taxonomy);
1837 1837
 
1838
-	$object_ids = (array) $wpdb->get_col( $wpdb->prepare( "SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $tt_id ) );
1838
+	$object_ids = (array) $wpdb->get_col($wpdb->prepare("SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $tt_id));
1839 1839
 
1840
-	foreach ( $object_ids as $object_id ) {
1841
-		$terms = wp_get_object_terms( $object_id, $taxonomy, array( 'fields' => 'ids', 'orderby' => 'none' ) );
1842
-		if ( 1 == count($terms) && isset($default) ) {
1840
+	foreach ($object_ids as $object_id) {
1841
+		$terms = wp_get_object_terms($object_id, $taxonomy, array('fields' => 'ids', 'orderby' => 'none'));
1842
+		if (1 == count($terms) && isset($default)) {
1843 1843
 			$terms = array($default);
1844 1844
 		} else {
1845 1845
 			$terms = array_diff($terms, array($term));
@@ -1847,17 +1847,17 @@  discard block
 block discarded – undo
1847 1847
 				$terms = array_merge($terms, array($default));
1848 1848
 		}
1849 1849
 		$terms = array_map('intval', $terms);
1850
-		wp_set_object_terms( $object_id, $terms, $taxonomy );
1850
+		wp_set_object_terms($object_id, $terms, $taxonomy);
1851 1851
 	}
1852 1852
 
1853 1853
 	// Clean the relationship caches for all object types using this term.
1854
-	$tax_object = get_taxonomy( $taxonomy );
1855
-	foreach ( $tax_object->object_type as $object_type )
1856
-		clean_object_term_cache( $object_ids, $object_type );
1854
+	$tax_object = get_taxonomy($taxonomy);
1855
+	foreach ($tax_object->object_type as $object_type)
1856
+		clean_object_term_cache($object_ids, $object_type);
1857 1857
 
1858
-	$term_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->termmeta WHERE term_id = %d ", $term ) );
1859
-	foreach ( $term_meta_ids as $mid ) {
1860
-		delete_metadata_by_mid( 'term', $mid );
1858
+	$term_meta_ids = $wpdb->get_col($wpdb->prepare("SELECT meta_id FROM $wpdb->termmeta WHERE term_id = %d ", $term));
1859
+	foreach ($term_meta_ids as $mid) {
1860
+		delete_metadata_by_mid('term', $mid);
1861 1861
 	}
1862 1862
 
1863 1863
 	/**
@@ -1867,8 +1867,8 @@  discard block
 block discarded – undo
1867 1867
 	 *
1868 1868
 	 * @param int $tt_id Term taxonomy ID.
1869 1869
 	 */
1870
-	do_action( 'delete_term_taxonomy', $tt_id );
1871
-	$wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $tt_id ) );
1870
+	do_action('delete_term_taxonomy', $tt_id);
1871
+	$wpdb->delete($wpdb->term_taxonomy, array('term_taxonomy_id' => $tt_id));
1872 1872
 
1873 1873
 	/**
1874 1874
 	 * Fires immediately after a term taxonomy ID is deleted.
@@ -1877,11 +1877,11 @@  discard block
 block discarded – undo
1877 1877
 	 *
1878 1878
 	 * @param int $tt_id Term taxonomy ID.
1879 1879
 	 */
1880
-	do_action( 'deleted_term_taxonomy', $tt_id );
1880
+	do_action('deleted_term_taxonomy', $tt_id);
1881 1881
 
1882 1882
 	// Delete the term if no taxonomies use it.
1883
-	if ( !$wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term) ) )
1884
-		$wpdb->delete( $wpdb->terms, array( 'term_id' => $term ) );
1883
+	if ( ! $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term)))
1884
+		$wpdb->delete($wpdb->terms, array('term_id' => $term));
1885 1885
 
1886 1886
 	clean_term_cache($term, $taxonomy);
1887 1887
 
@@ -1898,7 +1898,7 @@  discard block
 block discarded – undo
1898 1898
 	 *                              by the parent function. WP_Error otherwise.
1899 1899
 	 * @param array   $object_ids   List of term object IDs.
1900 1900
 	 */
1901
-	do_action( 'delete_term', $term, $tt_id, $taxonomy, $deleted_term, $object_ids );
1901
+	do_action('delete_term', $term, $tt_id, $taxonomy, $deleted_term, $object_ids);
1902 1902
 
1903 1903
 	/**
1904 1904
 	 * Fires after a term in a specific taxonomy is deleted.
@@ -1915,7 +1915,7 @@  discard block
 block discarded – undo
1915 1915
 	 *                              by the parent function. WP_Error otherwise.
1916 1916
 	 * @param array   $object_ids   List of term object IDs.
1917 1917
 	 */
1918
-	do_action( "delete_$taxonomy", $term, $tt_id, $deleted_term, $object_ids );
1918
+	do_action("delete_$taxonomy", $term, $tt_id, $deleted_term, $object_ids);
1919 1919
 
1920 1920
 	return true;
1921 1921
 }
@@ -1929,8 +1929,8 @@  discard block
 block discarded – undo
1929 1929
  * @return bool|int|WP_Error Returns true if completes delete action; false if term doesn't exist;
1930 1930
  * 	Zero on attempted deletion of default Category; WP_Error object is also a possibility.
1931 1931
  */
1932
-function wp_delete_category( $cat_ID ) {
1933
-	return wp_delete_term( $cat_ID, 'category' );
1932
+function wp_delete_category($cat_ID) {
1933
+	return wp_delete_term($cat_ID, 'category');
1934 1934
 }
1935 1935
 
1936 1936
 /**
@@ -1968,18 +1968,18 @@  discard block
 block discarded – undo
1968 1968
 function wp_get_object_terms($object_ids, $taxonomies, $args = array()) {
1969 1969
 	global $wpdb;
1970 1970
 
1971
-	if ( empty( $object_ids ) || empty( $taxonomies ) )
1971
+	if (empty($object_ids) || empty($taxonomies))
1972 1972
 		return array();
1973 1973
 
1974
-	if ( !is_array($taxonomies) )
1974
+	if ( ! is_array($taxonomies))
1975 1975
 		$taxonomies = array($taxonomies);
1976 1976
 
1977
-	foreach ( $taxonomies as $taxonomy ) {
1978
-		if ( ! taxonomy_exists($taxonomy) )
1979
-			return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) );
1977
+	foreach ($taxonomies as $taxonomy) {
1978
+		if ( ! taxonomy_exists($taxonomy))
1979
+			return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.'));
1980 1980
 	}
1981 1981
 
1982
-	if ( !is_array($object_ids) )
1982
+	if ( ! is_array($object_ids))
1983 1983
 		$object_ids = array($object_ids);
1984 1984
 	$object_ids = array_map('intval', $object_ids);
1985 1985
 
@@ -1991,20 +1991,20 @@  discard block
 block discarded – undo
1991 1991
 		'update_term_meta_cache' => true,
1992 1992
 		'meta_query' => '',
1993 1993
 	);
1994
-	$args = wp_parse_args( $args, $defaults );
1994
+	$args = wp_parse_args($args, $defaults);
1995 1995
 
1996 1996
 	$terms = array();
1997
-	if ( count($taxonomies) > 1 ) {
1998
-		foreach ( $taxonomies as $index => $taxonomy ) {
1997
+	if (count($taxonomies) > 1) {
1998
+		foreach ($taxonomies as $index => $taxonomy) {
1999 1999
 			$t = get_taxonomy($taxonomy);
2000
-			if ( isset($t->args) && is_array($t->args) && $args != array_merge($args, $t->args) ) {
2000
+			if (isset($t->args) && is_array($t->args) && $args != array_merge($args, $t->args)) {
2001 2001
 				unset($taxonomies[$index]);
2002 2002
 				$terms = array_merge($terms, wp_get_object_terms($object_ids, $taxonomy, array_merge($args, $t->args)));
2003 2003
 			}
2004 2004
 		}
2005 2005
 	} else {
2006 2006
 		$t = get_taxonomy($taxonomies[0]);
2007
-		if ( isset($t->args) && is_array($t->args) )
2007
+		if (isset($t->args) && is_array($t->args))
2008 2008
 			$args = array_merge($args, $t->args);
2009 2009
 	}
2010 2010
 
@@ -2012,13 +2012,13 @@  discard block
 block discarded – undo
2012 2012
 	$order = $args['order'];
2013 2013
 	$fields = $args['fields'];
2014 2014
 
2015
-	if ( in_array( $orderby, array( 'term_id', 'name', 'slug', 'term_group' ) ) ) {
2015
+	if (in_array($orderby, array('term_id', 'name', 'slug', 'term_group'))) {
2016 2016
 		$orderby = "t.$orderby";
2017
-	} elseif ( in_array( $orderby, array( 'count', 'parent', 'taxonomy', 'term_taxonomy_id' ) ) ) {
2017
+	} elseif (in_array($orderby, array('count', 'parent', 'taxonomy', 'term_taxonomy_id'))) {
2018 2018
 		$orderby = "tt.$orderby";
2019
-	} elseif ( 'term_order' === $orderby ) {
2019
+	} elseif ('term_order' === $orderby) {
2020 2020
 		$orderby = 'tr.term_order';
2021
-	} elseif ( 'none' === $orderby ) {
2021
+	} elseif ('none' === $orderby) {
2022 2022
 		$orderby = '';
2023 2023
 		$order = '';
2024 2024
 	} else {
@@ -2026,31 +2026,31 @@  discard block
 block discarded – undo
2026 2026
 	}
2027 2027
 
2028 2028
 	// tt_ids queries can only be none or tr.term_taxonomy_id
2029
-	if ( ('tt_ids' == $fields) && !empty($orderby) )
2029
+	if (('tt_ids' == $fields) && ! empty($orderby))
2030 2030
 		$orderby = 'tr.term_taxonomy_id';
2031 2031
 
2032
-	if ( !empty($orderby) )
2032
+	if ( ! empty($orderby))
2033 2033
 		$orderby = "ORDER BY $orderby";
2034 2034
 
2035
-	$order = strtoupper( $order );
2036
-	if ( '' !== $order && ! in_array( $order, array( 'ASC', 'DESC' ) ) )
2035
+	$order = strtoupper($order);
2036
+	if ('' !== $order && ! in_array($order, array('ASC', 'DESC')))
2037 2037
 		$order = 'ASC';
2038 2038
 
2039 2039
 	$taxonomy_array = $taxonomies;
2040 2040
 	$object_id_array = $object_ids;
2041
-	$taxonomies = "'" . implode("', '", array_map( 'esc_sql', $taxonomies ) ) . "'";
2041
+	$taxonomies = "'".implode("', '", array_map('esc_sql', $taxonomies))."'";
2042 2042
 	$object_ids = implode(', ', $object_ids);
2043 2043
 
2044 2044
 	$select_this = '';
2045
-	if ( 'all' == $fields ) {
2045
+	if ('all' == $fields) {
2046 2046
 		$select_this = 't.*, tt.*';
2047
-	} elseif ( 'ids' == $fields ) {
2047
+	} elseif ('ids' == $fields) {
2048 2048
 		$select_this = 't.term_id';
2049
-	} elseif ( 'names' == $fields ) {
2049
+	} elseif ('names' == $fields) {
2050 2050
 		$select_this = 't.name';
2051
-	} elseif ( 'slugs' == $fields ) {
2051
+	} elseif ('slugs' == $fields) {
2052 2052
 		$select_this = 't.slug';
2053
-	} elseif ( 'all_with_object_id' == $fields ) {
2053
+	} elseif ('all_with_object_id' == $fields) {
2054 2054
 		$select_this = 't.*, tt.*, tr.object_id';
2055 2055
 	}
2056 2056
 
@@ -2059,86 +2059,86 @@  discard block
 block discarded – undo
2059 2059
 		"tr.object_id IN ($object_ids)",
2060 2060
 	);
2061 2061
 
2062
-	if ( '' !== $args['parent'] ) {
2063
-		$where[] = $wpdb->prepare( 'tt.parent = %d', $args['parent'] );
2062
+	if ('' !== $args['parent']) {
2063
+		$where[] = $wpdb->prepare('tt.parent = %d', $args['parent']);
2064 2064
 	}
2065 2065
 
2066 2066
 	// Meta query support.
2067 2067
 	$meta_query_join = '';
2068
-	if ( ! empty( $args['meta_query'] ) ) {
2069
-		$mquery = new WP_Meta_Query( $args['meta_query'] );
2070
-		$mq_sql = $mquery->get_sql( 'term', 't', 'term_id' );
2068
+	if ( ! empty($args['meta_query'])) {
2069
+		$mquery = new WP_Meta_Query($args['meta_query']);
2070
+		$mq_sql = $mquery->get_sql('term', 't', 'term_id');
2071 2071
 
2072 2072
 		$meta_query_join .= $mq_sql['join'];
2073 2073
 
2074 2074
 		// Strip leading AND.
2075
-		$where[] = preg_replace( '/^\s*AND/', '', $mq_sql['where'] );
2075
+		$where[] = preg_replace('/^\s*AND/', '', $mq_sql['where']);
2076 2076
 	}
2077 2077
 
2078
-	$where = implode( ' AND ', $where );
2078
+	$where = implode(' AND ', $where);
2079 2079
 
2080 2080
 	$query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN $wpdb->term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id $meta_query_join WHERE $where $orderby $order";
2081 2081
 
2082 2082
 	$objects = false;
2083
-	if ( 'all' == $fields || 'all_with_object_id' == $fields ) {
2084
-		$_terms = $wpdb->get_results( $query );
2083
+	if ('all' == $fields || 'all_with_object_id' == $fields) {
2084
+		$_terms = $wpdb->get_results($query);
2085 2085
 		$object_id_index = array();
2086
-		foreach ( $_terms as $key => $term ) {
2087
-			$term = sanitize_term( $term, $taxonomy, 'raw' );
2088
-			$_terms[ $key ] = $term;
2086
+		foreach ($_terms as $key => $term) {
2087
+			$term = sanitize_term($term, $taxonomy, 'raw');
2088
+			$_terms[$key] = $term;
2089 2089
 
2090
-			if ( isset( $term->object_id ) ) {
2091
-				$object_id_index[ $key ] = $term->object_id;
2090
+			if (isset($term->object_id)) {
2091
+				$object_id_index[$key] = $term->object_id;
2092 2092
 			}
2093 2093
 		}
2094 2094
 
2095
-		update_term_cache( $_terms );
2096
-		$_terms = array_map( 'get_term', $_terms );
2095
+		update_term_cache($_terms);
2096
+		$_terms = array_map('get_term', $_terms);
2097 2097
 
2098 2098
 		// Re-add the object_id data, which is lost when fetching terms from cache.
2099
-		if ( 'all_with_object_id' === $fields ) {
2100
-			foreach ( $_terms as $key => $_term ) {
2101
-				if ( isset( $object_id_index[ $key ] ) ) {
2102
-					$_term->object_id = $object_id_index[ $key ];
2099
+		if ('all_with_object_id' === $fields) {
2100
+			foreach ($_terms as $key => $_term) {
2101
+				if (isset($object_id_index[$key])) {
2102
+					$_term->object_id = $object_id_index[$key];
2103 2103
 				}
2104 2104
 			}
2105 2105
 		}
2106 2106
 
2107
-		$terms = array_merge( $terms, $_terms );
2107
+		$terms = array_merge($terms, $_terms);
2108 2108
 		$objects = true;
2109 2109
 
2110
-	} elseif ( 'ids' == $fields || 'names' == $fields || 'slugs' == $fields ) {
2111
-		$_terms = $wpdb->get_col( $query );
2112
-		$_field = ( 'ids' == $fields ) ? 'term_id' : 'name';
2113
-		foreach ( $_terms as $key => $term ) {
2114
-			$_terms[$key] = sanitize_term_field( $_field, $term, $term, $taxonomy, 'raw' );
2110
+	} elseif ('ids' == $fields || 'names' == $fields || 'slugs' == $fields) {
2111
+		$_terms = $wpdb->get_col($query);
2112
+		$_field = ('ids' == $fields) ? 'term_id' : 'name';
2113
+		foreach ($_terms as $key => $term) {
2114
+			$_terms[$key] = sanitize_term_field($_field, $term, $term, $taxonomy, 'raw');
2115 2115
 		}
2116
-		$terms = array_merge( $terms, $_terms );
2117
-	} elseif ( 'tt_ids' == $fields ) {
2116
+		$terms = array_merge($terms, $_terms);
2117
+	} elseif ('tt_ids' == $fields) {
2118 2118
 		$terms = $wpdb->get_col("SELECT tr.term_taxonomy_id FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tr.object_id IN ($object_ids) AND tt.taxonomy IN ($taxonomies) $orderby $order");
2119
-		foreach ( $terms as $key => $tt_id ) {
2120
-			$terms[$key] = sanitize_term_field( 'term_taxonomy_id', $tt_id, 0, $taxonomy, 'raw' ); // 0 should be the term id, however is not needed when using raw context.
2119
+		foreach ($terms as $key => $tt_id) {
2120
+			$terms[$key] = sanitize_term_field('term_taxonomy_id', $tt_id, 0, $taxonomy, 'raw'); // 0 should be the term id, however is not needed when using raw context.
2121 2121
 		}
2122 2122
 	}
2123 2123
 
2124 2124
 	// Update termmeta cache, if necessary.
2125
-	if ( $args['update_term_meta_cache'] && ( 'all' === $fields || 'all_with_object_id' === $fields || 'ids' === $fields ) ) {
2126
-		if ( 'ids' === $fields ) {
2125
+	if ($args['update_term_meta_cache'] && ('all' === $fields || 'all_with_object_id' === $fields || 'ids' === $fields)) {
2126
+		if ('ids' === $fields) {
2127 2127
 			$term_ids = $terms;
2128 2128
 		} else {
2129
-			$term_ids = wp_list_pluck( $terms, 'term_id' );
2129
+			$term_ids = wp_list_pluck($terms, 'term_id');
2130 2130
 		}
2131 2131
 
2132
-		update_termmeta_cache( $term_ids );
2132
+		update_termmeta_cache($term_ids);
2133 2133
 	}
2134 2134
 
2135
-	if ( ! $terms ) {
2135
+	if ( ! $terms) {
2136 2136
 		$terms = array();
2137
-	} elseif ( $objects && 'all_with_object_id' !== $fields ) {
2137
+	} elseif ($objects && 'all_with_object_id' !== $fields) {
2138 2138
 		$_tt_ids = array();
2139 2139
 		$_terms = array();
2140
-		foreach ( $terms as $term ) {
2141
-			if ( in_array( $term->term_taxonomy_id, $_tt_ids ) ) {
2140
+		foreach ($terms as $term) {
2141
+			if (in_array($term->term_taxonomy_id, $_tt_ids)) {
2142 2142
 				continue;
2143 2143
 			}
2144 2144
 
@@ -2146,8 +2146,8 @@  discard block
 block discarded – undo
2146 2146
 			$_terms[] = $term;
2147 2147
 		}
2148 2148
 		$terms = $_terms;
2149
-	} elseif ( ! $objects ) {
2150
-		$terms = array_values( array_unique( $terms ) );
2149
+	} elseif ( ! $objects) {
2150
+		$terms = array_values(array_unique($terms));
2151 2151
 	}
2152 2152
 
2153 2153
 	/**
@@ -2161,7 +2161,7 @@  discard block
 block discarded – undo
2161 2161
 	 * @param array $args            An array of arguments for retrieving terms for the given
2162 2162
 	 *                               object(s). See wp_get_object_terms() for details.
2163 2163
 	 */
2164
-	$terms = apply_filters( 'get_object_terms', $terms, $object_id_array, $taxonomy_array, $args );
2164
+	$terms = apply_filters('get_object_terms', $terms, $object_id_array, $taxonomy_array, $args);
2165 2165
 
2166 2166
 	/**
2167 2167
 	 * Filters the terms for a given object or objects.
@@ -2177,7 +2177,7 @@  discard block
 block discarded – undo
2177 2177
 	 * @param array     $args       An array of arguments for retrieving terms for the given object(s).
2178 2178
 	 *                              See wp_get_object_terms() for details.
2179 2179
 	 */
2180
-	return apply_filters( 'wp_get_object_terms', $terms, $object_ids, $taxonomies, $args );
2180
+	return apply_filters('wp_get_object_terms', $terms, $object_ids, $taxonomies, $args);
2181 2181
 }
2182 2182
 
2183 2183
 /**
@@ -2223,11 +2223,11 @@  discard block
 block discarded – undo
2223 2223
  * @return array|WP_Error An array containing the `term_id` and `term_taxonomy_id`,
2224 2224
  *                        WP_Error otherwise.
2225 2225
  */
2226
-function wp_insert_term( $term, $taxonomy, $args = array() ) {
2226
+function wp_insert_term($term, $taxonomy, $args = array()) {
2227 2227
 	global $wpdb;
2228 2228
 
2229
-	if ( ! taxonomy_exists($taxonomy) ) {
2230
-		return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) );
2229
+	if ( ! taxonomy_exists($taxonomy)) {
2230
+		return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.'));
2231 2231
 	}
2232 2232
 	/**
2233 2233
 	 * Filters a term before it is sanitized and inserted into the database.
@@ -2237,21 +2237,21 @@  discard block
 block discarded – undo
2237 2237
 	 * @param string $term     The term to add or update.
2238 2238
 	 * @param string $taxonomy Taxonomy slug.
2239 2239
 	 */
2240
-	$term = apply_filters( 'pre_insert_term', $term, $taxonomy );
2241
-	if ( is_wp_error( $term ) ) {
2240
+	$term = apply_filters('pre_insert_term', $term, $taxonomy);
2241
+	if (is_wp_error($term)) {
2242 2242
 		return $term;
2243 2243
 	}
2244
-	if ( is_int( $term ) && 0 == $term ) {
2245
-		return new WP_Error( 'invalid_term_id', __( 'Invalid term ID.' ) );
2244
+	if (is_int($term) && 0 == $term) {
2245
+		return new WP_Error('invalid_term_id', __('Invalid term ID.'));
2246 2246
 	}
2247
-	if ( '' == trim( $term ) ) {
2248
-		return new WP_Error( 'empty_term_name', __( 'A name is required for this term.' ) );
2247
+	if ('' == trim($term)) {
2248
+		return new WP_Error('empty_term_name', __('A name is required for this term.'));
2249 2249
 	}
2250
-	$defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
2251
-	$args = wp_parse_args( $args, $defaults );
2250
+	$defaults = array('alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
2251
+	$args = wp_parse_args($args, $defaults);
2252 2252
 
2253
-	if ( $args['parent'] > 0 && ! term_exists( (int) $args['parent'] ) ) {
2254
-		return new WP_Error( 'missing_parent', __( 'Parent term does not exist.' ) );
2253
+	if ($args['parent'] > 0 && ! term_exists((int) $args['parent'])) {
2254
+		return new WP_Error('missing_parent', __('Parent term does not exist.'));
2255 2255
 	}
2256 2256
 
2257 2257
 	$args['name'] = $term;
@@ -2263,33 +2263,33 @@  discard block
 block discarded – undo
2263 2263
 	$args = sanitize_term($args, $taxonomy, 'db');
2264 2264
 
2265 2265
 	// expected_slashed ($name)
2266
-	$name = wp_unslash( $args['name'] );
2267
-	$description = wp_unslash( $args['description'] );
2266
+	$name = wp_unslash($args['name']);
2267
+	$description = wp_unslash($args['description']);
2268 2268
 	$parent = (int) $args['parent'];
2269 2269
 
2270
-	$slug_provided = ! empty( $args['slug'] );
2271
-	if ( ! $slug_provided ) {
2272
-		$slug = sanitize_title( $name );
2270
+	$slug_provided = ! empty($args['slug']);
2271
+	if ( ! $slug_provided) {
2272
+		$slug = sanitize_title($name);
2273 2273
 	} else {
2274 2274
 		$slug = $args['slug'];
2275 2275
 	}
2276 2276
 
2277 2277
 	$term_group = 0;
2278
-	if ( $args['alias_of'] ) {
2279
-		$alias = get_term_by( 'slug', $args['alias_of'], $taxonomy );
2280
-		if ( ! empty( $alias->term_group ) ) {
2278
+	if ($args['alias_of']) {
2279
+		$alias = get_term_by('slug', $args['alias_of'], $taxonomy);
2280
+		if ( ! empty($alias->term_group)) {
2281 2281
 			// The alias we want is already in a group, so let's use that one.
2282 2282
 			$term_group = $alias->term_group;
2283
-		} elseif ( ! empty( $alias->term_id ) ) {
2283
+		} elseif ( ! empty($alias->term_id)) {
2284 2284
 			/*
2285 2285
 			 * The alias is not in a group, so we create a new one
2286 2286
 			 * and add the alias to it.
2287 2287
 			 */
2288 2288
 			$term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1;
2289 2289
 
2290
-			wp_update_term( $alias->term_id, $taxonomy, array(
2290
+			wp_update_term($alias->term_id, $taxonomy, array(
2291 2291
 				'term_group' => $term_group,
2292
-			) );
2292
+			));
2293 2293
 		}
2294 2294
 	}
2295 2295
 
@@ -2297,73 +2297,73 @@  discard block
 block discarded – undo
2297 2297
 	 * Prevent the creation of terms with duplicate names at the same level of a taxonomy hierarchy,
2298 2298
 	 * unless a unique slug has been explicitly provided.
2299 2299
 	 */
2300
-	$name_matches = get_terms( $taxonomy, array(
2300
+	$name_matches = get_terms($taxonomy, array(
2301 2301
 		'name' => $name,
2302 2302
 		'hide_empty' => false,
2303
-	) );
2303
+	));
2304 2304
 
2305 2305
 	/*
2306 2306
 	 * The `name` match in `get_terms()` doesn't differentiate accented characters,
2307 2307
 	 * so we do a stricter comparison here.
2308 2308
 	 */
2309 2309
 	$name_match = null;
2310
-	if ( $name_matches ) {
2311
-		foreach ( $name_matches as $_match ) {
2312
-			if ( strtolower( $name ) === strtolower( $_match->name ) ) {
2310
+	if ($name_matches) {
2311
+		foreach ($name_matches as $_match) {
2312
+			if (strtolower($name) === strtolower($_match->name)) {
2313 2313
 				$name_match = $_match;
2314 2314
 				break;
2315 2315
 			}
2316 2316
 		}
2317 2317
 	}
2318 2318
 
2319
-	if ( $name_match ) {
2320
-		$slug_match = get_term_by( 'slug', $slug, $taxonomy );
2321
-		if ( ! $slug_provided || $name_match->slug === $slug || $slug_match ) {
2322
-			if ( is_taxonomy_hierarchical( $taxonomy ) ) {
2323
-				$siblings = get_terms( $taxonomy, array( 'get' => 'all', 'parent' => $parent ) );
2319
+	if ($name_match) {
2320
+		$slug_match = get_term_by('slug', $slug, $taxonomy);
2321
+		if ( ! $slug_provided || $name_match->slug === $slug || $slug_match) {
2322
+			if (is_taxonomy_hierarchical($taxonomy)) {
2323
+				$siblings = get_terms($taxonomy, array('get' => 'all', 'parent' => $parent));
2324 2324
 
2325 2325
 				$existing_term = null;
2326
-				if ( $name_match->slug === $slug && in_array( $name, wp_list_pluck( $siblings, 'name' ) ) ) {
2326
+				if ($name_match->slug === $slug && in_array($name, wp_list_pluck($siblings, 'name'))) {
2327 2327
 					$existing_term = $name_match;
2328
-				} elseif ( $slug_match && in_array( $slug, wp_list_pluck( $siblings, 'slug' ) ) ) {
2328
+				} elseif ($slug_match && in_array($slug, wp_list_pluck($siblings, 'slug'))) {
2329 2329
 					$existing_term = $slug_match;
2330 2330
 				}
2331 2331
 
2332
-				if ( $existing_term ) {
2333
-					return new WP_Error( 'term_exists', __( 'A term with the name provided already exists with this parent.' ), $existing_term->term_id );
2332
+				if ($existing_term) {
2333
+					return new WP_Error('term_exists', __('A term with the name provided already exists with this parent.'), $existing_term->term_id);
2334 2334
 				}
2335 2335
 			} else {
2336
-				return new WP_Error( 'term_exists', __( 'A term with the name provided already exists in this taxonomy.' ), $name_match->term_id );
2336
+				return new WP_Error('term_exists', __('A term with the name provided already exists in this taxonomy.'), $name_match->term_id);
2337 2337
 			}
2338 2338
 		}
2339 2339
 	}
2340 2340
 
2341
-	$slug = wp_unique_term_slug( $slug, (object) $args );
2341
+	$slug = wp_unique_term_slug($slug, (object) $args);
2342 2342
 
2343
-	if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) ) {
2344
-		return new WP_Error( 'db_insert_error', __( 'Could not insert term into the database' ), $wpdb->last_error );
2343
+	if (false === $wpdb->insert($wpdb->terms, compact('name', 'slug', 'term_group'))) {
2344
+		return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error);
2345 2345
 	}
2346 2346
 
2347 2347
 	$term_id = (int) $wpdb->insert_id;
2348 2348
 
2349 2349
 	// Seems unreachable, However, Is used in the case that a term name is provided, which sanitizes to an empty string.
2350
-	if ( empty($slug) ) {
2350
+	if (empty($slug)) {
2351 2351
 		$slug = sanitize_title($slug, $term_id);
2352 2352
 
2353 2353
 		/** This action is documented in wp-includes/taxonomy.php */
2354
-		do_action( 'edit_terms', $term_id, $taxonomy );
2355
-		$wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) );
2354
+		do_action('edit_terms', $term_id, $taxonomy);
2355
+		$wpdb->update($wpdb->terms, compact('slug'), compact('term_id'));
2356 2356
 
2357 2357
 		/** This action is documented in wp-includes/taxonomy.php */
2358
-		do_action( 'edited_terms', $term_id, $taxonomy );
2358
+		do_action('edited_terms', $term_id, $taxonomy);
2359 2359
 	}
2360 2360
 
2361
-	$tt_id = $wpdb->get_var( $wpdb->prepare( "SELECT tt.term_taxonomy_id FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.term_id = %d", $taxonomy, $term_id ) );
2361
+	$tt_id = $wpdb->get_var($wpdb->prepare("SELECT tt.term_taxonomy_id FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.term_id = %d", $taxonomy, $term_id));
2362 2362
 
2363
-	if ( !empty($tt_id) ) {
2363
+	if ( ! empty($tt_id)) {
2364 2364
 		return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
2365 2365
 	}
2366
-	$wpdb->insert( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent') + array( 'count' => 0 ) );
2366
+	$wpdb->insert($wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent') + array('count' => 0));
2367 2367
 	$tt_id = (int) $wpdb->insert_id;
2368 2368
 
2369 2369
 	/*
@@ -2372,16 +2372,16 @@  discard block
 block discarded – undo
2372 2372
 	 * and term_taxonomy_id of the older term instead. Then return out of the function so that the "create" hooks
2373 2373
 	 * are not fired.
2374 2374
 	 */
2375
-	$duplicate_term = $wpdb->get_row( $wpdb->prepare( "SELECT t.term_id, tt.term_taxonomy_id FROM $wpdb->terms t INNER JOIN $wpdb->term_taxonomy tt ON ( tt.term_id = t.term_id ) WHERE t.slug = %s AND tt.parent = %d AND tt.taxonomy = %s AND t.term_id < %d AND tt.term_taxonomy_id != %d", $slug, $parent, $taxonomy, $term_id, $tt_id ) );
2376
-	if ( $duplicate_term ) {
2377
-		$wpdb->delete( $wpdb->terms, array( 'term_id' => $term_id ) );
2378
-		$wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $tt_id ) );
2375
+	$duplicate_term = $wpdb->get_row($wpdb->prepare("SELECT t.term_id, tt.term_taxonomy_id FROM $wpdb->terms t INNER JOIN $wpdb->term_taxonomy tt ON ( tt.term_id = t.term_id ) WHERE t.slug = %s AND tt.parent = %d AND tt.taxonomy = %s AND t.term_id < %d AND tt.term_taxonomy_id != %d", $slug, $parent, $taxonomy, $term_id, $tt_id));
2376
+	if ($duplicate_term) {
2377
+		$wpdb->delete($wpdb->terms, array('term_id' => $term_id));
2378
+		$wpdb->delete($wpdb->term_taxonomy, array('term_taxonomy_id' => $tt_id));
2379 2379
 
2380 2380
 		$term_id = (int) $duplicate_term->term_id;
2381 2381
 		$tt_id   = (int) $duplicate_term->term_taxonomy_id;
2382 2382
 
2383
-		clean_term_cache( $term_id, $taxonomy );
2384
-		return array( 'term_id' => $term_id, 'term_taxonomy_id' => $tt_id );
2383
+		clean_term_cache($term_id, $taxonomy);
2384
+		return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
2385 2385
 	}
2386 2386
 
2387 2387
 	/**
@@ -2393,7 +2393,7 @@  discard block
 block discarded – undo
2393 2393
 	 * @param int    $tt_id    Term taxonomy ID.
2394 2394
 	 * @param string $taxonomy Taxonomy slug.
2395 2395
 	 */
2396
-	do_action( "create_term", $term_id, $tt_id, $taxonomy );
2396
+	do_action("create_term", $term_id, $tt_id, $taxonomy);
2397 2397
 
2398 2398
 	/**
2399 2399
 	 * Fires after a new term is created for a specific taxonomy.
@@ -2406,7 +2406,7 @@  discard block
 block discarded – undo
2406 2406
 	 * @param int $term_id Term ID.
2407 2407
 	 * @param int $tt_id   Term taxonomy ID.
2408 2408
 	 */
2409
-	do_action( "create_$taxonomy", $term_id, $tt_id );
2409
+	do_action("create_$taxonomy", $term_id, $tt_id);
2410 2410
 
2411 2411
 	/**
2412 2412
 	 * Filters the term ID after a new term is created.
@@ -2416,7 +2416,7 @@  discard block
 block discarded – undo
2416 2416
 	 * @param int $term_id Term ID.
2417 2417
 	 * @param int $tt_id   Taxonomy term ID.
2418 2418
 	 */
2419
-	$term_id = apply_filters( 'term_id_filter', $term_id, $tt_id );
2419
+	$term_id = apply_filters('term_id_filter', $term_id, $tt_id);
2420 2420
 
2421 2421
 	clean_term_cache($term_id, $taxonomy);
2422 2422
 
@@ -2429,7 +2429,7 @@  discard block
 block discarded – undo
2429 2429
 	 * @param int    $tt_id    Term taxonomy ID.
2430 2430
 	 * @param string $taxonomy Taxonomy slug.
2431 2431
 	 */
2432
-	do_action( 'created_term', $term_id, $tt_id, $taxonomy );
2432
+	do_action('created_term', $term_id, $tt_id, $taxonomy);
2433 2433
 
2434 2434
 	/**
2435 2435
 	 * Fires after a new term in a specific taxonomy is created, and after the term
@@ -2442,7 +2442,7 @@  discard block
 block discarded – undo
2442 2442
 	 * @param int $term_id Term ID.
2443 2443
 	 * @param int $tt_id   Term taxonomy ID.
2444 2444
 	 */
2445
-	do_action( "created_$taxonomy", $term_id, $tt_id );
2445
+	do_action("created_$taxonomy", $term_id, $tt_id);
2446 2446
 
2447 2447
 	return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
2448 2448
 }
@@ -2469,20 +2469,20 @@  discard block
 block discarded – undo
2469 2469
  * @param bool             $append    Optional. If false will delete difference of terms. Default false.
2470 2470
  * @return array|WP_Error Term taxonomy IDs of the affected terms.
2471 2471
  */
2472
-function wp_set_object_terms( $object_id, $terms, $taxonomy, $append = false ) {
2472
+function wp_set_object_terms($object_id, $terms, $taxonomy, $append = false) {
2473 2473
 	global $wpdb;
2474 2474
 
2475 2475
 	$object_id = (int) $object_id;
2476 2476
 
2477
-	if ( ! taxonomy_exists( $taxonomy ) ) {
2478
-		return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) );
2477
+	if ( ! taxonomy_exists($taxonomy)) {
2478
+		return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.'));
2479 2479
 	}
2480 2480
 
2481
-	if ( !is_array($terms) )
2481
+	if ( ! is_array($terms))
2482 2482
 		$terms = array($terms);
2483 2483
 
2484
-	if ( ! $append )
2485
-		$old_tt_ids =  wp_get_object_terms($object_id, $taxonomy, array('fields' => 'tt_ids', 'orderby' => 'none'));
2484
+	if ( ! $append)
2485
+		$old_tt_ids = wp_get_object_terms($object_id, $taxonomy, array('fields' => 'tt_ids', 'orderby' => 'none'));
2486 2486
 	else
2487 2487
 		$old_tt_ids = array();
2488 2488
 
@@ -2490,23 +2490,23 @@  discard block
 block discarded – undo
2490 2490
 	$term_ids = array();
2491 2491
 	$new_tt_ids = array();
2492 2492
 
2493
-	foreach ( (array) $terms as $term) {
2494
-		if ( !strlen(trim($term)) )
2493
+	foreach ((array) $terms as $term) {
2494
+		if ( ! strlen(trim($term)))
2495 2495
 			continue;
2496 2496
 
2497
-		if ( !$term_info = term_exists($term, $taxonomy) ) {
2497
+		if ( ! $term_info = term_exists($term, $taxonomy)) {
2498 2498
 			// Skip if a non-existent term ID is passed.
2499
-			if ( is_int($term) )
2499
+			if (is_int($term))
2500 2500
 				continue;
2501 2501
 			$term_info = wp_insert_term($term, $taxonomy);
2502 2502
 		}
2503
-		if ( is_wp_error($term_info) )
2503
+		if (is_wp_error($term_info))
2504 2504
 			return $term_info;
2505 2505
 		$term_ids[] = $term_info['term_id'];
2506 2506
 		$tt_id = $term_info['term_taxonomy_id'];
2507 2507
 		$tt_ids[] = $tt_id;
2508 2508
 
2509
-		if ( $wpdb->get_var( $wpdb->prepare( "SELECT term_taxonomy_id FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id = %d", $object_id, $tt_id ) ) )
2509
+		if ($wpdb->get_var($wpdb->prepare("SELECT term_taxonomy_id FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id = %d", $object_id, $tt_id)))
2510 2510
 			continue;
2511 2511
 
2512 2512
 		/**
@@ -2517,8 +2517,8 @@  discard block
 block discarded – undo
2517 2517
 		 * @param int $object_id Object ID.
2518 2518
 		 * @param int $tt_id     Term taxonomy ID.
2519 2519
 		 */
2520
-		do_action( 'add_term_relationship', $object_id, $tt_id );
2521
-		$wpdb->insert( $wpdb->term_relationships, array( 'object_id' => $object_id, 'term_taxonomy_id' => $tt_id ) );
2520
+		do_action('add_term_relationship', $object_id, $tt_id);
2521
+		$wpdb->insert($wpdb->term_relationships, array('object_id' => $object_id, 'term_taxonomy_id' => $tt_id));
2522 2522
 
2523 2523
 		/**
2524 2524
 		 * Fires immediately after an object-term relationship is added.
@@ -2528,42 +2528,42 @@  discard block
 block discarded – undo
2528 2528
 		 * @param int $object_id Object ID.
2529 2529
 		 * @param int $tt_id     Term taxonomy ID.
2530 2530
 		 */
2531
-		do_action( 'added_term_relationship', $object_id, $tt_id );
2531
+		do_action('added_term_relationship', $object_id, $tt_id);
2532 2532
 		$new_tt_ids[] = $tt_id;
2533 2533
 	}
2534 2534
 
2535
-	if ( $new_tt_ids )
2536
-		wp_update_term_count( $new_tt_ids, $taxonomy );
2535
+	if ($new_tt_ids)
2536
+		wp_update_term_count($new_tt_ids, $taxonomy);
2537 2537
 
2538
-	if ( ! $append ) {
2539
-		$delete_tt_ids = array_diff( $old_tt_ids, $tt_ids );
2538
+	if ( ! $append) {
2539
+		$delete_tt_ids = array_diff($old_tt_ids, $tt_ids);
2540 2540
 
2541
-		if ( $delete_tt_ids ) {
2542
-			$in_delete_tt_ids = "'" . implode( "', '", $delete_tt_ids ) . "'";
2543
-			$delete_term_ids = $wpdb->get_col( $wpdb->prepare( "SELECT tt.term_id FROM $wpdb->term_taxonomy AS tt WHERE tt.taxonomy = %s AND tt.term_taxonomy_id IN ($in_delete_tt_ids)", $taxonomy ) );
2544
-			$delete_term_ids = array_map( 'intval', $delete_term_ids );
2541
+		if ($delete_tt_ids) {
2542
+			$in_delete_tt_ids = "'".implode("', '", $delete_tt_ids)."'";
2543
+			$delete_term_ids = $wpdb->get_col($wpdb->prepare("SELECT tt.term_id FROM $wpdb->term_taxonomy AS tt WHERE tt.taxonomy = %s AND tt.term_taxonomy_id IN ($in_delete_tt_ids)", $taxonomy));
2544
+			$delete_term_ids = array_map('intval', $delete_term_ids);
2545 2545
 
2546
-			$remove = wp_remove_object_terms( $object_id, $delete_term_ids, $taxonomy );
2547
-			if ( is_wp_error( $remove ) ) {
2546
+			$remove = wp_remove_object_terms($object_id, $delete_term_ids, $taxonomy);
2547
+			if (is_wp_error($remove)) {
2548 2548
 				return $remove;
2549 2549
 			}
2550 2550
 		}
2551 2551
 	}
2552 2552
 
2553 2553
 	$t = get_taxonomy($taxonomy);
2554
-	if ( ! $append && isset($t->sort) && $t->sort ) {
2554
+	if ( ! $append && isset($t->sort) && $t->sort) {
2555 2555
 		$values = array();
2556 2556
 		$term_order = 0;
2557 2557
 		$final_tt_ids = wp_get_object_terms($object_id, $taxonomy, array('fields' => 'tt_ids'));
2558
-		foreach ( $tt_ids as $tt_id )
2559
-			if ( in_array($tt_id, $final_tt_ids) )
2560
-				$values[] = $wpdb->prepare( "(%d, %d, %d)", $object_id, $tt_id, ++$term_order);
2561
-		if ( $values )
2562
-			if ( false === $wpdb->query( "INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id, term_order) VALUES " . join( ',', $values ) . " ON DUPLICATE KEY UPDATE term_order = VALUES(term_order)" ) )
2563
-				return new WP_Error( 'db_insert_error', __( 'Could not insert term relationship into the database' ), $wpdb->last_error );
2558
+		foreach ($tt_ids as $tt_id)
2559
+			if (in_array($tt_id, $final_tt_ids))
2560
+				$values[] = $wpdb->prepare("(%d, %d, %d)", $object_id, $tt_id, ++$term_order);
2561
+		if ($values)
2562
+			if (false === $wpdb->query("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id, term_order) VALUES ".join(',', $values)." ON DUPLICATE KEY UPDATE term_order = VALUES(term_order)"))
2563
+				return new WP_Error('db_insert_error', __('Could not insert term relationship into the database'), $wpdb->last_error);
2564 2564
 	}
2565 2565
 
2566
-	wp_cache_delete( $object_id, $taxonomy . '_relationships' );
2566
+	wp_cache_delete($object_id, $taxonomy.'_relationships');
2567 2567
 
2568 2568
 	/**
2569 2569
 	 * Fires after an object's terms have been set.
@@ -2577,7 +2577,7 @@  discard block
 block discarded – undo
2577 2577
 	 * @param bool   $append     Whether to append new terms to the old terms.
2578 2578
 	 * @param array  $old_tt_ids Old array of term taxonomy IDs.
2579 2579
 	 */
2580
-	do_action( 'set_object_terms', $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids );
2580
+	do_action('set_object_terms', $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids);
2581 2581
 	return $tt_ids;
2582 2582
 }
2583 2583
 
@@ -2591,8 +2591,8 @@  discard block
 block discarded – undo
2591 2591
  * @param array|string     $taxonomy  Taxonomy name.
2592 2592
  * @return array|WP_Error Term taxonomy IDs of the affected terms.
2593 2593
  */
2594
-function wp_add_object_terms( $object_id, $terms, $taxonomy ) {
2595
-	return wp_set_object_terms( $object_id, $terms, $taxonomy, true );
2594
+function wp_add_object_terms($object_id, $terms, $taxonomy) {
2595
+	return wp_set_object_terms($object_id, $terms, $taxonomy, true);
2596 2596
 }
2597 2597
 
2598 2598
 /**
@@ -2607,42 +2607,42 @@  discard block
 block discarded – undo
2607 2607
  * @param array|string     $taxonomy  Taxonomy name.
2608 2608
  * @return bool|WP_Error True on success, false or WP_Error on failure.
2609 2609
  */
2610
-function wp_remove_object_terms( $object_id, $terms, $taxonomy ) {
2610
+function wp_remove_object_terms($object_id, $terms, $taxonomy) {
2611 2611
 	global $wpdb;
2612 2612
 
2613 2613
 	$object_id = (int) $object_id;
2614 2614
 
2615
-	if ( ! taxonomy_exists( $taxonomy ) ) {
2616
-		return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) );
2615
+	if ( ! taxonomy_exists($taxonomy)) {
2616
+		return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.'));
2617 2617
 	}
2618 2618
 
2619
-	if ( ! is_array( $terms ) ) {
2620
-		$terms = array( $terms );
2619
+	if ( ! is_array($terms)) {
2620
+		$terms = array($terms);
2621 2621
 	}
2622 2622
 
2623 2623
 	$tt_ids = array();
2624 2624
 
2625
-	foreach ( (array) $terms as $term ) {
2626
-		if ( ! strlen( trim( $term ) ) ) {
2625
+	foreach ((array) $terms as $term) {
2626
+		if ( ! strlen(trim($term))) {
2627 2627
 			continue;
2628 2628
 		}
2629 2629
 
2630
-		if ( ! $term_info = term_exists( $term, $taxonomy ) ) {
2630
+		if ( ! $term_info = term_exists($term, $taxonomy)) {
2631 2631
 			// Skip if a non-existent term ID is passed.
2632
-			if ( is_int( $term ) ) {
2632
+			if (is_int($term)) {
2633 2633
 				continue;
2634 2634
 			}
2635 2635
 		}
2636 2636
 
2637
-		if ( is_wp_error( $term_info ) ) {
2637
+		if (is_wp_error($term_info)) {
2638 2638
 			return $term_info;
2639 2639
 		}
2640 2640
 
2641 2641
 		$tt_ids[] = $term_info['term_taxonomy_id'];
2642 2642
 	}
2643 2643
 
2644
-	if ( $tt_ids ) {
2645
-		$in_tt_ids = "'" . implode( "', '", $tt_ids ) . "'";
2644
+	if ($tt_ids) {
2645
+		$in_tt_ids = "'".implode("', '", $tt_ids)."'";
2646 2646
 
2647 2647
 		/**
2648 2648
 		 * Fires immediately before an object-term relationship is deleted.
@@ -2652,10 +2652,10 @@  discard block
 block discarded – undo
2652 2652
 		 * @param int   $object_id Object ID.
2653 2653
 		 * @param array $tt_ids    An array of term taxonomy IDs.
2654 2654
 		 */
2655
-		do_action( 'delete_term_relationships', $object_id, $tt_ids );
2656
-		$deleted = $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_tt_ids)", $object_id ) );
2655
+		do_action('delete_term_relationships', $object_id, $tt_ids);
2656
+		$deleted = $wpdb->query($wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_tt_ids)", $object_id));
2657 2657
 
2658
-		wp_cache_delete( $object_id, $taxonomy . '_relationships' );
2658
+		wp_cache_delete($object_id, $taxonomy.'_relationships');
2659 2659
 
2660 2660
 		/**
2661 2661
 		 * Fires immediately after an object-term relationship is deleted.
@@ -2665,9 +2665,9 @@  discard block
 block discarded – undo
2665 2665
 		 * @param int   $object_id Object ID.
2666 2666
 		 * @param array $tt_ids    An array of term taxonomy IDs.
2667 2667
 		 */
2668
-		do_action( 'deleted_term_relationships', $object_id, $tt_ids );
2668
+		do_action('deleted_term_relationships', $object_id, $tt_ids);
2669 2669
 
2670
-		wp_update_term_count( $tt_ids, $taxonomy );
2670
+		wp_update_term_count($tt_ids, $taxonomy);
2671 2671
 
2672 2672
 		return (bool) $deleted;
2673 2673
 	}
@@ -2698,14 +2698,14 @@  discard block
 block discarded – undo
2698 2698
  * @param object $term The term object that the `$slug` will belong to.
2699 2699
  * @return string Will return a true unique slug.
2700 2700
  */
2701
-function wp_unique_term_slug( $slug, $term ) {
2701
+function wp_unique_term_slug($slug, $term) {
2702 2702
 	global $wpdb;
2703 2703
 
2704 2704
 	$needs_suffix = true;
2705 2705
 	$original_slug = $slug;
2706 2706
 
2707 2707
 	// As of 4.1, duplicate slugs are allowed as long as they're in different taxonomies.
2708
-	if ( ! term_exists( $slug ) || get_option( 'db_version' ) >= 30133 && ! get_term_by( 'slug', $slug, $term->taxonomy ) ) {
2708
+	if ( ! term_exists($slug) || get_option('db_version') >= 30133 && ! get_term_by('slug', $slug, $term->taxonomy)) {
2709 2709
 		$needs_suffix = false;
2710 2710
 	}
2711 2711
 
@@ -2714,18 +2714,18 @@  discard block
 block discarded – undo
2714 2714
 	 * by incorporating parent slugs.
2715 2715
 	 */
2716 2716
 	$parent_suffix = '';
2717
-	if ( $needs_suffix && is_taxonomy_hierarchical( $term->taxonomy ) && ! empty( $term->parent ) ) {
2717
+	if ($needs_suffix && is_taxonomy_hierarchical($term->taxonomy) && ! empty($term->parent)) {
2718 2718
 		$the_parent = $term->parent;
2719
-		while ( ! empty($the_parent) ) {
2719
+		while ( ! empty($the_parent)) {
2720 2720
 			$parent_term = get_term($the_parent, $term->taxonomy);
2721
-			if ( is_wp_error($parent_term) || empty($parent_term) )
2721
+			if (is_wp_error($parent_term) || empty($parent_term))
2722 2722
 				break;
2723
-			$parent_suffix .= '-' . $parent_term->slug;
2724
-			if ( ! term_exists( $slug . $parent_suffix ) ) {
2723
+			$parent_suffix .= '-'.$parent_term->slug;
2724
+			if ( ! term_exists($slug.$parent_suffix)) {
2725 2725
 				break;
2726 2726
 			}
2727 2727
 
2728
-			if ( empty($parent_term->parent) )
2728
+			if (empty($parent_term->parent))
2729 2729
 				break;
2730 2730
 			$the_parent = $parent_term->parent;
2731 2731
 		}
@@ -2742,22 +2742,22 @@  discard block
 block discarded – undo
2742 2742
 	 * @param string $slug         The slug.
2743 2743
 	 * @param object $term         Term object.
2744 2744
 	 */
2745
-	if ( apply_filters( 'wp_unique_term_slug_is_bad_slug', $needs_suffix, $slug, $term ) ) {
2746
-		if ( $parent_suffix ) {
2745
+	if (apply_filters('wp_unique_term_slug_is_bad_slug', $needs_suffix, $slug, $term)) {
2746
+		if ($parent_suffix) {
2747 2747
 			$slug .= $parent_suffix;
2748 2748
 		} else {
2749
-			if ( ! empty( $term->term_id ) )
2750
-				$query = $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s AND term_id != %d", $slug, $term->term_id );
2749
+			if ( ! empty($term->term_id))
2750
+				$query = $wpdb->prepare("SELECT slug FROM $wpdb->terms WHERE slug = %s AND term_id != %d", $slug, $term->term_id);
2751 2751
 			else
2752
-				$query = $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s", $slug );
2752
+				$query = $wpdb->prepare("SELECT slug FROM $wpdb->terms WHERE slug = %s", $slug);
2753 2753
 
2754
-			if ( $wpdb->get_var( $query ) ) {
2754
+			if ($wpdb->get_var($query)) {
2755 2755
 				$num = 2;
2756 2756
 				do {
2757
-					$alt_slug = $slug . "-$num";
2757
+					$alt_slug = $slug."-$num";
2758 2758
 					$num++;
2759
-					$slug_check = $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug ) );
2760
-				} while ( $slug_check );
2759
+					$slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug));
2760
+				} while ($slug_check);
2761 2761
 				$slug = $alt_slug;
2762 2762
 			}
2763 2763
 		}
@@ -2772,7 +2772,7 @@  discard block
 block discarded – undo
2772 2772
 	 * @param object $term          Term object.
2773 2773
 	 * @param string $original_slug Slug originally passed to the function for testing.
2774 2774
 	 */
2775
-	return apply_filters( 'wp_unique_term_slug', $slug, $term, $original_slug );
2775
+	return apply_filters('wp_unique_term_slug', $slug, $term, $original_slug);
2776 2776
 }
2777 2777
 
2778 2778
 /**
@@ -2805,56 +2805,56 @@  discard block
 block discarded – undo
2805 2805
  * @param array|string $args     Optional. Array of get_terms() arguments. Default empty array.
2806 2806
  * @return array|WP_Error Returns Term ID and Taxonomy Term ID
2807 2807
  */
2808
-function wp_update_term( $term_id, $taxonomy, $args = array() ) {
2808
+function wp_update_term($term_id, $taxonomy, $args = array()) {
2809 2809
 	global $wpdb;
2810 2810
 
2811
-	if ( ! taxonomy_exists( $taxonomy ) ) {
2812
-		return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) );
2811
+	if ( ! taxonomy_exists($taxonomy)) {
2812
+		return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.'));
2813 2813
 	}
2814 2814
 
2815 2815
 	$term_id = (int) $term_id;
2816 2816
 
2817 2817
 	// First, get all of the original args
2818
-	$term = get_term( $term_id, $taxonomy );
2818
+	$term = get_term($term_id, $taxonomy);
2819 2819
 
2820
-	if ( is_wp_error( $term ) ) {
2820
+	if (is_wp_error($term)) {
2821 2821
 		return $term;
2822 2822
 	}
2823 2823
 
2824
-	if ( ! $term ) {
2825
-		return new WP_Error( 'invalid_term', __( 'Empty Term' ) );
2824
+	if ( ! $term) {
2825
+		return new WP_Error('invalid_term', __('Empty Term'));
2826 2826
 	}
2827 2827
 
2828 2828
 	$term = (array) $term->data;
2829 2829
 
2830 2830
 	// Escape data pulled from DB.
2831
-	$term = wp_slash( $term );
2831
+	$term = wp_slash($term);
2832 2832
 
2833 2833
 	// Merge old and new args with new args overwriting old ones.
2834 2834
 	$args = array_merge($term, $args);
2835 2835
 
2836
-	$defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
2836
+	$defaults = array('alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
2837 2837
 	$args = wp_parse_args($args, $defaults);
2838 2838
 	$args = sanitize_term($args, $taxonomy, 'db');
2839 2839
 	$parsed_args = $args;
2840 2840
 
2841 2841
 	// expected_slashed ($name)
2842
-	$name = wp_unslash( $args['name'] );
2843
-	$description = wp_unslash( $args['description'] );
2842
+	$name = wp_unslash($args['name']);
2843
+	$description = wp_unslash($args['description']);
2844 2844
 
2845 2845
 	$parsed_args['name'] = $name;
2846 2846
 	$parsed_args['description'] = $description;
2847 2847
 
2848
-	if ( '' == trim( $name ) ) {
2849
-		return new WP_Error( 'empty_term_name', __( 'A name is required for this term.' ) );
2848
+	if ('' == trim($name)) {
2849
+		return new WP_Error('empty_term_name', __('A name is required for this term.'));
2850 2850
 	}
2851 2851
 
2852
-	if ( $parsed_args['parent'] > 0 && ! term_exists( (int) $parsed_args['parent'] ) ) {
2853
-		return new WP_Error( 'missing_parent', __( 'Parent term does not exist.' ) );
2852
+	if ($parsed_args['parent'] > 0 && ! term_exists((int) $parsed_args['parent'])) {
2853
+		return new WP_Error('missing_parent', __('Parent term does not exist.'));
2854 2854
 	}
2855 2855
 
2856 2856
 	$empty_slug = false;
2857
-	if ( empty( $args['slug'] ) ) {
2857
+	if (empty($args['slug'])) {
2858 2858
 		$empty_slug = true;
2859 2859
 		$slug = sanitize_title($name);
2860 2860
 	} else {
@@ -2863,22 +2863,22 @@  discard block
 block discarded – undo
2863 2863
 
2864 2864
 	$parsed_args['slug'] = $slug;
2865 2865
 
2866
-	$term_group = isset( $parsed_args['term_group'] ) ? $parsed_args['term_group'] : 0;
2867
-	if ( $args['alias_of'] ) {
2868
-		$alias = get_term_by( 'slug', $args['alias_of'], $taxonomy );
2869
-		if ( ! empty( $alias->term_group ) ) {
2866
+	$term_group = isset($parsed_args['term_group']) ? $parsed_args['term_group'] : 0;
2867
+	if ($args['alias_of']) {
2868
+		$alias = get_term_by('slug', $args['alias_of'], $taxonomy);
2869
+		if ( ! empty($alias->term_group)) {
2870 2870
 			// The alias we want is already in a group, so let's use that one.
2871 2871
 			$term_group = $alias->term_group;
2872
-		} elseif ( ! empty( $alias->term_id ) ) {
2872
+		} elseif ( ! empty($alias->term_id)) {
2873 2873
 			/*
2874 2874
 			 * The alias is not in a group, so we create a new one
2875 2875
 			 * and add the alias to it.
2876 2876
 			 */
2877 2877
 			$term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1;
2878 2878
 
2879
-			wp_update_term( $alias->term_id, $taxonomy, array(
2879
+			wp_update_term($alias->term_id, $taxonomy, array(
2880 2880
 				'term_group' => $term_group,
2881
-			) );
2881
+			));
2882 2882
 		}
2883 2883
 
2884 2884
 		$parsed_args['term_group'] = $term_group;
@@ -2897,24 +2897,24 @@  discard block
 block discarded – undo
2897 2897
 	 * @param array  $parsed_args An array of potentially altered update arguments for the given term.
2898 2898
 	 * @param array  $args        An array of update arguments for the given term.
2899 2899
 	 */
2900
-	$parent = apply_filters( 'wp_update_term_parent', $args['parent'], $term_id, $taxonomy, $parsed_args, $args );
2900
+	$parent = apply_filters('wp_update_term_parent', $args['parent'], $term_id, $taxonomy, $parsed_args, $args);
2901 2901
 
2902 2902
 	// Check for duplicate slug
2903
-	$duplicate = get_term_by( 'slug', $slug, $taxonomy );
2904
-	if ( $duplicate && $duplicate->term_id != $term_id ) {
2903
+	$duplicate = get_term_by('slug', $slug, $taxonomy);
2904
+	if ($duplicate && $duplicate->term_id != $term_id) {
2905 2905
 		// If an empty slug was passed or the parent changed, reset the slug to something unique.
2906 2906
 		// Otherwise, bail.
2907
-		if ( $empty_slug || ( $parent != $term['parent']) )
2907
+		if ($empty_slug || ($parent != $term['parent']))
2908 2908
 			$slug = wp_unique_term_slug($slug, (object) $args);
2909 2909
 		else
2910 2910
 			return new WP_Error('duplicate_term_slug', sprintf(__('The slug &#8220;%s&#8221; is already in use by another term'), $slug));
2911 2911
 	}
2912 2912
 
2913
-	$tt_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT tt.term_taxonomy_id FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.term_id = %d", $taxonomy, $term_id) );
2913
+	$tt_id = (int) $wpdb->get_var($wpdb->prepare("SELECT tt.term_taxonomy_id FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.term_id = %d", $taxonomy, $term_id));
2914 2914
 
2915 2915
 	// Check whether this is a shared term that needs splitting.
2916
-	$_term_id = _split_shared_term( $term_id, $tt_id );
2917
-	if ( ! is_wp_error( $_term_id ) ) {
2916
+	$_term_id = _split_shared_term($term_id, $tt_id);
2917
+	if ( ! is_wp_error($_term_id)) {
2918 2918
 		$term_id = $_term_id;
2919 2919
 	}
2920 2920
 
@@ -2926,11 +2926,11 @@  discard block
 block discarded – undo
2926 2926
 	 * @param int    $term_id  Term ID.
2927 2927
 	 * @param string $taxonomy Taxonomy slug.
2928 2928
 	 */
2929
-	do_action( 'edit_terms', $term_id, $taxonomy );
2930
-	$wpdb->update($wpdb->terms, compact( 'name', 'slug', 'term_group' ), compact( 'term_id' ) );
2931
-	if ( empty($slug) ) {
2929
+	do_action('edit_terms', $term_id, $taxonomy);
2930
+	$wpdb->update($wpdb->terms, compact('name', 'slug', 'term_group'), compact('term_id'));
2931
+	if (empty($slug)) {
2932 2932
 		$slug = sanitize_title($name, $term_id);
2933
-		$wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) );
2933
+		$wpdb->update($wpdb->terms, compact('slug'), compact('term_id'));
2934 2934
 	}
2935 2935
 
2936 2936
 	/**
@@ -2941,7 +2941,7 @@  discard block
 block discarded – undo
2941 2941
 	 * @param int    $term_id  Term ID
2942 2942
 	 * @param string $taxonomy Taxonomy slug.
2943 2943
 	 */
2944
-	do_action( 'edited_terms', $term_id, $taxonomy );
2944
+	do_action('edited_terms', $term_id, $taxonomy);
2945 2945
 
2946 2946
 	/**
2947 2947
 	 * Fires immediate before a term-taxonomy relationship is updated.
@@ -2951,9 +2951,9 @@  discard block
 block discarded – undo
2951 2951
 	 * @param int    $tt_id    Term taxonomy ID.
2952 2952
 	 * @param string $taxonomy Taxonomy slug.
2953 2953
 	 */
2954
-	do_action( 'edit_term_taxonomy', $tt_id, $taxonomy );
2954
+	do_action('edit_term_taxonomy', $tt_id, $taxonomy);
2955 2955
 
2956
-	$wpdb->update( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent' ), array( 'term_taxonomy_id' => $tt_id ) );
2956
+	$wpdb->update($wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent'), array('term_taxonomy_id' => $tt_id));
2957 2957
 
2958 2958
 	/**
2959 2959
 	 * Fires immediately after a term-taxonomy relationship is updated.
@@ -2963,7 +2963,7 @@  discard block
 block discarded – undo
2963 2963
 	 * @param int    $tt_id    Term taxonomy ID.
2964 2964
 	 * @param string $taxonomy Taxonomy slug.
2965 2965
 	 */
2966
-	do_action( 'edited_term_taxonomy', $tt_id, $taxonomy );
2966
+	do_action('edited_term_taxonomy', $tt_id, $taxonomy);
2967 2967
 
2968 2968
 	/**
2969 2969
 	 * Fires after a term has been updated, but before the term cache has been cleaned.
@@ -2974,7 +2974,7 @@  discard block
 block discarded – undo
2974 2974
 	 * @param int    $tt_id    Term taxonomy ID.
2975 2975
 	 * @param string $taxonomy Taxonomy slug.
2976 2976
 	 */
2977
-	do_action( "edit_term", $term_id, $tt_id, $taxonomy );
2977
+	do_action("edit_term", $term_id, $tt_id, $taxonomy);
2978 2978
 
2979 2979
 	/**
2980 2980
 	 * Fires after a term in a specific taxonomy has been updated, but before the term
@@ -2987,10 +2987,10 @@  discard block
 block discarded – undo
2987 2987
 	 * @param int $term_id Term ID.
2988 2988
 	 * @param int $tt_id   Term taxonomy ID.
2989 2989
 	 */
2990
-	do_action( "edit_$taxonomy", $term_id, $tt_id );
2990
+	do_action("edit_$taxonomy", $term_id, $tt_id);
2991 2991
 
2992 2992
 	/** This filter is documented in wp-includes/taxonomy.php */
2993
-	$term_id = apply_filters( 'term_id_filter', $term_id, $tt_id );
2993
+	$term_id = apply_filters('term_id_filter', $term_id, $tt_id);
2994 2994
 
2995 2995
 	clean_term_cache($term_id, $taxonomy);
2996 2996
 
@@ -3003,7 +3003,7 @@  discard block
 block discarded – undo
3003 3003
 	 * @param int    $tt_id    Term taxonomy ID.
3004 3004
 	 * @param string $taxonomy Taxonomy slug.
3005 3005
 	 */
3006
-	do_action( "edited_term", $term_id, $tt_id, $taxonomy );
3006
+	do_action("edited_term", $term_id, $tt_id, $taxonomy);
3007 3007
 
3008 3008
 	/**
3009 3009
 	 * Fires after a term for a specific taxonomy has been updated, and the term
@@ -3016,7 +3016,7 @@  discard block
 block discarded – undo
3016 3016
 	 * @param int $term_id Term ID.
3017 3017
 	 * @param int $tt_id   Term taxonomy ID.
3018 3018
 	 */
3019
-	do_action( "edited_$taxonomy", $term_id, $tt_id );
3019
+	do_action("edited_$taxonomy", $term_id, $tt_id);
3020 3020
 
3021 3021
 	return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
3022 3022
 }
@@ -3031,14 +3031,14 @@  discard block
 block discarded – undo
3031 3031
  * @param bool $defer Optional. Enable if true, disable if false.
3032 3032
  * @return bool Whether term counting is enabled or disabled.
3033 3033
  */
3034
-function wp_defer_term_counting($defer=null) {
3034
+function wp_defer_term_counting($defer = null) {
3035 3035
 	static $_defer = false;
3036 3036
 
3037
-	if ( is_bool($defer) ) {
3037
+	if (is_bool($defer)) {
3038 3038
 		$_defer = $defer;
3039 3039
 		// flush any deferred counts
3040
-		if ( !$defer )
3041
-			wp_update_term_count( null, null, true );
3040
+		if ( ! $defer)
3041
+			wp_update_term_count(null, null, true);
3042 3042
 	}
3043 3043
 
3044 3044
 	return $_defer;
@@ -3062,30 +3062,30 @@  discard block
 block discarded – undo
3062 3062
  * @param bool      $do_deferred Whether to flush the deferred term counts too. Default false.
3063 3063
  * @return bool If no terms will return false, and if successful will return true.
3064 3064
  */
3065
-function wp_update_term_count( $terms, $taxonomy, $do_deferred = false ) {
3065
+function wp_update_term_count($terms, $taxonomy, $do_deferred = false) {
3066 3066
 	static $_deferred = array();
3067 3067
 
3068
-	if ( $do_deferred ) {
3069
-		foreach ( (array) array_keys($_deferred) as $tax ) {
3070
-			wp_update_term_count_now( $_deferred[$tax], $tax );
3071
-			unset( $_deferred[$tax] );
3068
+	if ($do_deferred) {
3069
+		foreach ((array) array_keys($_deferred) as $tax) {
3070
+			wp_update_term_count_now($_deferred[$tax], $tax);
3071
+			unset($_deferred[$tax]);
3072 3072
 		}
3073 3073
 	}
3074 3074
 
3075
-	if ( empty($terms) )
3075
+	if (empty($terms))
3076 3076
 		return false;
3077 3077
 
3078
-	if ( !is_array($terms) )
3078
+	if ( ! is_array($terms))
3079 3079
 		$terms = array($terms);
3080 3080
 
3081
-	if ( wp_defer_term_counting() ) {
3082
-		if ( !isset($_deferred[$taxonomy]) )
3081
+	if (wp_defer_term_counting()) {
3082
+		if ( ! isset($_deferred[$taxonomy]))
3083 3083
 			$_deferred[$taxonomy] = array();
3084
-		$_deferred[$taxonomy] = array_unique( array_merge($_deferred[$taxonomy], $terms) );
3084
+		$_deferred[$taxonomy] = array_unique(array_merge($_deferred[$taxonomy], $terms));
3085 3085
 		return true;
3086 3086
 	}
3087 3087
 
3088
-	return wp_update_term_count_now( $terms, $taxonomy );
3088
+	return wp_update_term_count_now($terms, $taxonomy);
3089 3089
 }
3090 3090
 
3091 3091
 /**
@@ -3097,25 +3097,25 @@  discard block
 block discarded – undo
3097 3097
  * @param string $taxonomy The context of the term.
3098 3098
  * @return true Always true when complete.
3099 3099
  */
3100
-function wp_update_term_count_now( $terms, $taxonomy ) {
3100
+function wp_update_term_count_now($terms, $taxonomy) {
3101 3101
 	$terms = array_map('intval', $terms);
3102 3102
 
3103 3103
 	$taxonomy = get_taxonomy($taxonomy);
3104
-	if ( !empty($taxonomy->update_count_callback) ) {
3104
+	if ( ! empty($taxonomy->update_count_callback)) {
3105 3105
 		call_user_func($taxonomy->update_count_callback, $terms, $taxonomy);
3106 3106
 	} else {
3107 3107
 		$object_types = (array) $taxonomy->object_type;
3108
-		foreach ( $object_types as &$object_type ) {
3109
-			if ( 0 === strpos( $object_type, 'attachment:' ) )
3110
-				list( $object_type ) = explode( ':', $object_type );
3108
+		foreach ($object_types as &$object_type) {
3109
+			if (0 === strpos($object_type, 'attachment:'))
3110
+				list($object_type) = explode(':', $object_type);
3111 3111
 		}
3112 3112
 
3113
-		if ( $object_types == array_filter( $object_types, 'post_type_exists' ) ) {
3113
+		if ($object_types == array_filter($object_types, 'post_type_exists')) {
3114 3114
 			// Only post types are attached to this taxonomy
3115
-			_update_post_term_count( $terms, $taxonomy );
3115
+			_update_post_term_count($terms, $taxonomy);
3116 3116
 		} else {
3117 3117
 			// Default count updater
3118
-			_update_generic_term_count( $terms, $taxonomy );
3118
+			_update_generic_term_count($terms, $taxonomy);
3119 3119
 		}
3120 3120
 	}
3121 3121
 
@@ -3147,17 +3147,17 @@  discard block
 block discarded – undo
3147 3147
 function clean_object_term_cache($object_ids, $object_type) {
3148 3148
 	global $_wp_suspend_cache_invalidation;
3149 3149
 
3150
-	if ( ! empty( $_wp_suspend_cache_invalidation ) ) {
3150
+	if ( ! empty($_wp_suspend_cache_invalidation)) {
3151 3151
 		return;
3152 3152
 	}
3153 3153
 
3154
-	if ( !is_array($object_ids) )
3154
+	if ( ! is_array($object_ids))
3155 3155
 		$object_ids = array($object_ids);
3156 3156
 
3157
-	$taxonomies = get_object_taxonomies( $object_type );
3157
+	$taxonomies = get_object_taxonomies($object_type);
3158 3158
 
3159
-	foreach ( $object_ids as $id ) {
3160
-		foreach ( $taxonomies as $taxonomy ) {
3159
+	foreach ($object_ids as $id) {
3160
+		foreach ($taxonomies as $taxonomy) {
3161 3161
 			wp_cache_delete($id, "{$taxonomy}_relationships");
3162 3162
 		}
3163 3163
 	}
@@ -3170,7 +3170,7 @@  discard block
 block discarded – undo
3170 3170
 	 * @param array  $object_ids An array of object IDs.
3171 3171
 	 * @param string $objet_type Object type.
3172 3172
 	 */
3173
-	do_action( 'clean_object_term_cache', $object_ids, $object_type );
3173
+	do_action('clean_object_term_cache', $object_ids, $object_type);
3174 3174
 }
3175 3175
 
3176 3176
 /**
@@ -3190,37 +3190,37 @@  discard block
 block discarded – undo
3190 3190
 function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true) {
3191 3191
 	global $wpdb, $_wp_suspend_cache_invalidation;
3192 3192
 
3193
-	if ( ! empty( $_wp_suspend_cache_invalidation ) ) {
3193
+	if ( ! empty($_wp_suspend_cache_invalidation)) {
3194 3194
 		return;
3195 3195
 	}
3196 3196
 
3197
-	if ( !is_array($ids) )
3197
+	if ( ! is_array($ids))
3198 3198
 		$ids = array($ids);
3199 3199
 
3200 3200
 	$taxonomies = array();
3201 3201
 	// If no taxonomy, assume tt_ids.
3202
-	if ( empty($taxonomy) ) {
3202
+	if (empty($taxonomy)) {
3203 3203
 		$tt_ids = array_map('intval', $ids);
3204 3204
 		$tt_ids = implode(', ', $tt_ids);
3205 3205
 		$terms = $wpdb->get_results("SELECT term_id, taxonomy FROM $wpdb->term_taxonomy WHERE term_taxonomy_id IN ($tt_ids)");
3206 3206
 		$ids = array();
3207
-		foreach ( (array) $terms as $term ) {
3207
+		foreach ((array) $terms as $term) {
3208 3208
 			$taxonomies[] = $term->taxonomy;
3209 3209
 			$ids[] = $term->term_id;
3210
-			wp_cache_delete( $term->term_id, 'terms' );
3210
+			wp_cache_delete($term->term_id, 'terms');
3211 3211
 		}
3212 3212
 		$taxonomies = array_unique($taxonomies);
3213 3213
 	} else {
3214 3214
 		$taxonomies = array($taxonomy);
3215
-		foreach ( $taxonomies as $taxonomy ) {
3216
-			foreach ( $ids as $id ) {
3217
-				wp_cache_delete( $id, 'terms' );
3215
+		foreach ($taxonomies as $taxonomy) {
3216
+			foreach ($ids as $id) {
3217
+				wp_cache_delete($id, 'terms');
3218 3218
 			}
3219 3219
 		}
3220 3220
 	}
3221 3221
 
3222
-	foreach ( $taxonomies as $taxonomy ) {
3223
-		if ( $clean_taxonomy ) {
3222
+	foreach ($taxonomies as $taxonomy) {
3223
+		if ($clean_taxonomy) {
3224 3224
 			wp_cache_delete('all_ids', $taxonomy);
3225 3225
 			wp_cache_delete('get', $taxonomy);
3226 3226
 			delete_option("{$taxonomy}_children");
@@ -3238,10 +3238,10 @@  discard block
 block discarded – undo
3238 3238
 		 * @param string $taxonomy       Taxonomy slug.
3239 3239
 		 * @param bool   $clean_taxonomy Whether or not to clean taxonomy-wide caches
3240 3240
 		 */
3241
-		do_action( 'clean_term_cache', $ids, $taxonomy, $clean_taxonomy );
3241
+		do_action('clean_term_cache', $ids, $taxonomy, $clean_taxonomy);
3242 3242
 	}
3243 3243
 
3244
-	wp_cache_set( 'last_changed', microtime(), 'terms' );
3244
+	wp_cache_set('last_changed', microtime(), 'terms');
3245 3245
 }
3246 3246
 
3247 3247
 /**
@@ -3257,33 +3257,33 @@  discard block
 block discarded – undo
3257 3257
  * @param string $taxonomy Taxonomy name.
3258 3258
  * @return bool|array Array of `WP_Term` objects, if cached False if cache is empty for `$taxonomy` and `$id`.
3259 3259
  */
3260
-function get_object_term_cache( $id, $taxonomy ) {
3261
-	$_term_ids = wp_cache_get( $id, "{$taxonomy}_relationships" );
3260
+function get_object_term_cache($id, $taxonomy) {
3261
+	$_term_ids = wp_cache_get($id, "{$taxonomy}_relationships");
3262 3262
 
3263 3263
 	// We leave the priming of relationship caches to upstream functions.
3264
-	if ( false === $_term_ids ) {
3264
+	if (false === $_term_ids) {
3265 3265
 		return false;
3266 3266
 	}
3267 3267
 
3268 3268
 	// Backward compatibility for if a plugin is putting objects into the cache, rather than IDs.
3269 3269
 	$term_ids = array();
3270
-	foreach ( $_term_ids as $term_id ) {
3271
-		if ( is_numeric( $term_id ) ) {
3272
-			$term_ids[] = intval( $term_id );
3273
-		} elseif ( isset( $term_id->term_id ) ) {
3274
-			$term_ids[] = intval( $term_id->term_id );
3270
+	foreach ($_term_ids as $term_id) {
3271
+		if (is_numeric($term_id)) {
3272
+			$term_ids[] = intval($term_id);
3273
+		} elseif (isset($term_id->term_id)) {
3274
+			$term_ids[] = intval($term_id->term_id);
3275 3275
 		}
3276 3276
 	}
3277 3277
 
3278 3278
 	// Fill the term objects.
3279
-	_prime_term_caches( $term_ids );
3279
+	_prime_term_caches($term_ids);
3280 3280
 
3281 3281
 	$terms = array();
3282
-	foreach ( $term_ids as $term_id ) {
3283
-		$terms[] = wp_cache_get( $term_id, 'terms' );
3282
+	foreach ($term_ids as $term_id) {
3283
+		$terms[] = wp_cache_get($term_id, 'terms');
3284 3284
 	}
3285 3285
 
3286
-	return array_map( 'get_term', $terms );
3286
+	return array_map('get_term', $terms);
3287 3287
 }
3288 3288
 
3289 3289
 /**
@@ -3303,10 +3303,10 @@  discard block
 block discarded – undo
3303 3303
  * @return void|false False if all of the terms in `$object_ids` are already cached.
3304 3304
  */
3305 3305
 function update_object_term_cache($object_ids, $object_type) {
3306
-	if ( empty($object_ids) )
3306
+	if (empty($object_ids))
3307 3307
 		return;
3308 3308
 
3309
-	if ( !is_array($object_ids) )
3309
+	if ( ! is_array($object_ids))
3310 3310
 		$object_ids = explode(',', $object_ids);
3311 3311
 
3312 3312
 	$object_ids = array_map('intval', $object_ids);
@@ -3314,42 +3314,42 @@  discard block
 block discarded – undo
3314 3314
 	$taxonomies = get_object_taxonomies($object_type);
3315 3315
 
3316 3316
 	$ids = array();
3317
-	foreach ( (array) $object_ids as $id ) {
3318
-		foreach ( $taxonomies as $taxonomy ) {
3319
-			if ( false === wp_cache_get($id, "{$taxonomy}_relationships") ) {
3317
+	foreach ((array) $object_ids as $id) {
3318
+		foreach ($taxonomies as $taxonomy) {
3319
+			if (false === wp_cache_get($id, "{$taxonomy}_relationships")) {
3320 3320
 				$ids[] = $id;
3321 3321
 				break;
3322 3322
 			}
3323 3323
 		}
3324 3324
 	}
3325 3325
 
3326
-	if ( empty( $ids ) )
3326
+	if (empty($ids))
3327 3327
 		return false;
3328 3328
 
3329
-	$terms = wp_get_object_terms( $ids, $taxonomies, array(
3329
+	$terms = wp_get_object_terms($ids, $taxonomies, array(
3330 3330
 		'fields' => 'all_with_object_id',
3331 3331
 		'orderby' => 'name',
3332 3332
 		'update_term_meta_cache' => false,
3333
-	) );
3333
+	));
3334 3334
 
3335 3335
 	$object_terms = array();
3336
-	foreach ( (array) $terms as $term ) {
3337
-		$object_terms[ $term->object_id ][ $term->taxonomy ][] = $term->term_id;
3336
+	foreach ((array) $terms as $term) {
3337
+		$object_terms[$term->object_id][$term->taxonomy][] = $term->term_id;
3338 3338
 	}
3339 3339
 
3340
-	foreach ( $ids as $id ) {
3341
-		foreach ( $taxonomies as $taxonomy ) {
3342
-			if ( ! isset($object_terms[$id][$taxonomy]) ) {
3343
-				if ( !isset($object_terms[$id]) )
3340
+	foreach ($ids as $id) {
3341
+		foreach ($taxonomies as $taxonomy) {
3342
+			if ( ! isset($object_terms[$id][$taxonomy])) {
3343
+				if ( ! isset($object_terms[$id]))
3344 3344
 					$object_terms[$id] = array();
3345 3345
 				$object_terms[$id][$taxonomy] = array();
3346 3346
 			}
3347 3347
 		}
3348 3348
 	}
3349 3349
 
3350
-	foreach ( $object_terms as $id => $value ) {
3351
-		foreach ( $value as $taxonomy => $terms ) {
3352
-			wp_cache_add( $id, $terms, "{$taxonomy}_relationships" );
3350
+	foreach ($object_terms as $id => $value) {
3351
+		foreach ($value as $taxonomy => $terms) {
3352
+			wp_cache_add($id, $terms, "{$taxonomy}_relationships");
3353 3353
 		}
3354 3354
 	}
3355 3355
 }
@@ -3362,15 +3362,15 @@  discard block
 block discarded – undo
3362 3362
  * @param array  $terms    List of term objects to change.
3363 3363
  * @param string $taxonomy Optional. Update Term to this taxonomy in cache. Default empty.
3364 3364
  */
3365
-function update_term_cache( $terms, $taxonomy = '' ) {
3366
-	foreach ( (array) $terms as $term ) {
3365
+function update_term_cache($terms, $taxonomy = '') {
3366
+	foreach ((array) $terms as $term) {
3367 3367
 		// Create a copy in case the array was passed by reference.
3368 3368
 		$_term = clone $term;
3369 3369
 
3370 3370
 		// Object ID should not be cached.
3371
-		unset( $_term->object_id );
3371
+		unset($_term->object_id);
3372 3372
 
3373
-		wp_cache_add( $term->term_id, $_term, 'terms' );
3373
+		wp_cache_add($term->term_id, $_term, 'terms');
3374 3374
 	}
3375 3375
 }
3376 3376
 
@@ -3387,17 +3387,17 @@  discard block
 block discarded – undo
3387 3387
  * @param string $taxonomy Taxonomy name.
3388 3388
  * @return array Empty if $taxonomy isn't hierarchical or returns children as Term IDs.
3389 3389
  */
3390
-function _get_term_hierarchy( $taxonomy ) {
3391
-	if ( !is_taxonomy_hierarchical($taxonomy) )
3390
+function _get_term_hierarchy($taxonomy) {
3391
+	if ( ! is_taxonomy_hierarchical($taxonomy))
3392 3392
 		return array();
3393 3393
 	$children = get_option("{$taxonomy}_children");
3394 3394
 
3395
-	if ( is_array($children) )
3395
+	if (is_array($children))
3396 3396
 		return $children;
3397 3397
 	$children = array();
3398 3398
 	$terms = get_terms($taxonomy, array('get' => 'all', 'orderby' => 'id', 'fields' => 'id=>parent'));
3399
-	foreach ( $terms as $term_id => $parent ) {
3400
-		if ( $parent > 0 )
3399
+	foreach ($terms as $term_id => $parent) {
3400
+		if ($parent > 0)
3401 3401
 			$children[$parent][] = $term_id;
3402 3402
 	}
3403 3403
 	update_option("{$taxonomy}_children", $children);
@@ -3424,48 +3424,48 @@  discard block
 block discarded – undo
3424 3424
  *                          with 1 as value. Default empty array.
3425 3425
  * @return array|WP_Error The subset of $terms that are descendants of $term_id.
3426 3426
  */
3427
-function _get_term_children( $term_id, $terms, $taxonomy, &$ancestors = array() ) {
3427
+function _get_term_children($term_id, $terms, $taxonomy, &$ancestors = array()) {
3428 3428
 	$empty_array = array();
3429
-	if ( empty($terms) )
3429
+	if (empty($terms))
3430 3430
 		return $empty_array;
3431 3431
 
3432 3432
 	$term_list = array();
3433 3433
 	$has_children = _get_term_hierarchy($taxonomy);
3434 3434
 
3435
-	if  ( ( 0 != $term_id ) && ! isset($has_children[$term_id]) )
3435
+	if ((0 != $term_id) && ! isset($has_children[$term_id]))
3436 3436
 		return $empty_array;
3437 3437
 
3438 3438
 	// Include the term itself in the ancestors array, so we can properly detect when a loop has occurred.
3439
-	if ( empty( $ancestors ) ) {
3440
-		$ancestors[ $term_id ] = 1;
3439
+	if (empty($ancestors)) {
3440
+		$ancestors[$term_id] = 1;
3441 3441
 	}
3442 3442
 
3443
-	foreach ( (array) $terms as $term ) {
3443
+	foreach ((array) $terms as $term) {
3444 3444
 		$use_id = false;
3445
-		if ( !is_object($term) ) {
3445
+		if ( ! is_object($term)) {
3446 3446
 			$term = get_term($term, $taxonomy);
3447
-			if ( is_wp_error( $term ) )
3447
+			if (is_wp_error($term))
3448 3448
 				return $term;
3449 3449
 			$use_id = true;
3450 3450
 		}
3451 3451
 
3452 3452
 		// Don't recurse if we've already identified the term as a child - this indicates a loop.
3453
-		if ( isset( $ancestors[ $term->term_id ] ) ) {
3453
+		if (isset($ancestors[$term->term_id])) {
3454 3454
 			continue;
3455 3455
 		}
3456 3456
 
3457
-		if ( $term->parent == $term_id ) {
3458
-			if ( $use_id )
3457
+		if ($term->parent == $term_id) {
3458
+			if ($use_id)
3459 3459
 				$term_list[] = $term->term_id;
3460 3460
 			else
3461 3461
 				$term_list[] = $term;
3462 3462
 
3463
-			if ( !isset($has_children[$term->term_id]) )
3463
+			if ( ! isset($has_children[$term->term_id]))
3464 3464
 				continue;
3465 3465
 
3466
-			$ancestors[ $term->term_id ] = 1;
3466
+			$ancestors[$term->term_id] = 1;
3467 3467
 
3468
-			if ( $children = _get_term_children( $term->term_id, $terms, $taxonomy, $ancestors) )
3468
+			if ($children = _get_term_children($term->term_id, $terms, $taxonomy, $ancestors))
3469 3469
 				$term_list = array_merge($term_list, $children);
3470 3470
 		}
3471 3471
 	}
@@ -3487,23 +3487,23 @@  discard block
 block discarded – undo
3487 3487
  * @param array  $terms    List of term objects, passed by reference.
3488 3488
  * @param string $taxonomy Term context.
3489 3489
  */
3490
-function _pad_term_counts( &$terms, $taxonomy ) {
3490
+function _pad_term_counts(&$terms, $taxonomy) {
3491 3491
 	global $wpdb;
3492 3492
 
3493 3493
 	// This function only works for hierarchical taxonomies like post categories.
3494
-	if ( !is_taxonomy_hierarchical( $taxonomy ) )
3494
+	if ( ! is_taxonomy_hierarchical($taxonomy))
3495 3495
 		return;
3496 3496
 
3497 3497
 	$term_hier = _get_term_hierarchy($taxonomy);
3498 3498
 
3499
-	if ( empty($term_hier) )
3499
+	if (empty($term_hier))
3500 3500
 		return;
3501 3501
 
3502 3502
 	$term_items = array();
3503 3503
 	$terms_by_id = array();
3504 3504
 	$term_ids = array();
3505 3505
 
3506
-	foreach ( (array) $terms as $key => $term ) {
3506
+	foreach ((array) $terms as $key => $term) {
3507 3507
 		$terms_by_id[$term->term_id] = & $terms[$key];
3508 3508
 		$term_ids[$term->term_taxonomy_id] = $term->term_id;
3509 3509
 	}
@@ -3511,33 +3511,33 @@  discard block
 block discarded – undo
3511 3511
 	// Get the object and term ids and stick them in a lookup table.
3512 3512
 	$tax_obj = get_taxonomy($taxonomy);
3513 3513
 	$object_types = esc_sql($tax_obj->object_type);
3514
-	$results = $wpdb->get_results("SELECT object_id, term_taxonomy_id FROM $wpdb->term_relationships INNER JOIN $wpdb->posts ON object_id = ID WHERE term_taxonomy_id IN (" . implode(',', array_keys($term_ids)) . ") AND post_type IN ('" . implode("', '", $object_types) . "') AND post_status = 'publish'");
3515
-	foreach ( $results as $row ) {
3514
+	$results = $wpdb->get_results("SELECT object_id, term_taxonomy_id FROM $wpdb->term_relationships INNER JOIN $wpdb->posts ON object_id = ID WHERE term_taxonomy_id IN (".implode(',', array_keys($term_ids)).") AND post_type IN ('".implode("', '", $object_types)."') AND post_status = 'publish'");
3515
+	foreach ($results as $row) {
3516 3516
 		$id = $term_ids[$row->term_taxonomy_id];
3517 3517
 		$term_items[$id][$row->object_id] = isset($term_items[$id][$row->object_id]) ? ++$term_items[$id][$row->object_id] : 1;
3518 3518
 	}
3519 3519
 
3520 3520
 	// Touch every ancestor's lookup row for each post in each term.
3521
-	foreach ( $term_ids as $term_id ) {
3521
+	foreach ($term_ids as $term_id) {
3522 3522
 		$child = $term_id;
3523 3523
 		$ancestors = array();
3524
-		while ( !empty( $terms_by_id[$child] ) && $parent = $terms_by_id[$child]->parent ) {
3524
+		while ( ! empty($terms_by_id[$child]) && $parent = $terms_by_id[$child]->parent) {
3525 3525
 			$ancestors[] = $child;
3526
-			if ( !empty( $term_items[$term_id] ) )
3527
-				foreach ( $term_items[$term_id] as $item_id => $touches ) {
3528
-					$term_items[$parent][$item_id] = isset($term_items[$parent][$item_id]) ? ++$term_items[$parent][$item_id]: 1;
3526
+			if ( ! empty($term_items[$term_id]))
3527
+				foreach ($term_items[$term_id] as $item_id => $touches) {
3528
+					$term_items[$parent][$item_id] = isset($term_items[$parent][$item_id]) ? ++$term_items[$parent][$item_id] : 1;
3529 3529
 				}
3530 3530
 			$child = $parent;
3531 3531
 
3532
-			if ( in_array( $parent, $ancestors ) ) {
3532
+			if (in_array($parent, $ancestors)) {
3533 3533
 				break;
3534 3534
 			}
3535 3535
 		}
3536 3536
 	}
3537 3537
 
3538 3538
 	// Transfer the touched cells.
3539
-	foreach ( (array) $term_items as $id => $items )
3540
-		if ( isset($terms_by_id[$id]) )
3539
+	foreach ((array) $term_items as $id => $items)
3540
+		if (isset($terms_by_id[$id]))
3541 3541
 			$terms_by_id[$id]->count = count($items);
3542 3542
 }
3543 3543
 
@@ -3552,17 +3552,17 @@  discard block
 block discarded – undo
3552 3552
  * @param array $term_ids          Array of term IDs.
3553 3553
  * @param bool  $update_meta_cache Optional. Whether to update the meta cache. Default true.
3554 3554
  */
3555
-function _prime_term_caches( $term_ids, $update_meta_cache = true ) {
3555
+function _prime_term_caches($term_ids, $update_meta_cache = true) {
3556 3556
 	global $wpdb;
3557 3557
 
3558
-	$non_cached_ids = _get_non_cached_ids( $term_ids, 'terms' );
3559
-	if ( ! empty( $non_cached_ids ) ) {
3560
-		$fresh_terms = $wpdb->get_results( sprintf( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE t.term_id IN (%s)", join( ",", array_map( 'intval', $non_cached_ids ) ) ) );
3558
+	$non_cached_ids = _get_non_cached_ids($term_ids, 'terms');
3559
+	if ( ! empty($non_cached_ids)) {
3560
+		$fresh_terms = $wpdb->get_results(sprintf("SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE t.term_id IN (%s)", join(",", array_map('intval', $non_cached_ids))));
3561 3561
 
3562
-		update_term_cache( $fresh_terms, $update_meta_cache );
3562
+		update_term_cache($fresh_terms, $update_meta_cache);
3563 3563
 
3564
-		if ( $update_meta_cache ) {
3565
-			update_termmeta_cache( $non_cached_ids );
3564
+		if ($update_meta_cache) {
3565
+			update_termmeta_cache($non_cached_ids);
3566 3566
 		}
3567 3567
 	}
3568 3568
 }
@@ -3585,40 +3585,40 @@  discard block
 block discarded – undo
3585 3585
  * @param array  $terms    List of Term taxonomy IDs.
3586 3586
  * @param object $taxonomy Current taxonomy object of terms.
3587 3587
  */
3588
-function _update_post_term_count( $terms, $taxonomy ) {
3588
+function _update_post_term_count($terms, $taxonomy) {
3589 3589
 	global $wpdb;
3590 3590
 
3591 3591
 	$object_types = (array) $taxonomy->object_type;
3592 3592
 
3593
-	foreach ( $object_types as &$object_type )
3594
-		list( $object_type ) = explode( ':', $object_type );
3593
+	foreach ($object_types as &$object_type)
3594
+		list($object_type) = explode(':', $object_type);
3595 3595
 
3596
-	$object_types = array_unique( $object_types );
3596
+	$object_types = array_unique($object_types);
3597 3597
 
3598
-	if ( false !== ( $check_attachments = array_search( 'attachment', $object_types ) ) ) {
3599
-		unset( $object_types[ $check_attachments ] );
3598
+	if (false !== ($check_attachments = array_search('attachment', $object_types))) {
3599
+		unset($object_types[$check_attachments]);
3600 3600
 		$check_attachments = true;
3601 3601
 	}
3602 3602
 
3603
-	if ( $object_types )
3604
-		$object_types = esc_sql( array_filter( $object_types, 'post_type_exists' ) );
3603
+	if ($object_types)
3604
+		$object_types = esc_sql(array_filter($object_types, 'post_type_exists'));
3605 3605
 
3606
-	foreach ( (array) $terms as $term ) {
3606
+	foreach ((array) $terms as $term) {
3607 3607
 		$count = 0;
3608 3608
 
3609 3609
 		// Attachments can be 'inherit' status, we need to base count off the parent's status if so.
3610
-		if ( $check_attachments )
3611
-			$count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts p1 WHERE p1.ID = $wpdb->term_relationships.object_id AND ( post_status = 'publish' OR ( post_status = 'inherit' AND post_parent > 0 AND ( SELECT post_status FROM $wpdb->posts WHERE ID = p1.post_parent ) = 'publish' ) ) AND post_type = 'attachment' AND term_taxonomy_id = %d", $term ) );
3610
+		if ($check_attachments)
3611
+			$count += (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts p1 WHERE p1.ID = $wpdb->term_relationships.object_id AND ( post_status = 'publish' OR ( post_status = 'inherit' AND post_parent > 0 AND ( SELECT post_status FROM $wpdb->posts WHERE ID = p1.post_parent ) = 'publish' ) ) AND post_type = 'attachment' AND term_taxonomy_id = %d", $term));
3612 3612
 
3613
-		if ( $object_types )
3614
-			$count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type IN ('" . implode("', '", $object_types ) . "') AND term_taxonomy_id = %d", $term ) );
3613
+		if ($object_types)
3614
+			$count += (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type IN ('".implode("', '", $object_types)."') AND term_taxonomy_id = %d", $term));
3615 3615
 
3616 3616
 		/** This action is documented in wp-includes/taxonomy.php */
3617
-		do_action( 'edit_term_taxonomy', $term, $taxonomy->name );
3618
-		$wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
3617
+		do_action('edit_term_taxonomy', $term, $taxonomy->name);
3618
+		$wpdb->update($wpdb->term_taxonomy, compact('count'), array('term_taxonomy_id' => $term));
3619 3619
 
3620 3620
 		/** This action is documented in wp-includes/taxonomy.php */
3621
-		do_action( 'edited_term_taxonomy', $term, $taxonomy->name );
3621
+		do_action('edited_term_taxonomy', $term, $taxonomy->name);
3622 3622
 	}
3623 3623
 }
3624 3624
 
@@ -3634,18 +3634,18 @@  discard block
 block discarded – undo
3634 3634
  * @param array  $terms    List of term taxonomy IDs.
3635 3635
  * @param object $taxonomy Current taxonomy object of terms.
3636 3636
  */
3637
-function _update_generic_term_count( $terms, $taxonomy ) {
3637
+function _update_generic_term_count($terms, $taxonomy) {
3638 3638
 	global $wpdb;
3639 3639
 
3640
-	foreach ( (array) $terms as $term ) {
3641
-		$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term ) );
3640
+	foreach ((array) $terms as $term) {
3641
+		$count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term));
3642 3642
 
3643 3643
 		/** This action is documented in wp-includes/taxonomy.php */
3644
-		do_action( 'edit_term_taxonomy', $term, $taxonomy->name );
3645
-		$wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
3644
+		do_action('edit_term_taxonomy', $term, $taxonomy->name);
3645
+		$wpdb->update($wpdb->term_taxonomy, compact('count'), array('term_taxonomy_id' => $term));
3646 3646
 
3647 3647
 		/** This action is documented in wp-includes/taxonomy.php */
3648
-		do_action( 'edited_term_taxonomy', $term, $taxonomy->name );
3648
+		do_action('edited_term_taxonomy', $term, $taxonomy->name);
3649 3649
 	}
3650 3650
 }
3651 3651
 
@@ -3672,23 +3672,23 @@  discard block
 block discarded – undo
3672 3672
  *                      database schema), `$term_id` is returned. When the term is successfully split, the
3673 3673
  *                      new term_id is returned. A WP_Error is returned for miscellaneous errors.
3674 3674
  */
3675
-function _split_shared_term( $term_id, $term_taxonomy_id, $record = true ) {
3675
+function _split_shared_term($term_id, $term_taxonomy_id, $record = true) {
3676 3676
 	global $wpdb;
3677 3677
 
3678
-	if ( is_object( $term_id ) ) {
3678
+	if (is_object($term_id)) {
3679 3679
 		$shared_term = $term_id;
3680
-		$term_id = intval( $shared_term->term_id );
3680
+		$term_id = intval($shared_term->term_id);
3681 3681
 	}
3682 3682
 
3683
-	if ( is_object( $term_taxonomy_id ) ) {
3683
+	if (is_object($term_taxonomy_id)) {
3684 3684
 		$term_taxonomy = $term_taxonomy_id;
3685
-		$term_taxonomy_id = intval( $term_taxonomy->term_taxonomy_id );
3685
+		$term_taxonomy_id = intval($term_taxonomy->term_taxonomy_id);
3686 3686
 	}
3687 3687
 
3688 3688
 	// If there are no shared term_taxonomy rows, there's nothing to do here.
3689
-	$shared_tt_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy tt WHERE tt.term_id = %d AND tt.term_taxonomy_id != %d", $term_id, $term_taxonomy_id ) );
3689
+	$shared_tt_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_taxonomy tt WHERE tt.term_id = %d AND tt.term_taxonomy_id != %d", $term_id, $term_taxonomy_id));
3690 3690
 
3691
-	if ( ! $shared_tt_count ) {
3691
+	if ( ! $shared_tt_count) {
3692 3692
 		return $term_id;
3693 3693
 	}
3694 3694
 
@@ -3696,14 +3696,14 @@  discard block
 block discarded – undo
3696 3696
 	 * Verify that the term_taxonomy_id passed to the function is actually associated with the term_id.
3697 3697
 	 * If there's a mismatch, it may mean that the term is already split. Return the actual term_id from the db.
3698 3698
 	 */
3699
-	$check_term_id = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %d", $term_taxonomy_id ) );
3700
-	if ( $check_term_id != $term_id ) {
3699
+	$check_term_id = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %d", $term_taxonomy_id));
3700
+	if ($check_term_id != $term_id) {
3701 3701
 		return $check_term_id;
3702 3702
 	}
3703 3703
 
3704 3704
 	// Pull up data about the currently shared slug, which we'll use to populate the new one.
3705
-	if ( empty( $shared_term ) ) {
3706
-		$shared_term = $wpdb->get_row( $wpdb->prepare( "SELECT t.* FROM $wpdb->terms t WHERE t.term_id = %d", $term_id ) );
3705
+	if (empty($shared_term)) {
3706
+		$shared_term = $wpdb->get_row($wpdb->prepare("SELECT t.* FROM $wpdb->terms t WHERE t.term_id = %d", $term_id));
3707 3707
 	}
3708 3708
 
3709 3709
 	$new_term_data = array(
@@ -3712,54 +3712,54 @@  discard block
 block discarded – undo
3712 3712
 		'term_group' => $shared_term->term_group,
3713 3713
 	);
3714 3714
 
3715
-	if ( false === $wpdb->insert( $wpdb->terms, $new_term_data ) ) {
3716
-		return new WP_Error( 'db_insert_error', __( 'Could not split shared term.' ), $wpdb->last_error );
3715
+	if (false === $wpdb->insert($wpdb->terms, $new_term_data)) {
3716
+		return new WP_Error('db_insert_error', __('Could not split shared term.'), $wpdb->last_error);
3717 3717
 	}
3718 3718
 
3719 3719
 	$new_term_id = (int) $wpdb->insert_id;
3720 3720
 
3721 3721
 	// Update the existing term_taxonomy to point to the newly created term.
3722
-	$wpdb->update( $wpdb->term_taxonomy,
3723
-		array( 'term_id' => $new_term_id ),
3724
-		array( 'term_taxonomy_id' => $term_taxonomy_id )
3722
+	$wpdb->update($wpdb->term_taxonomy,
3723
+		array('term_id' => $new_term_id),
3724
+		array('term_taxonomy_id' => $term_taxonomy_id)
3725 3725
 	);
3726 3726
 
3727 3727
 	// Reassign child terms to the new parent.
3728
-	if ( empty( $term_taxonomy ) ) {
3729
-		$term_taxonomy = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %d", $term_taxonomy_id ) );
3728
+	if (empty($term_taxonomy)) {
3729
+		$term_taxonomy = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %d", $term_taxonomy_id));
3730 3730
 	}
3731 3731
 
3732
-	$children_tt_ids = $wpdb->get_col( $wpdb->prepare( "SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE parent = %d AND taxonomy = %s", $term_id, $term_taxonomy->taxonomy ) );
3733
-	if ( ! empty( $children_tt_ids ) ) {
3734
-		foreach ( $children_tt_ids as $child_tt_id ) {
3735
-			$wpdb->update( $wpdb->term_taxonomy,
3736
-				array( 'parent' => $new_term_id ),
3737
-				array( 'term_taxonomy_id' => $child_tt_id )
3732
+	$children_tt_ids = $wpdb->get_col($wpdb->prepare("SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE parent = %d AND taxonomy = %s", $term_id, $term_taxonomy->taxonomy));
3733
+	if ( ! empty($children_tt_ids)) {
3734
+		foreach ($children_tt_ids as $child_tt_id) {
3735
+			$wpdb->update($wpdb->term_taxonomy,
3736
+				array('parent' => $new_term_id),
3737
+				array('term_taxonomy_id' => $child_tt_id)
3738 3738
 			);
3739
-			clean_term_cache( $term_id, $term_taxonomy->taxonomy );
3739
+			clean_term_cache($term_id, $term_taxonomy->taxonomy);
3740 3740
 		}
3741 3741
 	} else {
3742 3742
 		// If the term has no children, we must force its taxonomy cache to be rebuilt separately.
3743
-		clean_term_cache( $new_term_id, $term_taxonomy->taxonomy );
3743
+		clean_term_cache($new_term_id, $term_taxonomy->taxonomy);
3744 3744
 	}
3745 3745
 
3746 3746
 	// Clean the cache for term taxonomies formerly shared with the current term.
3747
-	$shared_term_taxonomies = $wpdb->get_row( $wpdb->prepare( "SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d", $term_id ) );
3748
-	if ( $shared_term_taxonomies ) {
3749
-		foreach ( $shared_term_taxonomies as $shared_term_taxonomy ) {
3750
-			clean_term_cache( $term_id, $shared_term_taxonomy );
3747
+	$shared_term_taxonomies = $wpdb->get_row($wpdb->prepare("SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d", $term_id));
3748
+	if ($shared_term_taxonomies) {
3749
+		foreach ($shared_term_taxonomies as $shared_term_taxonomy) {
3750
+			clean_term_cache($term_id, $shared_term_taxonomy);
3751 3751
 		}
3752 3752
 	}
3753 3753
 
3754 3754
 	// Keep a record of term_ids that have been split, keyed by old term_id. See wp_get_split_term().
3755
-	if ( $record ) {
3756
-		$split_term_data = get_option( '_split_terms', array() );
3757
-		if ( ! isset( $split_term_data[ $term_id ] ) ) {
3758
-			$split_term_data[ $term_id ] = array();
3755
+	if ($record) {
3756
+		$split_term_data = get_option('_split_terms', array());
3757
+		if ( ! isset($split_term_data[$term_id])) {
3758
+			$split_term_data[$term_id] = array();
3759 3759
 		}
3760 3760
 
3761
-		$split_term_data[ $term_id ][ $term_taxonomy->taxonomy ] = $new_term_id;
3762
-		update_option( '_split_terms', $split_term_data );
3761
+		$split_term_data[$term_id][$term_taxonomy->taxonomy] = $new_term_id;
3762
+		update_option('_split_terms', $split_term_data);
3763 3763
 	}
3764 3764
 
3765 3765
 	// If we've just split the final shared term, set the "finished" flag.
@@ -3770,8 +3770,8 @@  discard block
 block discarded – undo
3770 3770
 		 HAVING term_tt_count > 1
3771 3771
 		 LIMIT 1"
3772 3772
 	);
3773
-	if ( ! $shared_terms_exist ) {
3774
-		update_option( 'finished_splitting_shared_terms', true );
3773
+	if ( ! $shared_terms_exist) {
3774
+		update_option('finished_splitting_shared_terms', true);
3775 3775
 	}
3776 3776
 
3777 3777
 	/**
@@ -3784,7 +3784,7 @@  discard block
 block discarded – undo
3784 3784
 	 * @param int    $term_taxonomy_id ID for the term_taxonomy row affected by the split.
3785 3785
 	 * @param string $taxonomy         Taxonomy for the split term.
3786 3786
 	 */
3787
-	do_action( 'split_shared_term', $term_id, $new_term_id, $term_taxonomy_id, $term_taxonomy->taxonomy );
3787
+	do_action('split_shared_term', $term_id, $new_term_id, $term_taxonomy_id, $term_taxonomy->taxonomy);
3788 3788
 
3789 3789
 	return $new_term_id;
3790 3790
 }
@@ -3802,20 +3802,20 @@  discard block
 block discarded – undo
3802 3802
 	$lock_name = 'term_split.lock';
3803 3803
 
3804 3804
 	// Try to lock.
3805
-	$lock_result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` ( `option_name`, `option_value`, `autoload` ) VALUES (%s, %s, 'no') /* LOCK */", $lock_name, time() ) );
3805
+	$lock_result = $wpdb->query($wpdb->prepare("INSERT IGNORE INTO `$wpdb->options` ( `option_name`, `option_value`, `autoload` ) VALUES (%s, %s, 'no') /* LOCK */", $lock_name, time()));
3806 3806
 
3807
-	if ( ! $lock_result ) {
3808
-		$lock_result = get_option( $lock_name );
3807
+	if ( ! $lock_result) {
3808
+		$lock_result = get_option($lock_name);
3809 3809
 
3810 3810
 		// Bail if we were unable to create a lock, or if the existing lock is still valid.
3811
-		if ( ! $lock_result || ( $lock_result > ( time() - HOUR_IN_SECONDS ) ) ) {
3812
-			wp_schedule_single_event( time() + ( 5 * MINUTE_IN_SECONDS ), 'wp_split_shared_term_batch' );
3811
+		if ( ! $lock_result || ($lock_result > (time() - HOUR_IN_SECONDS))) {
3812
+			wp_schedule_single_event(time() + (5 * MINUTE_IN_SECONDS), 'wp_split_shared_term_batch');
3813 3813
 			return;
3814 3814
 		}
3815 3815
 	}
3816 3816
 
3817 3817
 	// Update the lock, as by this point we've definitely got a lock, just need to fire the actions.
3818
-	update_option( $lock_name, time() );
3818
+	update_option($lock_name, time());
3819 3819
 
3820 3820
 	// Get a list of shared terms (those with more than one associated row in term_taxonomy).
3821 3821
 	$shared_terms = $wpdb->get_results(
@@ -3827,61 +3827,61 @@  discard block
 block discarded – undo
3827 3827
 	);
3828 3828
 
3829 3829
 	// No more terms, we're done here.
3830
-	if ( ! $shared_terms ) {
3831
-		update_option( 'finished_splitting_shared_terms', true );
3832
-		delete_option( $lock_name );
3830
+	if ( ! $shared_terms) {
3831
+		update_option('finished_splitting_shared_terms', true);
3832
+		delete_option($lock_name);
3833 3833
 		return;
3834 3834
 	}
3835 3835
 
3836 3836
 	// Shared terms found? We'll need to run this script again.
3837
-	wp_schedule_single_event( time() + ( 2 * MINUTE_IN_SECONDS ), 'wp_split_shared_term_batch' );
3837
+	wp_schedule_single_event(time() + (2 * MINUTE_IN_SECONDS), 'wp_split_shared_term_batch');
3838 3838
 
3839 3839
 	// Rekey shared term array for faster lookups.
3840 3840
 	$_shared_terms = array();
3841
-	foreach ( $shared_terms as $shared_term ) {
3842
-		$term_id = intval( $shared_term->term_id );
3843
-		$_shared_terms[ $term_id ] = $shared_term;
3841
+	foreach ($shared_terms as $shared_term) {
3842
+		$term_id = intval($shared_term->term_id);
3843
+		$_shared_terms[$term_id] = $shared_term;
3844 3844
 	}
3845 3845
 	$shared_terms = $_shared_terms;
3846 3846
 
3847 3847
 	// Get term taxonomy data for all shared terms.
3848
-	$shared_term_ids = implode( ',', array_keys( $shared_terms ) );
3849
-	$shared_tts = $wpdb->get_results( "SELECT * FROM {$wpdb->term_taxonomy} WHERE `term_id` IN ({$shared_term_ids})" );
3848
+	$shared_term_ids = implode(',', array_keys($shared_terms));
3849
+	$shared_tts = $wpdb->get_results("SELECT * FROM {$wpdb->term_taxonomy} WHERE `term_id` IN ({$shared_term_ids})");
3850 3850
 
3851 3851
 	// Split term data recording is slow, so we do it just once, outside the loop.
3852
-	$split_term_data = get_option( '_split_terms', array() );
3852
+	$split_term_data = get_option('_split_terms', array());
3853 3853
 	$skipped_first_term = $taxonomies = array();
3854
-	foreach ( $shared_tts as $shared_tt ) {
3855
-		$term_id = intval( $shared_tt->term_id );
3854
+	foreach ($shared_tts as $shared_tt) {
3855
+		$term_id = intval($shared_tt->term_id);
3856 3856
 
3857 3857
 		// Don't split the first tt belonging to a given term_id.
3858
-		if ( ! isset( $skipped_first_term[ $term_id ] ) ) {
3859
-			$skipped_first_term[ $term_id ] = 1;
3858
+		if ( ! isset($skipped_first_term[$term_id])) {
3859
+			$skipped_first_term[$term_id] = 1;
3860 3860
 			continue;
3861 3861
 		}
3862 3862
 
3863
-		if ( ! isset( $split_term_data[ $term_id ] ) ) {
3864
-			$split_term_data[ $term_id ] = array();
3863
+		if ( ! isset($split_term_data[$term_id])) {
3864
+			$split_term_data[$term_id] = array();
3865 3865
 		}
3866 3866
 
3867 3867
 		// Keep track of taxonomies whose hierarchies need flushing.
3868
-		if ( ! isset( $taxonomies[ $shared_tt->taxonomy ] ) ) {
3869
-			$taxonomies[ $shared_tt->taxonomy ] = 1;
3868
+		if ( ! isset($taxonomies[$shared_tt->taxonomy])) {
3869
+			$taxonomies[$shared_tt->taxonomy] = 1;
3870 3870
 		}
3871 3871
 
3872 3872
 		// Split the term.
3873
-		$split_term_data[ $term_id ][ $shared_tt->taxonomy ] = _split_shared_term( $shared_terms[ $term_id ], $shared_tt, false );
3873
+		$split_term_data[$term_id][$shared_tt->taxonomy] = _split_shared_term($shared_terms[$term_id], $shared_tt, false);
3874 3874
 	}
3875 3875
 
3876 3876
 	// Rebuild the cached hierarchy for each affected taxonomy.
3877
-	foreach ( array_keys( $taxonomies ) as $tax ) {
3878
-		delete_option( "{$tax}_children" );
3879
-		_get_term_hierarchy( $tax );
3877
+	foreach (array_keys($taxonomies) as $tax) {
3878
+		delete_option("{$tax}_children");
3879
+		_get_term_hierarchy($tax);
3880 3880
 	}
3881 3881
 
3882
-	update_option( '_split_terms', $split_term_data );
3882
+	update_option('_split_terms', $split_term_data);
3883 3883
 
3884
-	delete_option( $lock_name );
3884
+	delete_option($lock_name);
3885 3885
 }
3886 3886
 
3887 3887
 /**
@@ -3892,8 +3892,8 @@  discard block
 block discarded – undo
3892 3892
  * @since 4.3.0
3893 3893
  */
3894 3894
 function _wp_check_for_scheduled_split_terms() {
3895
-	if ( ! get_option( 'finished_splitting_shared_terms' ) && ! wp_next_scheduled( 'wp_split_shared_term_batch' ) ) {
3896
-		wp_schedule_single_event( time() + MINUTE_IN_SECONDS, 'wp_split_shared_term_batch' );
3895
+	if ( ! get_option('finished_splitting_shared_terms') && ! wp_next_scheduled('wp_split_shared_term_batch')) {
3896
+		wp_schedule_single_event(time() + MINUTE_IN_SECONDS, 'wp_split_shared_term_batch');
3897 3897
 	}
3898 3898
 }
3899 3899
 
@@ -3908,14 +3908,14 @@  discard block
 block discarded – undo
3908 3908
  * @param int    $term_taxonomy_id ID for the term_taxonomy row affected by the split.
3909 3909
  * @param string $taxonomy         Taxonomy for the split term.
3910 3910
  */
3911
-function _wp_check_split_default_terms( $term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) {
3912
-	if ( 'category' != $taxonomy ) {
3911
+function _wp_check_split_default_terms($term_id, $new_term_id, $term_taxonomy_id, $taxonomy) {
3912
+	if ('category' != $taxonomy) {
3913 3913
 		return;
3914 3914
 	}
3915 3915
 
3916
-	foreach ( array( 'default_category', 'default_link_category', 'default_email_category' ) as $option ) {
3917
-		if ( $term_id == get_option( $option, -1 ) ) {
3918
-			update_option( $option, $new_term_id );
3916
+	foreach (array('default_category', 'default_link_category', 'default_email_category') as $option) {
3917
+		if ($term_id == get_option($option, -1)) {
3918
+			update_option($option, $new_term_id);
3919 3919
 		}
3920 3920
 	}
3921 3921
 }
@@ -3933,9 +3933,9 @@  discard block
 block discarded – undo
3933 3933
  * @param int    $term_taxonomy_id ID for the term_taxonomy row affected by the split.
3934 3934
  * @param string $taxonomy         Taxonomy for the split term.
3935 3935
  */
3936
-function _wp_check_split_terms_in_menus( $term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) {
3936
+function _wp_check_split_terms_in_menus($term_id, $new_term_id, $term_taxonomy_id, $taxonomy) {
3937 3937
 	global $wpdb;
3938
-	$post_ids = $wpdb->get_col( $wpdb->prepare(
3938
+	$post_ids = $wpdb->get_col($wpdb->prepare(
3939 3939
 		"SELECT m1.post_id
3940 3940
 		FROM {$wpdb->postmeta} AS m1
3941 3941
 			INNER JOIN {$wpdb->postmeta} AS m2 ON ( m2.post_id = m1.post_id )
@@ -3945,11 +3945,11 @@  discard block
 block discarded – undo
3945 3945
 			AND ( m3.meta_key = '_menu_item_object_id' AND m3.meta_value = %d )",
3946 3946
 		$taxonomy,
3947 3947
 		$term_id
3948
-	) );
3948
+	));
3949 3949
 
3950
-	if ( $post_ids ) {
3951
-		foreach ( $post_ids as $post_id ) {
3952
-			update_post_meta( $post_id, '_menu_item_object_id', $new_term_id, $term_id );
3950
+	if ($post_ids) {
3951
+		foreach ($post_ids as $post_id) {
3952
+			update_post_meta($post_id, '_menu_item_object_id', $new_term_id, $term_id);
3953 3953
 		}
3954 3954
 	}
3955 3955
 }
@@ -3965,19 +3965,19 @@  discard block
 block discarded – undo
3965 3965
  * @param int    $term_taxonomy_id ID for the term_taxonomy row affected by the split.
3966 3966
  * @param string $taxonomy         Taxonomy for the split term.
3967 3967
  */
3968
-function _wp_check_split_nav_menu_terms( $term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) {
3969
-	if ( 'nav_menu' !== $taxonomy ) {
3968
+function _wp_check_split_nav_menu_terms($term_id, $new_term_id, $term_taxonomy_id, $taxonomy) {
3969
+	if ('nav_menu' !== $taxonomy) {
3970 3970
 		return;
3971 3971
 	}
3972 3972
 
3973 3973
 	// Update menu locations.
3974 3974
 	$locations = get_nav_menu_locations();
3975
-	foreach ( $locations as $location => $menu_id ) {
3976
-		if ( $term_id == $menu_id ) {
3977
-			$locations[ $location ] = $new_term_id;
3975
+	foreach ($locations as $location => $menu_id) {
3976
+		if ($term_id == $menu_id) {
3977
+			$locations[$location] = $new_term_id;
3978 3978
 		}
3979 3979
 	}
3980
-	set_theme_mod( 'nav_menu_locations', $locations );
3980
+	set_theme_mod('nav_menu_locations', $locations);
3981 3981
 }
3982 3982
 
3983 3983
 /**
@@ -3988,12 +3988,12 @@  discard block
 block discarded – undo
3988 3988
  * @param int $old_term_id Term ID. This is the old, pre-split term ID.
3989 3989
  * @return array Array of new term IDs, keyed by taxonomy.
3990 3990
  */
3991
-function wp_get_split_terms( $old_term_id ) {
3992
-	$split_terms = get_option( '_split_terms', array() );
3991
+function wp_get_split_terms($old_term_id) {
3992
+	$split_terms = get_option('_split_terms', array());
3993 3993
 
3994 3994
 	$terms = array();
3995
-	if ( isset( $split_terms[ $old_term_id ] ) ) {
3996
-		$terms = $split_terms[ $old_term_id ];
3995
+	if (isset($split_terms[$old_term_id])) {
3996
+		$terms = $split_terms[$old_term_id];
3997 3997
 	}
3998 3998
 
3999 3999
 	return $terms;
@@ -4010,12 +4010,12 @@  discard block
 block discarded – undo
4010 4010
  *                   the new term_id will be returned. If no previously split term is found matching
4011 4011
  *                   the parameters, returns false.
4012 4012
  */
4013
-function wp_get_split_term( $old_term_id, $taxonomy ) {
4014
-	$split_terms = wp_get_split_terms( $old_term_id );
4013
+function wp_get_split_term($old_term_id, $taxonomy) {
4014
+	$split_terms = wp_get_split_terms($old_term_id);
4015 4015
 
4016 4016
 	$term_id = false;
4017
-	if ( isset( $split_terms[ $taxonomy ] ) ) {
4018
-		$term_id = (int) $split_terms[ $taxonomy ];
4017
+	if (isset($split_terms[$taxonomy])) {
4018
+		$term_id = (int) $split_terms[$taxonomy];
4019 4019
 	}
4020 4020
 
4021 4021
 	return $term_id;
@@ -4032,14 +4032,14 @@  discard block
 block discarded – undo
4032 4032
  * @param int $term_id
4033 4033
  * @return bool
4034 4034
  */
4035
-function wp_term_is_shared( $term_id ) {
4035
+function wp_term_is_shared($term_id) {
4036 4036
 	global $wpdb;
4037 4037
 
4038
-	if ( get_option( 'finished_splitting_shared_terms' ) ) {
4038
+	if (get_option('finished_splitting_shared_terms')) {
4039 4039
 		return false;
4040 4040
 	}
4041 4041
 
4042
-	$tt_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term_id ) );
4042
+	$tt_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term_id));
4043 4043
 
4044 4044
 	return $tt_count > 1;
4045 4045
 }
@@ -4055,21 +4055,21 @@  discard block
 block discarded – undo
4055 4055
  * @param string            $taxonomy Optional. Taxonomy. Default empty.
4056 4056
  * @return string|WP_Error HTML link to taxonomy term archive on success, WP_Error if term does not exist.
4057 4057
  */
4058
-function get_term_link( $term, $taxonomy = '' ) {
4058
+function get_term_link($term, $taxonomy = '') {
4059 4059
 	global $wp_rewrite;
4060 4060
 
4061
-	if ( !is_object($term) ) {
4062
-		if ( is_int( $term ) ) {
4063
-			$term = get_term( $term, $taxonomy );
4061
+	if ( ! is_object($term)) {
4062
+		if (is_int($term)) {
4063
+			$term = get_term($term, $taxonomy);
4064 4064
 		} else {
4065
-			$term = get_term_by( 'slug', $term, $taxonomy );
4065
+			$term = get_term_by('slug', $term, $taxonomy);
4066 4066
 		}
4067 4067
 	}
4068 4068
 
4069
-	if ( !is_object($term) )
4069
+	if ( ! is_object($term))
4070 4070
 		$term = new WP_Error('invalid_term', __('Empty Term'));
4071 4071
 
4072
-	if ( is_wp_error( $term ) )
4072
+	if (is_wp_error($term))
4073 4073
 		return $term;
4074 4074
 
4075 4075
 	$taxonomy = $term->taxonomy;
@@ -4079,19 +4079,19 @@  discard block
 block discarded – undo
4079 4079
 	$slug = $term->slug;
4080 4080
 	$t = get_taxonomy($taxonomy);
4081 4081
 
4082
-	if ( empty($termlink) ) {
4083
-		if ( 'category' == $taxonomy )
4084
-			$termlink = '?cat=' . $term->term_id;
4085
-		elseif ( $t->query_var )
4082
+	if (empty($termlink)) {
4083
+		if ('category' == $taxonomy)
4084
+			$termlink = '?cat='.$term->term_id;
4085
+		elseif ($t->query_var)
4086 4086
 			$termlink = "?$t->query_var=$slug";
4087 4087
 		else
4088 4088
 			$termlink = "?taxonomy=$taxonomy&term=$slug";
4089 4089
 		$termlink = home_url($termlink);
4090 4090
 	} else {
4091
-		if ( $t->rewrite['hierarchical'] ) {
4091
+		if ($t->rewrite['hierarchical']) {
4092 4092
 			$hierarchical_slugs = array();
4093
-			$ancestors = get_ancestors( $term->term_id, $taxonomy, 'taxonomy' );
4094
-			foreach ( (array)$ancestors as $ancestor ) {
4093
+			$ancestors = get_ancestors($term->term_id, $taxonomy, 'taxonomy');
4094
+			foreach ((array) $ancestors as $ancestor) {
4095 4095
 				$ancestor_term = get_term($ancestor, $taxonomy);
4096 4096
 				$hierarchical_slugs[] = $ancestor_term->slug;
4097 4097
 			}
@@ -4101,10 +4101,10 @@  discard block
 block discarded – undo
4101 4101
 		} else {
4102 4102
 			$termlink = str_replace("%$taxonomy%", $slug, $termlink);
4103 4103
 		}
4104
-		$termlink = home_url( user_trailingslashit($termlink, 'category') );
4104
+		$termlink = home_url(user_trailingslashit($termlink, 'category'));
4105 4105
 	}
4106 4106
 	// Back Compat filters.
4107
-	if ( 'post_tag' == $taxonomy ) {
4107
+	if ('post_tag' == $taxonomy) {
4108 4108
 
4109 4109
 		/**
4110 4110
 		 * Filters the tag link.
@@ -4115,8 +4115,8 @@  discard block
 block discarded – undo
4115 4115
 		 * @param string $termlink Tag link URL.
4116 4116
 		 * @param int    $term_id  Term ID.
4117 4117
 		 */
4118
-		$termlink = apply_filters( 'tag_link', $termlink, $term->term_id );
4119
-	} elseif ( 'category' == $taxonomy ) {
4118
+		$termlink = apply_filters('tag_link', $termlink, $term->term_id);
4119
+	} elseif ('category' == $taxonomy) {
4120 4120
 
4121 4121
 		/**
4122 4122
 		 * Filters the category link.
@@ -4127,7 +4127,7 @@  discard block
 block discarded – undo
4127 4127
 		 * @param string $termlink Category link URL.
4128 4128
 		 * @param int    $term_id  Term ID.
4129 4129
 		 */
4130
-		$termlink = apply_filters( 'category_link', $termlink, $term->term_id );
4130
+		$termlink = apply_filters('category_link', $termlink, $term->term_id);
4131 4131
 	}
4132 4132
 
4133 4133
 	/**
@@ -4139,7 +4139,7 @@  discard block
 block discarded – undo
4139 4139
 	 * @param object $term     Term object.
4140 4140
 	 * @param string $taxonomy Taxonomy slug.
4141 4141
 	 */
4142
-	return apply_filters( 'term_link', $termlink, $term, $taxonomy );
4142
+	return apply_filters('term_link', $termlink, $term, $taxonomy);
4143 4143
 }
4144 4144
 
4145 4145
 /**
@@ -4161,7 +4161,7 @@  discard block
 block discarded – undo
4161 4161
  *     @type  string      $after  Displays after the taxonomies. Default empty string.
4162 4162
  * }
4163 4163
  */
4164
-function the_taxonomies( $args = array() ) {
4164
+function the_taxonomies($args = array()) {
4165 4165
 	$defaults = array(
4166 4166
 		'post' => 0,
4167 4167
 		'before' => '',
@@ -4169,9 +4169,9 @@  discard block
 block discarded – undo
4169 4169
 		'after' => '',
4170 4170
 	);
4171 4171
 
4172
-	$r = wp_parse_args( $args, $defaults );
4172
+	$r = wp_parse_args($args, $defaults);
4173 4173
 
4174
-	echo $r['before'] . join( $r['sep'], get_the_taxonomies( $r['post'], $r ) ) . $r['after'];
4174
+	echo $r['before'].join($r['sep'], get_the_taxonomies($r['post'], $r)).$r['after'];
4175 4175
 }
4176 4176
 
4177 4177
 /**
@@ -4193,47 +4193,47 @@  discard block
 block discarded – undo
4193 4193
  * }
4194 4194
  * @return array List of taxonomies.
4195 4195
  */
4196
-function get_the_taxonomies( $post = 0, $args = array() ) {
4197
-	$post = get_post( $post );
4196
+function get_the_taxonomies($post = 0, $args = array()) {
4197
+	$post = get_post($post);
4198 4198
 
4199
-	$args = wp_parse_args( $args, array(
4199
+	$args = wp_parse_args($args, array(
4200 4200
 		/* translators: %s: taxonomy label, %l: list of terms formatted as per $term_template */
4201
-		'template' => __( '%s: %l.' ),
4201
+		'template' => __('%s: %l.'),
4202 4202
 		'term_template' => '<a href="%1$s">%2$s</a>',
4203
-	) );
4203
+	));
4204 4204
 
4205 4205
 	$taxonomies = array();
4206 4206
 
4207
-	if ( ! $post ) {
4207
+	if ( ! $post) {
4208 4208
 		return $taxonomies;
4209 4209
 	}
4210 4210
 
4211
-	foreach ( get_object_taxonomies( $post ) as $taxonomy ) {
4212
-		$t = (array) get_taxonomy( $taxonomy );
4213
-		if ( empty( $t['label'] ) ) {
4211
+	foreach (get_object_taxonomies($post) as $taxonomy) {
4212
+		$t = (array) get_taxonomy($taxonomy);
4213
+		if (empty($t['label'])) {
4214 4214
 			$t['label'] = $taxonomy;
4215 4215
 		}
4216
-		if ( empty( $t['args'] ) ) {
4216
+		if (empty($t['args'])) {
4217 4217
 			$t['args'] = array();
4218 4218
 		}
4219
-		if ( empty( $t['template'] ) ) {
4219
+		if (empty($t['template'])) {
4220 4220
 			$t['template'] = $args['template'];
4221 4221
 		}
4222
-		if ( empty( $t['term_template'] ) ) {
4222
+		if (empty($t['term_template'])) {
4223 4223
 			$t['term_template'] = $args['term_template'];
4224 4224
 		}
4225 4225
 
4226
-		$terms = get_object_term_cache( $post->ID, $taxonomy );
4227
-		if ( false === $terms ) {
4228
-			$terms = wp_get_object_terms( $post->ID, $taxonomy, $t['args'] );
4226
+		$terms = get_object_term_cache($post->ID, $taxonomy);
4227
+		if (false === $terms) {
4228
+			$terms = wp_get_object_terms($post->ID, $taxonomy, $t['args']);
4229 4229
 		}
4230 4230
 		$links = array();
4231 4231
 
4232
-		foreach ( $terms as $term ) {
4233
-			$links[] = wp_sprintf( $t['term_template'], esc_attr( get_term_link( $term ) ), $term->name );
4232
+		foreach ($terms as $term) {
4233
+			$links[] = wp_sprintf($t['term_template'], esc_attr(get_term_link($term)), $term->name);
4234 4234
 		}
4235
-		if ( $links ) {
4236
-			$taxonomies[$taxonomy] = wp_sprintf( $t['template'], $t['label'], $links, $terms );
4235
+		if ($links) {
4236
+			$taxonomies[$taxonomy] = wp_sprintf($t['template'], $t['label'], $links, $terms);
4237 4237
 		}
4238 4238
 	}
4239 4239
 	return $taxonomies;
@@ -4247,8 +4247,8 @@  discard block
 block discarded – undo
4247 4247
  * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
4248 4248
  * @return array
4249 4249
  */
4250
-function get_post_taxonomies( $post = 0 ) {
4251
-	$post = get_post( $post );
4250
+function get_post_taxonomies($post = 0) {
4251
+	$post = get_post($post);
4252 4252
 
4253 4253
 	return get_object_taxonomies($post);
4254 4254
 }
@@ -4267,45 +4267,45 @@  discard block
 block discarded – undo
4267 4267
  * @param int|string|array $terms     Optional. Term term_id, name, slug or array of said. Default null.
4268 4268
  * @return bool|WP_Error WP_Error on input error.
4269 4269
  */
4270
-function is_object_in_term( $object_id, $taxonomy, $terms = null ) {
4271
-	if ( !$object_id = (int) $object_id )
4272
-		return new WP_Error( 'invalid_object', __( 'Invalid object ID' ) );
4270
+function is_object_in_term($object_id, $taxonomy, $terms = null) {
4271
+	if ( ! $object_id = (int) $object_id)
4272
+		return new WP_Error('invalid_object', __('Invalid object ID'));
4273 4273
 
4274
-	$object_terms = get_object_term_cache( $object_id, $taxonomy );
4275
-	if ( false === $object_terms ) {
4276
-		$object_terms = wp_get_object_terms( $object_id, $taxonomy, array( 'update_term_meta_cache' => false ) );
4277
-		wp_cache_set( $object_id, wp_list_pluck( $object_terms, 'term_id' ), "{$taxonomy}_relationships" );
4274
+	$object_terms = get_object_term_cache($object_id, $taxonomy);
4275
+	if (false === $object_terms) {
4276
+		$object_terms = wp_get_object_terms($object_id, $taxonomy, array('update_term_meta_cache' => false));
4277
+		wp_cache_set($object_id, wp_list_pluck($object_terms, 'term_id'), "{$taxonomy}_relationships");
4278 4278
 	}
4279 4279
 
4280
-	if ( is_wp_error( $object_terms ) )
4280
+	if (is_wp_error($object_terms))
4281 4281
 		return $object_terms;
4282
-	if ( empty( $object_terms ) )
4282
+	if (empty($object_terms))
4283 4283
 		return false;
4284
-	if ( empty( $terms ) )
4285
-		return ( !empty( $object_terms ) );
4284
+	if (empty($terms))
4285
+		return ( ! empty($object_terms));
4286 4286
 
4287 4287
 	$terms = (array) $terms;
4288 4288
 
4289
-	if ( $ints = array_filter( $terms, 'is_int' ) )
4290
-		$strs = array_diff( $terms, $ints );
4289
+	if ($ints = array_filter($terms, 'is_int'))
4290
+		$strs = array_diff($terms, $ints);
4291 4291
 	else
4292
-		$strs =& $terms;
4292
+		$strs = & $terms;
4293 4293
 
4294
-	foreach ( $object_terms as $object_term ) {
4294
+	foreach ($object_terms as $object_term) {
4295 4295
 		// If term is an int, check against term_ids only.
4296
-		if ( $ints && in_array( $object_term->term_id, $ints ) ) {
4296
+		if ($ints && in_array($object_term->term_id, $ints)) {
4297 4297
 			return true;
4298 4298
 		}
4299 4299
 
4300
-		if ( $strs ) {
4300
+		if ($strs) {
4301 4301
 			// Only check numeric strings against term_id, to avoid false matches due to type juggling.
4302
-			$numeric_strs = array_map( 'intval', array_filter( $strs, 'is_numeric' ) );
4303
-			if ( in_array( $object_term->term_id, $numeric_strs, true ) ) {
4302
+			$numeric_strs = array_map('intval', array_filter($strs, 'is_numeric'));
4303
+			if (in_array($object_term->term_id, $numeric_strs, true)) {
4304 4304
 				return true;
4305 4305
 			}
4306 4306
 
4307
-			if ( in_array( $object_term->name, $strs ) ) return true;
4308
-			if ( in_array( $object_term->slug, $strs ) ) return true;
4307
+			if (in_array($object_term->name, $strs)) return true;
4308
+			if (in_array($object_term->slug, $strs)) return true;
4309 4309
 		}
4310 4310
 	}
4311 4311
 
@@ -4321,12 +4321,12 @@  discard block
 block discarded – undo
4321 4321
  * @param string $taxonomy    Single taxonomy name.
4322 4322
  * @return bool True if object is associated with the taxonomy, otherwise false.
4323 4323
  */
4324
-function is_object_in_taxonomy( $object_type, $taxonomy ) {
4325
-	$taxonomies = get_object_taxonomies( $object_type );
4326
-	if ( empty( $taxonomies ) ) {
4324
+function is_object_in_taxonomy($object_type, $taxonomy) {
4325
+	$taxonomies = get_object_taxonomies($object_type);
4326
+	if (empty($taxonomies)) {
4327 4327
 		return false;
4328 4328
 	}
4329
-	return in_array( $taxonomy, $taxonomies );
4329
+	return in_array($taxonomy, $taxonomies);
4330 4330
 }
4331 4331
 
4332 4332
 /**
@@ -4342,32 +4342,32 @@  discard block
 block discarded – undo
4342 4342
  *                              or 'taxonomy'. Default empty.
4343 4343
  * @return array An array of ancestors from lowest to highest in the hierarchy.
4344 4344
  */
4345
-function get_ancestors( $object_id = 0, $object_type = '', $resource_type = '' ) {
4345
+function get_ancestors($object_id = 0, $object_type = '', $resource_type = '') {
4346 4346
 	$object_id = (int) $object_id;
4347 4347
 
4348 4348
 	$ancestors = array();
4349 4349
 
4350
-	if ( empty( $object_id ) ) {
4350
+	if (empty($object_id)) {
4351 4351
 
4352 4352
 		/** This filter is documented in wp-includes/taxonomy.php */
4353
-		return apply_filters( 'get_ancestors', $ancestors, $object_id, $object_type, $resource_type );
4353
+		return apply_filters('get_ancestors', $ancestors, $object_id, $object_type, $resource_type);
4354 4354
 	}
4355 4355
 
4356
-	if ( ! $resource_type ) {
4357
-		if ( is_taxonomy_hierarchical( $object_type ) ) {
4356
+	if ( ! $resource_type) {
4357
+		if (is_taxonomy_hierarchical($object_type)) {
4358 4358
 			$resource_type = 'taxonomy';
4359
-		} elseif ( post_type_exists( $object_type ) ) {
4359
+		} elseif (post_type_exists($object_type)) {
4360 4360
 			$resource_type = 'post_type';
4361 4361
 		}
4362 4362
 	}
4363 4363
 
4364
-	if ( 'taxonomy' === $resource_type ) {
4364
+	if ('taxonomy' === $resource_type) {
4365 4365
 		$term = get_term($object_id, $object_type);
4366
-		while ( ! is_wp_error($term) && ! empty( $term->parent ) && ! in_array( $term->parent, $ancestors ) ) {
4366
+		while ( ! is_wp_error($term) && ! empty($term->parent) && ! in_array($term->parent, $ancestors)) {
4367 4367
 			$ancestors[] = (int) $term->parent;
4368 4368
 			$term = get_term($term->parent, $object_type);
4369 4369
 		}
4370
-	} elseif ( 'post_type' === $resource_type ) {
4370
+	} elseif ('post_type' === $resource_type) {
4371 4371
 		$ancestors = get_post_ancestors($object_id);
4372 4372
 	}
4373 4373
 
@@ -4382,7 +4382,7 @@  discard block
 block discarded – undo
4382 4382
 	 * @param string $object_type   Type of object.
4383 4383
 	 * @param string $resource_type Type of resource $object_type is.
4384 4384
 	 */
4385
-	return apply_filters( 'get_ancestors', $ancestors, $object_id, $object_type, $resource_type );
4385
+	return apply_filters('get_ancestors', $ancestors, $object_id, $object_type, $resource_type);
4386 4386
 }
4387 4387
 
4388 4388
 /**
@@ -4394,9 +4394,9 @@  discard block
 block discarded – undo
4394 4394
  * @param string $taxonomy Taxonomy name.
4395 4395
  * @return int|false False on error.
4396 4396
  */
4397
-function wp_get_term_taxonomy_parent_id( $term_id, $taxonomy ) {
4398
-	$term = get_term( $term_id, $taxonomy );
4399
-	if ( ! $term || is_wp_error( $term ) ) {
4397
+function wp_get_term_taxonomy_parent_id($term_id, $taxonomy) {
4398
+	$term = get_term($term_id, $taxonomy);
4399
+	if ( ! $term || is_wp_error($term)) {
4400 4400
 		return false;
4401 4401
 	}
4402 4402
 	return (int) $term->parent;
@@ -4416,26 +4416,26 @@  discard block
 block discarded – undo
4416 4416
  *
4417 4417
  * @return int The new parent for the term.
4418 4418
  */
4419
-function wp_check_term_hierarchy_for_loops( $parent, $term_id, $taxonomy ) {
4419
+function wp_check_term_hierarchy_for_loops($parent, $term_id, $taxonomy) {
4420 4420
 	// Nothing fancy here - bail
4421
-	if ( !$parent )
4421
+	if ( ! $parent)
4422 4422
 		return 0;
4423 4423
 
4424 4424
 	// Can't be its own parent.
4425
-	if ( $parent == $term_id )
4425
+	if ($parent == $term_id)
4426 4426
 		return 0;
4427 4427
 
4428 4428
 	// Now look for larger loops.
4429
-	if ( !$loop = wp_find_hierarchy_loop( 'wp_get_term_taxonomy_parent_id', $term_id, $parent, array( $taxonomy ) ) )
4429
+	if ( ! $loop = wp_find_hierarchy_loop('wp_get_term_taxonomy_parent_id', $term_id, $parent, array($taxonomy)))
4430 4430
 		return $parent; // No loop
4431 4431
 
4432 4432
 	// Setting $parent to the given value causes a loop.
4433
-	if ( isset( $loop[$term_id] ) )
4433
+	if (isset($loop[$term_id]))
4434 4434
 		return 0;
4435 4435
 
4436 4436
 	// There's a loop, but it doesn't contain $term_id. Break the loop.
4437
-	foreach ( array_keys( $loop ) as $loop_member )
4438
-		wp_update_term( $loop_member, $taxonomy, array( 'parent' => 0 ) );
4437
+	foreach (array_keys($loop) as $loop_member)
4438
+		wp_update_term($loop_member, $taxonomy, array('parent' => 0));
4439 4439
 
4440 4440
 	return $parent;
4441 4441
 }
Please login to merge, or discard this patch.
Braces   +381 added lines, -259 removed lines patch added patch discarded remove patch
@@ -180,8 +180,9 @@  discard block
 block discarded – undo
180 180
 	global $wp_taxonomies;
181 181
 
182 182
 	if ( is_object($object) ) {
183
-		if ( $object->post_type == 'attachment' )
184
-			return get_attachment_taxonomies($object);
183
+		if ( $object->post_type == 'attachment' ) {
184
+					return get_attachment_taxonomies($object);
185
+		}
185 186
 		$object = $object->post_type;
186 187
 	}
187 188
 
@@ -190,10 +191,11 @@  discard block
 block discarded – undo
190 191
 	$taxonomies = array();
191 192
 	foreach ( (array) $wp_taxonomies as $tax_name => $tax_obj ) {
192 193
 		if ( array_intersect($object, (array) $tax_obj->object_type) ) {
193
-			if ( 'names' == $output )
194
-				$taxonomies[] = $tax_name;
195
-			else
196
-				$taxonomies[ $tax_name ] = $tax_obj;
194
+			if ( 'names' == $output ) {
195
+							$taxonomies[] = $tax_name;
196
+			} else {
197
+							$taxonomies[ $tax_name ] = $tax_obj;
198
+			}
197 199
 		}
198 200
 	}
199 201
 
@@ -216,8 +218,9 @@  discard block
 block discarded – undo
216 218
 function get_taxonomy( $taxonomy ) {
217 219
 	global $wp_taxonomies;
218 220
 
219
-	if ( ! taxonomy_exists( $taxonomy ) )
220
-		return false;
221
+	if ( ! taxonomy_exists( $taxonomy ) ) {
222
+			return false;
223
+	}
221 224
 
222 225
 	return $wp_taxonomies[$taxonomy];
223 226
 }
@@ -254,8 +257,9 @@  discard block
 block discarded – undo
254 257
  * @return bool Whether the taxonomy is hierarchical.
255 258
  */
256 259
 function is_taxonomy_hierarchical($taxonomy) {
257
-	if ( ! taxonomy_exists($taxonomy) )
258
-		return false;
260
+	if ( ! taxonomy_exists($taxonomy) ) {
261
+			return false;
262
+	}
259 263
 
260 264
 	$taxonomy = get_taxonomy($taxonomy);
261 265
 	return $taxonomy->hierarchical;
@@ -351,8 +355,9 @@  discard block
 block discarded – undo
351 355
 function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
352 356
 	global $wp_taxonomies, $wp;
353 357
 
354
-	if ( ! is_array( $wp_taxonomies ) )
355
-		$wp_taxonomies = array();
358
+	if ( ! is_array( $wp_taxonomies ) ) {
359
+			$wp_taxonomies = array();
360
+	}
356 361
 
357 362
 	$args = wp_parse_args( $args );
358 363
 
@@ -400,10 +405,11 @@  discard block
 block discarded – undo
400 405
 
401 406
 	// Non-publicly queryable taxonomies should not register query vars, except in the admin.
402 407
 	if ( false !== $args['query_var'] && ( is_admin() || false !== $args['publicly_queryable'] ) && ! empty( $wp ) ) {
403
-		if ( true === $args['query_var'] )
404
-			$args['query_var'] = $taxonomy;
405
-		else
406
-			$args['query_var'] = sanitize_title_with_dashes( $args['query_var'] );
408
+		if ( true === $args['query_var'] ) {
409
+					$args['query_var'] = $taxonomy;
410
+		} else {
411
+					$args['query_var'] = sanitize_title_with_dashes( $args['query_var'] );
412
+		}
407 413
 		$wp->add_query_var( $args['query_var'] );
408 414
 	} else {
409 415
 		// Force query_var to false for non-public taxonomies.
@@ -417,33 +423,39 @@  discard block
 block discarded – undo
417 423
 			'ep_mask' => EP_NONE,
418 424
 		) );
419 425
 
420
-		if ( empty( $args['rewrite']['slug'] ) )
421
-			$args['rewrite']['slug'] = sanitize_title_with_dashes( $taxonomy );
426
+		if ( empty( $args['rewrite']['slug'] ) ) {
427
+					$args['rewrite']['slug'] = sanitize_title_with_dashes( $taxonomy );
428
+		}
422 429
 
423
-		if ( $args['hierarchical'] && $args['rewrite']['hierarchical'] )
424
-			$tag = '(.+?)';
425
-		else
426
-			$tag = '([^/]+)';
430
+		if ( $args['hierarchical'] && $args['rewrite']['hierarchical'] ) {
431
+					$tag = '(.+?)';
432
+		} else {
433
+					$tag = '([^/]+)';
434
+		}
427 435
 
428 436
 		add_rewrite_tag( "%$taxonomy%", $tag, $args['query_var'] ? "{$args['query_var']}=" : "taxonomy=$taxonomy&term=" );
429 437
 		add_permastruct( $taxonomy, "{$args['rewrite']['slug']}/%$taxonomy%", $args['rewrite'] );
430 438
 	}
431 439
 
432 440
 	// If not set, default to the setting for public.
433
-	if ( null === $args['show_ui'] )
434
-		$args['show_ui'] = $args['public'];
441
+	if ( null === $args['show_ui'] ) {
442
+			$args['show_ui'] = $args['public'];
443
+	}
435 444
 
436 445
 	// If not set, default to the setting for show_ui.
437
-	if ( null === $args['show_in_menu' ] || ! $args['show_ui'] )
438
-		$args['show_in_menu' ] = $args['show_ui'];
446
+	if ( null === $args['show_in_menu' ] || ! $args['show_ui'] ) {
447
+			$args['show_in_menu' ] = $args['show_ui'];
448
+	}
439 449
 
440 450
 	// If not set, default to the setting for public.
441
-	if ( null === $args['show_in_nav_menus'] )
442
-		$args['show_in_nav_menus'] = $args['public'];
451
+	if ( null === $args['show_in_nav_menus'] ) {
452
+			$args['show_in_nav_menus'] = $args['public'];
453
+	}
443 454
 
444 455
 	// If not set, default to the setting for show_ui.
445
-	if ( null === $args['show_tagcloud'] )
446
-		$args['show_tagcloud'] = $args['show_ui'];
456
+	if ( null === $args['show_tagcloud'] ) {
457
+			$args['show_tagcloud'] = $args['show_ui'];
458
+	}
447 459
 
448 460
 	// If not set, default to the setting for show_ui.
449 461
 	if ( null === $args['show_in_quick_edit'] ) {
@@ -467,10 +479,11 @@  discard block
 block discarded – undo
467 479
 
468 480
 	// If not set, use the default meta box
469 481
 	if ( null === $args['meta_box_cb'] ) {
470
-		if ( $args['hierarchical'] )
471
-			$args['meta_box_cb'] = 'post_categories_meta_box';
472
-		else
473
-			$args['meta_box_cb'] = 'post_tags_meta_box';
482
+		if ( $args['hierarchical'] ) {
483
+					$args['meta_box_cb'] = 'post_categories_meta_box';
484
+		} else {
485
+					$args['meta_box_cb'] = 'post_tags_meta_box';
486
+		}
474 487
 	}
475 488
 
476 489
 	$wp_taxonomies[ $taxonomy ] = (object) $args;
@@ -585,11 +598,13 @@  discard block
 block discarded – undo
585 598
 function get_taxonomy_labels( $tax ) {
586 599
 	$tax->labels = (array) $tax->labels;
587 600
 
588
-	if ( isset( $tax->helps ) && empty( $tax->labels['separate_items_with_commas'] ) )
589
-		$tax->labels['separate_items_with_commas'] = $tax->helps;
601
+	if ( isset( $tax->helps ) && empty( $tax->labels['separate_items_with_commas'] ) ) {
602
+			$tax->labels['separate_items_with_commas'] = $tax->helps;
603
+	}
590 604
 
591
-	if ( isset( $tax->no_tagcloud ) && empty( $tax->labels['not_found'] ) )
592
-		$tax->labels['not_found'] = $tax->no_tagcloud;
605
+	if ( isset( $tax->no_tagcloud ) && empty( $tax->labels['not_found'] ) ) {
606
+			$tax->labels['not_found'] = $tax->no_tagcloud;
607
+	}
593 608
 
594 609
 	$nohier_vs_hier_defaults = array(
595 610
 		'name' => array( _x( 'Tags', 'taxonomy general name' ), _x( 'Categories', 'taxonomy general name' ) ),
@@ -653,14 +668,17 @@  discard block
 block discarded – undo
653 668
 function register_taxonomy_for_object_type( $taxonomy, $object_type) {
654 669
 	global $wp_taxonomies;
655 670
 
656
-	if ( !isset($wp_taxonomies[$taxonomy]) )
657
-		return false;
671
+	if ( !isset($wp_taxonomies[$taxonomy]) ) {
672
+			return false;
673
+	}
658 674
 
659
-	if ( ! get_post_type_object($object_type) )
660
-		return false;
675
+	if ( ! get_post_type_object($object_type) ) {
676
+			return false;
677
+	}
661 678
 
662
-	if ( ! in_array( $object_type, $wp_taxonomies[$taxonomy]->object_type ) )
663
-		$wp_taxonomies[$taxonomy]->object_type[] = $object_type;
679
+	if ( ! in_array( $object_type, $wp_taxonomies[$taxonomy]->object_type ) ) {
680
+			$wp_taxonomies[$taxonomy]->object_type[] = $object_type;
681
+	}
664 682
 
665 683
 	// Filter out empties.
666 684
 	$wp_taxonomies[ $taxonomy ]->object_type = array_filter( $wp_taxonomies[ $taxonomy ]->object_type );
@@ -682,15 +700,18 @@  discard block
 block discarded – undo
682 700
 function unregister_taxonomy_for_object_type( $taxonomy, $object_type ) {
683 701
 	global $wp_taxonomies;
684 702
 
685
-	if ( ! isset( $wp_taxonomies[ $taxonomy ] ) )
686
-		return false;
703
+	if ( ! isset( $wp_taxonomies[ $taxonomy ] ) ) {
704
+			return false;
705
+	}
687 706
 
688
-	if ( ! get_post_type_object( $object_type ) )
689
-		return false;
707
+	if ( ! get_post_type_object( $object_type ) ) {
708
+			return false;
709
+	}
690 710
 
691 711
 	$key = array_search( $object_type, $wp_taxonomies[ $taxonomy ]->object_type, true );
692
-	if ( false === $key )
693
-		return false;
712
+	if ( false === $key ) {
713
+			return false;
714
+	}
694 715
 
695 716
 	unset( $wp_taxonomies[ $taxonomy ]->object_type[ $key ] );
696 717
 	return true;
@@ -939,8 +960,9 @@  discard block
 block discarded – undo
939 960
 	if ( 'slug' == $field ) {
940 961
 		$_field = 't.slug';
941 962
 		$value = sanitize_title($value);
942
-		if ( empty($value) )
943
-			return false;
963
+		if ( empty($value) ) {
964
+					return false;
965
+		}
944 966
 	} elseif ( 'name' == $field ) {
945 967
 		// Assume already escaped
946 968
 		$value = wp_unslash($value);
@@ -960,8 +982,9 @@  discard block
 block discarded – undo
960 982
 	}
961 983
 
962 984
 	$term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE $_field = %s", $value ) . " $tax_clause LIMIT 1" );
963
-	if ( ! $term )
964
-		return false;
985
+	if ( ! $term ) {
986
+			return false;
987
+	}
965 988
 
966 989
 	// In the case of 'term_taxonomy_id', override the provided `$taxonomy` with whatever we find in the db.
967 990
 	if ( 'term_taxonomy_id' === $field ) {
@@ -996,8 +1019,9 @@  discard block
 block discarded – undo
996 1019
 
997 1020
 	$terms = _get_term_hierarchy($taxonomy);
998 1021
 
999
-	if ( ! isset($terms[$term_id]) )
1000
-		return array();
1022
+	if ( ! isset($terms[$term_id]) ) {
1023
+			return array();
1024
+	}
1001 1025
 
1002 1026
 	$children = $terms[$term_id];
1003 1027
 
@@ -1006,8 +1030,9 @@  discard block
 block discarded – undo
1006 1030
 			continue;
1007 1031
 		}
1008 1032
 
1009
-		if ( isset($terms[$child]) )
1010
-			$children = array_merge($children, get_term_children($child, $taxonomy));
1033
+		if ( isset($terms[$child]) ) {
1034
+					$children = array_merge($children, get_term_children($child, $taxonomy));
1035
+		}
1011 1036
 	}
1012 1037
 
1013 1038
 	return $children;
@@ -1031,14 +1056,17 @@  discard block
 block discarded – undo
1031 1056
  */
1032 1057
 function get_term_field( $field, $term, $taxonomy = '', $context = 'display' ) {
1033 1058
 	$term = get_term( $term, $taxonomy );
1034
-	if ( is_wp_error($term) )
1035
-		return $term;
1059
+	if ( is_wp_error($term) ) {
1060
+			return $term;
1061
+	}
1036 1062
 
1037
-	if ( !is_object($term) )
1038
-		return '';
1063
+	if ( !is_object($term) ) {
1064
+			return '';
1065
+	}
1039 1066
 
1040
-	if ( !isset($term->$field) )
1041
-		return '';
1067
+	if ( !isset($term->$field) ) {
1068
+			return '';
1069
+	}
1042 1070
 
1043 1071
 	return sanitize_term_field( $field, $term->$field, $term->term_id, $term->taxonomy, $context );
1044 1072
 }
@@ -1058,11 +1086,13 @@  discard block
 block discarded – undo
1058 1086
 function get_term_to_edit( $id, $taxonomy ) {
1059 1087
 	$term = get_term( $id, $taxonomy );
1060 1088
 
1061
-	if ( is_wp_error($term) )
1062
-		return $term;
1089
+	if ( is_wp_error($term) ) {
1090
+			return $term;
1091
+	}
1063 1092
 
1064
-	if ( !is_object($term) )
1065
-		return '';
1093
+	if ( !is_object($term) ) {
1094
+			return '';
1095
+	}
1066 1096
 
1067 1097
 	return sanitize_term($term, $taxonomy, 'edit');
1068 1098
 }
@@ -1394,13 +1424,15 @@  discard block
 block discarded – undo
1394 1424
 	$tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE ";
1395 1425
 
1396 1426
 	if ( is_int($term) ) {
1397
-		if ( 0 == $term )
1398
-			return 0;
1427
+		if ( 0 == $term ) {
1428
+					return 0;
1429
+		}
1399 1430
 		$where = 't.term_id = %d';
1400
-		if ( !empty($taxonomy) )
1401
-			return $wpdb->get_row( $wpdb->prepare( $tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy ), ARRAY_A );
1402
-		else
1403
-			return $wpdb->get_var( $wpdb->prepare( $select . $where, $term ) );
1431
+		if ( !empty($taxonomy) ) {
1432
+					return $wpdb->get_row( $wpdb->prepare( $tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy ), ARRAY_A );
1433
+		} else {
1434
+					return $wpdb->get_var( $wpdb->prepare( $select . $where, $term ) );
1435
+		}
1404 1436
 	}
1405 1437
 
1406 1438
 	$term = trim( wp_unslash( $term ) );
@@ -1424,14 +1456,16 @@  discard block
 block discarded – undo
1424 1456
 		$where_fields[] = $taxonomy;
1425 1457
 		$else_where_fields[] = $taxonomy;
1426 1458
 
1427
-		if ( $result = $wpdb->get_row( $wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s $orderby $limit", $where_fields), ARRAY_A) )
1428
-			return $result;
1459
+		if ( $result = $wpdb->get_row( $wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s $orderby $limit", $where_fields), ARRAY_A) ) {
1460
+					return $result;
1461
+		}
1429 1462
 
1430 1463
 		return $wpdb->get_row( $wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $else_where AND tt.taxonomy = %s $orderby $limit", $else_where_fields), ARRAY_A);
1431 1464
 	}
1432 1465
 
1433
-	if ( $result = $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where $orderby $limit", $where_fields) ) )
1434
-		return $result;
1466
+	if ( $result = $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where $orderby $limit", $where_fields) ) ) {
1467
+			return $result;
1468
+	}
1435 1469
 
1436 1470
 	return $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $else_where $orderby $limit", $else_where_fields) );
1437 1471
 }
@@ -1449,15 +1483,19 @@  discard block
 block discarded – undo
1449 1483
  * @return bool Whether `$term2` is a child of `$term1`.
1450 1484
  */
1451 1485
 function term_is_ancestor_of( $term1, $term2, $taxonomy ) {
1452
-	if ( ! isset( $term1->term_id ) )
1453
-		$term1 = get_term( $term1, $taxonomy );
1454
-	if ( ! isset( $term2->parent ) )
1455
-		$term2 = get_term( $term2, $taxonomy );
1486
+	if ( ! isset( $term1->term_id ) ) {
1487
+			$term1 = get_term( $term1, $taxonomy );
1488
+	}
1489
+	if ( ! isset( $term2->parent ) ) {
1490
+			$term2 = get_term( $term2, $taxonomy );
1491
+	}
1456 1492
 
1457
-	if ( empty( $term1->term_id ) || empty( $term2->parent ) )
1458
-		return false;
1459
-	if ( $term2->parent == $term1->term_id )
1460
-		return true;
1493
+	if ( empty( $term1->term_id ) || empty( $term2->parent ) ) {
1494
+			return false;
1495
+	}
1496
+	if ( $term2->parent == $term1->term_id ) {
1497
+			return true;
1498
+	}
1461 1499
 
1462 1500
 	return term_is_ancestor_of( $term1, get_term( $term2->parent, $taxonomy ), $taxonomy );
1463 1501
 }
@@ -1488,18 +1526,21 @@  discard block
 block discarded – undo
1488 1526
 
1489 1527
 	foreach ( (array) $fields as $field ) {
1490 1528
 		if ( $do_object ) {
1491
-			if ( isset($term->$field) )
1492
-				$term->$field = sanitize_term_field($field, $term->$field, $term_id, $taxonomy, $context);
1529
+			if ( isset($term->$field) ) {
1530
+							$term->$field = sanitize_term_field($field, $term->$field, $term_id, $taxonomy, $context);
1531
+			}
1493 1532
 		} else {
1494
-			if ( isset($term[$field]) )
1495
-				$term[$field] = sanitize_term_field($field, $term[$field], $term_id, $taxonomy, $context);
1533
+			if ( isset($term[$field]) ) {
1534
+							$term[$field] = sanitize_term_field($field, $term[$field], $term_id, $taxonomy, $context);
1535
+			}
1496 1536
 		}
1497 1537
 	}
1498 1538
 
1499
-	if ( $do_object )
1500
-		$term->filter = $context;
1501
-	else
1502
-		$term['filter'] = $context;
1539
+	if ( $do_object ) {
1540
+			$term->filter = $context;
1541
+	} else {
1542
+			$term['filter'] = $context;
1543
+	}
1503 1544
 
1504 1545
 	return $term;
1505 1546
 }
@@ -1531,12 +1572,14 @@  discard block
 block discarded – undo
1531 1572
 	$int_fields = array( 'parent', 'term_id', 'count', 'term_group', 'term_taxonomy_id', 'object_id' );
1532 1573
 	if ( in_array( $field, $int_fields ) ) {
1533 1574
 		$value = (int) $value;
1534
-		if ( $value < 0 )
1535
-			$value = 0;
1575
+		if ( $value < 0 ) {
1576
+					$value = 0;
1577
+		}
1536 1578
 	}
1537 1579
 
1538
-	if ( 'raw' == $context )
1539
-		return $value;
1580
+	if ( 'raw' == $context ) {
1581
+			return $value;
1582
+	}
1540 1583
 
1541 1584
 	if ( 'edit' == $context ) {
1542 1585
 
@@ -1566,10 +1609,13 @@  discard block
 block discarded – undo
1566 1609
 		 */
1567 1610
 		$value = apply_filters( "edit_{$taxonomy}_{$field}", $value, $term_id );
1568 1611
 
1569
-		if ( 'description' == $field )
1570
-			$value = esc_html($value); // textarea_escaped
1571
-		else
1572
-			$value = esc_attr($value);
1612
+		if ( 'description' == $field ) {
1613
+					$value = esc_html($value);
1614
+		}
1615
+		// textarea_escaped
1616
+		else {
1617
+					$value = esc_attr($value);
1618
+		}
1573 1619
 	} elseif ( 'db' == $context ) {
1574 1620
 
1575 1621
 		/**
@@ -1717,8 +1763,9 @@  discard block
 block discarded – undo
1717 1763
 function wp_delete_object_term_relationships( $object_id, $taxonomies ) {
1718 1764
 	$object_id = (int) $object_id;
1719 1765
 
1720
-	if ( !is_array($taxonomies) )
1721
-		$taxonomies = array($taxonomies);
1766
+	if ( !is_array($taxonomies) ) {
1767
+			$taxonomies = array($taxonomies);
1768
+	}
1722 1769
 
1723 1770
 	foreach ( (array) $taxonomies as $taxonomy ) {
1724 1771
 		$term_ids = wp_get_object_terms( $object_id, $taxonomy, array( 'fields' => 'ids' ) );
@@ -1759,10 +1806,12 @@  discard block
 block discarded – undo
1759 1806
 
1760 1807
 	$term = (int) $term;
1761 1808
 
1762
-	if ( ! $ids = term_exists($term, $taxonomy) )
1763
-		return false;
1764
-	if ( is_wp_error( $ids ) )
1765
-		return $ids;
1809
+	if ( ! $ids = term_exists($term, $taxonomy) ) {
1810
+			return false;
1811
+	}
1812
+	if ( is_wp_error( $ids ) ) {
1813
+			return $ids;
1814
+	}
1766 1815
 
1767 1816
 	$tt_id = $ids['term_taxonomy_id'];
1768 1817
 
@@ -1770,8 +1819,10 @@  discard block
 block discarded – undo
1770 1819
 
1771 1820
 	if ( 'category' == $taxonomy ) {
1772 1821
 		$defaults['default'] = get_option( 'default_category' );
1773
-		if ( $defaults['default'] == $term )
1774
-			return 0; // Don't delete the default category
1822
+		if ( $defaults['default'] == $term ) {
1823
+					return 0;
1824
+		}
1825
+		// Don't delete the default category
1775 1826
 	}
1776 1827
 
1777 1828
 	$args = wp_parse_args($args, $defaults);
@@ -1800,8 +1851,9 @@  discard block
 block discarded – undo
1800 1851
 	// Update children to point to new parent
1801 1852
 	if ( is_taxonomy_hierarchical($taxonomy) ) {
1802 1853
 		$term_obj = get_term($term, $taxonomy);
1803
-		if ( is_wp_error( $term_obj ) )
1804
-			return $term_obj;
1854
+		if ( is_wp_error( $term_obj ) ) {
1855
+					return $term_obj;
1856
+		}
1805 1857
 		$parent = $term_obj->parent;
1806 1858
 
1807 1859
 		$edit_ids = $wpdb->get_results( "SELECT term_id, term_taxonomy_id FROM $wpdb->term_taxonomy WHERE `parent` = " . (int)$term_obj->term_id );
@@ -1843,8 +1895,9 @@  discard block
 block discarded – undo
1843 1895
 			$terms = array($default);
1844 1896
 		} else {
1845 1897
 			$terms = array_diff($terms, array($term));
1846
-			if (isset($default) && isset($force_default) && $force_default)
1847
-				$terms = array_merge($terms, array($default));
1898
+			if (isset($default) && isset($force_default) && $force_default) {
1899
+							$terms = array_merge($terms, array($default));
1900
+			}
1848 1901
 		}
1849 1902
 		$terms = array_map('intval', $terms);
1850 1903
 		wp_set_object_terms( $object_id, $terms, $taxonomy );
@@ -1852,8 +1905,9 @@  discard block
 block discarded – undo
1852 1905
 
1853 1906
 	// Clean the relationship caches for all object types using this term.
1854 1907
 	$tax_object = get_taxonomy( $taxonomy );
1855
-	foreach ( $tax_object->object_type as $object_type )
1856
-		clean_object_term_cache( $object_ids, $object_type );
1908
+	foreach ( $tax_object->object_type as $object_type ) {
1909
+			clean_object_term_cache( $object_ids, $object_type );
1910
+	}
1857 1911
 
1858 1912
 	$term_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->termmeta WHERE term_id = %d ", $term ) );
1859 1913
 	foreach ( $term_meta_ids as $mid ) {
@@ -1880,8 +1934,9 @@  discard block
 block discarded – undo
1880 1934
 	do_action( 'deleted_term_taxonomy', $tt_id );
1881 1935
 
1882 1936
 	// Delete the term if no taxonomies use it.
1883
-	if ( !$wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term) ) )
1884
-		$wpdb->delete( $wpdb->terms, array( 'term_id' => $term ) );
1937
+	if ( !$wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term) ) ) {
1938
+			$wpdb->delete( $wpdb->terms, array( 'term_id' => $term ) );
1939
+	}
1885 1940
 
1886 1941
 	clean_term_cache($term, $taxonomy);
1887 1942
 
@@ -1968,19 +2023,23 @@  discard block
 block discarded – undo
1968 2023
 function wp_get_object_terms($object_ids, $taxonomies, $args = array()) {
1969 2024
 	global $wpdb;
1970 2025
 
1971
-	if ( empty( $object_ids ) || empty( $taxonomies ) )
1972
-		return array();
2026
+	if ( empty( $object_ids ) || empty( $taxonomies ) ) {
2027
+			return array();
2028
+	}
1973 2029
 
1974
-	if ( !is_array($taxonomies) )
1975
-		$taxonomies = array($taxonomies);
2030
+	if ( !is_array($taxonomies) ) {
2031
+			$taxonomies = array($taxonomies);
2032
+	}
1976 2033
 
1977 2034
 	foreach ( $taxonomies as $taxonomy ) {
1978
-		if ( ! taxonomy_exists($taxonomy) )
1979
-			return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) );
2035
+		if ( ! taxonomy_exists($taxonomy) ) {
2036
+					return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) );
2037
+		}
1980 2038
 	}
1981 2039
 
1982
-	if ( !is_array($object_ids) )
1983
-		$object_ids = array($object_ids);
2040
+	if ( !is_array($object_ids) ) {
2041
+			$object_ids = array($object_ids);
2042
+	}
1984 2043
 	$object_ids = array_map('intval', $object_ids);
1985 2044
 
1986 2045
 	$defaults = array(
@@ -2004,8 +2063,9 @@  discard block
 block discarded – undo
2004 2063
 		}
2005 2064
 	} else {
2006 2065
 		$t = get_taxonomy($taxonomies[0]);
2007
-		if ( isset($t->args) && is_array($t->args) )
2008
-			$args = array_merge($args, $t->args);
2066
+		if ( isset($t->args) && is_array($t->args) ) {
2067
+					$args = array_merge($args, $t->args);
2068
+		}
2009 2069
 	}
2010 2070
 
2011 2071
 	$orderby = $args['orderby'];
@@ -2026,15 +2086,18 @@  discard block
 block discarded – undo
2026 2086
 	}
2027 2087
 
2028 2088
 	// tt_ids queries can only be none or tr.term_taxonomy_id
2029
-	if ( ('tt_ids' == $fields) && !empty($orderby) )
2030
-		$orderby = 'tr.term_taxonomy_id';
2089
+	if ( ('tt_ids' == $fields) && !empty($orderby) ) {
2090
+			$orderby = 'tr.term_taxonomy_id';
2091
+	}
2031 2092
 
2032
-	if ( !empty($orderby) )
2033
-		$orderby = "ORDER BY $orderby";
2093
+	if ( !empty($orderby) ) {
2094
+			$orderby = "ORDER BY $orderby";
2095
+	}
2034 2096
 
2035 2097
 	$order = strtoupper( $order );
2036
-	if ( '' !== $order && ! in_array( $order, array( 'ASC', 'DESC' ) ) )
2037
-		$order = 'ASC';
2098
+	if ( '' !== $order && ! in_array( $order, array( 'ASC', 'DESC' ) ) ) {
2099
+			$order = 'ASC';
2100
+	}
2038 2101
 
2039 2102
 	$taxonomy_array = $taxonomies;
2040 2103
 	$object_id_array = $object_ids;
@@ -2478,36 +2541,42 @@  discard block
 block discarded – undo
2478 2541
 		return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) );
2479 2542
 	}
2480 2543
 
2481
-	if ( !is_array($terms) )
2482
-		$terms = array($terms);
2544
+	if ( !is_array($terms) ) {
2545
+			$terms = array($terms);
2546
+	}
2483 2547
 
2484
-	if ( ! $append )
2485
-		$old_tt_ids =  wp_get_object_terms($object_id, $taxonomy, array('fields' => 'tt_ids', 'orderby' => 'none'));
2486
-	else
2487
-		$old_tt_ids = array();
2548
+	if ( ! $append ) {
2549
+			$old_tt_ids =  wp_get_object_terms($object_id, $taxonomy, array('fields' => 'tt_ids', 'orderby' => 'none'));
2550
+	} else {
2551
+			$old_tt_ids = array();
2552
+	}
2488 2553
 
2489 2554
 	$tt_ids = array();
2490 2555
 	$term_ids = array();
2491 2556
 	$new_tt_ids = array();
2492 2557
 
2493 2558
 	foreach ( (array) $terms as $term) {
2494
-		if ( !strlen(trim($term)) )
2495
-			continue;
2559
+		if ( !strlen(trim($term)) ) {
2560
+					continue;
2561
+		}
2496 2562
 
2497 2563
 		if ( !$term_info = term_exists($term, $taxonomy) ) {
2498 2564
 			// Skip if a non-existent term ID is passed.
2499
-			if ( is_int($term) )
2500
-				continue;
2565
+			if ( is_int($term) ) {
2566
+							continue;
2567
+			}
2501 2568
 			$term_info = wp_insert_term($term, $taxonomy);
2502 2569
 		}
2503
-		if ( is_wp_error($term_info) )
2504
-			return $term_info;
2570
+		if ( is_wp_error($term_info) ) {
2571
+					return $term_info;
2572
+		}
2505 2573
 		$term_ids[] = $term_info['term_id'];
2506 2574
 		$tt_id = $term_info['term_taxonomy_id'];
2507 2575
 		$tt_ids[] = $tt_id;
2508 2576
 
2509
-		if ( $wpdb->get_var( $wpdb->prepare( "SELECT term_taxonomy_id FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id = %d", $object_id, $tt_id ) ) )
2510
-			continue;
2577
+		if ( $wpdb->get_var( $wpdb->prepare( "SELECT term_taxonomy_id FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id = %d", $object_id, $tt_id ) ) ) {
2578
+					continue;
2579
+		}
2511 2580
 
2512 2581
 		/**
2513 2582
 		 * Fires immediately before an object-term relationship is added.
@@ -2532,8 +2601,9 @@  discard block
 block discarded – undo
2532 2601
 		$new_tt_ids[] = $tt_id;
2533 2602
 	}
2534 2603
 
2535
-	if ( $new_tt_ids )
2536
-		wp_update_term_count( $new_tt_ids, $taxonomy );
2604
+	if ( $new_tt_ids ) {
2605
+			wp_update_term_count( $new_tt_ids, $taxonomy );
2606
+	}
2537 2607
 
2538 2608
 	if ( ! $append ) {
2539 2609
 		$delete_tt_ids = array_diff( $old_tt_ids, $tt_ids );
@@ -2555,12 +2625,14 @@  discard block
 block discarded – undo
2555 2625
 		$values = array();
2556 2626
 		$term_order = 0;
2557 2627
 		$final_tt_ids = wp_get_object_terms($object_id, $taxonomy, array('fields' => 'tt_ids'));
2558
-		foreach ( $tt_ids as $tt_id )
2559
-			if ( in_array($tt_id, $final_tt_ids) )
2628
+		foreach ( $tt_ids as $tt_id ) {
2629
+					if ( in_array($tt_id, $final_tt_ids) )
2560 2630
 				$values[] = $wpdb->prepare( "(%d, %d, %d)", $object_id, $tt_id, ++$term_order);
2561
-		if ( $values )
2562
-			if ( false === $wpdb->query( "INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id, term_order) VALUES " . join( ',', $values ) . " ON DUPLICATE KEY UPDATE term_order = VALUES(term_order)" ) )
2631
+		}
2632
+		if ( $values ) {
2633
+					if ( false === $wpdb->query( "INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id, term_order) VALUES " . join( ',', $values ) . " ON DUPLICATE KEY UPDATE term_order = VALUES(term_order)" ) )
2563 2634
 				return new WP_Error( 'db_insert_error', __( 'Could not insert term relationship into the database' ), $wpdb->last_error );
2635
+		}
2564 2636
 	}
2565 2637
 
2566 2638
 	wp_cache_delete( $object_id, $taxonomy . '_relationships' );
@@ -2718,15 +2790,17 @@  discard block
 block discarded – undo
2718 2790
 		$the_parent = $term->parent;
2719 2791
 		while ( ! empty($the_parent) ) {
2720 2792
 			$parent_term = get_term($the_parent, $term->taxonomy);
2721
-			if ( is_wp_error($parent_term) || empty($parent_term) )
2722
-				break;
2793
+			if ( is_wp_error($parent_term) || empty($parent_term) ) {
2794
+							break;
2795
+			}
2723 2796
 			$parent_suffix .= '-' . $parent_term->slug;
2724 2797
 			if ( ! term_exists( $slug . $parent_suffix ) ) {
2725 2798
 				break;
2726 2799
 			}
2727 2800
 
2728
-			if ( empty($parent_term->parent) )
2729
-				break;
2801
+			if ( empty($parent_term->parent) ) {
2802
+							break;
2803
+			}
2730 2804
 			$the_parent = $parent_term->parent;
2731 2805
 		}
2732 2806
 	}
@@ -2746,10 +2820,11 @@  discard block
 block discarded – undo
2746 2820
 		if ( $parent_suffix ) {
2747 2821
 			$slug .= $parent_suffix;
2748 2822
 		} else {
2749
-			if ( ! empty( $term->term_id ) )
2750
-				$query = $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s AND term_id != %d", $slug, $term->term_id );
2751
-			else
2752
-				$query = $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s", $slug );
2823
+			if ( ! empty( $term->term_id ) ) {
2824
+							$query = $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s AND term_id != %d", $slug, $term->term_id );
2825
+			} else {
2826
+							$query = $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s", $slug );
2827
+			}
2753 2828
 
2754 2829
 			if ( $wpdb->get_var( $query ) ) {
2755 2830
 				$num = 2;
@@ -2904,10 +2979,11 @@  discard block
 block discarded – undo
2904 2979
 	if ( $duplicate && $duplicate->term_id != $term_id ) {
2905 2980
 		// If an empty slug was passed or the parent changed, reset the slug to something unique.
2906 2981
 		// Otherwise, bail.
2907
-		if ( $empty_slug || ( $parent != $term['parent']) )
2908
-			$slug = wp_unique_term_slug($slug, (object) $args);
2909
-		else
2910
-			return new WP_Error('duplicate_term_slug', sprintf(__('The slug &#8220;%s&#8221; is already in use by another term'), $slug));
2982
+		if ( $empty_slug || ( $parent != $term['parent']) ) {
2983
+					$slug = wp_unique_term_slug($slug, (object) $args);
2984
+		} else {
2985
+					return new WP_Error('duplicate_term_slug', sprintf(__('The slug &#8220;%s&#8221; is already in use by another term'), $slug));
2986
+		}
2911 2987
 	}
2912 2988
 
2913 2989
 	$tt_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT tt.term_taxonomy_id FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.term_id = %d", $taxonomy, $term_id) );
@@ -3037,8 +3113,9 @@  discard block
 block discarded – undo
3037 3113
 	if ( is_bool($defer) ) {
3038 3114
 		$_defer = $defer;
3039 3115
 		// flush any deferred counts
3040
-		if ( !$defer )
3041
-			wp_update_term_count( null, null, true );
3116
+		if ( !$defer ) {
3117
+					wp_update_term_count( null, null, true );
3118
+		}
3042 3119
 	}
3043 3120
 
3044 3121
 	return $_defer;
@@ -3072,15 +3149,18 @@  discard block
 block discarded – undo
3072 3149
 		}
3073 3150
 	}
3074 3151
 
3075
-	if ( empty($terms) )
3076
-		return false;
3152
+	if ( empty($terms) ) {
3153
+			return false;
3154
+	}
3077 3155
 
3078
-	if ( !is_array($terms) )
3079
-		$terms = array($terms);
3156
+	if ( !is_array($terms) ) {
3157
+			$terms = array($terms);
3158
+	}
3080 3159
 
3081 3160
 	if ( wp_defer_term_counting() ) {
3082
-		if ( !isset($_deferred[$taxonomy]) )
3083
-			$_deferred[$taxonomy] = array();
3161
+		if ( !isset($_deferred[$taxonomy]) ) {
3162
+					$_deferred[$taxonomy] = array();
3163
+		}
3084 3164
 		$_deferred[$taxonomy] = array_unique( array_merge($_deferred[$taxonomy], $terms) );
3085 3165
 		return true;
3086 3166
 	}
@@ -3106,8 +3186,9 @@  discard block
 block discarded – undo
3106 3186
 	} else {
3107 3187
 		$object_types = (array) $taxonomy->object_type;
3108 3188
 		foreach ( $object_types as &$object_type ) {
3109
-			if ( 0 === strpos( $object_type, 'attachment:' ) )
3110
-				list( $object_type ) = explode( ':', $object_type );
3189
+			if ( 0 === strpos( $object_type, 'attachment:' ) ) {
3190
+							list( $object_type ) = explode( ':', $object_type );
3191
+			}
3111 3192
 		}
3112 3193
 
3113 3194
 		if ( $object_types == array_filter( $object_types, 'post_type_exists' ) ) {
@@ -3151,8 +3232,9 @@  discard block
 block discarded – undo
3151 3232
 		return;
3152 3233
 	}
3153 3234
 
3154
-	if ( !is_array($object_ids) )
3155
-		$object_ids = array($object_ids);
3235
+	if ( !is_array($object_ids) ) {
3236
+			$object_ids = array($object_ids);
3237
+	}
3156 3238
 
3157 3239
 	$taxonomies = get_object_taxonomies( $object_type );
3158 3240
 
@@ -3194,8 +3276,9 @@  discard block
 block discarded – undo
3194 3276
 		return;
3195 3277
 	}
3196 3278
 
3197
-	if ( !is_array($ids) )
3198
-		$ids = array($ids);
3279
+	if ( !is_array($ids) ) {
3280
+			$ids = array($ids);
3281
+	}
3199 3282
 
3200 3283
 	$taxonomies = array();
3201 3284
 	// If no taxonomy, assume tt_ids.
@@ -3303,11 +3386,13 @@  discard block
 block discarded – undo
3303 3386
  * @return void|false False if all of the terms in `$object_ids` are already cached.
3304 3387
  */
3305 3388
 function update_object_term_cache($object_ids, $object_type) {
3306
-	if ( empty($object_ids) )
3307
-		return;
3389
+	if ( empty($object_ids) ) {
3390
+			return;
3391
+	}
3308 3392
 
3309
-	if ( !is_array($object_ids) )
3310
-		$object_ids = explode(',', $object_ids);
3393
+	if ( !is_array($object_ids) ) {
3394
+			$object_ids = explode(',', $object_ids);
3395
+	}
3311 3396
 
3312 3397
 	$object_ids = array_map('intval', $object_ids);
3313 3398
 
@@ -3323,8 +3408,9 @@  discard block
 block discarded – undo
3323 3408
 		}
3324 3409
 	}
3325 3410
 
3326
-	if ( empty( $ids ) )
3327
-		return false;
3411
+	if ( empty( $ids ) ) {
3412
+			return false;
3413
+	}
3328 3414
 
3329 3415
 	$terms = wp_get_object_terms( $ids, $taxonomies, array(
3330 3416
 		'fields' => 'all_with_object_id',
@@ -3340,8 +3426,9 @@  discard block
 block discarded – undo
3340 3426
 	foreach ( $ids as $id ) {
3341 3427
 		foreach ( $taxonomies as $taxonomy ) {
3342 3428
 			if ( ! isset($object_terms[$id][$taxonomy]) ) {
3343
-				if ( !isset($object_terms[$id]) )
3344
-					$object_terms[$id] = array();
3429
+				if ( !isset($object_terms[$id]) ) {
3430
+									$object_terms[$id] = array();
3431
+				}
3345 3432
 				$object_terms[$id][$taxonomy] = array();
3346 3433
 			}
3347 3434
 		}
@@ -3388,17 +3475,20 @@  discard block
 block discarded – undo
3388 3475
  * @return array Empty if $taxonomy isn't hierarchical or returns children as Term IDs.
3389 3476
  */
3390 3477
 function _get_term_hierarchy( $taxonomy ) {
3391
-	if ( !is_taxonomy_hierarchical($taxonomy) )
3392
-		return array();
3478
+	if ( !is_taxonomy_hierarchical($taxonomy) ) {
3479
+			return array();
3480
+	}
3393 3481
 	$children = get_option("{$taxonomy}_children");
3394 3482
 
3395
-	if ( is_array($children) )
3396
-		return $children;
3483
+	if ( is_array($children) ) {
3484
+			return $children;
3485
+	}
3397 3486
 	$children = array();
3398 3487
 	$terms = get_terms($taxonomy, array('get' => 'all', 'orderby' => 'id', 'fields' => 'id=>parent'));
3399 3488
 	foreach ( $terms as $term_id => $parent ) {
3400
-		if ( $parent > 0 )
3401
-			$children[$parent][] = $term_id;
3489
+		if ( $parent > 0 ) {
3490
+					$children[$parent][] = $term_id;
3491
+		}
3402 3492
 	}
3403 3493
 	update_option("{$taxonomy}_children", $children);
3404 3494
 
@@ -3426,14 +3516,16 @@  discard block
 block discarded – undo
3426 3516
  */
3427 3517
 function _get_term_children( $term_id, $terms, $taxonomy, &$ancestors = array() ) {
3428 3518
 	$empty_array = array();
3429
-	if ( empty($terms) )
3430
-		return $empty_array;
3519
+	if ( empty($terms) ) {
3520
+			return $empty_array;
3521
+	}
3431 3522
 
3432 3523
 	$term_list = array();
3433 3524
 	$has_children = _get_term_hierarchy($taxonomy);
3434 3525
 
3435
-	if  ( ( 0 != $term_id ) && ! isset($has_children[$term_id]) )
3436
-		return $empty_array;
3526
+	if  ( ( 0 != $term_id ) && ! isset($has_children[$term_id]) ) {
3527
+			return $empty_array;
3528
+	}
3437 3529
 
3438 3530
 	// Include the term itself in the ancestors array, so we can properly detect when a loop has occurred.
3439 3531
 	if ( empty( $ancestors ) ) {
@@ -3444,8 +3536,9 @@  discard block
 block discarded – undo
3444 3536
 		$use_id = false;
3445 3537
 		if ( !is_object($term) ) {
3446 3538
 			$term = get_term($term, $taxonomy);
3447
-			if ( is_wp_error( $term ) )
3448
-				return $term;
3539
+			if ( is_wp_error( $term ) ) {
3540
+							return $term;
3541
+			}
3449 3542
 			$use_id = true;
3450 3543
 		}
3451 3544
 
@@ -3455,18 +3548,21 @@  discard block
 block discarded – undo
3455 3548
 		}
3456 3549
 
3457 3550
 		if ( $term->parent == $term_id ) {
3458
-			if ( $use_id )
3459
-				$term_list[] = $term->term_id;
3460
-			else
3461
-				$term_list[] = $term;
3551
+			if ( $use_id ) {
3552
+							$term_list[] = $term->term_id;
3553
+			} else {
3554
+							$term_list[] = $term;
3555
+			}
3462 3556
 
3463
-			if ( !isset($has_children[$term->term_id]) )
3464
-				continue;
3557
+			if ( !isset($has_children[$term->term_id]) ) {
3558
+							continue;
3559
+			}
3465 3560
 
3466 3561
 			$ancestors[ $term->term_id ] = 1;
3467 3562
 
3468
-			if ( $children = _get_term_children( $term->term_id, $terms, $taxonomy, $ancestors) )
3469
-				$term_list = array_merge($term_list, $children);
3563
+			if ( $children = _get_term_children( $term->term_id, $terms, $taxonomy, $ancestors) ) {
3564
+							$term_list = array_merge($term_list, $children);
3565
+			}
3470 3566
 		}
3471 3567
 	}
3472 3568
 
@@ -3491,13 +3587,15 @@  discard block
 block discarded – undo
3491 3587
 	global $wpdb;
3492 3588
 
3493 3589
 	// This function only works for hierarchical taxonomies like post categories.
3494
-	if ( !is_taxonomy_hierarchical( $taxonomy ) )
3495
-		return;
3590
+	if ( !is_taxonomy_hierarchical( $taxonomy ) ) {
3591
+			return;
3592
+	}
3496 3593
 
3497 3594
 	$term_hier = _get_term_hierarchy($taxonomy);
3498 3595
 
3499
-	if ( empty($term_hier) )
3500
-		return;
3596
+	if ( empty($term_hier) ) {
3597
+			return;
3598
+	}
3501 3599
 
3502 3600
 	$term_items = array();
3503 3601
 	$terms_by_id = array();
@@ -3523,9 +3621,10 @@  discard block
 block discarded – undo
3523 3621
 		$ancestors = array();
3524 3622
 		while ( !empty( $terms_by_id[$child] ) && $parent = $terms_by_id[$child]->parent ) {
3525 3623
 			$ancestors[] = $child;
3526
-			if ( !empty( $term_items[$term_id] ) )
3527
-				foreach ( $term_items[$term_id] as $item_id => $touches ) {
3624
+			if ( !empty( $term_items[$term_id] ) ) {
3625
+							foreach ( $term_items[$term_id] as $item_id => $touches ) {
3528 3626
 					$term_items[$parent][$item_id] = isset($term_items[$parent][$item_id]) ? ++$term_items[$parent][$item_id]: 1;
3627
+			}
3529 3628
 				}
3530 3629
 			$child = $parent;
3531 3630
 
@@ -3536,10 +3635,11 @@  discard block
 block discarded – undo
3536 3635
 	}
3537 3636
 
3538 3637
 	// Transfer the touched cells.
3539
-	foreach ( (array) $term_items as $id => $items )
3540
-		if ( isset($terms_by_id[$id]) )
3638
+	foreach ( (array) $term_items as $id => $items ) {
3639
+			if ( isset($terms_by_id[$id]) )
3541 3640
 			$terms_by_id[$id]->count = count($items);
3542
-}
3641
+	}
3642
+	}
3543 3643
 
3544 3644
 /**
3545 3645
  * Adds any terms from the given IDs to the cache that do not already exist in cache.
@@ -3590,8 +3690,9 @@  discard block
 block discarded – undo
3590 3690
 
3591 3691
 	$object_types = (array) $taxonomy->object_type;
3592 3692
 
3593
-	foreach ( $object_types as &$object_type )
3594
-		list( $object_type ) = explode( ':', $object_type );
3693
+	foreach ( $object_types as &$object_type ) {
3694
+			list( $object_type ) = explode( ':', $object_type );
3695
+	}
3595 3696
 
3596 3697
 	$object_types = array_unique( $object_types );
3597 3698
 
@@ -3600,18 +3701,21 @@  discard block
 block discarded – undo
3600 3701
 		$check_attachments = true;
3601 3702
 	}
3602 3703
 
3603
-	if ( $object_types )
3604
-		$object_types = esc_sql( array_filter( $object_types, 'post_type_exists' ) );
3704
+	if ( $object_types ) {
3705
+			$object_types = esc_sql( array_filter( $object_types, 'post_type_exists' ) );
3706
+	}
3605 3707
 
3606 3708
 	foreach ( (array) $terms as $term ) {
3607 3709
 		$count = 0;
3608 3710
 
3609 3711
 		// Attachments can be 'inherit' status, we need to base count off the parent's status if so.
3610
-		if ( $check_attachments )
3611
-			$count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts p1 WHERE p1.ID = $wpdb->term_relationships.object_id AND ( post_status = 'publish' OR ( post_status = 'inherit' AND post_parent > 0 AND ( SELECT post_status FROM $wpdb->posts WHERE ID = p1.post_parent ) = 'publish' ) ) AND post_type = 'attachment' AND term_taxonomy_id = %d", $term ) );
3712
+		if ( $check_attachments ) {
3713
+					$count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts p1 WHERE p1.ID = $wpdb->term_relationships.object_id AND ( post_status = 'publish' OR ( post_status = 'inherit' AND post_parent > 0 AND ( SELECT post_status FROM $wpdb->posts WHERE ID = p1.post_parent ) = 'publish' ) ) AND post_type = 'attachment' AND term_taxonomy_id = %d", $term ) );
3714
+		}
3612 3715
 
3613
-		if ( $object_types )
3614
-			$count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type IN ('" . implode("', '", $object_types ) . "') AND term_taxonomy_id = %d", $term ) );
3716
+		if ( $object_types ) {
3717
+					$count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type IN ('" . implode("', '", $object_types ) . "') AND term_taxonomy_id = %d", $term ) );
3718
+		}
3615 3719
 
3616 3720
 		/** This action is documented in wp-includes/taxonomy.php */
3617 3721
 		do_action( 'edit_term_taxonomy', $term, $taxonomy->name );
@@ -4066,11 +4170,13 @@  discard block
 block discarded – undo
4066 4170
 		}
4067 4171
 	}
4068 4172
 
4069
-	if ( !is_object($term) )
4070
-		$term = new WP_Error('invalid_term', __('Empty Term'));
4173
+	if ( !is_object($term) ) {
4174
+			$term = new WP_Error('invalid_term', __('Empty Term'));
4175
+	}
4071 4176
 
4072
-	if ( is_wp_error( $term ) )
4073
-		return $term;
4177
+	if ( is_wp_error( $term ) ) {
4178
+			return $term;
4179
+	}
4074 4180
 
4075 4181
 	$taxonomy = $term->taxonomy;
4076 4182
 
@@ -4080,12 +4186,13 @@  discard block
 block discarded – undo
4080 4186
 	$t = get_taxonomy($taxonomy);
4081 4187
 
4082 4188
 	if ( empty($termlink) ) {
4083
-		if ( 'category' == $taxonomy )
4084
-			$termlink = '?cat=' . $term->term_id;
4085
-		elseif ( $t->query_var )
4086
-			$termlink = "?$t->query_var=$slug";
4087
-		else
4088
-			$termlink = "?taxonomy=$taxonomy&term=$slug";
4189
+		if ( 'category' == $taxonomy ) {
4190
+					$termlink = '?cat=' . $term->term_id;
4191
+		} elseif ( $t->query_var ) {
4192
+					$termlink = "?$t->query_var=$slug";
4193
+		} else {
4194
+					$termlink = "?taxonomy=$taxonomy&term=$slug";
4195
+		}
4089 4196
 		$termlink = home_url($termlink);
4090 4197
 	} else {
4091 4198
 		if ( $t->rewrite['hierarchical'] ) {
@@ -4268,8 +4375,9 @@  discard block
 block discarded – undo
4268 4375
  * @return bool|WP_Error WP_Error on input error.
4269 4376
  */
4270 4377
 function is_object_in_term( $object_id, $taxonomy, $terms = null ) {
4271
-	if ( !$object_id = (int) $object_id )
4272
-		return new WP_Error( 'invalid_object', __( 'Invalid object ID' ) );
4378
+	if ( !$object_id = (int) $object_id ) {
4379
+			return new WP_Error( 'invalid_object', __( 'Invalid object ID' ) );
4380
+	}
4273 4381
 
4274 4382
 	$object_terms = get_object_term_cache( $object_id, $taxonomy );
4275 4383
 	if ( false === $object_terms ) {
@@ -4277,19 +4385,23 @@  discard block
 block discarded – undo
4277 4385
 		wp_cache_set( $object_id, wp_list_pluck( $object_terms, 'term_id' ), "{$taxonomy}_relationships" );
4278 4386
 	}
4279 4387
 
4280
-	if ( is_wp_error( $object_terms ) )
4281
-		return $object_terms;
4282
-	if ( empty( $object_terms ) )
4283
-		return false;
4284
-	if ( empty( $terms ) )
4285
-		return ( !empty( $object_terms ) );
4388
+	if ( is_wp_error( $object_terms ) ) {
4389
+			return $object_terms;
4390
+	}
4391
+	if ( empty( $object_terms ) ) {
4392
+			return false;
4393
+	}
4394
+	if ( empty( $terms ) ) {
4395
+			return ( !empty( $object_terms ) );
4396
+	}
4286 4397
 
4287 4398
 	$terms = (array) $terms;
4288 4399
 
4289
-	if ( $ints = array_filter( $terms, 'is_int' ) )
4290
-		$strs = array_diff( $terms, $ints );
4291
-	else
4292
-		$strs =& $terms;
4400
+	if ( $ints = array_filter( $terms, 'is_int' ) ) {
4401
+			$strs = array_diff( $terms, $ints );
4402
+	} else {
4403
+			$strs =& $terms;
4404
+	}
4293 4405
 
4294 4406
 	foreach ( $object_terms as $object_term ) {
4295 4407
 		// If term is an int, check against term_ids only.
@@ -4304,8 +4416,12 @@  discard block
 block discarded – undo
4304 4416
 				return true;
4305 4417
 			}
4306 4418
 
4307
-			if ( in_array( $object_term->name, $strs ) ) return true;
4308
-			if ( in_array( $object_term->slug, $strs ) ) return true;
4419
+			if ( in_array( $object_term->name, $strs ) ) {
4420
+				return true;
4421
+			}
4422
+			if ( in_array( $object_term->slug, $strs ) ) {
4423
+				return true;
4424
+			}
4309 4425
 		}
4310 4426
 	}
4311 4427
 
@@ -4418,24 +4534,30 @@  discard block
 block discarded – undo
4418 4534
  */
4419 4535
 function wp_check_term_hierarchy_for_loops( $parent, $term_id, $taxonomy ) {
4420 4536
 	// Nothing fancy here - bail
4421
-	if ( !$parent )
4422
-		return 0;
4537
+	if ( !$parent ) {
4538
+			return 0;
4539
+	}
4423 4540
 
4424 4541
 	// Can't be its own parent.
4425
-	if ( $parent == $term_id )
4426
-		return 0;
4542
+	if ( $parent == $term_id ) {
4543
+			return 0;
4544
+	}
4427 4545
 
4428 4546
 	// Now look for larger loops.
4429
-	if ( !$loop = wp_find_hierarchy_loop( 'wp_get_term_taxonomy_parent_id', $term_id, $parent, array( $taxonomy ) ) )
4430
-		return $parent; // No loop
4547
+	if ( !$loop = wp_find_hierarchy_loop( 'wp_get_term_taxonomy_parent_id', $term_id, $parent, array( $taxonomy ) ) ) {
4548
+			return $parent;
4549
+	}
4550
+	// No loop
4431 4551
 
4432 4552
 	// Setting $parent to the given value causes a loop.
4433
-	if ( isset( $loop[$term_id] ) )
4434
-		return 0;
4553
+	if ( isset( $loop[$term_id] ) ) {
4554
+			return 0;
4555
+	}
4435 4556
 
4436 4557
 	// There's a loop, but it doesn't contain $term_id. Break the loop.
4437
-	foreach ( array_keys( $loop ) as $loop_member )
4438
-		wp_update_term( $loop_member, $taxonomy, array( 'parent' => 0 ) );
4558
+	foreach ( array_keys( $loop ) as $loop_member ) {
4559
+			wp_update_term( $loop_member, $taxonomy, array( 'parent' => 0 ) );
4560
+	}
4439 4561
 
4440 4562
 	return $parent;
4441 4563
 }
Please login to merge, or discard this patch.
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.