Completed
Push — master ( c0c536...fdb3a7 )
by Stephen
20:33
created
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/SimplePie/Sanitize.php 3 patches
Doc Comments   +15 added lines patch added patch discarded remove patch
@@ -222,6 +222,9 @@  discard block
 block discarded – undo
222 222
 		$this->replace_url_attributes = (array) $element_attribute;
223 223
 	}
224 224
 
225
+	/**
226
+	 * @param string $data
227
+	 */
225 228
 	public function sanitize($data, $type, $base = '')
226 229
 	{
227 230
 		$data = trim($data);
@@ -381,6 +384,9 @@  discard block
 block discarded – undo
381 384
 		return $data;
382 385
 	}
383 386
 
387
+	/**
388
+	 * @param string $html
389
+	 */
384 390
 	protected function preprocess($html, $type)
385 391
 	{
386 392
 		$ret = '';
@@ -404,6 +410,9 @@  discard block
 block discarded – undo
404 410
 		return $ret;
405 411
 	}
406 412
 
413
+	/**
414
+	 * @param DOMDocument $document
415
+	 */
407 416
 	public function replace_urls($document, $tag, $attributes)
408 417
 	{
409 418
 		if (!is_array($attributes))
@@ -456,6 +465,9 @@  discard block
 block discarded – undo
456 465
 		}
457 466
 	}
458 467
 
468
+	/**
469
+	 * @param DOMDocument $document
470
+	 */
459 471
 	protected function strip_tag($tag, $document, $type)
460 472
 	{
461 473
 		$xpath = new DOMXPath($document);
@@ -541,6 +553,9 @@  discard block
 block discarded – undo
541 553
 		}
542 554
 	}
543 555
 
556
+	/**
557
+	 * @param DOMDocument $document
558
+	 */
544 559
 	protected function strip_attr($attrib, $document)
545 560
 	{
546 561
 		$xpath = new DOMXPath($document);
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 		{
230 230
 			if ($type & SIMPLEPIE_CONSTRUCT_MAYBE_HTML)
231 231
 			{
232
-				if (preg_match('/(&(#(x[0-9a-fA-F]+|[0-9]+)|[a-zA-Z0-9]+)|<\/[A-Za-z][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E]*' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>)/', $data))
232
+				if (preg_match('/(&(#(x[0-9a-fA-F]+|[0-9]+)|[a-zA-Z0-9]+)|<\/[A-Za-z][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E]*'.SIMPLEPIE_PCRE_HTML_ATTRIBUTE.'>)/', $data))
233 233
 				{
234 234
 					$type |= SIMPLEPIE_CONSTRUCT_HTML;
235 235
 				}
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 			if ($type & (SIMPLEPIE_CONSTRUCT_HTML | SIMPLEPIE_CONSTRUCT_XHTML))
248 248
 			{
249 249
 
250
-				if (!class_exists('DOMDocument'))
250
+				if ( ! class_exists('DOMDocument'))
251 251
 				{
252 252
 					$this->registry->call('Misc', 'error', array('DOMDocument not found, unable to use sanitizer', E_USER_WARNING, __FILE__, __LINE__));
253 253
 					return '';
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 
312 312
 							if ($cache->load())
313 313
 							{
314
-								$img->setAttribute('src', $this->image_handler . $image_url);
314
+								$img->setAttribute('src', $this->image_handler.$image_url);
315 315
 							}
316 316
 							else
317 317
 							{
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 								{
323 323
 									if ($cache->save(array('headers' => $file->headers, 'body' => $file->body)))
324 324
 									{
325
-										$img->setAttribute('src', $this->image_handler . $image_url);
325
+										$img->setAttribute('src', $this->image_handler.$image_url);
326 326
 									}
327 327
 									else
328 328
 									{
@@ -350,12 +350,12 @@  discard block
 block discarded – undo
350 350
 
351 351
 				if ($this->remove_div)
352 352
 				{
353
-					$data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '', $data);
353
+					$data = preg_replace('/^<div'.SIMPLEPIE_PCRE_XML_ATTRIBUTE.'>/', '', $data);
354 354
 					$data = preg_replace('/<\/div>$/', '', $data);
355 355
 				}
356 356
 				else
357 357
 				{
358
-					$data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '<div>', $data);
358
+					$data = preg_replace('/^<div'.SIMPLEPIE_PCRE_XML_ATTRIBUTE.'>/', '<div>', $data);
359 359
 				}
360 360
 			}
361 361
 
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 		{
389 389
 			// Atom XHTML constructs are wrapped with a div by default
390 390
 			// Note: No protection if $html contains a stray </div>!
391
-			$html = '<div>' . $html . '</div>';
391
+			$html = '<div>'.$html.'</div>';
392 392
 			$ret .= '<!DOCTYPE html>';
393 393
 			$content_type = 'text/html';
394 394
 		}
@@ -399,19 +399,19 @@  discard block
 block discarded – undo
399 399
 		}
400 400
 
401 401
 		$ret .= '<html><head>';
402
-		$ret .= '<meta http-equiv="Content-Type" content="' . $content_type . '; charset=utf-8" />';
403
-		$ret .= '</head><body>' . $html . '</body></html>';
402
+		$ret .= '<meta http-equiv="Content-Type" content="'.$content_type.'; charset=utf-8" />';
403
+		$ret .= '</head><body>'.$html.'</body></html>';
404 404
 		return $ret;
405 405
 	}
406 406
 
407 407
 	public function replace_urls($document, $tag, $attributes)
408 408
 	{
409
-		if (!is_array($attributes))
409
+		if ( ! is_array($attributes))
410 410
 		{
411 411
 			$attributes = array($attributes);
412 412
 		}
413 413
 
414
-		if (!is_array($this->strip_htmltags) || !in_array($tag, $this->strip_htmltags))
414
+		if ( ! is_array($this->strip_htmltags) || ! in_array($tag, $this->strip_htmltags))
415 415
 		{
416 416
 			$elements = $document->getElementsByTagName($tag);
417 417
 			foreach ($elements as $element)
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 	{
436 436
 		if ($this->encode_instead_of_strip)
437 437
 		{
438
-			if (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style')))
438
+			if (isset($match[4]) && ! in_array(strtolower($match[1]), array('script', 'style')))
439 439
 			{
440 440
 				$match[1] = htmlspecialchars($match[1], ENT_COMPAT, 'UTF-8');
441 441
 				$match[2] = htmlspecialchars($match[2], ENT_COMPAT, 'UTF-8');
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
 				return htmlspecialchars($match[0], ENT_COMPAT, 'UTF-8');
447 447
 			}
448 448
 		}
449
-		elseif (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style')))
449
+		elseif (isset($match[4]) && ! in_array(strtolower($match[1]), array('script', 'style')))
450 450
 		{
451 451
 			return $match[4];
452 452
 		}
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 	protected function strip_tag($tag, $document, $type)
460 460
 	{
461 461
 		$xpath = new DOMXPath($document);
462
-		$elements = $xpath->query('body//' . $tag);
462
+		$elements = $xpath->query('body//'.$tag);
463 463
 		if ($this->encode_instead_of_strip)
464 464
 		{
465 465
 			foreach ($elements as $element)
@@ -467,9 +467,9 @@  discard block
 block discarded – undo
467 467
 				$fragment = $document->createDocumentFragment();
468 468
 
469 469
 				// For elements which aren't script or style, include the tag itself
470
-				if (!in_array($tag, array('script', 'style')))
470
+				if ( ! in_array($tag, array('script', 'style')))
471 471
 				{
472
-					$text = '<' . $tag;
472
+					$text = '<'.$tag;
473 473
 					if ($element->hasAttributes())
474 474
 					{
475 475
 						$attrs = array();
@@ -490,9 +490,9 @@  discard block
 block discarded – undo
490 490
 							}
491 491
 
492 492
 							// Standard attribute text
493
-							$attrs[] = $name . '="' . $attr->value . '"';
493
+							$attrs[] = $name.'="'.$attr->value.'"';
494 494
 						}
495
-						$text .= ' ' . implode(' ', $attrs);
495
+						$text .= ' '.implode(' ', $attrs);
496 496
 					}
497 497
 					$text .= '>';
498 498
 					$fragment->appendChild(new DOMText($text));
@@ -505,9 +505,9 @@  discard block
 block discarded – undo
505 505
 					$fragment->appendChild($child);
506 506
 				}
507 507
 
508
-				if (!in_array($tag, array('script', 'style')))
508
+				if ( ! in_array($tag, array('script', 'style')))
509 509
 				{
510
-					$fragment->appendChild(new DOMText('</' . $tag . '>'));
510
+					$fragment->appendChild(new DOMText('</'.$tag.'>'));
511 511
 				}
512 512
 
513 513
 				$element->parentNode->replaceChild($fragment, $element);
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 	protected function strip_attr($attrib, $document)
545 545
 	{
546 546
 		$xpath = new DOMXPath($document);
547
-		$elements = $xpath->query('//*[@' . $attrib . ']');
547
+		$elements = $xpath->query('//*[@'.$attrib.']');
548 548
 
549 549
 		foreach ($elements as $element)
550 550
 		{
Please login to merge, or discard this patch.
Braces   +15 added lines, -30 removed lines patch added patch discarded remove patch
@@ -88,8 +88,7 @@  discard block
 block discarded – undo
88 88
 		if ($page)
89 89
 		{
90 90
 			$this->image_handler = (string) $page;
91
-		}
92
-		else
91
+		} else
93 92
 		{
94 93
 			$this->image_handler = false;
95 94
 		}
@@ -143,13 +142,11 @@  discard block
 block discarded – undo
143 142
 			if (is_array($tags))
144 143
 			{
145 144
 				$this->strip_htmltags = $tags;
146
-			}
147
-			else
145
+			} else
148 146
 			{
149 147
 				$this->strip_htmltags = explode(',', $tags);
150 148
 			}
151
-		}
152
-		else
149
+		} else
153 150
 		{
154 151
 			$this->strip_htmltags = false;
155 152
 		}
@@ -167,13 +164,11 @@  discard block
 block discarded – undo
167 164
 			if (is_array($attribs))
168 165
 			{
169 166
 				$this->strip_attributes = $attribs;
170
-			}
171
-			else
167
+			} else
172 168
 			{
173 169
 				$this->strip_attributes = explode(',', $attribs);
174 170
 			}
175
-		}
176
-		else
171
+		} else
177 172
 		{
178 173
 			$this->strip_attributes = false;
179 174
 		}
@@ -232,8 +227,7 @@  discard block
 block discarded – undo
232 227
 				if (preg_match('/(&(#(x[0-9a-fA-F]+|[0-9]+)|[a-zA-Z0-9]+)|<\/[A-Za-z][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E]*' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>)/', $data))
233 228
 				{
234 229
 					$type |= SIMPLEPIE_CONSTRUCT_HTML;
235
-				}
236
-				else
230
+				} else
237 231
 				{
238 232
 					$type |= SIMPLEPIE_CONSTRUCT_TEXT;
239 233
 				}
@@ -312,8 +306,7 @@  discard block
 block discarded – undo
312 306
 							if ($cache->load())
313 307
 							{
314 308
 								$img->setAttribute('src', $this->image_handler . $image_url);
315
-							}
316
-							else
309
+							} else
317 310
 							{
318 311
 								$file = $this->registry->create('File', array($img->getAttribute('src'), $this->timeout, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen));
319 312
 								$headers = $file->headers;
@@ -323,8 +316,7 @@  discard block
 block discarded – undo
323 316
 									if ($cache->save(array('headers' => $file->headers, 'body' => $file->body)))
324 317
 									{
325 318
 										$img->setAttribute('src', $this->image_handler . $image_url);
326
-									}
327
-									else
319
+									} else
328 320
 									{
329 321
 										trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);
330 322
 									}
@@ -352,8 +344,7 @@  discard block
 block discarded – undo
352 344
 				{
353 345
 					$data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '', $data);
354 346
 					$data = preg_replace('/<\/div>$/', '', $data);
355
-				}
356
-				else
347
+				} else
357 348
 				{
358 349
 					$data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '<div>', $data);
359 350
 				}
@@ -391,8 +382,7 @@  discard block
 block discarded – undo
391 382
 			$html = '<div>' . $html . '</div>';
392 383
 			$ret .= '<!DOCTYPE html>';
393 384
 			$content_type = 'text/html';
394
-		}
395
-		else
385
+		} else
396 386
 		{
397 387
 			$ret .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
398 388
 			$content_type = 'application/xhtml+xml';
@@ -440,17 +430,14 @@  discard block
 block discarded – undo
440 430
 				$match[1] = htmlspecialchars($match[1], ENT_COMPAT, 'UTF-8');
441 431
 				$match[2] = htmlspecialchars($match[2], ENT_COMPAT, 'UTF-8');
442 432
 				return "&lt;$match[1]$match[2]&gt;$match[3]&lt;/$match[1]&gt;";
443
-			}
444
-			else
433
+			} else
445 434
 			{
446 435
 				return htmlspecialchars($match[0], ENT_COMPAT, 'UTF-8');
447 436
 			}
448
-		}
449
-		elseif (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style')))
437
+		} elseif (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style')))
450 438
 		{
451 439
 			return $match[4];
452
-		}
453
-		else
440
+		} else
454 441
 		{
455 442
 			return '';
456 443
 		}
@@ -514,8 +501,7 @@  discard block
 block discarded – undo
514 501
 			}
515 502
 
516 503
 			return;
517
-		}
518
-		elseif (in_array($tag, array('script', 'style')))
504
+		} elseif (in_array($tag, array('script', 'style')))
519 505
 		{
520 506
 			foreach ($elements as $element)
521 507
 			{
@@ -523,8 +509,7 @@  discard block
 block discarded – undo
523 509
 			}
524 510
 
525 511
 			return;
526
-		}
527
-		else
512
+		} else
528 513
 		{
529 514
 			foreach ($elements as $element)
530 515
 			{
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   +893 added lines, -893 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' );
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');
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 metabox
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 metabox.
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,25 +987,25 @@  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) )
990
+function get_term_children($term_id, $taxonomy) {
991
+	if ( ! taxonomy_exists($taxonomy))
992 992
 		return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
993 993
 
994
-	$term_id = intval( $term_id );
994
+	$term_id = intval($term_id);
995 995
 
996 996
 	$terms = _get_term_hierarchy($taxonomy);
997 997
 
998
-	if ( ! isset($terms[$term_id]) )
998
+	if ( ! isset($terms[$term_id]))
999 999
 		return array();
1000 1000
 
1001 1001
 	$children = $terms[$term_id];
1002 1002
 
1003
-	foreach ( (array) $terms[$term_id] as $child ) {
1004
-		if ( $term_id == $child ) {
1003
+	foreach ((array) $terms[$term_id] as $child) {
1004
+		if ($term_id == $child) {
1005 1005
 			continue;
1006 1006
 		}
1007 1007
 
1008
-		if ( isset($terms[$child]) )
1008
+		if (isset($terms[$child]))
1009 1009
 			$children = array_merge($children, get_term_children($child, $taxonomy));
1010 1010
 	}
1011 1011
 
@@ -1028,18 +1028,18 @@  discard block
 block discarded – undo
1028 1028
  * @param string      $context  Optional, default is display. Look at sanitize_term_field() for available options.
1029 1029
  * @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.
1030 1030
  */
1031
-function get_term_field( $field, $term, $taxonomy = '', $context = 'display' ) {
1032
-	$term = get_term( $term, $taxonomy );
1033
-	if ( is_wp_error($term) )
1031
+function get_term_field($field, $term, $taxonomy = '', $context = 'display') {
1032
+	$term = get_term($term, $taxonomy);
1033
+	if (is_wp_error($term))
1034 1034
 		return $term;
1035 1035
 
1036
-	if ( !is_object($term) )
1036
+	if ( ! is_object($term))
1037 1037
 		return '';
1038 1038
 
1039
-	if ( !isset($term->$field) )
1039
+	if ( ! isset($term->$field))
1040 1040
 		return '';
1041 1041
 
1042
-	return sanitize_term_field( $field, $term->$field, $term->term_id, $term->taxonomy, $context );
1042
+	return sanitize_term_field($field, $term->$field, $term->term_id, $term->taxonomy, $context);
1043 1043
 }
1044 1044
 
1045 1045
 /**
@@ -1054,13 +1054,13 @@  discard block
 block discarded – undo
1054 1054
  * @param string     $taxonomy Taxonomy name.
1055 1055
  * @return string|int|null|WP_Error Will return empty string if $term is not an object.
1056 1056
  */
1057
-function get_term_to_edit( $id, $taxonomy ) {
1058
-	$term = get_term( $id, $taxonomy );
1057
+function get_term_to_edit($id, $taxonomy) {
1058
+	$term = get_term($id, $taxonomy);
1059 1059
 
1060
-	if ( is_wp_error($term) )
1060
+	if (is_wp_error($term))
1061 1061
 		return $term;
1062 1062
 
1063
-	if ( !is_object($term) )
1063
+	if ( ! is_object($term))
1064 1064
 		return '';
1065 1065
 
1066 1066
 	return sanitize_term($term, $taxonomy, 'edit');
@@ -1178,7 +1178,7 @@  discard block
 block discarded – undo
1178 1178
  * @return array|int|WP_Error List of WP_Term instances and their children. Will return WP_Error, if any of $taxonomies
1179 1179
  *                            do not exist.
1180 1180
  */
1181
-function get_terms( $args = array(), $deprecated = '' ) {
1181
+function get_terms($args = array(), $deprecated = '') {
1182 1182
 	global $wpdb;
1183 1183
 
1184 1184
 	$term_query = new WP_Term_Query();
@@ -1190,33 +1190,33 @@  discard block
 block discarded – undo
1190 1190
 	 * (a) a second non-empty parameter is passed, or
1191 1191
 	 * (b) the first parameter shares no keys with the default array (ie, it's a list of taxonomies)
1192 1192
 	 */
1193
-	$_args = wp_parse_args( $args );
1194
-	$key_intersect  = array_intersect_key( $term_query->query_var_defaults, (array) $_args );
1195
-	$do_legacy_args = $deprecated || empty( $key_intersect );
1193
+	$_args = wp_parse_args($args);
1194
+	$key_intersect  = array_intersect_key($term_query->query_var_defaults, (array) $_args);
1195
+	$do_legacy_args = $deprecated || empty($key_intersect);
1196 1196
 
1197
-	if ( $do_legacy_args ) {
1197
+	if ($do_legacy_args) {
1198 1198
 		$taxonomies = (array) $args;
1199
-		$args = wp_parse_args( $deprecated );
1199
+		$args = wp_parse_args($deprecated);
1200 1200
 		$args['taxonomy'] = $taxonomies;
1201 1201
 	} else {
1202
-		$args = wp_parse_args( $args );
1203
-		if ( isset( $args['taxonomy'] ) && null !== $args['taxonomy'] ) {
1202
+		$args = wp_parse_args($args);
1203
+		if (isset($args['taxonomy']) && null !== $args['taxonomy']) {
1204 1204
 			$args['taxonomy'] = (array) $args['taxonomy'];
1205 1205
 		}
1206 1206
 	}
1207 1207
 
1208
-	if ( ! empty( $args['taxonomy'] ) ) {
1209
-		foreach ( $args['taxonomy'] as $taxonomy ) {
1210
-			if ( ! taxonomy_exists( $taxonomy ) ) {
1211
-				return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy' ) );
1208
+	if ( ! empty($args['taxonomy'])) {
1209
+		foreach ($args['taxonomy'] as $taxonomy) {
1210
+			if ( ! taxonomy_exists($taxonomy)) {
1211
+				return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
1212 1212
 			}
1213 1213
 		}
1214 1214
 	}
1215 1215
 
1216
-	$terms = $term_query->query( $args );
1216
+	$terms = $term_query->query($args);
1217 1217
 
1218 1218
 	// Count queries are not filtered, for legacy reasons.
1219
-	if ( ! is_array( $terms ) ) {
1219
+	if ( ! is_array($terms)) {
1220 1220
 		return $terms;
1221 1221
 	}
1222 1222
 
@@ -1231,7 +1231,7 @@  discard block
 block discarded – undo
1231 1231
 	 * @param array         $args       An array of get_terms() arguments.
1232 1232
 	 * @param WP_Term_Query $term_query The WP_Term_Query object.
1233 1233
 	 */
1234
-	return apply_filters( 'get_terms', $terms, $term_query->query_vars['taxonomy'], $term_query->query_vars, $term_query );
1234
+	return apply_filters('get_terms', $terms, $term_query->query_vars['taxonomy'], $term_query->query_vars, $term_query);
1235 1235
 }
1236 1236
 
1237 1237
 /**
@@ -1247,21 +1247,21 @@  discard block
 block discarded – undo
1247 1247
  * @return int|WP_Error|bool Meta ID on success. WP_Error when term_id is ambiguous between taxonomies.
1248 1248
  *                           False on failure.
1249 1249
  */
1250
-function add_term_meta( $term_id, $meta_key, $meta_value, $unique = false ) {
1250
+function add_term_meta($term_id, $meta_key, $meta_value, $unique = false) {
1251 1251
 	// Bail if term meta table is not installed.
1252
-	if ( get_option( 'db_version' ) < 34370 ) {
1252
+	if (get_option('db_version') < 34370) {
1253 1253
 		return false;
1254 1254
 	}
1255 1255
 
1256
-	if ( wp_term_is_shared( $term_id ) ) {
1257
-		return new WP_Error( 'ambiguous_term_id', __( 'Term meta cannot be added to terms that are shared between taxonomies.'), $term_id );
1256
+	if (wp_term_is_shared($term_id)) {
1257
+		return new WP_Error('ambiguous_term_id', __('Term meta cannot be added to terms that are shared between taxonomies.'), $term_id);
1258 1258
 	}
1259 1259
 
1260
-	$added = add_metadata( 'term', $term_id, $meta_key, $meta_value, $unique );
1260
+	$added = add_metadata('term', $term_id, $meta_key, $meta_value, $unique);
1261 1261
 
1262 1262
 	// Bust term query cache.
1263
-	if ( $added ) {
1264
-		wp_cache_set( 'last_changed', microtime(), 'terms' );
1263
+	if ($added) {
1264
+		wp_cache_set('last_changed', microtime(), 'terms');
1265 1265
 	}
1266 1266
 
1267 1267
 	return $added;
@@ -1277,17 +1277,17 @@  discard block
 block discarded – undo
1277 1277
  * @param mixed  $meta_value Optional. Metadata value. If provided, rows will only be removed that match the value.
1278 1278
  * @return bool True on success, false on failure.
1279 1279
  */
1280
-function delete_term_meta( $term_id, $meta_key, $meta_value = '' ) {
1280
+function delete_term_meta($term_id, $meta_key, $meta_value = '') {
1281 1281
 	// Bail if term meta table is not installed.
1282
-	if ( get_option( 'db_version' ) < 34370 ) {
1282
+	if (get_option('db_version') < 34370) {
1283 1283
 		return false;
1284 1284
 	}
1285 1285
 
1286
-	$deleted = delete_metadata( 'term', $term_id, $meta_key, $meta_value );
1286
+	$deleted = delete_metadata('term', $term_id, $meta_key, $meta_value);
1287 1287
 
1288 1288
 	// Bust term query cache.
1289
-	if ( $deleted ) {
1290
-		wp_cache_set( 'last_changed', microtime(), 'terms' );
1289
+	if ($deleted) {
1290
+		wp_cache_set('last_changed', microtime(), 'terms');
1291 1291
 	}
1292 1292
 
1293 1293
 	return $deleted;
@@ -1304,13 +1304,13 @@  discard block
 block discarded – undo
1304 1304
  *                        `$term_id`/`$key` pair will be returned. Default: false.
1305 1305
  * @return mixed If `$single` is false, an array of metadata values. If `$single` is true, a single metadata value.
1306 1306
  */
1307
-function get_term_meta( $term_id, $key = '', $single = false ) {
1307
+function get_term_meta($term_id, $key = '', $single = false) {
1308 1308
 	// Bail if term meta table is not installed.
1309
-	if ( get_option( 'db_version' ) < 34370 ) {
1309
+	if (get_option('db_version') < 34370) {
1310 1310
 		return false;
1311 1311
 	}
1312 1312
 
1313
-	return get_metadata( 'term', $term_id, $key, $single );
1313
+	return get_metadata('term', $term_id, $key, $single);
1314 1314
 }
1315 1315
 
1316 1316
 /**
@@ -1329,21 +1329,21 @@  discard block
 block discarded – undo
1329 1329
  * @return int|WP_Error|bool Meta ID if the key didn't previously exist. True on successful update.
1330 1330
  *                           WP_Error when term_id is ambiguous between taxonomies. False on failure.
1331 1331
  */
1332
-function update_term_meta( $term_id, $meta_key, $meta_value, $prev_value = '' ) {
1332
+function update_term_meta($term_id, $meta_key, $meta_value, $prev_value = '') {
1333 1333
 	// Bail if term meta table is not installed.
1334
-	if ( get_option( 'db_version' ) < 34370 ) {
1334
+	if (get_option('db_version') < 34370) {
1335 1335
 		return false;
1336 1336
 	}
1337 1337
 
1338
-	if ( wp_term_is_shared( $term_id ) ) {
1339
-		return new WP_Error( 'ambiguous_term_id', __( 'Term meta cannot be added to terms that are shared between taxonomies.'), $term_id );
1338
+	if (wp_term_is_shared($term_id)) {
1339
+		return new WP_Error('ambiguous_term_id', __('Term meta cannot be added to terms that are shared between taxonomies.'), $term_id);
1340 1340
 	}
1341 1341
 
1342
-	$updated = update_metadata( 'term', $term_id, $meta_key, $meta_value, $prev_value );
1342
+	$updated = update_metadata('term', $term_id, $meta_key, $meta_value, $prev_value);
1343 1343
 
1344 1344
 	// Bust term query cache.
1345
-	if ( $updated ) {
1346
-		wp_cache_set( 'last_changed', microtime(), 'terms' );
1345
+	if ($updated) {
1346
+		wp_cache_set('last_changed', microtime(), 'terms');
1347 1347
 	}
1348 1348
 
1349 1349
 	return $updated;
@@ -1360,13 +1360,13 @@  discard block
 block discarded – undo
1360 1360
  * @param array $term_ids List of term IDs.
1361 1361
  * @return array|false Returns false if there is nothing to update. Returns an array of metadata on success.
1362 1362
  */
1363
-function update_termmeta_cache( $term_ids ) {
1363
+function update_termmeta_cache($term_ids) {
1364 1364
 	// Bail if term meta table is not installed.
1365
-	if ( get_option( 'db_version' ) < 34370 ) {
1365
+	if (get_option('db_version') < 34370) {
1366 1366
 		return;
1367 1367
 	}
1368 1368
 
1369
-	return update_meta_cache( 'term', $term_ids );
1369
+	return update_meta_cache('term', $term_ids);
1370 1370
 }
1371 1371
 
1372 1372
 /**
@@ -1386,24 +1386,24 @@  discard block
 block discarded – undo
1386 1386
  *               an array of the term ID and the term taxonomy ID the taxonomy
1387 1387
  *               is specified and the pairing exists.
1388 1388
  */
1389
-function term_exists( $term, $taxonomy = '', $parent = null ) {
1389
+function term_exists($term, $taxonomy = '', $parent = null) {
1390 1390
 	global $wpdb;
1391 1391
 
1392 1392
 	$select = "SELECT term_id FROM $wpdb->terms as t WHERE ";
1393 1393
 	$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 ";
1394 1394
 
1395
-	if ( is_int($term) ) {
1396
-		if ( 0 == $term )
1395
+	if (is_int($term)) {
1396
+		if (0 == $term)
1397 1397
 			return 0;
1398 1398
 		$where = 't.term_id = %d';
1399
-		if ( !empty($taxonomy) )
1400
-			return $wpdb->get_row( $wpdb->prepare( $tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy ), ARRAY_A );
1399
+		if ( ! empty($taxonomy))
1400
+			return $wpdb->get_row($wpdb->prepare($tax_select.$where." AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1401 1401
 		else
1402
-			return $wpdb->get_var( $wpdb->prepare( $select . $where, $term ) );
1402
+			return $wpdb->get_var($wpdb->prepare($select.$where, $term));
1403 1403
 	}
1404 1404
 
1405
-	$term = trim( wp_unslash( $term ) );
1406
-	$slug = sanitize_title( $term );
1405
+	$term = trim(wp_unslash($term));
1406
+	$slug = sanitize_title($term);
1407 1407
 
1408 1408
 	$where = 't.slug = %s';
1409 1409
 	$else_where = 't.name = %s';
@@ -1411,8 +1411,8 @@  discard block
 block discarded – undo
1411 1411
 	$else_where_fields = array($term);
1412 1412
 	$orderby = 'ORDER BY t.term_id ASC';
1413 1413
 	$limit = 'LIMIT 1';
1414
-	if ( !empty($taxonomy) ) {
1415
-		if ( is_numeric( $parent ) ) {
1414
+	if ( ! empty($taxonomy)) {
1415
+		if (is_numeric($parent)) {
1416 1416
 			$parent = (int) $parent;
1417 1417
 			$where_fields[] = $parent;
1418 1418
 			$else_where_fields[] = $parent;
@@ -1423,16 +1423,16 @@  discard block
 block discarded – undo
1423 1423
 		$where_fields[] = $taxonomy;
1424 1424
 		$else_where_fields[] = $taxonomy;
1425 1425
 
1426
-		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) )
1426
+		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 1427
 			return $result;
1428 1428
 
1429
-		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);
1429
+		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 1430
 	}
1431 1431
 
1432
-	if ( $result = $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where $orderby $limit", $where_fields) ) )
1432
+	if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where $orderby $limit", $where_fields)))
1433 1433
 		return $result;
1434 1434
 
1435
-	return $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $else_where $orderby $limit", $else_where_fields) );
1435
+	return $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $else_where $orderby $limit", $else_where_fields));
1436 1436
 }
1437 1437
 
1438 1438
 /**
@@ -1447,18 +1447,18 @@  discard block
 block discarded – undo
1447 1447
  * @param string     $taxonomy Taxonomy name that $term1 and `$term2` belong to.
1448 1448
  * @return bool Whether `$term2` is a child of `$term1`.
1449 1449
  */
1450
-function term_is_ancestor_of( $term1, $term2, $taxonomy ) {
1451
-	if ( ! isset( $term1->term_id ) )
1452
-		$term1 = get_term( $term1, $taxonomy );
1453
-	if ( ! isset( $term2->parent ) )
1454
-		$term2 = get_term( $term2, $taxonomy );
1450
+function term_is_ancestor_of($term1, $term2, $taxonomy) {
1451
+	if ( ! isset($term1->term_id))
1452
+		$term1 = get_term($term1, $taxonomy);
1453
+	if ( ! isset($term2->parent))
1454
+		$term2 = get_term($term2, $taxonomy);
1455 1455
 
1456
-	if ( empty( $term1->term_id ) || empty( $term2->parent ) )
1456
+	if (empty($term1->term_id) || empty($term2->parent))
1457 1457
 		return false;
1458
-	if ( $term2->parent == $term1->term_id )
1458
+	if ($term2->parent == $term1->term_id)
1459 1459
 		return true;
1460 1460
 
1461
-	return term_is_ancestor_of( $term1, get_term( $term2->parent, $taxonomy ), $taxonomy );
1461
+	return term_is_ancestor_of($term1, get_term($term2->parent, $taxonomy), $taxonomy);
1462 1462
 }
1463 1463
 
1464 1464
 /**
@@ -1479,23 +1479,23 @@  discard block
 block discarded – undo
1479 1479
  * @return array|object Term with all fields sanitized.
1480 1480
  */
1481 1481
 function sanitize_term($term, $taxonomy, $context = 'display') {
1482
-	$fields = array( 'term_id', 'name', 'description', 'slug', 'count', 'parent', 'term_group', 'term_taxonomy_id', 'object_id' );
1482
+	$fields = array('term_id', 'name', 'description', 'slug', 'count', 'parent', 'term_group', 'term_taxonomy_id', 'object_id');
1483 1483
 
1484
-	$do_object = is_object( $term );
1484
+	$do_object = is_object($term);
1485 1485
 
1486 1486
 	$term_id = $do_object ? $term->term_id : (isset($term['term_id']) ? $term['term_id'] : 0);
1487 1487
 
1488
-	foreach ( (array) $fields as $field ) {
1489
-		if ( $do_object ) {
1490
-			if ( isset($term->$field) )
1488
+	foreach ((array) $fields as $field) {
1489
+		if ($do_object) {
1490
+			if (isset($term->$field))
1491 1491
 				$term->$field = sanitize_term_field($field, $term->$field, $term_id, $taxonomy, $context);
1492 1492
 		} else {
1493
-			if ( isset($term[$field]) )
1493
+			if (isset($term[$field]))
1494 1494
 				$term[$field] = sanitize_term_field($field, $term[$field], $term_id, $taxonomy, $context);
1495 1495
 		}
1496 1496
 	}
1497 1497
 
1498
-	if ( $do_object )
1498
+	if ($do_object)
1499 1499
 		$term->filter = $context;
1500 1500
 	else
1501 1501
 		$term['filter'] = $context;
@@ -1527,17 +1527,17 @@  discard block
 block discarded – undo
1527 1527
  * @return mixed Sanitized field.
1528 1528
  */
1529 1529
 function sanitize_term_field($field, $value, $term_id, $taxonomy, $context) {
1530
-	$int_fields = array( 'parent', 'term_id', 'count', 'term_group', 'term_taxonomy_id', 'object_id' );
1531
-	if ( in_array( $field, $int_fields ) ) {
1530
+	$int_fields = array('parent', 'term_id', 'count', 'term_group', 'term_taxonomy_id', 'object_id');
1531
+	if (in_array($field, $int_fields)) {
1532 1532
 		$value = (int) $value;
1533
-		if ( $value < 0 )
1533
+		if ($value < 0)
1534 1534
 			$value = 0;
1535 1535
 	}
1536 1536
 
1537
-	if ( 'raw' == $context )
1537
+	if ('raw' == $context)
1538 1538
 		return $value;
1539 1539
 
1540
-	if ( 'edit' == $context ) {
1540
+	if ('edit' == $context) {
1541 1541
 
1542 1542
 		/**
1543 1543
 		 * Filters a term field to edit before it is sanitized.
@@ -1550,7 +1550,7 @@  discard block
 block discarded – undo
1550 1550
 		 * @param int   $term_id   Term ID.
1551 1551
 		 * @param string $taxonomy Taxonomy slug.
1552 1552
 		 */
1553
-		$value = apply_filters( "edit_term_{$field}", $value, $term_id, $taxonomy );
1553
+		$value = apply_filters("edit_term_{$field}", $value, $term_id, $taxonomy);
1554 1554
 
1555 1555
 		/**
1556 1556
 		 * Filters the taxonomy field to edit before it is sanitized.
@@ -1563,13 +1563,13 @@  discard block
 block discarded – undo
1563 1563
 		 * @param mixed $value   Value of the taxonomy field to edit.
1564 1564
 		 * @param int   $term_id Term ID.
1565 1565
 		 */
1566
-		$value = apply_filters( "edit_{$taxonomy}_{$field}", $value, $term_id );
1566
+		$value = apply_filters("edit_{$taxonomy}_{$field}", $value, $term_id);
1567 1567
 
1568
-		if ( 'description' == $field )
1568
+		if ('description' == $field)
1569 1569
 			$value = esc_html($value); // textarea_escaped
1570 1570
 		else
1571 1571
 			$value = esc_attr($value);
1572
-	} elseif ( 'db' == $context ) {
1572
+	} elseif ('db' == $context) {
1573 1573
 
1574 1574
 		/**
1575 1575
 		 * Filters a term field value before it is sanitized.
@@ -1581,7 +1581,7 @@  discard block
 block discarded – undo
1581 1581
 		 * @param mixed  $value    Value of the term field.
1582 1582
 		 * @param string $taxonomy Taxonomy slug.
1583 1583
 		 */
1584
-		$value = apply_filters( "pre_term_{$field}", $value, $taxonomy );
1584
+		$value = apply_filters("pre_term_{$field}", $value, $taxonomy);
1585 1585
 
1586 1586
 		/**
1587 1587
 		 * Filters a taxonomy field before it is sanitized.
@@ -1593,10 +1593,10 @@  discard block
 block discarded – undo
1593 1593
 		 *
1594 1594
 		 * @param mixed $value Value of the taxonomy field.
1595 1595
 		 */
1596
-		$value = apply_filters( "pre_{$taxonomy}_{$field}", $value );
1596
+		$value = apply_filters("pre_{$taxonomy}_{$field}", $value);
1597 1597
 
1598 1598
 		// Back compat filters
1599
-		if ( 'slug' == $field ) {
1599
+		if ('slug' == $field) {
1600 1600
 			/**
1601 1601
 			 * Filters the category nicename before it is sanitized.
1602 1602
 			 *
@@ -1606,10 +1606,10 @@  discard block
 block discarded – undo
1606 1606
 			 *
1607 1607
 			 * @param string $value The category nicename.
1608 1608
 			 */
1609
-			$value = apply_filters( 'pre_category_nicename', $value );
1609
+			$value = apply_filters('pre_category_nicename', $value);
1610 1610
 		}
1611 1611
 
1612
-	} elseif ( 'rss' == $context ) {
1612
+	} elseif ('rss' == $context) {
1613 1613
 
1614 1614
 		/**
1615 1615
 		 * Filters the term field for use in RSS.
@@ -1621,7 +1621,7 @@  discard block
 block discarded – undo
1621 1621
 		 * @param mixed  $value    Value of the term field.
1622 1622
 		 * @param string $taxonomy Taxonomy slug.
1623 1623
 		 */
1624
-		$value = apply_filters( "term_{$field}_rss", $value, $taxonomy );
1624
+		$value = apply_filters("term_{$field}_rss", $value, $taxonomy);
1625 1625
 
1626 1626
 		/**
1627 1627
 		 * Filters the taxonomy field for use in RSS.
@@ -1633,7 +1633,7 @@  discard block
 block discarded – undo
1633 1633
 		 *
1634 1634
 		 * @param mixed $value Value of the taxonomy field.
1635 1635
 		 */
1636
-		$value = apply_filters( "{$taxonomy}_{$field}_rss", $value );
1636
+		$value = apply_filters("{$taxonomy}_{$field}_rss", $value);
1637 1637
 	} else {
1638 1638
 		// Use display filters by default.
1639 1639
 
@@ -1649,7 +1649,7 @@  discard block
 block discarded – undo
1649 1649
 		 * @param string $taxonomy Taxonomy slug.
1650 1650
 		 * @param string $context  Context to retrieve the term field value.
1651 1651
 		 */
1652
-		$value = apply_filters( "term_{$field}", $value, $term_id, $taxonomy, $context );
1652
+		$value = apply_filters("term_{$field}", $value, $term_id, $taxonomy, $context);
1653 1653
 
1654 1654
 		/**
1655 1655
 		 * Filters the taxonomy field sanitized for display.
@@ -1663,12 +1663,12 @@  discard block
 block discarded – undo
1663 1663
 		 * @param int    $term_id Term ID.
1664 1664
 		 * @param string $context Context to retrieve the taxonomy field value.
1665 1665
 		 */
1666
-		$value = apply_filters( "{$taxonomy}_{$field}", $value, $term_id, $context );
1666
+		$value = apply_filters("{$taxonomy}_{$field}", $value, $term_id, $context);
1667 1667
 	}
1668 1668
 
1669
-	if ( 'attribute' == $context ) {
1669
+	if ('attribute' == $context) {
1670 1670
 		$value = esc_attr($value);
1671
-	} elseif ( 'js' == $context ) {
1671
+	} elseif ('js' == $context) {
1672 1672
 		$value = esc_js($value);
1673 1673
 	}
1674 1674
 	return $value;
@@ -1686,12 +1686,12 @@  discard block
 block discarded – undo
1686 1686
  *                               Default empty array.
1687 1687
  * @return array|int|WP_Error Number of terms in that taxonomy or WP_Error if the taxonomy does not exist.
1688 1688
  */
1689
-function wp_count_terms( $taxonomy, $args = array() ) {
1689
+function wp_count_terms($taxonomy, $args = array()) {
1690 1690
 	$defaults = array('hide_empty' => false);
1691 1691
 	$args = wp_parse_args($args, $defaults);
1692 1692
 
1693 1693
 	// backward compatibility
1694
-	if ( isset($args['ignore_empty']) ) {
1694
+	if (isset($args['ignore_empty'])) {
1695 1695
 		$args['hide_empty'] = $args['ignore_empty'];
1696 1696
 		unset($args['ignore_empty']);
1697 1697
 	}
@@ -1713,16 +1713,16 @@  discard block
 block discarded – undo
1713 1713
  * @param int          $object_id  The term Object Id that refers to the term.
1714 1714
  * @param string|array $taxonomies List of Taxonomy Names or single Taxonomy name.
1715 1715
  */
1716
-function wp_delete_object_term_relationships( $object_id, $taxonomies ) {
1716
+function wp_delete_object_term_relationships($object_id, $taxonomies) {
1717 1717
 	$object_id = (int) $object_id;
1718 1718
 
1719
-	if ( !is_array($taxonomies) )
1719
+	if ( ! is_array($taxonomies))
1720 1720
 		$taxonomies = array($taxonomies);
1721 1721
 
1722
-	foreach ( (array) $taxonomies as $taxonomy ) {
1723
-		$term_ids = wp_get_object_terms( $object_id, $taxonomy, array( 'fields' => 'ids' ) );
1724
-		$term_ids = array_map( 'intval', $term_ids );
1725
-		wp_remove_object_terms( $object_id, $term_ids, $taxonomy );
1722
+	foreach ((array) $taxonomies as $taxonomy) {
1723
+		$term_ids = wp_get_object_terms($object_id, $taxonomy, array('fields' => 'ids'));
1724
+		$term_ids = array_map('intval', $term_ids);
1725
+		wp_remove_object_terms($object_id, $term_ids, $taxonomy);
1726 1726
 	}
1727 1727
 }
1728 1728
 
@@ -1753,36 +1753,36 @@  discard block
 block discarded – undo
1753 1753
  * @return bool|int|WP_Error True on success, false if term does not exist. Zero on attempted
1754 1754
  *                           deletion of default Category. WP_Error if the taxonomy does not exist.
1755 1755
  */
1756
-function wp_delete_term( $term, $taxonomy, $args = array() ) {
1756
+function wp_delete_term($term, $taxonomy, $args = array()) {
1757 1757
 	global $wpdb;
1758 1758
 
1759 1759
 	$term = (int) $term;
1760 1760
 
1761
-	if ( ! $ids = term_exists($term, $taxonomy) )
1761
+	if ( ! $ids = term_exists($term, $taxonomy))
1762 1762
 		return false;
1763
-	if ( is_wp_error( $ids ) )
1763
+	if (is_wp_error($ids))
1764 1764
 		return $ids;
1765 1765
 
1766 1766
 	$tt_id = $ids['term_taxonomy_id'];
1767 1767
 
1768 1768
 	$defaults = array();
1769 1769
 
1770
-	if ( 'category' == $taxonomy ) {
1771
-		$defaults['default'] = get_option( 'default_category' );
1772
-		if ( $defaults['default'] == $term )
1770
+	if ('category' == $taxonomy) {
1771
+		$defaults['default'] = get_option('default_category');
1772
+		if ($defaults['default'] == $term)
1773 1773
 			return 0; // Don't delete the default category
1774 1774
 	}
1775 1775
 
1776 1776
 	$args = wp_parse_args($args, $defaults);
1777 1777
 
1778
-	if ( isset( $args['default'] ) ) {
1778
+	if (isset($args['default'])) {
1779 1779
 		$default = (int) $args['default'];
1780
-		if ( ! term_exists( $default, $taxonomy ) ) {
1781
-			unset( $default );
1780
+		if ( ! term_exists($default, $taxonomy)) {
1781
+			unset($default);
1782 1782
 		}
1783 1783
 	}
1784 1784
 
1785
-	if ( isset( $args['force_default'] ) ) {
1785
+	if (isset($args['force_default'])) {
1786 1786
 		$force_default = $args['force_default'];
1787 1787
 	}
1788 1788
 
@@ -1794,17 +1794,17 @@  discard block
 block discarded – undo
1794 1794
 	 * @param int    $term     Term ID.
1795 1795
 	 * @param string $taxonomy Taxonomy Name.
1796 1796
 	 */
1797
-	do_action( 'pre_delete_term', $term, $taxonomy );
1797
+	do_action('pre_delete_term', $term, $taxonomy);
1798 1798
 
1799 1799
 	// Update children to point to new parent
1800
-	if ( is_taxonomy_hierarchical($taxonomy) ) {
1800
+	if (is_taxonomy_hierarchical($taxonomy)) {
1801 1801
 		$term_obj = get_term($term, $taxonomy);
1802
-		if ( is_wp_error( $term_obj ) )
1802
+		if (is_wp_error($term_obj))
1803 1803
 			return $term_obj;
1804 1804
 		$parent = $term_obj->parent;
1805 1805
 
1806
-		$edit_ids = $wpdb->get_results( "SELECT term_id, term_taxonomy_id FROM $wpdb->term_taxonomy WHERE `parent` = " . (int)$term_obj->term_id );
1807
-		$edit_tt_ids = wp_list_pluck( $edit_ids, 'term_taxonomy_id' );
1806
+		$edit_ids = $wpdb->get_results("SELECT term_id, term_taxonomy_id FROM $wpdb->term_taxonomy WHERE `parent` = ".(int) $term_obj->term_id);
1807
+		$edit_tt_ids = wp_list_pluck($edit_ids, 'term_taxonomy_id');
1808 1808
 
1809 1809
 		/**
1810 1810
 		 * Fires immediately before a term to delete's children are reassigned a parent.
@@ -1813,13 +1813,13 @@  discard block
 block discarded – undo
1813 1813
 		 *
1814 1814
 		 * @param array $edit_tt_ids An array of term taxonomy IDs for the given term.
1815 1815
 		 */
1816
-		do_action( 'edit_term_taxonomies', $edit_tt_ids );
1816
+		do_action('edit_term_taxonomies', $edit_tt_ids);
1817 1817
 
1818
-		$wpdb->update( $wpdb->term_taxonomy, compact( 'parent' ), array( 'parent' => $term_obj->term_id) + compact( 'taxonomy' ) );
1818
+		$wpdb->update($wpdb->term_taxonomy, compact('parent'), array('parent' => $term_obj->term_id) + compact('taxonomy'));
1819 1819
 
1820 1820
 		// Clean the cache for all child terms.
1821
-		$edit_term_ids = wp_list_pluck( $edit_ids, 'term_id' );
1822
-		clean_term_cache( $edit_term_ids, $taxonomy );
1821
+		$edit_term_ids = wp_list_pluck($edit_ids, 'term_id');
1822
+		clean_term_cache($edit_term_ids, $taxonomy);
1823 1823
 
1824 1824
 		/**
1825 1825
 		 * Fires immediately after a term to delete's children are reassigned a parent.
@@ -1828,17 +1828,17 @@  discard block
 block discarded – undo
1828 1828
 		 *
1829 1829
 		 * @param array $edit_tt_ids An array of term taxonomy IDs for the given term.
1830 1830
 		 */
1831
-		do_action( 'edited_term_taxonomies', $edit_tt_ids );
1831
+		do_action('edited_term_taxonomies', $edit_tt_ids);
1832 1832
 	}
1833 1833
 
1834 1834
 	// Get the term before deleting it or its term relationships so we can pass to actions below.
1835
-	$deleted_term = get_term( $term, $taxonomy );
1835
+	$deleted_term = get_term($term, $taxonomy);
1836 1836
 
1837
-	$object_ids = (array) $wpdb->get_col( $wpdb->prepare( "SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $tt_id ) );
1837
+	$object_ids = (array) $wpdb->get_col($wpdb->prepare("SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $tt_id));
1838 1838
 
1839
-	foreach ( $object_ids as $object_id ) {
1840
-		$terms = wp_get_object_terms( $object_id, $taxonomy, array( 'fields' => 'ids', 'orderby' => 'none' ) );
1841
-		if ( 1 == count($terms) && isset($default) ) {
1839
+	foreach ($object_ids as $object_id) {
1840
+		$terms = wp_get_object_terms($object_id, $taxonomy, array('fields' => 'ids', 'orderby' => 'none'));
1841
+		if (1 == count($terms) && isset($default)) {
1842 1842
 			$terms = array($default);
1843 1843
 		} else {
1844 1844
 			$terms = array_diff($terms, array($term));
@@ -1846,17 +1846,17 @@  discard block
 block discarded – undo
1846 1846
 				$terms = array_merge($terms, array($default));
1847 1847
 		}
1848 1848
 		$terms = array_map('intval', $terms);
1849
-		wp_set_object_terms( $object_id, $terms, $taxonomy );
1849
+		wp_set_object_terms($object_id, $terms, $taxonomy);
1850 1850
 	}
1851 1851
 
1852 1852
 	// Clean the relationship caches for all object types using this term.
1853
-	$tax_object = get_taxonomy( $taxonomy );
1854
-	foreach ( $tax_object->object_type as $object_type )
1855
-		clean_object_term_cache( $object_ids, $object_type );
1853
+	$tax_object = get_taxonomy($taxonomy);
1854
+	foreach ($tax_object->object_type as $object_type)
1855
+		clean_object_term_cache($object_ids, $object_type);
1856 1856
 
1857
-	$term_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->termmeta WHERE term_id = %d ", $term ) );
1858
-	foreach ( $term_meta_ids as $mid ) {
1859
-		delete_metadata_by_mid( 'term', $mid );
1857
+	$term_meta_ids = $wpdb->get_col($wpdb->prepare("SELECT meta_id FROM $wpdb->termmeta WHERE term_id = %d ", $term));
1858
+	foreach ($term_meta_ids as $mid) {
1859
+		delete_metadata_by_mid('term', $mid);
1860 1860
 	}
1861 1861
 
1862 1862
 	/**
@@ -1866,8 +1866,8 @@  discard block
 block discarded – undo
1866 1866
 	 *
1867 1867
 	 * @param int $tt_id Term taxonomy ID.
1868 1868
 	 */
1869
-	do_action( 'delete_term_taxonomy', $tt_id );
1870
-	$wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $tt_id ) );
1869
+	do_action('delete_term_taxonomy', $tt_id);
1870
+	$wpdb->delete($wpdb->term_taxonomy, array('term_taxonomy_id' => $tt_id));
1871 1871
 
1872 1872
 	/**
1873 1873
 	 * Fires immediately after a term taxonomy ID is deleted.
@@ -1876,11 +1876,11 @@  discard block
 block discarded – undo
1876 1876
 	 *
1877 1877
 	 * @param int $tt_id Term taxonomy ID.
1878 1878
 	 */
1879
-	do_action( 'deleted_term_taxonomy', $tt_id );
1879
+	do_action('deleted_term_taxonomy', $tt_id);
1880 1880
 
1881 1881
 	// Delete the term if no taxonomies use it.
1882
-	if ( !$wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term) ) )
1883
-		$wpdb->delete( $wpdb->terms, array( 'term_id' => $term ) );
1882
+	if ( ! $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term)))
1883
+		$wpdb->delete($wpdb->terms, array('term_id' => $term));
1884 1884
 
1885 1885
 	clean_term_cache($term, $taxonomy);
1886 1886
 
@@ -1897,7 +1897,7 @@  discard block
 block discarded – undo
1897 1897
 	 *                              by the parent function. WP_Error otherwise.
1898 1898
 	 * @param array   $object_ids   List of term object IDs.
1899 1899
 	 */
1900
-	do_action( 'delete_term', $term, $tt_id, $taxonomy, $deleted_term, $object_ids );
1900
+	do_action('delete_term', $term, $tt_id, $taxonomy, $deleted_term, $object_ids);
1901 1901
 
1902 1902
 	/**
1903 1903
 	 * Fires after a term in a specific taxonomy is deleted.
@@ -1914,7 +1914,7 @@  discard block
 block discarded – undo
1914 1914
 	 *                              by the parent function. WP_Error otherwise.
1915 1915
 	 * @param array   $object_ids   List of term object IDs.
1916 1916
 	 */
1917
-	do_action( "delete_$taxonomy", $term, $tt_id, $deleted_term, $object_ids );
1917
+	do_action("delete_$taxonomy", $term, $tt_id, $deleted_term, $object_ids);
1918 1918
 
1919 1919
 	return true;
1920 1920
 }
@@ -1928,8 +1928,8 @@  discard block
 block discarded – undo
1928 1928
  * @return bool|int|WP_Error Returns true if completes delete action; false if term doesn't exist;
1929 1929
  * 	Zero on attempted deletion of default Category; WP_Error object is also a possibility.
1930 1930
  */
1931
-function wp_delete_category( $cat_ID ) {
1932
-	return wp_delete_term( $cat_ID, 'category' );
1931
+function wp_delete_category($cat_ID) {
1932
+	return wp_delete_term($cat_ID, 'category');
1933 1933
 }
1934 1934
 
1935 1935
 /**
@@ -1967,18 +1967,18 @@  discard block
 block discarded – undo
1967 1967
 function wp_get_object_terms($object_ids, $taxonomies, $args = array()) {
1968 1968
 	global $wpdb;
1969 1969
 
1970
-	if ( empty( $object_ids ) || empty( $taxonomies ) )
1970
+	if (empty($object_ids) || empty($taxonomies))
1971 1971
 		return array();
1972 1972
 
1973
-	if ( !is_array($taxonomies) )
1973
+	if ( ! is_array($taxonomies))
1974 1974
 		$taxonomies = array($taxonomies);
1975 1975
 
1976
-	foreach ( $taxonomies as $taxonomy ) {
1977
-		if ( ! taxonomy_exists($taxonomy) )
1976
+	foreach ($taxonomies as $taxonomy) {
1977
+		if ( ! taxonomy_exists($taxonomy))
1978 1978
 			return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
1979 1979
 	}
1980 1980
 
1981
-	if ( !is_array($object_ids) )
1981
+	if ( ! is_array($object_ids))
1982 1982
 		$object_ids = array($object_ids);
1983 1983
 	$object_ids = array_map('intval', $object_ids);
1984 1984
 
@@ -1990,20 +1990,20 @@  discard block
 block discarded – undo
1990 1990
 		'update_term_meta_cache' => true,
1991 1991
 		'meta_query' => '',
1992 1992
 	);
1993
-	$args = wp_parse_args( $args, $defaults );
1993
+	$args = wp_parse_args($args, $defaults);
1994 1994
 
1995 1995
 	$terms = array();
1996
-	if ( count($taxonomies) > 1 ) {
1997
-		foreach ( $taxonomies as $index => $taxonomy ) {
1996
+	if (count($taxonomies) > 1) {
1997
+		foreach ($taxonomies as $index => $taxonomy) {
1998 1998
 			$t = get_taxonomy($taxonomy);
1999
-			if ( isset($t->args) && is_array($t->args) && $args != array_merge($args, $t->args) ) {
1999
+			if (isset($t->args) && is_array($t->args) && $args != array_merge($args, $t->args)) {
2000 2000
 				unset($taxonomies[$index]);
2001 2001
 				$terms = array_merge($terms, wp_get_object_terms($object_ids, $taxonomy, array_merge($args, $t->args)));
2002 2002
 			}
2003 2003
 		}
2004 2004
 	} else {
2005 2005
 		$t = get_taxonomy($taxonomies[0]);
2006
-		if ( isset($t->args) && is_array($t->args) )
2006
+		if (isset($t->args) && is_array($t->args))
2007 2007
 			$args = array_merge($args, $t->args);
2008 2008
 	}
2009 2009
 
@@ -2011,13 +2011,13 @@  discard block
 block discarded – undo
2011 2011
 	$order = $args['order'];
2012 2012
 	$fields = $args['fields'];
2013 2013
 
2014
-	if ( in_array( $orderby, array( 'term_id', 'name', 'slug', 'term_group' ) ) ) {
2014
+	if (in_array($orderby, array('term_id', 'name', 'slug', 'term_group'))) {
2015 2015
 		$orderby = "t.$orderby";
2016
-	} elseif ( in_array( $orderby, array( 'count', 'parent', 'taxonomy', 'term_taxonomy_id' ) ) ) {
2016
+	} elseif (in_array($orderby, array('count', 'parent', 'taxonomy', 'term_taxonomy_id'))) {
2017 2017
 		$orderby = "tt.$orderby";
2018
-	} elseif ( 'term_order' === $orderby ) {
2018
+	} elseif ('term_order' === $orderby) {
2019 2019
 		$orderby = 'tr.term_order';
2020
-	} elseif ( 'none' === $orderby ) {
2020
+	} elseif ('none' === $orderby) {
2021 2021
 		$orderby = '';
2022 2022
 		$order = '';
2023 2023
 	} else {
@@ -2025,31 +2025,31 @@  discard block
 block discarded – undo
2025 2025
 	}
2026 2026
 
2027 2027
 	// tt_ids queries can only be none or tr.term_taxonomy_id
2028
-	if ( ('tt_ids' == $fields) && !empty($orderby) )
2028
+	if (('tt_ids' == $fields) && ! empty($orderby))
2029 2029
 		$orderby = 'tr.term_taxonomy_id';
2030 2030
 
2031
-	if ( !empty($orderby) )
2031
+	if ( ! empty($orderby))
2032 2032
 		$orderby = "ORDER BY $orderby";
2033 2033
 
2034
-	$order = strtoupper( $order );
2035
-	if ( '' !== $order && ! in_array( $order, array( 'ASC', 'DESC' ) ) )
2034
+	$order = strtoupper($order);
2035
+	if ('' !== $order && ! in_array($order, array('ASC', 'DESC')))
2036 2036
 		$order = 'ASC';
2037 2037
 
2038 2038
 	$taxonomy_array = $taxonomies;
2039 2039
 	$object_id_array = $object_ids;
2040
-	$taxonomies = "'" . implode("', '", array_map( 'esc_sql', $taxonomies ) ) . "'";
2040
+	$taxonomies = "'".implode("', '", array_map('esc_sql', $taxonomies))."'";
2041 2041
 	$object_ids = implode(', ', $object_ids);
2042 2042
 
2043 2043
 	$select_this = '';
2044
-	if ( 'all' == $fields ) {
2044
+	if ('all' == $fields) {
2045 2045
 		$select_this = 't.*, tt.*';
2046
-	} elseif ( 'ids' == $fields ) {
2046
+	} elseif ('ids' == $fields) {
2047 2047
 		$select_this = 't.term_id';
2048
-	} elseif ( 'names' == $fields ) {
2048
+	} elseif ('names' == $fields) {
2049 2049
 		$select_this = 't.name';
2050
-	} elseif ( 'slugs' == $fields ) {
2050
+	} elseif ('slugs' == $fields) {
2051 2051
 		$select_this = 't.slug';
2052
-	} elseif ( 'all_with_object_id' == $fields ) {
2052
+	} elseif ('all_with_object_id' == $fields) {
2053 2053
 		$select_this = 't.*, tt.*, tr.object_id';
2054 2054
 	}
2055 2055
 
@@ -2058,86 +2058,86 @@  discard block
 block discarded – undo
2058 2058
 		"tr.object_id IN ($object_ids)",
2059 2059
 	);
2060 2060
 
2061
-	if ( '' !== $args['parent'] ) {
2062
-		$where[] = $wpdb->prepare( 'tt.parent = %d', $args['parent'] );
2061
+	if ('' !== $args['parent']) {
2062
+		$where[] = $wpdb->prepare('tt.parent = %d', $args['parent']);
2063 2063
 	}
2064 2064
 
2065 2065
 	// Meta query support.
2066 2066
 	$meta_query_join = '';
2067
-	if ( ! empty( $args['meta_query'] ) ) {
2068
-		$mquery = new WP_Meta_Query( $args['meta_query'] );
2069
-		$mq_sql = $mquery->get_sql( 'term', 't', 'term_id' );
2067
+	if ( ! empty($args['meta_query'])) {
2068
+		$mquery = new WP_Meta_Query($args['meta_query']);
2069
+		$mq_sql = $mquery->get_sql('term', 't', 'term_id');
2070 2070
 
2071 2071
 		$meta_query_join .= $mq_sql['join'];
2072 2072
 
2073 2073
 		// Strip leading AND.
2074
-		$where[] = preg_replace( '/^\s*AND/', '', $mq_sql['where'] );
2074
+		$where[] = preg_replace('/^\s*AND/', '', $mq_sql['where']);
2075 2075
 	}
2076 2076
 
2077
-	$where = implode( ' AND ', $where );
2077
+	$where = implode(' AND ', $where);
2078 2078
 
2079 2079
 	$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";
2080 2080
 
2081 2081
 	$objects = false;
2082
-	if ( 'all' == $fields || 'all_with_object_id' == $fields ) {
2083
-		$_terms = $wpdb->get_results( $query );
2082
+	if ('all' == $fields || 'all_with_object_id' == $fields) {
2083
+		$_terms = $wpdb->get_results($query);
2084 2084
 		$object_id_index = array();
2085
-		foreach ( $_terms as $key => $term ) {
2086
-			$term = sanitize_term( $term, $taxonomy, 'raw' );
2087
-			$_terms[ $key ] = $term;
2085
+		foreach ($_terms as $key => $term) {
2086
+			$term = sanitize_term($term, $taxonomy, 'raw');
2087
+			$_terms[$key] = $term;
2088 2088
 
2089
-			if ( isset( $term->object_id ) ) {
2090
-				$object_id_index[ $key ] = $term->object_id;
2089
+			if (isset($term->object_id)) {
2090
+				$object_id_index[$key] = $term->object_id;
2091 2091
 			}
2092 2092
 		}
2093 2093
 
2094
-		update_term_cache( $_terms );
2095
-		$_terms = array_map( 'get_term', $_terms );
2094
+		update_term_cache($_terms);
2095
+		$_terms = array_map('get_term', $_terms);
2096 2096
 
2097 2097
 		// Re-add the object_id data, which is lost when fetching terms from cache.
2098
-		if ( 'all_with_object_id' === $fields ) {
2099
-			foreach ( $_terms as $key => $_term ) {
2100
-				if ( isset( $object_id_index[ $key ] ) ) {
2101
-					$_term->object_id = $object_id_index[ $key ];
2098
+		if ('all_with_object_id' === $fields) {
2099
+			foreach ($_terms as $key => $_term) {
2100
+				if (isset($object_id_index[$key])) {
2101
+					$_term->object_id = $object_id_index[$key];
2102 2102
 				}
2103 2103
 			}
2104 2104
 		}
2105 2105
 
2106
-		$terms = array_merge( $terms, $_terms );
2106
+		$terms = array_merge($terms, $_terms);
2107 2107
 		$objects = true;
2108 2108
 
2109
-	} elseif ( 'ids' == $fields || 'names' == $fields || 'slugs' == $fields ) {
2110
-		$_terms = $wpdb->get_col( $query );
2111
-		$_field = ( 'ids' == $fields ) ? 'term_id' : 'name';
2112
-		foreach ( $_terms as $key => $term ) {
2113
-			$_terms[$key] = sanitize_term_field( $_field, $term, $term, $taxonomy, 'raw' );
2109
+	} elseif ('ids' == $fields || 'names' == $fields || 'slugs' == $fields) {
2110
+		$_terms = $wpdb->get_col($query);
2111
+		$_field = ('ids' == $fields) ? 'term_id' : 'name';
2112
+		foreach ($_terms as $key => $term) {
2113
+			$_terms[$key] = sanitize_term_field($_field, $term, $term, $taxonomy, 'raw');
2114 2114
 		}
2115
-		$terms = array_merge( $terms, $_terms );
2116
-	} elseif ( 'tt_ids' == $fields ) {
2115
+		$terms = array_merge($terms, $_terms);
2116
+	} elseif ('tt_ids' == $fields) {
2117 2117
 		$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");
2118
-		foreach ( $terms as $key => $tt_id ) {
2119
-			$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.
2118
+		foreach ($terms as $key => $tt_id) {
2119
+			$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.
2120 2120
 		}
2121 2121
 	}
2122 2122
 
2123 2123
 	// Update termmeta cache, if necessary.
2124
-	if ( $args['update_term_meta_cache'] && ( 'all' === $fields || 'all_with_object_id' === $fields || 'ids' === $fields ) ) {
2125
-		if ( 'ids' === $fields ) {
2124
+	if ($args['update_term_meta_cache'] && ('all' === $fields || 'all_with_object_id' === $fields || 'ids' === $fields)) {
2125
+		if ('ids' === $fields) {
2126 2126
 			$term_ids = $terms;
2127 2127
 		} else {
2128
-			$term_ids = wp_list_pluck( $terms, 'term_id' );
2128
+			$term_ids = wp_list_pluck($terms, 'term_id');
2129 2129
 		}
2130 2130
 
2131
-		update_termmeta_cache( $term_ids );
2131
+		update_termmeta_cache($term_ids);
2132 2132
 	}
2133 2133
 
2134
-	if ( ! $terms ) {
2134
+	if ( ! $terms) {
2135 2135
 		$terms = array();
2136
-	} elseif ( $objects && 'all_with_object_id' !== $fields ) {
2136
+	} elseif ($objects && 'all_with_object_id' !== $fields) {
2137 2137
 		$_tt_ids = array();
2138 2138
 		$_terms = array();
2139
-		foreach ( $terms as $term ) {
2140
-			if ( in_array( $term->term_taxonomy_id, $_tt_ids ) ) {
2139
+		foreach ($terms as $term) {
2140
+			if (in_array($term->term_taxonomy_id, $_tt_ids)) {
2141 2141
 				continue;
2142 2142
 			}
2143 2143
 
@@ -2145,8 +2145,8 @@  discard block
 block discarded – undo
2145 2145
 			$_terms[] = $term;
2146 2146
 		}
2147 2147
 		$terms = $_terms;
2148
-	} elseif ( ! $objects ) {
2149
-		$terms = array_values( array_unique( $terms ) );
2148
+	} elseif ( ! $objects) {
2149
+		$terms = array_values(array_unique($terms));
2150 2150
 	}
2151 2151
 
2152 2152
 	/**
@@ -2160,7 +2160,7 @@  discard block
 block discarded – undo
2160 2160
 	 * @param array $args            An array of arguments for retrieving terms for the given
2161 2161
 	 *                               object(s). See wp_get_object_terms() for details.
2162 2162
 	 */
2163
-	$terms = apply_filters( 'get_object_terms', $terms, $object_id_array, $taxonomy_array, $args );
2163
+	$terms = apply_filters('get_object_terms', $terms, $object_id_array, $taxonomy_array, $args);
2164 2164
 
2165 2165
 	/**
2166 2166
 	 * Filters the terms for a given object or objects.
@@ -2176,7 +2176,7 @@  discard block
 block discarded – undo
2176 2176
 	 * @param array     $args       An array of arguments for retrieving terms for the given object(s).
2177 2177
 	 *                              See wp_get_object_terms() for details.
2178 2178
 	 */
2179
-	return apply_filters( 'wp_get_object_terms', $terms, $object_ids, $taxonomies, $args );
2179
+	return apply_filters('wp_get_object_terms', $terms, $object_ids, $taxonomies, $args);
2180 2180
 }
2181 2181
 
2182 2182
 /**
@@ -2222,10 +2222,10 @@  discard block
 block discarded – undo
2222 2222
  * @return array|WP_Error An array containing the `term_id` and `term_taxonomy_id`,
2223 2223
  *                        WP_Error otherwise.
2224 2224
  */
2225
-function wp_insert_term( $term, $taxonomy, $args = array() ) {
2225
+function wp_insert_term($term, $taxonomy, $args = array()) {
2226 2226
 	global $wpdb;
2227 2227
 
2228
-	if ( ! taxonomy_exists($taxonomy) ) {
2228
+	if ( ! taxonomy_exists($taxonomy)) {
2229 2229
 		return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
2230 2230
 	}
2231 2231
 	/**
@@ -2236,21 +2236,21 @@  discard block
 block discarded – undo
2236 2236
 	 * @param string $term     The term to add or update.
2237 2237
 	 * @param string $taxonomy Taxonomy slug.
2238 2238
 	 */
2239
-	$term = apply_filters( 'pre_insert_term', $term, $taxonomy );
2240
-	if ( is_wp_error( $term ) ) {
2239
+	$term = apply_filters('pre_insert_term', $term, $taxonomy);
2240
+	if (is_wp_error($term)) {
2241 2241
 		return $term;
2242 2242
 	}
2243
-	if ( is_int($term) && 0 == $term ) {
2243
+	if (is_int($term) && 0 == $term) {
2244 2244
 		return new WP_Error('invalid_term_id', __('Invalid term ID'));
2245 2245
 	}
2246
-	if ( '' == trim($term) ) {
2246
+	if ('' == trim($term)) {
2247 2247
 		return new WP_Error('empty_term_name', __('A name is required for this term'));
2248 2248
 	}
2249
-	$defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
2250
-	$args = wp_parse_args( $args, $defaults );
2249
+	$defaults = array('alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
2250
+	$args = wp_parse_args($args, $defaults);
2251 2251
 
2252
-	if ( $args['parent'] > 0 && ! term_exists( (int) $args['parent'] ) ) {
2253
-		return new WP_Error( 'missing_parent', __( 'Parent term does not exist.' ) );
2252
+	if ($args['parent'] > 0 && ! term_exists((int) $args['parent'])) {
2253
+		return new WP_Error('missing_parent', __('Parent term does not exist.'));
2254 2254
 	}
2255 2255
 
2256 2256
 	$args['name'] = $term;
@@ -2262,33 +2262,33 @@  discard block
 block discarded – undo
2262 2262
 	$args = sanitize_term($args, $taxonomy, 'db');
2263 2263
 
2264 2264
 	// expected_slashed ($name)
2265
-	$name = wp_unslash( $args['name'] );
2266
-	$description = wp_unslash( $args['description'] );
2265
+	$name = wp_unslash($args['name']);
2266
+	$description = wp_unslash($args['description']);
2267 2267
 	$parent = (int) $args['parent'];
2268 2268
 
2269
-	$slug_provided = ! empty( $args['slug'] );
2270
-	if ( ! $slug_provided ) {
2271
-		$slug = sanitize_title( $name );
2269
+	$slug_provided = ! empty($args['slug']);
2270
+	if ( ! $slug_provided) {
2271
+		$slug = sanitize_title($name);
2272 2272
 	} else {
2273 2273
 		$slug = $args['slug'];
2274 2274
 	}
2275 2275
 
2276 2276
 	$term_group = 0;
2277
-	if ( $args['alias_of'] ) {
2278
-		$alias = get_term_by( 'slug', $args['alias_of'], $taxonomy );
2279
-		if ( ! empty( $alias->term_group ) ) {
2277
+	if ($args['alias_of']) {
2278
+		$alias = get_term_by('slug', $args['alias_of'], $taxonomy);
2279
+		if ( ! empty($alias->term_group)) {
2280 2280
 			// The alias we want is already in a group, so let's use that one.
2281 2281
 			$term_group = $alias->term_group;
2282
-		} elseif ( ! empty( $alias->term_id ) ) {
2282
+		} elseif ( ! empty($alias->term_id)) {
2283 2283
 			/*
2284 2284
 			 * The alias is not in a group, so we create a new one
2285 2285
 			 * and add the alias to it.
2286 2286
 			 */
2287 2287
 			$term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1;
2288 2288
 
2289
-			wp_update_term( $alias->term_id, $taxonomy, array(
2289
+			wp_update_term($alias->term_id, $taxonomy, array(
2290 2290
 				'term_group' => $term_group,
2291
-			) );
2291
+			));
2292 2292
 		}
2293 2293
 	}
2294 2294
 
@@ -2296,73 +2296,73 @@  discard block
 block discarded – undo
2296 2296
 	 * Prevent the creation of terms with duplicate names at the same level of a taxonomy hierarchy,
2297 2297
 	 * unless a unique slug has been explicitly provided.
2298 2298
 	 */
2299
-	$name_matches = get_terms( $taxonomy, array(
2299
+	$name_matches = get_terms($taxonomy, array(
2300 2300
 		'name' => $name,
2301 2301
 		'hide_empty' => false,
2302
-	) );
2302
+	));
2303 2303
 
2304 2304
 	/*
2305 2305
 	 * The `name` match in `get_terms()` doesn't differentiate accented characters,
2306 2306
 	 * so we do a stricter comparison here.
2307 2307
 	 */
2308 2308
 	$name_match = null;
2309
-	if ( $name_matches ) {
2310
-		foreach ( $name_matches as $_match ) {
2311
-			if ( strtolower( $name ) === strtolower( $_match->name ) ) {
2309
+	if ($name_matches) {
2310
+		foreach ($name_matches as $_match) {
2311
+			if (strtolower($name) === strtolower($_match->name)) {
2312 2312
 				$name_match = $_match;
2313 2313
 				break;
2314 2314
 			}
2315 2315
 		}
2316 2316
 	}
2317 2317
 
2318
-	if ( $name_match ) {
2319
-		$slug_match = get_term_by( 'slug', $slug, $taxonomy );
2320
-		if ( ! $slug_provided || $name_match->slug === $slug || $slug_match ) {
2321
-			if ( is_taxonomy_hierarchical( $taxonomy ) ) {
2322
-				$siblings = get_terms( $taxonomy, array( 'get' => 'all', 'parent' => $parent ) );
2318
+	if ($name_match) {
2319
+		$slug_match = get_term_by('slug', $slug, $taxonomy);
2320
+		if ( ! $slug_provided || $name_match->slug === $slug || $slug_match) {
2321
+			if (is_taxonomy_hierarchical($taxonomy)) {
2322
+				$siblings = get_terms($taxonomy, array('get' => 'all', 'parent' => $parent));
2323 2323
 
2324 2324
 				$existing_term = null;
2325
-				if ( $name_match->slug === $slug && in_array( $name, wp_list_pluck( $siblings, 'name' ) ) ) {
2325
+				if ($name_match->slug === $slug && in_array($name, wp_list_pluck($siblings, 'name'))) {
2326 2326
 					$existing_term = $name_match;
2327
-				} elseif ( $slug_match && in_array( $slug, wp_list_pluck( $siblings, 'slug' ) ) ) {
2327
+				} elseif ($slug_match && in_array($slug, wp_list_pluck($siblings, 'slug'))) {
2328 2328
 					$existing_term = $slug_match;
2329 2329
 				}
2330 2330
 
2331
-				if ( $existing_term ) {
2332
-					return new WP_Error( 'term_exists', __( 'A term with the name provided already exists with this parent.' ), $existing_term->term_id );
2331
+				if ($existing_term) {
2332
+					return new WP_Error('term_exists', __('A term with the name provided already exists with this parent.'), $existing_term->term_id);
2333 2333
 				}
2334 2334
 			} else {
2335
-				return new WP_Error( 'term_exists', __( 'A term with the name provided already exists in this taxonomy.' ), $name_match->term_id );
2335
+				return new WP_Error('term_exists', __('A term with the name provided already exists in this taxonomy.'), $name_match->term_id);
2336 2336
 			}
2337 2337
 		}
2338 2338
 	}
2339 2339
 
2340
-	$slug = wp_unique_term_slug( $slug, (object) $args );
2340
+	$slug = wp_unique_term_slug($slug, (object) $args);
2341 2341
 
2342
-	if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) ) {
2343
-		return new WP_Error( 'db_insert_error', __( 'Could not insert term into the database' ), $wpdb->last_error );
2342
+	if (false === $wpdb->insert($wpdb->terms, compact('name', 'slug', 'term_group'))) {
2343
+		return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error);
2344 2344
 	}
2345 2345
 
2346 2346
 	$term_id = (int) $wpdb->insert_id;
2347 2347
 
2348 2348
 	// Seems unreachable, However, Is used in the case that a term name is provided, which sanitizes to an empty string.
2349
-	if ( empty($slug) ) {
2349
+	if (empty($slug)) {
2350 2350
 		$slug = sanitize_title($slug, $term_id);
2351 2351
 
2352 2352
 		/** This action is documented in wp-includes/taxonomy.php */
2353
-		do_action( 'edit_terms', $term_id, $taxonomy );
2354
-		$wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) );
2353
+		do_action('edit_terms', $term_id, $taxonomy);
2354
+		$wpdb->update($wpdb->terms, compact('slug'), compact('term_id'));
2355 2355
 
2356 2356
 		/** This action is documented in wp-includes/taxonomy.php */
2357
-		do_action( 'edited_terms', $term_id, $taxonomy );
2357
+		do_action('edited_terms', $term_id, $taxonomy);
2358 2358
 	}
2359 2359
 
2360
-	$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 ) );
2360
+	$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 2361
 
2362
-	if ( !empty($tt_id) ) {
2362
+	if ( ! empty($tt_id)) {
2363 2363
 		return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
2364 2364
 	}
2365
-	$wpdb->insert( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent') + array( 'count' => 0 ) );
2365
+	$wpdb->insert($wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent') + array('count' => 0));
2366 2366
 	$tt_id = (int) $wpdb->insert_id;
2367 2367
 
2368 2368
 	/*
@@ -2371,16 +2371,16 @@  discard block
 block discarded – undo
2371 2371
 	 * and term_taxonomy_id of the older term instead. Then return out of the function so that the "create" hooks
2372 2372
 	 * are not fired.
2373 2373
 	 */
2374
-	$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 ) );
2375
-	if ( $duplicate_term ) {
2376
-		$wpdb->delete( $wpdb->terms, array( 'term_id' => $term_id ) );
2377
-		$wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $tt_id ) );
2374
+	$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));
2375
+	if ($duplicate_term) {
2376
+		$wpdb->delete($wpdb->terms, array('term_id' => $term_id));
2377
+		$wpdb->delete($wpdb->term_taxonomy, array('term_taxonomy_id' => $tt_id));
2378 2378
 
2379 2379
 		$term_id = (int) $duplicate_term->term_id;
2380 2380
 		$tt_id   = (int) $duplicate_term->term_taxonomy_id;
2381 2381
 
2382
-		clean_term_cache( $term_id, $taxonomy );
2383
-		return array( 'term_id' => $term_id, 'term_taxonomy_id' => $tt_id );
2382
+		clean_term_cache($term_id, $taxonomy);
2383
+		return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
2384 2384
 	}
2385 2385
 
2386 2386
 	/**
@@ -2392,7 +2392,7 @@  discard block
 block discarded – undo
2392 2392
 	 * @param int    $tt_id    Term taxonomy ID.
2393 2393
 	 * @param string $taxonomy Taxonomy slug.
2394 2394
 	 */
2395
-	do_action( "create_term", $term_id, $tt_id, $taxonomy );
2395
+	do_action("create_term", $term_id, $tt_id, $taxonomy);
2396 2396
 
2397 2397
 	/**
2398 2398
 	 * Fires after a new term is created for a specific taxonomy.
@@ -2405,7 +2405,7 @@  discard block
 block discarded – undo
2405 2405
 	 * @param int $term_id Term ID.
2406 2406
 	 * @param int $tt_id   Term taxonomy ID.
2407 2407
 	 */
2408
-	do_action( "create_$taxonomy", $term_id, $tt_id );
2408
+	do_action("create_$taxonomy", $term_id, $tt_id);
2409 2409
 
2410 2410
 	/**
2411 2411
 	 * Filters the term ID after a new term is created.
@@ -2415,7 +2415,7 @@  discard block
 block discarded – undo
2415 2415
 	 * @param int $term_id Term ID.
2416 2416
 	 * @param int $tt_id   Taxonomy term ID.
2417 2417
 	 */
2418
-	$term_id = apply_filters( 'term_id_filter', $term_id, $tt_id );
2418
+	$term_id = apply_filters('term_id_filter', $term_id, $tt_id);
2419 2419
 
2420 2420
 	clean_term_cache($term_id, $taxonomy);
2421 2421
 
@@ -2428,7 +2428,7 @@  discard block
 block discarded – undo
2428 2428
 	 * @param int    $tt_id    Term taxonomy ID.
2429 2429
 	 * @param string $taxonomy Taxonomy slug.
2430 2430
 	 */
2431
-	do_action( 'created_term', $term_id, $tt_id, $taxonomy );
2431
+	do_action('created_term', $term_id, $tt_id, $taxonomy);
2432 2432
 
2433 2433
 	/**
2434 2434
 	 * Fires after a new term in a specific taxonomy is created, and after the term
@@ -2441,7 +2441,7 @@  discard block
 block discarded – undo
2441 2441
 	 * @param int $term_id Term ID.
2442 2442
 	 * @param int $tt_id   Term taxonomy ID.
2443 2443
 	 */
2444
-	do_action( "created_$taxonomy", $term_id, $tt_id );
2444
+	do_action("created_$taxonomy", $term_id, $tt_id);
2445 2445
 
2446 2446
 	return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
2447 2447
 }
@@ -2468,19 +2468,19 @@  discard block
 block discarded – undo
2468 2468
  * @param bool             $append    Optional. If false will delete difference of terms. Default false.
2469 2469
  * @return array|WP_Error Term taxonomy IDs of the affected terms.
2470 2470
  */
2471
-function wp_set_object_terms( $object_id, $terms, $taxonomy, $append = false ) {
2471
+function wp_set_object_terms($object_id, $terms, $taxonomy, $append = false) {
2472 2472
 	global $wpdb;
2473 2473
 
2474 2474
 	$object_id = (int) $object_id;
2475 2475
 
2476
-	if ( ! taxonomy_exists($taxonomy) )
2476
+	if ( ! taxonomy_exists($taxonomy))
2477 2477
 		return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
2478 2478
 
2479
-	if ( !is_array($terms) )
2479
+	if ( ! is_array($terms))
2480 2480
 		$terms = array($terms);
2481 2481
 
2482
-	if ( ! $append )
2483
-		$old_tt_ids =  wp_get_object_terms($object_id, $taxonomy, array('fields' => 'tt_ids', 'orderby' => 'none'));
2482
+	if ( ! $append)
2483
+		$old_tt_ids = wp_get_object_terms($object_id, $taxonomy, array('fields' => 'tt_ids', 'orderby' => 'none'));
2484 2484
 	else
2485 2485
 		$old_tt_ids = array();
2486 2486
 
@@ -2488,23 +2488,23 @@  discard block
 block discarded – undo
2488 2488
 	$term_ids = array();
2489 2489
 	$new_tt_ids = array();
2490 2490
 
2491
-	foreach ( (array) $terms as $term) {
2492
-		if ( !strlen(trim($term)) )
2491
+	foreach ((array) $terms as $term) {
2492
+		if ( ! strlen(trim($term)))
2493 2493
 			continue;
2494 2494
 
2495
-		if ( !$term_info = term_exists($term, $taxonomy) ) {
2495
+		if ( ! $term_info = term_exists($term, $taxonomy)) {
2496 2496
 			// Skip if a non-existent term ID is passed.
2497
-			if ( is_int($term) )
2497
+			if (is_int($term))
2498 2498
 				continue;
2499 2499
 			$term_info = wp_insert_term($term, $taxonomy);
2500 2500
 		}
2501
-		if ( is_wp_error($term_info) )
2501
+		if (is_wp_error($term_info))
2502 2502
 			return $term_info;
2503 2503
 		$term_ids[] = $term_info['term_id'];
2504 2504
 		$tt_id = $term_info['term_taxonomy_id'];
2505 2505
 		$tt_ids[] = $tt_id;
2506 2506
 
2507
-		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 ) ) )
2507
+		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)))
2508 2508
 			continue;
2509 2509
 
2510 2510
 		/**
@@ -2515,8 +2515,8 @@  discard block
 block discarded – undo
2515 2515
 		 * @param int $object_id Object ID.
2516 2516
 		 * @param int $tt_id     Term taxonomy ID.
2517 2517
 		 */
2518
-		do_action( 'add_term_relationship', $object_id, $tt_id );
2519
-		$wpdb->insert( $wpdb->term_relationships, array( 'object_id' => $object_id, 'term_taxonomy_id' => $tt_id ) );
2518
+		do_action('add_term_relationship', $object_id, $tt_id);
2519
+		$wpdb->insert($wpdb->term_relationships, array('object_id' => $object_id, 'term_taxonomy_id' => $tt_id));
2520 2520
 
2521 2521
 		/**
2522 2522
 		 * Fires immediately after an object-term relationship is added.
@@ -2526,42 +2526,42 @@  discard block
 block discarded – undo
2526 2526
 		 * @param int $object_id Object ID.
2527 2527
 		 * @param int $tt_id     Term taxonomy ID.
2528 2528
 		 */
2529
-		do_action( 'added_term_relationship', $object_id, $tt_id );
2529
+		do_action('added_term_relationship', $object_id, $tt_id);
2530 2530
 		$new_tt_ids[] = $tt_id;
2531 2531
 	}
2532 2532
 
2533
-	if ( $new_tt_ids )
2534
-		wp_update_term_count( $new_tt_ids, $taxonomy );
2533
+	if ($new_tt_ids)
2534
+		wp_update_term_count($new_tt_ids, $taxonomy);
2535 2535
 
2536
-	if ( ! $append ) {
2537
-		$delete_tt_ids = array_diff( $old_tt_ids, $tt_ids );
2536
+	if ( ! $append) {
2537
+		$delete_tt_ids = array_diff($old_tt_ids, $tt_ids);
2538 2538
 
2539
-		if ( $delete_tt_ids ) {
2540
-			$in_delete_tt_ids = "'" . implode( "', '", $delete_tt_ids ) . "'";
2541
-			$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 ) );
2542
-			$delete_term_ids = array_map( 'intval', $delete_term_ids );
2539
+		if ($delete_tt_ids) {
2540
+			$in_delete_tt_ids = "'".implode("', '", $delete_tt_ids)."'";
2541
+			$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));
2542
+			$delete_term_ids = array_map('intval', $delete_term_ids);
2543 2543
 
2544
-			$remove = wp_remove_object_terms( $object_id, $delete_term_ids, $taxonomy );
2545
-			if ( is_wp_error( $remove ) ) {
2544
+			$remove = wp_remove_object_terms($object_id, $delete_term_ids, $taxonomy);
2545
+			if (is_wp_error($remove)) {
2546 2546
 				return $remove;
2547 2547
 			}
2548 2548
 		}
2549 2549
 	}
2550 2550
 
2551 2551
 	$t = get_taxonomy($taxonomy);
2552
-	if ( ! $append && isset($t->sort) && $t->sort ) {
2552
+	if ( ! $append && isset($t->sort) && $t->sort) {
2553 2553
 		$values = array();
2554 2554
 		$term_order = 0;
2555 2555
 		$final_tt_ids = wp_get_object_terms($object_id, $taxonomy, array('fields' => 'tt_ids'));
2556
-		foreach ( $tt_ids as $tt_id )
2557
-			if ( in_array($tt_id, $final_tt_ids) )
2558
-				$values[] = $wpdb->prepare( "(%d, %d, %d)", $object_id, $tt_id, ++$term_order);
2559
-		if ( $values )
2560
-			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)" ) )
2561
-				return new WP_Error( 'db_insert_error', __( 'Could not insert term relationship into the database' ), $wpdb->last_error );
2556
+		foreach ($tt_ids as $tt_id)
2557
+			if (in_array($tt_id, $final_tt_ids))
2558
+				$values[] = $wpdb->prepare("(%d, %d, %d)", $object_id, $tt_id, ++$term_order);
2559
+		if ($values)
2560
+			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)"))
2561
+				return new WP_Error('db_insert_error', __('Could not insert term relationship into the database'), $wpdb->last_error);
2562 2562
 	}
2563 2563
 
2564
-	wp_cache_delete( $object_id, $taxonomy . '_relationships' );
2564
+	wp_cache_delete($object_id, $taxonomy.'_relationships');
2565 2565
 
2566 2566
 	/**
2567 2567
 	 * Fires after an object's terms have been set.
@@ -2575,7 +2575,7 @@  discard block
 block discarded – undo
2575 2575
 	 * @param bool   $append     Whether to append new terms to the old terms.
2576 2576
 	 * @param array  $old_tt_ids Old array of term taxonomy IDs.
2577 2577
 	 */
2578
-	do_action( 'set_object_terms', $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids );
2578
+	do_action('set_object_terms', $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids);
2579 2579
 	return $tt_ids;
2580 2580
 }
2581 2581
 
@@ -2589,8 +2589,8 @@  discard block
 block discarded – undo
2589 2589
  * @param array|string     $taxonomy  Taxonomy name.
2590 2590
  * @return array|WP_Error Term taxonomy IDs of the affected terms.
2591 2591
  */
2592
-function wp_add_object_terms( $object_id, $terms, $taxonomy ) {
2593
-	return wp_set_object_terms( $object_id, $terms, $taxonomy, true );
2592
+function wp_add_object_terms($object_id, $terms, $taxonomy) {
2593
+	return wp_set_object_terms($object_id, $terms, $taxonomy, true);
2594 2594
 }
2595 2595
 
2596 2596
 /**
@@ -2605,42 +2605,42 @@  discard block
 block discarded – undo
2605 2605
  * @param array|string     $taxonomy  Taxonomy name.
2606 2606
  * @return bool|WP_Error True on success, false or WP_Error on failure.
2607 2607
  */
2608
-function wp_remove_object_terms( $object_id, $terms, $taxonomy ) {
2608
+function wp_remove_object_terms($object_id, $terms, $taxonomy) {
2609 2609
 	global $wpdb;
2610 2610
 
2611 2611
 	$object_id = (int) $object_id;
2612 2612
 
2613
-	if ( ! taxonomy_exists( $taxonomy ) ) {
2614
-		return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy' ) );
2613
+	if ( ! taxonomy_exists($taxonomy)) {
2614
+		return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
2615 2615
 	}
2616 2616
 
2617
-	if ( ! is_array( $terms ) ) {
2618
-		$terms = array( $terms );
2617
+	if ( ! is_array($terms)) {
2618
+		$terms = array($terms);
2619 2619
 	}
2620 2620
 
2621 2621
 	$tt_ids = array();
2622 2622
 
2623
-	foreach ( (array) $terms as $term ) {
2624
-		if ( ! strlen( trim( $term ) ) ) {
2623
+	foreach ((array) $terms as $term) {
2624
+		if ( ! strlen(trim($term))) {
2625 2625
 			continue;
2626 2626
 		}
2627 2627
 
2628
-		if ( ! $term_info = term_exists( $term, $taxonomy ) ) {
2628
+		if ( ! $term_info = term_exists($term, $taxonomy)) {
2629 2629
 			// Skip if a non-existent term ID is passed.
2630
-			if ( is_int( $term ) ) {
2630
+			if (is_int($term)) {
2631 2631
 				continue;
2632 2632
 			}
2633 2633
 		}
2634 2634
 
2635
-		if ( is_wp_error( $term_info ) ) {
2635
+		if (is_wp_error($term_info)) {
2636 2636
 			return $term_info;
2637 2637
 		}
2638 2638
 
2639 2639
 		$tt_ids[] = $term_info['term_taxonomy_id'];
2640 2640
 	}
2641 2641
 
2642
-	if ( $tt_ids ) {
2643
-		$in_tt_ids = "'" . implode( "', '", $tt_ids ) . "'";
2642
+	if ($tt_ids) {
2643
+		$in_tt_ids = "'".implode("', '", $tt_ids)."'";
2644 2644
 
2645 2645
 		/**
2646 2646
 		 * Fires immediately before an object-term relationship is deleted.
@@ -2650,10 +2650,10 @@  discard block
 block discarded – undo
2650 2650
 		 * @param int   $object_id Object ID.
2651 2651
 		 * @param array $tt_ids    An array of term taxonomy IDs.
2652 2652
 		 */
2653
-		do_action( 'delete_term_relationships', $object_id, $tt_ids );
2654
-		$deleted = $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_tt_ids)", $object_id ) );
2653
+		do_action('delete_term_relationships', $object_id, $tt_ids);
2654
+		$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 2655
 
2656
-		wp_cache_delete( $object_id, $taxonomy . '_relationships' );
2656
+		wp_cache_delete($object_id, $taxonomy.'_relationships');
2657 2657
 
2658 2658
 		/**
2659 2659
 		 * Fires immediately after an object-term relationship is deleted.
@@ -2663,9 +2663,9 @@  discard block
 block discarded – undo
2663 2663
 		 * @param int   $object_id Object ID.
2664 2664
 		 * @param array $tt_ids    An array of term taxonomy IDs.
2665 2665
 		 */
2666
-		do_action( 'deleted_term_relationships', $object_id, $tt_ids );
2666
+		do_action('deleted_term_relationships', $object_id, $tt_ids);
2667 2667
 
2668
-		wp_update_term_count( $tt_ids, $taxonomy );
2668
+		wp_update_term_count($tt_ids, $taxonomy);
2669 2669
 
2670 2670
 		return (bool) $deleted;
2671 2671
 	}
@@ -2696,14 +2696,14 @@  discard block
 block discarded – undo
2696 2696
  * @param object $term The term object that the `$slug` will belong to.
2697 2697
  * @return string Will return a true unique slug.
2698 2698
  */
2699
-function wp_unique_term_slug( $slug, $term ) {
2699
+function wp_unique_term_slug($slug, $term) {
2700 2700
 	global $wpdb;
2701 2701
 
2702 2702
 	$needs_suffix = true;
2703 2703
 	$original_slug = $slug;
2704 2704
 
2705 2705
 	// As of 4.1, duplicate slugs are allowed as long as they're in different taxonomies.
2706
-	if ( ! term_exists( $slug ) || get_option( 'db_version' ) >= 30133 && ! get_term_by( 'slug', $slug, $term->taxonomy ) ) {
2706
+	if ( ! term_exists($slug) || get_option('db_version') >= 30133 && ! get_term_by('slug', $slug, $term->taxonomy)) {
2707 2707
 		$needs_suffix = false;
2708 2708
 	}
2709 2709
 
@@ -2712,18 +2712,18 @@  discard block
 block discarded – undo
2712 2712
 	 * by incorporating parent slugs.
2713 2713
 	 */
2714 2714
 	$parent_suffix = '';
2715
-	if ( $needs_suffix && is_taxonomy_hierarchical( $term->taxonomy ) && ! empty( $term->parent ) ) {
2715
+	if ($needs_suffix && is_taxonomy_hierarchical($term->taxonomy) && ! empty($term->parent)) {
2716 2716
 		$the_parent = $term->parent;
2717
-		while ( ! empty($the_parent) ) {
2717
+		while ( ! empty($the_parent)) {
2718 2718
 			$parent_term = get_term($the_parent, $term->taxonomy);
2719
-			if ( is_wp_error($parent_term) || empty($parent_term) )
2719
+			if (is_wp_error($parent_term) || empty($parent_term))
2720 2720
 				break;
2721
-			$parent_suffix .= '-' . $parent_term->slug;
2722
-			if ( ! term_exists( $slug . $parent_suffix ) ) {
2721
+			$parent_suffix .= '-'.$parent_term->slug;
2722
+			if ( ! term_exists($slug.$parent_suffix)) {
2723 2723
 				break;
2724 2724
 			}
2725 2725
 
2726
-			if ( empty($parent_term->parent) )
2726
+			if (empty($parent_term->parent))
2727 2727
 				break;
2728 2728
 			$the_parent = $parent_term->parent;
2729 2729
 		}
@@ -2740,22 +2740,22 @@  discard block
 block discarded – undo
2740 2740
 	 * @param string $slug         The slug.
2741 2741
 	 * @param object $term         Term object.
2742 2742
 	 */
2743
-	if ( apply_filters( 'wp_unique_term_slug_is_bad_slug', $needs_suffix, $slug, $term ) ) {
2744
-		if ( $parent_suffix ) {
2743
+	if (apply_filters('wp_unique_term_slug_is_bad_slug', $needs_suffix, $slug, $term)) {
2744
+		if ($parent_suffix) {
2745 2745
 			$slug .= $parent_suffix;
2746 2746
 		} else {
2747
-			if ( ! empty( $term->term_id ) )
2748
-				$query = $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s AND term_id != %d", $slug, $term->term_id );
2747
+			if ( ! empty($term->term_id))
2748
+				$query = $wpdb->prepare("SELECT slug FROM $wpdb->terms WHERE slug = %s AND term_id != %d", $slug, $term->term_id);
2749 2749
 			else
2750
-				$query = $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s", $slug );
2750
+				$query = $wpdb->prepare("SELECT slug FROM $wpdb->terms WHERE slug = %s", $slug);
2751 2751
 
2752
-			if ( $wpdb->get_var( $query ) ) {
2752
+			if ($wpdb->get_var($query)) {
2753 2753
 				$num = 2;
2754 2754
 				do {
2755
-					$alt_slug = $slug . "-$num";
2755
+					$alt_slug = $slug."-$num";
2756 2756
 					$num++;
2757
-					$slug_check = $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug ) );
2758
-				} while ( $slug_check );
2757
+					$slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug));
2758
+				} while ($slug_check);
2759 2759
 				$slug = $alt_slug;
2760 2760
 			}
2761 2761
 		}
@@ -2770,7 +2770,7 @@  discard block
 block discarded – undo
2770 2770
 	 * @param object $term          Term object.
2771 2771
 	 * @param string $original_slug Slug originally passed to the function for testing.
2772 2772
 	 */
2773
-	return apply_filters( 'wp_unique_term_slug', $slug, $term, $original_slug );
2773
+	return apply_filters('wp_unique_term_slug', $slug, $term, $original_slug);
2774 2774
 }
2775 2775
 
2776 2776
 /**
@@ -2803,55 +2803,55 @@  discard block
 block discarded – undo
2803 2803
  * @param array|string $args     Optional. Array of get_terms() arguments. Default empty array.
2804 2804
  * @return array|WP_Error Returns Term ID and Taxonomy Term ID
2805 2805
  */
2806
-function wp_update_term( $term_id, $taxonomy, $args = array() ) {
2806
+function wp_update_term($term_id, $taxonomy, $args = array()) {
2807 2807
 	global $wpdb;
2808 2808
 
2809
-	if ( ! taxonomy_exists( $taxonomy ) ) {
2810
-		return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy' ) );
2809
+	if ( ! taxonomy_exists($taxonomy)) {
2810
+		return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
2811 2811
 	}
2812 2812
 
2813 2813
 	$term_id = (int) $term_id;
2814 2814
 
2815 2815
 	// First, get all of the original args
2816
-	$term = get_term( $term_id, $taxonomy );
2816
+	$term = get_term($term_id, $taxonomy);
2817 2817
 
2818
-	if ( is_wp_error( $term ) ) {
2818
+	if (is_wp_error($term)) {
2819 2819
 		return $term;
2820 2820
 	}
2821 2821
 
2822
-	if ( ! $term ) {
2823
-		return new WP_Error( 'invalid_term', __( 'Empty Term' ) );
2822
+	if ( ! $term) {
2823
+		return new WP_Error('invalid_term', __('Empty Term'));
2824 2824
 	}
2825 2825
 
2826 2826
 	$term = (array) $term->data;
2827 2827
 
2828 2828
 	// Escape data pulled from DB.
2829
-	$term = wp_slash( $term );
2829
+	$term = wp_slash($term);
2830 2830
 
2831 2831
 	// Merge old and new args with new args overwriting old ones.
2832 2832
 	$args = array_merge($term, $args);
2833 2833
 
2834
-	$defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
2834
+	$defaults = array('alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
2835 2835
 	$args = wp_parse_args($args, $defaults);
2836 2836
 	$args = sanitize_term($args, $taxonomy, 'db');
2837 2837
 	$parsed_args = $args;
2838 2838
 
2839 2839
 	// expected_slashed ($name)
2840
-	$name = wp_unslash( $args['name'] );
2841
-	$description = wp_unslash( $args['description'] );
2840
+	$name = wp_unslash($args['name']);
2841
+	$description = wp_unslash($args['description']);
2842 2842
 
2843 2843
 	$parsed_args['name'] = $name;
2844 2844
 	$parsed_args['description'] = $description;
2845 2845
 
2846
-	if ( '' == trim($name) )
2846
+	if ('' == trim($name))
2847 2847
 		return new WP_Error('empty_term_name', __('A name is required for this term'));
2848 2848
 
2849
-	if ( $parsed_args['parent'] > 0 && ! term_exists( (int) $parsed_args['parent'] ) ) {
2850
-		return new WP_Error( 'missing_parent', __( 'Parent term does not exist.' ) );
2849
+	if ($parsed_args['parent'] > 0 && ! term_exists((int) $parsed_args['parent'])) {
2850
+		return new WP_Error('missing_parent', __('Parent term does not exist.'));
2851 2851
 	}
2852 2852
 
2853 2853
 	$empty_slug = false;
2854
-	if ( empty( $args['slug'] ) ) {
2854
+	if (empty($args['slug'])) {
2855 2855
 		$empty_slug = true;
2856 2856
 		$slug = sanitize_title($name);
2857 2857
 	} else {
@@ -2860,22 +2860,22 @@  discard block
 block discarded – undo
2860 2860
 
2861 2861
 	$parsed_args['slug'] = $slug;
2862 2862
 
2863
-	$term_group = isset( $parsed_args['term_group'] ) ? $parsed_args['term_group'] : 0;
2864
-	if ( $args['alias_of'] ) {
2865
-		$alias = get_term_by( 'slug', $args['alias_of'], $taxonomy );
2866
-		if ( ! empty( $alias->term_group ) ) {
2863
+	$term_group = isset($parsed_args['term_group']) ? $parsed_args['term_group'] : 0;
2864
+	if ($args['alias_of']) {
2865
+		$alias = get_term_by('slug', $args['alias_of'], $taxonomy);
2866
+		if ( ! empty($alias->term_group)) {
2867 2867
 			// The alias we want is already in a group, so let's use that one.
2868 2868
 			$term_group = $alias->term_group;
2869
-		} elseif ( ! empty( $alias->term_id ) ) {
2869
+		} elseif ( ! empty($alias->term_id)) {
2870 2870
 			/*
2871 2871
 			 * The alias is not in a group, so we create a new one
2872 2872
 			 * and add the alias to it.
2873 2873
 			 */
2874 2874
 			$term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1;
2875 2875
 
2876
-			wp_update_term( $alias->term_id, $taxonomy, array(
2876
+			wp_update_term($alias->term_id, $taxonomy, array(
2877 2877
 				'term_group' => $term_group,
2878
-			) );
2878
+			));
2879 2879
 		}
2880 2880
 
2881 2881
 		$parsed_args['term_group'] = $term_group;
@@ -2894,24 +2894,24 @@  discard block
 block discarded – undo
2894 2894
 	 * @param array  $parsed_args An array of potentially altered update arguments for the given term.
2895 2895
 	 * @param array  $args        An array of update arguments for the given term.
2896 2896
 	 */
2897
-	$parent = apply_filters( 'wp_update_term_parent', $args['parent'], $term_id, $taxonomy, $parsed_args, $args );
2897
+	$parent = apply_filters('wp_update_term_parent', $args['parent'], $term_id, $taxonomy, $parsed_args, $args);
2898 2898
 
2899 2899
 	// Check for duplicate slug
2900
-	$duplicate = get_term_by( 'slug', $slug, $taxonomy );
2901
-	if ( $duplicate && $duplicate->term_id != $term_id ) {
2900
+	$duplicate = get_term_by('slug', $slug, $taxonomy);
2901
+	if ($duplicate && $duplicate->term_id != $term_id) {
2902 2902
 		// If an empty slug was passed or the parent changed, reset the slug to something unique.
2903 2903
 		// Otherwise, bail.
2904
-		if ( $empty_slug || ( $parent != $term['parent']) )
2904
+		if ($empty_slug || ($parent != $term['parent']))
2905 2905
 			$slug = wp_unique_term_slug($slug, (object) $args);
2906 2906
 		else
2907 2907
 			return new WP_Error('duplicate_term_slug', sprintf(__('The slug &#8220;%s&#8221; is already in use by another term'), $slug));
2908 2908
 	}
2909 2909
 
2910
-	$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) );
2910
+	$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));
2911 2911
 
2912 2912
 	// Check whether this is a shared term that needs splitting.
2913
-	$_term_id = _split_shared_term( $term_id, $tt_id );
2914
-	if ( ! is_wp_error( $_term_id ) ) {
2913
+	$_term_id = _split_shared_term($term_id, $tt_id);
2914
+	if ( ! is_wp_error($_term_id)) {
2915 2915
 		$term_id = $_term_id;
2916 2916
 	}
2917 2917
 
@@ -2923,11 +2923,11 @@  discard block
 block discarded – undo
2923 2923
 	 * @param int    $term_id  Term ID.
2924 2924
 	 * @param string $taxonomy Taxonomy slug.
2925 2925
 	 */
2926
-	do_action( 'edit_terms', $term_id, $taxonomy );
2927
-	$wpdb->update($wpdb->terms, compact( 'name', 'slug', 'term_group' ), compact( 'term_id' ) );
2928
-	if ( empty($slug) ) {
2926
+	do_action('edit_terms', $term_id, $taxonomy);
2927
+	$wpdb->update($wpdb->terms, compact('name', 'slug', 'term_group'), compact('term_id'));
2928
+	if (empty($slug)) {
2929 2929
 		$slug = sanitize_title($name, $term_id);
2930
-		$wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) );
2930
+		$wpdb->update($wpdb->terms, compact('slug'), compact('term_id'));
2931 2931
 	}
2932 2932
 
2933 2933
 	/**
@@ -2938,7 +2938,7 @@  discard block
 block discarded – undo
2938 2938
 	 * @param int    $term_id  Term ID
2939 2939
 	 * @param string $taxonomy Taxonomy slug.
2940 2940
 	 */
2941
-	do_action( 'edited_terms', $term_id, $taxonomy );
2941
+	do_action('edited_terms', $term_id, $taxonomy);
2942 2942
 
2943 2943
 	/**
2944 2944
 	 * Fires immediate before a term-taxonomy relationship is updated.
@@ -2948,9 +2948,9 @@  discard block
 block discarded – undo
2948 2948
 	 * @param int    $tt_id    Term taxonomy ID.
2949 2949
 	 * @param string $taxonomy Taxonomy slug.
2950 2950
 	 */
2951
-	do_action( 'edit_term_taxonomy', $tt_id, $taxonomy );
2951
+	do_action('edit_term_taxonomy', $tt_id, $taxonomy);
2952 2952
 
2953
-	$wpdb->update( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent' ), array( 'term_taxonomy_id' => $tt_id ) );
2953
+	$wpdb->update($wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent'), array('term_taxonomy_id' => $tt_id));
2954 2954
 
2955 2955
 	/**
2956 2956
 	 * Fires immediately after a term-taxonomy relationship is updated.
@@ -2960,7 +2960,7 @@  discard block
 block discarded – undo
2960 2960
 	 * @param int    $tt_id    Term taxonomy ID.
2961 2961
 	 * @param string $taxonomy Taxonomy slug.
2962 2962
 	 */
2963
-	do_action( 'edited_term_taxonomy', $tt_id, $taxonomy );
2963
+	do_action('edited_term_taxonomy', $tt_id, $taxonomy);
2964 2964
 
2965 2965
 	/**
2966 2966
 	 * Fires after a term has been updated, but before the term cache has been cleaned.
@@ -2971,7 +2971,7 @@  discard block
 block discarded – undo
2971 2971
 	 * @param int    $tt_id    Term taxonomy ID.
2972 2972
 	 * @param string $taxonomy Taxonomy slug.
2973 2973
 	 */
2974
-	do_action( "edit_term", $term_id, $tt_id, $taxonomy );
2974
+	do_action("edit_term", $term_id, $tt_id, $taxonomy);
2975 2975
 
2976 2976
 	/**
2977 2977
 	 * Fires after a term in a specific taxonomy has been updated, but before the term
@@ -2984,10 +2984,10 @@  discard block
 block discarded – undo
2984 2984
 	 * @param int $term_id Term ID.
2985 2985
 	 * @param int $tt_id   Term taxonomy ID.
2986 2986
 	 */
2987
-	do_action( "edit_$taxonomy", $term_id, $tt_id );
2987
+	do_action("edit_$taxonomy", $term_id, $tt_id);
2988 2988
 
2989 2989
 	/** This filter is documented in wp-includes/taxonomy.php */
2990
-	$term_id = apply_filters( 'term_id_filter', $term_id, $tt_id );
2990
+	$term_id = apply_filters('term_id_filter', $term_id, $tt_id);
2991 2991
 
2992 2992
 	clean_term_cache($term_id, $taxonomy);
2993 2993
 
@@ -3000,7 +3000,7 @@  discard block
 block discarded – undo
3000 3000
 	 * @param int    $tt_id    Term taxonomy ID.
3001 3001
 	 * @param string $taxonomy Taxonomy slug.
3002 3002
 	 */
3003
-	do_action( "edited_term", $term_id, $tt_id, $taxonomy );
3003
+	do_action("edited_term", $term_id, $tt_id, $taxonomy);
3004 3004
 
3005 3005
 	/**
3006 3006
 	 * Fires after a term for a specific taxonomy has been updated, and the term
@@ -3013,7 +3013,7 @@  discard block
 block discarded – undo
3013 3013
 	 * @param int $term_id Term ID.
3014 3014
 	 * @param int $tt_id   Term taxonomy ID.
3015 3015
 	 */
3016
-	do_action( "edited_$taxonomy", $term_id, $tt_id );
3016
+	do_action("edited_$taxonomy", $term_id, $tt_id);
3017 3017
 
3018 3018
 	return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
3019 3019
 }
@@ -3028,14 +3028,14 @@  discard block
 block discarded – undo
3028 3028
  * @param bool $defer Optional. Enable if true, disable if false.
3029 3029
  * @return bool Whether term counting is enabled or disabled.
3030 3030
  */
3031
-function wp_defer_term_counting($defer=null) {
3031
+function wp_defer_term_counting($defer = null) {
3032 3032
 	static $_defer = false;
3033 3033
 
3034
-	if ( is_bool($defer) ) {
3034
+	if (is_bool($defer)) {
3035 3035
 		$_defer = $defer;
3036 3036
 		// flush any deferred counts
3037
-		if ( !$defer )
3038
-			wp_update_term_count( null, null, true );
3037
+		if ( ! $defer)
3038
+			wp_update_term_count(null, null, true);
3039 3039
 	}
3040 3040
 
3041 3041
 	return $_defer;
@@ -3059,30 +3059,30 @@  discard block
 block discarded – undo
3059 3059
  * @param bool      $do_deferred Whether to flush the deferred term counts too. Default false.
3060 3060
  * @return bool If no terms will return false, and if successful will return true.
3061 3061
  */
3062
-function wp_update_term_count( $terms, $taxonomy, $do_deferred = false ) {
3062
+function wp_update_term_count($terms, $taxonomy, $do_deferred = false) {
3063 3063
 	static $_deferred = array();
3064 3064
 
3065
-	if ( $do_deferred ) {
3066
-		foreach ( (array) array_keys($_deferred) as $tax ) {
3067
-			wp_update_term_count_now( $_deferred[$tax], $tax );
3068
-			unset( $_deferred[$tax] );
3065
+	if ($do_deferred) {
3066
+		foreach ((array) array_keys($_deferred) as $tax) {
3067
+			wp_update_term_count_now($_deferred[$tax], $tax);
3068
+			unset($_deferred[$tax]);
3069 3069
 		}
3070 3070
 	}
3071 3071
 
3072
-	if ( empty($terms) )
3072
+	if (empty($terms))
3073 3073
 		return false;
3074 3074
 
3075
-	if ( !is_array($terms) )
3075
+	if ( ! is_array($terms))
3076 3076
 		$terms = array($terms);
3077 3077
 
3078
-	if ( wp_defer_term_counting() ) {
3079
-		if ( !isset($_deferred[$taxonomy]) )
3078
+	if (wp_defer_term_counting()) {
3079
+		if ( ! isset($_deferred[$taxonomy]))
3080 3080
 			$_deferred[$taxonomy] = array();
3081
-		$_deferred[$taxonomy] = array_unique( array_merge($_deferred[$taxonomy], $terms) );
3081
+		$_deferred[$taxonomy] = array_unique(array_merge($_deferred[$taxonomy], $terms));
3082 3082
 		return true;
3083 3083
 	}
3084 3084
 
3085
-	return wp_update_term_count_now( $terms, $taxonomy );
3085
+	return wp_update_term_count_now($terms, $taxonomy);
3086 3086
 }
3087 3087
 
3088 3088
 /**
@@ -3094,25 +3094,25 @@  discard block
 block discarded – undo
3094 3094
  * @param string $taxonomy The context of the term.
3095 3095
  * @return true Always true when complete.
3096 3096
  */
3097
-function wp_update_term_count_now( $terms, $taxonomy ) {
3097
+function wp_update_term_count_now($terms, $taxonomy) {
3098 3098
 	$terms = array_map('intval', $terms);
3099 3099
 
3100 3100
 	$taxonomy = get_taxonomy($taxonomy);
3101
-	if ( !empty($taxonomy->update_count_callback) ) {
3101
+	if ( ! empty($taxonomy->update_count_callback)) {
3102 3102
 		call_user_func($taxonomy->update_count_callback, $terms, $taxonomy);
3103 3103
 	} else {
3104 3104
 		$object_types = (array) $taxonomy->object_type;
3105
-		foreach ( $object_types as &$object_type ) {
3106
-			if ( 0 === strpos( $object_type, 'attachment:' ) )
3107
-				list( $object_type ) = explode( ':', $object_type );
3105
+		foreach ($object_types as &$object_type) {
3106
+			if (0 === strpos($object_type, 'attachment:'))
3107
+				list($object_type) = explode(':', $object_type);
3108 3108
 		}
3109 3109
 
3110
-		if ( $object_types == array_filter( $object_types, 'post_type_exists' ) ) {
3110
+		if ($object_types == array_filter($object_types, 'post_type_exists')) {
3111 3111
 			// Only post types are attached to this taxonomy
3112
-			_update_post_term_count( $terms, $taxonomy );
3112
+			_update_post_term_count($terms, $taxonomy);
3113 3113
 		} else {
3114 3114
 			// Default count updater
3115
-			_update_generic_term_count( $terms, $taxonomy );
3115
+			_update_generic_term_count($terms, $taxonomy);
3116 3116
 		}
3117 3117
 	}
3118 3118
 
@@ -3144,17 +3144,17 @@  discard block
 block discarded – undo
3144 3144
 function clean_object_term_cache($object_ids, $object_type) {
3145 3145
 	global $_wp_suspend_cache_invalidation;
3146 3146
 
3147
-	if ( ! empty( $_wp_suspend_cache_invalidation ) ) {
3147
+	if ( ! empty($_wp_suspend_cache_invalidation)) {
3148 3148
 		return;
3149 3149
 	}
3150 3150
 
3151
-	if ( !is_array($object_ids) )
3151
+	if ( ! is_array($object_ids))
3152 3152
 		$object_ids = array($object_ids);
3153 3153
 
3154
-	$taxonomies = get_object_taxonomies( $object_type );
3154
+	$taxonomies = get_object_taxonomies($object_type);
3155 3155
 
3156
-	foreach ( $object_ids as $id ) {
3157
-		foreach ( $taxonomies as $taxonomy ) {
3156
+	foreach ($object_ids as $id) {
3157
+		foreach ($taxonomies as $taxonomy) {
3158 3158
 			wp_cache_delete($id, "{$taxonomy}_relationships");
3159 3159
 		}
3160 3160
 	}
@@ -3167,7 +3167,7 @@  discard block
 block discarded – undo
3167 3167
 	 * @param array  $object_ids An array of object IDs.
3168 3168
 	 * @param string $objet_type Object type.
3169 3169
 	 */
3170
-	do_action( 'clean_object_term_cache', $object_ids, $object_type );
3170
+	do_action('clean_object_term_cache', $object_ids, $object_type);
3171 3171
 }
3172 3172
 
3173 3173
 /**
@@ -3187,37 +3187,37 @@  discard block
 block discarded – undo
3187 3187
 function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true) {
3188 3188
 	global $wpdb, $_wp_suspend_cache_invalidation;
3189 3189
 
3190
-	if ( ! empty( $_wp_suspend_cache_invalidation ) ) {
3190
+	if ( ! empty($_wp_suspend_cache_invalidation)) {
3191 3191
 		return;
3192 3192
 	}
3193 3193
 
3194
-	if ( !is_array($ids) )
3194
+	if ( ! is_array($ids))
3195 3195
 		$ids = array($ids);
3196 3196
 
3197 3197
 	$taxonomies = array();
3198 3198
 	// If no taxonomy, assume tt_ids.
3199
-	if ( empty($taxonomy) ) {
3199
+	if (empty($taxonomy)) {
3200 3200
 		$tt_ids = array_map('intval', $ids);
3201 3201
 		$tt_ids = implode(', ', $tt_ids);
3202 3202
 		$terms = $wpdb->get_results("SELECT term_id, taxonomy FROM $wpdb->term_taxonomy WHERE term_taxonomy_id IN ($tt_ids)");
3203 3203
 		$ids = array();
3204
-		foreach ( (array) $terms as $term ) {
3204
+		foreach ((array) $terms as $term) {
3205 3205
 			$taxonomies[] = $term->taxonomy;
3206 3206
 			$ids[] = $term->term_id;
3207
-			wp_cache_delete( $term->term_id, 'terms' );
3207
+			wp_cache_delete($term->term_id, 'terms');
3208 3208
 		}
3209 3209
 		$taxonomies = array_unique($taxonomies);
3210 3210
 	} else {
3211 3211
 		$taxonomies = array($taxonomy);
3212
-		foreach ( $taxonomies as $taxonomy ) {
3213
-			foreach ( $ids as $id ) {
3214
-				wp_cache_delete( $id, 'terms' );
3212
+		foreach ($taxonomies as $taxonomy) {
3213
+			foreach ($ids as $id) {
3214
+				wp_cache_delete($id, 'terms');
3215 3215
 			}
3216 3216
 		}
3217 3217
 	}
3218 3218
 
3219
-	foreach ( $taxonomies as $taxonomy ) {
3220
-		if ( $clean_taxonomy ) {
3219
+	foreach ($taxonomies as $taxonomy) {
3220
+		if ($clean_taxonomy) {
3221 3221
 			wp_cache_delete('all_ids', $taxonomy);
3222 3222
 			wp_cache_delete('get', $taxonomy);
3223 3223
 			delete_option("{$taxonomy}_children");
@@ -3235,10 +3235,10 @@  discard block
 block discarded – undo
3235 3235
 		 * @param string $taxonomy       Taxonomy slug.
3236 3236
 		 * @param bool   $clean_taxonomy Whether or not to clean taxonomy-wide caches
3237 3237
 		 */
3238
-		do_action( 'clean_term_cache', $ids, $taxonomy, $clean_taxonomy );
3238
+		do_action('clean_term_cache', $ids, $taxonomy, $clean_taxonomy);
3239 3239
 	}
3240 3240
 
3241
-	wp_cache_set( 'last_changed', microtime(), 'terms' );
3241
+	wp_cache_set('last_changed', microtime(), 'terms');
3242 3242
 }
3243 3243
 
3244 3244
 /**
@@ -3254,33 +3254,33 @@  discard block
 block discarded – undo
3254 3254
  * @param string $taxonomy Taxonomy name.
3255 3255
  * @return bool|array Array of `WP_Term` objects, if cached False if cache is empty for `$taxonomy` and `$id`.
3256 3256
  */
3257
-function get_object_term_cache( $id, $taxonomy ) {
3258
-	$_term_ids = wp_cache_get( $id, "{$taxonomy}_relationships" );
3257
+function get_object_term_cache($id, $taxonomy) {
3258
+	$_term_ids = wp_cache_get($id, "{$taxonomy}_relationships");
3259 3259
 
3260 3260
 	// We leave the priming of relationship caches to upstream functions.
3261
-	if ( false === $_term_ids ) {
3261
+	if (false === $_term_ids) {
3262 3262
 		return false;
3263 3263
 	}
3264 3264
 
3265 3265
 	// Backward compatibility for if a plugin is putting objects into the cache, rather than IDs.
3266 3266
 	$term_ids = array();
3267
-	foreach ( $_term_ids as $term_id ) {
3268
-		if ( is_numeric( $term_id ) ) {
3269
-			$term_ids[] = intval( $term_id );
3270
-		} elseif ( isset( $term_id->term_id ) ) {
3271
-			$term_ids[] = intval( $term_id->term_id );
3267
+	foreach ($_term_ids as $term_id) {
3268
+		if (is_numeric($term_id)) {
3269
+			$term_ids[] = intval($term_id);
3270
+		} elseif (isset($term_id->term_id)) {
3271
+			$term_ids[] = intval($term_id->term_id);
3272 3272
 		}
3273 3273
 	}
3274 3274
 
3275 3275
 	// Fill the term objects.
3276
-	_prime_term_caches( $term_ids );
3276
+	_prime_term_caches($term_ids);
3277 3277
 
3278 3278
 	$terms = array();
3279
-	foreach ( $term_ids as $term_id ) {
3280
-		$terms[] = wp_cache_get( $term_id, 'terms' );
3279
+	foreach ($term_ids as $term_id) {
3280
+		$terms[] = wp_cache_get($term_id, 'terms');
3281 3281
 	}
3282 3282
 
3283
-	return array_map( 'get_term', $terms );
3283
+	return array_map('get_term', $terms);
3284 3284
 }
3285 3285
 
3286 3286
 /**
@@ -3300,10 +3300,10 @@  discard block
 block discarded – undo
3300 3300
  * @return void|false False if all of the terms in `$object_ids` are already cached.
3301 3301
  */
3302 3302
 function update_object_term_cache($object_ids, $object_type) {
3303
-	if ( empty($object_ids) )
3303
+	if (empty($object_ids))
3304 3304
 		return;
3305 3305
 
3306
-	if ( !is_array($object_ids) )
3306
+	if ( ! is_array($object_ids))
3307 3307
 		$object_ids = explode(',', $object_ids);
3308 3308
 
3309 3309
 	$object_ids = array_map('intval', $object_ids);
@@ -3311,42 +3311,42 @@  discard block
 block discarded – undo
3311 3311
 	$taxonomies = get_object_taxonomies($object_type);
3312 3312
 
3313 3313
 	$ids = array();
3314
-	foreach ( (array) $object_ids as $id ) {
3315
-		foreach ( $taxonomies as $taxonomy ) {
3316
-			if ( false === wp_cache_get($id, "{$taxonomy}_relationships") ) {
3314
+	foreach ((array) $object_ids as $id) {
3315
+		foreach ($taxonomies as $taxonomy) {
3316
+			if (false === wp_cache_get($id, "{$taxonomy}_relationships")) {
3317 3317
 				$ids[] = $id;
3318 3318
 				break;
3319 3319
 			}
3320 3320
 		}
3321 3321
 	}
3322 3322
 
3323
-	if ( empty( $ids ) )
3323
+	if (empty($ids))
3324 3324
 		return false;
3325 3325
 
3326
-	$terms = wp_get_object_terms( $ids, $taxonomies, array(
3326
+	$terms = wp_get_object_terms($ids, $taxonomies, array(
3327 3327
 		'fields' => 'all_with_object_id',
3328 3328
 		'orderby' => 'name',
3329 3329
 		'update_term_meta_cache' => false,
3330
-	) );
3330
+	));
3331 3331
 
3332 3332
 	$object_terms = array();
3333
-	foreach ( (array) $terms as $term ) {
3334
-		$object_terms[ $term->object_id ][ $term->taxonomy ][] = $term->term_id;
3333
+	foreach ((array) $terms as $term) {
3334
+		$object_terms[$term->object_id][$term->taxonomy][] = $term->term_id;
3335 3335
 	}
3336 3336
 
3337
-	foreach ( $ids as $id ) {
3338
-		foreach ( $taxonomies as $taxonomy ) {
3339
-			if ( ! isset($object_terms[$id][$taxonomy]) ) {
3340
-				if ( !isset($object_terms[$id]) )
3337
+	foreach ($ids as $id) {
3338
+		foreach ($taxonomies as $taxonomy) {
3339
+			if ( ! isset($object_terms[$id][$taxonomy])) {
3340
+				if ( ! isset($object_terms[$id]))
3341 3341
 					$object_terms[$id] = array();
3342 3342
 				$object_terms[$id][$taxonomy] = array();
3343 3343
 			}
3344 3344
 		}
3345 3345
 	}
3346 3346
 
3347
-	foreach ( $object_terms as $id => $value ) {
3348
-		foreach ( $value as $taxonomy => $terms ) {
3349
-			wp_cache_add( $id, $terms, "{$taxonomy}_relationships" );
3347
+	foreach ($object_terms as $id => $value) {
3348
+		foreach ($value as $taxonomy => $terms) {
3349
+			wp_cache_add($id, $terms, "{$taxonomy}_relationships");
3350 3350
 		}
3351 3351
 	}
3352 3352
 }
@@ -3359,15 +3359,15 @@  discard block
 block discarded – undo
3359 3359
  * @param array  $terms    List of term objects to change.
3360 3360
  * @param string $taxonomy Optional. Update Term to this taxonomy in cache. Default empty.
3361 3361
  */
3362
-function update_term_cache( $terms, $taxonomy = '' ) {
3363
-	foreach ( (array) $terms as $term ) {
3362
+function update_term_cache($terms, $taxonomy = '') {
3363
+	foreach ((array) $terms as $term) {
3364 3364
 		// Create a copy in case the array was passed by reference.
3365 3365
 		$_term = clone $term;
3366 3366
 
3367 3367
 		// Object ID should not be cached.
3368
-		unset( $_term->object_id );
3368
+		unset($_term->object_id);
3369 3369
 
3370
-		wp_cache_add( $term->term_id, $_term, 'terms' );
3370
+		wp_cache_add($term->term_id, $_term, 'terms');
3371 3371
 	}
3372 3372
 }
3373 3373
 
@@ -3384,17 +3384,17 @@  discard block
 block discarded – undo
3384 3384
  * @param string $taxonomy Taxonomy name.
3385 3385
  * @return array Empty if $taxonomy isn't hierarchical or returns children as Term IDs.
3386 3386
  */
3387
-function _get_term_hierarchy( $taxonomy ) {
3388
-	if ( !is_taxonomy_hierarchical($taxonomy) )
3387
+function _get_term_hierarchy($taxonomy) {
3388
+	if ( ! is_taxonomy_hierarchical($taxonomy))
3389 3389
 		return array();
3390 3390
 	$children = get_option("{$taxonomy}_children");
3391 3391
 
3392
-	if ( is_array($children) )
3392
+	if (is_array($children))
3393 3393
 		return $children;
3394 3394
 	$children = array();
3395 3395
 	$terms = get_terms($taxonomy, array('get' => 'all', 'orderby' => 'id', 'fields' => 'id=>parent'));
3396
-	foreach ( $terms as $term_id => $parent ) {
3397
-		if ( $parent > 0 )
3396
+	foreach ($terms as $term_id => $parent) {
3397
+		if ($parent > 0)
3398 3398
 			$children[$parent][] = $term_id;
3399 3399
 	}
3400 3400
 	update_option("{$taxonomy}_children", $children);
@@ -3421,48 +3421,48 @@  discard block
 block discarded – undo
3421 3421
  *                          with 1 as value. Default empty array.
3422 3422
  * @return array|WP_Error The subset of $terms that are descendants of $term_id.
3423 3423
  */
3424
-function _get_term_children( $term_id, $terms, $taxonomy, &$ancestors = array() ) {
3424
+function _get_term_children($term_id, $terms, $taxonomy, &$ancestors = array()) {
3425 3425
 	$empty_array = array();
3426
-	if ( empty($terms) )
3426
+	if (empty($terms))
3427 3427
 		return $empty_array;
3428 3428
 
3429 3429
 	$term_list = array();
3430 3430
 	$has_children = _get_term_hierarchy($taxonomy);
3431 3431
 
3432
-	if  ( ( 0 != $term_id ) && ! isset($has_children[$term_id]) )
3432
+	if ((0 != $term_id) && ! isset($has_children[$term_id]))
3433 3433
 		return $empty_array;
3434 3434
 
3435 3435
 	// Include the term itself in the ancestors array, so we can properly detect when a loop has occurred.
3436
-	if ( empty( $ancestors ) ) {
3437
-		$ancestors[ $term_id ] = 1;
3436
+	if (empty($ancestors)) {
3437
+		$ancestors[$term_id] = 1;
3438 3438
 	}
3439 3439
 
3440
-	foreach ( (array) $terms as $term ) {
3440
+	foreach ((array) $terms as $term) {
3441 3441
 		$use_id = false;
3442
-		if ( !is_object($term) ) {
3442
+		if ( ! is_object($term)) {
3443 3443
 			$term = get_term($term, $taxonomy);
3444
-			if ( is_wp_error( $term ) )
3444
+			if (is_wp_error($term))
3445 3445
 				return $term;
3446 3446
 			$use_id = true;
3447 3447
 		}
3448 3448
 
3449 3449
 		// Don't recurse if we've already identified the term as a child - this indicates a loop.
3450
-		if ( isset( $ancestors[ $term->term_id ] ) ) {
3450
+		if (isset($ancestors[$term->term_id])) {
3451 3451
 			continue;
3452 3452
 		}
3453 3453
 
3454
-		if ( $term->parent == $term_id ) {
3455
-			if ( $use_id )
3454
+		if ($term->parent == $term_id) {
3455
+			if ($use_id)
3456 3456
 				$term_list[] = $term->term_id;
3457 3457
 			else
3458 3458
 				$term_list[] = $term;
3459 3459
 
3460
-			if ( !isset($has_children[$term->term_id]) )
3460
+			if ( ! isset($has_children[$term->term_id]))
3461 3461
 				continue;
3462 3462
 
3463
-			$ancestors[ $term->term_id ] = 1;
3463
+			$ancestors[$term->term_id] = 1;
3464 3464
 
3465
-			if ( $children = _get_term_children( $term->term_id, $terms, $taxonomy, $ancestors) )
3465
+			if ($children = _get_term_children($term->term_id, $terms, $taxonomy, $ancestors))
3466 3466
 				$term_list = array_merge($term_list, $children);
3467 3467
 		}
3468 3468
 	}
@@ -3484,23 +3484,23 @@  discard block
 block discarded – undo
3484 3484
  * @param array  $terms    List of term objects, passed by reference.
3485 3485
  * @param string $taxonomy Term context.
3486 3486
  */
3487
-function _pad_term_counts( &$terms, $taxonomy ) {
3487
+function _pad_term_counts(&$terms, $taxonomy) {
3488 3488
 	global $wpdb;
3489 3489
 
3490 3490
 	// This function only works for hierarchical taxonomies like post categories.
3491
-	if ( !is_taxonomy_hierarchical( $taxonomy ) )
3491
+	if ( ! is_taxonomy_hierarchical($taxonomy))
3492 3492
 		return;
3493 3493
 
3494 3494
 	$term_hier = _get_term_hierarchy($taxonomy);
3495 3495
 
3496
-	if ( empty($term_hier) )
3496
+	if (empty($term_hier))
3497 3497
 		return;
3498 3498
 
3499 3499
 	$term_items = array();
3500 3500
 	$terms_by_id = array();
3501 3501
 	$term_ids = array();
3502 3502
 
3503
-	foreach ( (array) $terms as $key => $term ) {
3503
+	foreach ((array) $terms as $key => $term) {
3504 3504
 		$terms_by_id[$term->term_id] = & $terms[$key];
3505 3505
 		$term_ids[$term->term_taxonomy_id] = $term->term_id;
3506 3506
 	}
@@ -3508,33 +3508,33 @@  discard block
 block discarded – undo
3508 3508
 	// Get the object and term ids and stick them in a lookup table.
3509 3509
 	$tax_obj = get_taxonomy($taxonomy);
3510 3510
 	$object_types = esc_sql($tax_obj->object_type);
3511
-	$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'");
3512
-	foreach ( $results as $row ) {
3511
+	$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'");
3512
+	foreach ($results as $row) {
3513 3513
 		$id = $term_ids[$row->term_taxonomy_id];
3514 3514
 		$term_items[$id][$row->object_id] = isset($term_items[$id][$row->object_id]) ? ++$term_items[$id][$row->object_id] : 1;
3515 3515
 	}
3516 3516
 
3517 3517
 	// Touch every ancestor's lookup row for each post in each term.
3518
-	foreach ( $term_ids as $term_id ) {
3518
+	foreach ($term_ids as $term_id) {
3519 3519
 		$child = $term_id;
3520 3520
 		$ancestors = array();
3521
-		while ( !empty( $terms_by_id[$child] ) && $parent = $terms_by_id[$child]->parent ) {
3521
+		while ( ! empty($terms_by_id[$child]) && $parent = $terms_by_id[$child]->parent) {
3522 3522
 			$ancestors[] = $child;
3523
-			if ( !empty( $term_items[$term_id] ) )
3524
-				foreach ( $term_items[$term_id] as $item_id => $touches ) {
3525
-					$term_items[$parent][$item_id] = isset($term_items[$parent][$item_id]) ? ++$term_items[$parent][$item_id]: 1;
3523
+			if ( ! empty($term_items[$term_id]))
3524
+				foreach ($term_items[$term_id] as $item_id => $touches) {
3525
+					$term_items[$parent][$item_id] = isset($term_items[$parent][$item_id]) ? ++$term_items[$parent][$item_id] : 1;
3526 3526
 				}
3527 3527
 			$child = $parent;
3528 3528
 
3529
-			if ( in_array( $parent, $ancestors ) ) {
3529
+			if (in_array($parent, $ancestors)) {
3530 3530
 				break;
3531 3531
 			}
3532 3532
 		}
3533 3533
 	}
3534 3534
 
3535 3535
 	// Transfer the touched cells.
3536
-	foreach ( (array) $term_items as $id => $items )
3537
-		if ( isset($terms_by_id[$id]) )
3536
+	foreach ((array) $term_items as $id => $items)
3537
+		if (isset($terms_by_id[$id]))
3538 3538
 			$terms_by_id[$id]->count = count($items);
3539 3539
 }
3540 3540
 
@@ -3549,17 +3549,17 @@  discard block
 block discarded – undo
3549 3549
  * @param array $term_ids          Array of term IDs.
3550 3550
  * @param bool  $update_meta_cache Optional. Whether to update the meta cache. Default true.
3551 3551
  */
3552
-function _prime_term_caches( $term_ids, $update_meta_cache = true ) {
3552
+function _prime_term_caches($term_ids, $update_meta_cache = true) {
3553 3553
 	global $wpdb;
3554 3554
 
3555
-	$non_cached_ids = _get_non_cached_ids( $term_ids, 'terms' );
3556
-	if ( ! empty( $non_cached_ids ) ) {
3557
-		$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 ) ) ) );
3555
+	$non_cached_ids = _get_non_cached_ids($term_ids, 'terms');
3556
+	if ( ! empty($non_cached_ids)) {
3557
+		$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 3558
 
3559
-		update_term_cache( $fresh_terms, $update_meta_cache );
3559
+		update_term_cache($fresh_terms, $update_meta_cache);
3560 3560
 
3561
-		if ( $update_meta_cache ) {
3562
-			update_termmeta_cache( $non_cached_ids );
3561
+		if ($update_meta_cache) {
3562
+			update_termmeta_cache($non_cached_ids);
3563 3563
 		}
3564 3564
 	}
3565 3565
 }
@@ -3582,40 +3582,40 @@  discard block
 block discarded – undo
3582 3582
  * @param array  $terms    List of Term taxonomy IDs.
3583 3583
  * @param object $taxonomy Current taxonomy object of terms.
3584 3584
  */
3585
-function _update_post_term_count( $terms, $taxonomy ) {
3585
+function _update_post_term_count($terms, $taxonomy) {
3586 3586
 	global $wpdb;
3587 3587
 
3588 3588
 	$object_types = (array) $taxonomy->object_type;
3589 3589
 
3590
-	foreach ( $object_types as &$object_type )
3591
-		list( $object_type ) = explode( ':', $object_type );
3590
+	foreach ($object_types as &$object_type)
3591
+		list($object_type) = explode(':', $object_type);
3592 3592
 
3593
-	$object_types = array_unique( $object_types );
3593
+	$object_types = array_unique($object_types);
3594 3594
 
3595
-	if ( false !== ( $check_attachments = array_search( 'attachment', $object_types ) ) ) {
3596
-		unset( $object_types[ $check_attachments ] );
3595
+	if (false !== ($check_attachments = array_search('attachment', $object_types))) {
3596
+		unset($object_types[$check_attachments]);
3597 3597
 		$check_attachments = true;
3598 3598
 	}
3599 3599
 
3600
-	if ( $object_types )
3601
-		$object_types = esc_sql( array_filter( $object_types, 'post_type_exists' ) );
3600
+	if ($object_types)
3601
+		$object_types = esc_sql(array_filter($object_types, 'post_type_exists'));
3602 3602
 
3603
-	foreach ( (array) $terms as $term ) {
3603
+	foreach ((array) $terms as $term) {
3604 3604
 		$count = 0;
3605 3605
 
3606 3606
 		// Attachments can be 'inherit' status, we need to base count off the parent's status if so.
3607
-		if ( $check_attachments )
3608
-			$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 ) );
3607
+		if ($check_attachments)
3608
+			$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));
3609 3609
 
3610
-		if ( $object_types )
3611
-			$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 ) );
3610
+		if ($object_types)
3611
+			$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));
3612 3612
 
3613 3613
 		/** This action is documented in wp-includes/taxonomy.php */
3614
-		do_action( 'edit_term_taxonomy', $term, $taxonomy->name );
3615
-		$wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
3614
+		do_action('edit_term_taxonomy', $term, $taxonomy->name);
3615
+		$wpdb->update($wpdb->term_taxonomy, compact('count'), array('term_taxonomy_id' => $term));
3616 3616
 
3617 3617
 		/** This action is documented in wp-includes/taxonomy.php */
3618
-		do_action( 'edited_term_taxonomy', $term, $taxonomy->name );
3618
+		do_action('edited_term_taxonomy', $term, $taxonomy->name);
3619 3619
 	}
3620 3620
 }
3621 3621
 
@@ -3631,18 +3631,18 @@  discard block
 block discarded – undo
3631 3631
  * @param array  $terms    List of term taxonomy IDs.
3632 3632
  * @param object $taxonomy Current taxonomy object of terms.
3633 3633
  */
3634
-function _update_generic_term_count( $terms, $taxonomy ) {
3634
+function _update_generic_term_count($terms, $taxonomy) {
3635 3635
 	global $wpdb;
3636 3636
 
3637
-	foreach ( (array) $terms as $term ) {
3638
-		$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term ) );
3637
+	foreach ((array) $terms as $term) {
3638
+		$count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term));
3639 3639
 
3640 3640
 		/** This action is documented in wp-includes/taxonomy.php */
3641
-		do_action( 'edit_term_taxonomy', $term, $taxonomy->name );
3642
-		$wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
3641
+		do_action('edit_term_taxonomy', $term, $taxonomy->name);
3642
+		$wpdb->update($wpdb->term_taxonomy, compact('count'), array('term_taxonomy_id' => $term));
3643 3643
 
3644 3644
 		/** This action is documented in wp-includes/taxonomy.php */
3645
-		do_action( 'edited_term_taxonomy', $term, $taxonomy->name );
3645
+		do_action('edited_term_taxonomy', $term, $taxonomy->name);
3646 3646
 	}
3647 3647
 }
3648 3648
 
@@ -3669,23 +3669,23 @@  discard block
 block discarded – undo
3669 3669
  *                      database schema), `$term_id` is returned. When the term is successfully split, the
3670 3670
  *                      new term_id is returned. A WP_Error is returned for miscellaneous errors.
3671 3671
  */
3672
-function _split_shared_term( $term_id, $term_taxonomy_id, $record = true ) {
3672
+function _split_shared_term($term_id, $term_taxonomy_id, $record = true) {
3673 3673
 	global $wpdb;
3674 3674
 
3675
-	if ( is_object( $term_id ) ) {
3675
+	if (is_object($term_id)) {
3676 3676
 		$shared_term = $term_id;
3677
-		$term_id = intval( $shared_term->term_id );
3677
+		$term_id = intval($shared_term->term_id);
3678 3678
 	}
3679 3679
 
3680
-	if ( is_object( $term_taxonomy_id ) ) {
3680
+	if (is_object($term_taxonomy_id)) {
3681 3681
 		$term_taxonomy = $term_taxonomy_id;
3682
-		$term_taxonomy_id = intval( $term_taxonomy->term_taxonomy_id );
3682
+		$term_taxonomy_id = intval($term_taxonomy->term_taxonomy_id);
3683 3683
 	}
3684 3684
 
3685 3685
 	// If there are no shared term_taxonomy rows, there's nothing to do here.
3686
-	$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 ) );
3686
+	$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));
3687 3687
 
3688
-	if ( ! $shared_tt_count ) {
3688
+	if ( ! $shared_tt_count) {
3689 3689
 		return $term_id;
3690 3690
 	}
3691 3691
 
@@ -3693,14 +3693,14 @@  discard block
 block discarded – undo
3693 3693
 	 * Verify that the term_taxonomy_id passed to the function is actually associated with the term_id.
3694 3694
 	 * If there's a mismatch, it may mean that the term is already split. Return the actual term_id from the db.
3695 3695
 	 */
3696
-	$check_term_id = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %d", $term_taxonomy_id ) );
3697
-	if ( $check_term_id != $term_id ) {
3696
+	$check_term_id = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %d", $term_taxonomy_id));
3697
+	if ($check_term_id != $term_id) {
3698 3698
 		return $check_term_id;
3699 3699
 	}
3700 3700
 
3701 3701
 	// Pull up data about the currently shared slug, which we'll use to populate the new one.
3702
-	if ( empty( $shared_term ) ) {
3703
-		$shared_term = $wpdb->get_row( $wpdb->prepare( "SELECT t.* FROM $wpdb->terms t WHERE t.term_id = %d", $term_id ) );
3702
+	if (empty($shared_term)) {
3703
+		$shared_term = $wpdb->get_row($wpdb->prepare("SELECT t.* FROM $wpdb->terms t WHERE t.term_id = %d", $term_id));
3704 3704
 	}
3705 3705
 
3706 3706
 	$new_term_data = array(
@@ -3709,54 +3709,54 @@  discard block
 block discarded – undo
3709 3709
 		'term_group' => $shared_term->term_group,
3710 3710
 	);
3711 3711
 
3712
-	if ( false === $wpdb->insert( $wpdb->terms, $new_term_data ) ) {
3713
-		return new WP_Error( 'db_insert_error', __( 'Could not split shared term.' ), $wpdb->last_error );
3712
+	if (false === $wpdb->insert($wpdb->terms, $new_term_data)) {
3713
+		return new WP_Error('db_insert_error', __('Could not split shared term.'), $wpdb->last_error);
3714 3714
 	}
3715 3715
 
3716 3716
 	$new_term_id = (int) $wpdb->insert_id;
3717 3717
 
3718 3718
 	// Update the existing term_taxonomy to point to the newly created term.
3719
-	$wpdb->update( $wpdb->term_taxonomy,
3720
-		array( 'term_id' => $new_term_id ),
3721
-		array( 'term_taxonomy_id' => $term_taxonomy_id )
3719
+	$wpdb->update($wpdb->term_taxonomy,
3720
+		array('term_id' => $new_term_id),
3721
+		array('term_taxonomy_id' => $term_taxonomy_id)
3722 3722
 	);
3723 3723
 
3724 3724
 	// Reassign child terms to the new parent.
3725
-	if ( empty( $term_taxonomy ) ) {
3726
-		$term_taxonomy = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %d", $term_taxonomy_id ) );
3725
+	if (empty($term_taxonomy)) {
3726
+		$term_taxonomy = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %d", $term_taxonomy_id));
3727 3727
 	}
3728 3728
 
3729
-	$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 ) );
3730
-	if ( ! empty( $children_tt_ids ) ) {
3731
-		foreach ( $children_tt_ids as $child_tt_id ) {
3732
-			$wpdb->update( $wpdb->term_taxonomy,
3733
-				array( 'parent' => $new_term_id ),
3734
-				array( 'term_taxonomy_id' => $child_tt_id )
3729
+	$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));
3730
+	if ( ! empty($children_tt_ids)) {
3731
+		foreach ($children_tt_ids as $child_tt_id) {
3732
+			$wpdb->update($wpdb->term_taxonomy,
3733
+				array('parent' => $new_term_id),
3734
+				array('term_taxonomy_id' => $child_tt_id)
3735 3735
 			);
3736
-			clean_term_cache( $term_id, $term_taxonomy->taxonomy );
3736
+			clean_term_cache($term_id, $term_taxonomy->taxonomy);
3737 3737
 		}
3738 3738
 	} else {
3739 3739
 		// If the term has no children, we must force its taxonomy cache to be rebuilt separately.
3740
-		clean_term_cache( $new_term_id, $term_taxonomy->taxonomy );
3740
+		clean_term_cache($new_term_id, $term_taxonomy->taxonomy);
3741 3741
 	}
3742 3742
 
3743 3743
 	// Clean the cache for term taxonomies formerly shared with the current term.
3744
-	$shared_term_taxonomies = $wpdb->get_row( $wpdb->prepare( "SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d", $term_id ) );
3745
-	if ( $shared_term_taxonomies ) {
3746
-		foreach ( $shared_term_taxonomies as $shared_term_taxonomy ) {
3747
-			clean_term_cache( $term_id, $shared_term_taxonomy );
3744
+	$shared_term_taxonomies = $wpdb->get_row($wpdb->prepare("SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d", $term_id));
3745
+	if ($shared_term_taxonomies) {
3746
+		foreach ($shared_term_taxonomies as $shared_term_taxonomy) {
3747
+			clean_term_cache($term_id, $shared_term_taxonomy);
3748 3748
 		}
3749 3749
 	}
3750 3750
 
3751 3751
 	// Keep a record of term_ids that have been split, keyed by old term_id. See wp_get_split_term().
3752
-	if ( $record ) {
3753
-		$split_term_data = get_option( '_split_terms', array() );
3754
-		if ( ! isset( $split_term_data[ $term_id ] ) ) {
3755
-			$split_term_data[ $term_id ] = array();
3752
+	if ($record) {
3753
+		$split_term_data = get_option('_split_terms', array());
3754
+		if ( ! isset($split_term_data[$term_id])) {
3755
+			$split_term_data[$term_id] = array();
3756 3756
 		}
3757 3757
 
3758
-		$split_term_data[ $term_id ][ $term_taxonomy->taxonomy ] = $new_term_id;
3759
-		update_option( '_split_terms', $split_term_data );
3758
+		$split_term_data[$term_id][$term_taxonomy->taxonomy] = $new_term_id;
3759
+		update_option('_split_terms', $split_term_data);
3760 3760
 	}
3761 3761
 
3762 3762
 	// If we've just split the final shared term, set the "finished" flag.
@@ -3767,8 +3767,8 @@  discard block
 block discarded – undo
3767 3767
 		 HAVING term_tt_count > 1
3768 3768
 		 LIMIT 1"
3769 3769
 	);
3770
-	if ( ! $shared_terms_exist ) {
3771
-		update_option( 'finished_splitting_shared_terms', true );
3770
+	if ( ! $shared_terms_exist) {
3771
+		update_option('finished_splitting_shared_terms', true);
3772 3772
 	}
3773 3773
 
3774 3774
 	/**
@@ -3781,7 +3781,7 @@  discard block
 block discarded – undo
3781 3781
 	 * @param int    $term_taxonomy_id ID for the term_taxonomy row affected by the split.
3782 3782
 	 * @param string $taxonomy         Taxonomy for the split term.
3783 3783
 	 */
3784
-	do_action( 'split_shared_term', $term_id, $new_term_id, $term_taxonomy_id, $term_taxonomy->taxonomy );
3784
+	do_action('split_shared_term', $term_id, $new_term_id, $term_taxonomy_id, $term_taxonomy->taxonomy);
3785 3785
 
3786 3786
 	return $new_term_id;
3787 3787
 }
@@ -3799,20 +3799,20 @@  discard block
 block discarded – undo
3799 3799
 	$lock_name = 'term_split.lock';
3800 3800
 
3801 3801
 	// Try to lock.
3802
-	$lock_result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` ( `option_name`, `option_value`, `autoload` ) VALUES (%s, %s, 'no') /* LOCK */", $lock_name, time() ) );
3802
+	$lock_result = $wpdb->query($wpdb->prepare("INSERT IGNORE INTO `$wpdb->options` ( `option_name`, `option_value`, `autoload` ) VALUES (%s, %s, 'no') /* LOCK */", $lock_name, time()));
3803 3803
 
3804
-	if ( ! $lock_result ) {
3805
-		$lock_result = get_option( $lock_name );
3804
+	if ( ! $lock_result) {
3805
+		$lock_result = get_option($lock_name);
3806 3806
 
3807 3807
 		// Bail if we were unable to create a lock, or if the existing lock is still valid.
3808
-		if ( ! $lock_result || ( $lock_result > ( time() - HOUR_IN_SECONDS ) ) ) {
3809
-			wp_schedule_single_event( time() + ( 5 * MINUTE_IN_SECONDS ), 'wp_split_shared_term_batch' );
3808
+		if ( ! $lock_result || ($lock_result > (time() - HOUR_IN_SECONDS))) {
3809
+			wp_schedule_single_event(time() + (5 * MINUTE_IN_SECONDS), 'wp_split_shared_term_batch');
3810 3810
 			return;
3811 3811
 		}
3812 3812
 	}
3813 3813
 
3814 3814
 	// Update the lock, as by this point we've definitely got a lock, just need to fire the actions.
3815
-	update_option( $lock_name, time() );
3815
+	update_option($lock_name, time());
3816 3816
 
3817 3817
 	// Get a list of shared terms (those with more than one associated row in term_taxonomy).
3818 3818
 	$shared_terms = $wpdb->get_results(
@@ -3824,61 +3824,61 @@  discard block
 block discarded – undo
3824 3824
 	);
3825 3825
 
3826 3826
 	// No more terms, we're done here.
3827
-	if ( ! $shared_terms ) {
3828
-		update_option( 'finished_splitting_shared_terms', true );
3829
-		delete_option( $lock_name );
3827
+	if ( ! $shared_terms) {
3828
+		update_option('finished_splitting_shared_terms', true);
3829
+		delete_option($lock_name);
3830 3830
 		return;
3831 3831
 	}
3832 3832
 
3833 3833
 	// Shared terms found? We'll need to run this script again.
3834
-	wp_schedule_single_event( time() + ( 2 * MINUTE_IN_SECONDS ), 'wp_split_shared_term_batch' );
3834
+	wp_schedule_single_event(time() + (2 * MINUTE_IN_SECONDS), 'wp_split_shared_term_batch');
3835 3835
 
3836 3836
 	// Rekey shared term array for faster lookups.
3837 3837
 	$_shared_terms = array();
3838
-	foreach ( $shared_terms as $shared_term ) {
3839
-		$term_id = intval( $shared_term->term_id );
3840
-		$_shared_terms[ $term_id ] = $shared_term;
3838
+	foreach ($shared_terms as $shared_term) {
3839
+		$term_id = intval($shared_term->term_id);
3840
+		$_shared_terms[$term_id] = $shared_term;
3841 3841
 	}
3842 3842
 	$shared_terms = $_shared_terms;
3843 3843
 
3844 3844
 	// Get term taxonomy data for all shared terms.
3845
-	$shared_term_ids = implode( ',', array_keys( $shared_terms ) );
3846
-	$shared_tts = $wpdb->get_results( "SELECT * FROM {$wpdb->term_taxonomy} WHERE `term_id` IN ({$shared_term_ids})" );
3845
+	$shared_term_ids = implode(',', array_keys($shared_terms));
3846
+	$shared_tts = $wpdb->get_results("SELECT * FROM {$wpdb->term_taxonomy} WHERE `term_id` IN ({$shared_term_ids})");
3847 3847
 
3848 3848
 	// Split term data recording is slow, so we do it just once, outside the loop.
3849
-	$split_term_data = get_option( '_split_terms', array() );
3849
+	$split_term_data = get_option('_split_terms', array());
3850 3850
 	$skipped_first_term = $taxonomies = array();
3851
-	foreach ( $shared_tts as $shared_tt ) {
3852
-		$term_id = intval( $shared_tt->term_id );
3851
+	foreach ($shared_tts as $shared_tt) {
3852
+		$term_id = intval($shared_tt->term_id);
3853 3853
 
3854 3854
 		// Don't split the first tt belonging to a given term_id.
3855
-		if ( ! isset( $skipped_first_term[ $term_id ] ) ) {
3856
-			$skipped_first_term[ $term_id ] = 1;
3855
+		if ( ! isset($skipped_first_term[$term_id])) {
3856
+			$skipped_first_term[$term_id] = 1;
3857 3857
 			continue;
3858 3858
 		}
3859 3859
 
3860
-		if ( ! isset( $split_term_data[ $term_id ] ) ) {
3861
-			$split_term_data[ $term_id ] = array();
3860
+		if ( ! isset($split_term_data[$term_id])) {
3861
+			$split_term_data[$term_id] = array();
3862 3862
 		}
3863 3863
 
3864 3864
 		// Keep track of taxonomies whose hierarchies need flushing.
3865
-		if ( ! isset( $taxonomies[ $shared_tt->taxonomy ] ) ) {
3866
-			$taxonomies[ $shared_tt->taxonomy ] = 1;
3865
+		if ( ! isset($taxonomies[$shared_tt->taxonomy])) {
3866
+			$taxonomies[$shared_tt->taxonomy] = 1;
3867 3867
 		}
3868 3868
 
3869 3869
 		// Split the term.
3870
-		$split_term_data[ $term_id ][ $shared_tt->taxonomy ] = _split_shared_term( $shared_terms[ $term_id ], $shared_tt, false );
3870
+		$split_term_data[$term_id][$shared_tt->taxonomy] = _split_shared_term($shared_terms[$term_id], $shared_tt, false);
3871 3871
 	}
3872 3872
 
3873 3873
 	// Rebuild the cached hierarchy for each affected taxonomy.
3874
-	foreach ( array_keys( $taxonomies ) as $tax ) {
3875
-		delete_option( "{$tax}_children" );
3876
-		_get_term_hierarchy( $tax );
3874
+	foreach (array_keys($taxonomies) as $tax) {
3875
+		delete_option("{$tax}_children");
3876
+		_get_term_hierarchy($tax);
3877 3877
 	}
3878 3878
 
3879
-	update_option( '_split_terms', $split_term_data );
3879
+	update_option('_split_terms', $split_term_data);
3880 3880
 
3881
-	delete_option( $lock_name );
3881
+	delete_option($lock_name);
3882 3882
 }
3883 3883
 
3884 3884
 /**
@@ -3889,8 +3889,8 @@  discard block
 block discarded – undo
3889 3889
  * @since 4.3.0
3890 3890
  */
3891 3891
 function _wp_check_for_scheduled_split_terms() {
3892
-	if ( ! get_option( 'finished_splitting_shared_terms' ) && ! wp_next_scheduled( 'wp_split_shared_term_batch' ) ) {
3893
-		wp_schedule_single_event( time() + MINUTE_IN_SECONDS, 'wp_split_shared_term_batch' );
3892
+	if ( ! get_option('finished_splitting_shared_terms') && ! wp_next_scheduled('wp_split_shared_term_batch')) {
3893
+		wp_schedule_single_event(time() + MINUTE_IN_SECONDS, 'wp_split_shared_term_batch');
3894 3894
 	}
3895 3895
 }
3896 3896
 
@@ -3905,14 +3905,14 @@  discard block
 block discarded – undo
3905 3905
  * @param int    $term_taxonomy_id ID for the term_taxonomy row affected by the split.
3906 3906
  * @param string $taxonomy         Taxonomy for the split term.
3907 3907
  */
3908
-function _wp_check_split_default_terms( $term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) {
3909
-	if ( 'category' != $taxonomy ) {
3908
+function _wp_check_split_default_terms($term_id, $new_term_id, $term_taxonomy_id, $taxonomy) {
3909
+	if ('category' != $taxonomy) {
3910 3910
 		return;
3911 3911
 	}
3912 3912
 
3913
-	foreach ( array( 'default_category', 'default_link_category', 'default_email_category' ) as $option ) {
3914
-		if ( $term_id == get_option( $option, -1 ) ) {
3915
-			update_option( $option, $new_term_id );
3913
+	foreach (array('default_category', 'default_link_category', 'default_email_category') as $option) {
3914
+		if ($term_id == get_option($option, -1)) {
3915
+			update_option($option, $new_term_id);
3916 3916
 		}
3917 3917
 	}
3918 3918
 }
@@ -3930,9 +3930,9 @@  discard block
 block discarded – undo
3930 3930
  * @param int    $term_taxonomy_id ID for the term_taxonomy row affected by the split.
3931 3931
  * @param string $taxonomy         Taxonomy for the split term.
3932 3932
  */
3933
-function _wp_check_split_terms_in_menus( $term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) {
3933
+function _wp_check_split_terms_in_menus($term_id, $new_term_id, $term_taxonomy_id, $taxonomy) {
3934 3934
 	global $wpdb;
3935
-	$post_ids = $wpdb->get_col( $wpdb->prepare(
3935
+	$post_ids = $wpdb->get_col($wpdb->prepare(
3936 3936
 		"SELECT m1.post_id
3937 3937
 		FROM {$wpdb->postmeta} AS m1
3938 3938
 			INNER JOIN {$wpdb->postmeta} AS m2 ON ( m2.post_id = m1.post_id )
@@ -3942,11 +3942,11 @@  discard block
 block discarded – undo
3942 3942
 			AND ( m3.meta_key = '_menu_item_object_id' AND m3.meta_value = %d )",
3943 3943
 		$taxonomy,
3944 3944
 		$term_id
3945
-	) );
3945
+	));
3946 3946
 
3947
-	if ( $post_ids ) {
3948
-		foreach ( $post_ids as $post_id ) {
3949
-			update_post_meta( $post_id, '_menu_item_object_id', $new_term_id, $term_id );
3947
+	if ($post_ids) {
3948
+		foreach ($post_ids as $post_id) {
3949
+			update_post_meta($post_id, '_menu_item_object_id', $new_term_id, $term_id);
3950 3950
 		}
3951 3951
 	}
3952 3952
 }
@@ -3962,19 +3962,19 @@  discard block
 block discarded – undo
3962 3962
  * @param int    $term_taxonomy_id ID for the term_taxonomy row affected by the split.
3963 3963
  * @param string $taxonomy         Taxonomy for the split term.
3964 3964
  */
3965
-function _wp_check_split_nav_menu_terms( $term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) {
3966
-	if ( 'nav_menu' !== $taxonomy ) {
3965
+function _wp_check_split_nav_menu_terms($term_id, $new_term_id, $term_taxonomy_id, $taxonomy) {
3966
+	if ('nav_menu' !== $taxonomy) {
3967 3967
 		return;
3968 3968
 	}
3969 3969
 
3970 3970
 	// Update menu locations.
3971 3971
 	$locations = get_nav_menu_locations();
3972
-	foreach ( $locations as $location => $menu_id ) {
3973
-		if ( $term_id == $menu_id ) {
3974
-			$locations[ $location ] = $new_term_id;
3972
+	foreach ($locations as $location => $menu_id) {
3973
+		if ($term_id == $menu_id) {
3974
+			$locations[$location] = $new_term_id;
3975 3975
 		}
3976 3976
 	}
3977
-	set_theme_mod( 'nav_menu_locations', $locations );
3977
+	set_theme_mod('nav_menu_locations', $locations);
3978 3978
 }
3979 3979
 
3980 3980
 /**
@@ -3985,12 +3985,12 @@  discard block
 block discarded – undo
3985 3985
  * @param int $old_term_id Term ID. This is the old, pre-split term ID.
3986 3986
  * @return array Array of new term IDs, keyed by taxonomy.
3987 3987
  */
3988
-function wp_get_split_terms( $old_term_id ) {
3989
-	$split_terms = get_option( '_split_terms', array() );
3988
+function wp_get_split_terms($old_term_id) {
3989
+	$split_terms = get_option('_split_terms', array());
3990 3990
 
3991 3991
 	$terms = array();
3992
-	if ( isset( $split_terms[ $old_term_id ] ) ) {
3993
-		$terms = $split_terms[ $old_term_id ];
3992
+	if (isset($split_terms[$old_term_id])) {
3993
+		$terms = $split_terms[$old_term_id];
3994 3994
 	}
3995 3995
 
3996 3996
 	return $terms;
@@ -4007,12 +4007,12 @@  discard block
 block discarded – undo
4007 4007
  *                   the new term_id will be returned. If no previously split term is found matching
4008 4008
  *                   the parameters, returns false.
4009 4009
  */
4010
-function wp_get_split_term( $old_term_id, $taxonomy ) {
4011
-	$split_terms = wp_get_split_terms( $old_term_id );
4010
+function wp_get_split_term($old_term_id, $taxonomy) {
4011
+	$split_terms = wp_get_split_terms($old_term_id);
4012 4012
 
4013 4013
 	$term_id = false;
4014
-	if ( isset( $split_terms[ $taxonomy ] ) ) {
4015
-		$term_id = (int) $split_terms[ $taxonomy ];
4014
+	if (isset($split_terms[$taxonomy])) {
4015
+		$term_id = (int) $split_terms[$taxonomy];
4016 4016
 	}
4017 4017
 
4018 4018
 	return $term_id;
@@ -4029,14 +4029,14 @@  discard block
 block discarded – undo
4029 4029
  * @param int $term_id
4030 4030
  * @return bool
4031 4031
  */
4032
-function wp_term_is_shared( $term_id ) {
4032
+function wp_term_is_shared($term_id) {
4033 4033
 	global $wpdb;
4034 4034
 
4035
-	if ( get_option( 'finished_splitting_shared_terms' ) ) {
4035
+	if (get_option('finished_splitting_shared_terms')) {
4036 4036
 		return false;
4037 4037
 	}
4038 4038
 
4039
-	$tt_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term_id ) );
4039
+	$tt_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term_id));
4040 4040
 
4041 4041
 	return $tt_count > 1;
4042 4042
 }
@@ -4052,21 +4052,21 @@  discard block
 block discarded – undo
4052 4052
  * @param string            $taxonomy Optional. Taxonomy. Default empty.
4053 4053
  * @return string|WP_Error HTML link to taxonomy term archive on success, WP_Error if term does not exist.
4054 4054
  */
4055
-function get_term_link( $term, $taxonomy = '' ) {
4055
+function get_term_link($term, $taxonomy = '') {
4056 4056
 	global $wp_rewrite;
4057 4057
 
4058
-	if ( !is_object($term) ) {
4059
-		if ( is_int( $term ) ) {
4060
-			$term = get_term( $term, $taxonomy );
4058
+	if ( ! is_object($term)) {
4059
+		if (is_int($term)) {
4060
+			$term = get_term($term, $taxonomy);
4061 4061
 		} else {
4062
-			$term = get_term_by( 'slug', $term, $taxonomy );
4062
+			$term = get_term_by('slug', $term, $taxonomy);
4063 4063
 		}
4064 4064
 	}
4065 4065
 
4066
-	if ( !is_object($term) )
4066
+	if ( ! is_object($term))
4067 4067
 		$term = new WP_Error('invalid_term', __('Empty Term'));
4068 4068
 
4069
-	if ( is_wp_error( $term ) )
4069
+	if (is_wp_error($term))
4070 4070
 		return $term;
4071 4071
 
4072 4072
 	$taxonomy = $term->taxonomy;
@@ -4076,19 +4076,19 @@  discard block
 block discarded – undo
4076 4076
 	$slug = $term->slug;
4077 4077
 	$t = get_taxonomy($taxonomy);
4078 4078
 
4079
-	if ( empty($termlink) ) {
4080
-		if ( 'category' == $taxonomy )
4081
-			$termlink = '?cat=' . $term->term_id;
4082
-		elseif ( $t->query_var )
4079
+	if (empty($termlink)) {
4080
+		if ('category' == $taxonomy)
4081
+			$termlink = '?cat='.$term->term_id;
4082
+		elseif ($t->query_var)
4083 4083
 			$termlink = "?$t->query_var=$slug";
4084 4084
 		else
4085 4085
 			$termlink = "?taxonomy=$taxonomy&term=$slug";
4086 4086
 		$termlink = home_url($termlink);
4087 4087
 	} else {
4088
-		if ( $t->rewrite['hierarchical'] ) {
4088
+		if ($t->rewrite['hierarchical']) {
4089 4089
 			$hierarchical_slugs = array();
4090
-			$ancestors = get_ancestors( $term->term_id, $taxonomy, 'taxonomy' );
4091
-			foreach ( (array)$ancestors as $ancestor ) {
4090
+			$ancestors = get_ancestors($term->term_id, $taxonomy, 'taxonomy');
4091
+			foreach ((array) $ancestors as $ancestor) {
4092 4092
 				$ancestor_term = get_term($ancestor, $taxonomy);
4093 4093
 				$hierarchical_slugs[] = $ancestor_term->slug;
4094 4094
 			}
@@ -4098,10 +4098,10 @@  discard block
 block discarded – undo
4098 4098
 		} else {
4099 4099
 			$termlink = str_replace("%$taxonomy%", $slug, $termlink);
4100 4100
 		}
4101
-		$termlink = home_url( user_trailingslashit($termlink, 'category') );
4101
+		$termlink = home_url(user_trailingslashit($termlink, 'category'));
4102 4102
 	}
4103 4103
 	// Back Compat filters.
4104
-	if ( 'post_tag' == $taxonomy ) {
4104
+	if ('post_tag' == $taxonomy) {
4105 4105
 
4106 4106
 		/**
4107 4107
 		 * Filters the tag link.
@@ -4112,8 +4112,8 @@  discard block
 block discarded – undo
4112 4112
 		 * @param string $termlink Tag link URL.
4113 4113
 		 * @param int    $term_id  Term ID.
4114 4114
 		 */
4115
-		$termlink = apply_filters( 'tag_link', $termlink, $term->term_id );
4116
-	} elseif ( 'category' == $taxonomy ) {
4115
+		$termlink = apply_filters('tag_link', $termlink, $term->term_id);
4116
+	} elseif ('category' == $taxonomy) {
4117 4117
 
4118 4118
 		/**
4119 4119
 		 * Filters the category link.
@@ -4124,7 +4124,7 @@  discard block
 block discarded – undo
4124 4124
 		 * @param string $termlink Category link URL.
4125 4125
 		 * @param int    $term_id  Term ID.
4126 4126
 		 */
4127
-		$termlink = apply_filters( 'category_link', $termlink, $term->term_id );
4127
+		$termlink = apply_filters('category_link', $termlink, $term->term_id);
4128 4128
 	}
4129 4129
 
4130 4130
 	/**
@@ -4136,7 +4136,7 @@  discard block
 block discarded – undo
4136 4136
 	 * @param object $term     Term object.
4137 4137
 	 * @param string $taxonomy Taxonomy slug.
4138 4138
 	 */
4139
-	return apply_filters( 'term_link', $termlink, $term, $taxonomy );
4139
+	return apply_filters('term_link', $termlink, $term, $taxonomy);
4140 4140
 }
4141 4141
 
4142 4142
 /**
@@ -4158,7 +4158,7 @@  discard block
 block discarded – undo
4158 4158
  *     @type  string      $after  Displays after the taxonomies. Default empty string.
4159 4159
  * }
4160 4160
  */
4161
-function the_taxonomies( $args = array() ) {
4161
+function the_taxonomies($args = array()) {
4162 4162
 	$defaults = array(
4163 4163
 		'post' => 0,
4164 4164
 		'before' => '',
@@ -4166,9 +4166,9 @@  discard block
 block discarded – undo
4166 4166
 		'after' => '',
4167 4167
 	);
4168 4168
 
4169
-	$r = wp_parse_args( $args, $defaults );
4169
+	$r = wp_parse_args($args, $defaults);
4170 4170
 
4171
-	echo $r['before'] . join( $r['sep'], get_the_taxonomies( $r['post'], $r ) ) . $r['after'];
4171
+	echo $r['before'].join($r['sep'], get_the_taxonomies($r['post'], $r)).$r['after'];
4172 4172
 }
4173 4173
 
4174 4174
 /**
@@ -4190,47 +4190,47 @@  discard block
 block discarded – undo
4190 4190
  * }
4191 4191
  * @return array List of taxonomies.
4192 4192
  */
4193
-function get_the_taxonomies( $post = 0, $args = array() ) {
4194
-	$post = get_post( $post );
4193
+function get_the_taxonomies($post = 0, $args = array()) {
4194
+	$post = get_post($post);
4195 4195
 
4196
-	$args = wp_parse_args( $args, array(
4196
+	$args = wp_parse_args($args, array(
4197 4197
 		/* translators: %s: taxonomy label, %l: list of terms formatted as per $term_template */
4198
-		'template' => __( '%s: %l.' ),
4198
+		'template' => __('%s: %l.'),
4199 4199
 		'term_template' => '<a href="%1$s">%2$s</a>',
4200
-	) );
4200
+	));
4201 4201
 
4202 4202
 	$taxonomies = array();
4203 4203
 
4204
-	if ( ! $post ) {
4204
+	if ( ! $post) {
4205 4205
 		return $taxonomies;
4206 4206
 	}
4207 4207
 
4208
-	foreach ( get_object_taxonomies( $post ) as $taxonomy ) {
4209
-		$t = (array) get_taxonomy( $taxonomy );
4210
-		if ( empty( $t['label'] ) ) {
4208
+	foreach (get_object_taxonomies($post) as $taxonomy) {
4209
+		$t = (array) get_taxonomy($taxonomy);
4210
+		if (empty($t['label'])) {
4211 4211
 			$t['label'] = $taxonomy;
4212 4212
 		}
4213
-		if ( empty( $t['args'] ) ) {
4213
+		if (empty($t['args'])) {
4214 4214
 			$t['args'] = array();
4215 4215
 		}
4216
-		if ( empty( $t['template'] ) ) {
4216
+		if (empty($t['template'])) {
4217 4217
 			$t['template'] = $args['template'];
4218 4218
 		}
4219
-		if ( empty( $t['term_template'] ) ) {
4219
+		if (empty($t['term_template'])) {
4220 4220
 			$t['term_template'] = $args['term_template'];
4221 4221
 		}
4222 4222
 
4223
-		$terms = get_object_term_cache( $post->ID, $taxonomy );
4224
-		if ( false === $terms ) {
4225
-			$terms = wp_get_object_terms( $post->ID, $taxonomy, $t['args'] );
4223
+		$terms = get_object_term_cache($post->ID, $taxonomy);
4224
+		if (false === $terms) {
4225
+			$terms = wp_get_object_terms($post->ID, $taxonomy, $t['args']);
4226 4226
 		}
4227 4227
 		$links = array();
4228 4228
 
4229
-		foreach ( $terms as $term ) {
4230
-			$links[] = wp_sprintf( $t['term_template'], esc_attr( get_term_link( $term ) ), $term->name );
4229
+		foreach ($terms as $term) {
4230
+			$links[] = wp_sprintf($t['term_template'], esc_attr(get_term_link($term)), $term->name);
4231 4231
 		}
4232
-		if ( $links ) {
4233
-			$taxonomies[$taxonomy] = wp_sprintf( $t['template'], $t['label'], $links, $terms );
4232
+		if ($links) {
4233
+			$taxonomies[$taxonomy] = wp_sprintf($t['template'], $t['label'], $links, $terms);
4234 4234
 		}
4235 4235
 	}
4236 4236
 	return $taxonomies;
@@ -4244,8 +4244,8 @@  discard block
 block discarded – undo
4244 4244
  * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
4245 4245
  * @return array
4246 4246
  */
4247
-function get_post_taxonomies( $post = 0 ) {
4248
-	$post = get_post( $post );
4247
+function get_post_taxonomies($post = 0) {
4248
+	$post = get_post($post);
4249 4249
 
4250 4250
 	return get_object_taxonomies($post);
4251 4251
 }
@@ -4264,45 +4264,45 @@  discard block
 block discarded – undo
4264 4264
  * @param int|string|array $terms     Optional. Term term_id, name, slug or array of said. Default null.
4265 4265
  * @return bool|WP_Error WP_Error on input error.
4266 4266
  */
4267
-function is_object_in_term( $object_id, $taxonomy, $terms = null ) {
4268
-	if ( !$object_id = (int) $object_id )
4269
-		return new WP_Error( 'invalid_object', __( 'Invalid object ID' ) );
4267
+function is_object_in_term($object_id, $taxonomy, $terms = null) {
4268
+	if ( ! $object_id = (int) $object_id)
4269
+		return new WP_Error('invalid_object', __('Invalid object ID'));
4270 4270
 
4271
-	$object_terms = get_object_term_cache( $object_id, $taxonomy );
4272
-	if ( false === $object_terms ) {
4273
-		$object_terms = wp_get_object_terms( $object_id, $taxonomy, array( 'update_term_meta_cache' => false ) );
4274
-		wp_cache_set( $object_id, wp_list_pluck( $object_terms, 'term_id' ), "{$taxonomy}_relationships" );
4271
+	$object_terms = get_object_term_cache($object_id, $taxonomy);
4272
+	if (false === $object_terms) {
4273
+		$object_terms = wp_get_object_terms($object_id, $taxonomy, array('update_term_meta_cache' => false));
4274
+		wp_cache_set($object_id, wp_list_pluck($object_terms, 'term_id'), "{$taxonomy}_relationships");
4275 4275
 	}
4276 4276
 
4277
-	if ( is_wp_error( $object_terms ) )
4277
+	if (is_wp_error($object_terms))
4278 4278
 		return $object_terms;
4279
-	if ( empty( $object_terms ) )
4279
+	if (empty($object_terms))
4280 4280
 		return false;
4281
-	if ( empty( $terms ) )
4282
-		return ( !empty( $object_terms ) );
4281
+	if (empty($terms))
4282
+		return ( ! empty($object_terms));
4283 4283
 
4284 4284
 	$terms = (array) $terms;
4285 4285
 
4286
-	if ( $ints = array_filter( $terms, 'is_int' ) )
4287
-		$strs = array_diff( $terms, $ints );
4286
+	if ($ints = array_filter($terms, 'is_int'))
4287
+		$strs = array_diff($terms, $ints);
4288 4288
 	else
4289
-		$strs =& $terms;
4289
+		$strs = & $terms;
4290 4290
 
4291
-	foreach ( $object_terms as $object_term ) {
4291
+	foreach ($object_terms as $object_term) {
4292 4292
 		// If term is an int, check against term_ids only.
4293
-		if ( $ints && in_array( $object_term->term_id, $ints ) ) {
4293
+		if ($ints && in_array($object_term->term_id, $ints)) {
4294 4294
 			return true;
4295 4295
 		}
4296 4296
 
4297
-		if ( $strs ) {
4297
+		if ($strs) {
4298 4298
 			// Only check numeric strings against term_id, to avoid false matches due to type juggling.
4299
-			$numeric_strs = array_map( 'intval', array_filter( $strs, 'is_numeric' ) );
4300
-			if ( in_array( $object_term->term_id, $numeric_strs, true ) ) {
4299
+			$numeric_strs = array_map('intval', array_filter($strs, 'is_numeric'));
4300
+			if (in_array($object_term->term_id, $numeric_strs, true)) {
4301 4301
 				return true;
4302 4302
 			}
4303 4303
 
4304
-			if ( in_array( $object_term->name, $strs ) ) return true;
4305
-			if ( in_array( $object_term->slug, $strs ) ) return true;
4304
+			if (in_array($object_term->name, $strs)) return true;
4305
+			if (in_array($object_term->slug, $strs)) return true;
4306 4306
 		}
4307 4307
 	}
4308 4308
 
@@ -4318,12 +4318,12 @@  discard block
 block discarded – undo
4318 4318
  * @param string $taxonomy    Single taxonomy name.
4319 4319
  * @return bool True if object is associated with the taxonomy, otherwise false.
4320 4320
  */
4321
-function is_object_in_taxonomy( $object_type, $taxonomy ) {
4322
-	$taxonomies = get_object_taxonomies( $object_type );
4323
-	if ( empty( $taxonomies ) ) {
4321
+function is_object_in_taxonomy($object_type, $taxonomy) {
4322
+	$taxonomies = get_object_taxonomies($object_type);
4323
+	if (empty($taxonomies)) {
4324 4324
 		return false;
4325 4325
 	}
4326
-	return in_array( $taxonomy, $taxonomies );
4326
+	return in_array($taxonomy, $taxonomies);
4327 4327
 }
4328 4328
 
4329 4329
 /**
@@ -4339,32 +4339,32 @@  discard block
 block discarded – undo
4339 4339
  *                              or 'taxonomy'. Default empty.
4340 4340
  * @return array An array of ancestors from lowest to highest in the hierarchy.
4341 4341
  */
4342
-function get_ancestors( $object_id = 0, $object_type = '', $resource_type = '' ) {
4342
+function get_ancestors($object_id = 0, $object_type = '', $resource_type = '') {
4343 4343
 	$object_id = (int) $object_id;
4344 4344
 
4345 4345
 	$ancestors = array();
4346 4346
 
4347
-	if ( empty( $object_id ) ) {
4347
+	if (empty($object_id)) {
4348 4348
 
4349 4349
 		/** This filter is documented in wp-includes/taxonomy.php */
4350
-		return apply_filters( 'get_ancestors', $ancestors, $object_id, $object_type, $resource_type );
4350
+		return apply_filters('get_ancestors', $ancestors, $object_id, $object_type, $resource_type);
4351 4351
 	}
4352 4352
 
4353
-	if ( ! $resource_type ) {
4354
-		if ( is_taxonomy_hierarchical( $object_type ) ) {
4353
+	if ( ! $resource_type) {
4354
+		if (is_taxonomy_hierarchical($object_type)) {
4355 4355
 			$resource_type = 'taxonomy';
4356
-		} elseif ( post_type_exists( $object_type ) ) {
4356
+		} elseif (post_type_exists($object_type)) {
4357 4357
 			$resource_type = 'post_type';
4358 4358
 		}
4359 4359
 	}
4360 4360
 
4361
-	if ( 'taxonomy' === $resource_type ) {
4361
+	if ('taxonomy' === $resource_type) {
4362 4362
 		$term = get_term($object_id, $object_type);
4363
-		while ( ! is_wp_error($term) && ! empty( $term->parent ) && ! in_array( $term->parent, $ancestors ) ) {
4363
+		while ( ! is_wp_error($term) && ! empty($term->parent) && ! in_array($term->parent, $ancestors)) {
4364 4364
 			$ancestors[] = (int) $term->parent;
4365 4365
 			$term = get_term($term->parent, $object_type);
4366 4366
 		}
4367
-	} elseif ( 'post_type' === $resource_type ) {
4367
+	} elseif ('post_type' === $resource_type) {
4368 4368
 		$ancestors = get_post_ancestors($object_id);
4369 4369
 	}
4370 4370
 
@@ -4379,7 +4379,7 @@  discard block
 block discarded – undo
4379 4379
 	 * @param string $object_type   Type of object.
4380 4380
 	 * @param string $resource_type Type of resource $object_type is.
4381 4381
 	 */
4382
-	return apply_filters( 'get_ancestors', $ancestors, $object_id, $object_type, $resource_type );
4382
+	return apply_filters('get_ancestors', $ancestors, $object_id, $object_type, $resource_type);
4383 4383
 }
4384 4384
 
4385 4385
 /**
@@ -4391,9 +4391,9 @@  discard block
 block discarded – undo
4391 4391
  * @param string $taxonomy Taxonomy name.
4392 4392
  * @return int|false False on error.
4393 4393
  */
4394
-function wp_get_term_taxonomy_parent_id( $term_id, $taxonomy ) {
4395
-	$term = get_term( $term_id, $taxonomy );
4396
-	if ( ! $term || is_wp_error( $term ) ) {
4394
+function wp_get_term_taxonomy_parent_id($term_id, $taxonomy) {
4395
+	$term = get_term($term_id, $taxonomy);
4396
+	if ( ! $term || is_wp_error($term)) {
4397 4397
 		return false;
4398 4398
 	}
4399 4399
 	return (int) $term->parent;
@@ -4413,26 +4413,26 @@  discard block
 block discarded – undo
4413 4413
  *
4414 4414
  * @return int The new parent for the term.
4415 4415
  */
4416
-function wp_check_term_hierarchy_for_loops( $parent, $term_id, $taxonomy ) {
4416
+function wp_check_term_hierarchy_for_loops($parent, $term_id, $taxonomy) {
4417 4417
 	// Nothing fancy here - bail
4418
-	if ( !$parent )
4418
+	if ( ! $parent)
4419 4419
 		return 0;
4420 4420
 
4421 4421
 	// Can't be its own parent.
4422
-	if ( $parent == $term_id )
4422
+	if ($parent == $term_id)
4423 4423
 		return 0;
4424 4424
 
4425 4425
 	// Now look for larger loops.
4426
-	if ( !$loop = wp_find_hierarchy_loop( 'wp_get_term_taxonomy_parent_id', $term_id, $parent, array( $taxonomy ) ) )
4426
+	if ( ! $loop = wp_find_hierarchy_loop('wp_get_term_taxonomy_parent_id', $term_id, $parent, array($taxonomy)))
4427 4427
 		return $parent; // No loop
4428 4428
 
4429 4429
 	// Setting $parent to the given value causes a loop.
4430
-	if ( isset( $loop[$term_id] ) )
4430
+	if (isset($loop[$term_id]))
4431 4431
 		return 0;
4432 4432
 
4433 4433
 	// There's a loop, but it doesn't contain $term_id. Break the loop.
4434
-	foreach ( array_keys( $loop ) as $loop_member )
4435
-		wp_update_term( $loop_member, $taxonomy, array( 'parent' => 0 ) );
4434
+	foreach (array_keys($loop) as $loop_member)
4435
+		wp_update_term($loop_member, $taxonomy, array('parent' => 0));
4436 4436
 
4437 4437
 	return $parent;
4438 4438
 }
Please login to merge, or discard this patch.
Braces   +390 added lines, -265 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 ) {
@@ -988,15 +1011,17 @@  discard block
 block discarded – undo
988 1011
  * @return array|WP_Error List of Term IDs. WP_Error returned if `$taxonomy` does not exist.
989 1012
  */
990 1013
 function get_term_children( $term_id, $taxonomy ) {
991
-	if ( ! taxonomy_exists($taxonomy) )
992
-		return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
1014
+	if ( ! taxonomy_exists($taxonomy) ) {
1015
+			return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
1016
+	}
993 1017
 
994 1018
 	$term_id = intval( $term_id );
995 1019
 
996 1020
 	$terms = _get_term_hierarchy($taxonomy);
997 1021
 
998
-	if ( ! isset($terms[$term_id]) )
999
-		return array();
1022
+	if ( ! isset($terms[$term_id]) ) {
1023
+			return array();
1024
+	}
1000 1025
 
1001 1026
 	$children = $terms[$term_id];
1002 1027
 
@@ -1005,8 +1030,9 @@  discard block
 block discarded – undo
1005 1030
 			continue;
1006 1031
 		}
1007 1032
 
1008
-		if ( isset($terms[$child]) )
1009
-			$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
+		}
1010 1036
 	}
1011 1037
 
1012 1038
 	return $children;
@@ -1030,14 +1056,17 @@  discard block
 block discarded – undo
1030 1056
  */
1031 1057
 function get_term_field( $field, $term, $taxonomy = '', $context = 'display' ) {
1032 1058
 	$term = get_term( $term, $taxonomy );
1033
-	if ( is_wp_error($term) )
1034
-		return $term;
1059
+	if ( is_wp_error($term) ) {
1060
+			return $term;
1061
+	}
1035 1062
 
1036
-	if ( !is_object($term) )
1037
-		return '';
1063
+	if ( !is_object($term) ) {
1064
+			return '';
1065
+	}
1038 1066
 
1039
-	if ( !isset($term->$field) )
1040
-		return '';
1067
+	if ( !isset($term->$field) ) {
1068
+			return '';
1069
+	}
1041 1070
 
1042 1071
 	return sanitize_term_field( $field, $term->$field, $term->term_id, $term->taxonomy, $context );
1043 1072
 }
@@ -1057,11 +1086,13 @@  discard block
 block discarded – undo
1057 1086
 function get_term_to_edit( $id, $taxonomy ) {
1058 1087
 	$term = get_term( $id, $taxonomy );
1059 1088
 
1060
-	if ( is_wp_error($term) )
1061
-		return $term;
1089
+	if ( is_wp_error($term) ) {
1090
+			return $term;
1091
+	}
1062 1092
 
1063
-	if ( !is_object($term) )
1064
-		return '';
1093
+	if ( !is_object($term) ) {
1094
+			return '';
1095
+	}
1065 1096
 
1066 1097
 	return sanitize_term($term, $taxonomy, 'edit');
1067 1098
 }
@@ -1393,13 +1424,15 @@  discard block
 block discarded – undo
1393 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 ";
1394 1425
 
1395 1426
 	if ( is_int($term) ) {
1396
-		if ( 0 == $term )
1397
-			return 0;
1427
+		if ( 0 == $term ) {
1428
+					return 0;
1429
+		}
1398 1430
 		$where = 't.term_id = %d';
1399
-		if ( !empty($taxonomy) )
1400
-			return $wpdb->get_row( $wpdb->prepare( $tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy ), ARRAY_A );
1401
-		else
1402
-			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
+		}
1403 1436
 	}
1404 1437
 
1405 1438
 	$term = trim( wp_unslash( $term ) );
@@ -1423,14 +1456,16 @@  discard block
 block discarded – undo
1423 1456
 		$where_fields[] = $taxonomy;
1424 1457
 		$else_where_fields[] = $taxonomy;
1425 1458
 
1426
-		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
-			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
+		}
1428 1462
 
1429 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);
1430 1464
 	}
1431 1465
 
1432
-	if ( $result = $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where $orderby $limit", $where_fields) ) )
1433
-		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
+	}
1434 1469
 
1435 1470
 	return $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $else_where $orderby $limit", $else_where_fields) );
1436 1471
 }
@@ -1448,15 +1483,19 @@  discard block
 block discarded – undo
1448 1483
  * @return bool Whether `$term2` is a child of `$term1`.
1449 1484
  */
1450 1485
 function term_is_ancestor_of( $term1, $term2, $taxonomy ) {
1451
-	if ( ! isset( $term1->term_id ) )
1452
-		$term1 = get_term( $term1, $taxonomy );
1453
-	if ( ! isset( $term2->parent ) )
1454
-		$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
+	}
1455 1492
 
1456
-	if ( empty( $term1->term_id ) || empty( $term2->parent ) )
1457
-		return false;
1458
-	if ( $term2->parent == $term1->term_id )
1459
-		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
+	}
1460 1499
 
1461 1500
 	return term_is_ancestor_of( $term1, get_term( $term2->parent, $taxonomy ), $taxonomy );
1462 1501
 }
@@ -1487,18 +1526,21 @@  discard block
 block discarded – undo
1487 1526
 
1488 1527
 	foreach ( (array) $fields as $field ) {
1489 1528
 		if ( $do_object ) {
1490
-			if ( isset($term->$field) )
1491
-				$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
+			}
1492 1532
 		} else {
1493
-			if ( isset($term[$field]) )
1494
-				$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
+			}
1495 1536
 		}
1496 1537
 	}
1497 1538
 
1498
-	if ( $do_object )
1499
-		$term->filter = $context;
1500
-	else
1501
-		$term['filter'] = $context;
1539
+	if ( $do_object ) {
1540
+			$term->filter = $context;
1541
+	} else {
1542
+			$term['filter'] = $context;
1543
+	}
1502 1544
 
1503 1545
 	return $term;
1504 1546
 }
@@ -1530,12 +1572,14 @@  discard block
 block discarded – undo
1530 1572
 	$int_fields = array( 'parent', 'term_id', 'count', 'term_group', 'term_taxonomy_id', 'object_id' );
1531 1573
 	if ( in_array( $field, $int_fields ) ) {
1532 1574
 		$value = (int) $value;
1533
-		if ( $value < 0 )
1534
-			$value = 0;
1575
+		if ( $value < 0 ) {
1576
+					$value = 0;
1577
+		}
1535 1578
 	}
1536 1579
 
1537
-	if ( 'raw' == $context )
1538
-		return $value;
1580
+	if ( 'raw' == $context ) {
1581
+			return $value;
1582
+	}
1539 1583
 
1540 1584
 	if ( 'edit' == $context ) {
1541 1585
 
@@ -1565,10 +1609,13 @@  discard block
 block discarded – undo
1565 1609
 		 */
1566 1610
 		$value = apply_filters( "edit_{$taxonomy}_{$field}", $value, $term_id );
1567 1611
 
1568
-		if ( 'description' == $field )
1569
-			$value = esc_html($value); // textarea_escaped
1570
-		else
1571
-			$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
+		}
1572 1619
 	} elseif ( 'db' == $context ) {
1573 1620
 
1574 1621
 		/**
@@ -1716,8 +1763,9 @@  discard block
 block discarded – undo
1716 1763
 function wp_delete_object_term_relationships( $object_id, $taxonomies ) {
1717 1764
 	$object_id = (int) $object_id;
1718 1765
 
1719
-	if ( !is_array($taxonomies) )
1720
-		$taxonomies = array($taxonomies);
1766
+	if ( !is_array($taxonomies) ) {
1767
+			$taxonomies = array($taxonomies);
1768
+	}
1721 1769
 
1722 1770
 	foreach ( (array) $taxonomies as $taxonomy ) {
1723 1771
 		$term_ids = wp_get_object_terms( $object_id, $taxonomy, array( 'fields' => 'ids' ) );
@@ -1758,10 +1806,12 @@  discard block
 block discarded – undo
1758 1806
 
1759 1807
 	$term = (int) $term;
1760 1808
 
1761
-	if ( ! $ids = term_exists($term, $taxonomy) )
1762
-		return false;
1763
-	if ( is_wp_error( $ids ) )
1764
-		return $ids;
1809
+	if ( ! $ids = term_exists($term, $taxonomy) ) {
1810
+			return false;
1811
+	}
1812
+	if ( is_wp_error( $ids ) ) {
1813
+			return $ids;
1814
+	}
1765 1815
 
1766 1816
 	$tt_id = $ids['term_taxonomy_id'];
1767 1817
 
@@ -1769,8 +1819,10 @@  discard block
 block discarded – undo
1769 1819
 
1770 1820
 	if ( 'category' == $taxonomy ) {
1771 1821
 		$defaults['default'] = get_option( 'default_category' );
1772
-		if ( $defaults['default'] == $term )
1773
-			return 0; // Don't delete the default category
1822
+		if ( $defaults['default'] == $term ) {
1823
+					return 0;
1824
+		}
1825
+		// Don't delete the default category
1774 1826
 	}
1775 1827
 
1776 1828
 	$args = wp_parse_args($args, $defaults);
@@ -1799,8 +1851,9 @@  discard block
 block discarded – undo
1799 1851
 	// Update children to point to new parent
1800 1852
 	if ( is_taxonomy_hierarchical($taxonomy) ) {
1801 1853
 		$term_obj = get_term($term, $taxonomy);
1802
-		if ( is_wp_error( $term_obj ) )
1803
-			return $term_obj;
1854
+		if ( is_wp_error( $term_obj ) ) {
1855
+					return $term_obj;
1856
+		}
1804 1857
 		$parent = $term_obj->parent;
1805 1858
 
1806 1859
 		$edit_ids = $wpdb->get_results( "SELECT term_id, term_taxonomy_id FROM $wpdb->term_taxonomy WHERE `parent` = " . (int)$term_obj->term_id );
@@ -1842,8 +1895,9 @@  discard block
 block discarded – undo
1842 1895
 			$terms = array($default);
1843 1896
 		} else {
1844 1897
 			$terms = array_diff($terms, array($term));
1845
-			if (isset($default) && isset($force_default) && $force_default)
1846
-				$terms = array_merge($terms, array($default));
1898
+			if (isset($default) && isset($force_default) && $force_default) {
1899
+							$terms = array_merge($terms, array($default));
1900
+			}
1847 1901
 		}
1848 1902
 		$terms = array_map('intval', $terms);
1849 1903
 		wp_set_object_terms( $object_id, $terms, $taxonomy );
@@ -1851,8 +1905,9 @@  discard block
 block discarded – undo
1851 1905
 
1852 1906
 	// Clean the relationship caches for all object types using this term.
1853 1907
 	$tax_object = get_taxonomy( $taxonomy );
1854
-	foreach ( $tax_object->object_type as $object_type )
1855
-		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
+	}
1856 1911
 
1857 1912
 	$term_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->termmeta WHERE term_id = %d ", $term ) );
1858 1913
 	foreach ( $term_meta_ids as $mid ) {
@@ -1879,8 +1934,9 @@  discard block
 block discarded – undo
1879 1934
 	do_action( 'deleted_term_taxonomy', $tt_id );
1880 1935
 
1881 1936
 	// Delete the term if no taxonomies use it.
1882
-	if ( !$wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term) ) )
1883
-		$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
+	}
1884 1940
 
1885 1941
 	clean_term_cache($term, $taxonomy);
1886 1942
 
@@ -1967,19 +2023,23 @@  discard block
 block discarded – undo
1967 2023
 function wp_get_object_terms($object_ids, $taxonomies, $args = array()) {
1968 2024
 	global $wpdb;
1969 2025
 
1970
-	if ( empty( $object_ids ) || empty( $taxonomies ) )
1971
-		return array();
2026
+	if ( empty( $object_ids ) || empty( $taxonomies ) ) {
2027
+			return array();
2028
+	}
1972 2029
 
1973
-	if ( !is_array($taxonomies) )
1974
-		$taxonomies = array($taxonomies);
2030
+	if ( !is_array($taxonomies) ) {
2031
+			$taxonomies = array($taxonomies);
2032
+	}
1975 2033
 
1976 2034
 	foreach ( $taxonomies as $taxonomy ) {
1977
-		if ( ! taxonomy_exists($taxonomy) )
1978
-			return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
2035
+		if ( ! taxonomy_exists($taxonomy) ) {
2036
+					return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
2037
+		}
1979 2038
 	}
1980 2039
 
1981
-	if ( !is_array($object_ids) )
1982
-		$object_ids = array($object_ids);
2040
+	if ( !is_array($object_ids) ) {
2041
+			$object_ids = array($object_ids);
2042
+	}
1983 2043
 	$object_ids = array_map('intval', $object_ids);
1984 2044
 
1985 2045
 	$defaults = array(
@@ -2003,8 +2063,9 @@  discard block
 block discarded – undo
2003 2063
 		}
2004 2064
 	} else {
2005 2065
 		$t = get_taxonomy($taxonomies[0]);
2006
-		if ( isset($t->args) && is_array($t->args) )
2007
-			$args = array_merge($args, $t->args);
2066
+		if ( isset($t->args) && is_array($t->args) ) {
2067
+					$args = array_merge($args, $t->args);
2068
+		}
2008 2069
 	}
2009 2070
 
2010 2071
 	$orderby = $args['orderby'];
@@ -2025,15 +2086,18 @@  discard block
 block discarded – undo
2025 2086
 	}
2026 2087
 
2027 2088
 	// tt_ids queries can only be none or tr.term_taxonomy_id
2028
-	if ( ('tt_ids' == $fields) && !empty($orderby) )
2029
-		$orderby = 'tr.term_taxonomy_id';
2089
+	if ( ('tt_ids' == $fields) && !empty($orderby) ) {
2090
+			$orderby = 'tr.term_taxonomy_id';
2091
+	}
2030 2092
 
2031
-	if ( !empty($orderby) )
2032
-		$orderby = "ORDER BY $orderby";
2093
+	if ( !empty($orderby) ) {
2094
+			$orderby = "ORDER BY $orderby";
2095
+	}
2033 2096
 
2034 2097
 	$order = strtoupper( $order );
2035
-	if ( '' !== $order && ! in_array( $order, array( 'ASC', 'DESC' ) ) )
2036
-		$order = 'ASC';
2098
+	if ( '' !== $order && ! in_array( $order, array( 'ASC', 'DESC' ) ) ) {
2099
+			$order = 'ASC';
2100
+	}
2037 2101
 
2038 2102
 	$taxonomy_array = $taxonomies;
2039 2103
 	$object_id_array = $object_ids;
@@ -2473,39 +2537,46 @@  discard block
 block discarded – undo
2473 2537
 
2474 2538
 	$object_id = (int) $object_id;
2475 2539
 
2476
-	if ( ! taxonomy_exists($taxonomy) )
2477
-		return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
2540
+	if ( ! taxonomy_exists($taxonomy) ) {
2541
+			return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
2542
+	}
2478 2543
 
2479
-	if ( !is_array($terms) )
2480
-		$terms = array($terms);
2544
+	if ( !is_array($terms) ) {
2545
+			$terms = array($terms);
2546
+	}
2481 2547
 
2482
-	if ( ! $append )
2483
-		$old_tt_ids =  wp_get_object_terms($object_id, $taxonomy, array('fields' => 'tt_ids', 'orderby' => 'none'));
2484
-	else
2485
-		$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
+	}
2486 2553
 
2487 2554
 	$tt_ids = array();
2488 2555
 	$term_ids = array();
2489 2556
 	$new_tt_ids = array();
2490 2557
 
2491 2558
 	foreach ( (array) $terms as $term) {
2492
-		if ( !strlen(trim($term)) )
2493
-			continue;
2559
+		if ( !strlen(trim($term)) ) {
2560
+					continue;
2561
+		}
2494 2562
 
2495 2563
 		if ( !$term_info = term_exists($term, $taxonomy) ) {
2496 2564
 			// Skip if a non-existent term ID is passed.
2497
-			if ( is_int($term) )
2498
-				continue;
2565
+			if ( is_int($term) ) {
2566
+							continue;
2567
+			}
2499 2568
 			$term_info = wp_insert_term($term, $taxonomy);
2500 2569
 		}
2501
-		if ( is_wp_error($term_info) )
2502
-			return $term_info;
2570
+		if ( is_wp_error($term_info) ) {
2571
+					return $term_info;
2572
+		}
2503 2573
 		$term_ids[] = $term_info['term_id'];
2504 2574
 		$tt_id = $term_info['term_taxonomy_id'];
2505 2575
 		$tt_ids[] = $tt_id;
2506 2576
 
2507
-		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 ) ) )
2508
-			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
+		}
2509 2580
 
2510 2581
 		/**
2511 2582
 		 * Fires immediately before an object-term relationship is added.
@@ -2530,8 +2601,9 @@  discard block
 block discarded – undo
2530 2601
 		$new_tt_ids[] = $tt_id;
2531 2602
 	}
2532 2603
 
2533
-	if ( $new_tt_ids )
2534
-		wp_update_term_count( $new_tt_ids, $taxonomy );
2604
+	if ( $new_tt_ids ) {
2605
+			wp_update_term_count( $new_tt_ids, $taxonomy );
2606
+	}
2535 2607
 
2536 2608
 	if ( ! $append ) {
2537 2609
 		$delete_tt_ids = array_diff( $old_tt_ids, $tt_ids );
@@ -2553,12 +2625,14 @@  discard block
 block discarded – undo
2553 2625
 		$values = array();
2554 2626
 		$term_order = 0;
2555 2627
 		$final_tt_ids = wp_get_object_terms($object_id, $taxonomy, array('fields' => 'tt_ids'));
2556
-		foreach ( $tt_ids as $tt_id )
2557
-			if ( in_array($tt_id, $final_tt_ids) )
2628
+		foreach ( $tt_ids as $tt_id ) {
2629
+					if ( in_array($tt_id, $final_tt_ids) )
2558 2630
 				$values[] = $wpdb->prepare( "(%d, %d, %d)", $object_id, $tt_id, ++$term_order);
2559
-		if ( $values )
2560
-			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)" ) )
2561 2634
 				return new WP_Error( 'db_insert_error', __( 'Could not insert term relationship into the database' ), $wpdb->last_error );
2635
+		}
2562 2636
 	}
2563 2637
 
2564 2638
 	wp_cache_delete( $object_id, $taxonomy . '_relationships' );
@@ -2716,15 +2790,17 @@  discard block
 block discarded – undo
2716 2790
 		$the_parent = $term->parent;
2717 2791
 		while ( ! empty($the_parent) ) {
2718 2792
 			$parent_term = get_term($the_parent, $term->taxonomy);
2719
-			if ( is_wp_error($parent_term) || empty($parent_term) )
2720
-				break;
2793
+			if ( is_wp_error($parent_term) || empty($parent_term) ) {
2794
+							break;
2795
+			}
2721 2796
 			$parent_suffix .= '-' . $parent_term->slug;
2722 2797
 			if ( ! term_exists( $slug . $parent_suffix ) ) {
2723 2798
 				break;
2724 2799
 			}
2725 2800
 
2726
-			if ( empty($parent_term->parent) )
2727
-				break;
2801
+			if ( empty($parent_term->parent) ) {
2802
+							break;
2803
+			}
2728 2804
 			$the_parent = $parent_term->parent;
2729 2805
 		}
2730 2806
 	}
@@ -2744,10 +2820,11 @@  discard block
 block discarded – undo
2744 2820
 		if ( $parent_suffix ) {
2745 2821
 			$slug .= $parent_suffix;
2746 2822
 		} else {
2747
-			if ( ! empty( $term->term_id ) )
2748
-				$query = $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s AND term_id != %d", $slug, $term->term_id );
2749
-			else
2750
-				$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
+			}
2751 2828
 
2752 2829
 			if ( $wpdb->get_var( $query ) ) {
2753 2830
 				$num = 2;
@@ -2843,8 +2920,9 @@  discard block
 block discarded – undo
2843 2920
 	$parsed_args['name'] = $name;
2844 2921
 	$parsed_args['description'] = $description;
2845 2922
 
2846
-	if ( '' == trim($name) )
2847
-		return new WP_Error('empty_term_name', __('A name is required for this term'));
2923
+	if ( '' == trim($name) ) {
2924
+			return new WP_Error('empty_term_name', __('A name is required for this term'));
2925
+	}
2848 2926
 
2849 2927
 	if ( $parsed_args['parent'] > 0 && ! term_exists( (int) $parsed_args['parent'] ) ) {
2850 2928
 		return new WP_Error( 'missing_parent', __( 'Parent term does not exist.' ) );
@@ -2901,10 +2979,11 @@  discard block
 block discarded – undo
2901 2979
 	if ( $duplicate && $duplicate->term_id != $term_id ) {
2902 2980
 		// If an empty slug was passed or the parent changed, reset the slug to something unique.
2903 2981
 		// Otherwise, bail.
2904
-		if ( $empty_slug || ( $parent != $term['parent']) )
2905
-			$slug = wp_unique_term_slug($slug, (object) $args);
2906
-		else
2907
-			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
+		}
2908 2987
 	}
2909 2988
 
2910 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) );
@@ -3034,8 +3113,9 @@  discard block
 block discarded – undo
3034 3113
 	if ( is_bool($defer) ) {
3035 3114
 		$_defer = $defer;
3036 3115
 		// flush any deferred counts
3037
-		if ( !$defer )
3038
-			wp_update_term_count( null, null, true );
3116
+		if ( !$defer ) {
3117
+					wp_update_term_count( null, null, true );
3118
+		}
3039 3119
 	}
3040 3120
 
3041 3121
 	return $_defer;
@@ -3069,15 +3149,18 @@  discard block
 block discarded – undo
3069 3149
 		}
3070 3150
 	}
3071 3151
 
3072
-	if ( empty($terms) )
3073
-		return false;
3152
+	if ( empty($terms) ) {
3153
+			return false;
3154
+	}
3074 3155
 
3075
-	if ( !is_array($terms) )
3076
-		$terms = array($terms);
3156
+	if ( !is_array($terms) ) {
3157
+			$terms = array($terms);
3158
+	}
3077 3159
 
3078 3160
 	if ( wp_defer_term_counting() ) {
3079
-		if ( !isset($_deferred[$taxonomy]) )
3080
-			$_deferred[$taxonomy] = array();
3161
+		if ( !isset($_deferred[$taxonomy]) ) {
3162
+					$_deferred[$taxonomy] = array();
3163
+		}
3081 3164
 		$_deferred[$taxonomy] = array_unique( array_merge($_deferred[$taxonomy], $terms) );
3082 3165
 		return true;
3083 3166
 	}
@@ -3103,8 +3186,9 @@  discard block
 block discarded – undo
3103 3186
 	} else {
3104 3187
 		$object_types = (array) $taxonomy->object_type;
3105 3188
 		foreach ( $object_types as &$object_type ) {
3106
-			if ( 0 === strpos( $object_type, 'attachment:' ) )
3107
-				list( $object_type ) = explode( ':', $object_type );
3189
+			if ( 0 === strpos( $object_type, 'attachment:' ) ) {
3190
+							list( $object_type ) = explode( ':', $object_type );
3191
+			}
3108 3192
 		}
3109 3193
 
3110 3194
 		if ( $object_types == array_filter( $object_types, 'post_type_exists' ) ) {
@@ -3148,8 +3232,9 @@  discard block
 block discarded – undo
3148 3232
 		return;
3149 3233
 	}
3150 3234
 
3151
-	if ( !is_array($object_ids) )
3152
-		$object_ids = array($object_ids);
3235
+	if ( !is_array($object_ids) ) {
3236
+			$object_ids = array($object_ids);
3237
+	}
3153 3238
 
3154 3239
 	$taxonomies = get_object_taxonomies( $object_type );
3155 3240
 
@@ -3191,8 +3276,9 @@  discard block
 block discarded – undo
3191 3276
 		return;
3192 3277
 	}
3193 3278
 
3194
-	if ( !is_array($ids) )
3195
-		$ids = array($ids);
3279
+	if ( !is_array($ids) ) {
3280
+			$ids = array($ids);
3281
+	}
3196 3282
 
3197 3283
 	$taxonomies = array();
3198 3284
 	// If no taxonomy, assume tt_ids.
@@ -3300,11 +3386,13 @@  discard block
 block discarded – undo
3300 3386
  * @return void|false False if all of the terms in `$object_ids` are already cached.
3301 3387
  */
3302 3388
 function update_object_term_cache($object_ids, $object_type) {
3303
-	if ( empty($object_ids) )
3304
-		return;
3389
+	if ( empty($object_ids) ) {
3390
+			return;
3391
+	}
3305 3392
 
3306
-	if ( !is_array($object_ids) )
3307
-		$object_ids = explode(',', $object_ids);
3393
+	if ( !is_array($object_ids) ) {
3394
+			$object_ids = explode(',', $object_ids);
3395
+	}
3308 3396
 
3309 3397
 	$object_ids = array_map('intval', $object_ids);
3310 3398
 
@@ -3320,8 +3408,9 @@  discard block
 block discarded – undo
3320 3408
 		}
3321 3409
 	}
3322 3410
 
3323
-	if ( empty( $ids ) )
3324
-		return false;
3411
+	if ( empty( $ids ) ) {
3412
+			return false;
3413
+	}
3325 3414
 
3326 3415
 	$terms = wp_get_object_terms( $ids, $taxonomies, array(
3327 3416
 		'fields' => 'all_with_object_id',
@@ -3337,8 +3426,9 @@  discard block
 block discarded – undo
3337 3426
 	foreach ( $ids as $id ) {
3338 3427
 		foreach ( $taxonomies as $taxonomy ) {
3339 3428
 			if ( ! isset($object_terms[$id][$taxonomy]) ) {
3340
-				if ( !isset($object_terms[$id]) )
3341
-					$object_terms[$id] = array();
3429
+				if ( !isset($object_terms[$id]) ) {
3430
+									$object_terms[$id] = array();
3431
+				}
3342 3432
 				$object_terms[$id][$taxonomy] = array();
3343 3433
 			}
3344 3434
 		}
@@ -3385,17 +3475,20 @@  discard block
 block discarded – undo
3385 3475
  * @return array Empty if $taxonomy isn't hierarchical or returns children as Term IDs.
3386 3476
  */
3387 3477
 function _get_term_hierarchy( $taxonomy ) {
3388
-	if ( !is_taxonomy_hierarchical($taxonomy) )
3389
-		return array();
3478
+	if ( !is_taxonomy_hierarchical($taxonomy) ) {
3479
+			return array();
3480
+	}
3390 3481
 	$children = get_option("{$taxonomy}_children");
3391 3482
 
3392
-	if ( is_array($children) )
3393
-		return $children;
3483
+	if ( is_array($children) ) {
3484
+			return $children;
3485
+	}
3394 3486
 	$children = array();
3395 3487
 	$terms = get_terms($taxonomy, array('get' => 'all', 'orderby' => 'id', 'fields' => 'id=>parent'));
3396 3488
 	foreach ( $terms as $term_id => $parent ) {
3397
-		if ( $parent > 0 )
3398
-			$children[$parent][] = $term_id;
3489
+		if ( $parent > 0 ) {
3490
+					$children[$parent][] = $term_id;
3491
+		}
3399 3492
 	}
3400 3493
 	update_option("{$taxonomy}_children", $children);
3401 3494
 
@@ -3423,14 +3516,16 @@  discard block
 block discarded – undo
3423 3516
  */
3424 3517
 function _get_term_children( $term_id, $terms, $taxonomy, &$ancestors = array() ) {
3425 3518
 	$empty_array = array();
3426
-	if ( empty($terms) )
3427
-		return $empty_array;
3519
+	if ( empty($terms) ) {
3520
+			return $empty_array;
3521
+	}
3428 3522
 
3429 3523
 	$term_list = array();
3430 3524
 	$has_children = _get_term_hierarchy($taxonomy);
3431 3525
 
3432
-	if  ( ( 0 != $term_id ) && ! isset($has_children[$term_id]) )
3433
-		return $empty_array;
3526
+	if  ( ( 0 != $term_id ) && ! isset($has_children[$term_id]) ) {
3527
+			return $empty_array;
3528
+	}
3434 3529
 
3435 3530
 	// Include the term itself in the ancestors array, so we can properly detect when a loop has occurred.
3436 3531
 	if ( empty( $ancestors ) ) {
@@ -3441,8 +3536,9 @@  discard block
 block discarded – undo
3441 3536
 		$use_id = false;
3442 3537
 		if ( !is_object($term) ) {
3443 3538
 			$term = get_term($term, $taxonomy);
3444
-			if ( is_wp_error( $term ) )
3445
-				return $term;
3539
+			if ( is_wp_error( $term ) ) {
3540
+							return $term;
3541
+			}
3446 3542
 			$use_id = true;
3447 3543
 		}
3448 3544
 
@@ -3452,18 +3548,21 @@  discard block
 block discarded – undo
3452 3548
 		}
3453 3549
 
3454 3550
 		if ( $term->parent == $term_id ) {
3455
-			if ( $use_id )
3456
-				$term_list[] = $term->term_id;
3457
-			else
3458
-				$term_list[] = $term;
3551
+			if ( $use_id ) {
3552
+							$term_list[] = $term->term_id;
3553
+			} else {
3554
+							$term_list[] = $term;
3555
+			}
3459 3556
 
3460
-			if ( !isset($has_children[$term->term_id]) )
3461
-				continue;
3557
+			if ( !isset($has_children[$term->term_id]) ) {
3558
+							continue;
3559
+			}
3462 3560
 
3463 3561
 			$ancestors[ $term->term_id ] = 1;
3464 3562
 
3465
-			if ( $children = _get_term_children( $term->term_id, $terms, $taxonomy, $ancestors) )
3466
-				$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
+			}
3467 3566
 		}
3468 3567
 	}
3469 3568
 
@@ -3488,13 +3587,15 @@  discard block
 block discarded – undo
3488 3587
 	global $wpdb;
3489 3588
 
3490 3589
 	// This function only works for hierarchical taxonomies like post categories.
3491
-	if ( !is_taxonomy_hierarchical( $taxonomy ) )
3492
-		return;
3590
+	if ( !is_taxonomy_hierarchical( $taxonomy ) ) {
3591
+			return;
3592
+	}
3493 3593
 
3494 3594
 	$term_hier = _get_term_hierarchy($taxonomy);
3495 3595
 
3496
-	if ( empty($term_hier) )
3497
-		return;
3596
+	if ( empty($term_hier) ) {
3597
+			return;
3598
+	}
3498 3599
 
3499 3600
 	$term_items = array();
3500 3601
 	$terms_by_id = array();
@@ -3520,9 +3621,10 @@  discard block
 block discarded – undo
3520 3621
 		$ancestors = array();
3521 3622
 		while ( !empty( $terms_by_id[$child] ) && $parent = $terms_by_id[$child]->parent ) {
3522 3623
 			$ancestors[] = $child;
3523
-			if ( !empty( $term_items[$term_id] ) )
3524
-				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 ) {
3525 3626
 					$term_items[$parent][$item_id] = isset($term_items[$parent][$item_id]) ? ++$term_items[$parent][$item_id]: 1;
3627
+			}
3526 3628
 				}
3527 3629
 			$child = $parent;
3528 3630
 
@@ -3533,10 +3635,11 @@  discard block
 block discarded – undo
3533 3635
 	}
3534 3636
 
3535 3637
 	// Transfer the touched cells.
3536
-	foreach ( (array) $term_items as $id => $items )
3537
-		if ( isset($terms_by_id[$id]) )
3638
+	foreach ( (array) $term_items as $id => $items ) {
3639
+			if ( isset($terms_by_id[$id]) )
3538 3640
 			$terms_by_id[$id]->count = count($items);
3539
-}
3641
+	}
3642
+	}
3540 3643
 
3541 3644
 /**
3542 3645
  * Adds any terms from the given IDs to the cache that do not already exist in cache.
@@ -3587,8 +3690,9 @@  discard block
 block discarded – undo
3587 3690
 
3588 3691
 	$object_types = (array) $taxonomy->object_type;
3589 3692
 
3590
-	foreach ( $object_types as &$object_type )
3591
-		list( $object_type ) = explode( ':', $object_type );
3693
+	foreach ( $object_types as &$object_type ) {
3694
+			list( $object_type ) = explode( ':', $object_type );
3695
+	}
3592 3696
 
3593 3697
 	$object_types = array_unique( $object_types );
3594 3698
 
@@ -3597,18 +3701,21 @@  discard block
 block discarded – undo
3597 3701
 		$check_attachments = true;
3598 3702
 	}
3599 3703
 
3600
-	if ( $object_types )
3601
-		$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
+	}
3602 3707
 
3603 3708
 	foreach ( (array) $terms as $term ) {
3604 3709
 		$count = 0;
3605 3710
 
3606 3711
 		// Attachments can be 'inherit' status, we need to base count off the parent's status if so.
3607
-		if ( $check_attachments )
3608
-			$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
+		}
3609 3715
 
3610
-		if ( $object_types )
3611
-			$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
+		}
3612 3719
 
3613 3720
 		/** This action is documented in wp-includes/taxonomy.php */
3614 3721
 		do_action( 'edit_term_taxonomy', $term, $taxonomy->name );
@@ -4063,11 +4170,13 @@  discard block
 block discarded – undo
4063 4170
 		}
4064 4171
 	}
4065 4172
 
4066
-	if ( !is_object($term) )
4067
-		$term = new WP_Error('invalid_term', __('Empty Term'));
4173
+	if ( !is_object($term) ) {
4174
+			$term = new WP_Error('invalid_term', __('Empty Term'));
4175
+	}
4068 4176
 
4069
-	if ( is_wp_error( $term ) )
4070
-		return $term;
4177
+	if ( is_wp_error( $term ) ) {
4178
+			return $term;
4179
+	}
4071 4180
 
4072 4181
 	$taxonomy = $term->taxonomy;
4073 4182
 
@@ -4077,12 +4186,13 @@  discard block
 block discarded – undo
4077 4186
 	$t = get_taxonomy($taxonomy);
4078 4187
 
4079 4188
 	if ( empty($termlink) ) {
4080
-		if ( 'category' == $taxonomy )
4081
-			$termlink = '?cat=' . $term->term_id;
4082
-		elseif ( $t->query_var )
4083
-			$termlink = "?$t->query_var=$slug";
4084
-		else
4085
-			$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
+		}
4086 4196
 		$termlink = home_url($termlink);
4087 4197
 	} else {
4088 4198
 		if ( $t->rewrite['hierarchical'] ) {
@@ -4265,8 +4375,9 @@  discard block
 block discarded – undo
4265 4375
  * @return bool|WP_Error WP_Error on input error.
4266 4376
  */
4267 4377
 function is_object_in_term( $object_id, $taxonomy, $terms = null ) {
4268
-	if ( !$object_id = (int) $object_id )
4269
-		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
+	}
4270 4381
 
4271 4382
 	$object_terms = get_object_term_cache( $object_id, $taxonomy );
4272 4383
 	if ( false === $object_terms ) {
@@ -4274,19 +4385,23 @@  discard block
 block discarded – undo
4274 4385
 		wp_cache_set( $object_id, wp_list_pluck( $object_terms, 'term_id' ), "{$taxonomy}_relationships" );
4275 4386
 	}
4276 4387
 
4277
-	if ( is_wp_error( $object_terms ) )
4278
-		return $object_terms;
4279
-	if ( empty( $object_terms ) )
4280
-		return false;
4281
-	if ( empty( $terms ) )
4282
-		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
+	}
4283 4397
 
4284 4398
 	$terms = (array) $terms;
4285 4399
 
4286
-	if ( $ints = array_filter( $terms, 'is_int' ) )
4287
-		$strs = array_diff( $terms, $ints );
4288
-	else
4289
-		$strs =& $terms;
4400
+	if ( $ints = array_filter( $terms, 'is_int' ) ) {
4401
+			$strs = array_diff( $terms, $ints );
4402
+	} else {
4403
+			$strs =& $terms;
4404
+	}
4290 4405
 
4291 4406
 	foreach ( $object_terms as $object_term ) {
4292 4407
 		// If term is an int, check against term_ids only.
@@ -4301,8 +4416,12 @@  discard block
 block discarded – undo
4301 4416
 				return true;
4302 4417
 			}
4303 4418
 
4304
-			if ( in_array( $object_term->name, $strs ) ) return true;
4305
-			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
+			}
4306 4425
 		}
4307 4426
 	}
4308 4427
 
@@ -4415,24 +4534,30 @@  discard block
 block discarded – undo
4415 4534
  */
4416 4535
 function wp_check_term_hierarchy_for_loops( $parent, $term_id, $taxonomy ) {
4417 4536
 	// Nothing fancy here - bail
4418
-	if ( !$parent )
4419
-		return 0;
4537
+	if ( !$parent ) {
4538
+			return 0;
4539
+	}
4420 4540
 
4421 4541
 	// Can't be its own parent.
4422
-	if ( $parent == $term_id )
4423
-		return 0;
4542
+	if ( $parent == $term_id ) {
4543
+			return 0;
4544
+	}
4424 4545
 
4425 4546
 	// Now look for larger loops.
4426
-	if ( !$loop = wp_find_hierarchy_loop( 'wp_get_term_taxonomy_parent_id', $term_id, $parent, array( $taxonomy ) ) )
4427
-		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
4428 4551
 
4429 4552
 	// Setting $parent to the given value causes a loop.
4430
-	if ( isset( $loop[$term_id] ) )
4431
-		return 0;
4553
+	if ( isset( $loop[$term_id] ) ) {
4554
+			return 0;
4555
+	}
4432 4556
 
4433 4557
 	// There's a loop, but it doesn't contain $term_id. Break the loop.
4434
-	foreach ( array_keys( $loop ) as $loop_member )
4435
-		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
+	}
4436 4561
 
4437 4562
 	return $parent;
4438 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.
src/wp-includes/Text/Diff/Renderer.php 4 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -148,6 +148,12 @@  discard block
 block discarded – undo
148 148
         return $output . $this->_endDiff();
149 149
     }
150 150
 
151
+    /**
152
+     * @param integer $xbeg
153
+     * @param integer $xlen
154
+     * @param integer $ybeg
155
+     * @param integer $ylen
156
+     */
151 157
     function _block($xbeg, $xlen, $ybeg, $ylen, &$edits)
152 158
     {
153 159
         $output = $this->_startBlock($this->_blockHeader($xbeg, $xlen, $ybeg, $ylen));
@@ -204,6 +210,9 @@  discard block
 block discarded – undo
204 210
         return $xbeg . ($xlen ? ($ylen ? 'c' : 'd') : 'a') . $ybeg;
205 211
     }
206 212
 
213
+    /**
214
+     * @param string $header
215
+     */
207 216
     function _startBlock($header)
208 217
     {
209 218
         return $header . "\n";
Please login to merge, or discard this patch.
Indentation   +211 added lines, -211 removed lines patch added patch discarded remove patch
@@ -14,34 +14,34 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class Text_Diff_Renderer {
16 16
 
17
-    /**
18
-     * Number of leading context "lines" to preserve.
19
-     *
20
-     * This should be left at zero for this class, but subclasses may want to
21
-     * set this to other values.
22
-     */
23
-    var $_leading_context_lines = 0;
24
-
25
-    /**
26
-     * Number of trailing context "lines" to preserve.
27
-     *
28
-     * This should be left at zero for this class, but subclasses may want to
29
-     * set this to other values.
30
-     */
31
-    var $_trailing_context_lines = 0;
32
-
33
-    /**
34
-     * Constructor.
35
-     */
36
-    function __construct( $params = array() )
37
-    {
38
-        foreach ($params as $param => $value) {
39
-            $v = '_' . $param;
40
-            if (isset($this->$v)) {
41
-                $this->$v = $value;
42
-            }
43
-        }
44
-    }
17
+	/**
18
+	 * Number of leading context "lines" to preserve.
19
+	 *
20
+	 * This should be left at zero for this class, but subclasses may want to
21
+	 * set this to other values.
22
+	 */
23
+	var $_leading_context_lines = 0;
24
+
25
+	/**
26
+	 * Number of trailing context "lines" to preserve.
27
+	 *
28
+	 * This should be left at zero for this class, but subclasses may want to
29
+	 * set this to other values.
30
+	 */
31
+	var $_trailing_context_lines = 0;
32
+
33
+	/**
34
+	 * Constructor.
35
+	 */
36
+	function __construct( $params = array() )
37
+	{
38
+		foreach ($params as $param => $value) {
39
+			$v = '_' . $param;
40
+			if (isset($this->$v)) {
41
+				$this->$v = $value;
42
+			}
43
+		}
44
+	}
45 45
 
46 46
 	/**
47 47
 	 * PHP4 constructor.
@@ -50,193 +50,193 @@  discard block
 block discarded – undo
50 50
 		self::__construct( $params );
51 51
 	}
52 52
 
53
-    /**
54
-     * Get any renderer parameters.
55
-     *
56
-     * @return array  All parameters of this renderer object.
57
-     */
58
-    function getParams()
59
-    {
60
-        $params = array();
61
-        foreach (get_object_vars($this) as $k => $v) {
62
-            if ($k[0] == '_') {
63
-                $params[substr($k, 1)] = $v;
64
-            }
65
-        }
66
-
67
-        return $params;
68
-    }
69
-
70
-    /**
71
-     * Renders a diff.
72
-     *
73
-     * @param Text_Diff $diff  A Text_Diff object.
74
-     *
75
-     * @return string  The formatted output.
76
-     */
77
-    function render($diff)
78
-    {
79
-        $xi = $yi = 1;
80
-        $block = false;
81
-        $context = array();
82
-
83
-        $nlead = $this->_leading_context_lines;
84
-        $ntrail = $this->_trailing_context_lines;
85
-
86
-        $output = $this->_startDiff();
87
-
88
-        $diffs = $diff->getDiff();
89
-        foreach ($diffs as $i => $edit) {
90
-            /* If these are unchanged (copied) lines, and we want to keep
53
+	/**
54
+	 * Get any renderer parameters.
55
+	 *
56
+	 * @return array  All parameters of this renderer object.
57
+	 */
58
+	function getParams()
59
+	{
60
+		$params = array();
61
+		foreach (get_object_vars($this) as $k => $v) {
62
+			if ($k[0] == '_') {
63
+				$params[substr($k, 1)] = $v;
64
+			}
65
+		}
66
+
67
+		return $params;
68
+	}
69
+
70
+	/**
71
+	 * Renders a diff.
72
+	 *
73
+	 * @param Text_Diff $diff  A Text_Diff object.
74
+	 *
75
+	 * @return string  The formatted output.
76
+	 */
77
+	function render($diff)
78
+	{
79
+		$xi = $yi = 1;
80
+		$block = false;
81
+		$context = array();
82
+
83
+		$nlead = $this->_leading_context_lines;
84
+		$ntrail = $this->_trailing_context_lines;
85
+
86
+		$output = $this->_startDiff();
87
+
88
+		$diffs = $diff->getDiff();
89
+		foreach ($diffs as $i => $edit) {
90
+			/* If these are unchanged (copied) lines, and we want to keep
91 91
              * leading or trailing context lines, extract them from the copy
92 92
              * block. */
93
-            if (is_a($edit, 'Text_Diff_Op_copy')) {
94
-                /* Do we have any diff blocks yet? */
95
-                if (is_array($block)) {
96
-                    /* How many lines to keep as context from the copy
93
+			if (is_a($edit, 'Text_Diff_Op_copy')) {
94
+				/* Do we have any diff blocks yet? */
95
+				if (is_array($block)) {
96
+					/* How many lines to keep as context from the copy
97 97
                      * block. */
98
-                    $keep = $i == count($diffs) - 1 ? $ntrail : $nlead + $ntrail;
99
-                    if (count($edit->orig) <= $keep) {
100
-                        /* We have less lines in the block than we want for
98
+					$keep = $i == count($diffs) - 1 ? $ntrail : $nlead + $ntrail;
99
+					if (count($edit->orig) <= $keep) {
100
+						/* We have less lines in the block than we want for
101 101
                          * context => keep the whole block. */
102
-                        $block[] = $edit;
103
-                    } else {
104
-                        if ($ntrail) {
105
-                            /* Create a new block with as many lines as we need
102
+						$block[] = $edit;
103
+					} else {
104
+						if ($ntrail) {
105
+							/* Create a new block with as many lines as we need
106 106
                              * for the trailing context. */
107
-                            $context = array_slice($edit->orig, 0, $ntrail);
108
-                            $block[] = new Text_Diff_Op_copy($context);
109
-                        }
110
-                        /* @todo */
111
-                        $output .= $this->_block($x0, $ntrail + $xi - $x0,
112
-                                                 $y0, $ntrail + $yi - $y0,
113
-                                                 $block);
114
-                        $block = false;
115
-                    }
116
-                }
117
-                /* Keep the copy block as the context for the next block. */
118
-                $context = $edit->orig;
119
-            } else {
120
-                /* Don't we have any diff blocks yet? */
121
-                if (!is_array($block)) {
122
-                    /* Extract context lines from the preceding copy block. */
123
-                    $context = array_slice($context, count($context) - $nlead);
124
-                    $x0 = $xi - count($context);
125
-                    $y0 = $yi - count($context);
126
-                    $block = array();
127
-                    if ($context) {
128
-                        $block[] = new Text_Diff_Op_copy($context);
129
-                    }
130
-                }
131
-                $block[] = $edit;
132
-            }
133
-
134
-            if ($edit->orig) {
135
-                $xi += count($edit->orig);
136
-            }
137
-            if ($edit->final) {
138
-                $yi += count($edit->final);
139
-            }
140
-        }
141
-
142
-        if (is_array($block)) {
143
-            $output .= $this->_block($x0, $xi - $x0,
144
-                                     $y0, $yi - $y0,
145
-                                     $block);
146
-        }
147
-
148
-        return $output . $this->_endDiff();
149
-    }
150
-
151
-    function _block($xbeg, $xlen, $ybeg, $ylen, &$edits)
152
-    {
153
-        $output = $this->_startBlock($this->_blockHeader($xbeg, $xlen, $ybeg, $ylen));
154
-
155
-        foreach ($edits as $edit) {
156
-            switch (strtolower(get_class($edit))) {
157
-            case 'text_diff_op_copy':
158
-                $output .= $this->_context($edit->orig);
159
-                break;
160
-
161
-            case 'text_diff_op_add':
162
-                $output .= $this->_added($edit->final);
163
-                break;
164
-
165
-            case 'text_diff_op_delete':
166
-                $output .= $this->_deleted($edit->orig);
167
-                break;
168
-
169
-            case 'text_diff_op_change':
170
-                $output .= $this->_changed($edit->orig, $edit->final);
171
-                break;
172
-            }
173
-        }
174
-
175
-        return $output . $this->_endBlock();
176
-    }
177
-
178
-    function _startDiff()
179
-    {
180
-        return '';
181
-    }
182
-
183
-    function _endDiff()
184
-    {
185
-        return '';
186
-    }
187
-
188
-    function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
189
-    {
190
-        if ($xlen > 1) {
191
-            $xbeg .= ',' . ($xbeg + $xlen - 1);
192
-        }
193
-        if ($ylen > 1) {
194
-            $ybeg .= ',' . ($ybeg + $ylen - 1);
195
-        }
196
-
197
-        // this matches the GNU Diff behaviour
198
-        if ($xlen && !$ylen) {
199
-            $ybeg--;
200
-        } elseif (!$xlen) {
201
-            $xbeg--;
202
-        }
203
-
204
-        return $xbeg . ($xlen ? ($ylen ? 'c' : 'd') : 'a') . $ybeg;
205
-    }
206
-
207
-    function _startBlock($header)
208
-    {
209
-        return $header . "\n";
210
-    }
211
-
212
-    function _endBlock()
213
-    {
214
-        return '';
215
-    }
216
-
217
-    function _lines($lines, $prefix = ' ')
218
-    {
219
-        return $prefix . implode("\n$prefix", $lines) . "\n";
220
-    }
221
-
222
-    function _context($lines)
223
-    {
224
-        return $this->_lines($lines, '  ');
225
-    }
226
-
227
-    function _added($lines)
228
-    {
229
-        return $this->_lines($lines, '> ');
230
-    }
231
-
232
-    function _deleted($lines)
233
-    {
234
-        return $this->_lines($lines, '< ');
235
-    }
236
-
237
-    function _changed($orig, $final)
238
-    {
239
-        return $this->_deleted($orig) . "---\n" . $this->_added($final);
240
-    }
107
+							$context = array_slice($edit->orig, 0, $ntrail);
108
+							$block[] = new Text_Diff_Op_copy($context);
109
+						}
110
+						/* @todo */
111
+						$output .= $this->_block($x0, $ntrail + $xi - $x0,
112
+												 $y0, $ntrail + $yi - $y0,
113
+												 $block);
114
+						$block = false;
115
+					}
116
+				}
117
+				/* Keep the copy block as the context for the next block. */
118
+				$context = $edit->orig;
119
+			} else {
120
+				/* Don't we have any diff blocks yet? */
121
+				if (!is_array($block)) {
122
+					/* Extract context lines from the preceding copy block. */
123
+					$context = array_slice($context, count($context) - $nlead);
124
+					$x0 = $xi - count($context);
125
+					$y0 = $yi - count($context);
126
+					$block = array();
127
+					if ($context) {
128
+						$block[] = new Text_Diff_Op_copy($context);
129
+					}
130
+				}
131
+				$block[] = $edit;
132
+			}
133
+
134
+			if ($edit->orig) {
135
+				$xi += count($edit->orig);
136
+			}
137
+			if ($edit->final) {
138
+				$yi += count($edit->final);
139
+			}
140
+		}
141
+
142
+		if (is_array($block)) {
143
+			$output .= $this->_block($x0, $xi - $x0,
144
+									 $y0, $yi - $y0,
145
+									 $block);
146
+		}
147
+
148
+		return $output . $this->_endDiff();
149
+	}
150
+
151
+	function _block($xbeg, $xlen, $ybeg, $ylen, &$edits)
152
+	{
153
+		$output = $this->_startBlock($this->_blockHeader($xbeg, $xlen, $ybeg, $ylen));
154
+
155
+		foreach ($edits as $edit) {
156
+			switch (strtolower(get_class($edit))) {
157
+			case 'text_diff_op_copy':
158
+				$output .= $this->_context($edit->orig);
159
+				break;
160
+
161
+			case 'text_diff_op_add':
162
+				$output .= $this->_added($edit->final);
163
+				break;
164
+
165
+			case 'text_diff_op_delete':
166
+				$output .= $this->_deleted($edit->orig);
167
+				break;
168
+
169
+			case 'text_diff_op_change':
170
+				$output .= $this->_changed($edit->orig, $edit->final);
171
+				break;
172
+			}
173
+		}
174
+
175
+		return $output . $this->_endBlock();
176
+	}
177
+
178
+	function _startDiff()
179
+	{
180
+		return '';
181
+	}
182
+
183
+	function _endDiff()
184
+	{
185
+		return '';
186
+	}
187
+
188
+	function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
189
+	{
190
+		if ($xlen > 1) {
191
+			$xbeg .= ',' . ($xbeg + $xlen - 1);
192
+		}
193
+		if ($ylen > 1) {
194
+			$ybeg .= ',' . ($ybeg + $ylen - 1);
195
+		}
196
+
197
+		// this matches the GNU Diff behaviour
198
+		if ($xlen && !$ylen) {
199
+			$ybeg--;
200
+		} elseif (!$xlen) {
201
+			$xbeg--;
202
+		}
203
+
204
+		return $xbeg . ($xlen ? ($ylen ? 'c' : 'd') : 'a') . $ybeg;
205
+	}
206
+
207
+	function _startBlock($header)
208
+	{
209
+		return $header . "\n";
210
+	}
211
+
212
+	function _endBlock()
213
+	{
214
+		return '';
215
+	}
216
+
217
+	function _lines($lines, $prefix = ' ')
218
+	{
219
+		return $prefix . implode("\n$prefix", $lines) . "\n";
220
+	}
221
+
222
+	function _context($lines)
223
+	{
224
+		return $this->_lines($lines, '  ');
225
+	}
226
+
227
+	function _added($lines)
228
+	{
229
+		return $this->_lines($lines, '> ');
230
+	}
231
+
232
+	function _deleted($lines)
233
+	{
234
+		return $this->_lines($lines, '< ');
235
+	}
236
+
237
+	function _changed($orig, $final)
238
+	{
239
+		return $this->_deleted($orig) . "---\n" . $this->_added($final);
240
+	}
241 241
 
242 242
 }
Please login to merge, or discard this patch.
Switch Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -154,21 +154,21 @@
 block discarded – undo
154 154
 
155 155
         foreach ($edits as $edit) {
156 156
             switch (strtolower(get_class($edit))) {
157
-            case 'text_diff_op_copy':
158
-                $output .= $this->_context($edit->orig);
159
-                break;
157
+            	case 'text_diff_op_copy':
158
+                	$output .= $this->_context($edit->orig);
159
+                	break;
160 160
 
161
-            case 'text_diff_op_add':
162
-                $output .= $this->_added($edit->final);
163
-                break;
161
+            	case 'text_diff_op_add':
162
+                	$output .= $this->_added($edit->final);
163
+                	break;
164 164
 
165
-            case 'text_diff_op_delete':
166
-                $output .= $this->_deleted($edit->orig);
167
-                break;
165
+            	case 'text_diff_op_delete':
166
+                	$output .= $this->_deleted($edit->orig);
167
+                	break;
168 168
 
169
-            case 'text_diff_op_change':
170
-                $output .= $this->_changed($edit->orig, $edit->final);
171
-                break;
169
+            	case 'text_diff_op_change':
170
+                	$output .= $this->_changed($edit->orig, $edit->final);
171
+                	break;
172 172
             }
173 173
         }
174 174
 
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -33,10 +33,10 @@  discard block
 block discarded – undo
33 33
     /**
34 34
      * Constructor.
35 35
      */
36
-    function __construct( $params = array() )
36
+    function __construct($params = array())
37 37
     {
38 38
         foreach ($params as $param => $value) {
39
-            $v = '_' . $param;
39
+            $v = '_'.$param;
40 40
             if (isset($this->$v)) {
41 41
                 $this->$v = $value;
42 42
             }
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 	/**
47 47
 	 * PHP4 constructor.
48 48
 	 */
49
-	public function Text_Diff_Renderer( $params = array() ) {
50
-		self::__construct( $params );
49
+	public function Text_Diff_Renderer($params = array()) {
50
+		self::__construct($params);
51 51
 	}
52 52
 
53 53
     /**
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
                 $context = $edit->orig;
119 119
             } else {
120 120
                 /* Don't we have any diff blocks yet? */
121
-                if (!is_array($block)) {
121
+                if ( ! is_array($block)) {
122 122
                     /* Extract context lines from the preceding copy block. */
123 123
                     $context = array_slice($context, count($context) - $nlead);
124 124
                     $x0 = $xi - count($context);
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
                                      $block);
146 146
         }
147 147
 
148
-        return $output . $this->_endDiff();
148
+        return $output.$this->_endDiff();
149 149
     }
150 150
 
151 151
     function _block($xbeg, $xlen, $ybeg, $ylen, &$edits)
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
             }
173 173
         }
174 174
 
175
-        return $output . $this->_endBlock();
175
+        return $output.$this->_endBlock();
176 176
     }
177 177
 
178 178
     function _startDiff()
@@ -188,25 +188,25 @@  discard block
 block discarded – undo
188 188
     function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
189 189
     {
190 190
         if ($xlen > 1) {
191
-            $xbeg .= ',' . ($xbeg + $xlen - 1);
191
+            $xbeg .= ','.($xbeg + $xlen - 1);
192 192
         }
193 193
         if ($ylen > 1) {
194
-            $ybeg .= ',' . ($ybeg + $ylen - 1);
194
+            $ybeg .= ','.($ybeg + $ylen - 1);
195 195
         }
196 196
 
197 197
         // this matches the GNU Diff behaviour
198
-        if ($xlen && !$ylen) {
198
+        if ($xlen && ! $ylen) {
199 199
             $ybeg--;
200
-        } elseif (!$xlen) {
200
+        } elseif ( ! $xlen) {
201 201
             $xbeg--;
202 202
         }
203 203
 
204
-        return $xbeg . ($xlen ? ($ylen ? 'c' : 'd') : 'a') . $ybeg;
204
+        return $xbeg.($xlen ? ($ylen ? 'c' : 'd') : 'a').$ybeg;
205 205
     }
206 206
 
207 207
     function _startBlock($header)
208 208
     {
209
-        return $header . "\n";
209
+        return $header."\n";
210 210
     }
211 211
 
212 212
     function _endBlock()
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 
217 217
     function _lines($lines, $prefix = ' ')
218 218
     {
219
-        return $prefix . implode("\n$prefix", $lines) . "\n";
219
+        return $prefix.implode("\n$prefix", $lines)."\n";
220 220
     }
221 221
 
222 222
     function _context($lines)
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 
237 237
     function _changed($orig, $final)
238 238
     {
239
-        return $this->_deleted($orig) . "---\n" . $this->_added($final);
239
+        return $this->_deleted($orig)."---\n".$this->_added($final);
240 240
     }
241 241
 
242 242
 }
Please login to merge, or discard this patch.
src/wp-includes/Text/Diff/Renderer/inline.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -100,6 +100,9 @@  discard block
 block discarded – undo
100 100
         return $header;
101 101
     }
102 102
 
103
+    /**
104
+     * @param string[] $lines
105
+     */
103 106
     function _lines($lines, $prefix = ' ', $encode = true)
104 107
     {
105 108
         if ($encode) {
@@ -178,6 +181,9 @@  discard block
 block discarded – undo
178 181
         return str_replace($nl, "\n", $renderer->render($diff)) . "\n";
179 182
     }
180 183
 
184
+    /**
185
+     * @param string $string
186
+     */
181 187
     function _splitOnWords($string, $newlineEscape = "\n")
182 188
     {
183 189
         // Ignore \0; otherwise the while loop will never finish.
Please login to merge, or discard this patch.
Indentation   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -26,181 +26,181 @@
 block discarded – undo
26 26
  */
27 27
 class Text_Diff_Renderer_inline extends Text_Diff_Renderer {
28 28
 
29
-    /**
30
-     * Number of leading context "lines" to preserve.
31
-     *
32
-     * @var integer
33
-     */
34
-    var $_leading_context_lines = 10000;
35
-
36
-    /**
37
-     * Number of trailing context "lines" to preserve.
38
-     *
39
-     * @var integer
40
-     */
41
-    var $_trailing_context_lines = 10000;
42
-
43
-    /**
44
-     * Prefix for inserted text.
45
-     *
46
-     * @var string
47
-     */
48
-    var $_ins_prefix = '<ins>';
49
-
50
-    /**
51
-     * Suffix for inserted text.
52
-     *
53
-     * @var string
54
-     */
55
-    var $_ins_suffix = '</ins>';
56
-
57
-    /**
58
-     * Prefix for deleted text.
59
-     *
60
-     * @var string
61
-     */
62
-    var $_del_prefix = '<del>';
63
-
64
-    /**
65
-     * Suffix for deleted text.
66
-     *
67
-     * @var string
68
-     */
69
-    var $_del_suffix = '</del>';
70
-
71
-    /**
72
-     * Header for each change block.
73
-     *
74
-     * @var string
75
-     */
76
-    var $_block_header = '';
77
-
78
-    /**
79
-     * Whether to split down to character-level.
80
-     *
81
-     * @var boolean
82
-     */
83
-    var $_split_characters = false;
84
-
85
-    /**
86
-     * What are we currently splitting on? Used to recurse to show word-level
87
-     * or character-level changes.
88
-     *
89
-     * @var string
90
-     */
91
-    var $_split_level = 'lines';
92
-
93
-    function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
94
-    {
95
-        return $this->_block_header;
96
-    }
97
-
98
-    function _startBlock($header)
99
-    {
100
-        return $header;
101
-    }
102
-
103
-    function _lines($lines, $prefix = ' ', $encode = true)
104
-    {
105
-        if ($encode) {
106
-            array_walk($lines, array(&$this, '_encode'));
107
-        }
108
-
109
-        if ($this->_split_level == 'lines') {
110
-            return implode("\n", $lines) . "\n";
111
-        } else {
112
-            return implode('', $lines);
113
-        }
114
-    }
115
-
116
-    function _added($lines)
117
-    {
118
-        array_walk($lines, array(&$this, '_encode'));
119
-        $lines[0] = $this->_ins_prefix . $lines[0];
120
-        $lines[count($lines) - 1] .= $this->_ins_suffix;
121
-        return $this->_lines($lines, ' ', false);
122
-    }
123
-
124
-    function _deleted($lines, $words = false)
125
-    {
126
-        array_walk($lines, array(&$this, '_encode'));
127
-        $lines[0] = $this->_del_prefix . $lines[0];
128
-        $lines[count($lines) - 1] .= $this->_del_suffix;
129
-        return $this->_lines($lines, ' ', false);
130
-    }
131
-
132
-    function _changed($orig, $final)
133
-    {
134
-        /* If we've already split on characters, just display. */
135
-        if ($this->_split_level == 'characters') {
136
-            return $this->_deleted($orig)
137
-                . $this->_added($final);
138
-        }
139
-
140
-        /* If we've already split on words, just display. */
141
-        if ($this->_split_level == 'words') {
142
-            $prefix = '';
143
-            while ($orig[0] !== false && $final[0] !== false &&
144
-                   substr($orig[0], 0, 1) == ' ' &&
145
-                   substr($final[0], 0, 1) == ' ') {
146
-                $prefix .= substr($orig[0], 0, 1);
147
-                $orig[0] = substr($orig[0], 1);
148
-                $final[0] = substr($final[0], 1);
149
-            }
150
-            return $prefix . $this->_deleted($orig) . $this->_added($final);
151
-        }
152
-
153
-        $text1 = implode("\n", $orig);
154
-        $text2 = implode("\n", $final);
155
-
156
-        /* Non-printing newline marker. */
157
-        $nl = "\0";
158
-
159
-        if ($this->_split_characters) {
160
-            $diff = new Text_Diff('native',
161
-                                  array(preg_split('//', $text1),
162
-                                        preg_split('//', $text2)));
163
-        } else {
164
-            /* We want to split on word boundaries, but we need to preserve
29
+	/**
30
+	 * Number of leading context "lines" to preserve.
31
+	 *
32
+	 * @var integer
33
+	 */
34
+	var $_leading_context_lines = 10000;
35
+
36
+	/**
37
+	 * Number of trailing context "lines" to preserve.
38
+	 *
39
+	 * @var integer
40
+	 */
41
+	var $_trailing_context_lines = 10000;
42
+
43
+	/**
44
+	 * Prefix for inserted text.
45
+	 *
46
+	 * @var string
47
+	 */
48
+	var $_ins_prefix = '<ins>';
49
+
50
+	/**
51
+	 * Suffix for inserted text.
52
+	 *
53
+	 * @var string
54
+	 */
55
+	var $_ins_suffix = '</ins>';
56
+
57
+	/**
58
+	 * Prefix for deleted text.
59
+	 *
60
+	 * @var string
61
+	 */
62
+	var $_del_prefix = '<del>';
63
+
64
+	/**
65
+	 * Suffix for deleted text.
66
+	 *
67
+	 * @var string
68
+	 */
69
+	var $_del_suffix = '</del>';
70
+
71
+	/**
72
+	 * Header for each change block.
73
+	 *
74
+	 * @var string
75
+	 */
76
+	var $_block_header = '';
77
+
78
+	/**
79
+	 * Whether to split down to character-level.
80
+	 *
81
+	 * @var boolean
82
+	 */
83
+	var $_split_characters = false;
84
+
85
+	/**
86
+	 * What are we currently splitting on? Used to recurse to show word-level
87
+	 * or character-level changes.
88
+	 *
89
+	 * @var string
90
+	 */
91
+	var $_split_level = 'lines';
92
+
93
+	function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
94
+	{
95
+		return $this->_block_header;
96
+	}
97
+
98
+	function _startBlock($header)
99
+	{
100
+		return $header;
101
+	}
102
+
103
+	function _lines($lines, $prefix = ' ', $encode = true)
104
+	{
105
+		if ($encode) {
106
+			array_walk($lines, array(&$this, '_encode'));
107
+		}
108
+
109
+		if ($this->_split_level == 'lines') {
110
+			return implode("\n", $lines) . "\n";
111
+		} else {
112
+			return implode('', $lines);
113
+		}
114
+	}
115
+
116
+	function _added($lines)
117
+	{
118
+		array_walk($lines, array(&$this, '_encode'));
119
+		$lines[0] = $this->_ins_prefix . $lines[0];
120
+		$lines[count($lines) - 1] .= $this->_ins_suffix;
121
+		return $this->_lines($lines, ' ', false);
122
+	}
123
+
124
+	function _deleted($lines, $words = false)
125
+	{
126
+		array_walk($lines, array(&$this, '_encode'));
127
+		$lines[0] = $this->_del_prefix . $lines[0];
128
+		$lines[count($lines) - 1] .= $this->_del_suffix;
129
+		return $this->_lines($lines, ' ', false);
130
+	}
131
+
132
+	function _changed($orig, $final)
133
+	{
134
+		/* If we've already split on characters, just display. */
135
+		if ($this->_split_level == 'characters') {
136
+			return $this->_deleted($orig)
137
+				. $this->_added($final);
138
+		}
139
+
140
+		/* If we've already split on words, just display. */
141
+		if ($this->_split_level == 'words') {
142
+			$prefix = '';
143
+			while ($orig[0] !== false && $final[0] !== false &&
144
+				   substr($orig[0], 0, 1) == ' ' &&
145
+				   substr($final[0], 0, 1) == ' ') {
146
+				$prefix .= substr($orig[0], 0, 1);
147
+				$orig[0] = substr($orig[0], 1);
148
+				$final[0] = substr($final[0], 1);
149
+			}
150
+			return $prefix . $this->_deleted($orig) . $this->_added($final);
151
+		}
152
+
153
+		$text1 = implode("\n", $orig);
154
+		$text2 = implode("\n", $final);
155
+
156
+		/* Non-printing newline marker. */
157
+		$nl = "\0";
158
+
159
+		if ($this->_split_characters) {
160
+			$diff = new Text_Diff('native',
161
+								  array(preg_split('//', $text1),
162
+										preg_split('//', $text2)));
163
+		} else {
164
+			/* We want to split on word boundaries, but we need to preserve
165 165
              * whitespace as well. Therefore we split on words, but include
166 166
              * all blocks of whitespace in the wordlist. */
167
-            $diff = new Text_Diff('native',
168
-                                  array($this->_splitOnWords($text1, $nl),
169
-                                        $this->_splitOnWords($text2, $nl)));
170
-        }
171
-
172
-        /* Get the diff in inline format. */
173
-        $renderer = new Text_Diff_Renderer_inline
174
-            (array_merge($this->getParams(),
175
-                         array('split_level' => $this->_split_characters ? 'characters' : 'words')));
176
-
177
-        /* Run the diff and get the output. */
178
-        return str_replace($nl, "\n", $renderer->render($diff)) . "\n";
179
-    }
180
-
181
-    function _splitOnWords($string, $newlineEscape = "\n")
182
-    {
183
-        // Ignore \0; otherwise the while loop will never finish.
184
-        $string = str_replace("\0", '', $string);
185
-
186
-        $words = array();
187
-        $length = strlen($string);
188
-        $pos = 0;
189
-
190
-        while ($pos < $length) {
191
-            // Eat a word with any preceding whitespace.
192
-            $spaces = strspn(substr($string, $pos), " \n");
193
-            $nextpos = strcspn(substr($string, $pos + $spaces), " \n");
194
-            $words[] = str_replace("\n", $newlineEscape, substr($string, $pos, $spaces + $nextpos));
195
-            $pos += $spaces + $nextpos;
196
-        }
197
-
198
-        return $words;
199
-    }
200
-
201
-    function _encode(&$string)
202
-    {
203
-        $string = htmlspecialchars($string);
204
-    }
167
+			$diff = new Text_Diff('native',
168
+								  array($this->_splitOnWords($text1, $nl),
169
+										$this->_splitOnWords($text2, $nl)));
170
+		}
171
+
172
+		/* Get the diff in inline format. */
173
+		$renderer = new Text_Diff_Renderer_inline
174
+			(array_merge($this->getParams(),
175
+						 array('split_level' => $this->_split_characters ? 'characters' : 'words')));
176
+
177
+		/* Run the diff and get the output. */
178
+		return str_replace($nl, "\n", $renderer->render($diff)) . "\n";
179
+	}
180
+
181
+	function _splitOnWords($string, $newlineEscape = "\n")
182
+	{
183
+		// Ignore \0; otherwise the while loop will never finish.
184
+		$string = str_replace("\0", '', $string);
185
+
186
+		$words = array();
187
+		$length = strlen($string);
188
+		$pos = 0;
189
+
190
+		while ($pos < $length) {
191
+			// Eat a word with any preceding whitespace.
192
+			$spaces = strspn(substr($string, $pos), " \n");
193
+			$nextpos = strcspn(substr($string, $pos + $spaces), " \n");
194
+			$words[] = str_replace("\n", $newlineEscape, substr($string, $pos, $spaces + $nextpos));
195
+			$pos += $spaces + $nextpos;
196
+		}
197
+
198
+		return $words;
199
+	}
200
+
201
+	function _encode(&$string)
202
+	{
203
+		$string = htmlspecialchars($string);
204
+	}
205 205
 
206 206
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 /** Text_Diff_Renderer */
15 15
 
16 16
 // WP #7391
17
-require_once dirname(dirname(__FILE__)) . '/Renderer.php';
17
+require_once dirname(dirname(__FILE__)).'/Renderer.php';
18 18
 
19 19
 /**
20 20
  * "Inline" diff renderer.
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
         }
108 108
 
109 109
         if ($this->_split_level == 'lines') {
110
-            return implode("\n", $lines) . "\n";
110
+            return implode("\n", $lines)."\n";
111 111
         } else {
112 112
             return implode('', $lines);
113 113
         }
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
     function _added($lines)
117 117
     {
118 118
         array_walk($lines, array(&$this, '_encode'));
119
-        $lines[0] = $this->_ins_prefix . $lines[0];
119
+        $lines[0] = $this->_ins_prefix.$lines[0];
120 120
         $lines[count($lines) - 1] .= $this->_ins_suffix;
121 121
         return $this->_lines($lines, ' ', false);
122 122
     }
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
     function _deleted($lines, $words = false)
125 125
     {
126 126
         array_walk($lines, array(&$this, '_encode'));
127
-        $lines[0] = $this->_del_prefix . $lines[0];
127
+        $lines[0] = $this->_del_prefix.$lines[0];
128 128
         $lines[count($lines) - 1] .= $this->_del_suffix;
129 129
         return $this->_lines($lines, ' ', false);
130 130
     }
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
                 $orig[0] = substr($orig[0], 1);
148 148
                 $final[0] = substr($final[0], 1);
149 149
             }
150
-            return $prefix . $this->_deleted($orig) . $this->_added($final);
150
+            return $prefix.$this->_deleted($orig).$this->_added($final);
151 151
         }
152 152
 
153 153
         $text1 = implode("\n", $orig);
@@ -170,12 +170,11 @@  discard block
 block discarded – undo
170 170
         }
171 171
 
172 172
         /* Get the diff in inline format. */
173
-        $renderer = new Text_Diff_Renderer_inline
174
-            (array_merge($this->getParams(),
173
+        $renderer = new Text_Diff_Renderer_inline(array_merge($this->getParams(),
175 174
                          array('split_level' => $this->_split_characters ? 'characters' : 'words')));
176 175
 
177 176
         /* Run the diff and get the output. */
178
-        return str_replace($nl, "\n", $renderer->render($diff)) . "\n";
177
+        return str_replace($nl, "\n", $renderer->render($diff))."\n";
179 178
     }
180 179
 
181 180
     function _splitOnWords($string, $newlineEscape = "\n")
Please login to merge, or discard this patch.
src/wp-includes/wp-diff.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 	 * @access public
496 496
 	 *
497 497
 	 * @param string $name Property to check if set.
498
-	 * @return bool Whether the property is set.
498
+	 * @return boolean|null Whether the property is set.
499 499
 	 */
500 500
 	public function __isset( $name ) {
501 501
 		if ( in_array( $name, $this->compat_fields ) ) {
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
 	 *
533 533
 	 * @param string $string
534 534
 	 * @param string $newlineEscape
535
-	 * @return string
535
+	 * @return string[]
536 536
 	 */
537 537
 	public function _splitOnWords($string, $newlineEscape = "\n") {
538 538
 		$string = str_replace("\0", '', $string);
Please login to merge, or discard this patch.
Braces   +49 added lines, -35 removed lines patch added patch discarded remove patch
@@ -81,8 +81,9 @@  discard block
 block discarded – undo
81 81
 	 */
82 82
 	public function __construct( $params = array() ) {
83 83
 		parent::__construct( $params );
84
-		if ( isset( $params[ 'show_split_view' ] ) )
85
-			$this->_show_split_view = $params[ 'show_split_view' ];
84
+		if ( isset( $params[ 'show_split_view' ] ) ) {
85
+					$this->_show_split_view = $params[ 'show_split_view' ];
86
+		}
86 87
 	}
87 88
 
88 89
 	/**
@@ -280,8 +281,10 @@  discard block
 block discarded – undo
280 281
 					//	we double the length of chars not in those tags.
281 282
 					$stripped_diff = strlen(strip_tags( $diff )) * 2 - $stripped_matches;
282 283
 					$diff_ratio = $stripped_matches / $stripped_diff;
283
-					if ( $diff_ratio > $this->_diff_threshold )
284
-						continue; // Too different. Don't save diffs.
284
+					if ( $diff_ratio > $this->_diff_threshold ) {
285
+											continue;
286
+					}
287
+					// Too different. Don't save diffs.
285 288
 				}
286 289
 
287 290
 				// Un-inline the diffs by removing del or ins
@@ -292,23 +295,26 @@  discard block
 block discarded – undo
292 295
 
293 296
 		foreach ( array_keys($orig_rows) as $row ) {
294 297
 			// Both columns have blanks. Ignore them.
295
-			if ( $orig_rows[$row] < 0 && $final_rows[$row] < 0 )
296
-				continue;
298
+			if ( $orig_rows[$row] < 0 && $final_rows[$row] < 0 ) {
299
+							continue;
300
+			}
297 301
 
298 302
 			// If we have a word based diff, use it. Otherwise, use the normal line.
299
-			if ( isset( $orig_diffs[$orig_rows[$row]] ) )
300
-				$orig_line = $orig_diffs[$orig_rows[$row]];
301
-			elseif ( isset( $orig[$orig_rows[$row]] ) )
302
-				$orig_line = htmlspecialchars($orig[$orig_rows[$row]]);
303
-			else
304
-				$orig_line = '';
305
-
306
-			if ( isset( $final_diffs[$final_rows[$row]] ) )
307
-				$final_line = $final_diffs[$final_rows[$row]];
308
-			elseif ( isset( $final[$final_rows[$row]] ) )
309
-				$final_line = htmlspecialchars($final[$final_rows[$row]]);
310
-			else
311
-				$final_line = '';
303
+			if ( isset( $orig_diffs[$orig_rows[$row]] ) ) {
304
+							$orig_line = $orig_diffs[$orig_rows[$row]];
305
+			} elseif ( isset( $orig[$orig_rows[$row]] ) ) {
306
+							$orig_line = htmlspecialchars($orig[$orig_rows[$row]]);
307
+			} else {
308
+							$orig_line = '';
309
+			}
310
+
311
+			if ( isset( $final_diffs[$final_rows[$row]] ) ) {
312
+							$final_line = $final_diffs[$final_rows[$row]];
313
+			} elseif ( isset( $final[$final_rows[$row]] ) ) {
314
+							$final_line = htmlspecialchars($final[$final_rows[$row]]);
315
+			} else {
316
+							$final_line = '';
317
+			}
312 318
 
313 319
 			if ( $orig_rows[$row] < 0 ) { // Orig is blank. This is really an added row.
314 320
 				$r .= $this->_added( array($final_line), false );
@@ -360,8 +366,9 @@  discard block
 block discarded – undo
360 366
 			$f = (int) $f;
361 367
 
362 368
 			// Already have better matches for these guys
363
-			if ( isset($orig_matches[$o]) && isset($final_matches[$f]) )
364
-				continue;
369
+			if ( isset($orig_matches[$o]) && isset($final_matches[$f]) ) {
370
+							continue;
371
+			}
365 372
 
366 373
 			// First match for these guys. Must be best match
367 374
 			if ( !isset($orig_matches[$o]) && !isset($final_matches[$f]) ) {
@@ -371,12 +378,14 @@  discard block
 block discarded – undo
371 378
 			}
372 379
 
373 380
 			// Best match of this final is already taken?  Must mean this final is a new row.
374
-			if ( isset($orig_matches[$o]) )
375
-				$final_matches[$f] = 'x';
381
+			if ( isset($orig_matches[$o]) ) {
382
+							$final_matches[$f] = 'x';
383
+			}
376 384
 
377 385
 			// Best match of this orig is already taken?  Must mean this orig is a deleted row.
378
-			elseif ( isset($final_matches[$f]) )
379
-				$orig_matches[$o] = 'x';
386
+			elseif ( isset($final_matches[$f]) ) {
387
+							$orig_matches[$o] = 'x';
388
+			}
380 389
 		}
381 390
 
382 391
 		// We read the text in this order
@@ -397,24 +406,28 @@  discard block
 block discarded – undo
397 406
 				array_splice( $final_rows, $orig_pos, 0, -1 );
398 407
 			} elseif ( $final_pos < $orig_pos ) { // This orig's match is up a ways. Pad final with blank rows.
399 408
 				$diff_pos = $final_pos - $orig_pos;
400
-				while ( $diff_pos < 0 )
401
-					array_splice( $final_rows, $orig_pos, 0, $diff_pos++ );
409
+				while ( $diff_pos < 0 ) {
410
+									array_splice( $final_rows, $orig_pos, 0, $diff_pos++ );
411
+				}
402 412
 			} elseif ( $final_pos > $orig_pos ) { // This orig's match is down a ways. Pad orig with blank rows.
403 413
 				$diff_pos = $orig_pos - $final_pos;
404
-				while ( $diff_pos < 0 )
405
-					array_splice( $orig_rows, $orig_pos, 0, $diff_pos++ );
414
+				while ( $diff_pos < 0 ) {
415
+									array_splice( $orig_rows, $orig_pos, 0, $diff_pos++ );
416
+				}
406 417
 			}
407 418
 		}
408 419
 
409 420
 		// Pad the ends with blank rows if the columns aren't the same length
410 421
 		$diff_count = count($orig_rows) - count($final_rows);
411 422
 		if ( $diff_count < 0 ) {
412
-			while ( $diff_count < 0 )
413
-				array_push($orig_rows, $diff_count++);
423
+			while ( $diff_count < 0 ) {
424
+							array_push($orig_rows, $diff_count++);
425
+			}
414 426
 		} elseif ( $diff_count > 0 ) {
415 427
 			$diff_count = -1 * $diff_count;
416
-			while ( $diff_count < 0 )
417
-				array_push($final_rows, $diff_count++);
428
+			while ( $diff_count < 0 ) {
429
+							array_push($final_rows, $diff_count++);
430
+			}
418 431
 		}
419 432
 
420 433
 		return array($orig_matches, $final_matches, $orig_rows, $final_rows);
@@ -438,8 +451,9 @@  discard block
 block discarded – undo
438 451
 		$difference = array_sum( array_map( array($this, 'difference'), $chars1, $chars2 ) );
439 452
 
440 453
 		// $string1 has zero length? Odd. Give huge penalty by not dividing.
441
-		if ( !$string1 )
442
-			return $difference;
454
+		if ( !$string1 ) {
455
+					return $difference;
456
+		}
443 457
 
444 458
 		// Return distance per character (of string1).
445 459
 		return $difference / strlen($string1);
Please login to merge, or discard this patch.
Spacing   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -8,13 +8,13 @@  discard block
 block discarded – undo
8 8
  * @subpackage Diff
9 9
  */
10 10
 
11
-if ( ! class_exists( 'Text_Diff', false ) ) {
11
+if ( ! class_exists('Text_Diff', false)) {
12 12
 	/** Text_Diff class */
13
-	require( dirname(__FILE__).'/Text/Diff.php' );
13
+	require(dirname(__FILE__).'/Text/Diff.php');
14 14
 	/** Text_Diff_Renderer class */
15
-	require( dirname(__FILE__).'/Text/Diff/Renderer.php' );
15
+	require(dirname(__FILE__).'/Text/Diff/Renderer.php');
16 16
 	/** Text_Diff_Renderer_inline class */
17
-	require( dirname(__FILE__).'/Text/Diff/Renderer/inline.php' );
17
+	require(dirname(__FILE__).'/Text/Diff/Renderer/inline.php');
18 18
 }
19 19
 
20 20
 /**
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 * @access public
32 32
 	 * @since 2.6.0
33 33
 	 */
34
-	public $_leading_context_lines  = 10000;
34
+	public $_leading_context_lines = 10000;
35 35
 
36 36
 	/**
37 37
 	 * @see Text_Diff_Renderer::_trailing_context_lines
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	protected $_show_split_view = true;
70 70
 
71
-	protected $compat_fields = array( '_show_split_view', 'inline_diff_renderer', '_diff_threshold' );
71
+	protected $compat_fields = array('_show_split_view', 'inline_diff_renderer', '_diff_threshold');
72 72
 
73 73
 	/**
74 74
 	 * Constructor - Call parent constructor with params array.
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
 	 *
80 80
 	 * @param array $params
81 81
 	 */
82
-	public function __construct( $params = array() ) {
83
-		parent::__construct( $params );
84
-		if ( isset( $params[ 'show_split_view' ] ) )
85
-			$this->_show_split_view = $params[ 'show_split_view' ];
82
+	public function __construct($params = array()) {
83
+		parent::__construct($params);
84
+		if (isset($params['show_split_view']))
85
+			$this->_show_split_view = $params['show_split_view'];
86 86
 	}
87 87
 
88 88
 	/**
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 * @param string $header
92 92
 	 * @return string
93 93
 	 */
94
-	public function _startBlock( $header ) {
94
+	public function _startBlock($header) {
95 95
 		return '';
96 96
 	}
97 97
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 * @param array $lines
102 102
 	 * @param string $prefix
103 103
 	 */
104
-	public function _lines( $lines, $prefix=' ' ) {
104
+	public function _lines($lines, $prefix = ' ') {
105 105
 	}
106 106
 
107 107
 	/**
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 * @param string $line HTML-escape the value.
111 111
 	 * @return string
112 112
 	 */
113
-	public function addedLine( $line ) {
113
+	public function addedLine($line) {
114 114
 		return "<td class='diff-addedline'>{$line}</td>";
115 115
 
116 116
 	}
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 * @param string $line HTML-escape the value.
122 122
 	 * @return string
123 123
 	 */
124
-	public function deletedLine( $line ) {
124
+	public function deletedLine($line) {
125 125
 		return "<td class='diff-deletedline'>{$line}</td>";
126 126
 	}
127 127
 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 * @param string $line HTML-escape the value.
132 132
 	 * @return string
133 133
 	 */
134
-	public function contextLine( $line ) {
134
+	public function contextLine($line) {
135 135
 		return "<td class='diff-context'>{$line}</td>";
136 136
 	}
137 137
 
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
 	 * @param bool $encode
153 153
 	 * @return string
154 154
 	 */
155
-	public function _added( $lines, $encode = true ) {
155
+	public function _added($lines, $encode = true) {
156 156
 		$r = '';
157 157
 		foreach ($lines as $line) {
158
-			if ( $encode ) {
159
-				$processed_line = htmlspecialchars( $line );
158
+			if ($encode) {
159
+				$processed_line = htmlspecialchars($line);
160 160
 
161 161
 				/**
162 162
 				 * Contextually filter a diffed line.
@@ -171,13 +171,13 @@  discard block
 block discarded – undo
171 171
 				 * @param String $line           The unprocessed diffed line.
172 172
 		 		 * @param string null            The line context. Values are 'added', 'deleted' or 'unchanged'.
173 173
 				 */
174
-				$line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'added' );
174
+				$line = apply_filters('process_text_diff_html', $processed_line, $line, 'added');
175 175
 			}
176 176
 
177
-			if ( $this->_show_split_view ) {
178
-				$r .= '<tr>' . $this->emptyLine() . $this->emptyLine() . $this->addedLine( $line ) . "</tr>\n";
177
+			if ($this->_show_split_view) {
178
+				$r .= '<tr>'.$this->emptyLine().$this->emptyLine().$this->addedLine($line)."</tr>\n";
179 179
 			} else {
180
-				$r .= '<tr>' . $this->addedLine( $line ) . "</tr>\n";
180
+				$r .= '<tr>'.$this->addedLine($line)."</tr>\n";
181 181
 			}
182 182
 		}
183 183
 		return $r;
@@ -191,19 +191,19 @@  discard block
 block discarded – undo
191 191
 	 * @param bool $encode
192 192
 	 * @return string
193 193
 	 */
194
-	public function _deleted( $lines, $encode = true ) {
194
+	public function _deleted($lines, $encode = true) {
195 195
 		$r = '';
196 196
 		foreach ($lines as $line) {
197
-			if ( $encode ) {
198
-				$processed_line = htmlspecialchars( $line );
197
+			if ($encode) {
198
+				$processed_line = htmlspecialchars($line);
199 199
 
200 200
 				/** This filter is documented in wp-includes/wp-diff.php */
201
-				$line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'deleted' );
201
+				$line = apply_filters('process_text_diff_html', $processed_line, $line, 'deleted');
202 202
 			}
203
-			if ( $this->_show_split_view ) {
204
-				$r .= '<tr>' . $this->deletedLine( $line ) . $this->emptyLine() . $this->emptyLine() . "</tr>\n";
203
+			if ($this->_show_split_view) {
204
+				$r .= '<tr>'.$this->deletedLine($line).$this->emptyLine().$this->emptyLine()."</tr>\n";
205 205
 			} else {
206
-				$r .= '<tr>' . $this->deletedLine( $line ) . "</tr>\n";
206
+				$r .= '<tr>'.$this->deletedLine($line)."</tr>\n";
207 207
 			}
208 208
 
209 209
 		}
@@ -218,19 +218,19 @@  discard block
 block discarded – undo
218 218
 	 * @param bool $encode
219 219
 	 * @return string
220 220
 	 */
221
-	public function _context( $lines, $encode = true ) {
221
+	public function _context($lines, $encode = true) {
222 222
 		$r = '';
223 223
 		foreach ($lines as $line) {
224
-			if ( $encode ) {
225
-				$processed_line = htmlspecialchars( $line );
224
+			if ($encode) {
225
+				$processed_line = htmlspecialchars($line);
226 226
 
227 227
 				/** This filter is documented in wp-includes/wp-diff.php */
228
-				$line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'unchanged' );
228
+				$line = apply_filters('process_text_diff_html', $processed_line, $line, 'unchanged');
229 229
 			}
230
-			if (  $this->_show_split_view ) {
231
-				$r .= '<tr>' . $this->contextLine( $line ) . $this->emptyLine() . $this->contextLine( $line )  . "</tr>\n";
230
+			if ($this->_show_split_view) {
231
+				$r .= '<tr>'.$this->contextLine($line).$this->emptyLine().$this->contextLine($line)."</tr>\n";
232 232
 			} else {
233
-				$r .= '<tr>' . $this->contextLine( $line ) . "</tr>\n";
233
+				$r .= '<tr>'.$this->contextLine($line)."</tr>\n";
234 234
 			}
235 235
 		}
236 236
 		return $r;
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 	 * @param array $final
250 250
 	 * @return string
251 251
 	 */
252
-	public function _changed( $orig, $final ) {
252
+	public function _changed($orig, $final) {
253 253
 		$r = '';
254 254
 
255 255
 		// Does the aforementioned additional processing
@@ -259,66 +259,66 @@  discard block
 block discarded – undo
259 259
 		// *_rows are column vectors for the orig column and the final column.
260 260
 		//	row >= 0: an indix of the $orig or $final array
261 261
 		//	row  < 0: a blank row for that column
262
-		list($orig_matches, $final_matches, $orig_rows, $final_rows) = $this->interleave_changed_lines( $orig, $final );
262
+		list($orig_matches, $final_matches, $orig_rows, $final_rows) = $this->interleave_changed_lines($orig, $final);
263 263
 
264 264
 		// These will hold the word changes as determined by an inline diff
265 265
 		$orig_diffs  = array();
266 266
 		$final_diffs = array();
267 267
 
268 268
 		// Compute word diffs for each matched pair using the inline diff
269
-		foreach ( $orig_matches as $o => $f ) {
270
-			if ( is_numeric($o) && is_numeric($f) ) {
271
-				$text_diff = new Text_Diff( 'auto', array( array($orig[$o]), array($final[$f]) ) );
269
+		foreach ($orig_matches as $o => $f) {
270
+			if (is_numeric($o) && is_numeric($f)) {
271
+				$text_diff = new Text_Diff('auto', array(array($orig[$o]), array($final[$f])));
272 272
 				$renderer = new $this->inline_diff_renderer;
273
-				$diff = $renderer->render( $text_diff );
273
+				$diff = $renderer->render($text_diff);
274 274
 
275 275
 				// If they're too different, don't include any <ins> or <dels>
276
-				if ( preg_match_all( '!(<ins>.*?</ins>|<del>.*?</del>)!', $diff, $diff_matches ) ) {
276
+				if (preg_match_all('!(<ins>.*?</ins>|<del>.*?</del>)!', $diff, $diff_matches)) {
277 277
 					// length of all text between <ins> or <del>
278
-					$stripped_matches = strlen(strip_tags( join(' ', $diff_matches[0]) ));
278
+					$stripped_matches = strlen(strip_tags(join(' ', $diff_matches[0])));
279 279
 					// since we count lengith of text between <ins> or <del> (instead of picking just one),
280 280
 					//	we double the length of chars not in those tags.
281
-					$stripped_diff = strlen(strip_tags( $diff )) * 2 - $stripped_matches;
281
+					$stripped_diff = strlen(strip_tags($diff)) * 2 - $stripped_matches;
282 282
 					$diff_ratio = $stripped_matches / $stripped_diff;
283
-					if ( $diff_ratio > $this->_diff_threshold )
283
+					if ($diff_ratio > $this->_diff_threshold)
284 284
 						continue; // Too different. Don't save diffs.
285 285
 				}
286 286
 
287 287
 				// Un-inline the diffs by removing del or ins
288
-				$orig_diffs[$o]  = preg_replace( '|<ins>.*?</ins>|', '', $diff );
289
-				$final_diffs[$f] = preg_replace( '|<del>.*?</del>|', '', $diff );
288
+				$orig_diffs[$o]  = preg_replace('|<ins>.*?</ins>|', '', $diff);
289
+				$final_diffs[$f] = preg_replace('|<del>.*?</del>|', '', $diff);
290 290
 			}
291 291
 		}
292 292
 
293
-		foreach ( array_keys($orig_rows) as $row ) {
293
+		foreach (array_keys($orig_rows) as $row) {
294 294
 			// Both columns have blanks. Ignore them.
295
-			if ( $orig_rows[$row] < 0 && $final_rows[$row] < 0 )
295
+			if ($orig_rows[$row] < 0 && $final_rows[$row] < 0)
296 296
 				continue;
297 297
 
298 298
 			// If we have a word based diff, use it. Otherwise, use the normal line.
299
-			if ( isset( $orig_diffs[$orig_rows[$row]] ) )
299
+			if (isset($orig_diffs[$orig_rows[$row]]))
300 300
 				$orig_line = $orig_diffs[$orig_rows[$row]];
301
-			elseif ( isset( $orig[$orig_rows[$row]] ) )
301
+			elseif (isset($orig[$orig_rows[$row]]))
302 302
 				$orig_line = htmlspecialchars($orig[$orig_rows[$row]]);
303 303
 			else
304 304
 				$orig_line = '';
305 305
 
306
-			if ( isset( $final_diffs[$final_rows[$row]] ) )
306
+			if (isset($final_diffs[$final_rows[$row]]))
307 307
 				$final_line = $final_diffs[$final_rows[$row]];
308
-			elseif ( isset( $final[$final_rows[$row]] ) )
308
+			elseif (isset($final[$final_rows[$row]]))
309 309
 				$final_line = htmlspecialchars($final[$final_rows[$row]]);
310 310
 			else
311 311
 				$final_line = '';
312 312
 
313
-			if ( $orig_rows[$row] < 0 ) { // Orig is blank. This is really an added row.
314
-				$r .= $this->_added( array($final_line), false );
315
-			} elseif ( $final_rows[$row] < 0 ) { // Final is blank. This is really a deleted row.
316
-				$r .= $this->_deleted( array($orig_line), false );
313
+			if ($orig_rows[$row] < 0) { // Orig is blank. This is really an added row.
314
+				$r .= $this->_added(array($final_line), false);
315
+			} elseif ($final_rows[$row] < 0) { // Final is blank. This is really a deleted row.
316
+				$r .= $this->_deleted(array($orig_line), false);
317 317
 			} else { // A true changed row.
318
-				if ( $this->_show_split_view ) {
319
-					$r .= '<tr>' . $this->deletedLine( $orig_line ) . $this->emptyLine() . $this->addedLine( $final_line ) . "</tr>\n";
318
+				if ($this->_show_split_view) {
319
+					$r .= '<tr>'.$this->deletedLine($orig_line).$this->emptyLine().$this->addedLine($final_line)."</tr>\n";
320 320
 				} else {
321
-					$r .= '<tr>' . $this->deletedLine( $orig_line ) . "</tr><tr>" . $this->addedLine( $final_line ) . "</tr>\n";
321
+					$r .= '<tr>'.$this->deletedLine($orig_line)."</tr><tr>".$this->addedLine($final_line)."</tr>\n";
322 322
 				}
323 323
 			}
324 324
 		}
@@ -340,13 +340,13 @@  discard block
 block discarded – undo
340 340
 	 * @param array $final
341 341
 	 * @return array
342 342
 	 */
343
-	public function interleave_changed_lines( $orig, $final ) {
343
+	public function interleave_changed_lines($orig, $final) {
344 344
 
345 345
 		// Contains all pairwise string comparisons. Keys are such that this need only be a one dimensional array.
346 346
 		$matches = array();
347
-		foreach ( array_keys($orig) as $o ) {
348
-			foreach ( array_keys($final) as $f ) {
349
-				$matches["$o,$f"] = $this->compute_string_distance( $orig[$o], $final[$f] );
347
+		foreach (array_keys($orig) as $o) {
348
+			foreach (array_keys($final) as $f) {
349
+				$matches["$o,$f"] = $this->compute_string_distance($orig[$o], $final[$f]);
350 350
 			}
351 351
 		}
352 352
 		asort($matches); // Order by string distance.
@@ -354,28 +354,28 @@  discard block
 block discarded – undo
354 354
 		$orig_matches  = array();
355 355
 		$final_matches = array();
356 356
 
357
-		foreach ( $matches as $keys => $difference ) {
357
+		foreach ($matches as $keys => $difference) {
358 358
 			list($o, $f) = explode(',', $keys);
359 359
 			$o = (int) $o;
360 360
 			$f = (int) $f;
361 361
 
362 362
 			// Already have better matches for these guys
363
-			if ( isset($orig_matches[$o]) && isset($final_matches[$f]) )
363
+			if (isset($orig_matches[$o]) && isset($final_matches[$f]))
364 364
 				continue;
365 365
 
366 366
 			// First match for these guys. Must be best match
367
-			if ( !isset($orig_matches[$o]) && !isset($final_matches[$f]) ) {
367
+			if ( ! isset($orig_matches[$o]) && ! isset($final_matches[$f])) {
368 368
 				$orig_matches[$o] = $f;
369 369
 				$final_matches[$f] = $o;
370 370
 				continue;
371 371
 			}
372 372
 
373 373
 			// Best match of this final is already taken?  Must mean this final is a new row.
374
-			if ( isset($orig_matches[$o]) )
374
+			if (isset($orig_matches[$o]))
375 375
 				$final_matches[$f] = 'x';
376 376
 
377 377
 			// Best match of this orig is already taken?  Must mean this orig is a deleted row.
378
-			elseif ( isset($final_matches[$f]) )
378
+			elseif (isset($final_matches[$f]))
379 379
 				$orig_matches[$o] = 'x';
380 380
 		}
381 381
 
@@ -389,31 +389,31 @@  discard block
 block discarded – undo
389 389
 
390 390
 		// Interleaves rows with blanks to keep matches aligned.
391 391
 		// We may end up with some extraneous blank rows, but we'll just ignore them later.
392
-		foreach ( $orig_rows_copy as $orig_row ) {
392
+		foreach ($orig_rows_copy as $orig_row) {
393 393
 			$final_pos = array_search($orig_matches[$orig_row], $final_rows, true);
394 394
 			$orig_pos = (int) array_search($orig_row, $orig_rows, true);
395 395
 
396
-			if ( false === $final_pos ) { // This orig is paired with a blank final.
397
-				array_splice( $final_rows, $orig_pos, 0, -1 );
398
-			} elseif ( $final_pos < $orig_pos ) { // This orig's match is up a ways. Pad final with blank rows.
396
+			if (false === $final_pos) { // This orig is paired with a blank final.
397
+				array_splice($final_rows, $orig_pos, 0, -1);
398
+			} elseif ($final_pos < $orig_pos) { // This orig's match is up a ways. Pad final with blank rows.
399 399
 				$diff_pos = $final_pos - $orig_pos;
400
-				while ( $diff_pos < 0 )
401
-					array_splice( $final_rows, $orig_pos, 0, $diff_pos++ );
402
-			} elseif ( $final_pos > $orig_pos ) { // This orig's match is down a ways. Pad orig with blank rows.
400
+				while ($diff_pos < 0)
401
+					array_splice($final_rows, $orig_pos, 0, $diff_pos++);
402
+			} elseif ($final_pos > $orig_pos) { // This orig's match is down a ways. Pad orig with blank rows.
403 403
 				$diff_pos = $orig_pos - $final_pos;
404
-				while ( $diff_pos < 0 )
405
-					array_splice( $orig_rows, $orig_pos, 0, $diff_pos++ );
404
+				while ($diff_pos < 0)
405
+					array_splice($orig_rows, $orig_pos, 0, $diff_pos++);
406 406
 			}
407 407
 		}
408 408
 
409 409
 		// Pad the ends with blank rows if the columns aren't the same length
410 410
 		$diff_count = count($orig_rows) - count($final_rows);
411
-		if ( $diff_count < 0 ) {
412
-			while ( $diff_count < 0 )
411
+		if ($diff_count < 0) {
412
+			while ($diff_count < 0)
413 413
 				array_push($orig_rows, $diff_count++);
414
-		} elseif ( $diff_count > 0 ) {
414
+		} elseif ($diff_count > 0) {
415 415
 			$diff_count = -1 * $diff_count;
416
-			while ( $diff_count < 0 )
416
+			while ($diff_count < 0)
417 417
 				array_push($final_rows, $diff_count++);
418 418
 		}
419 419
 
@@ -429,16 +429,16 @@  discard block
 block discarded – undo
429 429
 	 * @param string $string2
430 430
 	 * @return int
431 431
 	 */
432
-	public function compute_string_distance( $string1, $string2 ) {
432
+	public function compute_string_distance($string1, $string2) {
433 433
 		// Vectors containing character frequency for all chars in each string
434 434
 		$chars1 = count_chars($string1);
435 435
 		$chars2 = count_chars($string2);
436 436
 
437 437
 		// L1-norm of difference vector.
438
-		$difference = array_sum( array_map( array($this, 'difference'), $chars1, $chars2 ) );
438
+		$difference = array_sum(array_map(array($this, 'difference'), $chars1, $chars2));
439 439
 
440 440
 		// $string1 has zero length? Odd. Give huge penalty by not dividing.
441
-		if ( !$string1 )
441
+		if ( ! $string1)
442 442
 			return $difference;
443 443
 
444 444
 		// Return distance per character (of string1).
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
 	 * @param int $b
454 454
 	 * @return int
455 455
 	 */
456
-	public function difference( $a, $b ) {
457
-		return abs( $a - $b );
456
+	public function difference($a, $b) {
457
+		return abs($a - $b);
458 458
 	}
459 459
 
460 460
 	/**
@@ -466,8 +466,8 @@  discard block
 block discarded – undo
466 466
 	 * @param string $name Property to get.
467 467
 	 * @return mixed Property.
468 468
 	 */
469
-	public function __get( $name ) {
470
-		if ( in_array( $name, $this->compat_fields ) ) {
469
+	public function __get($name) {
470
+		if (in_array($name, $this->compat_fields)) {
471 471
 			return $this->$name;
472 472
 		}
473 473
 	}
@@ -482,8 +482,8 @@  discard block
 block discarded – undo
482 482
 	 * @param mixed  $value Property value.
483 483
 	 * @return mixed Newly-set property.
484 484
 	 */
485
-	public function __set( $name, $value ) {
486
-		if ( in_array( $name, $this->compat_fields ) ) {
485
+	public function __set($name, $value) {
486
+		if (in_array($name, $this->compat_fields)) {
487 487
 			return $this->$name = $value;
488 488
 		}
489 489
 	}
@@ -497,9 +497,9 @@  discard block
 block discarded – undo
497 497
 	 * @param string $name Property to check if set.
498 498
 	 * @return bool Whether the property is set.
499 499
 	 */
500
-	public function __isset( $name ) {
501
-		if ( in_array( $name, $this->compat_fields ) ) {
502
-			return isset( $this->$name );
500
+	public function __isset($name) {
501
+		if (in_array($name, $this->compat_fields)) {
502
+			return isset($this->$name);
503 503
 		}
504 504
 	}
505 505
 
@@ -511,9 +511,9 @@  discard block
 block discarded – undo
511 511
 	 *
512 512
 	 * @param string $name Property to unset.
513 513
 	 */
514
-	public function __unset( $name ) {
515
-		if ( in_array( $name, $this->compat_fields ) ) {
516
-			unset( $this->$name );
514
+	public function __unset($name) {
515
+		if (in_array($name, $this->compat_fields)) {
516
+			unset($this->$name);
517 517
 		}
518 518
 	}
519 519
 }
@@ -536,8 +536,8 @@  discard block
 block discarded – undo
536 536
 	 */
537 537
 	public function _splitOnWords($string, $newlineEscape = "\n") {
538 538
 		$string = str_replace("\0", '', $string);
539
-		$words  = preg_split( '/([^\w])/u', $string, -1, PREG_SPLIT_DELIM_CAPTURE );
540
-		$words  = str_replace( "\n", $newlineEscape, $words );
539
+		$words  = preg_split('/([^\w])/u', $string, -1, PREG_SPLIT_DELIM_CAPTURE);
540
+		$words  = str_replace("\n", $newlineEscape, $words);
541 541
 		return $words;
542 542
 	}
543 543
 
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -169,7 +169,7 @@
 block discarded – undo
169 169
 				 *
170 170
 				 * @param String $processed_line The processed diffed line.
171 171
 				 * @param String $line           The unprocessed diffed line.
172
-		 		 * @param string null            The line context. Values are 'added', 'deleted' or 'unchanged'.
172
+				 * @param string null            The line context. Values are 'added', 'deleted' or 'unchanged'.
173 173
 				 */
174 174
 				$line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'added' );
175 175
 			}
Please login to merge, or discard this patch.
src/wp-trackback.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
  *
21 21
  * @since 0.71
22 22
  *
23
- * @param mixed  $error         Whether there was an error.
23
+ * @param integer  $error         Whether there was an error.
24 24
  *                              Default '0'. Accepts '0' or '1', true or false.
25 25
  * @param string $error_message Error message if an error occurred.
26 26
  */
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -9,8 +9,8 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 if (empty($wp)) {
12
-	require_once( dirname( __FILE__ ) . '/wp-load.php' );
13
-	wp( array( 'tb' => '1' ) );
12
+	require_once(dirname(__FILE__).'/wp-load.php');
13
+	wp(array('tb' => '1'));
14 14
 }
15 15
 
16 16
 /**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  * @param string $error_message Error message if an error occurred.
26 26
  */
27 27
 function trackback_response($error = 0, $error_message = '') {
28
-	header('Content-Type: text/xml; charset=' . get_option('blog_charset') );
28
+	header('Content-Type: text/xml; charset='.get_option('blog_charset'));
29 29
 	if ($error) {
30 30
 		echo '<?xml version="1.0" encoding="utf-8"?'.">\n";
31 31
 		echo "<response>\n";
@@ -44,30 +44,30 @@  discard block
 block discarded – undo
44 44
 // Trackback is done by a POST.
45 45
 $request_array = 'HTTP_POST_VARS';
46 46
 
47
-if ( !isset($_GET['tb_id']) || !$_GET['tb_id'] ) {
47
+if ( ! isset($_GET['tb_id']) || ! $_GET['tb_id']) {
48 48
 	$tb_id = explode('/', $_SERVER['REQUEST_URI']);
49
-	$tb_id = intval( $tb_id[ count($tb_id) - 1 ] );
49
+	$tb_id = intval($tb_id[count($tb_id) - 1]);
50 50
 }
51 51
 
52
-$tb_url  = isset($_POST['url'])     ? $_POST['url']     : '';
52
+$tb_url  = isset($_POST['url']) ? $_POST['url'] : '';
53 53
 $charset = isset($_POST['charset']) ? $_POST['charset'] : '';
54 54
 
55 55
 // These three are stripslashed here so they can be properly escaped after mb_convert_encoding().
56
-$title     = isset($_POST['title'])     ? wp_unslash($_POST['title'])      : '';
57
-$excerpt   = isset($_POST['excerpt'])   ? wp_unslash($_POST['excerpt'])    : '';
58
-$blog_name = isset($_POST['blog_name']) ? wp_unslash($_POST['blog_name'])  : '';
56
+$title     = isset($_POST['title']) ? wp_unslash($_POST['title']) : '';
57
+$excerpt   = isset($_POST['excerpt']) ? wp_unslash($_POST['excerpt']) : '';
58
+$blog_name = isset($_POST['blog_name']) ? wp_unslash($_POST['blog_name']) : '';
59 59
 
60 60
 if ($charset)
61
-	$charset = str_replace( array(',', ' '), '', strtoupper( trim($charset) ) );
61
+	$charset = str_replace(array(',', ' '), '', strtoupper(trim($charset)));
62 62
 else
63 63
 	$charset = 'ASCII, UTF-8, ISO-8859-1, JIS, EUC-JP, SJIS';
64 64
 
65 65
 // No valid uses for UTF-7.
66
-if ( false !== strpos($charset, 'UTF-7') )
66
+if (false !== strpos($charset, 'UTF-7'))
67 67
 	die;
68 68
 
69 69
 // For international trackbacks.
70
-if ( function_exists('mb_convert_encoding') ) {
70
+if (function_exists('mb_convert_encoding')) {
71 71
 	$title     = mb_convert_encoding($title, get_option('blog_charset'), $charset);
72 72
 	$excerpt   = mb_convert_encoding($excerpt, get_option('blog_charset'), $charset);
73 73
 	$blog_name = mb_convert_encoding($blog_name, get_option('blog_charset'), $charset);
@@ -78,10 +78,10 @@  discard block
 block discarded – undo
78 78
 $excerpt   = wp_slash($excerpt);
79 79
 $blog_name = wp_slash($blog_name);
80 80
 
81
-if ( is_single() || is_page() )
81
+if (is_single() || is_page())
82 82
 	$tb_id = $posts[0]->ID;
83 83
 
84
-if ( !isset($tb_id) || !intval( $tb_id ) )
84
+if ( ! isset($tb_id) || ! intval($tb_id))
85 85
 	trackback_response(1, 'I really need an ID for this to work.');
86 86
 
87 87
 if (empty($title) && empty($tb_url) && empty($blog_name)) {
@@ -90,14 +90,14 @@  discard block
 block discarded – undo
90 90
 	exit;
91 91
 }
92 92
 
93
-if ( !empty($tb_url) && !empty($title) ) {
94
-	header('Content-Type: text/xml; charset=' . get_option('blog_charset') );
93
+if ( ! empty($tb_url) && ! empty($title)) {
94
+	header('Content-Type: text/xml; charset='.get_option('blog_charset'));
95 95
 
96
-	if ( !pings_open($tb_id) )
96
+	if ( ! pings_open($tb_id))
97 97
 		trackback_response(1, 'Sorry, trackbacks are closed for this item.');
98 98
 
99
-	$title =  wp_html_excerpt( $title, 250, '&#8230;' );
100
-	$excerpt = wp_html_excerpt( $excerpt, 252, '&#8230;' );
99
+	$title = wp_html_excerpt($title, 250, '&#8230;');
100
+	$excerpt = wp_html_excerpt($excerpt, 252, '&#8230;');
101 101
 
102 102
 	$comment_post_ID = (int) $tb_id;
103 103
 	$comment_author = $blog_name;
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
 	$comment_content = "<strong>$title</strong>\n\n$excerpt";
107 107
 	$comment_type = 'trackback';
108 108
 
109
-	$dupe = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $comment_post_ID, $comment_author_url) );
110
-	if ( $dupe )
109
+	$dupe = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $comment_post_ID, $comment_author_url));
110
+	if ($dupe)
111 111
 		trackback_response(1, 'We already have a ping from that URL for this post.');
112 112
 
113 113
 	$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type');
@@ -122,6 +122,6 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 * @param int $trackback_id Trackback ID.
124 124
 	 */
125
-	do_action( 'trackback_post', $trackback_id );
126
-	trackback_response( 0 );
125
+	do_action('trackback_post', $trackback_id);
126
+	trackback_response(0);
127 127
 }
Please login to merge, or discard this patch.
Braces   +15 added lines, -9 removed lines patch added patch discarded remove patch
@@ -57,14 +57,16 @@  discard block
 block discarded – undo
57 57
 $excerpt   = isset($_POST['excerpt'])   ? wp_unslash($_POST['excerpt'])    : '';
58 58
 $blog_name = isset($_POST['blog_name']) ? wp_unslash($_POST['blog_name'])  : '';
59 59
 
60
-if ($charset)
60
+if ($charset) {
61 61
 	$charset = str_replace( array(',', ' '), '', strtoupper( trim($charset) ) );
62
-else
62
+} else {
63 63
 	$charset = 'ASCII, UTF-8, ISO-8859-1, JIS, EUC-JP, SJIS';
64
+}
64 65
 
65 66
 // No valid uses for UTF-7.
66
-if ( false !== strpos($charset, 'UTF-7') )
67
+if ( false !== strpos($charset, 'UTF-7') ) {
67 68
 	die;
69
+}
68 70
 
69 71
 // For international trackbacks.
70 72
 if ( function_exists('mb_convert_encoding') ) {
@@ -78,11 +80,13 @@  discard block
 block discarded – undo
78 80
 $excerpt   = wp_slash($excerpt);
79 81
 $blog_name = wp_slash($blog_name);
80 82
 
81
-if ( is_single() || is_page() )
83
+if ( is_single() || is_page() ) {
82 84
 	$tb_id = $posts[0]->ID;
85
+}
83 86
 
84
-if ( !isset($tb_id) || !intval( $tb_id ) )
87
+if ( !isset($tb_id) || !intval( $tb_id ) ) {
85 88
 	trackback_response(1, 'I really need an ID for this to work.');
89
+}
86 90
 
87 91
 if (empty($title) && empty($tb_url) && empty($blog_name)) {
88 92
 	// If it doesn't look like a trackback at all.
@@ -93,8 +97,9 @@  discard block
 block discarded – undo
93 97
 if ( !empty($tb_url) && !empty($title) ) {
94 98
 	header('Content-Type: text/xml; charset=' . get_option('blog_charset') );
95 99
 
96
-	if ( !pings_open($tb_id) )
97
-		trackback_response(1, 'Sorry, trackbacks are closed for this item.');
100
+	if ( !pings_open($tb_id) ) {
101
+			trackback_response(1, 'Sorry, trackbacks are closed for this item.');
102
+	}
98 103
 
99 104
 	$title =  wp_html_excerpt( $title, 250, '&#8230;' );
100 105
 	$excerpt = wp_html_excerpt( $excerpt, 252, '&#8230;' );
@@ -107,8 +112,9 @@  discard block
 block discarded – undo
107 112
 	$comment_type = 'trackback';
108 113
 
109 114
 	$dupe = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $comment_post_ID, $comment_author_url) );
110
-	if ( $dupe )
111
-		trackback_response(1, 'We already have a ping from that URL for this post.');
115
+	if ( $dupe ) {
116
+			trackback_response(1, 'We already have a ping from that URL for this post.');
117
+	}
112 118
 
113 119
 	$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type');
114 120
 
Please login to merge, or discard this patch.