Completed
Push — master ( cde0c6...d99bf9 )
by Stephen
15:46
created
src/wp-includes/IXR/class-IXR-introspectionserver.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -1048,6 +1048,12 @@
 block discarded – undo
1048 1048
 		self::__construct();
1049 1049
 	}
1050 1050
 
1051
+    /**
1052
+     * @param string $method
1053
+     * @param string $callback
1054
+     * @param string[] $args
1055
+     * @param string $help
1056
+     */
1051 1057
     function addCallback($method, $callback, $args, $help)
1052 1058
     {
1053 1059
         $this->callbacks[$method] = $callback;
Please login to merge, or discard this patch.
Indentation   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -8,45 +8,45 @@  discard block
 block discarded – undo
8 8
  */
9 9
 class IXR_IntrospectionServer extends IXR_Server
10 10
 {
11
-    var $signatures;
12
-    var $help;
11
+	var $signatures;
12
+	var $help;
13 13
 
14 14
 	/**
15 15
 	 * PHP5 constructor.
16 16
 	 */
17
-    function __construct()
18
-    {
19
-        $this->setCallbacks();
20
-        $this->setCapabilities();
21
-        $this->capabilities['introspection'] = array(
22
-            'specUrl' => 'http://xmlrpc.usefulinc.com/doc/reserved.html',
23
-            'specVersion' => 1
24
-        );
25
-        $this->addCallback(
26
-            'system.methodSignature',
27
-            'this:methodSignature',
28
-            array('array', 'string'),
29
-            'Returns an array describing the return type and required parameters of a method'
30
-        );
31
-        $this->addCallback(
32
-            'system.getCapabilities',
33
-            'this:getCapabilities',
34
-            array('struct'),
35
-            'Returns a struct describing the XML-RPC specifications supported by this server'
36
-        );
37
-        $this->addCallback(
38
-            'system.listMethods',
39
-            'this:listMethods',
40
-            array('array'),
41
-            'Returns an array of available methods on this server'
42
-        );
43
-        $this->addCallback(
44
-            'system.methodHelp',
45
-            'this:methodHelp',
46
-            array('string', 'string'),
47
-            'Returns a documentation string for the specified method'
48
-        );
49
-    }
17
+	function __construct()
18
+	{
19
+		$this->setCallbacks();
20
+		$this->setCapabilities();
21
+		$this->capabilities['introspection'] = array(
22
+			'specUrl' => 'http://xmlrpc.usefulinc.com/doc/reserved.html',
23
+			'specVersion' => 1
24
+		);
25
+		$this->addCallback(
26
+			'system.methodSignature',
27
+			'this:methodSignature',
28
+			array('array', 'string'),
29
+			'Returns an array describing the return type and required parameters of a method'
30
+		);
31
+		$this->addCallback(
32
+			'system.getCapabilities',
33
+			'this:getCapabilities',
34
+			array('struct'),
35
+			'Returns a struct describing the XML-RPC specifications supported by this server'
36
+		);
37
+		$this->addCallback(
38
+			'system.listMethods',
39
+			'this:listMethods',
40
+			array('array'),
41
+			'Returns an array of available methods on this server'
42
+		);
43
+		$this->addCallback(
44
+			'system.methodHelp',
45
+			'this:methodHelp',
46
+			array('string', 'string'),
47
+			'Returns a documentation string for the specified method'
48
+		);
49
+	}
50 50
 
51 51
 	/**
52 52
 	 * PHP4 constructor.
@@ -55,120 +55,120 @@  discard block
 block discarded – undo
55 55
 		self::__construct();
56 56
 	}
57 57
 
58
-    function addCallback($method, $callback, $args, $help)
59
-    {
60
-        $this->callbacks[$method] = $callback;
61
-        $this->signatures[$method] = $args;
62
-        $this->help[$method] = $help;
63
-    }
58
+	function addCallback($method, $callback, $args, $help)
59
+	{
60
+		$this->callbacks[$method] = $callback;
61
+		$this->signatures[$method] = $args;
62
+		$this->help[$method] = $help;
63
+	}
64 64
 
65
-    function call($methodname, $args)
66
-    {
67
-        // Make sure it's in an array
68
-        if ($args && !is_array($args)) {
69
-            $args = array($args);
70
-        }
65
+	function call($methodname, $args)
66
+	{
67
+		// Make sure it's in an array
68
+		if ($args && !is_array($args)) {
69
+			$args = array($args);
70
+		}
71 71
 
72
-        // Over-rides default call method, adds signature check
73
-        if (!$this->hasMethod($methodname)) {
74
-            return new IXR_Error(-32601, 'server error. requested method "'.$this->message->methodName.'" not specified.');
75
-        }
76
-        $method = $this->callbacks[$methodname];
77
-        $signature = $this->signatures[$methodname];
78
-        $returnType = array_shift($signature);
72
+		// Over-rides default call method, adds signature check
73
+		if (!$this->hasMethod($methodname)) {
74
+			return new IXR_Error(-32601, 'server error. requested method "'.$this->message->methodName.'" not specified.');
75
+		}
76
+		$method = $this->callbacks[$methodname];
77
+		$signature = $this->signatures[$methodname];
78
+		$returnType = array_shift($signature);
79 79
 
80
-        // Check the number of arguments
81
-        if (count($args) != count($signature)) {
82
-            return new IXR_Error(-32602, 'server error. wrong number of method parameters');
83
-        }
80
+		// Check the number of arguments
81
+		if (count($args) != count($signature)) {
82
+			return new IXR_Error(-32602, 'server error. wrong number of method parameters');
83
+		}
84 84
 
85
-        // Check the argument types
86
-        $ok = true;
87
-        $argsbackup = $args;
88
-        for ($i = 0, $j = count($args); $i < $j; $i++) {
89
-            $arg = array_shift($args);
90
-            $type = array_shift($signature);
91
-            switch ($type) {
92
-                case 'int':
93
-                case 'i4':
94
-                    if (is_array($arg) || !is_int($arg)) {
95
-                        $ok = false;
96
-                    }
97
-                    break;
98
-                case 'base64':
99
-                case 'string':
100
-                    if (!is_string($arg)) {
101
-                        $ok = false;
102
-                    }
103
-                    break;
104
-                case 'boolean':
105
-                    if ($arg !== false && $arg !== true) {
106
-                        $ok = false;
107
-                    }
108
-                    break;
109
-                case 'float':
110
-                case 'double':
111
-                    if (!is_float($arg)) {
112
-                        $ok = false;
113
-                    }
114
-                    break;
115
-                case 'date':
116
-                case 'dateTime.iso8601':
117
-                    if (!is_a($arg, 'IXR_Date')) {
118
-                        $ok = false;
119
-                    }
120
-                    break;
121
-            }
122
-            if (!$ok) {
123
-                return new IXR_Error(-32602, 'server error. invalid method parameters');
124
-            }
125
-        }
126
-        // It passed the test - run the "real" method call
127
-        return parent::call($methodname, $argsbackup);
128
-    }
85
+		// Check the argument types
86
+		$ok = true;
87
+		$argsbackup = $args;
88
+		for ($i = 0, $j = count($args); $i < $j; $i++) {
89
+			$arg = array_shift($args);
90
+			$type = array_shift($signature);
91
+			switch ($type) {
92
+				case 'int':
93
+				case 'i4':
94
+					if (is_array($arg) || !is_int($arg)) {
95
+						$ok = false;
96
+					}
97
+					break;
98
+				case 'base64':
99
+				case 'string':
100
+					if (!is_string($arg)) {
101
+						$ok = false;
102
+					}
103
+					break;
104
+				case 'boolean':
105
+					if ($arg !== false && $arg !== true) {
106
+						$ok = false;
107
+					}
108
+					break;
109
+				case 'float':
110
+				case 'double':
111
+					if (!is_float($arg)) {
112
+						$ok = false;
113
+					}
114
+					break;
115
+				case 'date':
116
+				case 'dateTime.iso8601':
117
+					if (!is_a($arg, 'IXR_Date')) {
118
+						$ok = false;
119
+					}
120
+					break;
121
+			}
122
+			if (!$ok) {
123
+				return new IXR_Error(-32602, 'server error. invalid method parameters');
124
+			}
125
+		}
126
+		// It passed the test - run the "real" method call
127
+		return parent::call($methodname, $argsbackup);
128
+	}
129 129
 
130
-    function methodSignature($method)
131
-    {
132
-        if (!$this->hasMethod($method)) {
133
-            return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
134
-        }
135
-        // We should be returning an array of types
136
-        $types = $this->signatures[$method];
137
-        $return = array();
138
-        foreach ($types as $type) {
139
-            switch ($type) {
140
-                case 'string':
141
-                    $return[] = 'string';
142
-                    break;
143
-                case 'int':
144
-                case 'i4':
145
-                    $return[] = 42;
146
-                    break;
147
-                case 'double':
148
-                    $return[] = 3.1415;
149
-                    break;
150
-                case 'dateTime.iso8601':
151
-                    $return[] = new IXR_Date(time());
152
-                    break;
153
-                case 'boolean':
154
-                    $return[] = true;
155
-                    break;
156
-                case 'base64':
157
-                    $return[] = new IXR_Base64('base64');
158
-                    break;
159
-                case 'array':
160
-                    $return[] = array('array');
161
-                    break;
162
-                case 'struct':
163
-                    $return[] = array('struct' => 'struct');
164
-                    break;
165
-            }
166
-        }
167
-        return $return;
168
-    }
130
+	function methodSignature($method)
131
+	{
132
+		if (!$this->hasMethod($method)) {
133
+			return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
134
+		}
135
+		// We should be returning an array of types
136
+		$types = $this->signatures[$method];
137
+		$return = array();
138
+		foreach ($types as $type) {
139
+			switch ($type) {
140
+				case 'string':
141
+					$return[] = 'string';
142
+					break;
143
+				case 'int':
144
+				case 'i4':
145
+					$return[] = 42;
146
+					break;
147
+				case 'double':
148
+					$return[] = 3.1415;
149
+					break;
150
+				case 'dateTime.iso8601':
151
+					$return[] = new IXR_Date(time());
152
+					break;
153
+				case 'boolean':
154
+					$return[] = true;
155
+					break;
156
+				case 'base64':
157
+					$return[] = new IXR_Base64('base64');
158
+					break;
159
+				case 'array':
160
+					$return[] = array('array');
161
+					break;
162
+				case 'struct':
163
+					$return[] = array('struct' => 'struct');
164
+					break;
165
+			}
166
+		}
167
+		return $return;
168
+	}
169 169
 
170
-    function methodHelp($method)
171
-    {
172
-        return $this->help[$method];
173
-    }
170
+	function methodHelp($method)
171
+	{
172
+		return $this->help[$method];
173
+	}
174 174
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -65,12 +65,12 @@  discard block
 block discarded – undo
65 65
     function call($methodname, $args)
66 66
     {
67 67
         // Make sure it's in an array
68
-        if ($args && !is_array($args)) {
68
+        if ($args && ! is_array($args)) {
69 69
             $args = array($args);
70 70
         }
71 71
 
72 72
         // Over-rides default call method, adds signature check
73
-        if (!$this->hasMethod($methodname)) {
73
+        if ( ! $this->hasMethod($methodname)) {
74 74
             return new IXR_Error(-32601, 'server error. requested method "'.$this->message->methodName.'" not specified.');
75 75
         }
76 76
         $method = $this->callbacks[$methodname];
@@ -91,13 +91,13 @@  discard block
 block discarded – undo
91 91
             switch ($type) {
92 92
                 case 'int':
93 93
                 case 'i4':
94
-                    if (is_array($arg) || !is_int($arg)) {
94
+                    if (is_array($arg) || ! is_int($arg)) {
95 95
                         $ok = false;
96 96
                     }
97 97
                     break;
98 98
                 case 'base64':
99 99
                 case 'string':
100
-                    if (!is_string($arg)) {
100
+                    if ( ! is_string($arg)) {
101 101
                         $ok = false;
102 102
                     }
103 103
                     break;
@@ -108,18 +108,18 @@  discard block
 block discarded – undo
108 108
                     break;
109 109
                 case 'float':
110 110
                 case 'double':
111
-                    if (!is_float($arg)) {
111
+                    if ( ! is_float($arg)) {
112 112
                         $ok = false;
113 113
                     }
114 114
                     break;
115 115
                 case 'date':
116 116
                 case 'dateTime.iso8601':
117
-                    if (!is_a($arg, 'IXR_Date')) {
117
+                    if ( ! is_a($arg, 'IXR_Date')) {
118 118
                         $ok = false;
119 119
                     }
120 120
                     break;
121 121
             }
122
-            if (!$ok) {
122
+            if ( ! $ok) {
123 123
                 return new IXR_Error(-32602, 'server error. invalid method parameters');
124 124
             }
125 125
         }
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 
130 130
     function methodSignature($method)
131 131
     {
132
-        if (!$this->hasMethod($method)) {
132
+        if ( ! $this->hasMethod($method)) {
133 133
             return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
134 134
         }
135 135
         // We should be returning an array of types
Please login to merge, or discard this patch.
src/wp-includes/option.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1867,7 +1867,7 @@
 block discarded – undo
1867 1867
  * @param string $option_group A settings group name. Should correspond to a whitelisted option key name.
1868 1868
  * 	Default whitelisted option key names include "general," "discussion," and "reading," among others.
1869 1869
  * @param string $option_name The name of an option to sanitize and save.
1870
- * @param array  $args {
1870
+ * @param callable  $args {
1871 1871
  *     Data used to describe the setting when registered.
1872 1872
  *
1873 1873
  *     @type string   $type              The type of data associated with this setting.
Please login to merge, or discard this patch.
Spacing   +438 added lines, -438 removed lines patch added patch discarded remove patch
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
  * @param mixed  $default Optional. Default value to return if the option does not exist.
28 28
  * @return mixed Value set for the option.
29 29
  */
30
-function get_option( $option, $default = false ) {
30
+function get_option($option, $default = false) {
31 31
 	global $wpdb;
32 32
 
33
-	$option = trim( $option );
34
-	if ( empty( $option ) )
33
+	$option = trim($option);
34
+	if (empty($option))
35 35
 		return false;
36 36
 
37 37
 	/**
@@ -49,20 +49,20 @@  discard block
 block discarded – undo
49 49
 	 *                               Default false to skip it.
50 50
 	 * @param string     $option     Option name.
51 51
 	 */
52
-	$pre = apply_filters( "pre_option_{$option}", false, $option );
53
-	if ( false !== $pre )
52
+	$pre = apply_filters("pre_option_{$option}", false, $option);
53
+	if (false !== $pre)
54 54
 		return $pre;
55 55
 
56
-	if ( defined( 'WP_SETUP_CONFIG' ) )
56
+	if (defined('WP_SETUP_CONFIG'))
57 57
 		return false;
58 58
 
59 59
 	// Distinguish between `false` as a default, and not passing one.
60 60
 	$passed_default = func_num_args() > 1;
61 61
 
62
-	if ( ! wp_installing() ) {
62
+	if ( ! wp_installing()) {
63 63
 		// prevent non-existent options from triggering multiple queries
64
-		$notoptions = wp_cache_get( 'notoptions', 'options' );
65
-		if ( isset( $notoptions[ $option ] ) ) {
64
+		$notoptions = wp_cache_get('notoptions', 'options');
65
+		if (isset($notoptions[$option])) {
66 66
 			/**
67 67
 			 * Filters the default value for an option.
68 68
 			 *
@@ -77,53 +77,53 @@  discard block
 block discarded – undo
77 77
 			 * @param string $option  Option name.
78 78
 			 * @param bool   $passed_default Was `get_option()` passed a default value?
79 79
 			 */
80
-			return apply_filters( "default_option_{$option}", $default, $option, $passed_default );
80
+			return apply_filters("default_option_{$option}", $default, $option, $passed_default);
81 81
 		}
82 82
 
83 83
 		$alloptions = wp_load_alloptions();
84 84
 
85
-		if ( isset( $alloptions[$option] ) ) {
85
+		if (isset($alloptions[$option])) {
86 86
 			$value = $alloptions[$option];
87 87
 		} else {
88
-			$value = wp_cache_get( $option, 'options' );
88
+			$value = wp_cache_get($option, 'options');
89 89
 
90
-			if ( false === $value ) {
91
-				$row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );
90
+			if (false === $value) {
91
+				$row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option));
92 92
 
93 93
 				// Has to be get_row instead of get_var because of funkiness with 0, false, null values
94
-				if ( is_object( $row ) ) {
94
+				if (is_object($row)) {
95 95
 					$value = $row->option_value;
96
-					wp_cache_add( $option, $value, 'options' );
96
+					wp_cache_add($option, $value, 'options');
97 97
 				} else { // option does not exist, so we must cache its non-existence
98
-					if ( ! is_array( $notoptions ) ) {
98
+					if ( ! is_array($notoptions)) {
99 99
 						 $notoptions = array();
100 100
 					}
101 101
 					$notoptions[$option] = true;
102
-					wp_cache_set( 'notoptions', $notoptions, 'options' );
102
+					wp_cache_set('notoptions', $notoptions, 'options');
103 103
 
104 104
 					/** This filter is documented in wp-includes/option.php */
105
-					return apply_filters( "default_option_{$option}", $default, $option, $passed_default );
105
+					return apply_filters("default_option_{$option}", $default, $option, $passed_default);
106 106
 				}
107 107
 			}
108 108
 		}
109 109
 	} else {
110 110
 		$suppress = $wpdb->suppress_errors();
111
-		$row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );
112
-		$wpdb->suppress_errors( $suppress );
113
-		if ( is_object( $row ) ) {
111
+		$row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option));
112
+		$wpdb->suppress_errors($suppress);
113
+		if (is_object($row)) {
114 114
 			$value = $row->option_value;
115 115
 		} else {
116 116
 			/** This filter is documented in wp-includes/option.php */
117
-			return apply_filters( "default_option_{$option}", $default, $option, $passed_default );
117
+			return apply_filters("default_option_{$option}", $default, $option, $passed_default);
118 118
 		}
119 119
 	}
120 120
 
121 121
 	// If home is not set use siteurl.
122
-	if ( 'home' == $option && '' == $value )
123
-		return get_option( 'siteurl' );
122
+	if ('home' == $option && '' == $value)
123
+		return get_option('siteurl');
124 124
 
125
-	if ( in_array( $option, array('siteurl', 'home', 'category_base', 'tag_base') ) )
126
-		$value = untrailingslashit( $value );
125
+	if (in_array($option, array('siteurl', 'home', 'category_base', 'tag_base')))
126
+		$value = untrailingslashit($value);
127 127
 
128 128
 	/**
129 129
 	 * Filters the value of an existing option.
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 *                       unserialized prior to being returned.
139 139
 	 * @param string $option Option name.
140 140
 	 */
141
-	return apply_filters( "option_{$option}", maybe_unserialize( $value ), $option );
141
+	return apply_filters("option_{$option}", maybe_unserialize($value), $option);
142 142
 }
143 143
 
144 144
 /**
@@ -151,9 +151,9 @@  discard block
 block discarded – undo
151 151
  *
152 152
  * @param string $option Option name.
153 153
  */
154
-function wp_protect_special_option( $option ) {
155
-	if ( 'alloptions' === $option || 'notoptions' === $option )
156
-		wp_die( sprintf( __( '%s is a protected WP option and may not be modified' ), esc_html( $option ) ) );
154
+function wp_protect_special_option($option) {
155
+	if ('alloptions' === $option || 'notoptions' === $option)
156
+		wp_die(sprintf(__('%s is a protected WP option and may not be modified'), esc_html($option)));
157 157
 }
158 158
 
159 159
 /**
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
  *
164 164
  * @param string $option Option name.
165 165
  */
166
-function form_option( $option ) {
167
-	echo esc_attr( get_option( $option ) );
166
+function form_option($option) {
167
+	echo esc_attr(get_option($option));
168 168
 }
169 169
 
170 170
 /**
@@ -179,22 +179,22 @@  discard block
 block discarded – undo
179 179
 function wp_load_alloptions() {
180 180
 	global $wpdb;
181 181
 
182
-	if ( ! wp_installing() || ! is_multisite() )
183
-		$alloptions = wp_cache_get( 'alloptions', 'options' );
182
+	if ( ! wp_installing() || ! is_multisite())
183
+		$alloptions = wp_cache_get('alloptions', 'options');
184 184
 	else
185 185
 		$alloptions = false;
186 186
 
187
-	if ( !$alloptions ) {
187
+	if ( ! $alloptions) {
188 188
 		$suppress = $wpdb->suppress_errors();
189
-		if ( !$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" ) )
190
-			$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" );
189
+		if ( ! $alloptions_db = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'"))
190
+			$alloptions_db = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options");
191 191
 		$wpdb->suppress_errors($suppress);
192 192
 		$alloptions = array();
193
-		foreach ( (array) $alloptions_db as $o ) {
193
+		foreach ((array) $alloptions_db as $o) {
194 194
 			$alloptions[$o->option_name] = $o->option_value;
195 195
 		}
196
-		if ( ! wp_installing() || ! is_multisite() )
197
-			wp_cache_add( 'alloptions', $alloptions, 'options' );
196
+		if ( ! wp_installing() || ! is_multisite())
197
+			wp_cache_add('alloptions', $alloptions, 'options');
198 198
 	}
199 199
 
200 200
 	return $alloptions;
@@ -209,26 +209,26 @@  discard block
 block discarded – undo
209 209
  *
210 210
  * @param int $site_id Optional site ID for which to query the options. Defaults to the current site.
211 211
  */
212
-function wp_load_core_site_options( $site_id = null ) {
212
+function wp_load_core_site_options($site_id = null) {
213 213
 	global $wpdb;
214 214
 
215
-	if ( ! is_multisite() || wp_using_ext_object_cache() || wp_installing() )
215
+	if ( ! is_multisite() || wp_using_ext_object_cache() || wp_installing())
216 216
 		return;
217 217
 
218
-	if ( empty($site_id) )
218
+	if (empty($site_id))
219 219
 		$site_id = $wpdb->siteid;
220 220
 
221
-	$core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled', 'ms_files_rewriting' );
221
+	$core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled', 'ms_files_rewriting');
222 222
 
223
-	$core_options_in = "'" . implode("', '", $core_options) . "'";
224
-	$options = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN ($core_options_in) AND site_id = %d", $site_id) );
223
+	$core_options_in = "'".implode("', '", $core_options)."'";
224
+	$options = $wpdb->get_results($wpdb->prepare("SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN ($core_options_in) AND site_id = %d", $site_id));
225 225
 
226
-	foreach ( $options as $option ) {
226
+	foreach ($options as $option) {
227 227
 		$key = $option->meta_key;
228 228
 		$cache_key = "{$site_id}:$key";
229
-		$option->meta_value = maybe_unserialize( $option->meta_value );
229
+		$option->meta_value = maybe_unserialize($option->meta_value);
230 230
 
231
-		wp_cache_set( $cache_key, $option->meta_value, 'site-options' );
231
+		wp_cache_set($cache_key, $option->meta_value, 'site-options');
232 232
 	}
233 233
 }
234 234
 
@@ -255,20 +255,20 @@  discard block
 block discarded – undo
255 255
  *                              the default value is 'yes'. Default null.
256 256
  * @return bool False if value was not updated and true if value was updated.
257 257
  */
258
-function update_option( $option, $value, $autoload = null ) {
258
+function update_option($option, $value, $autoload = null) {
259 259
 	global $wpdb;
260 260
 
261 261
 	$option = trim($option);
262
-	if ( empty($option) )
262
+	if (empty($option))
263 263
 		return false;
264 264
 
265
-	wp_protect_special_option( $option );
265
+	wp_protect_special_option($option);
266 266
 
267
-	if ( is_object( $value ) )
267
+	if (is_object($value))
268 268
 		$value = clone $value;
269 269
 
270
-	$value = sanitize_option( $option, $value );
271
-	$old_value = get_option( $option );
270
+	$value = sanitize_option($option, $value);
271
+	$old_value = get_option($option);
272 272
 
273 273
 	/**
274 274
 	 * Filters a specific option before its value is (maybe) serialized and updated.
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	 * @param mixed  $old_value The old option value.
283 283
 	 * @param string $option    Option name.
284 284
 	 */
285
-	$value = apply_filters( "pre_update_option_{$option}", $value, $old_value, $option );
285
+	$value = apply_filters("pre_update_option_{$option}", $value, $old_value, $option);
286 286
 
287 287
 	/**
288 288
 	 * Filters an option before its value is (maybe) serialized and updated.
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	 * @param string $option    Name of the option.
294 294
 	 * @param mixed  $old_value The old option value.
295 295
 	 */
296
-	$value = apply_filters( 'pre_update_option', $value, $option, $old_value );
296
+	$value = apply_filters('pre_update_option', $value, $option, $old_value);
297 297
 
298 298
 	/*
299 299
 	 * If the new and old values are the same, no need to update.
@@ -304,21 +304,21 @@  discard block
 block discarded – undo
304 304
 	 *
305 305
 	 * See https://core.trac.wordpress.org/ticket/38903
306 306
 	 */
307
-	if ( $value === $old_value || maybe_serialize( $value ) === maybe_serialize( $old_value ) ) {
307
+	if ($value === $old_value || maybe_serialize($value) === maybe_serialize($old_value)) {
308 308
 		return false;
309 309
 	}
310 310
 
311 311
 	/** This filter is documented in wp-includes/option.php */
312
-	if ( apply_filters( "default_option_{$option}", false, $option, false ) === $old_value ) {
312
+	if (apply_filters("default_option_{$option}", false, $option, false) === $old_value) {
313 313
 		// Default setting for new options is 'yes'.
314
-		if ( null === $autoload ) {
314
+		if (null === $autoload) {
315 315
 			$autoload = 'yes';
316 316
 		}
317 317
 
318
-		return add_option( $option, $value, '', $autoload );
318
+		return add_option($option, $value, '', $autoload);
319 319
 	}
320 320
 
321
-	$serialized_value = maybe_serialize( $value );
321
+	$serialized_value = maybe_serialize($value);
322 322
 
323 323
 	/**
324 324
 	 * Fires immediately before an option value is updated.
@@ -329,33 +329,33 @@  discard block
 block discarded – undo
329 329
 	 * @param mixed  $old_value The old option value.
330 330
 	 * @param mixed  $value     The new option value.
331 331
 	 */
332
-	do_action( 'update_option', $option, $old_value, $value );
332
+	do_action('update_option', $option, $old_value, $value);
333 333
 
334 334
 	$update_args = array(
335 335
 		'option_value' => $serialized_value,
336 336
 	);
337 337
 
338
-	if ( null !== $autoload ) {
339
-		$update_args['autoload'] = ( 'no' === $autoload || false === $autoload ) ? 'no' : 'yes';
338
+	if (null !== $autoload) {
339
+		$update_args['autoload'] = ('no' === $autoload || false === $autoload) ? 'no' : 'yes';
340 340
 	}
341 341
 
342
-	$result = $wpdb->update( $wpdb->options, $update_args, array( 'option_name' => $option ) );
343
-	if ( ! $result )
342
+	$result = $wpdb->update($wpdb->options, $update_args, array('option_name' => $option));
343
+	if ( ! $result)
344 344
 		return false;
345 345
 
346
-	$notoptions = wp_cache_get( 'notoptions', 'options' );
347
-	if ( is_array( $notoptions ) && isset( $notoptions[$option] ) ) {
348
-		unset( $notoptions[$option] );
349
-		wp_cache_set( 'notoptions', $notoptions, 'options' );
346
+	$notoptions = wp_cache_get('notoptions', 'options');
347
+	if (is_array($notoptions) && isset($notoptions[$option])) {
348
+		unset($notoptions[$option]);
349
+		wp_cache_set('notoptions', $notoptions, 'options');
350 350
 	}
351 351
 
352
-	if ( ! wp_installing() ) {
352
+	if ( ! wp_installing()) {
353 353
 		$alloptions = wp_load_alloptions();
354
-		if ( isset( $alloptions[$option] ) ) {
355
-			$alloptions[ $option ] = $serialized_value;
356
-			wp_cache_set( 'alloptions', $alloptions, 'options' );
354
+		if (isset($alloptions[$option])) {
355
+			$alloptions[$option] = $serialized_value;
356
+			wp_cache_set('alloptions', $alloptions, 'options');
357 357
 		} else {
358
-			wp_cache_set( $option, $serialized_value, 'options' );
358
+			wp_cache_set($option, $serialized_value, 'options');
359 359
 		}
360 360
 	}
361 361
 
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 	 * @param mixed  $value     The new option value.
372 372
 	 * @param string $option    Option name.
373 373
 	 */
374
-	do_action( "update_option_{$option}", $old_value, $value, $option );
374
+	do_action("update_option_{$option}", $old_value, $value, $option);
375 375
 
376 376
 	/**
377 377
 	 * Fires after the value of an option has been successfully updated.
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 	 * @param mixed  $old_value The old option value.
383 383
 	 * @param mixed  $value     The new option value.
384 384
 	 */
385
-	do_action( 'updated_option', $option, $old_value, $value );
385
+	do_action('updated_option', $option, $old_value, $value);
386 386
 	return true;
387 387
 }
388 388
 
@@ -409,32 +409,32 @@  discard block
 block discarded – undo
409 409
  *                                    Default is enabled. Accepts 'no' to disable for legacy reasons.
410 410
  * @return bool False if option was not added and true if option was added.
411 411
  */
412
-function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) {
412
+function add_option($option, $value = '', $deprecated = '', $autoload = 'yes') {
413 413
 	global $wpdb;
414 414
 
415
-	if ( !empty( $deprecated ) )
416
-		_deprecated_argument( __FUNCTION__, '2.3.0' );
415
+	if ( ! empty($deprecated))
416
+		_deprecated_argument(__FUNCTION__, '2.3.0');
417 417
 
418 418
 	$option = trim($option);
419
-	if ( empty($option) )
419
+	if (empty($option))
420 420
 		return false;
421 421
 
422
-	wp_protect_special_option( $option );
422
+	wp_protect_special_option($option);
423 423
 
424
-	if ( is_object($value) )
424
+	if (is_object($value))
425 425
 		$value = clone $value;
426 426
 
427
-	$value = sanitize_option( $option, $value );
427
+	$value = sanitize_option($option, $value);
428 428
 
429 429
 	// Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query
430
-	$notoptions = wp_cache_get( 'notoptions', 'options' );
431
-	if ( !is_array( $notoptions ) || !isset( $notoptions[$option] ) )
430
+	$notoptions = wp_cache_get('notoptions', 'options');
431
+	if ( ! is_array($notoptions) || ! isset($notoptions[$option]))
432 432
 		/** This filter is documented in wp-includes/option.php */
433
-		if ( apply_filters( "default_option_{$option}", false, $option, false ) !== get_option( $option ) )
433
+		if (apply_filters("default_option_{$option}", false, $option, false) !== get_option($option))
434 434
 			return false;
435 435
 
436
-	$serialized_value = maybe_serialize( $value );
437
-	$autoload = ( 'no' === $autoload || false === $autoload ) ? 'no' : 'yes';
436
+	$serialized_value = maybe_serialize($value);
437
+	$autoload = ('no' === $autoload || false === $autoload) ? 'no' : 'yes';
438 438
 
439 439
 	/**
440 440
 	 * Fires before an option is added.
@@ -444,27 +444,27 @@  discard block
 block discarded – undo
444 444
 	 * @param string $option Name of the option to add.
445 445
 	 * @param mixed  $value  Value of the option.
446 446
 	 */
447
-	do_action( 'add_option', $option, $value );
447
+	do_action('add_option', $option, $value);
448 448
 
449
-	$result = $wpdb->query( $wpdb->prepare( "INSERT INTO `$wpdb->options` (`option_name`, `option_value`, `autoload`) VALUES (%s, %s, %s) ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)", $option, $serialized_value, $autoload ) );
450
-	if ( ! $result )
449
+	$result = $wpdb->query($wpdb->prepare("INSERT INTO `$wpdb->options` (`option_name`, `option_value`, `autoload`) VALUES (%s, %s, %s) ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)", $option, $serialized_value, $autoload));
450
+	if ( ! $result)
451 451
 		return false;
452 452
 
453
-	if ( ! wp_installing() ) {
454
-		if ( 'yes' == $autoload ) {
453
+	if ( ! wp_installing()) {
454
+		if ('yes' == $autoload) {
455 455
 			$alloptions = wp_load_alloptions();
456
-			$alloptions[ $option ] = $serialized_value;
457
-			wp_cache_set( 'alloptions', $alloptions, 'options' );
456
+			$alloptions[$option] = $serialized_value;
457
+			wp_cache_set('alloptions', $alloptions, 'options');
458 458
 		} else {
459
-			wp_cache_set( $option, $serialized_value, 'options' );
459
+			wp_cache_set($option, $serialized_value, 'options');
460 460
 		}
461 461
 	}
462 462
 
463 463
 	// This option exists now
464
-	$notoptions = wp_cache_get( 'notoptions', 'options' ); // yes, again... we need it to be fresh
465
-	if ( is_array( $notoptions ) && isset( $notoptions[$option] ) ) {
466
-		unset( $notoptions[$option] );
467
-		wp_cache_set( 'notoptions', $notoptions, 'options' );
464
+	$notoptions = wp_cache_get('notoptions', 'options'); // yes, again... we need it to be fresh
465
+	if (is_array($notoptions) && isset($notoptions[$option])) {
466
+		unset($notoptions[$option]);
467
+		wp_cache_set('notoptions', $notoptions, 'options');
468 468
 	}
469 469
 
470 470
 	/**
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 	 * @param string $option Name of the option to add.
479 479
 	 * @param mixed  $value  Value of the option.
480 480
 	 */
481
-	do_action( "add_option_{$option}", $option, $value );
481
+	do_action("add_option_{$option}", $option, $value);
482 482
 
483 483
 	/**
484 484
 	 * Fires after an option has been added.
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 	 * @param string $option Name of the added option.
489 489
 	 * @param mixed  $value  Value of the option.
490 490
 	 */
491
-	do_action( 'added_option', $option, $value );
491
+	do_action('added_option', $option, $value);
492 492
 	return true;
493 493
 }
494 494
 
@@ -502,18 +502,18 @@  discard block
 block discarded – undo
502 502
  * @param string $option Name of option to remove. Expected to not be SQL-escaped.
503 503
  * @return bool True, if option is successfully deleted. False on failure.
504 504
  */
505
-function delete_option( $option ) {
505
+function delete_option($option) {
506 506
 	global $wpdb;
507 507
 
508
-	$option = trim( $option );
509
-	if ( empty( $option ) )
508
+	$option = trim($option);
509
+	if (empty($option))
510 510
 		return false;
511 511
 
512
-	wp_protect_special_option( $option );
512
+	wp_protect_special_option($option);
513 513
 
514 514
 	// Get the ID, if no ID then return
515
-	$row = $wpdb->get_row( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $option ) );
516
-	if ( is_null( $row ) )
515
+	$row = $wpdb->get_row($wpdb->prepare("SELECT autoload FROM $wpdb->options WHERE option_name = %s", $option));
516
+	if (is_null($row))
517 517
 		return false;
518 518
 
519 519
 	/**
@@ -523,21 +523,21 @@  discard block
 block discarded – undo
523 523
 	 *
524 524
 	 * @param string $option Name of the option to delete.
525 525
 	 */
526
-	do_action( 'delete_option', $option );
526
+	do_action('delete_option', $option);
527 527
 
528
-	$result = $wpdb->delete( $wpdb->options, array( 'option_name' => $option ) );
529
-	if ( ! wp_installing() ) {
530
-		if ( 'yes' == $row->autoload ) {
528
+	$result = $wpdb->delete($wpdb->options, array('option_name' => $option));
529
+	if ( ! wp_installing()) {
530
+		if ('yes' == $row->autoload) {
531 531
 			$alloptions = wp_load_alloptions();
532
-			if ( is_array( $alloptions ) && isset( $alloptions[$option] ) ) {
533
-				unset( $alloptions[$option] );
534
-				wp_cache_set( 'alloptions', $alloptions, 'options' );
532
+			if (is_array($alloptions) && isset($alloptions[$option])) {
533
+				unset($alloptions[$option]);
534
+				wp_cache_set('alloptions', $alloptions, 'options');
535 535
 			}
536 536
 		} else {
537
-			wp_cache_delete( $option, 'options' );
537
+			wp_cache_delete($option, 'options');
538 538
 		}
539 539
 	}
540
-	if ( $result ) {
540
+	if ($result) {
541 541
 
542 542
 		/**
543 543
 		 * Fires after a specific option has been deleted.
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 		 *
549 549
 		 * @param string $option Name of the deleted option.
550 550
 		 */
551
-		do_action( "delete_option_{$option}", $option );
551
+		do_action("delete_option_{$option}", $option);
552 552
 
553 553
 		/**
554 554
 		 * Fires after an option has been deleted.
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 		 *
558 558
 		 * @param string $option Name of the deleted option.
559 559
 		 */
560
-		do_action( 'deleted_option', $option );
560
+		do_action('deleted_option', $option);
561 561
 		return true;
562 562
 	}
563 563
 	return false;
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
  * @param string $transient Transient name. Expected to not be SQL-escaped.
572 572
  * @return bool true if successful, false otherwise
573 573
  */
574
-function delete_transient( $transient ) {
574
+function delete_transient($transient) {
575 575
 
576 576
 	/**
577 577
 	 * Fires immediately before a specific transient is deleted.
@@ -582,19 +582,19 @@  discard block
 block discarded – undo
582 582
 	 *
583 583
 	 * @param string $transient Transient name.
584 584
 	 */
585
-	do_action( "delete_transient_{$transient}", $transient );
585
+	do_action("delete_transient_{$transient}", $transient);
586 586
 
587
-	if ( wp_using_ext_object_cache() ) {
588
-		$result = wp_cache_delete( $transient, 'transient' );
587
+	if (wp_using_ext_object_cache()) {
588
+		$result = wp_cache_delete($transient, 'transient');
589 589
 	} else {
590
-		$option_timeout = '_transient_timeout_' . $transient;
591
-		$option = '_transient_' . $transient;
592
-		$result = delete_option( $option );
593
-		if ( $result )
594
-			delete_option( $option_timeout );
590
+		$option_timeout = '_transient_timeout_'.$transient;
591
+		$option = '_transient_'.$transient;
592
+		$result = delete_option($option);
593
+		if ($result)
594
+			delete_option($option_timeout);
595 595
 	}
596 596
 
597
-	if ( $result ) {
597
+	if ($result) {
598 598
 
599 599
 		/**
600 600
 		 * Fires after a transient is deleted.
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 		 *
604 604
 		 * @param string $transient Deleted transient name.
605 605
 		 */
606
-		do_action( 'deleted_transient', $transient );
606
+		do_action('deleted_transient', $transient);
607 607
 	}
608 608
 
609 609
 	return $result;
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
  * @param string $transient Transient name. Expected to not be SQL-escaped.
621 621
  * @return mixed Value of transient.
622 622
  */
623
-function get_transient( $transient ) {
623
+function get_transient($transient) {
624 624
 
625 625
 	/**
626 626
 	 * Filters the value of an existing transient.
@@ -638,30 +638,30 @@  discard block
 block discarded – undo
638 638
 	 *                              of the transient, and return the returned value.
639 639
 	 * @param string $transient     Transient name.
640 640
 	 */
641
-	$pre = apply_filters( "pre_transient_{$transient}", false, $transient );
642
-	if ( false !== $pre )
641
+	$pre = apply_filters("pre_transient_{$transient}", false, $transient);
642
+	if (false !== $pre)
643 643
 		return $pre;
644 644
 
645
-	if ( wp_using_ext_object_cache() ) {
646
-		$value = wp_cache_get( $transient, 'transient' );
645
+	if (wp_using_ext_object_cache()) {
646
+		$value = wp_cache_get($transient, 'transient');
647 647
 	} else {
648
-		$transient_option = '_transient_' . $transient;
649
-		if ( ! wp_installing() ) {
648
+		$transient_option = '_transient_'.$transient;
649
+		if ( ! wp_installing()) {
650 650
 			// If option is not in alloptions, it is not autoloaded and thus has a timeout
651 651
 			$alloptions = wp_load_alloptions();
652
-			if ( !isset( $alloptions[$transient_option] ) ) {
653
-				$transient_timeout = '_transient_timeout_' . $transient;
654
-				$timeout = get_option( $transient_timeout );
655
-				if ( false !== $timeout && $timeout < time() ) {
656
-					delete_option( $transient_option  );
657
-					delete_option( $transient_timeout );
652
+			if ( ! isset($alloptions[$transient_option])) {
653
+				$transient_timeout = '_transient_timeout_'.$transient;
654
+				$timeout = get_option($transient_timeout);
655
+				if (false !== $timeout && $timeout < time()) {
656
+					delete_option($transient_option);
657
+					delete_option($transient_timeout);
658 658
 					$value = false;
659 659
 				}
660 660
 			}
661 661
 		}
662 662
 
663
-		if ( ! isset( $value ) )
664
-			$value = get_option( $transient_option );
663
+		if ( ! isset($value))
664
+			$value = get_option($transient_option);
665 665
 	}
666 666
 
667 667
 	/**
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
 	 * @param mixed  $value     Value of transient.
676 676
 	 * @param string $transient Transient name.
677 677
 	 */
678
-	return apply_filters( "transient_{$transient}", $value, $transient );
678
+	return apply_filters("transient_{$transient}", $value, $transient);
679 679
 }
680 680
 
681 681
 /**
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
  * @param int    $expiration Optional. Time until expiration in seconds. Default 0 (no expiration).
694 694
  * @return bool False if value was not set and true if value was set.
695 695
  */
696
-function set_transient( $transient, $value, $expiration = 0 ) {
696
+function set_transient($transient, $value, $expiration = 0) {
697 697
 
698 698
 	$expiration = (int) $expiration;
699 699
 
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
 	 * @param int    $expiration Time until expiration in seconds.
711 711
 	 * @param string $transient  Transient name.
712 712
 	 */
713
-	$value = apply_filters( "pre_set_transient_{$transient}", $value, $expiration, $transient );
713
+	$value = apply_filters("pre_set_transient_{$transient}", $value, $expiration, $transient);
714 714
 
715 715
 	/**
716 716
 	 * Filters the expiration for a transient before its value is set.
@@ -723,41 +723,41 @@  discard block
 block discarded – undo
723 723
 	 * @param mixed  $value      New value of transient.
724 724
 	 * @param string $transient  Transient name.
725 725
 	 */
726
-	$expiration = apply_filters( "expiration_of_transient_{$transient}", $expiration, $value, $transient );
726
+	$expiration = apply_filters("expiration_of_transient_{$transient}", $expiration, $value, $transient);
727 727
 
728
-	if ( wp_using_ext_object_cache() ) {
729
-		$result = wp_cache_set( $transient, $value, 'transient', $expiration );
728
+	if (wp_using_ext_object_cache()) {
729
+		$result = wp_cache_set($transient, $value, 'transient', $expiration);
730 730
 	} else {
731
-		$transient_timeout = '_transient_timeout_' . $transient;
732
-		$transient_option = '_transient_' . $transient;
733
-		if ( false === get_option( $transient_option ) ) {
731
+		$transient_timeout = '_transient_timeout_'.$transient;
732
+		$transient_option = '_transient_'.$transient;
733
+		if (false === get_option($transient_option)) {
734 734
 			$autoload = 'yes';
735
-			if ( $expiration ) {
735
+			if ($expiration) {
736 736
 				$autoload = 'no';
737
-				add_option( $transient_timeout, time() + $expiration, '', 'no' );
737
+				add_option($transient_timeout, time() + $expiration, '', 'no');
738 738
 			}
739
-			$result = add_option( $transient_option, $value, '', $autoload );
739
+			$result = add_option($transient_option, $value, '', $autoload);
740 740
 		} else {
741 741
 			// If expiration is requested, but the transient has no timeout option,
742 742
 			// delete, then re-create transient rather than update.
743 743
 			$update = true;
744
-			if ( $expiration ) {
745
-				if ( false === get_option( $transient_timeout ) ) {
746
-					delete_option( $transient_option );
747
-					add_option( $transient_timeout, time() + $expiration, '', 'no' );
748
-					$result = add_option( $transient_option, $value, '', 'no' );
744
+			if ($expiration) {
745
+				if (false === get_option($transient_timeout)) {
746
+					delete_option($transient_option);
747
+					add_option($transient_timeout, time() + $expiration, '', 'no');
748
+					$result = add_option($transient_option, $value, '', 'no');
749 749
 					$update = false;
750 750
 				} else {
751
-					update_option( $transient_timeout, time() + $expiration );
751
+					update_option($transient_timeout, time() + $expiration);
752 752
 				}
753 753
 			}
754
-			if ( $update ) {
755
-				$result = update_option( $transient_option, $value );
754
+			if ($update) {
755
+				$result = update_option($transient_option, $value);
756 756
 			}
757 757
 		}
758 758
 	}
759 759
 
760
-	if ( $result ) {
760
+	if ($result) {
761 761
 
762 762
 		/**
763 763
 		 * Fires after the value for a specific transient has been set.
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
 		 * @param int    $expiration Time until expiration in seconds.
773 773
 		 * @param string $transient  The name of the transient.
774 774
 		 */
775
-		do_action( "set_transient_{$transient}", $value, $expiration, $transient );
775
+		do_action("set_transient_{$transient}", $value, $expiration, $transient);
776 776
 
777 777
 		/**
778 778
 		 * Fires after the value for a transient has been set.
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
 		 * @param mixed  $value      Transient value.
785 785
 		 * @param int    $expiration Time until expiration in seconds.
786 786
 		 */
787
-		do_action( 'setted_transient', $transient, $value, $expiration );
787
+		do_action('setted_transient', $transient, $value, $expiration);
788 788
 	}
789 789
 	return $result;
790 790
 }
@@ -800,43 +800,43 @@  discard block
 block discarded – undo
800 800
  */
801 801
 function wp_user_settings() {
802 802
 
803
-	if ( ! is_admin() || wp_doing_ajax() ) {
803
+	if ( ! is_admin() || wp_doing_ajax()) {
804 804
 		return;
805 805
 	}
806 806
 
807
-	if ( ! $user_id = get_current_user_id() ) {
807
+	if ( ! $user_id = get_current_user_id()) {
808 808
 		return;
809 809
 	}
810 810
 
811
-	if ( is_super_admin() && ! is_user_member_of_blog() ) {
811
+	if (is_super_admin() && ! is_user_member_of_blog()) {
812 812
 		return;
813 813
 	}
814 814
 
815
-	$settings = (string) get_user_option( 'user-settings', $user_id );
815
+	$settings = (string) get_user_option('user-settings', $user_id);
816 816
 
817
-	if ( isset( $_COOKIE['wp-settings-' . $user_id] ) ) {
818
-		$cookie = preg_replace( '/[^A-Za-z0-9=&_]/', '', $_COOKIE['wp-settings-' . $user_id] );
817
+	if (isset($_COOKIE['wp-settings-'.$user_id])) {
818
+		$cookie = preg_replace('/[^A-Za-z0-9=&_]/', '', $_COOKIE['wp-settings-'.$user_id]);
819 819
 
820 820
 		// No change or both empty
821
-		if ( $cookie == $settings )
821
+		if ($cookie == $settings)
822 822
 			return;
823 823
 
824
-		$last_saved = (int) get_user_option( 'user-settings-time', $user_id );
825
-		$current = isset( $_COOKIE['wp-settings-time-' . $user_id]) ? preg_replace( '/[^0-9]/', '', $_COOKIE['wp-settings-time-' . $user_id] ) : 0;
824
+		$last_saved = (int) get_user_option('user-settings-time', $user_id);
825
+		$current = isset($_COOKIE['wp-settings-time-'.$user_id]) ? preg_replace('/[^0-9]/', '', $_COOKIE['wp-settings-time-'.$user_id]) : 0;
826 826
 
827 827
 		// The cookie is newer than the saved value. Update the user_option and leave the cookie as-is
828
-		if ( $current > $last_saved ) {
829
-			update_user_option( $user_id, 'user-settings', $cookie, false );
830
-			update_user_option( $user_id, 'user-settings-time', time() - 5, false );
828
+		if ($current > $last_saved) {
829
+			update_user_option($user_id, 'user-settings', $cookie, false);
830
+			update_user_option($user_id, 'user-settings-time', time() - 5, false);
831 831
 			return;
832 832
 		}
833 833
 	}
834 834
 
835 835
 	// The cookie is not set in the current browser or the saved value is newer.
836
-	$secure = ( 'https' === parse_url( admin_url(), PHP_URL_SCHEME ) );
837
-	setcookie( 'wp-settings-' . $user_id, $settings, time() + YEAR_IN_SECONDS, SITECOOKIEPATH, null, $secure );
838
-	setcookie( 'wp-settings-time-' . $user_id, time(), time() + YEAR_IN_SECONDS, SITECOOKIEPATH, null, $secure );
839
-	$_COOKIE['wp-settings-' . $user_id] = $settings;
836
+	$secure = ('https' === parse_url(admin_url(), PHP_URL_SCHEME));
837
+	setcookie('wp-settings-'.$user_id, $settings, time() + YEAR_IN_SECONDS, SITECOOKIEPATH, null, $secure);
838
+	setcookie('wp-settings-time-'.$user_id, time(), time() + YEAR_IN_SECONDS, SITECOOKIEPATH, null, $secure);
839
+	$_COOKIE['wp-settings-'.$user_id] = $settings;
840 840
 }
841 841
 
842 842
 /**
@@ -848,10 +848,10 @@  discard block
 block discarded – undo
848 848
  * @param string $default Optional default value to return when $name is not set.
849 849
  * @return mixed the last saved user setting or the default value/false if it doesn't exist.
850 850
  */
851
-function get_user_setting( $name, $default = false ) {
851
+function get_user_setting($name, $default = false) {
852 852
 	$all_user_settings = get_all_user_settings();
853 853
 
854
-	return isset( $all_user_settings[$name] ) ? $all_user_settings[$name] : $default;
854
+	return isset($all_user_settings[$name]) ? $all_user_settings[$name] : $default;
855 855
 }
856 856
 
857 857
 /**
@@ -867,15 +867,15 @@  discard block
 block discarded – undo
867 867
  * @param string $value The value for the setting.
868 868
  * @return bool|null True if set successfully, false if not. Null if the current user can't be established.
869 869
  */
870
-function set_user_setting( $name, $value ) {
871
-	if ( headers_sent() ) {
870
+function set_user_setting($name, $value) {
871
+	if (headers_sent()) {
872 872
 		return false;
873 873
 	}
874 874
 
875 875
 	$all_user_settings = get_all_user_settings();
876 876
 	$all_user_settings[$name] = $value;
877 877
 
878
-	return wp_set_all_user_settings( $all_user_settings );
878
+	return wp_set_all_user_settings($all_user_settings);
879 879
 }
880 880
 
881 881
 /**
@@ -890,8 +890,8 @@  discard block
 block discarded – undo
890 890
  * @param string $names The name or array of names of the setting to be deleted.
891 891
  * @return bool|null True if deleted successfully, false if not. Null if the current user can't be established.
892 892
  */
893
-function delete_user_setting( $names ) {
894
-	if ( headers_sent() ) {
893
+function delete_user_setting($names) {
894
+	if (headers_sent()) {
895 895
 		return false;
896 896
 	}
897 897
 
@@ -899,15 +899,15 @@  discard block
 block discarded – undo
899 899
 	$names = (array) $names;
900 900
 	$deleted = false;
901 901
 
902
-	foreach ( $names as $name ) {
903
-		if ( isset( $all_user_settings[$name] ) ) {
904
-			unset( $all_user_settings[$name] );
902
+	foreach ($names as $name) {
903
+		if (isset($all_user_settings[$name])) {
904
+			unset($all_user_settings[$name]);
905 905
 			$deleted = true;
906 906
 		}
907 907
 	}
908 908
 
909
-	if ( $deleted ) {
910
-		return wp_set_all_user_settings( $all_user_settings );
909
+	if ($deleted) {
910
+		return wp_set_all_user_settings($all_user_settings);
911 911
 	}
912 912
 
913 913
 	return false;
@@ -925,27 +925,27 @@  discard block
 block discarded – undo
925 925
 function get_all_user_settings() {
926 926
 	global $_updated_user_settings;
927 927
 
928
-	if ( ! $user_id = get_current_user_id() ) {
928
+	if ( ! $user_id = get_current_user_id()) {
929 929
 		return array();
930 930
 	}
931 931
 
932
-	if ( isset( $_updated_user_settings ) && is_array( $_updated_user_settings ) ) {
932
+	if (isset($_updated_user_settings) && is_array($_updated_user_settings)) {
933 933
 		return $_updated_user_settings;
934 934
 	}
935 935
 
936 936
 	$user_settings = array();
937 937
 
938
-	if ( isset( $_COOKIE['wp-settings-' . $user_id] ) ) {
939
-		$cookie = preg_replace( '/[^A-Za-z0-9=&_-]/', '', $_COOKIE['wp-settings-' . $user_id] );
938
+	if (isset($_COOKIE['wp-settings-'.$user_id])) {
939
+		$cookie = preg_replace('/[^A-Za-z0-9=&_-]/', '', $_COOKIE['wp-settings-'.$user_id]);
940 940
 
941
-		if ( strpos( $cookie, '=' ) ) { // '=' cannot be 1st char
942
-			parse_str( $cookie, $user_settings );
941
+		if (strpos($cookie, '=')) { // '=' cannot be 1st char
942
+			parse_str($cookie, $user_settings);
943 943
 		}
944 944
 	} else {
945
-		$option = get_user_option( 'user-settings', $user_id );
945
+		$option = get_user_option('user-settings', $user_id);
946 946
 
947
-		if ( $option && is_string( $option ) ) {
948
-			parse_str( $option, $user_settings );
947
+		if ($option && is_string($option)) {
948
+			parse_str($option, $user_settings);
949 949
 		}
950 950
 	}
951 951
 
@@ -965,32 +965,32 @@  discard block
 block discarded – undo
965 965
  * @return bool|null False if the current user can't be found, null if the current
966 966
  *                   user is not a super admin or a member of the site, otherwise true.
967 967
  */
968
-function wp_set_all_user_settings( $user_settings ) {
968
+function wp_set_all_user_settings($user_settings) {
969 969
 	global $_updated_user_settings;
970 970
 
971
-	if ( ! $user_id = get_current_user_id() ) {
971
+	if ( ! $user_id = get_current_user_id()) {
972 972
 		return false;
973 973
 	}
974 974
 
975
-	if ( is_super_admin() && ! is_user_member_of_blog() ) {
975
+	if (is_super_admin() && ! is_user_member_of_blog()) {
976 976
 		return;
977 977
 	}
978 978
 
979 979
 	$settings = '';
980
-	foreach ( $user_settings as $name => $value ) {
981
-		$_name = preg_replace( '/[^A-Za-z0-9_-]+/', '', $name );
982
-		$_value = preg_replace( '/[^A-Za-z0-9_-]+/', '', $value );
980
+	foreach ($user_settings as $name => $value) {
981
+		$_name = preg_replace('/[^A-Za-z0-9_-]+/', '', $name);
982
+		$_value = preg_replace('/[^A-Za-z0-9_-]+/', '', $value);
983 983
 
984
-		if ( ! empty( $_name ) ) {
985
-			$settings .= $_name . '=' . $_value . '&';
984
+		if ( ! empty($_name)) {
985
+			$settings .= $_name.'='.$_value.'&';
986 986
 		}
987 987
 	}
988 988
 
989
-	$settings = rtrim( $settings, '&' );
990
-	parse_str( $settings, $_updated_user_settings );
989
+	$settings = rtrim($settings, '&');
990
+	parse_str($settings, $_updated_user_settings);
991 991
 
992
-	update_user_option( $user_id, 'user-settings', $settings, false );
993
-	update_user_option( $user_id, 'user-settings-time', time(), false );
992
+	update_user_option($user_id, 'user-settings', $settings, false);
993
+	update_user_option($user_id, 'user-settings-time', time(), false);
994 994
 
995 995
 	return true;
996 996
 }
@@ -1001,12 +1001,12 @@  discard block
 block discarded – undo
1001 1001
  * @since 2.7.0
1002 1002
  */
1003 1003
 function delete_all_user_settings() {
1004
-	if ( ! $user_id = get_current_user_id() ) {
1004
+	if ( ! $user_id = get_current_user_id()) {
1005 1005
 		return;
1006 1006
 	}
1007 1007
 
1008
-	update_user_option( $user_id, 'user-settings', '', false );
1009
-	setcookie( 'wp-settings-' . $user_id, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH );
1008
+	update_user_option($user_id, 'user-settings', '', false);
1009
+	setcookie('wp-settings-'.$user_id, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH);
1010 1010
 }
1011 1011
 
1012 1012
 /**
@@ -1023,8 +1023,8 @@  discard block
 block discarded – undo
1023 1023
  * @param bool   $deprecated Whether to use cache. Multisite only. Always set to true.
1024 1024
  * @return mixed Value set for the option.
1025 1025
  */
1026
-function get_site_option( $option, $default = false, $deprecated = true ) {
1027
-	return get_network_option( null, $option, $default );
1026
+function get_site_option($option, $default = false, $deprecated = true) {
1027
+	return get_network_option(null, $option, $default);
1028 1028
 }
1029 1029
 
1030 1030
 /**
@@ -1041,8 +1041,8 @@  discard block
 block discarded – undo
1041 1041
  * @param mixed  $value  Option value, can be anything. Expected to not be SQL-escaped.
1042 1042
  * @return bool False if the option was not added. True if the option was added.
1043 1043
  */
1044
-function add_site_option( $option, $value ) {
1045
-	return add_network_option( null, $option, $value );
1044
+function add_site_option($option, $value) {
1045
+	return add_network_option(null, $option, $value);
1046 1046
 }
1047 1047
 
1048 1048
 /**
@@ -1056,8 +1056,8 @@  discard block
 block discarded – undo
1056 1056
  * @param string $option Name of option to remove. Expected to not be SQL-escaped.
1057 1057
  * @return bool True, if succeed. False, if failure.
1058 1058
  */
1059
-function delete_site_option( $option ) {
1060
-	return delete_network_option( null, $option );
1059
+function delete_site_option($option) {
1060
+	return delete_network_option(null, $option);
1061 1061
 }
1062 1062
 
1063 1063
 /**
@@ -1072,8 +1072,8 @@  discard block
 block discarded – undo
1072 1072
  * @param mixed  $value  Option value. Expected to not be SQL-escaped.
1073 1073
  * @return bool False if value was not updated. True if value was updated.
1074 1074
  */
1075
-function update_site_option( $option, $value ) {
1076
-	return update_network_option( null, $option, $value );
1075
+function update_site_option($option, $value) {
1076
+	return update_network_option(null, $option, $value);
1077 1077
 }
1078 1078
 
1079 1079
 /**
@@ -1090,17 +1090,17 @@  discard block
 block discarded – undo
1090 1090
  * @param mixed    $default    Optional. Value to return if the option doesn't exist. Default false.
1091 1091
  * @return mixed Value set for the option.
1092 1092
  */
1093
-function get_network_option( $network_id, $option, $default = false ) {
1093
+function get_network_option($network_id, $option, $default = false) {
1094 1094
 	global $wpdb;
1095 1095
 
1096
-	if ( $network_id && ! is_numeric( $network_id ) ) {
1096
+	if ($network_id && ! is_numeric($network_id)) {
1097 1097
 		return false;
1098 1098
 	}
1099 1099
 
1100 1100
 	$network_id = (int) $network_id;
1101 1101
 
1102 1102
 	// Fallback to the current network if a network ID is not specified.
1103
-	if ( ! $network_id ) {
1103
+	if ( ! $network_id) {
1104 1104
 		$network_id = get_current_network_id();
1105 1105
 	}
1106 1106
 
@@ -1121,17 +1121,17 @@  discard block
 block discarded – undo
1121 1121
 	 * @param string $option     Option name.
1122 1122
 	 * @param int    $network_id ID of the network.
1123 1123
 	 */
1124
-	$pre = apply_filters( "pre_site_option_{$option}", false, $option, $network_id );
1124
+	$pre = apply_filters("pre_site_option_{$option}", false, $option, $network_id);
1125 1125
 
1126
-	if ( false !== $pre ) {
1126
+	if (false !== $pre) {
1127 1127
 		return $pre;
1128 1128
 	}
1129 1129
 
1130 1130
 	// prevent non-existent options from triggering multiple queries
1131 1131
 	$notoptions_key = "$network_id:notoptions";
1132
-	$notoptions = wp_cache_get( $notoptions_key, 'site-options' );
1132
+	$notoptions = wp_cache_get($notoptions_key, 'site-options');
1133 1133
 
1134
-	if ( isset( $notoptions[ $option ] ) ) {
1134
+	if (isset($notoptions[$option])) {
1135 1135
 
1136 1136
 		/**
1137 1137
 		 * Filters a specific default network option.
@@ -1147,34 +1147,34 @@  discard block
 block discarded – undo
1147 1147
 		 * @param string $option     Option name.
1148 1148
 		 * @param int    $network_id ID of the network.
1149 1149
 		 */
1150
-		return apply_filters( "default_site_option_{$option}", $default, $option, $network_id );
1150
+		return apply_filters("default_site_option_{$option}", $default, $option, $network_id);
1151 1151
 	}
1152 1152
 
1153
-	if ( ! is_multisite() ) {
1153
+	if ( ! is_multisite()) {
1154 1154
 		/** This filter is documented in wp-includes/option.php */
1155
-		$default = apply_filters( 'default_site_option_' . $option, $default, $option, $network_id );
1156
-		$value = get_option( $option, $default );
1155
+		$default = apply_filters('default_site_option_'.$option, $default, $option, $network_id);
1156
+		$value = get_option($option, $default);
1157 1157
 	} else {
1158 1158
 		$cache_key = "$network_id:$option";
1159
-		$value = wp_cache_get( $cache_key, 'site-options' );
1159
+		$value = wp_cache_get($cache_key, 'site-options');
1160 1160
 
1161
-		if ( ! isset( $value ) || false === $value ) {
1162
-			$row = $wpdb->get_row( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $network_id ) );
1161
+		if ( ! isset($value) || false === $value) {
1162
+			$row = $wpdb->get_row($wpdb->prepare("SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $network_id));
1163 1163
 
1164 1164
 			// Has to be get_row instead of get_var because of funkiness with 0, false, null values
1165
-			if ( is_object( $row ) ) {
1165
+			if (is_object($row)) {
1166 1166
 				$value = $row->meta_value;
1167
-				$value = maybe_unserialize( $value );
1168
-				wp_cache_set( $cache_key, $value, 'site-options' );
1167
+				$value = maybe_unserialize($value);
1168
+				wp_cache_set($cache_key, $value, 'site-options');
1169 1169
 			} else {
1170
-				if ( ! is_array( $notoptions ) ) {
1170
+				if ( ! is_array($notoptions)) {
1171 1171
 					$notoptions = array();
1172 1172
 				}
1173
-				$notoptions[ $option ] = true;
1174
-				wp_cache_set( $notoptions_key, $notoptions, 'site-options' );
1173
+				$notoptions[$option] = true;
1174
+				wp_cache_set($notoptions_key, $notoptions, 'site-options');
1175 1175
 
1176 1176
 				/** This filter is documented in wp-includes/option.php */
1177
-				$value = apply_filters( 'default_site_option_' . $option, $default, $option, $network_id );
1177
+				$value = apply_filters('default_site_option_'.$option, $default, $option, $network_id);
1178 1178
 			}
1179 1179
 		}
1180 1180
 	}
@@ -1193,7 +1193,7 @@  discard block
 block discarded – undo
1193 1193
 	 * @param string $option     Option name.
1194 1194
 	 * @param int    $network_id ID of the network.
1195 1195
 	 */
1196
-	return apply_filters( "site_option_{$option}", $value, $option, $network_id );
1196
+	return apply_filters("site_option_{$option}", $value, $option, $network_id);
1197 1197
 }
1198 1198
 
1199 1199
 /**
@@ -1212,21 +1212,21 @@  discard block
 block discarded – undo
1212 1212
  * @param mixed  $value      Option value, can be anything. Expected to not be SQL-escaped.
1213 1213
  * @return bool False if option was not added and true if option was added.
1214 1214
  */
1215
-function add_network_option( $network_id, $option, $value ) {
1215
+function add_network_option($network_id, $option, $value) {
1216 1216
 	global $wpdb;
1217 1217
 
1218
-	if ( $network_id && ! is_numeric( $network_id ) ) {
1218
+	if ($network_id && ! is_numeric($network_id)) {
1219 1219
 		return false;
1220 1220
 	}
1221 1221
 
1222 1222
 	$network_id = (int) $network_id;
1223 1223
 
1224 1224
 	// Fallback to the current network if a network ID is not specified.
1225
-	if ( ! $network_id ) {
1225
+	if ( ! $network_id) {
1226 1226
 		$network_id = get_current_network_id();
1227 1227
 	}
1228 1228
 
1229
-	wp_protect_special_option( $option );
1229
+	wp_protect_special_option($option);
1230 1230
 
1231 1231
 	/**
1232 1232
 	 * Filters the value of a specific network option before it is added.
@@ -1242,43 +1242,43 @@  discard block
 block discarded – undo
1242 1242
 	 * @param string $option     Option name.
1243 1243
 	 * @param int    $network_id ID of the network.
1244 1244
 	 */
1245
-	$value = apply_filters( "pre_add_site_option_{$option}", $value, $option, $network_id );
1245
+	$value = apply_filters("pre_add_site_option_{$option}", $value, $option, $network_id);
1246 1246
 
1247 1247
 	$notoptions_key = "$network_id:notoptions";
1248 1248
 
1249
-	if ( ! is_multisite() ) {
1250
-		$result = add_option( $option, $value, '', 'no' );
1249
+	if ( ! is_multisite()) {
1250
+		$result = add_option($option, $value, '', 'no');
1251 1251
 	} else {
1252 1252
 		$cache_key = "$network_id:$option";
1253 1253
 
1254 1254
 		// Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query
1255
-		$notoptions = wp_cache_get( $notoptions_key, 'site-options' );
1256
-		if ( ! is_array( $notoptions ) || ! isset( $notoptions[ $option ] ) ) {
1257
-			if ( false !== get_network_option( $network_id, $option, false ) ) {
1255
+		$notoptions = wp_cache_get($notoptions_key, 'site-options');
1256
+		if ( ! is_array($notoptions) || ! isset($notoptions[$option])) {
1257
+			if (false !== get_network_option($network_id, $option, false)) {
1258 1258
 				return false;
1259 1259
 			}
1260 1260
 		}
1261 1261
 
1262
-		$value = sanitize_option( $option, $value );
1262
+		$value = sanitize_option($option, $value);
1263 1263
 
1264
-		$serialized_value = maybe_serialize( $value );
1265
-		$result = $wpdb->insert( $wpdb->sitemeta, array( 'site_id'    => $network_id, 'meta_key'   => $option, 'meta_value' => $serialized_value ) );
1264
+		$serialized_value = maybe_serialize($value);
1265
+		$result = $wpdb->insert($wpdb->sitemeta, array('site_id'    => $network_id, 'meta_key'   => $option, 'meta_value' => $serialized_value));
1266 1266
 
1267
-		if ( ! $result ) {
1267
+		if ( ! $result) {
1268 1268
 			return false;
1269 1269
 		}
1270 1270
 
1271
-		wp_cache_set( $cache_key, $value, 'site-options' );
1271
+		wp_cache_set($cache_key, $value, 'site-options');
1272 1272
 
1273 1273
 		// This option exists now
1274
-		$notoptions = wp_cache_get( $notoptions_key, 'site-options' ); // yes, again... we need it to be fresh
1275
-		if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) {
1276
-			unset( $notoptions[ $option ] );
1277
-			wp_cache_set( $notoptions_key, $notoptions, 'site-options' );
1274
+		$notoptions = wp_cache_get($notoptions_key, 'site-options'); // yes, again... we need it to be fresh
1275
+		if (is_array($notoptions) && isset($notoptions[$option])) {
1276
+			unset($notoptions[$option]);
1277
+			wp_cache_set($notoptions_key, $notoptions, 'site-options');
1278 1278
 		}
1279 1279
 	}
1280 1280
 
1281
-	if ( $result ) {
1281
+	if ($result) {
1282 1282
 
1283 1283
 		/**
1284 1284
 		 * Fires after a specific network option has been successfully added.
@@ -1293,7 +1293,7 @@  discard block
 block discarded – undo
1293 1293
 		 * @param mixed  $value      Value of the network option.
1294 1294
 		 * @param int    $network_id ID of the network.
1295 1295
 		 */
1296
-		do_action( "add_site_option_{$option}", $option, $value, $network_id );
1296
+		do_action("add_site_option_{$option}", $option, $value, $network_id);
1297 1297
 
1298 1298
 		/**
1299 1299
 		 * Fires after a network option has been successfully added.
@@ -1305,7 +1305,7 @@  discard block
 block discarded – undo
1305 1305
 		 * @param mixed  $value      Value of the network option.
1306 1306
 		 * @param int    $network_id ID of the network.
1307 1307
 		 */
1308
-		do_action( 'add_site_option', $option, $value, $network_id );
1308
+		do_action('add_site_option', $option, $value, $network_id);
1309 1309
 
1310 1310
 		return true;
1311 1311
 	}
@@ -1326,17 +1326,17 @@  discard block
 block discarded – undo
1326 1326
  * @param string $option     Name of option to remove. Expected to not be SQL-escaped.
1327 1327
  * @return bool True, if succeed. False, if failure.
1328 1328
  */
1329
-function delete_network_option( $network_id, $option ) {
1329
+function delete_network_option($network_id, $option) {
1330 1330
 	global $wpdb;
1331 1331
 
1332
-	if ( $network_id && ! is_numeric( $network_id ) ) {
1332
+	if ($network_id && ! is_numeric($network_id)) {
1333 1333
 		return false;
1334 1334
 	}
1335 1335
 
1336 1336
 	$network_id = (int) $network_id;
1337 1337
 
1338 1338
 	// Fallback to the current network if a network ID is not specified.
1339
-	if ( ! $network_id ) {
1339
+	if ( ! $network_id) {
1340 1340
 		$network_id = get_current_network_id();
1341 1341
 	}
1342 1342
 
@@ -1352,22 +1352,22 @@  discard block
 block discarded – undo
1352 1352
 	 * @param string $option     Option name.
1353 1353
 	 * @param int    $network_id ID of the network.
1354 1354
 	 */
1355
-	do_action( "pre_delete_site_option_{$option}", $option, $network_id );
1355
+	do_action("pre_delete_site_option_{$option}", $option, $network_id);
1356 1356
 
1357
-	if ( ! is_multisite() ) {
1358
-		$result = delete_option( $option );
1357
+	if ( ! is_multisite()) {
1358
+		$result = delete_option($option);
1359 1359
 	} else {
1360
-		$row = $wpdb->get_row( $wpdb->prepare( "SELECT meta_id FROM {$wpdb->sitemeta} WHERE meta_key = %s AND site_id = %d", $option, $network_id ) );
1361
-		if ( is_null( $row ) || ! $row->meta_id ) {
1360
+		$row = $wpdb->get_row($wpdb->prepare("SELECT meta_id FROM {$wpdb->sitemeta} WHERE meta_key = %s AND site_id = %d", $option, $network_id));
1361
+		if (is_null($row) || ! $row->meta_id) {
1362 1362
 			return false;
1363 1363
 		}
1364 1364
 		$cache_key = "$network_id:$option";
1365
-		wp_cache_delete( $cache_key, 'site-options' );
1365
+		wp_cache_delete($cache_key, 'site-options');
1366 1366
 
1367
-		$result = $wpdb->delete( $wpdb->sitemeta, array( 'meta_key' => $option, 'site_id' => $network_id ) );
1367
+		$result = $wpdb->delete($wpdb->sitemeta, array('meta_key' => $option, 'site_id' => $network_id));
1368 1368
 	}
1369 1369
 
1370
-	if ( $result ) {
1370
+	if ($result) {
1371 1371
 
1372 1372
 		/**
1373 1373
 		 * Fires after a specific network option has been deleted.
@@ -1381,7 +1381,7 @@  discard block
 block discarded – undo
1381 1381
 		 * @param string $option     Name of the network option.
1382 1382
 		 * @param int    $network_id ID of the network.
1383 1383
 		 */
1384
-		do_action( "delete_site_option_{$option}", $option, $network_id );
1384
+		do_action("delete_site_option_{$option}", $option, $network_id);
1385 1385
 
1386 1386
 		/**
1387 1387
 		 * Fires after a network option has been deleted.
@@ -1392,7 +1392,7 @@  discard block
 block discarded – undo
1392 1392
 		 * @param string $option     Name of the network option.
1393 1393
 		 * @param int    $network_id ID of the network.
1394 1394
 		 */
1395
-		do_action( 'delete_site_option', $option, $network_id );
1395
+		do_action('delete_site_option', $option, $network_id);
1396 1396
 
1397 1397
 		return true;
1398 1398
 	}
@@ -1414,23 +1414,23 @@  discard block
 block discarded – undo
1414 1414
  * @param mixed    $value      Option value. Expected to not be SQL-escaped.
1415 1415
  * @return bool False if value was not updated and true if value was updated.
1416 1416
  */
1417
-function update_network_option( $network_id, $option, $value ) {
1417
+function update_network_option($network_id, $option, $value) {
1418 1418
 	global $wpdb;
1419 1419
 
1420
-	if ( $network_id && ! is_numeric( $network_id ) ) {
1420
+	if ($network_id && ! is_numeric($network_id)) {
1421 1421
 		return false;
1422 1422
 	}
1423 1423
 
1424 1424
 	$network_id = (int) $network_id;
1425 1425
 
1426 1426
 	// Fallback to the current network if a network ID is not specified.
1427
-	if ( ! $network_id ) {
1427
+	if ( ! $network_id) {
1428 1428
 		$network_id = get_current_network_id();
1429 1429
 	}
1430 1430
 
1431
-	wp_protect_special_option( $option );
1431
+	wp_protect_special_option($option);
1432 1432
 
1433
-	$old_value = get_network_option( $network_id, $option, false );
1433
+	$old_value = get_network_option($network_id, $option, false);
1434 1434
 
1435 1435
 	/**
1436 1436
 	 * Filters a specific network option before its value is updated.
@@ -1447,38 +1447,38 @@  discard block
 block discarded – undo
1447 1447
 	 * @param string $option     Option name.
1448 1448
 	 * @param int    $network_id ID of the network.
1449 1449
 	 */
1450
-	$value = apply_filters( "pre_update_site_option_{$option}", $value, $old_value, $option, $network_id );
1450
+	$value = apply_filters("pre_update_site_option_{$option}", $value, $old_value, $option, $network_id);
1451 1451
 
1452
-	if ( $value === $old_value ) {
1452
+	if ($value === $old_value) {
1453 1453
 		return false;
1454 1454
 	}
1455 1455
 
1456
-	if ( false === $old_value ) {
1457
-		return add_network_option( $network_id, $option, $value );
1456
+	if (false === $old_value) {
1457
+		return add_network_option($network_id, $option, $value);
1458 1458
 	}
1459 1459
 
1460 1460
 	$notoptions_key = "$network_id:notoptions";
1461
-	$notoptions = wp_cache_get( $notoptions_key, 'site-options' );
1462
-	if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) {
1463
-		unset( $notoptions[ $option ] );
1464
-		wp_cache_set( $notoptions_key, $notoptions, 'site-options' );
1461
+	$notoptions = wp_cache_get($notoptions_key, 'site-options');
1462
+	if (is_array($notoptions) && isset($notoptions[$option])) {
1463
+		unset($notoptions[$option]);
1464
+		wp_cache_set($notoptions_key, $notoptions, 'site-options');
1465 1465
 	}
1466 1466
 
1467
-	if ( ! is_multisite() ) {
1468
-		$result = update_option( $option, $value, 'no' );
1467
+	if ( ! is_multisite()) {
1468
+		$result = update_option($option, $value, 'no');
1469 1469
 	} else {
1470
-		$value = sanitize_option( $option, $value );
1470
+		$value = sanitize_option($option, $value);
1471 1471
 
1472
-		$serialized_value = maybe_serialize( $value );
1473
-		$result = $wpdb->update( $wpdb->sitemeta, array( 'meta_value' => $serialized_value ), array( 'site_id' => $network_id, 'meta_key' => $option ) );
1472
+		$serialized_value = maybe_serialize($value);
1473
+		$result = $wpdb->update($wpdb->sitemeta, array('meta_value' => $serialized_value), array('site_id' => $network_id, 'meta_key' => $option));
1474 1474
 
1475
-		if ( $result ) {
1475
+		if ($result) {
1476 1476
 			$cache_key = "$network_id:$option";
1477
-			wp_cache_set( $cache_key, $value, 'site-options' );
1477
+			wp_cache_set($cache_key, $value, 'site-options');
1478 1478
 		}
1479 1479
 	}
1480 1480
 
1481
-	if ( $result ) {
1481
+	if ($result) {
1482 1482
 
1483 1483
 		/**
1484 1484
 		 * Fires after the value of a specific network option has been successfully updated.
@@ -1494,7 +1494,7 @@  discard block
 block discarded – undo
1494 1494
 		 * @param mixed  $old_value  Old value of the network option.
1495 1495
 		 * @param int    $network_id ID of the network.
1496 1496
 		 */
1497
-		do_action( "update_site_option_{$option}", $option, $value, $old_value, $network_id );
1497
+		do_action("update_site_option_{$option}", $option, $value, $old_value, $network_id);
1498 1498
 
1499 1499
 		/**
1500 1500
 		 * Fires after the value of a network option has been successfully updated.
@@ -1507,7 +1507,7 @@  discard block
 block discarded – undo
1507 1507
 		 * @param mixed  $old_value  Old value of the network option.
1508 1508
 		 * @param int    $network_id ID of the network.
1509 1509
 		 */
1510
-		do_action( 'update_site_option', $option, $value, $old_value, $network_id );
1510
+		do_action('update_site_option', $option, $value, $old_value, $network_id);
1511 1511
 
1512 1512
 		return true;
1513 1513
 	}
@@ -1523,7 +1523,7 @@  discard block
 block discarded – undo
1523 1523
  * @param string $transient Transient name. Expected to not be SQL-escaped.
1524 1524
  * @return bool True if successful, false otherwise
1525 1525
  */
1526
-function delete_site_transient( $transient ) {
1526
+function delete_site_transient($transient) {
1527 1527
 
1528 1528
 	/**
1529 1529
 	 * Fires immediately before a specific site transient is deleted.
@@ -1534,18 +1534,18 @@  discard block
 block discarded – undo
1534 1534
 	 *
1535 1535
 	 * @param string $transient Transient name.
1536 1536
 	 */
1537
-	do_action( "delete_site_transient_{$transient}", $transient );
1537
+	do_action("delete_site_transient_{$transient}", $transient);
1538 1538
 
1539
-	if ( wp_using_ext_object_cache() ) {
1540
-		$result = wp_cache_delete( $transient, 'site-transient' );
1539
+	if (wp_using_ext_object_cache()) {
1540
+		$result = wp_cache_delete($transient, 'site-transient');
1541 1541
 	} else {
1542
-		$option_timeout = '_site_transient_timeout_' . $transient;
1543
-		$option = '_site_transient_' . $transient;
1544
-		$result = delete_site_option( $option );
1545
-		if ( $result )
1546
-			delete_site_option( $option_timeout );
1542
+		$option_timeout = '_site_transient_timeout_'.$transient;
1543
+		$option = '_site_transient_'.$transient;
1544
+		$result = delete_site_option($option);
1545
+		if ($result)
1546
+			delete_site_option($option_timeout);
1547 1547
 	}
1548
-	if ( $result ) {
1548
+	if ($result) {
1549 1549
 
1550 1550
 		/**
1551 1551
 		 * Fires after a transient is deleted.
@@ -1554,7 +1554,7 @@  discard block
 block discarded – undo
1554 1554
 		 *
1555 1555
 		 * @param string $transient Deleted transient name.
1556 1556
 		 */
1557
-		do_action( 'deleted_site_transient', $transient );
1557
+		do_action('deleted_site_transient', $transient);
1558 1558
 	}
1559 1559
 
1560 1560
 	return $result;
@@ -1573,7 +1573,7 @@  discard block
 block discarded – undo
1573 1573
  * @param string $transient Transient name. Expected to not be SQL-escaped.
1574 1574
  * @return mixed Value of transient.
1575 1575
  */
1576
-function get_site_transient( $transient ) {
1576
+function get_site_transient($transient) {
1577 1577
 
1578 1578
 	/**
1579 1579
 	 * Filters the value of an existing site transient.
@@ -1591,29 +1591,29 @@  discard block
 block discarded – undo
1591 1591
 	 *                                   of the transient, and return the returned value.
1592 1592
 	 * @param string $transient          Transient name.
1593 1593
 	 */
1594
-	$pre = apply_filters( "pre_site_transient_{$transient}", false, $transient );
1594
+	$pre = apply_filters("pre_site_transient_{$transient}", false, $transient);
1595 1595
 
1596
-	if ( false !== $pre )
1596
+	if (false !== $pre)
1597 1597
 		return $pre;
1598 1598
 
1599
-	if ( wp_using_ext_object_cache() ) {
1600
-		$value = wp_cache_get( $transient, 'site-transient' );
1599
+	if (wp_using_ext_object_cache()) {
1600
+		$value = wp_cache_get($transient, 'site-transient');
1601 1601
 	} else {
1602 1602
 		// Core transients that do not have a timeout. Listed here so querying timeouts can be avoided.
1603 1603
 		$no_timeout = array('update_core', 'update_plugins', 'update_themes');
1604
-		$transient_option = '_site_transient_' . $transient;
1605
-		if ( ! in_array( $transient, $no_timeout ) ) {
1606
-			$transient_timeout = '_site_transient_timeout_' . $transient;
1607
-			$timeout = get_site_option( $transient_timeout );
1608
-			if ( false !== $timeout && $timeout < time() ) {
1609
-				delete_site_option( $transient_option  );
1610
-				delete_site_option( $transient_timeout );
1604
+		$transient_option = '_site_transient_'.$transient;
1605
+		if ( ! in_array($transient, $no_timeout)) {
1606
+			$transient_timeout = '_site_transient_timeout_'.$transient;
1607
+			$timeout = get_site_option($transient_timeout);
1608
+			if (false !== $timeout && $timeout < time()) {
1609
+				delete_site_option($transient_option);
1610
+				delete_site_option($transient_timeout);
1611 1611
 				$value = false;
1612 1612
 			}
1613 1613
 		}
1614 1614
 
1615
-		if ( ! isset( $value ) )
1616
-			$value = get_site_option( $transient_option );
1615
+		if ( ! isset($value))
1616
+			$value = get_site_option($transient_option);
1617 1617
 	}
1618 1618
 
1619 1619
 	/**
@@ -1627,7 +1627,7 @@  discard block
 block discarded – undo
1627 1627
 	 * @param mixed  $value     Value of site transient.
1628 1628
 	 * @param string $transient Transient name.
1629 1629
 	 */
1630
-	return apply_filters( "site_transient_{$transient}", $value, $transient );
1630
+	return apply_filters("site_transient_{$transient}", $value, $transient);
1631 1631
 }
1632 1632
 
1633 1633
 /**
@@ -1646,7 +1646,7 @@  discard block
 block discarded – undo
1646 1646
  * @param int    $expiration Optional. Time until expiration in seconds. Default 0 (no expiration).
1647 1647
  * @return bool False if value was not set and true if value was set.
1648 1648
  */
1649
-function set_site_transient( $transient, $value, $expiration = 0 ) {
1649
+function set_site_transient($transient, $value, $expiration = 0) {
1650 1650
 
1651 1651
 	/**
1652 1652
 	 * Filters the value of a specific site transient before it is set.
@@ -1659,7 +1659,7 @@  discard block
 block discarded – undo
1659 1659
 	 * @param mixed  $value     New value of site transient.
1660 1660
 	 * @param string $transient Transient name.
1661 1661
 	 */
1662
-	$value = apply_filters( "pre_set_site_transient_{$transient}", $value, $transient );
1662
+	$value = apply_filters("pre_set_site_transient_{$transient}", $value, $transient);
1663 1663
 
1664 1664
 	$expiration = (int) $expiration;
1665 1665
 
@@ -1674,24 +1674,24 @@  discard block
 block discarded – undo
1674 1674
 	 * @param mixed  $value      New value of site transient.
1675 1675
 	 * @param string $transient  Transient name.
1676 1676
 	 */
1677
-	$expiration = apply_filters( "expiration_of_site_transient_{$transient}", $expiration, $value, $transient );
1677
+	$expiration = apply_filters("expiration_of_site_transient_{$transient}", $expiration, $value, $transient);
1678 1678
 
1679
-	if ( wp_using_ext_object_cache() ) {
1680
-		$result = wp_cache_set( $transient, $value, 'site-transient', $expiration );
1679
+	if (wp_using_ext_object_cache()) {
1680
+		$result = wp_cache_set($transient, $value, 'site-transient', $expiration);
1681 1681
 	} else {
1682
-		$transient_timeout = '_site_transient_timeout_' . $transient;
1683
-		$option = '_site_transient_' . $transient;
1684
-		if ( false === get_site_option( $option ) ) {
1685
-			if ( $expiration )
1686
-				add_site_option( $transient_timeout, time() + $expiration );
1687
-			$result = add_site_option( $option, $value );
1682
+		$transient_timeout = '_site_transient_timeout_'.$transient;
1683
+		$option = '_site_transient_'.$transient;
1684
+		if (false === get_site_option($option)) {
1685
+			if ($expiration)
1686
+				add_site_option($transient_timeout, time() + $expiration);
1687
+			$result = add_site_option($option, $value);
1688 1688
 		} else {
1689
-			if ( $expiration )
1690
-				update_site_option( $transient_timeout, time() + $expiration );
1691
-			$result = update_site_option( $option, $value );
1689
+			if ($expiration)
1690
+				update_site_option($transient_timeout, time() + $expiration);
1691
+			$result = update_site_option($option, $value);
1692 1692
 		}
1693 1693
 	}
1694
-	if ( $result ) {
1694
+	if ($result) {
1695 1695
 
1696 1696
 		/**
1697 1697
 		 * Fires after the value for a specific site transient has been set.
@@ -1705,7 +1705,7 @@  discard block
 block discarded – undo
1705 1705
 		 * @param int    $expiration Time until expiration in seconds.
1706 1706
 		 * @param string $transient  Transient name.
1707 1707
 		 */
1708
-		do_action( "set_site_transient_{$transient}", $value, $expiration, $transient );
1708
+		do_action("set_site_transient_{$transient}", $value, $expiration, $transient);
1709 1709
 
1710 1710
 		/**
1711 1711
 		 * Fires after the value for a site transient has been set.
@@ -1716,7 +1716,7 @@  discard block
 block discarded – undo
1716 1716
 		 * @param mixed  $value      Site transient value.
1717 1717
 		 * @param int    $expiration Time until expiration in seconds.
1718 1718
 		 */
1719
-		do_action( 'setted_site_transient', $transient, $value, $expiration );
1719
+		do_action('setted_site_transient', $transient, $value, $expiration);
1720 1720
 	}
1721 1721
 	return $result;
1722 1722
 }
@@ -1730,24 +1730,24 @@  discard block
 block discarded – undo
1730 1730
  * @since 4.7.0
1731 1731
  */
1732 1732
 function register_initial_settings() {
1733
-	register_setting( 'general', 'blogname', array(
1733
+	register_setting('general', 'blogname', array(
1734 1734
 		'show_in_rest' => array(
1735 1735
 			'name' => 'title',
1736 1736
 		),
1737 1737
 		'type'         => 'string',
1738
-		'description'  => __( 'Site title.' ),
1739
-	) );
1738
+		'description'  => __('Site title.'),
1739
+	));
1740 1740
 
1741
-	register_setting( 'general', 'blogdescription', array(
1741
+	register_setting('general', 'blogdescription', array(
1742 1742
 		'show_in_rest' => array(
1743 1743
 			'name' => 'description',
1744 1744
 		),
1745 1745
 		'type'         => 'string',
1746
-		'description'  => __( 'Site tagline.' ),
1747
-	) );
1746
+		'description'  => __('Site tagline.'),
1747
+	));
1748 1748
 
1749
-	if ( ! is_multisite() ) {
1750
-		register_setting( 'general', 'siteurl', array(
1749
+	if ( ! is_multisite()) {
1750
+		register_setting('general', 'siteurl', array(
1751 1751
 			'show_in_rest' => array(
1752 1752
 				'name'    => 'url',
1753 1753
 				'schema'  => array(
@@ -1755,12 +1755,12 @@  discard block
 block discarded – undo
1755 1755
 				),
1756 1756
 			),
1757 1757
 			'type'         => 'string',
1758
-			'description'  => __( 'Site URL.' ),
1759
-		) );
1758
+			'description'  => __('Site URL.'),
1759
+		));
1760 1760
 	}
1761 1761
 
1762
-	if ( ! is_multisite() ) {
1763
-		register_setting( 'general', 'admin_email', array(
1762
+	if ( ! is_multisite()) {
1763
+		register_setting('general', 'admin_email', array(
1764 1764
 			'show_in_rest' => array(
1765 1765
 				'name'    => 'email',
1766 1766
 				'schema'  => array(
@@ -1768,90 +1768,90 @@  discard block
 block discarded – undo
1768 1768
 				),
1769 1769
 			),
1770 1770
 			'type'         => 'string',
1771
-			'description'  => __( 'This address is used for admin purposes, like new user notification.' ),
1772
-		) );
1771
+			'description'  => __('This address is used for admin purposes, like new user notification.'),
1772
+		));
1773 1773
 	}
1774 1774
 
1775
-	register_setting( 'general', 'timezone_string', array(
1775
+	register_setting('general', 'timezone_string', array(
1776 1776
 		'show_in_rest' => array(
1777 1777
 			'name' => 'timezone',
1778 1778
 		),
1779 1779
 		'type'         => 'string',
1780
-		'description'  => __( 'A city in the same timezone as you.' ),
1781
-	) );
1780
+		'description'  => __('A city in the same timezone as you.'),
1781
+	));
1782 1782
 
1783
-	register_setting( 'general', 'date_format', array(
1783
+	register_setting('general', 'date_format', array(
1784 1784
 		'show_in_rest' => true,
1785 1785
 		'type'         => 'string',
1786
-		'description'  => __( 'A date format for all date strings.' ),
1787
-	) );
1786
+		'description'  => __('A date format for all date strings.'),
1787
+	));
1788 1788
 
1789
-	register_setting( 'general', 'time_format', array(
1789
+	register_setting('general', 'time_format', array(
1790 1790
 		'show_in_rest' => true,
1791 1791
 		'type'         => 'string',
1792
-		'description'  => __( 'A time format for all time strings.' ),
1793
-	) );
1792
+		'description'  => __('A time format for all time strings.'),
1793
+	));
1794 1794
 
1795
-	register_setting( 'general', 'start_of_week', array(
1795
+	register_setting('general', 'start_of_week', array(
1796 1796
 		'show_in_rest' => true,
1797 1797
 		'type'         => 'integer',
1798
-		'description'  => __( 'A day number of the week that the week should start on.' ),
1799
-	) );
1798
+		'description'  => __('A day number of the week that the week should start on.'),
1799
+	));
1800 1800
 
1801
-	register_setting( 'general', 'WPLANG', array(
1801
+	register_setting('general', 'WPLANG', array(
1802 1802
 		'show_in_rest' => array(
1803 1803
 			'name' => 'language',
1804 1804
 		),
1805 1805
 		'type'         => 'string',
1806
-		'description'  => __( 'WordPress locale code.' ),
1806
+		'description'  => __('WordPress locale code.'),
1807 1807
 		'default'      => 'en_US',
1808
-	) );
1808
+	));
1809 1809
 
1810
-	register_setting( 'writing', 'use_smilies', array(
1810
+	register_setting('writing', 'use_smilies', array(
1811 1811
 		'show_in_rest' => true,
1812 1812
 		'type'         => 'boolean',
1813
-		'description'  => __( 'Convert emoticons like :-) and :-P to graphics on display.' ),
1813
+		'description'  => __('Convert emoticons like :-) and :-P to graphics on display.'),
1814 1814
 		'default'      => true,
1815
-	) );
1815
+	));
1816 1816
 
1817
-	register_setting( 'writing', 'default_category', array(
1817
+	register_setting('writing', 'default_category', array(
1818 1818
 		'show_in_rest' => true,
1819 1819
 		'type'         => 'integer',
1820
-		'description'  => __( 'Default post category.' ),
1821
-	) );
1820
+		'description'  => __('Default post category.'),
1821
+	));
1822 1822
 
1823
-	register_setting( 'writing', 'default_post_format', array(
1823
+	register_setting('writing', 'default_post_format', array(
1824 1824
 		'show_in_rest' => true,
1825 1825
 		'type'         => 'string',
1826
-		'description'  => __( 'Default post format.' ),
1827
-	) );
1826
+		'description'  => __('Default post format.'),
1827
+	));
1828 1828
 
1829
-	register_setting( 'reading', 'posts_per_page', array(
1829
+	register_setting('reading', 'posts_per_page', array(
1830 1830
 		'show_in_rest' => true,
1831 1831
 		'type'         => 'integer',
1832
-		'description'  => __( 'Blog pages show at most.' ),
1832
+		'description'  => __('Blog pages show at most.'),
1833 1833
 		'default'      => 10,
1834
-	) );
1834
+	));
1835 1835
 
1836
-	register_setting( 'discussion', 'default_ping_status', array(
1836
+	register_setting('discussion', 'default_ping_status', array(
1837 1837
 		'show_in_rest' => array(
1838 1838
 			'schema'   => array(
1839
-				'enum' => array( 'open', 'closed' ),
1839
+				'enum' => array('open', 'closed'),
1840 1840
 			),
1841 1841
 		),
1842 1842
 		'type'         => 'string',
1843
-		'description'  => __( 'Allow link notifications from other blogs (pingbacks and trackbacks) on new articles.' ),
1844
-	) );
1843
+		'description'  => __('Allow link notifications from other blogs (pingbacks and trackbacks) on new articles.'),
1844
+	));
1845 1845
 
1846
-	register_setting( 'discussion', 'default_comment_status', array(
1846
+	register_setting('discussion', 'default_comment_status', array(
1847 1847
 		'show_in_rest' => array(
1848 1848
 			'schema'   => array(
1849
-				'enum' => array( 'open', 'closed' ),
1849
+				'enum' => array('open', 'closed'),
1850 1850
 			),
1851 1851
 		),
1852 1852
 		'type'         => 'string',
1853
-		'description'  => __( 'Allow people to post comments on new articles.' ),
1854
-	) );
1853
+		'description'  => __('Allow people to post comments on new articles.'),
1854
+	));
1855 1855
 
1856 1856
 }
1857 1857
 
@@ -1877,7 +1877,7 @@  discard block
 block discarded – undo
1877 1877
  *     @type mixed    $default           Default value when calling `get_option()`.
1878 1878
  * }
1879 1879
  */
1880
-function register_setting( $option_group, $option_name, $args = array() ) {
1880
+function register_setting($option_group, $option_name, $args = array()) {
1881 1881
 	global $new_whitelist_options, $wp_registered_settings;
1882 1882
 
1883 1883
 	$defaults = array(
@@ -1889,7 +1889,7 @@  discard block
 block discarded – undo
1889 1889
 	);
1890 1890
 
1891 1891
 	// Back-compat: old sanitize callback is added.
1892
-	if ( is_callable( $args ) ) {
1892
+	if (is_callable($args)) {
1893 1893
 		$args = array(
1894 1894
 			'sanitize_callback' => $args,
1895 1895
 		);
@@ -1905,32 +1905,32 @@  discard block
 block discarded – undo
1905 1905
 	 * @param string $option_group Setting group.
1906 1906
 	 * @param string $option_name  Setting name.
1907 1907
 	 */
1908
-	$args = apply_filters( 'register_setting_args', $args, $defaults, $option_group, $option_name );
1909
-	$args = wp_parse_args( $args, $defaults );
1908
+	$args = apply_filters('register_setting_args', $args, $defaults, $option_group, $option_name);
1909
+	$args = wp_parse_args($args, $defaults);
1910 1910
 
1911
-	if ( ! is_array( $wp_registered_settings ) ) {
1911
+	if ( ! is_array($wp_registered_settings)) {
1912 1912
 		$wp_registered_settings = array();
1913 1913
 	}
1914 1914
 
1915
-	if ( 'misc' == $option_group ) {
1916
-		_deprecated_argument( __FUNCTION__, '3.0.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'misc' ) );
1915
+	if ('misc' == $option_group) {
1916
+		_deprecated_argument(__FUNCTION__, '3.0.0', sprintf(__('The "%s" options group has been removed. Use another settings group.'), 'misc'));
1917 1917
 		$option_group = 'general';
1918 1918
 	}
1919 1919
 
1920
-	if ( 'privacy' == $option_group ) {
1921
-		_deprecated_argument( __FUNCTION__, '3.5.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'privacy' ) );
1920
+	if ('privacy' == $option_group) {
1921
+		_deprecated_argument(__FUNCTION__, '3.5.0', sprintf(__('The "%s" options group has been removed. Use another settings group.'), 'privacy'));
1922 1922
 		$option_group = 'reading';
1923 1923
 	}
1924 1924
 
1925
-	$new_whitelist_options[ $option_group ][] = $option_name;
1926
-	if ( ! empty( $args['sanitize_callback'] ) ) {
1927
-		add_filter( "sanitize_option_{$option_name}", $args['sanitize_callback'] );
1925
+	$new_whitelist_options[$option_group][] = $option_name;
1926
+	if ( ! empty($args['sanitize_callback'])) {
1927
+		add_filter("sanitize_option_{$option_name}", $args['sanitize_callback']);
1928 1928
 	}
1929
-	if ( array_key_exists( 'default', $args ) ) {
1930
-		add_filter( "default_option_{$option_name}", 'filter_default_option', 10, 3 );
1929
+	if (array_key_exists('default', $args)) {
1930
+		add_filter("default_option_{$option_name}", 'filter_default_option', 10, 3);
1931 1931
 	}
1932 1932
 
1933
-	$wp_registered_settings[ $option_name ] = $args;
1933
+	$wp_registered_settings[$option_name] = $args;
1934 1934
 }
1935 1935
 
1936 1936
 /**
@@ -1945,35 +1945,35 @@  discard block
 block discarded – undo
1945 1945
  * @param string   $option_name       The name of the option to unregister.
1946 1946
  * @param callable $deprecated        Deprecated.
1947 1947
  */
1948
-function unregister_setting( $option_group, $option_name, $deprecated = '' ) {
1948
+function unregister_setting($option_group, $option_name, $deprecated = '') {
1949 1949
 	global $new_whitelist_options, $wp_registered_settings;
1950 1950
 
1951
-	if ( 'misc' == $option_group ) {
1952
-		_deprecated_argument( __FUNCTION__, '3.0.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'misc' ) );
1951
+	if ('misc' == $option_group) {
1952
+		_deprecated_argument(__FUNCTION__, '3.0.0', sprintf(__('The "%s" options group has been removed. Use another settings group.'), 'misc'));
1953 1953
 		$option_group = 'general';
1954 1954
 	}
1955 1955
 
1956
-	if ( 'privacy' == $option_group ) {
1957
-		_deprecated_argument( __FUNCTION__, '3.5.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'privacy' ) );
1956
+	if ('privacy' == $option_group) {
1957
+		_deprecated_argument(__FUNCTION__, '3.5.0', sprintf(__('The "%s" options group has been removed. Use another settings group.'), 'privacy'));
1958 1958
 		$option_group = 'reading';
1959 1959
 	}
1960 1960
 
1961
-	$pos = array_search( $option_name, (array) $new_whitelist_options[ $option_group ] );
1962
-	if ( $pos !== false ) {
1963
-		unset( $new_whitelist_options[ $option_group ][ $pos ] );
1961
+	$pos = array_search($option_name, (array) $new_whitelist_options[$option_group]);
1962
+	if ($pos !== false) {
1963
+		unset($new_whitelist_options[$option_group][$pos]);
1964 1964
 	}
1965
-	if ( '' !== $deprecated ) {
1966
-		_deprecated_argument( __FUNCTION__, '4.7.0', __( '$sanitize_callback is deprecated. The callback from register_setting() is used instead.' ) );
1967
-		remove_filter( "sanitize_option_{$option_name}", $deprecated );
1965
+	if ('' !== $deprecated) {
1966
+		_deprecated_argument(__FUNCTION__, '4.7.0', __('$sanitize_callback is deprecated. The callback from register_setting() is used instead.'));
1967
+		remove_filter("sanitize_option_{$option_name}", $deprecated);
1968 1968
 	}
1969 1969
 
1970
-	if ( isset( $wp_registered_settings[ $option_name ] ) ) {
1970
+	if (isset($wp_registered_settings[$option_name])) {
1971 1971
 		// Remove the sanitize callback if one was set during registration.
1972
-		if ( ! empty( $wp_registered_settings[ $option_name ]['sanitize_callback'] ) ) {
1973
-			remove_filter( "sanitize_option_{$option_name}", $wp_registered_settings[ $option_name ]['sanitize_callback'] );
1972
+		if ( ! empty($wp_registered_settings[$option_name]['sanitize_callback'])) {
1973
+			remove_filter("sanitize_option_{$option_name}", $wp_registered_settings[$option_name]['sanitize_callback']);
1974 1974
 		}
1975 1975
 
1976
-		unset( $wp_registered_settings[ $option_name ] );
1976
+		unset($wp_registered_settings[$option_name]);
1977 1977
 	}
1978 1978
 }
1979 1979
 
@@ -1987,7 +1987,7 @@  discard block
 block discarded – undo
1987 1987
 function get_registered_settings() {
1988 1988
 	global $wp_registered_settings;
1989 1989
 
1990
-	if ( ! is_array( $wp_registered_settings ) ) {
1990
+	if ( ! is_array($wp_registered_settings)) {
1991 1991
 		return array();
1992 1992
 	}
1993 1993
 
@@ -2007,15 +2007,15 @@  discard block
 block discarded – undo
2007 2007
  * @param bool $passed_default Was `get_option()` passed a default value?
2008 2008
  * @return mixed Filtered default value.
2009 2009
  */
2010
-function filter_default_option( $default, $option, $passed_default ) {
2011
-	if ( $passed_default ) {
2010
+function filter_default_option($default, $option, $passed_default) {
2011
+	if ($passed_default) {
2012 2012
 		return $default;
2013 2013
 	}
2014 2014
 
2015 2015
 	$registered = get_registered_settings();
2016
-	if ( empty( $registered[ $option ] ) ) {
2016
+	if (empty($registered[$option])) {
2017 2017
 		return $default;
2018 2018
 	}
2019 2019
 
2020
-	return $registered[ $option ]['default'];
2020
+	return $registered[$option]['default'];
2021 2021
 }
Please login to merge, or discard this patch.
Braces   +93 added lines, -63 removed lines patch added patch discarded remove patch
@@ -31,8 +31,9 @@  discard block
 block discarded – undo
31 31
 	global $wpdb;
32 32
 
33 33
 	$option = trim( $option );
34
-	if ( empty( $option ) )
35
-		return false;
34
+	if ( empty( $option ) ) {
35
+			return false;
36
+	}
36 37
 
37 38
 	/**
38 39
 	 * Filters the value of an existing option before it is retrieved.
@@ -50,11 +51,13 @@  discard block
 block discarded – undo
50 51
 	 * @param string     $option     Option name.
51 52
 	 */
52 53
 	$pre = apply_filters( "pre_option_{$option}", false, $option );
53
-	if ( false !== $pre )
54
-		return $pre;
54
+	if ( false !== $pre ) {
55
+			return $pre;
56
+	}
55 57
 
56
-	if ( defined( 'WP_SETUP_CONFIG' ) )
57
-		return false;
58
+	if ( defined( 'WP_SETUP_CONFIG' ) ) {
59
+			return false;
60
+	}
58 61
 
59 62
 	// Distinguish between `false` as a default, and not passing one.
60 63
 	$passed_default = func_num_args() > 1;
@@ -119,11 +122,13 @@  discard block
 block discarded – undo
119 122
 	}
120 123
 
121 124
 	// If home is not set use siteurl.
122
-	if ( 'home' == $option && '' == $value )
123
-		return get_option( 'siteurl' );
125
+	if ( 'home' == $option && '' == $value ) {
126
+			return get_option( 'siteurl' );
127
+	}
124 128
 
125
-	if ( in_array( $option, array('siteurl', 'home', 'category_base', 'tag_base') ) )
126
-		$value = untrailingslashit( $value );
129
+	if ( in_array( $option, array('siteurl', 'home', 'category_base', 'tag_base') ) ) {
130
+			$value = untrailingslashit( $value );
131
+	}
127 132
 
128 133
 	/**
129 134
 	 * Filters the value of an existing option.
@@ -152,9 +157,10 @@  discard block
 block discarded – undo
152 157
  * @param string $option Option name.
153 158
  */
154 159
 function wp_protect_special_option( $option ) {
155
-	if ( 'alloptions' === $option || 'notoptions' === $option )
156
-		wp_die( sprintf( __( '%s is a protected WP option and may not be modified' ), esc_html( $option ) ) );
157
-}
160
+	if ( 'alloptions' === $option || 'notoptions' === $option ) {
161
+			wp_die( sprintf( __( '%s is a protected WP option and may not be modified' ), esc_html( $option ) ) );
162
+	}
163
+	}
158 164
 
159 165
 /**
160 166
  * Print option value after sanitizing for forms.
@@ -179,22 +185,25 @@  discard block
 block discarded – undo
179 185
 function wp_load_alloptions() {
180 186
 	global $wpdb;
181 187
 
182
-	if ( ! wp_installing() || ! is_multisite() )
183
-		$alloptions = wp_cache_get( 'alloptions', 'options' );
184
-	else
185
-		$alloptions = false;
188
+	if ( ! wp_installing() || ! is_multisite() ) {
189
+			$alloptions = wp_cache_get( 'alloptions', 'options' );
190
+	} else {
191
+			$alloptions = false;
192
+	}
186 193
 
187 194
 	if ( !$alloptions ) {
188 195
 		$suppress = $wpdb->suppress_errors();
189
-		if ( !$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" ) )
190
-			$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" );
196
+		if ( !$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" ) ) {
197
+					$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" );
198
+		}
191 199
 		$wpdb->suppress_errors($suppress);
192 200
 		$alloptions = array();
193 201
 		foreach ( (array) $alloptions_db as $o ) {
194 202
 			$alloptions[$o->option_name] = $o->option_value;
195 203
 		}
196
-		if ( ! wp_installing() || ! is_multisite() )
197
-			wp_cache_add( 'alloptions', $alloptions, 'options' );
204
+		if ( ! wp_installing() || ! is_multisite() ) {
205
+					wp_cache_add( 'alloptions', $alloptions, 'options' );
206
+		}
198 207
 	}
199 208
 
200 209
 	return $alloptions;
@@ -212,11 +221,13 @@  discard block
 block discarded – undo
212 221
 function wp_load_core_site_options( $site_id = null ) {
213 222
 	global $wpdb;
214 223
 
215
-	if ( ! is_multisite() || wp_using_ext_object_cache() || wp_installing() )
216
-		return;
224
+	if ( ! is_multisite() || wp_using_ext_object_cache() || wp_installing() ) {
225
+			return;
226
+	}
217 227
 
218
-	if ( empty($site_id) )
219
-		$site_id = $wpdb->siteid;
228
+	if ( empty($site_id) ) {
229
+			$site_id = $wpdb->siteid;
230
+	}
220 231
 
221 232
 	$core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled', 'ms_files_rewriting' );
222 233
 
@@ -259,13 +270,15 @@  discard block
 block discarded – undo
259 270
 	global $wpdb;
260 271
 
261 272
 	$option = trim($option);
262
-	if ( empty($option) )
263
-		return false;
273
+	if ( empty($option) ) {
274
+			return false;
275
+	}
264 276
 
265 277
 	wp_protect_special_option( $option );
266 278
 
267
-	if ( is_object( $value ) )
268
-		$value = clone $value;
279
+	if ( is_object( $value ) ) {
280
+			$value = clone $value;
281
+	}
269 282
 
270 283
 	$value = sanitize_option( $option, $value );
271 284
 	$old_value = get_option( $option );
@@ -340,8 +353,9 @@  discard block
 block discarded – undo
340 353
 	}
341 354
 
342 355
 	$result = $wpdb->update( $wpdb->options, $update_args, array( 'option_name' => $option ) );
343
-	if ( ! $result )
344
-		return false;
356
+	if ( ! $result ) {
357
+			return false;
358
+	}
345 359
 
346 360
 	$notoptions = wp_cache_get( 'notoptions', 'options' );
347 361
 	if ( is_array( $notoptions ) && isset( $notoptions[$option] ) ) {
@@ -412,26 +426,30 @@  discard block
 block discarded – undo
412 426
 function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) {
413 427
 	global $wpdb;
414 428
 
415
-	if ( !empty( $deprecated ) )
416
-		_deprecated_argument( __FUNCTION__, '2.3.0' );
429
+	if ( !empty( $deprecated ) ) {
430
+			_deprecated_argument( __FUNCTION__, '2.3.0' );
431
+	}
417 432
 
418 433
 	$option = trim($option);
419
-	if ( empty($option) )
420
-		return false;
434
+	if ( empty($option) ) {
435
+			return false;
436
+	}
421 437
 
422 438
 	wp_protect_special_option( $option );
423 439
 
424
-	if ( is_object($value) )
425
-		$value = clone $value;
440
+	if ( is_object($value) ) {
441
+			$value = clone $value;
442
+	}
426 443
 
427 444
 	$value = sanitize_option( $option, $value );
428 445
 
429 446
 	// Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query
430 447
 	$notoptions = wp_cache_get( 'notoptions', 'options' );
431
-	if ( !is_array( $notoptions ) || !isset( $notoptions[$option] ) )
432
-		/** This filter is documented in wp-includes/option.php */
448
+	if ( !is_array( $notoptions ) || !isset( $notoptions[$option] ) ) {
449
+			/** This filter is documented in wp-includes/option.php */
433 450
 		if ( apply_filters( "default_option_{$option}", false, $option, false ) !== get_option( $option ) )
434 451
 			return false;
452
+	}
435 453
 
436 454
 	$serialized_value = maybe_serialize( $value );
437 455
 	$autoload = ( 'no' === $autoload || false === $autoload ) ? 'no' : 'yes';
@@ -447,8 +465,9 @@  discard block
 block discarded – undo
447 465
 	do_action( 'add_option', $option, $value );
448 466
 
449 467
 	$result = $wpdb->query( $wpdb->prepare( "INSERT INTO `$wpdb->options` (`option_name`, `option_value`, `autoload`) VALUES (%s, %s, %s) ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)", $option, $serialized_value, $autoload ) );
450
-	if ( ! $result )
451
-		return false;
468
+	if ( ! $result ) {
469
+			return false;
470
+	}
452 471
 
453 472
 	if ( ! wp_installing() ) {
454 473
 		if ( 'yes' == $autoload ) {
@@ -506,15 +525,17 @@  discard block
 block discarded – undo
506 525
 	global $wpdb;
507 526
 
508 527
 	$option = trim( $option );
509
-	if ( empty( $option ) )
510
-		return false;
528
+	if ( empty( $option ) ) {
529
+			return false;
530
+	}
511 531
 
512 532
 	wp_protect_special_option( $option );
513 533
 
514 534
 	// Get the ID, if no ID then return
515 535
 	$row = $wpdb->get_row( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $option ) );
516
-	if ( is_null( $row ) )
517
-		return false;
536
+	if ( is_null( $row ) ) {
537
+			return false;
538
+	}
518 539
 
519 540
 	/**
520 541
 	 * Fires immediately before an option is deleted.
@@ -590,8 +611,9 @@  discard block
 block discarded – undo
590 611
 		$option_timeout = '_transient_timeout_' . $transient;
591 612
 		$option = '_transient_' . $transient;
592 613
 		$result = delete_option( $option );
593
-		if ( $result )
594
-			delete_option( $option_timeout );
614
+		if ( $result ) {
615
+					delete_option( $option_timeout );
616
+		}
595 617
 	}
596 618
 
597 619
 	if ( $result ) {
@@ -639,8 +661,9 @@  discard block
 block discarded – undo
639 661
 	 * @param string $transient     Transient name.
640 662
 	 */
641 663
 	$pre = apply_filters( "pre_transient_{$transient}", false, $transient );
642
-	if ( false !== $pre )
643
-		return $pre;
664
+	if ( false !== $pre ) {
665
+			return $pre;
666
+	}
644 667
 
645 668
 	if ( wp_using_ext_object_cache() ) {
646 669
 		$value = wp_cache_get( $transient, 'transient' );
@@ -660,8 +683,9 @@  discard block
 block discarded – undo
660 683
 			}
661 684
 		}
662 685
 
663
-		if ( ! isset( $value ) )
664
-			$value = get_option( $transient_option );
686
+		if ( ! isset( $value ) ) {
687
+					$value = get_option( $transient_option );
688
+		}
665 689
 	}
666 690
 
667 691
 	/**
@@ -818,8 +842,9 @@  discard block
 block discarded – undo
818 842
 		$cookie = preg_replace( '/[^A-Za-z0-9=&_]/', '', $_COOKIE['wp-settings-' . $user_id] );
819 843
 
820 844
 		// No change or both empty
821
-		if ( $cookie == $settings )
822
-			return;
845
+		if ( $cookie == $settings ) {
846
+					return;
847
+		}
823 848
 
824 849
 		$last_saved = (int) get_user_option( 'user-settings-time', $user_id );
825 850
 		$current = isset( $_COOKIE['wp-settings-time-' . $user_id]) ? preg_replace( '/[^0-9]/', '', $_COOKIE['wp-settings-time-' . $user_id] ) : 0;
@@ -1542,8 +1567,9 @@  discard block
 block discarded – undo
1542 1567
 		$option_timeout = '_site_transient_timeout_' . $transient;
1543 1568
 		$option = '_site_transient_' . $transient;
1544 1569
 		$result = delete_site_option( $option );
1545
-		if ( $result )
1546
-			delete_site_option( $option_timeout );
1570
+		if ( $result ) {
1571
+					delete_site_option( $option_timeout );
1572
+		}
1547 1573
 	}
1548 1574
 	if ( $result ) {
1549 1575
 
@@ -1593,8 +1619,9 @@  discard block
 block discarded – undo
1593 1619
 	 */
1594 1620
 	$pre = apply_filters( "pre_site_transient_{$transient}", false, $transient );
1595 1621
 
1596
-	if ( false !== $pre )
1597
-		return $pre;
1622
+	if ( false !== $pre ) {
1623
+			return $pre;
1624
+	}
1598 1625
 
1599 1626
 	if ( wp_using_ext_object_cache() ) {
1600 1627
 		$value = wp_cache_get( $transient, 'site-transient' );
@@ -1612,8 +1639,9 @@  discard block
 block discarded – undo
1612 1639
 			}
1613 1640
 		}
1614 1641
 
1615
-		if ( ! isset( $value ) )
1616
-			$value = get_site_option( $transient_option );
1642
+		if ( ! isset( $value ) ) {
1643
+					$value = get_site_option( $transient_option );
1644
+		}
1617 1645
 	}
1618 1646
 
1619 1647
 	/**
@@ -1682,12 +1710,14 @@  discard block
 block discarded – undo
1682 1710
 		$transient_timeout = '_site_transient_timeout_' . $transient;
1683 1711
 		$option = '_site_transient_' . $transient;
1684 1712
 		if ( false === get_site_option( $option ) ) {
1685
-			if ( $expiration )
1686
-				add_site_option( $transient_timeout, time() + $expiration );
1713
+			if ( $expiration ) {
1714
+							add_site_option( $transient_timeout, time() + $expiration );
1715
+			}
1687 1716
 			$result = add_site_option( $option, $value );
1688 1717
 		} else {
1689
-			if ( $expiration )
1690
-				update_site_option( $transient_timeout, time() + $expiration );
1718
+			if ( $expiration ) {
1719
+							update_site_option( $transient_timeout, time() + $expiration );
1720
+			}
1691 1721
 			$result = update_site_option( $option, $value );
1692 1722
 		}
1693 1723
 	}
Please login to merge, or discard this patch.
src/wp-includes/query.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  * @global WP_Query $wp_query Global WP_Query instance.
21 21
  *
22 22
  * @param string $var       The variable key to retrieve.
23
- * @param mixed  $default   Optional. Value to return if the query variable is not set. Default empty.
23
+ * @param integer  $default   Optional. Value to return if the query variable is not set. Default empty.
24 24
  * @return mixed Contents of the query variable.
25 25
  */
26 26
 function get_query_var( $var, $default = '' ) {
@@ -286,8 +286,8 @@  discard block
 block discarded – undo
286 286
  *
287 287
  * @global WP_Query $wp_query Global WP_Query instance.
288 288
  *
289
- * @param string|array     $taxonomy Optional. Taxonomy slug or slugs.
290
- * @param int|string|array $term     Optional. Term ID, name, slug or array of Term IDs, names, and slugs.
289
+ * @param string     $taxonomy Optional. Taxonomy slug or slugs.
290
+ * @param string $term     Optional. Term ID, name, slug or array of Term IDs, names, and slugs.
291 291
  * @return bool True for custom taxonomy archive pages, false for built-in taxonomies (category and tag archives).
292 292
  */
293 293
 function is_tax( $taxonomy = '', $term = '' ) {
Please login to merge, or discard this patch.
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
  * @param mixed  $default   Optional. Value to return if the query variable is not set. Default empty.
24 24
  * @return mixed Contents of the query variable.
25 25
  */
26
-function get_query_var( $var, $default = '' ) {
26
+function get_query_var($var, $default = '') {
27 27
 	global $wp_query;
28
-	return $wp_query->get( $var, $default );
28
+	return $wp_query->get($var, $default);
29 29
 }
30 30
 
31 31
 /**
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
  * @param string $var   Query variable key.
72 72
  * @param mixed  $value Query variable value.
73 73
  */
74
-function set_query_var( $var, $value ) {
74
+function set_query_var($var, $value) {
75 75
 	global $wp_query;
76
-	$wp_query->set( $var, $value );
76
+	$wp_query->set($var, $value);
77 77
 }
78 78
 
79 79
 /**
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 function wp_reset_postdata() {
128 128
 	global $wp_query;
129 129
 
130
-	if ( isset( $wp_query ) ) {
130
+	if (isset($wp_query)) {
131 131
 		$wp_query->reset_postdata();
132 132
 	}
133 133
 }
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
 function is_archive() {
151 151
 	global $wp_query;
152 152
 
153
-	if ( ! isset( $wp_query ) ) {
154
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
153
+	if ( ! isset($wp_query)) {
154
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
155 155
 		return false;
156 156
 	}
157 157
 
@@ -168,15 +168,15 @@  discard block
 block discarded – undo
168 168
  * @param string|array $post_types Optional. Post type or array of posts types to check against.
169 169
  * @return bool
170 170
  */
171
-function is_post_type_archive( $post_types = '' ) {
171
+function is_post_type_archive($post_types = '') {
172 172
 	global $wp_query;
173 173
 
174
-	if ( ! isset( $wp_query ) ) {
175
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
174
+	if ( ! isset($wp_query)) {
175
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
176 176
 		return false;
177 177
 	}
178 178
 
179
-	return $wp_query->is_post_type_archive( $post_types );
179
+	return $wp_query->is_post_type_archive($post_types);
180 180
 }
181 181
 
182 182
 /**
@@ -189,15 +189,15 @@  discard block
 block discarded – undo
189 189
  * @param int|string|array|object $attachment Attachment ID, title, slug, or array of such.
190 190
  * @return bool
191 191
  */
192
-function is_attachment( $attachment = '' ) {
192
+function is_attachment($attachment = '') {
193 193
 	global $wp_query;
194 194
 
195
-	if ( ! isset( $wp_query ) ) {
196
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
195
+	if ( ! isset($wp_query)) {
196
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
197 197
 		return false;
198 198
 	}
199 199
 
200
-	return $wp_query->is_attachment( $attachment );
200
+	return $wp_query->is_attachment($attachment);
201 201
 }
202 202
 
203 203
 /**
@@ -213,15 +213,15 @@  discard block
 block discarded – undo
213 213
  * @param mixed $author Optional. User ID, nickname, nicename, or array of User IDs, nicknames, and nicenames
214 214
  * @return bool
215 215
  */
216
-function is_author( $author = '' ) {
216
+function is_author($author = '') {
217 217
 	global $wp_query;
218 218
 
219
-	if ( ! isset( $wp_query ) ) {
220
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
219
+	if ( ! isset($wp_query)) {
220
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
221 221
 		return false;
222 222
 	}
223 223
 
224
-	return $wp_query->is_author( $author );
224
+	return $wp_query->is_author($author);
225 225
 }
226 226
 
227 227
 /**
@@ -237,15 +237,15 @@  discard block
 block discarded – undo
237 237
  * @param mixed $category Optional. Category ID, name, slug, or array of Category IDs, names, and slugs.
238 238
  * @return bool
239 239
  */
240
-function is_category( $category = '' ) {
240
+function is_category($category = '') {
241 241
 	global $wp_query;
242 242
 
243
-	if ( ! isset( $wp_query ) ) {
244
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
243
+	if ( ! isset($wp_query)) {
244
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
245 245
 		return false;
246 246
 	}
247 247
 
248
-	return $wp_query->is_category( $category );
248
+	return $wp_query->is_category($category);
249 249
 }
250 250
 
251 251
 /**
@@ -261,15 +261,15 @@  discard block
 block discarded – undo
261 261
  * @param mixed $tag Optional. Tag ID, name, slug, or array of Tag IDs, names, and slugs.
262 262
  * @return bool
263 263
  */
264
-function is_tag( $tag = '' ) {
264
+function is_tag($tag = '') {
265 265
 	global $wp_query;
266 266
 
267
-	if ( ! isset( $wp_query ) ) {
268
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
267
+	if ( ! isset($wp_query)) {
268
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
269 269
 		return false;
270 270
 	}
271 271
 
272
-	return $wp_query->is_tag( $tag );
272
+	return $wp_query->is_tag($tag);
273 273
 }
274 274
 
275 275
 /**
@@ -290,15 +290,15 @@  discard block
 block discarded – undo
290 290
  * @param int|string|array $term     Optional. Term ID, name, slug or array of Term IDs, names, and slugs.
291 291
  * @return bool True for custom taxonomy archive pages, false for built-in taxonomies (category and tag archives).
292 292
  */
293
-function is_tax( $taxonomy = '', $term = '' ) {
293
+function is_tax($taxonomy = '', $term = '') {
294 294
 	global $wp_query;
295 295
 
296
-	if ( ! isset( $wp_query ) ) {
297
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
296
+	if ( ! isset($wp_query)) {
297
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
298 298
 		return false;
299 299
 	}
300 300
 
301
-	return $wp_query->is_tax( $taxonomy, $term );
301
+	return $wp_query->is_tax($taxonomy, $term);
302 302
 }
303 303
 
304 304
 /**
@@ -313,8 +313,8 @@  discard block
 block discarded – undo
313 313
 function is_date() {
314 314
 	global $wp_query;
315 315
 
316
-	if ( ! isset( $wp_query ) ) {
317
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
316
+	if ( ! isset($wp_query)) {
317
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
318 318
 		return false;
319 319
 	}
320 320
 
@@ -333,8 +333,8 @@  discard block
 block discarded – undo
333 333
 function is_day() {
334 334
 	global $wp_query;
335 335
 
336
-	if ( ! isset( $wp_query ) ) {
337
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
336
+	if ( ! isset($wp_query)) {
337
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
338 338
 		return false;
339 339
 	}
340 340
 
@@ -351,15 +351,15 @@  discard block
 block discarded – undo
351 351
  * @param string|array $feeds Optional feed types to check.
352 352
  * @return bool
353 353
  */
354
-function is_feed( $feeds = '' ) {
354
+function is_feed($feeds = '') {
355 355
 	global $wp_query;
356 356
 
357
-	if ( ! isset( $wp_query ) ) {
358
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
357
+	if ( ! isset($wp_query)) {
358
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
359 359
 		return false;
360 360
 	}
361 361
 
362
-	return $wp_query->is_feed( $feeds );
362
+	return $wp_query->is_feed($feeds);
363 363
 }
364 364
 
365 365
 /**
@@ -374,8 +374,8 @@  discard block
 block discarded – undo
374 374
 function is_comment_feed() {
375 375
 	global $wp_query;
376 376
 
377
-	if ( ! isset( $wp_query ) ) {
378
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
377
+	if ( ! isset($wp_query)) {
378
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
379 379
 		return false;
380 380
 	}
381 381
 
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
 function is_front_page() {
404 404
 	global $wp_query;
405 405
 
406
-	if ( ! isset( $wp_query ) ) {
407
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
406
+	if ( ! isset($wp_query)) {
407
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
408 408
 		return false;
409 409
 	}
410 410
 
@@ -432,8 +432,8 @@  discard block
 block discarded – undo
432 432
 function is_home() {
433 433
 	global $wp_query;
434 434
 
435
-	if ( ! isset( $wp_query ) ) {
436
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
435
+	if ( ! isset($wp_query)) {
436
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
437 437
 		return false;
438 438
 	}
439 439
 
@@ -452,8 +452,8 @@  discard block
 block discarded – undo
452 452
 function is_month() {
453 453
 	global $wp_query;
454 454
 
455
-	if ( ! isset( $wp_query ) ) {
456
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
455
+	if ( ! isset($wp_query)) {
456
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
457 457
 		return false;
458 458
 	}
459 459
 
@@ -476,15 +476,15 @@  discard block
 block discarded – undo
476 476
  * @param int|string|array $page Optional. Page ID, title, slug, or array of such. Default empty.
477 477
  * @return bool Whether the query is for an existing single page.
478 478
  */
479
-function is_page( $page = '' ) {
479
+function is_page($page = '') {
480 480
 	global $wp_query;
481 481
 
482
-	if ( ! isset( $wp_query ) ) {
483
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
482
+	if ( ! isset($wp_query)) {
483
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
484 484
 		return false;
485 485
 	}
486 486
 
487
-	return $wp_query->is_page( $page );
487
+	return $wp_query->is_page($page);
488 488
 }
489 489
 
490 490
 /**
@@ -499,8 +499,8 @@  discard block
 block discarded – undo
499 499
 function is_paged() {
500 500
 	global $wp_query;
501 501
 
502
-	if ( ! isset( $wp_query ) ) {
503
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
502
+	if ( ! isset($wp_query)) {
503
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
504 504
 		return false;
505 505
 	}
506 506
 
@@ -519,8 +519,8 @@  discard block
 block discarded – undo
519 519
 function is_preview() {
520 520
 	global $wp_query;
521 521
 
522
-	if ( ! isset( $wp_query ) ) {
523
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
522
+	if ( ! isset($wp_query)) {
523
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
524 524
 		return false;
525 525
 	}
526 526
 
@@ -539,8 +539,8 @@  discard block
 block discarded – undo
539 539
 function is_robots() {
540 540
 	global $wp_query;
541 541
 
542
-	if ( ! isset( $wp_query ) ) {
543
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
542
+	if ( ! isset($wp_query)) {
543
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
544 544
 		return false;
545 545
 	}
546 546
 
@@ -559,8 +559,8 @@  discard block
 block discarded – undo
559 559
 function is_search() {
560 560
 	global $wp_query;
561 561
 
562
-	if ( ! isset( $wp_query ) ) {
563
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
562
+	if ( ! isset($wp_query)) {
563
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
564 564
 		return false;
565 565
 	}
566 566
 
@@ -585,15 +585,15 @@  discard block
 block discarded – undo
585 585
  * @param int|string|array $post Optional. Post ID, title, slug, or array of such. Default empty.
586 586
  * @return bool Whether the query is for an existing single post.
587 587
  */
588
-function is_single( $post = '' ) {
588
+function is_single($post = '') {
589 589
 	global $wp_query;
590 590
 
591
-	if ( ! isset( $wp_query ) ) {
592
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
591
+	if ( ! isset($wp_query)) {
592
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
593 593
 		return false;
594 594
 	}
595 595
 
596
-	return $wp_query->is_single( $post );
596
+	return $wp_query->is_single($post);
597 597
 }
598 598
 
599 599
 /**
@@ -612,15 +612,15 @@  discard block
 block discarded – undo
612 612
  * @param string|array $post_types Optional. Post type or array of post types. Default empty.
613 613
  * @return bool Whether the query is for an existing single post of any of the given post types.
614 614
  */
615
-function is_singular( $post_types = '' ) {
615
+function is_singular($post_types = '') {
616 616
 	global $wp_query;
617 617
 
618
-	if ( ! isset( $wp_query ) ) {
619
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
618
+	if ( ! isset($wp_query)) {
619
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
620 620
 		return false;
621 621
 	}
622 622
 
623
-	return $wp_query->is_singular( $post_types );
623
+	return $wp_query->is_singular($post_types);
624 624
 }
625 625
 
626 626
 /**
@@ -635,8 +635,8 @@  discard block
 block discarded – undo
635 635
 function is_time() {
636 636
 	global $wp_query;
637 637
 
638
-	if ( ! isset( $wp_query ) ) {
639
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
638
+	if ( ! isset($wp_query)) {
639
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
640 640
 		return false;
641 641
 	}
642 642
 
@@ -655,8 +655,8 @@  discard block
 block discarded – undo
655 655
 function is_trackback() {
656 656
 	global $wp_query;
657 657
 
658
-	if ( ! isset( $wp_query ) ) {
659
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
658
+	if ( ! isset($wp_query)) {
659
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
660 660
 		return false;
661 661
 	}
662 662
 
@@ -675,8 +675,8 @@  discard block
 block discarded – undo
675 675
 function is_year() {
676 676
 	global $wp_query;
677 677
 
678
-	if ( ! isset( $wp_query ) ) {
679
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
678
+	if ( ! isset($wp_query)) {
679
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
680 680
 		return false;
681 681
 	}
682 682
 
@@ -695,8 +695,8 @@  discard block
 block discarded – undo
695 695
 function is_404() {
696 696
 	global $wp_query;
697 697
 
698
-	if ( ! isset( $wp_query ) ) {
699
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
698
+	if ( ! isset($wp_query)) {
699
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
700 700
 		return false;
701 701
 	}
702 702
 
@@ -715,8 +715,8 @@  discard block
 block discarded – undo
715 715
 function is_embed() {
716 716
 	global $wp_query;
717 717
 
718
-	if ( ! isset( $wp_query ) ) {
719
-		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
718
+	if ( ! isset($wp_query)) {
719
+		_doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0');
720 720
 		return false;
721 721
 	}
722 722
 
@@ -733,16 +733,16 @@  discard block
 block discarded – undo
733 733
  * @return bool
734 734
  */
735 735
 function is_main_query() {
736
-	if ( 'pre_get_posts' === current_filter() ) {
736
+	if ('pre_get_posts' === current_filter()) {
737 737
 		$message = sprintf(
738 738
 			/* translators: 1: pre_get_posts 2: WP_Query->is_main_query() 3: is_main_query() 4: link to codex is_main_query() page. */
739
-			__( 'In %1$s, use the %2$s method, not the %3$s function. See %4$s.' ),
739
+			__('In %1$s, use the %2$s method, not the %3$s function. See %4$s.'),
740 740
 			'<code>pre_get_posts</code>',
741 741
 			'<code>WP_Query->is_main_query()</code>',
742 742
 			'<code>is_main_query()</code>',
743
-			__( 'https://codex.wordpress.org/Function_Reference/is_main_query' )
743
+			__('https://codex.wordpress.org/Function_Reference/is_main_query')
744 744
 		);
745
-		_doing_it_wrong( __FUNCTION__, $message, '3.7.0' );
745
+		_doing_it_wrong(__FUNCTION__, $message, '3.7.0');
746 746
 	}
747 747
 
748 748
 	global $wp_query;
@@ -847,58 +847,58 @@  discard block
 block discarded – undo
847 847
  * @global wpdb $wpdb WordPress database abstraction object.
848 848
  */
849 849
 function wp_old_slug_redirect() {
850
-	if ( is_404() && '' !== get_query_var( 'name' ) ) {
850
+	if (is_404() && '' !== get_query_var('name')) {
851 851
 		global $wpdb;
852 852
 
853 853
 		// Guess the current post_type based on the query vars.
854
-		if ( get_query_var( 'post_type' ) ) {
855
-			$post_type = get_query_var( 'post_type' );
856
-		} elseif ( get_query_var( 'attachment' ) ) {
854
+		if (get_query_var('post_type')) {
855
+			$post_type = get_query_var('post_type');
856
+		} elseif (get_query_var('attachment')) {
857 857
 			$post_type = 'attachment';
858
-		} elseif ( get_query_var( 'pagename' ) ) {
858
+		} elseif (get_query_var('pagename')) {
859 859
 			$post_type = 'page';
860 860
 		} else {
861 861
 			$post_type = 'post';
862 862
 		}
863 863
 
864
-		if ( is_array( $post_type ) ) {
865
-			if ( count( $post_type ) > 1 ) {
864
+		if (is_array($post_type)) {
865
+			if (count($post_type) > 1) {
866 866
 				return;
867 867
 			}
868
-			$post_type = reset( $post_type );
868
+			$post_type = reset($post_type);
869 869
 		}
870 870
 
871 871
 		// Do not attempt redirect for hierarchical post types
872
-		if ( is_post_type_hierarchical( $post_type ) ) {
872
+		if (is_post_type_hierarchical($post_type)) {
873 873
 			return;
874 874
 		}
875 875
 
876
-		$query = $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta, $wpdb->posts WHERE ID = post_id AND post_type = %s AND meta_key = '_wp_old_slug' AND meta_value = %s", $post_type, get_query_var( 'name' ) );
876
+		$query = $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta, $wpdb->posts WHERE ID = post_id AND post_type = %s AND meta_key = '_wp_old_slug' AND meta_value = %s", $post_type, get_query_var('name'));
877 877
 
878 878
 		// if year, monthnum, or day have been specified, make our query more precise
879 879
 		// just in case there are multiple identical _wp_old_slug values
880
-		if ( get_query_var( 'year' ) ) {
881
-			$query .= $wpdb->prepare(" AND YEAR(post_date) = %d", get_query_var( 'year' ) );
880
+		if (get_query_var('year')) {
881
+			$query .= $wpdb->prepare(" AND YEAR(post_date) = %d", get_query_var('year'));
882 882
 		}
883
-		if ( get_query_var( 'monthnum' ) ) {
884
-			$query .= $wpdb->prepare(" AND MONTH(post_date) = %d", get_query_var( 'monthnum' ) );
883
+		if (get_query_var('monthnum')) {
884
+			$query .= $wpdb->prepare(" AND MONTH(post_date) = %d", get_query_var('monthnum'));
885 885
 		}
886
-		if ( get_query_var( 'day' ) ) {
887
-			$query .= $wpdb->prepare(" AND DAYOFMONTH(post_date) = %d", get_query_var( 'day' ) );
886
+		if (get_query_var('day')) {
887
+			$query .= $wpdb->prepare(" AND DAYOFMONTH(post_date) = %d", get_query_var('day'));
888 888
 		}
889 889
 
890
-		$id = (int) $wpdb->get_var( $query );
890
+		$id = (int) $wpdb->get_var($query);
891 891
 
892
-		if ( ! $id ) {
892
+		if ( ! $id) {
893 893
 			return;
894 894
 		}
895 895
 
896
-		$link = get_permalink( $id );
896
+		$link = get_permalink($id);
897 897
 
898
-		if ( get_query_var( 'paged' ) > 1 ) {
899
-			$link = user_trailingslashit( trailingslashit( $link ) . 'page/' . get_query_var( 'paged' ) );
900
-		} elseif( is_embed() ) {
901
-			$link = user_trailingslashit( trailingslashit( $link ) . 'embed' );
898
+		if (get_query_var('paged') > 1) {
899
+			$link = user_trailingslashit(trailingslashit($link).'page/'.get_query_var('paged'));
900
+		} elseif (is_embed()) {
901
+			$link = user_trailingslashit(trailingslashit($link).'embed');
902 902
 		}
903 903
 
904 904
 		/**
@@ -908,13 +908,13 @@  discard block
 block discarded – undo
908 908
 		 *
909 909
 		 * @param string $link The redirect URL.
910 910
 		 */
911
-		$link = apply_filters( 'old_slug_redirect_url', $link );
911
+		$link = apply_filters('old_slug_redirect_url', $link);
912 912
 
913
-		if ( ! $link ) {
913
+		if ( ! $link) {
914 914
 			return;
915 915
 		}
916 916
 
917
-		wp_redirect( $link, 301 ); // Permanent redirect
917
+		wp_redirect($link, 301); // Permanent redirect
918 918
 		exit;
919 919
 	}
920 920
 }
@@ -930,11 +930,11 @@  discard block
 block discarded – undo
930 930
  * @param WP_Post|object|int $post WP_Post instance or Post ID/object.
931 931
  * @return bool True when finished.
932 932
  */
933
-function setup_postdata( $post ) {
933
+function setup_postdata($post) {
934 934
 	global $wp_query;
935 935
 
936
-	if ( ! empty( $wp_query ) && $wp_query instanceof WP_Query ) {
937
-		return $wp_query->setup_postdata( $post );
936
+	if ( ! empty($wp_query) && $wp_query instanceof WP_Query) {
937
+		return $wp_query->setup_postdata($post);
938 938
 	}
939 939
 
940 940
 	return false;
Please login to merge, or discard this patch.
src/wp-includes/rest-api.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@
 block discarded – undo
78 78
  * @global array $wp_rest_additional_fields Holds registered fields, organized
79 79
  *                                          by object type.
80 80
  *
81
- * @param string|array $object_type Object(s) the field is being registered
81
+ * @param string $object_type Object(s) the field is being registered
82 82
  *                                  to, "post"|"term"|"comment" etc.
83 83
  * @param string $attribute         The attribute name.
84 84
  * @param array  $args {
Please login to merge, or discard this patch.
Spacing   +241 added lines, -241 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  *
13 13
  * @var string
14 14
  */
15
-define( 'REST_API_VERSION', '2.0' );
15
+define('REST_API_VERSION', '2.0');
16 16
 
17 17
 /**
18 18
  * Registers a REST API route.
@@ -29,26 +29,26 @@  discard block
 block discarded – undo
29 29
  *                          false merges (with newer overriding if duplicate keys exist). Default false.
30 30
  * @return bool True on success, false on error.
31 31
  */
32
-function register_rest_route( $namespace, $route, $args = array(), $override = false ) {
32
+function register_rest_route($namespace, $route, $args = array(), $override = false) {
33 33
 	/** @var WP_REST_Server $wp_rest_server */
34 34
 	global $wp_rest_server;
35 35
 
36
-	if ( empty( $namespace ) ) {
36
+	if (empty($namespace)) {
37 37
 		/*
38 38
 		 * Non-namespaced routes are not allowed, with the exception of the main
39 39
 		 * and namespace indexes. If you really need to register a
40 40
 		 * non-namespaced route, call `WP_REST_Server::register_route` directly.
41 41
 		 */
42
-		_doing_it_wrong( 'register_rest_route', __( 'Routes must be namespaced with plugin or theme name and version.' ), '4.4.0' );
42
+		_doing_it_wrong('register_rest_route', __('Routes must be namespaced with plugin or theme name and version.'), '4.4.0');
43 43
 		return false;
44
-	} else if ( empty( $route ) ) {
45
-		_doing_it_wrong( 'register_rest_route', __( 'Route must be specified.' ), '4.4.0' );
44
+	} else if (empty($route)) {
45
+		_doing_it_wrong('register_rest_route', __('Route must be specified.'), '4.4.0');
46 46
 		return false;
47 47
 	}
48 48
 
49
-	if ( isset( $args['callback'] ) ) {
49
+	if (isset($args['callback'])) {
50 50
 		// Upgrade a single set to multiple.
51
-		$args = array( $args );
51
+		$args = array($args);
52 52
 	}
53 53
 
54 54
 	$defaults = array(
@@ -56,17 +56,17 @@  discard block
 block discarded – undo
56 56
 		'callback'        => null,
57 57
 		'args'            => array(),
58 58
 	);
59
-	foreach ( $args as $key => &$arg_group ) {
60
-		if ( ! is_numeric( $arg_group ) ) {
59
+	foreach ($args as $key => &$arg_group) {
60
+		if ( ! is_numeric($arg_group)) {
61 61
 			// Route option, skip here.
62 62
 			continue;
63 63
 		}
64 64
 
65
-		$arg_group = array_merge( $defaults, $arg_group );
65
+		$arg_group = array_merge($defaults, $arg_group);
66 66
 	}
67 67
 
68
-	$full_route = '/' . trim( $namespace, '/' ) . '/' . trim( $route, '/' );
69
-	$wp_rest_server->register_route( $namespace, $full_route, $args, $override );
68
+	$full_route = '/'.trim($namespace, '/').'/'.trim($route, '/');
69
+	$wp_rest_server->register_route($namespace, $full_route, $args, $override);
70 70
 	return true;
71 71
 }
72 72
 
@@ -94,21 +94,21 @@  discard block
 block discarded – undo
94 94
  *                                              this field. Default is 'null', no schema entry will be returned.
95 95
  * }
96 96
  */
97
-function register_rest_field( $object_type, $attribute, $args = array() ) {
97
+function register_rest_field($object_type, $attribute, $args = array()) {
98 98
 	$defaults = array(
99 99
 		'get_callback'    => null,
100 100
 		'update_callback' => null,
101 101
 		'schema'          => null,
102 102
 	);
103 103
 
104
-	$args = wp_parse_args( $args, $defaults );
104
+	$args = wp_parse_args($args, $defaults);
105 105
 
106 106
 	global $wp_rest_additional_fields;
107 107
 
108 108
 	$object_types = (array) $object_type;
109 109
 
110
-	foreach ( $object_types as $object_type ) {
111
-		$wp_rest_additional_fields[ $object_type ][ $attribute ] = $args;
110
+	foreach ($object_types as $object_type) {
111
+		$wp_rest_additional_fields[$object_type][$attribute] = $args;
112 112
 	}
113 113
 }
114 114
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	rest_api_register_rewrites();
125 125
 
126 126
 	global $wp;
127
-	$wp->add_query_var( 'rest_route' );
127
+	$wp->add_query_var('rest_route');
128 128
 }
129 129
 
130 130
 /**
@@ -138,10 +138,10 @@  discard block
 block discarded – undo
138 138
 function rest_api_register_rewrites() {
139 139
 	global $wp_rewrite;
140 140
 
141
-	add_rewrite_rule( '^' . rest_get_url_prefix() . '/?$','index.php?rest_route=/','top' );
142
-	add_rewrite_rule( '^' . rest_get_url_prefix() . '/(.*)?','index.php?rest_route=/$matches[1]','top' );
143
-	add_rewrite_rule( '^' . $wp_rewrite->index . '/' . rest_get_url_prefix() . '/?$','index.php?rest_route=/','top' );
144
-	add_rewrite_rule( '^' . $wp_rewrite->index . '/' . rest_get_url_prefix() . '/(.*)?','index.php?rest_route=/$matches[1]','top' );
141
+	add_rewrite_rule('^'.rest_get_url_prefix().'/?$', 'index.php?rest_route=/', 'top');
142
+	add_rewrite_rule('^'.rest_get_url_prefix().'/(.*)?', 'index.php?rest_route=/$matches[1]', 'top');
143
+	add_rewrite_rule('^'.$wp_rewrite->index.'/'.rest_get_url_prefix().'/?$', 'index.php?rest_route=/', 'top');
144
+	add_rewrite_rule('^'.$wp_rewrite->index.'/'.rest_get_url_prefix().'/(.*)?', 'index.php?rest_route=/$matches[1]', 'top');
145 145
 }
146 146
 
147 147
 /**
@@ -154,16 +154,16 @@  discard block
 block discarded – undo
154 154
  */
155 155
 function rest_api_default_filters() {
156 156
 	// Deprecated reporting.
157
-	add_action( 'deprecated_function_run', 'rest_handle_deprecated_function', 10, 3 );
158
-	add_filter( 'deprecated_function_trigger_error', '__return_false' );
159
-	add_action( 'deprecated_argument_run', 'rest_handle_deprecated_argument', 10, 3 );
160
-	add_filter( 'deprecated_argument_trigger_error', '__return_false' );
157
+	add_action('deprecated_function_run', 'rest_handle_deprecated_function', 10, 3);
158
+	add_filter('deprecated_function_trigger_error', '__return_false');
159
+	add_action('deprecated_argument_run', 'rest_handle_deprecated_argument', 10, 3);
160
+	add_filter('deprecated_argument_trigger_error', '__return_false');
161 161
 
162 162
 	// Default serving.
163
-	add_filter( 'rest_pre_serve_request', 'rest_send_cors_headers' );
164
-	add_filter( 'rest_post_dispatch', 'rest_send_allow_header', 10, 3 );
163
+	add_filter('rest_pre_serve_request', 'rest_send_cors_headers');
164
+	add_filter('rest_post_dispatch', 'rest_send_allow_header', 10, 3);
165 165
 
166
-	add_filter( 'rest_pre_dispatch', 'rest_handle_options_request', 10, 3 );
166
+	add_filter('rest_pre_dispatch', 'rest_handle_options_request', 10, 3);
167 167
 }
168 168
 
169 169
 /**
@@ -172,21 +172,21 @@  discard block
 block discarded – undo
172 172
  * @since 4.7.0
173 173
  */
174 174
 function create_initial_rest_routes() {
175
-	foreach ( get_post_types( array( 'show_in_rest' => true ), 'objects' ) as $post_type ) {
176
-		$class = ! empty( $post_type->rest_controller_class ) ? $post_type->rest_controller_class : 'WP_REST_Posts_Controller';
175
+	foreach (get_post_types(array('show_in_rest' => true), 'objects') as $post_type) {
176
+		$class = ! empty($post_type->rest_controller_class) ? $post_type->rest_controller_class : 'WP_REST_Posts_Controller';
177 177
 
178
-		if ( ! class_exists( $class ) ) {
178
+		if ( ! class_exists($class)) {
179 179
 			continue;
180 180
 		}
181
-		$controller = new $class( $post_type->name );
182
-		if ( ! is_subclass_of( $controller, 'WP_REST_Controller' ) ) {
181
+		$controller = new $class($post_type->name);
182
+		if ( ! is_subclass_of($controller, 'WP_REST_Controller')) {
183 183
 			continue;
184 184
 		}
185 185
 
186 186
 		$controller->register_routes();
187 187
 
188
-		if ( post_type_supports( $post_type->name, 'revisions' ) ) {
189
-			$revisions_controller = new WP_REST_Revisions_Controller( $post_type->name );
188
+		if (post_type_supports($post_type->name, 'revisions')) {
189
+			$revisions_controller = new WP_REST_Revisions_Controller($post_type->name);
190 190
 			$revisions_controller->register_routes();
191 191
 		}
192 192
 	}
@@ -204,14 +204,14 @@  discard block
 block discarded – undo
204 204
 	$controller->register_routes();
205 205
 
206 206
 	// Terms.
207
-	foreach ( get_taxonomies( array( 'show_in_rest' => true ), 'object' ) as $taxonomy ) {
208
-		$class = ! empty( $taxonomy->rest_controller_class ) ? $taxonomy->rest_controller_class : 'WP_REST_Terms_Controller';
207
+	foreach (get_taxonomies(array('show_in_rest' => true), 'object') as $taxonomy) {
208
+		$class = ! empty($taxonomy->rest_controller_class) ? $taxonomy->rest_controller_class : 'WP_REST_Terms_Controller';
209 209
 
210
-		if ( ! class_exists( $class ) ) {
210
+		if ( ! class_exists($class)) {
211 211
 			continue;
212 212
 		}
213
-		$controller = new $class( $taxonomy->name );
214
-		if ( ! is_subclass_of( $controller, 'WP_REST_Controller' ) ) {
213
+		$controller = new $class($taxonomy->name);
214
+		if ( ! is_subclass_of($controller, 'WP_REST_Controller')) {
215 215
 			continue;
216 216
 		}
217 217
 
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
  * @global WP_REST_Server $wp_rest_server ResponseHandler instance (usually WP_REST_Server).
241 241
  */
242 242
 function rest_api_loaded() {
243
-	if ( empty( $GLOBALS['wp']->query_vars['rest_route'] ) ) {
243
+	if (empty($GLOBALS['wp']->query_vars['rest_route'])) {
244 244
 		return;
245 245
 	}
246 246
 
@@ -250,13 +250,13 @@  discard block
 block discarded – undo
250 250
 	 * @since 4.4.0
251 251
 	 * @var bool
252 252
 	 */
253
-	define( 'REST_REQUEST', true );
253
+	define('REST_REQUEST', true);
254 254
 
255 255
 	// Initialize the server.
256 256
 	$server = rest_get_server();
257 257
 
258 258
 	// Fire off the request.
259
-	$server->serve_request( untrailingslashit( $GLOBALS['wp']->query_vars['rest_route'] ) );
259
+	$server->serve_request(untrailingslashit($GLOBALS['wp']->query_vars['rest_route']));
260 260
 
261 261
 	// We're done.
262 262
 	die();
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 	 *
278 278
 	 * @param string $prefix URL prefix. Default 'wp-json'.
279 279
 	 */
280
-	return apply_filters( 'rest_url_prefix', 'wp-json' );
280
+	return apply_filters('rest_url_prefix', 'wp-json');
281 281
 }
282 282
 
283 283
 /**
@@ -295,33 +295,33 @@  discard block
 block discarded – undo
295 295
  * @param string $scheme  Optional. Sanitization scheme. Default 'rest'.
296 296
  * @return string Full URL to the endpoint.
297 297
  */
298
-function get_rest_url( $blog_id = null, $path = '/', $scheme = 'rest' ) {
299
-	if ( empty( $path ) ) {
298
+function get_rest_url($blog_id = null, $path = '/', $scheme = 'rest') {
299
+	if (empty($path)) {
300 300
 		$path = '/';
301 301
 	}
302 302
 
303
-	if ( is_multisite() && get_blog_option( $blog_id, 'permalink_structure' ) || get_option( 'permalink_structure' ) ) {
303
+	if (is_multisite() && get_blog_option($blog_id, 'permalink_structure') || get_option('permalink_structure')) {
304 304
 		global $wp_rewrite;
305 305
 
306
-		if ( $wp_rewrite->using_index_permalinks() ) {
307
-			$url = get_home_url( $blog_id, $wp_rewrite->index . '/' . rest_get_url_prefix(), $scheme );
306
+		if ($wp_rewrite->using_index_permalinks()) {
307
+			$url = get_home_url($blog_id, $wp_rewrite->index.'/'.rest_get_url_prefix(), $scheme);
308 308
 		} else {
309
-			$url = get_home_url( $blog_id, rest_get_url_prefix(), $scheme );
309
+			$url = get_home_url($blog_id, rest_get_url_prefix(), $scheme);
310 310
 		}
311 311
 
312
-		$url .= '/' . ltrim( $path, '/' );
312
+		$url .= '/'.ltrim($path, '/');
313 313
 	} else {
314
-		$url = trailingslashit( get_home_url( $blog_id, '', $scheme ) );
314
+		$url = trailingslashit(get_home_url($blog_id, '', $scheme));
315 315
 
316
-		$path = '/' . ltrim( $path, '/' );
316
+		$path = '/'.ltrim($path, '/');
317 317
 
318
-		$url = add_query_arg( 'rest_route', $path, $url );
318
+		$url = add_query_arg('rest_route', $path, $url);
319 319
 	}
320 320
 
321
-	if ( is_ssl() ) {
321
+	if (is_ssl()) {
322 322
 		// If the current host is the same as the REST URL host, force the REST URL scheme to HTTPS.
323
-		if ( $_SERVER['SERVER_NAME'] === parse_url( get_home_url( $blog_id ), PHP_URL_HOST ) ) {
324
-			$url = set_url_scheme( $url, 'https' );
323
+		if ($_SERVER['SERVER_NAME'] === parse_url(get_home_url($blog_id), PHP_URL_HOST)) {
324
+			$url = set_url_scheme($url, 'https');
325 325
 		}
326 326
 	}
327 327
 
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 	 * @param int    $blog_id Blog ID.
338 338
 	 * @param string $scheme  Sanitization scheme.
339 339
 	 */
340
-	return apply_filters( 'rest_url', $url, $path, $blog_id, $scheme );
340
+	return apply_filters('rest_url', $url, $path, $blog_id, $scheme);
341 341
 }
342 342
 
343 343
 /**
@@ -351,8 +351,8 @@  discard block
 block discarded – undo
351 351
  * @param string $scheme Optional. Sanitization scheme. Default 'json'.
352 352
  * @return string Full URL to the endpoint.
353 353
  */
354
-function rest_url( $path = '', $scheme = 'json' ) {
355
-	return get_rest_url( null, $path, $scheme );
354
+function rest_url($path = '', $scheme = 'json') {
355
+	return get_rest_url(null, $path, $scheme);
356 356
 }
357 357
 
358 358
 /**
@@ -367,9 +367,9 @@  discard block
 block discarded – undo
367 367
  * @param WP_REST_Request|string $request Request.
368 368
  * @return WP_REST_Response REST response.
369 369
  */
370
-function rest_do_request( $request ) {
371
-	$request = rest_ensure_request( $request );
372
-	return rest_get_server()->dispatch( $request );
370
+function rest_do_request($request) {
371
+	$request = rest_ensure_request($request);
372
+	return rest_get_server()->dispatch($request);
373 373
 }
374 374
 
375 375
 /**
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 	/* @var WP_REST_Server $wp_rest_server */
388 388
 	global $wp_rest_server;
389 389
 
390
-	if ( empty( $wp_rest_server ) ) {
390
+	if (empty($wp_rest_server)) {
391 391
 		/**
392 392
 		 * Filters the REST Server Class.
393 393
 		 *
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 		 *
399 399
 		 * @param string $class_name The name of the server class. Default 'WP_REST_Server'.
400 400
 		 */
401
-		$wp_rest_server_class = apply_filters( 'wp_rest_server_class', 'WP_REST_Server' );
401
+		$wp_rest_server_class = apply_filters('wp_rest_server_class', 'WP_REST_Server');
402 402
 		$wp_rest_server = new $wp_rest_server_class;
403 403
 
404 404
 		/**
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 		 *
412 412
 		 * @param WP_REST_Server $wp_rest_server Server object.
413 413
 		 */
414
-		do_action( 'rest_api_init', $wp_rest_server );
414
+		do_action('rest_api_init', $wp_rest_server);
415 415
 	}
416 416
 
417 417
 	return $wp_rest_server;
@@ -425,12 +425,12 @@  discard block
 block discarded – undo
425 425
  * @param array|WP_REST_Request $request Request to check.
426 426
  * @return WP_REST_Request REST request instance.
427 427
  */
428
-function rest_ensure_request( $request ) {
429
-	if ( $request instanceof WP_REST_Request ) {
428
+function rest_ensure_request($request) {
429
+	if ($request instanceof WP_REST_Request) {
430 430
 		return $request;
431 431
 	}
432 432
 
433
-	return new WP_REST_Request( 'GET', '', $request );
433
+	return new WP_REST_Request('GET', '', $request);
434 434
 }
435 435
 
436 436
 /**
@@ -447,16 +447,16 @@  discard block
 block discarded – undo
447 447
  *                                is already an instance, WP_HTTP_Response, otherwise
448 448
  *                                returns a new WP_REST_Response instance.
449 449
  */
450
-function rest_ensure_response( $response ) {
451
-	if ( is_wp_error( $response ) ) {
450
+function rest_ensure_response($response) {
451
+	if (is_wp_error($response)) {
452 452
 		return $response;
453 453
 	}
454 454
 
455
-	if ( $response instanceof WP_HTTP_Response ) {
455
+	if ($response instanceof WP_HTTP_Response) {
456 456
 		return $response;
457 457
 	}
458 458
 
459
-	return new WP_REST_Response( $response );
459
+	return new WP_REST_Response($response);
460 460
 }
461 461
 
462 462
 /**
@@ -468,16 +468,16 @@  discard block
 block discarded – undo
468 468
  * @param string $replacement The function that should have been called.
469 469
  * @param string $version     Version.
470 470
  */
471
-function rest_handle_deprecated_function( $function, $replacement, $version ) {
472
-	if ( ! empty( $replacement ) ) {
471
+function rest_handle_deprecated_function($function, $replacement, $version) {
472
+	if ( ! empty($replacement)) {
473 473
 		/* translators: 1: function name, 2: WordPress version number, 3: new function name */
474
-		$string = sprintf( __( '%1$s (since %2$s; use %3$s instead)' ), $function, $version, $replacement );
474
+		$string = sprintf(__('%1$s (since %2$s; use %3$s instead)'), $function, $version, $replacement);
475 475
 	} else {
476 476
 		/* translators: 1: function name, 2: WordPress version number */
477
-		$string = sprintf( __( '%1$s (since %2$s; no alternative available)' ), $function, $version );
477
+		$string = sprintf(__('%1$s (since %2$s; no alternative available)'), $function, $version);
478 478
 	}
479 479
 
480
-	header( sprintf( 'X-WP-DeprecatedFunction: %s', $string ) );
480
+	header(sprintf('X-WP-DeprecatedFunction: %s', $string));
481 481
 }
482 482
 
483 483
 /**
@@ -489,16 +489,16 @@  discard block
 block discarded – undo
489 489
  * @param string $message     A message regarding the change.
490 490
  * @param string $version     Version.
491 491
  */
492
-function rest_handle_deprecated_argument( $function, $message, $version ) {
493
-	if ( ! empty( $message ) ) {
492
+function rest_handle_deprecated_argument($function, $message, $version) {
493
+	if ( ! empty($message)) {
494 494
 		/* translators: 1: function name, 2: WordPress version number, 3: error message */
495
-		$string = sprintf( __( '%1$s (since %2$s; %3$s)' ), $function, $version, $message );
495
+		$string = sprintf(__('%1$s (since %2$s; %3$s)'), $function, $version, $message);
496 496
 	} else {
497 497
 		/* translators: 1: function name, 2: WordPress version number */
498
-		$string = sprintf( __( '%1$s (since %2$s; no alternative available)' ), $function, $version );
498
+		$string = sprintf(__('%1$s (since %2$s; no alternative available)'), $function, $version);
499 499
 	}
500 500
 
501
-	header( sprintf( 'X-WP-DeprecatedParam: %s', $string ) );
501
+	header(sprintf('X-WP-DeprecatedParam: %s', $string));
502 502
 }
503 503
 
504 504
 /**
@@ -509,14 +509,14 @@  discard block
 block discarded – undo
509 509
  * @param mixed $value Response data.
510 510
  * @return mixed Response data.
511 511
  */
512
-function rest_send_cors_headers( $value ) {
512
+function rest_send_cors_headers($value) {
513 513
 	$origin = get_http_origin();
514 514
 
515
-	if ( $origin ) {
516
-		header( 'Access-Control-Allow-Origin: ' . esc_url_raw( $origin ) );
517
-		header( 'Access-Control-Allow-Methods: OPTIONS, GET, POST, PUT, PATCH, DELETE' );
518
-		header( 'Access-Control-Allow-Credentials: true' );
519
-		header( 'Vary: Origin' );
515
+	if ($origin) {
516
+		header('Access-Control-Allow-Origin: '.esc_url_raw($origin));
517
+		header('Access-Control-Allow-Methods: OPTIONS, GET, POST, PUT, PATCH, DELETE');
518
+		header('Access-Control-Allow-Credentials: true');
519
+		header('Vary: Origin');
520 520
 	}
521 521
 
522 522
 	return $value;
@@ -535,27 +535,27 @@  discard block
 block discarded – undo
535 535
  * @param WP_REST_Request $request  The request that was used to make current response.
536 536
  * @return WP_REST_Response Modified response, either response or `null` to indicate pass-through.
537 537
  */
538
-function rest_handle_options_request( $response, $handler, $request ) {
539
-	if ( ! empty( $response ) || $request->get_method() !== 'OPTIONS' ) {
538
+function rest_handle_options_request($response, $handler, $request) {
539
+	if ( ! empty($response) || $request->get_method() !== 'OPTIONS') {
540 540
 		return $response;
541 541
 	}
542 542
 
543 543
 	$response = new WP_REST_Response();
544 544
 	$data = array();
545 545
 
546
-	foreach ( $handler->get_routes() as $route => $endpoints ) {
547
-		$match = preg_match( '@^' . $route . '$@i', $request->get_route() );
546
+	foreach ($handler->get_routes() as $route => $endpoints) {
547
+		$match = preg_match('@^'.$route.'$@i', $request->get_route());
548 548
 
549
-		if ( ! $match ) {
549
+		if ( ! $match) {
550 550
 			continue;
551 551
 		}
552 552
 
553
-		$data = $handler->get_data_for_route( $route, $endpoints, 'help' );
554
-		$response->set_matched_route( $route );
553
+		$data = $handler->get_data_for_route($route, $endpoints, 'help');
554
+		$response->set_matched_route($route);
555 555
 		break;
556 556
 	}
557 557
 
558
-	$response->set_data( $data );
558
+	$response->set_data($data);
559 559
 	return $response;
560 560
 }
561 561
 
@@ -569,10 +569,10 @@  discard block
 block discarded – undo
569 569
  * @param WP_REST_Request  $request  The request that was used to make current response.
570 570
  * @return WP_REST_Response Response to be served, with "Allow" header if route has allowed methods.
571 571
  */
572
-function rest_send_allow_header( $response, $server, $request ) {
572
+function rest_send_allow_header($response, $server, $request) {
573 573
 	$matched_route = $response->get_matched_route();
574 574
 
575
-	if ( ! $matched_route ) {
575
+	if ( ! $matched_route) {
576 576
 		return $response;
577 577
 	}
578 578
 
@@ -581,25 +581,25 @@  discard block
 block discarded – undo
581 581
 	$allowed_methods = array();
582 582
 
583 583
 	// Get the allowed methods across the routes.
584
-	foreach ( $routes[ $matched_route ] as $_handler ) {
585
-		foreach ( $_handler['methods'] as $handler_method => $value ) {
584
+	foreach ($routes[$matched_route] as $_handler) {
585
+		foreach ($_handler['methods'] as $handler_method => $value) {
586 586
 
587
-			if ( ! empty( $_handler['permission_callback'] ) ) {
587
+			if ( ! empty($_handler['permission_callback'])) {
588 588
 
589
-				$permission = call_user_func( $_handler['permission_callback'], $request );
589
+				$permission = call_user_func($_handler['permission_callback'], $request);
590 590
 
591
-				$allowed_methods[ $handler_method ] = true === $permission;
591
+				$allowed_methods[$handler_method] = true === $permission;
592 592
 			} else {
593
-				$allowed_methods[ $handler_method ] = true;
593
+				$allowed_methods[$handler_method] = true;
594 594
 			}
595 595
 		}
596 596
 	}
597 597
 
598 598
 	// Strip out all the methods that are not allowed (false values).
599
-	$allowed_methods = array_filter( $allowed_methods );
599
+	$allowed_methods = array_filter($allowed_methods);
600 600
 
601
-	if ( $allowed_methods ) {
602
-		$response->header( 'Allow', implode( ', ', array_map( 'strtoupper', array_keys( $allowed_methods ) ) ) );
601
+	if ($allowed_methods) {
602
+		$response->header('Allow', implode(', ', array_map('strtoupper', array_keys($allowed_methods))));
603 603
 	}
604 604
 
605 605
 	return $response;
@@ -615,11 +615,11 @@  discard block
 block discarded – undo
615 615
 function rest_output_rsd() {
616 616
 	$api_root = get_rest_url();
617 617
 
618
-	if ( empty( $api_root ) ) {
618
+	if (empty($api_root)) {
619 619
 		return;
620 620
 	}
621 621
 	?>
622
-	<api name="WP-API" blogID="1" preferred="false" apiLink="<?php echo esc_url( $api_root ); ?>" />
622
+	<api name="WP-API" blogID="1" preferred="false" apiLink="<?php echo esc_url($api_root); ?>" />
623 623
 	<?php
624 624
 }
625 625
 
@@ -633,11 +633,11 @@  discard block
 block discarded – undo
633 633
 function rest_output_link_wp_head() {
634 634
 	$api_root = get_rest_url();
635 635
 
636
-	if ( empty( $api_root ) ) {
636
+	if (empty($api_root)) {
637 637
 		return;
638 638
 	}
639 639
 
640
-	echo "<link rel='https://api.w.org/' href='" . esc_url( $api_root ) . "' />\n";
640
+	echo "<link rel='https://api.w.org/' href='".esc_url($api_root)."' />\n";
641 641
 }
642 642
 
643 643
 /**
@@ -646,17 +646,17 @@  discard block
 block discarded – undo
646 646
  * @since 4.4.0
647 647
  */
648 648
 function rest_output_link_header() {
649
-	if ( headers_sent() ) {
649
+	if (headers_sent()) {
650 650
 		return;
651 651
 	}
652 652
 
653 653
 	$api_root = get_rest_url();
654 654
 
655
-	if ( empty( $api_root ) ) {
655
+	if (empty($api_root)) {
656 656
 		return;
657 657
 	}
658 658
 
659
-	header( 'Link: <' . esc_url_raw( $api_root ) . '>; rel="https://api.w.org/"', false );
659
+	header('Link: <'.esc_url_raw($api_root).'>; rel="https://api.w.org/"', false);
660 660
 }
661 661
 
662 662
 /**
@@ -676,8 +676,8 @@  discard block
 block discarded – undo
676 676
  *                               if not.
677 677
  * @return WP_Error|mixed|bool WP_Error if the cookie is invalid, the $result, otherwise true.
678 678
  */
679
-function rest_cookie_check_errors( $result ) {
680
-	if ( ! empty( $result ) ) {
679
+function rest_cookie_check_errors($result) {
680
+	if ( ! empty($result)) {
681 681
 		return $result;
682 682
 	}
683 683
 
@@ -688,34 +688,34 @@  discard block
 block discarded – undo
688 688
 	 * error, but we're still logged in, another authentication
689 689
 	 * must have been used).
690 690
 	 */
691
-	if ( true !== $wp_rest_auth_cookie && is_user_logged_in() ) {
691
+	if (true !== $wp_rest_auth_cookie && is_user_logged_in()) {
692 692
 		return $result;
693 693
 	}
694 694
 
695 695
 	// Determine if there is a nonce.
696 696
 	$nonce = null;
697 697
 
698
-	if ( isset( $_REQUEST['_wpnonce'] ) ) {
698
+	if (isset($_REQUEST['_wpnonce'])) {
699 699
 		$nonce = $_REQUEST['_wpnonce'];
700
-	} elseif ( isset( $_SERVER['HTTP_X_WP_NONCE'] ) ) {
700
+	} elseif (isset($_SERVER['HTTP_X_WP_NONCE'])) {
701 701
 		$nonce = $_SERVER['HTTP_X_WP_NONCE'];
702 702
 	}
703 703
 
704
-	if ( null === $nonce ) {
704
+	if (null === $nonce) {
705 705
 		// No nonce at all, so act as if it's an unauthenticated request.
706
-		wp_set_current_user( 0 );
706
+		wp_set_current_user(0);
707 707
 		return true;
708 708
 	}
709 709
 
710 710
 	// Check the nonce.
711
-	$result = wp_verify_nonce( $nonce, 'wp_rest' );
711
+	$result = wp_verify_nonce($nonce, 'wp_rest');
712 712
 
713
-	if ( ! $result ) {
714
-		return new WP_Error( 'rest_cookie_invalid_nonce', __( 'Cookie nonce is invalid' ), array( 'status' => 403 ) );
713
+	if ( ! $result) {
714
+		return new WP_Error('rest_cookie_invalid_nonce', __('Cookie nonce is invalid'), array('status' => 403));
715 715
 	}
716 716
 
717 717
 	// Send a refreshed nonce in header.
718
-	$wp_rest_server->send_header( 'X-WP-Nonce', wp_create_nonce( 'wp_rest' ) );
718
+	$wp_rest_server->send_header('X-WP-Nonce', wp_create_nonce('wp_rest'));
719 719
 
720 720
 	return true;
721 721
 }
@@ -735,8 +735,8 @@  discard block
 block discarded – undo
735 735
 
736 736
 	$status_type = current_action();
737 737
 
738
-	if ( 'auth_cookie_valid' !== $status_type ) {
739
-		$wp_rest_auth_cookie = substr( $status_type, 12 );
738
+	if ('auth_cookie_valid' !== $status_type) {
739
+		$wp_rest_auth_cookie = substr($status_type, 12);
740 740
 		return;
741 741
 	}
742 742
 
@@ -753,18 +753,18 @@  discard block
 block discarded – undo
753 753
  *                          the timestamp's timezone. Default false.
754 754
  * @return int Unix timestamp.
755 755
  */
756
-function rest_parse_date( $date, $force_utc = false ) {
757
-	if ( $force_utc ) {
758
-		$date = preg_replace( '/[+-]\d+:?\d+$/', '+00:00', $date );
756
+function rest_parse_date($date, $force_utc = false) {
757
+	if ($force_utc) {
758
+		$date = preg_replace('/[+-]\d+:?\d+$/', '+00:00', $date);
759 759
 	}
760 760
 
761 761
 	$regex = '#^\d{4}-\d{2}-\d{2}[Tt ]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}(?::\d{2})?)?$#';
762 762
 
763
-	if ( ! preg_match( $regex, $date, $matches ) ) {
763
+	if ( ! preg_match($regex, $date, $matches)) {
764 764
 		return false;
765 765
 	}
766 766
 
767
-	return strtotime( $date );
767
+	return strtotime($date);
768 768
 }
769 769
 
770 770
 /**
@@ -779,17 +779,17 @@  discard block
 block discarded – undo
779 779
  * @return array|null Local and UTC datetime strings, in MySQL datetime format (Y-m-d H:i:s),
780 780
  *                    null on failure.
781 781
  */
782
-function rest_get_date_with_gmt( $date, $force_utc = false ) {
783
-	$date = rest_parse_date( $date, $force_utc );
782
+function rest_get_date_with_gmt($date, $force_utc = false) {
783
+	$date = rest_parse_date($date, $force_utc);
784 784
 
785
-	if ( empty( $date ) ) {
785
+	if (empty($date)) {
786 786
 		return null;
787 787
 	}
788 788
 
789
-	$utc = date( 'Y-m-d H:i:s', $date );
790
-	$local = get_date_from_gmt( $utc );
789
+	$utc = date('Y-m-d H:i:s', $date);
790
+	$local = get_date_from_gmt($utc);
791 791
 
792
-	return array( $local, $utc );
792
+	return array($local, $utc);
793 793
 }
794 794
 
795 795
 /**
@@ -813,14 +813,14 @@  discard block
 block discarded – undo
813 813
  * @param  string           $param
814 814
  * @return WP_Error|boolean
815 815
  */
816
-function rest_validate_request_arg( $value, $request, $param ) {
816
+function rest_validate_request_arg($value, $request, $param) {
817 817
 	$attributes = $request->get_attributes();
818
-	if ( ! isset( $attributes['args'][ $param ] ) || ! is_array( $attributes['args'][ $param ] ) ) {
818
+	if ( ! isset($attributes['args'][$param]) || ! is_array($attributes['args'][$param])) {
819 819
 		return true;
820 820
 	}
821
-	$args = $attributes['args'][ $param ];
821
+	$args = $attributes['args'][$param];
822 822
 
823
-	return rest_validate_value_from_schema( $value, $args, $param );
823
+	return rest_validate_value_from_schema($value, $args, $param);
824 824
 }
825 825
 
826 826
 /**
@@ -833,14 +833,14 @@  discard block
 block discarded – undo
833 833
  * @param  string           $param
834 834
  * @return mixed
835 835
  */
836
-function rest_sanitize_request_arg( $value, $request, $param ) {
836
+function rest_sanitize_request_arg($value, $request, $param) {
837 837
 	$attributes = $request->get_attributes();
838
-	if ( ! isset( $attributes['args'][ $param ] ) || ! is_array( $attributes['args'][ $param ] ) ) {
838
+	if ( ! isset($attributes['args'][$param]) || ! is_array($attributes['args'][$param])) {
839 839
 		return $value;
840 840
 	}
841
-	$args = $attributes['args'][ $param ];
841
+	$args = $attributes['args'][$param];
842 842
 
843
-	return rest_sanitize_value_from_schema( $value, $args );
843
+	return rest_sanitize_value_from_schema($value, $args);
844 844
 }
845 845
 
846 846
 /**
@@ -856,14 +856,14 @@  discard block
 block discarded – undo
856 856
  * @param  string           $param
857 857
  * @return mixed
858 858
  */
859
-function rest_parse_request_arg( $value, $request, $param ) {
860
-	$is_valid = rest_validate_request_arg( $value, $request, $param );
859
+function rest_parse_request_arg($value, $request, $param) {
860
+	$is_valid = rest_validate_request_arg($value, $request, $param);
861 861
 
862
-	if ( is_wp_error( $is_valid ) ) {
862
+	if (is_wp_error($is_valid)) {
863 863
 		return $is_valid;
864 864
 	}
865 865
 
866
-	$value = rest_sanitize_request_arg( $value, $request, $param );
866
+	$value = rest_sanitize_request_arg($value, $request, $param);
867 867
 
868 868
 	return $value;
869 869
 }
@@ -878,10 +878,10 @@  discard block
 block discarded – undo
878 878
  * @param  string $ip IP address.
879 879
  * @return string|false The valid IP address, otherwise false.
880 880
  */
881
-function rest_is_ip_address( $ip ) {
881
+function rest_is_ip_address($ip) {
882 882
 	$ipv4_pattern = '/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/';
883 883
 
884
-	if ( ! preg_match( $ipv4_pattern, $ip ) && ! Requests_IPv6::check_ipv6( $ip ) ) {
884
+	if ( ! preg_match($ipv4_pattern, $ip) && ! Requests_IPv6::check_ipv6($ip)) {
885 885
 		return false;
886 886
 	}
887 887
 
@@ -896,11 +896,11 @@  discard block
 block discarded – undo
896 896
  * @param bool|string|int $value The value being evaluated.
897 897
  * @return boolean Returns the proper associated boolean value.
898 898
  */
899
-function rest_sanitize_boolean( $value ) {
899
+function rest_sanitize_boolean($value) {
900 900
 	// String values are translated to `true`; make sure 'false' is false.
901
-	if ( is_string( $value )  ) {
902
-		$value = strtolower( $value );
903
-		if ( in_array( $value, array( 'false', '0' ), true ) ) {
901
+	if (is_string($value)) {
902
+		$value = strtolower($value);
903
+		if (in_array($value, array('false', '0'), true)) {
904 904
 			$value = false;
905 905
 		}
906 906
 	}
@@ -917,13 +917,13 @@  discard block
 block discarded – undo
917 917
  * @param bool|string $maybe_bool The value being evaluated.
918 918
  * @return boolean True if a boolean, otherwise false.
919 919
  */
920
-function rest_is_boolean( $maybe_bool ) {
921
-	if ( is_bool( $maybe_bool ) ) {
920
+function rest_is_boolean($maybe_bool) {
921
+	if (is_bool($maybe_bool)) {
922 922
 		return true;
923 923
 	}
924 924
 
925
-	if ( is_string( $maybe_bool ) ) {
926
-		$maybe_bool = strtolower( $maybe_bool );
925
+	if (is_string($maybe_bool)) {
926
+		$maybe_bool = strtolower($maybe_bool);
927 927
 
928 928
 		$valid_boolean_values = array(
929 929
 			'false',
@@ -932,11 +932,11 @@  discard block
 block discarded – undo
932 932
 			'1',
933 933
 		);
934 934
 
935
-		return in_array( $maybe_bool, $valid_boolean_values, true );
935
+		return in_array($maybe_bool, $valid_boolean_values, true);
936 936
 	}
937 937
 
938
-	if ( is_int( $maybe_bool ) ) {
939
-		return in_array( $maybe_bool, array( 0, 1 ), true );
938
+	if (is_int($maybe_bool)) {
939
+		return in_array($maybe_bool, array(0, 1), true);
940 940
 	}
941 941
 
942 942
 	return false;
@@ -952,12 +952,12 @@  discard block
 block discarded – undo
952 952
  * @param string $email Email address.
953 953
  * @return array $urls Gravatar url for each size.
954 954
  */
955
-function rest_get_avatar_urls( $email ) {
955
+function rest_get_avatar_urls($email) {
956 956
 	$avatar_sizes = rest_get_avatar_sizes();
957 957
 
958 958
 	$urls = array();
959
-	foreach ( $avatar_sizes as $size ) {
960
-		$urls[ $size ] = get_avatar_url( $email, array( 'size' => $size ) );
959
+	foreach ($avatar_sizes as $size) {
960
+		$urls[$size] = get_avatar_url($email, array('size' => $size));
961 961
 	}
962 962
 
963 963
 	return $urls;
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
 	 * @param array $sizes An array of int values that are the pixel sizes for avatars.
983 983
 	 *                     Default `[ 24, 48, 96 ]`.
984 984
 	 */
985
-	return apply_filters( 'rest_avatar_sizes', array( 24, 48, 96 ) );
985
+	return apply_filters('rest_avatar_sizes', array(24, 48, 96));
986 986
 }
987 987
 
988 988
 /**
@@ -995,54 +995,54 @@  discard block
 block discarded – undo
995 995
  * @param string $param The parameter name, used in error messages.
996 996
  * @return true|WP_Error
997 997
  */
998
-function rest_validate_value_from_schema( $value, $args, $param = '' ) {
999
-	if ( 'array' === $args['type'] ) {
1000
-		if ( ! is_array( $value ) ) {
1001
-			$value = preg_split( '/[\s,]+/', $value );
998
+function rest_validate_value_from_schema($value, $args, $param = '') {
999
+	if ('array' === $args['type']) {
1000
+		if ( ! is_array($value)) {
1001
+			$value = preg_split('/[\s,]+/', $value);
1002 1002
 		}
1003
-		if ( ! wp_is_numeric_array( $value ) ) {
1003
+		if ( ! wp_is_numeric_array($value)) {
1004 1004
 			/* translators: 1: parameter, 2: type name */
1005
-			return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s is not of type %2$s.' ), $param, 'array' ) );
1005
+			return new WP_Error('rest_invalid_param', sprintf(__('%1$s is not of type %2$s.'), $param, 'array'));
1006 1006
 		}
1007
-		foreach ( $value as $index => $v ) {
1008
-			$is_valid = rest_validate_value_from_schema( $v, $args['items'], $param . '[' . $index . ']' );
1009
-			if ( is_wp_error( $is_valid ) ) {
1007
+		foreach ($value as $index => $v) {
1008
+			$is_valid = rest_validate_value_from_schema($v, $args['items'], $param.'['.$index.']');
1009
+			if (is_wp_error($is_valid)) {
1010 1010
 				return $is_valid;
1011 1011
 			}
1012 1012
 		}
1013 1013
 	}
1014
-	if ( ! empty( $args['enum'] ) ) {
1015
-		if ( ! in_array( $value, $args['enum'], true ) ) {
1014
+	if ( ! empty($args['enum'])) {
1015
+		if ( ! in_array($value, $args['enum'], true)) {
1016 1016
 			/* translators: 1: parameter, 2: list of valid values */
1017
-			return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s is not one of %2$s.' ), $param, implode( ', ', $args['enum'] ) ) );
1017
+			return new WP_Error('rest_invalid_param', sprintf(__('%1$s is not one of %2$s.'), $param, implode(', ', $args['enum'])));
1018 1018
 		}
1019 1019
 	}
1020 1020
 
1021
-	if ( in_array( $args['type'], array( 'integer', 'number' ) ) && ! is_numeric( $value ) ) {
1021
+	if (in_array($args['type'], array('integer', 'number')) && ! is_numeric($value)) {
1022 1022
 		/* translators: 1: parameter, 2: type name */
1023
-		return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s is not of type %2$s.' ), $param, $args['type'] ) );
1023
+		return new WP_Error('rest_invalid_param', sprintf(__('%1$s is not of type %2$s.'), $param, $args['type']));
1024 1024
 	}
1025 1025
 
1026
-	if ( 'integer' === $args['type'] && round( floatval( $value ) ) !== floatval( $value ) ) {
1026
+	if ('integer' === $args['type'] && round(floatval($value)) !== floatval($value)) {
1027 1027
 		/* translators: 1: parameter, 2: type name */
1028
-		return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s is not of type %2$s.' ), $param, 'integer' ) );
1028
+		return new WP_Error('rest_invalid_param', sprintf(__('%1$s is not of type %2$s.'), $param, 'integer'));
1029 1029
 	}
1030 1030
 
1031
-	if ( 'boolean' === $args['type'] && ! rest_is_boolean( $value ) ) {
1031
+	if ('boolean' === $args['type'] && ! rest_is_boolean($value)) {
1032 1032
 		/* translators: 1: parameter, 2: type name */
1033
-		return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s is not of type %2$s.' ), $value, 'boolean' ) );
1033
+		return new WP_Error('rest_invalid_param', sprintf(__('%1$s is not of type %2$s.'), $value, 'boolean'));
1034 1034
 	}
1035 1035
 
1036
-	if ( 'string' === $args['type'] && ! is_string( $value ) ) {
1036
+	if ('string' === $args['type'] && ! is_string($value)) {
1037 1037
 		/* translators: 1: parameter, 2: type name */
1038
-		return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s is not of type %2$s.' ), $param, 'string' ) );
1038
+		return new WP_Error('rest_invalid_param', sprintf(__('%1$s is not of type %2$s.'), $param, 'string'));
1039 1039
 	}
1040 1040
 
1041
-	if ( isset( $args['format'] ) ) {
1042
-		switch ( $args['format'] ) {
1041
+	if (isset($args['format'])) {
1042
+		switch ($args['format']) {
1043 1043
 			case 'date-time' :
1044
-				if ( ! rest_parse_date( $value ) ) {
1045
-					return new WP_Error( 'rest_invalid_date', __( 'Invalid date.' ) );
1044
+				if ( ! rest_parse_date($value)) {
1045
+					return new WP_Error('rest_invalid_date', __('Invalid date.'));
1046 1046
 				}
1047 1047
 				break;
1048 1048
 
@@ -1051,56 +1051,56 @@  discard block
 block discarded – undo
1051 1051
 				// wp_handle_comment_submission() requires 6 characters ([email protected])
1052 1052
 				//
1053 1053
 				// https://core.trac.wordpress.org/ticket/38506
1054
-				if ( ! is_email( $value ) || strlen( $value ) < 6 ) {
1055
-					return new WP_Error( 'rest_invalid_email', __( 'Invalid email address.' ) );
1054
+				if ( ! is_email($value) || strlen($value) < 6) {
1055
+					return new WP_Error('rest_invalid_email', __('Invalid email address.'));
1056 1056
 				}
1057 1057
 				break;
1058 1058
 			case 'ip' :
1059
-				if ( ! rest_is_ip_address( $value ) ) {
1059
+				if ( ! rest_is_ip_address($value)) {
1060 1060
 					/* translators: %s: IP address */
1061
-					return new WP_Error( 'rest_invalid_param', sprintf( __( '%s is not a valid IP address.' ), $value ) );
1061
+					return new WP_Error('rest_invalid_param', sprintf(__('%s is not a valid IP address.'), $value));
1062 1062
 				}
1063 1063
 				break;
1064 1064
 		}
1065 1065
 	}
1066 1066
 
1067
-	if ( in_array( $args['type'], array( 'number', 'integer' ), true ) && ( isset( $args['minimum'] ) || isset( $args['maximum'] ) ) ) {
1068
-		if ( isset( $args['minimum'] ) && ! isset( $args['maximum'] ) ) {
1069
-			if ( ! empty( $args['exclusiveMinimum'] ) && $value <= $args['minimum'] ) {
1067
+	if (in_array($args['type'], array('number', 'integer'), true) && (isset($args['minimum']) || isset($args['maximum']))) {
1068
+		if (isset($args['minimum']) && ! isset($args['maximum'])) {
1069
+			if ( ! empty($args['exclusiveMinimum']) && $value <= $args['minimum']) {
1070 1070
 				/* translators: 1: parameter, 2: minimum number */
1071
-				return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be greater than %2$d (exclusive)' ), $param, $args['minimum'] ) );
1072
-			} elseif ( empty( $args['exclusiveMinimum'] ) && $value < $args['minimum'] ) {
1071
+				return new WP_Error('rest_invalid_param', sprintf(__('%1$s must be greater than %2$d (exclusive)'), $param, $args['minimum']));
1072
+			} elseif (empty($args['exclusiveMinimum']) && $value < $args['minimum']) {
1073 1073
 				/* translators: 1: parameter, 2: minimum number */
1074
-				return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be greater than %2$d (inclusive)' ), $param, $args['minimum'] ) );
1074
+				return new WP_Error('rest_invalid_param', sprintf(__('%1$s must be greater than %2$d (inclusive)'), $param, $args['minimum']));
1075 1075
 			}
1076
-		} elseif ( isset( $args['maximum'] ) && ! isset( $args['minimum'] ) ) {
1077
-			if ( ! empty( $args['exclusiveMaximum'] ) && $value >= $args['maximum'] ) {
1076
+		} elseif (isset($args['maximum']) && ! isset($args['minimum'])) {
1077
+			if ( ! empty($args['exclusiveMaximum']) && $value >= $args['maximum']) {
1078 1078
 				/* translators: 1: parameter, 2: maximum number */
1079
-				return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be less than %2$d (exclusive)' ), $param, $args['maximum'] ) );
1080
-			} elseif ( empty( $args['exclusiveMaximum'] ) && $value > $args['maximum'] ) {
1079
+				return new WP_Error('rest_invalid_param', sprintf(__('%1$s must be less than %2$d (exclusive)'), $param, $args['maximum']));
1080
+			} elseif (empty($args['exclusiveMaximum']) && $value > $args['maximum']) {
1081 1081
 				/* translators: 1: parameter, 2: maximum number */
1082
-				return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be less than %2$d (inclusive)' ), $param, $args['maximum'] ) );
1082
+				return new WP_Error('rest_invalid_param', sprintf(__('%1$s must be less than %2$d (inclusive)'), $param, $args['maximum']));
1083 1083
 			}
1084
-		} elseif ( isset( $args['maximum'] ) && isset( $args['minimum'] ) ) {
1085
-			if ( ! empty( $args['exclusiveMinimum'] ) && ! empty( $args['exclusiveMaximum'] ) ) {
1086
-				if ( $value >= $args['maximum'] || $value <= $args['minimum'] ) {
1084
+		} elseif (isset($args['maximum']) && isset($args['minimum'])) {
1085
+			if ( ! empty($args['exclusiveMinimum']) && ! empty($args['exclusiveMaximum'])) {
1086
+				if ($value >= $args['maximum'] || $value <= $args['minimum']) {
1087 1087
 					/* translators: 1: parameter, 2: minimum number, 3: maximum number */
1088
-					return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be between %2$d (exclusive) and %3$d (exclusive)' ), $param, $args['minimum'], $args['maximum'] ) );
1088
+					return new WP_Error('rest_invalid_param', sprintf(__('%1$s must be between %2$d (exclusive) and %3$d (exclusive)'), $param, $args['minimum'], $args['maximum']));
1089 1089
 				}
1090
-			} elseif ( empty( $args['exclusiveMinimum'] ) && ! empty( $args['exclusiveMaximum'] ) ) {
1091
-				if ( $value >= $args['maximum'] || $value < $args['minimum'] ) {
1090
+			} elseif (empty($args['exclusiveMinimum']) && ! empty($args['exclusiveMaximum'])) {
1091
+				if ($value >= $args['maximum'] || $value < $args['minimum']) {
1092 1092
 					/* translators: 1: parameter, 2: minimum number, 3: maximum number */
1093
-					return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be between %2$d (inclusive) and %3$d (exclusive)' ), $param, $args['minimum'], $args['maximum'] ) );
1093
+					return new WP_Error('rest_invalid_param', sprintf(__('%1$s must be between %2$d (inclusive) and %3$d (exclusive)'), $param, $args['minimum'], $args['maximum']));
1094 1094
 				}
1095
-			} elseif ( ! empty( $args['exclusiveMinimum'] ) && empty( $args['exclusiveMaximum'] ) ) {
1096
-				if ( $value > $args['maximum'] || $value <= $args['minimum'] ) {
1095
+			} elseif ( ! empty($args['exclusiveMinimum']) && empty($args['exclusiveMaximum'])) {
1096
+				if ($value > $args['maximum'] || $value <= $args['minimum']) {
1097 1097
 					/* translators: 1: parameter, 2: minimum number, 3: maximum number */
1098
-					return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be between %2$d (exclusive) and %3$d (inclusive)' ), $param, $args['minimum'], $args['maximum'] ) );
1098
+					return new WP_Error('rest_invalid_param', sprintf(__('%1$s must be between %2$d (exclusive) and %3$d (inclusive)'), $param, $args['minimum'], $args['maximum']));
1099 1099
 				}
1100
-			} elseif ( empty( $args['exclusiveMinimum'] ) && empty( $args['exclusiveMaximum'] ) ) {
1101
-				if ( $value > $args['maximum'] || $value < $args['minimum'] ) {
1100
+			} elseif (empty($args['exclusiveMinimum']) && empty($args['exclusiveMaximum'])) {
1101
+				if ($value > $args['maximum'] || $value < $args['minimum']) {
1102 1102
 					/* translators: 1: parameter, 2: minimum number, 3: maximum number */
1103
-					return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be between %2$d (inclusive) and %3$d (inclusive)' ), $param, $args['minimum'], $args['maximum'] ) );
1103
+					return new WP_Error('rest_invalid_param', sprintf(__('%1$s must be between %2$d (inclusive) and %3$d (inclusive)'), $param, $args['minimum'], $args['maximum']));
1104 1104
 				}
1105 1105
 			}
1106 1106
 		}
@@ -1118,55 +1118,55 @@  discard block
 block discarded – undo
1118 1118
  * @param array $args  Schema array to use for sanitization.
1119 1119
  * @return true|WP_Error
1120 1120
  */
1121
-function rest_sanitize_value_from_schema( $value, $args ) {
1122
-	if ( 'array' === $args['type'] ) {
1123
-		if ( empty( $args['items'] ) ) {
1121
+function rest_sanitize_value_from_schema($value, $args) {
1122
+	if ('array' === $args['type']) {
1123
+		if (empty($args['items'])) {
1124 1124
 			return (array) $value;
1125 1125
 		}
1126
-		if ( ! is_array( $value ) ) {
1127
-			$value = preg_split( '/[\s,]+/', $value );
1126
+		if ( ! is_array($value)) {
1127
+			$value = preg_split('/[\s,]+/', $value);
1128 1128
 		}
1129
-		foreach ( $value as $index => $v ) {
1130
-			$value[ $index ] = rest_sanitize_value_from_schema( $v, $args['items'] );
1129
+		foreach ($value as $index => $v) {
1130
+			$value[$index] = rest_sanitize_value_from_schema($v, $args['items']);
1131 1131
 		}
1132 1132
 		// Normalize to numeric array so nothing unexpected
1133 1133
 		// is in the keys.
1134
-		$value = array_values( $value );
1134
+		$value = array_values($value);
1135 1135
 		return $value;
1136 1136
 	}
1137
-	if ( 'integer' === $args['type'] ) {
1137
+	if ('integer' === $args['type']) {
1138 1138
 		return (int) $value;
1139 1139
 	}
1140 1140
 
1141
-	if ( 'number' === $args['type'] ) {
1141
+	if ('number' === $args['type']) {
1142 1142
 		return (float) $value;
1143 1143
 	}
1144 1144
 
1145
-	if ( 'boolean' === $args['type'] ) {
1146
-		return rest_sanitize_boolean( $value );
1145
+	if ('boolean' === $args['type']) {
1146
+		return rest_sanitize_boolean($value);
1147 1147
 	}
1148 1148
 
1149
-	if ( isset( $args['format'] ) ) {
1150
-		switch ( $args['format'] ) {
1149
+	if (isset($args['format'])) {
1150
+		switch ($args['format']) {
1151 1151
 			case 'date-time' :
1152
-				return sanitize_text_field( $value );
1152
+				return sanitize_text_field($value);
1153 1153
 
1154 1154
 			case 'email' :
1155 1155
 				/*
1156 1156
 				 * sanitize_email() validates, which would be unexpected.
1157 1157
 				 */
1158
-				return sanitize_text_field( $value );
1158
+				return sanitize_text_field($value);
1159 1159
 
1160 1160
 			case 'uri' :
1161
-				return esc_url_raw( $value );
1161
+				return esc_url_raw($value);
1162 1162
 
1163 1163
 			case 'ip' :
1164
-				return sanitize_text_field( $value );
1164
+				return sanitize_text_field($value);
1165 1165
 		}
1166 1166
 	}
1167 1167
 
1168
-	if ( 'string' === $args['type'] ) {
1169
-		return strval( $value );
1168
+	if ('string' === $args['type']) {
1169
+		return strval($value);
1170 1170
 	}
1171 1171
 
1172 1172
 	return $value;
Please login to merge, or discard this patch.
src/wp-includes/rest-api/class-wp-rest-request.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -483,7 +483,7 @@
 block discarded – undo
483 483
 	 * @since 4.4.0
484 484
 	 * @access public
485 485
 	 *
486
-	 * @param array $params Parameter map of key to value.
486
+	 * @param string[] $params Parameter map of key to value.
487 487
 	 */
488 488
 	public function set_url_params( $params ) {
489 489
 		$this->params['URL'] = $params;
Please login to merge, or discard this patch.
Spacing   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 * @param string $route      Optional. Request route. Default empty.
119 119
 	 * @param array  $attributes Optional. Request attributes. Default empty array.
120 120
 	 */
121
-	public function __construct( $method = '', $route = '', $attributes = array() ) {
121
+	public function __construct($method = '', $route = '', $attributes = array()) {
122 122
 		$this->params = array(
123 123
 			'URL'   => array(),
124 124
 			'GET'   => array(),
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
 			'defaults' => array(),
132 132
 		);
133 133
 
134
-		$this->set_method( $method );
135
-		$this->set_route( $route );
136
-		$this->set_attributes( $attributes );
134
+		$this->set_method($method);
135
+		$this->set_route($route);
136
+		$this->set_attributes($attributes);
137 137
 	}
138 138
 
139 139
 	/**
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
 	 *
157 157
 	 * @param string $method HTTP method.
158 158
 	 */
159
-	public function set_method( $method ) {
160
-		$this->method = strtoupper( $method );
159
+	public function set_method($method) {
160
+		$this->method = strtoupper($method);
161 161
 	}
162 162
 
163 163
 	/**
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
 	 * @param string $key Header name.
193 193
 	 * @return string Canonicalized name.
194 194
 	 */
195
-	public static function canonicalize_header_name( $key ) {
196
-		$key = strtolower( $key );
197
-		$key = str_replace( '-', '_', $key );
195
+	public static function canonicalize_header_name($key) {
196
+		$key = strtolower($key);
197
+		$key = str_replace('-', '_', $key);
198 198
 
199 199
 		return $key;
200 200
 	}
@@ -212,14 +212,14 @@  discard block
 block discarded – undo
212 212
 	 * @param string $key Header name, will be canonicalized to lowercase.
213 213
 	 * @return string|null String value if set, null otherwise.
214 214
 	 */
215
-	public function get_header( $key ) {
216
-		$key = $this->canonicalize_header_name( $key );
215
+	public function get_header($key) {
216
+		$key = $this->canonicalize_header_name($key);
217 217
 
218
-		if ( ! isset( $this->headers[ $key ] ) ) {
218
+		if ( ! isset($this->headers[$key])) {
219 219
 			return null;
220 220
 		}
221 221
 
222
-		return implode( ',', $this->headers[ $key ] );
222
+		return implode(',', $this->headers[$key]);
223 223
 	}
224 224
 
225 225
 	/**
@@ -231,14 +231,14 @@  discard block
 block discarded – undo
231 231
 	 * @param string $key Header name, will be canonicalized to lowercase.
232 232
 	 * @return array|null List of string values if set, null otherwise.
233 233
 	 */
234
-	public function get_header_as_array( $key ) {
235
-		$key = $this->canonicalize_header_name( $key );
234
+	public function get_header_as_array($key) {
235
+		$key = $this->canonicalize_header_name($key);
236 236
 
237
-		if ( ! isset( $this->headers[ $key ] ) ) {
237
+		if ( ! isset($this->headers[$key])) {
238 238
 			return null;
239 239
 		}
240 240
 
241
-		return $this->headers[ $key ];
241
+		return $this->headers[$key];
242 242
 	}
243 243
 
244 244
 	/**
@@ -250,11 +250,11 @@  discard block
 block discarded – undo
250 250
 	 * @param string $key   Header name.
251 251
 	 * @param string $value Header value, or list of values.
252 252
 	 */
253
-	public function set_header( $key, $value ) {
254
-		$key = $this->canonicalize_header_name( $key );
253
+	public function set_header($key, $value) {
254
+		$key = $this->canonicalize_header_name($key);
255 255
 		$value = (array) $value;
256 256
 
257
-		$this->headers[ $key ] = $value;
257
+		$this->headers[$key] = $value;
258 258
 	}
259 259
 
260 260
 	/**
@@ -266,15 +266,15 @@  discard block
 block discarded – undo
266 266
 	 * @param string $key   Header name.
267 267
 	 * @param string $value Header value, or list of values.
268 268
 	 */
269
-	public function add_header( $key, $value ) {
270
-		$key = $this->canonicalize_header_name( $key );
269
+	public function add_header($key, $value) {
270
+		$key = $this->canonicalize_header_name($key);
271 271
 		$value = (array) $value;
272 272
 
273
-		if ( ! isset( $this->headers[ $key ] ) ) {
274
-			$this->headers[ $key ] = array();
273
+		if ( ! isset($this->headers[$key])) {
274
+			$this->headers[$key] = array();
275 275
 		}
276 276
 
277
-		$this->headers[ $key ] = array_merge( $this->headers[ $key ], $value );
277
+		$this->headers[$key] = array_merge($this->headers[$key], $value);
278 278
 	}
279 279
 
280 280
 	/**
@@ -285,8 +285,8 @@  discard block
 block discarded – undo
285 285
 	 *
286 286
 	 * @param string $key Header name.
287 287
 	 */
288
-	public function remove_header( $key ) {
289
-		unset( $this->headers[ $key ] );
288
+	public function remove_header($key) {
289
+		unset($this->headers[$key]);
290 290
 	}
291 291
 
292 292
 	/**
@@ -298,13 +298,13 @@  discard block
 block discarded – undo
298 298
 	 * @param array $headers  Map of header name to value.
299 299
 	 * @param bool  $override If true, replace the request's headers. Otherwise, merge with existing.
300 300
 	 */
301
-	public function set_headers( $headers, $override = true ) {
302
-		if ( true === $override ) {
301
+	public function set_headers($headers, $override = true) {
302
+		if (true === $override) {
303 303
 			$this->headers = array();
304 304
 		}
305 305
 
306
-		foreach ( $headers as $key => $value ) {
307
-			$this->set_header( $key, $value );
306
+		foreach ($headers as $key => $value) {
307
+			$this->set_header($key, $value);
308 308
 		}
309 309
 	}
310 310
 
@@ -317,26 +317,26 @@  discard block
 block discarded – undo
317 317
 	 * @return array Map containing 'value' and 'parameters' keys.
318 318
 	 */
319 319
 	public function get_content_type() {
320
-		$value = $this->get_header( 'content-type' );
321
-		if ( empty( $value ) ) {
320
+		$value = $this->get_header('content-type');
321
+		if (empty($value)) {
322 322
 			return null;
323 323
 		}
324 324
 
325 325
 		$parameters = '';
326
-		if ( strpos( $value, ';' ) ) {
327
-			list( $value, $parameters ) = explode( ';', $value, 2 );
326
+		if (strpos($value, ';')) {
327
+			list($value, $parameters) = explode(';', $value, 2);
328 328
 		}
329 329
 
330
-		$value = strtolower( $value );
331
-		if ( strpos( $value, '/' ) === false ) {
330
+		$value = strtolower($value);
331
+		if (strpos($value, '/') === false) {
332 332
 			return null;
333 333
 		}
334 334
 
335 335
 		// Parse type and subtype out.
336
-		list( $type, $subtype ) = explode( '/', $value, 2 );
336
+		list($type, $subtype) = explode('/', $value, 2);
337 337
 
338
-		$data = compact( 'value', 'type', 'subtype', 'parameters' );
339
-		$data = array_map( 'trim', $data );
338
+		$data = compact('value', 'type', 'subtype', 'parameters');
339
+		$data = array_map('trim', $data);
340 340
 
341 341
 		return $data;
342 342
 	}
@@ -360,12 +360,12 @@  discard block
 block discarded – undo
360 360
 		// Ensure we parse the body data.
361 361
 		$body = $this->get_body();
362 362
 
363
-		if ( 'POST' !== $this->method && ! empty( $body ) ) {
363
+		if ('POST' !== $this->method && ! empty($body)) {
364 364
 			$this->parse_body_params();
365 365
 		}
366 366
 
367
-		$accepts_body_data = array( 'POST', 'PUT', 'PATCH' );
368
-		if ( in_array( $this->method, $accepts_body_data ) ) {
367
+		$accepts_body_data = array('POST', 'PUT', 'PATCH');
368
+		if (in_array($this->method, $accepts_body_data)) {
369 369
 			$order[] = 'POST';
370 370
 		}
371 371
 
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 		 * }
389 389
 		 * @param WP_REST_Request $this The request object.
390 390
 		 */
391
-		return apply_filters( 'rest_request_parameter_order', $order, $this );
391
+		return apply_filters('rest_request_parameter_order', $order, $this);
392 392
 	}
393 393
 
394 394
 	/**
@@ -400,13 +400,13 @@  discard block
 block discarded – undo
400 400
 	 * @param string $key Parameter name.
401 401
 	 * @return mixed|null Value if set, null otherwise.
402 402
 	 */
403
-	public function get_param( $key ) {
403
+	public function get_param($key) {
404 404
 		$order = $this->get_parameter_order();
405 405
 
406
-		foreach ( $order as $type ) {
406
+		foreach ($order as $type) {
407 407
 			// Determine if we have the parameter for this type.
408
-			if ( isset( $this->params[ $type ][ $key ] ) ) {
409
-				return $this->params[ $type ][ $key ];
408
+			if (isset($this->params[$type][$key])) {
409
+				return $this->params[$type][$key];
410 410
 			}
411 411
 		}
412 412
 
@@ -422,14 +422,14 @@  discard block
 block discarded – undo
422 422
 	 * @param string $key   Parameter name.
423 423
 	 * @param mixed  $value Parameter value.
424 424
 	 */
425
-	public function set_param( $key, $value ) {
426
-		switch ( $this->method ) {
425
+	public function set_param($key, $value) {
426
+		switch ($this->method) {
427 427
 			case 'POST':
428
-				$this->params['POST'][ $key ] = $value;
428
+				$this->params['POST'][$key] = $value;
429 429
 				break;
430 430
 
431 431
 			default:
432
-				$this->params['GET'][ $key ] = $value;
432
+				$this->params['GET'][$key] = $value;
433 433
 				break;
434 434
 		}
435 435
 	}
@@ -447,14 +447,14 @@  discard block
 block discarded – undo
447 447
 	 */
448 448
 	public function get_params() {
449 449
 		$order = $this->get_parameter_order();
450
-		$order = array_reverse( $order, true );
450
+		$order = array_reverse($order, true);
451 451
 
452 452
 		$params = array();
453
-		foreach ( $order as $type ) {
453
+		foreach ($order as $type) {
454 454
 			// array_merge / the "+" operator will mess up
455 455
 			// numeric keys, so instead do a manual foreach.
456
-			foreach ( (array) $this->params[ $type ] as $key => $value ) {
457
-				$params[ $key ] = $value;
456
+			foreach ((array) $this->params[$type] as $key => $value) {
457
+				$params[$key] = $value;
458 458
 			}
459 459
 		}
460 460
 
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 	 *
486 486
 	 * @param array $params Parameter map of key to value.
487 487
 	 */
488
-	public function set_url_params( $params ) {
488
+	public function set_url_params($params) {
489 489
 		$this->params['URL'] = $params;
490 490
 	}
491 491
 
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
 	 *
514 514
 	 * @param array $params Parameter map of key to value.
515 515
 	 */
516
-	public function set_query_params( $params ) {
516
+	public function set_query_params($params) {
517 517
 		$this->params['GET'] = $params;
518 518
 	}
519 519
 
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 	 *
542 542
 	 * @param array $params Parameter map of key to value.
543 543
 	 */
544
-	public function set_body_params( $params ) {
544
+	public function set_body_params($params) {
545 545
 		$this->params['POST'] = $params;
546 546
 	}
547 547
 
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
 	 *
570 570
 	 * @param array $params Parameter map of key to value.
571 571
 	 */
572
-	public function set_file_params( $params ) {
572
+	public function set_file_params($params) {
573 573
 		$this->params['FILES'] = $params;
574 574
 	}
575 575
 
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 	 *
598 598
 	 * @param array $params Parameter map of key to value.
599 599
 	 */
600
-	public function set_default_params( $params ) {
600
+	public function set_default_params($params) {
601 601
 		$this->params['defaults'] = $params;
602 602
 	}
603 603
 
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
 	 *
622 622
 	 * @param string $data Binary data from the request body.
623 623
 	 */
624
-	public function set_body( $data ) {
624
+	public function set_body($data) {
625 625
 		$this->body = $data;
626 626
 
627 627
 		// Enable lazy parsing.
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
 	 * @return true|WP_Error True if the JSON data was passed or no JSON data was provided, WP_Error if invalid JSON was passed.
657 657
 	 */
658 658
 	protected function parse_json_params() {
659
-		if ( $this->parsed_json ) {
659
+		if ($this->parsed_json) {
660 660
 			return true;
661 661
 		}
662 662
 
@@ -665,16 +665,16 @@  discard block
 block discarded – undo
665 665
 		// Check that we actually got JSON.
666 666
 		$content_type = $this->get_content_type();
667 667
 
668
-		if ( empty( $content_type ) || 'application/json' !== $content_type['value'] ) {
668
+		if (empty($content_type) || 'application/json' !== $content_type['value']) {
669 669
 			return true;
670 670
 		}
671 671
 
672 672
 		$body = $this->get_body();
673
-		if ( empty( $body ) ) {
673
+		if (empty($body)) {
674 674
 			return true;
675 675
 		}
676 676
 
677
-		$params = json_decode( $body, true );
677
+		$params = json_decode($body, true);
678 678
 
679 679
 		/*
680 680
 		 * Check for a parsing error.
@@ -682,19 +682,19 @@  discard block
 block discarded – undo
682 682
 		 * Note that due to WP's JSON compatibility functions, json_last_error
683 683
 		 * might not be defined: https://core.trac.wordpress.org/ticket/27799
684 684
 		 */
685
-		if ( null === $params && ( ! function_exists( 'json_last_error' ) || JSON_ERROR_NONE !== json_last_error() ) ) {
685
+		if (null === $params && ( ! function_exists('json_last_error') || JSON_ERROR_NONE !== json_last_error())) {
686 686
 			// Ensure subsequent calls receive error instance.
687 687
 			$this->parsed_json = false;
688 688
 
689 689
 			$error_data = array(
690 690
 				'status' => WP_Http::BAD_REQUEST,
691 691
 			);
692
-			if ( function_exists( 'json_last_error' ) ) {
692
+			if (function_exists('json_last_error')) {
693 693
 				$error_data['json_error_code'] = json_last_error();
694 694
 				$error_data['json_error_message'] = json_last_error_msg();
695 695
 			}
696 696
 
697
-			return new WP_Error( 'rest_invalid_json', __( 'Invalid JSON body passed.' ), $error_data );
697
+			return new WP_Error('rest_invalid_json', __('Invalid JSON body passed.'), $error_data);
698 698
 		}
699 699
 
700 700
 		$this->params['JSON'] = $params;
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
 	 * @access protected
712 712
 	 */
713 713
 	protected function parse_body_params() {
714
-		if ( $this->parsed_body ) {
714
+		if ($this->parsed_body) {
715 715
 			return;
716 716
 		}
717 717
 
@@ -723,26 +723,26 @@  discard block
 block discarded – undo
723 723
 		 */
724 724
 		$content_type = $this->get_content_type();
725 725
 
726
-		if ( ! empty( $content_type ) && 'application/x-www-form-urlencoded' !== $content_type['value'] ) {
726
+		if ( ! empty($content_type) && 'application/x-www-form-urlencoded' !== $content_type['value']) {
727 727
 			return;
728 728
 		}
729 729
 
730
-		parse_str( $this->get_body(), $params );
730
+		parse_str($this->get_body(), $params);
731 731
 
732 732
 		/*
733 733
 		 * Amazingly, parse_str follows magic quote rules. Sigh.
734 734
 		 *
735 735
 		 * NOTE: Do not refactor to use `wp_unslash`.
736 736
 		 */
737
-		if ( get_magic_quotes_gpc() ) {
738
-			$params = stripslashes_deep( $params );
737
+		if (get_magic_quotes_gpc()) {
738
+			$params = stripslashes_deep($params);
739 739
 		}
740 740
 
741 741
 		/*
742 742
 		 * Add to the POST parameters stored internally. If a user has already
743 743
 		 * set these manually (via `set_body_params`), don't override them.
744 744
 		 */
745
-		$this->params['POST'] = array_merge( $params, $this->params['POST'] );
745
+		$this->params['POST'] = array_merge($params, $this->params['POST']);
746 746
 	}
747 747
 
748 748
 	/**
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
 	 *
766 766
 	 * @param string $route Route matching regex.
767 767
 	 */
768
-	public function set_route( $route ) {
768
+	public function set_route($route) {
769 769
 		$this->route = $route;
770 770
 	}
771 771
 
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
 	 *
792 792
 	 * @param array $attributes Attributes for the request.
793 793
 	 */
794
-	public function set_attributes( $attributes ) {
794
+	public function set_attributes($attributes) {
795 795
 		$this->attributes = $attributes;
796 796
 	}
797 797
 
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
 		$attributes = $this->get_attributes();
811 811
 
812 812
 		// No arguments set, skip sanitizing.
813
-		if ( empty( $attributes['args'] ) ) {
813
+		if (empty($attributes['args'])) {
814 814
 			return true;
815 815
 		}
816 816
 
@@ -818,37 +818,37 @@  discard block
 block discarded – undo
818 818
 
819 819
 		$invalid_params = array();
820 820
 
821
-		foreach ( $order as $type ) {
822
-			if ( empty( $this->params[ $type ] ) ) {
821
+		foreach ($order as $type) {
822
+			if (empty($this->params[$type])) {
823 823
 				continue;
824 824
 			}
825
-			foreach ( $this->params[ $type ] as $key => $value ) {
826
-				if ( ! isset( $attributes['args'][ $key ] ) ) {
825
+			foreach ($this->params[$type] as $key => $value) {
826
+				if ( ! isset($attributes['args'][$key])) {
827 827
 					continue;
828 828
 				}
829
-				$param_args = $attributes['args'][ $key ];
829
+				$param_args = $attributes['args'][$key];
830 830
 
831 831
 				// If the arg has a type but no sanitize_callback attribute, default to rest_parse_request_arg.
832
-				if ( ! array_key_exists( 'sanitize_callback', $param_args ) && ! empty( $param_args['type'] ) ) {
832
+				if ( ! array_key_exists('sanitize_callback', $param_args) && ! empty($param_args['type'])) {
833 833
 					$param_args['sanitize_callback'] = 'rest_parse_request_arg';
834 834
 				}
835 835
 				// If there's still no sanitize_callback, nothing to do here.
836
-				if ( empty( $param_args['sanitize_callback'] ) ) {
836
+				if (empty($param_args['sanitize_callback'])) {
837 837
 					continue;
838 838
 				}
839 839
 
840
-				$sanitized_value = call_user_func( $param_args['sanitize_callback'], $value, $this, $key );
840
+				$sanitized_value = call_user_func($param_args['sanitize_callback'], $value, $this, $key);
841 841
 
842
-				if ( is_wp_error( $sanitized_value ) ) {
843
-					$invalid_params[ $key ] = $sanitized_value->get_error_message();
842
+				if (is_wp_error($sanitized_value)) {
843
+					$invalid_params[$key] = $sanitized_value->get_error_message();
844 844
 				} else {
845
-					$this->params[ $type ][ $key ] = $sanitized_value;
845
+					$this->params[$type][$key] = $sanitized_value;
846 846
 				}
847 847
 			}
848 848
 		}
849 849
 
850
-		if ( $invalid_params ) {
851
-			return new WP_Error( 'rest_invalid_param', sprintf( __( 'Invalid parameter(s): %s' ), implode( ', ', array_keys( $invalid_params ) ) ), array( 'status' => 400, 'params' => $invalid_params ) );
850
+		if ($invalid_params) {
851
+			return new WP_Error('rest_invalid_param', sprintf(__('Invalid parameter(s): %s'), implode(', ', array_keys($invalid_params))), array('status' => 400, 'params' => $invalid_params));
852 852
 		}
853 853
 
854 854
 		return true;
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
 	public function has_valid_params() {
867 867
 		// If JSON data was passed, check for errors.
868 868
 		$json_error = $this->parse_json_params();
869
-		if ( is_wp_error( $json_error ) ) {
869
+		if (is_wp_error($json_error)) {
870 870
 			return $json_error;
871 871
 		}
872 872
 
@@ -874,20 +874,20 @@  discard block
 block discarded – undo
874 874
 		$required = array();
875 875
 
876 876
 		// No arguments set, skip validation.
877
-		if ( empty( $attributes['args'] ) ) {
877
+		if (empty($attributes['args'])) {
878 878
 			return true;
879 879
 		}
880 880
 
881
-		foreach ( $attributes['args'] as $key => $arg ) {
881
+		foreach ($attributes['args'] as $key => $arg) {
882 882
 
883
-			$param = $this->get_param( $key );
884
-			if ( isset( $arg['required'] ) && true === $arg['required'] && null === $param ) {
883
+			$param = $this->get_param($key);
884
+			if (isset($arg['required']) && true === $arg['required'] && null === $param) {
885 885
 				$required[] = $key;
886 886
 			}
887 887
 		}
888 888
 
889
-		if ( ! empty( $required ) ) {
890
-			return new WP_Error( 'rest_missing_callback_param', sprintf( __( 'Missing parameter(s): %s' ), implode( ', ', $required ) ), array( 'status' => 400, 'params' => $required ) );
889
+		if ( ! empty($required)) {
890
+			return new WP_Error('rest_missing_callback_param', sprintf(__('Missing parameter(s): %s'), implode(', ', $required)), array('status' => 400, 'params' => $required));
891 891
 		}
892 892
 
893 893
 		/*
@@ -897,25 +897,25 @@  discard block
 block discarded – undo
897 897
 		 */
898 898
 		$invalid_params = array();
899 899
 
900
-		foreach ( $attributes['args'] as $key => $arg ) {
900
+		foreach ($attributes['args'] as $key => $arg) {
901 901
 
902
-			$param = $this->get_param( $key );
902
+			$param = $this->get_param($key);
903 903
 
904
-			if ( null !== $param && ! empty( $arg['validate_callback'] ) ) {
905
-				$valid_check = call_user_func( $arg['validate_callback'], $param, $this, $key );
904
+			if (null !== $param && ! empty($arg['validate_callback'])) {
905
+				$valid_check = call_user_func($arg['validate_callback'], $param, $this, $key);
906 906
 
907
-				if ( false === $valid_check ) {
908
-					$invalid_params[ $key ] = __( 'Invalid parameter.' );
907
+				if (false === $valid_check) {
908
+					$invalid_params[$key] = __('Invalid parameter.');
909 909
 				}
910 910
 
911
-				if ( is_wp_error( $valid_check ) ) {
912
-					$invalid_params[ $key ] = $valid_check->get_error_message();
911
+				if (is_wp_error($valid_check)) {
912
+					$invalid_params[$key] = $valid_check->get_error_message();
913 913
 				}
914 914
 			}
915 915
 		}
916 916
 
917
-		if ( $invalid_params ) {
918
-			return new WP_Error( 'rest_invalid_param', sprintf( __( 'Invalid parameter(s): %s' ), implode( ', ', array_keys( $invalid_params ) ) ), array( 'status' => 400, 'params' => $invalid_params ) );
917
+		if ($invalid_params) {
918
+			return new WP_Error('rest_invalid_param', sprintf(__('Invalid parameter(s): %s'), implode(', ', array_keys($invalid_params))), array('status' => 400, 'params' => $invalid_params));
919 919
 		}
920 920
 
921 921
 		return true;
@@ -931,11 +931,11 @@  discard block
 block discarded – undo
931 931
 	 * @param string $offset Parameter name.
932 932
 	 * @return bool Whether the parameter is set.
933 933
 	 */
934
-	public function offsetExists( $offset ) {
934
+	public function offsetExists($offset) {
935 935
 		$order = $this->get_parameter_order();
936 936
 
937
-		foreach ( $order as $type ) {
938
-			if ( isset( $this->params[ $type ][ $offset ] ) ) {
937
+		foreach ($order as $type) {
938
+			if (isset($this->params[$type][$offset])) {
939 939
 				return true;
940 940
 			}
941 941
 		}
@@ -952,8 +952,8 @@  discard block
 block discarded – undo
952 952
 	 * @param string $offset Parameter name.
953 953
 	 * @return mixed|null Value if set, null otherwise.
954 954
 	 */
955
-	public function offsetGet( $offset ) {
956
-		return $this->get_param( $offset );
955
+	public function offsetGet($offset) {
956
+		return $this->get_param($offset);
957 957
 	}
958 958
 
959 959
 	/**
@@ -965,8 +965,8 @@  discard block
 block discarded – undo
965 965
 	 * @param string $offset Parameter name.
966 966
 	 * @param mixed  $value  Parameter value.
967 967
 	 */
968
-	public function offsetSet( $offset, $value ) {
969
-		$this->set_param( $offset, $value );
968
+	public function offsetSet($offset, $value) {
969
+		$this->set_param($offset, $value);
970 970
 	}
971 971
 
972 972
 	/**
@@ -977,12 +977,12 @@  discard block
 block discarded – undo
977 977
 	 *
978 978
 	 * @param string $offset Parameter name.
979 979
 	 */
980
-	public function offsetUnset( $offset ) {
980
+	public function offsetUnset($offset) {
981 981
 		$order = $this->get_parameter_order();
982 982
 
983 983
 		// Remove the offset from every group.
984
-		foreach ( $order as $type ) {
985
-			unset( $this->params[ $type ][ $offset ] );
984
+		foreach ($order as $type) {
985
+			unset($this->params[$type][$offset]);
986 986
 		}
987 987
 	}
988 988
 
@@ -996,29 +996,29 @@  discard block
 block discarded – undo
996 996
 	 * @param string $url URL with protocol, domain, path and query args.
997 997
 	 * @return WP_REST_Request|false WP_REST_Request object on success, false on failure.
998 998
 	 */
999
-	public static function from_url( $url ) {
1000
-		$bits = parse_url( $url );
999
+	public static function from_url($url) {
1000
+		$bits = parse_url($url);
1001 1001
 		$query_params = array();
1002 1002
 
1003
-		if ( ! empty( $bits['query'] ) ) {
1004
-			wp_parse_str( $bits['query'], $query_params );
1003
+		if ( ! empty($bits['query'])) {
1004
+			wp_parse_str($bits['query'], $query_params);
1005 1005
 		}
1006 1006
 
1007 1007
 		$api_root = rest_url();
1008
-		if ( get_option( 'permalink_structure' ) && 0 === strpos( $url, $api_root ) ) {
1008
+		if (get_option('permalink_structure') && 0 === strpos($url, $api_root)) {
1009 1009
 			// Pretty permalinks on, and URL is under the API root.
1010
-			$api_url_part = substr( $url, strlen( untrailingslashit( $api_root ) ) );
1011
-			$route = parse_url( $api_url_part, PHP_URL_PATH );
1012
-		} elseif ( ! empty( $query_params['rest_route'] ) ) {
1010
+			$api_url_part = substr($url, strlen(untrailingslashit($api_root)));
1011
+			$route = parse_url($api_url_part, PHP_URL_PATH);
1012
+		} elseif ( ! empty($query_params['rest_route'])) {
1013 1013
 			// ?rest_route=... set directly
1014 1014
 			$route = $query_params['rest_route'];
1015
-			unset( $query_params['rest_route'] );
1015
+			unset($query_params['rest_route']);
1016 1016
 		}
1017 1017
 
1018 1018
 		$request = false;
1019
-		if ( ! empty( $route ) ) {
1020
-			$request = new WP_REST_Request( 'GET', $route );
1021
-			$request->set_query_params( $query_params );
1019
+		if ( ! empty($route)) {
1020
+			$request = new WP_REST_Request('GET', $route);
1021
+			$request->set_query_params($query_params);
1022 1022
 		}
1023 1023
 
1024 1024
 		/**
@@ -1030,6 +1030,6 @@  discard block
 block discarded – undo
1030 1030
 		 *                                       could not be parsed.
1031 1031
 		 * @param string                $url     URL the request was generated from.
1032 1032
 		 */
1033
-		return apply_filters( 'rest_request_from_url', $request, $url );
1033
+		return apply_filters('rest_request_from_url', $request, $url);
1034 1034
 	}
1035 1035
 }
Please login to merge, or discard this patch.
src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 	 * @access public
249 249
 	 *
250 250
 	 * @param WP_REST_Request $request Request object.
251
-	 * @return WP_Error|stdClass $prepared_attachment Post object.
251
+	 * @return string $prepared_attachment Post object.
252 252
 	 */
253 253
 	protected function prepare_item_for_database( $request ) {
254 254
 		$prepared_attachment = parent::prepare_item_for_database( $request );
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 	 * @since 4.7.0
484 484
 	 * @access protected
485 485
 	 *
486
-	 * @param array $data    Supplied file data.
486
+	 * @param string $data    Supplied file data.
487 487
 	 * @param array $headers HTTP headers from the request.
488 488
 	 * @return array|WP_Error Data from wp_handle_sideload().
489 489
 	 */
Please login to merge, or discard this patch.
Spacing   +197 added lines, -197 removed lines patch added patch discarded remove patch
@@ -27,29 +27,29 @@  discard block
 block discarded – undo
27 27
 	 * @param WP_REST_Request $request       Optional. Request to prepare items for.
28 28
 	 * @return array Array of query arguments.
29 29
 	 */
30
-	protected function prepare_items_query( $prepared_args = array(), $request = null ) {
31
-		$query_args = parent::prepare_items_query( $prepared_args, $request );
30
+	protected function prepare_items_query($prepared_args = array(), $request = null) {
31
+		$query_args = parent::prepare_items_query($prepared_args, $request);
32 32
 
33
-		if ( empty( $query_args['post_status'] ) ) {
33
+		if (empty($query_args['post_status'])) {
34 34
 			$query_args['post_status'] = 'inherit';
35 35
 		}
36 36
 
37 37
 		$media_types = $this->get_media_types();
38 38
 
39
-		if ( ! empty( $request['media_type'] ) && isset( $media_types[ $request['media_type'] ] ) ) {
40
-			$query_args['post_mime_type'] = $media_types[ $request['media_type'] ];
39
+		if ( ! empty($request['media_type']) && isset($media_types[$request['media_type']])) {
40
+			$query_args['post_mime_type'] = $media_types[$request['media_type']];
41 41
 		}
42 42
 
43
-		if ( ! empty( $request['mime_type'] ) ) {
44
-			$parts = explode( '/', $request['mime_type'] );
45
-			if ( isset( $media_types[ $parts[0] ] ) && in_array( $request['mime_type'], $media_types[ $parts[0] ], true ) ) {
43
+		if ( ! empty($request['mime_type'])) {
44
+			$parts = explode('/', $request['mime_type']);
45
+			if (isset($media_types[$parts[0]]) && in_array($request['mime_type'], $media_types[$parts[0]], true)) {
46 46
 				$query_args['post_mime_type'] = $request['mime_type'];
47 47
 			}
48 48
 		}
49 49
 
50 50
 		// Filter query clauses to include filenames.
51
-		if ( isset( $query_args['s'] ) ) {
52
-			add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
51
+		if (isset($query_args['s'])) {
52
+			add_filter('posts_clauses', '_filter_query_attachment_filenames');
53 53
 		}
54 54
 
55 55
 		return $query_args;
@@ -64,24 +64,24 @@  discard block
 block discarded – undo
64 64
 	 * @param WP_REST_Request $request Full details about the request.
65 65
 	 * @return WP_Error|true Boolean true if the attachment may be created, or a WP_Error if not.
66 66
 	 */
67
-	public function create_item_permissions_check( $request ) {
68
-		$ret = parent::create_item_permissions_check( $request );
67
+	public function create_item_permissions_check($request) {
68
+		$ret = parent::create_item_permissions_check($request);
69 69
 
70
-		if ( ! $ret || is_wp_error( $ret ) ) {
70
+		if ( ! $ret || is_wp_error($ret)) {
71 71
 			return $ret;
72 72
 		}
73 73
 
74
-		if ( ! current_user_can( 'upload_files' ) ) {
75
-			return new WP_Error( 'rest_cannot_create', __( 'Sorry, you are not allowed to upload media on this site.' ), array( 'status' => 400 ) );
74
+		if ( ! current_user_can('upload_files')) {
75
+			return new WP_Error('rest_cannot_create', __('Sorry, you are not allowed to upload media on this site.'), array('status' => 400));
76 76
 		}
77 77
 
78 78
 		// Attaching media to a post requires ability to edit said post.
79
-		if ( ! empty( $request['post'] ) ) {
80
-			$parent = get_post( (int) $request['post'] );
81
-			$post_parent_type = get_post_type_object( $parent->post_type );
79
+		if ( ! empty($request['post'])) {
80
+			$parent = get_post((int) $request['post']);
81
+			$post_parent_type = get_post_type_object($parent->post_type);
82 82
 
83
-			if ( ! current_user_can( $post_parent_type->cap->edit_post, $request['post'] ) ) {
84
-				return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to upload media to this post.' ), array( 'status' => rest_authorization_required_code() ) );
83
+			if ( ! current_user_can($post_parent_type->cap->edit_post, $request['post'])) {
84
+				return new WP_Error('rest_cannot_edit', __('Sorry, you are not allowed to upload media to this post.'), array('status' => rest_authorization_required_code()));
85 85
 			}
86 86
 		}
87 87
 
@@ -97,68 +97,68 @@  discard block
 block discarded – undo
97 97
 	 * @param WP_REST_Request $request Full details about the request.
98 98
 	 * @return WP_Error|WP_REST_Response Response object on success, WP_Error object on failure.
99 99
 	 */
100
-	public function create_item( $request ) {
100
+	public function create_item($request) {
101 101
 
102
-		if ( ! empty( $request['post'] ) && in_array( get_post_type( $request['post'] ), array( 'revision', 'attachment' ), true ) ) {
103
-			return new WP_Error( 'rest_invalid_param', __( 'Invalid parent type.' ), array( 'status' => 400 ) );
102
+		if ( ! empty($request['post']) && in_array(get_post_type($request['post']), array('revision', 'attachment'), true)) {
103
+			return new WP_Error('rest_invalid_param', __('Invalid parent type.'), array('status' => 400));
104 104
 		}
105 105
 
106 106
 		// Get the file via $_FILES or raw data.
107 107
 		$files = $request->get_file_params();
108 108
 		$headers = $request->get_headers();
109 109
 
110
-		if ( ! empty( $files ) ) {
111
-			$file = $this->upload_from_file( $files, $headers );
110
+		if ( ! empty($files)) {
111
+			$file = $this->upload_from_file($files, $headers);
112 112
 		} else {
113
-			$file = $this->upload_from_data( $request->get_body(), $headers );
113
+			$file = $this->upload_from_data($request->get_body(), $headers);
114 114
 		}
115 115
 
116
-		if ( is_wp_error( $file ) ) {
116
+		if (is_wp_error($file)) {
117 117
 			return $file;
118 118
 		}
119 119
 
120
-		$name       = basename( $file['file'] );
121
-		$name_parts = pathinfo( $name );
122
-		$name       = trim( substr( $name, 0, -(1 + strlen( $name_parts['extension'] ) ) ) );
120
+		$name       = basename($file['file']);
121
+		$name_parts = pathinfo($name);
122
+		$name       = trim(substr($name, 0, -(1 + strlen($name_parts['extension']))));
123 123
 
124 124
 		$url     = $file['url'];
125 125
 		$type    = $file['type'];
126 126
 		$file    = $file['file'];
127 127
 
128 128
 		// use image exif/iptc data for title and caption defaults if possible
129
-		$image_meta = @wp_read_image_metadata( $file );
129
+		$image_meta = @wp_read_image_metadata($file);
130 130
 
131
-		if ( ! empty( $image_meta ) ) {
132
-			if ( empty( $request['title'] ) && trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) {
131
+		if ( ! empty($image_meta)) {
132
+			if (empty($request['title']) && trim($image_meta['title']) && ! is_numeric(sanitize_title($image_meta['title']))) {
133 133
 				$request['title'] = $image_meta['title'];
134 134
 			}
135 135
 
136
-			if ( empty( $request['caption'] ) && trim( $image_meta['caption'] ) ) {
136
+			if (empty($request['caption']) && trim($image_meta['caption'])) {
137 137
 				$request['caption'] = $image_meta['caption'];
138 138
 			}
139 139
 		}
140 140
 
141
-		$attachment = $this->prepare_item_for_database( $request );
141
+		$attachment = $this->prepare_item_for_database($request);
142 142
 		$attachment->file = $file;
143 143
 		$attachment->post_mime_type = $type;
144 144
 		$attachment->guid = $url;
145 145
 
146
-		if ( empty( $attachment->post_title ) ) {
147
-			$attachment->post_title = preg_replace( '/\.[^.]+$/', '', basename( $file ) );
146
+		if (empty($attachment->post_title)) {
147
+			$attachment->post_title = preg_replace('/\.[^.]+$/', '', basename($file));
148 148
 		}
149 149
 
150
-		$id = wp_insert_post( wp_slash( (array) $attachment ), true );
150
+		$id = wp_insert_post(wp_slash((array) $attachment), true);
151 151
 
152
-		if ( is_wp_error( $id ) ) {
153
-			if ( 'db_update_error' === $id->get_error_code() ) {
154
-				$id->add_data( array( 'status' => 500 ) );
152
+		if (is_wp_error($id)) {
153
+			if ('db_update_error' === $id->get_error_code()) {
154
+				$id->add_data(array('status' => 500));
155 155
 			} else {
156
-				$id->add_data( array( 'status' => 400 ) );
156
+				$id->add_data(array('status' => 400));
157 157
 			}
158 158
 			return $id;
159 159
 		}
160 160
 
161
-		$attachment = get_post( $id );
161
+		$attachment = get_post($id);
162 162
 
163 163
 		/**
164 164
 		 * Fires after a single attachment is created or updated via the REST API.
@@ -170,28 +170,28 @@  discard block
 block discarded – undo
170 170
 		 * @param WP_REST_Request $request    The request sent to the API.
171 171
 		 * @param bool            $creating   True when creating an attachment, false when updating.
172 172
 		 */
173
-		do_action( 'rest_insert_attachment', $attachment, $request, true );
173
+		do_action('rest_insert_attachment', $attachment, $request, true);
174 174
 
175 175
 		// Include admin functions to get access to wp_generate_attachment_metadata().
176
-		require_once ABSPATH . 'wp-admin/includes/admin.php';
176
+		require_once ABSPATH.'wp-admin/includes/admin.php';
177 177
 
178
-		wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
178
+		wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $file));
179 179
 
180
-		if ( isset( $request['alt_text'] ) ) {
181
-			update_post_meta( $id, '_wp_attachment_image_alt', sanitize_text_field( $request['alt_text'] ) );
180
+		if (isset($request['alt_text'])) {
181
+			update_post_meta($id, '_wp_attachment_image_alt', sanitize_text_field($request['alt_text']));
182 182
 		}
183 183
 
184
-		$fields_update = $this->update_additional_fields_for_object( $attachment, $request );
184
+		$fields_update = $this->update_additional_fields_for_object($attachment, $request);
185 185
 
186
-		if ( is_wp_error( $fields_update ) ) {
186
+		if (is_wp_error($fields_update)) {
187 187
 			return $fields_update;
188 188
 		}
189 189
 
190
-		$request->set_param( 'context', 'edit' );
191
-		$response = $this->prepare_item_for_response( $attachment, $request );
192
-		$response = rest_ensure_response( $response );
193
-		$response->set_status( 201 );
194
-		$response->header( 'Location', rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $id ) ) );
190
+		$request->set_param('context', 'edit');
191
+		$response = $this->prepare_item_for_response($attachment, $request);
192
+		$response = rest_ensure_response($response);
193
+		$response->set_status(201);
194
+		$response->header('Location', rest_url(sprintf('%s/%s/%d', $this->namespace, $this->rest_base, $id)));
195 195
 
196 196
 		return $response;
197 197
 	}
@@ -205,38 +205,38 @@  discard block
 block discarded – undo
205 205
 	 * @param WP_REST_Request $request Full details about the request.
206 206
 	 * @return WP_Error|WP_REST_Response Response object on success, WP_Error object on failure.
207 207
 	 */
208
-	public function update_item( $request ) {
209
-		if ( ! empty( $request['post'] ) && in_array( get_post_type( $request['post'] ), array( 'revision', 'attachment' ), true ) ) {
210
-			return new WP_Error( 'rest_invalid_param', __( 'Invalid parent type.' ), array( 'status' => 400 ) );
208
+	public function update_item($request) {
209
+		if ( ! empty($request['post']) && in_array(get_post_type($request['post']), array('revision', 'attachment'), true)) {
210
+			return new WP_Error('rest_invalid_param', __('Invalid parent type.'), array('status' => 400));
211 211
 		}
212 212
 
213
-		$response = parent::update_item( $request );
213
+		$response = parent::update_item($request);
214 214
 
215
-		if ( is_wp_error( $response ) ) {
215
+		if (is_wp_error($response)) {
216 216
 			return $response;
217 217
 		}
218 218
 
219
-		$response = rest_ensure_response( $response );
219
+		$response = rest_ensure_response($response);
220 220
 		$data = $response->get_data();
221 221
 
222
-		if ( isset( $request['alt_text'] ) ) {
223
-			update_post_meta( $data['id'], '_wp_attachment_image_alt', $request['alt_text'] );
222
+		if (isset($request['alt_text'])) {
223
+			update_post_meta($data['id'], '_wp_attachment_image_alt', $request['alt_text']);
224 224
 		}
225 225
 
226
-		$attachment = get_post( $request['id'] );
226
+		$attachment = get_post($request['id']);
227 227
 
228 228
 		/** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php */
229
-		do_action( 'rest_insert_attachment', $data, $request, false );
229
+		do_action('rest_insert_attachment', $data, $request, false);
230 230
 
231
-		$fields_update = $this->update_additional_fields_for_object( $attachment, $request );
231
+		$fields_update = $this->update_additional_fields_for_object($attachment, $request);
232 232
 
233
-		if ( is_wp_error( $fields_update ) ) {
233
+		if (is_wp_error($fields_update)) {
234 234
 			return $fields_update;
235 235
 		}
236 236
 
237
-		$request->set_param( 'context', 'edit' );
238
-		$response = $this->prepare_item_for_response( $attachment, $request );
239
-		$response = rest_ensure_response( $response );
237
+		$request->set_param('context', 'edit');
238
+		$response = $this->prepare_item_for_response($attachment, $request);
239
+		$response = rest_ensure_response($response);
240 240
 
241 241
 		return $response;
242 242
 	}
@@ -250,28 +250,28 @@  discard block
 block discarded – undo
250 250
 	 * @param WP_REST_Request $request Request object.
251 251
 	 * @return WP_Error|stdClass $prepared_attachment Post object.
252 252
 	 */
253
-	protected function prepare_item_for_database( $request ) {
254
-		$prepared_attachment = parent::prepare_item_for_database( $request );
253
+	protected function prepare_item_for_database($request) {
254
+		$prepared_attachment = parent::prepare_item_for_database($request);
255 255
 
256 256
 		// Attachment caption (post_excerpt internally)
257
-		if ( isset( $request['caption'] ) ) {
258
-			if ( is_string( $request['caption'] ) ) {
257
+		if (isset($request['caption'])) {
258
+			if (is_string($request['caption'])) {
259 259
 				$prepared_attachment->post_excerpt = $request['caption'];
260
-			} elseif ( isset( $request['caption']['raw'] ) ) {
260
+			} elseif (isset($request['caption']['raw'])) {
261 261
 				$prepared_attachment->post_excerpt = $request['caption']['raw'];
262 262
 			}
263 263
 		}
264 264
 
265 265
 		// Attachment description (post_content internally)
266
-		if ( isset( $request['description'] ) ) {
267
-			if ( is_string( $request['description'] ) ) {
266
+		if (isset($request['description'])) {
267
+			if (is_string($request['description'])) {
268 268
 				$prepared_attachment->post_content = $request['description'];
269
-			} elseif ( isset( $request['description']['raw'] ) ) {
269
+			} elseif (isset($request['description']['raw'])) {
270 270
 				$prepared_attachment->post_content = $request['description']['raw'];
271 271
 			}
272 272
 		}
273 273
 
274
-		if ( isset( $request['post'] ) ) {
274
+		if (isset($request['post'])) {
275 275
 			$prepared_attachment->post_parent = (int) $request['post'];
276 276
 		}
277 277
 
@@ -288,56 +288,56 @@  discard block
 block discarded – undo
288 288
 	 * @param WP_REST_Request $request Request object.
289 289
 	 * @return WP_REST_Response Response object.
290 290
 	 */
291
-	public function prepare_item_for_response( $post, $request ) {
292
-		$response = parent::prepare_item_for_response( $post, $request );
291
+	public function prepare_item_for_response($post, $request) {
292
+		$response = parent::prepare_item_for_response($post, $request);
293 293
 		$data = $response->get_data();
294 294
 
295 295
 		$data['description'] = array(
296 296
 			'raw'       => $post->post_content,
297 297
 			/** This filter is documented in wp-includes/post-template.php */
298
-			'rendered'  => apply_filters( 'the_content', $post->post_content ),
298
+			'rendered'  => apply_filters('the_content', $post->post_content),
299 299
 		);
300 300
 
301 301
 		/** This filter is documented in wp-includes/post-template.php */
302
-		$caption = apply_filters( 'the_excerpt', apply_filters( 'get_the_excerpt', $post->post_excerpt, $post ) );
302
+		$caption = apply_filters('the_excerpt', apply_filters('get_the_excerpt', $post->post_excerpt, $post));
303 303
 		$data['caption'] = array(
304 304
 			'raw'       => $post->post_excerpt,
305 305
 			'rendered'  => $caption,
306 306
 		);
307 307
 
308
-		$data['alt_text']      = get_post_meta( $post->ID, '_wp_attachment_image_alt', true );
309
-		$data['media_type']    = wp_attachment_is_image( $post->ID ) ? 'image' : 'file';
308
+		$data['alt_text']      = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
309
+		$data['media_type']    = wp_attachment_is_image($post->ID) ? 'image' : 'file';
310 310
 		$data['mime_type']     = $post->post_mime_type;
311
-		$data['media_details'] = wp_get_attachment_metadata( $post->ID );
312
-		$data['post']          = ! empty( $post->post_parent ) ? (int) $post->post_parent : null;
313
-		$data['source_url']    = wp_get_attachment_url( $post->ID );
311
+		$data['media_details'] = wp_get_attachment_metadata($post->ID);
312
+		$data['post']          = ! empty($post->post_parent) ? (int) $post->post_parent : null;
313
+		$data['source_url']    = wp_get_attachment_url($post->ID);
314 314
 
315 315
 		// Ensure empty details is an empty object.
316
-		if ( empty( $data['media_details'] ) ) {
316
+		if (empty($data['media_details'])) {
317 317
 			$data['media_details'] = new stdClass;
318
-		} elseif ( ! empty( $data['media_details']['sizes'] ) ) {
318
+		} elseif ( ! empty($data['media_details']['sizes'])) {
319 319
 
320
-			foreach ( $data['media_details']['sizes'] as $size => &$size_data ) {
320
+			foreach ($data['media_details']['sizes'] as $size => &$size_data) {
321 321
 
322
-				if ( isset( $size_data['mime-type'] ) ) {
322
+				if (isset($size_data['mime-type'])) {
323 323
 					$size_data['mime_type'] = $size_data['mime-type'];
324
-					unset( $size_data['mime-type'] );
324
+					unset($size_data['mime-type']);
325 325
 				}
326 326
 
327 327
 				// Use the same method image_downsize() does.
328
-				$image_src = wp_get_attachment_image_src( $post->ID, $size );
329
-				if ( ! $image_src ) {
328
+				$image_src = wp_get_attachment_image_src($post->ID, $size);
329
+				if ( ! $image_src) {
330 330
 					continue;
331 331
 				}
332 332
 
333 333
 				$size_data['source_url'] = $image_src[0];
334 334
 			}
335 335
 
336
-			$full_src = wp_get_attachment_image_src( $post->ID, 'full' );
336
+			$full_src = wp_get_attachment_image_src($post->ID, 'full');
337 337
 
338
-			if ( ! empty( $full_src ) ) {
338
+			if ( ! empty($full_src)) {
339 339
 				$data['media_details']['sizes']['full'] = array(
340
-					'file'       => wp_basename( $full_src[0] ),
340
+					'file'       => wp_basename($full_src[0]),
341 341
 					'width'      => $full_src[1],
342 342
 					'height'     => $full_src[2],
343 343
 					'mime_type'  => $post->post_mime_type,
@@ -348,14 +348,14 @@  discard block
 block discarded – undo
348 348
 			$data['media_details']['sizes'] = new stdClass;
349 349
 		}
350 350
 
351
-		$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
351
+		$context = ! empty($request['context']) ? $request['context'] : 'view';
352 352
 
353
-		$data = $this->filter_response_by_context( $data, $context );
353
+		$data = $this->filter_response_by_context($data, $context);
354 354
 
355 355
 		// Wrap the data in a response object.
356
-		$response = rest_ensure_response( $data );
356
+		$response = rest_ensure_response($data);
357 357
 
358
-		$response->add_links( $this->prepare_links( $post ) );
358
+		$response->add_links($this->prepare_links($post));
359 359
 
360 360
 		/**
361 361
 		 * Filters an attachment returned from the REST API.
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 		 * @param WP_Post          $post     The original attachment post.
369 369
 		 * @param WP_REST_Request  $request  Request used to generate the response.
370 370
 		 */
371
-		return apply_filters( 'rest_prepare_attachment', $response, $post, $request );
371
+		return apply_filters('rest_prepare_attachment', $response, $post, $request);
372 372
 	}
373 373
 
374 374
 	/**
@@ -384,95 +384,95 @@  discard block
 block discarded – undo
384 384
 		$schema = parent::get_item_schema();
385 385
 
386 386
 		$schema['properties']['alt_text'] = array(
387
-			'description'     => __( 'Alternative text to display when attachment is not displayed.' ),
387
+			'description'     => __('Alternative text to display when attachment is not displayed.'),
388 388
 			'type'            => 'string',
389
-			'context'         => array( 'view', 'edit', 'embed' ),
389
+			'context'         => array('view', 'edit', 'embed'),
390 390
 			'arg_options'     => array(
391 391
 				'sanitize_callback' => 'sanitize_text_field',
392 392
 			),
393 393
 		);
394 394
 
395 395
 		$schema['properties']['caption'] = array(
396
-			'description' => __( 'The attachment caption.' ),
396
+			'description' => __('The attachment caption.'),
397 397
 			'type'        => 'object',
398
-			'context'     => array( 'view', 'edit', 'embed' ),
398
+			'context'     => array('view', 'edit', 'embed'),
399 399
 			'arg_options' => array(
400 400
 				'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database()
401 401
 			),
402 402
 			'properties'  => array(
403 403
 				'raw' => array(
404
-					'description' => __( 'Caption for the attachment, as it exists in the database.' ),
404
+					'description' => __('Caption for the attachment, as it exists in the database.'),
405 405
 					'type'        => 'string',
406
-					'context'     => array( 'edit' ),
406
+					'context'     => array('edit'),
407 407
 				),
408 408
 				'rendered' => array(
409
-					'description' => __( 'HTML caption for the attachment, transformed for display.' ),
409
+					'description' => __('HTML caption for the attachment, transformed for display.'),
410 410
 					'type'        => 'string',
411
-					'context'     => array( 'view', 'edit', 'embed' ),
411
+					'context'     => array('view', 'edit', 'embed'),
412 412
 					'readonly'    => true,
413 413
 				),
414 414
 			),
415 415
 		);
416 416
 
417 417
 		$schema['properties']['description'] = array(
418
-			'description' => __( 'The attachment description.' ),
418
+			'description' => __('The attachment description.'),
419 419
 			'type'        => 'object',
420
-			'context'     => array( 'view', 'edit' ),
420
+			'context'     => array('view', 'edit'),
421 421
 			'arg_options' => array(
422 422
 				'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database()
423 423
 			),
424 424
 			'properties'  => array(
425 425
 				'raw' => array(
426
-					'description' => __( 'Description for the object, as it exists in the database.' ),
426
+					'description' => __('Description for the object, as it exists in the database.'),
427 427
 					'type'        => 'string',
428
-					'context'     => array( 'edit' ),
428
+					'context'     => array('edit'),
429 429
 				),
430 430
 				'rendered' => array(
431
-					'description' => __( 'HTML description for the object, transformed for display.' ),
431
+					'description' => __('HTML description for the object, transformed for display.'),
432 432
 					'type'        => 'string',
433
-					'context'     => array( 'view', 'edit' ),
433
+					'context'     => array('view', 'edit'),
434 434
 					'readonly'    => true,
435 435
 				),
436 436
 			),
437 437
 		);
438 438
 
439 439
 		$schema['properties']['media_type'] = array(
440
-			'description'     => __( 'Attachment type.' ),
440
+			'description'     => __('Attachment type.'),
441 441
 			'type'            => 'string',
442
-			'enum'            => array( 'image', 'file' ),
443
-			'context'         => array( 'view', 'edit', 'embed' ),
442
+			'enum'            => array('image', 'file'),
443
+			'context'         => array('view', 'edit', 'embed'),
444 444
 			'readonly'        => true,
445 445
 		);
446 446
 
447 447
 		$schema['properties']['mime_type'] = array(
448
-			'description'     => __( 'The attachment MIME type.' ),
448
+			'description'     => __('The attachment MIME type.'),
449 449
 			'type'            => 'string',
450
-			'context'         => array( 'view', 'edit', 'embed' ),
450
+			'context'         => array('view', 'edit', 'embed'),
451 451
 			'readonly'        => true,
452 452
 		);
453 453
 
454 454
 		$schema['properties']['media_details'] = array(
455
-			'description'     => __( 'Details about the media file, specific to its type.' ),
455
+			'description'     => __('Details about the media file, specific to its type.'),
456 456
 			'type'            => 'object',
457
-			'context'         => array( 'view', 'edit', 'embed' ),
457
+			'context'         => array('view', 'edit', 'embed'),
458 458
 			'readonly'        => true,
459 459
 		);
460 460
 
461 461
 		$schema['properties']['post'] = array(
462
-			'description'     => __( 'The ID for the associated post of the attachment.' ),
462
+			'description'     => __('The ID for the associated post of the attachment.'),
463 463
 			'type'            => 'integer',
464
-			'context'         => array( 'view', 'edit' ),
464
+			'context'         => array('view', 'edit'),
465 465
 		);
466 466
 
467 467
 		$schema['properties']['source_url'] = array(
468
-			'description'     => __( 'URL to the original attachment file.' ),
468
+			'description'     => __('URL to the original attachment file.'),
469 469
 			'type'            => 'string',
470 470
 			'format'          => 'uri',
471
-			'context'         => array( 'view', 'edit', 'embed' ),
471
+			'context'         => array('view', 'edit', 'embed'),
472 472
 			'readonly'        => true,
473 473
 		);
474 474
 
475
-		unset( $schema['properties']['password'] );
475
+		unset($schema['properties']['password']);
476 476
 
477 477
 		return $schema;
478 478
 	}
@@ -487,52 +487,52 @@  discard block
 block discarded – undo
487 487
 	 * @param array $headers HTTP headers from the request.
488 488
 	 * @return array|WP_Error Data from wp_handle_sideload().
489 489
 	 */
490
-	protected function upload_from_data( $data, $headers ) {
491
-		if ( empty( $data ) ) {
492
-			return new WP_Error( 'rest_upload_no_data', __( 'No data supplied.' ), array( 'status' => 400 ) );
490
+	protected function upload_from_data($data, $headers) {
491
+		if (empty($data)) {
492
+			return new WP_Error('rest_upload_no_data', __('No data supplied.'), array('status' => 400));
493 493
 		}
494 494
 
495
-		if ( empty( $headers['content_type'] ) ) {
496
-			return new WP_Error( 'rest_upload_no_content_type', __( 'No Content-Type supplied.' ), array( 'status' => 400 ) );
495
+		if (empty($headers['content_type'])) {
496
+			return new WP_Error('rest_upload_no_content_type', __('No Content-Type supplied.'), array('status' => 400));
497 497
 		}
498 498
 
499
-		if ( empty( $headers['content_disposition'] ) ) {
500
-			return new WP_Error( 'rest_upload_no_content_disposition', __( 'No Content-Disposition supplied.' ), array( 'status' => 400 ) );
499
+		if (empty($headers['content_disposition'])) {
500
+			return new WP_Error('rest_upload_no_content_disposition', __('No Content-Disposition supplied.'), array('status' => 400));
501 501
 		}
502 502
 
503
-		$filename = self::get_filename_from_disposition( $headers['content_disposition'] );
503
+		$filename = self::get_filename_from_disposition($headers['content_disposition']);
504 504
 
505
-		if ( empty( $filename ) ) {
506
-			return new WP_Error( 'rest_upload_invalid_disposition', __( 'Invalid Content-Disposition supplied. Content-Disposition needs to be formatted as `attachment; filename="image.png"` or similar.' ), array( 'status' => 400 ) );
505
+		if (empty($filename)) {
506
+			return new WP_Error('rest_upload_invalid_disposition', __('Invalid Content-Disposition supplied. Content-Disposition needs to be formatted as `attachment; filename="image.png"` or similar.'), array('status' => 400));
507 507
 		}
508 508
 
509
-		if ( ! empty( $headers['content_md5'] ) ) {
510
-			$content_md5 = array_shift( $headers['content_md5'] );
511
-			$expected    = trim( $content_md5 );
512
-			$actual      = md5( $data );
509
+		if ( ! empty($headers['content_md5'])) {
510
+			$content_md5 = array_shift($headers['content_md5']);
511
+			$expected    = trim($content_md5);
512
+			$actual      = md5($data);
513 513
 
514
-			if ( $expected !== $actual ) {
515
-				return new WP_Error( 'rest_upload_hash_mismatch', __( 'Content hash did not match expected.' ), array( 'status' => 412 ) );
514
+			if ($expected !== $actual) {
515
+				return new WP_Error('rest_upload_hash_mismatch', __('Content hash did not match expected.'), array('status' => 412));
516 516
 			}
517 517
 		}
518 518
 
519 519
 		// Get the content-type.
520
-		$type = array_shift( $headers['content_type'] );
520
+		$type = array_shift($headers['content_type']);
521 521
 
522 522
 		/** Include admin functions to get access to wp_tempnam() and wp_handle_sideload() */
523
-		require_once ABSPATH . 'wp-admin/includes/admin.php';
523
+		require_once ABSPATH.'wp-admin/includes/admin.php';
524 524
 
525 525
 		// Save the file.
526
-		$tmpfname = wp_tempnam( $filename );
526
+		$tmpfname = wp_tempnam($filename);
527 527
 
528
-		$fp = fopen( $tmpfname, 'w+' );
528
+		$fp = fopen($tmpfname, 'w+');
529 529
 
530
-		if ( ! $fp ) {
531
-			return new WP_Error( 'rest_upload_file_error', __( 'Could not open file handle.' ), array( 'status' => 500 ) );
530
+		if ( ! $fp) {
531
+			return new WP_Error('rest_upload_file_error', __('Could not open file handle.'), array('status' => 500));
532 532
 		}
533 533
 
534
-		fwrite( $fp, $data );
535
-		fclose( $fp );
534
+		fwrite($fp, $data);
535
+		fclose($fp);
536 536
 
537 537
 		// Now, sideload it in.
538 538
 		$file_data = array(
@@ -546,12 +546,12 @@  discard block
 block discarded – undo
546 546
 			'test_form' => false,
547 547
 		);
548 548
 
549
-		$sideloaded = wp_handle_sideload( $file_data, $overrides );
549
+		$sideloaded = wp_handle_sideload($file_data, $overrides);
550 550
 
551
-		if ( isset( $sideloaded['error'] ) ) {
552
-			@unlink( $tmpfname );
551
+		if (isset($sideloaded['error'])) {
552
+			@unlink($tmpfname);
553 553
 
554
-			return new WP_Error( 'rest_upload_sideload_error', $sideloaded['error'], array( 'status' => 500 ) );
554
+			return new WP_Error('rest_upload_sideload_error', $sideloaded['error'], array('status' => 500));
555 555
 		}
556 556
 
557 557
 		return $sideloaded;
@@ -587,41 +587,41 @@  discard block
 block discarded – undo
587 587
 	 * @param string[] $disposition_header List of Content-Disposition header values.
588 588
 	 * @return string|null Filename if available, or null if not found.
589 589
 	 */
590
-	public static function get_filename_from_disposition( $disposition_header ) {
590
+	public static function get_filename_from_disposition($disposition_header) {
591 591
 		// Get the filename.
592 592
 		$filename = null;
593 593
 
594
-		foreach ( $disposition_header as $value ) {
595
-			$value = trim( $value );
594
+		foreach ($disposition_header as $value) {
595
+			$value = trim($value);
596 596
 
597
-			if ( strpos( $value, ';' ) === false ) {
597
+			if (strpos($value, ';') === false) {
598 598
 				continue;
599 599
 			}
600 600
 
601
-			list( $type, $attr_parts ) = explode( ';', $value, 2 );
601
+			list($type, $attr_parts) = explode(';', $value, 2);
602 602
 
603
-			$attr_parts = explode( ';', $attr_parts );
603
+			$attr_parts = explode(';', $attr_parts);
604 604
 			$attributes = array();
605 605
 
606
-			foreach ( $attr_parts as $part ) {
607
-				if ( strpos( $part, '=' ) === false ) {
606
+			foreach ($attr_parts as $part) {
607
+				if (strpos($part, '=') === false) {
608 608
 					continue;
609 609
 				}
610 610
 
611
-				list( $key, $value ) = explode( '=', $part, 2 );
611
+				list($key, $value) = explode('=', $part, 2);
612 612
 
613
-				$attributes[ trim( $key ) ] = trim( $value );
613
+				$attributes[trim($key)] = trim($value);
614 614
 			}
615 615
 
616
-			if ( empty( $attributes['filename'] ) ) {
616
+			if (empty($attributes['filename'])) {
617 617
 				continue;
618 618
 			}
619 619
 
620
-			$filename = trim( $attributes['filename'] );
620
+			$filename = trim($attributes['filename']);
621 621
 
622 622
 			// Unquote quoted filename, but after trimming.
623
-			if ( substr( $filename, 0, 1 ) === '"' && substr( $filename, -1, 1 ) === '"' ) {
624
-				$filename = substr( $filename, 1, -1 );
623
+			if (substr($filename, 0, 1) === '"' && substr($filename, -1, 1) === '"') {
624
+				$filename = substr($filename, 1, -1);
625 625
 			}
626 626
 		}
627 627
 
@@ -639,19 +639,19 @@  discard block
 block discarded – undo
639 639
 	public function get_collection_params() {
640 640
 		$params = parent::get_collection_params();
641 641
 		$params['status']['default'] = 'inherit';
642
-		$params['status']['items']['enum'] = array( 'inherit', 'private', 'trash' );
642
+		$params['status']['items']['enum'] = array('inherit', 'private', 'trash');
643 643
 		$media_types = $this->get_media_types();
644 644
 
645 645
 		$params['media_type'] = array(
646 646
 			'default'           => null,
647
-			'description'       => __( 'Limit result set to attachments of a particular media type.' ),
647
+			'description'       => __('Limit result set to attachments of a particular media type.'),
648 648
 			'type'              => 'string',
649
-			'enum'              => array_keys( $media_types ),
649
+			'enum'              => array_keys($media_types),
650 650
 		);
651 651
 
652 652
 		$params['mime_type'] = array(
653 653
 			'default'     => null,
654
-			'description' => __( 'Limit result set to attachments of a particular MIME type.' ),
654
+			'description' => __('Limit result set to attachments of a particular MIME type.'),
655 655
 			'type'        => 'string',
656 656
 		);
657 657
 
@@ -669,12 +669,12 @@  discard block
 block discarded – undo
669 669
 	 * @param string          $parameter Additional parameter to pass for validation.
670 670
 	 * @return WP_Error|bool True if the user may query, WP_Error if not.
671 671
 	 */
672
-	public function validate_user_can_query_private_statuses( $value, $request, $parameter ) {
673
-		if ( 'inherit' === $value ) {
672
+	public function validate_user_can_query_private_statuses($value, $request, $parameter) {
673
+		if ('inherit' === $value) {
674 674
 			return true;
675 675
 		}
676 676
 
677
-		return parent::validate_user_can_query_private_statuses( $value, $request, $parameter );
677
+		return parent::validate_user_can_query_private_statuses($value, $request, $parameter);
678 678
 	}
679 679
 
680 680
 	/**
@@ -687,19 +687,19 @@  discard block
 block discarded – undo
687 687
 	 * @param array $headers HTTP headers from the request.
688 688
 	 * @return array|WP_Error Data from wp_handle_upload().
689 689
 	 */
690
-	protected function upload_from_file( $files, $headers ) {
691
-		if ( empty( $files ) ) {
692
-			return new WP_Error( 'rest_upload_no_data', __( 'No data supplied.' ), array( 'status' => 400 ) );
690
+	protected function upload_from_file($files, $headers) {
691
+		if (empty($files)) {
692
+			return new WP_Error('rest_upload_no_data', __('No data supplied.'), array('status' => 400));
693 693
 		}
694 694
 
695 695
 		// Verify hash, if given.
696
-		if ( ! empty( $headers['content_md5'] ) ) {
697
-			$content_md5 = array_shift( $headers['content_md5'] );
698
-			$expected    = trim( $content_md5 );
699
-			$actual      = md5_file( $files['file']['tmp_name'] );
696
+		if ( ! empty($headers['content_md5'])) {
697
+			$content_md5 = array_shift($headers['content_md5']);
698
+			$expected    = trim($content_md5);
699
+			$actual      = md5_file($files['file']['tmp_name']);
700 700
 
701
-			if ( $expected !== $actual ) {
702
-				return new WP_Error( 'rest_upload_hash_mismatch', __( 'Content hash did not match expected.' ), array( 'status' => 412 ) );
701
+			if ($expected !== $actual) {
702
+				return new WP_Error('rest_upload_hash_mismatch', __('Content hash did not match expected.'), array('status' => 412));
703 703
 			}
704 704
 		}
705 705
 
@@ -709,17 +709,17 @@  discard block
 block discarded – undo
709 709
 		);
710 710
 
711 711
 		// Bypasses is_uploaded_file() when running unit tests.
712
-		if ( defined( 'DIR_TESTDATA' ) && DIR_TESTDATA ) {
712
+		if (defined('DIR_TESTDATA') && DIR_TESTDATA) {
713 713
 			$overrides['action'] = 'wp_handle_mock_upload';
714 714
 		}
715 715
 
716 716
 		/** Include admin functions to get access to wp_handle_upload() */
717
-		require_once ABSPATH . 'wp-admin/includes/admin.php';
717
+		require_once ABSPATH.'wp-admin/includes/admin.php';
718 718
 
719
-		$file = wp_handle_upload( $files['file'], $overrides );
719
+		$file = wp_handle_upload($files['file'], $overrides);
720 720
 
721
-		if ( isset( $file['error'] ) ) {
722
-			return new WP_Error( 'rest_upload_unknown_error', $file['error'], array( 'status' => 500 ) );
721
+		if (isset($file['error'])) {
722
+			return new WP_Error('rest_upload_unknown_error', $file['error'], array('status' => 500));
723 723
 		}
724 724
 
725 725
 		return $file;
@@ -738,14 +738,14 @@  discard block
 block discarded – undo
738 738
 	protected function get_media_types() {
739 739
 		$media_types = array();
740 740
 
741
-		foreach ( get_allowed_mime_types() as $mime_type ) {
742
-			$parts = explode( '/', $mime_type );
741
+		foreach (get_allowed_mime_types() as $mime_type) {
742
+			$parts = explode('/', $mime_type);
743 743
 
744
-			if ( ! isset( $media_types[ $parts[0] ] ) ) {
745
-				$media_types[ $parts[0] ] = array();
744
+			if ( ! isset($media_types[$parts[0]])) {
745
+				$media_types[$parts[0]] = array();
746 746
 			}
747 747
 
748
-			$media_types[ $parts[0] ][] = $mime_type;
748
+			$media_types[$parts[0]][] = $mime_type;
749 749
 		}
750 750
 
751 751
 		return $media_types;
Please login to merge, or discard this patch.
src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1002,7 +1002,7 @@
 block discarded – undo
1002 1002
 	 * @since 4.7.0
1003 1003
 	 * @access protected
1004 1004
 	 *
1005
-	 * @param string|int $comment_approved comment status.
1005
+	 * @param string $comment_approved comment status.
1006 1006
 	 * @return string Comment status.
1007 1007
 	 */
1008 1008
 	protected function prepare_status_response( $comment_approved ) {
Please login to merge, or discard this patch.
Spacing   +418 added lines, -418 removed lines patch added patch discarded remove patch
@@ -46,59 +46,59 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	public function register_routes() {
48 48
 
49
-		register_rest_route( $this->namespace, '/' . $this->rest_base, array(
49
+		register_rest_route($this->namespace, '/'.$this->rest_base, array(
50 50
 			array(
51 51
 				'methods'   => WP_REST_Server::READABLE,
52
-				'callback'  => array( $this, 'get_items' ),
53
-				'permission_callback' => array( $this, 'get_items_permissions_check' ),
52
+				'callback'  => array($this, 'get_items'),
53
+				'permission_callback' => array($this, 'get_items_permissions_check'),
54 54
 				'args'      => $this->get_collection_params(),
55 55
 			),
56 56
 			array(
57 57
 				'methods'  => WP_REST_Server::CREATABLE,
58
-				'callback' => array( $this, 'create_item' ),
59
-				'permission_callback' => array( $this, 'create_item_permissions_check' ),
60
-				'args'     => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ),
58
+				'callback' => array($this, 'create_item'),
59
+				'permission_callback' => array($this, 'create_item_permissions_check'),
60
+				'args'     => $this->get_endpoint_args_for_item_schema(WP_REST_Server::CREATABLE),
61 61
 			),
62
-			'schema' => array( $this, 'get_public_item_schema' ),
63
-		) );
62
+			'schema' => array($this, 'get_public_item_schema'),
63
+		));
64 64
 
65
-		register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
65
+		register_rest_route($this->namespace, '/'.$this->rest_base.'/(?P<id>[\d]+)', array(
66 66
 			array(
67 67
 				'methods'  => WP_REST_Server::READABLE,
68
-				'callback' => array( $this, 'get_item' ),
69
-				'permission_callback' => array( $this, 'get_item_permissions_check' ),
68
+				'callback' => array($this, 'get_item'),
69
+				'permission_callback' => array($this, 'get_item_permissions_check'),
70 70
 				'args'     => array(
71
-					'context'          => $this->get_context_param( array( 'default' => 'view' ) ),
71
+					'context'          => $this->get_context_param(array('default' => 'view')),
72 72
 					'password' => array(
73
-						'description' => __( 'The password for the post if it is password protected.' ),
73
+						'description' => __('The password for the post if it is password protected.'),
74 74
 						'type'        => 'string',
75 75
 					),
76 76
 				),
77 77
 			),
78 78
 			array(
79 79
 				'methods'  => WP_REST_Server::EDITABLE,
80
-				'callback' => array( $this, 'update_item' ),
81
-				'permission_callback' => array( $this, 'update_item_permissions_check' ),
82
-				'args'     => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ),
80
+				'callback' => array($this, 'update_item'),
81
+				'permission_callback' => array($this, 'update_item_permissions_check'),
82
+				'args'     => $this->get_endpoint_args_for_item_schema(WP_REST_Server::EDITABLE),
83 83
 			),
84 84
 			array(
85 85
 				'methods'  => WP_REST_Server::DELETABLE,
86
-				'callback' => array( $this, 'delete_item' ),
87
-				'permission_callback' => array( $this, 'delete_item_permissions_check' ),
86
+				'callback' => array($this, 'delete_item'),
87
+				'permission_callback' => array($this, 'delete_item_permissions_check'),
88 88
 				'args'     => array(
89 89
 					'force'    => array(
90 90
 						'type'        => 'boolean',
91 91
 						'default'     => false,
92
-						'description' => __( 'Whether to bypass trash and force deletion.' ),
92
+						'description' => __('Whether to bypass trash and force deletion.'),
93 93
 					),
94 94
 					'password' => array(
95
-						'description' => __( 'The password for the post if it is password protected.' ),
95
+						'description' => __('The password for the post if it is password protected.'),
96 96
 						'type'        => 'string',
97 97
 					),
98 98
 				),
99 99
 			),
100
-			'schema' => array( $this, 'get_public_item_schema' ),
101
-		) );
100
+			'schema' => array($this, 'get_public_item_schema'),
101
+		));
102 102
 	}
103 103
 
104 104
 	/**
@@ -110,44 +110,44 @@  discard block
 block discarded – undo
110 110
 	 * @param WP_REST_Request $request Full details about the request.
111 111
 	 * @return WP_Error|bool True if the request has read access, error object otherwise.
112 112
 	 */
113
-	public function get_items_permissions_check( $request ) {
113
+	public function get_items_permissions_check($request) {
114 114
 
115
-		if ( ! empty( $request['post'] ) ) {
116
-			foreach ( (array) $request['post'] as $post_id ) {
117
-				$post = get_post( $post_id );
115
+		if ( ! empty($request['post'])) {
116
+			foreach ((array) $request['post'] as $post_id) {
117
+				$post = get_post($post_id);
118 118
 
119
-				if ( ! empty( $post_id ) && $post && ! $this->check_read_post_permission( $post, $request ) ) {
120
-					return new WP_Error( 'rest_cannot_read_post', __( 'Sorry, you are not allowed to read the post for this comment.' ), array( 'status' => rest_authorization_required_code() ) );
121
-				} elseif ( 0 === $post_id && ! current_user_can( 'moderate_comments' ) ) {
122
-					return new WP_Error( 'rest_cannot_read', __( 'Sorry, you are not allowed to read comments without a post.' ), array( 'status' => rest_authorization_required_code() ) );
119
+				if ( ! empty($post_id) && $post && ! $this->check_read_post_permission($post, $request)) {
120
+					return new WP_Error('rest_cannot_read_post', __('Sorry, you are not allowed to read the post for this comment.'), array('status' => rest_authorization_required_code()));
121
+				} elseif (0 === $post_id && ! current_user_can('moderate_comments')) {
122
+					return new WP_Error('rest_cannot_read', __('Sorry, you are not allowed to read comments without a post.'), array('status' => rest_authorization_required_code()));
123 123
 				}
124 124
 			}
125 125
 		}
126 126
 
127
-		if ( ! empty( $request['context'] ) && 'edit' === $request['context'] && ! current_user_can( 'moderate_comments' ) ) {
128
-			return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit comments.' ), array( 'status' => rest_authorization_required_code() ) );
127
+		if ( ! empty($request['context']) && 'edit' === $request['context'] && ! current_user_can('moderate_comments')) {
128
+			return new WP_Error('rest_forbidden_context', __('Sorry, you are not allowed to edit comments.'), array('status' => rest_authorization_required_code()));
129 129
 		}
130 130
 
131
-		if ( ! current_user_can( 'edit_posts' ) ) {
132
-			$protected_params = array( 'author', 'author_exclude', 'author_email', 'type', 'status' );
131
+		if ( ! current_user_can('edit_posts')) {
132
+			$protected_params = array('author', 'author_exclude', 'author_email', 'type', 'status');
133 133
 			$forbidden_params = array();
134 134
 
135
-			foreach ( $protected_params as $param ) {
136
-				if ( 'status' === $param ) {
137
-					if ( 'approve' !== $request[ $param ] ) {
135
+			foreach ($protected_params as $param) {
136
+				if ('status' === $param) {
137
+					if ('approve' !== $request[$param]) {
138 138
 						$forbidden_params[] = $param;
139 139
 					}
140
-				} elseif ( 'type' === $param ) {
141
-					if ( 'comment' !== $request[ $param ] ) {
140
+				} elseif ('type' === $param) {
141
+					if ('comment' !== $request[$param]) {
142 142
 						$forbidden_params[] = $param;
143 143
 					}
144
-				} elseif ( ! empty( $request[ $param ] ) ) {
144
+				} elseif ( ! empty($request[$param])) {
145 145
 					$forbidden_params[] = $param;
146 146
 				}
147 147
 			}
148 148
 
149
-			if ( ! empty( $forbidden_params ) ) {
150
-				return new WP_Error( 'rest_forbidden_param', sprintf( __( 'Query parameter not permitted: %s' ), implode( ', ', $forbidden_params ) ), array( 'status' => rest_authorization_required_code() ) );
149
+			if ( ! empty($forbidden_params)) {
150
+				return new WP_Error('rest_forbidden_param', sprintf(__('Query parameter not permitted: %s'), implode(', ', $forbidden_params)), array('status' => rest_authorization_required_code()));
151 151
 			}
152 152
 		}
153 153
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 	 * @param WP_REST_Request $request Full details about the request.
164 164
 	 * @return WP_Error|WP_REST_Response Response object on success, or error object on failure.
165 165
 	 */
166
-	public function get_items( $request ) {
166
+	public function get_items($request) {
167 167
 
168 168
 		// Retrieve the list of registered collection query parameters.
169 169
 		$registered = $this->get_collection_params();
@@ -197,21 +197,21 @@  discard block
 block discarded – undo
197 197
 		 * For each known parameter which is both registered and present in the request,
198 198
 		 * set the parameter's value on the query $prepared_args.
199 199
 		 */
200
-		foreach ( $parameter_mappings as $api_param => $wp_param ) {
201
-			if ( isset( $registered[ $api_param ], $request[ $api_param ] ) ) {
202
-				$prepared_args[ $wp_param ] = $request[ $api_param ];
200
+		foreach ($parameter_mappings as $api_param => $wp_param) {
201
+			if (isset($registered[$api_param], $request[$api_param])) {
202
+				$prepared_args[$wp_param] = $request[$api_param];
203 203
 			}
204 204
 		}
205 205
 
206 206
 		// Ensure certain parameter values default to empty strings.
207
-		foreach ( array( 'author_email', 'search' ) as $param ) {
208
-			if ( ! isset( $prepared_args[ $param ] ) ) {
209
-				$prepared_args[ $param ] = '';
207
+		foreach (array('author_email', 'search') as $param) {
208
+			if ( ! isset($prepared_args[$param])) {
209
+				$prepared_args[$param] = '';
210 210
 			}
211 211
 		}
212 212
 
213
-		if ( isset( $registered['orderby'] ) ) {
214
-			$prepared_args['orderby'] = $this->normalize_query_param( $request['orderby'] );
213
+		if (isset($registered['orderby'])) {
214
+			$prepared_args['orderby'] = $this->normalize_query_param($request['orderby']);
215 215
 		}
216 216
 
217 217
 		$prepared_args['no_found_rows'] = false;
@@ -219,17 +219,17 @@  discard block
 block discarded – undo
219 219
 		$prepared_args['date_query'] = array();
220 220
 
221 221
 		// Set before into date query. Date query must be specified as an array of an array.
222
-		if ( isset( $registered['before'], $request['before'] ) ) {
222
+		if (isset($registered['before'], $request['before'])) {
223 223
 			$prepared_args['date_query'][0]['before'] = $request['before'];
224 224
 		}
225 225
 
226 226
 		// Set after into date query. Date query must be specified as an array of an array.
227
-		if ( isset( $registered['after'], $request['after'] ) ) {
227
+		if (isset($registered['after'], $request['after'])) {
228 228
 			$prepared_args['date_query'][0]['after'] = $request['after'];
229 229
 		}
230 230
 
231
-		if ( isset( $registered['page'] ) && empty( $request['offset'] ) ) {
232
-			$prepared_args['offset'] = $prepared_args['number'] * ( absint( $request['page'] ) - 1 );
231
+		if (isset($registered['page']) && empty($request['offset'])) {
232
+			$prepared_args['offset'] = $prepared_args['number'] * (absint($request['page']) - 1);
233 233
 		}
234 234
 
235 235
 		/**
@@ -242,58 +242,58 @@  discard block
 block discarded – undo
242 242
 		 * @param array           $prepared_args Array of arguments for WP_Comment_Query.
243 243
 		 * @param WP_REST_Request $request       The current request.
244 244
 		 */
245
-		$prepared_args = apply_filters( 'rest_comment_query', $prepared_args, $request );
245
+		$prepared_args = apply_filters('rest_comment_query', $prepared_args, $request);
246 246
 
247 247
 		$query = new WP_Comment_Query;
248
-		$query_result = $query->query( $prepared_args );
248
+		$query_result = $query->query($prepared_args);
249 249
 
250 250
 		$comments = array();
251 251
 
252
-		foreach ( $query_result as $comment ) {
253
-			if ( ! $this->check_read_permission( $comment, $request ) ) {
252
+		foreach ($query_result as $comment) {
253
+			if ( ! $this->check_read_permission($comment, $request)) {
254 254
 				continue;
255 255
 			}
256 256
 
257
-			$data = $this->prepare_item_for_response( $comment, $request );
258
-			$comments[] = $this->prepare_response_for_collection( $data );
257
+			$data = $this->prepare_item_for_response($comment, $request);
258
+			$comments[] = $this->prepare_response_for_collection($data);
259 259
 		}
260 260
 
261 261
 		$total_comments = (int) $query->found_comments;
262 262
 		$max_pages      = (int) $query->max_num_pages;
263 263
 
264
-		if ( $total_comments < 1 ) {
264
+		if ($total_comments < 1) {
265 265
 			// Out-of-bounds, run the query again without LIMIT for total count.
266
-			unset( $prepared_args['number'], $prepared_args['offset'] );
266
+			unset($prepared_args['number'], $prepared_args['offset']);
267 267
 
268 268
 			$query = new WP_Comment_Query;
269 269
 			$prepared_args['count'] = true;
270 270
 
271
-			$total_comments = $query->query( $prepared_args );
272
-			$max_pages = ceil( $total_comments / $request['per_page'] );
271
+			$total_comments = $query->query($prepared_args);
272
+			$max_pages = ceil($total_comments / $request['per_page']);
273 273
 		}
274 274
 
275
-		$response = rest_ensure_response( $comments );
276
-		$response->header( 'X-WP-Total', $total_comments );
277
-		$response->header( 'X-WP-TotalPages', $max_pages );
275
+		$response = rest_ensure_response($comments);
276
+		$response->header('X-WP-Total', $total_comments);
277
+		$response->header('X-WP-TotalPages', $max_pages);
278 278
 
279
-		$base = add_query_arg( $request->get_query_params(), rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ) );
279
+		$base = add_query_arg($request->get_query_params(), rest_url(sprintf('%s/%s', $this->namespace, $this->rest_base)));
280 280
 
281
-		if ( $request['page'] > 1 ) {
281
+		if ($request['page'] > 1) {
282 282
 			$prev_page = $request['page'] - 1;
283 283
 
284
-			if ( $prev_page > $max_pages ) {
284
+			if ($prev_page > $max_pages) {
285 285
 				$prev_page = $max_pages;
286 286
 			}
287 287
 
288
-			$prev_link = add_query_arg( 'page', $prev_page, $base );
289
-			$response->link_header( 'prev', $prev_link );
288
+			$prev_link = add_query_arg('page', $prev_page, $base);
289
+			$response->link_header('prev', $prev_link);
290 290
 		}
291 291
 
292
-		if ( $max_pages > $request['page'] ) {
292
+		if ($max_pages > $request['page']) {
293 293
 			$next_page = $request['page'] + 1;
294
-			$next_link = add_query_arg( 'page', $next_page, $base );
294
+			$next_link = add_query_arg('page', $next_page, $base);
295 295
 
296
-			$response->link_header( 'next', $next_link );
296
+			$response->link_header('next', $next_link);
297 297
 		}
298 298
 
299 299
 		return $response;
@@ -308,27 +308,27 @@  discard block
 block discarded – undo
308 308
 	 * @param WP_REST_Request $request Full details about the request.
309 309
 	 * @return WP_Error|bool True if the request has read access for the item, error object otherwise.
310 310
 	 */
311
-	public function get_item_permissions_check( $request ) {
311
+	public function get_item_permissions_check($request) {
312 312
 		$id = (int) $request['id'];
313 313
 
314
-		$comment = get_comment( $id );
314
+		$comment = get_comment($id);
315 315
 
316
-		if ( ! $comment ) {
316
+		if ( ! $comment) {
317 317
 			return true;
318 318
 		}
319 319
 
320
-		if ( ! empty( $request['context'] ) && 'edit' === $request['context'] && ! current_user_can( 'moderate_comments' ) ) {
321
-			return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit comments.' ), array( 'status' => rest_authorization_required_code() ) );
320
+		if ( ! empty($request['context']) && 'edit' === $request['context'] && ! current_user_can('moderate_comments')) {
321
+			return new WP_Error('rest_forbidden_context', __('Sorry, you are not allowed to edit comments.'), array('status' => rest_authorization_required_code()));
322 322
 		}
323 323
 
324
-		$post = get_post( $comment->comment_post_ID );
324
+		$post = get_post($comment->comment_post_ID);
325 325
 
326
-		if ( ! $this->check_read_permission( $comment, $request ) ) {
327
-			return new WP_Error( 'rest_cannot_read', __( 'Sorry, you are not allowed to read this comment.' ), array( 'status' => rest_authorization_required_code() ) );
326
+		if ( ! $this->check_read_permission($comment, $request)) {
327
+			return new WP_Error('rest_cannot_read', __('Sorry, you are not allowed to read this comment.'), array('status' => rest_authorization_required_code()));
328 328
 		}
329 329
 
330
-		if ( $post && ! $this->check_read_post_permission( $post, $request ) ) {
331
-			return new WP_Error( 'rest_cannot_read_post', __( 'Sorry, you are not allowed to read the post for this comment.' ), array( 'status' => rest_authorization_required_code() ) );
330
+		if ($post && ! $this->check_read_post_permission($post, $request)) {
331
+			return new WP_Error('rest_cannot_read_post', __('Sorry, you are not allowed to read the post for this comment.'), array('status' => rest_authorization_required_code()));
332 332
 		}
333 333
 
334 334
 		return true;
@@ -343,23 +343,23 @@  discard block
 block discarded – undo
343 343
 	 * @param WP_REST_Request $request Full details about the request.
344 344
 	 * @return WP_Error|WP_REST_Response Response object on success, or error object on failure.
345 345
 	 */
346
-	public function get_item( $request ) {
346
+	public function get_item($request) {
347 347
 		$id = (int) $request['id'];
348 348
 
349
-		$comment = get_comment( $id );
350
-		if ( empty( $comment ) ) {
351
-			return new WP_Error( 'rest_comment_invalid_id', __( 'Invalid comment ID.' ), array( 'status' => 404 ) );
349
+		$comment = get_comment($id);
350
+		if (empty($comment)) {
351
+			return new WP_Error('rest_comment_invalid_id', __('Invalid comment ID.'), array('status' => 404));
352 352
 		}
353 353
 
354
-		if ( ! empty( $comment->comment_post_ID ) ) {
355
-			$post = get_post( $comment->comment_post_ID );
356
-			if ( empty( $post ) ) {
357
-				return new WP_Error( 'rest_post_invalid_id', __( 'Invalid post ID.' ), array( 'status' => 404 ) );
354
+		if ( ! empty($comment->comment_post_ID)) {
355
+			$post = get_post($comment->comment_post_ID);
356
+			if (empty($post)) {
357
+				return new WP_Error('rest_post_invalid_id', __('Invalid post ID.'), array('status' => 404));
358 358
 			}
359 359
 		}
360 360
 
361
-		$data = $this->prepare_item_for_response( $comment, $request );
362
-		$response = rest_ensure_response( $data );
361
+		$data = $this->prepare_item_for_response($comment, $request);
362
+		$response = rest_ensure_response($data);
363 363
 
364 364
 		return $response;
365 365
 	}
@@ -373,10 +373,10 @@  discard block
 block discarded – undo
373 373
 	 * @param WP_REST_Request $request Full details about the request.
374 374
 	 * @return WP_Error|bool True if the request has access to create items, error object otherwise.
375 375
 	 */
376
-	public function create_item_permissions_check( $request ) {
377
-		if ( ! is_user_logged_in() ) {
378
-			if ( get_option( 'comment_registration' ) ) {
379
-				return new WP_Error( 'rest_comment_login_required', __( 'Sorry, you must be logged in to comment.' ), array( 'status' => 401 ) );
376
+	public function create_item_permissions_check($request) {
377
+		if ( ! is_user_logged_in()) {
378
+			if (get_option('comment_registration')) {
379
+				return new WP_Error('rest_comment_login_required', __('Sorry, you must be logged in to comment.'), array('status' => 401));
380 380
 			}
381 381
 
382 382
 			/**
@@ -391,62 +391,62 @@  discard block
 block discarded – undo
391 391
 			 * @param WP_REST_Request $request Request used to generate the
392 392
 			 *                                 response.
393 393
 			 */
394
-			$allow_anonymous = apply_filters( 'rest_allow_anonymous_comments', false, $request );
395
-			if ( ! $allow_anonymous ) {
396
-				return new WP_Error( 'rest_comment_login_required', __( 'Sorry, you must be logged in to comment.' ), array( 'status' => 401 ) );
394
+			$allow_anonymous = apply_filters('rest_allow_anonymous_comments', false, $request);
395
+			if ( ! $allow_anonymous) {
396
+				return new WP_Error('rest_comment_login_required', __('Sorry, you must be logged in to comment.'), array('status' => 401));
397 397
 			}
398 398
 		}
399 399
 
400 400
 		// Limit who can set comment `author`, `author_ip` or `status` to anything other than the default.
401
-		if ( isset( $request['author'] ) && get_current_user_id() !== $request['author'] && ! current_user_can( 'moderate_comments' ) ) {
402
-			return new WP_Error( 'rest_comment_invalid_author',
401
+		if (isset($request['author']) && get_current_user_id() !== $request['author'] && ! current_user_can('moderate_comments')) {
402
+			return new WP_Error('rest_comment_invalid_author',
403 403
 				/* translators: %s: request parameter */
404
-				sprintf( __( "Sorry, you are not allowed to edit '%s' for comments." ), 'author' ),
405
-				array( 'status' => rest_authorization_required_code() )
404
+				sprintf(__("Sorry, you are not allowed to edit '%s' for comments."), 'author'),
405
+				array('status' => rest_authorization_required_code())
406 406
 			);
407 407
 		}
408 408
 
409
-		if ( isset( $request['author_ip'] ) && ! current_user_can( 'moderate_comments' ) ) {
410
-			if ( empty( $_SERVER['REMOTE_ADDR'] ) || $request['author_ip'] !== $_SERVER['REMOTE_ADDR'] ) {
411
-				return new WP_Error( 'rest_comment_invalid_author_ip',
409
+		if (isset($request['author_ip']) && ! current_user_can('moderate_comments')) {
410
+			if (empty($_SERVER['REMOTE_ADDR']) || $request['author_ip'] !== $_SERVER['REMOTE_ADDR']) {
411
+				return new WP_Error('rest_comment_invalid_author_ip',
412 412
 					/* translators: %s: request parameter */
413
-					sprintf( __( "Sorry, you are not allowed to edit '%s' for comments." ), 'author_ip' ),
414
-					array( 'status' => rest_authorization_required_code() )
413
+					sprintf(__("Sorry, you are not allowed to edit '%s' for comments."), 'author_ip'),
414
+					array('status' => rest_authorization_required_code())
415 415
 				);
416 416
 			}
417 417
 		}
418 418
 
419
-		if ( isset( $request['status'] ) && ! current_user_can( 'moderate_comments' ) ) {
420
-			return new WP_Error( 'rest_comment_invalid_status',
419
+		if (isset($request['status']) && ! current_user_can('moderate_comments')) {
420
+			return new WP_Error('rest_comment_invalid_status',
421 421
 				/* translators: %s: request parameter */
422
-				sprintf( __( "Sorry, you are not allowed to edit '%s' for comments." ), 'status' ),
423
-				array( 'status' => rest_authorization_required_code() )
422
+				sprintf(__("Sorry, you are not allowed to edit '%s' for comments."), 'status'),
423
+				array('status' => rest_authorization_required_code())
424 424
 			);
425 425
 		}
426 426
 
427
-		if ( empty( $request['post'] ) ) {
428
-			return new WP_Error( 'rest_comment_invalid_post_id', __( 'Sorry, you are not allowed to create this comment without a post.' ), array( 'status' => 403 ) );
427
+		if (empty($request['post'])) {
428
+			return new WP_Error('rest_comment_invalid_post_id', __('Sorry, you are not allowed to create this comment without a post.'), array('status' => 403));
429 429
 		}
430 430
 
431
-		$post = get_post( (int) $request['post'] );
432
-		if ( ! $post ) {
433
-			return new WP_Error( 'rest_comment_invalid_post_id', __( 'Sorry, you are not allowed to create this comment without a post.' ), array( 'status' => 403 ) );
431
+		$post = get_post((int) $request['post']);
432
+		if ( ! $post) {
433
+			return new WP_Error('rest_comment_invalid_post_id', __('Sorry, you are not allowed to create this comment without a post.'), array('status' => 403));
434 434
 		}
435 435
 
436
-		if ( 'draft' === $post->post_status ) {
437
-			return new WP_Error( 'rest_comment_draft_post', __( 'Sorry, you are not allowed to create a comment on this post.' ), array( 'status' => 403 ) );
436
+		if ('draft' === $post->post_status) {
437
+			return new WP_Error('rest_comment_draft_post', __('Sorry, you are not allowed to create a comment on this post.'), array('status' => 403));
438 438
 		}
439 439
 
440
-		if ( 'trash' === $post->post_status ) {
441
-			return new WP_Error( 'rest_comment_trash_post', __( 'Sorry, you are not allowed to create a comment on this post.' ), array( 'status' => 403 ) );
440
+		if ('trash' === $post->post_status) {
441
+			return new WP_Error('rest_comment_trash_post', __('Sorry, you are not allowed to create a comment on this post.'), array('status' => 403));
442 442
 		}
443 443
 
444
-		if ( ! $this->check_read_post_permission( $post, $request ) ) {
445
-			return new WP_Error( 'rest_cannot_read_post', __( 'Sorry, you are not allowed to read the post for this comment.' ), array( 'status' => rest_authorization_required_code() ) );
444
+		if ( ! $this->check_read_post_permission($post, $request)) {
445
+			return new WP_Error('rest_cannot_read_post', __('Sorry, you are not allowed to read the post for this comment.'), array('status' => rest_authorization_required_code()));
446 446
 		}
447 447
 
448
-		if ( ! comments_open( $post->ID ) ) {
449
-			return new WP_Error( 'rest_comment_closed', __( 'Sorry, comments are closed for this item.' ), array( 'status' => 403 ) );
448
+		if ( ! comments_open($post->ID)) {
449
+			return new WP_Error('rest_comment_closed', __('Sorry, comments are closed for this item.'), array('status' => 403));
450 450
 		}
451 451
 
452 452
 		return true;
@@ -461,18 +461,18 @@  discard block
 block discarded – undo
461 461
 	 * @param WP_REST_Request $request Full details about the request.
462 462
 	 * @return WP_Error|WP_REST_Response Response object on success, or error object on failure.
463 463
 	 */
464
-	public function create_item( $request ) {
465
-		if ( ! empty( $request['id'] ) ) {
466
-			return new WP_Error( 'rest_comment_exists', __( 'Cannot create existing comment.' ), array( 'status' => 400 ) );
464
+	public function create_item($request) {
465
+		if ( ! empty($request['id'])) {
466
+			return new WP_Error('rest_comment_exists', __('Cannot create existing comment.'), array('status' => 400));
467 467
 		}
468 468
 
469 469
 		// Do not allow comments to be created with a non-default type.
470
-		if ( ! empty( $request['type'] ) && 'comment' !== $request['type'] ) {
471
-			return new WP_Error( 'rest_invalid_comment_type', __( 'Cannot create a comment with that type.' ), array( 'status' => 400 ) );
470
+		if ( ! empty($request['type']) && 'comment' !== $request['type']) {
471
+			return new WP_Error('rest_invalid_comment_type', __('Cannot create a comment with that type.'), array('status' => 400));
472 472
 		}
473 473
 
474
-		$prepared_comment = $this->prepare_item_for_database( $request );
475
-		if ( is_wp_error( $prepared_comment ) ) {
474
+		$prepared_comment = $this->prepare_item_for_database($request);
475
+		if (is_wp_error($prepared_comment)) {
476 476
 			return $prepared_comment;
477 477
 		}
478 478
 
@@ -482,22 +482,22 @@  discard block
 block discarded – undo
482 482
 		 * Do not allow a comment to be created with missing or empty
483 483
 		 * comment_content. See wp_handle_comment_submission().
484 484
 		 */
485
-		if ( empty( $prepared_comment['comment_content'] ) ) {
486
-			return new WP_Error( 'rest_comment_content_invalid', __( 'Invalid comment content.' ), array( 'status' => 400 ) );
485
+		if (empty($prepared_comment['comment_content'])) {
486
+			return new WP_Error('rest_comment_content_invalid', __('Invalid comment content.'), array('status' => 400));
487 487
 		}
488 488
 
489 489
 		// Setting remaining values before wp_insert_comment so we can use wp_allow_comment().
490
-		if ( ! isset( $prepared_comment['comment_date_gmt'] ) ) {
491
-			$prepared_comment['comment_date_gmt'] = current_time( 'mysql', true );
490
+		if ( ! isset($prepared_comment['comment_date_gmt'])) {
491
+			$prepared_comment['comment_date_gmt'] = current_time('mysql', true);
492 492
 		}
493 493
 
494 494
 		// Set author data if the user's logged in.
495
-		$missing_author = empty( $prepared_comment['user_id'] )
496
-			&& empty( $prepared_comment['comment_author'] )
497
-			&& empty( $prepared_comment['comment_author_email'] )
498
-			&& empty( $prepared_comment['comment_author_url'] );
495
+		$missing_author = empty($prepared_comment['user_id'])
496
+			&& empty($prepared_comment['comment_author'])
497
+			&& empty($prepared_comment['comment_author_email'])
498
+			&& empty($prepared_comment['comment_author_url']);
499 499
 
500
-		if ( is_user_logged_in() && $missing_author ) {
500
+		if (is_user_logged_in() && $missing_author) {
501 501
 			$user = wp_get_current_user();
502 502
 
503 503
 			$prepared_comment['user_id'] = $user->ID;
@@ -507,42 +507,42 @@  discard block
 block discarded – undo
507 507
 		}
508 508
 
509 509
 		// Honor the discussion setting that requires a name and email address of the comment author.
510
-		if ( get_option( 'require_name_email' ) ) {
511
-			if ( empty( $prepared_comment['comment_author'] ) || empty( $prepared_comment['comment_author_email'] ) ) {
512
-				return new WP_Error( 'rest_comment_author_data_required', __( 'Creating a comment requires valid author name and email values.' ), array( 'status' => 400 ) );
510
+		if (get_option('require_name_email')) {
511
+			if (empty($prepared_comment['comment_author']) || empty($prepared_comment['comment_author_email'])) {
512
+				return new WP_Error('rest_comment_author_data_required', __('Creating a comment requires valid author name and email values.'), array('status' => 400));
513 513
 			}
514 514
 		}
515 515
 
516
-		if ( ! isset( $prepared_comment['comment_author_email'] ) ) {
516
+		if ( ! isset($prepared_comment['comment_author_email'])) {
517 517
 			$prepared_comment['comment_author_email'] = '';
518 518
 		}
519 519
 
520
-		if ( ! isset( $prepared_comment['comment_author_url'] ) ) {
520
+		if ( ! isset($prepared_comment['comment_author_url'])) {
521 521
 			$prepared_comment['comment_author_url'] = '';
522 522
 		}
523 523
 
524
-		if ( ! isset( $prepared_comment['comment_agent'] ) ) {
524
+		if ( ! isset($prepared_comment['comment_agent'])) {
525 525
 			$prepared_comment['comment_agent'] = '';
526 526
 		}
527 527
 
528
-		$check_comment_lengths = wp_check_comment_data_max_lengths( $prepared_comment );
529
-		if ( is_wp_error( $check_comment_lengths ) ) {
528
+		$check_comment_lengths = wp_check_comment_data_max_lengths($prepared_comment);
529
+		if (is_wp_error($check_comment_lengths)) {
530 530
 			$error_code = $check_comment_lengths->get_error_code();
531
-			return new WP_Error( $error_code, __( 'Comment field exceeds maximum length allowed.' ), array( 'status' => 400 ) );
531
+			return new WP_Error($error_code, __('Comment field exceeds maximum length allowed.'), array('status' => 400));
532 532
 		}
533 533
 
534
-		$prepared_comment['comment_approved'] = wp_allow_comment( $prepared_comment, true );
534
+		$prepared_comment['comment_approved'] = wp_allow_comment($prepared_comment, true);
535 535
 
536
-		if ( is_wp_error( $prepared_comment['comment_approved'] ) ) {
536
+		if (is_wp_error($prepared_comment['comment_approved'])) {
537 537
 			$error_code    = $prepared_comment['comment_approved']->get_error_code();
538 538
 			$error_message = $prepared_comment['comment_approved']->get_error_message();
539 539
 
540
-			if ( 'comment_duplicate' === $error_code ) {
541
-				return new WP_Error( $error_code, $error_message, array( 'status' => 409 ) );
540
+			if ('comment_duplicate' === $error_code) {
541
+				return new WP_Error($error_code, $error_message, array('status' => 409));
542 542
 			}
543 543
 
544
-			if ( 'comment_flood' === $error_code ) {
545
-				return new WP_Error( $error_code, $error_message, array( 'status' => 400 ) );
544
+			if ('comment_flood' === $error_code) {
545
+				return new WP_Error($error_code, $error_message, array('status' => 400));
546 546
 			}
547 547
 
548 548
 			return $prepared_comment['comment_approved'];
@@ -558,19 +558,19 @@  discard block
 block discarded – undo
558 558
 		 * @param array           $prepared_comment The prepared comment data for wp_insert_comment().
559 559
 		 * @param WP_REST_Request $request          Request used to insert the comment.
560 560
 		 */
561
-		$prepared_comment = apply_filters( 'rest_pre_insert_comment', $prepared_comment, $request );
561
+		$prepared_comment = apply_filters('rest_pre_insert_comment', $prepared_comment, $request);
562 562
 
563
-		$comment_id = wp_insert_comment( wp_filter_comment( wp_slash( (array) $prepared_comment ) ) );
563
+		$comment_id = wp_insert_comment(wp_filter_comment(wp_slash((array) $prepared_comment)));
564 564
 
565
-		if ( ! $comment_id ) {
566
-			return new WP_Error( 'rest_comment_failed_create', __( 'Creating comment failed.' ), array( 'status' => 500 ) );
565
+		if ( ! $comment_id) {
566
+			return new WP_Error('rest_comment_failed_create', __('Creating comment failed.'), array('status' => 500));
567 567
 		}
568 568
 
569
-		if ( isset( $request['status'] ) ) {
570
-			$this->handle_status_param( $request['status'], $comment_id );
569
+		if (isset($request['status'])) {
570
+			$this->handle_status_param($request['status'], $comment_id);
571 571
 		}
572 572
 
573
-		$comment = get_comment( $comment_id );
573
+		$comment = get_comment($comment_id);
574 574
 
575 575
 		/**
576 576
 		 * Fires after a comment is created or updated via the REST API.
@@ -582,33 +582,33 @@  discard block
 block discarded – undo
582 582
 		 * @param bool            $creating True when creating a comment, false
583 583
 		 *                                  when updating.
584 584
 		 */
585
-		do_action( 'rest_insert_comment', $comment, $request, true );
585
+		do_action('rest_insert_comment', $comment, $request, true);
586 586
 
587 587
 		$schema = $this->get_item_schema();
588 588
 
589
-		if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) {
590
-			$meta_update = $this->meta->update_value( $request['meta'], $comment_id );
589
+		if ( ! empty($schema['properties']['meta']) && isset($request['meta'])) {
590
+			$meta_update = $this->meta->update_value($request['meta'], $comment_id);
591 591
 
592
-			if ( is_wp_error( $meta_update ) ) {
592
+			if (is_wp_error($meta_update)) {
593 593
 				return $meta_update;
594 594
 			}
595 595
 		}
596 596
 
597
-		$fields_update = $this->update_additional_fields_for_object( $comment, $request );
597
+		$fields_update = $this->update_additional_fields_for_object($comment, $request);
598 598
 
599
-		if ( is_wp_error( $fields_update ) ) {
599
+		if (is_wp_error($fields_update)) {
600 600
 			return $fields_update;
601 601
 		}
602 602
 
603
-		$context = current_user_can( 'moderate_comments' ) ? 'edit' : 'view';
603
+		$context = current_user_can('moderate_comments') ? 'edit' : 'view';
604 604
 
605
-		$request->set_param( 'context', $context );
605
+		$request->set_param('context', $context);
606 606
 
607
-		$response = $this->prepare_item_for_response( $comment, $request );
608
-		$response = rest_ensure_response( $response );
607
+		$response = $this->prepare_item_for_response($comment, $request);
608
+		$response = rest_ensure_response($response);
609 609
 
610
-		$response->set_status( 201 );
611
-		$response->header( 'Location', rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $comment_id ) ) );
610
+		$response->set_status(201);
611
+		$response->header('Location', rest_url(sprintf('%s/%s/%d', $this->namespace, $this->rest_base, $comment_id)));
612 612
 
613 613
 
614 614
 		return $response;
@@ -623,14 +623,14 @@  discard block
 block discarded – undo
623 623
 	 * @param WP_REST_Request $request Full details about the request.
624 624
 	 * @return WP_Error|bool True if the request has access to update the item, error object otherwise.
625 625
 	 */
626
-	public function update_item_permissions_check( $request ) {
626
+	public function update_item_permissions_check($request) {
627 627
 
628 628
 		$id = (int) $request['id'];
629 629
 
630
-		$comment = get_comment( $id );
630
+		$comment = get_comment($id);
631 631
 
632
-		if ( $comment && ! $this->check_edit_permission( $comment ) ) {
633
-			return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to edit this comment.' ), array( 'status' => rest_authorization_required_code() ) );
632
+		if ($comment && ! $this->check_edit_permission($comment)) {
633
+			return new WP_Error('rest_cannot_edit', __('Sorry, you are not allowed to edit this comment.'), array('status' => rest_authorization_required_code()));
634 634
 		}
635 635
 
636 636
 		return true;
@@ -645,93 +645,93 @@  discard block
 block discarded – undo
645 645
 	 * @param WP_REST_Request $request Full details about the request.
646 646
 	 * @return WP_Error|WP_REST_Response Response object on success, or error object on failure.
647 647
 	 */
648
-	public function update_item( $request ) {
648
+	public function update_item($request) {
649 649
 		$id = (int) $request['id'];
650 650
 
651
-		$comment = get_comment( $id );
651
+		$comment = get_comment($id);
652 652
 
653
-		if ( empty( $comment ) ) {
654
-			return new WP_Error( 'rest_comment_invalid_id', __( 'Invalid comment ID.' ), array( 'status' => 404 ) );
653
+		if (empty($comment)) {
654
+			return new WP_Error('rest_comment_invalid_id', __('Invalid comment ID.'), array('status' => 404));
655 655
 		}
656 656
 
657
-		if ( isset( $request['type'] ) && get_comment_type( $id ) !== $request['type'] ) {
658
-			return new WP_Error( 'rest_comment_invalid_type', __( 'Sorry, you are not allowed to change the comment type.' ), array( 'status' => 404 ) );
657
+		if (isset($request['type']) && get_comment_type($id) !== $request['type']) {
658
+			return new WP_Error('rest_comment_invalid_type', __('Sorry, you are not allowed to change the comment type.'), array('status' => 404));
659 659
 		}
660 660
 
661
-		$prepared_args = $this->prepare_item_for_database( $request );
661
+		$prepared_args = $this->prepare_item_for_database($request);
662 662
 
663
-		if ( is_wp_error( $prepared_args ) ) {
663
+		if (is_wp_error($prepared_args)) {
664 664
 			return $prepared_args;
665 665
 		}
666 666
 
667
-		if ( ! empty( $prepared_args['comment_post_ID'] ) ) {
668
-			$post = get_post( $prepared_args['comment_post_ID'] );
669
-			if ( empty( $post ) ) {
670
-				return new WP_Error( 'rest_comment_invalid_post_id', __( 'Invalid post ID.' ), array( 'status' => 403 ) );
667
+		if ( ! empty($prepared_args['comment_post_ID'])) {
668
+			$post = get_post($prepared_args['comment_post_ID']);
669
+			if (empty($post)) {
670
+				return new WP_Error('rest_comment_invalid_post_id', __('Invalid post ID.'), array('status' => 403));
671 671
 			}
672 672
 		}
673 673
 
674
-		if ( empty( $prepared_args ) && isset( $request['status'] ) ) {
674
+		if (empty($prepared_args) && isset($request['status'])) {
675 675
 			// Only the comment status is being changed.
676
-			$change = $this->handle_status_param( $request['status'], $id );
676
+			$change = $this->handle_status_param($request['status'], $id);
677 677
 
678
-			if ( ! $change ) {
679
-				return new WP_Error( 'rest_comment_failed_edit', __( 'Updating comment status failed.' ), array( 'status' => 500 ) );
678
+			if ( ! $change) {
679
+				return new WP_Error('rest_comment_failed_edit', __('Updating comment status failed.'), array('status' => 500));
680 680
 			}
681
-		} elseif ( ! empty( $prepared_args ) ) {
682
-			if ( is_wp_error( $prepared_args ) ) {
681
+		} elseif ( ! empty($prepared_args)) {
682
+			if (is_wp_error($prepared_args)) {
683 683
 				return $prepared_args;
684 684
 			}
685 685
 
686
-			if ( isset( $prepared_args['comment_content'] ) && empty( $prepared_args['comment_content'] ) ) {
687
-				return new WP_Error( 'rest_comment_content_invalid', __( 'Invalid comment content.' ), array( 'status' => 400 ) );
686
+			if (isset($prepared_args['comment_content']) && empty($prepared_args['comment_content'])) {
687
+				return new WP_Error('rest_comment_content_invalid', __('Invalid comment content.'), array('status' => 400));
688 688
 			}
689 689
 
690 690
 			$prepared_args['comment_ID'] = $id;
691 691
 
692
-			$check_comment_lengths = wp_check_comment_data_max_lengths( $prepared_args );
693
-			if ( is_wp_error( $check_comment_lengths ) ) {
692
+			$check_comment_lengths = wp_check_comment_data_max_lengths($prepared_args);
693
+			if (is_wp_error($check_comment_lengths)) {
694 694
 				$error_code = $check_comment_lengths->get_error_code();
695
-				return new WP_Error( $error_code, __( 'Comment field exceeds maximum length allowed.' ), array( 'status' => 400 ) );
695
+				return new WP_Error($error_code, __('Comment field exceeds maximum length allowed.'), array('status' => 400));
696 696
 			}
697 697
 
698
-			$updated = wp_update_comment( wp_slash( (array) $prepared_args ) );
698
+			$updated = wp_update_comment(wp_slash((array) $prepared_args));
699 699
 
700
-			if ( false === $updated ) {
701
-				return new WP_Error( 'rest_comment_failed_edit', __( 'Updating comment failed.' ), array( 'status' => 500 ) );
700
+			if (false === $updated) {
701
+				return new WP_Error('rest_comment_failed_edit', __('Updating comment failed.'), array('status' => 500));
702 702
 			}
703 703
 
704
-			if ( isset( $request['status'] ) ) {
705
-				$this->handle_status_param( $request['status'], $id );
704
+			if (isset($request['status'])) {
705
+				$this->handle_status_param($request['status'], $id);
706 706
 			}
707 707
 		}
708 708
 
709
-		$comment = get_comment( $id );
709
+		$comment = get_comment($id);
710 710
 
711 711
 		/** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php */
712
-		do_action( 'rest_insert_comment', $comment, $request, false );
712
+		do_action('rest_insert_comment', $comment, $request, false);
713 713
 
714 714
 		$schema = $this->get_item_schema();
715 715
 
716
-		if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) {
717
-			$meta_update = $this->meta->update_value( $request['meta'], $id );
716
+		if ( ! empty($schema['properties']['meta']) && isset($request['meta'])) {
717
+			$meta_update = $this->meta->update_value($request['meta'], $id);
718 718
 
719
-			if ( is_wp_error( $meta_update ) ) {
719
+			if (is_wp_error($meta_update)) {
720 720
 				return $meta_update;
721 721
 			}
722 722
 		}
723 723
 
724
-		$fields_update = $this->update_additional_fields_for_object( $comment, $request );
724
+		$fields_update = $this->update_additional_fields_for_object($comment, $request);
725 725
 
726
-		if ( is_wp_error( $fields_update ) ) {
726
+		if (is_wp_error($fields_update)) {
727 727
 			return $fields_update;
728 728
 		}
729 729
 
730
-		$request->set_param( 'context', 'edit' );
730
+		$request->set_param('context', 'edit');
731 731
 
732
-		$response = $this->prepare_item_for_response( $comment, $request );
732
+		$response = $this->prepare_item_for_response($comment, $request);
733 733
 
734
-		return rest_ensure_response( $response );
734
+		return rest_ensure_response($response);
735 735
 	}
736 736
 
737 737
 	/**
@@ -743,16 +743,16 @@  discard block
 block discarded – undo
743 743
 	 * @param WP_REST_Request $request Full details about the request.
744 744
 	 * @return WP_Error|bool True if the request has access to delete the item, error object otherwise.
745 745
 	 */
746
-	public function delete_item_permissions_check( $request ) {
746
+	public function delete_item_permissions_check($request) {
747 747
 		$id      = (int) $request['id'];
748
-		$comment = get_comment( $id );
748
+		$comment = get_comment($id);
749 749
 
750
-		if ( ! $comment ) {
751
-			return new WP_Error( 'rest_comment_invalid_id', __( 'Invalid comment ID.' ), array( 'status' => 404 ) );
750
+		if ( ! $comment) {
751
+			return new WP_Error('rest_comment_invalid_id', __('Invalid comment ID.'), array('status' => 404));
752 752
 		}
753 753
 
754
-		if ( ! $this->check_edit_permission( $comment ) ) {
755
-			return new WP_Error( 'rest_cannot_delete', __( 'Sorry, you are not allowed to delete this comment.' ), array( 'status' => rest_authorization_required_code() ) );
754
+		if ( ! $this->check_edit_permission($comment)) {
755
+			return new WP_Error('rest_cannot_delete', __('Sorry, you are not allowed to delete this comment.'), array('status' => rest_authorization_required_code()));
756 756
 		}
757 757
 		return true;
758 758
 	}
@@ -766,14 +766,14 @@  discard block
 block discarded – undo
766 766
 	 * @param WP_REST_Request $request Full details about the request.
767 767
 	 * @return WP_Error|WP_REST_Response Response object on success, or error object on failure.
768 768
 	 */
769
-	public function delete_item( $request ) {
769
+	public function delete_item($request) {
770 770
 		$id    = (int) $request['id'];
771
-		$force = isset( $request['force'] ) ? (bool) $request['force'] : false;
771
+		$force = isset($request['force']) ? (bool) $request['force'] : false;
772 772
 
773
-		$comment = get_comment( $id );
773
+		$comment = get_comment($id);
774 774
 
775
-		if ( empty( $comment ) ) {
776
-			return new WP_Error( 'rest_comment_invalid_id', __( 'Invalid comment ID.' ), array( 'status' => 404 ) );
775
+		if (empty($comment)) {
776
+			return new WP_Error('rest_comment_invalid_id', __('Invalid comment ID.'), array('status' => 404));
777 777
 		}
778 778
 
779 779
 		/**
@@ -786,32 +786,32 @@  discard block
 block discarded – undo
786 786
 		 * @param bool    $supports_trash Whether the post type support trashing.
787 787
 		 * @param WP_Post $comment        The comment object being considered for trashing support.
788 788
 		 */
789
-		$supports_trash = apply_filters( 'rest_comment_trashable', ( EMPTY_TRASH_DAYS > 0 ), $comment );
789
+		$supports_trash = apply_filters('rest_comment_trashable', (EMPTY_TRASH_DAYS > 0), $comment);
790 790
 
791
-		$request->set_param( 'context', 'edit' );
791
+		$request->set_param('context', 'edit');
792 792
 
793
-		if ( $force ) {
794
-			$previous = $this->prepare_item_for_response( $comment, $request );
795
-			$result = wp_delete_comment( $comment->comment_ID, true );
793
+		if ($force) {
794
+			$previous = $this->prepare_item_for_response($comment, $request);
795
+			$result = wp_delete_comment($comment->comment_ID, true);
796 796
 			$response = new WP_REST_Response();
797
-			$response->set_data( array( 'deleted' => true, 'previous' => $previous->get_data() ) );
797
+			$response->set_data(array('deleted' => true, 'previous' => $previous->get_data()));
798 798
 		} else {
799 799
 			// If this type doesn't support trashing, error out.
800
-			if ( ! $supports_trash ) {
801
-				return new WP_Error( 'rest_trash_not_supported', __( 'The comment does not support trashing. Set force=true to delete.' ), array( 'status' => 501 ) );
800
+			if ( ! $supports_trash) {
801
+				return new WP_Error('rest_trash_not_supported', __('The comment does not support trashing. Set force=true to delete.'), array('status' => 501));
802 802
 			}
803 803
 
804
-			if ( 'trash' === $comment->comment_approved ) {
805
-				return new WP_Error( 'rest_already_trashed', __( 'The comment has already been trashed.' ), array( 'status' => 410 ) );
804
+			if ('trash' === $comment->comment_approved) {
805
+				return new WP_Error('rest_already_trashed', __('The comment has already been trashed.'), array('status' => 410));
806 806
 			}
807 807
 
808
-			$result = wp_trash_comment( $comment->comment_ID );
809
-			$comment = get_comment( $comment->comment_ID );
810
-			$response = $this->prepare_item_for_response( $comment, $request );
808
+			$result = wp_trash_comment($comment->comment_ID);
809
+			$comment = get_comment($comment->comment_ID);
810
+			$response = $this->prepare_item_for_response($comment, $request);
811 811
 		}
812 812
 
813
-		if ( ! $result ) {
814
-			return new WP_Error( 'rest_cannot_delete', __( 'The comment cannot be deleted.' ), array( 'status' => 500 ) );
813
+		if ( ! $result) {
814
+			return new WP_Error('rest_cannot_delete', __('The comment cannot be deleted.'), array('status' => 500));
815 815
 		}
816 816
 
817 817
 		/**
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
 		 * @param WP_REST_Response $response The response returned from the API.
824 824
 		 * @param WP_REST_Request  $request  The request sent to the API.
825 825
 		 */
826
-		do_action( 'rest_delete_comment', $comment, $response, $request );
826
+		do_action('rest_delete_comment', $comment, $response, $request);
827 827
 
828 828
 		return $response;
829 829
 	}
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
 	 * @param WP_REST_Request $request Request object.
839 839
 	 * @return WP_REST_Response Response object.
840 840
 	 */
841
-	public function prepare_item_for_response( $comment, $request ) {
841
+	public function prepare_item_for_response($comment, $request) {
842 842
 		$data = array(
843 843
 			'id'                 => (int) $comment->comment_ID,
844 844
 			'post'               => (int) $comment->comment_post_ID,
@@ -849,36 +849,36 @@  discard block
 block discarded – undo
849 849
 			'author_url'         => $comment->comment_author_url,
850 850
 			'author_ip'          => $comment->comment_author_IP,
851 851
 			'author_user_agent'  => $comment->comment_agent,
852
-			'date'               => mysql_to_rfc3339( $comment->comment_date ),
853
-			'date_gmt'           => mysql_to_rfc3339( $comment->comment_date_gmt ),
852
+			'date'               => mysql_to_rfc3339($comment->comment_date),
853
+			'date_gmt'           => mysql_to_rfc3339($comment->comment_date_gmt),
854 854
 			'content'            => array(
855 855
 				/** This filter is documented in wp-includes/comment-template.php */
856
-				'rendered' => apply_filters( 'comment_text', $comment->comment_content, $comment ),
856
+				'rendered' => apply_filters('comment_text', $comment->comment_content, $comment),
857 857
 				'raw'      => $comment->comment_content,
858 858
 			),
859
-			'link'               => get_comment_link( $comment ),
860
-			'status'             => $this->prepare_status_response( $comment->comment_approved ),
861
-			'type'               => get_comment_type( $comment->comment_ID ),
859
+			'link'               => get_comment_link($comment),
860
+			'status'             => $this->prepare_status_response($comment->comment_approved),
861
+			'type'               => get_comment_type($comment->comment_ID),
862 862
 		);
863 863
 
864 864
 		$schema = $this->get_item_schema();
865 865
 
866
-		if ( ! empty( $schema['properties']['author_avatar_urls'] ) ) {
867
-			$data['author_avatar_urls'] = rest_get_avatar_urls( $comment->comment_author_email );
866
+		if ( ! empty($schema['properties']['author_avatar_urls'])) {
867
+			$data['author_avatar_urls'] = rest_get_avatar_urls($comment->comment_author_email);
868 868
 		}
869 869
 
870
-		if ( ! empty( $schema['properties']['meta'] ) ) {
871
-			$data['meta'] = $this->meta->get_value( $comment->comment_ID, $request );
870
+		if ( ! empty($schema['properties']['meta'])) {
871
+			$data['meta'] = $this->meta->get_value($comment->comment_ID, $request);
872 872
 		}
873 873
 
874
-		$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
875
-		$data    = $this->add_additional_fields_to_object( $data, $request );
876
-		$data    = $this->filter_response_by_context( $data, $context );
874
+		$context = ! empty($request['context']) ? $request['context'] : 'view';
875
+		$data    = $this->add_additional_fields_to_object($data, $request);
876
+		$data    = $this->filter_response_by_context($data, $context);
877 877
 
878 878
 		// Wrap the data in a response object.
879
-		$response = rest_ensure_response( $data );
879
+		$response = rest_ensure_response($data);
880 880
 
881
-		$response->add_links( $this->prepare_links( $comment ) );
881
+		$response->add_links($this->prepare_links($comment));
882 882
 
883 883
 		/**
884 884
 		 * Filters a comment returned from the API.
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
 		 * @param WP_Comment        $comment  The original comment object.
892 892
 		 * @param WP_REST_Request   $request  Request used to generate the response.
893 893
 		 */
894
-		return apply_filters( 'rest_prepare_comment', $response, $comment, $request );
894
+		return apply_filters('rest_prepare_comment', $response, $comment, $request);
895 895
 	}
896 896
 
897 897
 	/**
@@ -903,57 +903,57 @@  discard block
 block discarded – undo
903 903
 	 * @param WP_Comment $comment Comment object.
904 904
 	 * @return array Links for the given comment.
905 905
 	 */
906
-	protected function prepare_links( $comment ) {
906
+	protected function prepare_links($comment) {
907 907
 		$links = array(
908 908
 			'self' => array(
909
-				'href' => rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $comment->comment_ID ) ),
909
+				'href' => rest_url(sprintf('%s/%s/%d', $this->namespace, $this->rest_base, $comment->comment_ID)),
910 910
 			),
911 911
 			'collection' => array(
912
-				'href' => rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ),
912
+				'href' => rest_url(sprintf('%s/%s', $this->namespace, $this->rest_base)),
913 913
 			),
914 914
 		);
915 915
 
916
-		if ( 0 !== (int) $comment->user_id ) {
916
+		if (0 !== (int) $comment->user_id) {
917 917
 			$links['author'] = array(
918
-				'href'       => rest_url( 'wp/v2/users/' . $comment->user_id ),
918
+				'href'       => rest_url('wp/v2/users/'.$comment->user_id),
919 919
 				'embeddable' => true,
920 920
 			);
921 921
 		}
922 922
 
923
-		if ( 0 !== (int) $comment->comment_post_ID ) {
924
-			$post = get_post( $comment->comment_post_ID );
923
+		if (0 !== (int) $comment->comment_post_ID) {
924
+			$post = get_post($comment->comment_post_ID);
925 925
 
926
-			if ( ! empty( $post->ID ) ) {
927
-				$obj = get_post_type_object( $post->post_type );
928
-				$base = ! empty( $obj->rest_base ) ? $obj->rest_base : $obj->name;
926
+			if ( ! empty($post->ID)) {
927
+				$obj = get_post_type_object($post->post_type);
928
+				$base = ! empty($obj->rest_base) ? $obj->rest_base : $obj->name;
929 929
 
930 930
 				$links['up'] = array(
931
-					'href'       => rest_url( 'wp/v2/' . $base . '/' . $comment->comment_post_ID ),
931
+					'href'       => rest_url('wp/v2/'.$base.'/'.$comment->comment_post_ID),
932 932
 					'embeddable' => true,
933 933
 					'post_type'  => $post->post_type,
934 934
 				);
935 935
 			}
936 936
 		}
937 937
 
938
-		if ( 0 !== (int) $comment->comment_parent ) {
938
+		if (0 !== (int) $comment->comment_parent) {
939 939
 			$links['in-reply-to'] = array(
940
-				'href'       => rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $comment->comment_parent ) ),
940
+				'href'       => rest_url(sprintf('%s/%s/%d', $this->namespace, $this->rest_base, $comment->comment_parent)),
941 941
 				'embeddable' => true,
942 942
 			);
943 943
 		}
944 944
 
945 945
 		// Only grab one comment to verify the comment has children.
946
-		$comment_children = $comment->get_children( array(
946
+		$comment_children = $comment->get_children(array(
947 947
 			'number' => 1,
948 948
 			'count'  => true
949
-		) );
949
+		));
950 950
 
951
-		if ( ! empty( $comment_children ) ) {
951
+		if ( ! empty($comment_children)) {
952 952
 			$args = array(
953 953
 				'parent' => $comment->comment_ID
954 954
 			);
955 955
 
956
-			$rest_url = add_query_arg( $args, rest_url( $this->namespace . '/' . $this->rest_base ) );
956
+			$rest_url = add_query_arg($args, rest_url($this->namespace.'/'.$this->rest_base));
957 957
 
958 958
 			$links['children'] = array(
959 959
 				'href' => $rest_url,
@@ -972,24 +972,24 @@  discard block
 block discarded – undo
972 972
 	 * @param string $query_param Query parameter.
973 973
 	 * @return string The normalized query parameter.
974 974
 	 */
975
-	protected function normalize_query_param( $query_param ) {
975
+	protected function normalize_query_param($query_param) {
976 976
 		$prefix = 'comment_';
977 977
 
978
-		switch ( $query_param ) {
978
+		switch ($query_param) {
979 979
 			case 'id':
980
-				$normalized = $prefix . 'ID';
980
+				$normalized = $prefix.'ID';
981 981
 				break;
982 982
 			case 'post':
983
-				$normalized = $prefix . 'post_ID';
983
+				$normalized = $prefix.'post_ID';
984 984
 				break;
985 985
 			case 'parent':
986
-				$normalized = $prefix . 'parent';
986
+				$normalized = $prefix.'parent';
987 987
 				break;
988 988
 			case 'include':
989 989
 				$normalized = 'comment__in';
990 990
 				break;
991 991
 			default:
992
-				$normalized = $prefix . $query_param;
992
+				$normalized = $prefix.$query_param;
993 993
 				break;
994 994
 		}
995 995
 
@@ -1005,9 +1005,9 @@  discard block
 block discarded – undo
1005 1005
 	 * @param string|int $comment_approved comment status.
1006 1006
 	 * @return string Comment status.
1007 1007
 	 */
1008
-	protected function prepare_status_response( $comment_approved ) {
1008
+	protected function prepare_status_response($comment_approved) {
1009 1009
 
1010
-		switch ( $comment_approved ) {
1010
+		switch ($comment_approved) {
1011 1011
 			case 'hold':
1012 1012
 			case '0':
1013 1013
 				$status = 'hold';
@@ -1037,77 +1037,77 @@  discard block
 block discarded – undo
1037 1037
 	 * @param WP_REST_Request $request Request object.
1038 1038
 	 * @return array|WP_Error Prepared comment, otherwise WP_Error object.
1039 1039
 	 */
1040
-	protected function prepare_item_for_database( $request ) {
1040
+	protected function prepare_item_for_database($request) {
1041 1041
 		$prepared_comment = array();
1042 1042
 
1043 1043
 		/*
1044 1044
 		 * Allow the comment_content to be set via the 'content' or
1045 1045
 		 * the 'content.raw' properties of the Request object.
1046 1046
 		 */
1047
-		if ( isset( $request['content'] ) && is_string( $request['content'] ) ) {
1047
+		if (isset($request['content']) && is_string($request['content'])) {
1048 1048
 			$prepared_comment['comment_content'] = $request['content'];
1049
-		} elseif ( isset( $request['content']['raw'] ) && is_string( $request['content']['raw'] ) ) {
1049
+		} elseif (isset($request['content']['raw']) && is_string($request['content']['raw'])) {
1050 1050
 			$prepared_comment['comment_content'] = $request['content']['raw'];
1051 1051
 		}
1052 1052
 
1053
-		if ( isset( $request['post'] ) ) {
1053
+		if (isset($request['post'])) {
1054 1054
 			$prepared_comment['comment_post_ID'] = (int) $request['post'];
1055 1055
 		}
1056 1056
 
1057
-		if ( isset( $request['parent'] ) ) {
1057
+		if (isset($request['parent'])) {
1058 1058
 			$prepared_comment['comment_parent'] = $request['parent'];
1059 1059
 		}
1060 1060
 
1061
-		if ( isset( $request['author'] ) ) {
1062
-			$user = new WP_User( $request['author'] );
1061
+		if (isset($request['author'])) {
1062
+			$user = new WP_User($request['author']);
1063 1063
 
1064
-			if ( $user->exists() ) {
1064
+			if ($user->exists()) {
1065 1065
 				$prepared_comment['user_id'] = $user->ID;
1066 1066
 				$prepared_comment['comment_author'] = $user->display_name;
1067 1067
 				$prepared_comment['comment_author_email'] = $user->user_email;
1068 1068
 				$prepared_comment['comment_author_url'] = $user->user_url;
1069 1069
 			} else {
1070
-				return new WP_Error( 'rest_comment_author_invalid', __( 'Invalid comment author ID.' ), array( 'status' => 400 ) );
1070
+				return new WP_Error('rest_comment_author_invalid', __('Invalid comment author ID.'), array('status' => 400));
1071 1071
 			}
1072 1072
 		}
1073 1073
 
1074
-		if ( isset( $request['author_name'] ) ) {
1074
+		if (isset($request['author_name'])) {
1075 1075
 			$prepared_comment['comment_author'] = $request['author_name'];
1076 1076
 		}
1077 1077
 
1078
-		if ( isset( $request['author_email'] ) ) {
1078
+		if (isset($request['author_email'])) {
1079 1079
 			$prepared_comment['comment_author_email'] = $request['author_email'];
1080 1080
 		}
1081 1081
 
1082
-		if ( isset( $request['author_url'] ) ) {
1082
+		if (isset($request['author_url'])) {
1083 1083
 			$prepared_comment['comment_author_url'] = $request['author_url'];
1084 1084
 		}
1085 1085
 
1086
-		if ( isset( $request['author_ip'] ) && current_user_can( 'moderate_comments' ) ) {
1086
+		if (isset($request['author_ip']) && current_user_can('moderate_comments')) {
1087 1087
 			$prepared_comment['comment_author_IP'] = $request['author_ip'];
1088
-		} elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) && rest_is_ip_address( $_SERVER['REMOTE_ADDR'] ) ) {
1088
+		} elseif ( ! empty($_SERVER['REMOTE_ADDR']) && rest_is_ip_address($_SERVER['REMOTE_ADDR'])) {
1089 1089
 			$prepared_comment['comment_author_IP'] = $_SERVER['REMOTE_ADDR'];
1090 1090
 		} else {
1091 1091
 			$prepared_comment['comment_author_IP'] = '127.0.0.1';
1092 1092
 		}
1093 1093
 
1094
-		if ( ! empty( $request['author_user_agent'] ) ) {
1094
+		if ( ! empty($request['author_user_agent'])) {
1095 1095
 			$prepared_comment['comment_agent'] = $request['author_user_agent'];
1096
-		} elseif ( $request->get_header( 'user_agent' ) ) {
1097
-			$prepared_comment['comment_agent'] = $request->get_header( 'user_agent' );
1096
+		} elseif ($request->get_header('user_agent')) {
1097
+			$prepared_comment['comment_agent'] = $request->get_header('user_agent');
1098 1098
 		}
1099 1099
 
1100
-		if ( ! empty( $request['date'] ) ) {
1101
-			$date_data = rest_get_date_with_gmt( $request['date'] );
1100
+		if ( ! empty($request['date'])) {
1101
+			$date_data = rest_get_date_with_gmt($request['date']);
1102 1102
 
1103
-			if ( ! empty( $date_data ) ) {
1104
-				list( $prepared_comment['comment_date'], $prepared_comment['comment_date_gmt'] ) = $date_data;
1103
+			if ( ! empty($date_data)) {
1104
+				list($prepared_comment['comment_date'], $prepared_comment['comment_date_gmt']) = $date_data;
1105 1105
 			}
1106
-		} elseif ( ! empty( $request['date_gmt'] ) ) {
1107
-			$date_data = rest_get_date_with_gmt( $request['date_gmt'], true );
1106
+		} elseif ( ! empty($request['date_gmt'])) {
1107
+			$date_data = rest_get_date_with_gmt($request['date_gmt'], true);
1108 1108
 
1109
-			if ( ! empty( $date_data ) ) {
1110
-				list( $prepared_comment['comment_date'], $prepared_comment['comment_date_gmt'] ) = $date_data;
1109
+			if ( ! empty($date_data)) {
1110
+				list($prepared_comment['comment_date'], $prepared_comment['comment_date_gmt']) = $date_data;
1111 1111
 			}
1112 1112
 		}
1113 1113
 
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
 		 * @param array           $prepared_comment The prepared comment data for `wp_insert_comment`.
1122 1122
 		 * @param WP_REST_Request $request          The current request.
1123 1123
 		 */
1124
-		return apply_filters( 'rest_preprocess_comment', $prepared_comment, $request );
1124
+		return apply_filters('rest_preprocess_comment', $prepared_comment, $request);
1125 1125
 	}
1126 1126
 
1127 1127
 	/**
@@ -1139,141 +1139,141 @@  discard block
 block discarded – undo
1139 1139
 			'type'                 => 'object',
1140 1140
 			'properties'           => array(
1141 1141
 				'id'               => array(
1142
-					'description'  => __( 'Unique identifier for the object.' ),
1142
+					'description'  => __('Unique identifier for the object.'),
1143 1143
 					'type'         => 'integer',
1144
-					'context'      => array( 'view', 'edit', 'embed' ),
1144
+					'context'      => array('view', 'edit', 'embed'),
1145 1145
 					'readonly'     => true,
1146 1146
 				),
1147 1147
 				'author'           => array(
1148
-					'description'  => __( 'The ID of the user object, if author was a user.' ),
1148
+					'description'  => __('The ID of the user object, if author was a user.'),
1149 1149
 					'type'         => 'integer',
1150
-					'context'      => array( 'view', 'edit', 'embed' ),
1150
+					'context'      => array('view', 'edit', 'embed'),
1151 1151
 				),
1152 1152
 				'author_email'     => array(
1153
-					'description'  => __( 'Email address for the object author.' ),
1153
+					'description'  => __('Email address for the object author.'),
1154 1154
 					'type'         => 'string',
1155 1155
 					'format'       => 'email',
1156
-					'context'      => array( 'edit' ),
1156
+					'context'      => array('edit'),
1157 1157
 					'arg_options'  => array(
1158
-						'sanitize_callback' => array( $this, 'check_comment_author_email' ),
1158
+						'sanitize_callback' => array($this, 'check_comment_author_email'),
1159 1159
 						'validate_callback' => null, // skip built-in validation of 'email'.
1160 1160
 					),
1161 1161
 				),
1162 1162
 				'author_ip'     => array(
1163
-					'description'  => __( 'IP address for the object author.' ),
1163
+					'description'  => __('IP address for the object author.'),
1164 1164
 					'type'         => 'string',
1165 1165
 					'format'       => 'ip',
1166
-					'context'      => array( 'edit' ),
1166
+					'context'      => array('edit'),
1167 1167
 				),
1168 1168
 				'author_name'     => array(
1169
-					'description'  => __( 'Display name for the object author.' ),
1169
+					'description'  => __('Display name for the object author.'),
1170 1170
 					'type'         => 'string',
1171
-					'context'      => array( 'view', 'edit', 'embed' ),
1171
+					'context'      => array('view', 'edit', 'embed'),
1172 1172
 					'arg_options'  => array(
1173 1173
 						'sanitize_callback' => 'sanitize_text_field',
1174 1174
 					),
1175 1175
 				),
1176 1176
 				'author_url'       => array(
1177
-					'description'  => __( 'URL for the object author.' ),
1177
+					'description'  => __('URL for the object author.'),
1178 1178
 					'type'         => 'string',
1179 1179
 					'format'       => 'uri',
1180
-					'context'      => array( 'view', 'edit', 'embed' ),
1180
+					'context'      => array('view', 'edit', 'embed'),
1181 1181
 				),
1182 1182
 				'author_user_agent'     => array(
1183
-					'description'  => __( 'User agent for the object author.' ),
1183
+					'description'  => __('User agent for the object author.'),
1184 1184
 					'type'         => 'string',
1185
-					'context'      => array( 'edit' ),
1185
+					'context'      => array('edit'),
1186 1186
 					'arg_options'  => array(
1187 1187
 						'sanitize_callback' => 'sanitize_text_field',
1188 1188
 					),
1189 1189
 				),
1190 1190
 				'content'          => array(
1191
-					'description'     => __( 'The content for the object.' ),
1191
+					'description'     => __('The content for the object.'),
1192 1192
 					'type'            => 'object',
1193
-					'context'         => array( 'view', 'edit', 'embed' ),
1193
+					'context'         => array('view', 'edit', 'embed'),
1194 1194
 					'arg_options'     => array(
1195 1195
 						'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database()
1196 1196
 					),
1197 1197
 					'properties'      => array(
1198 1198
 						'raw'         => array(
1199
-							'description'     => __( 'Content for the object, as it exists in the database.' ),
1199
+							'description'     => __('Content for the object, as it exists in the database.'),
1200 1200
 							'type'            => 'string',
1201
-							'context'         => array( 'edit' ),
1201
+							'context'         => array('edit'),
1202 1202
 						),
1203 1203
 						'rendered'    => array(
1204
-							'description'     => __( 'HTML content for the object, transformed for display.' ),
1204
+							'description'     => __('HTML content for the object, transformed for display.'),
1205 1205
 							'type'            => 'string',
1206
-							'context'         => array( 'view', 'edit', 'embed' ),
1206
+							'context'         => array('view', 'edit', 'embed'),
1207 1207
 							'readonly'        => true,
1208 1208
 						),
1209 1209
 					),
1210 1210
 				),
1211 1211
 				'date'             => array(
1212
-					'description'  => __( "The date the object was published, in the site's timezone." ),
1212
+					'description'  => __("The date the object was published, in the site's timezone."),
1213 1213
 					'type'         => 'string',
1214 1214
 					'format'       => 'date-time',
1215
-					'context'      => array( 'view', 'edit', 'embed' ),
1215
+					'context'      => array('view', 'edit', 'embed'),
1216 1216
 				),
1217 1217
 				'date_gmt'         => array(
1218
-					'description'  => __( 'The date the object was published, as GMT.' ),
1218
+					'description'  => __('The date the object was published, as GMT.'),
1219 1219
 					'type'         => 'string',
1220 1220
 					'format'       => 'date-time',
1221
-					'context'      => array( 'view', 'edit' ),
1221
+					'context'      => array('view', 'edit'),
1222 1222
 				),
1223 1223
 				'link'             => array(
1224
-					'description'  => __( 'URL to the object.' ),
1224
+					'description'  => __('URL to the object.'),
1225 1225
 					'type'         => 'string',
1226 1226
 					'format'       => 'uri',
1227
-					'context'      => array( 'view', 'edit', 'embed' ),
1227
+					'context'      => array('view', 'edit', 'embed'),
1228 1228
 					'readonly'     => true,
1229 1229
 				),
1230 1230
 				'parent'           => array(
1231
-					'description'  => __( 'The ID for the parent of the object.' ),
1231
+					'description'  => __('The ID for the parent of the object.'),
1232 1232
 					'type'         => 'integer',
1233
-					'context'      => array( 'view', 'edit', 'embed' ),
1233
+					'context'      => array('view', 'edit', 'embed'),
1234 1234
 					'default'      => 0,
1235 1235
 				),
1236 1236
 				'post'             => array(
1237
-					'description'  => __( 'The ID of the associated post object.' ),
1237
+					'description'  => __('The ID of the associated post object.'),
1238 1238
 					'type'         => 'integer',
1239
-					'context'      => array( 'view', 'edit' ),
1239
+					'context'      => array('view', 'edit'),
1240 1240
 					'default'      => 0,
1241 1241
 				),
1242 1242
 				'status'           => array(
1243
-					'description'  => __( 'State of the object.' ),
1243
+					'description'  => __('State of the object.'),
1244 1244
 					'type'         => 'string',
1245
-					'context'      => array( 'view', 'edit' ),
1245
+					'context'      => array('view', 'edit'),
1246 1246
 					'arg_options'  => array(
1247 1247
 						'sanitize_callback' => 'sanitize_key',
1248 1248
 					),
1249 1249
 				),
1250 1250
 				'type'             => array(
1251
-					'description'  => __( 'Type of Comment for the object.' ),
1251
+					'description'  => __('Type of Comment for the object.'),
1252 1252
 					'type'         => 'string',
1253
-					'context'      => array( 'view', 'edit', 'embed' ),
1253
+					'context'      => array('view', 'edit', 'embed'),
1254 1254
 					'readonly'     => true,
1255 1255
 				),
1256 1256
 			),
1257 1257
 		);
1258 1258
 
1259
-		if ( get_option( 'show_avatars' ) ) {
1259
+		if (get_option('show_avatars')) {
1260 1260
 			$avatar_properties = array();
1261 1261
 
1262 1262
 			$avatar_sizes = rest_get_avatar_sizes();
1263
-			foreach ( $avatar_sizes as $size ) {
1264
-				$avatar_properties[ $size ] = array(
1263
+			foreach ($avatar_sizes as $size) {
1264
+				$avatar_properties[$size] = array(
1265 1265
 					/* translators: %d: avatar image size in pixels */
1266
-					'description' => sprintf( __( 'Avatar URL with image size of %d pixels.' ), $size ),
1266
+					'description' => sprintf(__('Avatar URL with image size of %d pixels.'), $size),
1267 1267
 					'type'        => 'string',
1268 1268
 					'format'      => 'uri',
1269
-					'context'     => array( 'embed', 'view', 'edit' ),
1269
+					'context'     => array('embed', 'view', 'edit'),
1270 1270
 				);
1271 1271
 			}
1272 1272
 
1273 1273
 			$schema['properties']['author_avatar_urls'] = array(
1274
-				'description'   => __( 'Avatar URLs for the object author.' ),
1274
+				'description'   => __('Avatar URLs for the object author.'),
1275 1275
 				'type'          => 'object',
1276
-				'context'       => array( 'view', 'edit', 'embed' ),
1276
+				'context'       => array('view', 'edit', 'embed'),
1277 1277
 				'readonly'      => true,
1278 1278
 				'properties'    => $avatar_properties,
1279 1279
 			);
@@ -1281,7 +1281,7 @@  discard block
 block discarded – undo
1281 1281
 
1282 1282
 		$schema['properties']['meta'] = $this->meta->get_field_schema();
1283 1283
 
1284
-		return $this->add_additional_fields_schema( $schema );
1284
+		return $this->add_additional_fields_schema($schema);
1285 1285
 	}
1286 1286
 
1287 1287
 	/**
@@ -1298,13 +1298,13 @@  discard block
 block discarded – undo
1298 1298
 		$query_params['context']['default'] = 'view';
1299 1299
 
1300 1300
 		$query_params['after'] = array(
1301
-			'description'       => __( 'Limit response to comments published after a given ISO8601 compliant date.' ),
1301
+			'description'       => __('Limit response to comments published after a given ISO8601 compliant date.'),
1302 1302
 			'type'              => 'string',
1303 1303
 			'format'            => 'date-time',
1304 1304
 		);
1305 1305
 
1306 1306
 		$query_params['author'] = array(
1307
-			'description'       => __( 'Limit result set to comments assigned to specific user IDs. Requires authorization.' ),
1307
+			'description'       => __('Limit result set to comments assigned to specific user IDs. Requires authorization.'),
1308 1308
 			'type'              => 'array',
1309 1309
 			'items'             => array(
1310 1310
 				'type'          => 'integer',
@@ -1312,7 +1312,7 @@  discard block
 block discarded – undo
1312 1312
 		);
1313 1313
 
1314 1314
 		$query_params['author_exclude'] = array(
1315
-			'description'       => __( 'Ensure result set excludes comments assigned to specific user IDs. Requires authorization.' ),
1315
+			'description'       => __('Ensure result set excludes comments assigned to specific user IDs. Requires authorization.'),
1316 1316
 			'type'              => 'array',
1317 1317
 			'items'             => array(
1318 1318
 				'type'          => 'integer',
@@ -1321,19 +1321,19 @@  discard block
 block discarded – undo
1321 1321
 
1322 1322
 		$query_params['author_email'] = array(
1323 1323
 			'default'           => null,
1324
-			'description'       => __( 'Limit result set to that from a specific author email. Requires authorization.' ),
1324
+			'description'       => __('Limit result set to that from a specific author email. Requires authorization.'),
1325 1325
 			'format'            => 'email',
1326 1326
 			'type'              => 'string',
1327 1327
 		);
1328 1328
 
1329 1329
 		$query_params['before'] = array(
1330
-			'description'       => __( 'Limit response to comments published before a given ISO8601 compliant date.' ),
1330
+			'description'       => __('Limit response to comments published before a given ISO8601 compliant date.'),
1331 1331
 			'type'              => 'string',
1332 1332
 			'format'            => 'date-time',
1333 1333
 		);
1334 1334
 
1335 1335
 		$query_params['exclude'] = array(
1336
-			'description'        => __( 'Ensure result set excludes specific IDs.' ),
1336
+			'description'        => __('Ensure result set excludes specific IDs.'),
1337 1337
 			'type'               => 'array',
1338 1338
 			'items'              => array(
1339 1339
 				'type'           => 'integer',
@@ -1342,7 +1342,7 @@  discard block
 block discarded – undo
1342 1342
 		);
1343 1343
 
1344 1344
 		$query_params['include'] = array(
1345
-			'description'        => __( 'Limit result set to specific IDs.' ),
1345
+			'description'        => __('Limit result set to specific IDs.'),
1346 1346
 			'type'               => 'array',
1347 1347
 			'items'              => array(
1348 1348
 				'type'           => 'integer',
@@ -1351,12 +1351,12 @@  discard block
 block discarded – undo
1351 1351
 		);
1352 1352
 
1353 1353
 		$query_params['offset'] = array(
1354
-			'description'        => __( 'Offset the result set by a specific number of items.' ),
1354
+			'description'        => __('Offset the result set by a specific number of items.'),
1355 1355
 			'type'               => 'integer',
1356 1356
 		);
1357 1357
 
1358
-		$query_params['order']      = array(
1359
-			'description'           => __( 'Order sort attribute ascending or descending.' ),
1358
+		$query_params['order'] = array(
1359
+			'description'           => __('Order sort attribute ascending or descending.'),
1360 1360
 			'type'                  => 'string',
1361 1361
 			'default'               => 'desc',
1362 1362
 			'enum'                  => array(
@@ -1365,8 +1365,8 @@  discard block
 block discarded – undo
1365 1365
 			),
1366 1366
 		);
1367 1367
 
1368
-		$query_params['orderby']    = array(
1369
-			'description'           => __( 'Sort collection by object attribute.' ),
1368
+		$query_params['orderby'] = array(
1369
+			'description'           => __('Sort collection by object attribute.'),
1370 1370
 			'type'                  => 'string',
1371 1371
 			'default'               => 'date_gmt',
1372 1372
 			'enum'                  => array(
@@ -1382,7 +1382,7 @@  discard block
 block discarded – undo
1382 1382
 
1383 1383
 		$query_params['parent'] = array(
1384 1384
 			'default'           => array(),
1385
-			'description'       => __( 'Limit result set to comments of specific parent IDs.' ),
1385
+			'description'       => __('Limit result set to comments of specific parent IDs.'),
1386 1386
 			'type'              => 'array',
1387 1387
 			'items'             => array(
1388 1388
 				'type'          => 'integer',
@@ -1391,16 +1391,16 @@  discard block
 block discarded – undo
1391 1391
 
1392 1392
 		$query_params['parent_exclude'] = array(
1393 1393
 			'default'           => array(),
1394
-			'description'       => __( 'Ensure result set excludes specific parent IDs.' ),
1394
+			'description'       => __('Ensure result set excludes specific parent IDs.'),
1395 1395
 			'type'              => 'array',
1396 1396
 			'items'             => array(
1397 1397
 				'type'          => 'integer',
1398 1398
 			),
1399 1399
 		);
1400 1400
 
1401
-		$query_params['post']   = array(
1401
+		$query_params['post'] = array(
1402 1402
 			'default'           => array(),
1403
-			'description'       => __( 'Limit result set to comments assigned to specific post IDs.' ),
1403
+			'description'       => __('Limit result set to comments assigned to specific post IDs.'),
1404 1404
 			'type'              => 'array',
1405 1405
 			'items'             => array(
1406 1406
 				'type'          => 'integer',
@@ -1409,7 +1409,7 @@  discard block
 block discarded – undo
1409 1409
 
1410 1410
 		$query_params['status'] = array(
1411 1411
 			'default'           => 'approve',
1412
-			'description'       => __( 'Limit result set to comments assigned a specific status. Requires authorization.' ),
1412
+			'description'       => __('Limit result set to comments assigned a specific status. Requires authorization.'),
1413 1413
 			'sanitize_callback' => 'sanitize_key',
1414 1414
 			'type'              => 'string',
1415 1415
 			'validate_callback' => 'rest_validate_request_arg',
@@ -1417,14 +1417,14 @@  discard block
 block discarded – undo
1417 1417
 
1418 1418
 		$query_params['type'] = array(
1419 1419
 			'default'           => 'comment',
1420
-			'description'       => __( 'Limit result set to comments assigned a specific type. Requires authorization.' ),
1420
+			'description'       => __('Limit result set to comments assigned a specific type. Requires authorization.'),
1421 1421
 			'sanitize_callback' => 'sanitize_key',
1422 1422
 			'type'              => 'string',
1423 1423
 			'validate_callback' => 'rest_validate_request_arg',
1424 1424
 		);
1425 1425
 
1426 1426
 		$query_params['password'] = array(
1427
-			'description' => __( 'The password for the post if it is password protected.' ),
1427
+			'description' => __('The password for the post if it is password protected.'),
1428 1428
 			'type'        => 'string',
1429 1429
 		);
1430 1430
 
@@ -1439,7 +1439,7 @@  discard block
 block discarded – undo
1439 1439
 		 *
1440 1440
 		 * @param array $query_params JSON Schema-formatted collection parameters.
1441 1441
 		 */
1442
-		return apply_filters( 'rest_comment_collection_params', $query_params );
1442
+		return apply_filters('rest_comment_collection_params', $query_params);
1443 1443
 	}
1444 1444
 
1445 1445
 	/**
@@ -1452,34 +1452,34 @@  discard block
 block discarded – undo
1452 1452
 	 * @param int        $comment_id Comment ID.
1453 1453
 	 * @return bool Whether the status was changed.
1454 1454
 	 */
1455
-	protected function handle_status_param( $new_status, $comment_id ) {
1456
-		$old_status = wp_get_comment_status( $comment_id );
1455
+	protected function handle_status_param($new_status, $comment_id) {
1456
+		$old_status = wp_get_comment_status($comment_id);
1457 1457
 
1458
-		if ( $new_status === $old_status ) {
1458
+		if ($new_status === $old_status) {
1459 1459
 			return false;
1460 1460
 		}
1461 1461
 
1462
-		switch ( $new_status ) {
1462
+		switch ($new_status) {
1463 1463
 			case 'approved' :
1464 1464
 			case 'approve':
1465 1465
 			case '1':
1466
-				$changed = wp_set_comment_status( $comment_id, 'approve' );
1466
+				$changed = wp_set_comment_status($comment_id, 'approve');
1467 1467
 				break;
1468 1468
 			case 'hold':
1469 1469
 			case '0':
1470
-				$changed = wp_set_comment_status( $comment_id, 'hold' );
1470
+				$changed = wp_set_comment_status($comment_id, 'hold');
1471 1471
 				break;
1472 1472
 			case 'spam' :
1473
-				$changed = wp_spam_comment( $comment_id );
1473
+				$changed = wp_spam_comment($comment_id);
1474 1474
 				break;
1475 1475
 			case 'unspam' :
1476
-				$changed = wp_unspam_comment( $comment_id );
1476
+				$changed = wp_unspam_comment($comment_id);
1477 1477
 				break;
1478 1478
 			case 'trash' :
1479
-				$changed = wp_trash_comment( $comment_id );
1479
+				$changed = wp_trash_comment($comment_id);
1480 1480
 				break;
1481 1481
 			case 'untrash' :
1482
-				$changed = wp_untrash_comment( $comment_id );
1482
+				$changed = wp_untrash_comment($comment_id);
1483 1483
 				break;
1484 1484
 			default :
1485 1485
 				$changed = false;
@@ -1501,29 +1501,29 @@  discard block
 block discarded – undo
1501 1501
 	 * @param WP_REST_Request $request Request data to check.
1502 1502
 	 * @return bool Whether post can be read.
1503 1503
 	 */
1504
-	protected function check_read_post_permission( $post, $request ) {
1505
-		$posts_controller = new WP_REST_Posts_Controller( $post->post_type );
1506
-		$post_type = get_post_type_object( $post->post_type );
1504
+	protected function check_read_post_permission($post, $request) {
1505
+		$posts_controller = new WP_REST_Posts_Controller($post->post_type);
1506
+		$post_type = get_post_type_object($post->post_type);
1507 1507
 
1508 1508
 		$has_password_filter = false;
1509 1509
 
1510 1510
 		// Only check password if a specific post was queried for or a single comment
1511
-		$requested_post = ! empty( $request['post'] ) && 1 === count( $request['post'] );
1512
-		$requested_comment = ! empty( $request['id'] );
1513
-		if ( ( $requested_post || $requested_comment ) && $posts_controller->can_access_password_content( $post, $request ) ) {
1514
-			add_filter( 'post_password_required', '__return_false' );
1511
+		$requested_post = ! empty($request['post']) && 1 === count($request['post']);
1512
+		$requested_comment = ! empty($request['id']);
1513
+		if (($requested_post || $requested_comment) && $posts_controller->can_access_password_content($post, $request)) {
1514
+			add_filter('post_password_required', '__return_false');
1515 1515
 
1516 1516
 			$has_password_filter = true;
1517 1517
 		}
1518 1518
 
1519
-		if ( post_password_required( $post ) ) {
1520
-			$result = current_user_can( $post_type->cap->edit_post, $post->ID );
1519
+		if (post_password_required($post)) {
1520
+			$result = current_user_can($post_type->cap->edit_post, $post->ID);
1521 1521
 		} else {
1522
-			$result = $posts_controller->check_read_permission( $post );
1522
+			$result = $posts_controller->check_read_permission($post);
1523 1523
 		}
1524 1524
 
1525
-		if ( $has_password_filter ) {
1526
-			remove_filter( 'post_password_required', '__return_false' );
1525
+		if ($has_password_filter) {
1526
+			remove_filter('post_password_required', '__return_false');
1527 1527
 		}
1528 1528
 
1529 1529
 		return $result;
@@ -1539,29 +1539,29 @@  discard block
 block discarded – undo
1539 1539
 	 * @param WP_REST_Request $request Request data to check.
1540 1540
 	 * @return bool Whether the comment can be read.
1541 1541
 	 */
1542
-	protected function check_read_permission( $comment, $request ) {
1543
-		if ( ! empty( $comment->comment_post_ID ) ) {
1544
-			$post = get_post( $comment->comment_post_ID );
1545
-			if ( $post ) {
1546
-				if ( $this->check_read_post_permission( $post, $request ) && 1 === (int) $comment->comment_approved ) {
1542
+	protected function check_read_permission($comment, $request) {
1543
+		if ( ! empty($comment->comment_post_ID)) {
1544
+			$post = get_post($comment->comment_post_ID);
1545
+			if ($post) {
1546
+				if ($this->check_read_post_permission($post, $request) && 1 === (int) $comment->comment_approved) {
1547 1547
 					return true;
1548 1548
 				}
1549 1549
 			}
1550 1550
 		}
1551 1551
 
1552
-		if ( 0 === get_current_user_id() ) {
1552
+		if (0 === get_current_user_id()) {
1553 1553
 			return false;
1554 1554
 		}
1555 1555
 
1556
-		if ( empty( $comment->comment_post_ID ) && ! current_user_can( 'moderate_comments' ) ) {
1556
+		if (empty($comment->comment_post_ID) && ! current_user_can('moderate_comments')) {
1557 1557
 			return false;
1558 1558
 		}
1559 1559
 
1560
-		if ( ! empty( $comment->user_id ) && get_current_user_id() === (int) $comment->user_id ) {
1560
+		if ( ! empty($comment->user_id) && get_current_user_id() === (int) $comment->user_id) {
1561 1561
 			return true;
1562 1562
 		}
1563 1563
 
1564
-		return current_user_can( 'edit_comment', $comment->comment_ID );
1564
+		return current_user_can('edit_comment', $comment->comment_ID);
1565 1565
 	}
1566 1566
 
1567 1567
 	/**
@@ -1573,16 +1573,16 @@  discard block
 block discarded – undo
1573 1573
 	 * @param object $comment Comment object.
1574 1574
 	 * @return bool Whether the comment can be edited or deleted.
1575 1575
 	 */
1576
-	protected function check_edit_permission( $comment ) {
1577
-		if ( 0 === (int) get_current_user_id() ) {
1576
+	protected function check_edit_permission($comment) {
1577
+		if (0 === (int) get_current_user_id()) {
1578 1578
 			return false;
1579 1579
 		}
1580 1580
 
1581
-		if ( ! current_user_can( 'moderate_comments' ) ) {
1581
+		if ( ! current_user_can('moderate_comments')) {
1582 1582
 			return false;
1583 1583
 		}
1584 1584
 
1585
-		return current_user_can( 'edit_comment', $comment->comment_ID );
1585
+		return current_user_can('edit_comment', $comment->comment_ID);
1586 1586
 	}
1587 1587
 
1588 1588
 	/**
@@ -1601,14 +1601,14 @@  discard block
 block discarded – undo
1601 1601
 	 * @return WP_Error|string The sanitized email address, if valid,
1602 1602
 	 *                         otherwise an error.
1603 1603
 	 */
1604
-	public function check_comment_author_email( $value, $request, $param ) {
1604
+	public function check_comment_author_email($value, $request, $param) {
1605 1605
 		$email = (string) $value;
1606
-		if ( empty( $email ) ) {
1606
+		if (empty($email)) {
1607 1607
 			return $email;
1608 1608
 		}
1609 1609
 
1610
-		$check_email = rest_validate_request_arg( $email, $request, $param );
1611
-		if ( is_wp_error( $check_email ) ) {
1610
+		$check_email = rest_validate_request_arg($email, $request, $param);
1611
+		if (is_wp_error($check_email)) {
1612 1612
 			return $check_email;
1613 1613
 		}
1614 1614
 
Please login to merge, or discard this patch.
src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -179,7 +179,7 @@
 block discarded – undo
179 179
 	 * @access public
180 180
 	 *
181 181
 	 * @param WP_REST_Request $request Request object.
182
-	 * @return WP_Error|object The prepared item, or WP_Error object on failure.
182
+	 * @return WP_Error The prepared item, or WP_Error object on failure.
183 183
 	 */
184 184
 	protected function prepare_item_for_database( $request ) {
185 185
 		return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
Please login to merge, or discard this patch.
Spacing   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 * @access public
40 40
 	 */
41 41
 	public function register_routes() {
42
-		_doing_it_wrong( 'WP_REST_Controller::register_routes', __( 'The register_routes() method must be overridden' ), '4.7' );
42
+		_doing_it_wrong('WP_REST_Controller::register_routes', __('The register_routes() method must be overridden'), '4.7');
43 43
 	}
44 44
 
45 45
 	/**
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
 	 * @param WP_REST_Request $request Full data about the request.
52 52
 	 * @return WP_Error|bool True if the request has read access, WP_Error object otherwise.
53 53
 	 */
54
-	public function get_items_permissions_check( $request ) {
55
-		return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
54
+	public function get_items_permissions_check($request) {
55
+		return new WP_Error('invalid-method', sprintf(__("Method '%s' not implemented. Must be overridden in subclass."), __METHOD__), array('status' => 405));
56 56
 	}
57 57
 
58 58
 	/**
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
 	 * @param WP_REST_Request $request Full data about the request.
65 65
 	 * @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure.
66 66
 	 */
67
-	public function get_items( $request ) {
68
-		return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
67
+	public function get_items($request) {
68
+		return new WP_Error('invalid-method', sprintf(__("Method '%s' not implemented. Must be overridden in subclass."), __METHOD__), array('status' => 405));
69 69
 	}
70 70
 
71 71
 	/**
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
 	 * @param WP_REST_Request $request Full data about the request.
78 78
 	 * @return WP_Error|bool True if the request has read access for the item, WP_Error object otherwise.
79 79
 	 */
80
-	public function get_item_permissions_check( $request ) {
81
-		return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
80
+	public function get_item_permissions_check($request) {
81
+		return new WP_Error('invalid-method', sprintf(__("Method '%s' not implemented. Must be overridden in subclass."), __METHOD__), array('status' => 405));
82 82
 	}
83 83
 
84 84
 	/**
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
 	 * @param WP_REST_Request $request Full data about the request.
91 91
 	 * @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure.
92 92
 	 */
93
-	public function get_item( $request ) {
94
-		return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
93
+	public function get_item($request) {
94
+		return new WP_Error('invalid-method', sprintf(__("Method '%s' not implemented. Must be overridden in subclass."), __METHOD__), array('status' => 405));
95 95
 	}
96 96
 
97 97
 	/**
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 	 * @param WP_REST_Request $request Full data about the request.
104 104
 	 * @return WP_Error|bool True if the request has access to create items, WP_Error object otherwise.
105 105
 	 */
106
-	public function create_item_permissions_check( $request ) {
107
-		return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
106
+	public function create_item_permissions_check($request) {
107
+		return new WP_Error('invalid-method', sprintf(__("Method '%s' not implemented. Must be overridden in subclass."), __METHOD__), array('status' => 405));
108 108
 	}
109 109
 
110 110
 	/**
@@ -116,8 +116,8 @@  discard block
 block discarded – undo
116 116
 	 * @param WP_REST_Request $request Full data about the request.
117 117
 	 * @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure.
118 118
 	 */
119
-	public function create_item( $request ) {
120
-		return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
119
+	public function create_item($request) {
120
+		return new WP_Error('invalid-method', sprintf(__("Method '%s' not implemented. Must be overridden in subclass."), __METHOD__), array('status' => 405));
121 121
 	}
122 122
 
123 123
 	/**
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
 	 * @param WP_REST_Request $request Full data about the request.
130 130
 	 * @return WP_Error|bool True if the request has access to update the item, WP_Error object otherwise.
131 131
 	 */
132
-	public function update_item_permissions_check( $request ) {
133
-		return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
132
+	public function update_item_permissions_check($request) {
133
+		return new WP_Error('invalid-method', sprintf(__("Method '%s' not implemented. Must be overridden in subclass."), __METHOD__), array('status' => 405));
134 134
 	}
135 135
 
136 136
 	/**
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
 	 * @param WP_REST_Request $request Full data about the request.
143 143
 	 * @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure.
144 144
 	 */
145
-	public function update_item( $request ) {
146
-		return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
145
+	public function update_item($request) {
146
+		return new WP_Error('invalid-method', sprintf(__("Method '%s' not implemented. Must be overridden in subclass."), __METHOD__), array('status' => 405));
147 147
 	}
148 148
 
149 149
 	/**
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
 	 * @param WP_REST_Request $request Full data about the request.
156 156
 	 * @return WP_Error|bool True if the request has access to delete the item, WP_Error object otherwise.
157 157
 	 */
158
-	public function delete_item_permissions_check( $request ) {
159
-		return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
158
+	public function delete_item_permissions_check($request) {
159
+		return new WP_Error('invalid-method', sprintf(__("Method '%s' not implemented. Must be overridden in subclass."), __METHOD__), array('status' => 405));
160 160
 	}
161 161
 
162 162
 	/**
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 	 * @param WP_REST_Request $request Full data about the request.
169 169
 	 * @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure.
170 170
 	 */
171
-	public function delete_item( $request ) {
172
-		return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
171
+	public function delete_item($request) {
172
+		return new WP_Error('invalid-method', sprintf(__("Method '%s' not implemented. Must be overridden in subclass."), __METHOD__), array('status' => 405));
173 173
 	}
174 174
 
175 175
 	/**
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
 	 * @param WP_REST_Request $request Request object.
182 182
 	 * @return WP_Error|object The prepared item, or WP_Error object on failure.
183 183
 	 */
184
-	protected function prepare_item_for_database( $request ) {
185
-		return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
184
+	protected function prepare_item_for_database($request) {
185
+		return new WP_Error('invalid-method', sprintf(__("Method '%s' not implemented. Must be overridden in subclass."), __METHOD__), array('status' => 405));
186 186
 	}
187 187
 
188 188
 	/**
@@ -195,8 +195,8 @@  discard block
 block discarded – undo
195 195
 	 * @param WP_REST_Request $request Request object.
196 196
 	 * @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure.
197 197
 	 */
198
-	public function prepare_item_for_response( $item, $request ) {
199
-		return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
198
+	public function prepare_item_for_response($item, $request) {
199
+		return new WP_Error('invalid-method', sprintf(__("Method '%s' not implemented. Must be overridden in subclass."), __METHOD__), array('status' => 405));
200 200
 	}
201 201
 
202 202
 	/**
@@ -208,21 +208,21 @@  discard block
 block discarded – undo
208 208
 	 * @param WP_REST_Response $response Response object.
209 209
 	 * @return array|mixed Response data, ready for insertion into collection data.
210 210
 	 */
211
-	public function prepare_response_for_collection( $response ) {
212
-		if ( ! ( $response instanceof WP_REST_Response ) ) {
211
+	public function prepare_response_for_collection($response) {
212
+		if ( ! ($response instanceof WP_REST_Response)) {
213 213
 			return $response;
214 214
 		}
215 215
 
216 216
 		$data   = (array) $response->get_data();
217 217
 		$server = rest_get_server();
218 218
 
219
-		if ( method_exists( $server, 'get_compact_response_links' ) ) {
220
-			$links = call_user_func( array( $server, 'get_compact_response_links' ), $response );
219
+		if (method_exists($server, 'get_compact_response_links')) {
220
+			$links = call_user_func(array($server, 'get_compact_response_links'), $response);
221 221
 		} else {
222
-			$links = call_user_func( array( $server, 'get_response_links' ), $response );
222
+			$links = call_user_func(array($server, 'get_response_links'), $response);
223 223
 		}
224 224
 
225
-		if ( ! empty( $links ) ) {
225
+		if ( ! empty($links)) {
226 226
 			$data['_links'] = $links;
227 227
 		}
228 228
 
@@ -239,29 +239,29 @@  discard block
 block discarded – undo
239 239
 	 * @param string $context Context defined in the schema.
240 240
 	 * @return array Filtered response.
241 241
 	 */
242
-	public function filter_response_by_context( $data, $context ) {
242
+	public function filter_response_by_context($data, $context) {
243 243
 
244 244
 		$schema = $this->get_item_schema();
245 245
 
246
-		foreach ( $data as $key => $value ) {
247
-			if ( empty( $schema['properties'][ $key ] ) || empty( $schema['properties'][ $key ]['context'] ) ) {
246
+		foreach ($data as $key => $value) {
247
+			if (empty($schema['properties'][$key]) || empty($schema['properties'][$key]['context'])) {
248 248
 				continue;
249 249
 			}
250 250
 
251
-			if ( ! in_array( $context, $schema['properties'][ $key ]['context'], true ) ) {
252
-				unset( $data[ $key ] );
251
+			if ( ! in_array($context, $schema['properties'][$key]['context'], true)) {
252
+				unset($data[$key]);
253 253
 				continue;
254 254
 			}
255 255
 
256
-			if ( 'object' === $schema['properties'][ $key ]['type'] && ! empty( $schema['properties'][ $key ]['properties'] ) ) {
257
-				foreach ( $schema['properties'][ $key ]['properties'] as $attribute => $details ) {
258
-					if ( empty( $details['context'] ) ) {
256
+			if ('object' === $schema['properties'][$key]['type'] && ! empty($schema['properties'][$key]['properties'])) {
257
+				foreach ($schema['properties'][$key]['properties'] as $attribute => $details) {
258
+					if (empty($details['context'])) {
259 259
 						continue;
260 260
 					}
261 261
 
262
-					if ( ! in_array( $context, $details['context'], true ) ) {
263
-						if ( isset( $data[ $key ][ $attribute ] ) ) {
264
-							unset( $data[ $key ][ $attribute ] );
262
+					if ( ! in_array($context, $details['context'], true)) {
263
+						if (isset($data[$key][$attribute])) {
264
+							unset($data[$key][$attribute]);
265 265
 						}
266 266
 					}
267 267
 				}
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 	 * @return array Item schema data.
281 281
 	 */
282 282
 	public function get_item_schema() {
283
-		return $this->add_additional_fields_schema( array() );
283
+		return $this->add_additional_fields_schema(array());
284 284
 	}
285 285
 
286 286
 	/**
@@ -295,8 +295,8 @@  discard block
 block discarded – undo
295 295
 
296 296
 		$schema = $this->get_item_schema();
297 297
 
298
-		foreach ( $schema['properties'] as &$property ) {
299
-			unset( $property['arg_options'] );
298
+		foreach ($schema['properties'] as &$property) {
299
+			unset($property['arg_options']);
300 300
 		}
301 301
 
302 302
 		return $schema;
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 		return array(
315 315
 			'context'                => $this->get_context_param(),
316 316
 			'page'                   => array(
317
-				'description'        => __( 'Current page of the collection.' ),
317
+				'description'        => __('Current page of the collection.'),
318 318
 				'type'               => 'integer',
319 319
 				'default'            => 1,
320 320
 				'sanitize_callback'  => 'absint',
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 				'minimum'            => 1,
323 323
 			),
324 324
 			'per_page'               => array(
325
-				'description'        => __( 'Maximum number of items to be returned in result set.' ),
325
+				'description'        => __('Maximum number of items to be returned in result set.'),
326 326
 				'type'               => 'integer',
327 327
 				'default'            => 10,
328 328
 				'minimum'            => 1,
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 				'validate_callback'  => 'rest_validate_request_arg',
332 332
 			),
333 333
 			'search'                 => array(
334
-				'description'        => __( 'Limit results to those matching a string.' ),
334
+				'description'        => __('Limit results to those matching a string.'),
335 335
 				'type'               => 'string',
336 336
 				'sanitize_callback'  => 'sanitize_text_field',
337 337
 				'validate_callback'  => 'rest_validate_request_arg',
@@ -350,9 +350,9 @@  discard block
 block discarded – undo
350 350
 	 * @param array $args Optional. Additional arguments for context parameter. Default empty array.
351 351
 	 * @return array Context parameter details.
352 352
 	 */
353
-	public function get_context_param( $args = array() ) {
353
+	public function get_context_param($args = array()) {
354 354
 		$param_details = array(
355
-			'description'        => __( 'Scope under which the request is made; determines fields present in response.' ),
355
+			'description'        => __('Scope under which the request is made; determines fields present in response.'),
356 356
 			'type'               => 'string',
357 357
 			'sanitize_callback'  => 'sanitize_key',
358 358
 			'validate_callback'  => 'rest_validate_request_arg',
@@ -360,24 +360,24 @@  discard block
 block discarded – undo
360 360
 
361 361
 		$schema = $this->get_item_schema();
362 362
 
363
-		if ( empty( $schema['properties'] ) ) {
364
-			return array_merge( $param_details, $args );
363
+		if (empty($schema['properties'])) {
364
+			return array_merge($param_details, $args);
365 365
 		}
366 366
 
367 367
 		$contexts = array();
368 368
 
369
-		foreach ( $schema['properties'] as $attributes ) {
370
-			if ( ! empty( $attributes['context'] ) ) {
371
-				$contexts = array_merge( $contexts, $attributes['context'] );
369
+		foreach ($schema['properties'] as $attributes) {
370
+			if ( ! empty($attributes['context'])) {
371
+				$contexts = array_merge($contexts, $attributes['context']);
372 372
 			}
373 373
 		}
374 374
 
375
-		if ( ! empty( $contexts ) ) {
376
-			$param_details['enum'] = array_unique( $contexts );
377
-			rsort( $param_details['enum'] );
375
+		if ( ! empty($contexts)) {
376
+			$param_details['enum'] = array_unique($contexts);
377
+			rsort($param_details['enum']);
378 378
 		}
379 379
 
380
-		return array_merge( $param_details, $args );
380
+		return array_merge($param_details, $args);
381 381
 	}
382 382
 
383 383
 	/**
@@ -390,17 +390,17 @@  discard block
 block discarded – undo
390 390
 	 * @param WP_REST_Request $request Full details about the request.
391 391
 	 * @return array Modified data object with additional fields.
392 392
 	 */
393
-	protected function add_additional_fields_to_object( $object, $request ) {
393
+	protected function add_additional_fields_to_object($object, $request) {
394 394
 
395 395
 		$additional_fields = $this->get_additional_fields();
396 396
 
397
-		foreach ( $additional_fields as $field_name => $field_options ) {
397
+		foreach ($additional_fields as $field_name => $field_options) {
398 398
 
399
-			if ( ! $field_options['get_callback'] ) {
399
+			if ( ! $field_options['get_callback']) {
400 400
 				continue;
401 401
 			}
402 402
 
403
-			$object[ $field_name ] = call_user_func( $field_options['get_callback'], $object, $field_name, $request, $this->get_object_type() );
403
+			$object[$field_name] = call_user_func($field_options['get_callback'], $object, $field_name, $request, $this->get_object_type());
404 404
 		}
405 405
 
406 406
 		return $object;
@@ -416,22 +416,22 @@  discard block
 block discarded – undo
416 416
 	 * @param WP_REST_Request $request Full details about the request.
417 417
 	 * @return bool|WP_Error True on success, WP_Error object if a field cannot be updated.
418 418
 	 */
419
-	protected function update_additional_fields_for_object( $object, $request ) {
419
+	protected function update_additional_fields_for_object($object, $request) {
420 420
 		$additional_fields = $this->get_additional_fields();
421 421
 
422
-		foreach ( $additional_fields as $field_name => $field_options ) {
423
-			if ( ! $field_options['update_callback'] ) {
422
+		foreach ($additional_fields as $field_name => $field_options) {
423
+			if ( ! $field_options['update_callback']) {
424 424
 				continue;
425 425
 			}
426 426
 
427 427
 			// Don't run the update callbacks if the data wasn't passed in the request.
428
-			if ( ! isset( $request[ $field_name ] ) ) {
428
+			if ( ! isset($request[$field_name])) {
429 429
 				continue;
430 430
 			}
431 431
 
432
-			$result = call_user_func( $field_options['update_callback'], $request[ $field_name ], $object, $field_name, $request, $this->get_object_type() );
432
+			$result = call_user_func($field_options['update_callback'], $request[$field_name], $object, $field_name, $request, $this->get_object_type());
433 433
 
434
-			if ( is_wp_error( $result ) ) {
434
+			if (is_wp_error($result)) {
435 435
 				return $result;
436 436
 			}
437 437
 		}
@@ -450,22 +450,22 @@  discard block
 block discarded – undo
450 450
 	 * @param array $schema Schema array.
451 451
 	 * @return array Modified Schema array.
452 452
 	 */
453
-	protected function add_additional_fields_schema( $schema ) {
454
-		if ( empty( $schema['title'] ) ) {
453
+	protected function add_additional_fields_schema($schema) {
454
+		if (empty($schema['title'])) {
455 455
 			return $schema;
456 456
 		}
457 457
 
458 458
 		// Can't use $this->get_object_type otherwise we cause an inf loop.
459 459
 		$object_type = $schema['title'];
460 460
 
461
-		$additional_fields = $this->get_additional_fields( $object_type );
461
+		$additional_fields = $this->get_additional_fields($object_type);
462 462
 
463
-		foreach ( $additional_fields as $field_name => $field_options ) {
464
-			if ( ! $field_options['schema'] ) {
463
+		foreach ($additional_fields as $field_name => $field_options) {
464
+			if ( ! $field_options['schema']) {
465 465
 				continue;
466 466
 			}
467 467
 
468
-			$schema['properties'][ $field_name ] = $field_options['schema'];
468
+			$schema['properties'][$field_name] = $field_options['schema'];
469 469
 		}
470 470
 
471 471
 		return $schema;
@@ -481,23 +481,23 @@  discard block
 block discarded – undo
481 481
 	 * @return array Registered additional fields (if any), empty array if none or if the object type could
482 482
 	 *               not be inferred.
483 483
 	 */
484
-	protected function get_additional_fields( $object_type = null ) {
484
+	protected function get_additional_fields($object_type = null) {
485 485
 
486
-		if ( ! $object_type ) {
486
+		if ( ! $object_type) {
487 487
 			$object_type = $this->get_object_type();
488 488
 		}
489 489
 
490
-		if ( ! $object_type ) {
490
+		if ( ! $object_type) {
491 491
 			return array();
492 492
 		}
493 493
 
494 494
 		global $wp_rest_additional_fields;
495 495
 
496
-		if ( ! $wp_rest_additional_fields || ! isset( $wp_rest_additional_fields[ $object_type ] ) ) {
496
+		if ( ! $wp_rest_additional_fields || ! isset($wp_rest_additional_fields[$object_type])) {
497 497
 			return array();
498 498
 		}
499 499
 
500
-		return $wp_rest_additional_fields[ $object_type ];
500
+		return $wp_rest_additional_fields[$object_type];
501 501
 	}
502 502
 
503 503
 	/**
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 	protected function get_object_type() {
512 512
 		$schema = $this->get_item_schema();
513 513
 
514
-		if ( ! $schema || ! isset( $schema['title'] ) ) {
514
+		if ( ! $schema || ! isset($schema['title'])) {
515 515
 			return null;
516 516
 		}
517 517
 
@@ -529,51 +529,51 @@  discard block
 block discarded – undo
529 529
 	 *                       on `EDITABLE` requests. Default WP_REST_Server::CREATABLE.
530 530
 	 * @return array Endpoint arguments.
531 531
 	 */
532
-	public function get_endpoint_args_for_item_schema( $method = WP_REST_Server::CREATABLE ) {
532
+	public function get_endpoint_args_for_item_schema($method = WP_REST_Server::CREATABLE) {
533 533
 
534 534
 		$schema            = $this->get_item_schema();
535
-		$schema_properties = ! empty( $schema['properties'] ) ? $schema['properties'] : array();
535
+		$schema_properties = ! empty($schema['properties']) ? $schema['properties'] : array();
536 536
 		$endpoint_args     = array();
537 537
 
538
-		foreach ( $schema_properties as $field_id => $params ) {
538
+		foreach ($schema_properties as $field_id => $params) {
539 539
 
540 540
 			// Arguments specified as `readonly` are not allowed to be set.
541
-			if ( ! empty( $params['readonly'] ) ) {
541
+			if ( ! empty($params['readonly'])) {
542 542
 				continue;
543 543
 			}
544 544
 
545
-			$endpoint_args[ $field_id ] = array(
545
+			$endpoint_args[$field_id] = array(
546 546
 				'validate_callback' => 'rest_validate_request_arg',
547 547
 				'sanitize_callback' => 'rest_sanitize_request_arg',
548 548
 			);
549 549
 
550
-			if ( isset( $params['description'] ) ) {
551
-				$endpoint_args[ $field_id ]['description'] = $params['description'];
550
+			if (isset($params['description'])) {
551
+				$endpoint_args[$field_id]['description'] = $params['description'];
552 552
 			}
553 553
 
554
-			if ( WP_REST_Server::CREATABLE === $method && isset( $params['default'] ) ) {
555
-				$endpoint_args[ $field_id ]['default'] = $params['default'];
554
+			if (WP_REST_Server::CREATABLE === $method && isset($params['default'])) {
555
+				$endpoint_args[$field_id]['default'] = $params['default'];
556 556
 			}
557 557
 
558
-			if ( WP_REST_Server::CREATABLE === $method && ! empty( $params['required'] ) ) {
559
-				$endpoint_args[ $field_id ]['required'] = true;
558
+			if (WP_REST_Server::CREATABLE === $method && ! empty($params['required'])) {
559
+				$endpoint_args[$field_id]['required'] = true;
560 560
 			}
561 561
 
562
-			foreach ( array( 'type', 'format', 'enum', 'items' ) as $schema_prop ) {
563
-				if ( isset( $params[ $schema_prop ] ) ) {
564
-					$endpoint_args[ $field_id ][ $schema_prop ] = $params[ $schema_prop ];
562
+			foreach (array('type', 'format', 'enum', 'items') as $schema_prop) {
563
+				if (isset($params[$schema_prop])) {
564
+					$endpoint_args[$field_id][$schema_prop] = $params[$schema_prop];
565 565
 				}
566 566
 			}
567 567
 
568 568
 			// Merge in any options provided by the schema property.
569
-			if ( isset( $params['arg_options'] ) ) {
569
+			if (isset($params['arg_options'])) {
570 570
 
571 571
 				// Only use required / default from arg_options on CREATABLE endpoints.
572
-				if ( WP_REST_Server::CREATABLE !== $method ) {
573
-					$params['arg_options'] = array_diff_key( $params['arg_options'], array( 'required' => '', 'default' => '' ) );
572
+				if (WP_REST_Server::CREATABLE !== $method) {
573
+					$params['arg_options'] = array_diff_key($params['arg_options'], array('required' => '', 'default' => ''));
574 574
 				}
575 575
 
576
-				$endpoint_args[ $field_id ] = array_merge( $endpoint_args[ $field_id ], $params['arg_options'] );
576
+				$endpoint_args[$field_id] = array_merge($endpoint_args[$field_id], $params['arg_options']);
577 577
 			}
578 578
 		}
579 579
 
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 	 * @param string $slug Slug value passed in request.
598 598
 	 * @return string Sanitized value for the slug.
599 599
 	 */
600
-	public function sanitize_slug( $slug ) {
601
-		return sanitize_title( $slug );
600
+	public function sanitize_slug($slug) {
601
+		return sanitize_title($slug);
602 602
 	}
603 603
 }
Please login to merge, or discard this patch.
src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1061,7 +1061,7 @@  discard block
 block discarded – undo
1061 1061
 	 * @access protected
1062 1062
 	 *
1063 1063
 	 * @param string $post_status Post status.
1064
-	 * @param object $post_type   Post type.
1064
+	 * @param WP_Post_Type|null $post_type   Post type.
1065 1065
 	 * @return string|WP_Error Post status or WP_Error if lacking the proper permission.
1066 1066
 	 */
1067 1067
 	protected function handle_status_param( $post_status, $post_type ) {
@@ -1201,7 +1201,7 @@  discard block
 block discarded – undo
1201 1201
 	 * @since 4.7.0
1202 1202
 	 * @access protected
1203 1203
 	 *
1204
-	 * @param object|string $post_type Post type name or object.
1204
+	 * @param WP_Post_Type|null $post_type Post type name or object.
1205 1205
 	 * @return bool Whether the post type is allowed in REST.
1206 1206
 	 */
1207 1207
 	protected function check_is_post_type_allowed( $post_type ) {
Please login to merge, or discard this patch.
Spacing   +561 added lines, -561 removed lines patch added patch discarded remove patch
@@ -42,13 +42,13 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @param string $post_type Post type.
44 44
 	 */
45
-	public function __construct( $post_type ) {
45
+	public function __construct($post_type) {
46 46
 		$this->post_type = $post_type;
47 47
 		$this->namespace = 'wp/v2';
48
-		$obj = get_post_type_object( $post_type );
49
-		$this->rest_base = ! empty( $obj->rest_base ) ? $obj->rest_base : $obj->name;
48
+		$obj = get_post_type_object($post_type);
49
+		$this->rest_base = ! empty($obj->rest_base) ? $obj->rest_base : $obj->name;
50 50
 
51
-		$this->meta = new WP_REST_Post_Meta_Fields( $this->post_type );
51
+		$this->meta = new WP_REST_Post_Meta_Fields($this->post_type);
52 52
 	}
53 53
 
54 54
 	/**
@@ -61,59 +61,59 @@  discard block
 block discarded – undo
61 61
 	 */
62 62
 	public function register_routes() {
63 63
 
64
-		register_rest_route( $this->namespace, '/' . $this->rest_base, array(
64
+		register_rest_route($this->namespace, '/'.$this->rest_base, array(
65 65
 			array(
66 66
 				'methods'             => WP_REST_Server::READABLE,
67
-				'callback'            => array( $this, 'get_items' ),
68
-				'permission_callback' => array( $this, 'get_items_permissions_check' ),
67
+				'callback'            => array($this, 'get_items'),
68
+				'permission_callback' => array($this, 'get_items_permissions_check'),
69 69
 				'args'                => $this->get_collection_params(),
70 70
 			),
71 71
 			array(
72 72
 				'methods'             => WP_REST_Server::CREATABLE,
73
-				'callback'            => array( $this, 'create_item' ),
74
-				'permission_callback' => array( $this, 'create_item_permissions_check' ),
75
-				'args'                => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ),
73
+				'callback'            => array($this, 'create_item'),
74
+				'permission_callback' => array($this, 'create_item_permissions_check'),
75
+				'args'                => $this->get_endpoint_args_for_item_schema(WP_REST_Server::CREATABLE),
76 76
 			),
77
-			'schema' => array( $this, 'get_public_item_schema' ),
78
-		) );
77
+			'schema' => array($this, 'get_public_item_schema'),
78
+		));
79 79
 
80 80
 		$schema = $this->get_item_schema();
81 81
 		$get_item_args = array(
82
-			'context'  => $this->get_context_param( array( 'default' => 'view' ) ),
82
+			'context'  => $this->get_context_param(array('default' => 'view')),
83 83
 		);
84
-		if ( isset( $schema['properties']['password'] ) ) {
84
+		if (isset($schema['properties']['password'])) {
85 85
 			$get_item_args['password'] = array(
86
-				'description' => __( 'The password for the post if it is password protected.' ),
86
+				'description' => __('The password for the post if it is password protected.'),
87 87
 				'type'        => 'string',
88 88
 			);
89 89
 		}
90
-		register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
90
+		register_rest_route($this->namespace, '/'.$this->rest_base.'/(?P<id>[\d]+)', array(
91 91
 			array(
92 92
 				'methods'             => WP_REST_Server::READABLE,
93
-				'callback'            => array( $this, 'get_item' ),
94
-				'permission_callback' => array( $this, 'get_item_permissions_check' ),
93
+				'callback'            => array($this, 'get_item'),
94
+				'permission_callback' => array($this, 'get_item_permissions_check'),
95 95
 				'args'                => $get_item_args,
96 96
 			),
97 97
 			array(
98 98
 				'methods'             => WP_REST_Server::EDITABLE,
99
-				'callback'            => array( $this, 'update_item' ),
100
-				'permission_callback' => array( $this, 'update_item_permissions_check' ),
101
-				'args'                => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ),
99
+				'callback'            => array($this, 'update_item'),
100
+				'permission_callback' => array($this, 'update_item_permissions_check'),
101
+				'args'                => $this->get_endpoint_args_for_item_schema(WP_REST_Server::EDITABLE),
102 102
 			),
103 103
 			array(
104 104
 				'methods'             => WP_REST_Server::DELETABLE,
105
-				'callback'            => array( $this, 'delete_item' ),
106
-				'permission_callback' => array( $this, 'delete_item_permissions_check' ),
105
+				'callback'            => array($this, 'delete_item'),
106
+				'permission_callback' => array($this, 'delete_item_permissions_check'),
107 107
 				'args'                => array(
108 108
 					'force' => array(
109 109
 						'type'        => 'boolean',
110 110
 						'default'     => false,
111
-						'description' => __( 'Whether to bypass trash and force deletion.' ),
111
+						'description' => __('Whether to bypass trash and force deletion.'),
112 112
 					),
113 113
 				),
114 114
 			),
115
-			'schema' => array( $this, 'get_public_item_schema' ),
116
-		) );
115
+			'schema' => array($this, 'get_public_item_schema'),
116
+		));
117 117
 	}
118 118
 
119 119
 	/**
@@ -125,12 +125,12 @@  discard block
 block discarded – undo
125 125
 	 * @param  WP_REST_Request $request Full details about the request.
126 126
 	 * @return true|WP_Error True if the request has read access, WP_Error object otherwise.
127 127
 	 */
128
-	public function get_items_permissions_check( $request ) {
128
+	public function get_items_permissions_check($request) {
129 129
 
130
-		$post_type = get_post_type_object( $this->post_type );
130
+		$post_type = get_post_type_object($this->post_type);
131 131
 
132
-		if ( 'edit' === $request['context'] && ! current_user_can( $post_type->cap->edit_posts ) ) {
133
-			return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit posts in this post type.' ), array( 'status' => rest_authorization_required_code() ) );
132
+		if ('edit' === $request['context'] && ! current_user_can($post_type->cap->edit_posts)) {
133
+			return new WP_Error('rest_forbidden_context', __('Sorry, you are not allowed to edit posts in this post type.'), array('status' => rest_authorization_required_code()));
134 134
 		}
135 135
 
136 136
 		return true;
@@ -145,16 +145,16 @@  discard block
 block discarded – undo
145 145
 	 * @param WP_REST_Request $request Full details about the request.
146 146
 	 * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
147 147
 	 */
148
-	public function get_items( $request ) {
148
+	public function get_items($request) {
149 149
 
150 150
 		// Ensure a search string is set in case the orderby is set to 'relevance'.
151
-		if ( ! empty( $request['orderby'] ) && 'relevance' === $request['orderby'] && empty( $request['search'] ) ) {
152
-			return new WP_Error( 'rest_no_search_term_defined', __( 'You need to define a search term to order by relevance.' ), array( 'status' => 400 ) );
151
+		if ( ! empty($request['orderby']) && 'relevance' === $request['orderby'] && empty($request['search'])) {
152
+			return new WP_Error('rest_no_search_term_defined', __('You need to define a search term to order by relevance.'), array('status' => 400));
153 153
 		}
154 154
 
155 155
 		// Ensure an include parameter is set in case the orderby is set to 'include'.
156
-		if ( ! empty( $request['orderby'] ) && 'include' === $request['orderby'] && empty( $request['include'] ) ) {
157
-			return new WP_Error( 'rest_orderby_include_missing_include', sprintf( __( 'Missing parameter(s): %s' ), 'include' ), array( 'status' => 400 ) );
156
+		if ( ! empty($request['orderby']) && 'include' === $request['orderby'] && empty($request['include'])) {
157
+			return new WP_Error('rest_orderby_include_missing_include', sprintf(__('Missing parameter(s): %s'), 'include'), array('status' => 400));
158 158
 		}
159 159
 
160 160
 		// Retrieve the list of registered collection query parameters.
@@ -188,9 +188,9 @@  discard block
 block discarded – undo
188 188
 		 * For each known parameter which is both registered and present in the request,
189 189
 		 * set the parameter's value on the query $args.
190 190
 		 */
191
-		foreach ( $parameter_mappings as $api_param => $wp_param ) {
192
-			if ( isset( $registered[ $api_param ], $request[ $api_param ] ) ) {
193
-				$args[ $wp_param ] = $request[ $api_param ];
191
+		foreach ($parameter_mappings as $api_param => $wp_param) {
192
+			if (isset($registered[$api_param], $request[$api_param])) {
193
+				$args[$wp_param] = $request[$api_param];
194 194
 			}
195 195
 		}
196 196
 
@@ -198,45 +198,45 @@  discard block
 block discarded – undo
198 198
 		$args['date_query'] = array();
199 199
 
200 200
 		// Set before into date query. Date query must be specified as an array of an array.
201
-		if ( isset( $registered['before'], $request['before'] ) ) {
201
+		if (isset($registered['before'], $request['before'])) {
202 202
 			$args['date_query'][0]['before'] = $request['before'];
203 203
 		}
204 204
 
205 205
 		// Set after into date query. Date query must be specified as an array of an array.
206
-		if ( isset( $registered['after'], $request['after'] ) ) {
206
+		if (isset($registered['after'], $request['after'])) {
207 207
 			$args['date_query'][0]['after'] = $request['after'];
208 208
 		}
209 209
 
210 210
 		// Ensure our per_page parameter overrides any provided posts_per_page filter.
211
-		if ( isset( $registered['per_page'] ) ) {
211
+		if (isset($registered['per_page'])) {
212 212
 			$args['posts_per_page'] = $request['per_page'];
213 213
 		}
214 214
 
215
-		if ( isset( $registered['sticky'], $request['sticky'] ) ) {
216
-			$sticky_posts = get_option( 'sticky_posts', array() );
217
-			if ( $sticky_posts && $request['sticky'] ) {
215
+		if (isset($registered['sticky'], $request['sticky'])) {
216
+			$sticky_posts = get_option('sticky_posts', array());
217
+			if ($sticky_posts && $request['sticky']) {
218 218
 				/*
219 219
 				 * As post__in will be used to only get sticky posts,
220 220
 				 * we have to support the case where post__in was already
221 221
 				 * specified.
222 222
 				 */
223
-				$args['post__in'] = $args['post__in'] ? array_intersect( $sticky_posts, $args['post__in'] ) : $sticky_posts;
223
+				$args['post__in'] = $args['post__in'] ? array_intersect($sticky_posts, $args['post__in']) : $sticky_posts;
224 224
 
225 225
 				/*
226 226
 				 * If we intersected, but there are no post ids in common,
227 227
 				 * WP_Query won't return "no posts" for post__in = array()
228 228
 				 * so we have to fake it a bit.
229 229
 				 */
230
-				if ( ! $args['post__in'] ) {
230
+				if ( ! $args['post__in']) {
231 231
 					$args['post__in'] = array( -1 );
232 232
 				}
233
-			} elseif ( $sticky_posts ) {
233
+			} elseif ($sticky_posts) {
234 234
 				/*
235 235
 				 * As post___not_in will be used to only get posts that
236 236
 				 * are not sticky, we have to support the case where post__not_in
237 237
 				 * was already specified.
238 238
 				 */
239
-				$args['post__not_in'] = array_merge( $args['post__not_in'], $sticky_posts );
239
+				$args['post__not_in'] = array_merge($args['post__not_in'], $sticky_posts);
240 240
 			}
241 241
 		}
242 242
 
@@ -255,29 +255,29 @@  discard block
 block discarded – undo
255 255
 		 * @param array           $args    Key value array of query var to query value.
256 256
 		 * @param WP_REST_Request $request The request used.
257 257
 		 */
258
-		$args = apply_filters( "rest_{$this->post_type}_query", $args, $request );
259
-		$query_args = $this->prepare_items_query( $args, $request );
258
+		$args = apply_filters("rest_{$this->post_type}_query", $args, $request);
259
+		$query_args = $this->prepare_items_query($args, $request);
260 260
 
261
-		$taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) );
261
+		$taxonomies = wp_list_filter(get_object_taxonomies($this->post_type, 'objects'), array('show_in_rest' => true));
262 262
 
263
-		foreach ( $taxonomies as $taxonomy ) {
264
-			$base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;
265
-			$tax_exclude = $base . '_exclude';
263
+		foreach ($taxonomies as $taxonomy) {
264
+			$base = ! empty($taxonomy->rest_base) ? $taxonomy->rest_base : $taxonomy->name;
265
+			$tax_exclude = $base.'_exclude';
266 266
 
267
-			if ( ! empty( $request[ $base ] ) ) {
267
+			if ( ! empty($request[$base])) {
268 268
 				$query_args['tax_query'][] = array(
269 269
 					'taxonomy'         => $taxonomy->name,
270 270
 					'field'            => 'term_id',
271
-					'terms'            => $request[ $base ],
271
+					'terms'            => $request[$base],
272 272
 					'include_children' => false,
273 273
 				);
274 274
 			}
275 275
 
276
-			if ( ! empty( $request[ $tax_exclude ] ) ) {
276
+			if ( ! empty($request[$tax_exclude])) {
277 277
 				$query_args['tax_query'][] = array(
278 278
 					'taxonomy'         => $taxonomy->name,
279 279
 					'field'            => 'term_id',
280
-					'terms'            => $request[ $tax_exclude ],
280
+					'terms'            => $request[$tax_exclude],
281 281
 					'include_children' => false,
282 282
 					'operator'         => 'NOT IN',
283 283
 				);
@@ -285,65 +285,65 @@  discard block
 block discarded – undo
285 285
 		}
286 286
 
287 287
 		$posts_query  = new WP_Query();
288
-		$query_result = $posts_query->query( $query_args );
288
+		$query_result = $posts_query->query($query_args);
289 289
 
290 290
 		// Allow access to all password protected posts if the context is edit.
291
-		if ( 'edit' === $request['context'] ) {
292
-			add_filter( 'post_password_required', '__return_false' );
291
+		if ('edit' === $request['context']) {
292
+			add_filter('post_password_required', '__return_false');
293 293
 		}
294 294
 
295 295
 		$posts = array();
296 296
 
297
-		foreach ( $query_result as $post ) {
298
-			if ( ! $this->check_read_permission( $post ) ) {
297
+		foreach ($query_result as $post) {
298
+			if ( ! $this->check_read_permission($post)) {
299 299
 				continue;
300 300
 			}
301 301
 
302
-			$data    = $this->prepare_item_for_response( $post, $request );
303
-			$posts[] = $this->prepare_response_for_collection( $data );
302
+			$data    = $this->prepare_item_for_response($post, $request);
303
+			$posts[] = $this->prepare_response_for_collection($data);
304 304
 		}
305 305
 
306 306
 		// Reset filter.
307
-		if ( 'edit' === $request['context'] ) {
308
-			remove_filter( 'post_password_required', '__return_false' );
307
+		if ('edit' === $request['context']) {
308
+			remove_filter('post_password_required', '__return_false');
309 309
 		}
310 310
 
311 311
 		$page = (int) $query_args['paged'];
312 312
 		$total_posts = $posts_query->found_posts;
313 313
 
314
-		if ( $total_posts < 1 ) {
314
+		if ($total_posts < 1) {
315 315
 			// Out-of-bounds, run the query again without LIMIT for total count.
316
-			unset( $query_args['paged'] );
316
+			unset($query_args['paged']);
317 317
 
318 318
 			$count_query = new WP_Query();
319
-			$count_query->query( $query_args );
319
+			$count_query->query($query_args);
320 320
 			$total_posts = $count_query->found_posts;
321 321
 		}
322 322
 
323
-		$max_pages = ceil( $total_posts / (int) $posts_query->query_vars['posts_per_page'] );
324
-		$response  = rest_ensure_response( $posts );
323
+		$max_pages = ceil($total_posts / (int) $posts_query->query_vars['posts_per_page']);
324
+		$response  = rest_ensure_response($posts);
325 325
 
326
-		$response->header( 'X-WP-Total', (int) $total_posts );
327
-		$response->header( 'X-WP-TotalPages', (int) $max_pages );
326
+		$response->header('X-WP-Total', (int) $total_posts);
327
+		$response->header('X-WP-TotalPages', (int) $max_pages);
328 328
 
329 329
 		$request_params = $request->get_query_params();
330
-		$base = add_query_arg( $request_params, rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ) );
330
+		$base = add_query_arg($request_params, rest_url(sprintf('%s/%s', $this->namespace, $this->rest_base)));
331 331
 
332
-		if ( $page > 1 ) {
332
+		if ($page > 1) {
333 333
 			$prev_page = $page - 1;
334 334
 
335
-			if ( $prev_page > $max_pages ) {
335
+			if ($prev_page > $max_pages) {
336 336
 				$prev_page = $max_pages;
337 337
 			}
338 338
 
339
-			$prev_link = add_query_arg( 'page', $prev_page, $base );
340
-			$response->link_header( 'prev', $prev_link );
339
+			$prev_link = add_query_arg('page', $prev_page, $base);
340
+			$response->link_header('prev', $prev_link);
341 341
 		}
342
-		if ( $max_pages > $page ) {
342
+		if ($max_pages > $page) {
343 343
 			$next_page = $page + 1;
344
-			$next_link = add_query_arg( 'page', $next_page, $base );
344
+			$next_link = add_query_arg('page', $next_page, $base);
345 345
 
346
-			$response->link_header( 'next', $next_link );
346
+			$response->link_header('next', $next_link);
347 347
 		}
348 348
 
349 349
 		return $response;
@@ -358,28 +358,28 @@  discard block
 block discarded – undo
358 358
 	 * @param WP_REST_Request $request Full details about the request.
359 359
 	 * @return bool|WP_Error True if the request has read access for the item, WP_Error object otherwise.
360 360
 	 */
361
-	public function get_item_permissions_check( $request ) {
361
+	public function get_item_permissions_check($request) {
362 362
 
363
-		$post = get_post( (int) $request['id'] );
363
+		$post = get_post((int) $request['id']);
364 364
 
365
-		if ( 'edit' === $request['context'] && $post && ! $this->check_update_permission( $post ) ) {
366
-			return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit this post.' ), array( 'status' => rest_authorization_required_code() ) );
365
+		if ('edit' === $request['context'] && $post && ! $this->check_update_permission($post)) {
366
+			return new WP_Error('rest_forbidden_context', __('Sorry, you are not allowed to edit this post.'), array('status' => rest_authorization_required_code()));
367 367
 		}
368 368
 
369
-		if ( $post && ! empty( $request['password'] ) ) {
369
+		if ($post && ! empty($request['password'])) {
370 370
 			// Check post password, and return error if invalid.
371
-			if ( ! hash_equals( $post->post_password, $request['password'] ) ) {
372
-				return new WP_Error( 'rest_post_incorrect_password', __( 'Incorrect post password.' ), array( 'status' => 403 ) );
371
+			if ( ! hash_equals($post->post_password, $request['password'])) {
372
+				return new WP_Error('rest_post_incorrect_password', __('Incorrect post password.'), array('status' => 403));
373 373
 			}
374 374
 		}
375 375
 
376 376
 		// Allow access to all password protected posts if the context is edit.
377
-		if ( 'edit' === $request['context'] ) {
378
-			add_filter( 'post_password_required', '__return_false' );
377
+		if ('edit' === $request['context']) {
378
+			add_filter('post_password_required', '__return_false');
379 379
 		}
380 380
 
381
-		if ( $post ) {
382
-			return $this->check_read_permission( $post );
381
+		if ($post) {
382
+			return $this->check_read_permission($post);
383 383
 		}
384 384
 
385 385
 		return true;
@@ -398,24 +398,24 @@  discard block
 block discarded – undo
398 398
 	 * @param WP_REST_Request $request Request data to check.
399 399
 	 * @return bool True if the user can access password-protected content, otherwise false.
400 400
 	 */
401
-	public function can_access_password_content( $post, $request ) {
402
-		if ( empty( $post->post_password ) ) {
401
+	public function can_access_password_content($post, $request) {
402
+		if (empty($post->post_password)) {
403 403
 			// No filter required.
404 404
 			return false;
405 405
 		}
406 406
 
407 407
 		// Edit context always gets access to password-protected posts.
408
-		if ( 'edit' === $request['context'] ) {
408
+		if ('edit' === $request['context']) {
409 409
 			return true;
410 410
 		}
411 411
 
412 412
 		// No password, no auth.
413
-		if ( empty( $request['password'] ) ) {
413
+		if (empty($request['password'])) {
414 414
 			return false;
415 415
 		}
416 416
 
417 417
 		// Double-check the request password.
418
-		return hash_equals( $post->post_password, $request['password'] );
418
+		return hash_equals($post->post_password, $request['password']);
419 419
 	}
420 420
 
421 421
 	/**
@@ -427,19 +427,19 @@  discard block
 block discarded – undo
427 427
 	 * @param WP_REST_Request $request Full details about the request.
428 428
 	 * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
429 429
 	 */
430
-	public function get_item( $request ) {
430
+	public function get_item($request) {
431 431
 		$id   = (int) $request['id'];
432
-		$post = get_post( $id );
432
+		$post = get_post($id);
433 433
 
434
-		if ( empty( $id ) || empty( $post->ID ) || $this->post_type !== $post->post_type ) {
435
-			return new WP_Error( 'rest_post_invalid_id', __( 'Invalid post ID.' ), array( 'status' => 404 ) );
434
+		if (empty($id) || empty($post->ID) || $this->post_type !== $post->post_type) {
435
+			return new WP_Error('rest_post_invalid_id', __('Invalid post ID.'), array('status' => 404));
436 436
 		}
437 437
 
438
-		$data     = $this->prepare_item_for_response( $post, $request );
439
-		$response = rest_ensure_response( $data );
438
+		$data     = $this->prepare_item_for_response($post, $request);
439
+		$response = rest_ensure_response($data);
440 440
 
441
-		if ( is_post_type_viewable( get_post_type_object( $post->post_type ) ) ) {
442
-			$response->link_header( 'alternate',  get_permalink( $id ), array( 'type' => 'text/html' ) );
441
+		if (is_post_type_viewable(get_post_type_object($post->post_type))) {
442
+			$response->link_header('alternate', get_permalink($id), array('type' => 'text/html'));
443 443
 		}
444 444
 
445 445
 		return $response;
@@ -454,24 +454,24 @@  discard block
 block discarded – undo
454 454
 	 * @param WP_REST_Request $request Full details about the request.
455 455
 	 * @return true|WP_Error True if the request has access to create items, WP_Error object otherwise.
456 456
 	 */
457
-	public function create_item_permissions_check( $request ) {
457
+	public function create_item_permissions_check($request) {
458 458
 
459
-		$post_type = get_post_type_object( $this->post_type );
459
+		$post_type = get_post_type_object($this->post_type);
460 460
 
461
-		if ( ! empty( $request['author'] ) && get_current_user_id() !== $request['author'] && ! current_user_can( $post_type->cap->edit_others_posts ) ) {
462
-			return new WP_Error( 'rest_cannot_edit_others', __( 'Sorry, you are not allowed to create posts as this user.' ), array( 'status' => rest_authorization_required_code() ) );
461
+		if ( ! empty($request['author']) && get_current_user_id() !== $request['author'] && ! current_user_can($post_type->cap->edit_others_posts)) {
462
+			return new WP_Error('rest_cannot_edit_others', __('Sorry, you are not allowed to create posts as this user.'), array('status' => rest_authorization_required_code()));
463 463
 		}
464 464
 
465
-		if ( ! empty( $request['sticky'] ) && ! current_user_can( $post_type->cap->edit_others_posts ) ) {
466
-			return new WP_Error( 'rest_cannot_assign_sticky', __( 'Sorry, you are not allowed to make posts sticky.' ), array( 'status' => rest_authorization_required_code() ) );
465
+		if ( ! empty($request['sticky']) && ! current_user_can($post_type->cap->edit_others_posts)) {
466
+			return new WP_Error('rest_cannot_assign_sticky', __('Sorry, you are not allowed to make posts sticky.'), array('status' => rest_authorization_required_code()));
467 467
 		}
468 468
 
469
-		if ( ! current_user_can( $post_type->cap->create_posts ) ) {
470
-			return new WP_Error( 'rest_cannot_create', __( 'Sorry, you are not allowed to create posts as this user.' ), array( 'status' => rest_authorization_required_code() ) );
469
+		if ( ! current_user_can($post_type->cap->create_posts)) {
470
+			return new WP_Error('rest_cannot_create', __('Sorry, you are not allowed to create posts as this user.'), array('status' => rest_authorization_required_code()));
471 471
 		}
472 472
 
473
-		if ( ! $this->check_assign_terms_permission( $request ) ) {
474
-			return new WP_Error( 'rest_cannot_assign_term', __( 'Sorry, you are not allowed to assign the provided terms.' ), array( 'status' => rest_authorization_required_code() ) );
473
+		if ( ! $this->check_assign_terms_permission($request)) {
474
+			return new WP_Error('rest_cannot_assign_term', __('Sorry, you are not allowed to assign the provided terms.'), array('status' => rest_authorization_required_code()));
475 475
 		}
476 476
 
477 477
 		return true;
@@ -486,33 +486,33 @@  discard block
 block discarded – undo
486 486
 	 * @param WP_REST_Request $request Full details about the request.
487 487
 	 * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
488 488
 	 */
489
-	public function create_item( $request ) {
490
-		if ( ! empty( $request['id'] ) ) {
491
-			return new WP_Error( 'rest_post_exists', __( 'Cannot create existing post.' ), array( 'status' => 400 ) );
489
+	public function create_item($request) {
490
+		if ( ! empty($request['id'])) {
491
+			return new WP_Error('rest_post_exists', __('Cannot create existing post.'), array('status' => 400));
492 492
 		}
493 493
 
494
-		$prepared_post = $this->prepare_item_for_database( $request );
494
+		$prepared_post = $this->prepare_item_for_database($request);
495 495
 
496
-		if ( is_wp_error( $prepared_post ) ) {
496
+		if (is_wp_error($prepared_post)) {
497 497
 			return $prepared_post;
498 498
 		}
499 499
 
500 500
 		$prepared_post->post_type = $this->post_type;
501 501
 
502
-		$post_id = wp_insert_post( wp_slash( (array) $prepared_post ), true );
502
+		$post_id = wp_insert_post(wp_slash((array) $prepared_post), true);
503 503
 
504
-		if ( is_wp_error( $post_id ) ) {
504
+		if (is_wp_error($post_id)) {
505 505
 
506
-			if ( 'db_insert_error' === $post_id->get_error_code() ) {
507
-				$post_id->add_data( array( 'status' => 500 ) );
506
+			if ('db_insert_error' === $post_id->get_error_code()) {
507
+				$post_id->add_data(array('status' => 500));
508 508
 			} else {
509
-				$post_id->add_data( array( 'status' => 400 ) );
509
+				$post_id->add_data(array('status' => 400));
510 510
 			}
511 511
 
512 512
 			return $post_id;
513 513
 		}
514 514
 
515
-		$post = get_post( $post_id );
515
+		$post = get_post($post_id);
516 516
 
517 517
 		/**
518 518
 		 * Fires after a single post is created or updated via the REST API.
@@ -525,58 +525,58 @@  discard block
 block discarded – undo
525 525
 		 * @param WP_REST_Request $request  Request object.
526 526
 		 * @param bool            $creating True when creating a post, false when updating.
527 527
 		 */
528
-		do_action( "rest_insert_{$this->post_type}", $post, $request, true );
528
+		do_action("rest_insert_{$this->post_type}", $post, $request, true);
529 529
 
530 530
 		$schema = $this->get_item_schema();
531 531
 
532
-		if ( ! empty( $schema['properties']['sticky'] ) ) {
533
-			if ( ! empty( $request['sticky'] ) ) {
534
-				stick_post( $post_id );
532
+		if ( ! empty($schema['properties']['sticky'])) {
533
+			if ( ! empty($request['sticky'])) {
534
+				stick_post($post_id);
535 535
 			} else {
536
-				unstick_post( $post_id );
536
+				unstick_post($post_id);
537 537
 			}
538 538
 		}
539 539
 
540
-		if ( ! empty( $schema['properties']['featured_media'] ) && isset( $request['featured_media'] ) ) {
541
-			$this->handle_featured_media( $request['featured_media'], $post_id );
540
+		if ( ! empty($schema['properties']['featured_media']) && isset($request['featured_media'])) {
541
+			$this->handle_featured_media($request['featured_media'], $post_id);
542 542
 		}
543 543
 
544
-		if ( ! empty( $schema['properties']['format'] ) && ! empty( $request['format'] ) ) {
545
-			set_post_format( $post, $request['format'] );
544
+		if ( ! empty($schema['properties']['format']) && ! empty($request['format'])) {
545
+			set_post_format($post, $request['format']);
546 546
 		}
547 547
 
548
-		if ( ! empty( $schema['properties']['template'] ) && isset( $request['template'] ) ) {
549
-			$this->handle_template( $request['template'], $post_id );
548
+		if ( ! empty($schema['properties']['template']) && isset($request['template'])) {
549
+			$this->handle_template($request['template'], $post_id);
550 550
 		}
551 551
 
552
-		$terms_update = $this->handle_terms( $post_id, $request );
552
+		$terms_update = $this->handle_terms($post_id, $request);
553 553
 
554
-		if ( is_wp_error( $terms_update ) ) {
554
+		if (is_wp_error($terms_update)) {
555 555
 			return $terms_update;
556 556
 		}
557 557
 
558
-		if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) {
559
-			$meta_update = $this->meta->update_value( $request['meta'], $post_id );
558
+		if ( ! empty($schema['properties']['meta']) && isset($request['meta'])) {
559
+			$meta_update = $this->meta->update_value($request['meta'], $post_id);
560 560
 
561
-			if ( is_wp_error( $meta_update ) ) {
561
+			if (is_wp_error($meta_update)) {
562 562
 				return $meta_update;
563 563
 			}
564 564
 		}
565 565
 
566
-		$post = get_post( $post_id );
567
-		$fields_update = $this->update_additional_fields_for_object( $post, $request );
566
+		$post = get_post($post_id);
567
+		$fields_update = $this->update_additional_fields_for_object($post, $request);
568 568
 
569
-		if ( is_wp_error( $fields_update ) ) {
569
+		if (is_wp_error($fields_update)) {
570 570
 			return $fields_update;
571 571
 		}
572 572
 
573
-		$request->set_param( 'context', 'edit' );
573
+		$request->set_param('context', 'edit');
574 574
 
575
-		$response = $this->prepare_item_for_response( $post, $request );
576
-		$response = rest_ensure_response( $response );
575
+		$response = $this->prepare_item_for_response($post, $request);
576
+		$response = rest_ensure_response($response);
577 577
 
578
-		$response->set_status( 201 );
579
-		$response->header( 'Location', rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $post_id ) ) );
578
+		$response->set_status(201);
579
+		$response->header('Location', rest_url(sprintf('%s/%s/%d', $this->namespace, $this->rest_base, $post_id)));
580 580
 
581 581
 		return $response;
582 582
 	}
@@ -590,25 +590,25 @@  discard block
 block discarded – undo
590 590
 	 * @param WP_REST_Request $request Full details about the request.
591 591
 	 * @return true|WP_Error True if the request has access to update the item, WP_Error object otherwise.
592 592
 	 */
593
-	public function update_item_permissions_check( $request ) {
593
+	public function update_item_permissions_check($request) {
594 594
 
595
-		$post = get_post( $request['id'] );
596
-		$post_type = get_post_type_object( $this->post_type );
595
+		$post = get_post($request['id']);
596
+		$post_type = get_post_type_object($this->post_type);
597 597
 
598
-		if ( $post && ! $this->check_update_permission( $post ) ) {
599
-			return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to edit this post.' ), array( 'status' => rest_authorization_required_code() ) );
598
+		if ($post && ! $this->check_update_permission($post)) {
599
+			return new WP_Error('rest_cannot_edit', __('Sorry, you are not allowed to edit this post.'), array('status' => rest_authorization_required_code()));
600 600
 		}
601 601
 
602
-		if ( ! empty( $request['author'] ) && get_current_user_id() !== $request['author'] && ! current_user_can( $post_type->cap->edit_others_posts ) ) {
603
-			return new WP_Error( 'rest_cannot_edit_others', __( 'Sorry, you are not allowed to update posts as this user.' ), array( 'status' => rest_authorization_required_code() ) );
602
+		if ( ! empty($request['author']) && get_current_user_id() !== $request['author'] && ! current_user_can($post_type->cap->edit_others_posts)) {
603
+			return new WP_Error('rest_cannot_edit_others', __('Sorry, you are not allowed to update posts as this user.'), array('status' => rest_authorization_required_code()));
604 604
 		}
605 605
 
606
-		if ( ! empty( $request['sticky'] ) && ! current_user_can( $post_type->cap->edit_others_posts ) ) {
607
-			return new WP_Error( 'rest_cannot_assign_sticky', __( 'Sorry, you are not allowed to make posts sticky.' ), array( 'status' => rest_authorization_required_code() ) );
606
+		if ( ! empty($request['sticky']) && ! current_user_can($post_type->cap->edit_others_posts)) {
607
+			return new WP_Error('rest_cannot_assign_sticky', __('Sorry, you are not allowed to make posts sticky.'), array('status' => rest_authorization_required_code()));
608 608
 		}
609 609
 
610
-		if ( ! $this->check_assign_terms_permission( $request ) ) {
611
-			return new WP_Error( 'rest_cannot_assign_term', __( 'Sorry, you are not allowed to assign the provided terms.' ), array( 'status' => rest_authorization_required_code() ) );
610
+		if ( ! $this->check_assign_terms_permission($request)) {
611
+			return new WP_Error('rest_cannot_assign_term', __('Sorry, you are not allowed to assign the provided terms.'), array('status' => rest_authorization_required_code()));
612 612
 		}
613 613
 
614 614
 		return true;
@@ -623,85 +623,85 @@  discard block
 block discarded – undo
623 623
 	 * @param WP_REST_Request $request Full details about the request.
624 624
 	 * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
625 625
 	 */
626
-	public function update_item( $request ) {
626
+	public function update_item($request) {
627 627
 		$id   = (int) $request['id'];
628
-		$post = get_post( $id );
628
+		$post = get_post($id);
629 629
 
630
-		if ( empty( $id ) || empty( $post->ID ) || $this->post_type !== $post->post_type ) {
631
-			return new WP_Error( 'rest_post_invalid_id', __( 'Invalid post ID.' ), array( 'status' => 404 ) );
630
+		if (empty($id) || empty($post->ID) || $this->post_type !== $post->post_type) {
631
+			return new WP_Error('rest_post_invalid_id', __('Invalid post ID.'), array('status' => 404));
632 632
 		}
633 633
 
634
-		$post = $this->prepare_item_for_database( $request );
634
+		$post = $this->prepare_item_for_database($request);
635 635
 
636
-		if ( is_wp_error( $post ) ) {
636
+		if (is_wp_error($post)) {
637 637
 			return $post;
638 638
 		}
639 639
 
640 640
 		// convert the post object to an array, otherwise wp_update_post will expect non-escaped input.
641
-		$post_id = wp_update_post( wp_slash( (array) $post ), true );
641
+		$post_id = wp_update_post(wp_slash((array) $post), true);
642 642
 
643
-		if ( is_wp_error( $post_id ) ) {
644
-			if ( 'db_update_error' === $post_id->get_error_code() ) {
645
-				$post_id->add_data( array( 'status' => 500 ) );
643
+		if (is_wp_error($post_id)) {
644
+			if ('db_update_error' === $post_id->get_error_code()) {
645
+				$post_id->add_data(array('status' => 500));
646 646
 			} else {
647
-				$post_id->add_data( array( 'status' => 400 ) );
647
+				$post_id->add_data(array('status' => 400));
648 648
 			}
649 649
 			return $post_id;
650 650
 		}
651 651
 
652
-		$post = get_post( $post_id );
652
+		$post = get_post($post_id);
653 653
 
654 654
 		/** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php */
655
-		do_action( "rest_insert_{$this->post_type}", $post, $request, false );
655
+		do_action("rest_insert_{$this->post_type}", $post, $request, false);
656 656
 
657 657
 		$schema = $this->get_item_schema();
658 658
 
659
-		if ( ! empty( $schema['properties']['format'] ) && ! empty( $request['format'] ) ) {
660
-			set_post_format( $post, $request['format'] );
659
+		if ( ! empty($schema['properties']['format']) && ! empty($request['format'])) {
660
+			set_post_format($post, $request['format']);
661 661
 		}
662 662
 
663
-		if ( ! empty( $schema['properties']['featured_media'] ) && isset( $request['featured_media'] ) ) {
664
-			$this->handle_featured_media( $request['featured_media'], $post_id );
663
+		if ( ! empty($schema['properties']['featured_media']) && isset($request['featured_media'])) {
664
+			$this->handle_featured_media($request['featured_media'], $post_id);
665 665
 		}
666 666
 
667
-		if ( ! empty( $schema['properties']['sticky'] ) && isset( $request['sticky'] ) ) {
668
-			if ( ! empty( $request['sticky'] ) ) {
669
-				stick_post( $post_id );
667
+		if ( ! empty($schema['properties']['sticky']) && isset($request['sticky'])) {
668
+			if ( ! empty($request['sticky'])) {
669
+				stick_post($post_id);
670 670
 			} else {
671
-				unstick_post( $post_id );
671
+				unstick_post($post_id);
672 672
 			}
673 673
 		}
674 674
 
675
-		if ( ! empty( $schema['properties']['template'] ) && isset( $request['template'] ) ) {
676
-			$this->handle_template( $request['template'], $post->ID );
675
+		if ( ! empty($schema['properties']['template']) && isset($request['template'])) {
676
+			$this->handle_template($request['template'], $post->ID);
677 677
 		}
678 678
 
679
-		$terms_update = $this->handle_terms( $post->ID, $request );
679
+		$terms_update = $this->handle_terms($post->ID, $request);
680 680
 
681
-		if ( is_wp_error( $terms_update ) ) {
681
+		if (is_wp_error($terms_update)) {
682 682
 			return $terms_update;
683 683
 		}
684 684
 
685
-		if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) {
686
-			$meta_update = $this->meta->update_value( $request['meta'], $post->ID );
685
+		if ( ! empty($schema['properties']['meta']) && isset($request['meta'])) {
686
+			$meta_update = $this->meta->update_value($request['meta'], $post->ID);
687 687
 
688
-			if ( is_wp_error( $meta_update ) ) {
688
+			if (is_wp_error($meta_update)) {
689 689
 				return $meta_update;
690 690
 			}
691 691
 		}
692 692
 
693
-		$post = get_post( $post_id );
694
-		$fields_update = $this->update_additional_fields_for_object( $post, $request );
693
+		$post = get_post($post_id);
694
+		$fields_update = $this->update_additional_fields_for_object($post, $request);
695 695
 
696
-		if ( is_wp_error( $fields_update ) ) {
696
+		if (is_wp_error($fields_update)) {
697 697
 			return $fields_update;
698 698
 		}
699 699
 
700
-		$request->set_param( 'context', 'edit' );
700
+		$request->set_param('context', 'edit');
701 701
 
702
-		$response = $this->prepare_item_for_response( $post, $request );
702
+		$response = $this->prepare_item_for_response($post, $request);
703 703
 
704
-		return rest_ensure_response( $response );
704
+		return rest_ensure_response($response);
705 705
 	}
706 706
 
707 707
 	/**
@@ -713,12 +713,12 @@  discard block
 block discarded – undo
713 713
 	 * @param WP_REST_Request $request Full details about the request.
714 714
 	 * @return true|WP_Error True if the request has access to delete the item, WP_Error object otherwise.
715 715
 	 */
716
-	public function delete_item_permissions_check( $request ) {
716
+	public function delete_item_permissions_check($request) {
717 717
 
718
-		$post = get_post( $request['id'] );
718
+		$post = get_post($request['id']);
719 719
 
720
-		if ( $post && ! $this->check_delete_permission( $post ) ) {
721
-			return new WP_Error( 'rest_cannot_delete', __( 'Sorry, you are not allowed to delete this post.' ), array( 'status' => rest_authorization_required_code() ) );
720
+		if ($post && ! $this->check_delete_permission($post)) {
721
+			return new WP_Error('rest_cannot_delete', __('Sorry, you are not allowed to delete this post.'), array('status' => rest_authorization_required_code()));
722 722
 		}
723 723
 
724 724
 		return true;
@@ -733,19 +733,19 @@  discard block
 block discarded – undo
733 733
 	 * @param WP_REST_Request $request Full details about the request.
734 734
 	 * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
735 735
 	 */
736
-	public function delete_item( $request ) {
736
+	public function delete_item($request) {
737 737
 		$id    = (int) $request['id'];
738 738
 		$force = (bool) $request['force'];
739 739
 
740
-		$post = get_post( $id );
740
+		$post = get_post($id);
741 741
 
742
-		if ( empty( $id ) || empty( $post->ID ) || $this->post_type !== $post->post_type ) {
743
-			return new WP_Error( 'rest_post_invalid_id', __( 'Invalid post ID.' ), array( 'status' => 404 ) );
742
+		if (empty($id) || empty($post->ID) || $this->post_type !== $post->post_type) {
743
+			return new WP_Error('rest_post_invalid_id', __('Invalid post ID.'), array('status' => 404));
744 744
 		}
745 745
 
746
-		$supports_trash = ( EMPTY_TRASH_DAYS > 0 );
746
+		$supports_trash = (EMPTY_TRASH_DAYS > 0);
747 747
 
748
-		if ( 'attachment' === $post->post_type ) {
748
+		if ('attachment' === $post->post_type) {
749 749
 			$supports_trash = $supports_trash && MEDIA_TRASH;
750 750
 		}
751 751
 
@@ -761,41 +761,41 @@  discard block
 block discarded – undo
761 761
 		 * @param bool    $supports_trash Whether the post type support trashing.
762 762
 		 * @param WP_Post $post           The Post object being considered for trashing support.
763 763
 		 */
764
-		$supports_trash = apply_filters( "rest_{$this->post_type}_trashable", $supports_trash, $post );
764
+		$supports_trash = apply_filters("rest_{$this->post_type}_trashable", $supports_trash, $post);
765 765
 
766
-		if ( ! $this->check_delete_permission( $post ) ) {
767
-			return new WP_Error( 'rest_user_cannot_delete_post', __( 'Sorry, you are not allowed to delete this post.' ), array( 'status' => rest_authorization_required_code() ) );
766
+		if ( ! $this->check_delete_permission($post)) {
767
+			return new WP_Error('rest_user_cannot_delete_post', __('Sorry, you are not allowed to delete this post.'), array('status' => rest_authorization_required_code()));
768 768
 		}
769 769
 
770
-		$request->set_param( 'context', 'edit' );
770
+		$request->set_param('context', 'edit');
771 771
 
772 772
 
773 773
 		// If we're forcing, then delete permanently.
774
-		if ( $force ) {
775
-			$previous = $this->prepare_item_for_response( $post, $request );
776
-			$result = wp_delete_post( $id, true );
774
+		if ($force) {
775
+			$previous = $this->prepare_item_for_response($post, $request);
776
+			$result = wp_delete_post($id, true);
777 777
 			$response = new WP_REST_Response();
778
-			$response->set_data( array( 'deleted' => true, 'previous' => $previous->get_data() ) );
778
+			$response->set_data(array('deleted' => true, 'previous' => $previous->get_data()));
779 779
 		} else {
780 780
 			// If we don't support trashing for this type, error out.
781
-			if ( ! $supports_trash ) {
782
-				return new WP_Error( 'rest_trash_not_supported', __( 'The post does not support trashing. Set force=true to delete.' ), array( 'status' => 501 ) );
781
+			if ( ! $supports_trash) {
782
+				return new WP_Error('rest_trash_not_supported', __('The post does not support trashing. Set force=true to delete.'), array('status' => 501));
783 783
 			}
784 784
 
785 785
 			// Otherwise, only trash if we haven't already.
786
-			if ( 'trash' === $post->post_status ) {
787
-				return new WP_Error( 'rest_already_trashed', __( 'The post has already been deleted.' ), array( 'status' => 410 ) );
786
+			if ('trash' === $post->post_status) {
787
+				return new WP_Error('rest_already_trashed', __('The post has already been deleted.'), array('status' => 410));
788 788
 			}
789 789
 
790 790
 			// (Note that internally this falls through to `wp_delete_post` if
791 791
 			// the trash is disabled.)
792
-			$result = wp_trash_post( $id );
793
-			$post = get_post( $id );
794
-			$response = $this->prepare_item_for_response( $post, $request );
792
+			$result = wp_trash_post($id);
793
+			$post = get_post($id);
794
+			$response = $this->prepare_item_for_response($post, $request);
795 795
 		}
796 796
 
797
-		if ( ! $result ) {
798
-			return new WP_Error( 'rest_cannot_delete', __( 'The post cannot be deleted.' ), array( 'status' => 500 ) );
797
+		if ( ! $result) {
798
+			return new WP_Error('rest_cannot_delete', __('The post cannot be deleted.'), array('status' => 500));
799 799
 		}
800 800
 
801 801
 		/**
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
 		 * @param WP_REST_Response $response The response data.
810 810
 		 * @param WP_REST_Request  $request  The request sent to the API.
811 811
 		 */
812
-		do_action( "rest_delete_{$this->post_type}", $post, $response, $request );
812
+		do_action("rest_delete_{$this->post_type}", $post, $response, $request);
813 813
 
814 814
 		return $response;
815 815
 	}
@@ -825,10 +825,10 @@  discard block
 block discarded – undo
825 825
 	 * @param WP_REST_Request $request       Optional. Full details about the request.
826 826
 	 * @return array Items query arguments.
827 827
 	 */
828
-	protected function prepare_items_query( $prepared_args = array(), $request = null ) {
828
+	protected function prepare_items_query($prepared_args = array(), $request = null) {
829 829
 		$query_args = array();
830 830
 
831
-		foreach ( $prepared_args as $key => $value ) {
831
+		foreach ($prepared_args as $key => $value) {
832 832
 			/**
833 833
 			 * Filters the query_vars used in get_items() for the constructed query.
834 834
 			 *
@@ -838,23 +838,23 @@  discard block
 block discarded – undo
838 838
 			 *
839 839
 			 * @param string $value The query_var value.
840 840
 			 */
841
-			$query_args[ $key ] = apply_filters( "rest_query_var-{$key}", $value );
841
+			$query_args[$key] = apply_filters("rest_query_var-{$key}", $value);
842 842
 		}
843 843
 
844
-		if ( 'post' !== $this->post_type || ! isset( $query_args['ignore_sticky_posts'] ) ) {
844
+		if ('post' !== $this->post_type || ! isset($query_args['ignore_sticky_posts'])) {
845 845
 			$query_args['ignore_sticky_posts'] = true;
846 846
 		}
847 847
 
848 848
 		// Map to proper WP_Query orderby param.
849
-		if ( isset( $query_args['orderby'] ) && isset( $request['orderby'] ) ) {
849
+		if (isset($query_args['orderby']) && isset($request['orderby'])) {
850 850
 			$orderby_mappings = array(
851 851
 				'id'      => 'ID',
852 852
 				'include' => 'post__in',
853 853
 				'slug'    => 'post_name',
854 854
 			);
855 855
 
856
-			if ( isset( $orderby_mappings[ $request['orderby'] ] ) ) {
857
-				$query_args['orderby'] = $orderby_mappings[ $request['orderby'] ];
856
+			if (isset($orderby_mappings[$request['orderby']])) {
857
+				$query_args['orderby'] = $orderby_mappings[$request['orderby']];
858 858
 			}
859 859
 		}
860 860
 
@@ -872,19 +872,19 @@  discard block
 block discarded – undo
872 872
 	 * @param string|null $date     Optional. Local publication time. Default null.
873 873
 	 * @return string|null ISO8601/RFC3339 formatted datetime.
874 874
 	 */
875
-	protected function prepare_date_response( $date_gmt, $date = null ) {
875
+	protected function prepare_date_response($date_gmt, $date = null) {
876 876
 		// Use the date if passed.
877
-		if ( isset( $date ) ) {
878
-			return mysql_to_rfc3339( $date );
877
+		if (isset($date)) {
878
+			return mysql_to_rfc3339($date);
879 879
 		}
880 880
 
881 881
 		// Return null if $date_gmt is empty/zeros.
882
-		if ( '0000-00-00 00:00:00' === $date_gmt ) {
882
+		if ('0000-00-00 00:00:00' === $date_gmt) {
883 883
 			return null;
884 884
 		}
885 885
 
886 886
 		// Return the formatted datetime.
887
-		return mysql_to_rfc3339( $date_gmt );
887
+		return mysql_to_rfc3339($date_gmt);
888 888
 	}
889 889
 
890 890
 	/**
@@ -896,59 +896,59 @@  discard block
 block discarded – undo
896 896
 	 * @param WP_REST_Request $request Request object.
897 897
 	 * @return stdClass|WP_Error Post object or WP_Error.
898 898
 	 */
899
-	protected function prepare_item_for_database( $request ) {
899
+	protected function prepare_item_for_database($request) {
900 900
 		$prepared_post = new stdClass;
901 901
 
902 902
 		// Post ID.
903
-		if ( isset( $request['id'] ) ) {
904
-			$prepared_post->ID = absint( $request['id'] );
903
+		if (isset($request['id'])) {
904
+			$prepared_post->ID = absint($request['id']);
905 905
 		}
906 906
 
907 907
 		$schema = $this->get_item_schema();
908 908
 
909 909
 		// Post title.
910
-		if ( ! empty( $schema['properties']['title'] ) && isset( $request['title'] ) ) {
911
-			if ( is_string( $request['title'] ) ) {
910
+		if ( ! empty($schema['properties']['title']) && isset($request['title'])) {
911
+			if (is_string($request['title'])) {
912 912
 				$prepared_post->post_title = $request['title'];
913
-			} elseif ( ! empty( $request['title']['raw'] ) ) {
913
+			} elseif ( ! empty($request['title']['raw'])) {
914 914
 				$prepared_post->post_title = $request['title']['raw'];
915 915
 			}
916 916
 		}
917 917
 
918 918
 		// Post content.
919
-		if ( ! empty( $schema['properties']['content'] ) && isset( $request['content'] ) ) {
920
-			if ( is_string( $request['content'] ) ) {
919
+		if ( ! empty($schema['properties']['content']) && isset($request['content'])) {
920
+			if (is_string($request['content'])) {
921 921
 				$prepared_post->post_content = $request['content'];
922
-			} elseif ( isset( $request['content']['raw'] ) ) {
922
+			} elseif (isset($request['content']['raw'])) {
923 923
 				$prepared_post->post_content = $request['content']['raw'];
924 924
 			}
925 925
 		}
926 926
 
927 927
 		// Post excerpt.
928
-		if ( ! empty( $schema['properties']['excerpt'] ) && isset( $request['excerpt'] ) ) {
929
-			if ( is_string( $request['excerpt'] ) ) {
928
+		if ( ! empty($schema['properties']['excerpt']) && isset($request['excerpt'])) {
929
+			if (is_string($request['excerpt'])) {
930 930
 				$prepared_post->post_excerpt = $request['excerpt'];
931
-			} elseif ( isset( $request['excerpt']['raw'] ) ) {
931
+			} elseif (isset($request['excerpt']['raw'])) {
932 932
 				$prepared_post->post_excerpt = $request['excerpt']['raw'];
933 933
 			}
934 934
 		}
935 935
 
936 936
 		// Post type.
937
-		if ( empty( $request['id'] ) ) {
937
+		if (empty($request['id'])) {
938 938
 			// Creating new post, use default type for the controller.
939 939
 			$prepared_post->post_type = $this->post_type;
940 940
 		} else {
941 941
 			// Updating a post, use previous type.
942
-			$prepared_post->post_type = get_post_type( $request['id'] );
942
+			$prepared_post->post_type = get_post_type($request['id']);
943 943
 		}
944 944
 
945
-		$post_type = get_post_type_object( $prepared_post->post_type );
945
+		$post_type = get_post_type_object($prepared_post->post_type);
946 946
 
947 947
 		// Post status.
948
-		if ( ! empty( $schema['properties']['status'] ) && isset( $request['status'] ) ) {
949
-			$status = $this->handle_status_param( $request['status'], $post_type );
948
+		if ( ! empty($schema['properties']['status']) && isset($request['status'])) {
949
+			$status = $this->handle_status_param($request['status'], $post_type);
950 950
 
951
-			if ( is_wp_error( $status ) ) {
951
+			if (is_wp_error($status)) {
952 952
 				return $status;
953 953
 			}
954 954
 
@@ -956,34 +956,34 @@  discard block
 block discarded – undo
956 956
 		}
957 957
 
958 958
 		// Post date.
959
-		if ( ! empty( $schema['properties']['date'] ) && ! empty( $request['date'] ) ) {
960
-			$date_data = rest_get_date_with_gmt( $request['date'] );
959
+		if ( ! empty($schema['properties']['date']) && ! empty($request['date'])) {
960
+			$date_data = rest_get_date_with_gmt($request['date']);
961 961
 
962
-			if ( ! empty( $date_data ) ) {
963
-				list( $prepared_post->post_date, $prepared_post->post_date_gmt ) = $date_data;
962
+			if ( ! empty($date_data)) {
963
+				list($prepared_post->post_date, $prepared_post->post_date_gmt) = $date_data;
964 964
 			}
965
-		} elseif ( ! empty( $schema['properties']['date_gmt'] ) && ! empty( $request['date_gmt'] ) ) {
966
-			$date_data = rest_get_date_with_gmt( $request['date_gmt'], true );
965
+		} elseif ( ! empty($schema['properties']['date_gmt']) && ! empty($request['date_gmt'])) {
966
+			$date_data = rest_get_date_with_gmt($request['date_gmt'], true);
967 967
 
968
-			if ( ! empty( $date_data ) ) {
969
-				list( $prepared_post->post_date, $prepared_post->post_date_gmt ) = $date_data;
968
+			if ( ! empty($date_data)) {
969
+				list($prepared_post->post_date, $prepared_post->post_date_gmt) = $date_data;
970 970
 			}
971 971
 		}
972 972
 
973 973
 		// Post slug.
974
-		if ( ! empty( $schema['properties']['slug'] ) && isset( $request['slug'] ) ) {
974
+		if ( ! empty($schema['properties']['slug']) && isset($request['slug'])) {
975 975
 			$prepared_post->post_name = $request['slug'];
976 976
 		}
977 977
 
978 978
 		// Author.
979
-		if ( ! empty( $schema['properties']['author'] ) && ! empty( $request['author'] ) ) {
979
+		if ( ! empty($schema['properties']['author']) && ! empty($request['author'])) {
980 980
 			$post_author = (int) $request['author'];
981 981
 
982
-			if ( get_current_user_id() !== $post_author ) {
983
-				$user_obj = get_userdata( $post_author );
982
+			if (get_current_user_id() !== $post_author) {
983
+				$user_obj = get_userdata($post_author);
984 984
 
985
-				if ( ! $user_obj ) {
986
-					return new WP_Error( 'rest_invalid_author', __( 'Invalid author ID.' ), array( 'status' => 400 ) );
985
+				if ( ! $user_obj) {
986
+					return new WP_Error('rest_invalid_author', __('Invalid author ID.'), array('status' => 400));
987 987
 				}
988 988
 			}
989 989
 
@@ -991,51 +991,51 @@  discard block
 block discarded – undo
991 991
 		}
992 992
 
993 993
 		// Post password.
994
-		if ( ! empty( $schema['properties']['password'] ) && isset( $request['password'] ) ) {
994
+		if ( ! empty($schema['properties']['password']) && isset($request['password'])) {
995 995
 			$prepared_post->post_password = $request['password'];
996 996
 
997
-			if ( '' !== $request['password'] ) {
998
-				if ( ! empty( $schema['properties']['sticky'] ) && ! empty( $request['sticky'] ) ) {
999
-					return new WP_Error( 'rest_invalid_field', __( 'A post can not be sticky and have a password.' ), array( 'status' => 400 ) );
997
+			if ('' !== $request['password']) {
998
+				if ( ! empty($schema['properties']['sticky']) && ! empty($request['sticky'])) {
999
+					return new WP_Error('rest_invalid_field', __('A post can not be sticky and have a password.'), array('status' => 400));
1000 1000
 				}
1001 1001
 
1002
-				if ( ! empty( $prepared_post->ID ) && is_sticky( $prepared_post->ID ) ) {
1003
-					return new WP_Error( 'rest_invalid_field', __( 'A sticky post can not be password protected.' ), array( 'status' => 400 ) );
1002
+				if ( ! empty($prepared_post->ID) && is_sticky($prepared_post->ID)) {
1003
+					return new WP_Error('rest_invalid_field', __('A sticky post can not be password protected.'), array('status' => 400));
1004 1004
 				}
1005 1005
 			}
1006 1006
 		}
1007 1007
 
1008
-		if ( ! empty( $schema['properties']['sticky'] ) && ! empty( $request['sticky'] ) ) {
1009
-			if ( ! empty( $prepared_post->ID ) && post_password_required( $prepared_post->ID ) ) {
1010
-				return new WP_Error( 'rest_invalid_field', __( 'A password protected post can not be set to sticky.' ), array( 'status' => 400 ) );
1008
+		if ( ! empty($schema['properties']['sticky']) && ! empty($request['sticky'])) {
1009
+			if ( ! empty($prepared_post->ID) && post_password_required($prepared_post->ID)) {
1010
+				return new WP_Error('rest_invalid_field', __('A password protected post can not be set to sticky.'), array('status' => 400));
1011 1011
 			}
1012 1012
 		}
1013 1013
 
1014 1014
 		// Parent.
1015
-		if ( ! empty( $schema['properties']['parent'] ) && isset( $request['parent'] ) ) {
1016
-			if ( 0 === (int) $request['parent'] ) {
1015
+		if ( ! empty($schema['properties']['parent']) && isset($request['parent'])) {
1016
+			if (0 === (int) $request['parent']) {
1017 1017
 				$prepared_post->post_parent = 0;
1018 1018
 			} else {
1019
-				$parent = get_post( (int) $request['parent'] );
1020
-				if ( empty( $parent ) ) {
1021
-					return new WP_Error( 'rest_post_invalid_id', __( 'Invalid post parent ID.' ), array( 'status' => 400 ) );
1019
+				$parent = get_post((int) $request['parent']);
1020
+				if (empty($parent)) {
1021
+					return new WP_Error('rest_post_invalid_id', __('Invalid post parent ID.'), array('status' => 400));
1022 1022
 				}
1023 1023
 				$prepared_post->post_parent = (int) $parent->ID;
1024 1024
 			}
1025 1025
 		}
1026 1026
 
1027 1027
 		// Menu order.
1028
-		if ( ! empty( $schema['properties']['menu_order'] ) && isset( $request['menu_order'] ) ) {
1028
+		if ( ! empty($schema['properties']['menu_order']) && isset($request['menu_order'])) {
1029 1029
 			$prepared_post->menu_order = (int) $request['menu_order'];
1030 1030
 		}
1031 1031
 
1032 1032
 		// Comment status.
1033
-		if ( ! empty( $schema['properties']['comment_status'] ) && ! empty( $request['comment_status'] ) ) {
1033
+		if ( ! empty($schema['properties']['comment_status']) && ! empty($request['comment_status'])) {
1034 1034
 			$prepared_post->comment_status = $request['comment_status'];
1035 1035
 		}
1036 1036
 
1037 1037
 		// Ping status.
1038
-		if ( ! empty( $schema['properties']['ping_status'] ) && ! empty( $request['ping_status'] ) ) {
1038
+		if ( ! empty($schema['properties']['ping_status']) && ! empty($request['ping_status'])) {
1039 1039
 			$prepared_post->ping_status = $request['ping_status'];
1040 1040
 		}
1041 1041
 
@@ -1050,7 +1050,7 @@  discard block
 block discarded – undo
1050 1050
 		 *                                       for inserting or updating the database.
1051 1051
 		 * @param WP_REST_Request $request       Request object.
1052 1052
 		 */
1053
-		return apply_filters( "rest_pre_insert_{$this->post_type}", $prepared_post, $request );
1053
+		return apply_filters("rest_pre_insert_{$this->post_type}", $prepared_post, $request);
1054 1054
 
1055 1055
 	}
1056 1056
 
@@ -1064,25 +1064,25 @@  discard block
 block discarded – undo
1064 1064
 	 * @param object $post_type   Post type.
1065 1065
 	 * @return string|WP_Error Post status or WP_Error if lacking the proper permission.
1066 1066
 	 */
1067
-	protected function handle_status_param( $post_status, $post_type ) {
1067
+	protected function handle_status_param($post_status, $post_type) {
1068 1068
 
1069
-		switch ( $post_status ) {
1069
+		switch ($post_status) {
1070 1070
 			case 'draft':
1071 1071
 			case 'pending':
1072 1072
 				break;
1073 1073
 			case 'private':
1074
-				if ( ! current_user_can( $post_type->cap->publish_posts ) ) {
1075
-					return new WP_Error( 'rest_cannot_publish', __( 'Sorry, you are not allowed to create private posts in this post type.' ), array( 'status' => rest_authorization_required_code() ) );
1074
+				if ( ! current_user_can($post_type->cap->publish_posts)) {
1075
+					return new WP_Error('rest_cannot_publish', __('Sorry, you are not allowed to create private posts in this post type.'), array('status' => rest_authorization_required_code()));
1076 1076
 				}
1077 1077
 				break;
1078 1078
 			case 'publish':
1079 1079
 			case 'future':
1080
-				if ( ! current_user_can( $post_type->cap->publish_posts ) ) {
1081
-					return new WP_Error( 'rest_cannot_publish', __( 'Sorry, you are not allowed to publish posts in this post type.' ), array( 'status' => rest_authorization_required_code() ) );
1080
+				if ( ! current_user_can($post_type->cap->publish_posts)) {
1081
+					return new WP_Error('rest_cannot_publish', __('Sorry, you are not allowed to publish posts in this post type.'), array('status' => rest_authorization_required_code()));
1082 1082
 				}
1083 1083
 				break;
1084 1084
 			default:
1085
-				if ( ! get_post_status_object( $post_status ) ) {
1085
+				if ( ! get_post_status_object($post_status)) {
1086 1086
 					$post_status = 'draft';
1087 1087
 				}
1088 1088
 				break;
@@ -1101,18 +1101,18 @@  discard block
 block discarded – undo
1101 1101
 	 * @param int $post_id        Post ID.
1102 1102
 	 * @return bool|WP_Error Whether the post thumbnail was successfully deleted, otherwise WP_Error.
1103 1103
 	 */
1104
-	protected function handle_featured_media( $featured_media, $post_id ) {
1104
+	protected function handle_featured_media($featured_media, $post_id) {
1105 1105
 
1106 1106
 		$featured_media = (int) $featured_media;
1107
-		if ( $featured_media ) {
1108
-			$result = set_post_thumbnail( $post_id, $featured_media );
1109
-			if ( $result ) {
1107
+		if ($featured_media) {
1108
+			$result = set_post_thumbnail($post_id, $featured_media);
1109
+			if ($result) {
1110 1110
 				return true;
1111 1111
 			} else {
1112
-				return new WP_Error( 'rest_invalid_featured_media', __( 'Invalid featured media ID.' ), array( 'status' => 400 ) );
1112
+				return new WP_Error('rest_invalid_featured_media', __('Invalid featured media ID.'), array('status' => 400));
1113 1113
 			}
1114 1114
 		} else {
1115
-			return delete_post_thumbnail( $post_id );
1115
+			return delete_post_thumbnail($post_id);
1116 1116
 		}
1117 1117
 
1118 1118
 	}
@@ -1126,11 +1126,11 @@  discard block
 block discarded – undo
1126 1126
 	 * @param string  $template Page template filename.
1127 1127
 	 * @param integer $post_id  Post ID.
1128 1128
 	 */
1129
-	public function handle_template( $template, $post_id ) {
1130
-		if ( in_array( $template, array_keys( wp_get_theme()->get_page_templates( get_post( $post_id ) ) ), true ) ) {
1131
-			update_post_meta( $post_id, '_wp_page_template', $template );
1129
+	public function handle_template($template, $post_id) {
1130
+		if (in_array($template, array_keys(wp_get_theme()->get_page_templates(get_post($post_id))), true)) {
1131
+			update_post_meta($post_id, '_wp_page_template', $template);
1132 1132
 		} else {
1133
-			update_post_meta( $post_id, '_wp_page_template', '' );
1133
+			update_post_meta($post_id, '_wp_page_template', '');
1134 1134
 		}
1135 1135
 	}
1136 1136
 
@@ -1144,19 +1144,19 @@  discard block
 block discarded – undo
1144 1144
 	 * @param WP_REST_Request $request The request object with post and terms data.
1145 1145
 	 * @return null|WP_Error WP_Error on an error assigning any of the terms, otherwise null.
1146 1146
 	 */
1147
-	protected function handle_terms( $post_id, $request ) {
1148
-		$taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) );
1147
+	protected function handle_terms($post_id, $request) {
1148
+		$taxonomies = wp_list_filter(get_object_taxonomies($this->post_type, 'objects'), array('show_in_rest' => true));
1149 1149
 
1150
-		foreach ( $taxonomies as $taxonomy ) {
1151
-			$base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;
1150
+		foreach ($taxonomies as $taxonomy) {
1151
+			$base = ! empty($taxonomy->rest_base) ? $taxonomy->rest_base : $taxonomy->name;
1152 1152
 
1153
-			if ( ! isset( $request[ $base ] ) ) {
1153
+			if ( ! isset($request[$base])) {
1154 1154
 				continue;
1155 1155
 			}
1156 1156
 
1157
-			$result = wp_set_object_terms( $post_id, $request[ $base ], $taxonomy->name );
1157
+			$result = wp_set_object_terms($post_id, $request[$base], $taxonomy->name);
1158 1158
 
1159
-			if ( is_wp_error( $result ) ) {
1159
+			if (is_wp_error($result)) {
1160 1160
 				return $result;
1161 1161
 			}
1162 1162
 		}
@@ -1171,22 +1171,22 @@  discard block
 block discarded – undo
1171 1171
 	 * @param WP_REST_Request $request The request object with post and terms data.
1172 1172
 	 * @return bool Whether the current user can assign the provided terms.
1173 1173
 	 */
1174
-	protected function check_assign_terms_permission( $request ) {
1175
-		$taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) );
1176
-		foreach ( $taxonomies as $taxonomy ) {
1177
-			$base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;
1174
+	protected function check_assign_terms_permission($request) {
1175
+		$taxonomies = wp_list_filter(get_object_taxonomies($this->post_type, 'objects'), array('show_in_rest' => true));
1176
+		foreach ($taxonomies as $taxonomy) {
1177
+			$base = ! empty($taxonomy->rest_base) ? $taxonomy->rest_base : $taxonomy->name;
1178 1178
 
1179
-			if ( ! isset( $request[ $base ] ) ) {
1179
+			if ( ! isset($request[$base])) {
1180 1180
 				continue;
1181 1181
 			}
1182 1182
 
1183
-			foreach ( $request[ $base ] as $term_id ) {
1183
+			foreach ($request[$base] as $term_id) {
1184 1184
 				// Invalid terms will be rejected later.
1185
-				if ( ! get_term( $term_id, $taxonomy->name ) ) {
1185
+				if ( ! get_term($term_id, $taxonomy->name)) {
1186 1186
 					continue;
1187 1187
 				}
1188 1188
 
1189
-				if ( ! current_user_can( 'assign_term', (int) $term_id ) ) {
1189
+				if ( ! current_user_can('assign_term', (int) $term_id)) {
1190 1190
 					return false;
1191 1191
 				}
1192 1192
 			}
@@ -1204,12 +1204,12 @@  discard block
 block discarded – undo
1204 1204
 	 * @param object|string $post_type Post type name or object.
1205 1205
 	 * @return bool Whether the post type is allowed in REST.
1206 1206
 	 */
1207
-	protected function check_is_post_type_allowed( $post_type ) {
1208
-		if ( ! is_object( $post_type ) ) {
1209
-			$post_type = get_post_type_object( $post_type );
1207
+	protected function check_is_post_type_allowed($post_type) {
1208
+		if ( ! is_object($post_type)) {
1209
+			$post_type = get_post_type_object($post_type);
1210 1210
 		}
1211 1211
 
1212
-		if ( ! empty( $post_type ) && ! empty( $post_type->show_in_rest ) ) {
1212
+		if ( ! empty($post_type) && ! empty($post_type->show_in_rest)) {
1213 1213
 			return true;
1214 1214
 		}
1215 1215
 
@@ -1227,33 +1227,33 @@  discard block
 block discarded – undo
1227 1227
 	 * @param object $post Post object.
1228 1228
 	 * @return bool Whether the post can be read.
1229 1229
 	 */
1230
-	public function check_read_permission( $post ) {
1231
-		$post_type = get_post_type_object( $post->post_type );
1232
-		if ( ! $this->check_is_post_type_allowed( $post_type ) ) {
1230
+	public function check_read_permission($post) {
1231
+		$post_type = get_post_type_object($post->post_type);
1232
+		if ( ! $this->check_is_post_type_allowed($post_type)) {
1233 1233
 			return false;
1234 1234
 		}
1235 1235
 
1236 1236
 		// Is the post readable?
1237
-		if ( 'publish' === $post->post_status || current_user_can( $post_type->cap->read_post, $post->ID ) ) {
1237
+		if ('publish' === $post->post_status || current_user_can($post_type->cap->read_post, $post->ID)) {
1238 1238
 			return true;
1239 1239
 		}
1240 1240
 
1241
-		$post_status_obj = get_post_status_object( $post->post_status );
1242
-		if ( $post_status_obj && $post_status_obj->public ) {
1241
+		$post_status_obj = get_post_status_object($post->post_status);
1242
+		if ($post_status_obj && $post_status_obj->public) {
1243 1243
 			return true;
1244 1244
 		}
1245 1245
 
1246 1246
 		// Can we read the parent if we're inheriting?
1247
-		if ( 'inherit' === $post->post_status && $post->post_parent > 0 ) {
1248
-			$parent = get_post( $post->post_parent );
1249
-			return $this->check_read_permission( $parent );
1247
+		if ('inherit' === $post->post_status && $post->post_parent > 0) {
1248
+			$parent = get_post($post->post_parent);
1249
+			return $this->check_read_permission($parent);
1250 1250
 		}
1251 1251
 
1252 1252
 		/*
1253 1253
 		 * If there isn't a parent, but the status is set to inherit, assume
1254 1254
 		 * it's published (as per get_post_status()).
1255 1255
 		 */
1256
-		if ( 'inherit' === $post->post_status ) {
1256
+		if ('inherit' === $post->post_status) {
1257 1257
 			return true;
1258 1258
 		}
1259 1259
 
@@ -1269,14 +1269,14 @@  discard block
 block discarded – undo
1269 1269
 	 * @param object $post Post object.
1270 1270
 	 * @return bool Whether the post can be edited.
1271 1271
 	 */
1272
-	protected function check_update_permission( $post ) {
1273
-		$post_type = get_post_type_object( $post->post_type );
1272
+	protected function check_update_permission($post) {
1273
+		$post_type = get_post_type_object($post->post_type);
1274 1274
 
1275
-		if ( ! $this->check_is_post_type_allowed( $post_type ) ) {
1275
+		if ( ! $this->check_is_post_type_allowed($post_type)) {
1276 1276
 			return false;
1277 1277
 		}
1278 1278
 
1279
-		return current_user_can( $post_type->cap->edit_post, $post->ID );
1279
+		return current_user_can($post_type->cap->edit_post, $post->ID);
1280 1280
 	}
1281 1281
 
1282 1282
 	/**
@@ -1288,14 +1288,14 @@  discard block
 block discarded – undo
1288 1288
 	 * @param object $post Post object.
1289 1289
 	 * @return bool Whether the post can be created.
1290 1290
 	 */
1291
-	protected function check_create_permission( $post ) {
1292
-		$post_type = get_post_type_object( $post->post_type );
1291
+	protected function check_create_permission($post) {
1292
+		$post_type = get_post_type_object($post->post_type);
1293 1293
 
1294
-		if ( ! $this->check_is_post_type_allowed( $post_type ) ) {
1294
+		if ( ! $this->check_is_post_type_allowed($post_type)) {
1295 1295
 			return false;
1296 1296
 		}
1297 1297
 
1298
-		return current_user_can( $post_type->cap->create_posts );
1298
+		return current_user_can($post_type->cap->create_posts);
1299 1299
 	}
1300 1300
 
1301 1301
 	/**
@@ -1307,14 +1307,14 @@  discard block
 block discarded – undo
1307 1307
 	 * @param object $post Post object.
1308 1308
 	 * @return bool Whether the post can be deleted.
1309 1309
 	 */
1310
-	protected function check_delete_permission( $post ) {
1311
-		$post_type = get_post_type_object( $post->post_type );
1310
+	protected function check_delete_permission($post) {
1311
+		$post_type = get_post_type_object($post->post_type);
1312 1312
 
1313
-		if ( ! $this->check_is_post_type_allowed( $post_type ) ) {
1313
+		if ( ! $this->check_is_post_type_allowed($post_type)) {
1314 1314
 			return false;
1315 1315
 		}
1316 1316
 
1317
-		return current_user_can( $post_type->cap->delete_post, $post->ID );
1317
+		return current_user_can($post_type->cap->delete_post, $post->ID);
1318 1318
 	}
1319 1319
 
1320 1320
 	/**
@@ -1327,176 +1327,176 @@  discard block
 block discarded – undo
1327 1327
 	 * @param WP_REST_Request $request Request object.
1328 1328
 	 * @return WP_REST_Response Response object.
1329 1329
 	 */
1330
-	public function prepare_item_for_response( $post, $request ) {
1330
+	public function prepare_item_for_response($post, $request) {
1331 1331
 		$GLOBALS['post'] = $post;
1332 1332
 
1333
-		setup_postdata( $post );
1333
+		setup_postdata($post);
1334 1334
 
1335 1335
 		$schema = $this->get_item_schema();
1336 1336
 
1337 1337
 		// Base fields for every post.
1338 1338
 		$data = array();
1339 1339
 
1340
-		if ( ! empty( $schema['properties']['id'] ) ) {
1340
+		if ( ! empty($schema['properties']['id'])) {
1341 1341
 			$data['id'] = $post->ID;
1342 1342
 		}
1343 1343
 
1344
-		if ( ! empty( $schema['properties']['date'] ) ) {
1345
-			$data['date'] = $this->prepare_date_response( $post->post_date_gmt, $post->post_date );
1344
+		if ( ! empty($schema['properties']['date'])) {
1345
+			$data['date'] = $this->prepare_date_response($post->post_date_gmt, $post->post_date);
1346 1346
 		}
1347 1347
 
1348
-		if ( ! empty( $schema['properties']['date_gmt'] ) ) {
1349
-			$data['date_gmt'] = $this->prepare_date_response( $post->post_date_gmt );
1348
+		if ( ! empty($schema['properties']['date_gmt'])) {
1349
+			$data['date_gmt'] = $this->prepare_date_response($post->post_date_gmt);
1350 1350
 		}
1351 1351
 
1352
-		if ( ! empty( $schema['properties']['guid'] ) ) {
1352
+		if ( ! empty($schema['properties']['guid'])) {
1353 1353
 			$data['guid'] = array(
1354 1354
 				/** This filter is documented in wp-includes/post-template.php */
1355
-				'rendered' => apply_filters( 'get_the_guid', $post->guid ),
1355
+				'rendered' => apply_filters('get_the_guid', $post->guid),
1356 1356
 				'raw'      => $post->guid,
1357 1357
 			);
1358 1358
 		}
1359 1359
 
1360
-		if ( ! empty( $schema['properties']['modified'] ) ) {
1361
-			$data['modified'] = $this->prepare_date_response( $post->post_modified_gmt, $post->post_modified );
1360
+		if ( ! empty($schema['properties']['modified'])) {
1361
+			$data['modified'] = $this->prepare_date_response($post->post_modified_gmt, $post->post_modified);
1362 1362
 		}
1363 1363
 
1364
-		if ( ! empty( $schema['properties']['modified_gmt'] ) ) {
1365
-			$data['modified_gmt'] = $this->prepare_date_response( $post->post_modified_gmt );
1364
+		if ( ! empty($schema['properties']['modified_gmt'])) {
1365
+			$data['modified_gmt'] = $this->prepare_date_response($post->post_modified_gmt);
1366 1366
 		}
1367 1367
 
1368
-		if ( ! empty( $schema['properties']['password'] ) ) {
1368
+		if ( ! empty($schema['properties']['password'])) {
1369 1369
 			$data['password'] = $post->post_password;
1370 1370
 		}
1371 1371
 
1372
-		if ( ! empty( $schema['properties']['slug'] ) ) {
1372
+		if ( ! empty($schema['properties']['slug'])) {
1373 1373
 			$data['slug'] = $post->post_name;
1374 1374
 		}
1375 1375
 
1376
-		if ( ! empty( $schema['properties']['status'] ) ) {
1376
+		if ( ! empty($schema['properties']['status'])) {
1377 1377
 			$data['status'] = $post->post_status;
1378 1378
 		}
1379 1379
 
1380
-		if ( ! empty( $schema['properties']['type'] ) ) {
1380
+		if ( ! empty($schema['properties']['type'])) {
1381 1381
 			$data['type'] = $post->post_type;
1382 1382
 		}
1383 1383
 
1384
-		if ( ! empty( $schema['properties']['link'] ) ) {
1385
-			$data['link'] = get_permalink( $post->ID );
1384
+		if ( ! empty($schema['properties']['link'])) {
1385
+			$data['link'] = get_permalink($post->ID);
1386 1386
 		}
1387 1387
 
1388
-		if ( ! empty( $schema['properties']['title'] ) ) {
1389
-			add_filter( 'protected_title_format', array( $this, 'protected_title_format' ) );
1388
+		if ( ! empty($schema['properties']['title'])) {
1389
+			add_filter('protected_title_format', array($this, 'protected_title_format'));
1390 1390
 
1391 1391
 			$data['title'] = array(
1392 1392
 				'raw'      => $post->post_title,
1393
-				'rendered' => get_the_title( $post->ID ),
1393
+				'rendered' => get_the_title($post->ID),
1394 1394
 			);
1395 1395
 
1396
-			remove_filter( 'protected_title_format', array( $this, 'protected_title_format' ) );
1396
+			remove_filter('protected_title_format', array($this, 'protected_title_format'));
1397 1397
 		}
1398 1398
 
1399 1399
 		$has_password_filter = false;
1400 1400
 
1401
-		if ( $this->can_access_password_content( $post, $request ) ) {
1401
+		if ($this->can_access_password_content($post, $request)) {
1402 1402
 			// Allow access to the post, permissions already checked before.
1403
-			add_filter( 'post_password_required', '__return_false' );
1403
+			add_filter('post_password_required', '__return_false');
1404 1404
 
1405 1405
 			$has_password_filter = true;
1406 1406
 		}
1407 1407
 
1408
-		if ( ! empty( $schema['properties']['content'] ) ) {
1408
+		if ( ! empty($schema['properties']['content'])) {
1409 1409
 			$data['content'] = array(
1410 1410
 				'raw'       => $post->post_content,
1411 1411
 				/** This filter is documented in wp-includes/post-template.php */
1412
-				'rendered'  => post_password_required( $post ) ? '' : apply_filters( 'the_content', $post->post_content ),
1412
+				'rendered'  => post_password_required($post) ? '' : apply_filters('the_content', $post->post_content),
1413 1413
 				'protected' => (bool) $post->post_password,
1414 1414
 			);
1415 1415
 		}
1416 1416
 
1417
-		if ( ! empty( $schema['properties']['excerpt'] ) ) {
1417
+		if ( ! empty($schema['properties']['excerpt'])) {
1418 1418
 			/** This filter is documented in wp-includes/post-template.php */
1419
-			$excerpt = apply_filters( 'the_excerpt', apply_filters( 'get_the_excerpt', $post->post_excerpt, $post ) );
1419
+			$excerpt = apply_filters('the_excerpt', apply_filters('get_the_excerpt', $post->post_excerpt, $post));
1420 1420
 			$data['excerpt'] = array(
1421 1421
 				'raw'       => $post->post_excerpt,
1422
-				'rendered'  => post_password_required( $post ) ? '' : $excerpt,
1422
+				'rendered'  => post_password_required($post) ? '' : $excerpt,
1423 1423
 				'protected' => (bool) $post->post_password,
1424 1424
 			);
1425 1425
 		}
1426 1426
 
1427
-		if ( $has_password_filter ) {
1427
+		if ($has_password_filter) {
1428 1428
 			// Reset filter.
1429
-			remove_filter( 'post_password_required', '__return_false' );
1429
+			remove_filter('post_password_required', '__return_false');
1430 1430
 		}
1431 1431
 
1432
-		if ( ! empty( $schema['properties']['author'] ) ) {
1432
+		if ( ! empty($schema['properties']['author'])) {
1433 1433
 			$data['author'] = (int) $post->post_author;
1434 1434
 		}
1435 1435
 
1436
-		if ( ! empty( $schema['properties']['featured_media'] ) ) {
1437
-			$data['featured_media'] = (int) get_post_thumbnail_id( $post->ID );
1436
+		if ( ! empty($schema['properties']['featured_media'])) {
1437
+			$data['featured_media'] = (int) get_post_thumbnail_id($post->ID);
1438 1438
 		}
1439 1439
 
1440
-		if ( ! empty( $schema['properties']['parent'] ) ) {
1440
+		if ( ! empty($schema['properties']['parent'])) {
1441 1441
 			$data['parent'] = (int) $post->post_parent;
1442 1442
 		}
1443 1443
 
1444
-		if ( ! empty( $schema['properties']['menu_order'] ) ) {
1444
+		if ( ! empty($schema['properties']['menu_order'])) {
1445 1445
 			$data['menu_order'] = (int) $post->menu_order;
1446 1446
 		}
1447 1447
 
1448
-		if ( ! empty( $schema['properties']['comment_status'] ) ) {
1448
+		if ( ! empty($schema['properties']['comment_status'])) {
1449 1449
 			$data['comment_status'] = $post->comment_status;
1450 1450
 		}
1451 1451
 
1452
-		if ( ! empty( $schema['properties']['ping_status'] ) ) {
1452
+		if ( ! empty($schema['properties']['ping_status'])) {
1453 1453
 			$data['ping_status'] = $post->ping_status;
1454 1454
 		}
1455 1455
 
1456
-		if ( ! empty( $schema['properties']['sticky'] ) ) {
1457
-			$data['sticky'] = is_sticky( $post->ID );
1456
+		if ( ! empty($schema['properties']['sticky'])) {
1457
+			$data['sticky'] = is_sticky($post->ID);
1458 1458
 		}
1459 1459
 
1460
-		if ( ! empty( $schema['properties']['template'] ) ) {
1461
-			if ( $template = get_page_template_slug( $post->ID ) ) {
1460
+		if ( ! empty($schema['properties']['template'])) {
1461
+			if ($template = get_page_template_slug($post->ID)) {
1462 1462
 				$data['template'] = $template;
1463 1463
 			} else {
1464 1464
 				$data['template'] = '';
1465 1465
 			}
1466 1466
 		}
1467 1467
 
1468
-		if ( ! empty( $schema['properties']['format'] ) ) {
1469
-			$data['format'] = get_post_format( $post->ID );
1468
+		if ( ! empty($schema['properties']['format'])) {
1469
+			$data['format'] = get_post_format($post->ID);
1470 1470
 
1471 1471
 			// Fill in blank post format.
1472
-			if ( empty( $data['format'] ) ) {
1472
+			if (empty($data['format'])) {
1473 1473
 				$data['format'] = 'standard';
1474 1474
 			}
1475 1475
 		}
1476 1476
 
1477
-		if ( ! empty( $schema['properties']['meta'] ) ) {
1478
-			$data['meta'] = $this->meta->get_value( $post->ID, $request );
1477
+		if ( ! empty($schema['properties']['meta'])) {
1478
+			$data['meta'] = $this->meta->get_value($post->ID, $request);
1479 1479
 		}
1480 1480
 
1481
-		$taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) );
1481
+		$taxonomies = wp_list_filter(get_object_taxonomies($this->post_type, 'objects'), array('show_in_rest' => true));
1482 1482
 
1483
-		foreach ( $taxonomies as $taxonomy ) {
1484
-			$base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;
1483
+		foreach ($taxonomies as $taxonomy) {
1484
+			$base = ! empty($taxonomy->rest_base) ? $taxonomy->rest_base : $taxonomy->name;
1485 1485
 
1486
-			if ( ! empty( $schema['properties'][ $base ] ) ) {
1487
-				$terms = get_the_terms( $post, $taxonomy->name );
1488
-				$data[ $base ] = $terms ? array_values( wp_list_pluck( $terms, 'term_id' ) ) : array();
1486
+			if ( ! empty($schema['properties'][$base])) {
1487
+				$terms = get_the_terms($post, $taxonomy->name);
1488
+				$data[$base] = $terms ? array_values(wp_list_pluck($terms, 'term_id')) : array();
1489 1489
 			}
1490 1490
 		}
1491 1491
 
1492
-		$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
1493
-		$data    = $this->add_additional_fields_to_object( $data, $request );
1494
-		$data    = $this->filter_response_by_context( $data, $context );
1492
+		$context = ! empty($request['context']) ? $request['context'] : 'view';
1493
+		$data    = $this->add_additional_fields_to_object($data, $request);
1494
+		$data    = $this->filter_response_by_context($data, $context);
1495 1495
 
1496 1496
 		// Wrap the data in a response object.
1497
-		$response = rest_ensure_response( $data );
1497
+		$response = rest_ensure_response($data);
1498 1498
 
1499
-		$response->add_links( $this->prepare_links( $post ) );
1499
+		$response->add_links($this->prepare_links($post));
1500 1500
 
1501 1501
 		/**
1502 1502
 		 * Filters the post data for a response.
@@ -1509,7 +1509,7 @@  discard block
 block discarded – undo
1509 1509
 		 * @param WP_Post          $post     Post object.
1510 1510
 		 * @param WP_REST_Request  $request  Request object.
1511 1511
 		 */
1512
-		return apply_filters( "rest_prepare_{$this->post_type}", $response, $post, $request );
1512
+		return apply_filters("rest_prepare_{$this->post_type}", $response, $post, $request);
1513 1513
 	}
1514 1514
 
1515 1515
 	/**
@@ -1537,33 +1537,33 @@  discard block
 block discarded – undo
1537 1537
 	 * @param WP_Post $post Post object.
1538 1538
 	 * @return array Links for the given post.
1539 1539
 	 */
1540
-	protected function prepare_links( $post ) {
1541
-		$base = sprintf( '%s/%s', $this->namespace, $this->rest_base );
1540
+	protected function prepare_links($post) {
1541
+		$base = sprintf('%s/%s', $this->namespace, $this->rest_base);
1542 1542
 
1543 1543
 		// Entity meta.
1544 1544
 		$links = array(
1545 1545
 			'self' => array(
1546
-				'href'   => rest_url( trailingslashit( $base ) . $post->ID ),
1546
+				'href'   => rest_url(trailingslashit($base).$post->ID),
1547 1547
 			),
1548 1548
 			'collection' => array(
1549
-				'href'   => rest_url( $base ),
1549
+				'href'   => rest_url($base),
1550 1550
 			),
1551 1551
 			'about'      => array(
1552
-				'href'   => rest_url( 'wp/v2/types/' . $this->post_type ),
1552
+				'href'   => rest_url('wp/v2/types/'.$this->post_type),
1553 1553
 			),
1554 1554
 		);
1555 1555
 
1556
-		if ( ( in_array( $post->post_type, array( 'post', 'page' ), true ) || post_type_supports( $post->post_type, 'author' ) )
1557
-			&& ! empty( $post->post_author ) ) {
1556
+		if ((in_array($post->post_type, array('post', 'page'), true) || post_type_supports($post->post_type, 'author'))
1557
+			&& ! empty($post->post_author)) {
1558 1558
 			$links['author'] = array(
1559
-				'href'       => rest_url( 'wp/v2/users/' . $post->post_author ),
1559
+				'href'       => rest_url('wp/v2/users/'.$post->post_author),
1560 1560
 				'embeddable' => true,
1561 1561
 			);
1562 1562
 		}
1563 1563
 
1564
-		if ( in_array( $post->post_type, array( 'post', 'page' ), true ) || post_type_supports( $post->post_type, 'comments' ) ) {
1565
-			$replies_url = rest_url( 'wp/v2/comments' );
1566
-			$replies_url = add_query_arg( 'post', $post->ID, $replies_url );
1564
+		if (in_array($post->post_type, array('post', 'page'), true) || post_type_supports($post->post_type, 'comments')) {
1565
+			$replies_url = rest_url('wp/v2/comments');
1566
+			$replies_url = add_query_arg('post', $post->ID, $replies_url);
1567 1567
 
1568 1568
 			$links['replies'] = array(
1569 1569
 				'href'       => $replies_url,
@@ -1571,24 +1571,24 @@  discard block
 block discarded – undo
1571 1571
 			);
1572 1572
 		}
1573 1573
 
1574
-		if ( in_array( $post->post_type, array( 'post', 'page' ), true ) || post_type_supports( $post->post_type, 'revisions' ) ) {
1574
+		if (in_array($post->post_type, array('post', 'page'), true) || post_type_supports($post->post_type, 'revisions')) {
1575 1575
 			$links['version-history'] = array(
1576
-				'href' => rest_url( trailingslashit( $base ) . $post->ID . '/revisions' ),
1576
+				'href' => rest_url(trailingslashit($base).$post->ID.'/revisions'),
1577 1577
 			);
1578 1578
 		}
1579 1579
 
1580
-		$post_type_obj = get_post_type_object( $post->post_type );
1580
+		$post_type_obj = get_post_type_object($post->post_type);
1581 1581
 
1582
-		if ( $post_type_obj->hierarchical && ! empty( $post->post_parent ) ) {
1582
+		if ($post_type_obj->hierarchical && ! empty($post->post_parent)) {
1583 1583
 			$links['up'] = array(
1584
-				'href'       => rest_url( trailingslashit( $base ) . (int) $post->post_parent ),
1584
+				'href'       => rest_url(trailingslashit($base).(int) $post->post_parent),
1585 1585
 				'embeddable' => true,
1586 1586
 			);
1587 1587
 		}
1588 1588
 
1589 1589
 		// If we have a featured media, add that.
1590
-		if ( $featured_media = get_post_thumbnail_id( $post->ID ) ) {
1591
-			$image_url = rest_url( 'wp/v2/media/' . $featured_media );
1590
+		if ($featured_media = get_post_thumbnail_id($post->ID)) {
1591
+			$image_url = rest_url('wp/v2/media/'.$featured_media);
1592 1592
 
1593 1593
 			$links['https://api.w.org/featuredmedia'] = array(
1594 1594
 				'href'       => $image_url,
@@ -1596,34 +1596,34 @@  discard block
 block discarded – undo
1596 1596
 			);
1597 1597
 		}
1598 1598
 
1599
-		if ( ! in_array( $post->post_type, array( 'attachment', 'nav_menu_item', 'revision' ), true ) ) {
1600
-			$attachments_url = rest_url( 'wp/v2/media' );
1601
-			$attachments_url = add_query_arg( 'parent', $post->ID, $attachments_url );
1599
+		if ( ! in_array($post->post_type, array('attachment', 'nav_menu_item', 'revision'), true)) {
1600
+			$attachments_url = rest_url('wp/v2/media');
1601
+			$attachments_url = add_query_arg('parent', $post->ID, $attachments_url);
1602 1602
 
1603 1603
 			$links['https://api.w.org/attachment'] = array(
1604 1604
 				'href' => $attachments_url,
1605 1605
 			);
1606 1606
 		}
1607 1607
 
1608
-		$taxonomies = get_object_taxonomies( $post->post_type );
1608
+		$taxonomies = get_object_taxonomies($post->post_type);
1609 1609
 
1610
-		if ( ! empty( $taxonomies ) ) {
1610
+		if ( ! empty($taxonomies)) {
1611 1611
 			$links['https://api.w.org/term'] = array();
1612 1612
 
1613
-			foreach ( $taxonomies as $tax ) {
1614
-				$taxonomy_obj = get_taxonomy( $tax );
1613
+			foreach ($taxonomies as $tax) {
1614
+				$taxonomy_obj = get_taxonomy($tax);
1615 1615
 
1616 1616
 				// Skip taxonomies that are not public.
1617
-				if ( empty( $taxonomy_obj->show_in_rest ) ) {
1617
+				if (empty($taxonomy_obj->show_in_rest)) {
1618 1618
 					continue;
1619 1619
 				}
1620 1620
 
1621
-				$tax_base = ! empty( $taxonomy_obj->rest_base ) ? $taxonomy_obj->rest_base : $tax;
1621
+				$tax_base = ! empty($taxonomy_obj->rest_base) ? $taxonomy_obj->rest_base : $tax;
1622 1622
 
1623 1623
 				$terms_url = add_query_arg(
1624 1624
 					'post',
1625 1625
 					$post->ID,
1626
-					rest_url( 'wp/v2/' . $tax_base )
1626
+					rest_url('wp/v2/'.$tax_base)
1627 1627
 				);
1628 1628
 
1629 1629
 				$links['https://api.w.org/term'][] = array(
@@ -1654,99 +1654,99 @@  discard block
 block discarded – undo
1654 1654
 			// Base properties for every Post.
1655 1655
 			'properties' => array(
1656 1656
 				'date'            => array(
1657
-					'description' => __( "The date the object was published, in the site's timezone." ),
1657
+					'description' => __("The date the object was published, in the site's timezone."),
1658 1658
 					'type'        => 'string',
1659 1659
 					'format'      => 'date-time',
1660
-					'context'     => array( 'view', 'edit', 'embed' ),
1660
+					'context'     => array('view', 'edit', 'embed'),
1661 1661
 				),
1662 1662
 				'date_gmt'        => array(
1663
-					'description' => __( 'The date the object was published, as GMT.' ),
1663
+					'description' => __('The date the object was published, as GMT.'),
1664 1664
 					'type'        => 'string',
1665 1665
 					'format'      => 'date-time',
1666
-					'context'     => array( 'view', 'edit' ),
1666
+					'context'     => array('view', 'edit'),
1667 1667
 				),
1668 1668
 				'guid'            => array(
1669
-					'description' => __( 'The globally unique identifier for the object.' ),
1669
+					'description' => __('The globally unique identifier for the object.'),
1670 1670
 					'type'        => 'object',
1671
-					'context'     => array( 'view', 'edit' ),
1671
+					'context'     => array('view', 'edit'),
1672 1672
 					'readonly'    => true,
1673 1673
 					'properties'  => array(
1674 1674
 						'raw'      => array(
1675
-							'description' => __( 'GUID for the object, as it exists in the database.' ),
1675
+							'description' => __('GUID for the object, as it exists in the database.'),
1676 1676
 							'type'        => 'string',
1677
-							'context'     => array( 'edit' ),
1677
+							'context'     => array('edit'),
1678 1678
 							'readonly'    => true,
1679 1679
 						),
1680 1680
 						'rendered' => array(
1681
-							'description' => __( 'GUID for the object, transformed for display.' ),
1681
+							'description' => __('GUID for the object, transformed for display.'),
1682 1682
 							'type'        => 'string',
1683
-							'context'     => array( 'view', 'edit' ),
1683
+							'context'     => array('view', 'edit'),
1684 1684
 							'readonly'    => true,
1685 1685
 						),
1686 1686
 					),
1687 1687
 				),
1688 1688
 				'id'              => array(
1689
-					'description' => __( 'Unique identifier for the object.' ),
1689
+					'description' => __('Unique identifier for the object.'),
1690 1690
 					'type'        => 'integer',
1691
-					'context'     => array( 'view', 'edit', 'embed' ),
1691
+					'context'     => array('view', 'edit', 'embed'),
1692 1692
 					'readonly'    => true,
1693 1693
 				),
1694 1694
 				'link'            => array(
1695
-					'description' => __( 'URL to the object.' ),
1695
+					'description' => __('URL to the object.'),
1696 1696
 					'type'        => 'string',
1697 1697
 					'format'      => 'uri',
1698
-					'context'     => array( 'view', 'edit', 'embed' ),
1698
+					'context'     => array('view', 'edit', 'embed'),
1699 1699
 					'readonly'    => true,
1700 1700
 				),
1701 1701
 				'modified'        => array(
1702
-					'description' => __( "The date the object was last modified, in the site's timezone." ),
1702
+					'description' => __("The date the object was last modified, in the site's timezone."),
1703 1703
 					'type'        => 'string',
1704 1704
 					'format'      => 'date-time',
1705
-					'context'     => array( 'view', 'edit' ),
1705
+					'context'     => array('view', 'edit'),
1706 1706
 					'readonly'    => true,
1707 1707
 				),
1708 1708
 				'modified_gmt'    => array(
1709
-					'description' => __( 'The date the object was last modified, as GMT.' ),
1709
+					'description' => __('The date the object was last modified, as GMT.'),
1710 1710
 					'type'        => 'string',
1711 1711
 					'format'      => 'date-time',
1712
-					'context'     => array( 'view', 'edit' ),
1712
+					'context'     => array('view', 'edit'),
1713 1713
 					'readonly'    => true,
1714 1714
 				),
1715 1715
 				'slug'            => array(
1716
-					'description' => __( 'An alphanumeric identifier for the object unique to its type.' ),
1716
+					'description' => __('An alphanumeric identifier for the object unique to its type.'),
1717 1717
 					'type'        => 'string',
1718
-					'context'     => array( 'view', 'edit', 'embed' ),
1718
+					'context'     => array('view', 'edit', 'embed'),
1719 1719
 					'arg_options' => array(
1720
-						'sanitize_callback' => array( $this, 'sanitize_slug' ),
1720
+						'sanitize_callback' => array($this, 'sanitize_slug'),
1721 1721
 					),
1722 1722
 				),
1723 1723
 				'status'          => array(
1724
-					'description' => __( 'A named status for the object.' ),
1724
+					'description' => __('A named status for the object.'),
1725 1725
 					'type'        => 'string',
1726
-					'enum'        => array_keys( get_post_stati( array( 'internal' => false ) ) ),
1727
-					'context'     => array( 'edit' ),
1726
+					'enum'        => array_keys(get_post_stati(array('internal' => false))),
1727
+					'context'     => array('edit'),
1728 1728
 				),
1729 1729
 				'type'            => array(
1730
-					'description' => __( 'Type of Post for the object.' ),
1730
+					'description' => __('Type of Post for the object.'),
1731 1731
 					'type'        => 'string',
1732
-					'context'     => array( 'view', 'edit', 'embed' ),
1732
+					'context'     => array('view', 'edit', 'embed'),
1733 1733
 					'readonly'    => true,
1734 1734
 				),
1735 1735
 				'password'        => array(
1736
-					'description' => __( 'A password to protect access to the content and excerpt.' ),
1736
+					'description' => __('A password to protect access to the content and excerpt.'),
1737 1737
 					'type'        => 'string',
1738
-					'context'     => array( 'edit' ),
1738
+					'context'     => array('edit'),
1739 1739
 				),
1740 1740
 			),
1741 1741
 		);
1742 1742
 
1743
-		$post_type_obj = get_post_type_object( $this->post_type );
1743
+		$post_type_obj = get_post_type_object($this->post_type);
1744 1744
 
1745
-		if ( $post_type_obj->hierarchical ) {
1745
+		if ($post_type_obj->hierarchical) {
1746 1746
 			$schema['properties']['parent'] = array(
1747
-				'description' => __( 'The ID for the parent of the object.' ),
1747
+				'description' => __('The ID for the parent of the object.'),
1748 1748
 				'type'        => 'integer',
1749
-				'context'     => array( 'view', 'edit' ),
1749
+				'context'     => array('view', 'edit'),
1750 1750
 			);
1751 1751
 		}
1752 1752
 
@@ -1793,33 +1793,33 @@  discard block
 block discarded – undo
1793 1793
 				'custom-fields',
1794 1794
 			),
1795 1795
 		);
1796
-		foreach ( $post_type_attributes as $attribute ) {
1797
-			if ( isset( $fixed_schemas[ $this->post_type ] ) && ! in_array( $attribute, $fixed_schemas[ $this->post_type ], true ) ) {
1796
+		foreach ($post_type_attributes as $attribute) {
1797
+			if (isset($fixed_schemas[$this->post_type]) && ! in_array($attribute, $fixed_schemas[$this->post_type], true)) {
1798 1798
 				continue;
1799
-			} elseif ( ! isset( $fixed_schemas[ $this->post_type ] ) && ! post_type_supports( $this->post_type, $attribute ) ) {
1799
+			} elseif ( ! isset($fixed_schemas[$this->post_type]) && ! post_type_supports($this->post_type, $attribute)) {
1800 1800
 				continue;
1801 1801
 			}
1802 1802
 
1803
-			switch ( $attribute ) {
1803
+			switch ($attribute) {
1804 1804
 
1805 1805
 				case 'title':
1806 1806
 					$schema['properties']['title'] = array(
1807
-						'description' => __( 'The title for the object.' ),
1807
+						'description' => __('The title for the object.'),
1808 1808
 						'type'        => 'object',
1809
-						'context'     => array( 'view', 'edit', 'embed' ),
1809
+						'context'     => array('view', 'edit', 'embed'),
1810 1810
 						'arg_options' => array(
1811 1811
 							'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database()
1812 1812
 						),
1813 1813
 						'properties'  => array(
1814 1814
 							'raw' => array(
1815
-								'description' => __( 'Title for the object, as it exists in the database.' ),
1815
+								'description' => __('Title for the object, as it exists in the database.'),
1816 1816
 								'type'        => 'string',
1817
-								'context'     => array( 'edit' ),
1817
+								'context'     => array('edit'),
1818 1818
 							),
1819 1819
 							'rendered' => array(
1820
-								'description' => __( 'HTML title for the object, transformed for display.' ),
1820
+								'description' => __('HTML title for the object, transformed for display.'),
1821 1821
 								'type'        => 'string',
1822
-								'context'     => array( 'view', 'edit', 'embed' ),
1822
+								'context'     => array('view', 'edit', 'embed'),
1823 1823
 								'readonly'    => true,
1824 1824
 							),
1825 1825
 						),
@@ -1828,28 +1828,28 @@  discard block
 block discarded – undo
1828 1828
 
1829 1829
 				case 'editor':
1830 1830
 					$schema['properties']['content'] = array(
1831
-						'description' => __( 'The content for the object.' ),
1831
+						'description' => __('The content for the object.'),
1832 1832
 						'type'        => 'object',
1833
-						'context'     => array( 'view', 'edit' ),
1833
+						'context'     => array('view', 'edit'),
1834 1834
 						'arg_options' => array(
1835 1835
 							'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database()
1836 1836
 						),
1837 1837
 						'properties'  => array(
1838 1838
 							'raw' => array(
1839
-								'description' => __( 'Content for the object, as it exists in the database.' ),
1839
+								'description' => __('Content for the object, as it exists in the database.'),
1840 1840
 								'type'        => 'string',
1841
-								'context'     => array( 'edit' ),
1841
+								'context'     => array('edit'),
1842 1842
 							),
1843 1843
 							'rendered' => array(
1844
-								'description' => __( 'HTML content for the object, transformed for display.' ),
1844
+								'description' => __('HTML content for the object, transformed for display.'),
1845 1845
 								'type'        => 'string',
1846
-								'context'     => array( 'view', 'edit' ),
1846
+								'context'     => array('view', 'edit'),
1847 1847
 								'readonly'    => true,
1848 1848
 							),
1849 1849
 							'protected'       => array(
1850
-								'description' => __( 'Whether the content is protected with a password.' ),
1850
+								'description' => __('Whether the content is protected with a password.'),
1851 1851
 								'type'        => 'boolean',
1852
-								'context'     => array( 'view', 'edit', 'embed' ),
1852
+								'context'     => array('view', 'edit', 'embed'),
1853 1853
 								'readonly'    => true,
1854 1854
 							),
1855 1855
 						),
@@ -1858,36 +1858,36 @@  discard block
 block discarded – undo
1858 1858
 
1859 1859
 				case 'author':
1860 1860
 					$schema['properties']['author'] = array(
1861
-						'description' => __( 'The ID for the author of the object.' ),
1861
+						'description' => __('The ID for the author of the object.'),
1862 1862
 						'type'        => 'integer',
1863
-						'context'     => array( 'view', 'edit', 'embed' ),
1863
+						'context'     => array('view', 'edit', 'embed'),
1864 1864
 					);
1865 1865
 					break;
1866 1866
 
1867 1867
 				case 'excerpt':
1868 1868
 					$schema['properties']['excerpt'] = array(
1869
-						'description' => __( 'The excerpt for the object.' ),
1869
+						'description' => __('The excerpt for the object.'),
1870 1870
 						'type'        => 'object',
1871
-						'context'     => array( 'view', 'edit', 'embed' ),
1871
+						'context'     => array('view', 'edit', 'embed'),
1872 1872
 						'arg_options' => array(
1873 1873
 							'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database()
1874 1874
 						),
1875 1875
 						'properties'  => array(
1876 1876
 							'raw' => array(
1877
-								'description' => __( 'Excerpt for the object, as it exists in the database.' ),
1877
+								'description' => __('Excerpt for the object, as it exists in the database.'),
1878 1878
 								'type'        => 'string',
1879
-								'context'     => array( 'edit' ),
1879
+								'context'     => array('edit'),
1880 1880
 							),
1881 1881
 							'rendered' => array(
1882
-								'description' => __( 'HTML excerpt for the object, transformed for display.' ),
1882
+								'description' => __('HTML excerpt for the object, transformed for display.'),
1883 1883
 								'type'        => 'string',
1884
-								'context'     => array( 'view', 'edit', 'embed' ),
1884
+								'context'     => array('view', 'edit', 'embed'),
1885 1885
 								'readonly'    => true,
1886 1886
 							),
1887 1887
 							'protected'       => array(
1888
-								'description' => __( 'Whether the excerpt is protected with a password.' ),
1888
+								'description' => __('Whether the excerpt is protected with a password.'),
1889 1889
 								'type'        => 'boolean',
1890
-								'context'     => array( 'view', 'edit', 'embed' ),
1890
+								'context'     => array('view', 'edit', 'embed'),
1891 1891
 								'readonly'    => true,
1892 1892
 							),
1893 1893
 						),
@@ -1896,48 +1896,48 @@  discard block
 block discarded – undo
1896 1896
 
1897 1897
 				case 'thumbnail':
1898 1898
 					$schema['properties']['featured_media'] = array(
1899
-						'description' => __( 'The ID of the featured media for the object.' ),
1899
+						'description' => __('The ID of the featured media for the object.'),
1900 1900
 						'type'        => 'integer',
1901
-						'context'     => array( 'view', 'edit' ),
1901
+						'context'     => array('view', 'edit'),
1902 1902
 					);
1903 1903
 					break;
1904 1904
 
1905 1905
 				case 'comments':
1906 1906
 					$schema['properties']['comment_status'] = array(
1907
-						'description' => __( 'Whether or not comments are open on the object.' ),
1907
+						'description' => __('Whether or not comments are open on the object.'),
1908 1908
 						'type'        => 'string',
1909
-						'enum'        => array( 'open', 'closed' ),
1910
-						'context'     => array( 'view', 'edit' ),
1909
+						'enum'        => array('open', 'closed'),
1910
+						'context'     => array('view', 'edit'),
1911 1911
 					);
1912 1912
 					$schema['properties']['ping_status'] = array(
1913
-						'description' => __( 'Whether or not the object can be pinged.' ),
1913
+						'description' => __('Whether or not the object can be pinged.'),
1914 1914
 						'type'        => 'string',
1915
-						'enum'        => array( 'open', 'closed' ),
1916
-						'context'     => array( 'view', 'edit' ),
1915
+						'enum'        => array('open', 'closed'),
1916
+						'context'     => array('view', 'edit'),
1917 1917
 					);
1918 1918
 					break;
1919 1919
 
1920 1920
 				case 'page-attributes':
1921 1921
 					$schema['properties']['menu_order'] = array(
1922
-						'description' => __( 'The order of the object in relation to other object of its type.' ),
1922
+						'description' => __('The order of the object in relation to other object of its type.'),
1923 1923
 						'type'        => 'integer',
1924
-						'context'     => array( 'view', 'edit' ),
1924
+						'context'     => array('view', 'edit'),
1925 1925
 					);
1926 1926
 					break;
1927 1927
 
1928 1928
 				case 'post-formats':
1929
-					$supports_formats = get_theme_support( 'post-formats' );
1929
+					$supports_formats = get_theme_support('post-formats');
1930 1930
 
1931 1931
 					// Force to an array. Supports formats can return true even if empty in some cases.
1932
-					$supports_formats = is_array( $supports_formats ) ? array_values( $supports_formats[0] ) : array();
1932
+					$supports_formats = is_array($supports_formats) ? array_values($supports_formats[0]) : array();
1933 1933
 
1934
-					$supported_formats = array_merge( array( 'standard' ), $supports_formats );
1934
+					$supported_formats = array_merge(array('standard'), $supports_formats);
1935 1935
 
1936 1936
 					$schema['properties']['format'] = array(
1937
-						'description' => __( 'The format for the object.' ),
1937
+						'description' => __('The format for the object.'),
1938 1938
 						'type'        => 'string',
1939 1939
 						'enum'        => $supported_formats,
1940
-						'context'     => array( 'view', 'edit' ),
1940
+						'context'     => array('view', 'edit'),
1941 1941
 					);
1942 1942
 					break;
1943 1943
 
@@ -1948,36 +1948,36 @@  discard block
 block discarded – undo
1948 1948
 			}
1949 1949
 		}
1950 1950
 
1951
-		if ( 'post' === $this->post_type ) {
1951
+		if ('post' === $this->post_type) {
1952 1952
 			$schema['properties']['sticky'] = array(
1953
-				'description' => __( 'Whether or not the object should be treated as sticky.' ),
1953
+				'description' => __('Whether or not the object should be treated as sticky.'),
1954 1954
 				'type'        => 'boolean',
1955
-				'context'     => array( 'view', 'edit' ),
1955
+				'context'     => array('view', 'edit'),
1956 1956
 			);
1957 1957
 		}
1958 1958
 
1959 1959
 		$schema['properties']['template'] = array(
1960
-			'description' => __( 'The theme file to use to display the object.' ),
1960
+			'description' => __('The theme file to use to display the object.'),
1961 1961
 			'type'        => 'string',
1962
-			'enum'        => array_merge( array_keys( wp_get_theme()->get_page_templates( null, $this->post_type ) ), array( '' ) ),
1963
-			'context'     => array( 'view', 'edit' ),
1962
+			'enum'        => array_merge(array_keys(wp_get_theme()->get_page_templates(null, $this->post_type)), array('')),
1963
+			'context'     => array('view', 'edit'),
1964 1964
 		);
1965 1965
 
1966
-		$taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) );
1967
-		foreach ( $taxonomies as $taxonomy ) {
1968
-			$base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;
1969
-			$schema['properties'][ $base ] = array(
1966
+		$taxonomies = wp_list_filter(get_object_taxonomies($this->post_type, 'objects'), array('show_in_rest' => true));
1967
+		foreach ($taxonomies as $taxonomy) {
1968
+			$base = ! empty($taxonomy->rest_base) ? $taxonomy->rest_base : $taxonomy->name;
1969
+			$schema['properties'][$base] = array(
1970 1970
 				/* translators: %s: taxonomy name */
1971
-				'description' => sprintf( __( 'The terms assigned to the object in the %s taxonomy.' ), $taxonomy->name ),
1971
+				'description' => sprintf(__('The terms assigned to the object in the %s taxonomy.'), $taxonomy->name),
1972 1972
 				'type'        => 'array',
1973 1973
 				'items'       => array(
1974 1974
 					'type'    => 'integer',
1975 1975
 				),
1976
-				'context'     => array( 'view', 'edit' ),
1976
+				'context'     => array('view', 'edit'),
1977 1977
 			);
1978 1978
 		}
1979 1979
 
1980
-		return $this->add_additional_fields_schema( $schema );
1980
+		return $this->add_additional_fields_schema($schema);
1981 1981
 	}
1982 1982
 
1983 1983
 	/**
@@ -1994,14 +1994,14 @@  discard block
 block discarded – undo
1994 1994
 		$query_params['context']['default'] = 'view';
1995 1995
 
1996 1996
 		$query_params['after'] = array(
1997
-			'description'        => __( 'Limit response to posts published after a given ISO8601 compliant date.' ),
1997
+			'description'        => __('Limit response to posts published after a given ISO8601 compliant date.'),
1998 1998
 			'type'               => 'string',
1999 1999
 			'format'             => 'date-time',
2000 2000
 		);
2001 2001
 
2002
-		if ( post_type_supports( $this->post_type, 'author' ) ) {
2002
+		if (post_type_supports($this->post_type, 'author')) {
2003 2003
 			$query_params['author'] = array(
2004
-				'description'         => __( 'Limit result set to posts assigned to specific authors.' ),
2004
+				'description'         => __('Limit result set to posts assigned to specific authors.'),
2005 2005
 				'type'                => 'array',
2006 2006
 				'items'               => array(
2007 2007
 					'type'            => 'integer',
@@ -2009,7 +2009,7 @@  discard block
 block discarded – undo
2009 2009
 				'default'             => array(),
2010 2010
 			);
2011 2011
 			$query_params['author_exclude'] = array(
2012
-				'description'         => __( 'Ensure result set excludes posts assigned to specific authors.' ),
2012
+				'description'         => __('Ensure result set excludes posts assigned to specific authors.'),
2013 2013
 				'type'                => 'array',
2014 2014
 				'items'               => array(
2015 2015
 					'type'            => 'integer',
@@ -2019,13 +2019,13 @@  discard block
 block discarded – undo
2019 2019
 		}
2020 2020
 
2021 2021
 		$query_params['before'] = array(
2022
-			'description'        => __( 'Limit response to posts published before a given ISO8601 compliant date.' ),
2022
+			'description'        => __('Limit response to posts published before a given ISO8601 compliant date.'),
2023 2023
 			'type'               => 'string',
2024 2024
 			'format'             => 'date-time',
2025 2025
 		);
2026 2026
 
2027 2027
 		$query_params['exclude'] = array(
2028
-			'description'        => __( 'Ensure result set excludes specific IDs.' ),
2028
+			'description'        => __('Ensure result set excludes specific IDs.'),
2029 2029
 			'type'               => 'array',
2030 2030
 			'items'              => array(
2031 2031
 				'type'           => 'integer',
@@ -2034,7 +2034,7 @@  discard block
 block discarded – undo
2034 2034
 		);
2035 2035
 
2036 2036
 		$query_params['include'] = array(
2037
-			'description'        => __( 'Limit result set to specific IDs.' ),
2037
+			'description'        => __('Limit result set to specific IDs.'),
2038 2038
 			'type'               => 'array',
2039 2039
 			'items'              => array(
2040 2040
 				'type'           => 'integer',
@@ -2042,27 +2042,27 @@  discard block
 block discarded – undo
2042 2042
 			'default'            => array(),
2043 2043
 		);
2044 2044
 
2045
-		if ( 'page' === $this->post_type || post_type_supports( $this->post_type, 'page-attributes' ) ) {
2045
+		if ('page' === $this->post_type || post_type_supports($this->post_type, 'page-attributes')) {
2046 2046
 			$query_params['menu_order'] = array(
2047
-				'description'        => __( 'Limit result set to posts with a specific menu_order value.' ),
2047
+				'description'        => __('Limit result set to posts with a specific menu_order value.'),
2048 2048
 				'type'               => 'integer',
2049 2049
 			);
2050 2050
 		}
2051 2051
 
2052 2052
 		$query_params['offset'] = array(
2053
-			'description'        => __( 'Offset the result set by a specific number of items.' ),
2053
+			'description'        => __('Offset the result set by a specific number of items.'),
2054 2054
 			'type'               => 'integer',
2055 2055
 		);
2056 2056
 
2057 2057
 		$query_params['order'] = array(
2058
-			'description'        => __( 'Order sort attribute ascending or descending.' ),
2058
+			'description'        => __('Order sort attribute ascending or descending.'),
2059 2059
 			'type'               => 'string',
2060 2060
 			'default'            => 'desc',
2061
-			'enum'               => array( 'asc', 'desc' ),
2061
+			'enum'               => array('asc', 'desc'),
2062 2062
 		);
2063 2063
 
2064 2064
 		$query_params['orderby'] = array(
2065
-			'description'        => __( 'Sort collection by object attribute.' ),
2065
+			'description'        => __('Sort collection by object attribute.'),
2066 2066
 			'type'               => 'string',
2067 2067
 			'default'            => 'date',
2068 2068
 			'enum'               => array(
@@ -2075,15 +2075,15 @@  discard block
 block discarded – undo
2075 2075
 			),
2076 2076
 		);
2077 2077
 
2078
-		if ( 'page' === $this->post_type || post_type_supports( $this->post_type, 'page-attributes' ) ) {
2078
+		if ('page' === $this->post_type || post_type_supports($this->post_type, 'page-attributes')) {
2079 2079
 			$query_params['orderby']['enum'][] = 'menu_order';
2080 2080
 		}
2081 2081
 
2082
-		$post_type = get_post_type_object( $this->post_type );
2082
+		$post_type = get_post_type_object($this->post_type);
2083 2083
 
2084
-		if ( $post_type->hierarchical || 'attachment' === $this->post_type ) {
2084
+		if ($post_type->hierarchical || 'attachment' === $this->post_type) {
2085 2085
 			$query_params['parent'] = array(
2086
-				'description'       => __( 'Limit result set to those of particular parent IDs.' ),
2086
+				'description'       => __('Limit result set to those of particular parent IDs.'),
2087 2087
 				'type'              => 'array',
2088 2088
 				'items'             => array(
2089 2089
 					'type'          => 'integer',
@@ -2091,7 +2091,7 @@  discard block
 block discarded – undo
2091 2091
 				'default'           => array(),
2092 2092
 			);
2093 2093
 			$query_params['parent_exclude'] = array(
2094
-				'description'       => __( 'Limit result set to all items except those of a particular parent ID.' ),
2094
+				'description'       => __('Limit result set to all items except those of a particular parent ID.'),
2095 2095
 				'type'              => 'array',
2096 2096
 				'items'             => array(
2097 2097
 					'type'          => 'integer',
@@ -2101,7 +2101,7 @@  discard block
 block discarded – undo
2101 2101
 		}
2102 2102
 
2103 2103
 		$query_params['slug'] = array(
2104
-			'description'       => __( 'Limit result set to posts with one or more specific slugs.' ),
2104
+			'description'       => __('Limit result set to posts with one or more specific slugs.'),
2105 2105
 			'type'              => 'array',
2106 2106
 			'items'             => array(
2107 2107
 				'type'          => 'string',
@@ -2111,23 +2111,23 @@  discard block
 block discarded – undo
2111 2111
 
2112 2112
 		$query_params['status'] = array(
2113 2113
 			'default'           => 'publish',
2114
-			'description'       => __( 'Limit result set to posts assigned one or more statuses.' ),
2114
+			'description'       => __('Limit result set to posts assigned one or more statuses.'),
2115 2115
 			'type'              => 'array',
2116 2116
 			'items'             => array(
2117
-				'enum'          => array_merge( array_keys( get_post_stati() ), array( 'any' ) ),
2117
+				'enum'          => array_merge(array_keys(get_post_stati()), array('any')),
2118 2118
 				'type'          => 'string',
2119 2119
 			),
2120
-			'sanitize_callback' => array( $this, 'sanitize_post_statuses' ),
2120
+			'sanitize_callback' => array($this, 'sanitize_post_statuses'),
2121 2121
 		);
2122 2122
 
2123
-		$taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) );
2123
+		$taxonomies = wp_list_filter(get_object_taxonomies($this->post_type, 'objects'), array('show_in_rest' => true));
2124 2124
 
2125
-		foreach ( $taxonomies as $taxonomy ) {
2126
-			$base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;
2125
+		foreach ($taxonomies as $taxonomy) {
2126
+			$base = ! empty($taxonomy->rest_base) ? $taxonomy->rest_base : $taxonomy->name;
2127 2127
 
2128
-			$query_params[ $base ] = array(
2128
+			$query_params[$base] = array(
2129 2129
 				/* translators: %s: taxonomy name */
2130
-				'description'       => sprintf( __( 'Limit result set to all items that have the specified term assigned in the %s taxonomy.' ), $base ),
2130
+				'description'       => sprintf(__('Limit result set to all items that have the specified term assigned in the %s taxonomy.'), $base),
2131 2131
 				'type'              => 'array',
2132 2132
 				'items'             => array(
2133 2133
 					'type'          => 'integer',
@@ -2135,9 +2135,9 @@  discard block
 block discarded – undo
2135 2135
 				'default'           => array(),
2136 2136
 			);
2137 2137
 
2138
-			$query_params[ $base . '_exclude' ] = array(
2138
+			$query_params[$base.'_exclude'] = array(
2139 2139
 				/* translators: %s: taxonomy name */
2140
-				'description' => sprintf( __( 'Limit result set to all items except those that have the specified term assigned in the %s taxonomy.' ), $base ),
2140
+				'description' => sprintf(__('Limit result set to all items except those that have the specified term assigned in the %s taxonomy.'), $base),
2141 2141
 				'type'        => 'array',
2142 2142
 				'items'       => array(
2143 2143
 					'type'    => 'integer',
@@ -2146,9 +2146,9 @@  discard block
 block discarded – undo
2146 2146
 			);
2147 2147
 		}
2148 2148
 
2149
-		if ( 'post' === $this->post_type ) {
2149
+		if ('post' === $this->post_type) {
2150 2150
 			$query_params['sticky'] = array(
2151
-				'description'       => __( 'Limit result set to items that are sticky.' ),
2151
+				'description'       => __('Limit result set to items that are sticky.'),
2152 2152
 				'type'              => 'boolean',
2153 2153
 			);
2154 2154
 		}
@@ -2168,7 +2168,7 @@  discard block
 block discarded – undo
2168 2168
 		 * @param array        $query_params JSON Schema-formatted collection parameters.
2169 2169
 		 * @param WP_Post_Type $post_type    Post type object.
2170 2170
 		 */
2171
-		return apply_filters( "rest_{$this->post_type}_collection_params", $query_params, $post_type );
2171
+		return apply_filters("rest_{$this->post_type}_collection_params", $query_params, $post_type);
2172 2172
 	}
2173 2173
 
2174 2174
 	/**
@@ -2183,27 +2183,27 @@  discard block
 block discarded – undo
2183 2183
 	 * @param  string          $parameter Additional parameter to pass to validation.
2184 2184
 	 * @return array|WP_Error A list of valid statuses, otherwise WP_Error object.
2185 2185
 	 */
2186
-	public function sanitize_post_statuses( $statuses, $request, $parameter ) {
2187
-		$statuses = wp_parse_slug_list( $statuses );
2186
+	public function sanitize_post_statuses($statuses, $request, $parameter) {
2187
+		$statuses = wp_parse_slug_list($statuses);
2188 2188
 
2189 2189
 		// The default status is different in WP_REST_Attachments_Controller
2190 2190
 		$attributes = $request->get_attributes();
2191 2191
 		$default_status = $attributes['args']['status']['default'];
2192 2192
 
2193
-		foreach ( $statuses as $status ) {
2194
-			if ( $status === $default_status ) {
2193
+		foreach ($statuses as $status) {
2194
+			if ($status === $default_status) {
2195 2195
 				continue;
2196 2196
 			}
2197 2197
 
2198
-			$post_type_obj = get_post_type_object( $this->post_type );
2198
+			$post_type_obj = get_post_type_object($this->post_type);
2199 2199
 
2200
-			if ( current_user_can( $post_type_obj->cap->edit_posts ) ) {
2201
-				$result = rest_validate_request_arg( $status, $request, $parameter );
2202
-				if ( is_wp_error( $result ) ) {
2200
+			if (current_user_can($post_type_obj->cap->edit_posts)) {
2201
+				$result = rest_validate_request_arg($status, $request, $parameter);
2202
+				if (is_wp_error($result)) {
2203 2203
 					return $result;
2204 2204
 				}
2205 2205
 			} else {
2206
-				return new WP_Error( 'rest_forbidden_status', __( 'Status is forbidden.' ), array( 'status' => rest_authorization_required_code() ) );
2206
+				return new WP_Error('rest_forbidden_status', __('Status is forbidden.'), array('status' => rest_authorization_required_code()));
2207 2207
 			}
2208 2208
 		}
2209 2209
 
Please login to merge, or discard this patch.