Completed
Push — master ( d99bf9...491baf )
by Stephen
13:47
created
src/wp-includes/atomlib.php 3 patches
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -137,7 +137,9 @@  discard block
 block discarded – undo
137 137
 
138 138
         $fp = fopen($this->FILE, "r");
139 139
         while ($data = fread($fp, 4096)) {
140
-            if($this->debug) $this->content .= $data;
140
+            if($this->debug) {
141
+            	$this->content .= $data;
142
+            }
141 143
 
142 144
             if(!xml_parse($parser, $data, feof($fp))) {
143 145
                 /* translators: 1: error message, 2: line number */
@@ -182,8 +184,9 @@  discard block
 block discarded – undo
182 184
 
183 185
             $this->content_ns_decls = array();
184 186
 
185
-            if($this->is_html || $this->is_text)
186
-                trigger_error("Invalid content in element found. Content must not be of type text or html if it contains markup.");
187
+            if($this->is_html || $this->is_text) {
188
+                            trigger_error("Invalid content in element found. Content must not be of type text or html if it contains markup.");
189
+            }
187 190
 
188 191
             $attrs_prefix = array();
189 192
 
Please login to merge, or discard this patch.
Indentation   +289 added lines, -289 removed lines patch added patch discarded remove patch
@@ -21,20 +21,20 @@  discard block
 block discarded – undo
21 21
 	 * @var array
22 22
 	 * @access public
23 23
 	 */
24
-    var $links = array();
25
-    /**
26
-     * Stores Categories
27
-     * @var array
28
-     * @access public
29
-     */
30
-    var $categories = array();
24
+	var $links = array();
25
+	/**
26
+	 * Stores Categories
27
+	 * @var array
28
+	 * @access public
29
+	 */
30
+	var $categories = array();
31 31
 	/**
32 32
 	 * Stores Entries
33 33
 	 *
34 34
 	 * @var array
35 35
 	 * @access public
36 36
 	 */
37
-    var $entries = array();
37
+	var $entries = array();
38 38
 }
39 39
 
40 40
 /**
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 	 * @var array
49 49
 	 * @access public
50 50
 	 */
51
-    var $links = array();
52
-    /**
53
-     * Stores Categories
54
-     * @var array
51
+	var $links = array();
52
+	/**
53
+	 * Stores Categories
54
+	 * @var array
55 55
 	 * @access public
56
-     */
57
-    var $categories = array();
56
+	 */
57
+	var $categories = array();
58 58
 }
59 59
 
60 60
 /**
@@ -64,39 +64,39 @@  discard block
 block discarded – undo
64 64
  */
65 65
 class AtomParser {
66 66
 
67
-    var $NS = 'http://www.w3.org/2005/Atom';
68
-    var $ATOM_CONTENT_ELEMENTS = array('content','summary','title','subtitle','rights');
69
-    var $ATOM_SIMPLE_ELEMENTS = array('id','updated','published','draft');
67
+	var $NS = 'http://www.w3.org/2005/Atom';
68
+	var $ATOM_CONTENT_ELEMENTS = array('content','summary','title','subtitle','rights');
69
+	var $ATOM_SIMPLE_ELEMENTS = array('id','updated','published','draft');
70 70
 
71
-    var $debug = false;
71
+	var $debug = false;
72 72
 
73
-    var $depth = 0;
74
-    var $indent = 2;
75
-    var $in_content;
76
-    var $ns_contexts = array();
77
-    var $ns_decls = array();
78
-    var $content_ns_decls = array();
79
-    var $content_ns_contexts = array();
80
-    var $is_xhtml = false;
81
-    var $is_html = false;
82
-    var $is_text = true;
83
-    var $skipped_div = false;
73
+	var $depth = 0;
74
+	var $indent = 2;
75
+	var $in_content;
76
+	var $ns_contexts = array();
77
+	var $ns_decls = array();
78
+	var $content_ns_decls = array();
79
+	var $content_ns_contexts = array();
80
+	var $is_xhtml = false;
81
+	var $is_html = false;
82
+	var $is_text = true;
83
+	var $skipped_div = false;
84 84
 
85
-    var $FILE = "php://input";
85
+	var $FILE = "php://input";
86 86
 
87
-    var $feed;
88
-    var $current;
87
+	var $feed;
88
+	var $current;
89 89
 
90 90
 	/**
91 91
 	 * PHP5 constructor.
92 92
 	 */
93
-    function __construct() {
93
+	function __construct() {
94 94
 
95
-        $this->feed = new AtomFeed();
96
-        $this->current = null;
97
-        $this->map_attrs_func = array( __CLASS__, 'map_attrs' );
98
-        $this->map_xmlns_func = array( __CLASS__, 'map_xmlns' );
99
-    }
95
+		$this->feed = new AtomFeed();
96
+		$this->current = null;
97
+		$this->map_attrs_func = array( __CLASS__, 'map_attrs' );
98
+		$this->map_xmlns_func = array( __CLASS__, 'map_xmlns' );
99
+	}
100 100
 
101 101
 	/**
102 102
 	 * PHP4 constructor.
@@ -131,264 +131,264 @@  discard block
 block discarded – undo
131 131
 		return "{$xd}=\"{$n[1]}\"";
132 132
 	}
133 133
 
134
-    function _p($msg) {
135
-        if($this->debug) {
136
-            print str_repeat(" ", $this->depth * $this->indent) . $msg ."\n";
137
-        }
138
-    }
134
+	function _p($msg) {
135
+		if($this->debug) {
136
+			print str_repeat(" ", $this->depth * $this->indent) . $msg ."\n";
137
+		}
138
+	}
139
+
140
+	function error_handler($log_level, $log_text, $error_file, $error_line) {
141
+		$this->error = $log_text;
142
+	}
143
+
144
+	function parse() {
139 145
 
140
-    function error_handler($log_level, $log_text, $error_file, $error_line) {
141
-        $this->error = $log_text;
142
-    }
146
+		set_error_handler(array(&$this, 'error_handler'));
143 147
 
144
-    function parse() {
148
+		array_unshift($this->ns_contexts, array());
145 149
 
146
-        set_error_handler(array(&$this, 'error_handler'));
150
+		if ( ! function_exists( 'xml_parser_create_ns' ) ) {
151
+			trigger_error( __( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." ) );
152
+			return false;
153
+		}
154
+
155
+		$parser = xml_parser_create_ns();
156
+		xml_set_object($parser, $this);
157
+		xml_set_element_handler($parser, "start_element", "end_element");
158
+		xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
159
+		xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,0);
160
+		xml_set_character_data_handler($parser, "cdata");
161
+		xml_set_default_handler($parser, "_default");
162
+		xml_set_start_namespace_decl_handler($parser, "start_ns");
163
+		xml_set_end_namespace_decl_handler($parser, "end_ns");
164
+
165
+		$this->content = '';
166
+
167
+		$ret = true;
168
+
169
+		$fp = fopen($this->FILE, "r");
170
+		while ($data = fread($fp, 4096)) {
171
+			if($this->debug) $this->content .= $data;
172
+
173
+			if(!xml_parse($parser, $data, feof($fp))) {
174
+				/* translators: 1: error message, 2: line number */
175
+				trigger_error(sprintf(__('XML Error: %1$s at line %2$s')."\n",
176
+					xml_error_string(xml_get_error_code($parser)),
177
+					xml_get_current_line_number($parser)));
178
+				$ret = false;
179
+				break;
180
+			}
181
+		}
182
+		fclose($fp);
147 183
 
148
-        array_unshift($this->ns_contexts, array());
184
+		xml_parser_free($parser);
149 185
 
150
-        if ( ! function_exists( 'xml_parser_create_ns' ) ) {
151
-        	trigger_error( __( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." ) );
152
-        	return false;
153
-        }
186
+		restore_error_handler();
154 187
 
155
-        $parser = xml_parser_create_ns();
156
-        xml_set_object($parser, $this);
157
-        xml_set_element_handler($parser, "start_element", "end_element");
158
-        xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
159
-        xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,0);
160
-        xml_set_character_data_handler($parser, "cdata");
161
-        xml_set_default_handler($parser, "_default");
162
-        xml_set_start_namespace_decl_handler($parser, "start_ns");
163
-        xml_set_end_namespace_decl_handler($parser, "end_ns");
164
-
165
-        $this->content = '';
188
+		return $ret;
189
+	}
166 190
 
167
-        $ret = true;
168
-
169
-        $fp = fopen($this->FILE, "r");
170
-        while ($data = fread($fp, 4096)) {
171
-            if($this->debug) $this->content .= $data;
191
+	function start_element($parser, $name, $attrs) {
172 192
 
173
-            if(!xml_parse($parser, $data, feof($fp))) {
174
-                /* translators: 1: error message, 2: line number */
175
-                trigger_error(sprintf(__('XML Error: %1$s at line %2$s')."\n",
176
-                    xml_error_string(xml_get_error_code($parser)),
177
-                    xml_get_current_line_number($parser)));
178
-                $ret = false;
179
-                break;
180
-            }
181
-        }
182
-        fclose($fp);
193
+		$tag = array_pop(explode(":", $name));
183 194
 
184
-        xml_parser_free($parser);
185
-
186
-        restore_error_handler();
187
-
188
-        return $ret;
189
-    }
190
-
191
-    function start_element($parser, $name, $attrs) {
192
-
193
-        $tag = array_pop(explode(":", $name));
194
-
195
-        switch($name) {
196
-            case $this->NS . ':feed':
197
-                $this->current = $this->feed;
198
-                break;
199
-            case $this->NS . ':entry':
200
-                $this->current = new AtomEntry();
201
-                break;
202
-        };
203
-
204
-        $this->_p("start_element('$name')");
205
-        #$this->_p(print_r($this->ns_contexts,true));
206
-        #$this->_p('current(' . $this->current . ')');
207
-
208
-        array_unshift($this->ns_contexts, $this->ns_decls);
209
-
210
-        $this->depth++;
211
-
212
-        if(!empty($this->in_content)) {
213
-
214
-            $this->content_ns_decls = array();
215
-
216
-            if($this->is_html || $this->is_text)
217
-                trigger_error("Invalid content in element found. Content must not be of type text or html if it contains markup.");
218
-
219
-            $attrs_prefix = array();
220
-
221
-            // resolve prefixes for attributes
222
-            foreach($attrs as $key => $value) {
223
-                $with_prefix = $this->ns_to_prefix($key, true);
224
-                $attrs_prefix[$with_prefix[1]] = $this->xml_escape($value);
225
-            }
226
-
227
-            $attrs_str = join(' ', array_map($this->map_attrs_func, array_keys($attrs_prefix), array_values($attrs_prefix)));
228
-            if(strlen($attrs_str) > 0) {
229
-                $attrs_str = " " . $attrs_str;
230
-            }
231
-
232
-            $with_prefix = $this->ns_to_prefix($name);
233
-
234
-            if(!$this->is_declared_content_ns($with_prefix[0])) {
235
-                array_push($this->content_ns_decls, $with_prefix[0]);
236
-            }
237
-
238
-            $xmlns_str = '';
239
-            if(count($this->content_ns_decls) > 0) {
240
-                array_unshift($this->content_ns_contexts, $this->content_ns_decls);
241
-                $xmlns_str .= join(' ', array_map($this->map_xmlns_func, array_keys($this->content_ns_contexts[0]), array_values($this->content_ns_contexts[0])));
242
-                if(strlen($xmlns_str) > 0) {
243
-                    $xmlns_str = " " . $xmlns_str;
244
-                }
245
-            }
246
-
247
-            array_push($this->in_content, array($tag, $this->depth, "<". $with_prefix[1] ."{$xmlns_str}{$attrs_str}" . ">"));
248
-
249
-        } else if(in_array($tag, $this->ATOM_CONTENT_ELEMENTS) || in_array($tag, $this->ATOM_SIMPLE_ELEMENTS)) {
250
-            $this->in_content = array();
251
-            $this->is_xhtml = $attrs['type'] == 'xhtml';
252
-            $this->is_html = $attrs['type'] == 'html' || $attrs['type'] == 'text/html';
253
-            $this->is_text = !in_array('type',array_keys($attrs)) || $attrs['type'] == 'text';
254
-            $type = $this->is_xhtml ? 'XHTML' : ($this->is_html ? 'HTML' : ($this->is_text ? 'TEXT' : $attrs['type']));
255
-
256
-            if(in_array('src',array_keys($attrs))) {
257
-                $this->current->$tag = $attrs;
258
-            } else {
259
-                array_push($this->in_content, array($tag,$this->depth, $type));
260
-            }
261
-        } else if($tag == 'link') {
262
-            array_push($this->current->links, $attrs);
263
-        } else if($tag == 'category') {
264
-            array_push($this->current->categories, $attrs);
265
-        }
266
-
267
-        $this->ns_decls = array();
268
-    }
269
-
270
-    function end_element($parser, $name) {
271
-
272
-        $tag = array_pop(explode(":", $name));
273
-
274
-        $ccount = count($this->in_content);
275
-
276
-        # if we are *in* content, then let's proceed to serialize it
277
-        if(!empty($this->in_content)) {
278
-            # if we are ending the original content element
279
-            # then let's finalize the content
280
-            if($this->in_content[0][0] == $tag &&
281
-                $this->in_content[0][1] == $this->depth) {
282
-                $origtype = $this->in_content[0][2];
283
-                array_shift($this->in_content);
284
-                $newcontent = array();
285
-                foreach($this->in_content as $c) {
286
-                    if(count($c) == 3) {
287
-                        array_push($newcontent, $c[2]);
288
-                    } else {
289
-                        if($this->is_xhtml || $this->is_text) {
290
-                            array_push($newcontent, $this->xml_escape($c));
291
-                        } else {
292
-                            array_push($newcontent, $c);
293
-                        }
294
-                    }
295
-                }
296
-                if(in_array($tag, $this->ATOM_CONTENT_ELEMENTS)) {
297
-                    $this->current->$tag = array($origtype, join('',$newcontent));
298
-                } else {
299
-                    $this->current->$tag = join('',$newcontent);
300
-                }
301
-                $this->in_content = array();
302
-            } else if($this->in_content[$ccount-1][0] == $tag &&
303
-                $this->in_content[$ccount-1][1] == $this->depth) {
304
-                $this->in_content[$ccount-1][2] = substr($this->in_content[$ccount-1][2],0,-1) . "/>";
305
-            } else {
306
-                # else, just finalize the current element's content
307
-                $endtag = $this->ns_to_prefix($name);
308
-                array_push($this->in_content, array($tag, $this->depth, "</$endtag[1]>"));
309
-            }
310
-        }
311
-
312
-        array_shift($this->ns_contexts);
313
-
314
-        $this->depth--;
315
-
316
-        if($name == ($this->NS . ':entry')) {
317
-            array_push($this->feed->entries, $this->current);
318
-            $this->current = null;
319
-        }
320
-
321
-        $this->_p("end_element('$name')");
322
-    }
323
-
324
-    function start_ns($parser, $prefix, $uri) {
325
-        $this->_p("starting: " . $prefix . ":" . $uri);
326
-        array_push($this->ns_decls, array($prefix,$uri));
327
-    }
328
-
329
-    function end_ns($parser, $prefix) {
330
-        $this->_p("ending: #" . $prefix . "#");
331
-    }
332
-
333
-    function cdata($parser, $data) {
334
-        $this->_p("data: #" . str_replace(array("\n"), array("\\n"), trim($data)) . "#");
335
-        if(!empty($this->in_content)) {
336
-            array_push($this->in_content, $data);
337
-        }
338
-    }
339
-
340
-    function _default($parser, $data) {
341
-        # when does this gets called?
342
-    }
343
-
344
-
345
-    function ns_to_prefix($qname, $attr=false) {
346
-        # split 'http://www.w3.org/1999/xhtml:div' into ('http','//www.w3.org/1999/xhtml','div')
347
-        $components = explode(":", $qname);
348
-
349
-        # grab the last one (e.g 'div')
350
-        $name = array_pop($components);
351
-
352
-        if(!empty($components)) {
353
-            # re-join back the namespace component
354
-            $ns = join(":",$components);
355
-            foreach($this->ns_contexts as $context) {
356
-                foreach($context as $mapping) {
357
-                    if($mapping[1] == $ns && strlen($mapping[0]) > 0) {
358
-                        return array($mapping, "$mapping[0]:$name");
359
-                    }
360
-                }
361
-            }
362
-        }
363
-
364
-        if($attr) {
365
-            return array(null, $name);
366
-        } else {
367
-            foreach($this->ns_contexts as $context) {
368
-                foreach($context as $mapping) {
369
-                    if(strlen($mapping[0]) == 0) {
370
-                        return array($mapping, $name);
371
-                    }
372
-                }
373
-            }
374
-        }
375
-    }
376
-
377
-    function is_declared_content_ns($new_mapping) {
378
-        foreach($this->content_ns_contexts as $context) {
379
-            foreach($context as $mapping) {
380
-                if($new_mapping == $mapping) {
381
-                    return true;
382
-                }
383
-            }
384
-        }
385
-        return false;
386
-    }
387
-
388
-    function xml_escape($string)
389
-    {
390
-             return str_replace(array('&','"',"'",'<','>'),
391
-                array('&amp;','&quot;','&apos;','&lt;','&gt;'),
392
-                $string );
393
-    }
195
+		switch($name) {
196
+			case $this->NS . ':feed':
197
+				$this->current = $this->feed;
198
+				break;
199
+			case $this->NS . ':entry':
200
+				$this->current = new AtomEntry();
201
+				break;
202
+		};
203
+
204
+		$this->_p("start_element('$name')");
205
+		#$this->_p(print_r($this->ns_contexts,true));
206
+		#$this->_p('current(' . $this->current . ')');
207
+
208
+		array_unshift($this->ns_contexts, $this->ns_decls);
209
+
210
+		$this->depth++;
211
+
212
+		if(!empty($this->in_content)) {
213
+
214
+			$this->content_ns_decls = array();
215
+
216
+			if($this->is_html || $this->is_text)
217
+				trigger_error("Invalid content in element found. Content must not be of type text or html if it contains markup.");
218
+
219
+			$attrs_prefix = array();
220
+
221
+			// resolve prefixes for attributes
222
+			foreach($attrs as $key => $value) {
223
+				$with_prefix = $this->ns_to_prefix($key, true);
224
+				$attrs_prefix[$with_prefix[1]] = $this->xml_escape($value);
225
+			}
226
+
227
+			$attrs_str = join(' ', array_map($this->map_attrs_func, array_keys($attrs_prefix), array_values($attrs_prefix)));
228
+			if(strlen($attrs_str) > 0) {
229
+				$attrs_str = " " . $attrs_str;
230
+			}
231
+
232
+			$with_prefix = $this->ns_to_prefix($name);
233
+
234
+			if(!$this->is_declared_content_ns($with_prefix[0])) {
235
+				array_push($this->content_ns_decls, $with_prefix[0]);
236
+			}
237
+
238
+			$xmlns_str = '';
239
+			if(count($this->content_ns_decls) > 0) {
240
+				array_unshift($this->content_ns_contexts, $this->content_ns_decls);
241
+				$xmlns_str .= join(' ', array_map($this->map_xmlns_func, array_keys($this->content_ns_contexts[0]), array_values($this->content_ns_contexts[0])));
242
+				if(strlen($xmlns_str) > 0) {
243
+					$xmlns_str = " " . $xmlns_str;
244
+				}
245
+			}
246
+
247
+			array_push($this->in_content, array($tag, $this->depth, "<". $with_prefix[1] ."{$xmlns_str}{$attrs_str}" . ">"));
248
+
249
+		} else if(in_array($tag, $this->ATOM_CONTENT_ELEMENTS) || in_array($tag, $this->ATOM_SIMPLE_ELEMENTS)) {
250
+			$this->in_content = array();
251
+			$this->is_xhtml = $attrs['type'] == 'xhtml';
252
+			$this->is_html = $attrs['type'] == 'html' || $attrs['type'] == 'text/html';
253
+			$this->is_text = !in_array('type',array_keys($attrs)) || $attrs['type'] == 'text';
254
+			$type = $this->is_xhtml ? 'XHTML' : ($this->is_html ? 'HTML' : ($this->is_text ? 'TEXT' : $attrs['type']));
255
+
256
+			if(in_array('src',array_keys($attrs))) {
257
+				$this->current->$tag = $attrs;
258
+			} else {
259
+				array_push($this->in_content, array($tag,$this->depth, $type));
260
+			}
261
+		} else if($tag == 'link') {
262
+			array_push($this->current->links, $attrs);
263
+		} else if($tag == 'category') {
264
+			array_push($this->current->categories, $attrs);
265
+		}
266
+
267
+		$this->ns_decls = array();
268
+	}
269
+
270
+	function end_element($parser, $name) {
271
+
272
+		$tag = array_pop(explode(":", $name));
273
+
274
+		$ccount = count($this->in_content);
275
+
276
+		# if we are *in* content, then let's proceed to serialize it
277
+		if(!empty($this->in_content)) {
278
+			# if we are ending the original content element
279
+			# then let's finalize the content
280
+			if($this->in_content[0][0] == $tag &&
281
+				$this->in_content[0][1] == $this->depth) {
282
+				$origtype = $this->in_content[0][2];
283
+				array_shift($this->in_content);
284
+				$newcontent = array();
285
+				foreach($this->in_content as $c) {
286
+					if(count($c) == 3) {
287
+						array_push($newcontent, $c[2]);
288
+					} else {
289
+						if($this->is_xhtml || $this->is_text) {
290
+							array_push($newcontent, $this->xml_escape($c));
291
+						} else {
292
+							array_push($newcontent, $c);
293
+						}
294
+					}
295
+				}
296
+				if(in_array($tag, $this->ATOM_CONTENT_ELEMENTS)) {
297
+					$this->current->$tag = array($origtype, join('',$newcontent));
298
+				} else {
299
+					$this->current->$tag = join('',$newcontent);
300
+				}
301
+				$this->in_content = array();
302
+			} else if($this->in_content[$ccount-1][0] == $tag &&
303
+				$this->in_content[$ccount-1][1] == $this->depth) {
304
+				$this->in_content[$ccount-1][2] = substr($this->in_content[$ccount-1][2],0,-1) . "/>";
305
+			} else {
306
+				# else, just finalize the current element's content
307
+				$endtag = $this->ns_to_prefix($name);
308
+				array_push($this->in_content, array($tag, $this->depth, "</$endtag[1]>"));
309
+			}
310
+		}
311
+
312
+		array_shift($this->ns_contexts);
313
+
314
+		$this->depth--;
315
+
316
+		if($name == ($this->NS . ':entry')) {
317
+			array_push($this->feed->entries, $this->current);
318
+			$this->current = null;
319
+		}
320
+
321
+		$this->_p("end_element('$name')");
322
+	}
323
+
324
+	function start_ns($parser, $prefix, $uri) {
325
+		$this->_p("starting: " . $prefix . ":" . $uri);
326
+		array_push($this->ns_decls, array($prefix,$uri));
327
+	}
328
+
329
+	function end_ns($parser, $prefix) {
330
+		$this->_p("ending: #" . $prefix . "#");
331
+	}
332
+
333
+	function cdata($parser, $data) {
334
+		$this->_p("data: #" . str_replace(array("\n"), array("\\n"), trim($data)) . "#");
335
+		if(!empty($this->in_content)) {
336
+			array_push($this->in_content, $data);
337
+		}
338
+	}
339
+
340
+	function _default($parser, $data) {
341
+		# when does this gets called?
342
+	}
343
+
344
+
345
+	function ns_to_prefix($qname, $attr=false) {
346
+		# split 'http://www.w3.org/1999/xhtml:div' into ('http','//www.w3.org/1999/xhtml','div')
347
+		$components = explode(":", $qname);
348
+
349
+		# grab the last one (e.g 'div')
350
+		$name = array_pop($components);
351
+
352
+		if(!empty($components)) {
353
+			# re-join back the namespace component
354
+			$ns = join(":",$components);
355
+			foreach($this->ns_contexts as $context) {
356
+				foreach($context as $mapping) {
357
+					if($mapping[1] == $ns && strlen($mapping[0]) > 0) {
358
+						return array($mapping, "$mapping[0]:$name");
359
+					}
360
+				}
361
+			}
362
+		}
363
+
364
+		if($attr) {
365
+			return array(null, $name);
366
+		} else {
367
+			foreach($this->ns_contexts as $context) {
368
+				foreach($context as $mapping) {
369
+					if(strlen($mapping[0]) == 0) {
370
+						return array($mapping, $name);
371
+					}
372
+				}
373
+			}
374
+		}
375
+	}
376
+
377
+	function is_declared_content_ns($new_mapping) {
378
+		foreach($this->content_ns_contexts as $context) {
379
+			foreach($context as $mapping) {
380
+				if($new_mapping == $mapping) {
381
+					return true;
382
+				}
383
+			}
384
+		}
385
+		return false;
386
+	}
387
+
388
+	function xml_escape($string)
389
+	{
390
+			 return str_replace(array('&','"',"'",'<','>'),
391
+				array('&amp;','&quot;','&apos;','&lt;','&gt;'),
392
+				$string );
393
+	}
394 394
 }
Please login to merge, or discard this patch.
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
 class AtomParser {
66 66
 
67 67
     var $NS = 'http://www.w3.org/2005/Atom';
68
-    var $ATOM_CONTENT_ELEMENTS = array('content','summary','title','subtitle','rights');
69
-    var $ATOM_SIMPLE_ELEMENTS = array('id','updated','published','draft');
68
+    var $ATOM_CONTENT_ELEMENTS = array('content', 'summary', 'title', 'subtitle', 'rights');
69
+    var $ATOM_SIMPLE_ELEMENTS = array('id', 'updated', 'published', 'draft');
70 70
 
71 71
     var $debug = false;
72 72
 
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
 
95 95
         $this->feed = new AtomFeed();
96 96
         $this->current = null;
97
-        $this->map_attrs_func = array( __CLASS__, 'map_attrs' );
98
-        $this->map_xmlns_func = array( __CLASS__, 'map_xmlns' );
97
+        $this->map_attrs_func = array(__CLASS__, 'map_attrs');
98
+        $this->map_xmlns_func = array(__CLASS__, 'map_xmlns');
99 99
     }
100 100
 
101 101
 	/**
@@ -125,15 +125,15 @@  discard block
 block discarded – undo
125 125
 	 */
126 126
 	public static function map_xmlns($p, $n) {
127 127
 		$xd = "xmlns";
128
-		if( 0 < strlen($n[0]) ) {
128
+		if (0 < strlen($n[0])) {
129 129
 			$xd .= ":{$n[0]}";
130 130
 		}
131 131
 		return "{$xd}=\"{$n[1]}\"";
132 132
 	}
133 133
 
134 134
     function _p($msg) {
135
-        if($this->debug) {
136
-            print str_repeat(" ", $this->depth * $this->indent) . $msg ."\n";
135
+        if ($this->debug) {
136
+            print str_repeat(" ", $this->depth * $this->indent).$msg."\n";
137 137
         }
138 138
     }
139 139
 
@@ -147,16 +147,16 @@  discard block
 block discarded – undo
147 147
 
148 148
         array_unshift($this->ns_contexts, array());
149 149
 
150
-        if ( ! function_exists( 'xml_parser_create_ns' ) ) {
151
-        	trigger_error( __( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." ) );
150
+        if ( ! function_exists('xml_parser_create_ns')) {
151
+        	trigger_error(__("PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension."));
152 152
         	return false;
153 153
         }
154 154
 
155 155
         $parser = xml_parser_create_ns();
156 156
         xml_set_object($parser, $this);
157 157
         xml_set_element_handler($parser, "start_element", "end_element");
158
-        xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
159
-        xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,0);
158
+        xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
159
+        xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0);
160 160
         xml_set_character_data_handler($parser, "cdata");
161 161
         xml_set_default_handler($parser, "_default");
162 162
         xml_set_start_namespace_decl_handler($parser, "start_ns");
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
 
169 169
         $fp = fopen($this->FILE, "r");
170 170
         while ($data = fread($fp, 4096)) {
171
-            if($this->debug) $this->content .= $data;
171
+            if ($this->debug) $this->content .= $data;
172 172
 
173
-            if(!xml_parse($parser, $data, feof($fp))) {
173
+            if ( ! xml_parse($parser, $data, feof($fp))) {
174 174
                 /* translators: 1: error message, 2: line number */
175 175
                 trigger_error(sprintf(__('XML Error: %1$s at line %2$s')."\n",
176 176
                     xml_error_string(xml_get_error_code($parser)),
@@ -192,11 +192,11 @@  discard block
 block discarded – undo
192 192
 
193 193
         $tag = array_pop(explode(":", $name));
194 194
 
195
-        switch($name) {
196
-            case $this->NS . ':feed':
195
+        switch ($name) {
196
+            case $this->NS.':feed':
197 197
                 $this->current = $this->feed;
198 198
                 break;
199
-            case $this->NS . ':entry':
199
+            case $this->NS.':entry':
200 200
                 $this->current = new AtomEntry();
201 201
                 break;
202 202
         };
@@ -209,58 +209,58 @@  discard block
 block discarded – undo
209 209
 
210 210
         $this->depth++;
211 211
 
212
-        if(!empty($this->in_content)) {
212
+        if ( ! empty($this->in_content)) {
213 213
 
214 214
             $this->content_ns_decls = array();
215 215
 
216
-            if($this->is_html || $this->is_text)
216
+            if ($this->is_html || $this->is_text)
217 217
                 trigger_error("Invalid content in element found. Content must not be of type text or html if it contains markup.");
218 218
 
219 219
             $attrs_prefix = array();
220 220
 
221 221
             // resolve prefixes for attributes
222
-            foreach($attrs as $key => $value) {
222
+            foreach ($attrs as $key => $value) {
223 223
                 $with_prefix = $this->ns_to_prefix($key, true);
224 224
                 $attrs_prefix[$with_prefix[1]] = $this->xml_escape($value);
225 225
             }
226 226
 
227 227
             $attrs_str = join(' ', array_map($this->map_attrs_func, array_keys($attrs_prefix), array_values($attrs_prefix)));
228
-            if(strlen($attrs_str) > 0) {
229
-                $attrs_str = " " . $attrs_str;
228
+            if (strlen($attrs_str) > 0) {
229
+                $attrs_str = " ".$attrs_str;
230 230
             }
231 231
 
232 232
             $with_prefix = $this->ns_to_prefix($name);
233 233
 
234
-            if(!$this->is_declared_content_ns($with_prefix[0])) {
234
+            if ( ! $this->is_declared_content_ns($with_prefix[0])) {
235 235
                 array_push($this->content_ns_decls, $with_prefix[0]);
236 236
             }
237 237
 
238 238
             $xmlns_str = '';
239
-            if(count($this->content_ns_decls) > 0) {
239
+            if (count($this->content_ns_decls) > 0) {
240 240
                 array_unshift($this->content_ns_contexts, $this->content_ns_decls);
241 241
                 $xmlns_str .= join(' ', array_map($this->map_xmlns_func, array_keys($this->content_ns_contexts[0]), array_values($this->content_ns_contexts[0])));
242
-                if(strlen($xmlns_str) > 0) {
243
-                    $xmlns_str = " " . $xmlns_str;
242
+                if (strlen($xmlns_str) > 0) {
243
+                    $xmlns_str = " ".$xmlns_str;
244 244
                 }
245 245
             }
246 246
 
247
-            array_push($this->in_content, array($tag, $this->depth, "<". $with_prefix[1] ."{$xmlns_str}{$attrs_str}" . ">"));
247
+            array_push($this->in_content, array($tag, $this->depth, "<".$with_prefix[1]."{$xmlns_str}{$attrs_str}".">"));
248 248
 
249
-        } else if(in_array($tag, $this->ATOM_CONTENT_ELEMENTS) || in_array($tag, $this->ATOM_SIMPLE_ELEMENTS)) {
249
+        } else if (in_array($tag, $this->ATOM_CONTENT_ELEMENTS) || in_array($tag, $this->ATOM_SIMPLE_ELEMENTS)) {
250 250
             $this->in_content = array();
251 251
             $this->is_xhtml = $attrs['type'] == 'xhtml';
252 252
             $this->is_html = $attrs['type'] == 'html' || $attrs['type'] == 'text/html';
253
-            $this->is_text = !in_array('type',array_keys($attrs)) || $attrs['type'] == 'text';
253
+            $this->is_text = ! in_array('type', array_keys($attrs)) || $attrs['type'] == 'text';
254 254
             $type = $this->is_xhtml ? 'XHTML' : ($this->is_html ? 'HTML' : ($this->is_text ? 'TEXT' : $attrs['type']));
255 255
 
256
-            if(in_array('src',array_keys($attrs))) {
256
+            if (in_array('src', array_keys($attrs))) {
257 257
                 $this->current->$tag = $attrs;
258 258
             } else {
259
-                array_push($this->in_content, array($tag,$this->depth, $type));
259
+                array_push($this->in_content, array($tag, $this->depth, $type));
260 260
             }
261
-        } else if($tag == 'link') {
261
+        } else if ($tag == 'link') {
262 262
             array_push($this->current->links, $attrs);
263
-        } else if($tag == 'category') {
263
+        } else if ($tag == 'category') {
264 264
             array_push($this->current->categories, $attrs);
265 265
         }
266 266
 
@@ -274,34 +274,34 @@  discard block
 block discarded – undo
274 274
         $ccount = count($this->in_content);
275 275
 
276 276
         # if we are *in* content, then let's proceed to serialize it
277
-        if(!empty($this->in_content)) {
277
+        if ( ! empty($this->in_content)) {
278 278
             # if we are ending the original content element
279 279
             # then let's finalize the content
280
-            if($this->in_content[0][0] == $tag &&
280
+            if ($this->in_content[0][0] == $tag &&
281 281
                 $this->in_content[0][1] == $this->depth) {
282 282
                 $origtype = $this->in_content[0][2];
283 283
                 array_shift($this->in_content);
284 284
                 $newcontent = array();
285
-                foreach($this->in_content as $c) {
286
-                    if(count($c) == 3) {
285
+                foreach ($this->in_content as $c) {
286
+                    if (count($c) == 3) {
287 287
                         array_push($newcontent, $c[2]);
288 288
                     } else {
289
-                        if($this->is_xhtml || $this->is_text) {
289
+                        if ($this->is_xhtml || $this->is_text) {
290 290
                             array_push($newcontent, $this->xml_escape($c));
291 291
                         } else {
292 292
                             array_push($newcontent, $c);
293 293
                         }
294 294
                     }
295 295
                 }
296
-                if(in_array($tag, $this->ATOM_CONTENT_ELEMENTS)) {
297
-                    $this->current->$tag = array($origtype, join('',$newcontent));
296
+                if (in_array($tag, $this->ATOM_CONTENT_ELEMENTS)) {
297
+                    $this->current->$tag = array($origtype, join('', $newcontent));
298 298
                 } else {
299
-                    $this->current->$tag = join('',$newcontent);
299
+                    $this->current->$tag = join('', $newcontent);
300 300
                 }
301 301
                 $this->in_content = array();
302
-            } else if($this->in_content[$ccount-1][0] == $tag &&
303
-                $this->in_content[$ccount-1][1] == $this->depth) {
304
-                $this->in_content[$ccount-1][2] = substr($this->in_content[$ccount-1][2],0,-1) . "/>";
302
+            } else if ($this->in_content[$ccount - 1][0] == $tag &&
303
+                $this->in_content[$ccount - 1][1] == $this->depth) {
304
+                $this->in_content[$ccount - 1][2] = substr($this->in_content[$ccount - 1][2], 0, -1)."/>";
305 305
             } else {
306 306
                 # else, just finalize the current element's content
307 307
                 $endtag = $this->ns_to_prefix($name);
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 
314 314
         $this->depth--;
315 315
 
316
-        if($name == ($this->NS . ':entry')) {
316
+        if ($name == ($this->NS.':entry')) {
317 317
             array_push($this->feed->entries, $this->current);
318 318
             $this->current = null;
319 319
         }
@@ -322,17 +322,17 @@  discard block
 block discarded – undo
322 322
     }
323 323
 
324 324
     function start_ns($parser, $prefix, $uri) {
325
-        $this->_p("starting: " . $prefix . ":" . $uri);
326
-        array_push($this->ns_decls, array($prefix,$uri));
325
+        $this->_p("starting: ".$prefix.":".$uri);
326
+        array_push($this->ns_decls, array($prefix, $uri));
327 327
     }
328 328
 
329 329
     function end_ns($parser, $prefix) {
330
-        $this->_p("ending: #" . $prefix . "#");
330
+        $this->_p("ending: #".$prefix."#");
331 331
     }
332 332
 
333 333
     function cdata($parser, $data) {
334
-        $this->_p("data: #" . str_replace(array("\n"), array("\\n"), trim($data)) . "#");
335
-        if(!empty($this->in_content)) {
334
+        $this->_p("data: #".str_replace(array("\n"), array("\\n"), trim($data))."#");
335
+        if ( ! empty($this->in_content)) {
336 336
             array_push($this->in_content, $data);
337 337
         }
338 338
     }
@@ -342,31 +342,31 @@  discard block
 block discarded – undo
342 342
     }
343 343
 
344 344
 
345
-    function ns_to_prefix($qname, $attr=false) {
345
+    function ns_to_prefix($qname, $attr = false) {
346 346
         # split 'http://www.w3.org/1999/xhtml:div' into ('http','//www.w3.org/1999/xhtml','div')
347 347
         $components = explode(":", $qname);
348 348
 
349 349
         # grab the last one (e.g 'div')
350 350
         $name = array_pop($components);
351 351
 
352
-        if(!empty($components)) {
352
+        if ( ! empty($components)) {
353 353
             # re-join back the namespace component
354
-            $ns = join(":",$components);
355
-            foreach($this->ns_contexts as $context) {
356
-                foreach($context as $mapping) {
357
-                    if($mapping[1] == $ns && strlen($mapping[0]) > 0) {
354
+            $ns = join(":", $components);
355
+            foreach ($this->ns_contexts as $context) {
356
+                foreach ($context as $mapping) {
357
+                    if ($mapping[1] == $ns && strlen($mapping[0]) > 0) {
358 358
                         return array($mapping, "$mapping[0]:$name");
359 359
                     }
360 360
                 }
361 361
             }
362 362
         }
363 363
 
364
-        if($attr) {
364
+        if ($attr) {
365 365
             return array(null, $name);
366 366
         } else {
367
-            foreach($this->ns_contexts as $context) {
368
-                foreach($context as $mapping) {
369
-                    if(strlen($mapping[0]) == 0) {
367
+            foreach ($this->ns_contexts as $context) {
368
+                foreach ($context as $mapping) {
369
+                    if (strlen($mapping[0]) == 0) {
370 370
                         return array($mapping, $name);
371 371
                     }
372 372
                 }
@@ -375,9 +375,9 @@  discard block
 block discarded – undo
375 375
     }
376 376
 
377 377
     function is_declared_content_ns($new_mapping) {
378
-        foreach($this->content_ns_contexts as $context) {
379
-            foreach($context as $mapping) {
380
-                if($new_mapping == $mapping) {
378
+        foreach ($this->content_ns_contexts as $context) {
379
+            foreach ($context as $mapping) {
380
+                if ($new_mapping == $mapping) {
381 381
                     return true;
382 382
                 }
383 383
             }
@@ -387,8 +387,8 @@  discard block
 block discarded – undo
387 387
 
388 388
     function xml_escape($string)
389 389
     {
390
-             return str_replace(array('&','"',"'",'<','>'),
391
-                array('&amp;','&quot;','&apos;','&lt;','&gt;'),
392
-                $string );
390
+             return str_replace(array('&', '"', "'", '<', '>'),
391
+                array('&amp;', '&quot;', '&apos;', '&lt;', '&gt;'),
392
+                $string);
393 393
     }
394 394
 }
Please login to merge, or discard this patch.
src/wp-includes/feed-rdf.php 2 patches
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -68,10 +68,13 @@
 block discarded – undo
68 68
 	<?php the_category_rss('rdf') ?>
69 69
 <?php if (get_option('rss_use_excerpt')) : ?>
70 70
 	<description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
71
-<?php else : ?>
71
+<?php else {
72
+	: ?>
72 73
 	<description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
73 74
 	<content:encoded><![CDATA[<?php the_content_feed('rdf') ?>]]></content:encoded>
74
-<?php endif; ?>
75
+<?php endif;
76
+}
77
+?>
75 78
 	<?php
76 79
 	/**
77 80
 	 * Fires at the end of each RDF feed item.
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -5,13 +5,13 @@  discard block
 block discarded – undo
5 5
  * @package WordPress
6 6
  */
7 7
 
8
-header('Content-Type: ' . feed_content_type('rdf') . '; charset=' . get_option('blog_charset'), true);
8
+header('Content-Type: '.feed_content_type('rdf').'; charset='.get_option('blog_charset'), true);
9 9
 $more = 1;
10 10
 
11 11
 echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>';
12 12
 
13 13
 /** This action is documented in wp-includes/feed-rss2.php */
14
-do_action( 'rss_tag_pre', 'rdf' );
14
+do_action('rss_tag_pre', 'rdf');
15 15
 ?>
16 16
 <rdf:RDF
17 17
 	xmlns="http://purl.org/rss/1.0/"
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 *
27 27
 	 * @since 2.0.0
28 28
 	 */
29
-	do_action( 'rdf_ns' );
29
+	do_action('rdf_ns');
30 30
 	?>
31 31
 >
32 32
 <channel rdf:about="<?php bloginfo_rss("url") ?>">
@@ -34,16 +34,16 @@  discard block
 block discarded – undo
34 34
 	<link><?php bloginfo_rss('url') ?></link>
35 35
 	<description><?php bloginfo_rss('description') ?></description>
36 36
 	<dc:date><?php
37
-		$date = get_lastpostmodified( 'GMT' );
38
-		echo $date ? mysql2date( 'Y-m-d\TH:i:s\Z', $date ) : date( 'Y-m-d\TH:i:s\Z' );
37
+		$date = get_lastpostmodified('GMT');
38
+		echo $date ? mysql2date('Y-m-d\TH:i:s\Z', $date) : date('Y-m-d\TH:i:s\Z');
39 39
 	?></dc:date>
40 40
 	<sy:updatePeriod><?php
41 41
 		/** This filter is documented in wp-includes/feed-rss2.php */
42
-		echo apply_filters( 'rss_update_period', 'hourly' );
42
+		echo apply_filters('rss_update_period', 'hourly');
43 43
 	?></sy:updatePeriod>
44 44
 	<sy:updateFrequency><?php
45 45
 		/** This filter is documented in wp-includes/feed-rss2.php */
46
-		echo apply_filters( 'rss_update_frequency', '1' );
46
+		echo apply_filters('rss_update_frequency', '1');
47 47
 	?></sy:updateFrequency>
48 48
 	<sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
49 49
 	<?php
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @since 2.0.0
54 54
 	 */
55
-	do_action( 'rdf_header' );
55
+	do_action('rdf_header');
56 56
 	?>
57 57
 	<items>
58 58
 		<rdf:Seq>
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 	 *
82 82
 	 * @since 2.0.0
83 83
 	 */
84
-	do_action( 'rdf_item' );
84
+	do_action('rdf_item');
85 85
 	?>
86 86
 </item>
87
-<?php endwhile;  ?>
87
+<?php endwhile; ?>
88 88
 </rdf:RDF>
Please login to merge, or discard this patch.
wp-config-sample.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
  *
47 47
  * @since 2.6.0
48 48
  */
49
-define('AUTH_KEY',         'put your unique phrase here');
50
-define('SECURE_AUTH_KEY',  'put your unique phrase here');
51
-define('LOGGED_IN_KEY',    'put your unique phrase here');
52
-define('NONCE_KEY',        'put your unique phrase here');
53
-define('AUTH_SALT',        'put your unique phrase here');
49
+define('AUTH_KEY', 'put your unique phrase here');
50
+define('SECURE_AUTH_KEY', 'put your unique phrase here');
51
+define('LOGGED_IN_KEY', 'put your unique phrase here');
52
+define('NONCE_KEY', 'put your unique phrase here');
53
+define('AUTH_SALT', 'put your unique phrase here');
54 54
 define('SECURE_AUTH_SALT', 'put your unique phrase here');
55
-define('LOGGED_IN_SALT',   'put your unique phrase here');
56
-define('NONCE_SALT',       'put your unique phrase here');
55
+define('LOGGED_IN_SALT', 'put your unique phrase here');
56
+define('NONCE_SALT', 'put your unique phrase here');
57 57
 
58 58
 /**#@-*/
59 59
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
  * You can have multiple installations in one database if you give each
64 64
  * a unique prefix. Only numbers, letters, and underscores please!
65 65
  */
66
-$table_prefix  = 'wp_';
66
+$table_prefix = 'wp_';
67 67
 
68 68
 /**
69 69
  * For developers: WordPress debugging mode.
@@ -82,8 +82,8 @@  discard block
 block discarded – undo
82 82
 /* That's all, stop editing! Happy blogging. */
83 83
 
84 84
 /** Absolute path to the WordPress directory. */
85
-if ( !defined('ABSPATH') )
86
-	define('ABSPATH', dirname(__FILE__) . '/');
85
+if ( ! defined('ABSPATH'))
86
+	define('ABSPATH', dirname(__FILE__).'/');
87 87
 
88 88
 /** Sets up WordPress vars and included files. */
89
-require_once(ABSPATH . 'wp-settings.php');
89
+require_once(ABSPATH.'wp-settings.php');
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -82,8 +82,9 @@
 block discarded – undo
82 82
 /* That's all, stop editing! Happy blogging. */
83 83
 
84 84
 /** Absolute path to the WordPress directory. */
85
-if ( !defined('ABSPATH') )
86
-	define('ABSPATH', dirname(__FILE__) . '/');
85
+if ( !defined('ABSPATH') ) {
86
+	define('ABSPATH', dirname(__FILE__) . '/');
87
+}
87 88
 
88 89
 /** Sets up WordPress vars and included files. */
89 90
 require_once(ABSPATH . 'wp-settings.php');
Please login to merge, or discard this patch.
src/wp-admin/includes/bookmark.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@
 block discarded – undo
82 82
  * @global wpdb $wpdb WordPress database abstraction object.
83 83
  *
84 84
  * @param int $link_id ID of the link to delete
85
- * @return true Always true.
85
+ * @return boolean Always true.
86 86
  */
87 87
 function wp_delete_link( $link_id ) {
88 88
 	global $wpdb;
Please login to merge, or discard this patch.
Braces   +24 added lines, -18 removed lines patch added patch discarded remove patch
@@ -39,8 +39,9 @@  discard block
 block discarded – undo
39 39
 	$_POST['link_name'] = esc_html( $_POST['link_name'] );
40 40
 	$_POST['link_image'] = esc_html( $_POST['link_image'] );
41 41
 	$_POST['link_rss'] = esc_url($_POST['link_rss']);
42
-	if ( !isset($_POST['link_visible']) || 'N' != $_POST['link_visible'] )
43
-		$_POST['link_visible'] = 'Y';
42
+	if ( !isset($_POST['link_visible']) || 'N' != $_POST['link_visible'] ) {
43
+			$_POST['link_visible'] = 'Y';
44
+	}
44 45
 
45 46
 	if ( !empty( $link_id ) ) {
46 47
 		$_POST['link_id'] = $link_id;
@@ -59,15 +60,17 @@  discard block
 block discarded – undo
59 60
  */
60 61
 function get_default_link_to_edit() {
61 62
 	$link = new stdClass;
62
-	if ( isset( $_GET['linkurl'] ) )
63
-		$link->link_url = esc_url( wp_unslash( $_GET['linkurl'] ) );
64
-	else
65
-		$link->link_url = '';
63
+	if ( isset( $_GET['linkurl'] ) ) {
64
+			$link->link_url = esc_url( wp_unslash( $_GET['linkurl'] ) );
65
+	} else {
66
+			$link->link_url = '';
67
+	}
66 68
 
67
-	if ( isset( $_GET['name'] ) )
68
-		$link->link_name = esc_attr( wp_unslash( $_GET['name'] ) );
69
-	else
70
-		$link->link_name = '';
69
+	if ( isset( $_GET['name'] ) ) {
70
+			$link->link_name = esc_attr( wp_unslash( $_GET['name'] ) );
71
+	} else {
72
+			$link->link_name = '';
73
+	}
71 74
 
72 75
 	$link->link_visible = 'Y';
73 76
 
@@ -249,8 +252,9 @@  discard block
 block discarded – undo
249 252
  */
250 253
 function wp_set_link_cats( $link_id = 0, $link_categories = array() ) {
251 254
 	// If $link_categories isn't already an array, make it one:
252
-	if ( !is_array( $link_categories ) || 0 == count( $link_categories ) )
253
-		$link_categories = array( get_option( 'default_link_category' ) );
255
+	if ( !is_array( $link_categories ) || 0 == count( $link_categories ) ) {
256
+			$link_categories = array( get_option( 'default_link_category' ) );
257
+	}
254 258
 
255 259
 	$link_categories = array_map( 'intval', $link_categories );
256 260
 	$link_categories = array_unique( $link_categories );
@@ -278,10 +282,11 @@  discard block
 block discarded – undo
278 282
 
279 283
 	// Passed link category list overwrites existing category list if not empty.
280 284
 	if ( isset( $linkdata['link_category'] ) && is_array( $linkdata['link_category'] )
281
-			 && 0 != count( $linkdata['link_category'] ) )
282
-		$link_cats = $linkdata['link_category'];
283
-	else
284
-		$link_cats = $link['link_category'];
285
+			 && 0 != count( $linkdata['link_category'] ) ) {
286
+			$link_cats = $linkdata['link_category'];
287
+	} else {
288
+			$link_cats = $link['link_category'];
289
+	}
285 290
 
286 291
 	// Merge old and new fields with new fields overwriting old ones.
287 292
 	$linkdata = array_merge( $link, $linkdata );
@@ -300,8 +305,9 @@  discard block
 block discarded – undo
300 305
  */
301 306
 function wp_link_manager_disabled_message() {
302 307
 	global $pagenow;
303
-	if ( 'link-manager.php' != $pagenow && 'link-add.php' != $pagenow && 'link.php' != $pagenow )
304
-		return;
308
+	if ( 'link-manager.php' != $pagenow && 'link-add.php' != $pagenow && 'link.php' != $pagenow ) {
309
+			return;
310
+	}
305 311
 
306 312
 	add_filter( 'pre_option_link_manager_enabled', '__return_true', 100 );
307 313
 	$really_can_manage_links = current_user_can( 'manage_links' );
Please login to merge, or discard this patch.
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -25,28 +25,28 @@  discard block
 block discarded – undo
25 25
  * @param int $link_id Optional. ID of the link to edit. Default 0.
26 26
  * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success.
27 27
  */
28
-function edit_link( $link_id = 0 ) {
29
-	if ( ! current_user_can( 'manage_links' ) ) {
28
+function edit_link($link_id = 0) {
29
+	if ( ! current_user_can('manage_links')) {
30 30
 		wp_die(
31
-			'<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
32
-			'<p>' . __( 'Sorry, you are not allowed to edit the links for this site.' ) . '</p>',
31
+			'<h1>'.__('Cheatin&#8217; uh?').'</h1>'.
32
+			'<p>'.__('Sorry, you are not allowed to edit the links for this site.').'</p>',
33 33
 			403
34 34
 		);
35 35
 	}
36 36
 
37
-	$_POST['link_url'] = esc_html( $_POST['link_url'] );
37
+	$_POST['link_url'] = esc_html($_POST['link_url']);
38 38
 	$_POST['link_url'] = esc_url($_POST['link_url']);
39
-	$_POST['link_name'] = esc_html( $_POST['link_name'] );
40
-	$_POST['link_image'] = esc_html( $_POST['link_image'] );
39
+	$_POST['link_name'] = esc_html($_POST['link_name']);
40
+	$_POST['link_image'] = esc_html($_POST['link_image']);
41 41
 	$_POST['link_rss'] = esc_url($_POST['link_rss']);
42
-	if ( !isset($_POST['link_visible']) || 'N' != $_POST['link_visible'] )
42
+	if ( ! isset($_POST['link_visible']) || 'N' != $_POST['link_visible'])
43 43
 		$_POST['link_visible'] = 'Y';
44 44
 
45
-	if ( !empty( $link_id ) ) {
45
+	if ( ! empty($link_id)) {
46 46
 		$_POST['link_id'] = $link_id;
47
-		return wp_update_link( $_POST );
47
+		return wp_update_link($_POST);
48 48
 	} else {
49
-		return wp_insert_link( $_POST );
49
+		return wp_insert_link($_POST);
50 50
 	}
51 51
 }
52 52
 
@@ -59,13 +59,13 @@  discard block
 block discarded – undo
59 59
  */
60 60
 function get_default_link_to_edit() {
61 61
 	$link = new stdClass;
62
-	if ( isset( $_GET['linkurl'] ) )
63
-		$link->link_url = esc_url( wp_unslash( $_GET['linkurl'] ) );
62
+	if (isset($_GET['linkurl']))
63
+		$link->link_url = esc_url(wp_unslash($_GET['linkurl']));
64 64
 	else
65 65
 		$link->link_url = '';
66 66
 
67
-	if ( isset( $_GET['name'] ) )
68
-		$link->link_name = esc_attr( wp_unslash( $_GET['name'] ) );
67
+	if (isset($_GET['name']))
68
+		$link->link_name = esc_attr(wp_unslash($_GET['name']));
69 69
 	else
70 70
 		$link->link_name = '';
71 71
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
  * @param int $link_id ID of the link to delete
85 85
  * @return true Always true.
86 86
  */
87
-function wp_delete_link( $link_id ) {
87
+function wp_delete_link($link_id) {
88 88
 	global $wpdb;
89 89
 	/**
90 90
 	 * Fires before a link is deleted.
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
 	 *
94 94
 	 * @param int $link_id ID of the link to delete.
95 95
 	 */
96
-	do_action( 'delete_link', $link_id );
96
+	do_action('delete_link', $link_id);
97 97
 
98
-	wp_delete_object_term_relationships( $link_id, 'link_category' );
98
+	wp_delete_object_term_relationships($link_id, 'link_category');
99 99
 
100
-	$wpdb->delete( $wpdb->links, array( 'link_id' => $link_id ) );
100
+	$wpdb->delete($wpdb->links, array('link_id' => $link_id));
101 101
 
102 102
 	/**
103 103
 	 * Fires after a link has been deleted.
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
 	 *
107 107
 	 * @param int $link_id ID of the deleted link.
108 108
 	 */
109
-	do_action( 'deleted_link', $link_id );
109
+	do_action('deleted_link', $link_id);
110 110
 
111
-	clean_bookmark_cache( $link_id );
111
+	clean_bookmark_cache($link_id);
112 112
 
113 113
 	return true;
114 114
 }
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
  * @param int $link_id Link ID to look up
122 122
  * @return array The requested link's categories
123 123
  */
124
-function wp_get_link_cats( $link_id = 0 ) {
125
-	$cats = wp_get_object_terms( $link_id, 'link_category', array('fields' => 'ids') );
126
-	return array_unique( $cats );
124
+function wp_get_link_cats($link_id = 0) {
125
+	$cats = wp_get_object_terms($link_id, 'link_category', array('fields' => 'ids'));
126
+	return array_unique($cats);
127 127
 }
128 128
 
129 129
 /**
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
  * @param int|stdClass $link Link ID or object to retrieve.
135 135
  * @return object Link object for editing.
136 136
  */
137
-function get_link_to_edit( $link ) {
138
-	return get_bookmark( $link, OBJECT, 'edit' );
137
+function get_link_to_edit($link) {
138
+	return get_bookmark($link, OBJECT, 'edit');
139 139
 }
140 140
 
141 141
 /**
@@ -149,63 +149,63 @@  discard block
 block discarded – undo
149 149
  * @param bool  $wp_error Optional. Whether to return a WP_Error object on failure. Default false.
150 150
  * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success.
151 151
  */
152
-function wp_insert_link( $linkdata, $wp_error = false ) {
152
+function wp_insert_link($linkdata, $wp_error = false) {
153 153
 	global $wpdb;
154 154
 
155
-	$defaults = array( 'link_id' => 0, 'link_name' => '', 'link_url' => '', 'link_rating' => 0 );
155
+	$defaults = array('link_id' => 0, 'link_name' => '', 'link_url' => '', 'link_rating' => 0);
156 156
 
157
-	$args = wp_parse_args( $linkdata, $defaults );
158
-	$r = wp_unslash( sanitize_bookmark( $args, 'db' ) );
157
+	$args = wp_parse_args($linkdata, $defaults);
158
+	$r = wp_unslash(sanitize_bookmark($args, 'db'));
159 159
 
160 160
 	$link_id   = $r['link_id'];
161 161
 	$link_name = $r['link_name'];
162 162
 	$link_url  = $r['link_url'];
163 163
 
164 164
 	$update = false;
165
-	if ( ! empty( $link_id ) ) {
165
+	if ( ! empty($link_id)) {
166 166
 		$update = true;
167 167
 	}
168 168
 
169
-	if ( trim( $link_name ) == '' ) {
170
-		if ( trim( $link_url ) != '' ) {
169
+	if (trim($link_name) == '') {
170
+		if (trim($link_url) != '') {
171 171
 			$link_name = $link_url;
172 172
 		} else {
173 173
 			return 0;
174 174
 		}
175 175
 	}
176 176
 
177
-	if ( trim( $link_url ) == '' ) {
177
+	if (trim($link_url) == '') {
178 178
 		return 0;
179 179
 	}
180 180
 
181
-	$link_rating      = ( ! empty( $r['link_rating'] ) ) ? $r['link_rating'] : 0;
182
-	$link_image       = ( ! empty( $r['link_image'] ) ) ? $r['link_image'] : '';
183
-	$link_target      = ( ! empty( $r['link_target'] ) ) ? $r['link_target'] : '';
184
-	$link_visible     = ( ! empty( $r['link_visible'] ) ) ? $r['link_visible'] : 'Y';
185
-	$link_owner       = ( ! empty( $r['link_owner'] ) ) ? $r['link_owner'] : get_current_user_id();
186
-	$link_notes       = ( ! empty( $r['link_notes'] ) ) ? $r['link_notes'] : '';
187
-	$link_description = ( ! empty( $r['link_description'] ) ) ? $r['link_description'] : '';
188
-	$link_rss         = ( ! empty( $r['link_rss'] ) ) ? $r['link_rss'] : '';
189
-	$link_rel         = ( ! empty( $r['link_rel'] ) ) ? $r['link_rel'] : '';
190
-	$link_category    = ( ! empty( $r['link_category'] ) ) ? $r['link_category'] : array();
181
+	$link_rating      = ( ! empty($r['link_rating'])) ? $r['link_rating'] : 0;
182
+	$link_image       = ( ! empty($r['link_image'])) ? $r['link_image'] : '';
183
+	$link_target      = ( ! empty($r['link_target'])) ? $r['link_target'] : '';
184
+	$link_visible     = ( ! empty($r['link_visible'])) ? $r['link_visible'] : 'Y';
185
+	$link_owner       = ( ! empty($r['link_owner'])) ? $r['link_owner'] : get_current_user_id();
186
+	$link_notes       = ( ! empty($r['link_notes'])) ? $r['link_notes'] : '';
187
+	$link_description = ( ! empty($r['link_description'])) ? $r['link_description'] : '';
188
+	$link_rss         = ( ! empty($r['link_rss'])) ? $r['link_rss'] : '';
189
+	$link_rel         = ( ! empty($r['link_rel'])) ? $r['link_rel'] : '';
190
+	$link_category    = ( ! empty($r['link_category'])) ? $r['link_category'] : array();
191 191
 
192 192
 	// Make sure we set a valid category.
193
-	if ( ! is_array( $link_category ) || 0 == count( $link_category ) ) {
194
-		$link_category = array( get_option( 'default_link_category' ) );
193
+	if ( ! is_array($link_category) || 0 == count($link_category)) {
194
+		$link_category = array(get_option('default_link_category'));
195 195
 	}
196 196
 
197
-	if ( $update ) {
198
-		if ( false === $wpdb->update( $wpdb->links, compact( 'link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_rating', 'link_rel', 'link_notes', 'link_rss' ), compact( 'link_id' ) ) ) {
199
-			if ( $wp_error ) {
200
-				return new WP_Error( 'db_update_error', __( 'Could not update link in the database' ), $wpdb->last_error );
197
+	if ($update) {
198
+		if (false === $wpdb->update($wpdb->links, compact('link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_rating', 'link_rel', 'link_notes', 'link_rss'), compact('link_id'))) {
199
+			if ($wp_error) {
200
+				return new WP_Error('db_update_error', __('Could not update link in the database'), $wpdb->last_error);
201 201
 			} else {
202 202
 				return 0;
203 203
 			}
204 204
 		}
205 205
 	} else {
206
-		if ( false === $wpdb->insert( $wpdb->links, compact( 'link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_rel', 'link_notes', 'link_rss' ) ) ) {
207
-			if ( $wp_error ) {
208
-				return new WP_Error( 'db_insert_error', __( 'Could not insert link into the database' ), $wpdb->last_error );
206
+		if (false === $wpdb->insert($wpdb->links, compact('link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_rel', 'link_notes', 'link_rss'))) {
207
+			if ($wp_error) {
208
+				return new WP_Error('db_insert_error', __('Could not insert link into the database'), $wpdb->last_error);
209 209
 			} else {
210 210
 				return 0;
211 211
 			}
@@ -213,9 +213,9 @@  discard block
 block discarded – undo
213 213
 		$link_id = (int) $wpdb->insert_id;
214 214
 	}
215 215
 
216
-	wp_set_link_cats( $link_id, $link_category );
216
+	wp_set_link_cats($link_id, $link_category);
217 217
 
218
-	if ( $update ) {
218
+	if ($update) {
219 219
 		/**
220 220
 		 * Fires after a link was updated in the database.
221 221
 		 *
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 		 *
224 224
 		 * @param int $link_id ID of the link that was updated.
225 225
 		 */
226
-		do_action( 'edit_link', $link_id );
226
+		do_action('edit_link', $link_id);
227 227
 	} else {
228 228
 		/**
229 229
 		 * Fires after a link was added to the database.
@@ -232,9 +232,9 @@  discard block
 block discarded – undo
232 232
 		 *
233 233
 		 * @param int $link_id ID of the link that was added.
234 234
 		 */
235
-		do_action( 'add_link', $link_id );
235
+		do_action('add_link', $link_id);
236 236
 	}
237
-	clean_bookmark_cache( $link_id );
237
+	clean_bookmark_cache($link_id);
238 238
 
239 239
 	return $link_id;
240 240
 }
@@ -247,17 +247,17 @@  discard block
 block discarded – undo
247 247
  * @param int   $link_id         ID of the link to update.
248 248
  * @param array $link_categories Array of link categories to add the link to.
249 249
  */
250
-function wp_set_link_cats( $link_id = 0, $link_categories = array() ) {
250
+function wp_set_link_cats($link_id = 0, $link_categories = array()) {
251 251
 	// If $link_categories isn't already an array, make it one:
252
-	if ( !is_array( $link_categories ) || 0 == count( $link_categories ) )
253
-		$link_categories = array( get_option( 'default_link_category' ) );
252
+	if ( ! is_array($link_categories) || 0 == count($link_categories))
253
+		$link_categories = array(get_option('default_link_category'));
254 254
 
255
-	$link_categories = array_map( 'intval', $link_categories );
256
-	$link_categories = array_unique( $link_categories );
255
+	$link_categories = array_map('intval', $link_categories);
256
+	$link_categories = array_unique($link_categories);
257 257
 
258
-	wp_set_object_terms( $link_id, $link_categories, 'link_category' );
258
+	wp_set_object_terms($link_id, $link_categories, 'link_category');
259 259
 
260
-	clean_bookmark_cache( $link_id );
260
+	clean_bookmark_cache($link_id);
261 261
 }
262 262
 
263 263
 /**
@@ -268,26 +268,26 @@  discard block
 block discarded – undo
268 268
  * @param array $linkdata Link data to update.
269 269
  * @return int|WP_Error Value 0 or WP_Error on failure. The updated link ID on success.
270 270
  */
271
-function wp_update_link( $linkdata ) {
271
+function wp_update_link($linkdata) {
272 272
 	$link_id = (int) $linkdata['link_id'];
273 273
 
274
-	$link = get_bookmark( $link_id, ARRAY_A );
274
+	$link = get_bookmark($link_id, ARRAY_A);
275 275
 
276 276
 	// Escape data pulled from DB.
277
-	$link = wp_slash( $link );
277
+	$link = wp_slash($link);
278 278
 
279 279
 	// Passed link category list overwrites existing category list if not empty.
280
-	if ( isset( $linkdata['link_category'] ) && is_array( $linkdata['link_category'] )
281
-			 && 0 != count( $linkdata['link_category'] ) )
280
+	if (isset($linkdata['link_category']) && is_array($linkdata['link_category'])
281
+			 && 0 != count($linkdata['link_category']))
282 282
 		$link_cats = $linkdata['link_category'];
283 283
 	else
284 284
 		$link_cats = $link['link_category'];
285 285
 
286 286
 	// Merge old and new fields with new fields overwriting old ones.
287
-	$linkdata = array_merge( $link, $linkdata );
287
+	$linkdata = array_merge($link, $linkdata);
288 288
 	$linkdata['link_category'] = $link_cats;
289 289
 
290
-	return wp_insert_link( $linkdata );
290
+	return wp_insert_link($linkdata);
291 291
 }
292 292
 
293 293
 /**
@@ -300,17 +300,17 @@  discard block
 block discarded – undo
300 300
  */
301 301
 function wp_link_manager_disabled_message() {
302 302
 	global $pagenow;
303
-	if ( 'link-manager.php' != $pagenow && 'link-add.php' != $pagenow && 'link.php' != $pagenow )
303
+	if ('link-manager.php' != $pagenow && 'link-add.php' != $pagenow && 'link.php' != $pagenow)
304 304
 		return;
305 305
 
306
-	add_filter( 'pre_option_link_manager_enabled', '__return_true', 100 );
307
-	$really_can_manage_links = current_user_can( 'manage_links' );
308
-	remove_filter( 'pre_option_link_manager_enabled', '__return_true', 100 );
306
+	add_filter('pre_option_link_manager_enabled', '__return_true', 100);
307
+	$really_can_manage_links = current_user_can('manage_links');
308
+	remove_filter('pre_option_link_manager_enabled', '__return_true', 100);
309 309
 
310
-	if ( $really_can_manage_links && current_user_can( 'install_plugins' ) ) {
311
-		$link = network_admin_url( 'plugin-install.php?tab=search&amp;s=Link+Manager' );
312
-		wp_die( sprintf( __( 'If you are looking to use the link manager, please install the <a href="%s">Link Manager</a> plugin.' ), $link ) );
310
+	if ($really_can_manage_links && current_user_can('install_plugins')) {
311
+		$link = network_admin_url('plugin-install.php?tab=search&amp;s=Link+Manager');
312
+		wp_die(sprintf(__('If you are looking to use the link manager, please install the <a href="%s">Link Manager</a> plugin.'), $link));
313 313
 	}
314 314
 
315
-	wp_die( __( 'Sorry, you are not allowed to edit the links for this site.' ) );
315
+	wp_die(__('Sorry, you are not allowed to edit the links for this site.'));
316 316
 }
Please login to merge, or discard this patch.
src/wp-admin/includes/class-wp-posts-list-table.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 
485 485
 	/**
486 486
 	 *
487
-	 * @return array
487
+	 * @return string[]
488 488
 	 */
489 489
 	protected function get_table_classes() {
490 490
 		return array( 'widefat', 'fixed', 'striped', is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' );
@@ -1162,7 +1162,7 @@  discard block
 block discarded – undo
1162 1162
 	 * @since 4.3.0
1163 1163
 	 * @access protected
1164 1164
 	 *
1165
-	 * @param object $post        Post being acted upon.
1165
+	 * @param WP_Post $post        Post being acted upon.
1166 1166
 	 * @param string $column_name Current column name.
1167 1167
 	 * @param string $primary     Primary column name.
1168 1168
 	 * @return string Row actions output for posts.
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1175,10 +1175,10 @@  discard block
 block discarded – undo
1175 1175
 		}
1176 1176
 
1177 1177
 		if ( $post->post_parent ) {
1178
-		    $count = count( get_post_ancestors( $post->ID ) );
1179
-		    $classes .= ' level-'. $count;
1178
+			$count = count( get_post_ancestors( $post->ID ) );
1179
+			$classes .= ' level-'. $count;
1180 1180
 		} else {
1181
-		    $classes .= ' level-0';
1181
+			$classes .= ' level-0';
1182 1182
 		}
1183 1183
 	?>
1184 1184
 		<tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>">
@@ -1553,7 +1553,7 @@  discard block
 block discarded – undo
1553 1553
                 <?php
1554 1554
 				/** This filter is documented in wp-admin/includes/meta-boxes.php */
1555 1555
 				$default_title = apply_filters( 'default_page_template_title',  __( 'Default Template' ), 'quick-edit' );
1556
-                ?>
1556
+				?>
1557 1557
 				<option value="default"><?php echo esc_html( $default_title ); ?></option>
1558 1558
 				<?php page_template_dropdown( '', $screen->post_type ) ?>
1559 1559
 			</select>
Please login to merge, or discard this patch.
Spacing   +429 added lines, -429 removed lines patch added patch discarded remove patch
@@ -77,35 +77,35 @@  discard block
 block discarded – undo
77 77
 	 *
78 78
 	 * @param array $args An associative array of arguments.
79 79
 	 */
80
-	public function __construct( $args = array() ) {
80
+	public function __construct($args = array()) {
81 81
 		global $post_type_object, $wpdb;
82 82
 
83
-		parent::__construct( array(
83
+		parent::__construct(array(
84 84
 			'plural' => 'posts',
85
-			'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
86
-		) );
85
+			'screen' => isset($args['screen']) ? $args['screen'] : null,
86
+		));
87 87
 
88 88
 		$post_type        = $this->screen->post_type;
89
-		$post_type_object = get_post_type_object( $post_type );
89
+		$post_type_object = get_post_type_object($post_type);
90 90
 
91
-		$exclude_states   = get_post_stati( array(
91
+		$exclude_states   = get_post_stati(array(
92 92
 			'show_in_admin_all_list' => false,
93
-		) );
94
-		$this->user_posts_count = intval( $wpdb->get_var( $wpdb->prepare( "
93
+		));
94
+		$this->user_posts_count = intval($wpdb->get_var($wpdb->prepare("
95 95
 			SELECT COUNT( 1 )
96 96
 			FROM $wpdb->posts
97 97
 			WHERE post_type = %s
98
-			AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' )
98
+			AND post_status NOT IN ( '".implode("','", $exclude_states)."' )
99 99
 			AND post_author = %d
100
-		", $post_type, get_current_user_id() ) ) );
100
+		", $post_type, get_current_user_id())));
101 101
 
102
-		if ( $this->user_posts_count && ! current_user_can( $post_type_object->cap->edit_others_posts ) && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) ) {
102
+		if ($this->user_posts_count && ! current_user_can($post_type_object->cap->edit_others_posts) && empty($_REQUEST['post_status']) && empty($_REQUEST['all_posts']) && empty($_REQUEST['author']) && empty($_REQUEST['show_sticky'])) {
103 103
 			$_GET['author'] = get_current_user_id();
104 104
 		}
105 105
 
106
-		if ( 'post' === $post_type && $sticky_posts = get_option( 'sticky_posts' ) ) {
107
-			$sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) );
108
-			$this->sticky_posts_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( 1 ) FROM $wpdb->posts WHERE post_type = %s AND post_status NOT IN ('trash', 'auto-draft') AND ID IN ($sticky_posts)", $post_type ) );
106
+		if ('post' === $post_type && $sticky_posts = get_option('sticky_posts')) {
107
+			$sticky_posts = implode(', ', array_map('absint', (array) $sticky_posts));
108
+			$this->sticky_posts_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT( 1 ) FROM $wpdb->posts WHERE post_type = %s AND post_status NOT IN ('trash', 'auto-draft') AND ID IN ($sticky_posts)", $post_type));
109 109
 		}
110 110
 	}
111 111
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 *
117 117
 	 * @param bool $display Whether the table layout should be hierarchical.
118 118
 	 */
119
-	public function set_hierarchical_display( $display ) {
119
+	public function set_hierarchical_display($display) {
120 120
 		$this->hierarchical_display = $display;
121 121
 	}
122 122
 
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	 * @return bool
126 126
 	 */
127 127
 	public function ajax_user_can() {
128
-		return current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_posts );
128
+		return current_user_can(get_post_type_object($this->screen->post_type)->cap->edit_posts);
129 129
 	}
130 130
 
131 131
 	/**
@@ -141,50 +141,50 @@  discard block
 block discarded – undo
141 141
 		// is going to call wp()
142 142
 		$avail_post_stati = wp_edit_posts_query();
143 143
 
144
-		$this->set_hierarchical_display( is_post_type_hierarchical( $this->screen->post_type ) && 'menu_order title' === $wp_query->query['orderby'] );
144
+		$this->set_hierarchical_display(is_post_type_hierarchical($this->screen->post_type) && 'menu_order title' === $wp_query->query['orderby']);
145 145
 
146 146
 		$post_type = $this->screen->post_type;
147
-		$per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' );
147
+		$per_page = $this->get_items_per_page('edit_'.$post_type.'_per_page');
148 148
 
149 149
 		/** This filter is documented in wp-admin/includes/post.php */
150
- 		$per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type );
150
+ 		$per_page = apply_filters('edit_posts_per_page', $per_page, $post_type);
151 151
 
152
-		if ( $this->hierarchical_display ) {
152
+		if ($this->hierarchical_display) {
153 153
 			$total_items = $wp_query->post_count;
154
-		} elseif ( $wp_query->found_posts || $this->get_pagenum() === 1 ) {
154
+		} elseif ($wp_query->found_posts || $this->get_pagenum() === 1) {
155 155
 			$total_items = $wp_query->found_posts;
156 156
 		} else {
157
-			$post_counts = (array) wp_count_posts( $post_type, 'readable' );
157
+			$post_counts = (array) wp_count_posts($post_type, 'readable');
158 158
 
159
-			if ( isset( $_REQUEST['post_status'] ) && in_array( $_REQUEST['post_status'] , $avail_post_stati ) ) {
160
-				$total_items = $post_counts[ $_REQUEST['post_status'] ];
161
-			} elseif ( isset( $_REQUEST['show_sticky'] ) && $_REQUEST['show_sticky'] ) {
159
+			if (isset($_REQUEST['post_status']) && in_array($_REQUEST['post_status'], $avail_post_stati)) {
160
+				$total_items = $post_counts[$_REQUEST['post_status']];
161
+			} elseif (isset($_REQUEST['show_sticky']) && $_REQUEST['show_sticky']) {
162 162
 				$total_items = $this->sticky_posts_count;
163
-			} elseif ( isset( $_GET['author'] ) && $_GET['author'] == get_current_user_id() ) {
163
+			} elseif (isset($_GET['author']) && $_GET['author'] == get_current_user_id()) {
164 164
 				$total_items = $this->user_posts_count;
165 165
 			} else {
166
-				$total_items = array_sum( $post_counts );
166
+				$total_items = array_sum($post_counts);
167 167
 
168 168
 				// Subtract post types that are not included in the admin all list.
169
-				foreach ( get_post_stati( array( 'show_in_admin_all_list' => false ) ) as $state ) {
170
-					$total_items -= $post_counts[ $state ];
169
+				foreach (get_post_stati(array('show_in_admin_all_list' => false)) as $state) {
170
+					$total_items -= $post_counts[$state];
171 171
 				}
172 172
 			}
173 173
 		}
174 174
 
175
-		if ( ! empty( $_REQUEST['mode'] ) ) {
175
+		if ( ! empty($_REQUEST['mode'])) {
176 176
 			$mode = $_REQUEST['mode'] === 'excerpt' ? 'excerpt' : 'list';
177
-			set_user_setting( 'posts_list_mode', $mode );
177
+			set_user_setting('posts_list_mode', $mode);
178 178
 		} else {
179
-			$mode = get_user_setting( 'posts_list_mode', 'list' );
179
+			$mode = get_user_setting('posts_list_mode', 'list');
180 180
 		}
181 181
 
182
-		$this->is_trash = isset( $_REQUEST['post_status'] ) && $_REQUEST['post_status'] === 'trash';
182
+		$this->is_trash = isset($_REQUEST['post_status']) && $_REQUEST['post_status'] === 'trash';
183 183
 
184
-		$this->set_pagination_args( array(
184
+		$this->set_pagination_args(array(
185 185
 			'total_items' => $total_items,
186 186
 			'per_page' => $per_page
187
-		) );
187
+		));
188 188
 	}
189 189
 
190 190
 	/**
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
 	 * @access public
200 200
 	 */
201 201
 	public function no_items() {
202
-		if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] )
203
-			echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash;
202
+		if (isset($_REQUEST['post_status']) && 'trash' === $_REQUEST['post_status'])
203
+			echo get_post_type_object($this->screen->post_type)->labels->not_found_in_trash;
204 204
 		else
205
-			echo get_post_type_object( $this->screen->post_type )->labels->not_found;
205
+			echo get_post_type_object($this->screen->post_type)->labels->not_found;
206 206
 	}
207 207
 
208 208
 	/**
@@ -214,15 +214,15 @@  discard block
 block discarded – undo
214 214
 	 */
215 215
 	protected function is_base_request() {
216 216
 		$vars = $_GET;
217
-		unset( $vars['paged'] );
217
+		unset($vars['paged']);
218 218
 
219
-		if ( empty( $vars ) ) {
219
+		if (empty($vars)) {
220 220
 			return true;
221
-		} elseif ( 1 === count( $vars ) && ! empty( $vars['post_type'] ) ) {
221
+		} elseif (1 === count($vars) && ! empty($vars['post_type'])) {
222 222
 			return $this->screen->post_type === $vars['post_type'];
223 223
 		}
224 224
 
225
-		return 1 === count( $vars ) && ! empty( $vars['mode'] );
225
+		return 1 === count($vars) && ! empty($vars['mode']);
226 226
 	}
227 227
 
228 228
 	/**
@@ -236,20 +236,20 @@  discard block
 block discarded – undo
236 236
 	 * @param string $class Optional. Class attribute. Default empty string.
237 237
 	 * @return string The formatted link string.
238 238
 	 */
239
-	protected function get_edit_link( $args, $label, $class = '' ) {
240
-		$url = add_query_arg( $args, 'edit.php' );
239
+	protected function get_edit_link($args, $label, $class = '') {
240
+		$url = add_query_arg($args, 'edit.php');
241 241
 
242 242
 		$class_html = '';
243
-		if ( ! empty( $class ) ) {
243
+		if ( ! empty($class)) {
244 244
 			 $class_html = sprintf(
245 245
 				' class="%s"',
246
-				esc_attr( $class )
246
+				esc_attr($class)
247 247
 			);
248 248
 		}
249 249
 
250 250
 		return sprintf(
251 251
 			'<a href="%s"%s>%s</a>',
252
-			esc_url( $url ),
252
+			esc_url($url),
253 253
 			$class_html,
254 254
 			$label
255 255
 		);
@@ -266,25 +266,25 @@  discard block
 block discarded – undo
266 266
 
267 267
 		$post_type = $this->screen->post_type;
268 268
 
269
-		if ( !empty($locked_post_status) )
269
+		if ( ! empty($locked_post_status))
270 270
 			return array();
271 271
 
272 272
 		$status_links = array();
273
-		$num_posts = wp_count_posts( $post_type, 'readable' );
274
-		$total_posts = array_sum( (array) $num_posts );
273
+		$num_posts = wp_count_posts($post_type, 'readable');
274
+		$total_posts = array_sum((array) $num_posts);
275 275
 		$class = '';
276 276
 
277 277
 		$current_user_id = get_current_user_id();
278
-		$all_args = array( 'post_type' => $post_type );
278
+		$all_args = array('post_type' => $post_type);
279 279
 		$mine = '';
280 280
 
281 281
 		// Subtract post types that are not included in the admin all list.
282
-		foreach ( get_post_stati( array( 'show_in_admin_all_list' => false ) ) as $state ) {
282
+		foreach (get_post_stati(array('show_in_admin_all_list' => false)) as $state) {
283 283
 			$total_posts -= $num_posts->$state;
284 284
 		}
285 285
 
286
-		if ( $this->user_posts_count && $this->user_posts_count !== $total_posts ) {
287
-			if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user_id ) ) {
286
+		if ($this->user_posts_count && $this->user_posts_count !== $total_posts) {
287
+			if (isset($_GET['author']) && ($_GET['author'] == $current_user_id)) {
288 288
 				$class = 'current';
289 289
 			}
290 290
 
@@ -300,16 +300,16 @@  discard block
 block discarded – undo
300 300
 					$this->user_posts_count,
301 301
 					'posts'
302 302
 				),
303
-				number_format_i18n( $this->user_posts_count )
303
+				number_format_i18n($this->user_posts_count)
304 304
 			);
305 305
 
306
-			$mine = $this->get_edit_link( $mine_args, $mine_inner_html, $class );
306
+			$mine = $this->get_edit_link($mine_args, $mine_inner_html, $class);
307 307
 
308 308
 			$all_args['all_posts'] = 1;
309 309
 			$class = '';
310 310
 		}
311 311
 
312
-		if ( empty( $class ) && ( $this->is_base_request() || isset( $_REQUEST['all_posts'] ) ) ) {
312
+		if (empty($class) && ($this->is_base_request() || isset($_REQUEST['all_posts']))) {
313 313
 			$class = 'current';
314 314
 		}
315 315
 
@@ -320,24 +320,24 @@  discard block
 block discarded – undo
320 320
 				$total_posts,
321 321
 				'posts'
322 322
 			),
323
-			number_format_i18n( $total_posts )
323
+			number_format_i18n($total_posts)
324 324
 		);
325 325
 
326
-		$status_links['all'] = $this->get_edit_link( $all_args, $all_inner_html, $class );
327
-		if ( $mine ) {
326
+		$status_links['all'] = $this->get_edit_link($all_args, $all_inner_html, $class);
327
+		if ($mine) {
328 328
 			$status_links['mine'] = $mine;
329 329
 		}
330 330
 
331
-		foreach ( get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status ) {
331
+		foreach (get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status) {
332 332
 			$class = '';
333 333
 
334 334
 			$status_name = $status->name;
335 335
 
336
-			if ( ! in_array( $status_name, $avail_post_stati ) || empty( $num_posts->$status_name ) ) {
336
+			if ( ! in_array($status_name, $avail_post_stati) || empty($num_posts->$status_name)) {
337 337
 				continue;
338 338
 			}
339 339
 
340
-			if ( isset($_REQUEST['post_status']) && $status_name === $_REQUEST['post_status'] ) {
340
+			if (isset($_REQUEST['post_status']) && $status_name === $_REQUEST['post_status']) {
341 341
 				$class = 'current';
342 342
 			}
343 343
 
@@ -347,15 +347,15 @@  discard block
 block discarded – undo
347 347
 			);
348 348
 
349 349
 			$status_label = sprintf(
350
-				translate_nooped_plural( $status->label_count, $num_posts->$status_name ),
351
-				number_format_i18n( $num_posts->$status_name )
350
+				translate_nooped_plural($status->label_count, $num_posts->$status_name),
351
+				number_format_i18n($num_posts->$status_name)
352 352
 			);
353 353
 
354
-			$status_links[ $status_name ] = $this->get_edit_link( $status_args, $status_label, $class );
354
+			$status_links[$status_name] = $this->get_edit_link($status_args, $status_label, $class);
355 355
 		}
356 356
 
357
-		if ( ! empty( $this->sticky_posts_count ) ) {
358
-			$class = ! empty( $_REQUEST['show_sticky'] ) ? 'current' : '';
357
+		if ( ! empty($this->sticky_posts_count)) {
358
+			$class = ! empty($_REQUEST['show_sticky']) ? 'current' : '';
359 359
 
360 360
 			$sticky_args = array(
361 361
 				'post_type'	=> $post_type,
@@ -369,16 +369,16 @@  discard block
 block discarded – undo
369 369
 					$this->sticky_posts_count,
370 370
 					'posts'
371 371
 				),
372
-				number_format_i18n( $this->sticky_posts_count )
372
+				number_format_i18n($this->sticky_posts_count)
373 373
 			);
374 374
 
375 375
 			$sticky_link = array(
376
-				'sticky' => $this->get_edit_link( $sticky_args, $sticky_inner_html, $class )
376
+				'sticky' => $this->get_edit_link($sticky_args, $sticky_inner_html, $class)
377 377
 			);
378 378
 
379 379
 			// Sticky comes after Publish, or if not listed, after All.
380
-			$split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ) );
381
-			$status_links = array_merge( array_slice( $status_links, 0, $split ), $sticky_link, array_slice( $status_links, $split ) );
380
+			$split = 1 + array_search((isset($status_links['publish']) ? 'publish' : 'all'), array_keys($status_links));
381
+			$status_links = array_merge(array_slice($status_links, 0, $split), $sticky_link, array_slice($status_links, $split));
382 382
 		}
383 383
 
384 384
 		return $status_links;
@@ -390,21 +390,21 @@  discard block
 block discarded – undo
390 390
 	 */
391 391
 	protected function get_bulk_actions() {
392 392
 		$actions = array();
393
-		$post_type_obj = get_post_type_object( $this->screen->post_type );
393
+		$post_type_obj = get_post_type_object($this->screen->post_type);
394 394
 
395
-		if ( current_user_can( $post_type_obj->cap->edit_posts ) ) {
396
-			if ( $this->is_trash ) {
397
-				$actions['untrash'] = __( 'Restore' );
395
+		if (current_user_can($post_type_obj->cap->edit_posts)) {
396
+			if ($this->is_trash) {
397
+				$actions['untrash'] = __('Restore');
398 398
 			} else {
399
-				$actions['edit'] = __( 'Edit' );
399
+				$actions['edit'] = __('Edit');
400 400
 			}
401 401
 		}
402 402
 
403
-		if ( current_user_can( $post_type_obj->cap->delete_posts ) ) {
404
-			if ( $this->is_trash || ! EMPTY_TRASH_DAYS ) {
405
-				$actions['delete'] = __( 'Delete Permanently' );
403
+		if (current_user_can($post_type_obj->cap->delete_posts)) {
404
+			if ($this->is_trash || ! EMPTY_TRASH_DAYS) {
405
+				$actions['delete'] = __('Delete Permanently');
406 406
 			} else {
407
-				$actions['trash'] = __( 'Move to Trash' );
407
+				$actions['trash'] = __('Move to Trash');
408 408
 			}
409 409
 		}
410 410
 
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 	 *
422 422
 	 * @param string $post_type Post type slug.
423 423
 	 */
424
-	protected function categories_dropdown( $post_type ) {
424
+	protected function categories_dropdown($post_type) {
425 425
 		global $cat;
426 426
 
427 427
 		/**
@@ -432,13 +432,13 @@  discard block
 block discarded – undo
432 432
 		 * @param bool   $disable   Whether to disable the categories drop-down. Default false.
433 433
 		 * @param string $post_type Post type slug.
434 434
 		 */
435
-		if ( false !== apply_filters( 'disable_categories_dropdown', false, $post_type ) ) {
435
+		if (false !== apply_filters('disable_categories_dropdown', false, $post_type)) {
436 436
 			return;
437 437
 		}
438 438
 
439
-		if ( is_object_in_taxonomy( $post_type, 'category' ) ) {
439
+		if (is_object_in_taxonomy($post_type, 'category')) {
440 440
 			$dropdown_options = array(
441
-				'show_option_all' => get_taxonomy( 'category' )->labels->all_items,
441
+				'show_option_all' => get_taxonomy('category')->labels->all_items,
442 442
 				'hide_empty' => 0,
443 443
 				'hierarchical' => 1,
444 444
 				'show_count' => 0,
@@ -446,23 +446,23 @@  discard block
 block discarded – undo
446 446
 				'selected' => $cat
447 447
 			);
448 448
 
449
-			echo '<label class="screen-reader-text" for="cat">' . __( 'Filter by category' ) . '</label>';
450
-			wp_dropdown_categories( $dropdown_options );
449
+			echo '<label class="screen-reader-text" for="cat">'.__('Filter by category').'</label>';
450
+			wp_dropdown_categories($dropdown_options);
451 451
 		}
452 452
 	}
453 453
 
454 454
 	/**
455 455
 	 * @param string $which
456 456
 	 */
457
-	protected function extra_tablenav( $which ) {
457
+	protected function extra_tablenav($which) {
458 458
 ?>
459 459
 		<div class="alignleft actions">
460 460
 <?php
461
-		if ( 'top' === $which && !is_singular() ) {
461
+		if ('top' === $which && ! is_singular()) {
462 462
 			ob_start();
463 463
 
464
-			$this->months_dropdown( $this->screen->post_type );
465
-			$this->categories_dropdown( $this->screen->post_type );
464
+			$this->months_dropdown($this->screen->post_type);
465
+			$this->categories_dropdown($this->screen->post_type);
466 466
 
467 467
 			/**
468 468
 			 * Fires before the Filter button on the Posts and Pages list tables.
@@ -479,18 +479,18 @@  discard block
 block discarded – undo
479 479
 			 *                          'top' or 'bottom' for WP_Posts_List_Table,
480 480
 			 *                          'bar' for WP_Media_List_Table.
481 481
 			 */
482
-			do_action( 'restrict_manage_posts', $this->screen->post_type, $which );
482
+			do_action('restrict_manage_posts', $this->screen->post_type, $which);
483 483
 
484 484
 			$output = ob_get_clean();
485 485
 
486
-			if ( ! empty( $output ) ) {
486
+			if ( ! empty($output)) {
487 487
 				echo $output;
488
-				submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
488
+				submit_button(__('Filter'), '', 'filter_action', false, array('id' => 'post-query-submit'));
489 489
 			}
490 490
 		}
491 491
 
492
-		if ( $this->is_trash && current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts ) && $this->has_items() ) {
493
-			submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false );
492
+		if ($this->is_trash && current_user_can(get_post_type_object($this->screen->post_type)->cap->edit_others_posts) && $this->has_items()) {
493
+			submit_button(__('Empty Trash'), 'apply', 'delete_all', false);
494 494
 		}
495 495
 ?>
496 496
 		</div>
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
 		 *
504 504
 		 * @param string $which The location of the extra table nav markup: 'top' or 'bottom'.
505 505
 		 */
506
-		do_action( 'manage_posts_extra_tablenav', $which );
506
+		do_action('manage_posts_extra_tablenav', $which);
507 507
 	}
508 508
 
509 509
 	/**
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 	 * @return string
512 512
 	 */
513 513
 	public function current_action() {
514
-		if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
514
+		if (isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2']))
515 515
 			return 'delete_all';
516 516
 
517 517
 		return parent::current_action();
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 	 * @return array
523 523
 	 */
524 524
 	protected function get_table_classes() {
525
-		return array( 'widefat', 'fixed', 'striped', is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' );
525
+		return array('widefat', 'fixed', 'striped', is_post_type_hierarchical($this->screen->post_type) ? 'pages' : 'posts');
526 526
 	}
527 527
 
528 528
 	/**
@@ -537,14 +537,14 @@  discard block
 block discarded – undo
537 537
 		$posts_columns['cb'] = '<input type="checkbox" />';
538 538
 
539 539
 		/* translators: manage posts column name */
540
-		$posts_columns['title'] = _x( 'Title', 'column name' );
540
+		$posts_columns['title'] = _x('Title', 'column name');
541 541
 
542
-		if ( post_type_supports( $post_type, 'author' ) ) {
543
-			$posts_columns['author'] = __( 'Author' );
542
+		if (post_type_supports($post_type, 'author')) {
543
+			$posts_columns['author'] = __('Author');
544 544
 		}
545 545
 
546
-		$taxonomies = get_object_taxonomies( $post_type, 'objects' );
547
-		$taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' );
546
+		$taxonomies = get_object_taxonomies($post_type, 'objects');
547
+		$taxonomies = wp_filter_object_list($taxonomies, array('show_admin_column' => true), 'and', 'name');
548 548
 
549 549
 		/**
550 550
 		 * Filters the taxonomy columns in the Posts list table.
@@ -557,27 +557,27 @@  discard block
 block discarded – undo
557 557
 		 * @param array  $taxonomies Array of taxonomies to show columns for.
558 558
 		 * @param string $post_type  The post type.
559 559
 		 */
560
-		$taxonomies = apply_filters( "manage_taxonomies_for_{$post_type}_columns", $taxonomies, $post_type );
561
-		$taxonomies = array_filter( $taxonomies, 'taxonomy_exists' );
560
+		$taxonomies = apply_filters("manage_taxonomies_for_{$post_type}_columns", $taxonomies, $post_type);
561
+		$taxonomies = array_filter($taxonomies, 'taxonomy_exists');
562 562
 
563
-		foreach ( $taxonomies as $taxonomy ) {
564
-			if ( 'category' === $taxonomy )
563
+		foreach ($taxonomies as $taxonomy) {
564
+			if ('category' === $taxonomy)
565 565
 				$column_key = 'categories';
566
-			elseif ( 'post_tag' === $taxonomy )
566
+			elseif ('post_tag' === $taxonomy)
567 567
 				$column_key = 'tags';
568 568
 			else
569
-				$column_key = 'taxonomy-' . $taxonomy;
569
+				$column_key = 'taxonomy-'.$taxonomy;
570 570
 
571
-			$posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name;
571
+			$posts_columns[$column_key] = get_taxonomy($taxonomy)->labels->name;
572 572
 		}
573 573
 
574
-		$post_status = !empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all';
575
-		if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) )
576
-			$posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>';
574
+		$post_status = ! empty($_REQUEST['post_status']) ? $_REQUEST['post_status'] : 'all';
575
+		if (post_type_supports($post_type, 'comments') && ! in_array($post_status, array('pending', 'draft', 'future')))
576
+			$posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="'.esc_attr__('Comments').'"><span class="screen-reader-text">'.__('Comments').'</span></span>';
577 577
 
578
-		$posts_columns['date'] = __( 'Date' );
578
+		$posts_columns['date'] = __('Date');
579 579
 
580
-		if ( 'page' === $post_type ) {
580
+		if ('page' === $post_type) {
581 581
 
582 582
 			/**
583 583
 			 * Filters the columns displayed in the Pages list table.
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 			 *
587 587
 			 * @param array $post_columns An array of column names.
588 588
 			 */
589
-			$posts_columns = apply_filters( 'manage_pages_columns', $posts_columns );
589
+			$posts_columns = apply_filters('manage_pages_columns', $posts_columns);
590 590
 		} else {
591 591
 
592 592
 			/**
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 			 * @param array  $posts_columns An array of column names.
598 598
 			 * @param string $post_type     The post type slug.
599 599
 			 */
600
-			$posts_columns = apply_filters( 'manage_posts_columns', $posts_columns, $post_type );
600
+			$posts_columns = apply_filters('manage_posts_columns', $posts_columns, $post_type);
601 601
 		}
602 602
 
603 603
 		/**
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
 		 *
610 610
 		 * @param array $post_columns An array of column names.
611 611
 		 */
612
-		return apply_filters( "manage_{$post_type}_posts_columns", $posts_columns );
612
+		return apply_filters("manage_{$post_type}_posts_columns", $posts_columns);
613 613
 	}
614 614
 
615 615
 	/**
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
 			'title'    => 'title',
622 622
 			'parent'   => 'parent',
623 623
 			'comments' => 'comment_count',
624
-			'date'     => array( 'date', true )
624
+			'date'     => array('date', true)
625 625
 		);
626 626
 	}
627 627
 
@@ -631,18 +631,18 @@  discard block
 block discarded – undo
631 631
 	 * @param array $posts
632 632
 	 * @param int $level
633 633
 	 */
634
-	public function display_rows( $posts = array(), $level = 0 ) {
634
+	public function display_rows($posts = array(), $level = 0) {
635 635
 		global $wp_query, $per_page;
636 636
 
637
-		if ( empty( $posts ) )
637
+		if (empty($posts))
638 638
 			$posts = $wp_query->posts;
639 639
 
640
-		add_filter( 'the_title', 'esc_html' );
640
+		add_filter('the_title', 'esc_html');
641 641
 
642
-		if ( $this->hierarchical_display ) {
643
-			$this->_display_rows_hierarchical( $posts, $this->get_pagenum(), $per_page );
642
+		if ($this->hierarchical_display) {
643
+			$this->_display_rows_hierarchical($posts, $this->get_pagenum(), $per_page);
644 644
 		} else {
645
-			$this->_display_rows( $posts, $level );
645
+			$this->_display_rows($posts, $level);
646 646
 		}
647 647
 	}
648 648
 
@@ -650,17 +650,17 @@  discard block
 block discarded – undo
650 650
 	 * @param array $posts
651 651
 	 * @param int $level
652 652
 	 */
653
-	private function _display_rows( $posts, $level = 0 ) {
653
+	private function _display_rows($posts, $level = 0) {
654 654
 		// Create array of post IDs.
655 655
 		$post_ids = array();
656 656
 
657
-		foreach ( $posts as $a_post )
657
+		foreach ($posts as $a_post)
658 658
 			$post_ids[] = $a_post->ID;
659 659
 
660
-		$this->comment_pending_count = get_pending_comments_num( $post_ids );
660
+		$this->comment_pending_count = get_pending_comments_num($post_ids);
661 661
 
662
-		foreach ( $posts as $post )
663
-			$this->single_row( $post, $level );
662
+		foreach ($posts as $post)
663
+			$this->single_row($post, $level);
664 664
 	}
665 665
 
666 666
 	/**
@@ -670,15 +670,15 @@  discard block
 block discarded – undo
670 670
 	 * @param int $pagenum
671 671
 	 * @param int $per_page
672 672
 	 */
673
-	private function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) {
673
+	private function _display_rows_hierarchical($pages, $pagenum = 1, $per_page = 20) {
674 674
 		global $wpdb;
675 675
 
676 676
 		$level = 0;
677 677
 
678
-		if ( ! $pages ) {
679
-			$pages = get_pages( array( 'sort_column' => 'menu_order' ) );
678
+		if ( ! $pages) {
679
+			$pages = get_pages(array('sort_column' => 'menu_order'));
680 680
 
681
-			if ( ! $pages )
681
+			if ( ! $pages)
682 682
 				return;
683 683
 		}
684 684
 
@@ -689,56 +689,56 @@  discard block
 block discarded – undo
689 689
 		 * It only takes O( N ) to arrange this and it takes O( 1 ) for subsequent lookup operations
690 690
 		 * If searching, ignore hierarchy and treat everything as top level
691 691
 		 */
692
-		if ( empty( $_REQUEST['s'] ) ) {
692
+		if (empty($_REQUEST['s'])) {
693 693
 
694 694
 			$top_level_pages = array();
695 695
 			$children_pages = array();
696 696
 
697
-			foreach ( $pages as $page ) {
697
+			foreach ($pages as $page) {
698 698
 
699 699
 				// Catch and repair bad pages.
700
-				if ( $page->post_parent == $page->ID ) {
700
+				if ($page->post_parent == $page->ID) {
701 701
 					$page->post_parent = 0;
702
-					$wpdb->update( $wpdb->posts, array( 'post_parent' => 0 ), array( 'ID' => $page->ID ) );
703
-					clean_post_cache( $page );
702
+					$wpdb->update($wpdb->posts, array('post_parent' => 0), array('ID' => $page->ID));
703
+					clean_post_cache($page);
704 704
 				}
705 705
 
706
-				if ( 0 == $page->post_parent )
706
+				if (0 == $page->post_parent)
707 707
 					$top_level_pages[] = $page;
708 708
 				else
709
-					$children_pages[ $page->post_parent ][] = $page;
709
+					$children_pages[$page->post_parent][] = $page;
710 710
 			}
711 711
 
712 712
 			$pages = &$top_level_pages;
713 713
 		}
714 714
 
715 715
 		$count = 0;
716
-		$start = ( $pagenum - 1 ) * $per_page;
716
+		$start = ($pagenum - 1) * $per_page;
717 717
 		$end = $start + $per_page;
718 718
 		$to_display = array();
719 719
 
720
-		foreach ( $pages as $page ) {
721
-			if ( $count >= $end )
720
+		foreach ($pages as $page) {
721
+			if ($count >= $end)
722 722
 				break;
723 723
 
724
-			if ( $count >= $start ) {
724
+			if ($count >= $start) {
725 725
 				$to_display[$page->ID] = $level;
726 726
 			}
727 727
 
728 728
 			$count++;
729 729
 
730
-			if ( isset( $children_pages ) )
731
-				$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display );
730
+			if (isset($children_pages))
731
+				$this->_page_rows($children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display);
732 732
 		}
733 733
 
734 734
 		// If it is the last pagenum and there are orphaned pages, display them with paging as well.
735
-		if ( isset( $children_pages ) && $count < $end ){
736
-			foreach ( $children_pages as $orphans ){
737
-				foreach ( $orphans as $op ) {
738
-					if ( $count >= $end )
735
+		if (isset($children_pages) && $count < $end) {
736
+			foreach ($children_pages as $orphans) {
737
+				foreach ($orphans as $op) {
738
+					if ($count >= $end)
739 739
 						break;
740 740
 
741
-					if ( $count >= $start ) {
741
+					if ($count >= $start) {
742 742
 						$to_display[$op->ID] = 0;
743 743
 					}
744 744
 
@@ -747,16 +747,16 @@  discard block
 block discarded – undo
747 747
 			}
748 748
 		}
749 749
 
750
-		$ids = array_keys( $to_display );
751
-		_prime_post_caches( $ids );
750
+		$ids = array_keys($to_display);
751
+		_prime_post_caches($ids);
752 752
 
753
-		if ( ! isset( $GLOBALS['post'] ) ) {
754
-			$GLOBALS['post'] = reset( $ids );
753
+		if ( ! isset($GLOBALS['post'])) {
754
+			$GLOBALS['post'] = reset($ids);
755 755
 		}
756 756
 
757
-		foreach ( $to_display as $page_id => $level ) {
757
+		foreach ($to_display as $page_id => $level) {
758 758
 			echo "\t";
759
-			$this->single_row( $page_id, $level );
759
+			$this->single_row($page_id, $level);
760 760
 		}
761 761
 	}
762 762
 
@@ -775,51 +775,51 @@  discard block
 block discarded – undo
775 775
 	 * @param int $per_page
776 776
 	 * @param array $to_display List of pages to be displayed. Passed by reference.
777 777
 	 */
778
-	private function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page, &$to_display ) {
779
-		if ( ! isset( $children_pages[$parent] ) )
778
+	private function _page_rows(&$children_pages, &$count, $parent, $level, $pagenum, $per_page, &$to_display) {
779
+		if ( ! isset($children_pages[$parent]))
780 780
 			return;
781 781
 
782
-		$start = ( $pagenum - 1 ) * $per_page;
782
+		$start = ($pagenum - 1) * $per_page;
783 783
 		$end = $start + $per_page;
784 784
 
785
-		foreach ( $children_pages[$parent] as $page ) {
786
-			if ( $count >= $end )
785
+		foreach ($children_pages[$parent] as $page) {
786
+			if ($count >= $end)
787 787
 				break;
788 788
 
789 789
 			// If the page starts in a subtree, print the parents.
790
-			if ( $count == $start && $page->post_parent > 0 ) {
790
+			if ($count == $start && $page->post_parent > 0) {
791 791
 				$my_parents = array();
792 792
 				$my_parent = $page->post_parent;
793
-				while ( $my_parent ) {
793
+				while ($my_parent) {
794 794
 					// Get the ID from the list or the attribute if my_parent is an object
795 795
 					$parent_id = $my_parent;
796
-					if ( is_object( $my_parent ) ) {
796
+					if (is_object($my_parent)) {
797 797
 						$parent_id = $my_parent->ID;
798 798
 					}
799 799
 
800
-					$my_parent = get_post( $parent_id );
800
+					$my_parent = get_post($parent_id);
801 801
 					$my_parents[] = $my_parent;
802
-					if ( !$my_parent->post_parent )
802
+					if ( ! $my_parent->post_parent)
803 803
 						break;
804 804
 					$my_parent = $my_parent->post_parent;
805 805
 				}
806
-				$num_parents = count( $my_parents );
807
-				while ( $my_parent = array_pop( $my_parents ) ) {
806
+				$num_parents = count($my_parents);
807
+				while ($my_parent = array_pop($my_parents)) {
808 808
 					$to_display[$my_parent->ID] = $level - $num_parents;
809 809
 					$num_parents--;
810 810
 				}
811 811
 			}
812 812
 
813
-			if ( $count >= $start ) {
813
+			if ($count >= $start) {
814 814
 				$to_display[$page->ID] = $level;
815 815
 			}
816 816
 
817 817
 			$count++;
818 818
 
819
-			$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display );
819
+			$this->_page_rows($children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display);
820 820
 		}
821 821
 
822
-		unset( $children_pages[$parent] ); //required in order to keep track of orphans
822
+		unset($children_pages[$parent]); //required in order to keep track of orphans
823 823
 	}
824 824
 
825 825
 	/**
@@ -830,10 +830,10 @@  discard block
 block discarded – undo
830 830
 	 *
831 831
 	 * @param WP_Post $post The current WP_Post object.
832 832
 	 */
833
-	public function column_cb( $post ) {
834
-		if ( current_user_can( 'edit_post', $post->ID ) ): ?>
833
+	public function column_cb($post) {
834
+		if (current_user_can('edit_post', $post->ID)): ?>
835 835
 			<label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php
836
-				printf( __( 'Select %s' ), _draft_or_post_title() );
836
+				printf(__('Select %s'), _draft_or_post_title());
837 837
 			?></label>
838 838
 			<input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" />
839 839
 			<div class="locked-indicator">
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 				<span class="screen-reader-text"><?php
842 842
 				printf(
843 843
 					/* translators: %s: post title */
844
-					__( '&#8220;%s&#8221; is locked' ),
844
+					__('&#8220;%s&#8221; is locked'),
845 845
 					_draft_or_post_title()
846 846
 				);
847 847
 				?></span>
@@ -858,10 +858,10 @@  discard block
 block discarded – undo
858 858
 	 * @param string  $data
859 859
 	 * @param string  $primary
860 860
 	 */
861
-	protected function _column_title( $post, $classes, $data, $primary ) {
862
-		echo '<td class="' . $classes . ' page-title" ', $data, '>';
863
-		echo $this->column_title( $post );
864
-		echo $this->handle_row_actions( $post, 'title', $primary );
861
+	protected function _column_title($post, $classes, $data, $primary) {
862
+		echo '<td class="'.$classes.' page-title" ', $data, '>';
863
+		echo $this->column_title($post);
864
+		echo $this->handle_row_actions($post, 'title', $primary);
865 865
 		echo '</td>';
866 866
 	}
867 867
 
@@ -875,91 +875,91 @@  discard block
 block discarded – undo
875 875
 	 *
876 876
 	 * @param WP_Post $post The current WP_Post object.
877 877
 	 */
878
-	public function column_title( $post ) {
878
+	public function column_title($post) {
879 879
 		global $mode;
880 880
 
881
-		if ( $this->hierarchical_display ) {
882
-			if ( 0 === $this->current_level && (int) $post->post_parent > 0 ) {
881
+		if ($this->hierarchical_display) {
882
+			if (0 === $this->current_level && (int) $post->post_parent > 0) {
883 883
 				// Sent level 0 by accident, by default, or because we don't know the actual level.
884 884
 				$find_main_page = (int) $post->post_parent;
885
-				while ( $find_main_page > 0 ) {
886
-					$parent = get_post( $find_main_page );
885
+				while ($find_main_page > 0) {
886
+					$parent = get_post($find_main_page);
887 887
 
888
-					if ( is_null( $parent ) ) {
888
+					if (is_null($parent)) {
889 889
 						break;
890 890
 					}
891 891
 
892 892
 					$this->current_level++;
893 893
 					$find_main_page = (int) $parent->post_parent;
894 894
 
895
-					if ( ! isset( $parent_name ) ) {
895
+					if ( ! isset($parent_name)) {
896 896
 						/** This filter is documented in wp-includes/post-template.php */
897
-						$parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID );
897
+						$parent_name = apply_filters('the_title', $parent->post_title, $parent->ID);
898 898
 					}
899 899
 				}
900 900
 			}
901 901
 		}
902 902
 
903
-		$can_edit_post = current_user_can( 'edit_post', $post->ID );
903
+		$can_edit_post = current_user_can('edit_post', $post->ID);
904 904
 
905
-		if ( $can_edit_post && $post->post_status != 'trash' ) {
906
-			$lock_holder = wp_check_post_lock( $post->ID );
905
+		if ($can_edit_post && $post->post_status != 'trash') {
906
+			$lock_holder = wp_check_post_lock($post->ID);
907 907
 
908
-			if ( $lock_holder ) {
909
-				$lock_holder = get_userdata( $lock_holder );
910
-				$locked_avatar = get_avatar( $lock_holder->ID, 18 );
911
-				$locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) );
908
+			if ($lock_holder) {
909
+				$lock_holder = get_userdata($lock_holder);
910
+				$locked_avatar = get_avatar($lock_holder->ID, 18);
911
+				$locked_text = esc_html(sprintf(__('%s is currently editing'), $lock_holder->display_name));
912 912
 			} else {
913 913
 				$locked_avatar = $locked_text = '';
914 914
 			}
915 915
 
916
-			echo '<div class="locked-info"><span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span></div>\n";
916
+			echo '<div class="locked-info"><span class="locked-avatar">'.$locked_avatar.'</span> <span class="locked-text">'.$locked_text."</span></div>\n";
917 917
 		}
918 918
 
919
-		$pad = str_repeat( '&#8212; ', $this->current_level );
919
+		$pad = str_repeat('&#8212; ', $this->current_level);
920 920
 		echo "<strong>";
921 921
 
922
-		$format = get_post_format( $post->ID );
923
-		if ( $format ) {
924
-			$label = get_post_format_string( $format );
922
+		$format = get_post_format($post->ID);
923
+		if ($format) {
924
+			$label = get_post_format_string($format);
925 925
 
926
-			$format_class = 'post-state-format post-format-icon post-format-' . $format;
926
+			$format_class = 'post-state-format post-format-icon post-format-'.$format;
927 927
 
928 928
 			$format_args = array(
929 929
 				'post_format' => $format,
930 930
 				'post_type' => $post->post_type
931 931
 			);
932 932
 
933
-			echo $this->get_edit_link( $format_args, $label . ':', $format_class );
933
+			echo $this->get_edit_link($format_args, $label.':', $format_class);
934 934
 		}
935 935
 
936 936
 		$title = _draft_or_post_title();
937 937
 
938
-		if ( $can_edit_post && $post->post_status != 'trash' ) {
938
+		if ($can_edit_post && $post->post_status != 'trash') {
939 939
 			printf(
940 940
 				'<a class="row-title" href="%s" aria-label="%s">%s%s</a>',
941
-				get_edit_post_link( $post->ID ),
941
+				get_edit_post_link($post->ID),
942 942
 				/* translators: %s: post title */
943
-				esc_attr( sprintf( __( '&#8220;%s&#8221; (Edit)' ), $title ) ),
943
+				esc_attr(sprintf(__('&#8220;%s&#8221; (Edit)'), $title)),
944 944
 				$pad,
945 945
 				$title
946 946
 			);
947 947
 		} else {
948
-			echo $pad . $title;
948
+			echo $pad.$title;
949 949
 		}
950
-		_post_states( $post );
950
+		_post_states($post);
951 951
 
952
-		if ( isset( $parent_name ) ) {
953
-			$post_type_object = get_post_type_object( $post->post_type );
954
-			echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name );
952
+		if (isset($parent_name)) {
953
+			$post_type_object = get_post_type_object($post->post_type);
954
+			echo ' | '.$post_type_object->labels->parent_item_colon.' '.esc_html($parent_name);
955 955
 		}
956 956
 		echo "</strong>\n";
957 957
 
958
-		if ( ! is_post_type_hierarchical( $this->screen->post_type ) && 'excerpt' === $mode && current_user_can( 'read_post', $post->ID ) ) {
959
-			echo esc_html( get_the_excerpt() );
958
+		if ( ! is_post_type_hierarchical($this->screen->post_type) && 'excerpt' === $mode && current_user_can('read_post', $post->ID)) {
959
+			echo esc_html(get_the_excerpt());
960 960
 		}
961 961
 
962
-		get_inline_data( $post );
962
+		get_inline_data($post);
963 963
 	}
964 964
 
965 965
 	/**
@@ -972,36 +972,36 @@  discard block
 block discarded – undo
972 972
 	 *
973 973
 	 * @param WP_Post $post The current WP_Post object.
974 974
 	 */
975
-	public function column_date( $post ) {
975
+	public function column_date($post) {
976 976
 		global $mode;
977 977
 
978
-		if ( '0000-00-00 00:00:00' === $post->post_date ) {
979
-			$t_time = $h_time = __( 'Unpublished' );
978
+		if ('0000-00-00 00:00:00' === $post->post_date) {
979
+			$t_time = $h_time = __('Unpublished');
980 980
 			$time_diff = 0;
981 981
 		} else {
982
-			$t_time = get_the_time( __( 'Y/m/d g:i:s a' ) );
982
+			$t_time = get_the_time(__('Y/m/d g:i:s a'));
983 983
 			$m_time = $post->post_date;
984
-			$time = get_post_time( 'G', true, $post );
984
+			$time = get_post_time('G', true, $post);
985 985
 
986 986
 			$time_diff = time() - $time;
987 987
 
988
-			if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) {
989
-				$h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
988
+			if ($time_diff > 0 && $time_diff < DAY_IN_SECONDS) {
989
+				$h_time = sprintf(__('%s ago'), human_time_diff($time));
990 990
 			} else {
991
-				$h_time = mysql2date( __( 'Y/m/d' ), $m_time );
991
+				$h_time = mysql2date(__('Y/m/d'), $m_time);
992 992
 			}
993 993
 		}
994 994
 
995
-		if ( 'publish' === $post->post_status ) {
996
-			$status = __( 'Published' );
997
-		} elseif ( 'future' === $post->post_status ) {
998
-			if ( $time_diff > 0 ) {
999
-				$status = '<strong class="error-message">' . __( 'Missed schedule' ) . '</strong>';
995
+		if ('publish' === $post->post_status) {
996
+			$status = __('Published');
997
+		} elseif ('future' === $post->post_status) {
998
+			if ($time_diff > 0) {
999
+				$status = '<strong class="error-message">'.__('Missed schedule').'</strong>';
1000 1000
 			} else {
1001
-				$status = __( 'Scheduled' );
1001
+				$status = __('Scheduled');
1002 1002
 			}
1003 1003
 		} else {
1004
-			$status = __( 'Last Modified' );
1004
+			$status = __('Last Modified');
1005 1005
 		}
1006 1006
 
1007 1007
 		/**
@@ -1014,13 +1014,13 @@  discard block
 block discarded – undo
1014 1014
 		 * @param string  $column_name The column name.
1015 1015
 		 * @param string  $mode        The list display mode ('excerpt' or 'list').
1016 1016
 		 */
1017
-		$status = apply_filters( 'post_date_column_status', $status, $post, 'date', $mode );
1017
+		$status = apply_filters('post_date_column_status', $status, $post, 'date', $mode);
1018 1018
 
1019
-		if ( $status ) {
1020
-			echo $status . '<br />';
1019
+		if ($status) {
1020
+			echo $status.'<br />';
1021 1021
 		}
1022 1022
 
1023
-		if ( 'excerpt' === $mode ) {
1023
+		if ('excerpt' === $mode) {
1024 1024
 			/**
1025 1025
 			 * Filters the published time of the post.
1026 1026
 			 *
@@ -1035,11 +1035,11 @@  discard block
 block discarded – undo
1035 1035
 			 * @param string  $column_name The column name.
1036 1036
 			 * @param string  $mode        The list display mode ('excerpt' or 'list').
1037 1037
 			 */
1038
-			echo apply_filters( 'post_date_column_time', $t_time, $post, 'date', $mode );
1038
+			echo apply_filters('post_date_column_time', $t_time, $post, 'date', $mode);
1039 1039
 		} else {
1040 1040
 
1041 1041
 			/** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */
1042
-			echo '<abbr title="' . $t_time . '">' . apply_filters( 'post_date_column_time', $h_time, $post, 'date', $mode ) . '</abbr>';
1042
+			echo '<abbr title="'.$t_time.'">'.apply_filters('post_date_column_time', $h_time, $post, 'date', $mode).'</abbr>';
1043 1043
 		}
1044 1044
 	}
1045 1045
 
@@ -1051,13 +1051,13 @@  discard block
 block discarded – undo
1051 1051
 	 *
1052 1052
 	 * @param WP_Post $post The current WP_Post object.
1053 1053
 	 */
1054
-	public function column_comments( $post ) {
1054
+	public function column_comments($post) {
1055 1055
 		?>
1056 1056
 		<div class="post-com-count-wrapper">
1057 1057
 		<?php
1058
-			$pending_comments = isset( $this->comment_pending_count[$post->ID] ) ? $this->comment_pending_count[$post->ID] : 0;
1058
+			$pending_comments = isset($this->comment_pending_count[$post->ID]) ? $this->comment_pending_count[$post->ID] : 0;
1059 1059
 
1060
-			$this->comments_bubble( $post->ID, $pending_comments );
1060
+			$this->comments_bubble($post->ID, $pending_comments);
1061 1061
 		?>
1062 1062
 		</div>
1063 1063
 		<?php
@@ -1071,12 +1071,12 @@  discard block
 block discarded – undo
1071 1071
 	 *
1072 1072
 	 * @param WP_Post $post The current WP_Post object.
1073 1073
 	 */
1074
-	public function column_author( $post ) {
1074
+	public function column_author($post) {
1075 1075
 		$args = array(
1076 1076
 			'post_type' => $post->post_type,
1077
-			'author' => get_the_author_meta( 'ID' )
1077
+			'author' => get_the_author_meta('ID')
1078 1078
 		);
1079
-		echo $this->get_edit_link( $args, get_the_author() );
1079
+		echo $this->get_edit_link($args, get_the_author());
1080 1080
 	}
1081 1081
 
1082 1082
 	/**
@@ -1088,45 +1088,45 @@  discard block
 block discarded – undo
1088 1088
 	 * @param WP_Post $post        The current WP_Post object.
1089 1089
 	 * @param string  $column_name The current column name.
1090 1090
 	 */
1091
-	public function column_default( $post, $column_name ) {
1092
-		if ( 'categories' === $column_name ) {
1091
+	public function column_default($post, $column_name) {
1092
+		if ('categories' === $column_name) {
1093 1093
 			$taxonomy = 'category';
1094
-		} elseif ( 'tags' === $column_name ) {
1094
+		} elseif ('tags' === $column_name) {
1095 1095
 			$taxonomy = 'post_tag';
1096
-		} elseif ( 0 === strpos( $column_name, 'taxonomy-' ) ) {
1097
-			$taxonomy = substr( $column_name, 9 );
1096
+		} elseif (0 === strpos($column_name, 'taxonomy-')) {
1097
+			$taxonomy = substr($column_name, 9);
1098 1098
 		} else {
1099 1099
 			$taxonomy = false;
1100 1100
 		}
1101
-		if ( $taxonomy ) {
1102
-			$taxonomy_object = get_taxonomy( $taxonomy );
1103
-			$terms = get_the_terms( $post->ID, $taxonomy );
1104
-			if ( is_array( $terms ) ) {
1101
+		if ($taxonomy) {
1102
+			$taxonomy_object = get_taxonomy($taxonomy);
1103
+			$terms = get_the_terms($post->ID, $taxonomy);
1104
+			if (is_array($terms)) {
1105 1105
 				$out = array();
1106
-				foreach ( $terms as $t ) {
1106
+				foreach ($terms as $t) {
1107 1107
 					$posts_in_term_qv = array();
1108
-					if ( 'post' != $post->post_type ) {
1108
+					if ('post' != $post->post_type) {
1109 1109
 						$posts_in_term_qv['post_type'] = $post->post_type;
1110 1110
 					}
1111
-					if ( $taxonomy_object->query_var ) {
1112
-						$posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug;
1111
+					if ($taxonomy_object->query_var) {
1112
+						$posts_in_term_qv[$taxonomy_object->query_var] = $t->slug;
1113 1113
 					} else {
1114 1114
 						$posts_in_term_qv['taxonomy'] = $taxonomy;
1115 1115
 						$posts_in_term_qv['term'] = $t->slug;
1116 1116
 					}
1117 1117
 
1118
-					$label = esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) );
1119
-					$out[] = $this->get_edit_link( $posts_in_term_qv, $label );
1118
+					$label = esc_html(sanitize_term_field('name', $t->name, $t->term_id, $taxonomy, 'display'));
1119
+					$out[] = $this->get_edit_link($posts_in_term_qv, $label);
1120 1120
 				}
1121 1121
 				/* translators: used between list items, there is a space after the comma */
1122
-				echo join( __( ', ' ), $out );
1122
+				echo join(__(', '), $out);
1123 1123
 			} else {
1124
-				echo '<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">' . $taxonomy_object->labels->no_terms . '</span>';
1124
+				echo '<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">'.$taxonomy_object->labels->no_terms.'</span>';
1125 1125
 			}
1126 1126
 			return;
1127 1127
 		}
1128 1128
 
1129
-		if ( is_post_type_hierarchical( $post->post_type ) ) {
1129
+		if (is_post_type_hierarchical($post->post_type)) {
1130 1130
 
1131 1131
 			/**
1132 1132
 			 * Fires in each custom column on the Posts list table.
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
 			 * @param string $column_name The name of the column to display.
1140 1140
 			 * @param int    $post_id     The current post ID.
1141 1141
 			 */
1142
-			do_action( 'manage_pages_custom_column', $column_name, $post->ID );
1142
+			do_action('manage_pages_custom_column', $column_name, $post->ID);
1143 1143
 		} else {
1144 1144
 
1145 1145
 			/**
@@ -1153,7 +1153,7 @@  discard block
 block discarded – undo
1153 1153
 			 * @param string $column_name The name of the column to display.
1154 1154
 			 * @param int    $post_id     The current post ID.
1155 1155
 			 */
1156
-			do_action( 'manage_posts_custom_column', $column_name, $post->ID );
1156
+			do_action('manage_posts_custom_column', $column_name, $post->ID);
1157 1157
 		}
1158 1158
 
1159 1159
 		/**
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
 		 * @param string $column_name The name of the column to display.
1167 1167
 		 * @param int    $post_id     The current post ID.
1168 1168
 		 */
1169
-		do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID );
1169
+		do_action("manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID);
1170 1170
 	}
1171 1171
 
1172 1172
 	/**
@@ -1175,31 +1175,31 @@  discard block
 block discarded – undo
1175 1175
 	 * @param int|WP_Post $post
1176 1176
 	 * @param int         $level
1177 1177
 	 */
1178
-	public function single_row( $post, $level = 0 ) {
1178
+	public function single_row($post, $level = 0) {
1179 1179
 		$global_post = get_post();
1180 1180
 
1181
-		$post = get_post( $post );
1181
+		$post = get_post($post);
1182 1182
 		$this->current_level = $level;
1183 1183
 
1184 1184
 		$GLOBALS['post'] = $post;
1185
-		setup_postdata( $post );
1185
+		setup_postdata($post);
1186 1186
 
1187
-		$classes = 'iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
1187
+		$classes = 'iedit author-'.(get_current_user_id() == $post->post_author ? 'self' : 'other');
1188 1188
 
1189
-		$lock_holder = wp_check_post_lock( $post->ID );
1190
-		if ( $lock_holder ) {
1189
+		$lock_holder = wp_check_post_lock($post->ID);
1190
+		if ($lock_holder) {
1191 1191
 			$classes .= ' wp-locked';
1192 1192
 		}
1193 1193
 
1194
-		if ( $post->post_parent ) {
1195
-		    $count = count( get_post_ancestors( $post->ID ) );
1196
-		    $classes .= ' level-'. $count;
1194
+		if ($post->post_parent) {
1195
+		    $count = count(get_post_ancestors($post->ID));
1196
+		    $classes .= ' level-'.$count;
1197 1197
 		} else {
1198 1198
 		    $classes .= ' level-0';
1199 1199
 		}
1200 1200
 	?>
1201
-		<tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>">
1202
-			<?php $this->single_row_columns( $post ); ?>
1201
+		<tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode(' ', get_post_class($classes, $post->ID)); ?>">
1202
+			<?php $this->single_row_columns($post); ?>
1203 1203
 		</tr>
1204 1204
 	<?php
1205 1205
 		$GLOBALS['post'] = $global_post;
@@ -1228,85 +1228,85 @@  discard block
 block discarded – undo
1228 1228
 	 * @param string $primary     Primary column name.
1229 1229
 	 * @return string Row actions output for posts.
1230 1230
 	 */
1231
-	protected function handle_row_actions( $post, $column_name, $primary ) {
1232
-		if ( $primary !== $column_name ) {
1231
+	protected function handle_row_actions($post, $column_name, $primary) {
1232
+		if ($primary !== $column_name) {
1233 1233
 			return '';
1234 1234
 		}
1235 1235
 
1236
-		$post_type_object = get_post_type_object( $post->post_type );
1237
-		$can_edit_post = current_user_can( 'edit_post', $post->ID );
1236
+		$post_type_object = get_post_type_object($post->post_type);
1237
+		$can_edit_post = current_user_can('edit_post', $post->ID);
1238 1238
 		$actions = array();
1239 1239
 		$title = _draft_or_post_title();
1240 1240
 
1241
-		if ( $can_edit_post && 'trash' != $post->post_status ) {
1241
+		if ($can_edit_post && 'trash' != $post->post_status) {
1242 1242
 			$actions['edit'] = sprintf(
1243 1243
 				'<a href="%s" aria-label="%s">%s</a>',
1244
-				get_edit_post_link( $post->ID ),
1244
+				get_edit_post_link($post->ID),
1245 1245
 				/* translators: %s: post title */
1246
-				esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ),
1247
-				__( 'Edit' )
1246
+				esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $title)),
1247
+				__('Edit')
1248 1248
 			);
1249 1249
 			$actions['inline hide-if-no-js'] = sprintf(
1250 1250
 				'<a href="#" class="editinline" aria-label="%s">%s</a>',
1251 1251
 				/* translators: %s: post title */
1252
-				esc_attr( sprintf( __( 'Quick edit &#8220;%s&#8221; inline' ), $title ) ),
1253
-				__( 'Quick&nbsp;Edit' )
1252
+				esc_attr(sprintf(__('Quick edit &#8220;%s&#8221; inline'), $title)),
1253
+				__('Quick&nbsp;Edit')
1254 1254
 			);
1255 1255
 		}
1256 1256
 
1257
-		if ( current_user_can( 'delete_post', $post->ID ) ) {
1258
-			if ( 'trash' === $post->post_status ) {
1257
+		if (current_user_can('delete_post', $post->ID)) {
1258
+			if ('trash' === $post->post_status) {
1259 1259
 				$actions['untrash'] = sprintf(
1260 1260
 					'<a href="%s" aria-label="%s">%s</a>',
1261
-					wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&amp;action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ),
1261
+					wp_nonce_url(admin_url(sprintf($post_type_object->_edit_link.'&amp;action=untrash', $post->ID)), 'untrash-post_'.$post->ID),
1262 1262
 					/* translators: %s: post title */
1263
-					esc_attr( sprintf( __( 'Restore &#8220;%s&#8221; from the Trash' ), $title ) ),
1264
-					__( 'Restore' )
1263
+					esc_attr(sprintf(__('Restore &#8220;%s&#8221; from the Trash'), $title)),
1264
+					__('Restore')
1265 1265
 				);
1266
-			} elseif ( EMPTY_TRASH_DAYS ) {
1266
+			} elseif (EMPTY_TRASH_DAYS) {
1267 1267
 				$actions['trash'] = sprintf(
1268 1268
 					'<a href="%s" class="submitdelete" aria-label="%s">%s</a>',
1269
-					get_delete_post_link( $post->ID ),
1269
+					get_delete_post_link($post->ID),
1270 1270
 					/* translators: %s: post title */
1271
-					esc_attr( sprintf( __( 'Move &#8220;%s&#8221; to the Trash' ), $title ) ),
1272
-					_x( 'Trash', 'verb' )
1271
+					esc_attr(sprintf(__('Move &#8220;%s&#8221; to the Trash'), $title)),
1272
+					_x('Trash', 'verb')
1273 1273
 				);
1274 1274
 			}
1275
-			if ( 'trash' === $post->post_status || ! EMPTY_TRASH_DAYS ) {
1275
+			if ('trash' === $post->post_status || ! EMPTY_TRASH_DAYS) {
1276 1276
 				$actions['delete'] = sprintf(
1277 1277
 					'<a href="%s" class="submitdelete" aria-label="%s">%s</a>',
1278
-					get_delete_post_link( $post->ID, '', true ),
1278
+					get_delete_post_link($post->ID, '', true),
1279 1279
 					/* translators: %s: post title */
1280
-					esc_attr( sprintf( __( 'Delete &#8220;%s&#8221; permanently' ), $title ) ),
1281
-					__( 'Delete Permanently' )
1280
+					esc_attr(sprintf(__('Delete &#8220;%s&#8221; permanently'), $title)),
1281
+					__('Delete Permanently')
1282 1282
 				);
1283 1283
 			}
1284 1284
 		}
1285 1285
 
1286
-		if ( is_post_type_viewable( $post_type_object ) ) {
1287
-			if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) {
1288
-				if ( $can_edit_post ) {
1289
-					$preview_link = get_preview_post_link( $post );
1286
+		if (is_post_type_viewable($post_type_object)) {
1287
+			if (in_array($post->post_status, array('pending', 'draft', 'future'))) {
1288
+				if ($can_edit_post) {
1289
+					$preview_link = get_preview_post_link($post);
1290 1290
 					$actions['view'] = sprintf(
1291 1291
 						'<a href="%s" rel="bookmark" aria-label="%s">%s</a>',
1292
-						esc_url( $preview_link ),
1292
+						esc_url($preview_link),
1293 1293
 						/* translators: %s: post title */
1294
-						esc_attr( sprintf( __( 'Preview &#8220;%s&#8221;' ), $title ) ),
1295
-						__( 'Preview' )
1294
+						esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)),
1295
+						__('Preview')
1296 1296
 					);
1297 1297
 				}
1298
-			} elseif ( 'trash' != $post->post_status ) {
1298
+			} elseif ('trash' != $post->post_status) {
1299 1299
 				$actions['view'] = sprintf(
1300 1300
 					'<a href="%s" rel="bookmark" aria-label="%s">%s</a>',
1301
-					get_permalink( $post->ID ),
1301
+					get_permalink($post->ID),
1302 1302
 					/* translators: %s: post title */
1303
-					esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $title ) ),
1304
-					__( 'View' )
1303
+					esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)),
1304
+					__('View')
1305 1305
 				);
1306 1306
 			}
1307 1307
 		}
1308 1308
 
1309
-		if ( is_post_type_hierarchical( $post->post_type ) ) {
1309
+		if (is_post_type_hierarchical($post->post_type)) {
1310 1310
 
1311 1311
 			/**
1312 1312
 			 * Filters the array of row action links on the Pages list table.
@@ -1320,7 +1320,7 @@  discard block
 block discarded – undo
1320 1320
 			 *                         'Delete Permanently', 'Preview', and 'View'.
1321 1321
 			 * @param WP_Post $post The post object.
1322 1322
 			 */
1323
-			$actions = apply_filters( 'page_row_actions', $actions, $post );
1323
+			$actions = apply_filters('page_row_actions', $actions, $post);
1324 1324
 		} else {
1325 1325
 
1326 1326
 			/**
@@ -1335,10 +1335,10 @@  discard block
 block discarded – undo
1335 1335
 			 *                         'Delete Permanently', 'Preview', and 'View'.
1336 1336
 			 * @param WP_Post $post The post object.
1337 1337
 			 */
1338
-			$actions = apply_filters( 'post_row_actions', $actions, $post );
1338
+			$actions = apply_filters('post_row_actions', $actions, $post);
1339 1339
 		}
1340 1340
 
1341
-		return $this->row_actions( $actions );
1341
+		return $this->row_actions($actions);
1342 1342
 	}
1343 1343
 
1344 1344
 	/**
@@ -1353,15 +1353,15 @@  discard block
 block discarded – undo
1353 1353
 
1354 1354
 		$screen = $this->screen;
1355 1355
 
1356
-		$post = get_default_post_to_edit( $screen->post_type );
1357
-		$post_type_object = get_post_type_object( $screen->post_type );
1356
+		$post = get_default_post_to_edit($screen->post_type);
1357
+		$post_type_object = get_post_type_object($screen->post_type);
1358 1358
 
1359
-		$taxonomy_names = get_object_taxonomies( $screen->post_type );
1359
+		$taxonomy_names = get_object_taxonomies($screen->post_type);
1360 1360
 		$hierarchical_taxonomies = array();
1361 1361
 		$flat_taxonomies = array();
1362
-		foreach ( $taxonomy_names as $taxonomy_name ) {
1362
+		foreach ($taxonomy_names as $taxonomy_name) {
1363 1363
 
1364
-			$taxonomy = get_taxonomy( $taxonomy_name );
1364
+			$taxonomy = get_taxonomy($taxonomy_name);
1365 1365
 
1366 1366
 			$show_in_quick_edit = $taxonomy->show_in_quick_edit;
1367 1367
 
@@ -1374,39 +1374,39 @@  discard block
 block discarded – undo
1374 1374
 			 * @param string $taxonomy_name      Taxonomy name.
1375 1375
 			 * @param string $post_type          Post type of current Quick Edit post.
1376 1376
 			 */
1377
-			if ( ! apply_filters( 'quick_edit_show_taxonomy', $show_in_quick_edit, $taxonomy_name, $screen->post_type ) ) {
1377
+			if ( ! apply_filters('quick_edit_show_taxonomy', $show_in_quick_edit, $taxonomy_name, $screen->post_type)) {
1378 1378
 				continue;
1379 1379
 			}
1380 1380
 
1381
-			if ( $taxonomy->hierarchical )
1381
+			if ($taxonomy->hierarchical)
1382 1382
 				$hierarchical_taxonomies[] = $taxonomy;
1383 1383
 			else
1384 1384
 				$flat_taxonomies[] = $taxonomy;
1385 1385
 		}
1386 1386
 
1387
-		$m = ( isset( $mode ) && 'excerpt' === $mode ) ? 'excerpt' : 'list';
1388
-		$can_publish = current_user_can( $post_type_object->cap->publish_posts );
1389
-		$core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );
1387
+		$m = (isset($mode) && 'excerpt' === $mode) ? 'excerpt' : 'list';
1388
+		$can_publish = current_user_can($post_type_object->cap->publish_posts);
1389
+		$core_columns = array('cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true);
1390 1390
 
1391 1391
 	?>
1392 1392
 
1393 1393
 	<form method="get"><table style="display: none"><tbody id="inlineedit">
1394 1394
 		<?php
1395
-		$hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page';
1395
+		$hclass = count($hierarchical_taxonomies) ? 'post' : 'page';
1396 1396
 		$bulk = 0;
1397
-		while ( $bulk < 2 ) { ?>
1397
+		while ($bulk < 2) { ?>
1398 1398
 
1399
-		<tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-" . $screen->post_type;
1399
+		<tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-".$screen->post_type;
1400 1400
 			echo $bulk ? " bulk-edit-row bulk-edit-row-$hclass bulk-edit-{$screen->post_type}" : " quick-edit-row quick-edit-row-$hclass inline-edit-{$screen->post_type}";
1401 1401
 		?>" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
1402 1402
 
1403 1403
 		<fieldset class="inline-edit-col-left">
1404
-			<legend class="inline-edit-legend"><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></legend>
1404
+			<legend class="inline-edit-legend"><?php echo $bulk ? __('Bulk Edit') : __('Quick Edit'); ?></legend>
1405 1405
 			<div class="inline-edit-col">
1406 1406
 	<?php
1407 1407
 
1408
-	if ( post_type_supports( $screen->post_type, 'title' ) ) :
1409
-		if ( $bulk ) : ?>
1408
+	if (post_type_supports($screen->post_type, 'title')) :
1409
+		if ($bulk) : ?>
1410 1410
 			<div id="bulk-title-div">
1411 1411
 				<div id="bulk-titles"></div>
1412 1412
 			</div>
@@ -1414,30 +1414,30 @@  discard block
 block discarded – undo
1414 1414
 	<?php else : // $bulk ?>
1415 1415
 
1416 1416
 			<label>
1417
-				<span class="title"><?php _e( 'Title' ); ?></span>
1417
+				<span class="title"><?php _e('Title'); ?></span>
1418 1418
 				<span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>
1419 1419
 			</label>
1420 1420
 
1421 1421
 			<label>
1422
-				<span class="title"><?php _e( 'Slug' ); ?></span>
1422
+				<span class="title"><?php _e('Slug'); ?></span>
1423 1423
 				<span class="input-text-wrap"><input type="text" name="post_name" value="" /></span>
1424 1424
 			</label>
1425 1425
 
1426 1426
 	<?php endif; // $bulk
1427 1427
 	endif; // post_type_supports title ?>
1428 1428
 
1429
-	<?php if ( !$bulk ) : ?>
1429
+	<?php if ( ! $bulk) : ?>
1430 1430
 			<fieldset class="inline-edit-date">
1431
-			<legend><span class="title"><?php _e( 'Date' ); ?></span></legend>
1432
-				<?php touch_time( 1, 1, 0, 1 ); ?>
1431
+			<legend><span class="title"><?php _e('Date'); ?></span></legend>
1432
+				<?php touch_time(1, 1, 0, 1); ?>
1433 1433
 			</fieldset>
1434 1434
 			<br class="clear" />
1435 1435
 	<?php endif; // $bulk
1436 1436
 
1437
-		if ( post_type_supports( $screen->post_type, 'author' ) ) :
1437
+		if (post_type_supports($screen->post_type, 'author')) :
1438 1438
 			$authors_dropdown = '';
1439 1439
 
1440
-			if ( current_user_can( $post_type_object->cap->edit_others_posts ) ) :
1440
+			if (current_user_can($post_type_object->cap->edit_others_posts)) :
1441 1441
 				$users_opt = array(
1442 1442
 					'hide_if_only_one_author' => false,
1443 1443
 					'who' => 'authors',
@@ -1447,39 +1447,39 @@  discard block
 block discarded – undo
1447 1447
 					'echo' => 0,
1448 1448
 					'show' => 'display_name_with_login',
1449 1449
 				);
1450
-				if ( $bulk )
1451
-					$users_opt['show_option_none'] = __( '&mdash; No Change &mdash;' );
1450
+				if ($bulk)
1451
+					$users_opt['show_option_none'] = __('&mdash; No Change &mdash;');
1452 1452
 
1453
-				if ( $authors = wp_dropdown_users( $users_opt ) ) :
1453
+				if ($authors = wp_dropdown_users($users_opt)) :
1454 1454
 					$authors_dropdown  = '<label class="inline-edit-author">';
1455
-					$authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>';
1455
+					$authors_dropdown .= '<span class="title">'.__('Author').'</span>';
1456 1456
 					$authors_dropdown .= $authors;
1457 1457
 					$authors_dropdown .= '</label>';
1458 1458
 				endif;
1459 1459
 			endif; // authors
1460 1460
 	?>
1461 1461
 
1462
-	<?php if ( !$bulk ) echo $authors_dropdown;
1462
+	<?php if ( ! $bulk) echo $authors_dropdown;
1463 1463
 	endif; // post_type_supports author
1464 1464
 
1465
-	if ( !$bulk && $can_publish ) :
1465
+	if ( ! $bulk && $can_publish) :
1466 1466
 	?>
1467 1467
 
1468 1468
 			<div class="inline-edit-group wp-clearfix">
1469 1469
 				<label class="alignleft">
1470
-					<span class="title"><?php _e( 'Password' ); ?></span>
1470
+					<span class="title"><?php _e('Password'); ?></span>
1471 1471
 					<span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span>
1472 1472
 				</label>
1473 1473
 
1474 1474
 				<em class="alignleft inline-edit-or">
1475 1475
 					<?php
1476 1476
 					/* translators: Between password field and private checkbox on post quick edit interface */
1477
-					_e( '&ndash;OR&ndash;' );
1477
+					_e('&ndash;OR&ndash;');
1478 1478
 					?>
1479 1479
 				</em>
1480 1480
 				<label class="alignleft inline-edit-private">
1481 1481
 					<input type="checkbox" name="keep_private" value="private" />
1482
-					<span class="checkbox-title"><?php _e( 'Private' ); ?></span>
1482
+					<span class="checkbox-title"><?php _e('Private'); ?></span>
1483 1483
 				</label>
1484 1484
 			</div>
1485 1485
 
@@ -1487,16 +1487,16 @@  discard block
 block discarded – undo
1487 1487
 
1488 1488
 		</div></fieldset>
1489 1489
 
1490
-	<?php if ( count( $hierarchical_taxonomies ) && !$bulk ) : ?>
1490
+	<?php if (count($hierarchical_taxonomies) && ! $bulk) : ?>
1491 1491
 
1492 1492
 		<fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col">
1493 1493
 
1494
-	<?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?>
1494
+	<?php foreach ($hierarchical_taxonomies as $taxonomy) : ?>
1495 1495
 
1496
-			<span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ) ?></span>
1497
-			<input type="hidden" name="<?php echo ( $taxonomy->name === 'category' ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" />
1498
-			<ul class="cat-checklist <?php echo esc_attr( $taxonomy->name )?>-checklist">
1499
-				<?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ) ?>
1496
+			<span class="title inline-edit-categories-label"><?php echo esc_html($taxonomy->labels->name) ?></span>
1497
+			<input type="hidden" name="<?php echo ($taxonomy->name === 'category') ? 'post_category[]' : 'tax_input['.esc_attr($taxonomy->name).'][]'; ?>" value="0" />
1498
+			<ul class="cat-checklist <?php echo esc_attr($taxonomy->name)?>-checklist">
1499
+				<?php wp_terms_checklist(null, array('taxonomy' => $taxonomy->name)) ?>
1500 1500
 			</ul>
1501 1501
 
1502 1502
 	<?php endforeach; //$hierarchical_taxonomies as $taxonomy ?>
@@ -1508,27 +1508,27 @@  discard block
 block discarded – undo
1508 1508
 		<fieldset class="inline-edit-col-right"><div class="inline-edit-col">
1509 1509
 
1510 1510
 	<?php
1511
-		if ( post_type_supports( $screen->post_type, 'author' ) && $bulk )
1511
+		if (post_type_supports($screen->post_type, 'author') && $bulk)
1512 1512
 			echo $authors_dropdown;
1513 1513
 
1514
-		if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) :
1514
+		if (post_type_supports($screen->post_type, 'page-attributes')) :
1515 1515
 
1516
-			if ( $post_type_object->hierarchical ) :
1516
+			if ($post_type_object->hierarchical) :
1517 1517
 		?>
1518 1518
 			<label>
1519
-				<span class="title"><?php _e( 'Parent' ); ?></span>
1519
+				<span class="title"><?php _e('Parent'); ?></span>
1520 1520
 	<?php
1521 1521
 		$dropdown_args = array(
1522 1522
 			'post_type'         => $post_type_object->name,
1523 1523
 			'selected'          => $post->post_parent,
1524 1524
 			'name'              => 'post_parent',
1525
-			'show_option_none'  => __( 'Main Page (no parent)' ),
1525
+			'show_option_none'  => __('Main Page (no parent)'),
1526 1526
 			'option_none_value' => 0,
1527 1527
 			'sort_column'       => 'menu_order, post_title',
1528 1528
 		);
1529 1529
 
1530
-		if ( $bulk )
1531
-			$dropdown_args['show_option_no_change'] =  __( '&mdash; No Change &mdash;' );
1530
+		if ($bulk)
1531
+			$dropdown_args['show_option_no_change'] = __('&mdash; No Change &mdash;');
1532 1532
 
1533 1533
 		/**
1534 1534
 		 * Filters the arguments used to generate the Quick Edit page-parent drop-down.
@@ -1539,19 +1539,19 @@  discard block
 block discarded – undo
1539 1539
 		 *
1540 1540
 		 * @param array $dropdown_args An array of arguments.
1541 1541
 		 */
1542
-		$dropdown_args = apply_filters( 'quick_edit_dropdown_pages_args', $dropdown_args );
1542
+		$dropdown_args = apply_filters('quick_edit_dropdown_pages_args', $dropdown_args);
1543 1543
 
1544
-		wp_dropdown_pages( $dropdown_args );
1544
+		wp_dropdown_pages($dropdown_args);
1545 1545
 	?>
1546 1546
 			</label>
1547 1547
 
1548 1548
 	<?php
1549 1549
 			endif; // hierarchical
1550 1550
 
1551
-			if ( !$bulk ) : ?>
1551
+			if ( ! $bulk) : ?>
1552 1552
 
1553 1553
 			<label>
1554
-				<span class="title"><?php _e( 'Order' ); ?></span>
1554
+				<span class="title"><?php _e('Order'); ?></span>
1555 1555
 				<span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span>
1556 1556
 			</label>
1557 1557
 
@@ -1560,32 +1560,32 @@  discard block
 block discarded – undo
1560 1560
 		endif; // page-attributes
1561 1561
 	?>
1562 1562
 
1563
-	<?php if ( 0 < count( get_page_templates( null, $screen->post_type ) ) ) : ?>
1563
+	<?php if (0 < count(get_page_templates(null, $screen->post_type))) : ?>
1564 1564
 		<label>
1565
-			<span class="title"><?php _e( 'Template' ); ?></span>
1565
+			<span class="title"><?php _e('Template'); ?></span>
1566 1566
 			<select name="page_template">
1567
-<?php	if ( $bulk ) : ?>
1568
-				<option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
1567
+<?php	if ($bulk) : ?>
1568
+				<option value="-1"><?php _e('&mdash; No Change &mdash;'); ?></option>
1569 1569
 <?php	endif; // $bulk ?>
1570 1570
                 <?php
1571 1571
 				/** This filter is documented in wp-admin/includes/meta-boxes.php */
1572
-				$default_title = apply_filters( 'default_page_template_title',  __( 'Default Template' ), 'quick-edit' );
1572
+				$default_title = apply_filters('default_page_template_title', __('Default Template'), 'quick-edit');
1573 1573
                 ?>
1574
-				<option value="default"><?php echo esc_html( $default_title ); ?></option>
1575
-				<?php page_template_dropdown( '', $screen->post_type ) ?>
1574
+				<option value="default"><?php echo esc_html($default_title); ?></option>
1575
+				<?php page_template_dropdown('', $screen->post_type) ?>
1576 1576
 			</select>
1577 1577
 		</label>
1578 1578
 	<?php endif; ?>
1579 1579
 
1580
-	<?php if ( count( $flat_taxonomies ) && !$bulk ) : ?>
1580
+	<?php if (count($flat_taxonomies) && ! $bulk) : ?>
1581 1581
 
1582
-	<?php foreach ( $flat_taxonomies as $taxonomy ) : ?>
1583
-		<?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) :
1584
-			$taxonomy_name = esc_attr( $taxonomy->name );
1582
+	<?php foreach ($flat_taxonomies as $taxonomy) : ?>
1583
+		<?php if (current_user_can($taxonomy->cap->assign_terms)) :
1584
+			$taxonomy_name = esc_attr($taxonomy->name);
1585 1585
 
1586 1586
 			?>
1587 1587
 			<label class="inline-edit-tags">
1588
-				<span class="title"><?php echo esc_html( $taxonomy->labels->name ) ?></span>
1588
+				<span class="title"><?php echo esc_html($taxonomy->labels->name) ?></span>
1589 1589
 				<textarea data-wp-taxonomy="<?php echo $taxonomy_name; ?>" cols="22" rows="1" name="tax_input[<?php echo $taxonomy_name; ?>]" class="tax_input_<?php echo $taxonomy_name; ?>"></textarea>
1590 1590
 			</label>
1591 1591
 		<?php endif; ?>
@@ -1594,26 +1594,26 @@  discard block
 block discarded – undo
1594 1594
 
1595 1595
 	<?php endif; // count( $flat_taxonomies ) && !$bulk  ?>
1596 1596
 
1597
-	<?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) :
1598
-		if ( $bulk ) : ?>
1597
+	<?php if (post_type_supports($screen->post_type, 'comments') || post_type_supports($screen->post_type, 'trackbacks')) :
1598
+		if ($bulk) : ?>
1599 1599
 
1600 1600
 			<div class="inline-edit-group wp-clearfix">
1601
-		<?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
1601
+		<?php if (post_type_supports($screen->post_type, 'comments')) : ?>
1602 1602
 			<label class="alignleft">
1603
-				<span class="title"><?php _e( 'Comments' ); ?></span>
1603
+				<span class="title"><?php _e('Comments'); ?></span>
1604 1604
 				<select name="comment_status">
1605
-					<option value=""><?php _e( '&mdash; No Change &mdash;' ); ?></option>
1606
-					<option value="open"><?php _e( 'Allow' ); ?></option>
1607
-					<option value="closed"><?php _e( 'Do not allow' ); ?></option>
1605
+					<option value=""><?php _e('&mdash; No Change &mdash;'); ?></option>
1606
+					<option value="open"><?php _e('Allow'); ?></option>
1607
+					<option value="closed"><?php _e('Do not allow'); ?></option>
1608 1608
 				</select>
1609 1609
 			</label>
1610
-		<?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
1610
+		<?php endif; if (post_type_supports($screen->post_type, 'trackbacks')) : ?>
1611 1611
 			<label class="alignright">
1612
-				<span class="title"><?php _e( 'Pings' ); ?></span>
1612
+				<span class="title"><?php _e('Pings'); ?></span>
1613 1613
 				<select name="ping_status">
1614
-					<option value=""><?php _e( '&mdash; No Change &mdash;' ); ?></option>
1615
-					<option value="open"><?php _e( 'Allow' ); ?></option>
1616
-					<option value="closed"><?php _e( 'Do not allow' ); ?></option>
1614
+					<option value=""><?php _e('&mdash; No Change &mdash;'); ?></option>
1615
+					<option value="open"><?php _e('Allow'); ?></option>
1616
+					<option value="closed"><?php _e('Do not allow'); ?></option>
1617 1617
 				</select>
1618 1618
 			</label>
1619 1619
 		<?php endif; ?>
@@ -1622,15 +1622,15 @@  discard block
 block discarded – undo
1622 1622
 	<?php else : // $bulk ?>
1623 1623
 
1624 1624
 			<div class="inline-edit-group wp-clearfix">
1625
-			<?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
1625
+			<?php if (post_type_supports($screen->post_type, 'comments')) : ?>
1626 1626
 				<label class="alignleft">
1627 1627
 					<input type="checkbox" name="comment_status" value="open" />
1628
-					<span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span>
1628
+					<span class="checkbox-title"><?php _e('Allow Comments'); ?></span>
1629 1629
 				</label>
1630
-			<?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
1630
+			<?php endif; if (post_type_supports($screen->post_type, 'trackbacks')) : ?>
1631 1631
 				<label class="alignleft">
1632 1632
 					<input type="checkbox" name="ping_status" value="open" />
1633
-					<span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span>
1633
+					<span class="checkbox-title"><?php _e('Allow Pings'); ?></span>
1634 1634
 				</label>
1635 1635
 			<?php endif; ?>
1636 1636
 			</div>
@@ -1640,33 +1640,33 @@  discard block
 block discarded – undo
1640 1640
 
1641 1641
 			<div class="inline-edit-group wp-clearfix">
1642 1642
 				<label class="inline-edit-status alignleft">
1643
-					<span class="title"><?php _e( 'Status' ); ?></span>
1643
+					<span class="title"><?php _e('Status'); ?></span>
1644 1644
 					<select name="_status">
1645
-	<?php if ( $bulk ) : ?>
1646
-						<option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
1645
+	<?php if ($bulk) : ?>
1646
+						<option value="-1"><?php _e('&mdash; No Change &mdash;'); ?></option>
1647 1647
 	<?php endif; // $bulk ?>
1648
-					<?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?>
1649
-						<option value="publish"><?php _e( 'Published' ); ?></option>
1650
-						<option value="future"><?php _e( 'Scheduled' ); ?></option>
1651
-	<?php if ( $bulk ) : ?>
1652
-						<option value="private"><?php _e( 'Private' ) ?></option>
1648
+					<?php if ($can_publish) : // Contributors only get "Unpublished" and "Pending Review" ?>
1649
+						<option value="publish"><?php _e('Published'); ?></option>
1650
+						<option value="future"><?php _e('Scheduled'); ?></option>
1651
+	<?php if ($bulk) : ?>
1652
+						<option value="private"><?php _e('Private') ?></option>
1653 1653
 	<?php endif; // $bulk ?>
1654 1654
 					<?php endif; ?>
1655
-						<option value="pending"><?php _e( 'Pending Review' ); ?></option>
1656
-						<option value="draft"><?php _e( 'Draft' ); ?></option>
1655
+						<option value="pending"><?php _e('Pending Review'); ?></option>
1656
+						<option value="draft"><?php _e('Draft'); ?></option>
1657 1657
 					</select>
1658 1658
 				</label>
1659 1659
 
1660
-	<?php if ( 'post' === $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?>
1660
+	<?php if ('post' === $screen->post_type && $can_publish && current_user_can($post_type_object->cap->edit_others_posts)) : ?>
1661 1661
 
1662
-	<?php	if ( $bulk ) : ?>
1662
+	<?php	if ($bulk) : ?>
1663 1663
 
1664 1664
 				<label class="alignright">
1665
-					<span class="title"><?php _e( 'Sticky' ); ?></span>
1665
+					<span class="title"><?php _e('Sticky'); ?></span>
1666 1666
 					<select name="sticky">
1667
-						<option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
1668
-						<option value="sticky"><?php _e( 'Sticky' ); ?></option>
1669
-						<option value="unsticky"><?php _e( 'Not Sticky' ); ?></option>
1667
+						<option value="-1"><?php _e('&mdash; No Change &mdash;'); ?></option>
1668
+						<option value="sticky"><?php _e('Sticky'); ?></option>
1669
+						<option value="unsticky"><?php _e('Not Sticky'); ?></option>
1670 1670
 					</select>
1671 1671
 				</label>
1672 1672
 
@@ -1674,7 +1674,7 @@  discard block
 block discarded – undo
1674 1674
 
1675 1675
 				<label class="alignleft">
1676 1676
 					<input type="checkbox" name="sticky" value="sticky" />
1677
-					<span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span>
1677
+					<span class="checkbox-title"><?php _e('Make this post sticky'); ?></span>
1678 1678
 				</label>
1679 1679
 
1680 1680
 	<?php	endif; // $bulk ?>
@@ -1685,20 +1685,20 @@  discard block
 block discarded – undo
1685 1685
 
1686 1686
 	<?php
1687 1687
 
1688
-	if ( $bulk && current_theme_supports( 'post-formats' ) && post_type_supports( $screen->post_type, 'post-formats' ) ) {
1689
-		$post_formats = get_theme_support( 'post-formats' );
1688
+	if ($bulk && current_theme_supports('post-formats') && post_type_supports($screen->post_type, 'post-formats')) {
1689
+		$post_formats = get_theme_support('post-formats');
1690 1690
 
1691 1691
 		?>
1692 1692
 		<label class="alignleft">
1693
-		<span class="title"><?php _ex( 'Format', 'post format' ); ?></span>
1693
+		<span class="title"><?php _ex('Format', 'post format'); ?></span>
1694 1694
 		<select name="post_format">
1695
-			<option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
1696
-			<option value="0"><?php echo get_post_format_string( 'standard' ); ?></option>
1695
+			<option value="-1"><?php _e('&mdash; No Change &mdash;'); ?></option>
1696
+			<option value="0"><?php echo get_post_format_string('standard'); ?></option>
1697 1697
 			<?php
1698
-			if ( is_array( $post_formats[0] ) ) {
1699
-				foreach ( $post_formats[0] as $format ) {
1698
+			if (is_array($post_formats[0])) {
1699
+				foreach ($post_formats[0] as $format) {
1700 1700
 					?>
1701
-					<option value="<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></option>
1701
+					<option value="<?php echo esc_attr($format); ?>"><?php echo esc_html(get_post_format_string($format)); ?></option>
1702 1702
 					<?php
1703 1703
 				}
1704 1704
 			}
@@ -1713,13 +1713,13 @@  discard block
 block discarded – undo
1713 1713
 		</div></fieldset>
1714 1714
 
1715 1715
 	<?php
1716
-		list( $columns ) = $this->get_column_info();
1716
+		list($columns) = $this->get_column_info();
1717 1717
 
1718
-		foreach ( $columns as $column_name => $column_display_name ) {
1719
-			if ( isset( $core_columns[$column_name] ) )
1718
+		foreach ($columns as $column_name => $column_display_name) {
1719
+			if (isset($core_columns[$column_name]))
1720 1720
 				continue;
1721 1721
 
1722
-			if ( $bulk ) {
1722
+			if ($bulk) {
1723 1723
 
1724 1724
 				/**
1725 1725
 				 * Fires once for each column in Bulk Edit mode.
@@ -1729,7 +1729,7 @@  discard block
 block discarded – undo
1729 1729
 				 * @param string  $column_name Name of the column to edit.
1730 1730
 				 * @param WP_Post $post_type   The post type slug.
1731 1731
 				 */
1732
-				do_action( 'bulk_edit_custom_box', $column_name, $screen->post_type );
1732
+				do_action('bulk_edit_custom_box', $column_name, $screen->post_type);
1733 1733
 			} else {
1734 1734
 
1735 1735
 				/**
@@ -1740,25 +1740,25 @@  discard block
 block discarded – undo
1740 1740
 				 * @param string $column_name Name of the column to edit.
1741 1741
 				 * @param string $post_type   The post type slug.
1742 1742
 				 */
1743
-				do_action( 'quick_edit_custom_box', $column_name, $screen->post_type );
1743
+				do_action('quick_edit_custom_box', $column_name, $screen->post_type);
1744 1744
 			}
1745 1745
 
1746 1746
 		}
1747 1747
 	?>
1748 1748
 		<p class="submit inline-edit-save">
1749
-			<button type="button" class="button cancel alignleft"><?php _e( 'Cancel' ); ?></button>
1750
-			<?php if ( ! $bulk ) {
1751
-				wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );
1749
+			<button type="button" class="button cancel alignleft"><?php _e('Cancel'); ?></button>
1750
+			<?php if ( ! $bulk) {
1751
+				wp_nonce_field('inlineeditnonce', '_inline_edit', false);
1752 1752
 				?>
1753
-				<button type="button" class="button button-primary save alignright"><?php _e( 'Update' ); ?></button>
1753
+				<button type="button" class="button button-primary save alignright"><?php _e('Update'); ?></button>
1754 1754
 				<span class="spinner"></span>
1755 1755
 			<?php } else {
1756
-				submit_button( __( 'Update' ), 'primary alignright', 'bulk_edit', false );
1756
+				submit_button(__('Update'), 'primary alignright', 'bulk_edit', false);
1757 1757
 			} ?>
1758
-			<input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" />
1759
-			<input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" />
1760
-			<?php if ( ! $bulk && ! post_type_supports( $screen->post_type, 'author' ) ) { ?>
1761
-				<input type="hidden" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" />
1758
+			<input type="hidden" name="post_view" value="<?php echo esc_attr($m); ?>" />
1759
+			<input type="hidden" name="screen" value="<?php echo esc_attr($screen->id); ?>" />
1760
+			<?php if ( ! $bulk && ! post_type_supports($screen->post_type, 'author')) { ?>
1761
+				<input type="hidden" name="post_author" value="<?php echo esc_attr($post->post_author); ?>" />
1762 1762
 			<?php } ?>
1763 1763
 			<span class="error" style="display:none"></span>
1764 1764
 			<br class="clear" />
Please login to merge, or discard this patch.
Braces   +91 added lines, -59 removed lines patch added patch discarded remove patch
@@ -199,10 +199,11 @@  discard block
 block discarded – undo
199 199
 	 * @access public
200 200
 	 */
201 201
 	public function no_items() {
202
-		if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] )
203
-			echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash;
204
-		else
205
-			echo get_post_type_object( $this->screen->post_type )->labels->not_found;
202
+		if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) {
203
+					echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash;
204
+		} else {
205
+					echo get_post_type_object( $this->screen->post_type )->labels->not_found;
206
+		}
206 207
 	}
207 208
 
208 209
 	/**
@@ -266,8 +267,9 @@  discard block
 block discarded – undo
266 267
 
267 268
 		$post_type = $this->screen->post_type;
268 269
 
269
-		if ( !empty($locked_post_status) )
270
-			return array();
270
+		if ( !empty($locked_post_status) ) {
271
+					return array();
272
+		}
271 273
 
272 274
 		$status_links = array();
273 275
 		$num_posts = wp_count_posts( $post_type, 'readable' );
@@ -511,8 +513,9 @@  discard block
 block discarded – undo
511 513
 	 * @return string
512 514
 	 */
513 515
 	public function current_action() {
514
-		if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
515
-			return 'delete_all';
516
+		if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) {
517
+					return 'delete_all';
518
+		}
516 519
 
517 520
 		return parent::current_action();
518 521
 	}
@@ -561,19 +564,21 @@  discard block
 block discarded – undo
561 564
 		$taxonomies = array_filter( $taxonomies, 'taxonomy_exists' );
562 565
 
563 566
 		foreach ( $taxonomies as $taxonomy ) {
564
-			if ( 'category' === $taxonomy )
565
-				$column_key = 'categories';
566
-			elseif ( 'post_tag' === $taxonomy )
567
-				$column_key = 'tags';
568
-			else
569
-				$column_key = 'taxonomy-' . $taxonomy;
567
+			if ( 'category' === $taxonomy ) {
568
+							$column_key = 'categories';
569
+			} elseif ( 'post_tag' === $taxonomy ) {
570
+							$column_key = 'tags';
571
+			} else {
572
+							$column_key = 'taxonomy-' . $taxonomy;
573
+			}
570 574
 
571 575
 			$posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name;
572 576
 		}
573 577
 
574 578
 		$post_status = !empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all';
575
-		if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) )
576
-			$posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>';
579
+		if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) ) {
580
+					$posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>';
581
+		}
577 582
 
578 583
 		$posts_columns['date'] = __( 'Date' );
579 584
 
@@ -634,8 +639,9 @@  discard block
 block discarded – undo
634 639
 	public function display_rows( $posts = array(), $level = 0 ) {
635 640
 		global $wp_query, $per_page;
636 641
 
637
-		if ( empty( $posts ) )
638
-			$posts = $wp_query->posts;
642
+		if ( empty( $posts ) ) {
643
+					$posts = $wp_query->posts;
644
+		}
639 645
 
640 646
 		add_filter( 'the_title', 'esc_html' );
641 647
 
@@ -654,13 +660,15 @@  discard block
 block discarded – undo
654 660
 		// Create array of post IDs.
655 661
 		$post_ids = array();
656 662
 
657
-		foreach ( $posts as $a_post )
658
-			$post_ids[] = $a_post->ID;
663
+		foreach ( $posts as $a_post ) {
664
+					$post_ids[] = $a_post->ID;
665
+		}
659 666
 
660 667
 		$this->comment_pending_count = get_pending_comments_num( $post_ids );
661 668
 
662
-		foreach ( $posts as $post )
663
-			$this->single_row( $post, $level );
669
+		foreach ( $posts as $post ) {
670
+					$this->single_row( $post, $level );
671
+		}
664 672
 	}
665 673
 
666 674
 	/**
@@ -678,8 +686,9 @@  discard block
 block discarded – undo
678 686
 		if ( ! $pages ) {
679 687
 			$pages = get_pages( array( 'sort_column' => 'menu_order' ) );
680 688
 
681
-			if ( ! $pages )
682
-				return;
689
+			if ( ! $pages ) {
690
+							return;
691
+			}
683 692
 		}
684 693
 
685 694
 		/*
@@ -703,10 +712,11 @@  discard block
 block discarded – undo
703 712
 					clean_post_cache( $page );
704 713
 				}
705 714
 
706
-				if ( 0 == $page->post_parent )
707
-					$top_level_pages[] = $page;
708
-				else
709
-					$children_pages[ $page->post_parent ][] = $page;
715
+				if ( 0 == $page->post_parent ) {
716
+									$top_level_pages[] = $page;
717
+				} else {
718
+									$children_pages[ $page->post_parent ][] = $page;
719
+				}
710 720
 			}
711 721
 
712 722
 			$pages = &$top_level_pages;
@@ -718,8 +728,9 @@  discard block
 block discarded – undo
718 728
 		$to_display = array();
719 729
 
720 730
 		foreach ( $pages as $page ) {
721
-			if ( $count >= $end )
722
-				break;
731
+			if ( $count >= $end ) {
732
+							break;
733
+			}
723 734
 
724 735
 			if ( $count >= $start ) {
725 736
 				$to_display[$page->ID] = $level;
@@ -727,16 +738,18 @@  discard block
 block discarded – undo
727 738
 
728 739
 			$count++;
729 740
 
730
-			if ( isset( $children_pages ) )
731
-				$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display );
741
+			if ( isset( $children_pages ) ) {
742
+							$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display );
743
+			}
732 744
 		}
733 745
 
734 746
 		// If it is the last pagenum and there are orphaned pages, display them with paging as well.
735 747
 		if ( isset( $children_pages ) && $count < $end ){
736 748
 			foreach ( $children_pages as $orphans ){
737 749
 				foreach ( $orphans as $op ) {
738
-					if ( $count >= $end )
739
-						break;
750
+					if ( $count >= $end ) {
751
+											break;
752
+					}
740 753
 
741 754
 					if ( $count >= $start ) {
742 755
 						$to_display[$op->ID] = 0;
@@ -776,15 +789,17 @@  discard block
 block discarded – undo
776 789
 	 * @param array $to_display List of pages to be displayed. Passed by reference.
777 790
 	 */
778 791
 	private function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page, &$to_display ) {
779
-		if ( ! isset( $children_pages[$parent] ) )
780
-			return;
792
+		if ( ! isset( $children_pages[$parent] ) ) {
793
+					return;
794
+		}
781 795
 
782 796
 		$start = ( $pagenum - 1 ) * $per_page;
783 797
 		$end = $start + $per_page;
784 798
 
785 799
 		foreach ( $children_pages[$parent] as $page ) {
786
-			if ( $count >= $end )
787
-				break;
800
+			if ( $count >= $end ) {
801
+							break;
802
+			}
788 803
 
789 804
 			// If the page starts in a subtree, print the parents.
790 805
 			if ( $count == $start && $page->post_parent > 0 ) {
@@ -799,8 +814,9 @@  discard block
 block discarded – undo
799 814
 
800 815
 					$my_parent = get_post( $parent_id );
801 816
 					$my_parents[] = $my_parent;
802
-					if ( !$my_parent->post_parent )
803
-						break;
817
+					if ( !$my_parent->post_parent ) {
818
+											break;
819
+					}
804 820
 					$my_parent = $my_parent->post_parent;
805 821
 				}
806 822
 				$num_parents = count( $my_parents );
@@ -1378,10 +1394,11 @@  discard block
 block discarded – undo
1378 1394
 				continue;
1379 1395
 			}
1380 1396
 
1381
-			if ( $taxonomy->hierarchical )
1382
-				$hierarchical_taxonomies[] = $taxonomy;
1383
-			else
1384
-				$flat_taxonomies[] = $taxonomy;
1397
+			if ( $taxonomy->hierarchical ) {
1398
+							$hierarchical_taxonomies[] = $taxonomy;
1399
+			} else {
1400
+							$flat_taxonomies[] = $taxonomy;
1401
+			}
1385 1402
 		}
1386 1403
 
1387 1404
 		$m = ( isset( $mode ) && 'excerpt' === $mode ) ? 'excerpt' : 'list';
@@ -1411,10 +1428,13 @@  discard block
 block discarded – undo
1411 1428
 				<div id="bulk-titles"></div>
1412 1429
 			</div>
1413 1430
 
1414
-	<?php else : // $bulk ?>
1431
+	<?php else {
1432
+	: // $bulk ?>
1415 1433
 
1416 1434
 			<label>
1417
-				<span class="title"><?php _e( 'Title' ); ?></span>
1435
+				<span class="title"><?php _e( 'Title' );
1436
+}
1437
+?></span>
1418 1438
 				<span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>
1419 1439
 			</label>
1420 1440
 
@@ -1447,8 +1467,9 @@  discard block
 block discarded – undo
1447 1467
 					'echo' => 0,
1448 1468
 					'show' => 'display_name_with_login',
1449 1469
 				);
1450
-				if ( $bulk )
1451
-					$users_opt['show_option_none'] = __( '&mdash; No Change &mdash;' );
1470
+				if ( $bulk ) {
1471
+									$users_opt['show_option_none'] = __( '&mdash; No Change &mdash;' );
1472
+				}
1452 1473
 
1453 1474
 				if ( $authors = wp_dropdown_users( $users_opt ) ) :
1454 1475
 					$authors_dropdown  = '<label class="inline-edit-author">';
@@ -1459,7 +1480,9 @@  discard block
 block discarded – undo
1459 1480
 			endif; // authors
1460 1481
 	?>
1461 1482
 
1462
-	<?php if ( !$bulk ) echo $authors_dropdown;
1483
+	<?php if ( !$bulk ) {
1484
+	echo $authors_dropdown;
1485
+}
1463 1486
 	endif; // post_type_supports author
1464 1487
 
1465 1488
 	if ( !$bulk && $can_publish ) :
@@ -1508,8 +1531,9 @@  discard block
 block discarded – undo
1508 1531
 		<fieldset class="inline-edit-col-right"><div class="inline-edit-col">
1509 1532
 
1510 1533
 	<?php
1511
-		if ( post_type_supports( $screen->post_type, 'author' ) && $bulk )
1512
-			echo $authors_dropdown;
1534
+		if ( post_type_supports( $screen->post_type, 'author' ) && $bulk ) {
1535
+					echo $authors_dropdown;
1536
+		}
1513 1537
 
1514 1538
 		if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) :
1515 1539
 
@@ -1527,8 +1551,9 @@  discard block
 block discarded – undo
1527 1551
 			'sort_column'       => 'menu_order, post_title',
1528 1552
 		);
1529 1553
 
1530
-		if ( $bulk )
1531
-			$dropdown_args['show_option_no_change'] =  __( '&mdash; No Change &mdash;' );
1554
+		if ( $bulk ) {
1555
+					$dropdown_args['show_option_no_change'] =  __( '&mdash; No Change &mdash;' );
1556
+		}
1532 1557
 
1533 1558
 		/**
1534 1559
 		 * Filters the arguments used to generate the Quick Edit page-parent drop-down.
@@ -1619,13 +1644,16 @@  discard block
 block discarded – undo
1619 1644
 		<?php endif; ?>
1620 1645
 			</div>
1621 1646
 
1622
-	<?php else : // $bulk ?>
1647
+	<?php else {
1648
+	: // $bulk ?>
1623 1649
 
1624 1650
 			<div class="inline-edit-group wp-clearfix">
1625 1651
 			<?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
1626 1652
 				<label class="alignleft">
1627 1653
 					<input type="checkbox" name="comment_status" value="open" />
1628
-					<span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span>
1654
+					<span class="checkbox-title"><?php _e( 'Allow Comments' );
1655
+}
1656
+?></span>
1629 1657
 				</label>
1630 1658
 			<?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
1631 1659
 				<label class="alignleft">
@@ -1670,11 +1698,14 @@  discard block
 block discarded – undo
1670 1698
 					</select>
1671 1699
 				</label>
1672 1700
 
1673
-	<?php	else : // $bulk ?>
1701
+	<?php	else {
1702
+	: // $bulk ?>
1674 1703
 
1675 1704
 				<label class="alignleft">
1676 1705
 					<input type="checkbox" name="sticky" value="sticky" />
1677
-					<span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span>
1706
+					<span class="checkbox-title"><?php _e( 'Make this post sticky' );
1707
+}
1708
+?></span>
1678 1709
 				</label>
1679 1710
 
1680 1711
 	<?php	endif; // $bulk ?>
@@ -1716,8 +1747,9 @@  discard block
 block discarded – undo
1716 1747
 		list( $columns ) = $this->get_column_info();
1717 1748
 
1718 1749
 		foreach ( $columns as $column_name => $column_display_name ) {
1719
-			if ( isset( $core_columns[$column_name] ) )
1720
-				continue;
1750
+			if ( isset( $core_columns[$column_name] ) ) {
1751
+							continue;
1752
+			}
1721 1753
 
1722 1754
 			if ( $bulk ) {
1723 1755
 
Please login to merge, or discard this patch.
src/wp-includes/cache.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
  *
42 42
  * @since 2.0.0
43 43
  *
44
- * @return true Always returns true.
44
+ * @return boolean Always returns true.
45 45
  */
46 46
 function wp_cache_close() {
47 47
 	return true;
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 	 * @since 2.0.0
511 511
 	 * @access public
512 512
 	 *
513
-	 * @return true Always returns true.
513
+	 * @return boolean Always returns true.
514 514
 	 */
515 515
 	public function flush() {
516 516
 		$this->cache = array();
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
 	 * @param mixed      $data   The contents to store in the cache.
660 660
 	 * @param string     $group  Optional. Where to group the cache contents. Default 'default'.
661 661
 	 * @param int        $expire Not Used.
662
-	 * @return true Always returns true.
662
+	 * @return boolean Always returns true.
663 663
 	 */
664 664
 	public function set( $key, $data, $group = 'default', $expire = 0 ) {
665 665
 		if ( empty( $group ) )
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
 	 *
754 754
 	 * @since 2.0.8
755 755
 	 *
756
-	 * @return true Always returns true.
756
+	 * @return boolean Always returns true.
757 757
 	 */
758 758
 	public function __destruct() {
759 759
 		return true;
Please login to merge, or discard this patch.
Spacing   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
  *                           Default 0 (no expiration).
25 25
  * @return bool False if cache key and group already exist, true on success.
26 26
  */
27
-function wp_cache_add( $key, $data, $group = '', $expire = 0 ) {
27
+function wp_cache_add($key, $data, $group = '', $expire = 0) {
28 28
 	global $wp_object_cache;
29 29
 
30
-	return $wp_object_cache->add( $key, $data, $group, (int) $expire );
30
+	return $wp_object_cache->add($key, $data, $group, (int) $expire);
31 31
 }
32 32
 
33 33
 /**
@@ -60,10 +60,10 @@  discard block
 block discarded – undo
60 60
  * @param string     $group  Optional. The group the key is in. Default empty.
61 61
  * @return false|int False on failure, the item's new value on success.
62 62
  */
63
-function wp_cache_decr( $key, $offset = 1, $group = '' ) {
63
+function wp_cache_decr($key, $offset = 1, $group = '') {
64 64
 	global $wp_object_cache;
65 65
 
66
-	return $wp_object_cache->decr( $key, $offset, $group );
66
+	return $wp_object_cache->decr($key, $offset, $group);
67 67
 }
68 68
 
69 69
 /**
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
  * @param string     $group Optional. Where the cache contents are grouped. Default empty.
79 79
  * @return bool True on successful removal, false on failure.
80 80
  */
81
-function wp_cache_delete( $key, $group = '' ) {
81
+function wp_cache_delete($key, $group = '') {
82 82
 	global $wp_object_cache;
83 83
 
84 84
 	return $wp_object_cache->delete($key, $group);
@@ -117,10 +117,10 @@  discard block
 block discarded – undo
117 117
  * @return bool|mixed False on failure to retrieve contents or the cache
118 118
  *		              contents on success
119 119
  */
120
-function wp_cache_get( $key, $group = '', $force = false, &$found = null ) {
120
+function wp_cache_get($key, $group = '', $force = false, &$found = null) {
121 121
 	global $wp_object_cache;
122 122
 
123
-	return $wp_object_cache->get( $key, $group, $force, $found );
123
+	return $wp_object_cache->get($key, $group, $force, $found);
124 124
 }
125 125
 
126 126
 /**
@@ -136,10 +136,10 @@  discard block
 block discarded – undo
136 136
  * @param string     $group  Optional. The group the key is in. Default empty.
137 137
  * @return false|int False on failure, the item's new value on success.
138 138
  */
139
-function wp_cache_incr( $key, $offset = 1, $group = '' ) {
139
+function wp_cache_incr($key, $offset = 1, $group = '') {
140 140
 	global $wp_object_cache;
141 141
 
142
-	return $wp_object_cache->incr( $key, $offset, $group );
142
+	return $wp_object_cache->incr($key, $offset, $group);
143 143
 }
144 144
 
145 145
 /**
@@ -169,10 +169,10 @@  discard block
 block discarded – undo
169 169
  *                           Default 0 (no expiration).
170 170
  * @return bool False if original value does not exist, true if contents were replaced
171 171
  */
172
-function wp_cache_replace( $key, $data, $group = '', $expire = 0 ) {
172
+function wp_cache_replace($key, $data, $group = '', $expire = 0) {
173 173
 	global $wp_object_cache;
174 174
 
175
-	return $wp_object_cache->replace( $key, $data, $group, (int) $expire );
175
+	return $wp_object_cache->replace($key, $data, $group, (int) $expire);
176 176
 }
177 177
 
178 178
 /**
@@ -193,10 +193,10 @@  discard block
 block discarded – undo
193 193
  *                           Default 0 (no expiration).
194 194
  * @return bool False on failure, true on success
195 195
  */
196
-function wp_cache_set( $key, $data, $group = '', $expire = 0 ) {
196
+function wp_cache_set($key, $data, $group = '', $expire = 0) {
197 197
 	global $wp_object_cache;
198 198
 
199
-	return $wp_object_cache->set( $key, $data, $group, (int) $expire );
199
+	return $wp_object_cache->set($key, $data, $group, (int) $expire);
200 200
 }
201 201
 
202 202
 /**
@@ -211,10 +211,10 @@  discard block
 block discarded – undo
211 211
  *
212 212
  * @param int $blog_id Site ID.
213 213
  */
214
-function wp_cache_switch_to_blog( $blog_id ) {
214
+function wp_cache_switch_to_blog($blog_id) {
215 215
 	global $wp_object_cache;
216 216
 
217
-	$wp_object_cache->switch_to_blog( $blog_id );
217
+	$wp_object_cache->switch_to_blog($blog_id);
218 218
 }
219 219
 
220 220
 /**
@@ -227,10 +227,10 @@  discard block
 block discarded – undo
227 227
  *
228 228
  * @param string|array $groups A group or an array of groups to add.
229 229
  */
230
-function wp_cache_add_global_groups( $groups ) {
230
+function wp_cache_add_global_groups($groups) {
231 231
 	global $wp_object_cache;
232 232
 
233
-	$wp_object_cache->add_global_groups( $groups );
233
+	$wp_object_cache->add_global_groups($groups);
234 234
 }
235 235
 
236 236
 /**
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
  *
241 241
  * @param string|array $groups A group or an array of groups to add.
242 242
  */
243
-function wp_cache_add_non_persistent_groups( $groups ) {
243
+function wp_cache_add_non_persistent_groups($groups) {
244 244
 	// Default cache doesn't persist so nothing to do here.
245 245
 }
246 246
 
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
  * @global WP_Object_Cache $wp_object_cache Object cache global instance.
265 265
  */
266 266
 function wp_cache_reset() {
267
-	_deprecated_function( __FUNCTION__, '3.5.0' );
267
+	_deprecated_function(__FUNCTION__, '3.5.0');
268 268
 
269 269
 	global $wp_object_cache;
270 270
 
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 	 * @param string $name Property to get.
353 353
 	 * @return mixed Property.
354 354
 	 */
355
-	public function __get( $name ) {
355
+	public function __get($name) {
356 356
 		return $this->$name;
357 357
 	}
358 358
 
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 	 * @param mixed  $value Property value.
367 367
 	 * @return mixed Newly-set property.
368 368
 	 */
369
-	public function __set( $name, $value ) {
369
+	public function __set($name, $value) {
370 370
 		return $this->$name = $value;
371 371
 	}
372 372
 
@@ -379,8 +379,8 @@  discard block
 block discarded – undo
379 379
 	 * @param string $name Property to check if set.
380 380
 	 * @return bool Whether the property is set.
381 381
 	 */
382
-	public function __isset( $name ) {
383
-		return isset( $this->$name );
382
+	public function __isset($name) {
383
+		return isset($this->$name);
384 384
 	}
385 385
 
386 386
 	/**
@@ -391,8 +391,8 @@  discard block
 block discarded – undo
391 391
 	 *
392 392
 	 * @param string $name Property to unset.
393 393
 	 */
394
-	public function __unset( $name ) {
395
-		unset( $this->$name );
394
+	public function __unset($name) {
395
+		unset($this->$name);
396 396
 	}
397 397
 
398 398
 	/**
@@ -411,21 +411,21 @@  discard block
 block discarded – undo
411 411
 	 * @param int        $expire Optional. When to expire the cache contents. Default 0 (no expiration).
412 412
 	 * @return bool False if cache key and group already exist, true on success
413 413
 	 */
414
-	public function add( $key, $data, $group = 'default', $expire = 0 ) {
415
-		if ( wp_suspend_cache_addition() )
414
+	public function add($key, $data, $group = 'default', $expire = 0) {
415
+		if (wp_suspend_cache_addition())
416 416
 			return false;
417 417
 
418
-		if ( empty( $group ) )
418
+		if (empty($group))
419 419
 			$group = 'default';
420 420
 
421 421
 		$id = $key;
422
-		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
423
-			$id = $this->blog_prefix . $key;
422
+		if ($this->multisite && ! isset($this->global_groups[$group]))
423
+			$id = $this->blog_prefix.$key;
424 424
 
425
-		if ( $this->_exists( $id, $group ) )
425
+		if ($this->_exists($id, $group))
426 426
 			return false;
427 427
 
428
-		return $this->set( $key, $data, $group, (int) $expire );
428
+		return $this->set($key, $data, $group, (int) $expire);
429 429
 	}
430 430
 
431 431
 	/**
@@ -436,11 +436,11 @@  discard block
 block discarded – undo
436 436
 	 *
437 437
 	 * @param array $groups List of groups that are global.
438 438
 	 */
439
-	public function add_global_groups( $groups ) {
439
+	public function add_global_groups($groups) {
440 440
 		$groups = (array) $groups;
441 441
 
442
-		$groups = array_fill_keys( $groups, true );
443
-		$this->global_groups = array_merge( $this->global_groups, $groups );
442
+		$groups = array_fill_keys($groups, true);
443
+		$this->global_groups = array_merge($this->global_groups, $groups);
444 444
 	}
445 445
 
446 446
 	/**
@@ -454,27 +454,27 @@  discard block
 block discarded – undo
454 454
 	 * @param string     $group  Optional. The group the key is in. Default 'default'.
455 455
 	 * @return false|int False on failure, the item's new value on success.
456 456
 	 */
457
-	public function decr( $key, $offset = 1, $group = 'default' ) {
458
-		if ( empty( $group ) )
457
+	public function decr($key, $offset = 1, $group = 'default') {
458
+		if (empty($group))
459 459
 			$group = 'default';
460 460
 
461
-		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
462
-			$key = $this->blog_prefix . $key;
461
+		if ($this->multisite && ! isset($this->global_groups[$group]))
462
+			$key = $this->blog_prefix.$key;
463 463
 
464
-		if ( ! $this->_exists( $key, $group ) )
464
+		if ( ! $this->_exists($key, $group))
465 465
 			return false;
466 466
 
467
-		if ( ! is_numeric( $this->cache[ $group ][ $key ] ) )
468
-			$this->cache[ $group ][ $key ] = 0;
467
+		if ( ! is_numeric($this->cache[$group][$key]))
468
+			$this->cache[$group][$key] = 0;
469 469
 
470 470
 		$offset = (int) $offset;
471 471
 
472
-		$this->cache[ $group ][ $key ] -= $offset;
472
+		$this->cache[$group][$key] -= $offset;
473 473
 
474
-		if ( $this->cache[ $group ][ $key ] < 0 )
475
-			$this->cache[ $group ][ $key ] = 0;
474
+		if ($this->cache[$group][$key] < 0)
475
+			$this->cache[$group][$key] = 0;
476 476
 
477
-		return $this->cache[ $group ][ $key ];
477
+		return $this->cache[$group][$key];
478 478
 	}
479 479
 
480 480
 	/**
@@ -490,17 +490,17 @@  discard block
 block discarded – undo
490 490
 	 * @param bool       $deprecated Optional. Unused. Default false.
491 491
 	 * @return bool False if the contents weren't deleted and true on success.
492 492
 	 */
493
-	public function delete( $key, $group = 'default', $deprecated = false ) {
494
-		if ( empty( $group ) )
493
+	public function delete($key, $group = 'default', $deprecated = false) {
494
+		if (empty($group))
495 495
 			$group = 'default';
496 496
 
497
-		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
498
-			$key = $this->blog_prefix . $key;
497
+		if ($this->multisite && ! isset($this->global_groups[$group]))
498
+			$key = $this->blog_prefix.$key;
499 499
 
500
-		if ( ! $this->_exists( $key, $group ) )
500
+		if ( ! $this->_exists($key, $group))
501 501
 			return false;
502 502
 
503
-		unset( $this->cache[$group][$key] );
503
+		unset($this->cache[$group][$key]);
504 504
 		return true;
505 505
 	}
506 506
 
@@ -538,17 +538,17 @@  discard block
 block discarded – undo
538 538
 	 *                           false, a storable value. Passed by reference. Default null.
539 539
 	 * @return false|mixed False on failure to retrieve contents or the cache contents on success.
540 540
 	 */
541
-	public function get( $key, $group = 'default', $force = false, &$found = null ) {
542
-		if ( empty( $group ) )
541
+	public function get($key, $group = 'default', $force = false, &$found = null) {
542
+		if (empty($group))
543 543
 			$group = 'default';
544 544
 
545
-		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
546
-			$key = $this->blog_prefix . $key;
545
+		if ($this->multisite && ! isset($this->global_groups[$group]))
546
+			$key = $this->blog_prefix.$key;
547 547
 
548
-		if ( $this->_exists( $key, $group ) ) {
548
+		if ($this->_exists($key, $group)) {
549 549
 			$found = true;
550 550
 			$this->cache_hits += 1;
551
-			if ( is_object($this->cache[$group][$key]) )
551
+			if (is_object($this->cache[$group][$key]))
552 552
 				return clone $this->cache[$group][$key];
553 553
 			else
554 554
 				return $this->cache[$group][$key];
@@ -570,27 +570,27 @@  discard block
 block discarded – undo
570 570
 	 * @param string     $group  Optional. The group the key is in. Default 'default'.
571 571
 	 * @return false|int False on failure, the item's new value on success.
572 572
 	 */
573
-	public function incr( $key, $offset = 1, $group = 'default' ) {
574
-		if ( empty( $group ) )
573
+	public function incr($key, $offset = 1, $group = 'default') {
574
+		if (empty($group))
575 575
 			$group = 'default';
576 576
 
577
-		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
578
-			$key = $this->blog_prefix . $key;
577
+		if ($this->multisite && ! isset($this->global_groups[$group]))
578
+			$key = $this->blog_prefix.$key;
579 579
 
580
-		if ( ! $this->_exists( $key, $group ) )
580
+		if ( ! $this->_exists($key, $group))
581 581
 			return false;
582 582
 
583
-		if ( ! is_numeric( $this->cache[ $group ][ $key ] ) )
584
-			$this->cache[ $group ][ $key ] = 0;
583
+		if ( ! is_numeric($this->cache[$group][$key]))
584
+			$this->cache[$group][$key] = 0;
585 585
 
586 586
 		$offset = (int) $offset;
587 587
 
588
-		$this->cache[ $group ][ $key ] += $offset;
588
+		$this->cache[$group][$key] += $offset;
589 589
 
590
-		if ( $this->cache[ $group ][ $key ] < 0 )
591
-			$this->cache[ $group ][ $key ] = 0;
590
+		if ($this->cache[$group][$key] < 0)
591
+			$this->cache[$group][$key] = 0;
592 592
 
593
-		return $this->cache[ $group ][ $key ];
593
+		return $this->cache[$group][$key];
594 594
 	}
595 595
 
596 596
 	/**
@@ -607,18 +607,18 @@  discard block
 block discarded – undo
607 607
 	 * @param int        $expire Optional. When to expire the cache contents. Default 0 (no expiration).
608 608
 	 * @return bool False if not exists, true if contents were replaced.
609 609
 	 */
610
-	public function replace( $key, $data, $group = 'default', $expire = 0 ) {
611
-		if ( empty( $group ) )
610
+	public function replace($key, $data, $group = 'default', $expire = 0) {
611
+		if (empty($group))
612 612
 			$group = 'default';
613 613
 
614 614
 		$id = $key;
615
-		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
616
-			$id = $this->blog_prefix . $key;
615
+		if ($this->multisite && ! isset($this->global_groups[$group]))
616
+			$id = $this->blog_prefix.$key;
617 617
 
618
-		if ( ! $this->_exists( $id, $group ) )
618
+		if ( ! $this->_exists($id, $group))
619 619
 			return false;
620 620
 
621
-		return $this->set( $key, $data, $group, (int) $expire );
621
+		return $this->set($key, $data, $group, (int) $expire);
622 622
 	}
623 623
 
624 624
 	/**
@@ -631,12 +631,12 @@  discard block
 block discarded – undo
631 631
 	 * @see switch_to_blog()
632 632
 	 */
633 633
 	public function reset() {
634
-		_deprecated_function( __FUNCTION__, '3.5.0', 'switch_to_blog()' );
634
+		_deprecated_function(__FUNCTION__, '3.5.0', 'switch_to_blog()');
635 635
 
636 636
 		// Clear out non-global caches since the blog ID has changed.
637
-		foreach ( array_keys( $this->cache ) as $group ) {
638
-			if ( ! isset( $this->global_groups[ $group ] ) )
639
-				unset( $this->cache[ $group ] );
637
+		foreach (array_keys($this->cache) as $group) {
638
+			if ( ! isset($this->global_groups[$group]))
639
+				unset($this->cache[$group]);
640 640
 		}
641 641
 	}
642 642
 
@@ -661,14 +661,14 @@  discard block
 block discarded – undo
661 661
 	 * @param int        $expire Not Used.
662 662
 	 * @return true Always returns true.
663 663
 	 */
664
-	public function set( $key, $data, $group = 'default', $expire = 0 ) {
665
-		if ( empty( $group ) )
664
+	public function set($key, $data, $group = 'default', $expire = 0) {
665
+		if (empty($group))
666 666
 			$group = 'default';
667 667
 
668
-		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
669
-			$key = $this->blog_prefix . $key;
668
+		if ($this->multisite && ! isset($this->global_groups[$group]))
669
+			$key = $this->blog_prefix.$key;
670 670
 
671
-		if ( is_object( $data ) )
671
+		if (is_object($data))
672 672
 			$data = clone $data;
673 673
 
674 674
 		$this->cache[$group][$key] = $data;
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
 		echo "</p>";
692 692
 		echo '<ul>';
693 693
 		foreach ($this->cache as $group => $cache) {
694
-			echo "<li><strong>Group:</strong> $group - ( " . number_format( strlen( serialize( $cache ) ) / KB_IN_BYTES, 2 ) . 'k )</li>';
694
+			echo "<li><strong>Group:</strong> $group - ( ".number_format(strlen(serialize($cache)) / KB_IN_BYTES, 2).'k )</li>';
695 695
 		}
696 696
 		echo '</ul>';
697 697
 	}
@@ -706,9 +706,9 @@  discard block
 block discarded – undo
706 706
 	 *
707 707
 	 * @param int $blog_id Blog ID.
708 708
 	 */
709
-	public function switch_to_blog( $blog_id ) {
709
+	public function switch_to_blog($blog_id) {
710 710
 		$blog_id = (int) $blog_id;
711
-		$this->blog_prefix = $this->multisite ? $blog_id . ':' : '';
711
+		$this->blog_prefix = $this->multisite ? $blog_id.':' : '';
712 712
 	}
713 713
 
714 714
 	/**
@@ -721,8 +721,8 @@  discard block
 block discarded – undo
721 721
 	 * @param string     $group Cache group for the key existence check.
722 722
 	 * @return bool Whether the key exists in the cache for the given group.
723 723
 	 */
724
-	protected function _exists( $key, $group ) {
725
-		return isset( $this->cache[ $group ] ) && ( isset( $this->cache[ $group ][ $key ] ) || array_key_exists( $key, $this->cache[ $group ] ) );
724
+	protected function _exists($key, $group) {
725
+		return isset($this->cache[$group]) && (isset($this->cache[$group][$key]) || array_key_exists($key, $this->cache[$group]));
726 726
 	}
727 727
 
728 728
 	/**
@@ -732,14 +732,14 @@  discard block
 block discarded – undo
732 732
 	 */
733 733
 	public function __construct() {
734 734
 		$this->multisite = is_multisite();
735
-		$this->blog_prefix =  $this->multisite ? get_current_blog_id() . ':' : '';
735
+		$this->blog_prefix = $this->multisite ? get_current_blog_id().':' : '';
736 736
 
737 737
 
738 738
 		/**
739 739
 		 * @todo This should be moved to the PHP4 style constructor, PHP5
740 740
 		 * already calls __destruct()
741 741
 		 */
742
-		register_shutdown_function( array( $this, '__destruct' ) );
742
+		register_shutdown_function(array($this, '__destruct'));
743 743
 	}
744 744
 
745 745
 	/**
Please login to merge, or discard this patch.
Braces   +83 added lines, -56 removed lines patch added patch discarded remove patch
@@ -412,18 +412,22 @@  discard block
 block discarded – undo
412 412
 	 * @return bool False if cache key and group already exist, true on success
413 413
 	 */
414 414
 	public function add( $key, $data, $group = 'default', $expire = 0 ) {
415
-		if ( wp_suspend_cache_addition() )
416
-			return false;
415
+		if ( wp_suspend_cache_addition() ) {
416
+					return false;
417
+		}
417 418
 
418
-		if ( empty( $group ) )
419
-			$group = 'default';
419
+		if ( empty( $group ) ) {
420
+					$group = 'default';
421
+		}
420 422
 
421 423
 		$id = $key;
422
-		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
423
-			$id = $this->blog_prefix . $key;
424
+		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) {
425
+					$id = $this->blog_prefix . $key;
426
+		}
424 427
 
425
-		if ( $this->_exists( $id, $group ) )
426
-			return false;
428
+		if ( $this->_exists( $id, $group ) ) {
429
+					return false;
430
+		}
427 431
 
428 432
 		return $this->set( $key, $data, $group, (int) $expire );
429 433
 	}
@@ -455,24 +459,29 @@  discard block
 block discarded – undo
455 459
 	 * @return false|int False on failure, the item's new value on success.
456 460
 	 */
457 461
 	public function decr( $key, $offset = 1, $group = 'default' ) {
458
-		if ( empty( $group ) )
459
-			$group = 'default';
462
+		if ( empty( $group ) ) {
463
+					$group = 'default';
464
+		}
460 465
 
461
-		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
462
-			$key = $this->blog_prefix . $key;
466
+		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) {
467
+					$key = $this->blog_prefix . $key;
468
+		}
463 469
 
464
-		if ( ! $this->_exists( $key, $group ) )
465
-			return false;
470
+		if ( ! $this->_exists( $key, $group ) ) {
471
+					return false;
472
+		}
466 473
 
467
-		if ( ! is_numeric( $this->cache[ $group ][ $key ] ) )
468
-			$this->cache[ $group ][ $key ] = 0;
474
+		if ( ! is_numeric( $this->cache[ $group ][ $key ] ) ) {
475
+					$this->cache[ $group ][ $key ] = 0;
476
+		}
469 477
 
470 478
 		$offset = (int) $offset;
471 479
 
472 480
 		$this->cache[ $group ][ $key ] -= $offset;
473 481
 
474
-		if ( $this->cache[ $group ][ $key ] < 0 )
475
-			$this->cache[ $group ][ $key ] = 0;
482
+		if ( $this->cache[ $group ][ $key ] < 0 ) {
483
+					$this->cache[ $group ][ $key ] = 0;
484
+		}
476 485
 
477 486
 		return $this->cache[ $group ][ $key ];
478 487
 	}
@@ -491,14 +500,17 @@  discard block
 block discarded – undo
491 500
 	 * @return bool False if the contents weren't deleted and true on success.
492 501
 	 */
493 502
 	public function delete( $key, $group = 'default', $deprecated = false ) {
494
-		if ( empty( $group ) )
495
-			$group = 'default';
503
+		if ( empty( $group ) ) {
504
+					$group = 'default';
505
+		}
496 506
 
497
-		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
498
-			$key = $this->blog_prefix . $key;
507
+		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) {
508
+					$key = $this->blog_prefix . $key;
509
+		}
499 510
 
500
-		if ( ! $this->_exists( $key, $group ) )
501
-			return false;
511
+		if ( ! $this->_exists( $key, $group ) ) {
512
+					return false;
513
+		}
502 514
 
503 515
 		unset( $this->cache[$group][$key] );
504 516
 		return true;
@@ -539,19 +551,22 @@  discard block
 block discarded – undo
539 551
 	 * @return false|mixed False on failure to retrieve contents or the cache contents on success.
540 552
 	 */
541 553
 	public function get( $key, $group = 'default', $force = false, &$found = null ) {
542
-		if ( empty( $group ) )
543
-			$group = 'default';
554
+		if ( empty( $group ) ) {
555
+					$group = 'default';
556
+		}
544 557
 
545
-		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
546
-			$key = $this->blog_prefix . $key;
558
+		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) {
559
+					$key = $this->blog_prefix . $key;
560
+		}
547 561
 
548 562
 		if ( $this->_exists( $key, $group ) ) {
549 563
 			$found = true;
550 564
 			$this->cache_hits += 1;
551
-			if ( is_object($this->cache[$group][$key]) )
552
-				return clone $this->cache[$group][$key];
553
-			else
554
-				return $this->cache[$group][$key];
565
+			if ( is_object($this->cache[$group][$key]) ) {
566
+							return clone $this->cache[$group][$key];
567
+			} else {
568
+							return $this->cache[$group][$key];
569
+			}
555 570
 		}
556 571
 
557 572
 		$found = false;
@@ -571,24 +586,29 @@  discard block
 block discarded – undo
571 586
 	 * @return false|int False on failure, the item's new value on success.
572 587
 	 */
573 588
 	public function incr( $key, $offset = 1, $group = 'default' ) {
574
-		if ( empty( $group ) )
575
-			$group = 'default';
589
+		if ( empty( $group ) ) {
590
+					$group = 'default';
591
+		}
576 592
 
577
-		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
578
-			$key = $this->blog_prefix . $key;
593
+		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) {
594
+					$key = $this->blog_prefix . $key;
595
+		}
579 596
 
580
-		if ( ! $this->_exists( $key, $group ) )
581
-			return false;
597
+		if ( ! $this->_exists( $key, $group ) ) {
598
+					return false;
599
+		}
582 600
 
583
-		if ( ! is_numeric( $this->cache[ $group ][ $key ] ) )
584
-			$this->cache[ $group ][ $key ] = 0;
601
+		if ( ! is_numeric( $this->cache[ $group ][ $key ] ) ) {
602
+					$this->cache[ $group ][ $key ] = 0;
603
+		}
585 604
 
586 605
 		$offset = (int) $offset;
587 606
 
588 607
 		$this->cache[ $group ][ $key ] += $offset;
589 608
 
590
-		if ( $this->cache[ $group ][ $key ] < 0 )
591
-			$this->cache[ $group ][ $key ] = 0;
609
+		if ( $this->cache[ $group ][ $key ] < 0 ) {
610
+					$this->cache[ $group ][ $key ] = 0;
611
+		}
592 612
 
593 613
 		return $this->cache[ $group ][ $key ];
594 614
 	}
@@ -608,15 +628,18 @@  discard block
 block discarded – undo
608 628
 	 * @return bool False if not exists, true if contents were replaced.
609 629
 	 */
610 630
 	public function replace( $key, $data, $group = 'default', $expire = 0 ) {
611
-		if ( empty( $group ) )
612
-			$group = 'default';
631
+		if ( empty( $group ) ) {
632
+					$group = 'default';
633
+		}
613 634
 
614 635
 		$id = $key;
615
-		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
616
-			$id = $this->blog_prefix . $key;
636
+		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) {
637
+					$id = $this->blog_prefix . $key;
638
+		}
617 639
 
618
-		if ( ! $this->_exists( $id, $group ) )
619
-			return false;
640
+		if ( ! $this->_exists( $id, $group ) ) {
641
+					return false;
642
+		}
620 643
 
621 644
 		return $this->set( $key, $data, $group, (int) $expire );
622 645
 	}
@@ -635,8 +658,9 @@  discard block
 block discarded – undo
635 658
 
636 659
 		// Clear out non-global caches since the blog ID has changed.
637 660
 		foreach ( array_keys( $this->cache ) as $group ) {
638
-			if ( ! isset( $this->global_groups[ $group ] ) )
639
-				unset( $this->cache[ $group ] );
661
+			if ( ! isset( $this->global_groups[ $group ] ) ) {
662
+							unset( $this->cache[ $group ] );
663
+			}
640 664
 		}
641 665
 	}
642 666
 
@@ -662,14 +686,17 @@  discard block
 block discarded – undo
662 686
 	 * @return true Always returns true.
663 687
 	 */
664 688
 	public function set( $key, $data, $group = 'default', $expire = 0 ) {
665
-		if ( empty( $group ) )
666
-			$group = 'default';
689
+		if ( empty( $group ) ) {
690
+					$group = 'default';
691
+		}
667 692
 
668
-		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
669
-			$key = $this->blog_prefix . $key;
693
+		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) {
694
+					$key = $this->blog_prefix . $key;
695
+		}
670 696
 
671
-		if ( is_object( $data ) )
672
-			$data = clone $data;
697
+		if ( is_object( $data ) ) {
698
+					$data = clone $data;
699
+		}
673 700
 
674 701
 		$this->cache[$group][$key] = $data;
675 702
 		return true;
Please login to merge, or discard this patch.
src/wp-includes/capabilities.php 4 patches
Doc Comments   -9 removed lines patch added patch discarded remove patch
@@ -20,10 +20,6 @@  discard block
 block discarded – undo
20 20
  *
21 21
  * @param string $cap       Capability name.
22 22
  * @param int    $user_id   User ID.
23
- * @param int    $object_id Optional. ID of the specific object to check against if `$cap` is a "meta" cap.
24
- *                          "Meta" capabilities, e.g. 'edit_post', 'edit_user', etc., are capabilities used
25
- *                          by map_meta_cap() to map to other "primitive" capabilities, e.g. 'edit_posts',
26
- *                          'edit_others_posts', etc. The parameter is accessed via func_get_args().
27 23
  * @return array Actual capabilities for meta capability.
28 24
  */
29 25
 function map_meta_cap( $cap, $user_id ) {
@@ -416,11 +412,6 @@  discard block
 block discarded – undo
416 412
  * @see map_meta_cap()
417 413
  *
418 414
  * @param string $capability Capability name.
419
- * @param int    $object_id  Optional. ID of the specific object to check against if `$capability` is a "meta" cap.
420
- *                           "Meta" capabilities, e.g. 'edit_post', 'edit_user', etc., are capabilities used
421
- *                           by map_meta_cap() to map to other "primitive" capabilities, e.g. 'edit_posts',
422
- *                           'edit_others_posts', etc. Accessed via func_get_args() and passed to WP_User::has_cap(),
423
- *                           then map_meta_cap().
424 415
  * @return bool Whether the current user has the given capability. If `$capability` is a meta cap and `$object_id` is
425 416
  *              passed, whether the current user has the given meta capability for the given object.
426 417
  */
Please login to merge, or discard this patch.
Switch Indentation   +351 added lines, -351 removed lines patch added patch discarded remove patch
@@ -31,235 +31,235 @@  discard block
 block discarded – undo
31 31
 	$caps = array();
32 32
 
33 33
 	switch ( $cap ) {
34
-	case 'remove_user':
35
-		// In multisite the user must be a super admin to remove themselves.
36
-		if ( isset( $args[0] ) && $user_id == $args[0] && ! is_super_admin( $user_id ) ) {
37
-			$caps[] = 'do_not_allow';
38
-		} else {
39
-			$caps[] = 'remove_users';
40
-		}
41
-		break;
42
-	case 'promote_user':
43
-	case 'add_users':
44
-		$caps[] = 'promote_users';
45
-		break;
46
-	case 'edit_user':
47
-	case 'edit_users':
48
-		// Allow user to edit itself
49
-		if ( 'edit_user' == $cap && isset( $args[0] ) && $user_id == $args[0] )
34
+		case 'remove_user':
35
+			// In multisite the user must be a super admin to remove themselves.
36
+			if ( isset( $args[0] ) && $user_id == $args[0] && ! is_super_admin( $user_id ) ) {
37
+				$caps[] = 'do_not_allow';
38
+			} else {
39
+				$caps[] = 'remove_users';
40
+			}
50 41
 			break;
51
-
52
-		// In multisite the user must have manage_network_users caps. If editing a super admin, the user must be a super admin.
53
-		if ( is_multisite() && ( ( ! is_super_admin( $user_id ) && 'edit_user' === $cap && is_super_admin( $args[0] ) ) || ! user_can( $user_id, 'manage_network_users' ) ) ) {
54
-			$caps[] = 'do_not_allow';
55
-		} else {
56
-			$caps[] = 'edit_users'; // edit_user maps to edit_users.
57
-		}
58
-		break;
59
-	case 'delete_post':
60
-	case 'delete_page':
61
-		$post = get_post( $args[0] );
62
-		if ( ! $post ) {
63
-			$caps[] = 'do_not_allow';
42
+		case 'promote_user':
43
+		case 'add_users':
44
+			$caps[] = 'promote_users';
64 45
 			break;
65
-		}
46
+		case 'edit_user':
47
+		case 'edit_users':
48
+			// Allow user to edit itself
49
+			if ( 'edit_user' == $cap && isset( $args[0] ) && $user_id == $args[0] )
50
+				break;
66 51
 
67
-		if ( 'revision' == $post->post_type ) {
68
-			$post = get_post( $post->post_parent );
52
+			// In multisite the user must have manage_network_users caps. If editing a super admin, the user must be a super admin.
53
+			if ( is_multisite() && ( ( ! is_super_admin( $user_id ) && 'edit_user' === $cap && is_super_admin( $args[0] ) ) || ! user_can( $user_id, 'manage_network_users' ) ) ) {
54
+				$caps[] = 'do_not_allow';
55
+			} else {
56
+				$caps[] = 'edit_users'; // edit_user maps to edit_users.
57
+			}
58
+			break;
59
+		case 'delete_post':
60
+		case 'delete_page':
61
+			$post = get_post( $args[0] );
69 62
 			if ( ! $post ) {
70 63
 				$caps[] = 'do_not_allow';
71 64
 				break;
72 65
 			}
73
-		}
74 66
 
75
-		if ( ( get_option( 'page_for_posts' ) == $post->ID ) || ( get_option( 'page_on_front' ) == $post->ID ) ) {
76
-			$caps[] = 'manage_options';
77
-			break;
78
-		}
67
+			if ( 'revision' == $post->post_type ) {
68
+				$post = get_post( $post->post_parent );
69
+				if ( ! $post ) {
70
+					$caps[] = 'do_not_allow';
71
+					break;
72
+				}
73
+			}
79 74
 
80
-		$post_type = get_post_type_object( $post->post_type );
81
-		if ( ! $post_type ) {
82
-			/* translators: 1: post type, 2: capability name */
83
-			_doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' );
84
-			$caps[] = 'edit_others_posts';
85
-			break;
86
-		}
75
+			if ( ( get_option( 'page_for_posts' ) == $post->ID ) || ( get_option( 'page_on_front' ) == $post->ID ) ) {
76
+				$caps[] = 'manage_options';
77
+				break;
78
+			}
87 79
 
88
-		if ( ! $post_type->map_meta_cap ) {
89
-			$caps[] = $post_type->cap->$cap;
90
-			// Prior to 3.1 we would re-call map_meta_cap here.
91
-			if ( 'delete_post' == $cap )
92
-				$cap = $post_type->cap->$cap;
93
-			break;
94
-		}
80
+			$post_type = get_post_type_object( $post->post_type );
81
+			if ( ! $post_type ) {
82
+				/* translators: 1: post type, 2: capability name */
83
+				_doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' );
84
+				$caps[] = 'edit_others_posts';
85
+				break;
86
+			}
95 87
 
96
-		// If the post author is set and the user is the author...
97
-		if ( $post->post_author && $user_id == $post->post_author ) {
98
-			// If the post is published or scheduled...
99
-			if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
100
-				$caps[] = $post_type->cap->delete_published_posts;
101
-			} elseif ( 'trash' == $post->post_status ) {
102
-				$status = get_post_meta( $post->ID, '_wp_trash_meta_status', true );
103
-				if ( in_array( $status, array( 'publish', 'future' ), true ) ) {
88
+			if ( ! $post_type->map_meta_cap ) {
89
+				$caps[] = $post_type->cap->$cap;
90
+				// Prior to 3.1 we would re-call map_meta_cap here.
91
+				if ( 'delete_post' == $cap )
92
+					$cap = $post_type->cap->$cap;
93
+				break;
94
+			}
95
+
96
+			// If the post author is set and the user is the author...
97
+			if ( $post->post_author && $user_id == $post->post_author ) {
98
+				// If the post is published or scheduled...
99
+				if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
104 100
 					$caps[] = $post_type->cap->delete_published_posts;
101
+				} elseif ( 'trash' == $post->post_status ) {
102
+					$status = get_post_meta( $post->ID, '_wp_trash_meta_status', true );
103
+					if ( in_array( $status, array( 'publish', 'future' ), true ) ) {
104
+						$caps[] = $post_type->cap->delete_published_posts;
105
+					} else {
106
+						$caps[] = $post_type->cap->delete_posts;
107
+					}
105 108
 				} else {
109
+					// If the post is draft...
106 110
 					$caps[] = $post_type->cap->delete_posts;
107 111
 				}
108 112
 			} else {
109
-				// If the post is draft...
110
-				$caps[] = $post_type->cap->delete_posts;
111
-			}
112
-		} else {
113
-			// The user is trying to edit someone else's post.
114
-			$caps[] = $post_type->cap->delete_others_posts;
115
-			// The post is published or scheduled, extra cap required.
116
-			if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
117
-				$caps[] = $post_type->cap->delete_published_posts;
118
-			} elseif ( 'private' == $post->post_status ) {
119
-				$caps[] = $post_type->cap->delete_private_posts;
113
+				// The user is trying to edit someone else's post.
114
+				$caps[] = $post_type->cap->delete_others_posts;
115
+				// The post is published or scheduled, extra cap required.
116
+				if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
117
+					$caps[] = $post_type->cap->delete_published_posts;
118
+				} elseif ( 'private' == $post->post_status ) {
119
+					$caps[] = $post_type->cap->delete_private_posts;
120
+				}
120 121
 			}
121
-		}
122
-		break;
123
-		// edit_post breaks down to edit_posts, edit_published_posts, or
124
-		// edit_others_posts
125
-	case 'edit_post':
126
-	case 'edit_page':
127
-		$post = get_post( $args[0] );
128
-		if ( ! $post ) {
129
-			$caps[] = 'do_not_allow';
130 122
 			break;
131
-		}
132
-
133
-		if ( 'revision' == $post->post_type ) {
134
-			$post = get_post( $post->post_parent );
123
+			// edit_post breaks down to edit_posts, edit_published_posts, or
124
+			// edit_others_posts
125
+		case 'edit_post':
126
+		case 'edit_page':
127
+			$post = get_post( $args[0] );
135 128
 			if ( ! $post ) {
136 129
 				$caps[] = 'do_not_allow';
137 130
 				break;
138 131
 			}
139
-		}
140 132
 
141
-		$post_type = get_post_type_object( $post->post_type );
142
-		if ( ! $post_type ) {
143
-			/* translators: 1: post type, 2: capability name */
144
-			_doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' );
145
-			$caps[] = 'edit_others_posts';
146
-			break;
147
-		}
133
+			if ( 'revision' == $post->post_type ) {
134
+				$post = get_post( $post->post_parent );
135
+				if ( ! $post ) {
136
+					$caps[] = 'do_not_allow';
137
+					break;
138
+				}
139
+			}
148 140
 
149
-		if ( ! $post_type->map_meta_cap ) {
150
-			$caps[] = $post_type->cap->$cap;
151
-			// Prior to 3.1 we would re-call map_meta_cap here.
152
-			if ( 'edit_post' == $cap )
153
-				$cap = $post_type->cap->$cap;
154
-			break;
155
-		}
141
+			$post_type = get_post_type_object( $post->post_type );
142
+			if ( ! $post_type ) {
143
+				/* translators: 1: post type, 2: capability name */
144
+				_doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' );
145
+				$caps[] = 'edit_others_posts';
146
+				break;
147
+			}
156 148
 
157
-		// If the post author is set and the user is the author...
158
-		if ( $post->post_author && $user_id == $post->post_author ) {
159
-			// If the post is published or scheduled...
160
-			if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
161
-				$caps[] = $post_type->cap->edit_published_posts;
162
-			} elseif ( 'trash' == $post->post_status ) {
163
-				$status = get_post_meta( $post->ID, '_wp_trash_meta_status', true );
164
-				if ( in_array( $status, array( 'publish', 'future' ), true ) ) {
149
+			if ( ! $post_type->map_meta_cap ) {
150
+				$caps[] = $post_type->cap->$cap;
151
+				// Prior to 3.1 we would re-call map_meta_cap here.
152
+				if ( 'edit_post' == $cap )
153
+					$cap = $post_type->cap->$cap;
154
+				break;
155
+			}
156
+
157
+			// If the post author is set and the user is the author...
158
+			if ( $post->post_author && $user_id == $post->post_author ) {
159
+				// If the post is published or scheduled...
160
+				if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
165 161
 					$caps[] = $post_type->cap->edit_published_posts;
162
+				} elseif ( 'trash' == $post->post_status ) {
163
+					$status = get_post_meta( $post->ID, '_wp_trash_meta_status', true );
164
+					if ( in_array( $status, array( 'publish', 'future' ), true ) ) {
165
+						$caps[] = $post_type->cap->edit_published_posts;
166
+					} else {
167
+						$caps[] = $post_type->cap->edit_posts;
168
+					}
166 169
 				} else {
170
+					// If the post is draft...
167 171
 					$caps[] = $post_type->cap->edit_posts;
168 172
 				}
169 173
 			} else {
170
-				// If the post is draft...
171
-				$caps[] = $post_type->cap->edit_posts;
172
-			}
173
-		} else {
174
-			// The user is trying to edit someone else's post.
175
-			$caps[] = $post_type->cap->edit_others_posts;
176
-			// The post is published or scheduled, extra cap required.
177
-			if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
178
-				$caps[] = $post_type->cap->edit_published_posts;
179
-			} elseif ( 'private' == $post->post_status ) {
180
-				$caps[] = $post_type->cap->edit_private_posts;
174
+				// The user is trying to edit someone else's post.
175
+				$caps[] = $post_type->cap->edit_others_posts;
176
+				// The post is published or scheduled, extra cap required.
177
+				if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
178
+					$caps[] = $post_type->cap->edit_published_posts;
179
+				} elseif ( 'private' == $post->post_status ) {
180
+					$caps[] = $post_type->cap->edit_private_posts;
181
+				}
181 182
 			}
182
-		}
183
-		break;
184
-	case 'read_post':
185
-	case 'read_page':
186
-		$post = get_post( $args[0] );
187
-		if ( ! $post ) {
188
-			$caps[] = 'do_not_allow';
189 183
 			break;
190
-		}
191
-
192
-		if ( 'revision' == $post->post_type ) {
193
-			$post = get_post( $post->post_parent );
184
+		case 'read_post':
185
+		case 'read_page':
186
+			$post = get_post( $args[0] );
194 187
 			if ( ! $post ) {
195 188
 				$caps[] = 'do_not_allow';
196 189
 				break;
197 190
 			}
198
-		}
199 191
 
200
-		$post_type = get_post_type_object( $post->post_type );
201
-		if ( ! $post_type ) {
202
-			/* translators: 1: post type, 2: capability name */
203
-			_doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' );
204
-			$caps[] = 'edit_others_posts';
205
-			break;
206
-		}
192
+			if ( 'revision' == $post->post_type ) {
193
+				$post = get_post( $post->post_parent );
194
+				if ( ! $post ) {
195
+					$caps[] = 'do_not_allow';
196
+					break;
197
+				}
198
+			}
207 199
 
208
-		if ( ! $post_type->map_meta_cap ) {
209
-			$caps[] = $post_type->cap->$cap;
210
-			// Prior to 3.1 we would re-call map_meta_cap here.
211
-			if ( 'read_post' == $cap )
212
-				$cap = $post_type->cap->$cap;
213
-			break;
214
-		}
200
+			$post_type = get_post_type_object( $post->post_type );
201
+			if ( ! $post_type ) {
202
+				/* translators: 1: post type, 2: capability name */
203
+				_doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' );
204
+				$caps[] = 'edit_others_posts';
205
+				break;
206
+			}
215 207
 
216
-		$status_obj = get_post_status_object( $post->post_status );
217
-		if ( $status_obj->public ) {
218
-			$caps[] = $post_type->cap->read;
219
-			break;
220
-		}
208
+			if ( ! $post_type->map_meta_cap ) {
209
+				$caps[] = $post_type->cap->$cap;
210
+				// Prior to 3.1 we would re-call map_meta_cap here.
211
+				if ( 'read_post' == $cap )
212
+					$cap = $post_type->cap->$cap;
213
+				break;
214
+			}
221 215
 
222
-		if ( $post->post_author && $user_id == $post->post_author ) {
223
-			$caps[] = $post_type->cap->read;
224
-		} elseif ( $status_obj->private ) {
225
-			$caps[] = $post_type->cap->read_private_posts;
226
-		} else {
227
-			$caps = map_meta_cap( 'edit_post', $user_id, $post->ID );
228
-		}
229
-		break;
230
-	case 'publish_post':
231
-		$post = get_post( $args[0] );
232
-		if ( ! $post ) {
233
-			$caps[] = 'do_not_allow';
234
-			break;
235
-		}
216
+			$status_obj = get_post_status_object( $post->post_status );
217
+			if ( $status_obj->public ) {
218
+				$caps[] = $post_type->cap->read;
219
+				break;
220
+			}
236 221
 
237
-		$post_type = get_post_type_object( $post->post_type );
238
-		if ( ! $post_type ) {
239
-			/* translators: 1: post type, 2: capability name */
240
-			_doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' );
241
-			$caps[] = 'edit_others_posts';
222
+			if ( $post->post_author && $user_id == $post->post_author ) {
223
+				$caps[] = $post_type->cap->read;
224
+			} elseif ( $status_obj->private ) {
225
+				$caps[] = $post_type->cap->read_private_posts;
226
+			} else {
227
+				$caps = map_meta_cap( 'edit_post', $user_id, $post->ID );
228
+			}
242 229
 			break;
243
-		}
230
+		case 'publish_post':
231
+			$post = get_post( $args[0] );
232
+			if ( ! $post ) {
233
+				$caps[] = 'do_not_allow';
234
+				break;
235
+			}
244 236
 
245
-		$caps[] = $post_type->cap->publish_posts;
246
-		break;
247
-	case 'edit_post_meta':
248
-	case 'delete_post_meta':
249
-	case 'add_post_meta':
250
-	case 'edit_comment_meta':
251
-	case 'delete_comment_meta':
252
-	case 'add_comment_meta':
253
-	case 'edit_term_meta':
254
-	case 'delete_term_meta':
255
-	case 'add_term_meta':
256
-	case 'edit_user_meta':
257
-	case 'delete_user_meta':
258
-	case 'add_user_meta':
259
-		list( $_, $object_type, $_ ) = explode( '_', $cap );
260
-		$object_id = (int) $args[0];
261
-
262
-		switch ( $object_type ) {
237
+			$post_type = get_post_type_object( $post->post_type );
238
+			if ( ! $post_type ) {
239
+				/* translators: 1: post type, 2: capability name */
240
+				_doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' );
241
+				$caps[] = 'edit_others_posts';
242
+				break;
243
+			}
244
+
245
+			$caps[] = $post_type->cap->publish_posts;
246
+			break;
247
+		case 'edit_post_meta':
248
+		case 'delete_post_meta':
249
+		case 'add_post_meta':
250
+		case 'edit_comment_meta':
251
+		case 'delete_comment_meta':
252
+		case 'add_comment_meta':
253
+		case 'edit_term_meta':
254
+		case 'delete_term_meta':
255
+		case 'add_term_meta':
256
+		case 'edit_user_meta':
257
+		case 'delete_user_meta':
258
+		case 'add_user_meta':
259
+			list( $_, $object_type, $_ ) = explode( '_', $cap );
260
+			$object_id = (int) $args[0];
261
+
262
+			switch ( $object_type ) {
263 263
 			case 'post':
264 264
 				$post = get_post( $object_id );
265 265
 				if ( ! $post ) {
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 
296 296
 				$sub_type = 'user';
297 297
 				break;
298
-		}
298
+			}
299 299
 
300 300
 		if ( empty( $sub_type ) ) {
301 301
 			$caps[] = 'do_not_allow';
@@ -321,183 +321,183 @@  discard block
 block discarded – undo
321 321
 			$caps[] = $cap;
322 322
 		}
323 323
 		break;
324
-	case 'edit_comment':
325
-		$comment = get_comment( $args[0] );
326
-		if ( ! $comment ) {
327
-			$caps[] = 'do_not_allow';
328
-			break;
329
-		}
324
+		case 'edit_comment':
325
+			$comment = get_comment( $args[0] );
326
+			if ( ! $comment ) {
327
+				$caps[] = 'do_not_allow';
328
+				break;
329
+			}
330 330
 
331
-		$post = get_post( $comment->comment_post_ID );
331
+			$post = get_post( $comment->comment_post_ID );
332 332
 
333
-		/*
333
+			/*
334 334
 		 * If the post doesn't exist, we have an orphaned comment.
335 335
 		 * Fall back to the edit_posts capability, instead.
336 336
 		 */
337
-		if ( $post ) {
338
-			$caps = map_meta_cap( 'edit_post', $user_id, $post->ID );
339
-		} else {
340
-			$caps = map_meta_cap( 'edit_posts', $user_id );
341
-		}
342
-		break;
343
-	case 'unfiltered_upload':
344
-		if ( defined('ALLOW_UNFILTERED_UPLOADS') && ALLOW_UNFILTERED_UPLOADS && ( !is_multisite() || is_super_admin( $user_id ) )  )
345
-			$caps[] = $cap;
346
-		else
347
-			$caps[] = 'do_not_allow';
348
-		break;
349
-	case 'edit_css' :
350
-	case 'unfiltered_html' :
351
-		// Disallow unfiltered_html for all users, even admins and super admins.
352
-		if ( defined( 'DISALLOW_UNFILTERED_HTML' ) && DISALLOW_UNFILTERED_HTML )
353
-			$caps[] = 'do_not_allow';
354
-		elseif ( is_multisite() && ! is_super_admin( $user_id ) )
355
-			$caps[] = 'do_not_allow';
356
-		else
357
-			$caps[] = 'unfiltered_html';
358
-		break;
359
-	case 'edit_files':
360
-	case 'edit_plugins':
361
-	case 'edit_themes':
362
-		// Disallow the file editors.
363
-		if ( defined( 'DISALLOW_FILE_EDIT' ) && DISALLOW_FILE_EDIT )
364
-			$caps[] = 'do_not_allow';
365
-		elseif ( ! wp_is_file_mod_allowed( 'capability_edit_themes' ) )
366
-			$caps[] = 'do_not_allow';
367
-		elseif ( is_multisite() && ! is_super_admin( $user_id ) )
368
-			$caps[] = 'do_not_allow';
369
-		else
370
-			$caps[] = $cap;
371
-		break;
372
-	case 'update_plugins':
373
-	case 'delete_plugins':
374
-	case 'install_plugins':
375
-	case 'upload_plugins':
376
-	case 'update_themes':
377
-	case 'delete_themes':
378
-	case 'install_themes':
379
-	case 'upload_themes':
380
-	case 'update_core':
381
-		// Disallow anything that creates, deletes, or updates core, plugin, or theme files.
382
-		// Files in uploads are excepted.
383
-		if ( ! wp_is_file_mod_allowed( 'capability_update_core' ) ) {
384
-			$caps[] = 'do_not_allow';
385
-		} elseif ( is_multisite() && ! is_super_admin( $user_id ) ) {
386
-			$caps[] = 'do_not_allow';
387
-		} elseif ( 'upload_themes' === $cap ) {
388
-			$caps[] = 'install_themes';
389
-		} elseif ( 'upload_plugins' === $cap ) {
390
-			$caps[] = 'install_plugins';
391
-		} else {
392
-			$caps[] = $cap;
393
-		}
394
-		break;
395
-	case 'activate_plugins':
396
-		$caps[] = $cap;
397
-		if ( is_multisite() ) {
398
-			// update_, install_, and delete_ are handled above with is_super_admin().
399
-			$menu_perms = get_site_option( 'menu_items', array() );
400
-			if ( empty( $menu_perms['plugins'] ) )
401
-				$caps[] = 'manage_network_plugins';
402
-		}
403
-		break;
404
-	case 'delete_user':
405
-	case 'delete_users':
406
-		// If multisite only super admins can delete users.
407
-		if ( is_multisite() && ! is_super_admin( $user_id ) )
408
-			$caps[] = 'do_not_allow';
409
-		else
410
-			$caps[] = 'delete_users'; // delete_user maps to delete_users.
411
-		break;
412
-	case 'create_users':
413
-		if ( !is_multisite() )
414
-			$caps[] = $cap;
415
-		elseif ( is_super_admin( $user_id ) || get_site_option( 'add_new_users' ) )
416
-			$caps[] = $cap;
417
-		else
418
-			$caps[] = 'do_not_allow';
419
-		break;
420
-	case 'manage_links' :
421
-		if ( get_option( 'link_manager_enabled' ) )
337
+			if ( $post ) {
338
+				$caps = map_meta_cap( 'edit_post', $user_id, $post->ID );
339
+			} else {
340
+				$caps = map_meta_cap( 'edit_posts', $user_id );
341
+			}
342
+			break;
343
+		case 'unfiltered_upload':
344
+			if ( defined('ALLOW_UNFILTERED_UPLOADS') && ALLOW_UNFILTERED_UPLOADS && ( !is_multisite() || is_super_admin( $user_id ) )  )
345
+				$caps[] = $cap;
346
+			else
347
+				$caps[] = 'do_not_allow';
348
+			break;
349
+		case 'edit_css' :
350
+		case 'unfiltered_html' :
351
+			// Disallow unfiltered_html for all users, even admins and super admins.
352
+			if ( defined( 'DISALLOW_UNFILTERED_HTML' ) && DISALLOW_UNFILTERED_HTML )
353
+				$caps[] = 'do_not_allow';
354
+			elseif ( is_multisite() && ! is_super_admin( $user_id ) )
355
+				$caps[] = 'do_not_allow';
356
+			else
357
+				$caps[] = 'unfiltered_html';
358
+			break;
359
+		case 'edit_files':
360
+		case 'edit_plugins':
361
+		case 'edit_themes':
362
+			// Disallow the file editors.
363
+			if ( defined( 'DISALLOW_FILE_EDIT' ) && DISALLOW_FILE_EDIT )
364
+				$caps[] = 'do_not_allow';
365
+			elseif ( ! wp_is_file_mod_allowed( 'capability_edit_themes' ) )
366
+				$caps[] = 'do_not_allow';
367
+			elseif ( is_multisite() && ! is_super_admin( $user_id ) )
368
+				$caps[] = 'do_not_allow';
369
+			else
370
+				$caps[] = $cap;
371
+			break;
372
+		case 'update_plugins':
373
+		case 'delete_plugins':
374
+		case 'install_plugins':
375
+		case 'upload_plugins':
376
+		case 'update_themes':
377
+		case 'delete_themes':
378
+		case 'install_themes':
379
+		case 'upload_themes':
380
+		case 'update_core':
381
+			// Disallow anything that creates, deletes, or updates core, plugin, or theme files.
382
+			// Files in uploads are excepted.
383
+			if ( ! wp_is_file_mod_allowed( 'capability_update_core' ) ) {
384
+				$caps[] = 'do_not_allow';
385
+			} elseif ( is_multisite() && ! is_super_admin( $user_id ) ) {
386
+				$caps[] = 'do_not_allow';
387
+			} elseif ( 'upload_themes' === $cap ) {
388
+				$caps[] = 'install_themes';
389
+			} elseif ( 'upload_plugins' === $cap ) {
390
+				$caps[] = 'install_plugins';
391
+			} else {
392
+				$caps[] = $cap;
393
+			}
394
+			break;
395
+		case 'activate_plugins':
422 396
 			$caps[] = $cap;
423
-		else
424
-			$caps[] = 'do_not_allow';
425
-		break;
426
-	case 'customize' :
427
-		$caps[] = 'edit_theme_options';
428
-		break;
429
-	case 'delete_site':
430
-		if ( is_multisite() ) {
431
-			$caps[] = 'manage_options';
432
-		} else {
433
-			$caps[] = 'do_not_allow';
434
-		}
435
-		break;
436
-	case 'edit_term':
437
-	case 'delete_term':
438
-	case 'assign_term':
439
-		$term_id = (int) $args[0];
440
-		$term = get_term( $term_id );
441
-		if ( ! $term || is_wp_error( $term ) ) {
442
-			$caps[] = 'do_not_allow';
397
+			if ( is_multisite() ) {
398
+				// update_, install_, and delete_ are handled above with is_super_admin().
399
+				$menu_perms = get_site_option( 'menu_items', array() );
400
+				if ( empty( $menu_perms['plugins'] ) )
401
+					$caps[] = 'manage_network_plugins';
402
+			}
443 403
 			break;
444
-		}
445
-
446
-		$tax = get_taxonomy( $term->taxonomy );
447
-		if ( ! $tax ) {
448
-			$caps[] = 'do_not_allow';
404
+		case 'delete_user':
405
+		case 'delete_users':
406
+			// If multisite only super admins can delete users.
407
+			if ( is_multisite() && ! is_super_admin( $user_id ) )
408
+				$caps[] = 'do_not_allow';
409
+			else
410
+				$caps[] = 'delete_users'; // delete_user maps to delete_users.
449 411
 			break;
450
-		}
451
-
452
-		if ( 'delete_term' === $cap && ( $term->term_id == get_option( 'default_' . $term->taxonomy ) ) ) {
453
-			$caps[] = 'do_not_allow';
412
+		case 'create_users':
413
+			if ( !is_multisite() )
414
+				$caps[] = $cap;
415
+			elseif ( is_super_admin( $user_id ) || get_site_option( 'add_new_users' ) )
416
+				$caps[] = $cap;
417
+			else
418
+				$caps[] = 'do_not_allow';
454 419
 			break;
455
-		}
420
+		case 'manage_links' :
421
+			if ( get_option( 'link_manager_enabled' ) )
422
+				$caps[] = $cap;
423
+			else
424
+				$caps[] = 'do_not_allow';
425
+			break;
426
+		case 'customize' :
427
+			$caps[] = 'edit_theme_options';
428
+			break;
429
+		case 'delete_site':
430
+			if ( is_multisite() ) {
431
+				$caps[] = 'manage_options';
432
+			} else {
433
+				$caps[] = 'do_not_allow';
434
+			}
435
+			break;
436
+		case 'edit_term':
437
+		case 'delete_term':
438
+		case 'assign_term':
439
+			$term_id = (int) $args[0];
440
+			$term = get_term( $term_id );
441
+			if ( ! $term || is_wp_error( $term ) ) {
442
+				$caps[] = 'do_not_allow';
443
+				break;
444
+			}
456 445
 
457
-		$taxo_cap = $cap . 's';
446
+			$tax = get_taxonomy( $term->taxonomy );
447
+			if ( ! $tax ) {
448
+				$caps[] = 'do_not_allow';
449
+				break;
450
+			}
458 451
 
459
-		$caps = map_meta_cap( $tax->cap->$taxo_cap, $user_id, $term_id );
452
+			if ( 'delete_term' === $cap && ( $term->term_id == get_option( 'default_' . $term->taxonomy ) ) ) {
453
+				$caps[] = 'do_not_allow';
454
+				break;
455
+			}
460 456
 
461
-		break;
462
-	case 'manage_post_tags':
463
-	case 'edit_categories':
464
-	case 'edit_post_tags':
465
-	case 'delete_categories':
466
-	case 'delete_post_tags':
467
-		$caps[] = 'manage_categories';
468
-		break;
469
-	case 'assign_categories':
470
-	case 'assign_post_tags':
471
-		$caps[] = 'edit_posts';
472
-		break;
473
-	case 'create_sites':
474
-	case 'delete_sites':
475
-	case 'manage_network':
476
-	case 'manage_sites':
477
-	case 'manage_network_users':
478
-	case 'manage_network_plugins':
479
-	case 'manage_network_themes':
480
-	case 'manage_network_options':
481
-	case 'upgrade_network':
482
-		$caps[] = $cap;
483
-		break;
484
-	case 'setup_network':
485
-		if ( is_multisite() ) {
486
-			$caps[] = 'manage_network_options';
487
-		} else {
488
-			$caps[] = 'manage_options';
489
-		}
490
-		break;
491
-	default:
492
-		// Handle meta capabilities for custom post types.
493
-		global $post_type_meta_caps;
494
-		if ( isset( $post_type_meta_caps[ $cap ] ) ) {
495
-			$args = array_merge( array( $post_type_meta_caps[ $cap ], $user_id ), $args );
496
-			return call_user_func_array( 'map_meta_cap', $args );
497
-		}
457
+			$taxo_cap = $cap . 's';
498 458
 
499
-		// If no meta caps match, return the original cap.
500
-		$caps[] = $cap;
459
+			$caps = map_meta_cap( $tax->cap->$taxo_cap, $user_id, $term_id );
460
+
461
+			break;
462
+		case 'manage_post_tags':
463
+		case 'edit_categories':
464
+		case 'edit_post_tags':
465
+		case 'delete_categories':
466
+		case 'delete_post_tags':
467
+			$caps[] = 'manage_categories';
468
+			break;
469
+		case 'assign_categories':
470
+		case 'assign_post_tags':
471
+			$caps[] = 'edit_posts';
472
+			break;
473
+		case 'create_sites':
474
+		case 'delete_sites':
475
+		case 'manage_network':
476
+		case 'manage_sites':
477
+		case 'manage_network_users':
478
+		case 'manage_network_plugins':
479
+		case 'manage_network_themes':
480
+		case 'manage_network_options':
481
+		case 'upgrade_network':
482
+			$caps[] = $cap;
483
+			break;
484
+		case 'setup_network':
485
+			if ( is_multisite() ) {
486
+				$caps[] = 'manage_network_options';
487
+			} else {
488
+				$caps[] = 'manage_options';
489
+			}
490
+			break;
491
+		default:
492
+			// Handle meta capabilities for custom post types.
493
+			global $post_type_meta_caps;
494
+			if ( isset( $post_type_meta_caps[ $cap ] ) ) {
495
+				$args = array_merge( array( $post_type_meta_caps[ $cap ], $user_id ), $args );
496
+				return call_user_func_array( 'map_meta_cap', $args );
497
+			}
498
+
499
+			// If no meta caps match, return the original cap.
500
+			$caps[] = $cap;
501 501
 	}
502 502
 
503 503
 	/**
Please login to merge, or discard this patch.
Spacing   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -26,14 +26,14 @@  discard block
 block discarded – undo
26 26
  *                          'edit_others_posts', etc. The parameter is accessed via func_get_args().
27 27
  * @return array Actual capabilities for meta capability.
28 28
  */
29
-function map_meta_cap( $cap, $user_id ) {
30
-	$args = array_slice( func_get_args(), 2 );
29
+function map_meta_cap($cap, $user_id) {
30
+	$args = array_slice(func_get_args(), 2);
31 31
 	$caps = array();
32 32
 
33
-	switch ( $cap ) {
33
+	switch ($cap) {
34 34
 	case 'remove_user':
35 35
 		// In multisite the user must be a super admin to remove themselves.
36
-		if ( isset( $args[0] ) && $user_id == $args[0] && ! is_super_admin( $user_id ) ) {
36
+		if (isset($args[0]) && $user_id == $args[0] && ! is_super_admin($user_id)) {
37 37
 			$caps[] = 'do_not_allow';
38 38
 		} else {
39 39
 			$caps[] = 'remove_users';
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
 	case 'edit_user':
47 47
 	case 'edit_users':
48 48
 		// Allow user to edit itself
49
-		if ( 'edit_user' == $cap && isset( $args[0] ) && $user_id == $args[0] )
49
+		if ('edit_user' == $cap && isset($args[0]) && $user_id == $args[0])
50 50
 			break;
51 51
 
52 52
 		// In multisite the user must have manage_network_users caps. If editing a super admin, the user must be a super admin.
53
-		if ( is_multisite() && ( ( ! is_super_admin( $user_id ) && 'edit_user' === $cap && is_super_admin( $args[0] ) ) || ! user_can( $user_id, 'manage_network_users' ) ) ) {
53
+		if (is_multisite() && (( ! is_super_admin($user_id) && 'edit_user' === $cap && is_super_admin($args[0])) || ! user_can($user_id, 'manage_network_users'))) {
54 54
 			$caps[] = 'do_not_allow';
55 55
 		} else {
56 56
 			$caps[] = 'edit_users'; // edit_user maps to edit_users.
@@ -58,49 +58,49 @@  discard block
 block discarded – undo
58 58
 		break;
59 59
 	case 'delete_post':
60 60
 	case 'delete_page':
61
-		$post = get_post( $args[0] );
62
-		if ( ! $post ) {
61
+		$post = get_post($args[0]);
62
+		if ( ! $post) {
63 63
 			$caps[] = 'do_not_allow';
64 64
 			break;
65 65
 		}
66 66
 
67
-		if ( 'revision' == $post->post_type ) {
68
-			$post = get_post( $post->post_parent );
69
-			if ( ! $post ) {
67
+		if ('revision' == $post->post_type) {
68
+			$post = get_post($post->post_parent);
69
+			if ( ! $post) {
70 70
 				$caps[] = 'do_not_allow';
71 71
 				break;
72 72
 			}
73 73
 		}
74 74
 
75
-		if ( ( get_option( 'page_for_posts' ) == $post->ID ) || ( get_option( 'page_on_front' ) == $post->ID ) ) {
75
+		if ((get_option('page_for_posts') == $post->ID) || (get_option('page_on_front') == $post->ID)) {
76 76
 			$caps[] = 'manage_options';
77 77
 			break;
78 78
 		}
79 79
 
80
-		$post_type = get_post_type_object( $post->post_type );
81
-		if ( ! $post_type ) {
80
+		$post_type = get_post_type_object($post->post_type);
81
+		if ( ! $post_type) {
82 82
 			/* translators: 1: post type, 2: capability name */
83
-			_doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' );
83
+			_doing_it_wrong(__FUNCTION__, sprintf(__('The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.'), $post->post_type, $cap), '4.4.0');
84 84
 			$caps[] = 'edit_others_posts';
85 85
 			break;
86 86
 		}
87 87
 
88
-		if ( ! $post_type->map_meta_cap ) {
88
+		if ( ! $post_type->map_meta_cap) {
89 89
 			$caps[] = $post_type->cap->$cap;
90 90
 			// Prior to 3.1 we would re-call map_meta_cap here.
91
-			if ( 'delete_post' == $cap )
91
+			if ('delete_post' == $cap)
92 92
 				$cap = $post_type->cap->$cap;
93 93
 			break;
94 94
 		}
95 95
 
96 96
 		// If the post author is set and the user is the author...
97
-		if ( $post->post_author && $user_id == $post->post_author ) {
97
+		if ($post->post_author && $user_id == $post->post_author) {
98 98
 			// If the post is published or scheduled...
99
-			if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
99
+			if (in_array($post->post_status, array('publish', 'future'), true)) {
100 100
 				$caps[] = $post_type->cap->delete_published_posts;
101
-			} elseif ( 'trash' == $post->post_status ) {
102
-				$status = get_post_meta( $post->ID, '_wp_trash_meta_status', true );
103
-				if ( in_array( $status, array( 'publish', 'future' ), true ) ) {
101
+			} elseif ('trash' == $post->post_status) {
102
+				$status = get_post_meta($post->ID, '_wp_trash_meta_status', true);
103
+				if (in_array($status, array('publish', 'future'), true)) {
104 104
 					$caps[] = $post_type->cap->delete_published_posts;
105 105
 				} else {
106 106
 					$caps[] = $post_type->cap->delete_posts;
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 			// The user is trying to edit someone else's post.
114 114
 			$caps[] = $post_type->cap->delete_others_posts;
115 115
 			// The post is published or scheduled, extra cap required.
116
-			if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
116
+			if (in_array($post->post_status, array('publish', 'future'), true)) {
117 117
 				$caps[] = $post_type->cap->delete_published_posts;
118
-			} elseif ( 'private' == $post->post_status ) {
118
+			} elseif ('private' == $post->post_status) {
119 119
 				$caps[] = $post_type->cap->delete_private_posts;
120 120
 			}
121 121
 		}
@@ -124,44 +124,44 @@  discard block
 block discarded – undo
124 124
 		// edit_others_posts
125 125
 	case 'edit_post':
126 126
 	case 'edit_page':
127
-		$post = get_post( $args[0] );
128
-		if ( ! $post ) {
127
+		$post = get_post($args[0]);
128
+		if ( ! $post) {
129 129
 			$caps[] = 'do_not_allow';
130 130
 			break;
131 131
 		}
132 132
 
133
-		if ( 'revision' == $post->post_type ) {
134
-			$post = get_post( $post->post_parent );
135
-			if ( ! $post ) {
133
+		if ('revision' == $post->post_type) {
134
+			$post = get_post($post->post_parent);
135
+			if ( ! $post) {
136 136
 				$caps[] = 'do_not_allow';
137 137
 				break;
138 138
 			}
139 139
 		}
140 140
 
141
-		$post_type = get_post_type_object( $post->post_type );
142
-		if ( ! $post_type ) {
141
+		$post_type = get_post_type_object($post->post_type);
142
+		if ( ! $post_type) {
143 143
 			/* translators: 1: post type, 2: capability name */
144
-			_doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' );
144
+			_doing_it_wrong(__FUNCTION__, sprintf(__('The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.'), $post->post_type, $cap), '4.4.0');
145 145
 			$caps[] = 'edit_others_posts';
146 146
 			break;
147 147
 		}
148 148
 
149
-		if ( ! $post_type->map_meta_cap ) {
149
+		if ( ! $post_type->map_meta_cap) {
150 150
 			$caps[] = $post_type->cap->$cap;
151 151
 			// Prior to 3.1 we would re-call map_meta_cap here.
152
-			if ( 'edit_post' == $cap )
152
+			if ('edit_post' == $cap)
153 153
 				$cap = $post_type->cap->$cap;
154 154
 			break;
155 155
 		}
156 156
 
157 157
 		// If the post author is set and the user is the author...
158
-		if ( $post->post_author && $user_id == $post->post_author ) {
158
+		if ($post->post_author && $user_id == $post->post_author) {
159 159
 			// If the post is published or scheduled...
160
-			if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
160
+			if (in_array($post->post_status, array('publish', 'future'), true)) {
161 161
 				$caps[] = $post_type->cap->edit_published_posts;
162
-			} elseif ( 'trash' == $post->post_status ) {
163
-				$status = get_post_meta( $post->ID, '_wp_trash_meta_status', true );
164
-				if ( in_array( $status, array( 'publish', 'future' ), true ) ) {
162
+			} elseif ('trash' == $post->post_status) {
163
+				$status = get_post_meta($post->ID, '_wp_trash_meta_status', true);
164
+				if (in_array($status, array('publish', 'future'), true)) {
165 165
 					$caps[] = $post_type->cap->edit_published_posts;
166 166
 				} else {
167 167
 					$caps[] = $post_type->cap->edit_posts;
@@ -174,70 +174,70 @@  discard block
 block discarded – undo
174 174
 			// The user is trying to edit someone else's post.
175 175
 			$caps[] = $post_type->cap->edit_others_posts;
176 176
 			// The post is published or scheduled, extra cap required.
177
-			if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
177
+			if (in_array($post->post_status, array('publish', 'future'), true)) {
178 178
 				$caps[] = $post_type->cap->edit_published_posts;
179
-			} elseif ( 'private' == $post->post_status ) {
179
+			} elseif ('private' == $post->post_status) {
180 180
 				$caps[] = $post_type->cap->edit_private_posts;
181 181
 			}
182 182
 		}
183 183
 		break;
184 184
 	case 'read_post':
185 185
 	case 'read_page':
186
-		$post = get_post( $args[0] );
187
-		if ( ! $post ) {
186
+		$post = get_post($args[0]);
187
+		if ( ! $post) {
188 188
 			$caps[] = 'do_not_allow';
189 189
 			break;
190 190
 		}
191 191
 
192
-		if ( 'revision' == $post->post_type ) {
193
-			$post = get_post( $post->post_parent );
194
-			if ( ! $post ) {
192
+		if ('revision' == $post->post_type) {
193
+			$post = get_post($post->post_parent);
194
+			if ( ! $post) {
195 195
 				$caps[] = 'do_not_allow';
196 196
 				break;
197 197
 			}
198 198
 		}
199 199
 
200
-		$post_type = get_post_type_object( $post->post_type );
201
-		if ( ! $post_type ) {
200
+		$post_type = get_post_type_object($post->post_type);
201
+		if ( ! $post_type) {
202 202
 			/* translators: 1: post type, 2: capability name */
203
-			_doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' );
203
+			_doing_it_wrong(__FUNCTION__, sprintf(__('The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.'), $post->post_type, $cap), '4.4.0');
204 204
 			$caps[] = 'edit_others_posts';
205 205
 			break;
206 206
 		}
207 207
 
208
-		if ( ! $post_type->map_meta_cap ) {
208
+		if ( ! $post_type->map_meta_cap) {
209 209
 			$caps[] = $post_type->cap->$cap;
210 210
 			// Prior to 3.1 we would re-call map_meta_cap here.
211
-			if ( 'read_post' == $cap )
211
+			if ('read_post' == $cap)
212 212
 				$cap = $post_type->cap->$cap;
213 213
 			break;
214 214
 		}
215 215
 
216
-		$status_obj = get_post_status_object( $post->post_status );
217
-		if ( $status_obj->public ) {
216
+		$status_obj = get_post_status_object($post->post_status);
217
+		if ($status_obj->public) {
218 218
 			$caps[] = $post_type->cap->read;
219 219
 			break;
220 220
 		}
221 221
 
222
-		if ( $post->post_author && $user_id == $post->post_author ) {
222
+		if ($post->post_author && $user_id == $post->post_author) {
223 223
 			$caps[] = $post_type->cap->read;
224
-		} elseif ( $status_obj->private ) {
224
+		} elseif ($status_obj->private) {
225 225
 			$caps[] = $post_type->cap->read_private_posts;
226 226
 		} else {
227
-			$caps = map_meta_cap( 'edit_post', $user_id, $post->ID );
227
+			$caps = map_meta_cap('edit_post', $user_id, $post->ID);
228 228
 		}
229 229
 		break;
230 230
 	case 'publish_post':
231
-		$post = get_post( $args[0] );
232
-		if ( ! $post ) {
231
+		$post = get_post($args[0]);
232
+		if ( ! $post) {
233 233
 			$caps[] = 'do_not_allow';
234 234
 			break;
235 235
 		}
236 236
 
237
-		$post_type = get_post_type_object( $post->post_type );
238
-		if ( ! $post_type ) {
237
+		$post_type = get_post_type_object($post->post_type);
238
+		if ( ! $post_type) {
239 239
 			/* translators: 1: post type, 2: capability name */
240
-			_doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' );
240
+			_doing_it_wrong(__FUNCTION__, sprintf(__('The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.'), $post->post_type, $cap), '4.4.0');
241 241
 			$caps[] = 'edit_others_posts';
242 242
 			break;
243 243
 		}
@@ -256,31 +256,31 @@  discard block
 block discarded – undo
256 256
 	case 'edit_user_meta':
257 257
 	case 'delete_user_meta':
258 258
 	case 'add_user_meta':
259
-		list( $_, $object_type, $_ ) = explode( '_', $cap );
259
+		list($_, $object_type, $_) = explode('_', $cap);
260 260
 		$object_id = (int) $args[0];
261 261
 
262
-		switch ( $object_type ) {
262
+		switch ($object_type) {
263 263
 			case 'post':
264
-				$post = get_post( $object_id );
265
-				if ( ! $post ) {
264
+				$post = get_post($object_id);
265
+				if ( ! $post) {
266 266
 					break;
267 267
 				}
268 268
 
269
-				$sub_type = get_post_type( $post );
269
+				$sub_type = get_post_type($post);
270 270
 				break;
271 271
 
272 272
 			case 'comment':
273
-				$comment = get_comment( $object_id );
274
-				if ( ! $comment ) {
273
+				$comment = get_comment($object_id);
274
+				if ( ! $comment) {
275 275
 					break;
276 276
 				}
277 277
 
278
-				$sub_type = empty( $comment->comment_type ) ? 'comment' : $comment->comment_type;
278
+				$sub_type = empty($comment->comment_type) ? 'comment' : $comment->comment_type;
279 279
 				break;
280 280
 
281 281
 			case 'term':
282
-				$term = get_term( $object_id );
283
-				if ( ! $term ) {
282
+				$term = get_term($object_id);
283
+				if ( ! $term) {
284 284
 					break;
285 285
 				}
286 286
 
@@ -288,8 +288,8 @@  discard block
 block discarded – undo
288 288
 				break;
289 289
 
290 290
 			case 'user':
291
-				$user = get_user_by( 'id', $object_id );
292
-				if ( ! $user ) {
291
+				$user = get_user_by('id', $object_id);
292
+				if ( ! $user) {
293 293
 					break;
294 294
 				}
295 295
 
@@ -297,51 +297,51 @@  discard block
 block discarded – undo
297 297
 				break;
298 298
 		}
299 299
 
300
-		if ( empty( $sub_type ) ) {
300
+		if (empty($sub_type)) {
301 301
 			$caps[] = 'do_not_allow';
302 302
 			break;
303 303
 		}
304 304
 
305
-		$caps = map_meta_cap( "edit_{$object_type}", $user_id, $object_id );
305
+		$caps = map_meta_cap("edit_{$object_type}", $user_id, $object_id);
306 306
 
307
-		$meta_key = isset( $args[1] ) ? $args[1] : false;
307
+		$meta_key = isset($args[1]) ? $args[1] : false;
308 308
 
309
-		$has_filter = has_filter( "auth_{$object_type}_meta_{$meta_key}" ) || has_filter( "auth_{$object_type}_{$sub_type}_meta_{$meta_key}" );
310
-		if ( $meta_key && $has_filter ) {
309
+		$has_filter = has_filter("auth_{$object_type}_meta_{$meta_key}") || has_filter("auth_{$object_type}_{$sub_type}_meta_{$meta_key}");
310
+		if ($meta_key && $has_filter) {
311 311
 			/** This filter is documented in wp-includes/meta.php */
312
-			$allowed = apply_filters( "auth_{$object_type}_meta_{$meta_key}", false, $meta_key, $object_id, $user_id, $cap, $caps );
312
+			$allowed = apply_filters("auth_{$object_type}_meta_{$meta_key}", false, $meta_key, $object_id, $user_id, $cap, $caps);
313 313
 
314 314
 			/** This filter is documented in wp-includes/meta.php */
315
-			$allowed = apply_filters( "auth_{$object_type}_{$sub_type}_meta_{$meta_key}", $allowed, $meta_key, $object_id, $user_id, $cap, $caps );
315
+			$allowed = apply_filters("auth_{$object_type}_{$sub_type}_meta_{$meta_key}", $allowed, $meta_key, $object_id, $user_id, $cap, $caps);
316 316
 
317
-			if ( ! $allowed ) {
317
+			if ( ! $allowed) {
318 318
 				$caps[] = $cap;
319 319
 			}
320
-		} elseif ( $meta_key && is_protected_meta( $meta_key, $object_type ) ) {
320
+		} elseif ($meta_key && is_protected_meta($meta_key, $object_type)) {
321 321
 			$caps[] = $cap;
322 322
 		}
323 323
 		break;
324 324
 	case 'edit_comment':
325
-		$comment = get_comment( $args[0] );
326
-		if ( ! $comment ) {
325
+		$comment = get_comment($args[0]);
326
+		if ( ! $comment) {
327 327
 			$caps[] = 'do_not_allow';
328 328
 			break;
329 329
 		}
330 330
 
331
-		$post = get_post( $comment->comment_post_ID );
331
+		$post = get_post($comment->comment_post_ID);
332 332
 
333 333
 		/*
334 334
 		 * If the post doesn't exist, we have an orphaned comment.
335 335
 		 * Fall back to the edit_posts capability, instead.
336 336
 		 */
337
-		if ( $post ) {
338
-			$caps = map_meta_cap( 'edit_post', $user_id, $post->ID );
337
+		if ($post) {
338
+			$caps = map_meta_cap('edit_post', $user_id, $post->ID);
339 339
 		} else {
340
-			$caps = map_meta_cap( 'edit_posts', $user_id );
340
+			$caps = map_meta_cap('edit_posts', $user_id);
341 341
 		}
342 342
 		break;
343 343
 	case 'unfiltered_upload':
344
-		if ( defined('ALLOW_UNFILTERED_UPLOADS') && ALLOW_UNFILTERED_UPLOADS && ( !is_multisite() || is_super_admin( $user_id ) )  )
344
+		if (defined('ALLOW_UNFILTERED_UPLOADS') && ALLOW_UNFILTERED_UPLOADS && ( ! is_multisite() || is_super_admin($user_id)))
345 345
 			$caps[] = $cap;
346 346
 		else
347 347
 			$caps[] = 'do_not_allow';
@@ -349,9 +349,9 @@  discard block
 block discarded – undo
349 349
 	case 'edit_css' :
350 350
 	case 'unfiltered_html' :
351 351
 		// Disallow unfiltered_html for all users, even admins and super admins.
352
-		if ( defined( 'DISALLOW_UNFILTERED_HTML' ) && DISALLOW_UNFILTERED_HTML )
352
+		if (defined('DISALLOW_UNFILTERED_HTML') && DISALLOW_UNFILTERED_HTML)
353 353
 			$caps[] = 'do_not_allow';
354
-		elseif ( is_multisite() && ! is_super_admin( $user_id ) )
354
+		elseif (is_multisite() && ! is_super_admin($user_id))
355 355
 			$caps[] = 'do_not_allow';
356 356
 		else
357 357
 			$caps[] = 'unfiltered_html';
@@ -360,11 +360,11 @@  discard block
 block discarded – undo
360 360
 	case 'edit_plugins':
361 361
 	case 'edit_themes':
362 362
 		// Disallow the file editors.
363
-		if ( defined( 'DISALLOW_FILE_EDIT' ) && DISALLOW_FILE_EDIT )
363
+		if (defined('DISALLOW_FILE_EDIT') && DISALLOW_FILE_EDIT)
364 364
 			$caps[] = 'do_not_allow';
365
-		elseif ( ! wp_is_file_mod_allowed( 'capability_edit_themes' ) )
365
+		elseif ( ! wp_is_file_mod_allowed('capability_edit_themes'))
366 366
 			$caps[] = 'do_not_allow';
367
-		elseif ( is_multisite() && ! is_super_admin( $user_id ) )
367
+		elseif (is_multisite() && ! is_super_admin($user_id))
368 368
 			$caps[] = 'do_not_allow';
369 369
 		else
370 370
 			$caps[] = $cap;
@@ -380,13 +380,13 @@  discard block
 block discarded – undo
380 380
 	case 'update_core':
381 381
 		// Disallow anything that creates, deletes, or updates core, plugin, or theme files.
382 382
 		// Files in uploads are excepted.
383
-		if ( ! wp_is_file_mod_allowed( 'capability_update_core' ) ) {
383
+		if ( ! wp_is_file_mod_allowed('capability_update_core')) {
384 384
 			$caps[] = 'do_not_allow';
385
-		} elseif ( is_multisite() && ! is_super_admin( $user_id ) ) {
385
+		} elseif (is_multisite() && ! is_super_admin($user_id)) {
386 386
 			$caps[] = 'do_not_allow';
387
-		} elseif ( 'upload_themes' === $cap ) {
387
+		} elseif ('upload_themes' === $cap) {
388 388
 			$caps[] = 'install_themes';
389
-		} elseif ( 'upload_plugins' === $cap ) {
389
+		} elseif ('upload_plugins' === $cap) {
390 390
 			$caps[] = 'install_plugins';
391 391
 		} else {
392 392
 			$caps[] = $cap;
@@ -394,31 +394,31 @@  discard block
 block discarded – undo
394 394
 		break;
395 395
 	case 'activate_plugins':
396 396
 		$caps[] = $cap;
397
-		if ( is_multisite() ) {
397
+		if (is_multisite()) {
398 398
 			// update_, install_, and delete_ are handled above with is_super_admin().
399
-			$menu_perms = get_site_option( 'menu_items', array() );
400
-			if ( empty( $menu_perms['plugins'] ) )
399
+			$menu_perms = get_site_option('menu_items', array());
400
+			if (empty($menu_perms['plugins']))
401 401
 				$caps[] = 'manage_network_plugins';
402 402
 		}
403 403
 		break;
404 404
 	case 'delete_user':
405 405
 	case 'delete_users':
406 406
 		// If multisite only super admins can delete users.
407
-		if ( is_multisite() && ! is_super_admin( $user_id ) )
407
+		if (is_multisite() && ! is_super_admin($user_id))
408 408
 			$caps[] = 'do_not_allow';
409 409
 		else
410 410
 			$caps[] = 'delete_users'; // delete_user maps to delete_users.
411 411
 		break;
412 412
 	case 'create_users':
413
-		if ( !is_multisite() )
413
+		if ( ! is_multisite())
414 414
 			$caps[] = $cap;
415
-		elseif ( is_super_admin( $user_id ) || get_site_option( 'add_new_users' ) )
415
+		elseif (is_super_admin($user_id) || get_site_option('add_new_users'))
416 416
 			$caps[] = $cap;
417 417
 		else
418 418
 			$caps[] = 'do_not_allow';
419 419
 		break;
420 420
 	case 'manage_links' :
421
-		if ( get_option( 'link_manager_enabled' ) )
421
+		if (get_option('link_manager_enabled'))
422 422
 			$caps[] = $cap;
423 423
 		else
424 424
 			$caps[] = 'do_not_allow';
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 		$caps[] = 'edit_theme_options';
428 428
 		break;
429 429
 	case 'delete_site':
430
-		if ( is_multisite() ) {
430
+		if (is_multisite()) {
431 431
 			$caps[] = 'manage_options';
432 432
 		} else {
433 433
 			$caps[] = 'do_not_allow';
@@ -437,26 +437,26 @@  discard block
 block discarded – undo
437 437
 	case 'delete_term':
438 438
 	case 'assign_term':
439 439
 		$term_id = (int) $args[0];
440
-		$term = get_term( $term_id );
441
-		if ( ! $term || is_wp_error( $term ) ) {
440
+		$term = get_term($term_id);
441
+		if ( ! $term || is_wp_error($term)) {
442 442
 			$caps[] = 'do_not_allow';
443 443
 			break;
444 444
 		}
445 445
 
446
-		$tax = get_taxonomy( $term->taxonomy );
447
-		if ( ! $tax ) {
446
+		$tax = get_taxonomy($term->taxonomy);
447
+		if ( ! $tax) {
448 448
 			$caps[] = 'do_not_allow';
449 449
 			break;
450 450
 		}
451 451
 
452
-		if ( 'delete_term' === $cap && ( $term->term_id == get_option( 'default_' . $term->taxonomy ) ) ) {
452
+		if ('delete_term' === $cap && ($term->term_id == get_option('default_'.$term->taxonomy))) {
453 453
 			$caps[] = 'do_not_allow';
454 454
 			break;
455 455
 		}
456 456
 
457
-		$taxo_cap = $cap . 's';
457
+		$taxo_cap = $cap.'s';
458 458
 
459
-		$caps = map_meta_cap( $tax->cap->$taxo_cap, $user_id, $term_id );
459
+		$caps = map_meta_cap($tax->cap->$taxo_cap, $user_id, $term_id);
460 460
 
461 461
 		break;
462 462
 	case 'manage_post_tags':
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
 		$caps[] = $cap;
483 483
 		break;
484 484
 	case 'setup_network':
485
-		if ( is_multisite() ) {
485
+		if (is_multisite()) {
486 486
 			$caps[] = 'manage_network_options';
487 487
 		} else {
488 488
 			$caps[] = 'manage_options';
@@ -491,9 +491,9 @@  discard block
 block discarded – undo
491 491
 	default:
492 492
 		// Handle meta capabilities for custom post types.
493 493
 		global $post_type_meta_caps;
494
-		if ( isset( $post_type_meta_caps[ $cap ] ) ) {
495
-			$args = array_merge( array( $post_type_meta_caps[ $cap ], $user_id ), $args );
496
-			return call_user_func_array( 'map_meta_cap', $args );
494
+		if (isset($post_type_meta_caps[$cap])) {
495
+			$args = array_merge(array($post_type_meta_caps[$cap], $user_id), $args);
496
+			return call_user_func_array('map_meta_cap', $args);
497 497
 		}
498 498
 
499 499
 		// If no meta caps match, return the original cap.
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 	 * @param int    $user_id The user ID.
511 511
 	 * @param array  $args    Adds the context to the cap. Typically the object ID.
512 512
 	 */
513
-	return apply_filters( 'map_meta_cap', $caps, $cap, $user_id, $args );
513
+	return apply_filters('map_meta_cap', $caps, $cap, $user_id, $args);
514 514
 }
515 515
 
516 516
 /**
@@ -535,16 +535,16 @@  discard block
 block discarded – undo
535 535
  * @return bool Whether the current user has the given capability. If `$capability` is a meta cap and `$object_id` is
536 536
  *              passed, whether the current user has the given meta capability for the given object.
537 537
  */
538
-function current_user_can( $capability ) {
538
+function current_user_can($capability) {
539 539
 	$current_user = wp_get_current_user();
540 540
 
541
-	if ( empty( $current_user ) )
541
+	if (empty($current_user))
542 542
 		return false;
543 543
 
544
-	$args = array_slice( func_get_args(), 1 );
545
-	$args = array_merge( array( $capability ), $args );
544
+	$args = array_slice(func_get_args(), 1);
545
+	$args = array_merge(array($capability), $args);
546 546
 
547
-	return call_user_func_array( array( $current_user, 'has_cap' ), $args );
547
+	return call_user_func_array(array($current_user, 'has_cap'), $args);
548 548
 }
549 549
 
550 550
 /**
@@ -556,24 +556,24 @@  discard block
 block discarded – undo
556 556
  * @param string $capability Capability or role name.
557 557
  * @return bool
558 558
  */
559
-function current_user_can_for_blog( $blog_id, $capability ) {
560
-	$switched = is_multisite() ? switch_to_blog( $blog_id ) : false;
559
+function current_user_can_for_blog($blog_id, $capability) {
560
+	$switched = is_multisite() ? switch_to_blog($blog_id) : false;
561 561
 
562 562
 	$current_user = wp_get_current_user();
563 563
 
564
-	if ( empty( $current_user ) ) {
565
-		if ( $switched ) {
564
+	if (empty($current_user)) {
565
+		if ($switched) {
566 566
 			restore_current_blog();
567 567
 		}
568 568
 		return false;
569 569
 	}
570 570
 
571
-	$args = array_slice( func_get_args(), 2 );
572
-	$args = array_merge( array( $capability ), $args );
571
+	$args = array_slice(func_get_args(), 2);
572
+	$args = array_merge(array($capability), $args);
573 573
 
574
-	$can = call_user_func_array( array( $current_user, 'has_cap' ), $args );
574
+	$can = call_user_func_array(array($current_user, 'has_cap'), $args);
575 575
 
576
-	if ( $switched ) {
576
+	if ($switched) {
577 577
 		restore_current_blog();
578 578
 	}
579 579
 
@@ -589,19 +589,19 @@  discard block
 block discarded – undo
589 589
  * @param string $capability Capability or role name.
590 590
  * @return bool
591 591
  */
592
-function author_can( $post, $capability ) {
593
-	if ( !$post = get_post($post) )
592
+function author_can($post, $capability) {
593
+	if ( ! $post = get_post($post))
594 594
 		return false;
595 595
 
596
-	$author = get_userdata( $post->post_author );
596
+	$author = get_userdata($post->post_author);
597 597
 
598
-	if ( ! $author )
598
+	if ( ! $author)
599 599
 		return false;
600 600
 
601
-	$args = array_slice( func_get_args(), 2 );
602
-	$args = array_merge( array( $capability ), $args );
601
+	$args = array_slice(func_get_args(), 2);
602
+	$args = array_merge(array($capability), $args);
603 603
 
604
-	return call_user_func_array( array( $author, 'has_cap' ), $args );
604
+	return call_user_func_array(array($author, 'has_cap'), $args);
605 605
 }
606 606
 
607 607
 /**
@@ -613,17 +613,17 @@  discard block
 block discarded – undo
613 613
  * @param string $capability Capability or role name.
614 614
  * @return bool
615 615
  */
616
-function user_can( $user, $capability ) {
617
-	if ( ! is_object( $user ) )
618
-		$user = get_userdata( $user );
616
+function user_can($user, $capability) {
617
+	if ( ! is_object($user))
618
+		$user = get_userdata($user);
619 619
 
620
-	if ( ! $user || ! $user->exists() )
620
+	if ( ! $user || ! $user->exists())
621 621
 		return false;
622 622
 
623
-	$args = array_slice( func_get_args(), 2 );
624
-	$args = array_merge( array( $capability ), $args );
623
+	$args = array_slice(func_get_args(), 2);
624
+	$args = array_merge(array($capability), $args);
625 625
 
626
-	return call_user_func_array( array( $user, 'has_cap' ), $args );
626
+	return call_user_func_array(array($user, 'has_cap'), $args);
627 627
 }
628 628
 
629 629
 /**
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
 function wp_roles() {
639 639
 	global $wp_roles;
640 640
 
641
-	if ( ! isset( $wp_roles ) ) {
641
+	if ( ! isset($wp_roles)) {
642 642
 		$wp_roles = new WP_Roles();
643 643
 	}
644 644
 	return $wp_roles;
@@ -652,8 +652,8 @@  discard block
 block discarded – undo
652 652
  * @param string $role Role name.
653 653
  * @return WP_Role|null WP_Role object if found, null if the role does not exist.
654 654
  */
655
-function get_role( $role ) {
656
-	return wp_roles()->get_role( $role );
655
+function get_role($role) {
656
+	return wp_roles()->get_role($role);
657 657
 }
658 658
 
659 659
 /**
@@ -666,11 +666,11 @@  discard block
 block discarded – undo
666 666
  * @param array $capabilities List of capabilities, e.g. array( 'edit_posts' => true, 'delete_posts' => false );
667 667
  * @return WP_Role|null WP_Role object if role is added, null if already exists.
668 668
  */
669
-function add_role( $role, $display_name, $capabilities = array() ) {
670
-	if ( empty( $role ) ) {
669
+function add_role($role, $display_name, $capabilities = array()) {
670
+	if (empty($role)) {
671 671
 		return;
672 672
 	}
673
-	return wp_roles()->add_role( $role, $display_name, $capabilities );
673
+	return wp_roles()->add_role($role, $display_name, $capabilities);
674 674
 }
675 675
 
676 676
 /**
@@ -680,8 +680,8 @@  discard block
 block discarded – undo
680 680
  *
681 681
  * @param string $role Role name.
682 682
  */
683
-function remove_role( $role ) {
684
-	wp_roles()->remove_role( $role );
683
+function remove_role($role) {
684
+	wp_roles()->remove_role($role);
685 685
 }
686 686
 
687 687
 /**
@@ -696,10 +696,10 @@  discard block
 block discarded – undo
696 696
 function get_super_admins() {
697 697
 	global $super_admins;
698 698
 
699
-	if ( isset($super_admins) )
699
+	if (isset($super_admins))
700 700
 		return $super_admins;
701 701
 	else
702
-		return get_site_option( 'site_admins', array('admin') );
702
+		return get_site_option('site_admins', array('admin'));
703 703
 }
704 704
 
705 705
 /**
@@ -710,21 +710,21 @@  discard block
 block discarded – undo
710 710
  * @param int $user_id (Optional) The ID of a user. Defaults to the current user.
711 711
  * @return bool True if the user is a site admin.
712 712
  */
713
-function is_super_admin( $user_id = false ) {
714
-	if ( ! $user_id || $user_id == get_current_user_id() )
713
+function is_super_admin($user_id = false) {
714
+	if ( ! $user_id || $user_id == get_current_user_id())
715 715
 		$user = wp_get_current_user();
716 716
 	else
717
-		$user = get_userdata( $user_id );
717
+		$user = get_userdata($user_id);
718 718
 
719
-	if ( ! $user || ! $user->exists() )
719
+	if ( ! $user || ! $user->exists())
720 720
 		return false;
721 721
 
722
-	if ( is_multisite() ) {
722
+	if (is_multisite()) {
723 723
 		$super_admins = get_super_admins();
724
-		if ( is_array( $super_admins ) && in_array( $user->user_login, $super_admins ) )
724
+		if (is_array($super_admins) && in_array($user->user_login, $super_admins))
725 725
 			return true;
726 726
 	} else {
727
-		if ( $user->has_cap('delete_users') )
727
+		if ($user->has_cap('delete_users'))
728 728
 			return true;
729 729
 	}
730 730
 
@@ -742,9 +742,9 @@  discard block
 block discarded – undo
742 742
  * @return bool True on success, false on failure. This can fail when the user is
743 743
  *              already a super admin or when the `$super_admins` global is defined.
744 744
  */
745
-function grant_super_admin( $user_id ) {
745
+function grant_super_admin($user_id) {
746 746
 	// If global super_admins override is defined, there is nothing to do here.
747
-	if ( isset( $GLOBALS['super_admins'] ) || ! is_multisite() ) {
747
+	if (isset($GLOBALS['super_admins']) || ! is_multisite()) {
748 748
 		return false;
749 749
 	}
750 750
 
@@ -755,15 +755,15 @@  discard block
 block discarded – undo
755 755
 	 *
756 756
 	 * @param int $user_id ID of the user that is about to be granted Super Admin privileges.
757 757
 	 */
758
-	do_action( 'grant_super_admin', $user_id );
758
+	do_action('grant_super_admin', $user_id);
759 759
 
760 760
 	// Directly fetch site_admins instead of using get_super_admins()
761
-	$super_admins = get_site_option( 'site_admins', array( 'admin' ) );
761
+	$super_admins = get_site_option('site_admins', array('admin'));
762 762
 
763
-	$user = get_userdata( $user_id );
764
-	if ( $user && ! in_array( $user->user_login, $super_admins ) ) {
763
+	$user = get_userdata($user_id);
764
+	if ($user && ! in_array($user->user_login, $super_admins)) {
765 765
 		$super_admins[] = $user->user_login;
766
-		update_site_option( 'site_admins' , $super_admins );
766
+		update_site_option('site_admins', $super_admins);
767 767
 
768 768
 		/**
769 769
 		 * Fires after the user is granted Super Admin privileges.
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
 		 *
773 773
 		 * @param int $user_id ID of the user that was granted Super Admin privileges.
774 774
 		 */
775
-		do_action( 'granted_super_admin', $user_id );
775
+		do_action('granted_super_admin', $user_id);
776 776
 		return true;
777 777
 	}
778 778
 	return false;
@@ -789,9 +789,9 @@  discard block
 block discarded – undo
789 789
  * @return bool True on success, false on failure. This can fail when the user's email
790 790
  *              is the network admin email or when the `$super_admins` global is defined.
791 791
  */
792
-function revoke_super_admin( $user_id ) {
792
+function revoke_super_admin($user_id) {
793 793
 	// If global super_admins override is defined, there is nothing to do here.
794
-	if ( isset( $GLOBALS['super_admins'] ) || ! is_multisite() ) {
794
+	if (isset($GLOBALS['super_admins']) || ! is_multisite()) {
795 795
 		return false;
796 796
 	}
797 797
 
@@ -802,16 +802,16 @@  discard block
 block discarded – undo
802 802
 	 *
803 803
 	 * @param int $user_id ID of the user Super Admin privileges are being revoked from.
804 804
 	 */
805
-	do_action( 'revoke_super_admin', $user_id );
805
+	do_action('revoke_super_admin', $user_id);
806 806
 
807 807
 	// Directly fetch site_admins instead of using get_super_admins()
808
-	$super_admins = get_site_option( 'site_admins', array( 'admin' ) );
808
+	$super_admins = get_site_option('site_admins', array('admin'));
809 809
 
810
-	$user = get_userdata( $user_id );
811
-	if ( $user && 0 !== strcasecmp( $user->user_email, get_site_option( 'admin_email' ) ) ) {
812
-		if ( false !== ( $key = array_search( $user->user_login, $super_admins ) ) ) {
813
-			unset( $super_admins[$key] );
814
-			update_site_option( 'site_admins', $super_admins );
810
+	$user = get_userdata($user_id);
811
+	if ($user && 0 !== strcasecmp($user->user_email, get_site_option('admin_email'))) {
812
+		if (false !== ($key = array_search($user->user_login, $super_admins))) {
813
+			unset($super_admins[$key]);
814
+			update_site_option('site_admins', $super_admins);
815 815
 
816 816
 			/**
817 817
 			 * Fires after the user's Super Admin privileges are revoked.
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
 			 *
821 821
 			 * @param int $user_id ID of the user Super Admin privileges were revoked from.
822 822
 			 */
823
-			do_action( 'revoked_super_admin', $user_id );
823
+			do_action('revoked_super_admin', $user_id);
824 824
 			return true;
825 825
 		}
826 826
 	}
Please login to merge, or discard this patch.
Braces   +89 added lines, -67 removed lines patch added patch discarded remove patch
@@ -46,8 +46,9 @@  discard block
 block discarded – undo
46 46
 	case 'edit_user':
47 47
 	case 'edit_users':
48 48
 		// Allow user to edit itself
49
-		if ( 'edit_user' == $cap && isset( $args[0] ) && $user_id == $args[0] )
50
-			break;
49
+		if ( 'edit_user' == $cap && isset( $args[0] ) && $user_id == $args[0] ) {
50
+					break;
51
+		}
51 52
 
52 53
 		// In multisite the user must have manage_network_users caps. If editing a super admin, the user must be a super admin.
53 54
 		if ( is_multisite() && ( ( ! is_super_admin( $user_id ) && 'edit_user' === $cap && is_super_admin( $args[0] ) ) || ! user_can( $user_id, 'manage_network_users' ) ) ) {
@@ -88,8 +89,9 @@  discard block
 block discarded – undo
88 89
 		if ( ! $post_type->map_meta_cap ) {
89 90
 			$caps[] = $post_type->cap->$cap;
90 91
 			// Prior to 3.1 we would re-call map_meta_cap here.
91
-			if ( 'delete_post' == $cap )
92
-				$cap = $post_type->cap->$cap;
92
+			if ( 'delete_post' == $cap ) {
93
+							$cap = $post_type->cap->$cap;
94
+			}
93 95
 			break;
94 96
 		}
95 97
 
@@ -149,8 +151,9 @@  discard block
 block discarded – undo
149 151
 		if ( ! $post_type->map_meta_cap ) {
150 152
 			$caps[] = $post_type->cap->$cap;
151 153
 			// Prior to 3.1 we would re-call map_meta_cap here.
152
-			if ( 'edit_post' == $cap )
153
-				$cap = $post_type->cap->$cap;
154
+			if ( 'edit_post' == $cap ) {
155
+							$cap = $post_type->cap->$cap;
156
+			}
154 157
 			break;
155 158
 		}
156 159
 
@@ -208,8 +211,9 @@  discard block
 block discarded – undo
208 211
 		if ( ! $post_type->map_meta_cap ) {
209 212
 			$caps[] = $post_type->cap->$cap;
210 213
 			// Prior to 3.1 we would re-call map_meta_cap here.
211
-			if ( 'read_post' == $cap )
212
-				$cap = $post_type->cap->$cap;
214
+			if ( 'read_post' == $cap ) {
215
+							$cap = $post_type->cap->$cap;
216
+			}
213 217
 			break;
214 218
 		}
215 219
 
@@ -341,33 +345,36 @@  discard block
 block discarded – undo
341 345
 		}
342 346
 		break;
343 347
 	case 'unfiltered_upload':
344
-		if ( defined('ALLOW_UNFILTERED_UPLOADS') && ALLOW_UNFILTERED_UPLOADS && ( !is_multisite() || is_super_admin( $user_id ) )  )
345
-			$caps[] = $cap;
346
-		else
347
-			$caps[] = 'do_not_allow';
348
+		if ( defined('ALLOW_UNFILTERED_UPLOADS') && ALLOW_UNFILTERED_UPLOADS && ( !is_multisite() || is_super_admin( $user_id ) )  ) {
349
+					$caps[] = $cap;
350
+		} else {
351
+					$caps[] = 'do_not_allow';
352
+		}
348 353
 		break;
349 354
 	case 'edit_css' :
350 355
 	case 'unfiltered_html' :
351 356
 		// Disallow unfiltered_html for all users, even admins and super admins.
352
-		if ( defined( 'DISALLOW_UNFILTERED_HTML' ) && DISALLOW_UNFILTERED_HTML )
353
-			$caps[] = 'do_not_allow';
354
-		elseif ( is_multisite() && ! is_super_admin( $user_id ) )
355
-			$caps[] = 'do_not_allow';
356
-		else
357
-			$caps[] = 'unfiltered_html';
357
+		if ( defined( 'DISALLOW_UNFILTERED_HTML' ) && DISALLOW_UNFILTERED_HTML ) {
358
+					$caps[] = 'do_not_allow';
359
+		} elseif ( is_multisite() && ! is_super_admin( $user_id ) ) {
360
+					$caps[] = 'do_not_allow';
361
+		} else {
362
+					$caps[] = 'unfiltered_html';
363
+		}
358 364
 		break;
359 365
 	case 'edit_files':
360 366
 	case 'edit_plugins':
361 367
 	case 'edit_themes':
362 368
 		// Disallow the file editors.
363
-		if ( defined( 'DISALLOW_FILE_EDIT' ) && DISALLOW_FILE_EDIT )
364
-			$caps[] = 'do_not_allow';
365
-		elseif ( ! wp_is_file_mod_allowed( 'capability_edit_themes' ) )
366
-			$caps[] = 'do_not_allow';
367
-		elseif ( is_multisite() && ! is_super_admin( $user_id ) )
368
-			$caps[] = 'do_not_allow';
369
-		else
370
-			$caps[] = $cap;
369
+		if ( defined( 'DISALLOW_FILE_EDIT' ) && DISALLOW_FILE_EDIT ) {
370
+					$caps[] = 'do_not_allow';
371
+		} elseif ( ! wp_is_file_mod_allowed( 'capability_edit_themes' ) ) {
372
+					$caps[] = 'do_not_allow';
373
+		} elseif ( is_multisite() && ! is_super_admin( $user_id ) ) {
374
+					$caps[] = 'do_not_allow';
375
+		} else {
376
+					$caps[] = $cap;
377
+		}
371 378
 		break;
372 379
 	case 'update_plugins':
373 380
 	case 'delete_plugins':
@@ -397,31 +404,36 @@  discard block
 block discarded – undo
397 404
 		if ( is_multisite() ) {
398 405
 			// update_, install_, and delete_ are handled above with is_super_admin().
399 406
 			$menu_perms = get_site_option( 'menu_items', array() );
400
-			if ( empty( $menu_perms['plugins'] ) )
401
-				$caps[] = 'manage_network_plugins';
407
+			if ( empty( $menu_perms['plugins'] ) ) {
408
+							$caps[] = 'manage_network_plugins';
409
+			}
402 410
 		}
403 411
 		break;
404 412
 	case 'delete_user':
405 413
 	case 'delete_users':
406 414
 		// If multisite only super admins can delete users.
407
-		if ( is_multisite() && ! is_super_admin( $user_id ) )
408
-			$caps[] = 'do_not_allow';
409
-		else
410
-			$caps[] = 'delete_users'; // delete_user maps to delete_users.
415
+		if ( is_multisite() && ! is_super_admin( $user_id ) ) {
416
+					$caps[] = 'do_not_allow';
417
+		} else {
418
+					$caps[] = 'delete_users';
419
+		}
420
+		// delete_user maps to delete_users.
411 421
 		break;
412 422
 	case 'create_users':
413
-		if ( !is_multisite() )
414
-			$caps[] = $cap;
415
-		elseif ( is_super_admin( $user_id ) || get_site_option( 'add_new_users' ) )
416
-			$caps[] = $cap;
417
-		else
418
-			$caps[] = 'do_not_allow';
423
+		if ( !is_multisite() ) {
424
+					$caps[] = $cap;
425
+		} elseif ( is_super_admin( $user_id ) || get_site_option( 'add_new_users' ) ) {
426
+					$caps[] = $cap;
427
+		} else {
428
+					$caps[] = 'do_not_allow';
429
+		}
419 430
 		break;
420 431
 	case 'manage_links' :
421
-		if ( get_option( 'link_manager_enabled' ) )
422
-			$caps[] = $cap;
423
-		else
424
-			$caps[] = 'do_not_allow';
432
+		if ( get_option( 'link_manager_enabled' ) ) {
433
+					$caps[] = $cap;
434
+		} else {
435
+					$caps[] = 'do_not_allow';
436
+		}
425 437
 		break;
426 438
 	case 'customize' :
427 439
 		$caps[] = 'edit_theme_options';
@@ -538,8 +550,9 @@  discard block
 block discarded – undo
538 550
 function current_user_can( $capability ) {
539 551
 	$current_user = wp_get_current_user();
540 552
 
541
-	if ( empty( $current_user ) )
542
-		return false;
553
+	if ( empty( $current_user ) ) {
554
+			return false;
555
+	}
543 556
 
544 557
 	$args = array_slice( func_get_args(), 1 );
545 558
 	$args = array_merge( array( $capability ), $args );
@@ -590,13 +603,15 @@  discard block
 block discarded – undo
590 603
  * @return bool
591 604
  */
592 605
 function author_can( $post, $capability ) {
593
-	if ( !$post = get_post($post) )
594
-		return false;
606
+	if ( !$post = get_post($post) ) {
607
+			return false;
608
+	}
595 609
 
596 610
 	$author = get_userdata( $post->post_author );
597 611
 
598
-	if ( ! $author )
599
-		return false;
612
+	if ( ! $author ) {
613
+			return false;
614
+	}
600 615
 
601 616
 	$args = array_slice( func_get_args(), 2 );
602 617
 	$args = array_merge( array( $capability ), $args );
@@ -614,11 +629,13 @@  discard block
 block discarded – undo
614 629
  * @return bool
615 630
  */
616 631
 function user_can( $user, $capability ) {
617
-	if ( ! is_object( $user ) )
618
-		$user = get_userdata( $user );
632
+	if ( ! is_object( $user ) ) {
633
+			$user = get_userdata( $user );
634
+	}
619 635
 
620
-	if ( ! $user || ! $user->exists() )
621
-		return false;
636
+	if ( ! $user || ! $user->exists() ) {
637
+			return false;
638
+	}
622 639
 
623 640
 	$args = array_slice( func_get_args(), 2 );
624 641
 	$args = array_merge( array( $capability ), $args );
@@ -696,11 +713,12 @@  discard block
 block discarded – undo
696 713
 function get_super_admins() {
697 714
 	global $super_admins;
698 715
 
699
-	if ( isset($super_admins) )
700
-		return $super_admins;
701
-	else
702
-		return get_site_option( 'site_admins', array('admin') );
703
-}
716
+	if ( isset($super_admins) ) {
717
+			return $super_admins;
718
+	} else {
719
+			return get_site_option( 'site_admins', array('admin') );
720
+	}
721
+	}
704 722
 
705 723
 /**
706 724
  * Determine if user is a site admin.
@@ -711,21 +729,25 @@  discard block
 block discarded – undo
711 729
  * @return bool True if the user is a site admin.
712 730
  */
713 731
 function is_super_admin( $user_id = false ) {
714
-	if ( ! $user_id || $user_id == get_current_user_id() )
715
-		$user = wp_get_current_user();
716
-	else
717
-		$user = get_userdata( $user_id );
732
+	if ( ! $user_id || $user_id == get_current_user_id() ) {
733
+			$user = wp_get_current_user();
734
+	} else {
735
+			$user = get_userdata( $user_id );
736
+	}
718 737
 
719
-	if ( ! $user || ! $user->exists() )
720
-		return false;
738
+	if ( ! $user || ! $user->exists() ) {
739
+			return false;
740
+	}
721 741
 
722 742
 	if ( is_multisite() ) {
723 743
 		$super_admins = get_super_admins();
724
-		if ( is_array( $super_admins ) && in_array( $user->user_login, $super_admins ) )
725
-			return true;
744
+		if ( is_array( $super_admins ) && in_array( $user->user_login, $super_admins ) ) {
745
+					return true;
746
+		}
726 747
 	} else {
727
-		if ( $user->has_cap('delete_users') )
728
-			return true;
748
+		if ( $user->has_cap('delete_users') ) {
749
+					return true;
750
+		}
729 751
 	}
730 752
 
731 753
 	return false;
Please login to merge, or discard this patch.
src/wp-includes/class-http.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 	 * @since 2.7.0
523 523
 	 *
524 524
 	 * @param string $strResponse The full response string
525
-	 * @return array Array with 'headers' and 'body' keys.
525
+	 * @return string Array with 'headers' and 'body' keys.
526 526
 	 */
527 527
 	public static function processResponse($strResponse) {
528 528
 		$res = explode("\r\n\r\n", $strResponse, 2);
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 	 *
543 543
 	 * @param string|array $headers
544 544
 	 * @param string $url The URL that was requested
545
-	 * @return array Processed string headers. If duplicate headers are encountered,
545
+	 * @return string Processed string headers. If duplicate headers are encountered,
546 546
 	 * 					Then a numbered array is returned as the value of that header-key.
547 547
 	 */
548 548
 	public static function processHeaders( $headers, $url = '' ) {
Please login to merge, or discard this patch.
Braces   +97 added lines, -66 removed lines patch added patch discarded remove patch
@@ -212,8 +212,9 @@  discard block
 block discarded – undo
212 212
 		$args = wp_parse_args( $args );
213 213
 
214 214
 		// By default, Head requests do not cause redirections.
215
-		if ( isset($args['method']) && 'HEAD' == $args['method'] )
216
-			$defaults['redirection'] = 0;
215
+		if ( isset($args['method']) && 'HEAD' == $args['method'] ) {
216
+					$defaults['redirection'] = 0;
217
+		}
217 218
 
218 219
 		$r = wp_parse_args( $args, $defaults );
219 220
 		/**
@@ -227,8 +228,9 @@  discard block
 block discarded – undo
227 228
 		$r = apply_filters( 'http_request_args', $r, $url );
228 229
 
229 230
 		// The transports decrement this, store a copy of the original value for loop purposes.
230
-		if ( ! isset( $r['_redirection'] ) )
231
-			$r['_redirection'] = $r['redirection'];
231
+		if ( ! isset( $r['_redirection'] ) ) {
232
+					$r['_redirection'] = $r['redirection'];
233
+		}
232 234
 
233 235
 		/**
234 236
 		 * Filters whether to preempt an HTTP request's return value.
@@ -250,8 +252,9 @@  discard block
 block discarded – undo
250 252
 		 */
251 253
 		$pre = apply_filters( 'pre_http_request', false, $r, $url );
252 254
 
253
-		if ( false !== $pre )
254
-			return $pre;
255
+		if ( false !== $pre ) {
256
+					return $pre;
257
+		}
255 258
 
256 259
 		if ( function_exists( 'wp_kses_bad_protocol' ) ) {
257 260
 			if ( $r['reject_unsafe_urls'] ) {
@@ -371,8 +374,7 @@  discard block
 block discarded – undo
371 374
 
372 375
 			// Add the original object to the array.
373 376
 			$response['http_response'] = $http_response;
374
-		}
375
-		catch ( Requests_Exception $e ) {
377
+		} catch ( Requests_Exception $e ) {
376 378
 			$response = new WP_Error( 'http_request_failed', $e->getMessage() );
377 379
 		}
378 380
 
@@ -498,8 +500,9 @@  discard block
 block discarded – undo
498 500
 			$class = 'WP_Http_' . $transport;
499 501
 
500 502
 			// Check to see if this transport is a possibility, calls the transport statically.
501
-			if ( !call_user_func( array( $class, 'test' ), $args, $url ) )
502
-				continue;
503
+			if ( !call_user_func( array( $class, 'test' ), $args, $url ) ) {
504
+							continue;
505
+			}
503 506
 
504 507
 			return $class;
505 508
 		}
@@ -528,20 +531,23 @@  discard block
 block discarded – undo
528 531
 		static $transports = array();
529 532
 
530 533
 		$class = $this->_get_first_available_transport( $args, $url );
531
-		if ( !$class )
532
-			return new WP_Error( 'http_failure', __( 'There are no HTTP transports available which can complete the requested request.' ) );
534
+		if ( !$class ) {
535
+					return new WP_Error( 'http_failure', __( 'There are no HTTP transports available which can complete the requested request.' ) );
536
+		}
533 537
 
534 538
 		// Transport claims to support request, instantiate it and give it a whirl.
535
-		if ( empty( $transports[$class] ) )
536
-			$transports[$class] = new $class;
539
+		if ( empty( $transports[$class] ) ) {
540
+					$transports[$class] = new $class;
541
+		}
537 542
 
538 543
 		$response = $transports[$class]->request( $url, $args );
539 544
 
540 545
 		/** This action is documented in wp-includes/class-http.php */
541 546
 		do_action( 'http_api_debug', $response, 'response', $class, $args, $url );
542 547
 
543
-		if ( is_wp_error( $response ) )
544
-			return $response;
548
+		if ( is_wp_error( $response ) ) {
549
+					return $response;
550
+		}
545 551
 
546 552
 		/**
547 553
 		 * Filters the HTTP API response immediately before the response is returned.
@@ -670,8 +676,9 @@  discard block
 block discarded – undo
670 676
 		$cookies = array();
671 677
 		$newheaders = array();
672 678
 		foreach ( (array) $headers as $tempheader ) {
673
-			if ( empty($tempheader) )
674
-				continue;
679
+			if ( empty($tempheader) ) {
680
+							continue;
681
+			}
675 682
 
676 683
 			if ( false === strpos($tempheader, ':') ) {
677 684
 				$stack = explode(' ', $tempheader, 3);
@@ -686,14 +693,16 @@  discard block
 block discarded – undo
686 693
 			$value = trim( $value );
687 694
 
688 695
 			if ( isset( $newheaders[ $key ] ) ) {
689
-				if ( ! is_array( $newheaders[ $key ] ) )
690
-					$newheaders[$key] = array( $newheaders[ $key ] );
696
+				if ( ! is_array( $newheaders[ $key ] ) ) {
697
+									$newheaders[$key] = array( $newheaders[ $key ] );
698
+				}
691 699
 				$newheaders[ $key ][] = $value;
692 700
 			} else {
693 701
 				$newheaders[ $key ] = $value;
694 702
 			}
695
-			if ( 'set-cookie' == $key )
696
-				$cookies[] = new WP_Http_Cookie( $value, $url );
703
+			if ( 'set-cookie' == $key ) {
704
+							$cookies[] = new WP_Http_Cookie( $value, $url );
705
+			}
697 706
 		}
698 707
 
699 708
 		// Cast the Response Code to an int
@@ -719,8 +728,9 @@  discard block
 block discarded – undo
719 728
 		if ( ! empty($r['cookies']) ) {
720 729
 			// Upgrade any name => value cookie pairs to WP_HTTP_Cookie instances.
721 730
 			foreach ( $r['cookies'] as $name => $value ) {
722
-				if ( ! is_object( $value ) )
723
-					$r['cookies'][ $name ] = new WP_Http_Cookie( array( 'name' => $name, 'value' => $value ) );
731
+				if ( ! is_object( $value ) ) {
732
+									$r['cookies'][ $name ] = new WP_Http_Cookie( array( 'name' => $name, 'value' => $value ) );
733
+				}
724 734
 			}
725 735
 
726 736
 			$cookies_header = '';
@@ -749,8 +759,9 @@  discard block
 block discarded – undo
749 759
 	 */
750 760
 	public static function chunkTransferDecode( $body ) {
751 761
 		// The body is not chunked encoded or is malformed.
752
-		if ( ! preg_match( '/^([0-9a-f]+)[^\r\n]*\r\n/i', trim( $body ) ) )
753
-			return $body;
762
+		if ( ! preg_match( '/^([0-9a-f]+)[^\r\n]*\r\n/i', trim( $body ) ) ) {
763
+					return $body;
764
+		}
754 765
 
755 766
 		$parsed_body = '';
756 767
 
@@ -759,8 +770,9 @@  discard block
 block discarded – undo
759 770
 
760 771
 		while ( true ) {
761 772
 			$has_chunk = (bool) preg_match( '/^([0-9a-f]+)[^\r\n]*\r\n/i', $body, $match );
762
-			if ( ! $has_chunk || empty( $match[1] ) )
763
-				return $body_original;
773
+			if ( ! $has_chunk || empty( $match[1] ) ) {
774
+							return $body_original;
775
+			}
764 776
 
765 777
 			$length = hexdec( $match[1] );
766 778
 			$chunk_length = strlen( $match[0] );
@@ -772,8 +784,9 @@  discard block
 block discarded – undo
772 784
 			$body = substr( $body, $length + $chunk_length );
773 785
 
774 786
 			// End of the document.
775
-			if ( '0' === trim( $body ) )
776
-				return $parsed_body;
787
+			if ( '0' === trim( $body ) ) {
788
+							return $parsed_body;
789
+			}
777 790
 		}
778 791
 	}
779 792
 
@@ -801,12 +814,14 @@  discard block
 block discarded – undo
801 814
 	 */
802 815
 	public function block_request($uri) {
803 816
 		// We don't need to block requests, because nothing is blocked.
804
-		if ( ! defined( 'WP_HTTP_BLOCK_EXTERNAL' ) || ! WP_HTTP_BLOCK_EXTERNAL )
805
-			return false;
817
+		if ( ! defined( 'WP_HTTP_BLOCK_EXTERNAL' ) || ! WP_HTTP_BLOCK_EXTERNAL ) {
818
+					return false;
819
+		}
806 820
 
807 821
 		$check = parse_url($uri);
808
-		if ( ! $check )
809
-			return true;
822
+		if ( ! $check ) {
823
+					return true;
824
+		}
810 825
 
811 826
 		$home = parse_url( get_option('siteurl') );
812 827
 
@@ -823,8 +838,9 @@  discard block
 block discarded – undo
823 838
 			return apply_filters( 'block_local_requests', false );
824 839
 		}
825 840
 
826
-		if ( !defined('WP_ACCESSIBLE_HOSTS') )
827
-			return true;
841
+		if ( !defined('WP_ACCESSIBLE_HOSTS') ) {
842
+					return true;
843
+		}
828 844
 
829 845
 		static $accessible_hosts = null;
830 846
 		static $wildcard_regex = array();
@@ -833,16 +849,19 @@  discard block
 block discarded – undo
833 849
 
834 850
 			if ( false !== strpos(WP_ACCESSIBLE_HOSTS, '*') ) {
835 851
 				$wildcard_regex = array();
836
-				foreach ( $accessible_hosts as $host )
837
-					$wildcard_regex[] = str_replace( '\*', '.+', preg_quote( $host, '/' ) );
852
+				foreach ( $accessible_hosts as $host ) {
853
+									$wildcard_regex[] = str_replace( '\*', '.+', preg_quote( $host, '/' ) );
854
+				}
838 855
 				$wildcard_regex = '/^(' . implode('|', $wildcard_regex) . ')$/i';
839 856
 			}
840 857
 		}
841 858
 
842
-		if ( !empty($wildcard_regex) )
843
-			return !preg_match($wildcard_regex, $check['host']);
844
-		else
845
-			return !in_array( $check['host'], $accessible_hosts ); //Inverse logic, If it's in the array, then we can't access it.
859
+		if ( !empty($wildcard_regex) ) {
860
+					return !preg_match($wildcard_regex, $check['host']);
861
+		} else {
862
+					return !in_array( $check['host'], $accessible_hosts );
863
+		}
864
+		//Inverse logic, If it's in the array, then we can't access it.
846 865
 
847 866
 	}
848 867
 
@@ -877,8 +896,9 @@  discard block
 block discarded – undo
877 896
 	 * @return string An Absolute URL, in a failure condition where the URL cannot be parsed, the relative URL will be returned.
878 897
 	 */
879 898
 	public static function make_absolute_url( $maybe_relative_path, $url ) {
880
-		if ( empty( $url ) )
881
-			return $maybe_relative_path;
899
+		if ( empty( $url ) ) {
900
+					return $maybe_relative_path;
901
+		}
882 902
 
883 903
 		if ( ! $url_parts = wp_parse_url( $url ) ) {
884 904
 			return $maybe_relative_path;
@@ -898,12 +918,14 @@  discard block
 block discarded – undo
898 918
 		// Schemeless URL's will make it this far, so we check for a host in the relative url and convert it to a protocol-url
899 919
 		if ( isset( $relative_url_parts['host'] ) ) {
900 920
 			$absolute_path .= $relative_url_parts['host'];
901
-			if ( isset( $relative_url_parts['port'] ) )
902
-				$absolute_path .= ':' . $relative_url_parts['port'];
921
+			if ( isset( $relative_url_parts['port'] ) ) {
922
+							$absolute_path .= ':' . $relative_url_parts['port'];
923
+			}
903 924
 		} else {
904 925
 			$absolute_path .= $url_parts['host'];
905
-			if ( isset( $url_parts['port'] ) )
906
-				$absolute_path .= ':' . $url_parts['port'];
926
+			if ( isset( $url_parts['port'] ) ) {
927
+							$absolute_path .= ':' . $url_parts['port'];
928
+			}
907 929
 		}
908 930
 
909 931
 		// Start off with the Absolute URL path.
@@ -931,8 +953,9 @@  discard block
 block discarded – undo
931 953
 		}
932 954
 
933 955
 		// Add the Query string.
934
-		if ( ! empty( $relative_url_parts['query'] ) )
935
-			$path .= '?' . $relative_url_parts['query'];
956
+		if ( ! empty( $relative_url_parts['query'] ) ) {
957
+					$path .= '?' . $relative_url_parts['query'];
958
+		}
936 959
 
937 960
 		return $absolute_path . '/' . ltrim( $path, '/' );
938 961
 	}
@@ -951,36 +974,42 @@  discard block
 block discarded – undo
951 974
 	 */
952 975
 	public static function handle_redirects( $url, $args, $response ) {
953 976
 		// If no redirects are present, or, redirects were not requested, perform no action.
954
-		if ( ! isset( $response['headers']['location'] ) || 0 === $args['_redirection'] )
955
-			return false;
977
+		if ( ! isset( $response['headers']['location'] ) || 0 === $args['_redirection'] ) {
978
+					return false;
979
+		}
956 980
 
957 981
 		// Only perform redirections on redirection http codes.
958
-		if ( $response['response']['code'] > 399 || $response['response']['code'] < 300 )
959
-			return false;
982
+		if ( $response['response']['code'] > 399 || $response['response']['code'] < 300 ) {
983
+					return false;
984
+		}
960 985
 
961 986
 		// Don't redirect if we've run out of redirects.
962
-		if ( $args['redirection']-- <= 0 )
963
-			return new WP_Error( 'http_request_failed', __('Too many redirects.') );
987
+		if ( $args['redirection']-- <= 0 ) {
988
+					return new WP_Error( 'http_request_failed', __('Too many redirects.') );
989
+		}
964 990
 
965 991
 		$redirect_location = $response['headers']['location'];
966 992
 
967 993
 		// If there were multiple Location headers, use the last header specified.
968
-		if ( is_array( $redirect_location ) )
969
-			$redirect_location = array_pop( $redirect_location );
994
+		if ( is_array( $redirect_location ) ) {
995
+					$redirect_location = array_pop( $redirect_location );
996
+		}
970 997
 
971 998
 		$redirect_location = WP_Http::make_absolute_url( $redirect_location, $url );
972 999
 
973 1000
 		// POST requests should not POST to a redirected location.
974 1001
 		if ( 'POST' == $args['method'] ) {
975
-			if ( in_array( $response['response']['code'], array( 302, 303 ) ) )
976
-				$args['method'] = 'GET';
1002
+			if ( in_array( $response['response']['code'], array( 302, 303 ) ) ) {
1003
+							$args['method'] = 'GET';
1004
+			}
977 1005
 		}
978 1006
 
979 1007
 		// Include valid cookies in the redirect process.
980 1008
 		if ( ! empty( $response['cookies'] ) ) {
981 1009
 			foreach ( $response['cookies'] as $cookie ) {
982
-				if ( $cookie->test( $redirect_location ) )
983
-					$args['cookies'][] = $cookie;
1010
+				if ( $cookie->test( $redirect_location ) ) {
1011
+									$args['cookies'][] = $cookie;
1012
+				}
984 1013
 			}
985 1014
 		}
986 1015
 
@@ -1004,11 +1033,13 @@  discard block
 block discarded – undo
1004 1033
 	 * @return integer|bool Upon success, '4' or '6' to represent a IPv4 or IPv6 address, false upon failure
1005 1034
 	 */
1006 1035
 	public static function is_ip_address( $maybe_ip ) {
1007
-		if ( preg_match( '/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $maybe_ip ) )
1008
-			return 4;
1036
+		if ( preg_match( '/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $maybe_ip ) ) {
1037
+					return 4;
1038
+		}
1009 1039
 
1010
-		if ( false !== strpos( $maybe_ip, ':' ) && preg_match( '/^(((?=.*(::))(?!.*\3.+\3))\3?|([\dA-F]{1,4}(\3|:\b|$)|\2))(?4){5}((?4){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i', trim( $maybe_ip, ' []' ) ) )
1011
-			return 6;
1040
+		if ( false !== strpos( $maybe_ip, ':' ) && preg_match( '/^(((?=.*(::))(?!.*\3.+\3))\3?|([\dA-F]{1,4}(\3|:\b|$)|\2))(?4){5}((?4){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i', trim( $maybe_ip, ' []' ) ) ) {
1041
+					return 6;
1042
+		}
1012 1043
 
1013 1044
 		return false;
1014 1045
 	}
Please login to merge, or discard this patch.
Spacing   +179 added lines, -179 removed lines patch added patch discarded remove patch
@@ -7,11 +7,11 @@  discard block
 block discarded – undo
7 7
  * @since 2.7.0
8 8
  */
9 9
 
10
-if ( ! class_exists( 'Requests' ) ) {
11
-	require( ABSPATH . WPINC . '/class-requests.php' );
10
+if ( ! class_exists('Requests')) {
11
+	require(ABSPATH.WPINC.'/class-requests.php');
12 12
 
13 13
 	Requests::register_autoloader();
14
-	Requests::set_certificate_path( ABSPATH . WPINC . '/certificates/ca-bundle.crt' );
14
+	Requests::set_certificate_path(ABSPATH.WPINC.'/certificates/ca-bundle.crt');
15 15
 }
16 16
 
17 17
 /**
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'.
146 146
 	 *                        A WP_Error instance upon error.
147 147
 	 */
148
-	public function request( $url, $args = array() ) {
148
+	public function request($url, $args = array()) {
149 149
 		$defaults = array(
150 150
 			'method' => 'GET',
151 151
 			/**
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 			 * @param int $timeout_value Time in seconds until a request times out.
157 157
 			 *                           Default 5.
158 158
 			 */
159
-			'timeout' => apply_filters( 'http_request_timeout', 5 ),
159
+			'timeout' => apply_filters('http_request_timeout', 5),
160 160
 			/**
161 161
 			 * Filters the number of redirects allowed during an HTTP request.
162 162
 			 *
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 			 *
165 165
 			 * @param int $redirect_count Number of redirects allowed. Default 5.
166 166
 			 */
167
-			'redirection' => apply_filters( 'http_request_redirection_count', 5 ),
167
+			'redirection' => apply_filters('http_request_redirection_count', 5),
168 168
 			/**
169 169
 			 * Filters the version of the HTTP protocol used in a request.
170 170
 			 *
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 			 * @param string $version Version of HTTP used. Accepts '1.0' and '1.1'.
174 174
 			 *                        Default '1.0'.
175 175
 			 */
176
-			'httpversion' => apply_filters( 'http_request_version', '1.0' ),
176
+			'httpversion' => apply_filters('http_request_version', '1.0'),
177 177
 			/**
178 178
 			 * Filters the user agent value sent with an HTTP request.
179 179
 			 *
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 			 *
182 182
 			 * @param string $user_agent WordPress user agent string.
183 183
 			 */
184
-			'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . get_bloginfo( 'version' ) . '; ' . get_bloginfo( 'url' ) ),
184
+			'user-agent' => apply_filters('http_headers_useragent', 'WordPress/'.get_bloginfo('version').'; '.get_bloginfo('url')),
185 185
 			/**
186 186
 			 * Filters whether to pass URLs through wp_http_validate_url() in an HTTP request.
187 187
 			 *
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 			 * @param bool $pass_url Whether to pass URLs through wp_http_validate_url().
191 191
 			 *                       Default false.
192 192
 			 */
193
-			'reject_unsafe_urls' => apply_filters( 'http_request_reject_unsafe_urls', false ),
193
+			'reject_unsafe_urls' => apply_filters('http_request_reject_unsafe_urls', false),
194 194
 			'blocking' => true,
195 195
 			'headers' => array(),
196 196
 			'cookies' => array(),
@@ -198,20 +198,20 @@  discard block
 block discarded – undo
198 198
 			'compress' => false,
199 199
 			'decompress' => true,
200 200
 			'sslverify' => true,
201
-			'sslcertificates' => ABSPATH . WPINC . '/certificates/ca-bundle.crt',
201
+			'sslcertificates' => ABSPATH.WPINC.'/certificates/ca-bundle.crt',
202 202
 			'stream' => false,
203 203
 			'filename' => null,
204 204
 			'limit_response_size' => null,
205 205
 		);
206 206
 
207 207
 		// Pre-parse for the HEAD checks.
208
-		$args = wp_parse_args( $args );
208
+		$args = wp_parse_args($args);
209 209
 
210 210
 		// By default, Head requests do not cause redirections.
211
-		if ( isset($args['method']) && 'HEAD' == $args['method'] )
211
+		if (isset($args['method']) && 'HEAD' == $args['method'])
212 212
 			$defaults['redirection'] = 0;
213 213
 
214
-		$r = wp_parse_args( $args, $defaults );
214
+		$r = wp_parse_args($args, $defaults);
215 215
 		/**
216 216
 		 * Filters the arguments used in an HTTP request.
217 217
 		 *
@@ -220,10 +220,10 @@  discard block
 block discarded – undo
220 220
 		 * @param array  $r   An array of HTTP request arguments.
221 221
 		 * @param string $url The request URL.
222 222
 		 */
223
-		$r = apply_filters( 'http_request_args', $r, $url );
223
+		$r = apply_filters('http_request_args', $r, $url);
224 224
 
225 225
 		// The transports decrement this, store a copy of the original value for loop purposes.
226
-		if ( ! isset( $r['_redirection'] ) )
226
+		if ( ! isset($r['_redirection']))
227 227
 			$r['_redirection'] = $r['redirection'];
228 228
 
229 229
 		/**
@@ -244,51 +244,51 @@  discard block
 block discarded – undo
244 244
 		 * @param array               $r        HTTP request arguments.
245 245
 		 * @param string              $url      The request URL.
246 246
 		 */
247
-		$pre = apply_filters( 'pre_http_request', false, $r, $url );
247
+		$pre = apply_filters('pre_http_request', false, $r, $url);
248 248
 
249
-		if ( false !== $pre )
249
+		if (false !== $pre)
250 250
 			return $pre;
251 251
 
252
-		if ( function_exists( 'wp_kses_bad_protocol' ) ) {
253
-			if ( $r['reject_unsafe_urls'] ) {
254
-				$url = wp_http_validate_url( $url );
252
+		if (function_exists('wp_kses_bad_protocol')) {
253
+			if ($r['reject_unsafe_urls']) {
254
+				$url = wp_http_validate_url($url);
255 255
 			}
256
-			if ( $url ) {
257
-				$url = wp_kses_bad_protocol( $url, array( 'http', 'https', 'ssl' ) );
256
+			if ($url) {
257
+				$url = wp_kses_bad_protocol($url, array('http', 'https', 'ssl'));
258 258
 			}
259 259
 		}
260 260
 
261
-		$arrURL = @parse_url( $url );
261
+		$arrURL = @parse_url($url);
262 262
 
263
-		if ( empty( $url ) || empty( $arrURL['scheme'] ) ) {
263
+		if (empty($url) || empty($arrURL['scheme'])) {
264 264
 			return new WP_Error('http_request_failed', __('A valid URL was not provided.'));
265 265
 		}
266 266
 
267
-		if ( $this->block_request( $url ) ) {
268
-			return new WP_Error( 'http_request_failed', __( 'User has blocked requests through HTTP.' ) );
267
+		if ($this->block_request($url)) {
268
+			return new WP_Error('http_request_failed', __('User has blocked requests through HTTP.'));
269 269
 		}
270 270
 
271 271
 		// If we are streaming to a file but no filename was given drop it in the WP temp dir
272 272
 		// and pick its name using the basename of the $url
273
-		if ( $r['stream'] ) {
274
-			if ( empty( $r['filename'] ) ) {
275
-				$r['filename'] = get_temp_dir() . basename( $url );
273
+		if ($r['stream']) {
274
+			if (empty($r['filename'])) {
275
+				$r['filename'] = get_temp_dir().basename($url);
276 276
 			}
277 277
 
278 278
 			// Force some settings if we are streaming to a file and check for existence and perms of destination directory
279 279
 			$r['blocking'] = true;
280
-			if ( ! wp_is_writable( dirname( $r['filename'] ) ) ) {
281
-				return new WP_Error( 'http_request_failed', __( 'Destination directory for file streaming does not exist or is not writable.' ) );
280
+			if ( ! wp_is_writable(dirname($r['filename']))) {
281
+				return new WP_Error('http_request_failed', __('Destination directory for file streaming does not exist or is not writable.'));
282 282
 			}
283 283
 		}
284 284
 
285
-		if ( is_null( $r['headers'] ) ) {
285
+		if (is_null($r['headers'])) {
286 286
 			$r['headers'] = array();
287 287
 		}
288 288
 
289 289
 		// WP allows passing in headers as a string, weirdly.
290
-		if ( ! is_array( $r['headers'] ) ) {
291
-			$processedHeaders = WP_Http::processHeaders( $r['headers'] );
290
+		if ( ! is_array($r['headers'])) {
291
+			$processedHeaders = WP_Http::processHeaders($r['headers']);
292 292
 			$r['headers'] = $processedHeaders['headers'];
293 293
 		}
294 294
 
@@ -300,38 +300,38 @@  discard block
 block discarded – undo
300 300
 			'timeout' => $r['timeout'],
301 301
 			'useragent' => $r['user-agent'],
302 302
 			'blocking' => $r['blocking'],
303
-			'hooks' => new WP_HTTP_Requests_Hooks( $url, $r ),
303
+			'hooks' => new WP_HTTP_Requests_Hooks($url, $r),
304 304
 		);
305 305
 
306 306
 		// Ensure redirects follow browser behaviour.
307
-		$options['hooks']->register( 'requests.before_redirect', array( get_class(), 'browser_redirect_compatibility' ) );
307
+		$options['hooks']->register('requests.before_redirect', array(get_class(), 'browser_redirect_compatibility'));
308 308
 
309 309
 		// Validate redirected URLs.
310
-		if ( function_exists( 'wp_kses_bad_protocol' ) && $r['reject_unsafe_urls'] ) {
311
-			$options['hooks']->register( 'requests.before_redirect', array( get_class(), 'validate_redirects' ) );
310
+		if (function_exists('wp_kses_bad_protocol') && $r['reject_unsafe_urls']) {
311
+			$options['hooks']->register('requests.before_redirect', array(get_class(), 'validate_redirects'));
312 312
 		}
313 313
 
314
-		if ( $r['stream'] ) {
314
+		if ($r['stream']) {
315 315
 			$options['filename'] = $r['filename'];
316 316
 		}
317
-		if ( empty( $r['redirection'] ) ) {
317
+		if (empty($r['redirection'])) {
318 318
 			$options['follow_redirects'] = false;
319 319
 		} else {
320 320
 			$options['redirects'] = $r['redirection'];
321 321
 		}
322 322
 
323 323
 		// Use byte limit, if we can
324
-		if ( isset( $r['limit_response_size'] ) ) {
324
+		if (isset($r['limit_response_size'])) {
325 325
 			$options['max_bytes'] = $r['limit_response_size'];
326 326
 		}
327 327
 
328 328
 		// If we've got cookies, use and convert them to Requests_Cookie.
329
-		if ( ! empty( $r['cookies'] ) ) {
330
-			$options['cookies'] = WP_Http::normalize_cookies( $r['cookies'] );
329
+		if ( ! empty($r['cookies'])) {
330
+			$options['cookies'] = WP_Http::normalize_cookies($r['cookies']);
331 331
 		}
332 332
 
333 333
 		// SSL certificate handling
334
-		if ( ! $r['sslverify'] ) {
334
+		if ( ! $r['sslverify']) {
335 335
 			$options['verify'] = false;
336 336
 			$options['verifyname'] = false;
337 337
 		} else {
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 		}
340 340
 
341 341
 		// All non-GET/HEAD requests should put the arguments in the form body.
342
-		if ( 'HEAD' !== $type && 'GET' !== $type ) {
342
+		if ('HEAD' !== $type && 'GET' !== $type) {
343 343
 			$options['data_format'] = 'body';
344 344
 		}
345 345
 
@@ -350,14 +350,14 @@  discard block
 block discarded – undo
350 350
 		 *
351 351
 		 * @param bool $ssl_verify Whether to verify the SSL connection. Default true.
352 352
 		 */
353
-		$options['verify'] = apply_filters( 'https_ssl_verify', $options['verify'] );
353
+		$options['verify'] = apply_filters('https_ssl_verify', $options['verify']);
354 354
 
355 355
 		// Check for proxies.
356 356
 		$proxy = new WP_HTTP_Proxy();
357
-		if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) {
358
-			$options['proxy'] = new Requests_Proxy_HTTP( $proxy->host() . ':' . $proxy->port() );
357
+		if ($proxy->is_enabled() && $proxy->send_through_proxy($url)) {
358
+			$options['proxy'] = new Requests_Proxy_HTTP($proxy->host().':'.$proxy->port());
359 359
 
360
-			if ( $proxy->use_authentication() ) {
360
+			if ($proxy->use_authentication()) {
361 361
 				$options['proxy']->use_authentication = true;
362 362
 				$options['proxy']->user = $proxy->username();
363 363
 				$options['proxy']->pass = $proxy->password();
@@ -368,17 +368,17 @@  discard block
 block discarded – undo
368 368
 		mbstring_binary_safe_encoding();
369 369
 
370 370
 		try {
371
-			$requests_response = Requests::request( $url, $headers, $data, $type, $options );
371
+			$requests_response = Requests::request($url, $headers, $data, $type, $options);
372 372
 
373 373
 			// Convert the response into an array
374
-			$http_response = new WP_HTTP_Requests_Response( $requests_response, $r['filename'] );
374
+			$http_response = new WP_HTTP_Requests_Response($requests_response, $r['filename']);
375 375
 			$response = $http_response->to_array();
376 376
 
377 377
 			// Add the original object to the array.
378 378
 			$response['http_response'] = $http_response;
379 379
 		}
380
-		catch ( Requests_Exception $e ) {
381
-			$response = new WP_Error( 'http_request_failed', $e->getMessage() );
380
+		catch (Requests_Exception $e) {
381
+			$response = new WP_Error('http_request_failed', $e->getMessage());
382 382
 		}
383 383
 
384 384
 		reset_mbstring_encoding();
@@ -394,12 +394,12 @@  discard block
 block discarded – undo
394 394
 		 * @param array          $args     HTTP request arguments.
395 395
 		 * @param string         $url      The request URL.
396 396
 		 */
397
-		do_action( 'http_api_debug', $response, 'response', 'Requests', $r, $url );
398
-		if ( is_wp_error( $response ) ) {
397
+		do_action('http_api_debug', $response, 'response', 'Requests', $r, $url);
398
+		if (is_wp_error($response)) {
399 399
 			return $response;
400 400
 		}
401 401
 
402
-		if ( ! $r['blocking'] ) {
402
+		if ( ! $r['blocking']) {
403 403
 			return array(
404 404
 				'headers' => array(),
405 405
 				'body' => '',
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 		 * @param array  $r        HTTP request arguments.
422 422
 		 * @param string $url      The request URL.
423 423
 		 */
424
-		return apply_filters( 'http_response', $response, $r, $url );
424
+		return apply_filters('http_response', $response, $r, $url);
425 425
 	}
426 426
 
427 427
 	/**
@@ -434,14 +434,14 @@  discard block
 block discarded – undo
434 434
 	 * @param array $cookies List of cookies to send with the request.
435 435
 	 * @return Requests_Cookie_Jar Cookie holder object.
436 436
 	 */
437
-	public static function normalize_cookies( $cookies ) {
437
+	public static function normalize_cookies($cookies) {
438 438
 		$cookie_jar = new Requests_Cookie_Jar();
439 439
 
440
-		foreach ( $cookies as $name => $value ) {
441
-			if ( $value instanceof WP_Http_Cookie ) {
442
-				$cookie_jar[ $value->name ] = new Requests_Cookie( $value->name, $value->value, $value->get_attributes() );
443
-			} elseif ( is_scalar( $value ) ) {
444
-				$cookie_jar[ $name ] = new Requests_Cookie( $name, $value );
440
+		foreach ($cookies as $name => $value) {
441
+			if ($value instanceof WP_Http_Cookie) {
442
+				$cookie_jar[$value->name] = new Requests_Cookie($value->name, $value->value, $value->get_attributes());
443
+			} elseif (is_scalar($value)) {
444
+				$cookie_jar[$name] = new Requests_Cookie($name, $value);
445 445
 			}
446 446
 		}
447 447
 
@@ -464,9 +464,9 @@  discard block
 block discarded – undo
464 464
 	 * @param array             $options  Redirect request options.
465 465
 	 * @param Requests_Response $original Response object.
466 466
 	 */
467
-	public static function browser_redirect_compatibility( $location, $headers, $data, &$options, $original ) {
467
+	public static function browser_redirect_compatibility($location, $headers, $data, &$options, $original) {
468 468
 		// Browser compat
469
-		if ( $original->status_code === 302 ) {
469
+		if ($original->status_code === 302) {
470 470
 			$options['type'] = Requests::GET;
471 471
 		}
472 472
 	}
@@ -479,9 +479,9 @@  discard block
 block discarded – undo
479 479
 	 * @throws Requests_Exception On unsuccessful URL validation
480 480
 	 * @param string $location URL to redirect to.
481 481
 	 */
482
-	public static function validate_redirects( $location ) {
483
-		if ( ! wp_http_validate_url( $location ) ) {
484
-			throw new Requests_Exception( __('A valid URL was not provided.'), 'wp_http.redirect_failed_validation' );
482
+	public static function validate_redirects($location) {
483
+		if ( ! wp_http_validate_url($location)) {
484
+			throw new Requests_Exception(__('A valid URL was not provided.'), 'wp_http.redirect_failed_validation');
485 485
 		}
486 486
 	}
487 487
 
@@ -496,8 +496,8 @@  discard block
 block discarded – undo
496 496
 	 *
497 497
 	 * @return string|false Class name for the first transport that claims to support the request. False if no transport claims to support the request.
498 498
 	 */
499
-	public function _get_first_available_transport( $args, $url = null ) {
500
-		$transports = array( 'curl', 'streams' );
499
+	public function _get_first_available_transport($args, $url = null) {
500
+		$transports = array('curl', 'streams');
501 501
 
502 502
 		/**
503 503
 		 * Filters which HTTP transports are available and in what order.
@@ -509,17 +509,17 @@  discard block
 block discarded – undo
509 509
 		 * @param array  $args       HTTP request arguments.
510 510
 		 * @param string $url        The URL to request.
511 511
 		 */
512
-		$request_order = apply_filters( 'http_api_transports', $transports, $args, $url );
512
+		$request_order = apply_filters('http_api_transports', $transports, $args, $url);
513 513
 
514 514
 		// Loop over each transport on each HTTP request looking for one which will serve this request's needs.
515
-		foreach ( $request_order as $transport ) {
516
-			if ( in_array( $transport, $transports ) ) {
517
-				$transport = ucfirst( $transport );
515
+		foreach ($request_order as $transport) {
516
+			if (in_array($transport, $transports)) {
517
+				$transport = ucfirst($transport);
518 518
 			}
519
-			$class = 'WP_Http_' . $transport;
519
+			$class = 'WP_Http_'.$transport;
520 520
 
521 521
 			// Check to see if this transport is a possibility, calls the transport statically.
522
-			if ( !call_user_func( array( $class, 'test' ), $args, $url ) )
522
+			if ( ! call_user_func(array($class, 'test'), $args, $url))
523 523
 				continue;
524 524
 
525 525
 			return $class;
@@ -545,23 +545,23 @@  discard block
 block discarded – undo
545 545
 	 * @param array $args Request arguments
546 546
 	 * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error
547 547
 	 */
548
-	private function _dispatch_request( $url, $args ) {
548
+	private function _dispatch_request($url, $args) {
549 549
 		static $transports = array();
550 550
 
551
-		$class = $this->_get_first_available_transport( $args, $url );
552
-		if ( !$class )
553
-			return new WP_Error( 'http_failure', __( 'There are no HTTP transports available which can complete the requested request.' ) );
551
+		$class = $this->_get_first_available_transport($args, $url);
552
+		if ( ! $class)
553
+			return new WP_Error('http_failure', __('There are no HTTP transports available which can complete the requested request.'));
554 554
 
555 555
 		// Transport claims to support request, instantiate it and give it a whirl.
556
-		if ( empty( $transports[$class] ) )
556
+		if (empty($transports[$class]))
557 557
 			$transports[$class] = new $class;
558 558
 
559
-		$response = $transports[$class]->request( $url, $args );
559
+		$response = $transports[$class]->request($url, $args);
560 560
 
561 561
 		/** This action is documented in wp-includes/class-http.php */
562
-		do_action( 'http_api_debug', $response, 'response', $class, $args, $url );
562
+		do_action('http_api_debug', $response, 'response', $class, $args, $url);
563 563
 
564
-		if ( is_wp_error( $response ) )
564
+		if (is_wp_error($response))
565 565
 			return $response;
566 566
 
567 567
 		/**
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 		 * @param array  $args     HTTP request arguments.
574 574
 		 * @param string $url      The request URL.
575 575
 		 */
576
-		return apply_filters( 'http_response', $response, $args, $url );
576
+		return apply_filters('http_response', $response, $args, $url);
577 577
 	}
578 578
 
579 579
 	/**
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 	 */
591 591
 	public function post($url, $args = array()) {
592 592
 		$defaults = array('method' => 'POST');
593
-		$r = wp_parse_args( $args, $defaults );
593
+		$r = wp_parse_args($args, $defaults);
594 594
 		return $this->request($url, $r);
595 595
 	}
596 596
 
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 	 */
609 609
 	public function get($url, $args = array()) {
610 610
 		$defaults = array('method' => 'GET');
611
-		$r = wp_parse_args( $args, $defaults );
611
+		$r = wp_parse_args($args, $defaults);
612 612
 		return $this->request($url, $r);
613 613
 	}
614 614
 
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 	 */
627 627
 	public function head($url, $args = array()) {
628 628
 		$defaults = array('method' => 'HEAD');
629
-		$r = wp_parse_args( $args, $defaults );
629
+		$r = wp_parse_args($args, $defaults);
630 630
 		return $this->request($url, $r);
631 631
 	}
632 632
 
@@ -661,9 +661,9 @@  discard block
 block discarded – undo
661 661
 	 * @return array Processed string headers. If duplicate headers are encountered,
662 662
 	 * 					Then a numbered array is returned as the value of that header-key.
663 663
 	 */
664
-	public static function processHeaders( $headers, $url = '' ) {
664
+	public static function processHeaders($headers, $url = '') {
665 665
 		// Split headers, one per array element.
666
-		if ( is_string($headers) ) {
666
+		if (is_string($headers)) {
667 667
 			// Tolerate line terminator: CRLF = LF (RFC 2616 19.3).
668 668
 			$headers = str_replace("\r\n", "\n", $headers);
669 669
 			/*
@@ -681,8 +681,8 @@  discard block
 block discarded – undo
681 681
 		 * If a redirection has taken place, The headers for each page request may have been passed.
682 682
 		 * In this case, determine the final HTTP header and parse from there.
683 683
 		 */
684
-		for ( $i = count($headers)-1; $i >= 0; $i-- ) {
685
-			if ( !empty($headers[$i]) && false === strpos($headers[$i], ':') ) {
684
+		for ($i = count($headers) - 1; $i >= 0; $i--) {
685
+			if ( ! empty($headers[$i]) && false === strpos($headers[$i], ':')) {
686 686
 				$headers = array_splice($headers, $i);
687 687
 				break;
688 688
 			}
@@ -690,35 +690,35 @@  discard block
 block discarded – undo
690 690
 
691 691
 		$cookies = array();
692 692
 		$newheaders = array();
693
-		foreach ( (array) $headers as $tempheader ) {
694
-			if ( empty($tempheader) )
693
+		foreach ((array) $headers as $tempheader) {
694
+			if (empty($tempheader))
695 695
 				continue;
696 696
 
697
-			if ( false === strpos($tempheader, ':') ) {
697
+			if (false === strpos($tempheader, ':')) {
698 698
 				$stack = explode(' ', $tempheader, 3);
699 699
 				$stack[] = '';
700
-				list( , $response['code'], $response['message']) = $stack;
700
+				list(, $response['code'], $response['message']) = $stack;
701 701
 				continue;
702 702
 			}
703 703
 
704 704
 			list($key, $value) = explode(':', $tempheader, 2);
705 705
 
706
-			$key = strtolower( $key );
707
-			$value = trim( $value );
706
+			$key = strtolower($key);
707
+			$value = trim($value);
708 708
 
709
-			if ( isset( $newheaders[ $key ] ) ) {
710
-				if ( ! is_array( $newheaders[ $key ] ) )
711
-					$newheaders[$key] = array( $newheaders[ $key ] );
712
-				$newheaders[ $key ][] = $value;
709
+			if (isset($newheaders[$key])) {
710
+				if ( ! is_array($newheaders[$key]))
711
+					$newheaders[$key] = array($newheaders[$key]);
712
+				$newheaders[$key][] = $value;
713 713
 			} else {
714
-				$newheaders[ $key ] = $value;
714
+				$newheaders[$key] = $value;
715 715
 			}
716
-			if ( 'set-cookie' == $key )
717
-				$cookies[] = new WP_Http_Cookie( $value, $url );
716
+			if ('set-cookie' == $key)
717
+				$cookies[] = new WP_Http_Cookie($value, $url);
718 718
 		}
719 719
 
720 720
 		// Cast the Response Code to an int
721
-		$response['code'] = intval( $response['code'] );
721
+		$response['code'] = intval($response['code']);
722 722
 
723 723
 		return array('response' => $response, 'headers' => $newheaders, 'cookies' => $cookies);
724 724
 	}
@@ -736,20 +736,20 @@  discard block
 block discarded – undo
736 736
 	 *
737 737
 	 * @param array $r Full array of args passed into ::request()
738 738
 	 */
739
-	public static function buildCookieHeader( &$r ) {
740
-		if ( ! empty($r['cookies']) ) {
739
+	public static function buildCookieHeader(&$r) {
740
+		if ( ! empty($r['cookies'])) {
741 741
 			// Upgrade any name => value cookie pairs to WP_HTTP_Cookie instances.
742
-			foreach ( $r['cookies'] as $name => $value ) {
743
-				if ( ! is_object( $value ) )
744
-					$r['cookies'][ $name ] = new WP_Http_Cookie( array( 'name' => $name, 'value' => $value ) );
742
+			foreach ($r['cookies'] as $name => $value) {
743
+				if ( ! is_object($value))
744
+					$r['cookies'][$name] = new WP_Http_Cookie(array('name' => $name, 'value' => $value));
745 745
 			}
746 746
 
747 747
 			$cookies_header = '';
748
-			foreach ( (array) $r['cookies'] as $cookie ) {
749
-				$cookies_header .= $cookie->getHeaderValue() . '; ';
748
+			foreach ((array) $r['cookies'] as $cookie) {
749
+				$cookies_header .= $cookie->getHeaderValue().'; ';
750 750
 			}
751 751
 
752
-			$cookies_header = substr( $cookies_header, 0, -2 );
752
+			$cookies_header = substr($cookies_header, 0, -2);
753 753
 			$r['headers']['cookie'] = $cookies_header;
754 754
 		}
755 755
 	}
@@ -768,9 +768,9 @@  discard block
 block discarded – undo
768 768
 	 * @param string $body Body content
769 769
 	 * @return string Chunked decoded body on success or raw body on failure.
770 770
 	 */
771
-	public static function chunkTransferDecode( $body ) {
771
+	public static function chunkTransferDecode($body) {
772 772
 		// The body is not chunked encoded or is malformed.
773
-		if ( ! preg_match( '/^([0-9a-f]+)[^\r\n]*\r\n/i', trim( $body ) ) )
773
+		if ( ! preg_match('/^([0-9a-f]+)[^\r\n]*\r\n/i', trim($body)))
774 774
 			return $body;
775 775
 
776 776
 		$parsed_body = '';
@@ -778,22 +778,22 @@  discard block
 block discarded – undo
778 778
 		// We'll be altering $body, so need a backup in case of error.
779 779
 		$body_original = $body;
780 780
 
781
-		while ( true ) {
782
-			$has_chunk = (bool) preg_match( '/^([0-9a-f]+)[^\r\n]*\r\n/i', $body, $match );
783
-			if ( ! $has_chunk || empty( $match[1] ) )
781
+		while (true) {
782
+			$has_chunk = (bool) preg_match('/^([0-9a-f]+)[^\r\n]*\r\n/i', $body, $match);
783
+			if ( ! $has_chunk || empty($match[1]))
784 784
 				return $body_original;
785 785
 
786
-			$length = hexdec( $match[1] );
787
-			$chunk_length = strlen( $match[0] );
786
+			$length = hexdec($match[1]);
787
+			$chunk_length = strlen($match[0]);
788 788
 
789 789
 			// Parse out the chunk of data.
790
-			$parsed_body .= substr( $body, $chunk_length, $length );
790
+			$parsed_body .= substr($body, $chunk_length, $length);
791 791
 
792 792
 			// Remove the chunk from the raw data.
793
-			$body = substr( $body, $length + $chunk_length );
793
+			$body = substr($body, $length + $chunk_length);
794 794
 
795 795
 			// End of the document.
796
-			if ( '0' === trim( $body ) )
796
+			if ('0' === trim($body))
797 797
 				return $parsed_body;
798 798
 		}
799 799
 	}
@@ -822,17 +822,17 @@  discard block
 block discarded – undo
822 822
 	 */
823 823
 	public function block_request($uri) {
824 824
 		// We don't need to block requests, because nothing is blocked.
825
-		if ( ! defined( 'WP_HTTP_BLOCK_EXTERNAL' ) || ! WP_HTTP_BLOCK_EXTERNAL )
825
+		if ( ! defined('WP_HTTP_BLOCK_EXTERNAL') || ! WP_HTTP_BLOCK_EXTERNAL)
826 826
 			return false;
827 827
 
828 828
 		$check = parse_url($uri);
829
-		if ( ! $check )
829
+		if ( ! $check)
830 830
 			return true;
831 831
 
832
-		$home = parse_url( get_option('siteurl') );
832
+		$home = parse_url(get_option('siteurl'));
833 833
 
834 834
 		// Don't block requests back to ourselves by default.
835
-		if ( 'localhost' == $check['host'] || ( isset( $home['host'] ) && $home['host'] == $check['host'] ) ) {
835
+		if ('localhost' == $check['host'] || (isset($home['host']) && $home['host'] == $check['host'])) {
836 836
 			/**
837 837
 			 * Filters whether to block local requests through the proxy.
838 838
 			 *
@@ -841,29 +841,29 @@  discard block
 block discarded – undo
841 841
 			 * @param bool $block Whether to block local requests through proxy.
842 842
 			 *                    Default false.
843 843
 			 */
844
-			return apply_filters( 'block_local_requests', false );
844
+			return apply_filters('block_local_requests', false);
845 845
 		}
846 846
 
847
-		if ( !defined('WP_ACCESSIBLE_HOSTS') )
847
+		if ( ! defined('WP_ACCESSIBLE_HOSTS'))
848 848
 			return true;
849 849
 
850 850
 		static $accessible_hosts = null;
851 851
 		static $wildcard_regex = array();
852
-		if ( null === $accessible_hosts ) {
852
+		if (null === $accessible_hosts) {
853 853
 			$accessible_hosts = preg_split('|,\s*|', WP_ACCESSIBLE_HOSTS);
854 854
 
855
-			if ( false !== strpos(WP_ACCESSIBLE_HOSTS, '*') ) {
855
+			if (false !== strpos(WP_ACCESSIBLE_HOSTS, '*')) {
856 856
 				$wildcard_regex = array();
857
-				foreach ( $accessible_hosts as $host )
858
-					$wildcard_regex[] = str_replace( '\*', '.+', preg_quote( $host, '/' ) );
859
-				$wildcard_regex = '/^(' . implode('|', $wildcard_regex) . ')$/i';
857
+				foreach ($accessible_hosts as $host)
858
+					$wildcard_regex[] = str_replace('\*', '.+', preg_quote($host, '/'));
859
+				$wildcard_regex = '/^('.implode('|', $wildcard_regex).')$/i';
860 860
 			}
861 861
 		}
862 862
 
863
-		if ( !empty($wildcard_regex) )
864
-			return !preg_match($wildcard_regex, $check['host']);
863
+		if ( ! empty($wildcard_regex))
864
+			return ! preg_match($wildcard_regex, $check['host']);
865 865
 		else
866
-			return !in_array( $check['host'], $accessible_hosts ); //Inverse logic, If it's in the array, then we can't access it.
866
+			return ! in_array($check['host'], $accessible_hosts); //Inverse logic, If it's in the array, then we can't access it.
867 867
 
868 868
 	}
869 869
 
@@ -878,9 +878,9 @@  discard block
 block discarded – undo
878 878
 	 * @return bool|array False on failure; Array of URL components on success;
879 879
 	 *                    See parse_url()'s return values.
880 880
 	 */
881
-	protected static function parse_url( $url ) {
882
-		_deprecated_function( __METHOD__, '4.4.0', 'wp_parse_url()' );
883
-		return wp_parse_url( $url );
881
+	protected static function parse_url($url) {
882
+		_deprecated_function(__METHOD__, '4.4.0', 'wp_parse_url()');
883
+		return wp_parse_url($url);
884 884
 	}
885 885
 
886 886
 	/**
@@ -897,65 +897,65 @@  discard block
 block discarded – undo
897 897
 	 * @param string $url                 The URL which $maybe_relative_path is relative to
898 898
 	 * @return string An Absolute URL, in a failure condition where the URL cannot be parsed, the relative URL will be returned.
899 899
 	 */
900
-	public static function make_absolute_url( $maybe_relative_path, $url ) {
901
-		if ( empty( $url ) )
900
+	public static function make_absolute_url($maybe_relative_path, $url) {
901
+		if (empty($url))
902 902
 			return $maybe_relative_path;
903 903
 
904
-		if ( ! $url_parts = wp_parse_url( $url ) ) {
904
+		if ( ! $url_parts = wp_parse_url($url)) {
905 905
 			return $maybe_relative_path;
906 906
 		}
907 907
 
908
-		if ( ! $relative_url_parts = wp_parse_url( $maybe_relative_path ) ) {
908
+		if ( ! $relative_url_parts = wp_parse_url($maybe_relative_path)) {
909 909
 			return $maybe_relative_path;
910 910
 		}
911 911
 
912 912
 		// Check for a scheme on the 'relative' url
913
-		if ( ! empty( $relative_url_parts['scheme'] ) ) {
913
+		if ( ! empty($relative_url_parts['scheme'])) {
914 914
 			return $maybe_relative_path;
915 915
 		}
916 916
 
917
-		$absolute_path = $url_parts['scheme'] . '://';
917
+		$absolute_path = $url_parts['scheme'].'://';
918 918
 
919 919
 		// Schemeless URL's will make it this far, so we check for a host in the relative url and convert it to a protocol-url
920
-		if ( isset( $relative_url_parts['host'] ) ) {
920
+		if (isset($relative_url_parts['host'])) {
921 921
 			$absolute_path .= $relative_url_parts['host'];
922
-			if ( isset( $relative_url_parts['port'] ) )
923
-				$absolute_path .= ':' . $relative_url_parts['port'];
922
+			if (isset($relative_url_parts['port']))
923
+				$absolute_path .= ':'.$relative_url_parts['port'];
924 924
 		} else {
925 925
 			$absolute_path .= $url_parts['host'];
926
-			if ( isset( $url_parts['port'] ) )
927
-				$absolute_path .= ':' . $url_parts['port'];
926
+			if (isset($url_parts['port']))
927
+				$absolute_path .= ':'.$url_parts['port'];
928 928
 		}
929 929
 
930 930
 		// Start off with the Absolute URL path.
931
-		$path = ! empty( $url_parts['path'] ) ? $url_parts['path'] : '/';
931
+		$path = ! empty($url_parts['path']) ? $url_parts['path'] : '/';
932 932
 
933 933
 		// If it's a root-relative path, then great.
934
-		if ( ! empty( $relative_url_parts['path'] ) && '/' == $relative_url_parts['path'][0] ) {
934
+		if ( ! empty($relative_url_parts['path']) && '/' == $relative_url_parts['path'][0]) {
935 935
 			$path = $relative_url_parts['path'];
936 936
 
937 937
 		// Else it's a relative path.
938
-		} elseif ( ! empty( $relative_url_parts['path'] ) ) {
938
+		} elseif ( ! empty($relative_url_parts['path'])) {
939 939
 			// Strip off any file components from the absolute path.
940
-			$path = substr( $path, 0, strrpos( $path, '/' ) + 1 );
940
+			$path = substr($path, 0, strrpos($path, '/') + 1);
941 941
 
942 942
 			// Build the new path.
943 943
 			$path .= $relative_url_parts['path'];
944 944
 
945 945
 			// Strip all /path/../ out of the path.
946
-			while ( strpos( $path, '../' ) > 1 ) {
947
-				$path = preg_replace( '![^/]+/\.\./!', '', $path );
946
+			while (strpos($path, '../') > 1) {
947
+				$path = preg_replace('![^/]+/\.\./!', '', $path);
948 948
 			}
949 949
 
950 950
 			// Strip any final leading ../ from the path.
951
-			$path = preg_replace( '!^/(\.\./)+!', '', $path );
951
+			$path = preg_replace('!^/(\.\./)+!', '', $path);
952 952
 		}
953 953
 
954 954
 		// Add the Query string.
955
-		if ( ! empty( $relative_url_parts['query'] ) )
956
-			$path .= '?' . $relative_url_parts['query'];
955
+		if ( ! empty($relative_url_parts['query']))
956
+			$path .= '?'.$relative_url_parts['query'];
957 957
 
958
-		return $absolute_path . '/' . ltrim( $path, '/' );
958
+		return $absolute_path.'/'.ltrim($path, '/');
959 959
 	}
960 960
 
961 961
 	/**
@@ -970,42 +970,42 @@  discard block
 block discarded – undo
970 970
 	 * @param array $response The Response of the HTTP request.
971 971
 	 * @return false|object False if no redirect is present, a WP_HTTP or WP_Error result otherwise.
972 972
 	 */
973
-	public static function handle_redirects( $url, $args, $response ) {
973
+	public static function handle_redirects($url, $args, $response) {
974 974
 		// If no redirects are present, or, redirects were not requested, perform no action.
975
-		if ( ! isset( $response['headers']['location'] ) || 0 === $args['_redirection'] )
975
+		if ( ! isset($response['headers']['location']) || 0 === $args['_redirection'])
976 976
 			return false;
977 977
 
978 978
 		// Only perform redirections on redirection http codes.
979
-		if ( $response['response']['code'] > 399 || $response['response']['code'] < 300 )
979
+		if ($response['response']['code'] > 399 || $response['response']['code'] < 300)
980 980
 			return false;
981 981
 
982 982
 		// Don't redirect if we've run out of redirects.
983
-		if ( $args['redirection']-- <= 0 )
984
-			return new WP_Error( 'http_request_failed', __('Too many redirects.') );
983
+		if ($args['redirection']-- <= 0)
984
+			return new WP_Error('http_request_failed', __('Too many redirects.'));
985 985
 
986 986
 		$redirect_location = $response['headers']['location'];
987 987
 
988 988
 		// If there were multiple Location headers, use the last header specified.
989
-		if ( is_array( $redirect_location ) )
990
-			$redirect_location = array_pop( $redirect_location );
989
+		if (is_array($redirect_location))
990
+			$redirect_location = array_pop($redirect_location);
991 991
 
992
-		$redirect_location = WP_Http::make_absolute_url( $redirect_location, $url );
992
+		$redirect_location = WP_Http::make_absolute_url($redirect_location, $url);
993 993
 
994 994
 		// POST requests should not POST to a redirected location.
995
-		if ( 'POST' == $args['method'] ) {
996
-			if ( in_array( $response['response']['code'], array( 302, 303 ) ) )
995
+		if ('POST' == $args['method']) {
996
+			if (in_array($response['response']['code'], array(302, 303)))
997 997
 				$args['method'] = 'GET';
998 998
 		}
999 999
 
1000 1000
 		// Include valid cookies in the redirect process.
1001
-		if ( ! empty( $response['cookies'] ) ) {
1002
-			foreach ( $response['cookies'] as $cookie ) {
1003
-				if ( $cookie->test( $redirect_location ) )
1001
+		if ( ! empty($response['cookies'])) {
1002
+			foreach ($response['cookies'] as $cookie) {
1003
+				if ($cookie->test($redirect_location))
1004 1004
 					$args['cookies'][] = $cookie;
1005 1005
 			}
1006 1006
 		}
1007 1007
 
1008
-		return wp_remote_request( $redirect_location, $args );
1008
+		return wp_remote_request($redirect_location, $args);
1009 1009
 	}
1010 1010
 
1011 1011
 	/**
@@ -1024,11 +1024,11 @@  discard block
 block discarded – undo
1024 1024
 	 * @param string $maybe_ip A suspected IP address
1025 1025
 	 * @return integer|bool Upon success, '4' or '6' to represent a IPv4 or IPv6 address, false upon failure
1026 1026
 	 */
1027
-	public static function is_ip_address( $maybe_ip ) {
1028
-		if ( preg_match( '/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $maybe_ip ) )
1027
+	public static function is_ip_address($maybe_ip) {
1028
+		if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $maybe_ip))
1029 1029
 			return 4;
1030 1030
 
1031
-		if ( false !== strpos( $maybe_ip, ':' ) && preg_match( '/^(((?=.*(::))(?!.*\3.+\3))\3?|([\dA-F]{1,4}(\3|:\b|$)|\2))(?4){5}((?4){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i', trim( $maybe_ip, ' []' ) ) )
1031
+		if (false !== strpos($maybe_ip, ':') && preg_match('/^(((?=.*(::))(?!.*\3.+\3))\3?|([\dA-F]{1,4}(\3|:\b|$)|\2))(?4){5}((?4){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i', trim($maybe_ip, ' []')))
1032 1032
 			return 6;
1033 1033
 
1034 1034
 		return false;
Please login to merge, or discard this patch.
src/wp-includes/class-wp-comment-query.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1004,7 +1004,7 @@
 block discarded – undo
1004 1004
 	 * @global wpdb $wpdb WordPress database abstraction object.
1005 1005
 	 *
1006 1006
 	 * @param string $string
1007
-	 * @param array $cols
1007
+	 * @param string[] $cols
1008 1008
 	 * @return string
1009 1009
 	 */
1010 1010
 	protected function get_search_sql( $string, $cols ) {
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -251,7 +251,7 @@
 block discarded – undo
251 251
 	 *                                                   The parameter is ignored (forced to `false`) when
252 252
 	 *                                                   `$fields` is 'ids' or 'counts'. Accepts 'threaded',
253 253
 	 *                                                   'flat', or false. Default: false.
254
- 	 *     @type string       $cache_domain              Unique cache key to be produced when this query is stored in
254
+	 *     @type string       $cache_domain              Unique cache key to be produced when this query is stored in
255 255
 	 *                                                   an object cache. Default is 'core'.
256 256
 	 *     @type bool         $update_comment_meta_cache Whether to prime the metadata cache for found comments.
257 257
 	 *                                                   Default true.
Please login to merge, or discard this patch.
Spacing   +236 added lines, -237 removed lines patch added patch discarded remove patch
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
 	 * @param array    $arguments Arguments to pass when calling.
135 135
 	 * @return mixed|false Return value of the callback, false otherwise.
136 136
 	 */
137
-	public function __call( $name, $arguments ) {
138
-		if ( 'get_search_sql' === $name ) {
139
-			return call_user_func_array( array( $this, $name ), $arguments );
137
+	public function __call($name, $arguments) {
138
+		if ('get_search_sql' === $name) {
139
+			return call_user_func_array(array($this, $name), $arguments);
140 140
 		}
141 141
 		return false;
142 142
 	}
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 	 *                                                   Default false.
260 260
 	 * }
261 261
 	 */
262
-	public function __construct( $query = '' ) {
262
+	public function __construct($query = '') {
263 263
 		$this->query_var_defaults = array(
264 264
 			'author_email' => '',
265 265
 			'author_url' => '',
@@ -307,8 +307,8 @@  discard block
 block discarded – undo
307 307
 			'update_comment_post_cache' => false,
308 308
 		);
309 309
 
310
-		if ( ! empty( $query ) ) {
311
-			$this->query( $query );
310
+		if ( ! empty($query)) {
311
+			$this->query($query);
312 312
 		}
313 313
 	}
314 314
 
@@ -321,12 +321,12 @@  discard block
 block discarded – undo
321 321
 	 *
322 322
 	 * @param string|array $query WP_Comment_Query arguments. See WP_Comment_Query::__construct()
323 323
 	 */
324
-	public function parse_query( $query = '' ) {
325
-		if ( empty( $query ) ) {
324
+	public function parse_query($query = '') {
325
+		if (empty($query)) {
326 326
 			$query = $this->query_vars;
327 327
 		}
328 328
 
329
-		$this->query_vars = wp_parse_args( $query, $this->query_var_defaults );
329
+		$this->query_vars = wp_parse_args($query, $this->query_var_defaults);
330 330
 
331 331
 		/**
332 332
 		 * Fires after the comment query vars have been parsed.
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 		 *
336 336
 		 * @param WP_Comment_Query &$this The WP_Comment_Query instance (passed by reference).
337 337
 		 */
338
-		do_action_ref_array( 'parse_comment_query', array( &$this ) );
338
+		do_action_ref_array('parse_comment_query', array(&$this));
339 339
 	}
340 340
 
341 341
 	/**
@@ -352,8 +352,8 @@  discard block
 block discarded – undo
352 352
 	 * @param string|array $query Array or URL query string of parameters.
353 353
 	 * @return array|int List of comments, or number of comments when 'count' is passed as a query var.
354 354
 	 */
355
-	public function query( $query ) {
356
-		$this->query_vars = wp_parse_args( $query );
355
+	public function query($query) {
356
+		$this->query_vars = wp_parse_args($query);
357 357
 		return $this->get_comments();
358 358
 	}
359 359
 
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 
375 375
 		// Parse meta query
376 376
 		$this->meta_query = new WP_Meta_Query();
377
-		$this->meta_query->parse_query_vars( $this->query_vars );
377
+		$this->meta_query->parse_query_vars($this->query_vars);
378 378
 
379 379
 		/**
380 380
 		 * Fires before comments are retrieved.
@@ -383,24 +383,24 @@  discard block
 block discarded – undo
383 383
 		 *
384 384
 		 * @param WP_Comment_Query &$this Current instance of WP_Comment_Query, passed by reference.
385 385
 		 */
386
-		do_action_ref_array( 'pre_get_comments', array( &$this ) );
386
+		do_action_ref_array('pre_get_comments', array(&$this));
387 387
 
388 388
 		// Reparse query vars, in case they were modified in a 'pre_get_comments' callback.
389
-		$this->meta_query->parse_query_vars( $this->query_vars );
390
-		if ( ! empty( $this->meta_query->queries ) ) {
391
-			$this->meta_query_clauses = $this->meta_query->get_sql( 'comment', $wpdb->comments, 'comment_ID', $this );
389
+		$this->meta_query->parse_query_vars($this->query_vars);
390
+		if ( ! empty($this->meta_query->queries)) {
391
+			$this->meta_query_clauses = $this->meta_query->get_sql('comment', $wpdb->comments, 'comment_ID', $this);
392 392
 		}
393 393
 
394 394
 		// $args can include anything. Only use the args defined in the query_var_defaults to compute the key.
395
-		$key = md5( serialize( wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) ) ) );
396
-		$last_changed = wp_cache_get_last_changed( 'comment' );
395
+		$key = md5(serialize(wp_array_slice_assoc($this->query_vars, array_keys($this->query_var_defaults))));
396
+		$last_changed = wp_cache_get_last_changed('comment');
397 397
 
398 398
 
399 399
 		$cache_key   = "get_comments:$key:$last_changed";
400
-		$cache_value = wp_cache_get( $cache_key, 'comment' );
401
-		if ( false === $cache_value ) {
400
+		$cache_value = wp_cache_get($cache_key, 'comment');
401
+		if (false === $cache_value) {
402 402
 			$comment_ids = $this->get_comment_ids();
403
-			if ( $comment_ids ) {
403
+			if ($comment_ids) {
404 404
 				$this->set_found_comments();
405 405
 			}
406 406
 
@@ -408,47 +408,47 @@  discard block
 block discarded – undo
408 408
 				'comment_ids'    => $comment_ids,
409 409
 				'found_comments' => $this->found_comments,
410 410
 			);
411
-			wp_cache_add( $cache_key, $cache_value, 'comment' );
411
+			wp_cache_add($cache_key, $cache_value, 'comment');
412 412
 		} else {
413 413
 			$comment_ids          = $cache_value['comment_ids'];
414 414
 			$this->found_comments = $cache_value['found_comments'];
415 415
 		}
416 416
 
417
-		if ( $this->found_comments && $this->query_vars['number'] ) {
418
-			$this->max_num_pages = ceil( $this->found_comments / $this->query_vars['number'] );
417
+		if ($this->found_comments && $this->query_vars['number']) {
418
+			$this->max_num_pages = ceil($this->found_comments / $this->query_vars['number']);
419 419
 		}
420 420
 
421 421
 		// If querying for a count only, there's nothing more to do.
422
-		if ( $this->query_vars['count'] ) {
422
+		if ($this->query_vars['count']) {
423 423
 			// $comment_ids is actually a count in this case.
424
-			return intval( $comment_ids );
424
+			return intval($comment_ids);
425 425
 		}
426 426
 
427
-		$comment_ids = array_map( 'intval', $comment_ids );
427
+		$comment_ids = array_map('intval', $comment_ids);
428 428
 
429
-		if ( 'ids' == $this->query_vars['fields'] ) {
429
+		if ('ids' == $this->query_vars['fields']) {
430 430
 			$this->comments = $comment_ids;
431 431
 			return $this->comments;
432 432
 		}
433 433
 
434
-		_prime_comment_caches( $comment_ids, $this->query_vars['update_comment_meta_cache'] );
434
+		_prime_comment_caches($comment_ids, $this->query_vars['update_comment_meta_cache']);
435 435
 
436 436
 		// Fetch full comment objects from the primed cache.
437 437
 		$_comments = array();
438
-		foreach ( $comment_ids as $comment_id ) {
439
-			if ( $_comment = get_comment( $comment_id ) ) {
438
+		foreach ($comment_ids as $comment_id) {
439
+			if ($_comment = get_comment($comment_id)) {
440 440
 				$_comments[] = $_comment;
441 441
 			}
442 442
 		}
443 443
 
444 444
 		// Prime comment post caches.
445
-		if ( $this->query_vars['update_comment_post_cache'] ) {
445
+		if ($this->query_vars['update_comment_post_cache']) {
446 446
 			$comment_post_ids = array();
447
-			foreach ( $_comments as $_comment ) {
447
+			foreach ($_comments as $_comment) {
448 448
 				$comment_post_ids[] = $_comment->comment_post_ID;
449 449
 			}
450 450
 
451
-			_prime_post_caches( $comment_post_ids, false, false );
451
+			_prime_post_caches($comment_post_ids, false, false);
452 452
 		}
453 453
 
454 454
 		/**
@@ -459,13 +459,13 @@  discard block
 block discarded – undo
459 459
 		 * @param array            $results  An array of comments.
460 460
 		 * @param WP_Comment_Query &$this    Current instance of WP_Comment_Query, passed by reference.
461 461
 		 */
462
-		$_comments = apply_filters_ref_array( 'the_comments', array( $_comments, &$this ) );
462
+		$_comments = apply_filters_ref_array('the_comments', array($_comments, &$this));
463 463
 
464 464
 		// Convert to WP_Comment instances
465
-		$comments = array_map( 'get_comment', $_comments );
465
+		$comments = array_map('get_comment', $_comments);
466 466
 
467
-		if ( $this->query_vars['hierarchical'] ) {
468
-			$comments = $this->fill_descendants( $comments );
467
+		if ($this->query_vars['hierarchical']) {
468
+			$comments = $this->fill_descendants($comments);
469 469
 		}
470 470
 
471 471
 		$this->comments = $comments;
@@ -489,14 +489,14 @@  discard block
 block discarded – undo
489 489
 		// 'status' accepts an array or a comma-separated string.
490 490
 		$status_clauses = array();
491 491
 		$statuses = $this->query_vars['status'];
492
-		if ( ! is_array( $statuses ) ) {
493
-			$statuses = preg_split( '/[\s,]+/', $statuses );
492
+		if ( ! is_array($statuses)) {
493
+			$statuses = preg_split('/[\s,]+/', $statuses);
494 494
 		}
495 495
 
496 496
 		// 'any' overrides other statuses.
497
-		if ( ! in_array( 'any', $statuses ) ) {
498
-			foreach ( $statuses as $status ) {
499
-				switch ( $status ) {
497
+		if ( ! in_array('any', $statuses)) {
498
+			foreach ($statuses as $status) {
499
+				switch ($status) {
500 500
 					case 'hold' :
501 501
 						$status_clauses[] = "comment_approved = '0'";
502 502
 						break;
@@ -511,65 +511,64 @@  discard block
 block discarded – undo
511 511
 						break;
512 512
 
513 513
 					default :
514
-						$status_clauses[] = $wpdb->prepare( "comment_approved = %s", $status );
514
+						$status_clauses[] = $wpdb->prepare("comment_approved = %s", $status);
515 515
 						break;
516 516
 				}
517 517
 			}
518 518
 
519
-			if ( ! empty( $status_clauses ) ) {
520
-				$approved_clauses[] = '( ' . implode( ' OR ', $status_clauses ) . ' )';
519
+			if ( ! empty($status_clauses)) {
520
+				$approved_clauses[] = '( '.implode(' OR ', $status_clauses).' )';
521 521
 			}
522 522
 		}
523 523
 
524 524
 		// User IDs or emails whose unapproved comments are included, regardless of $status.
525
-		if ( ! empty( $this->query_vars['include_unapproved'] ) ) {
525
+		if ( ! empty($this->query_vars['include_unapproved'])) {
526 526
 			$include_unapproved = $this->query_vars['include_unapproved'];
527 527
 
528 528
 			// Accepts arrays or comma-separated strings.
529
-			if ( ! is_array( $include_unapproved ) ) {
530
-				$include_unapproved = preg_split( '/[\s,]+/', $include_unapproved );
529
+			if ( ! is_array($include_unapproved)) {
530
+				$include_unapproved = preg_split('/[\s,]+/', $include_unapproved);
531 531
 			}
532 532
 
533 533
 			$unapproved_ids = $unapproved_emails = array();
534
-			foreach ( $include_unapproved as $unapproved_identifier ) {
534
+			foreach ($include_unapproved as $unapproved_identifier) {
535 535
 				// Numeric values are assumed to be user ids.
536
-				if ( is_numeric( $unapproved_identifier ) ) {
537
-					$approved_clauses[] = $wpdb->prepare( "( user_id = %d AND comment_approved = '0' )", $unapproved_identifier );
536
+				if (is_numeric($unapproved_identifier)) {
537
+					$approved_clauses[] = $wpdb->prepare("( user_id = %d AND comment_approved = '0' )", $unapproved_identifier);
538 538
 
539 539
 				// Otherwise we match against email addresses.
540 540
 				} else {
541
-					$approved_clauses[] = $wpdb->prepare( "( comment_author_email = %s AND comment_approved = '0' )", $unapproved_identifier );
541
+					$approved_clauses[] = $wpdb->prepare("( comment_author_email = %s AND comment_approved = '0' )", $unapproved_identifier);
542 542
 				}
543 543
 			}
544 544
 		}
545 545
 
546 546
 		// Collapse comment_approved clauses into a single OR-separated clause.
547
-		if ( ! empty( $approved_clauses ) ) {
548
-			if ( 1 === count( $approved_clauses ) ) {
547
+		if ( ! empty($approved_clauses)) {
548
+			if (1 === count($approved_clauses)) {
549 549
 				$this->sql_clauses['where']['approved'] = $approved_clauses[0];
550 550
 			} else {
551
-				$this->sql_clauses['where']['approved'] = '( ' . implode( ' OR ', $approved_clauses ) . ' )';
551
+				$this->sql_clauses['where']['approved'] = '( '.implode(' OR ', $approved_clauses).' )';
552 552
 			}
553 553
 		}
554 554
 
555
-		$order = ( 'ASC' == strtoupper( $this->query_vars['order'] ) ) ? 'ASC' : 'DESC';
555
+		$order = ('ASC' == strtoupper($this->query_vars['order'])) ? 'ASC' : 'DESC';
556 556
 
557 557
 		// Disable ORDER BY with 'none', an empty array, or boolean false.
558
-		if ( in_array( $this->query_vars['orderby'], array( 'none', array(), false ), true ) ) {
558
+		if (in_array($this->query_vars['orderby'], array('none', array(), false), true)) {
559 559
 			$orderby = '';
560
-		} elseif ( ! empty( $this->query_vars['orderby'] ) ) {
561
-			$ordersby = is_array( $this->query_vars['orderby'] ) ?
562
-				$this->query_vars['orderby'] :
563
-				preg_split( '/[,\s]/', $this->query_vars['orderby'] );
560
+		} elseif ( ! empty($this->query_vars['orderby'])) {
561
+			$ordersby = is_array($this->query_vars['orderby']) ?
562
+				$this->query_vars['orderby'] : preg_split('/[,\s]/', $this->query_vars['orderby']);
564 563
 
565 564
 			$orderby_array = array();
566 565
 			$found_orderby_comment_ID = false;
567
-			foreach ( $ordersby as $_key => $_value ) {
568
-				if ( ! $_value ) {
566
+			foreach ($ordersby as $_key => $_value) {
567
+				if ( ! $_value) {
569 568
 					continue;
570 569
 				}
571 570
 
572
-				if ( is_int( $_key ) ) {
571
+				if (is_int($_key)) {
573 572
 					$_orderby = $_value;
574 573
 					$_order = $order;
575 574
 				} else {
@@ -577,45 +576,45 @@  discard block
 block discarded – undo
577 576
 					$_order = $_value;
578 577
 				}
579 578
 
580
-				if ( ! $found_orderby_comment_ID && in_array( $_orderby, array( 'comment_ID', 'comment__in' ) ) ) {
579
+				if ( ! $found_orderby_comment_ID && in_array($_orderby, array('comment_ID', 'comment__in'))) {
581 580
 					$found_orderby_comment_ID = true;
582 581
 				}
583 582
 
584
-				$parsed = $this->parse_orderby( $_orderby );
583
+				$parsed = $this->parse_orderby($_orderby);
585 584
 
586
-				if ( ! $parsed ) {
585
+				if ( ! $parsed) {
587 586
 					continue;
588 587
 				}
589 588
 
590
-				if ( 'comment__in' === $_orderby ) {
589
+				if ('comment__in' === $_orderby) {
591 590
 					$orderby_array[] = $parsed;
592 591
 					continue;
593 592
 				}
594 593
 
595
-				$orderby_array[] = $parsed . ' ' . $this->parse_order( $_order );
594
+				$orderby_array[] = $parsed.' '.$this->parse_order($_order);
596 595
 			}
597 596
 
598 597
 			// If no valid clauses were found, order by comment_date_gmt.
599
-			if ( empty( $orderby_array ) ) {
598
+			if (empty($orderby_array)) {
600 599
 				$orderby_array[] = "$wpdb->comments.comment_date_gmt $order";
601 600
 			}
602 601
 
603 602
 			// To ensure determinate sorting, always include a comment_ID clause.
604
-			if ( ! $found_orderby_comment_ID ) {
603
+			if ( ! $found_orderby_comment_ID) {
605 604
 				$comment_ID_order = '';
606 605
 
607 606
 				// Inherit order from comment_date or comment_date_gmt, if available.
608
-				foreach ( $orderby_array as $orderby_clause ) {
609
-					if ( preg_match( '/comment_date(?:_gmt)*\ (ASC|DESC)/', $orderby_clause, $match ) ) {
607
+				foreach ($orderby_array as $orderby_clause) {
608
+					if (preg_match('/comment_date(?:_gmt)*\ (ASC|DESC)/', $orderby_clause, $match)) {
610 609
 						$comment_ID_order = $match[1];
611 610
 						break;
612 611
 					}
613 612
 				}
614 613
 
615 614
 				// If no date-related order is available, use the date from the first available clause.
616
-				if ( ! $comment_ID_order ) {
617
-					foreach ( $orderby_array as $orderby_clause ) {
618
-						if ( false !== strpos( 'ASC', $orderby_clause ) ) {
615
+				if ( ! $comment_ID_order) {
616
+					foreach ($orderby_array as $orderby_clause) {
617
+						if (false !== strpos('ASC', $orderby_clause)) {
619 618
 							$comment_ID_order = 'ASC';
620 619
 						} else {
621 620
 							$comment_ID_order = 'DESC';
@@ -626,94 +625,94 @@  discard block
 block discarded – undo
626 625
 				}
627 626
 
628 627
 				// Default to DESC.
629
-				if ( ! $comment_ID_order ) {
628
+				if ( ! $comment_ID_order) {
630 629
 					$comment_ID_order = 'DESC';
631 630
 				}
632 631
 
633 632
 				$orderby_array[] = "$wpdb->comments.comment_ID $comment_ID_order";
634 633
 			}
635 634
 
636
-			$orderby = implode( ', ', $orderby_array );
635
+			$orderby = implode(', ', $orderby_array);
637 636
 		} else {
638 637
 			$orderby = "$wpdb->comments.comment_date_gmt $order";
639 638
 		}
640 639
 
641
-		$number = absint( $this->query_vars['number'] );
642
-		$offset = absint( $this->query_vars['offset'] );
640
+		$number = absint($this->query_vars['number']);
641
+		$offset = absint($this->query_vars['offset']);
643 642
 
644
-		if ( ! empty( $number ) ) {
645
-			if ( $offset ) {
646
-				$limits = 'LIMIT ' . $offset . ',' . $number;
643
+		if ( ! empty($number)) {
644
+			if ($offset) {
645
+				$limits = 'LIMIT '.$offset.','.$number;
647 646
 			} else {
648
-				$limits = 'LIMIT ' . $number;
647
+				$limits = 'LIMIT '.$number;
649 648
 			}
650 649
 		}
651 650
 
652
-		if ( $this->query_vars['count'] ) {
651
+		if ($this->query_vars['count']) {
653 652
 			$fields = 'COUNT(*)';
654 653
 		} else {
655 654
 			$fields = "$wpdb->comments.comment_ID";
656 655
 		}
657 656
 
658
-		$post_id = absint( $this->query_vars['post_id'] );
659
-		if ( ! empty( $post_id ) ) {
660
-			$this->sql_clauses['where']['post_id'] = $wpdb->prepare( 'comment_post_ID = %d', $post_id );
657
+		$post_id = absint($this->query_vars['post_id']);
658
+		if ( ! empty($post_id)) {
659
+			$this->sql_clauses['where']['post_id'] = $wpdb->prepare('comment_post_ID = %d', $post_id);
661 660
 		}
662 661
 
663 662
 		// Parse comment IDs for an IN clause.
664
-		if ( ! empty( $this->query_vars['comment__in'] ) ) {
665
-			$this->sql_clauses['where']['comment__in'] = "$wpdb->comments.comment_ID IN ( " . implode( ',', wp_parse_id_list( $this->query_vars['comment__in'] ) ) . ' )';
663
+		if ( ! empty($this->query_vars['comment__in'])) {
664
+			$this->sql_clauses['where']['comment__in'] = "$wpdb->comments.comment_ID IN ( ".implode(',', wp_parse_id_list($this->query_vars['comment__in'])).' )';
666 665
 		}
667 666
 
668 667
 		// Parse comment IDs for a NOT IN clause.
669
-		if ( ! empty( $this->query_vars['comment__not_in'] ) ) {
670
-			$this->sql_clauses['where']['comment__not_in'] = "$wpdb->comments.comment_ID NOT IN ( " . implode( ',', wp_parse_id_list( $this->query_vars['comment__not_in'] ) ) . ' )';
668
+		if ( ! empty($this->query_vars['comment__not_in'])) {
669
+			$this->sql_clauses['where']['comment__not_in'] = "$wpdb->comments.comment_ID NOT IN ( ".implode(',', wp_parse_id_list($this->query_vars['comment__not_in'])).' )';
671 670
 		}
672 671
 
673 672
 		// Parse comment parent IDs for an IN clause.
674
-		if ( ! empty( $this->query_vars['parent__in'] ) ) {
675
-			$this->sql_clauses['where']['parent__in'] = 'comment_parent IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['parent__in'] ) ) . ' )';
673
+		if ( ! empty($this->query_vars['parent__in'])) {
674
+			$this->sql_clauses['where']['parent__in'] = 'comment_parent IN ( '.implode(',', wp_parse_id_list($this->query_vars['parent__in'])).' )';
676 675
 		}
677 676
 
678 677
 		// Parse comment parent IDs for a NOT IN clause.
679
-		if ( ! empty( $this->query_vars['parent__not_in'] ) ) {
680
-			$this->sql_clauses['where']['parent__not_in'] = 'comment_parent NOT IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['parent__not_in'] ) ) . ' )';
678
+		if ( ! empty($this->query_vars['parent__not_in'])) {
679
+			$this->sql_clauses['where']['parent__not_in'] = 'comment_parent NOT IN ( '.implode(',', wp_parse_id_list($this->query_vars['parent__not_in'])).' )';
681 680
 		}
682 681
 
683 682
 		// Parse comment post IDs for an IN clause.
684
-		if ( ! empty( $this->query_vars['post__in'] ) ) {
685
-			$this->sql_clauses['where']['post__in'] = 'comment_post_ID IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['post__in'] ) ) . ' )';
683
+		if ( ! empty($this->query_vars['post__in'])) {
684
+			$this->sql_clauses['where']['post__in'] = 'comment_post_ID IN ( '.implode(',', wp_parse_id_list($this->query_vars['post__in'])).' )';
686 685
 		}
687 686
 
688 687
 		// Parse comment post IDs for a NOT IN clause.
689
-		if ( ! empty( $this->query_vars['post__not_in'] ) ) {
690
-			$this->sql_clauses['where']['post__not_in'] = 'comment_post_ID NOT IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['post__not_in'] ) ) . ' )';
688
+		if ( ! empty($this->query_vars['post__not_in'])) {
689
+			$this->sql_clauses['where']['post__not_in'] = 'comment_post_ID NOT IN ( '.implode(',', wp_parse_id_list($this->query_vars['post__not_in'])).' )';
691 690
 		}
692 691
 
693
-		if ( '' !== $this->query_vars['author_email'] ) {
694
-			$this->sql_clauses['where']['author_email'] = $wpdb->prepare( 'comment_author_email = %s', $this->query_vars['author_email'] );
692
+		if ('' !== $this->query_vars['author_email']) {
693
+			$this->sql_clauses['where']['author_email'] = $wpdb->prepare('comment_author_email = %s', $this->query_vars['author_email']);
695 694
 		}
696 695
 
697
-		if ( '' !== $this->query_vars['author_url'] ) {
698
-			$this->sql_clauses['where']['author_url'] = $wpdb->prepare( 'comment_author_url = %s', $this->query_vars['author_url'] );
696
+		if ('' !== $this->query_vars['author_url']) {
697
+			$this->sql_clauses['where']['author_url'] = $wpdb->prepare('comment_author_url = %s', $this->query_vars['author_url']);
699 698
 		}
700 699
 
701
-		if ( '' !== $this->query_vars['karma'] ) {
702
-			$this->sql_clauses['where']['karma'] = $wpdb->prepare( 'comment_karma = %d', $this->query_vars['karma'] );
700
+		if ('' !== $this->query_vars['karma']) {
701
+			$this->sql_clauses['where']['karma'] = $wpdb->prepare('comment_karma = %d', $this->query_vars['karma']);
703 702
 		}
704 703
 
705 704
 		// Filtering by comment_type: 'type', 'type__in', 'type__not_in'.
706 705
 		$raw_types = array(
707
-			'IN' => array_merge( (array) $this->query_vars['type'], (array) $this->query_vars['type__in'] ),
706
+			'IN' => array_merge((array) $this->query_vars['type'], (array) $this->query_vars['type__in']),
708 707
 			'NOT IN' => (array) $this->query_vars['type__not_in'],
709 708
 		);
710 709
 
711 710
 		$comment_types = array();
712
-		foreach ( $raw_types as $operator => $_raw_types ) {
713
-			$_raw_types = array_unique( $_raw_types );
711
+		foreach ($raw_types as $operator => $_raw_types) {
712
+			$_raw_types = array_unique($_raw_types);
714 713
 
715
-			foreach ( $_raw_types as $type ) {
716
-				switch ( $type ) {
714
+			foreach ($_raw_types as $type) {
715
+				switch ($type) {
717 716
 					// An empty translates to 'all', for backward compatibility
718 717
 					case '':
719 718
 					case 'all' :
@@ -721,134 +720,134 @@  discard block
 block discarded – undo
721 720
 
722 721
 					case 'comment':
723 722
 					case 'comments':
724
-						$comment_types[ $operator ][] = "''";
723
+						$comment_types[$operator][] = "''";
725 724
 						break;
726 725
 
727 726
 					case 'pings':
728
-						$comment_types[ $operator ][] = "'pingback'";
729
-						$comment_types[ $operator ][] = "'trackback'";
727
+						$comment_types[$operator][] = "'pingback'";
728
+						$comment_types[$operator][] = "'trackback'";
730 729
 						break;
731 730
 
732 731
 					default:
733
-						$comment_types[ $operator ][] = $wpdb->prepare( '%s', $type );
732
+						$comment_types[$operator][] = $wpdb->prepare('%s', $type);
734 733
 						break;
735 734
 				}
736 735
 			}
737 736
 
738
-			if ( ! empty( $comment_types[ $operator ] ) ) {
739
-				$types_sql = implode( ', ', $comment_types[ $operator ] );
740
-				$this->sql_clauses['where']['comment_type__' . strtolower( str_replace( ' ', '_', $operator ) ) ] = "comment_type $operator ($types_sql)";
737
+			if ( ! empty($comment_types[$operator])) {
738
+				$types_sql = implode(', ', $comment_types[$operator]);
739
+				$this->sql_clauses['where']['comment_type__'.strtolower(str_replace(' ', '_', $operator))] = "comment_type $operator ($types_sql)";
741 740
 			}
742 741
 		}
743 742
 
744 743
 		$parent = $this->query_vars['parent'];
745
-		if ( $this->query_vars['hierarchical'] && ! $parent ) {
744
+		if ($this->query_vars['hierarchical'] && ! $parent) {
746 745
 			$parent = 0;
747 746
 		}
748 747
 
749
-		if ( '' !== $parent ) {
750
-			$this->sql_clauses['where']['parent'] = $wpdb->prepare( 'comment_parent = %d', $parent );
748
+		if ('' !== $parent) {
749
+			$this->sql_clauses['where']['parent'] = $wpdb->prepare('comment_parent = %d', $parent);
751 750
 		}
752 751
 
753
-		if ( is_array( $this->query_vars['user_id'] ) ) {
754
-			$this->sql_clauses['where']['user_id'] = 'user_id IN (' . implode( ',', array_map( 'absint', $this->query_vars['user_id'] ) ) . ')';
755
-		} elseif ( '' !== $this->query_vars['user_id'] ) {
756
-			$this->sql_clauses['where']['user_id'] = $wpdb->prepare( 'user_id = %d', $this->query_vars['user_id'] );
752
+		if (is_array($this->query_vars['user_id'])) {
753
+			$this->sql_clauses['where']['user_id'] = 'user_id IN ('.implode(',', array_map('absint', $this->query_vars['user_id'])).')';
754
+		} elseif ('' !== $this->query_vars['user_id']) {
755
+			$this->sql_clauses['where']['user_id'] = $wpdb->prepare('user_id = %d', $this->query_vars['user_id']);
757 756
 		}
758 757
 
759 758
 		// Falsy search strings are ignored.
760
-		if ( strlen( $this->query_vars['search'] ) ) {
759
+		if (strlen($this->query_vars['search'])) {
761 760
 			$search_sql = $this->get_search_sql(
762 761
 				$this->query_vars['search'],
763
-				array( 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_content' )
762
+				array('comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_content')
764 763
 			);
765 764
 
766 765
 			// Strip leading 'AND'.
767
-			$this->sql_clauses['where']['search'] = preg_replace( '/^\s*AND\s*/', '', $search_sql );
766
+			$this->sql_clauses['where']['search'] = preg_replace('/^\s*AND\s*/', '', $search_sql);
768 767
 		}
769 768
 
770 769
 		// If any post-related query vars are passed, join the posts table.
771 770
 		$join_posts_table = false;
772
-		$plucked = wp_array_slice_assoc( $this->query_vars, array( 'post_author', 'post_name', 'post_parent' ) );
773
-		$post_fields = array_filter( $plucked );
771
+		$plucked = wp_array_slice_assoc($this->query_vars, array('post_author', 'post_name', 'post_parent'));
772
+		$post_fields = array_filter($plucked);
774 773
 
775
-		if ( ! empty( $post_fields ) ) {
774
+		if ( ! empty($post_fields)) {
776 775
 			$join_posts_table = true;
777
-			foreach ( $post_fields as $field_name => $field_value ) {
776
+			foreach ($post_fields as $field_name => $field_value) {
778 777
 				// $field_value may be an array.
779
-				$esses = array_fill( 0, count( (array) $field_value ), '%s' );
780
-				$this->sql_clauses['where'][ $field_name ] = $wpdb->prepare( " {$wpdb->posts}.{$field_name} IN (" . implode( ',', $esses ) . ')', $field_value );
778
+				$esses = array_fill(0, count((array) $field_value), '%s');
779
+				$this->sql_clauses['where'][$field_name] = $wpdb->prepare(" {$wpdb->posts}.{$field_name} IN (".implode(',', $esses).')', $field_value);
781 780
 			}
782 781
 		}
783 782
 
784 783
 		// 'post_status' and 'post_type' are handled separately, due to the specialized behavior of 'any'.
785
-		foreach ( array( 'post_status', 'post_type' ) as $field_name ) {
784
+		foreach (array('post_status', 'post_type') as $field_name) {
786 785
 			$q_values = array();
787
-			if ( ! empty( $this->query_vars[ $field_name ] ) ) {
788
-				$q_values = $this->query_vars[ $field_name ];
789
-				if ( ! is_array( $q_values ) ) {
790
-					$q_values = explode( ',', $q_values );
786
+			if ( ! empty($this->query_vars[$field_name])) {
787
+				$q_values = $this->query_vars[$field_name];
788
+				if ( ! is_array($q_values)) {
789
+					$q_values = explode(',', $q_values);
791 790
 				}
792 791
 
793 792
 				// 'any' will cause the query var to be ignored.
794
-				if ( in_array( 'any', $q_values, true ) || empty( $q_values ) ) {
793
+				if (in_array('any', $q_values, true) || empty($q_values)) {
795 794
 					continue;
796 795
 				}
797 796
 
798 797
 				$join_posts_table = true;
799 798
 
800
-				$esses = array_fill( 0, count( $q_values ), '%s' );
801
-				$this->sql_clauses['where'][ $field_name ] = $wpdb->prepare( " {$wpdb->posts}.{$field_name} IN (" . implode( ',', $esses ) . ")", $q_values );
799
+				$esses = array_fill(0, count($q_values), '%s');
800
+				$this->sql_clauses['where'][$field_name] = $wpdb->prepare(" {$wpdb->posts}.{$field_name} IN (".implode(',', $esses).")", $q_values);
802 801
 			}
803 802
 		}
804 803
 
805 804
 		// Comment author IDs for an IN clause.
806
-		if ( ! empty( $this->query_vars['author__in'] ) ) {
807
-			$this->sql_clauses['where']['author__in'] = 'user_id IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['author__in'] ) ) . ' )';
805
+		if ( ! empty($this->query_vars['author__in'])) {
806
+			$this->sql_clauses['where']['author__in'] = 'user_id IN ( '.implode(',', wp_parse_id_list($this->query_vars['author__in'])).' )';
808 807
 		}
809 808
 
810 809
 		// Comment author IDs for a NOT IN clause.
811
-		if ( ! empty( $this->query_vars['author__not_in'] ) ) {
812
-			$this->sql_clauses['where']['author__not_in'] = 'user_id NOT IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['author__not_in'] ) ) . ' )';
810
+		if ( ! empty($this->query_vars['author__not_in'])) {
811
+			$this->sql_clauses['where']['author__not_in'] = 'user_id NOT IN ( '.implode(',', wp_parse_id_list($this->query_vars['author__not_in'])).' )';
813 812
 		}
814 813
 
815 814
 		// Post author IDs for an IN clause.
816
-		if ( ! empty( $this->query_vars['post_author__in'] ) ) {
815
+		if ( ! empty($this->query_vars['post_author__in'])) {
817 816
 			$join_posts_table = true;
818
-			$this->sql_clauses['where']['post_author__in'] = 'post_author IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['post_author__in'] ) ) . ' )';
817
+			$this->sql_clauses['where']['post_author__in'] = 'post_author IN ( '.implode(',', wp_parse_id_list($this->query_vars['post_author__in'])).' )';
819 818
 		}
820 819
 
821 820
 		// Post author IDs for a NOT IN clause.
822
-		if ( ! empty( $this->query_vars['post_author__not_in'] ) ) {
821
+		if ( ! empty($this->query_vars['post_author__not_in'])) {
823 822
 			$join_posts_table = true;
824
-			$this->sql_clauses['where']['post_author__not_in'] = 'post_author NOT IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['post_author__not_in'] ) ) . ' )';
823
+			$this->sql_clauses['where']['post_author__not_in'] = 'post_author NOT IN ( '.implode(',', wp_parse_id_list($this->query_vars['post_author__not_in'])).' )';
825 824
 		}
826 825
 
827 826
 		$join = '';
828 827
 
829
-		if ( $join_posts_table ) {
828
+		if ($join_posts_table) {
830 829
 			$join .= "JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID";
831 830
 		}
832 831
 
833
-		if ( ! empty( $this->meta_query_clauses ) ) {
832
+		if ( ! empty($this->meta_query_clauses)) {
834 833
 			$join .= $this->meta_query_clauses['join'];
835 834
 
836 835
 			// Strip leading 'AND'.
837
-			$this->sql_clauses['where']['meta_query'] = preg_replace( '/^\s*AND\s*/', '', $this->meta_query_clauses['where'] );
836
+			$this->sql_clauses['where']['meta_query'] = preg_replace('/^\s*AND\s*/', '', $this->meta_query_clauses['where']);
838 837
 
839
-			if ( ! $this->query_vars['count'] ) {
838
+			if ( ! $this->query_vars['count']) {
840 839
 				$groupby = "{$wpdb->comments}.comment_ID";
841 840
 			}
842 841
 		}
843 842
 
844
-		if ( ! empty( $this->query_vars['date_query'] ) && is_array( $this->query_vars['date_query'] ) ) {
845
-			$this->date_query = new WP_Date_Query( $this->query_vars['date_query'], 'comment_date' );
846
-			$this->sql_clauses['where']['date_query'] = preg_replace( '/^\s*AND\s*/', '', $this->date_query->get_sql() );
843
+		if ( ! empty($this->query_vars['date_query']) && is_array($this->query_vars['date_query'])) {
844
+			$this->date_query = new WP_Date_Query($this->query_vars['date_query'], 'comment_date');
845
+			$this->sql_clauses['where']['date_query'] = preg_replace('/^\s*AND\s*/', '', $this->date_query->get_sql());
847 846
 		}
848 847
 
849
-		$where = implode( ' AND ', $this->sql_clauses['where'] );
848
+		$where = implode(' AND ', $this->sql_clauses['where']);
850 849
 
851
-		$pieces = array( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' );
850
+		$pieces = array('fields', 'join', 'where', 'orderby', 'limits', 'groupby');
852 851
 		/**
853 852
 		 * Filters the comment query clauses.
854 853
 		 *
@@ -857,31 +856,31 @@  discard block
 block discarded – undo
857 856
 		 * @param array            $pieces A compacted array of comment query clauses.
858 857
 		 * @param WP_Comment_Query &$this  Current instance of WP_Comment_Query, passed by reference.
859 858
 		 */
860
-		$clauses = apply_filters_ref_array( 'comments_clauses', array( compact( $pieces ), &$this ) );
859
+		$clauses = apply_filters_ref_array('comments_clauses', array(compact($pieces), &$this));
861 860
 
862
-		$fields = isset( $clauses[ 'fields' ] ) ? $clauses[ 'fields' ] : '';
863
-		$join = isset( $clauses[ 'join' ] ) ? $clauses[ 'join' ] : '';
864
-		$where = isset( $clauses[ 'where' ] ) ? $clauses[ 'where' ] : '';
865
-		$orderby = isset( $clauses[ 'orderby' ] ) ? $clauses[ 'orderby' ] : '';
866
-		$limits = isset( $clauses[ 'limits' ] ) ? $clauses[ 'limits' ] : '';
867
-		$groupby = isset( $clauses[ 'groupby' ] ) ? $clauses[ 'groupby' ] : '';
861
+		$fields = isset($clauses['fields']) ? $clauses['fields'] : '';
862
+		$join = isset($clauses['join']) ? $clauses['join'] : '';
863
+		$where = isset($clauses['where']) ? $clauses['where'] : '';
864
+		$orderby = isset($clauses['orderby']) ? $clauses['orderby'] : '';
865
+		$limits = isset($clauses['limits']) ? $clauses['limits'] : '';
866
+		$groupby = isset($clauses['groupby']) ? $clauses['groupby'] : '';
868 867
 
869 868
 		$this->filtered_where_clause = $where;
870 869
 
871
-		if ( $where ) {
872
-			$where = 'WHERE ' . $where;
870
+		if ($where) {
871
+			$where = 'WHERE '.$where;
873 872
 		}
874 873
 
875
-		if ( $groupby ) {
876
-			$groupby = 'GROUP BY ' . $groupby;
874
+		if ($groupby) {
875
+			$groupby = 'GROUP BY '.$groupby;
877 876
 		}
878 877
 
879
-		if ( $orderby ) {
878
+		if ($orderby) {
880 879
 			$orderby = "ORDER BY $orderby";
881 880
 		}
882 881
 
883 882
 		$found_rows = '';
884
-		if ( ! $this->query_vars['no_found_rows'] ) {
883
+		if ( ! $this->query_vars['no_found_rows']) {
885 884
 			$found_rows = 'SQL_CALC_FOUND_ROWS';
886 885
 		}
887 886
 
@@ -893,11 +892,11 @@  discard block
 block discarded – undo
893 892
 
894 893
 		$this->request = "{$this->sql_clauses['select']} {$this->sql_clauses['from']} {$where} {$this->sql_clauses['groupby']} {$this->sql_clauses['orderby']} {$this->sql_clauses['limits']}";
895 894
 
896
-		if ( $this->query_vars['count'] ) {
897
-			return intval( $wpdb->get_var( $this->request ) );
895
+		if ($this->query_vars['count']) {
896
+			return intval($wpdb->get_var($this->request));
898 897
 		} else {
899
-			$comment_ids = $wpdb->get_col( $this->request );
900
-			return array_map( 'intval', $comment_ids );
898
+			$comment_ids = $wpdb->get_col($this->request);
899
+			return array_map('intval', $comment_ids);
901 900
 		}
902 901
 	}
903 902
 
@@ -913,7 +912,7 @@  discard block
 block discarded – undo
913 912
 	private function set_found_comments() {
914 913
 		global $wpdb;
915 914
 
916
-		if ( $this->query_vars['number'] && ! $this->query_vars['no_found_rows'] ) {
915
+		if ($this->query_vars['number'] && ! $this->query_vars['no_found_rows']) {
917 916
 			/**
918 917
 			 * Filters the query used to retrieve found comment count.
919 918
 			 *
@@ -922,9 +921,9 @@  discard block
 block discarded – undo
922 921
 			 * @param string           $found_comments_query SQL query. Default 'SELECT FOUND_ROWS()'.
923 922
 			 * @param WP_Comment_Query $comment_query        The `WP_Comment_Query` instance.
924 923
 			 */
925
-			$found_comments_query = apply_filters( 'found_comments_query', 'SELECT FOUND_ROWS()', $this );
924
+			$found_comments_query = apply_filters('found_comments_query', 'SELECT FOUND_ROWS()', $this);
926 925
 
927
-			$this->found_comments = (int) $wpdb->get_var( $found_comments_query );
926
+			$this->found_comments = (int) $wpdb->get_var($found_comments_query);
928 927
 		}
929 928
 	}
930 929
 
@@ -939,38 +938,38 @@  discard block
 block discarded – undo
939 938
 	 * @param array $comments Array of top-level comments whose descendants should be filled in.
940 939
 	 * @return array
941 940
 	 */
942
-	protected function fill_descendants( $comments ) {
941
+	protected function fill_descendants($comments) {
943 942
 		global $wpdb;
944 943
 
945 944
 		$levels = array(
946
-			0 => wp_list_pluck( $comments, 'comment_ID' ),
945
+			0 => wp_list_pluck($comments, 'comment_ID'),
947 946
 		);
948 947
 
949
-		$key = md5( serialize( wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) ) ) );
950
-		$last_changed = wp_cache_get_last_changed( 'comment' );
948
+		$key = md5(serialize(wp_array_slice_assoc($this->query_vars, array_keys($this->query_var_defaults))));
949
+		$last_changed = wp_cache_get_last_changed('comment');
951 950
 
952 951
 		// Fetch an entire level of the descendant tree at a time.
953 952
 		$level = 0;
954
-		$exclude_keys = array( 'parent', 'parent__in', 'parent__not_in' );
953
+		$exclude_keys = array('parent', 'parent__in', 'parent__not_in');
955 954
 		do {
956 955
 			// Parent-child relationships may be cached. Only query for those that are not.
957 956
 			$child_ids = $uncached_parent_ids = array();
958
-			$_parent_ids = $levels[ $level ];
959
-			foreach ( $_parent_ids as $parent_id ) {
957
+			$_parent_ids = $levels[$level];
958
+			foreach ($_parent_ids as $parent_id) {
960 959
 				$cache_key = "get_comment_child_ids:$parent_id:$key:$last_changed";
961
-				$parent_child_ids = wp_cache_get( $cache_key, 'comment' );
962
-				if ( false !== $parent_child_ids ) {
963
-					$child_ids = array_merge( $child_ids, $parent_child_ids );
960
+				$parent_child_ids = wp_cache_get($cache_key, 'comment');
961
+				if (false !== $parent_child_ids) {
962
+					$child_ids = array_merge($child_ids, $parent_child_ids);
964 963
 				} else {
965 964
 					$uncached_parent_ids[] = $parent_id;
966 965
 				}
967 966
 			}
968 967
 
969
-			if ( $uncached_parent_ids ) {
968
+			if ($uncached_parent_ids) {
970 969
 				// Fetch this level of comments.
971 970
 				$parent_query_args = $this->query_vars;
972
-				foreach ( $exclude_keys as $exclude_key ) {
973
-					$parent_query_args[ $exclude_key ] = '';
971
+				foreach ($exclude_keys as $exclude_key) {
972
+					$parent_query_args[$exclude_key] = '';
974 973
 				}
975 974
 				$parent_query_args['parent__in']    = $uncached_parent_ids;
976 975
 				$parent_query_args['no_found_rows'] = true;
@@ -978,61 +977,61 @@  discard block
 block discarded – undo
978 977
 				$parent_query_args['offset']        = 0;
979 978
 				$parent_query_args['number']        = 0;
980 979
 
981
-				$level_comments = get_comments( $parent_query_args );
980
+				$level_comments = get_comments($parent_query_args);
982 981
 
983 982
 				// Cache parent-child relationships.
984
-				$parent_map = array_fill_keys( $uncached_parent_ids, array() );
985
-				foreach ( $level_comments as $level_comment ) {
986
-					$parent_map[ $level_comment->comment_parent ][] = $level_comment->comment_ID;
983
+				$parent_map = array_fill_keys($uncached_parent_ids, array());
984
+				foreach ($level_comments as $level_comment) {
985
+					$parent_map[$level_comment->comment_parent][] = $level_comment->comment_ID;
987 986
 					$child_ids[] = $level_comment->comment_ID;
988 987
 				}
989 988
 
990
-				foreach ( $parent_map as $parent_id => $children ) {
989
+				foreach ($parent_map as $parent_id => $children) {
991 990
 					$cache_key = "get_comment_child_ids:$parent_id:$key:$last_changed";
992
-					wp_cache_set( $cache_key, $children, 'comment' );
991
+					wp_cache_set($cache_key, $children, 'comment');
993 992
 				}
994 993
 			}
995 994
 
996 995
 			$level++;
997
-			$levels[ $level ] = $child_ids;
998
-		} while ( $child_ids );
996
+			$levels[$level] = $child_ids;
997
+		} while ($child_ids);
999 998
 
1000 999
 		// Prime comment caches for non-top-level comments.
1001 1000
 		$descendant_ids = array();
1002
-		for ( $i = 1, $c = count( $levels ); $i < $c; $i++ ) {
1003
-			$descendant_ids = array_merge( $descendant_ids, $levels[ $i ] );
1001
+		for ($i = 1, $c = count($levels); $i < $c; $i++) {
1002
+			$descendant_ids = array_merge($descendant_ids, $levels[$i]);
1004 1003
 		}
1005 1004
 
1006
-		_prime_comment_caches( $descendant_ids, $this->query_vars['update_comment_meta_cache'] );
1005
+		_prime_comment_caches($descendant_ids, $this->query_vars['update_comment_meta_cache']);
1007 1006
 
1008 1007
 		// Assemble a flat array of all comments + descendants.
1009 1008
 		$all_comments = $comments;
1010
-		foreach ( $descendant_ids as $descendant_id ) {
1011
-			$all_comments[] = get_comment( $descendant_id );
1009
+		foreach ($descendant_ids as $descendant_id) {
1010
+			$all_comments[] = get_comment($descendant_id);
1012 1011
 		}
1013 1012
 
1014 1013
 		// If a threaded representation was requested, build the tree.
1015
-		if ( 'threaded' === $this->query_vars['hierarchical'] ) {
1014
+		if ('threaded' === $this->query_vars['hierarchical']) {
1016 1015
 			$threaded_comments = $ref = array();
1017
-			foreach ( $all_comments as $k => $c ) {
1018
-				$_c = get_comment( $c->comment_ID );
1016
+			foreach ($all_comments as $k => $c) {
1017
+				$_c = get_comment($c->comment_ID);
1019 1018
 
1020 1019
 				// If the comment isn't in the reference array, it goes in the top level of the thread.
1021
-				if ( ! isset( $ref[ $c->comment_parent ] ) ) {
1022
-					$threaded_comments[ $_c->comment_ID ] = $_c;
1023
-					$ref[ $_c->comment_ID ] = $threaded_comments[ $_c->comment_ID ];
1020
+				if ( ! isset($ref[$c->comment_parent])) {
1021
+					$threaded_comments[$_c->comment_ID] = $_c;
1022
+					$ref[$_c->comment_ID] = $threaded_comments[$_c->comment_ID];
1024 1023
 
1025 1024
 				// Otherwise, set it as a child of its parent.
1026 1025
 				} else {
1027 1026
 
1028
-					$ref[ $_c->comment_parent ]->add_child( $_c );
1029
-					$ref[ $_c->comment_ID ] = $ref[ $_c->comment_parent ]->get_child( $_c->comment_ID );
1027
+					$ref[$_c->comment_parent]->add_child($_c);
1028
+					$ref[$_c->comment_ID] = $ref[$_c->comment_parent]->get_child($_c->comment_ID);
1030 1029
 				}
1031 1030
 			}
1032 1031
 
1033 1032
 			// Set the 'populated_children' flag, to ensure additional database queries aren't run.
1034
-			foreach ( $ref as $_ref ) {
1035
-				$_ref->populated_children( true );
1033
+			foreach ($ref as $_ref) {
1034
+				$_ref->populated_children(true);
1036 1035
 			}
1037 1036
 
1038 1037
 			$comments = $threaded_comments;
@@ -1055,17 +1054,17 @@  discard block
 block discarded – undo
1055 1054
 	 * @param array $cols
1056 1055
 	 * @return string
1057 1056
 	 */
1058
-	protected function get_search_sql( $string, $cols ) {
1057
+	protected function get_search_sql($string, $cols) {
1059 1058
 		global $wpdb;
1060 1059
 
1061
-		$like = '%' . $wpdb->esc_like( $string ) . '%';
1060
+		$like = '%'.$wpdb->esc_like($string).'%';
1062 1061
 
1063 1062
 		$searches = array();
1064
-		foreach ( $cols as $col ) {
1065
-			$searches[] = $wpdb->prepare( "$col LIKE %s", $like );
1063
+		foreach ($cols as $col) {
1064
+			$searches[] = $wpdb->prepare("$col LIKE %s", $like);
1066 1065
 		}
1067 1066
 
1068
-		return ' AND (' . implode(' OR ', $searches) . ')';
1067
+		return ' AND ('.implode(' OR ', $searches).')';
1069 1068
 	}
1070 1069
 
1071 1070
 	/**
@@ -1079,7 +1078,7 @@  discard block
 block discarded – undo
1079 1078
 	 * @param string $orderby Alias for the field to order by.
1080 1079
 	 * @return string|false Value to used in the ORDER clause. False otherwise.
1081 1080
 	 */
1082
-	protected function parse_orderby( $orderby ) {
1081
+	protected function parse_orderby($orderby) {
1083 1082
 		global $wpdb;
1084 1083
 
1085 1084
 		$allowed_keys = array(
@@ -1100,30 +1099,30 @@  discard block
 block discarded – undo
1100 1099
 			'user_id',
1101 1100
 		);
1102 1101
 
1103
-		if ( ! empty( $this->query_vars['meta_key'] ) ) {
1102
+		if ( ! empty($this->query_vars['meta_key'])) {
1104 1103
 			$allowed_keys[] = $this->query_vars['meta_key'];
1105 1104
 			$allowed_keys[] = 'meta_value';
1106 1105
 			$allowed_keys[] = 'meta_value_num';
1107 1106
 		}
1108 1107
 
1109 1108
 		$meta_query_clauses = $this->meta_query->get_clauses();
1110
-		if ( $meta_query_clauses ) {
1111
-			$allowed_keys = array_merge( $allowed_keys, array_keys( $meta_query_clauses ) );
1109
+		if ($meta_query_clauses) {
1110
+			$allowed_keys = array_merge($allowed_keys, array_keys($meta_query_clauses));
1112 1111
 		}
1113 1112
 
1114 1113
 		$parsed = false;
1115
-		if ( $orderby == $this->query_vars['meta_key'] || $orderby == 'meta_value' ) {
1114
+		if ($orderby == $this->query_vars['meta_key'] || $orderby == 'meta_value') {
1116 1115
 			$parsed = "$wpdb->commentmeta.meta_value";
1117
-		} elseif ( $orderby == 'meta_value_num' ) {
1116
+		} elseif ($orderby == 'meta_value_num') {
1118 1117
 			$parsed = "$wpdb->commentmeta.meta_value+0";
1119
-		} elseif ( $orderby == 'comment__in' ) {
1120
-			$comment__in = implode( ',', array_map( 'absint', $this->query_vars['comment__in'] ) );
1118
+		} elseif ($orderby == 'comment__in') {
1119
+			$comment__in = implode(',', array_map('absint', $this->query_vars['comment__in']));
1121 1120
 			$parsed = "FIELD( {$wpdb->comments}.comment_ID, $comment__in )";
1122
-		} elseif ( in_array( $orderby, $allowed_keys ) ) {
1121
+		} elseif (in_array($orderby, $allowed_keys)) {
1123 1122
 
1124
-			if ( isset( $meta_query_clauses[ $orderby ] ) ) {
1125
-				$meta_clause = $meta_query_clauses[ $orderby ];
1126
-				$parsed = sprintf( "CAST(%s.meta_value AS %s)", esc_sql( $meta_clause['alias'] ), esc_sql( $meta_clause['cast'] ) );
1123
+			if (isset($meta_query_clauses[$orderby])) {
1124
+				$meta_clause = $meta_query_clauses[$orderby];
1125
+				$parsed = sprintf("CAST(%s.meta_value AS %s)", esc_sql($meta_clause['alias']), esc_sql($meta_clause['cast']));
1127 1126
 			} else {
1128 1127
 				$parsed = "$wpdb->comments.$orderby";
1129 1128
 			}
@@ -1141,12 +1140,12 @@  discard block
 block discarded – undo
1141 1140
 	 * @param string $order The 'order' query variable.
1142 1141
 	 * @return string The sanitized 'order' query variable.
1143 1142
 	 */
1144
-	protected function parse_order( $order ) {
1145
-		if ( ! is_string( $order ) || empty( $order ) ) {
1143
+	protected function parse_order($order) {
1144
+		if ( ! is_string($order) || empty($order)) {
1146 1145
 			return 'DESC';
1147 1146
 		}
1148 1147
 
1149
-		if ( 'ASC' === strtoupper( $order ) ) {
1148
+		if ('ASC' === strtoupper($order)) {
1150 1149
 			return 'ASC';
1151 1150
 		} else {
1152 1151
 			return 'DESC';
Please login to merge, or discard this patch.