Completed
Push — master ( cde0c6...d99bf9 )
by Stephen
15:46
created
src/wp-includes/random_compat/random.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -199,6 +199,7 @@
 block discarded – undo
199 199
             /**
200 200
              * We don't have any more options, so let's throw an exception right now
201 201
              * and hope the developer won't let it fail silently.
202
+             * @param integer $length
202 203
              */
203 204
             function random_bytes($length)
204 205
             {
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
  * SOFTWARE.
30 30
  */
31 31
 
32
-if (!defined('PHP_VERSION_ID')) {
32
+if ( ! defined('PHP_VERSION_ID')) {
33 33
     // This constant was introduced in PHP 5.2.7
34 34
     $RandomCompatversion = explode('.', PHP_VERSION);
35 35
     define(
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 
44 44
 if (PHP_VERSION_ID < 70000) {
45 45
 
46
-    if (!defined('RANDOM_COMPAT_READ_BUFFER')) {
46
+    if ( ! defined('RANDOM_COMPAT_READ_BUFFER')) {
47 47
         define('RANDOM_COMPAT_READ_BUFFER', 8);
48 48
     }
49 49
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     require_once $RandomCompatDIR.'/cast_to_int.php';
54 54
     require_once $RandomCompatDIR.'/error_polyfill.php';
55 55
 
56
-    if (!function_exists('random_bytes')) {
56
+    if ( ! function_exists('random_bytes')) {
57 57
         /**
58 58
          * PHP 5.2.0 - 5.6.x way to implement random_bytes()
59 59
          *
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
             $RandomCompatUrandom = true;
88 88
             $RandomCompat_basedir = ini_get('open_basedir');
89 89
 
90
-            if (!empty($RandomCompat_basedir)) {
90
+            if ( ! empty($RandomCompat_basedir)) {
91 91
                 $RandomCompat_open_basedir = explode(
92 92
                     PATH_SEPARATOR,
93 93
                     strtolower($RandomCompat_basedir)
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
             }
101 101
 
102 102
             if (
103
-                !function_exists('random_bytes')
103
+                ! function_exists('random_bytes')
104 104
                 &&
105 105
                 $RandomCompatUrandom
106 106
                 &&
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
          * mcrypt_create_iv()
125 125
          */
126 126
         if (
127
-            !function_exists('random_bytes')
127
+            ! function_exists('random_bytes')
128 128
             &&
129 129
             PHP_VERSION_ID >= 50307
130 130
             &&
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
         }
143 143
 
144 144
         if (
145
-            !function_exists('random_bytes')
145
+            ! function_exists('random_bytes')
146 146
             &&
147 147
             extension_loaded('com_dotnet')
148 148
             &&
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
                 strtolower(ini_get('disable_classes'))
154 154
             );
155 155
 
156
-            if (!in_array('com', $RandomCompat_disabled_classes)) {
156
+            if ( ! in_array('com', $RandomCompat_disabled_classes)) {
157 157
                 try {
158 158
                     $RandomCompatCOMtest = new COM('CAPICOM.Utilities.1');
159 159
                     if (method_exists($RandomCompatCOMtest, 'GetRandom')) {
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
                 PHP_VERSION_ID >= 50401
185 185
             )
186 186
             &&
187
-            !function_exists('random_bytes')
187
+            ! function_exists('random_bytes')
188 188
             &&
189 189
             extension_loaded('openssl')
190 190
         ) {
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
         /**
196 196
          * throw new Exception
197 197
          */
198
-        if (!function_exists('random_bytes')) {
198
+        if ( ! function_exists('random_bytes')) {
199 199
             /**
200 200
              * We don't have any more options, so let's throw an exception right now
201 201
              * and hope the developer won't let it fail silently.
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
         }
210 210
     }
211 211
 
212
-    if (!function_exists('random_int')) {
212
+    if ( ! function_exists('random_int')) {
213 213
         require_once $RandomCompatDIR.'/random_int.php';
214 214
     }
215 215
 
Please login to merge, or discard this patch.
Indentation   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -30,188 +30,188 @@
 block discarded – undo
30 30
  */
31 31
 
32 32
 if (!defined('PHP_VERSION_ID')) {
33
-    // This constant was introduced in PHP 5.2.7
34
-    $RandomCompatversion = explode('.', PHP_VERSION);
35
-    define(
36
-        'PHP_VERSION_ID',
37
-        $RandomCompatversion[0] * 10000
38
-        + $RandomCompatversion[1] * 100
39
-        + $RandomCompatversion[2]
40
-    );
41
-    $RandomCompatversion = null;
33
+	// This constant was introduced in PHP 5.2.7
34
+	$RandomCompatversion = explode('.', PHP_VERSION);
35
+	define(
36
+		'PHP_VERSION_ID',
37
+		$RandomCompatversion[0] * 10000
38
+		+ $RandomCompatversion[1] * 100
39
+		+ $RandomCompatversion[2]
40
+	);
41
+	$RandomCompatversion = null;
42 42
 }
43 43
 
44 44
 if (PHP_VERSION_ID < 70000) {
45 45
 
46
-    if (!defined('RANDOM_COMPAT_READ_BUFFER')) {
47
-        define('RANDOM_COMPAT_READ_BUFFER', 8);
48
-    }
49
-
50
-    $RandomCompatDIR = dirname(__FILE__);
51
-
52
-    require_once $RandomCompatDIR.'/byte_safe_strings.php';
53
-    require_once $RandomCompatDIR.'/cast_to_int.php';
54
-    require_once $RandomCompatDIR.'/error_polyfill.php';
55
-
56
-    if (!function_exists('random_bytes')) {
57
-        /**
58
-         * PHP 5.2.0 - 5.6.x way to implement random_bytes()
59
-         *
60
-         * We use conditional statements here to define the function in accordance
61
-         * to the operating environment. It's a micro-optimization.
62
-         *
63
-         * In order of preference:
64
-         *   1. Use libsodium if available.
65
-         *   2. fread() /dev/urandom if available (never on Windows)
66
-         *   3. mcrypt_create_iv($bytes, MCRYPT_DEV_URANDOM)
67
-         *   4. COM('CAPICOM.Utilities.1')->GetRandom()
68
-         *   5. openssl_random_pseudo_bytes() (absolute last resort)
69
-         *
70
-         * See ERRATA.md for our reasoning behind this particular order
71
-         */
72
-        if (extension_loaded('libsodium')) {
73
-            // See random_bytes_libsodium.php
74
-            if (PHP_VERSION_ID >= 50300 && function_exists('\\Sodium\\randombytes_buf')) {
75
-                require_once $RandomCompatDIR.'/random_bytes_libsodium.php';
76
-            } elseif (method_exists('Sodium', 'randombytes_buf')) {
77
-                require_once $RandomCompatDIR.'/random_bytes_libsodium_legacy.php';
78
-            }
79
-        }
80
-
81
-        /**
82
-         * Reading directly from /dev/urandom:
83
-         */
84
-        if (DIRECTORY_SEPARATOR === '/') {
85
-            // DIRECTORY_SEPARATOR === '/' on Unix-like OSes -- this is a fast
86
-            // way to exclude Windows.
87
-            $RandomCompatUrandom = true;
88
-            $RandomCompat_basedir = ini_get('open_basedir');
89
-
90
-            if (!empty($RandomCompat_basedir)) {
91
-                $RandomCompat_open_basedir = explode(
92
-                    PATH_SEPARATOR,
93
-                    strtolower($RandomCompat_basedir)
94
-                );
95
-                $RandomCompatUrandom = in_array(
96
-                    '/dev',
97
-                    $RandomCompat_open_basedir
98
-                );
99
-                $RandomCompat_open_basedir = null;
100
-            }
101
-
102
-            if (
103
-                !function_exists('random_bytes')
104
-                &&
105
-                $RandomCompatUrandom
106
-                &&
107
-                @is_readable('/dev/urandom')
108
-            ) {
109
-                // Error suppression on is_readable() in case of an open_basedir
110
-                // or safe_mode failure. All we care about is whether or not we
111
-                // can read it at this point. If the PHP environment is going to
112
-                // panic over trying to see if the file can be read in the first
113
-                // place, that is not helpful to us here.
114
-
115
-                // See random_bytes_dev_urandom.php
116
-                require_once $RandomCompatDIR.'/random_bytes_dev_urandom.php';
117
-            }
118
-            // Unset variables after use
119
-            $RandomCompat_basedir = null;
120
-            $RandomCompatUrandom = null;
121
-        }
122
-
123
-        /**
124
-         * mcrypt_create_iv()
125
-         */
126
-        if (
127
-            !function_exists('random_bytes')
128
-            &&
129
-            PHP_VERSION_ID >= 50307
130
-            &&
131
-            extension_loaded('mcrypt')
132
-        ) {
133
-            // Prevent this code from hanging indefinitely on non-Windows;
134
-            // see https://bugs.php.net/bug.php?id=69833
135
-            if (
136
-                DIRECTORY_SEPARATOR !== '/' ||
137
-                (PHP_VERSION_ID <= 50609 || PHP_VERSION_ID >= 50613)
138
-            ) {
139
-                // See random_bytes_mcrypt.php
140
-                require_once $RandomCompatDIR.'/random_bytes_mcrypt.php';
141
-            }
142
-        }
143
-
144
-        if (
145
-            !function_exists('random_bytes')
146
-            &&
147
-            extension_loaded('com_dotnet')
148
-            &&
149
-            class_exists('COM')
150
-        ) {
151
-            $RandomCompat_disabled_classes = preg_split(
152
-                '#\s*,\s*#',
153
-                strtolower(ini_get('disable_classes'))
154
-            );
155
-
156
-            if (!in_array('com', $RandomCompat_disabled_classes)) {
157
-                try {
158
-                    $RandomCompatCOMtest = new COM('CAPICOM.Utilities.1');
159
-                    if (method_exists($RandomCompatCOMtest, 'GetRandom')) {
160
-                        // See random_bytes_com_dotnet.php
161
-                        require_once $RandomCompatDIR.'/random_bytes_com_dotnet.php';
162
-                    }
163
-                } catch (com_exception $e) {
164
-                    // Don't try to use it.
165
-                }
166
-            }
167
-            $RandomCompat_disabled_classes = null;
168
-            $RandomCompatCOMtest = null;
169
-        }
170
-
171
-        /**
172
-         * openssl_random_pseudo_bytes()
173
-         */
174
-        if (
175
-            (
176
-                // Unix-like with PHP >= 5.3.0 or
177
-                (
178
-                    DIRECTORY_SEPARATOR === '/'
179
-                    &&
180
-                    PHP_VERSION_ID >= 50300
181
-                )
182
-                ||
183
-                // Windows with PHP >= 5.4.1
184
-                PHP_VERSION_ID >= 50401
185
-            )
186
-            &&
187
-            !function_exists('random_bytes')
188
-            &&
189
-            extension_loaded('openssl')
190
-        ) {
191
-            // See random_bytes_openssl.php
192
-            require_once $RandomCompatDIR.'/random_bytes_openssl.php';
193
-        }
194
-
195
-        /**
196
-         * throw new Exception
197
-         */
198
-        if (!function_exists('random_bytes')) {
199
-            /**
200
-             * We don't have any more options, so let's throw an exception right now
201
-             * and hope the developer won't let it fail silently.
202
-             */
203
-            function random_bytes($length)
204
-            {
205
-                throw new Exception(
206
-                    'There is no suitable CSPRNG installed on your system'
207
-                );
208
-            }
209
-        }
210
-    }
211
-
212
-    if (!function_exists('random_int')) {
213
-        require_once $RandomCompatDIR.'/random_int.php';
214
-    }
215
-
216
-    $RandomCompatDIR = null;
46
+	if (!defined('RANDOM_COMPAT_READ_BUFFER')) {
47
+		define('RANDOM_COMPAT_READ_BUFFER', 8);
48
+	}
49
+
50
+	$RandomCompatDIR = dirname(__FILE__);
51
+
52
+	require_once $RandomCompatDIR.'/byte_safe_strings.php';
53
+	require_once $RandomCompatDIR.'/cast_to_int.php';
54
+	require_once $RandomCompatDIR.'/error_polyfill.php';
55
+
56
+	if (!function_exists('random_bytes')) {
57
+		/**
58
+		 * PHP 5.2.0 - 5.6.x way to implement random_bytes()
59
+		 *
60
+		 * We use conditional statements here to define the function in accordance
61
+		 * to the operating environment. It's a micro-optimization.
62
+		 *
63
+		 * In order of preference:
64
+		 *   1. Use libsodium if available.
65
+		 *   2. fread() /dev/urandom if available (never on Windows)
66
+		 *   3. mcrypt_create_iv($bytes, MCRYPT_DEV_URANDOM)
67
+		 *   4. COM('CAPICOM.Utilities.1')->GetRandom()
68
+		 *   5. openssl_random_pseudo_bytes() (absolute last resort)
69
+		 *
70
+		 * See ERRATA.md for our reasoning behind this particular order
71
+		 */
72
+		if (extension_loaded('libsodium')) {
73
+			// See random_bytes_libsodium.php
74
+			if (PHP_VERSION_ID >= 50300 && function_exists('\\Sodium\\randombytes_buf')) {
75
+				require_once $RandomCompatDIR.'/random_bytes_libsodium.php';
76
+			} elseif (method_exists('Sodium', 'randombytes_buf')) {
77
+				require_once $RandomCompatDIR.'/random_bytes_libsodium_legacy.php';
78
+			}
79
+		}
80
+
81
+		/**
82
+		 * Reading directly from /dev/urandom:
83
+		 */
84
+		if (DIRECTORY_SEPARATOR === '/') {
85
+			// DIRECTORY_SEPARATOR === '/' on Unix-like OSes -- this is a fast
86
+			// way to exclude Windows.
87
+			$RandomCompatUrandom = true;
88
+			$RandomCompat_basedir = ini_get('open_basedir');
89
+
90
+			if (!empty($RandomCompat_basedir)) {
91
+				$RandomCompat_open_basedir = explode(
92
+					PATH_SEPARATOR,
93
+					strtolower($RandomCompat_basedir)
94
+				);
95
+				$RandomCompatUrandom = in_array(
96
+					'/dev',
97
+					$RandomCompat_open_basedir
98
+				);
99
+				$RandomCompat_open_basedir = null;
100
+			}
101
+
102
+			if (
103
+				!function_exists('random_bytes')
104
+				&&
105
+				$RandomCompatUrandom
106
+				&&
107
+				@is_readable('/dev/urandom')
108
+			) {
109
+				// Error suppression on is_readable() in case of an open_basedir
110
+				// or safe_mode failure. All we care about is whether or not we
111
+				// can read it at this point. If the PHP environment is going to
112
+				// panic over trying to see if the file can be read in the first
113
+				// place, that is not helpful to us here.
114
+
115
+				// See random_bytes_dev_urandom.php
116
+				require_once $RandomCompatDIR.'/random_bytes_dev_urandom.php';
117
+			}
118
+			// Unset variables after use
119
+			$RandomCompat_basedir = null;
120
+			$RandomCompatUrandom = null;
121
+		}
122
+
123
+		/**
124
+		 * mcrypt_create_iv()
125
+		 */
126
+		if (
127
+			!function_exists('random_bytes')
128
+			&&
129
+			PHP_VERSION_ID >= 50307
130
+			&&
131
+			extension_loaded('mcrypt')
132
+		) {
133
+			// Prevent this code from hanging indefinitely on non-Windows;
134
+			// see https://bugs.php.net/bug.php?id=69833
135
+			if (
136
+				DIRECTORY_SEPARATOR !== '/' ||
137
+				(PHP_VERSION_ID <= 50609 || PHP_VERSION_ID >= 50613)
138
+			) {
139
+				// See random_bytes_mcrypt.php
140
+				require_once $RandomCompatDIR.'/random_bytes_mcrypt.php';
141
+			}
142
+		}
143
+
144
+		if (
145
+			!function_exists('random_bytes')
146
+			&&
147
+			extension_loaded('com_dotnet')
148
+			&&
149
+			class_exists('COM')
150
+		) {
151
+			$RandomCompat_disabled_classes = preg_split(
152
+				'#\s*,\s*#',
153
+				strtolower(ini_get('disable_classes'))
154
+			);
155
+
156
+			if (!in_array('com', $RandomCompat_disabled_classes)) {
157
+				try {
158
+					$RandomCompatCOMtest = new COM('CAPICOM.Utilities.1');
159
+					if (method_exists($RandomCompatCOMtest, 'GetRandom')) {
160
+						// See random_bytes_com_dotnet.php
161
+						require_once $RandomCompatDIR.'/random_bytes_com_dotnet.php';
162
+					}
163
+				} catch (com_exception $e) {
164
+					// Don't try to use it.
165
+				}
166
+			}
167
+			$RandomCompat_disabled_classes = null;
168
+			$RandomCompatCOMtest = null;
169
+		}
170
+
171
+		/**
172
+		 * openssl_random_pseudo_bytes()
173
+		 */
174
+		if (
175
+			(
176
+				// Unix-like with PHP >= 5.3.0 or
177
+				(
178
+					DIRECTORY_SEPARATOR === '/'
179
+					&&
180
+					PHP_VERSION_ID >= 50300
181
+				)
182
+				||
183
+				// Windows with PHP >= 5.4.1
184
+				PHP_VERSION_ID >= 50401
185
+			)
186
+			&&
187
+			!function_exists('random_bytes')
188
+			&&
189
+			extension_loaded('openssl')
190
+		) {
191
+			// See random_bytes_openssl.php
192
+			require_once $RandomCompatDIR.'/random_bytes_openssl.php';
193
+		}
194
+
195
+		/**
196
+		 * throw new Exception
197
+		 */
198
+		if (!function_exists('random_bytes')) {
199
+			/**
200
+			 * We don't have any more options, so let's throw an exception right now
201
+			 * and hope the developer won't let it fail silently.
202
+			 */
203
+			function random_bytes($length)
204
+			{
205
+				throw new Exception(
206
+					'There is no suitable CSPRNG installed on your system'
207
+				);
208
+			}
209
+		}
210
+	}
211
+
212
+	if (!function_exists('random_int')) {
213
+		require_once $RandomCompatDIR.'/random_int.php';
214
+	}
215
+
216
+	$RandomCompatDIR = null;
217 217
 }
Please login to merge, or discard this patch.
src/wp-includes/rest-api/class-wp-rest-server.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -907,7 +907,7 @@
 block discarded – undo
907 907
 	 * @since 4.4.0
908 908
 	 * @access protected
909 909
 	 *
910
-	 * @return bool|string Boolean false or string error message.
910
+	 * @return false|string Boolean false or string error message.
911 911
 	 */
912 912
 	protected function get_json_last_error() {
913 913
 		// See https://core.trac.wordpress.org/ticket/27799.
Please login to merge, or discard this patch.
Spacing   +254 added lines, -254 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 		$this->endpoints = array(
92 92
 			// Meta endpoints.
93 93
 			'/' => array(
94
-				'callback' => array( $this, 'get_index' ),
94
+				'callback' => array($this, 'get_index'),
95 95
 				'methods' => 'GET',
96 96
 				'args' => array(
97 97
 					'context' => array(
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 		 * @param WP_Error|null|bool WP_Error if authentication error, null if authentication
138 138
 		 *                              method wasn't used, true if authentication succeeded.
139 139
 		 */
140
-		return apply_filters( 'rest_authentication_errors', null );
140
+		return apply_filters('rest_authentication_errors', null);
141 141
 	}
142 142
 
143 143
 	/**
@@ -153,10 +153,10 @@  discard block
 block discarded – undo
153 153
 	 * @param WP_Error $error WP_Error instance.
154 154
 	 * @return WP_REST_Response List of associative arrays with code and message keys.
155 155
 	 */
156
-	protected function error_to_response( $error ) {
156
+	protected function error_to_response($error) {
157 157
 		$error_data = $error->get_error_data();
158 158
 
159
-		if ( is_array( $error_data ) && isset( $error_data['status'] ) ) {
159
+		if (is_array($error_data) && isset($error_data['status'])) {
160 160
 			$status = $error_data['status'];
161 161
 		} else {
162 162
 			$status = 500;
@@ -164,20 +164,20 @@  discard block
 block discarded – undo
164 164
 
165 165
 		$errors = array();
166 166
 
167
-		foreach ( (array) $error->errors as $code => $messages ) {
168
-			foreach ( (array) $messages as $message ) {
169
-				$errors[] = array( 'code' => $code, 'message' => $message, 'data' => $error->get_error_data( $code ) );
167
+		foreach ((array) $error->errors as $code => $messages) {
168
+			foreach ((array) $messages as $message) {
169
+				$errors[] = array('code' => $code, 'message' => $message, 'data' => $error->get_error_data($code));
170 170
 			}
171 171
 		}
172 172
 
173 173
 		$data = $errors[0];
174
-		if ( count( $errors ) > 1 ) {
174
+		if (count($errors) > 1) {
175 175
 			// Remove the primary error.
176
-			array_shift( $errors );
176
+			array_shift($errors);
177 177
 			$data['additional_errors'] = $errors;
178 178
 		}
179 179
 
180
-		$response = new WP_REST_Response( $data, $status );
180
+		$response = new WP_REST_Response($data, $status);
181 181
 
182 182
 		return $response;
183 183
 	}
@@ -198,14 +198,14 @@  discard block
 block discarded – undo
198 198
 	 * @param int    $status  Optional. HTTP status code to send. Default null.
199 199
 	 * @return string JSON representation of the error
200 200
 	 */
201
-	protected function json_error( $code, $message, $status = null ) {
202
-		if ( $status ) {
203
-			$this->set_status( $status );
201
+	protected function json_error($code, $message, $status = null) {
202
+		if ($status) {
203
+			$this->set_status($status);
204 204
 		}
205 205
 
206
-		$error = compact( 'code', 'message' );
206
+		$error = compact('code', 'message');
207 207
 
208
-		return wp_json_encode( $error );
208
+		return wp_json_encode($error);
209 209
 	}
210 210
 
211 211
 	/**
@@ -223,14 +223,14 @@  discard block
 block discarded – undo
223 223
 	 *                     Default null.
224 224
 	 * @return false|null Null if not served and a HEAD request, false otherwise.
225 225
 	 */
226
-	public function serve_request( $path = null ) {
227
-		$content_type = isset( $_GET['_jsonp'] ) ? 'application/javascript' : 'application/json';
228
-		$this->send_header( 'Content-Type', $content_type . '; charset=' . get_option( 'blog_charset' ) );
229
-		$this->send_header( 'X-Robots-Tag', 'noindex' );
226
+	public function serve_request($path = null) {
227
+		$content_type = isset($_GET['_jsonp']) ? 'application/javascript' : 'application/json';
228
+		$this->send_header('Content-Type', $content_type.'; charset='.get_option('blog_charset'));
229
+		$this->send_header('X-Robots-Tag', 'noindex');
230 230
 
231 231
 		$api_root = get_rest_url();
232
-		if ( ! empty( $api_root ) ) {
233
-			$this->send_header( 'Link', '<' . esc_url_raw( $api_root ) . '>; rel="https://api.w.org/"' );
232
+		if ( ! empty($api_root)) {
233
+			$this->send_header('Link', '<'.esc_url_raw($api_root).'>; rel="https://api.w.org/"');
234 234
 		}
235 235
 
236 236
 		/*
@@ -238,9 +238,9 @@  discard block
 block discarded – undo
238 238
 		 *
239 239
 		 * https://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/
240 240
 		 */
241
-		$this->send_header( 'X-Content-Type-Options', 'nosniff' );
242
-		$this->send_header( 'Access-Control-Expose-Headers', 'X-WP-Total, X-WP-TotalPages' );
243
-		$this->send_header( 'Access-Control-Allow-Headers', 'Authorization, Content-Type' );
241
+		$this->send_header('X-Content-Type-Options', 'nosniff');
242
+		$this->send_header('Access-Control-Expose-Headers', 'X-WP-Total, X-WP-TotalPages');
243
+		$this->send_header('Access-Control-Allow-Headers', 'Authorization, Content-Type');
244 244
 
245 245
 		/**
246 246
 		 * Send nocache headers on authenticated requests.
@@ -249,10 +249,10 @@  discard block
 block discarded – undo
249 249
 		 *
250 250
 		 * @param bool $rest_send_nocache_headers Whether to send no-cache headers.
251 251
 		 */
252
-		$send_no_cache_headers = apply_filters( 'rest_send_nocache_headers', is_user_logged_in() );
253
-		if ( $send_no_cache_headers ) {
254
-			foreach ( wp_get_nocache_headers() as $header => $header_value ) {
255
-				$this->send_header( $header, $header_value );
252
+		$send_no_cache_headers = apply_filters('rest_send_nocache_headers', is_user_logged_in());
253
+		if ($send_no_cache_headers) {
254
+			foreach (wp_get_nocache_headers() as $header => $header_value) {
255
+				$this->send_header($header, $header_value);
256 256
 			}
257 257
 		}
258 258
 
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 		 *
265 265
 		 * @param bool $rest_enabled Whether the REST API is enabled. Default true.
266 266
 		 */
267
-		apply_filters_deprecated( 'rest_enabled', array( true ), '4.7.0', 'rest_authentication_errors', __( 'The REST API can no longer be completely disabled, the rest_authentication_errors can be used to restrict access to the API, instead.' ) );
267
+		apply_filters_deprecated('rest_enabled', array(true), '4.7.0', 'rest_authentication_errors', __('The REST API can no longer be completely disabled, the rest_authentication_errors can be used to restrict access to the API, instead.'));
268 268
 
269 269
 		/**
270 270
 		 * Filters whether jsonp is enabled.
@@ -273,62 +273,62 @@  discard block
 block discarded – undo
273 273
 		 *
274 274
 		 * @param bool $jsonp_enabled Whether jsonp is enabled. Default true.
275 275
 		 */
276
-		$jsonp_enabled = apply_filters( 'rest_jsonp_enabled', true );
276
+		$jsonp_enabled = apply_filters('rest_jsonp_enabled', true);
277 277
 
278 278
 		$jsonp_callback = null;
279 279
 
280
-		if ( isset( $_GET['_jsonp'] ) ) {
281
-			if ( ! $jsonp_enabled ) {
282
-				echo $this->json_error( 'rest_callback_disabled', __( 'JSONP support is disabled on this site.' ), 400 );
280
+		if (isset($_GET['_jsonp'])) {
281
+			if ( ! $jsonp_enabled) {
282
+				echo $this->json_error('rest_callback_disabled', __('JSONP support is disabled on this site.'), 400);
283 283
 				return false;
284 284
 			}
285 285
 
286 286
 			$jsonp_callback = $_GET['_jsonp'];
287
-			if ( ! wp_check_jsonp_callback( $jsonp_callback ) ) {
288
-				echo $this->json_error( 'rest_callback_invalid', __( 'Invalid JSONP callback function.' ), 400 );
287
+			if ( ! wp_check_jsonp_callback($jsonp_callback)) {
288
+				echo $this->json_error('rest_callback_invalid', __('Invalid JSONP callback function.'), 400);
289 289
 				return false;
290 290
 			}
291 291
 		}
292 292
 
293
-		if ( empty( $path ) ) {
294
-			if ( isset( $_SERVER['PATH_INFO'] ) ) {
293
+		if (empty($path)) {
294
+			if (isset($_SERVER['PATH_INFO'])) {
295 295
 				$path = $_SERVER['PATH_INFO'];
296 296
 			} else {
297 297
 				$path = '/';
298 298
 			}
299 299
 		}
300 300
 
301
-		$request = new WP_REST_Request( $_SERVER['REQUEST_METHOD'], $path );
301
+		$request = new WP_REST_Request($_SERVER['REQUEST_METHOD'], $path);
302 302
 
303
-		$request->set_query_params( wp_unslash( $_GET ) );
304
-		$request->set_body_params( wp_unslash( $_POST ) );
305
-		$request->set_file_params( $_FILES );
306
-		$request->set_headers( $this->get_headers( wp_unslash( $_SERVER ) ) );
307
-		$request->set_body( $this->get_raw_data() );
303
+		$request->set_query_params(wp_unslash($_GET));
304
+		$request->set_body_params(wp_unslash($_POST));
305
+		$request->set_file_params($_FILES);
306
+		$request->set_headers($this->get_headers(wp_unslash($_SERVER)));
307
+		$request->set_body($this->get_raw_data());
308 308
 
309 309
 		/*
310 310
 		 * HTTP method override for clients that can't use PUT/PATCH/DELETE. First, we check
311 311
 		 * $_GET['_method']. If that is not set, we check for the HTTP_X_HTTP_METHOD_OVERRIDE
312 312
 		 * header.
313 313
 		 */
314
-		if ( isset( $_GET['_method'] ) ) {
315
-			$request->set_method( $_GET['_method'] );
316
-		} elseif ( isset( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ) ) {
317
-			$request->set_method( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] );
314
+		if (isset($_GET['_method'])) {
315
+			$request->set_method($_GET['_method']);
316
+		} elseif (isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) {
317
+			$request->set_method($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']);
318 318
 		}
319 319
 
320 320
 		$result = $this->check_authentication();
321 321
 
322
-		if ( ! is_wp_error( $result ) ) {
323
-			$result = $this->dispatch( $request );
322
+		if ( ! is_wp_error($result)) {
323
+			$result = $this->dispatch($request);
324 324
 		}
325 325
 
326 326
 		// Normalize to either WP_Error or WP_REST_Response...
327
-		$result = rest_ensure_response( $result );
327
+		$result = rest_ensure_response($result);
328 328
 
329 329
 		// ...then convert WP_Error across.
330
-		if ( is_wp_error( $result ) ) {
331
-			$result = $this->error_to_response( $result );
330
+		if (is_wp_error($result)) {
331
+			$result = $this->error_to_response($result);
332 332
 		}
333 333
 
334 334
 		/**
@@ -343,19 +343,19 @@  discard block
 block discarded – undo
343 343
 		 * @param WP_REST_Server   $this    Server instance.
344 344
 		 * @param WP_REST_Request  $request Request used to generate the response.
345 345
 		 */
346
-		$result = apply_filters( 'rest_post_dispatch', rest_ensure_response( $result ), $this, $request );
346
+		$result = apply_filters('rest_post_dispatch', rest_ensure_response($result), $this, $request);
347 347
 
348 348
 		// Wrap the response in an envelope if asked for.
349
-		if ( isset( $_GET['_envelope'] ) ) {
350
-			$result = $this->envelope_response( $result, isset( $_GET['_embed'] ) );
349
+		if (isset($_GET['_envelope'])) {
350
+			$result = $this->envelope_response($result, isset($_GET['_embed']));
351 351
 		}
352 352
 
353 353
 		// Send extra data from response objects.
354 354
 		$headers = $result->get_headers();
355
-		$this->send_headers( $headers );
355
+		$this->send_headers($headers);
356 356
 
357 357
 		$code = $result->get_status();
358
-		$this->set_status( $code );
358
+		$this->set_status($code);
359 359
 
360 360
 		/**
361 361
 		 * Filters whether the request has already been served.
@@ -371,29 +371,29 @@  discard block
 block discarded – undo
371 371
 		 * @param WP_REST_Request  $request Request used to generate the response.
372 372
 		 * @param WP_REST_Server   $this    Server instance.
373 373
 		 */
374
-		$served = apply_filters( 'rest_pre_serve_request', false, $result, $request, $this );
374
+		$served = apply_filters('rest_pre_serve_request', false, $result, $request, $this);
375 375
 
376
-		if ( ! $served ) {
377
-			if ( 'HEAD' === $request->get_method() ) {
376
+		if ( ! $served) {
377
+			if ('HEAD' === $request->get_method()) {
378 378
 				return null;
379 379
 			}
380 380
 
381 381
 			// Embed links inside the request.
382
-			$result = $this->response_to_data( $result, isset( $_GET['_embed'] ) );
382
+			$result = $this->response_to_data($result, isset($_GET['_embed']));
383 383
 
384
-			$result = wp_json_encode( $result );
384
+			$result = wp_json_encode($result);
385 385
 
386 386
 			$json_error_message = $this->get_json_last_error();
387
-			if ( $json_error_message ) {
388
-				$json_error_obj = new WP_Error( 'rest_encode_error', $json_error_message, array( 'status' => 500 ) );
389
-				$result = $this->error_to_response( $json_error_obj );
390
-				$result = wp_json_encode( $result->data[0] );
387
+			if ($json_error_message) {
388
+				$json_error_obj = new WP_Error('rest_encode_error', $json_error_message, array('status' => 500));
389
+				$result = $this->error_to_response($json_error_obj);
390
+				$result = wp_json_encode($result->data[0]);
391 391
 			}
392 392
 
393
-			if ( $jsonp_callback ) {
393
+			if ($jsonp_callback) {
394 394
 				// Prepend '/**/' to mitigate possible JSONP Flash attacks.
395 395
 				// https://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/
396
-				echo '/**/' . $jsonp_callback . '(' . $result . ')';
396
+				echo '/**/'.$jsonp_callback.'('.$result.')';
397 397
 			} else {
398 398
 				echo $result;
399 399
 			}
@@ -416,20 +416,20 @@  discard block
 block discarded – undo
416 416
 	 *     @type array [$_embedded] Embeddeds.
417 417
 	 * }
418 418
 	 */
419
-	public function response_to_data( $response, $embed ) {
419
+	public function response_to_data($response, $embed) {
420 420
 		$data  = $response->get_data();
421
-		$links = $this->get_compact_response_links( $response );
421
+		$links = $this->get_compact_response_links($response);
422 422
 
423
-		if ( ! empty( $links ) ) {
423
+		if ( ! empty($links)) {
424 424
 			// Convert links to part of the data.
425 425
 			$data['_links'] = $links;
426 426
 		}
427
-		if ( $embed ) {
427
+		if ($embed) {
428 428
 			// Determine if this is a numeric array.
429
-			if ( wp_is_numeric_array( $data ) ) {
430
-				$data = array_map( array( $this, 'embed_links' ), $data );
429
+			if (wp_is_numeric_array($data)) {
430
+				$data = array_map(array($this, 'embed_links'), $data);
431 431
 			} else {
432
-				$data = $this->embed_links( $data );
432
+				$data = $this->embed_links($data);
433 433
 			}
434 434
 		}
435 435
 
@@ -449,21 +449,21 @@  discard block
 block discarded – undo
449 449
 	 * @param WP_REST_Response $response Response to extract links from.
450 450
 	 * @return array Map of link relation to list of link hashes.
451 451
 	 */
452
-	public static function get_response_links( $response ) {
452
+	public static function get_response_links($response) {
453 453
 		$links = $response->get_links();
454
-		if ( empty( $links ) ) {
454
+		if (empty($links)) {
455 455
 			return array();
456 456
 		}
457 457
 
458 458
 		// Convert links to part of the data.
459 459
 		$data = array();
460
-		foreach ( $links as $rel => $items ) {
461
-			$data[ $rel ] = array();
460
+		foreach ($links as $rel => $items) {
461
+			$data[$rel] = array();
462 462
 
463
-			foreach ( $items as $item ) {
463
+			foreach ($items as $item) {
464 464
 				$attributes = $item['attributes'];
465 465
 				$attributes['href'] = $item['href'];
466
-				$data[ $rel ][] = $attributes;
466
+				$data[$rel][] = $attributes;
467 467
 			}
468 468
 		}
469 469
 
@@ -483,41 +483,41 @@  discard block
 block discarded – undo
483 483
 	 * @param WP_REST_Response $response Response to extract links from.
484 484
 	 * @return array Map of link relation to list of link hashes.
485 485
 	 */
486
-	public static function get_compact_response_links( $response ) {
487
-		$links = self::get_response_links( $response );
486
+	public static function get_compact_response_links($response) {
487
+		$links = self::get_response_links($response);
488 488
 
489
-		if ( empty( $links ) ) {
489
+		if (empty($links)) {
490 490
 			return array();
491 491
 		}
492 492
 
493 493
 		$curies = $response->get_curies();
494 494
 		$used_curies = array();
495 495
 
496
-		foreach ( $links as $rel => $items ) {
496
+		foreach ($links as $rel => $items) {
497 497
 
498 498
 			// Convert $rel URIs to their compact versions if they exist.
499
-			foreach ( $curies as $curie ) {
500
-				$href_prefix = substr( $curie['href'], 0, strpos( $curie['href'], '{rel}' ) );
501
-				if ( strpos( $rel, $href_prefix ) !== 0 ) {
499
+			foreach ($curies as $curie) {
500
+				$href_prefix = substr($curie['href'], 0, strpos($curie['href'], '{rel}'));
501
+				if (strpos($rel, $href_prefix) !== 0) {
502 502
 					continue;
503 503
 				}
504 504
 
505 505
 				// Relation now changes from '$uri' to '$curie:$relation'.
506
-				$rel_regex = str_replace( '\{rel\}', '(.+)', preg_quote( $curie['href'], '!' ) );
507
-				preg_match( '!' . $rel_regex . '!', $rel, $matches );
508
-				if ( $matches ) {
509
-					$new_rel = $curie['name'] . ':' . $matches[1];
510
-					$used_curies[ $curie['name'] ] = $curie;
511
-					$links[ $new_rel ] = $items;
512
-					unset( $links[ $rel ] );
506
+				$rel_regex = str_replace('\{rel\}', '(.+)', preg_quote($curie['href'], '!'));
507
+				preg_match('!'.$rel_regex.'!', $rel, $matches);
508
+				if ($matches) {
509
+					$new_rel = $curie['name'].':'.$matches[1];
510
+					$used_curies[$curie['name']] = $curie;
511
+					$links[$new_rel] = $items;
512
+					unset($links[$rel]);
513 513
 					break;
514 514
 				}
515 515
 			}
516 516
 		}
517 517
 
518 518
 		// Push the curies onto the start of the links array.
519
-		if ( $used_curies ) {
520
-			$links['curies'] = array_values( $used_curies );
519
+		if ($used_curies) {
520
+			$links['curies'] = array_values($used_curies);
521 521
 		}
522 522
 
523 523
 		return $links;
@@ -537,58 +537,58 @@  discard block
 block discarded – undo
537 537
 	 *     @type array [$_embedded] Embeddeds.
538 538
 	 * }
539 539
 	 */
540
-	protected function embed_links( $data ) {
541
-		if ( empty( $data['_links'] ) ) {
540
+	protected function embed_links($data) {
541
+		if (empty($data['_links'])) {
542 542
 			return $data;
543 543
 		}
544 544
 
545 545
 		$embedded = array();
546 546
 
547
-		foreach ( $data['_links'] as $rel => $links ) {
547
+		foreach ($data['_links'] as $rel => $links) {
548 548
 			// Ignore links to self, for obvious reasons.
549
-			if ( 'self' === $rel ) {
549
+			if ('self' === $rel) {
550 550
 				continue;
551 551
 			}
552 552
 
553 553
 			$embeds = array();
554 554
 
555
-			foreach ( $links as $item ) {
555
+			foreach ($links as $item) {
556 556
 				// Determine if the link is embeddable.
557
-				if ( empty( $item['embeddable'] ) ) {
557
+				if (empty($item['embeddable'])) {
558 558
 					// Ensure we keep the same order.
559 559
 					$embeds[] = array();
560 560
 					continue;
561 561
 				}
562 562
 
563 563
 				// Run through our internal routing and serve.
564
-				$request = WP_REST_Request::from_url( $item['href'] );
565
-				if ( ! $request ) {
564
+				$request = WP_REST_Request::from_url($item['href']);
565
+				if ( ! $request) {
566 566
 					$embeds[] = array();
567 567
 					continue;
568 568
 				}
569 569
 
570 570
 				// Embedded resources get passed context=embed.
571
-				if ( empty( $request['context'] ) ) {
571
+				if (empty($request['context'])) {
572 572
 					$request['context'] = 'embed';
573 573
 				}
574 574
 
575
-				$response = $this->dispatch( $request );
575
+				$response = $this->dispatch($request);
576 576
 
577 577
 				/** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */
578
-				$response = apply_filters( 'rest_post_dispatch', rest_ensure_response( $response ), $this, $request );
578
+				$response = apply_filters('rest_post_dispatch', rest_ensure_response($response), $this, $request);
579 579
 
580
-				$embeds[] = $this->response_to_data( $response, false );
580
+				$embeds[] = $this->response_to_data($response, false);
581 581
 			}
582 582
 
583 583
 			// Determine if any real links were found.
584
-			$has_links = count( array_filter( $embeds ) );
584
+			$has_links = count(array_filter($embeds));
585 585
 
586
-			if ( $has_links ) {
587
-				$embedded[ $rel ] = $embeds;
586
+			if ($has_links) {
587
+				$embedded[$rel] = $embeds;
588 588
 			}
589 589
 		}
590 590
 
591
-		if ( ! empty( $embedded ) ) {
591
+		if ( ! empty($embedded)) {
592 592
 			$data['_embedded'] = $embedded;
593 593
 		}
594 594
 
@@ -609,9 +609,9 @@  discard block
 block discarded – undo
609 609
 	 * @param bool             $embed    Whether links should be embedded.
610 610
 	 * @return WP_REST_Response New response with wrapped data
611 611
 	 */
612
-	public function envelope_response( $response, $embed ) {
612
+	public function envelope_response($response, $embed) {
613 613
 		$envelope = array(
614
-			'body'    => $this->response_to_data( $response, $embed ),
614
+			'body'    => $this->response_to_data($response, $embed),
615 615
 			'status'  => $response->get_status(),
616 616
 			'headers' => $response->get_headers(),
617 617
 		);
@@ -624,10 +624,10 @@  discard block
 block discarded – undo
624 624
 		 * @param array            $envelope Envelope data.
625 625
 		 * @param WP_REST_Response $response Original response data.
626 626
 		 */
627
-		$envelope = apply_filters( 'rest_envelope_response', $envelope, $response );
627
+		$envelope = apply_filters('rest_envelope_response', $envelope, $response);
628 628
 
629 629
 		// Ensure it's still a response and return.
630
-		return rest_ensure_response( $envelope );
630
+		return rest_ensure_response($envelope);
631 631
 	}
632 632
 
633 633
 	/**
@@ -642,14 +642,14 @@  discard block
 block discarded – undo
642 642
 	 * @param bool   $override   Optional. Whether the route should be overridden if it already exists.
643 643
 	 *                           Default false.
644 644
 	 */
645
-	public function register_route( $namespace, $route, $route_args, $override = false ) {
646
-		if ( ! isset( $this->namespaces[ $namespace ] ) ) {
647
-			$this->namespaces[ $namespace ] = array();
645
+	public function register_route($namespace, $route, $route_args, $override = false) {
646
+		if ( ! isset($this->namespaces[$namespace])) {
647
+			$this->namespaces[$namespace] = array();
648 648
 
649
-			$this->register_route( $namespace, '/' . $namespace, array(
649
+			$this->register_route($namespace, '/'.$namespace, array(
650 650
 				array(
651 651
 					'methods' => self::READABLE,
652
-					'callback' => array( $this, 'get_namespace_index' ),
652
+					'callback' => array($this, 'get_namespace_index'),
653 653
 					'args' => array(
654 654
 						'namespace' => array(
655 655
 							'default' => $namespace,
@@ -659,17 +659,17 @@  discard block
 block discarded – undo
659 659
 						),
660 660
 					),
661 661
 				),
662
-			) );
662
+			));
663 663
 		}
664 664
 
665 665
 		// Associative to avoid double-registration.
666
-		$this->namespaces[ $namespace ][ $route ] = true;
666
+		$this->namespaces[$namespace][$route] = true;
667 667
 		$route_args['namespace'] = $namespace;
668 668
 
669
-		if ( $override || empty( $this->endpoints[ $route ] ) ) {
670
-			$this->endpoints[ $route ] = $route_args;
669
+		if ($override || empty($this->endpoints[$route])) {
670
+			$this->endpoints[$route] = $route_args;
671 671
 		} else {
672
-			$this->endpoints[ $route ] = array_merge( $this->endpoints[ $route ], $route_args );
672
+			$this->endpoints[$route] = array_merge($this->endpoints[$route], $route_args);
673 673
 		}
674 674
 	}
675 675
 
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
 		 *                         `'/path/regex' => array( $callback, $bitmask )` or
707 707
 		 *                         `'/path/regex' => array( array( $callback, $bitmask ).
708 708
 		 */
709
-		$endpoints = apply_filters( 'rest_endpoints', $this->endpoints );
709
+		$endpoints = apply_filters('rest_endpoints', $this->endpoints);
710 710
 
711 711
 		// Normalise the endpoints.
712 712
 		$defaults = array(
@@ -717,32 +717,32 @@  discard block
 block discarded – undo
717 717
 			'args'          => array(),
718 718
 		);
719 719
 
720
-		foreach ( $endpoints as $route => &$handlers ) {
720
+		foreach ($endpoints as $route => &$handlers) {
721 721
 
722
-			if ( isset( $handlers['callback'] ) ) {
722
+			if (isset($handlers['callback'])) {
723 723
 				// Single endpoint, add one deeper.
724
-				$handlers = array( $handlers );
724
+				$handlers = array($handlers);
725 725
 			}
726 726
 
727
-			if ( ! isset( $this->route_options[ $route ] ) ) {
728
-				$this->route_options[ $route ] = array();
727
+			if ( ! isset($this->route_options[$route])) {
728
+				$this->route_options[$route] = array();
729 729
 			}
730 730
 
731
-			foreach ( $handlers as $key => &$handler ) {
731
+			foreach ($handlers as $key => &$handler) {
732 732
 
733
-				if ( ! is_numeric( $key ) ) {
733
+				if ( ! is_numeric($key)) {
734 734
 					// Route option, move it to the options.
735
-					$this->route_options[ $route ][ $key ] = $handler;
736
-					unset( $handlers[ $key ] );
735
+					$this->route_options[$route][$key] = $handler;
736
+					unset($handlers[$key]);
737 737
 					continue;
738 738
 				}
739 739
 
740
-				$handler = wp_parse_args( $handler, $defaults );
740
+				$handler = wp_parse_args($handler, $defaults);
741 741
 
742 742
 				// Allow comma-separated HTTP methods.
743
-				if ( is_string( $handler['methods'] ) ) {
744
-					$methods = explode( ',', $handler['methods'] );
745
-				} elseif ( is_array( $handler['methods'] ) ) {
743
+				if (is_string($handler['methods'])) {
744
+					$methods = explode(',', $handler['methods']);
745
+				} elseif (is_array($handler['methods'])) {
746 746
 					$methods = $handler['methods'];
747 747
 				} else {
748 748
 					$methods = array();
@@ -750,9 +750,9 @@  discard block
 block discarded – undo
750 750
 
751 751
 				$handler['methods'] = array();
752 752
 
753
-				foreach ( $methods as $method ) {
754
-					$method = strtoupper( trim( $method ) );
755
-					$handler['methods'][ $method ] = true;
753
+				foreach ($methods as $method) {
754
+					$method = strtoupper(trim($method));
755
+					$handler['methods'][$method] = true;
756 756
 				}
757 757
 			}
758 758
 		}
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
 	 * @return array List of registered namespaces.
770 770
 	 */
771 771
 	public function get_namespaces() {
772
-		return array_keys( $this->namespaces );
772
+		return array_keys($this->namespaces);
773 773
 	}
774 774
 
775 775
 	/**
@@ -781,12 +781,12 @@  discard block
 block discarded – undo
781 781
 	 * @param string $route Route pattern to fetch options for.
782 782
 	 * @return array|null Data as an associative array if found, or null if not found.
783 783
 	 */
784
-	public function get_route_options( $route ) {
785
-		if ( ! isset( $this->route_options[ $route ] ) ) {
784
+	public function get_route_options($route) {
785
+		if ( ! isset($this->route_options[$route])) {
786 786
 			return null;
787 787
 		}
788 788
 
789
-		return $this->route_options[ $route ];
789
+		return $this->route_options[$route];
790 790
 	}
791 791
 
792 792
 	/**
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
 	 * @param WP_REST_Request $request Request to attempt dispatching.
799 799
 	 * @return WP_REST_Response Response returned by the callback.
800 800
 	 */
801
-	public function dispatch( $request ) {
801
+	public function dispatch($request) {
802 802
 		/**
803 803
 		 * Filters the pre-calculated result of a REST dispatch request.
804 804
 		 *
@@ -812,62 +812,62 @@  discard block
 block discarded – undo
812 812
 		 * @param WP_REST_Server  $this    Server instance.
813 813
 		 * @param WP_REST_Request $request Request used to generate the response.
814 814
 		 */
815
-		$result = apply_filters( 'rest_pre_dispatch', null, $this, $request );
815
+		$result = apply_filters('rest_pre_dispatch', null, $this, $request);
816 816
 
817
-		if ( ! empty( $result ) ) {
817
+		if ( ! empty($result)) {
818 818
 			return $result;
819 819
 		}
820 820
 
821 821
 		$method = $request->get_method();
822 822
 		$path   = $request->get_route();
823 823
 
824
-		foreach ( $this->get_routes() as $route => $handlers ) {
825
-			$match = preg_match( '@^' . $route . '$@i', $path, $args );
824
+		foreach ($this->get_routes() as $route => $handlers) {
825
+			$match = preg_match('@^'.$route.'$@i', $path, $args);
826 826
 
827
-			if ( ! $match ) {
827
+			if ( ! $match) {
828 828
 				continue;
829 829
 			}
830 830
 
831
-			foreach ( $handlers as $handler ) {
832
-				$callback  = $handler['callback'];
831
+			foreach ($handlers as $handler) {
832
+				$callback = $handler['callback'];
833 833
 				$response = null;
834 834
 
835 835
 				// Fallback to GET method if no HEAD method is registered.
836 836
 				$checked_method = $method;
837
-				if ( 'HEAD' === $method && empty( $handler['methods']['HEAD'] ) ) {
837
+				if ('HEAD' === $method && empty($handler['methods']['HEAD'])) {
838 838
 					$checked_method = 'GET';
839 839
 				}
840
-				if ( empty( $handler['methods'][ $checked_method ] ) ) {
840
+				if (empty($handler['methods'][$checked_method])) {
841 841
 					continue;
842 842
 				}
843 843
 
844
-				if ( ! is_callable( $callback ) ) {
845
-					$response = new WP_Error( 'rest_invalid_handler', __( 'The handler for the route is invalid' ), array( 'status' => 500 ) );
844
+				if ( ! is_callable($callback)) {
845
+					$response = new WP_Error('rest_invalid_handler', __('The handler for the route is invalid'), array('status' => 500));
846 846
 				}
847 847
 
848
-				if ( ! is_wp_error( $response ) ) {
848
+				if ( ! is_wp_error($response)) {
849 849
 					// Remove the redundant preg_match argument.
850
-					unset( $args[0] );
850
+					unset($args[0]);
851 851
 
852
-					$request->set_url_params( $args );
853
-					$request->set_attributes( $handler );
852
+					$request->set_url_params($args);
853
+					$request->set_attributes($handler);
854 854
 
855 855
 					$defaults = array();
856 856
 
857
-					foreach ( $handler['args'] as $arg => $options ) {
858
-						if ( isset( $options['default'] ) ) {
859
-							$defaults[ $arg ] = $options['default'];
857
+					foreach ($handler['args'] as $arg => $options) {
858
+						if (isset($options['default'])) {
859
+							$defaults[$arg] = $options['default'];
860 860
 						}
861 861
 					}
862 862
 
863
-					$request->set_default_params( $defaults );
863
+					$request->set_default_params($defaults);
864 864
 
865 865
 					$check_required = $request->has_valid_params();
866
-					if ( is_wp_error( $check_required ) ) {
866
+					if (is_wp_error($check_required)) {
867 867
 						$response = $check_required;
868 868
 					} else {
869 869
 						$check_sanitized = $request->sanitize_params();
870
-						if ( is_wp_error( $check_sanitized ) ) {
870
+						if (is_wp_error($check_sanitized)) {
871 871
 							$response = $check_sanitized;
872 872
 						}
873 873
 					}
@@ -889,22 +889,22 @@  discard block
 block discarded – undo
889 889
 				 * @param WP_REST_Server   $handler  ResponseHandler instance (usually WP_REST_Server).
890 890
 				 * @param WP_REST_Request  $request  Request used to generate the response.
891 891
 				 */
892
-				$response = apply_filters( 'rest_request_before_callbacks', $response, $handler, $request );
892
+				$response = apply_filters('rest_request_before_callbacks', $response, $handler, $request);
893 893
 
894
-				if ( ! is_wp_error( $response ) ) {
894
+				if ( ! is_wp_error($response)) {
895 895
 					// Check permission specified on the route.
896
-					if ( ! empty( $handler['permission_callback'] ) ) {
897
-						$permission = call_user_func( $handler['permission_callback'], $request );
896
+					if ( ! empty($handler['permission_callback'])) {
897
+						$permission = call_user_func($handler['permission_callback'], $request);
898 898
 
899
-						if ( is_wp_error( $permission ) ) {
899
+						if (is_wp_error($permission)) {
900 900
 							$response = $permission;
901
-						} elseif ( false === $permission || null === $permission ) {
902
-							$response = new WP_Error( 'rest_forbidden', __( 'Sorry, you are not allowed to do that.' ), array( 'status' => 403 ) );
901
+						} elseif (false === $permission || null === $permission) {
902
+							$response = new WP_Error('rest_forbidden', __('Sorry, you are not allowed to do that.'), array('status' => 403));
903 903
 						}
904 904
 					}
905 905
 				}
906 906
 
907
-				if ( ! is_wp_error( $response ) ) {
907
+				if ( ! is_wp_error($response)) {
908 908
 					/**
909 909
 					 * Filters the REST dispatch request result.
910 910
 					 *
@@ -918,13 +918,13 @@  discard block
 block discarded – undo
918 918
 					 * @param string          $route           Route matched for the request.
919 919
 					 * @param array           $handler         Route handler used for the request.
920 920
 					 */
921
-					$dispatch_result = apply_filters( 'rest_dispatch_request', null, $request, $route, $handler );
921
+					$dispatch_result = apply_filters('rest_dispatch_request', null, $request, $route, $handler);
922 922
 
923 923
 					// Allow plugins to halt the request via this filter.
924
-					if ( null !== $dispatch_result ) {
924
+					if (null !== $dispatch_result) {
925 925
 						$response = $dispatch_result;
926 926
 					} else {
927
-						$response = call_user_func( $callback, $request );
927
+						$response = call_user_func($callback, $request);
928 928
 					}
929 929
 				}
930 930
 
@@ -948,22 +948,22 @@  discard block
 block discarded – undo
948 948
 				 * @param WP_REST_Server   $handler  ResponseHandler instance (usually WP_REST_Server).
949 949
 				 * @param WP_REST_Request  $request  Request used to generate the response.
950 950
 				 */
951
-				$response = apply_filters( 'rest_request_after_callbacks', $response, $handler, $request );
951
+				$response = apply_filters('rest_request_after_callbacks', $response, $handler, $request);
952 952
 
953
-				if ( is_wp_error( $response ) ) {
954
-					$response = $this->error_to_response( $response );
953
+				if (is_wp_error($response)) {
954
+					$response = $this->error_to_response($response);
955 955
 				} else {
956
-					$response = rest_ensure_response( $response );
956
+					$response = rest_ensure_response($response);
957 957
 				}
958 958
 
959
-				$response->set_matched_route( $route );
960
-				$response->set_matched_handler( $handler );
959
+				$response->set_matched_route($route);
960
+				$response->set_matched_handler($handler);
961 961
 
962 962
 				return $response;
963 963
 			}
964 964
 		}
965 965
 
966
-		return $this->error_to_response( new WP_Error( 'rest_no_route', __( 'No route was found matching the URL and request method' ), array( 'status' => 404 ) ) );
966
+		return $this->error_to_response(new WP_Error('rest_no_route', __('No route was found matching the URL and request method'), array('status' => 404)));
967 967
 	}
968 968
 
969 969
 	/**
@@ -979,13 +979,13 @@  discard block
 block discarded – undo
979 979
 	 */
980 980
 	protected function get_json_last_error() {
981 981
 		// See https://core.trac.wordpress.org/ticket/27799.
982
-		if ( ! function_exists( 'json_last_error' ) ) {
982
+		if ( ! function_exists('json_last_error')) {
983 983
 			return false;
984 984
 		}
985 985
 
986 986
 		$last_error_code = json_last_error();
987 987
 
988
-		if ( ( defined( 'JSON_ERROR_NONE' ) && JSON_ERROR_NONE === $last_error_code ) || empty( $last_error_code ) ) {
988
+		if ((defined('JSON_ERROR_NONE') && JSON_ERROR_NONE === $last_error_code) || empty($last_error_code)) {
989 989
 			return false;
990 990
 		}
991 991
 
@@ -1007,21 +1007,21 @@  discard block
 block discarded – undo
1007 1007
 	 * }
1008 1008
 	 * @return array Index entity
1009 1009
 	 */
1010
-	public function get_index( $request ) {
1010
+	public function get_index($request) {
1011 1011
 		// General site data.
1012 1012
 		$available = array(
1013
-			'name'           => get_option( 'blogname' ),
1014
-			'description'    => get_option( 'blogdescription' ),
1015
-			'url'            => get_option( 'siteurl' ),
1013
+			'name'           => get_option('blogname'),
1014
+			'description'    => get_option('blogdescription'),
1015
+			'url'            => get_option('siteurl'),
1016 1016
 			'home'           => home_url(),
1017
-			'namespaces'     => array_keys( $this->namespaces ),
1017
+			'namespaces'     => array_keys($this->namespaces),
1018 1018
 			'authentication' => array(),
1019
-			'routes'         => $this->get_data_for_routes( $this->get_routes(), $request['context'] ),
1019
+			'routes'         => $this->get_data_for_routes($this->get_routes(), $request['context']),
1020 1020
 		);
1021 1021
 
1022
-		$response = new WP_REST_Response( $available );
1022
+		$response = new WP_REST_Response($available);
1023 1023
 
1024
-		$response->add_link( 'help', 'http://v2.wp-api.org/' );
1024
+		$response->add_link('help', 'http://v2.wp-api.org/');
1025 1025
 
1026 1026
 		/**
1027 1027
 		 * Filters the API root index data.
@@ -1034,7 +1034,7 @@  discard block
 block discarded – undo
1034 1034
 		 *
1035 1035
 		 * @param WP_REST_Response $response Response data.
1036 1036
 		 */
1037
-		return apply_filters( 'rest_index', $response );
1037
+		return apply_filters('rest_index', $response);
1038 1038
 	}
1039 1039
 
1040 1040
 	/**
@@ -1047,24 +1047,24 @@  discard block
 block discarded – undo
1047 1047
 	 * @return WP_REST_Response|WP_Error WP_REST_Response instance if the index was found,
1048 1048
 	 *                                   WP_Error if the namespace isn't set.
1049 1049
 	 */
1050
-	public function get_namespace_index( $request ) {
1050
+	public function get_namespace_index($request) {
1051 1051
 		$namespace = $request['namespace'];
1052 1052
 
1053
-		if ( ! isset( $this->namespaces[ $namespace ] ) ) {
1054
-			return new WP_Error( 'rest_invalid_namespace', __( 'The specified namespace could not be found.' ), array( 'status' => 404 ) );
1053
+		if ( ! isset($this->namespaces[$namespace])) {
1054
+			return new WP_Error('rest_invalid_namespace', __('The specified namespace could not be found.'), array('status' => 404));
1055 1055
 		}
1056 1056
 
1057
-		$routes = $this->namespaces[ $namespace ];
1058
-		$endpoints = array_intersect_key( $this->get_routes(), $routes );
1057
+		$routes = $this->namespaces[$namespace];
1058
+		$endpoints = array_intersect_key($this->get_routes(), $routes);
1059 1059
 
1060 1060
 		$data = array(
1061 1061
 			'namespace' => $namespace,
1062
-			'routes' => $this->get_data_for_routes( $endpoints, $request['context'] ),
1062
+			'routes' => $this->get_data_for_routes($endpoints, $request['context']),
1063 1063
 		);
1064
-		$response = rest_ensure_response( $data );
1064
+		$response = rest_ensure_response($data);
1065 1065
 
1066 1066
 		// Link to the root index.
1067
-		$response->add_link( 'up', rest_url( '/' ) );
1067
+		$response->add_link('up', rest_url('/'));
1068 1068
 
1069 1069
 		/**
1070 1070
 		 * Filters the namespace index data.
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
 		 * @param WP_REST_Response $response Response data.
1078 1078
 		 * @param WP_REST_Request  $request  Request data. The namespace is passed as the 'namespace' parameter.
1079 1079
 		 */
1080
-		return apply_filters( 'rest_namespace_index', $response, $request );
1080
+		return apply_filters('rest_namespace_index', $response, $request);
1081 1081
 	}
1082 1082
 
1083 1083
 	/**
@@ -1090,13 +1090,13 @@  discard block
 block discarded – undo
1090 1090
 	 * @param string $context Optional. Context for data. Accepts 'view' or 'help'. Default 'view'.
1091 1091
 	 * @return array Route data to expose in indexes.
1092 1092
 	 */
1093
-	public function get_data_for_routes( $routes, $context = 'view' ) {
1093
+	public function get_data_for_routes($routes, $context = 'view') {
1094 1094
 		$available = array();
1095 1095
 
1096 1096
 		// Find the available routes.
1097
-		foreach ( $routes as $route => $callbacks ) {
1098
-			$data = $this->get_data_for_route( $route, $callbacks, $context );
1099
-			if ( empty( $data ) ) {
1097
+		foreach ($routes as $route => $callbacks) {
1098
+			$data = $this->get_data_for_route($route, $callbacks, $context);
1099
+			if (empty($data)) {
1100 1100
 				continue;
1101 1101
 			}
1102 1102
 
@@ -1107,7 +1107,7 @@  discard block
 block discarded – undo
1107 1107
 			 *
1108 1108
 			 * @param WP_REST_Request $request Request data. The namespace is passed as the 'namespace' parameter.
1109 1109
 			 */
1110
-			$available[ $route ] = apply_filters( 'rest_endpoints_description', $data );
1110
+			$available[$route] = apply_filters('rest_endpoints_description', $data);
1111 1111
 		}
1112 1112
 
1113 1113
 		/**
@@ -1122,7 +1122,7 @@  discard block
 block discarded – undo
1122 1122
 		 * @param array $available Map of route to route data.
1123 1123
 		 * @param array $routes    Internal route data as an associative array.
1124 1124
 		 */
1125
-		return apply_filters( 'rest_route_data', $available, $routes );
1125
+		return apply_filters('rest_route_data', $available, $routes);
1126 1126
 	}
1127 1127
 
1128 1128
 	/**
@@ -1136,74 +1136,74 @@  discard block
 block discarded – undo
1136 1136
 	 * @param string $context   Optional. Context for the data. Accepts 'view' or 'help'. Default 'view'.
1137 1137
 	 * @return array|null Data for the route, or null if no publicly-visible data.
1138 1138
 	 */
1139
-	public function get_data_for_route( $route, $callbacks, $context = 'view' ) {
1139
+	public function get_data_for_route($route, $callbacks, $context = 'view') {
1140 1140
 		$data = array(
1141 1141
 			'namespace' => '',
1142 1142
 			'methods' => array(),
1143 1143
 			'endpoints' => array(),
1144 1144
 		);
1145 1145
 
1146
-		if ( isset( $this->route_options[ $route ] ) ) {
1147
-			$options = $this->route_options[ $route ];
1146
+		if (isset($this->route_options[$route])) {
1147
+			$options = $this->route_options[$route];
1148 1148
 
1149
-			if ( isset( $options['namespace'] ) ) {
1149
+			if (isset($options['namespace'])) {
1150 1150
 				$data['namespace'] = $options['namespace'];
1151 1151
 			}
1152 1152
 
1153
-			if ( isset( $options['schema'] ) && 'help' === $context ) {
1154
-				$data['schema'] = call_user_func( $options['schema'] );
1153
+			if (isset($options['schema']) && 'help' === $context) {
1154
+				$data['schema'] = call_user_func($options['schema']);
1155 1155
 			}
1156 1156
 		}
1157 1157
 
1158
-		$route = preg_replace( '#\(\?P<(\w+?)>.*?\)#', '{$1}', $route );
1158
+		$route = preg_replace('#\(\?P<(\w+?)>.*?\)#', '{$1}', $route);
1159 1159
 
1160
-		foreach ( $callbacks as $callback ) {
1160
+		foreach ($callbacks as $callback) {
1161 1161
 			// Skip to the next route if any callback is hidden.
1162
-			if ( empty( $callback['show_in_index'] ) ) {
1162
+			if (empty($callback['show_in_index'])) {
1163 1163
 				continue;
1164 1164
 			}
1165 1165
 
1166
-			$data['methods'] = array_merge( $data['methods'], array_keys( $callback['methods'] ) );
1166
+			$data['methods'] = array_merge($data['methods'], array_keys($callback['methods']));
1167 1167
 			$endpoint_data = array(
1168
-				'methods' => array_keys( $callback['methods'] ),
1168
+				'methods' => array_keys($callback['methods']),
1169 1169
 			);
1170 1170
 
1171
-			if ( isset( $callback['args'] ) ) {
1171
+			if (isset($callback['args'])) {
1172 1172
 				$endpoint_data['args'] = array();
1173
-				foreach ( $callback['args'] as $key => $opts ) {
1173
+				foreach ($callback['args'] as $key => $opts) {
1174 1174
 					$arg_data = array(
1175
-						'required' => ! empty( $opts['required'] ),
1175
+						'required' => ! empty($opts['required']),
1176 1176
 					);
1177
-					if ( isset( $opts['default'] ) ) {
1177
+					if (isset($opts['default'])) {
1178 1178
 						$arg_data['default'] = $opts['default'];
1179 1179
 					}
1180
-					if ( isset( $opts['enum'] ) ) {
1180
+					if (isset($opts['enum'])) {
1181 1181
 						$arg_data['enum'] = $opts['enum'];
1182 1182
 					}
1183
-					if ( isset( $opts['description'] ) ) {
1183
+					if (isset($opts['description'])) {
1184 1184
 						$arg_data['description'] = $opts['description'];
1185 1185
 					}
1186
-					if ( isset( $opts['type'] ) ) {
1186
+					if (isset($opts['type'])) {
1187 1187
 						$arg_data['type'] = $opts['type'];
1188 1188
 					}
1189
-					if ( isset( $opts['items'] ) ) {
1189
+					if (isset($opts['items'])) {
1190 1190
 						$arg_data['items'] = $opts['items'];
1191 1191
 					}
1192
-					$endpoint_data['args'][ $key ] = $arg_data;
1192
+					$endpoint_data['args'][$key] = $arg_data;
1193 1193
 				}
1194 1194
 			}
1195 1195
 
1196 1196
 			$data['endpoints'][] = $endpoint_data;
1197 1197
 
1198 1198
 			// For non-variable routes, generate links.
1199
-			if ( strpos( $route, '{' ) === false ) {
1199
+			if (strpos($route, '{') === false) {
1200 1200
 				$data['_links'] = array(
1201
-					'self' => rest_url( $route ),
1201
+					'self' => rest_url($route),
1202 1202
 				);
1203 1203
 			}
1204 1204
 		}
1205 1205
 
1206
-		if ( empty( $data['methods'] ) ) {
1206
+		if (empty($data['methods'])) {
1207 1207
 			// No methods supported, hide the route.
1208 1208
 			return null;
1209 1209
 		}
@@ -1219,8 +1219,8 @@  discard block
 block discarded – undo
1219 1219
 	 *
1220 1220
 	 * @param int $code HTTP status.
1221 1221
 	 */
1222
-	protected function set_status( $code ) {
1223
-		status_header( $code );
1222
+	protected function set_status($code) {
1223
+		status_header($code);
1224 1224
 	}
1225 1225
 
1226 1226
 	/**
@@ -1232,7 +1232,7 @@  discard block
 block discarded – undo
1232 1232
 	 * @param string $key Header key.
1233 1233
 	 * @param string $value Header value.
1234 1234
 	 */
1235
-	public function send_header( $key, $value ) {
1235
+	public function send_header($key, $value) {
1236 1236
 		/*
1237 1237
 		 * Sanitize as per RFC2616 (Section 4.2):
1238 1238
 		 *
@@ -1240,8 +1240,8 @@  discard block
 block discarded – undo
1240 1240
 		 * single SP before interpreting the field value or forwarding the
1241 1241
 		 * message downstream.
1242 1242
 		 */
1243
-		$value = preg_replace( '/\s+/', ' ', $value );
1244
-		header( sprintf( '%s: %s', $key, $value ) );
1243
+		$value = preg_replace('/\s+/', ' ', $value);
1244
+		header(sprintf('%s: %s', $key, $value));
1245 1245
 	}
1246 1246
 
1247 1247
 	/**
@@ -1252,9 +1252,9 @@  discard block
 block discarded – undo
1252 1252
 	 *
1253 1253
 	 * @param array $headers Map of header name to header value.
1254 1254
 	 */
1255
-	public function send_headers( $headers ) {
1256
-		foreach ( $headers as $key => $value ) {
1257
-			$this->send_header( $key, $value );
1255
+	public function send_headers($headers) {
1256
+		foreach ($headers as $key => $value) {
1257
+			$this->send_header($key, $value);
1258 1258
 		}
1259 1259
 	}
1260 1260
 
@@ -1275,8 +1275,8 @@  discard block
 block discarded – undo
1275 1275
 		 * A bug in PHP < 5.2.2 makes $HTTP_RAW_POST_DATA not set by default,
1276 1276
 		 * but we can do it ourself.
1277 1277
 		 */
1278
-		if ( ! isset( $HTTP_RAW_POST_DATA ) ) {
1279
-			$HTTP_RAW_POST_DATA = file_get_contents( 'php://input' );
1278
+		if ( ! isset($HTTP_RAW_POST_DATA)) {
1279
+			$HTTP_RAW_POST_DATA = file_get_contents('php://input');
1280 1280
 		}
1281 1281
 
1282 1282
 		return $HTTP_RAW_POST_DATA;
@@ -1291,17 +1291,17 @@  discard block
 block discarded – undo
1291 1291
 	 * @param array $server Associative array similar to `$_SERVER`.
1292 1292
 	 * @return array Headers extracted from the input.
1293 1293
 	 */
1294
-	public function get_headers( $server ) {
1294
+	public function get_headers($server) {
1295 1295
 		$headers = array();
1296 1296
 
1297 1297
 		// CONTENT_* headers are not prefixed with HTTP_.
1298
-		$additional = array( 'CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true );
1298
+		$additional = array('CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true);
1299 1299
 
1300
-		foreach ( $server as $key => $value ) {
1301
-			if ( strpos( $key, 'HTTP_' ) === 0 ) {
1302
-				$headers[ substr( $key, 5 ) ] = $value;
1303
-			} elseif ( isset( $additional[ $key ] ) ) {
1304
-				$headers[ $key ] = $value;
1300
+		foreach ($server as $key => $value) {
1301
+			if (strpos($key, 'HTTP_') === 0) {
1302
+				$headers[substr($key, 5)] = $value;
1303
+			} elseif (isset($additional[$key])) {
1304
+				$headers[$key] = $value;
1305 1305
 			}
1306 1306
 		}
1307 1307
 
Please login to merge, or discard this patch.
src/wp-includes/user.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
  *
735 735
  * @param int    $user_id    User ID.
736 736
  * @param string $meta_key   Metadata name.
737
- * @param mixed  $meta_value Metadata value.
737
+ * @param string  $meta_value Metadata value.
738 738
  * @param bool   $unique     Optional, default is false. Whether the same key should not be added.
739 739
  * @return int|false Meta ID on success, false on failure.
740 740
  */
@@ -1211,7 +1211,7 @@  discard block
 block discarded – undo
1211 1211
  * @since 3.0.0
1212 1212
  *
1213 1213
  * @param object|WP_User $user User object to be cached
1214
- * @return bool|null Returns false on failure.
1214
+ * @return false|null Returns false on failure.
1215 1215
  */
1216 1216
 function update_user_caches( $user ) {
1217 1217
 	if ( $user instanceof WP_User ) {
Please login to merge, or discard this patch.
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -67,13 +67,13 @@  discard block
 block discarded – undo
67 67
 	 *
68 68
 	 * @param bool  $secure_cookie Whether to use a secure sign-on cookie.
69 69
 	 * @param array $credentials {
70
- 	 *     Array of entered sign-on data.
71
- 	 *
72
- 	 *     @type string $user_login    Username.
73
- 	 *     @type string $user_password Password entered.
70
+	 *     Array of entered sign-on data.
71
+	 *
72
+	 *     @type string $user_login    Username.
73
+	 *     @type string $user_password Password entered.
74 74
 	 *     @type bool   $remember      Whether to 'remember' the user. Increases the time
75 75
 	 *                                 that the cookie will be kept. Default false.
76
- 	 * }
76
+	 * }
77 77
 	 */
78 78
 	$secure_cookie = apply_filters( 'secure_signon_cookie', $secure_cookie, $credentials );
79 79
 
@@ -1184,7 +1184,7 @@  discard block
 block discarded – undo
1184 1184
 			 *
1185 1185
 			 * The dynamic portion of the hook name, `$field`, refers to the prefixed user
1186 1186
 			 * field being filtered, such as 'user_login', 'user_email', 'first_name', etc.
1187
- 			 *
1187
+			 *
1188 1188
 			 * @since 2.9.0
1189 1189
 			 *
1190 1190
 			 * @param mixed $value Value of the prefixed user field.
@@ -1625,16 +1625,16 @@  discard block
 block discarded – undo
1625 1625
 	$user = new WP_User( $user_id );
1626 1626
 
1627 1627
 	/**
1628
- 	 * Filters a user's meta values and keys before the user is created or updated.
1629
- 	 *
1630
- 	 * Does not include contact methods. These are added using `wp_get_user_contact_methods( $user )`.
1631
- 	 *
1632
- 	 * @since 4.4.0
1633
- 	 *
1634
- 	 * @param array $meta {
1635
- 	 *     Default meta values and keys for the user.
1636
- 	 *
1637
- 	 *     @type string   $nickname             The user's nickname. Default is the user's username.
1628
+	 * Filters a user's meta values and keys before the user is created or updated.
1629
+	 *
1630
+	 * Does not include contact methods. These are added using `wp_get_user_contact_methods( $user )`.
1631
+	 *
1632
+	 * @since 4.4.0
1633
+	 *
1634
+	 * @param array $meta {
1635
+	 *     Default meta values and keys for the user.
1636
+	 *
1637
+	 *     @type string   $nickname             The user's nickname. Default is the user's username.
1638 1638
 	 *     @type string   $first_name           The user's first name.
1639 1639
 	 *     @type string   $last_name            The user's last name.
1640 1640
 	 *     @type string   $description          The user's description.
@@ -1645,10 +1645,10 @@  discard block
 block discarded – undo
1645 1645
 	 *                                          not forced.
1646 1646
 	 *     @type bool     $show_admin_bar_front Whether to show the admin bar on the front end for the user.
1647 1647
 	 *                                          Default true.
1648
- 	 * }
1648
+	 * }
1649 1649
 	 * @param WP_User $user   User object.
1650 1650
 	 * @param bool    $update Whether the user is being updated rather than created.
1651
- 	 */
1651
+	 */
1652 1652
 	$meta = apply_filters( 'insert_user_meta', $meta, $user, $update );
1653 1653
 
1654 1654
 	// Update user meta.
@@ -1983,7 +1983,7 @@  discard block
 block discarded – undo
1983 1983
 	 * @since 2.9.0
1984 1984
 	 *
1985 1985
 	 * @param array   $methods Array of contact methods and their labels.
1986
- 	 * @param WP_User $user    WP_User object.
1986
+	 * @param WP_User $user    WP_User object.
1987 1987
 	 */
1988 1988
 	return apply_filters( 'user_contactmethods', $methods, $user );
1989 1989
 }
Please login to merge, or discard this patch.
Spacing   +492 added lines, -492 removed lines patch added patch discarded remove patch
@@ -25,19 +25,19 @@  discard block
 block discarded – undo
25 25
  * @param string|bool $secure_cookie Optional. Whether to use secure cookie.
26 26
  * @return WP_User|WP_Error WP_User on success, WP_Error on failure.
27 27
  */
28
-function wp_signon( $credentials = array(), $secure_cookie = '' ) {
29
-	if ( empty($credentials) ) {
28
+function wp_signon($credentials = array(), $secure_cookie = '') {
29
+	if (empty($credentials)) {
30 30
 		$credentials = array(); // Back-compat for plugins passing an empty string.
31 31
 
32
-		if ( ! empty($_POST['log']) )
32
+		if ( ! empty($_POST['log']))
33 33
 			$credentials['user_login'] = $_POST['log'];
34
-		if ( ! empty($_POST['pwd']) )
34
+		if ( ! empty($_POST['pwd']))
35 35
 			$credentials['user_password'] = $_POST['pwd'];
36
-		if ( ! empty($_POST['rememberme']) )
36
+		if ( ! empty($_POST['rememberme']))
37 37
 			$credentials['remember'] = $_POST['rememberme'];
38 38
 	}
39 39
 
40
-	if ( !empty($credentials['remember']) )
40
+	if ( ! empty($credentials['remember']))
41 41
 		$credentials['remember'] = true;
42 42
 	else
43 43
 		$credentials['remember'] = false;
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
 	 * @param string $user_login    Username, passed by reference.
56 56
 	 * @param string $user_password User password, passed by reference.
57 57
 	 */
58
-	do_action_ref_array( 'wp_authenticate', array( &$credentials['user_login'], &$credentials['user_password'] ) );
58
+	do_action_ref_array('wp_authenticate', array(&$credentials['user_login'], &$credentials['user_password']));
59 59
 
60
-	if ( '' === $secure_cookie )
60
+	if ('' === $secure_cookie)
61 61
 		$secure_cookie = is_ssl();
62 62
 
63 63
 	/**
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 *                                 that the cookie will be kept. Default false.
76 76
  	 * }
77 77
 	 */
78
-	$secure_cookie = apply_filters( 'secure_signon_cookie', $secure_cookie, $credentials );
78
+	$secure_cookie = apply_filters('secure_signon_cookie', $secure_cookie, $credentials);
79 79
 
80 80
 	global $auth_secure_cookie; // XXX ugly hack to pass this to wp_authenticate_cookie
81 81
 	$auth_secure_cookie = $secure_cookie;
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 
85 85
 	$user = wp_authenticate($credentials['user_login'], $credentials['user_password']);
86 86
 
87
-	if ( is_wp_error($user) ) {
88
-		if ( $user->get_error_codes() == array('empty_username', 'empty_password') ) {
87
+	if (is_wp_error($user)) {
88
+		if ($user->get_error_codes() == array('empty_username', 'empty_password')) {
89 89
 			$user = new WP_Error('', '');
90 90
 		}
91 91
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 * @param string  $user_login Username.
102 102
 	 * @param WP_User $user       WP_User object of the logged-in user.
103 103
 	 */
104
-	do_action( 'wp_login', $user->user_login, $user );
104
+	do_action('wp_login', $user->user_login, $user);
105 105
 	return $user;
106 106
 }
107 107
 
@@ -116,20 +116,20 @@  discard block
 block discarded – undo
116 116
  * @return WP_User|WP_Error WP_User on success, WP_Error on failure.
117 117
  */
118 118
 function wp_authenticate_username_password($user, $username, $password) {
119
-	if ( $user instanceof WP_User ) {
119
+	if ($user instanceof WP_User) {
120 120
 		return $user;
121 121
 	}
122 122
 
123
-	if ( empty($username) || empty($password) ) {
124
-		if ( is_wp_error( $user ) )
123
+	if (empty($username) || empty($password)) {
124
+		if (is_wp_error($user))
125 125
 			return $user;
126 126
 
127 127
 		$error = new WP_Error();
128 128
 
129
-		if ( empty($username) )
129
+		if (empty($username))
130 130
 			$error->add('empty_username', __('<strong>ERROR</strong>: The username field is empty.'));
131 131
 
132
-		if ( empty($password) )
132
+		if (empty($password))
133 133
 			$error->add('empty_password', __('<strong>ERROR</strong>: The password field is empty.'));
134 134
 
135 135
 		return $error;
@@ -137,11 +137,11 @@  discard block
 block discarded – undo
137 137
 
138 138
 	$user = get_user_by('login', $username);
139 139
 
140
-	if ( !$user ) {
141
-		return new WP_Error( 'invalid_username',
142
-			__( '<strong>ERROR</strong>: Invalid username.' ) .
143
-			' <a href="' . wp_lostpassword_url() . '">' .
144
-			__( 'Lost your password?' ) .
140
+	if ( ! $user) {
141
+		return new WP_Error('invalid_username',
142
+			__('<strong>ERROR</strong>: Invalid username.').
143
+			' <a href="'.wp_lostpassword_url().'">'.
144
+			__('Lost your password?').
145 145
 			'</a>'
146 146
 		);
147 147
 	}
@@ -155,19 +155,19 @@  discard block
 block discarded – undo
155 155
 	 *                                   callback failed authentication.
156 156
 	 * @param string           $password Password to check against the user.
157 157
 	 */
158
-	$user = apply_filters( 'wp_authenticate_user', $user, $password );
159
-	if ( is_wp_error($user) )
158
+	$user = apply_filters('wp_authenticate_user', $user, $password);
159
+	if (is_wp_error($user))
160 160
 		return $user;
161 161
 
162
-	if ( ! wp_check_password( $password, $user->user_pass, $user->ID ) ) {
163
-		return new WP_Error( 'incorrect_password',
162
+	if ( ! wp_check_password($password, $user->user_pass, $user->ID)) {
163
+		return new WP_Error('incorrect_password',
164 164
 			sprintf(
165 165
 				/* translators: %s: user name */
166
-				__( '<strong>ERROR</strong>: The password you entered for the username %s is incorrect.' ),
167
-				'<strong>' . $username . '</strong>'
168
-			) .
169
-			' <a href="' . wp_lostpassword_url() . '">' .
170
-			__( 'Lost your password?' ) .
166
+				__('<strong>ERROR</strong>: The password you entered for the username %s is incorrect.'),
167
+				'<strong>'.$username.'</strong>'
168
+			).
169
+			' <a href="'.wp_lostpassword_url().'">'.
170
+			__('Lost your password?').
171 171
 			'</a>'
172 172
 		);
173 173
 	}
@@ -186,60 +186,60 @@  discard block
 block discarded – undo
186 186
  * @param string                $password Password for authentication.
187 187
  * @return WP_User|WP_Error WP_User on success, WP_Error on failure.
188 188
  */
189
-function wp_authenticate_email_password( $user, $email, $password ) {
190
-	if ( $user instanceof WP_User ) {
189
+function wp_authenticate_email_password($user, $email, $password) {
190
+	if ($user instanceof WP_User) {
191 191
 		return $user;
192 192
 	}
193 193
 
194
-	if ( empty( $email ) || empty( $password ) ) {
195
-		if ( is_wp_error( $user ) ) {
194
+	if (empty($email) || empty($password)) {
195
+		if (is_wp_error($user)) {
196 196
 			return $user;
197 197
 		}
198 198
 
199 199
 		$error = new WP_Error();
200 200
 
201
-		if ( empty( $email ) ) {
202
-			$error->add( 'empty_username', __( '<strong>ERROR</strong>: The email field is empty.' ) ); // Uses 'empty_username' for back-compat with wp_signon()
201
+		if (empty($email)) {
202
+			$error->add('empty_username', __('<strong>ERROR</strong>: The email field is empty.')); // Uses 'empty_username' for back-compat with wp_signon()
203 203
 		}
204 204
 
205
-		if ( empty( $password ) ) {
206
-			$error->add( 'empty_password', __( '<strong>ERROR</strong>: The password field is empty.' ) );
205
+		if (empty($password)) {
206
+			$error->add('empty_password', __('<strong>ERROR</strong>: The password field is empty.'));
207 207
 		}
208 208
 
209 209
 		return $error;
210 210
 	}
211 211
 
212
-	if ( ! is_email( $email ) ) {
212
+	if ( ! is_email($email)) {
213 213
 		return $user;
214 214
 	}
215 215
 
216
-	$user = get_user_by( 'email', $email );
216
+	$user = get_user_by('email', $email);
217 217
 
218
-	if ( ! $user ) {
219
-		return new WP_Error( 'invalid_email',
220
-			__( '<strong>ERROR</strong>: Invalid email address.' ) .
221
-			' <a href="' . wp_lostpassword_url() . '">' .
222
-			__( 'Lost your password?' ) .
218
+	if ( ! $user) {
219
+		return new WP_Error('invalid_email',
220
+			__('<strong>ERROR</strong>: Invalid email address.').
221
+			' <a href="'.wp_lostpassword_url().'">'.
222
+			__('Lost your password?').
223 223
 			'</a>'
224 224
 		);
225 225
 	}
226 226
 
227 227
 	/** This filter is documented in wp-includes/user.php */
228
-	$user = apply_filters( 'wp_authenticate_user', $user, $password );
228
+	$user = apply_filters('wp_authenticate_user', $user, $password);
229 229
 
230
-	if ( is_wp_error( $user ) ) {
230
+	if (is_wp_error($user)) {
231 231
 		return $user;
232 232
 	}
233 233
 
234
-	if ( ! wp_check_password( $password, $user->user_pass, $user->ID ) ) {
235
-		return new WP_Error( 'incorrect_password',
234
+	if ( ! wp_check_password($password, $user->user_pass, $user->ID)) {
235
+		return new WP_Error('incorrect_password',
236 236
 			sprintf(
237 237
 				/* translators: %s: email address */
238
-				__( '<strong>ERROR</strong>: The password you entered for the email address %s is incorrect.' ),
239
-				'<strong>' . $email . '</strong>'
240
-			) .
241
-			' <a href="' . wp_lostpassword_url() . '">' .
242
-			__( 'Lost your password?' ) .
238
+				__('<strong>ERROR</strong>: The password you entered for the email address %s is incorrect.'),
239
+				'<strong>'.$email.'</strong>'
240
+			).
241
+			' <a href="'.wp_lostpassword_url().'">'.
242
+			__('Lost your password?').
243 243
 			'</a>'
244 244
 		);
245 245
 	}
@@ -260,23 +260,23 @@  discard block
 block discarded – undo
260 260
  * @return WP_User|WP_Error WP_User on success, WP_Error on failure.
261 261
  */
262 262
 function wp_authenticate_cookie($user, $username, $password) {
263
-	if ( $user instanceof WP_User ) {
263
+	if ($user instanceof WP_User) {
264 264
 		return $user;
265 265
 	}
266 266
 
267
-	if ( empty($username) && empty($password) ) {
267
+	if (empty($username) && empty($password)) {
268 268
 		$user_id = wp_validate_auth_cookie();
269
-		if ( $user_id )
269
+		if ($user_id)
270 270
 			return new WP_User($user_id);
271 271
 
272 272
 		global $auth_secure_cookie;
273 273
 
274
-		if ( $auth_secure_cookie )
274
+		if ($auth_secure_cookie)
275 275
 			$auth_cookie = SECURE_AUTH_COOKIE;
276 276
 		else
277 277
 			$auth_cookie = AUTH_COOKIE;
278 278
 
279
-		if ( !empty($_COOKIE[$auth_cookie]) )
279
+		if ( ! empty($_COOKIE[$auth_cookie]))
280 280
 			return new WP_Error('expired_session', __('Please log in again.'));
281 281
 
282 282
 		// If the cookie is not set, be silent.
@@ -294,8 +294,8 @@  discard block
 block discarded – undo
294 294
  * @param WP_User|WP_Error|null $user WP_User or WP_Error object from a previous callback. Default null.
295 295
  * @return WP_User|WP_Error WP_User on success, WP_Error if the user is considered a spammer.
296 296
  */
297
-function wp_authenticate_spam_check( $user ) {
298
-	if ( $user instanceof WP_User && is_multisite() ) {
297
+function wp_authenticate_spam_check($user) {
298
+	if ($user instanceof WP_User && is_multisite()) {
299 299
 		/**
300 300
 		 * Filters whether the user has been marked as a spammer.
301 301
 		 *
@@ -304,10 +304,10 @@  discard block
 block discarded – undo
304 304
 		 * @param bool    $spammed Whether the user is considered a spammer.
305 305
 		 * @param WP_User $user    User to check against.
306 306
 		 */
307
-		$spammed = apply_filters( 'check_is_user_spammed', is_user_spammy( $user ), $user );
307
+		$spammed = apply_filters('check_is_user_spammed', is_user_spammy($user), $user);
308 308
 
309
-		if ( $spammed )
310
-			return new WP_Error( 'spammer_account', __( '<strong>ERROR</strong>: Your account has been marked as a spammer.' ) );
309
+		if ($spammed)
310
+			return new WP_Error('spammer_account', __('<strong>ERROR</strong>: Your account has been marked as a spammer.'));
311 311
 	}
312 312
 	return $user;
313 313
 }
@@ -327,16 +327,16 @@  discard block
 block discarded – undo
327 327
  * @return int|false User ID if validated, false otherwise. If a user ID from
328 328
  *                   an earlier filter callback is received, that value is returned.
329 329
  */
330
-function wp_validate_logged_in_cookie( $user_id ) {
331
-	if ( $user_id ) {
330
+function wp_validate_logged_in_cookie($user_id) {
331
+	if ($user_id) {
332 332
 		return $user_id;
333 333
 	}
334 334
 
335
-	if ( is_blog_admin() || is_network_admin() || empty( $_COOKIE[LOGGED_IN_COOKIE] ) ) {
335
+	if (is_blog_admin() || is_network_admin() || empty($_COOKIE[LOGGED_IN_COOKIE])) {
336 336
 		return false;
337 337
 	}
338 338
 
339
-	return wp_validate_auth_cookie( $_COOKIE[LOGGED_IN_COOKIE], 'logged_in' );
339
+	return wp_validate_auth_cookie($_COOKIE[LOGGED_IN_COOKIE], 'logged_in');
340 340
 }
341 341
 
342 342
 /**
@@ -354,12 +354,12 @@  discard block
 block discarded – undo
354 354
  * @param bool         $public_only Optional. Whether to only return counts for public posts. Default false.
355 355
  * @return string Number of posts the user has written in this post type.
356 356
  */
357
-function count_user_posts( $userid, $post_type = 'post', $public_only = false ) {
357
+function count_user_posts($userid, $post_type = 'post', $public_only = false) {
358 358
 	global $wpdb;
359 359
 
360
-	$where = get_posts_by_author_sql( $post_type, true, $userid, $public_only );
360
+	$where = get_posts_by_author_sql($post_type, true, $userid, $public_only);
361 361
 
362
-	$count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts $where" );
362
+	$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts $where");
363 363
 
364 364
 	/**
365 365
 	 * Filters the number of posts a user has written.
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 	 * @param string|array $post_type   Single post type or array of post types to count the number of posts for.
374 374
 	 * @param bool         $public_only Whether to limit counted posts to public posts.
375 375
 	 */
376
-	return apply_filters( 'get_usernumposts', $count, $userid, $post_type, $public_only );
376
+	return apply_filters('get_usernumposts', $count, $userid, $post_type, $public_only);
377 377
 }
378 378
 
379 379
 /**
@@ -388,24 +388,24 @@  discard block
 block discarded – undo
388 388
  * @param bool         $public_only Optional. Only return counts for public posts.  Defaults to false.
389 389
  * @return array Amount of posts each user has written.
390 390
  */
391
-function count_many_users_posts( $users, $post_type = 'post', $public_only = false ) {
391
+function count_many_users_posts($users, $post_type = 'post', $public_only = false) {
392 392
 	global $wpdb;
393 393
 
394 394
 	$count = array();
395
-	if ( empty( $users ) || ! is_array( $users ) )
395
+	if (empty($users) || ! is_array($users))
396 396
 		return $count;
397 397
 
398
-	$userlist = implode( ',', array_map( 'absint', $users ) );
399
-	$where = get_posts_by_author_sql( $post_type, true, null, $public_only );
398
+	$userlist = implode(',', array_map('absint', $users));
399
+	$where = get_posts_by_author_sql($post_type, true, null, $public_only);
400 400
 
401
-	$result = $wpdb->get_results( "SELECT post_author, COUNT(*) FROM $wpdb->posts $where AND post_author IN ($userlist) GROUP BY post_author", ARRAY_N );
402
-	foreach ( $result as $row ) {
403
-		$count[ $row[0] ] = $row[1];
401
+	$result = $wpdb->get_results("SELECT post_author, COUNT(*) FROM $wpdb->posts $where AND post_author IN ($userlist) GROUP BY post_author", ARRAY_N);
402
+	foreach ($result as $row) {
403
+		$count[$row[0]] = $row[1];
404 404
 	}
405 405
 
406
-	foreach ( $users as $id ) {
407
-		if ( ! isset( $count[ $id ] ) )
408
-			$count[ $id ] = 0;
406
+	foreach ($users as $id) {
407
+		if ( ! isset($count[$id]))
408
+			$count[$id] = 0;
409 409
 	}
410 410
 
411 411
 	return $count;
@@ -423,10 +423,10 @@  discard block
 block discarded – undo
423 423
  * @return int The current user's ID, or 0 if no user is logged in.
424 424
  */
425 425
 function get_current_user_id() {
426
-	if ( ! function_exists( 'wp_get_current_user' ) )
426
+	if ( ! function_exists('wp_get_current_user'))
427 427
 		return 0;
428 428
 	$user = wp_get_current_user();
429
-	return ( isset( $user->ID ) ? (int) $user->ID : 0 );
429
+	return (isset($user->ID) ? (int) $user->ID : 0);
430 430
 }
431 431
 
432 432
 /**
@@ -448,23 +448,23 @@  discard block
 block discarded – undo
448 448
  * @param string $deprecated Use get_option() to check for an option in the options table.
449 449
  * @return mixed User option value on success, false on failure.
450 450
  */
451
-function get_user_option( $option, $user = 0, $deprecated = '' ) {
451
+function get_user_option($option, $user = 0, $deprecated = '') {
452 452
 	global $wpdb;
453 453
 
454
-	if ( !empty( $deprecated ) )
455
-		_deprecated_argument( __FUNCTION__, '3.0.0' );
454
+	if ( ! empty($deprecated))
455
+		_deprecated_argument(__FUNCTION__, '3.0.0');
456 456
 
457
-	if ( empty( $user ) )
457
+	if (empty($user))
458 458
 		$user = get_current_user_id();
459 459
 
460
-	if ( ! $user = get_userdata( $user ) )
460
+	if ( ! $user = get_userdata($user))
461 461
 		return false;
462 462
 
463 463
 	$prefix = $wpdb->get_blog_prefix();
464
-	if ( $user->has_prop( $prefix . $option ) ) // Blog specific
465
-		$result = $user->get( $prefix . $option );
466
-	elseif ( $user->has_prop( $option ) ) // User specific and cross-blog
467
-		$result = $user->get( $option );
464
+	if ($user->has_prop($prefix.$option)) // Blog specific
465
+		$result = $user->get($prefix.$option);
466
+	elseif ($user->has_prop($option)) // User specific and cross-blog
467
+		$result = $user->get($option);
468 468
 	else
469 469
 		$result = false;
470 470
 
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 	 * @param string  $option Name of the option being retrieved.
480 480
 	 * @param WP_User $user   WP_User object of the user whose option is being retrieved.
481 481
 	 */
482
-	return apply_filters( "get_user_option_{$option}", $result, $option, $user );
482
+	return apply_filters("get_user_option_{$option}", $result, $option, $user);
483 483
 }
484 484
 
485 485
 /**
@@ -503,13 +503,13 @@  discard block
 block discarded – undo
503 503
  * @return int|bool User meta ID if the option didn't exist, true on successful update,
504 504
  *                  false on failure.
505 505
  */
506
-function update_user_option( $user_id, $option_name, $newvalue, $global = false ) {
506
+function update_user_option($user_id, $option_name, $newvalue, $global = false) {
507 507
 	global $wpdb;
508 508
 
509
-	if ( !$global )
510
-		$option_name = $wpdb->get_blog_prefix() . $option_name;
509
+	if ( ! $global)
510
+		$option_name = $wpdb->get_blog_prefix().$option_name;
511 511
 
512
-	return update_user_meta( $user_id, $option_name, $newvalue );
512
+	return update_user_meta($user_id, $option_name, $newvalue);
513 513
 }
514 514
 
515 515
 /**
@@ -529,12 +529,12 @@  discard block
 block discarded – undo
529 529
  *                            Default false (blog specific).
530 530
  * @return bool True on success, false on failure.
531 531
  */
532
-function delete_user_option( $user_id, $option_name, $global = false ) {
532
+function delete_user_option($user_id, $option_name, $global = false) {
533 533
 	global $wpdb;
534 534
 
535
-	if ( !$global )
536
-		$option_name = $wpdb->get_blog_prefix() . $option_name;
537
-	return delete_user_meta( $user_id, $option_name );
535
+	if ( ! $global)
536
+		$option_name = $wpdb->get_blog_prefix().$option_name;
537
+	return delete_user_meta($user_id, $option_name);
538 538
 }
539 539
 
540 540
 /**
@@ -548,9 +548,9 @@  discard block
 block discarded – undo
548 548
  *                    for more information on accepted arguments.
549 549
  * @return array List of users.
550 550
  */
551
-function get_users( $args = array() ) {
551
+function get_users($args = array()) {
552 552
 
553
-	$args = wp_parse_args( $args );
553
+	$args = wp_parse_args($args);
554 554
 	$args['count_total'] = false;
555 555
 
556 556
 	$user_search = new WP_User_Query($args);
@@ -572,13 +572,13 @@  discard block
 block discarded – undo
572 572
  * @return array A list of the user's sites. An empty array if the user doesn't exist
573 573
  *               or belongs to no sites.
574 574
  */
575
-function get_blogs_of_user( $user_id, $all = false ) {
575
+function get_blogs_of_user($user_id, $all = false) {
576 576
 	global $wpdb;
577 577
 
578 578
 	$user_id = (int) $user_id;
579 579
 
580 580
 	// Logged out users can't have sites
581
-	if ( empty( $user_id ) )
581
+	if (empty($user_id))
582 582
 		return array();
583 583
 
584 584
 	/**
@@ -594,47 +594,47 @@  discard block
 block discarded – undo
594 594
 	 * @param bool       $all     Whether the returned array should contain all sites, including
595 595
 	 *                            those marked 'deleted', 'archived', or 'spam'. Default false.
596 596
 	 */
597
-	$sites = apply_filters( 'pre_get_blogs_of_user', null, $user_id, $all );
597
+	$sites = apply_filters('pre_get_blogs_of_user', null, $user_id, $all);
598 598
 
599
-	if ( null !== $sites ) {
599
+	if (null !== $sites) {
600 600
 		return $sites;
601 601
 	}
602 602
 
603
-	$keys = get_user_meta( $user_id );
604
-	if ( empty( $keys ) )
603
+	$keys = get_user_meta($user_id);
604
+	if (empty($keys))
605 605
 		return array();
606 606
 
607
-	if ( ! is_multisite() ) {
607
+	if ( ! is_multisite()) {
608 608
 		$site_id = get_current_blog_id();
609
-		$sites = array( $site_id => new stdClass );
610
-		$sites[ $site_id ]->userblog_id = $site_id;
611
-		$sites[ $site_id ]->blogname = get_option('blogname');
612
-		$sites[ $site_id ]->domain = '';
613
-		$sites[ $site_id ]->path = '';
614
-		$sites[ $site_id ]->site_id = 1;
615
-		$sites[ $site_id ]->siteurl = get_option('siteurl');
616
-		$sites[ $site_id ]->archived = 0;
617
-		$sites[ $site_id ]->spam = 0;
618
-		$sites[ $site_id ]->deleted = 0;
609
+		$sites = array($site_id => new stdClass);
610
+		$sites[$site_id]->userblog_id = $site_id;
611
+		$sites[$site_id]->blogname = get_option('blogname');
612
+		$sites[$site_id]->domain = '';
613
+		$sites[$site_id]->path = '';
614
+		$sites[$site_id]->site_id = 1;
615
+		$sites[$site_id]->siteurl = get_option('siteurl');
616
+		$sites[$site_id]->archived = 0;
617
+		$sites[$site_id]->spam = 0;
618
+		$sites[$site_id]->deleted = 0;
619 619
 		return $sites;
620 620
 	}
621 621
 
622 622
 	$site_ids = array();
623 623
 
624
-	if ( isset( $keys[ $wpdb->base_prefix . 'capabilities' ] ) && defined( 'MULTISITE' ) ) {
624
+	if (isset($keys[$wpdb->base_prefix.'capabilities']) && defined('MULTISITE')) {
625 625
 		$site_ids[] = 1;
626
-		unset( $keys[ $wpdb->base_prefix . 'capabilities' ] );
626
+		unset($keys[$wpdb->base_prefix.'capabilities']);
627 627
 	}
628 628
 
629
-	$keys = array_keys( $keys );
629
+	$keys = array_keys($keys);
630 630
 
631
-	foreach ( $keys as $key ) {
632
-		if ( 'capabilities' !== substr( $key, -12 ) )
631
+	foreach ($keys as $key) {
632
+		if ('capabilities' !== substr($key, -12))
633 633
 			continue;
634
-		if ( $wpdb->base_prefix && 0 !== strpos( $key, $wpdb->base_prefix ) )
634
+		if ($wpdb->base_prefix && 0 !== strpos($key, $wpdb->base_prefix))
635 635
 			continue;
636
-		$site_id = str_replace( array( $wpdb->base_prefix, '_capabilities' ), '', $key );
637
-		if ( ! is_numeric( $site_id ) )
636
+		$site_id = str_replace(array($wpdb->base_prefix, '_capabilities'), '', $key);
637
+		if ( ! is_numeric($site_id))
638 638
 			continue;
639 639
 
640 640
 		$site_ids[] = (int) $site_id;
@@ -642,21 +642,21 @@  discard block
 block discarded – undo
642 642
 
643 643
 	$sites = array();
644 644
 
645
-	if ( ! empty( $site_ids ) ) {
645
+	if ( ! empty($site_ids)) {
646 646
 		$args = array(
647 647
 			'number'   => '',
648 648
 			'site__in' => $site_ids,
649 649
 		);
650
-		if ( ! $all ) {
650
+		if ( ! $all) {
651 651
 			$args['archived'] = 0;
652 652
 			$args['spam']     = 0;
653 653
 			$args['deleted']  = 0;
654 654
 		}
655 655
 
656
-		$_sites = get_sites( $args );
656
+		$_sites = get_sites($args);
657 657
 
658
-		foreach ( $_sites as $site ) {
659
-			$sites[ $site->id ] = (object) array(
658
+		foreach ($_sites as $site) {
659
+			$sites[$site->id] = (object) array(
660 660
 				'userblog_id' => $site->id,
661 661
 				'blogname'    => $site->blogname,
662 662
 				'domain'      => $site->domain,
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
 	 * @param bool  $all     Whether the returned sites array should contain all sites, including
682 682
 	 *                       those marked 'deleted', 'archived', or 'spam'. Default false.
683 683
 	 */
684
-	return apply_filters( 'get_blogs_of_user', $sites, $user_id, $all );
684
+	return apply_filters('get_blogs_of_user', $sites, $user_id, $all);
685 685
 }
686 686
 
687 687
 /**
@@ -693,55 +693,55 @@  discard block
 block discarded – undo
693 693
  * @param int $blog_id Optional. ID of the blog to check. Defaults to the current site.
694 694
  * @return bool
695 695
  */
696
-function is_user_member_of_blog( $user_id = 0, $blog_id = 0 ) {
696
+function is_user_member_of_blog($user_id = 0, $blog_id = 0) {
697 697
 	global $wpdb;
698 698
 
699 699
 	$user_id = (int) $user_id;
700 700
 	$blog_id = (int) $blog_id;
701 701
 
702
-	if ( empty( $user_id ) ) {
702
+	if (empty($user_id)) {
703 703
 		$user_id = get_current_user_id();
704 704
 	}
705 705
 
706 706
 	// Technically not needed, but does save calls to get_site and get_user_meta
707 707
 	// in the event that the function is called when a user isn't logged in
708
-	if ( empty( $user_id ) ) {
708
+	if (empty($user_id)) {
709 709
 		return false;
710 710
 	} else {
711
-		$user = get_userdata( $user_id );
712
-		if ( ! $user instanceof WP_User ) {
711
+		$user = get_userdata($user_id);
712
+		if ( ! $user instanceof WP_User) {
713 713
 			return false;
714 714
 		}
715 715
 	}
716 716
 
717
-	if ( ! is_multisite() ) {
717
+	if ( ! is_multisite()) {
718 718
 		return true;
719 719
 	}
720 720
 
721
-	if ( empty( $blog_id ) ) {
721
+	if (empty($blog_id)) {
722 722
 		$blog_id = get_current_blog_id();
723 723
 	}
724 724
 
725
-	$blog = get_site( $blog_id );
725
+	$blog = get_site($blog_id);
726 726
 
727
-	if ( ! $blog || ! isset( $blog->domain ) || $blog->archived || $blog->spam || $blog->deleted ) {
727
+	if ( ! $blog || ! isset($blog->domain) || $blog->archived || $blog->spam || $blog->deleted) {
728 728
 		return false;
729 729
 	}
730 730
 
731
-	$keys = get_user_meta( $user_id );
732
-	if ( empty( $keys ) ) {
731
+	$keys = get_user_meta($user_id);
732
+	if (empty($keys)) {
733 733
 		return false;
734 734
 	}
735 735
 
736 736
 	// no underscore before capabilities in $base_capabilities_key
737
-	$base_capabilities_key = $wpdb->base_prefix . 'capabilities';
738
-	$site_capabilities_key = $wpdb->base_prefix . $blog_id . '_capabilities';
737
+	$base_capabilities_key = $wpdb->base_prefix.'capabilities';
738
+	$site_capabilities_key = $wpdb->base_prefix.$blog_id.'_capabilities';
739 739
 
740
-	if ( isset( $keys[ $base_capabilities_key ] ) && $blog_id == 1 ) {
740
+	if (isset($keys[$base_capabilities_key]) && $blog_id == 1) {
741 741
 		return true;
742 742
 	}
743 743
 
744
-	if ( isset( $keys[ $site_capabilities_key ] ) ) {
744
+	if (isset($keys[$site_capabilities_key])) {
745 745
 		return true;
746 746
 	}
747 747
 
@@ -845,24 +845,24 @@  discard block
 block discarded – undo
845 845
 	$blog_prefix = $wpdb->get_blog_prefix($id);
846 846
 	$result = array();
847 847
 
848
-	if ( 'time' == $strategy ) {
848
+	if ('time' == $strategy) {
849 849
 		$avail_roles = wp_roles()->get_names();
850 850
 
851 851
 		// Build a CPU-intensive query that will return concise information.
852 852
 		$select_count = array();
853
-		foreach ( $avail_roles as $this_role => $name ) {
854
-			$select_count[] = $wpdb->prepare( "COUNT(NULLIF(`meta_value` LIKE %s, false))", '%' . $wpdb->esc_like( '"' . $this_role . '"' ) . '%');
853
+		foreach ($avail_roles as $this_role => $name) {
854
+			$select_count[] = $wpdb->prepare("COUNT(NULLIF(`meta_value` LIKE %s, false))", '%'.$wpdb->esc_like('"'.$this_role.'"').'%');
855 855
 		}
856 856
 		$select_count[] = "COUNT(NULLIF(`meta_value` = 'a:0:{}', false))";
857 857
 		$select_count = implode(', ', $select_count);
858 858
 
859 859
 		// Add the meta_value index to the selection list, then run the query.
860
-		$row = $wpdb->get_row( "SELECT $select_count, COUNT(*) FROM $wpdb->usermeta WHERE meta_key = '{$blog_prefix}capabilities'", ARRAY_N );
860
+		$row = $wpdb->get_row("SELECT $select_count, COUNT(*) FROM $wpdb->usermeta WHERE meta_key = '{$blog_prefix}capabilities'", ARRAY_N);
861 861
 
862 862
 		// Run the previous loop again to associate results with role names.
863 863
 		$col = 0;
864 864
 		$role_counts = array();
865
-		foreach ( $avail_roles as $this_role => $name ) {
865
+		foreach ($avail_roles as $this_role => $name) {
866 866
 			$count = (int) $row[$col++];
867 867
 			if ($count > 0) {
868 868
 				$role_counts[$this_role] = $count;
@@ -875,23 +875,23 @@  discard block
 block discarded – undo
875 875
 		$total_users = (int) $row[$col];
876 876
 
877 877
 		$result['total_users'] = $total_users;
878
-		$result['avail_roles'] =& $role_counts;
878
+		$result['avail_roles'] = & $role_counts;
879 879
 	} else {
880 880
 		$avail_roles = array(
881 881
 			'none' => 0,
882 882
 		);
883 883
 
884
-		$users_of_blog = $wpdb->get_col( "SELECT meta_value FROM $wpdb->usermeta WHERE meta_key = '{$blog_prefix}capabilities'" );
884
+		$users_of_blog = $wpdb->get_col("SELECT meta_value FROM $wpdb->usermeta WHERE meta_key = '{$blog_prefix}capabilities'");
885 885
 
886
-		foreach ( $users_of_blog as $caps_meta ) {
886
+		foreach ($users_of_blog as $caps_meta) {
887 887
 			$b_roles = maybe_unserialize($caps_meta);
888
-			if ( ! is_array( $b_roles ) )
888
+			if ( ! is_array($b_roles))
889 889
 				continue;
890
-			if ( empty( $b_roles ) ) {
890
+			if (empty($b_roles)) {
891 891
 				$avail_roles['none']++;
892 892
 			}
893
-			foreach ( $b_roles as $b_role => $val ) {
894
-				if ( isset($avail_roles[$b_role]) ) {
893
+			foreach ($b_roles as $b_role => $val) {
894
+				if (isset($avail_roles[$b_role])) {
895 895
 					$avail_roles[$b_role]++;
896 896
 				} else {
897 897
 					$avail_roles[$b_role] = 1;
@@ -899,11 +899,11 @@  discard block
 block discarded – undo
899 899
 			}
900 900
 		}
901 901
 
902
-		$result['total_users'] = count( $users_of_blog );
903
-		$result['avail_roles'] =& $avail_roles;
902
+		$result['total_users'] = count($users_of_blog);
903
+		$result['avail_roles'] = & $avail_roles;
904 904
 	}
905 905
 
906
-	if ( is_multisite() ) {
906
+	if (is_multisite()) {
907 907
 		$result['avail_roles']['none'] = 0;
908 908
 	}
909 909
 
@@ -934,11 +934,11 @@  discard block
 block discarded – undo
934 934
 function setup_userdata($for_user_id = '') {
935 935
 	global $user_login, $userdata, $user_level, $user_ID, $user_email, $user_url, $user_identity;
936 936
 
937
-	if ( '' == $for_user_id )
937
+	if ('' == $for_user_id)
938 938
 		$for_user_id = get_current_user_id();
939
-	$user = get_userdata( $for_user_id );
939
+	$user = get_userdata($for_user_id);
940 940
 
941
-	if ( ! $user ) {
941
+	if ( ! $user) {
942 942
 		$user_ID = 0;
943 943
 		$user_level = 0;
944 944
 		$userdata = null;
@@ -1018,7 +1018,7 @@  discard block
 block discarded – undo
1018 1018
  * }
1019 1019
  * @return string String of HTML content.
1020 1020
  */
1021
-function wp_dropdown_users( $args = '' ) {
1021
+function wp_dropdown_users($args = '') {
1022 1022
 	$defaults = array(
1023 1023
 		'show_option_all' => '', 'show_option_none' => '', 'hide_if_only_one_author' => '',
1024 1024
 		'orderby' => 'display_name', 'order' => 'ASC',
@@ -1032,16 +1032,16 @@  discard block
 block discarded – undo
1032 1032
 		'role__not_in' => array(),
1033 1033
 	);
1034 1034
 
1035
-	$defaults['selected'] = is_author() ? get_query_var( 'author' ) : 0;
1035
+	$defaults['selected'] = is_author() ? get_query_var('author') : 0;
1036 1036
 
1037
-	$r = wp_parse_args( $args, $defaults );
1037
+	$r = wp_parse_args($args, $defaults);
1038 1038
 
1039
-	$query_args = wp_array_slice_assoc( $r, array( 'blog_id', 'include', 'exclude', 'orderby', 'order', 'who', 'role', 'role__in', 'role__not_in' ) );
1039
+	$query_args = wp_array_slice_assoc($r, array('blog_id', 'include', 'exclude', 'orderby', 'order', 'who', 'role', 'role__in', 'role__not_in'));
1040 1040
 
1041
-	$fields = array( 'ID', 'user_login' );
1041
+	$fields = array('ID', 'user_login');
1042 1042
 
1043
-	$show = ! empty( $r['show'] ) ? $r['show'] : 'display_name';
1044
-	if ( 'display_name_with_login' === $show ) {
1043
+	$show = ! empty($r['show']) ? $r['show'] : 'display_name';
1044
+	if ('display_name_with_login' === $show) {
1045 1045
 		$fields[] = 'display_name';
1046 1046
 	} else {
1047 1047
 		$fields[] = $show;
@@ -1061,56 +1061,56 @@  discard block
 block discarded – undo
1061 1061
 	 * @param array $query_args The query arguments for get_users().
1062 1062
 	 * @param array $r          The arguments passed to wp_dropdown_users() combined with the defaults.
1063 1063
 	 */
1064
-	$query_args = apply_filters( 'wp_dropdown_users_args', $query_args, $r );
1064
+	$query_args = apply_filters('wp_dropdown_users_args', $query_args, $r);
1065 1065
 
1066
-	$users = get_users( $query_args );
1066
+	$users = get_users($query_args);
1067 1067
 
1068 1068
 	$output = '';
1069
-	if ( ! empty( $users ) && ( empty( $r['hide_if_only_one_author'] ) || count( $users ) > 1 ) ) {
1070
-		$name = esc_attr( $r['name'] );
1071
-		if ( $r['multi'] && ! $r['id'] ) {
1069
+	if ( ! empty($users) && (empty($r['hide_if_only_one_author']) || count($users) > 1)) {
1070
+		$name = esc_attr($r['name']);
1071
+		if ($r['multi'] && ! $r['id']) {
1072 1072
 			$id = '';
1073 1073
 		} else {
1074
-			$id = $r['id'] ? " id='" . esc_attr( $r['id'] ) . "'" : " id='$name'";
1074
+			$id = $r['id'] ? " id='".esc_attr($r['id'])."'" : " id='$name'";
1075 1075
 		}
1076
-		$output = "<select name='{$name}'{$id} class='" . $r['class'] . "'>\n";
1076
+		$output = "<select name='{$name}'{$id} class='".$r['class']."'>\n";
1077 1077
 
1078
-		if ( $show_option_all ) {
1078
+		if ($show_option_all) {
1079 1079
 			$output .= "\t<option value='0'>$show_option_all</option>\n";
1080 1080
 		}
1081 1081
 
1082
-		if ( $show_option_none ) {
1083
-			$_selected = selected( $option_none_value, $r['selected'], false );
1084
-			$output .= "\t<option value='" . esc_attr( $option_none_value ) . "'$_selected>$show_option_none</option>\n";
1082
+		if ($show_option_none) {
1083
+			$_selected = selected($option_none_value, $r['selected'], false);
1084
+			$output .= "\t<option value='".esc_attr($option_none_value)."'$_selected>$show_option_none</option>\n";
1085 1085
 		}
1086 1086
 
1087
-		if ( $r['include_selected'] && ( $r['selected'] > 0 ) ) {
1087
+		if ($r['include_selected'] && ($r['selected'] > 0)) {
1088 1088
 			$found_selected = false;
1089 1089
 			$r['selected'] = (int) $r['selected'];
1090
-			foreach ( (array) $users as $user ) {
1090
+			foreach ((array) $users as $user) {
1091 1091
 				$user->ID = (int) $user->ID;
1092
-				if ( $user->ID === $r['selected'] ) {
1092
+				if ($user->ID === $r['selected']) {
1093 1093
 					$found_selected = true;
1094 1094
 				}
1095 1095
 			}
1096 1096
 
1097
-			if ( ! $found_selected ) {
1098
-				$users[] = get_userdata( $r['selected'] );
1097
+			if ( ! $found_selected) {
1098
+				$users[] = get_userdata($r['selected']);
1099 1099
 			}
1100 1100
 		}
1101 1101
 
1102
-		foreach ( (array) $users as $user ) {
1103
-			if ( 'display_name_with_login' === $show ) {
1102
+		foreach ((array) $users as $user) {
1103
+			if ('display_name_with_login' === $show) {
1104 1104
 				/* translators: 1: display name, 2: user_login */
1105
-				$display = sprintf( _x( '%1$s (%2$s)', 'user dropdown' ), $user->display_name, $user->user_login );
1106
-			} elseif ( ! empty( $user->$show ) ) {
1105
+				$display = sprintf(_x('%1$s (%2$s)', 'user dropdown'), $user->display_name, $user->user_login);
1106
+			} elseif ( ! empty($user->$show)) {
1107 1107
 				$display = $user->$show;
1108 1108
 			} else {
1109
-				$display = '(' . $user->user_login . ')';
1109
+				$display = '('.$user->user_login.')';
1110 1110
 			}
1111 1111
 
1112
-			$_selected = selected( $user->ID, $r['selected'], false );
1113
-			$output .= "\t<option value='$user->ID'$_selected>" . esc_html( $display ) . "</option>\n";
1112
+			$_selected = selected($user->ID, $r['selected'], false);
1113
+			$output .= "\t<option value='$user->ID'$_selected>".esc_html($display)."</option>\n";
1114 1114
 		}
1115 1115
 
1116 1116
 		$output .= "</select>";
@@ -1123,9 +1123,9 @@  discard block
 block discarded – undo
1123 1123
 	 *
1124 1124
 	 * @param string $output HTML output generated by wp_dropdown_users().
1125 1125
 	 */
1126
-	$html = apply_filters( 'wp_dropdown_users', $output );
1126
+	$html = apply_filters('wp_dropdown_users', $output);
1127 1127
 
1128
-	if ( $r['echo'] ) {
1128
+	if ($r['echo']) {
1129 1129
 		echo $html;
1130 1130
 	}
1131 1131
 	return $html;
@@ -1149,22 +1149,22 @@  discard block
 block discarded – undo
1149 1149
  */
1150 1150
 function sanitize_user_field($field, $value, $user_id, $context) {
1151 1151
 	$int_fields = array('ID');
1152
-	if ( in_array($field, $int_fields) )
1152
+	if (in_array($field, $int_fields))
1153 1153
 		$value = (int) $value;
1154 1154
 
1155
-	if ( 'raw' == $context )
1155
+	if ('raw' == $context)
1156 1156
 		return $value;
1157 1157
 
1158
-	if ( !is_string($value) && !is_numeric($value) )
1158
+	if ( ! is_string($value) && ! is_numeric($value))
1159 1159
 		return $value;
1160 1160
 
1161
-	$prefixed = false !== strpos( $field, 'user_' );
1161
+	$prefixed = false !== strpos($field, 'user_');
1162 1162
 
1163
-	if ( 'edit' == $context ) {
1164
-		if ( $prefixed ) {
1163
+	if ('edit' == $context) {
1164
+		if ($prefixed) {
1165 1165
 
1166 1166
 			/** This filter is documented in wp-includes/post.php */
1167
-			$value = apply_filters( "edit_{$field}", $value, $user_id );
1167
+			$value = apply_filters("edit_{$field}", $value, $user_id);
1168 1168
 		} else {
1169 1169
 
1170 1170
 			/**
@@ -1178,17 +1178,17 @@  discard block
 block discarded – undo
1178 1178
 			 * @param mixed $value   Value of the prefixed user field.
1179 1179
 			 * @param int   $user_id User ID.
1180 1180
 			 */
1181
-			$value = apply_filters( "edit_user_{$field}", $value, $user_id );
1181
+			$value = apply_filters("edit_user_{$field}", $value, $user_id);
1182 1182
 		}
1183 1183
 
1184
-		if ( 'description' == $field )
1185
-			$value = esc_html( $value ); // textarea_escaped?
1184
+		if ('description' == $field)
1185
+			$value = esc_html($value); // textarea_escaped?
1186 1186
 		else
1187 1187
 			$value = esc_attr($value);
1188
-	} elseif ( 'db' == $context ) {
1189
-		if ( $prefixed ) {
1188
+	} elseif ('db' == $context) {
1189
+		if ($prefixed) {
1190 1190
 			/** This filter is documented in wp-includes/post.php */
1191
-			$value = apply_filters( "pre_{$field}", $value );
1191
+			$value = apply_filters("pre_{$field}", $value);
1192 1192
 		} else {
1193 1193
 
1194 1194
 			/**
@@ -1201,14 +1201,14 @@  discard block
 block discarded – undo
1201 1201
 			 *
1202 1202
 			 * @param mixed $value Value of the prefixed user field.
1203 1203
 			 */
1204
-			$value = apply_filters( "pre_user_{$field}", $value );
1204
+			$value = apply_filters("pre_user_{$field}", $value);
1205 1205
 		}
1206 1206
 	} else {
1207 1207
 		// Use display filters by default.
1208
-		if ( $prefixed ) {
1208
+		if ($prefixed) {
1209 1209
 
1210 1210
 			/** This filter is documented in wp-includes/post.php */
1211
-			$value = apply_filters( "{$field}", $value, $user_id, $context );
1211
+			$value = apply_filters("{$field}", $value, $user_id, $context);
1212 1212
 		} else {
1213 1213
 
1214 1214
 			/**
@@ -1223,17 +1223,17 @@  discard block
 block discarded – undo
1223 1223
 			 * @param int    $user_id User ID.
1224 1224
 			 * @param string $context The context to filter within.
1225 1225
 			 */
1226
-			$value = apply_filters( "user_{$field}", $value, $user_id, $context );
1226
+			$value = apply_filters("user_{$field}", $value, $user_id, $context);
1227 1227
 		}
1228 1228
 	}
1229 1229
 
1230
-	if ( 'user_url' == $field )
1230
+	if ('user_url' == $field)
1231 1231
 		$value = esc_url($value);
1232 1232
 
1233
-	if ( 'attribute' == $context ) {
1234
-		$value = esc_attr( $value );
1235
-	} elseif ( 'js' == $context ) {
1236
-		$value = esc_js( $value );
1233
+	if ('attribute' == $context) {
1234
+		$value = esc_attr($value);
1235
+	} elseif ('js' == $context) {
1236
+		$value = esc_js($value);
1237 1237
 	}
1238 1238
 	return $value;
1239 1239
 }
@@ -1246,9 +1246,9 @@  discard block
 block discarded – undo
1246 1246
  * @param object|WP_User $user User object to be cached
1247 1247
  * @return bool|null Returns false on failure.
1248 1248
  */
1249
-function update_user_caches( $user ) {
1250
-	if ( $user instanceof WP_User ) {
1251
-		if ( ! $user->exists() ) {
1249
+function update_user_caches($user) {
1250
+	if ($user instanceof WP_User) {
1251
+		if ( ! $user->exists()) {
1252 1252
 			return false;
1253 1253
 		}
1254 1254
 
@@ -1269,17 +1269,17 @@  discard block
 block discarded – undo
1269 1269
  *
1270 1270
  * @param WP_User|int $user User object or ID to be cleaned from the cache
1271 1271
  */
1272
-function clean_user_cache( $user ) {
1273
-	if ( is_numeric( $user ) )
1274
-		$user = new WP_User( $user );
1272
+function clean_user_cache($user) {
1273
+	if (is_numeric($user))
1274
+		$user = new WP_User($user);
1275 1275
 
1276
-	if ( ! $user->exists() )
1276
+	if ( ! $user->exists())
1277 1277
 		return;
1278 1278
 
1279
-	wp_cache_delete( $user->ID, 'users' );
1280
-	wp_cache_delete( $user->user_login, 'userlogins' );
1281
-	wp_cache_delete( $user->user_email, 'useremail' );
1282
-	wp_cache_delete( $user->user_nicename, 'userslugs' );
1279
+	wp_cache_delete($user->ID, 'users');
1280
+	wp_cache_delete($user->user_login, 'userlogins');
1281
+	wp_cache_delete($user->user_email, 'useremail');
1282
+	wp_cache_delete($user->user_nicename, 'userslugs');
1283 1283
 
1284 1284
 	/**
1285 1285
 	 * Fires immediately after the given user's cache is cleaned.
@@ -1289,7 +1289,7 @@  discard block
 block discarded – undo
1289 1289
 	 * @param int     $user_id User ID.
1290 1290
 	 * @param WP_User $user    User object.
1291 1291
 	 */
1292
-	do_action( 'clean_user_cache', $user->ID, $user );
1292
+	do_action('clean_user_cache', $user->ID, $user);
1293 1293
 }
1294 1294
 
1295 1295
 /**
@@ -1300,8 +1300,8 @@  discard block
 block discarded – undo
1300 1300
  * @param string $username Username.
1301 1301
  * @return int|false The user's ID on success, and false on failure.
1302 1302
  */
1303
-function username_exists( $username ) {
1304
-	if ( $user = get_user_by( 'login', $username ) ) {
1303
+function username_exists($username) {
1304
+	if ($user = get_user_by('login', $username)) {
1305 1305
 		return $user->ID;
1306 1306
 	}
1307 1307
 	return false;
@@ -1315,8 +1315,8 @@  discard block
 block discarded – undo
1315 1315
  * @param string $email Email.
1316 1316
  * @return int|false The user's ID on success, and false on failure.
1317 1317
  */
1318
-function email_exists( $email ) {
1319
-	if ( $user = get_user_by( 'email', $email) ) {
1318
+function email_exists($email) {
1319
+	if ($user = get_user_by('email', $email)) {
1320 1320
 		return $user->ID;
1321 1321
 	}
1322 1322
 	return false;
@@ -1331,9 +1331,9 @@  discard block
 block discarded – undo
1331 1331
  * @param string $username Username.
1332 1332
  * @return bool Whether username given is valid
1333 1333
  */
1334
-function validate_username( $username ) {
1335
-	$sanitized = sanitize_user( $username, true );
1336
-	$valid = ( $sanitized == $username && ! empty( $sanitized ) );
1334
+function validate_username($username) {
1335
+	$sanitized = sanitize_user($username, true);
1336
+	$valid = ($sanitized == $username && ! empty($sanitized));
1337 1337
 
1338 1338
 	/**
1339 1339
 	 * Filters whether the provided username is valid or not.
@@ -1343,7 +1343,7 @@  discard block
 block discarded – undo
1343 1343
 	 * @param bool   $valid    Whether given username is valid.
1344 1344
 	 * @param string $username Username to check.
1345 1345
 	 */
1346
-	return apply_filters( 'validate_username', $valid, $username );
1346
+	return apply_filters('validate_username', $valid, $username);
1347 1347
 }
1348 1348
 
1349 1349
 /**
@@ -1398,34 +1398,34 @@  discard block
 block discarded – undo
1398 1398
  * @return int|WP_Error The newly created user's ID or a WP_Error object if the user could not
1399 1399
  *                      be created.
1400 1400
  */
1401
-function wp_insert_user( $userdata ) {
1401
+function wp_insert_user($userdata) {
1402 1402
 	global $wpdb;
1403 1403
 
1404
-	if ( $userdata instanceof stdClass ) {
1405
-		$userdata = get_object_vars( $userdata );
1406
-	} elseif ( $userdata instanceof WP_User ) {
1404
+	if ($userdata instanceof stdClass) {
1405
+		$userdata = get_object_vars($userdata);
1406
+	} elseif ($userdata instanceof WP_User) {
1407 1407
 		$userdata = $userdata->to_array();
1408 1408
 	}
1409 1409
 
1410 1410
 	// Are we updating or creating?
1411
-	if ( ! empty( $userdata['ID'] ) ) {
1411
+	if ( ! empty($userdata['ID'])) {
1412 1412
 		$ID = (int) $userdata['ID'];
1413 1413
 		$update = true;
1414
-		$old_user_data = get_userdata( $ID );
1414
+		$old_user_data = get_userdata($ID);
1415 1415
 
1416
-		if ( ! $old_user_data ) {
1417
-			return new WP_Error( 'invalid_user_id', __( 'Invalid user ID.' ) );
1416
+		if ( ! $old_user_data) {
1417
+			return new WP_Error('invalid_user_id', __('Invalid user ID.'));
1418 1418
 		}
1419 1419
 
1420 1420
 		// hashed in wp_update_user(), plaintext if called directly
1421
-		$user_pass = ! empty( $userdata['user_pass'] ) ? $userdata['user_pass'] : $old_user_data->user_pass;
1421
+		$user_pass = ! empty($userdata['user_pass']) ? $userdata['user_pass'] : $old_user_data->user_pass;
1422 1422
 	} else {
1423 1423
 		$update = false;
1424 1424
 		// Hash the password
1425
-		$user_pass = wp_hash_password( $userdata['user_pass'] );
1425
+		$user_pass = wp_hash_password($userdata['user_pass']);
1426 1426
 	}
1427 1427
 
1428
-	$sanitized_user_login = sanitize_user( $userdata['user_login'], true );
1428
+	$sanitized_user_login = sanitize_user($userdata['user_login'], true);
1429 1429
 
1430 1430
 	/**
1431 1431
 	 * Filters a username after it has been sanitized.
@@ -1436,20 +1436,20 @@  discard block
 block discarded – undo
1436 1436
 	 *
1437 1437
 	 * @param string $sanitized_user_login Username after it has been sanitized.
1438 1438
 	 */
1439
-	$pre_user_login = apply_filters( 'pre_user_login', $sanitized_user_login );
1439
+	$pre_user_login = apply_filters('pre_user_login', $sanitized_user_login);
1440 1440
 
1441 1441
 	//Remove any non-printable chars from the login string to see if we have ended up with an empty username
1442
-	$user_login = trim( $pre_user_login );
1442
+	$user_login = trim($pre_user_login);
1443 1443
 
1444 1444
 	// user_login must be between 0 and 60 characters.
1445
-	if ( empty( $user_login ) ) {
1446
-		return new WP_Error('empty_user_login', __('Cannot create a user with an empty login name.') );
1447
-	} elseif ( mb_strlen( $user_login ) > 60 ) {
1448
-		return new WP_Error( 'user_login_too_long', __( 'Username may not be longer than 60 characters.' ) );
1445
+	if (empty($user_login)) {
1446
+		return new WP_Error('empty_user_login', __('Cannot create a user with an empty login name.'));
1447
+	} elseif (mb_strlen($user_login) > 60) {
1448
+		return new WP_Error('user_login_too_long', __('Username may not be longer than 60 characters.'));
1449 1449
 	}
1450 1450
 
1451
-	if ( ! $update && username_exists( $user_login ) ) {
1452
-		return new WP_Error( 'existing_user_login', __( 'Sorry, that username already exists!' ) );
1451
+	if ( ! $update && username_exists($user_login)) {
1452
+		return new WP_Error('existing_user_login', __('Sorry, that username already exists!'));
1453 1453
 	}
1454 1454
 
1455 1455
 	/**
@@ -1459,26 +1459,26 @@  discard block
 block discarded – undo
1459 1459
 	 *
1460 1460
 	 * @param array $usernames Array of blacklisted usernames.
1461 1461
 	 */
1462
-	$illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
1462
+	$illegal_logins = (array) apply_filters('illegal_user_logins', array());
1463 1463
 
1464
-	if ( in_array( strtolower( $user_login ), array_map( 'strtolower', $illegal_logins ) ) ) {
1465
-		return new WP_Error( 'invalid_username', __( 'Sorry, that username is not allowed.' ) );
1464
+	if (in_array(strtolower($user_login), array_map('strtolower', $illegal_logins))) {
1465
+		return new WP_Error('invalid_username', __('Sorry, that username is not allowed.'));
1466 1466
 	}
1467 1467
 
1468 1468
 	/*
1469 1469
 	 * If a nicename is provided, remove unsafe user characters before using it.
1470 1470
 	 * Otherwise build a nicename from the user_login.
1471 1471
 	 */
1472
-	if ( ! empty( $userdata['user_nicename'] ) ) {
1473
-		$user_nicename = sanitize_user( $userdata['user_nicename'], true );
1474
-		if ( mb_strlen( $user_nicename ) > 50 ) {
1475
-			return new WP_Error( 'user_nicename_too_long', __( 'Nicename may not be longer than 50 characters.' ) );
1472
+	if ( ! empty($userdata['user_nicename'])) {
1473
+		$user_nicename = sanitize_user($userdata['user_nicename'], true);
1474
+		if (mb_strlen($user_nicename) > 50) {
1475
+			return new WP_Error('user_nicename_too_long', __('Nicename may not be longer than 50 characters.'));
1476 1476
 		}
1477 1477
 	} else {
1478
-		$user_nicename = mb_substr( $user_login, 0, 50 );
1478
+		$user_nicename = mb_substr($user_login, 0, 50);
1479 1479
 	}
1480 1480
 
1481
-	$user_nicename = sanitize_title( $user_nicename );
1481
+	$user_nicename = sanitize_title($user_nicename);
1482 1482
 
1483 1483
 	// Store values to save in user meta.
1484 1484
 	$meta = array();
@@ -1490,9 +1490,9 @@  discard block
 block discarded – undo
1490 1490
 	 *
1491 1491
 	 * @param string $user_nicename The user's nicename.
1492 1492
 	 */
1493
-	$user_nicename = apply_filters( 'pre_user_nicename', $user_nicename );
1493
+	$user_nicename = apply_filters('pre_user_nicename', $user_nicename);
1494 1494
 
1495
-	$raw_user_url = empty( $userdata['user_url'] ) ? '' : $userdata['user_url'];
1495
+	$raw_user_url = empty($userdata['user_url']) ? '' : $userdata['user_url'];
1496 1496
 
1497 1497
 	/**
1498 1498
 	 * Filters a user's URL before the user is created or updated.
@@ -1501,9 +1501,9 @@  discard block
 block discarded – undo
1501 1501
 	 *
1502 1502
 	 * @param string $raw_user_url The user's URL.
1503 1503
 	 */
1504
-	$user_url = apply_filters( 'pre_user_url', $raw_user_url );
1504
+	$user_url = apply_filters('pre_user_url', $raw_user_url);
1505 1505
 
1506
-	$raw_user_email = empty( $userdata['user_email'] ) ? '' : $userdata['user_email'];
1506
+	$raw_user_email = empty($userdata['user_email']) ? '' : $userdata['user_email'];
1507 1507
 
1508 1508
 	/**
1509 1509
 	 * Filters a user's email before the user is created or updated.
@@ -1512,20 +1512,20 @@  discard block
 block discarded – undo
1512 1512
 	 *
1513 1513
 	 * @param string $raw_user_email The user's email.
1514 1514
 	 */
1515
-	$user_email = apply_filters( 'pre_user_email', $raw_user_email );
1515
+	$user_email = apply_filters('pre_user_email', $raw_user_email);
1516 1516
 
1517 1517
 	/*
1518 1518
 	 * If there is no update, just check for `email_exists`. If there is an update,
1519 1519
 	 * check if current email and new email are the same, or not, and check `email_exists`
1520 1520
 	 * accordingly.
1521 1521
 	 */
1522
-	if ( ( ! $update || ( ! empty( $old_user_data ) && 0 !== strcasecmp( $user_email, $old_user_data->user_email ) ) )
1523
-		&& ! defined( 'WP_IMPORTING' )
1524
-		&& email_exists( $user_email )
1522
+	if (( ! $update || ( ! empty($old_user_data) && 0 !== strcasecmp($user_email, $old_user_data->user_email)))
1523
+		&& ! defined('WP_IMPORTING')
1524
+		&& email_exists($user_email)
1525 1525
 	) {
1526
-		return new WP_Error( 'existing_user_email', __( 'Sorry, that email address is already used!' ) );
1526
+		return new WP_Error('existing_user_email', __('Sorry, that email address is already used!'));
1527 1527
 	}
1528
-	$nickname = empty( $userdata['nickname'] ) ? $user_login : $userdata['nickname'];
1528
+	$nickname = empty($userdata['nickname']) ? $user_login : $userdata['nickname'];
1529 1529
 
1530 1530
 	/**
1531 1531
 	 * Filters a user's nickname before the user is created or updated.
@@ -1534,9 +1534,9 @@  discard block
 block discarded – undo
1534 1534
 	 *
1535 1535
 	 * @param string $nickname The user's nickname.
1536 1536
 	 */
1537
-	$meta['nickname'] = apply_filters( 'pre_user_nickname', $nickname );
1537
+	$meta['nickname'] = apply_filters('pre_user_nickname', $nickname);
1538 1538
 
1539
-	$first_name = empty( $userdata['first_name'] ) ? '' : $userdata['first_name'];
1539
+	$first_name = empty($userdata['first_name']) ? '' : $userdata['first_name'];
1540 1540
 
1541 1541
 	/**
1542 1542
 	 * Filters a user's first name before the user is created or updated.
@@ -1545,9 +1545,9 @@  discard block
 block discarded – undo
1545 1545
 	 *
1546 1546
 	 * @param string $first_name The user's first name.
1547 1547
 	 */
1548
-	$meta['first_name'] = apply_filters( 'pre_user_first_name', $first_name );
1548
+	$meta['first_name'] = apply_filters('pre_user_first_name', $first_name);
1549 1549
 
1550
-	$last_name = empty( $userdata['last_name'] ) ? '' : $userdata['last_name'];
1550
+	$last_name = empty($userdata['last_name']) ? '' : $userdata['last_name'];
1551 1551
 
1552 1552
 	/**
1553 1553
 	 * Filters a user's last name before the user is created or updated.
@@ -1556,17 +1556,17 @@  discard block
 block discarded – undo
1556 1556
 	 *
1557 1557
 	 * @param string $last_name The user's last name.
1558 1558
 	 */
1559
-	$meta['last_name'] = apply_filters( 'pre_user_last_name', $last_name );
1559
+	$meta['last_name'] = apply_filters('pre_user_last_name', $last_name);
1560 1560
 
1561
-	if ( empty( $userdata['display_name'] ) ) {
1562
-		if ( $update ) {
1561
+	if (empty($userdata['display_name'])) {
1562
+		if ($update) {
1563 1563
 			$display_name = $user_login;
1564
-		} elseif ( $meta['first_name'] && $meta['last_name'] ) {
1564
+		} elseif ($meta['first_name'] && $meta['last_name']) {
1565 1565
 			/* translators: 1: first name, 2: last name */
1566
-			$display_name = sprintf( _x( '%1$s %2$s', 'Display name based on first name and last name' ), $meta['first_name'], $meta['last_name'] );
1567
-		} elseif ( $meta['first_name'] ) {
1566
+			$display_name = sprintf(_x('%1$s %2$s', 'Display name based on first name and last name'), $meta['first_name'], $meta['last_name']);
1567
+		} elseif ($meta['first_name']) {
1568 1568
 			$display_name = $meta['first_name'];
1569
-		} elseif ( $meta['last_name'] ) {
1569
+		} elseif ($meta['last_name']) {
1570 1570
 			$display_name = $meta['last_name'];
1571 1571
 		} else {
1572 1572
 			$display_name = $user_login;
@@ -1582,9 +1582,9 @@  discard block
 block discarded – undo
1582 1582
 	 *
1583 1583
 	 * @param string $display_name The user's display name.
1584 1584
 	 */
1585
-	$display_name = apply_filters( 'pre_user_display_name', $display_name );
1585
+	$display_name = apply_filters('pre_user_display_name', $display_name);
1586 1586
 
1587
-	$description = empty( $userdata['description'] ) ? '' : $userdata['description'];
1587
+	$description = empty($userdata['description']) ? '' : $userdata['description'];
1588 1588
 
1589 1589
 	/**
1590 1590
 	 * Filters a user's description before the user is created or updated.
@@ -1593,52 +1593,52 @@  discard block
 block discarded – undo
1593 1593
 	 *
1594 1594
 	 * @param string $description The user's description.
1595 1595
 	 */
1596
-	$meta['description'] = apply_filters( 'pre_user_description', $description );
1596
+	$meta['description'] = apply_filters('pre_user_description', $description);
1597 1597
 
1598
-	$meta['rich_editing'] = empty( $userdata['rich_editing'] ) ? 'true' : $userdata['rich_editing'];
1598
+	$meta['rich_editing'] = empty($userdata['rich_editing']) ? 'true' : $userdata['rich_editing'];
1599 1599
 
1600
-	$meta['comment_shortcuts'] = empty( $userdata['comment_shortcuts'] ) || 'false' === $userdata['comment_shortcuts'] ? 'false' : 'true';
1600
+	$meta['comment_shortcuts'] = empty($userdata['comment_shortcuts']) || 'false' === $userdata['comment_shortcuts'] ? 'false' : 'true';
1601 1601
 
1602
-	$admin_color = empty( $userdata['admin_color'] ) ? 'fresh' : $userdata['admin_color'];
1603
-	$meta['admin_color'] = preg_replace( '|[^a-z0-9 _.\-@]|i', '', $admin_color );
1602
+	$admin_color = empty($userdata['admin_color']) ? 'fresh' : $userdata['admin_color'];
1603
+	$meta['admin_color'] = preg_replace('|[^a-z0-9 _.\-@]|i', '', $admin_color);
1604 1604
 
1605
-	$meta['use_ssl'] = empty( $userdata['use_ssl'] ) ? 0 : $userdata['use_ssl'];
1605
+	$meta['use_ssl'] = empty($userdata['use_ssl']) ? 0 : $userdata['use_ssl'];
1606 1606
 
1607
-	$user_registered = empty( $userdata['user_registered'] ) ? gmdate( 'Y-m-d H:i:s' ) : $userdata['user_registered'];
1607
+	$user_registered = empty($userdata['user_registered']) ? gmdate('Y-m-d H:i:s') : $userdata['user_registered'];
1608 1608
 
1609
-	$meta['show_admin_bar_front'] = empty( $userdata['show_admin_bar_front'] ) ? 'true' : $userdata['show_admin_bar_front'];
1609
+	$meta['show_admin_bar_front'] = empty($userdata['show_admin_bar_front']) ? 'true' : $userdata['show_admin_bar_front'];
1610 1610
 
1611
-	$meta['locale'] = isset( $userdata['locale'] ) ? $userdata['locale'] : '';
1611
+	$meta['locale'] = isset($userdata['locale']) ? $userdata['locale'] : '';
1612 1612
 
1613
-	$user_nicename_check = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1" , $user_nicename, $user_login));
1613
+	$user_nicename_check = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1", $user_nicename, $user_login));
1614 1614
 
1615
-	if ( $user_nicename_check ) {
1615
+	if ($user_nicename_check) {
1616 1616
 		$suffix = 2;
1617 1617
 		while ($user_nicename_check) {
1618 1618
 			// user_nicename allows 50 chars. Subtract one for a hyphen, plus the length of the suffix.
1619
-			$base_length = 49 - mb_strlen( $suffix );
1620
-			$alt_user_nicename = mb_substr( $user_nicename, 0, $base_length ) . "-$suffix";
1621
-			$user_nicename_check = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1" , $alt_user_nicename, $user_login));
1619
+			$base_length = 49 - mb_strlen($suffix);
1620
+			$alt_user_nicename = mb_substr($user_nicename, 0, $base_length)."-$suffix";
1621
+			$user_nicename_check = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1", $alt_user_nicename, $user_login));
1622 1622
 			$suffix++;
1623 1623
 		}
1624 1624
 		$user_nicename = $alt_user_nicename;
1625 1625
 	}
1626 1626
 
1627
-	$compacted = compact( 'user_pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered' );
1628
-	$data = wp_unslash( $compacted );
1627
+	$compacted = compact('user_pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered');
1628
+	$data = wp_unslash($compacted);
1629 1629
 
1630
-	if ( $update ) {
1631
-		if ( $user_email !== $old_user_data->user_email ) {
1630
+	if ($update) {
1631
+		if ($user_email !== $old_user_data->user_email) {
1632 1632
 			$data['user_activation_key'] = '';
1633 1633
 		}
1634
-		$wpdb->update( $wpdb->users, $data, compact( 'ID' ) );
1634
+		$wpdb->update($wpdb->users, $data, compact('ID'));
1635 1635
 		$user_id = (int) $ID;
1636 1636
 	} else {
1637
-		$wpdb->insert( $wpdb->users, $data + compact( 'user_login' ) );
1637
+		$wpdb->insert($wpdb->users, $data + compact('user_login'));
1638 1638
 		$user_id = (int) $wpdb->insert_id;
1639 1639
 	}
1640 1640
 
1641
-	$user = new WP_User( $user_id );
1641
+	$user = new WP_User($user_id);
1642 1642
 
1643 1643
 	/**
1644 1644
  	 * Filters a user's meta values and keys before the user is created or updated.
@@ -1665,28 +1665,28 @@  discard block
 block discarded – undo
1665 1665
 	 * @param WP_User $user   User object.
1666 1666
 	 * @param bool    $update Whether the user is being updated rather than created.
1667 1667
  	 */
1668
-	$meta = apply_filters( 'insert_user_meta', $meta, $user, $update );
1668
+	$meta = apply_filters('insert_user_meta', $meta, $user, $update);
1669 1669
 
1670 1670
 	// Update user meta.
1671
-	foreach ( $meta as $key => $value ) {
1672
-		update_user_meta( $user_id, $key, $value );
1671
+	foreach ($meta as $key => $value) {
1672
+		update_user_meta($user_id, $key, $value);
1673 1673
 	}
1674 1674
 
1675
-	foreach ( wp_get_user_contact_methods( $user ) as $key => $value ) {
1676
-		if ( isset( $userdata[ $key ] ) ) {
1677
-			update_user_meta( $user_id, $key, $userdata[ $key ] );
1675
+	foreach (wp_get_user_contact_methods($user) as $key => $value) {
1676
+		if (isset($userdata[$key])) {
1677
+			update_user_meta($user_id, $key, $userdata[$key]);
1678 1678
 		}
1679 1679
 	}
1680 1680
 
1681
-	if ( isset( $userdata['role'] ) ) {
1682
-		$user->set_role( $userdata['role'] );
1683
-	} elseif ( ! $update ) {
1681
+	if (isset($userdata['role'])) {
1682
+		$user->set_role($userdata['role']);
1683
+	} elseif ( ! $update) {
1684 1684
 		$user->set_role(get_option('default_role'));
1685 1685
 	}
1686
-	wp_cache_delete( $user_id, 'users' );
1687
-	wp_cache_delete( $user_login, 'userlogins' );
1686
+	wp_cache_delete($user_id, 'users');
1687
+	wp_cache_delete($user_login, 'userlogins');
1688 1688
 
1689
-	if ( $update ) {
1689
+	if ($update) {
1690 1690
 		/**
1691 1691
 		 * Fires immediately after an existing user is updated.
1692 1692
 		 *
@@ -1695,7 +1695,7 @@  discard block
 block discarded – undo
1695 1695
 		 * @param int    $user_id       User ID.
1696 1696
 		 * @param object $old_user_data Object containing user's data prior to update.
1697 1697
 		 */
1698
-		do_action( 'profile_update', $user_id, $old_user_data );
1698
+		do_action('profile_update', $user_id, $old_user_data);
1699 1699
 	} else {
1700 1700
 		/**
1701 1701
 		 * Fires immediately after a new user is registered.
@@ -1704,7 +1704,7 @@  discard block
 block discarded – undo
1704 1704
 		 *
1705 1705
 		 * @param int $user_id User ID.
1706 1706
 		 */
1707
-		do_action( 'user_register', $user_id );
1707
+		do_action('user_register', $user_id);
1708 1708
 	}
1709 1709
 
1710 1710
 	return $user_id;
@@ -1727,37 +1727,37 @@  discard block
 block discarded – undo
1727 1727
  * @return int|WP_Error The updated user's ID or a WP_Error object if the user could not be updated.
1728 1728
  */
1729 1729
 function wp_update_user($userdata) {
1730
-	if ( $userdata instanceof stdClass ) {
1731
-		$userdata = get_object_vars( $userdata );
1732
-	} elseif ( $userdata instanceof WP_User ) {
1730
+	if ($userdata instanceof stdClass) {
1731
+		$userdata = get_object_vars($userdata);
1732
+	} elseif ($userdata instanceof WP_User) {
1733 1733
 		$userdata = $userdata->to_array();
1734 1734
 	}
1735 1735
 
1736
-	$ID = isset( $userdata['ID'] ) ? (int) $userdata['ID'] : 0;
1737
-	if ( ! $ID ) {
1738
-		return new WP_Error( 'invalid_user_id', __( 'Invalid user ID.' ) );
1736
+	$ID = isset($userdata['ID']) ? (int) $userdata['ID'] : 0;
1737
+	if ( ! $ID) {
1738
+		return new WP_Error('invalid_user_id', __('Invalid user ID.'));
1739 1739
 	}
1740 1740
 
1741 1741
 	// First, get all of the original fields
1742
-	$user_obj = get_userdata( $ID );
1743
-	if ( ! $user_obj ) {
1744
-		return new WP_Error( 'invalid_user_id', __( 'Invalid user ID.' ) );
1742
+	$user_obj = get_userdata($ID);
1743
+	if ( ! $user_obj) {
1744
+		return new WP_Error('invalid_user_id', __('Invalid user ID.'));
1745 1745
 	}
1746 1746
 
1747 1747
 	$user = $user_obj->to_array();
1748 1748
 
1749 1749
 	// Add additional custom fields
1750
-	foreach ( _get_additional_user_keys( $user_obj ) as $key ) {
1751
-		$user[ $key ] = get_user_meta( $ID, $key, true );
1750
+	foreach (_get_additional_user_keys($user_obj) as $key) {
1751
+		$user[$key] = get_user_meta($ID, $key, true);
1752 1752
 	}
1753 1753
 
1754 1754
 	// Escape data pulled from DB.
1755
-	$user = add_magic_quotes( $user );
1755
+	$user = add_magic_quotes($user);
1756 1756
 
1757
-	if ( ! empty( $userdata['user_pass'] ) && $userdata['user_pass'] !== $user_obj->user_pass ) {
1757
+	if ( ! empty($userdata['user_pass']) && $userdata['user_pass'] !== $user_obj->user_pass) {
1758 1758
 		// If password is changing, hash it now
1759 1759
 		$plaintext_pass = $userdata['user_pass'];
1760
-		$userdata['user_pass'] = wp_hash_password( $userdata['user_pass'] );
1760
+		$userdata['user_pass'] = wp_hash_password($userdata['user_pass']);
1761 1761
 
1762 1762
 		/**
1763 1763
 		 * Filters whether to send the password change email.
@@ -1771,10 +1771,10 @@  discard block
 block discarded – undo
1771 1771
 		 * @param array $userdata The updated user array.
1772 1772
 		 *
1773 1773
 		 */
1774
-		$send_password_change_email = apply_filters( 'send_password_change_email', true, $user, $userdata );
1774
+		$send_password_change_email = apply_filters('send_password_change_email', true, $user, $userdata);
1775 1775
 	}
1776 1776
 
1777
-	if ( isset( $userdata['user_email'] ) && $user['user_email'] !== $userdata['user_email'] ) {
1777
+	if (isset($userdata['user_email']) && $user['user_email'] !== $userdata['user_email']) {
1778 1778
 		/**
1779 1779
 		 * Filters whether to send the email change email.
1780 1780
 		 *
@@ -1787,28 +1787,28 @@  discard block
 block discarded – undo
1787 1787
 		 * @param array $userdata The updated user array.
1788 1788
 		 *
1789 1789
 		 */
1790
-		$send_email_change_email = apply_filters( 'send_email_change_email', true, $user, $userdata );
1790
+		$send_email_change_email = apply_filters('send_email_change_email', true, $user, $userdata);
1791 1791
 	}
1792 1792
 
1793
-	wp_cache_delete( $user['user_email'], 'useremail' );
1794
-	wp_cache_delete( $user['user_nicename'], 'userslugs' );
1793
+	wp_cache_delete($user['user_email'], 'useremail');
1794
+	wp_cache_delete($user['user_nicename'], 'userslugs');
1795 1795
 
1796 1796
 	// Merge old and new fields with new fields overwriting old ones.
1797
-	$userdata = array_merge( $user, $userdata );
1798
-	$user_id = wp_insert_user( $userdata );
1797
+	$userdata = array_merge($user, $userdata);
1798
+	$user_id = wp_insert_user($userdata);
1799 1799
 
1800
-	if ( ! is_wp_error( $user_id ) ) {
1800
+	if ( ! is_wp_error($user_id)) {
1801 1801
 
1802
-		$blog_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
1802
+		$blog_name = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
1803 1803
 
1804 1804
 		$switched_locale = false;
1805
-		if ( ! empty( $send_password_change_email ) || ! empty( $send_email_change_email ) ) {
1806
-			$switched_locale = switch_to_locale( get_user_locale( $user_id ) );
1805
+		if ( ! empty($send_password_change_email) || ! empty($send_email_change_email)) {
1806
+			$switched_locale = switch_to_locale(get_user_locale($user_id));
1807 1807
 		}
1808 1808
 
1809
-		if ( ! empty( $send_password_change_email ) ) {
1809
+		if ( ! empty($send_password_change_email)) {
1810 1810
 			/* translators: Do not translate USERNAME, ADMIN_EMAIL, EMAIL, SITENAME, SITEURL: those are placeholders. */
1811
-			$pass_change_text = __( 'Hi ###USERNAME###,
1811
+			$pass_change_text = __('Hi ###USERNAME###,
1812 1812
 
1813 1813
 This notice confirms that your password was changed on ###SITENAME###.
1814 1814
 
@@ -1824,7 +1824,7 @@  discard block
 block discarded – undo
1824 1824
 			$pass_change_email = array(
1825 1825
 				'to'      => $user['user_email'],
1826 1826
 				/* translators: User password change notification email subject. 1: Site name */
1827
-				'subject' => __( '[%s] Notice of Password Change' ),
1827
+				'subject' => __('[%s] Notice of Password Change'),
1828 1828
 				'message' => $pass_change_text,
1829 1829
 				'headers' => '',
1830 1830
 			);
@@ -1851,20 +1851,20 @@  discard block
 block discarded – undo
1851 1851
 			 * @param array $userdata The updated user array.
1852 1852
 			 *
1853 1853
 			 */
1854
-			$pass_change_email = apply_filters( 'password_change_email', $pass_change_email, $user, $userdata );
1854
+			$pass_change_email = apply_filters('password_change_email', $pass_change_email, $user, $userdata);
1855 1855
 
1856
-			$pass_change_email['message'] = str_replace( '###USERNAME###', $user['user_login'], $pass_change_email['message'] );
1857
-			$pass_change_email['message'] = str_replace( '###ADMIN_EMAIL###', get_option( 'admin_email' ), $pass_change_email['message'] );
1858
-			$pass_change_email['message'] = str_replace( '###EMAIL###', $user['user_email'], $pass_change_email['message'] );
1859
-			$pass_change_email['message'] = str_replace( '###SITENAME###', $blog_name, $pass_change_email['message'] );
1860
-			$pass_change_email['message'] = str_replace( '###SITEURL###', home_url(), $pass_change_email['message'] );
1856
+			$pass_change_email['message'] = str_replace('###USERNAME###', $user['user_login'], $pass_change_email['message']);
1857
+			$pass_change_email['message'] = str_replace('###ADMIN_EMAIL###', get_option('admin_email'), $pass_change_email['message']);
1858
+			$pass_change_email['message'] = str_replace('###EMAIL###', $user['user_email'], $pass_change_email['message']);
1859
+			$pass_change_email['message'] = str_replace('###SITENAME###', $blog_name, $pass_change_email['message']);
1860
+			$pass_change_email['message'] = str_replace('###SITEURL###', home_url(), $pass_change_email['message']);
1861 1861
 
1862
-			wp_mail( $pass_change_email['to'], sprintf( $pass_change_email['subject'], $blog_name ), $pass_change_email['message'], $pass_change_email['headers'] );
1862
+			wp_mail($pass_change_email['to'], sprintf($pass_change_email['subject'], $blog_name), $pass_change_email['message'], $pass_change_email['headers']);
1863 1863
 		}
1864 1864
 
1865
-		if ( ! empty( $send_email_change_email ) ) {
1865
+		if ( ! empty($send_email_change_email)) {
1866 1866
 			/* translators: Do not translate USERNAME, ADMIN_EMAIL, EMAIL, SITENAME, SITEURL: those are placeholders. */
1867
-			$email_change_text = __( 'Hi ###USERNAME###,
1867
+			$email_change_text = __('Hi ###USERNAME###,
1868 1868
 
1869 1869
 This notice confirms that your email was changed on ###SITENAME###.
1870 1870
 
@@ -1880,7 +1880,7 @@  discard block
 block discarded – undo
1880 1880
 			$email_change_email = array(
1881 1881
 				'to'      => $user['user_email'],
1882 1882
 				/* translators: User email change notification email subject. 1: Site name */
1883
-				'subject' => __( '[%s] Notice of Email Change' ),
1883
+				'subject' => __('[%s] Notice of Email Change'),
1884 1884
 				'message' => $email_change_text,
1885 1885
 				'headers' => '',
1886 1886
 			);
@@ -1906,36 +1906,36 @@  discard block
 block discarded – undo
1906 1906
 			 * @param array $user The original user array.
1907 1907
 			 * @param array $userdata The updated user array.
1908 1908
 			 */
1909
-			$email_change_email = apply_filters( 'email_change_email', $email_change_email, $user, $userdata );
1909
+			$email_change_email = apply_filters('email_change_email', $email_change_email, $user, $userdata);
1910 1910
 
1911
-			$email_change_email['message'] = str_replace( '###USERNAME###', $user['user_login'], $email_change_email['message'] );
1912
-			$email_change_email['message'] = str_replace( '###ADMIN_EMAIL###', get_option( 'admin_email' ), $email_change_email['message'] );
1913
-			$email_change_email['message'] = str_replace( '###EMAIL###', $user['user_email'], $email_change_email['message'] );
1914
-			$email_change_email['message'] = str_replace( '###SITENAME###', $blog_name, $email_change_email['message'] );
1915
-			$email_change_email['message'] = str_replace( '###SITEURL###', home_url(), $email_change_email['message'] );
1911
+			$email_change_email['message'] = str_replace('###USERNAME###', $user['user_login'], $email_change_email['message']);
1912
+			$email_change_email['message'] = str_replace('###ADMIN_EMAIL###', get_option('admin_email'), $email_change_email['message']);
1913
+			$email_change_email['message'] = str_replace('###EMAIL###', $user['user_email'], $email_change_email['message']);
1914
+			$email_change_email['message'] = str_replace('###SITENAME###', $blog_name, $email_change_email['message']);
1915
+			$email_change_email['message'] = str_replace('###SITEURL###', home_url(), $email_change_email['message']);
1916 1916
 
1917
-			wp_mail( $email_change_email['to'], sprintf( $email_change_email['subject'], $blog_name ), $email_change_email['message'], $email_change_email['headers'] );
1917
+			wp_mail($email_change_email['to'], sprintf($email_change_email['subject'], $blog_name), $email_change_email['message'], $email_change_email['headers']);
1918 1918
 		}
1919 1919
 
1920
-		if ( $switched_locale ) {
1920
+		if ($switched_locale) {
1921 1921
 			restore_previous_locale();
1922 1922
 		}
1923 1923
 	}
1924 1924
 
1925 1925
 	// Update the cookies if the password changed.
1926 1926
 	$current_user = wp_get_current_user();
1927
-	if ( $current_user->ID == $ID ) {
1928
-		if ( isset($plaintext_pass) ) {
1927
+	if ($current_user->ID == $ID) {
1928
+		if (isset($plaintext_pass)) {
1929 1929
 			wp_clear_auth_cookie();
1930 1930
 
1931 1931
 			// Here we calculate the expiration length of the current auth cookie and compare it to the default expiration.
1932 1932
 			// If it's greater than this, then we know the user checked 'Remember Me' when they logged in.
1933
-			$logged_in_cookie    = wp_parse_auth_cookie( '', 'logged_in' );
1933
+			$logged_in_cookie    = wp_parse_auth_cookie('', 'logged_in');
1934 1934
 			/** This filter is documented in wp-includes/pluggable.php */
1935
-			$default_cookie_life = apply_filters( 'auth_cookie_expiration', ( 2 * DAY_IN_SECONDS ), $ID, false );
1936
-			$remember            = ( ( $logged_in_cookie['expiration'] - time() ) > $default_cookie_life );
1935
+			$default_cookie_life = apply_filters('auth_cookie_expiration', (2 * DAY_IN_SECONDS), $ID, false);
1936
+			$remember            = (($logged_in_cookie['expiration'] - time()) > $default_cookie_life);
1937 1937
 
1938
-			wp_set_auth_cookie( $ID, $remember );
1938
+			wp_set_auth_cookie($ID, $remember);
1939 1939
 		}
1940 1940
 	}
1941 1941
 
@@ -1958,8 +1958,8 @@  discard block
 block discarded – undo
1958 1958
  *                      be created.
1959 1959
  */
1960 1960
 function wp_create_user($username, $password, $email = '') {
1961
-	$user_login = wp_slash( $username );
1962
-	$user_email = wp_slash( $email    );
1961
+	$user_login = wp_slash($username);
1962
+	$user_email = wp_slash($email);
1963 1963
 	$user_pass = $password;
1964 1964
 
1965 1965
 	$userdata = compact('user_login', 'user_email', 'user_pass');
@@ -1978,9 +1978,9 @@  discard block
 block discarded – undo
1978 1978
  * @param WP_User $user WP_User instance.
1979 1979
  * @return array List of user keys to be populated in wp_update_user().
1980 1980
  */
1981
-function _get_additional_user_keys( $user ) {
1982
-	$keys = array( 'first_name', 'last_name', 'nickname', 'description', 'rich_editing', 'comment_shortcuts', 'admin_color', 'use_ssl', 'show_admin_bar_front', 'locale' );
1983
-	return array_merge( $keys, array_keys( wp_get_user_contact_methods( $user ) ) );
1981
+function _get_additional_user_keys($user) {
1982
+	$keys = array('first_name', 'last_name', 'nickname', 'description', 'rich_editing', 'comment_shortcuts', 'admin_color', 'use_ssl', 'show_admin_bar_front', 'locale');
1983
+	return array_merge($keys, array_keys(wp_get_user_contact_methods($user)));
1984 1984
 }
1985 1985
 
1986 1986
 /**
@@ -1993,13 +1993,13 @@  discard block
 block discarded – undo
1993 1993
  * @param WP_User $user Optional. WP_User object.
1994 1994
  * @return array Array of contact methods and their labels.
1995 1995
  */
1996
-function wp_get_user_contact_methods( $user = null ) {
1996
+function wp_get_user_contact_methods($user = null) {
1997 1997
 	$methods = array();
1998
-	if ( get_site_option( 'initial_db_version' ) < 23588 ) {
1998
+	if (get_site_option('initial_db_version') < 23588) {
1999 1999
 		$methods = array(
2000
-			'aim'    => __( 'AIM' ),
2001
-			'yim'    => __( 'Yahoo IM' ),
2002
-			'jabber' => __( 'Jabber / Google Talk' )
2000
+			'aim'    => __('AIM'),
2001
+			'yim'    => __('Yahoo IM'),
2002
+			'jabber' => __('Jabber / Google Talk')
2003 2003
 		);
2004 2004
 	}
2005 2005
 
@@ -2011,7 +2011,7 @@  discard block
 block discarded – undo
2011 2011
 	 * @param array   $methods Array of contact methods and their labels.
2012 2012
  	 * @param WP_User $user    WP_User object.
2013 2013
 	 */
2014
-	return apply_filters( 'user_contactmethods', $methods, $user );
2014
+	return apply_filters('user_contactmethods', $methods, $user);
2015 2015
 }
2016 2016
 
2017 2017
 /**
@@ -2025,8 +2025,8 @@  discard block
 block discarded – undo
2025 2025
  * @param WP_User $user Optional. WP_User object. Default null.
2026 2026
  * @return array Array of contact methods and their labels.
2027 2027
  */
2028
-function _wp_get_user_contactmethods( $user = null ) {
2029
-	return wp_get_user_contact_methods( $user );
2028
+function _wp_get_user_contactmethods($user = null) {
2029
+	return wp_get_user_contact_methods($user);
2030 2030
 }
2031 2031
 
2032 2032
 /**
@@ -2037,7 +2037,7 @@  discard block
 block discarded – undo
2037 2037
  * @return string The password hint text.
2038 2038
  */
2039 2039
 function wp_get_password_hint() {
2040
-	$hint = __( 'Hint: The password should be at least twelve characters long. To make it stronger, use upper and lower case letters, numbers, and symbols like ! " ? $ % ^ &amp; ).' );
2040
+	$hint = __('Hint: The password should be at least twelve characters long. To make it stronger, use upper and lower case letters, numbers, and symbols like ! " ? $ % ^ &amp; ).');
2041 2041
 
2042 2042
 	/**
2043 2043
 	 * Filters the text describing the site's password complexity policy.
@@ -2046,7 +2046,7 @@  discard block
 block discarded – undo
2046 2046
 	 *
2047 2047
 	 * @param string $hint The password hint text.
2048 2048
 	 */
2049
-	return apply_filters( 'password_hint', $hint );
2049
+	return apply_filters('password_hint', $hint);
2050 2050
 }
2051 2051
 
2052 2052
 /**
@@ -2061,7 +2061,7 @@  discard block
 block discarded – undo
2061 2061
  *
2062 2062
  * @return string|WP_Error Password reset key on success. WP_Error on error.
2063 2063
  */
2064
-function get_password_reset_key( $user ) {
2064
+function get_password_reset_key($user) {
2065 2065
 	global $wpdb, $wp_hasher;
2066 2066
 
2067 2067
 	/**
@@ -2074,7 +2074,7 @@  discard block
 block discarded – undo
2074 2074
 	 *
2075 2075
 	 * @param string $user_login The user login name.
2076 2076
 	 */
2077
-	do_action( 'retreive_password', $user->user_login );
2077
+	do_action('retreive_password', $user->user_login);
2078 2078
 
2079 2079
 	/**
2080 2080
 	 * Fires before a new password is retrieved.
@@ -2083,10 +2083,10 @@  discard block
 block discarded – undo
2083 2083
 	 *
2084 2084
 	 * @param string $user_login The user login name.
2085 2085
 	 */
2086
-	do_action( 'retrieve_password', $user->user_login );
2086
+	do_action('retrieve_password', $user->user_login);
2087 2087
 
2088 2088
 	$allow = true;
2089
-	if ( is_multisite() && is_user_spammy( $user ) ) {
2089
+	if (is_multisite() && is_user_spammy($user)) {
2090 2090
 		$allow = false;
2091 2091
 	}
2092 2092
 
@@ -2098,16 +2098,16 @@  discard block
 block discarded – undo
2098 2098
 	 * @param bool $allow         Whether to allow the password to be reset. Default true.
2099 2099
 	 * @param int  $user_data->ID The ID of the user attempting to reset a password.
2100 2100
 	 */
2101
-	$allow = apply_filters( 'allow_password_reset', $allow, $user->ID );
2101
+	$allow = apply_filters('allow_password_reset', $allow, $user->ID);
2102 2102
 
2103
-	if ( ! $allow ) {
2104
-		return new WP_Error( 'no_password_reset', __( 'Password reset is not allowed for this user' ) );
2105
-	} elseif ( is_wp_error( $allow ) ) {
2103
+	if ( ! $allow) {
2104
+		return new WP_Error('no_password_reset', __('Password reset is not allowed for this user'));
2105
+	} elseif (is_wp_error($allow)) {
2106 2106
 		return $allow;
2107 2107
 	}
2108 2108
 
2109 2109
 	// Generate something random for a password reset key.
2110
-	$key = wp_generate_password( 20, false );
2110
+	$key = wp_generate_password(20, false);
2111 2111
 
2112 2112
 	/**
2113 2113
 	 * Fires when a password reset key is generated.
@@ -2117,16 +2117,16 @@  discard block
 block discarded – undo
2117 2117
 	 * @param string $user_login The username for the user.
2118 2118
 	 * @param string $key        The generated password reset key.
2119 2119
 	 */
2120
-	do_action( 'retrieve_password_key', $user->user_login, $key );
2120
+	do_action('retrieve_password_key', $user->user_login, $key);
2121 2121
 
2122 2122
 	// Now insert the key, hashed, into the DB.
2123
-	if ( empty( $wp_hasher ) ) {
2124
-		$wp_hasher = new PasswordHash( 8, true );
2123
+	if (empty($wp_hasher)) {
2124
+		$wp_hasher = new PasswordHash(8, true);
2125 2125
 	}
2126
-	$hashed = time() . ':' . $wp_hasher->HashPassword( $key );
2127
-	$key_saved = $wpdb->update( $wpdb->users, array( 'user_activation_key' => $hashed ), array( 'user_login' => $user->user_login ) );
2128
-	if ( false === $key_saved ) {
2129
-		return new WP_Error( 'no_password_key_update', __( 'Could not save password reset key to database.' ) );
2126
+	$hashed = time().':'.$wp_hasher->HashPassword($key);
2127
+	$key_saved = $wpdb->update($wpdb->users, array('user_activation_key' => $hashed), array('user_login' => $user->user_login));
2128
+	if (false === $key_saved) {
2129
+		return new WP_Error('no_password_key_update', __('Could not save password reset key to database.'));
2130 2130
 	}
2131 2131
 
2132 2132
 	return $key;
@@ -2154,18 +2154,18 @@  discard block
 block discarded – undo
2154 2154
 
2155 2155
 	$key = preg_replace('/[^a-z0-9]/i', '', $key);
2156 2156
 
2157
-	if ( empty( $key ) || !is_string( $key ) )
2157
+	if (empty($key) || ! is_string($key))
2158 2158
 		return new WP_Error('invalid_key', __('Invalid key'));
2159 2159
 
2160
-	if ( empty($login) || !is_string($login) )
2160
+	if (empty($login) || ! is_string($login))
2161 2161
 		return new WP_Error('invalid_key', __('Invalid key'));
2162 2162
 
2163
-	$row = $wpdb->get_row( $wpdb->prepare( "SELECT ID, user_activation_key FROM $wpdb->users WHERE user_login = %s", $login ) );
2164
-	if ( ! $row )
2163
+	$row = $wpdb->get_row($wpdb->prepare("SELECT ID, user_activation_key FROM $wpdb->users WHERE user_login = %s", $login));
2164
+	if ( ! $row)
2165 2165
 		return new WP_Error('invalid_key', __('Invalid key'));
2166 2166
 
2167
-	if ( empty( $wp_hasher ) ) {
2168
-		$wp_hasher = new PasswordHash( 8, true );
2167
+	if (empty($wp_hasher)) {
2168
+		$wp_hasher = new PasswordHash(8, true);
2169 2169
 	}
2170 2170
 
2171 2171
 	/**
@@ -2175,31 +2175,31 @@  discard block
 block discarded – undo
2175 2175
 	 *
2176 2176
 	 * @param int $expiration The expiration time in seconds.
2177 2177
 	 */
2178
-	$expiration_duration = apply_filters( 'password_reset_expiration', DAY_IN_SECONDS );
2178
+	$expiration_duration = apply_filters('password_reset_expiration', DAY_IN_SECONDS);
2179 2179
 
2180
-	if ( false !== strpos( $row->user_activation_key, ':' ) ) {
2181
-		list( $pass_request_time, $pass_key ) = explode( ':', $row->user_activation_key, 2 );
2180
+	if (false !== strpos($row->user_activation_key, ':')) {
2181
+		list($pass_request_time, $pass_key) = explode(':', $row->user_activation_key, 2);
2182 2182
 		$expiration_time = $pass_request_time + $expiration_duration;
2183 2183
 	} else {
2184 2184
 		$pass_key = $row->user_activation_key;
2185 2185
 		$expiration_time = false;
2186 2186
 	}
2187 2187
 
2188
-	if ( ! $pass_key ) {
2189
-		return new WP_Error( 'invalid_key', __( 'Invalid key' ) );
2188
+	if ( ! $pass_key) {
2189
+		return new WP_Error('invalid_key', __('Invalid key'));
2190 2190
 	}
2191 2191
 
2192
-	$hash_is_correct = $wp_hasher->CheckPassword( $key, $pass_key );
2192
+	$hash_is_correct = $wp_hasher->CheckPassword($key, $pass_key);
2193 2193
 
2194
-	if ( $hash_is_correct && $expiration_time && time() < $expiration_time ) {
2195
-		return get_userdata( $row->ID );
2196
-	} elseif ( $hash_is_correct && $expiration_time ) {
2194
+	if ($hash_is_correct && $expiration_time && time() < $expiration_time) {
2195
+		return get_userdata($row->ID);
2196
+	} elseif ($hash_is_correct && $expiration_time) {
2197 2197
 		// Key has an expiration time that's passed
2198
-		return new WP_Error( 'expired_key', __( 'Invalid key' ) );
2198
+		return new WP_Error('expired_key', __('Invalid key'));
2199 2199
 	}
2200 2200
 
2201
-	if ( hash_equals( $row->user_activation_key, $key ) || ( $hash_is_correct && ! $expiration_time ) ) {
2202
-		$return = new WP_Error( 'expired_key', __( 'Invalid key' ) );
2201
+	if (hash_equals($row->user_activation_key, $key) || ($hash_is_correct && ! $expiration_time)) {
2202
+		$return = new WP_Error('expired_key', __('Invalid key'));
2203 2203
 		$user_id = $row->ID;
2204 2204
 
2205 2205
 		/**
@@ -2213,10 +2213,10 @@  discard block
 block discarded – undo
2213 2213
 		 *                          Return a WP_User object to validate the key.
2214 2214
 		 * @param int      $user_id The matched user ID.
2215 2215
 		 */
2216
-		return apply_filters( 'password_reset_key_expired', $return, $user_id );
2216
+		return apply_filters('password_reset_key_expired', $return, $user_id);
2217 2217
 	}
2218 2218
 
2219
-	return new WP_Error( 'invalid_key', __( 'Invalid key' ) );
2219
+	return new WP_Error('invalid_key', __('Invalid key'));
2220 2220
 }
2221 2221
 
2222 2222
 /**
@@ -2227,7 +2227,7 @@  discard block
 block discarded – undo
2227 2227
  * @param object $user     The user
2228 2228
  * @param string $new_pass New password for the user in plaintext
2229 2229
  */
2230
-function reset_password( $user, $new_pass ) {
2230
+function reset_password($user, $new_pass) {
2231 2231
 	/**
2232 2232
 	 * Fires before the user's password is reset.
2233 2233
 	 *
@@ -2236,10 +2236,10 @@  discard block
 block discarded – undo
2236 2236
 	 * @param object $user     The user.
2237 2237
 	 * @param string $new_pass New user password.
2238 2238
 	 */
2239
-	do_action( 'password_reset', $user, $new_pass );
2239
+	do_action('password_reset', $user, $new_pass);
2240 2240
 
2241
-	wp_set_password( $new_pass, $user->ID );
2242
-	update_user_option( $user->ID, 'default_password_nag', false, true );
2241
+	wp_set_password($new_pass, $user->ID);
2242
+	update_user_option($user->ID, 'default_password_nag', false, true);
2243 2243
 
2244 2244
 	/**
2245 2245
 	 * Fires after the user's password is reset.
@@ -2249,7 +2249,7 @@  discard block
 block discarded – undo
2249 2249
 	 * @param object $user     The user.
2250 2250
 	 * @param string $new_pass New user password.
2251 2251
 	 */
2252
-	do_action( 'after_password_reset', $user, $new_pass );
2252
+	do_action('after_password_reset', $user, $new_pass);
2253 2253
 }
2254 2254
 
2255 2255
 /**
@@ -2261,10 +2261,10 @@  discard block
 block discarded – undo
2261 2261
  * @param string $user_email User's email address to send password and add
2262 2262
  * @return int|WP_Error Either user's ID or error on failure.
2263 2263
  */
2264
-function register_new_user( $user_login, $user_email ) {
2264
+function register_new_user($user_login, $user_email) {
2265 2265
 	$errors = new WP_Error();
2266 2266
 
2267
-	$sanitized_user_login = sanitize_user( $user_login );
2267
+	$sanitized_user_login = sanitize_user($user_login);
2268 2268
 	/**
2269 2269
 	 * Filters the email address of a user being registered.
2270 2270
 	 *
@@ -2272,33 +2272,33 @@  discard block
 block discarded – undo
2272 2272
 	 *
2273 2273
 	 * @param string $user_email The email address of the new user.
2274 2274
 	 */
2275
-	$user_email = apply_filters( 'user_registration_email', $user_email );
2275
+	$user_email = apply_filters('user_registration_email', $user_email);
2276 2276
 
2277 2277
 	// Check the username
2278
-	if ( $sanitized_user_login == '' ) {
2279
-		$errors->add( 'empty_username', __( '<strong>ERROR</strong>: Please enter a username.' ) );
2280
-	} elseif ( ! validate_username( $user_login ) ) {
2281
-		$errors->add( 'invalid_username', __( '<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.' ) );
2278
+	if ($sanitized_user_login == '') {
2279
+		$errors->add('empty_username', __('<strong>ERROR</strong>: Please enter a username.'));
2280
+	} elseif ( ! validate_username($user_login)) {
2281
+		$errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.'));
2282 2282
 		$sanitized_user_login = '';
2283
-	} elseif ( username_exists( $sanitized_user_login ) ) {
2284
-		$errors->add( 'username_exists', __( '<strong>ERROR</strong>: This username is already registered. Please choose another one.' ) );
2283
+	} elseif (username_exists($sanitized_user_login)) {
2284
+		$errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered. Please choose another one.'));
2285 2285
 
2286 2286
 	} else {
2287 2287
 		/** This filter is documented in wp-includes/user.php */
2288
-		$illegal_user_logins = array_map( 'strtolower', (array) apply_filters( 'illegal_user_logins', array() ) );
2289
-		if ( in_array( strtolower( $sanitized_user_login ), $illegal_user_logins ) ) {
2290
-			$errors->add( 'invalid_username', __( '<strong>ERROR</strong>: Sorry, that username is not allowed.' ) );
2288
+		$illegal_user_logins = array_map('strtolower', (array) apply_filters('illegal_user_logins', array()));
2289
+		if (in_array(strtolower($sanitized_user_login), $illegal_user_logins)) {
2290
+			$errors->add('invalid_username', __('<strong>ERROR</strong>: Sorry, that username is not allowed.'));
2291 2291
 		}
2292 2292
 	}
2293 2293
 
2294 2294
 	// Check the email address
2295
-	if ( $user_email == '' ) {
2296
-		$errors->add( 'empty_email', __( '<strong>ERROR</strong>: Please type your email address.' ) );
2297
-	} elseif ( ! is_email( $user_email ) ) {
2298
-		$errors->add( 'invalid_email', __( '<strong>ERROR</strong>: The email address isn&#8217;t correct.' ) );
2295
+	if ($user_email == '') {
2296
+		$errors->add('empty_email', __('<strong>ERROR</strong>: Please type your email address.'));
2297
+	} elseif ( ! is_email($user_email)) {
2298
+		$errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn&#8217;t correct.'));
2299 2299
 		$user_email = '';
2300
-	} elseif ( email_exists( $user_email ) ) {
2301
-		$errors->add( 'email_exists', __( '<strong>ERROR</strong>: This email is already registered, please choose another one.' ) );
2300
+	} elseif (email_exists($user_email)) {
2301
+		$errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.'));
2302 2302
 	}
2303 2303
 
2304 2304
 	/**
@@ -2312,7 +2312,7 @@  discard block
 block discarded – undo
2312 2312
 	 *                                       e.g., an empty field, an invalid username or email,
2313 2313
 	 *                                       or an existing username or email.
2314 2314
 	 */
2315
-	do_action( 'register_post', $sanitized_user_login, $user_email, $errors );
2315
+	do_action('register_post', $sanitized_user_login, $user_email, $errors);
2316 2316
 
2317 2317
 	/**
2318 2318
 	 * Filters the errors encountered when a new user is being registered.
@@ -2330,19 +2330,19 @@  discard block
 block discarded – undo
2330 2330
 	 * @param string   $sanitized_user_login User's username after it has been sanitized.
2331 2331
 	 * @param string   $user_email           User's email.
2332 2332
 	 */
2333
-	$errors = apply_filters( 'registration_errors', $errors, $sanitized_user_login, $user_email );
2333
+	$errors = apply_filters('registration_errors', $errors, $sanitized_user_login, $user_email);
2334 2334
 
2335
-	if ( $errors->get_error_code() )
2335
+	if ($errors->get_error_code())
2336 2336
 		return $errors;
2337 2337
 
2338
-	$user_pass = wp_generate_password( 12, false );
2339
-	$user_id = wp_create_user( $sanitized_user_login, $user_pass, $user_email );
2340
-	if ( ! $user_id || is_wp_error( $user_id ) ) {
2341
-		$errors->add( 'registerfail', sprintf( __( '<strong>ERROR</strong>: Couldn&#8217;t register you&hellip; please contact the <a href="mailto:%s">webmaster</a> !' ), get_option( 'admin_email' ) ) );
2338
+	$user_pass = wp_generate_password(12, false);
2339
+	$user_id = wp_create_user($sanitized_user_login, $user_pass, $user_email);
2340
+	if ( ! $user_id || is_wp_error($user_id)) {
2341
+		$errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn&#8217;t register you&hellip; please contact the <a href="mailto:%s">webmaster</a> !'), get_option('admin_email')));
2342 2342
 		return $errors;
2343 2343
 	}
2344 2344
 
2345
-	update_user_option( $user_id, 'default_password_nag', true, true ); //Set up the Password change nag.
2345
+	update_user_option($user_id, 'default_password_nag', true, true); //Set up the Password change nag.
2346 2346
 
2347 2347
 	/**
2348 2348
 	 * Fires after a new user registration has been recorded.
@@ -2351,7 +2351,7 @@  discard block
 block discarded – undo
2351 2351
 	 *
2352 2352
 	 * @param int $user_id ID of the newly registered user.
2353 2353
 	 */
2354
-	do_action( 'register_new_user', $user_id );
2354
+	do_action('register_new_user', $user_id);
2355 2355
 
2356 2356
 	return $user_id;
2357 2357
 }
@@ -2370,8 +2370,8 @@  discard block
 block discarded – undo
2370 2370
  *                        or an empty string (admin only), 'user', or 'both' (admin and user).
2371 2371
  *                        Default 'both'.
2372 2372
  */
2373
-function wp_send_new_user_notifications( $user_id, $notify = 'both' ) {
2374
-	wp_new_user_notification( $user_id, null, $notify );
2373
+function wp_send_new_user_notifications($user_id, $notify = 'both') {
2374
+	wp_new_user_notification($user_id, null, $notify);
2375 2375
 }
2376 2376
 
2377 2377
 /**
@@ -2382,8 +2382,8 @@  discard block
 block discarded – undo
2382 2382
  * @return string Token.
2383 2383
  */
2384 2384
 function wp_get_session_token() {
2385
-	$cookie = wp_parse_auth_cookie( '', 'logged_in' );
2386
-	return ! empty( $cookie['token'] ) ? $cookie['token'] : '';
2385
+	$cookie = wp_parse_auth_cookie('', 'logged_in');
2386
+	return ! empty($cookie['token']) ? $cookie['token'] : '';
2387 2387
 }
2388 2388
 
2389 2389
 /**
@@ -2393,7 +2393,7 @@  discard block
 block discarded – undo
2393 2393
  * @return array Array of sessions.
2394 2394
  */
2395 2395
 function wp_get_all_sessions() {
2396
-	$manager = WP_Session_Tokens::get_instance( get_current_user_id() );
2396
+	$manager = WP_Session_Tokens::get_instance(get_current_user_id());
2397 2397
 	return $manager->get_all();
2398 2398
 }
2399 2399
 
@@ -2404,9 +2404,9 @@  discard block
 block discarded – undo
2404 2404
  */
2405 2405
 function wp_destroy_current_session() {
2406 2406
 	$token = wp_get_session_token();
2407
-	if ( $token ) {
2408
-		$manager = WP_Session_Tokens::get_instance( get_current_user_id() );
2409
-		$manager->destroy( $token );
2407
+	if ($token) {
2408
+		$manager = WP_Session_Tokens::get_instance(get_current_user_id());
2409
+		$manager->destroy($token);
2410 2410
 	}
2411 2411
 }
2412 2412
 
@@ -2417,9 +2417,9 @@  discard block
 block discarded – undo
2417 2417
  */
2418 2418
 function wp_destroy_other_sessions() {
2419 2419
 	$token = wp_get_session_token();
2420
-	if ( $token ) {
2421
-		$manager = WP_Session_Tokens::get_instance( get_current_user_id() );
2422
-		$manager->destroy_others( $token );
2420
+	if ($token) {
2421
+		$manager = WP_Session_Tokens::get_instance(get_current_user_id());
2422
+		$manager->destroy_others($token);
2423 2423
 	}
2424 2424
 }
2425 2425
 
@@ -2429,7 +2429,7 @@  discard block
 block discarded – undo
2429 2429
  * @since 4.0.0
2430 2430
  */
2431 2431
 function wp_destroy_all_sessions() {
2432
-	$manager = WP_Session_Tokens::get_instance( get_current_user_id() );
2432
+	$manager = WP_Session_Tokens::get_instance(get_current_user_id());
2433 2433
 	$manager->destroy_all();
2434 2434
 }
2435 2435
 
@@ -2445,19 +2445,19 @@  discard block
 block discarded – undo
2445 2445
 function wp_get_users_with_no_role() {
2446 2446
 	global $wpdb;
2447 2447
 
2448
-	if ( is_multisite() ) {
2448
+	if (is_multisite()) {
2449 2449
 		return array();
2450 2450
 	}
2451 2451
 
2452 2452
 	$prefix = $wpdb->get_blog_prefix();
2453
-	$regex  = implode( '|', array_keys( wp_roles()->get_names() ) );
2454
-	$regex  = preg_replace( '/[^a-zA-Z_\|-]/', '', $regex );
2455
-	$users  = $wpdb->get_col( $wpdb->prepare( "
2453
+	$regex  = implode('|', array_keys(wp_roles()->get_names()));
2454
+	$regex  = preg_replace('/[^a-zA-Z_\|-]/', '', $regex);
2455
+	$users  = $wpdb->get_col($wpdb->prepare("
2456 2456
 		SELECT user_id
2457 2457
 		FROM $wpdb->usermeta
2458 2458
 		WHERE meta_key = '{$prefix}capabilities'
2459 2459
 		AND meta_value NOT REGEXP %s
2460
-	", $regex ) );
2460
+	", $regex));
2461 2461
 
2462 2462
 	return $users;
2463 2463
 }
@@ -2484,27 +2484,27 @@  discard block
 block discarded – undo
2484 2484
 function _wp_get_current_user() {
2485 2485
 	global $current_user;
2486 2486
 
2487
-	if ( ! empty( $current_user ) ) {
2488
-		if ( $current_user instanceof WP_User ) {
2487
+	if ( ! empty($current_user)) {
2488
+		if ($current_user instanceof WP_User) {
2489 2489
 			return $current_user;
2490 2490
 		}
2491 2491
 
2492 2492
 		// Upgrade stdClass to WP_User
2493
-		if ( is_object( $current_user ) && isset( $current_user->ID ) ) {
2493
+		if (is_object($current_user) && isset($current_user->ID)) {
2494 2494
 			$cur_id = $current_user->ID;
2495 2495
 			$current_user = null;
2496
-			wp_set_current_user( $cur_id );
2496
+			wp_set_current_user($cur_id);
2497 2497
 			return $current_user;
2498 2498
 		}
2499 2499
 
2500 2500
 		// $current_user has a junk value. Force to WP_User with ID 0.
2501 2501
 		$current_user = null;
2502
-		wp_set_current_user( 0 );
2502
+		wp_set_current_user(0);
2503 2503
 		return $current_user;
2504 2504
 	}
2505 2505
 
2506
-	if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST ) {
2507
-		wp_set_current_user( 0 );
2506
+	if (defined('XMLRPC_REQUEST') && XMLRPC_REQUEST) {
2507
+		wp_set_current_user(0);
2508 2508
 		return $current_user;
2509 2509
 	}
2510 2510
 
@@ -2521,13 +2521,13 @@  discard block
 block discarded – undo
2521 2521
 	 *
2522 2522
 	 * @param int|bool $user_id User ID if one has been determined, false otherwise.
2523 2523
 	 */
2524
-	$user_id = apply_filters( 'determine_current_user', false );
2525
-	if ( ! $user_id ) {
2526
-		wp_set_current_user( 0 );
2524
+	$user_id = apply_filters('determine_current_user', false);
2525
+	if ( ! $user_id) {
2526
+		wp_set_current_user(0);
2527 2527
 		return $current_user;
2528 2528
 	}
2529 2529
 
2530
-	wp_set_current_user( $user_id );
2530
+	wp_set_current_user($user_id);
2531 2531
 
2532 2532
 	return $current_user;
2533 2533
 }
Please login to merge, or discard this patch.
Braces   +132 added lines, -88 removed lines patch added patch discarded remove patch
@@ -29,18 +29,22 @@  discard block
 block discarded – undo
29 29
 	if ( empty($credentials) ) {
30 30
 		$credentials = array(); // Back-compat for plugins passing an empty string.
31 31
 
32
-		if ( ! empty($_POST['log']) )
33
-			$credentials['user_login'] = $_POST['log'];
34
-		if ( ! empty($_POST['pwd']) )
35
-			$credentials['user_password'] = $_POST['pwd'];
36
-		if ( ! empty($_POST['rememberme']) )
37
-			$credentials['remember'] = $_POST['rememberme'];
32
+		if ( ! empty($_POST['log']) ) {
33
+					$credentials['user_login'] = $_POST['log'];
34
+		}
35
+		if ( ! empty($_POST['pwd']) ) {
36
+					$credentials['user_password'] = $_POST['pwd'];
37
+		}
38
+		if ( ! empty($_POST['rememberme']) ) {
39
+					$credentials['remember'] = $_POST['rememberme'];
40
+		}
38 41
 	}
39 42
 
40
-	if ( !empty($credentials['remember']) )
41
-		$credentials['remember'] = true;
42
-	else
43
-		$credentials['remember'] = false;
43
+	if ( !empty($credentials['remember']) ) {
44
+			$credentials['remember'] = true;
45
+	} else {
46
+			$credentials['remember'] = false;
47
+	}
44 48
 
45 49
 	/**
46 50
 	 * Fires before the user is authenticated.
@@ -57,8 +61,9 @@  discard block
 block discarded – undo
57 61
 	 */
58 62
 	do_action_ref_array( 'wp_authenticate', array( &$credentials['user_login'], &$credentials['user_password'] ) );
59 63
 
60
-	if ( '' === $secure_cookie )
61
-		$secure_cookie = is_ssl();
64
+	if ( '' === $secure_cookie ) {
65
+			$secure_cookie = is_ssl();
66
+	}
62 67
 
63 68
 	/**
64 69
 	 * Filters whether to use a secure sign-on cookie.
@@ -121,16 +126,19 @@  discard block
 block discarded – undo
121 126
 	}
122 127
 
123 128
 	if ( empty($username) || empty($password) ) {
124
-		if ( is_wp_error( $user ) )
125
-			return $user;
129
+		if ( is_wp_error( $user ) ) {
130
+					return $user;
131
+		}
126 132
 
127 133
 		$error = new WP_Error();
128 134
 
129
-		if ( empty($username) )
130
-			$error->add('empty_username', __('<strong>ERROR</strong>: The username field is empty.'));
135
+		if ( empty($username) ) {
136
+					$error->add('empty_username', __('<strong>ERROR</strong>: The username field is empty.'));
137
+		}
131 138
 
132
-		if ( empty($password) )
133
-			$error->add('empty_password', __('<strong>ERROR</strong>: The password field is empty.'));
139
+		if ( empty($password) ) {
140
+					$error->add('empty_password', __('<strong>ERROR</strong>: The password field is empty.'));
141
+		}
134 142
 
135 143
 		return $error;
136 144
 	}
@@ -156,8 +164,9 @@  discard block
 block discarded – undo
156 164
 	 * @param string           $password Password to check against the user.
157 165
 	 */
158 166
 	$user = apply_filters( 'wp_authenticate_user', $user, $password );
159
-	if ( is_wp_error($user) )
160
-		return $user;
167
+	if ( is_wp_error($user) ) {
168
+			return $user;
169
+	}
161 170
 
162 171
 	if ( ! wp_check_password( $password, $user->user_pass, $user->ID ) ) {
163 172
 		return new WP_Error( 'incorrect_password',
@@ -266,18 +275,21 @@  discard block
 block discarded – undo
266 275
 
267 276
 	if ( empty($username) && empty($password) ) {
268 277
 		$user_id = wp_validate_auth_cookie();
269
-		if ( $user_id )
270
-			return new WP_User($user_id);
278
+		if ( $user_id ) {
279
+					return new WP_User($user_id);
280
+		}
271 281
 
272 282
 		global $auth_secure_cookie;
273 283
 
274
-		if ( $auth_secure_cookie )
275
-			$auth_cookie = SECURE_AUTH_COOKIE;
276
-		else
277
-			$auth_cookie = AUTH_COOKIE;
284
+		if ( $auth_secure_cookie ) {
285
+					$auth_cookie = SECURE_AUTH_COOKIE;
286
+		} else {
287
+					$auth_cookie = AUTH_COOKIE;
288
+		}
278 289
 
279
-		if ( !empty($_COOKIE[$auth_cookie]) )
280
-			return new WP_Error('expired_session', __('Please log in again.'));
290
+		if ( !empty($_COOKIE[$auth_cookie]) ) {
291
+					return new WP_Error('expired_session', __('Please log in again.'));
292
+		}
281 293
 
282 294
 		// If the cookie is not set, be silent.
283 295
 	}
@@ -306,8 +318,9 @@  discard block
 block discarded – undo
306 318
 		 */
307 319
 		$spammed = apply_filters( 'check_is_user_spammed', is_user_spammy( $user ), $user );
308 320
 
309
-		if ( $spammed )
310
-			return new WP_Error( 'spammer_account', __( '<strong>ERROR</strong>: Your account has been marked as a spammer.' ) );
321
+		if ( $spammed ) {
322
+					return new WP_Error( 'spammer_account', __( '<strong>ERROR</strong>: Your account has been marked as a spammer.' ) );
323
+		}
311 324
 	}
312 325
 	return $user;
313 326
 }
@@ -392,8 +405,9 @@  discard block
 block discarded – undo
392 405
 	global $wpdb;
393 406
 
394 407
 	$count = array();
395
-	if ( empty( $users ) || ! is_array( $users ) )
396
-		return $count;
408
+	if ( empty( $users ) || ! is_array( $users ) ) {
409
+			return $count;
410
+	}
397 411
 
398 412
 	$userlist = implode( ',', array_map( 'absint', $users ) );
399 413
 	$where = get_posts_by_author_sql( $post_type, true, null, $public_only );
@@ -404,8 +418,9 @@  discard block
 block discarded – undo
404 418
 	}
405 419
 
406 420
 	foreach ( $users as $id ) {
407
-		if ( ! isset( $count[ $id ] ) )
408
-			$count[ $id ] = 0;
421
+		if ( ! isset( $count[ $id ] ) ) {
422
+					$count[ $id ] = 0;
423
+		}
409 424
 	}
410 425
 
411 426
 	return $count;
@@ -423,8 +438,9 @@  discard block
 block discarded – undo
423 438
  * @return int The current user's ID, or 0 if no user is logged in.
424 439
  */
425 440
 function get_current_user_id() {
426
-	if ( ! function_exists( 'wp_get_current_user' ) )
427
-		return 0;
441
+	if ( ! function_exists( 'wp_get_current_user' ) ) {
442
+			return 0;
443
+	}
428 444
 	$user = wp_get_current_user();
429 445
 	return ( isset( $user->ID ) ? (int) $user->ID : 0 );
430 446
 }
@@ -451,22 +467,28 @@  discard block
 block discarded – undo
451 467
 function get_user_option( $option, $user = 0, $deprecated = '' ) {
452 468
 	global $wpdb;
453 469
 
454
-	if ( !empty( $deprecated ) )
455
-		_deprecated_argument( __FUNCTION__, '3.0.0' );
470
+	if ( !empty( $deprecated ) ) {
471
+			_deprecated_argument( __FUNCTION__, '3.0.0' );
472
+	}
456 473
 
457
-	if ( empty( $user ) )
458
-		$user = get_current_user_id();
474
+	if ( empty( $user ) ) {
475
+			$user = get_current_user_id();
476
+	}
459 477
 
460
-	if ( ! $user = get_userdata( $user ) )
461
-		return false;
478
+	if ( ! $user = get_userdata( $user ) ) {
479
+			return false;
480
+	}
462 481
 
463 482
 	$prefix = $wpdb->get_blog_prefix();
464
-	if ( $user->has_prop( $prefix . $option ) ) // Blog specific
483
+	if ( $user->has_prop( $prefix . $option ) ) {
484
+		// Blog specific
465 485
 		$result = $user->get( $prefix . $option );
466
-	elseif ( $user->has_prop( $option ) ) // User specific and cross-blog
486
+	} elseif ( $user->has_prop( $option ) ) {
487
+		// User specific and cross-blog
467 488
 		$result = $user->get( $option );
468
-	else
469
-		$result = false;
489
+	} else {
490
+			$result = false;
491
+	}
470 492
 
471 493
 	/**
472 494
 	 * Filters a specific user option value.
@@ -506,8 +528,9 @@  discard block
 block discarded – undo
506 528
 function update_user_option( $user_id, $option_name, $newvalue, $global = false ) {
507 529
 	global $wpdb;
508 530
 
509
-	if ( !$global )
510
-		$option_name = $wpdb->get_blog_prefix() . $option_name;
531
+	if ( !$global ) {
532
+			$option_name = $wpdb->get_blog_prefix() . $option_name;
533
+	}
511 534
 
512 535
 	return update_user_meta( $user_id, $option_name, $newvalue );
513 536
 }
@@ -532,8 +555,9 @@  discard block
 block discarded – undo
532 555
 function delete_user_option( $user_id, $option_name, $global = false ) {
533 556
 	global $wpdb;
534 557
 
535
-	if ( !$global )
536
-		$option_name = $wpdb->get_blog_prefix() . $option_name;
558
+	if ( !$global ) {
559
+			$option_name = $wpdb->get_blog_prefix() . $option_name;
560
+	}
537 561
 	return delete_user_meta( $user_id, $option_name );
538 562
 }
539 563
 
@@ -578,8 +602,9 @@  discard block
 block discarded – undo
578 602
 	$user_id = (int) $user_id;
579 603
 
580 604
 	// Logged out users can't have sites
581
-	if ( empty( $user_id ) )
582
-		return array();
605
+	if ( empty( $user_id ) ) {
606
+			return array();
607
+	}
583 608
 
584 609
 	/**
585 610
 	 * Filters the list of a user's sites before it is populated.
@@ -601,8 +626,9 @@  discard block
 block discarded – undo
601 626
 	}
602 627
 
603 628
 	$keys = get_user_meta( $user_id );
604
-	if ( empty( $keys ) )
605
-		return array();
629
+	if ( empty( $keys ) ) {
630
+			return array();
631
+	}
606 632
 
607 633
 	if ( ! is_multisite() ) {
608 634
 		$site_id = get_current_blog_id();
@@ -629,13 +655,16 @@  discard block
 block discarded – undo
629 655
 	$keys = array_keys( $keys );
630 656
 
631 657
 	foreach ( $keys as $key ) {
632
-		if ( 'capabilities' !== substr( $key, -12 ) )
633
-			continue;
634
-		if ( $wpdb->base_prefix && 0 !== strpos( $key, $wpdb->base_prefix ) )
635
-			continue;
658
+		if ( 'capabilities' !== substr( $key, -12 ) ) {
659
+					continue;
660
+		}
661
+		if ( $wpdb->base_prefix && 0 !== strpos( $key, $wpdb->base_prefix ) ) {
662
+					continue;
663
+		}
636 664
 		$site_id = str_replace( array( $wpdb->base_prefix, '_capabilities' ), '', $key );
637
-		if ( ! is_numeric( $site_id ) )
638
-			continue;
665
+		if ( ! is_numeric( $site_id ) ) {
666
+					continue;
667
+		}
639 668
 
640 669
 		$site_ids[] = (int) $site_id;
641 670
 	}
@@ -885,8 +914,9 @@  discard block
 block discarded – undo
885 914
 
886 915
 		foreach ( $users_of_blog as $caps_meta ) {
887 916
 			$b_roles = maybe_unserialize($caps_meta);
888
-			if ( ! is_array( $b_roles ) )
889
-				continue;
917
+			if ( ! is_array( $b_roles ) ) {
918
+							continue;
919
+			}
890 920
 			if ( empty( $b_roles ) ) {
891 921
 				$avail_roles['none']++;
892 922
 			}
@@ -934,8 +964,9 @@  discard block
 block discarded – undo
934 964
 function setup_userdata($for_user_id = '') {
935 965
 	global $user_login, $userdata, $user_level, $user_ID, $user_email, $user_url, $user_identity;
936 966
 
937
-	if ( '' == $for_user_id )
938
-		$for_user_id = get_current_user_id();
967
+	if ( '' == $for_user_id ) {
968
+			$for_user_id = get_current_user_id();
969
+	}
939 970
 	$user = get_userdata( $for_user_id );
940 971
 
941 972
 	if ( ! $user ) {
@@ -1149,14 +1180,17 @@  discard block
 block discarded – undo
1149 1180
  */
1150 1181
 function sanitize_user_field($field, $value, $user_id, $context) {
1151 1182
 	$int_fields = array('ID');
1152
-	if ( in_array($field, $int_fields) )
1153
-		$value = (int) $value;
1183
+	if ( in_array($field, $int_fields) ) {
1184
+			$value = (int) $value;
1185
+	}
1154 1186
 
1155
-	if ( 'raw' == $context )
1156
-		return $value;
1187
+	if ( 'raw' == $context ) {
1188
+			return $value;
1189
+	}
1157 1190
 
1158
-	if ( !is_string($value) && !is_numeric($value) )
1159
-		return $value;
1191
+	if ( !is_string($value) && !is_numeric($value) ) {
1192
+			return $value;
1193
+	}
1160 1194
 
1161 1195
 	$prefixed = false !== strpos( $field, 'user_' );
1162 1196
 
@@ -1181,10 +1215,13 @@  discard block
 block discarded – undo
1181 1215
 			$value = apply_filters( "edit_user_{$field}", $value, $user_id );
1182 1216
 		}
1183 1217
 
1184
-		if ( 'description' == $field )
1185
-			$value = esc_html( $value ); // textarea_escaped?
1186
-		else
1187
-			$value = esc_attr($value);
1218
+		if ( 'description' == $field ) {
1219
+					$value = esc_html( $value );
1220
+		}
1221
+		// textarea_escaped?
1222
+		else {
1223
+					$value = esc_attr($value);
1224
+		}
1188 1225
 	} elseif ( 'db' == $context ) {
1189 1226
 		if ( $prefixed ) {
1190 1227
 			/** This filter is documented in wp-includes/post.php */
@@ -1227,8 +1264,9 @@  discard block
 block discarded – undo
1227 1264
 		}
1228 1265
 	}
1229 1266
 
1230
-	if ( 'user_url' == $field )
1231
-		$value = esc_url($value);
1267
+	if ( 'user_url' == $field ) {
1268
+			$value = esc_url($value);
1269
+	}
1232 1270
 
1233 1271
 	if ( 'attribute' == $context ) {
1234 1272
 		$value = esc_attr( $value );
@@ -1270,11 +1308,13 @@  discard block
 block discarded – undo
1270 1308
  * @param WP_User|int $user User object or ID to be cleaned from the cache
1271 1309
  */
1272 1310
 function clean_user_cache( $user ) {
1273
-	if ( is_numeric( $user ) )
1274
-		$user = new WP_User( $user );
1311
+	if ( is_numeric( $user ) ) {
1312
+			$user = new WP_User( $user );
1313
+	}
1275 1314
 
1276
-	if ( ! $user->exists() )
1277
-		return;
1315
+	if ( ! $user->exists() ) {
1316
+			return;
1317
+	}
1278 1318
 
1279 1319
 	wp_cache_delete( $user->ID, 'users' );
1280 1320
 	wp_cache_delete( $user->user_login, 'userlogins' );
@@ -2154,15 +2194,18 @@  discard block
 block discarded – undo
2154 2194
 
2155 2195
 	$key = preg_replace('/[^a-z0-9]/i', '', $key);
2156 2196
 
2157
-	if ( empty( $key ) || !is_string( $key ) )
2158
-		return new WP_Error('invalid_key', __('Invalid key'));
2197
+	if ( empty( $key ) || !is_string( $key ) ) {
2198
+			return new WP_Error('invalid_key', __('Invalid key'));
2199
+	}
2159 2200
 
2160
-	if ( empty($login) || !is_string($login) )
2161
-		return new WP_Error('invalid_key', __('Invalid key'));
2201
+	if ( empty($login) || !is_string($login) ) {
2202
+			return new WP_Error('invalid_key', __('Invalid key'));
2203
+	}
2162 2204
 
2163 2205
 	$row = $wpdb->get_row( $wpdb->prepare( "SELECT ID, user_activation_key FROM $wpdb->users WHERE user_login = %s", $login ) );
2164
-	if ( ! $row )
2165
-		return new WP_Error('invalid_key', __('Invalid key'));
2206
+	if ( ! $row ) {
2207
+			return new WP_Error('invalid_key', __('Invalid key'));
2208
+	}
2166 2209
 
2167 2210
 	if ( empty( $wp_hasher ) ) {
2168 2211
 		$wp_hasher = new PasswordHash( 8, true );
@@ -2332,8 +2375,9 @@  discard block
 block discarded – undo
2332 2375
 	 */
2333 2376
 	$errors = apply_filters( 'registration_errors', $errors, $sanitized_user_login, $user_email );
2334 2377
 
2335
-	if ( $errors->get_error_code() )
2336
-		return $errors;
2378
+	if ( $errors->get_error_code() ) {
2379
+			return $errors;
2380
+	}
2337 2381
 
2338 2382
 	$user_pass = wp_generate_password( 12, false );
2339 2383
 	$user_id = wp_create_user( $sanitized_user_login, $user_pass, $user_email );
Please login to merge, or discard this patch.
src/wp-includes/widgets.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
  *
550 550
  * @global array $wp_registered_widget_controls
551 551
  *
552
- * @param int|string $id            Widget ID.
552
+ * @param boolean|string $id            Widget ID.
553 553
  * @param string     $name          Name attribute for the widget.
554 554
  * @param callable   $form_callback Form callback.
555 555
  * @param array      $options       Optional. Widget control options. See {@see wp_register_widget_control()}.
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
  * @global array $wp_registered_sidebars
608 608
  * @global array $wp_registered_widgets
609 609
  *
610
- * @param int|string $index Optional, default is 1. Index, name or ID of dynamic sidebar.
610
+ * @param integer $index Optional, default is 1. Index, name or ID of dynamic sidebar.
611 611
  * @return bool True, if widget sidebar was found and called. False if not found or not called.
612 612
  */
613 613
 function dynamic_sidebar( $index = 1 ) {
@@ -844,7 +844,7 @@  discard block
 block discarded – undo
844 844
  *
845 845
  * @since 2.8.0
846 846
  *
847
- * @param string|int $index Sidebar name, id or number to check.
847
+ * @param string $index Sidebar name, id or number to check.
848 848
  * @return bool true if the sidebar is in use, false otherwise.
849 849
  */
850 850
 function is_active_sidebar( $index ) {
Please login to merge, or discard this patch.
Spacing   +241 added lines, -241 removed lines patch added patch discarded remove patch
@@ -159,34 +159,34 @@  discard block
 block discarded – undo
159 159
  *                        Default 'Sidebar' for the first sidebar, otherwise 'Sidebar %d'.
160 160
  * }
161 161
  */
162
-function register_sidebars( $number = 1, $args = array() ) {
162
+function register_sidebars($number = 1, $args = array()) {
163 163
 	global $wp_registered_sidebars;
164 164
 	$number = (int) $number;
165 165
 
166
-	if ( is_string($args) )
166
+	if (is_string($args))
167 167
 		parse_str($args, $args);
168 168
 
169
-	for ( $i = 1; $i <= $number; $i++ ) {
169
+	for ($i = 1; $i <= $number; $i++) {
170 170
 		$_args = $args;
171 171
 
172
-		if ( $number > 1 )
172
+		if ($number > 1)
173 173
 			$_args['name'] = isset($args['name']) ? sprintf($args['name'], $i) : sprintf(__('Sidebar %d'), $i);
174 174
 		else
175 175
 			$_args['name'] = isset($args['name']) ? $args['name'] : __('Sidebar');
176 176
 
177 177
 		// Custom specified ID's are suffixed if they exist already.
178 178
 		// Automatically generated sidebar names need to be suffixed regardless starting at -0
179
-		if ( isset($args['id']) ) {
179
+		if (isset($args['id'])) {
180 180
 			$_args['id'] = $args['id'];
181 181
 			$n = 2; // Start at -2 for conflicting custom ID's
182
-			while ( is_registered_sidebar( $_args['id'] ) ) {
183
-				$_args['id'] = $args['id'] . '-' . $n++;
182
+			while (is_registered_sidebar($_args['id'])) {
183
+				$_args['id'] = $args['id'].'-'.$n++;
184 184
 			}
185 185
 		} else {
186
-			$n = count( $wp_registered_sidebars );
186
+			$n = count($wp_registered_sidebars);
187 187
 			do {
188
-				$_args['id'] = 'sidebar-' . ++$n;
189
-			} while ( is_registered_sidebar( $_args['id'] ) );
188
+				$_args['id'] = 'sidebar-'.++$n;
189
+			} while (is_registered_sidebar($_args['id']));
190 190
 		}
191 191
 		register_sidebar($_args);
192 192
 	}
@@ -238,10 +238,10 @@  discard block
 block discarded – undo
238 238
 
239 239
 	$i = count($wp_registered_sidebars) + 1;
240 240
 
241
-	$id_is_empty = empty( $args['id'] );
241
+	$id_is_empty = empty($args['id']);
242 242
 
243 243
 	$defaults = array(
244
-		'name' => sprintf(__('Sidebar %d'), $i ),
244
+		'name' => sprintf(__('Sidebar %d'), $i),
245 245
 		'id' => "sidebar-$i",
246 246
 		'description' => '',
247 247
 		'class' => '',
@@ -251,11 +251,11 @@  discard block
 block discarded – undo
251 251
 		'after_title' => "</h2>\n",
252 252
 	);
253 253
 
254
-	$sidebar = wp_parse_args( $args, $defaults );
254
+	$sidebar = wp_parse_args($args, $defaults);
255 255
 
256
-	if ( $id_is_empty ) {
256
+	if ($id_is_empty) {
257 257
 		/* translators: 1: the id argument, 2: sidebar name, 3: recommended id value */
258
-		_doing_it_wrong( __FUNCTION__, sprintf( __( 'No %1$s was set in the arguments array for the "%2$s" sidebar. Defaulting to "%3$s". Manually set the %1$s to "%3$s" to silence this notice and keep existing sidebar content.' ), '<code>id</code>', $sidebar['name'], $sidebar['id'] ), '4.2.0' );
258
+		_doing_it_wrong(__FUNCTION__, sprintf(__('No %1$s was set in the arguments array for the "%2$s" sidebar. Defaulting to "%3$s". Manually set the %1$s to "%3$s" to silence this notice and keep existing sidebar content.'), '<code>id</code>', $sidebar['name'], $sidebar['id']), '4.2.0');
259 259
 	}
260 260
 
261 261
 	$wp_registered_sidebars[$sidebar['id']] = $sidebar;
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	 *
270 270
 	 * @param array $sidebar Parsed arguments for the registered sidebar.
271 271
 	 */
272
-	do_action( 'register_sidebar', $sidebar );
272
+	do_action('register_sidebar', $sidebar);
273 273
 
274 274
 	return $sidebar['id'];
275 275
 }
@@ -283,10 +283,10 @@  discard block
 block discarded – undo
283 283
  *
284 284
  * @param string $name The ID of the sidebar when it was added.
285 285
  */
286
-function unregister_sidebar( $name ) {
286
+function unregister_sidebar($name) {
287 287
 	global $wp_registered_sidebars;
288 288
 
289
-	unset( $wp_registered_sidebars[ $name ] );
289
+	unset($wp_registered_sidebars[$name]);
290 290
 }
291 291
 
292 292
 /**
@@ -299,10 +299,10 @@  discard block
 block discarded – undo
299 299
  * @param string|int $sidebar_id The ID of the sidebar when it was registered.
300 300
  * @return bool True if the sidebar is registered, false otherwise.
301 301
  */
302
-function is_registered_sidebar( $sidebar_id ) {
302
+function is_registered_sidebar($sidebar_id) {
303 303
 	global $wp_registered_sidebars;
304 304
 
305
-	return isset( $wp_registered_sidebars[ $sidebar_id ] );
305
+	return isset($wp_registered_sidebars[$sidebar_id]);
306 306
 }
307 307
 
308 308
 /**
@@ -332,20 +332,20 @@  discard block
 block discarded – undo
332 332
  *                               panel and/or theme.
333 333
  * }
334 334
  */
335
-function wp_register_sidebar_widget( $id, $name, $output_callback, $options = array() ) {
335
+function wp_register_sidebar_widget($id, $name, $output_callback, $options = array()) {
336 336
 	global $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_widget_updates, $_wp_deprecated_widgets_callbacks;
337 337
 
338 338
 	$id = strtolower($id);
339 339
 
340
-	if ( empty($output_callback) ) {
340
+	if (empty($output_callback)) {
341 341
 		unset($wp_registered_widgets[$id]);
342 342
 		return;
343 343
 	}
344 344
 
345 345
 	$id_base = _get_widget_id_base($id);
346
-	if ( in_array($output_callback, $_wp_deprecated_widgets_callbacks, true) && !is_callable($output_callback) ) {
347
-		unset( $wp_registered_widget_controls[ $id ] );
348
-		unset( $wp_registered_widget_updates[ $id_base ] );
346
+	if (in_array($output_callback, $_wp_deprecated_widgets_callbacks, true) && ! is_callable($output_callback)) {
347
+		unset($wp_registered_widget_controls[$id]);
348
+		unset($wp_registered_widget_updates[$id_base]);
349 349
 		return;
350 350
 	}
351 351
 
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 	);
360 360
 	$widget = array_merge($widget, $options);
361 361
 
362
-	if ( is_callable($output_callback) && ( !isset($wp_registered_widgets[$id]) || did_action( 'widgets_init' ) ) ) {
362
+	if (is_callable($output_callback) && ( ! isset($wp_registered_widgets[$id]) || did_action('widgets_init'))) {
363 363
 
364 364
 		/**
365 365
 		 * Fires once for each registered widget.
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 		 *
369 369
 		 * @param array $widget An array of default widget arguments.
370 370
 		 */
371
-		do_action( 'wp_register_sidebar_widget', $widget );
371
+		do_action('wp_register_sidebar_widget', $widget);
372 372
 		$wp_registered_widgets[$id] = $widget;
373 373
 	}
374 374
 }
@@ -387,14 +387,14 @@  discard block
 block discarded – undo
387 387
  * @param int|string $id Widget ID.
388 388
  * @return string|void Widget description, if available.
389 389
  */
390
-function wp_widget_description( $id ) {
391
-	if ( !is_scalar($id) )
390
+function wp_widget_description($id) {
391
+	if ( ! is_scalar($id))
392 392
 		return;
393 393
 
394 394
 	global $wp_registered_widgets;
395 395
 
396
-	if ( isset($wp_registered_widgets[$id]['description']) )
397
-		return esc_html( $wp_registered_widgets[$id]['description'] );
396
+	if (isset($wp_registered_widgets[$id]['description']))
397
+		return esc_html($wp_registered_widgets[$id]['description']);
398 398
 }
399 399
 
400 400
 /**
@@ -410,14 +410,14 @@  discard block
 block discarded – undo
410 410
  * @param string $id sidebar ID.
411 411
  * @return string|void Sidebar description, if available.
412 412
  */
413
-function wp_sidebar_description( $id ) {
414
-	if ( !is_scalar($id) )
413
+function wp_sidebar_description($id) {
414
+	if ( ! is_scalar($id))
415 415
 		return;
416 416
 
417 417
 	global $wp_registered_sidebars;
418 418
 
419
-	if ( isset($wp_registered_sidebars[$id]['description']) )
420
-		return esc_html( $wp_registered_sidebars[$id]['description'] );
419
+	if (isset($wp_registered_sidebars[$id]['description']))
420
+		return esc_html($wp_registered_sidebars[$id]['description']);
421 421
 }
422 422
 
423 423
 /**
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 	 *
437 437
 	 * @param int $id The widget ID.
438 438
 	 */
439
-	do_action( 'wp_unregister_sidebar_widget', $id );
439
+	do_action('wp_unregister_sidebar_widget', $id);
440 440
 
441 441
 	wp_register_sidebar_widget($id, '', '');
442 442
 	wp_unregister_widget_control($id);
@@ -467,27 +467,27 @@  discard block
 block discarded – undo
467 467
  *                               text widget. The widget id will end up looking like `{$id_base}-{$unique_number}`.
468 468
  * }
469 469
  */
470
-function wp_register_widget_control( $id, $name, $control_callback, $options = array() ) {
470
+function wp_register_widget_control($id, $name, $control_callback, $options = array()) {
471 471
 	global $wp_registered_widget_controls, $wp_registered_widget_updates, $wp_registered_widgets, $_wp_deprecated_widgets_callbacks;
472 472
 
473 473
 	$id = strtolower($id);
474 474
 	$id_base = _get_widget_id_base($id);
475 475
 
476
-	if ( empty($control_callback) ) {
476
+	if (empty($control_callback)) {
477 477
 		unset($wp_registered_widget_controls[$id]);
478 478
 		unset($wp_registered_widget_updates[$id_base]);
479 479
 		return;
480 480
 	}
481 481
 
482
-	if ( in_array($control_callback, $_wp_deprecated_widgets_callbacks, true) && !is_callable($control_callback) ) {
483
-		unset( $wp_registered_widgets[ $id ] );
482
+	if (in_array($control_callback, $_wp_deprecated_widgets_callbacks, true) && ! is_callable($control_callback)) {
483
+		unset($wp_registered_widgets[$id]);
484 484
 		return;
485 485
 	}
486 486
 
487
-	if ( isset($wp_registered_widget_controls[$id]) && !did_action( 'widgets_init' ) )
487
+	if (isset($wp_registered_widget_controls[$id]) && ! did_action('widgets_init'))
488 488
 		return;
489 489
 
490
-	$defaults = array('width' => 250, 'height' => 200 ); // height is never used
490
+	$defaults = array('width' => 250, 'height' => 200); // height is never used
491 491
 	$options = wp_parse_args($options, $defaults);
492 492
 	$options['width'] = (int) $options['width'];
493 493
 	$options['height'] = (int) $options['height'];
@@ -502,10 +502,10 @@  discard block
 block discarded – undo
502 502
 
503 503
 	$wp_registered_widget_controls[$id] = $widget;
504 504
 
505
-	if ( isset($wp_registered_widget_updates[$id_base]) )
505
+	if (isset($wp_registered_widget_updates[$id_base]))
506 506
 		return;
507 507
 
508
-	if ( isset($widget['params'][0]['number']) )
508
+	if (isset($widget['params'][0]['number']))
509 509
 		$widget['params'][0]['number'] = -1;
510 510
 
511 511
 	unset($widget['width'], $widget['height'], $widget['name'], $widget['id']);
@@ -524,11 +524,11 @@  discard block
 block discarded – undo
524 524
  * @param array    $options         Optional. Widget control options. See wp_register_widget_control().
525 525
  *                                  Default empty array.
526 526
  */
527
-function _register_widget_update_callback( $id_base, $update_callback, $options = array() ) {
527
+function _register_widget_update_callback($id_base, $update_callback, $options = array()) {
528 528
 	global $wp_registered_widget_updates;
529 529
 
530
-	if ( isset($wp_registered_widget_updates[$id_base]) ) {
531
-		if ( empty($update_callback) )
530
+	if (isset($wp_registered_widget_updates[$id_base])) {
531
+		if (empty($update_callback))
532 532
 			unset($wp_registered_widget_updates[$id_base]);
533 533
 		return;
534 534
 	}
@@ -560,15 +560,15 @@  discard block
 block discarded – undo
560 560
 
561 561
 	$id = strtolower($id);
562 562
 
563
-	if ( empty($form_callback) ) {
563
+	if (empty($form_callback)) {
564 564
 		unset($wp_registered_widget_controls[$id]);
565 565
 		return;
566 566
 	}
567 567
 
568
-	if ( isset($wp_registered_widget_controls[$id]) && !did_action( 'widgets_init' ) )
568
+	if (isset($wp_registered_widget_controls[$id]) && ! did_action('widgets_init'))
569 569
 		return;
570 570
 
571
-	$defaults = array('width' => 250, 'height' => 200 );
571
+	$defaults = array('width' => 250, 'height' => 200);
572 572
 	$options = wp_parse_args($options, $defaults);
573 573
 	$options['width'] = (int) $options['width'];
574 574
 	$options['height'] = (int) $options['height'];
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
  * @param int|string $id Widget ID.
593 593
  */
594 594
 function wp_unregister_widget_control($id) {
595
-	wp_register_widget_control( $id, '', '' );
595
+	wp_register_widget_control($id, '', '');
596 596
 }
597 597
 
598 598
 /**
@@ -610,15 +610,15 @@  discard block
 block discarded – undo
610 610
  * @param int|string $index Optional, default is 1. Index, name or ID of dynamic sidebar.
611 611
  * @return bool True, if widget sidebar was found and called. False if not found or not called.
612 612
  */
613
-function dynamic_sidebar( $index = 1 ) {
613
+function dynamic_sidebar($index = 1) {
614 614
 	global $wp_registered_sidebars, $wp_registered_widgets;
615 615
 
616
-	if ( is_int( $index ) ) {
616
+	if (is_int($index)) {
617 617
 		$index = "sidebar-$index";
618 618
 	} else {
619
-		$index = sanitize_title( $index );
620
-		foreach ( (array) $wp_registered_sidebars as $key => $value ) {
621
-			if ( sanitize_title( $value['name'] ) == $index ) {
619
+		$index = sanitize_title($index);
620
+		foreach ((array) $wp_registered_sidebars as $key => $value) {
621
+			if (sanitize_title($value['name']) == $index) {
622 622
 				$index = $key;
623 623
 				break;
624 624
 			}
@@ -626,13 +626,13 @@  discard block
 block discarded – undo
626 626
 	}
627 627
 
628 628
 	$sidebars_widgets = wp_get_sidebars_widgets();
629
-	if ( empty( $wp_registered_sidebars[ $index ] ) || empty( $sidebars_widgets[ $index ] ) || ! is_array( $sidebars_widgets[ $index ] ) ) {
629
+	if (empty($wp_registered_sidebars[$index]) || empty($sidebars_widgets[$index]) || ! is_array($sidebars_widgets[$index])) {
630 630
 		/** This action is documented in wp-includes/widget.php */
631
-		do_action( 'dynamic_sidebar_before', $index, false );
631
+		do_action('dynamic_sidebar_before', $index, false);
632 632
 		/** This action is documented in wp-includes/widget.php */
633
-		do_action( 'dynamic_sidebar_after',  $index, false );
633
+		do_action('dynamic_sidebar_after', $index, false);
634 634
 		/** This filter is documented in wp-includes/widget.php */
635
-		return apply_filters( 'dynamic_sidebar_has_widgets', false, $index );
635
+		return apply_filters('dynamic_sidebar_has_widgets', false, $index);
636 636
 	}
637 637
 
638 638
 	/**
@@ -647,26 +647,26 @@  discard block
 block discarded – undo
647 647
 	 * @param bool       $has_widgets Whether the sidebar is populated with widgets.
648 648
 	 *                                Default true.
649 649
 	 */
650
-	do_action( 'dynamic_sidebar_before', $index, true );
650
+	do_action('dynamic_sidebar_before', $index, true);
651 651
 	$sidebar = $wp_registered_sidebars[$index];
652 652
 
653 653
 	$did_one = false;
654
-	foreach ( (array) $sidebars_widgets[$index] as $id ) {
654
+	foreach ((array) $sidebars_widgets[$index] as $id) {
655 655
 
656
-		if ( !isset($wp_registered_widgets[$id]) ) continue;
656
+		if ( ! isset($wp_registered_widgets[$id])) continue;
657 657
 
658 658
 		$params = array_merge(
659
-			array( array_merge( $sidebar, array('widget_id' => $id, 'widget_name' => $wp_registered_widgets[$id]['name']) ) ),
659
+			array(array_merge($sidebar, array('widget_id' => $id, 'widget_name' => $wp_registered_widgets[$id]['name']))),
660 660
 			(array) $wp_registered_widgets[$id]['params']
661 661
 		);
662 662
 
663 663
 		// Substitute HTML id and class attributes into before_widget
664 664
 		$classname_ = '';
665
-		foreach ( (array) $wp_registered_widgets[$id]['classname'] as $cn ) {
666
-			if ( is_string($cn) )
667
-				$classname_ .= '_' . $cn;
668
-			elseif ( is_object($cn) )
669
-				$classname_ .= '_' . get_class($cn);
665
+		foreach ((array) $wp_registered_widgets[$id]['classname'] as $cn) {
666
+			if (is_string($cn))
667
+				$classname_ .= '_'.$cn;
668
+			elseif (is_object($cn))
669
+				$classname_ .= '_'.get_class($cn);
670 670
 		}
671 671
 		$classname_ = ltrim($classname_, '_');
672 672
 		$params[0]['before_widget'] = sprintf($params[0]['before_widget'], $id, $classname_);
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 		 *     }
704 704
 		 * }
705 705
 		 */
706
-		$params = apply_filters( 'dynamic_sidebar_params', $params );
706
+		$params = apply_filters('dynamic_sidebar_params', $params);
707 707
 
708 708
 		$callback = $wp_registered_widgets[$id]['callback'];
709 709
 
@@ -732,9 +732,9 @@  discard block
 block discarded – undo
732 732
 		 *                                       with an array containing the widget object, see $callback.
733 733
 		 * }
734 734
 		 */
735
-		do_action( 'dynamic_sidebar', $wp_registered_widgets[ $id ] );
735
+		do_action('dynamic_sidebar', $wp_registered_widgets[$id]);
736 736
 
737
-		if ( is_callable($callback) ) {
737
+		if (is_callable($callback)) {
738 738
 			call_user_func_array($callback, $params);
739 739
 			$did_one = true;
740 740
 		}
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
 	 * @param bool       $has_widgets Whether the sidebar is populated with widgets.
753 753
 	 *                                Default true.
754 754
 	 */
755
-	do_action( 'dynamic_sidebar_after', $index, true );
755
+	do_action('dynamic_sidebar_after', $index, true);
756 756
 
757 757
 	/**
758 758
 	 * Filters whether a sidebar has widgets.
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
 	 *                            Default false.
767 767
 	 * @param int|string $index   Index, name, or ID of the dynamic sidebar.
768 768
 	 */
769
-	return apply_filters( 'dynamic_sidebar_has_widgets', $did_one, $index );
769
+	return apply_filters('dynamic_sidebar_has_widgets', $did_one, $index);
770 770
 }
771 771
 
772 772
 /**
@@ -792,21 +792,21 @@  discard block
 block discarded – undo
792 792
  * @param bool         $skip_inactive Optional. Whether to check in 'wp_inactive_widgets'. Default true.
793 793
  * @return string|false False if widget is not active or id of sidebar in which the widget is active.
794 794
  */
795
-function is_active_widget( $callback = false, $widget_id = false, $id_base = false, $skip_inactive = true ) {
795
+function is_active_widget($callback = false, $widget_id = false, $id_base = false, $skip_inactive = true) {
796 796
 	global $wp_registered_widgets;
797 797
 
798 798
 	$sidebars_widgets = wp_get_sidebars_widgets();
799 799
 
800
-	if ( is_array($sidebars_widgets) ) {
801
-		foreach ( $sidebars_widgets as $sidebar => $widgets ) {
802
-			if ( $skip_inactive && ( 'wp_inactive_widgets' === $sidebar || 'orphaned_widgets' === substr( $sidebar, 0, 16 ) ) ) {
800
+	if (is_array($sidebars_widgets)) {
801
+		foreach ($sidebars_widgets as $sidebar => $widgets) {
802
+			if ($skip_inactive && ('wp_inactive_widgets' === $sidebar || 'orphaned_widgets' === substr($sidebar, 0, 16))) {
803 803
 				continue;
804 804
 			}
805 805
 
806
-			if ( is_array($widgets) ) {
807
-				foreach ( $widgets as $widget ) {
808
-					if ( ( $callback && isset($wp_registered_widgets[$widget]['callback']) && $wp_registered_widgets[$widget]['callback'] == $callback ) || ( $id_base && _get_widget_id_base($widget) == $id_base ) ) {
809
-						if ( !$widget_id || $widget_id == $wp_registered_widgets[$widget]['id'] )
806
+			if (is_array($widgets)) {
807
+				foreach ($widgets as $widget) {
808
+					if (($callback && isset($wp_registered_widgets[$widget]['callback']) && $wp_registered_widgets[$widget]['callback'] == $callback) || ($id_base && _get_widget_id_base($widget) == $id_base)) {
809
+						if ( ! $widget_id || $widget_id == $wp_registered_widgets[$widget]['id'])
810 810
 							return $sidebar;
811 811
 					}
812 812
 				}
@@ -829,10 +829,10 @@  discard block
 block discarded – undo
829 829
 function is_dynamic_sidebar() {
830 830
 	global $wp_registered_widgets, $wp_registered_sidebars;
831 831
 	$sidebars_widgets = get_option('sidebars_widgets');
832
-	foreach ( (array) $wp_registered_sidebars as $index => $sidebar ) {
833
-		if ( ! empty( $sidebars_widgets[ $index ] ) ) {
834
-			foreach ( (array) $sidebars_widgets[$index] as $widget )
835
-				if ( array_key_exists($widget, $wp_registered_widgets) )
832
+	foreach ((array) $wp_registered_sidebars as $index => $sidebar) {
833
+		if ( ! empty($sidebars_widgets[$index])) {
834
+			foreach ((array) $sidebars_widgets[$index] as $widget)
835
+				if (array_key_exists($widget, $wp_registered_widgets))
836 836
 					return true;
837 837
 		}
838 838
 	}
@@ -847,10 +847,10 @@  discard block
 block discarded – undo
847 847
  * @param string|int $index Sidebar name, id or number to check.
848 848
  * @return bool true if the sidebar is in use, false otherwise.
849 849
  */
850
-function is_active_sidebar( $index ) {
851
-	$index = ( is_int($index) ) ? "sidebar-$index" : sanitize_title($index);
850
+function is_active_sidebar($index) {
851
+	$index = (is_int($index)) ? "sidebar-$index" : sanitize_title($index);
852 852
 	$sidebars_widgets = wp_get_sidebars_widgets();
853
-	$is_active_sidebar = ! empty( $sidebars_widgets[$index] );
853
+	$is_active_sidebar = ! empty($sidebars_widgets[$index]);
854 854
 
855 855
 	/**
856 856
 	 * Filters whether a dynamic sidebar is considered "active".
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
 	 *                                      In other words, whether the sidebar contains any widgets.
862 862
 	 * @param int|string $index             Index, name, or ID of the dynamic sidebar.
863 863
 	 */
864
-	return apply_filters( 'is_active_sidebar', $is_active_sidebar, $index );
864
+	return apply_filters('is_active_sidebar', $is_active_sidebar, $index);
865 865
 }
866 866
 
867 867
 //
@@ -883,16 +883,16 @@  discard block
 block discarded – undo
883 883
  * @param bool $deprecated Not used (argument deprecated).
884 884
  * @return array Upgraded list of widgets to version 3 array format when called from the admin.
885 885
  */
886
-function wp_get_sidebars_widgets( $deprecated = true ) {
887
-	if ( $deprecated !== true )
888
-		_deprecated_argument( __FUNCTION__, '2.8.1' );
886
+function wp_get_sidebars_widgets($deprecated = true) {
887
+	if ($deprecated !== true)
888
+		_deprecated_argument(__FUNCTION__, '2.8.1');
889 889
 
890 890
 	global $_wp_sidebars_widgets, $sidebars_widgets;
891 891
 
892 892
 	// If loading from front page, consult $_wp_sidebars_widgets rather than options
893 893
 	// to see if wp_convert_widget_settings() has made manipulations in memory.
894
-	if ( !is_admin() ) {
895
-		if ( empty($_wp_sidebars_widgets) )
894
+	if ( ! is_admin()) {
895
+		if (empty($_wp_sidebars_widgets))
896 896
 			$_wp_sidebars_widgets = get_option('sidebars_widgets', array());
897 897
 
898 898
 		$sidebars_widgets = $_wp_sidebars_widgets;
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
 		$sidebars_widgets = get_option('sidebars_widgets', array());
901 901
 	}
902 902
 
903
-	if ( is_array( $sidebars_widgets ) && isset($sidebars_widgets['array_version']) )
903
+	if (is_array($sidebars_widgets) && isset($sidebars_widgets['array_version']))
904 904
 		unset($sidebars_widgets['array_version']);
905 905
 
906 906
 	/**
@@ -910,7 +910,7 @@  discard block
 block discarded – undo
910 910
 	 *
911 911
 	 * @param array $sidebars_widgets An associative array of sidebars and their widgets.
912 912
 	 */
913
-	return apply_filters( 'sidebars_widgets', $sidebars_widgets );
913
+	return apply_filters('sidebars_widgets', $sidebars_widgets);
914 914
 }
915 915
 
916 916
 /**
@@ -921,10 +921,10 @@  discard block
 block discarded – undo
921 921
  *
922 922
  * @param array $sidebars_widgets Sidebar widgets and their settings.
923 923
  */
924
-function wp_set_sidebars_widgets( $sidebars_widgets ) {
925
-	if ( !isset( $sidebars_widgets['array_version'] ) )
924
+function wp_set_sidebars_widgets($sidebars_widgets) {
925
+	if ( ! isset($sidebars_widgets['array_version']))
926 926
 		$sidebars_widgets['array_version'] = 3;
927
-	update_option( 'sidebars_widgets', $sidebars_widgets );
927
+	update_option('sidebars_widgets', $sidebars_widgets);
928 928
 }
929 929
 
930 930
 /**
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
 
943 943
 	$defaults = array();
944 944
 
945
-	foreach ( (array) $wp_registered_sidebars as $index => $sidebar )
945
+	foreach ((array) $wp_registered_sidebars as $index => $sidebar)
946 946
 		$defaults[$index] = array();
947 947
 
948 948
 	return $defaults;
@@ -963,35 +963,35 @@  discard block
 block discarded – undo
963 963
 function wp_convert_widget_settings($base_name, $option_name, $settings) {
964 964
 	// This test may need expanding.
965 965
 	$single = $changed = false;
966
-	if ( empty($settings) ) {
966
+	if (empty($settings)) {
967 967
 		$single = true;
968 968
 	} else {
969
-		foreach ( array_keys($settings) as $number ) {
970
-			if ( 'number' == $number )
969
+		foreach (array_keys($settings) as $number) {
970
+			if ('number' == $number)
971 971
 				continue;
972
-			if ( !is_numeric($number) ) {
972
+			if ( ! is_numeric($number)) {
973 973
 				$single = true;
974 974
 				break;
975 975
 			}
976 976
 		}
977 977
 	}
978 978
 
979
-	if ( $single ) {
980
-		$settings = array( 2 => $settings );
979
+	if ($single) {
980
+		$settings = array(2 => $settings);
981 981
 
982 982
 		// If loading from the front page, update sidebar in memory but don't save to options
983
-		if ( is_admin() ) {
983
+		if (is_admin()) {
984 984
 			$sidebars_widgets = get_option('sidebars_widgets');
985 985
 		} else {
986
-			if ( empty($GLOBALS['_wp_sidebars_widgets']) )
986
+			if (empty($GLOBALS['_wp_sidebars_widgets']))
987 987
 				$GLOBALS['_wp_sidebars_widgets'] = get_option('sidebars_widgets', array());
988 988
 			$sidebars_widgets = &$GLOBALS['_wp_sidebars_widgets'];
989 989
 		}
990 990
 
991
-		foreach ( (array) $sidebars_widgets as $index => $sidebar ) {
992
-			if ( is_array($sidebar) ) {
993
-				foreach ( $sidebar as $i => $name ) {
994
-					if ( $base_name == $name ) {
991
+		foreach ((array) $sidebars_widgets as $index => $sidebar) {
992
+			if (is_array($sidebar)) {
993
+				foreach ($sidebar as $i => $name) {
994
+					if ($base_name == $name) {
995 995
 						$sidebars_widgets[$index][$i] = "$name-2";
996 996
 						$changed = true;
997 997
 						break 2;
@@ -1000,13 +1000,13 @@  discard block
 block discarded – undo
1000 1000
 			}
1001 1001
 		}
1002 1002
 
1003
-		if ( is_admin() && $changed )
1003
+		if (is_admin() && $changed)
1004 1004
 			update_option('sidebars_widgets', $sidebars_widgets);
1005 1005
 	}
1006 1006
 
1007 1007
 	$settings['_multiwidget'] = 1;
1008
-	if ( is_admin() )
1009
-		update_option( $option_name, $settings );
1008
+	if (is_admin())
1009
+		update_option($option_name, $settings);
1010 1010
 
1011 1011
 	return $settings;
1012 1012
 }
@@ -1033,11 +1033,11 @@  discard block
 block discarded – undo
1033 1033
  *                                 Default `</h2>`.
1034 1034
  * }
1035 1035
  */
1036
-function the_widget( $widget, $instance = array(), $args = array() ) {
1036
+function the_widget($widget, $instance = array(), $args = array()) {
1037 1037
 	global $wp_widget_factory;
1038 1038
 
1039 1039
 	$widget_obj = $wp_widget_factory->widgets[$widget];
1040
-	if ( ! ( $widget_obj instanceof WP_Widget ) ) {
1040
+	if ( ! ($widget_obj instanceof WP_Widget)) {
1041 1041
 		return;
1042 1042
 	}
1043 1043
 
@@ -1047,8 +1047,8 @@  discard block
 block discarded – undo
1047 1047
 		'before_title'  => '<h2 class="widgettitle">',
1048 1048
 		'after_title'   => '</h2>',
1049 1049
 	);
1050
-	$args = wp_parse_args( $args, $default_args );
1051
-	$args['before_widget'] = sprintf( $args['before_widget'], $widget_obj->widget_options['classname'] );
1050
+	$args = wp_parse_args($args, $default_args);
1051
+	$args['before_widget'] = sprintf($args['before_widget'], $widget_obj->widget_options['classname']);
1052 1052
 
1053 1053
 	$instance = wp_parse_args($instance);
1054 1054
 
@@ -1061,7 +1061,7 @@  discard block
 block discarded – undo
1061 1061
 	 * @param array  $instance The current widget instance's settings.
1062 1062
 	 * @param array  $args     An array of the widget's sidebar arguments.
1063 1063
 	 */
1064
-	do_action( 'the_widget', $widget, $instance, $args );
1064
+	do_action('the_widget', $widget, $instance, $args);
1065 1065
 
1066 1066
 	$widget_obj->_set(-1);
1067 1067
 	$widget_obj->widget($args, $instance);
@@ -1075,8 +1075,8 @@  discard block
 block discarded – undo
1075 1075
  * @param string $id Widget ID.
1076 1076
  * @return string Widget ID base.
1077 1077
  */
1078
-function _get_widget_id_base( $id ) {
1079
-	return preg_replace( '/-[0-9]+$/', '', $id );
1078
+function _get_widget_id_base($id) {
1079
+	return preg_replace('/-[0-9]+$/', '', $id);
1080 1080
 }
1081 1081
 
1082 1082
 /**
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
 function _wp_sidebars_changed() {
1091 1091
 	global $sidebars_widgets;
1092 1092
 
1093
-	if ( ! is_array( $sidebars_widgets ) )
1093
+	if ( ! is_array($sidebars_widgets))
1094 1094
 		$sidebars_widgets = wp_get_sidebars_widgets();
1095 1095
 
1096 1096
 	retrieve_widgets(true);
@@ -1109,78 +1109,78 @@  discard block
 block discarded – undo
1109 1109
  *                                   of 'customize' defers updates for the Customizer.
1110 1110
  * @return array|void
1111 1111
  */
1112
-function retrieve_widgets( $theme_changed = false ) {
1112
+function retrieve_widgets($theme_changed = false) {
1113 1113
 	global $wp_registered_sidebars, $sidebars_widgets, $wp_registered_widgets;
1114 1114
 
1115
-	$registered_sidebar_keys = array_keys( $wp_registered_sidebars );
1115
+	$registered_sidebar_keys = array_keys($wp_registered_sidebars);
1116 1116
 	$orphaned = 0;
1117 1117
 
1118
-	$old_sidebars_widgets = get_theme_mod( 'sidebars_widgets' );
1119
-	if ( is_array( $old_sidebars_widgets ) ) {
1118
+	$old_sidebars_widgets = get_theme_mod('sidebars_widgets');
1119
+	if (is_array($old_sidebars_widgets)) {
1120 1120
 		// time() that sidebars were stored is in $old_sidebars_widgets['time']
1121 1121
 		$_sidebars_widgets = $old_sidebars_widgets['data'];
1122 1122
 
1123
-		if ( 'customize' !== $theme_changed ) {
1124
-			remove_theme_mod( 'sidebars_widgets' );
1123
+		if ('customize' !== $theme_changed) {
1124
+			remove_theme_mod('sidebars_widgets');
1125 1125
 		}
1126 1126
 
1127
-		foreach ( $_sidebars_widgets as $sidebar => $widgets ) {
1128
-			if ( 'wp_inactive_widgets' === $sidebar || 'orphaned_widgets' === substr( $sidebar, 0, 16 ) ) {
1127
+		foreach ($_sidebars_widgets as $sidebar => $widgets) {
1128
+			if ('wp_inactive_widgets' === $sidebar || 'orphaned_widgets' === substr($sidebar, 0, 16)) {
1129 1129
 				continue;
1130 1130
 			}
1131 1131
 
1132
-			if ( !in_array( $sidebar, $registered_sidebar_keys ) ) {
1133
-				$_sidebars_widgets['orphaned_widgets_' . ++$orphaned] = $widgets;
1134
-				unset( $_sidebars_widgets[$sidebar] );
1132
+			if ( ! in_array($sidebar, $registered_sidebar_keys)) {
1133
+				$_sidebars_widgets['orphaned_widgets_'.++$orphaned] = $widgets;
1134
+				unset($_sidebars_widgets[$sidebar]);
1135 1135
 			}
1136 1136
 		}
1137 1137
 	} else {
1138
-		if ( empty( $sidebars_widgets ) )
1138
+		if (empty($sidebars_widgets))
1139 1139
 			return;
1140 1140
 
1141
-		unset( $sidebars_widgets['array_version'] );
1141
+		unset($sidebars_widgets['array_version']);
1142 1142
 
1143 1143
 		$old = array_keys($sidebars_widgets);
1144 1144
 		sort($old);
1145 1145
 		sort($registered_sidebar_keys);
1146 1146
 
1147
-		if ( $old == $registered_sidebar_keys )
1147
+		if ($old == $registered_sidebar_keys)
1148 1148
 			return;
1149 1149
 
1150 1150
 		$_sidebars_widgets = array(
1151
-			'wp_inactive_widgets' => !empty( $sidebars_widgets['wp_inactive_widgets'] ) ? $sidebars_widgets['wp_inactive_widgets'] : array()
1151
+			'wp_inactive_widgets' => ! empty($sidebars_widgets['wp_inactive_widgets']) ? $sidebars_widgets['wp_inactive_widgets'] : array()
1152 1152
 		);
1153 1153
 
1154
-		unset( $sidebars_widgets['wp_inactive_widgets'] );
1154
+		unset($sidebars_widgets['wp_inactive_widgets']);
1155 1155
 
1156
-		foreach ( $wp_registered_sidebars as $id => $settings ) {
1157
-			if ( $theme_changed ) {
1158
-				$_sidebars_widgets[$id] = array_shift( $sidebars_widgets );
1156
+		foreach ($wp_registered_sidebars as $id => $settings) {
1157
+			if ($theme_changed) {
1158
+				$_sidebars_widgets[$id] = array_shift($sidebars_widgets);
1159 1159
 			} else {
1160 1160
 				// no theme change, grab only sidebars that are currently registered
1161
-				if ( isset( $sidebars_widgets[$id] ) ) {
1161
+				if (isset($sidebars_widgets[$id])) {
1162 1162
 					$_sidebars_widgets[$id] = $sidebars_widgets[$id];
1163
-					unset( $sidebars_widgets[$id] );
1163
+					unset($sidebars_widgets[$id]);
1164 1164
 				}
1165 1165
 			}
1166 1166
 		}
1167 1167
 
1168
-		foreach ( $sidebars_widgets as $val ) {
1169
-			if ( is_array($val) && ! empty( $val ) )
1170
-				$_sidebars_widgets['orphaned_widgets_' . ++$orphaned] = $val;
1168
+		foreach ($sidebars_widgets as $val) {
1169
+			if (is_array($val) && ! empty($val))
1170
+				$_sidebars_widgets['orphaned_widgets_'.++$orphaned] = $val;
1171 1171
 		}
1172 1172
 	}
1173 1173
 
1174 1174
 	// discard invalid, theme-specific widgets from sidebars
1175 1175
 	$shown_widgets = array();
1176 1176
 
1177
-	foreach ( $_sidebars_widgets as $sidebar => $widgets ) {
1178
-		if ( !is_array($widgets) )
1177
+	foreach ($_sidebars_widgets as $sidebar => $widgets) {
1178
+		if ( ! is_array($widgets))
1179 1179
 			continue;
1180 1180
 
1181 1181
 		$_widgets = array();
1182
-		foreach ( $widgets as $widget ) {
1183
-			if ( isset($wp_registered_widgets[$widget]) )
1182
+		foreach ($widgets as $widget) {
1183
+			if (isset($wp_registered_widgets[$widget]))
1184 1184
 				$_widgets[] = $widget;
1185 1185
 		}
1186 1186
 
@@ -1193,21 +1193,21 @@  discard block
 block discarded – undo
1193 1193
 
1194 1194
 	// find hidden/lost multi-widget instances
1195 1195
 	$lost_widgets = array();
1196
-	foreach ( $wp_registered_widgets as $key => $val ) {
1197
-		if ( in_array($key, $shown_widgets, true) )
1196
+	foreach ($wp_registered_widgets as $key => $val) {
1197
+		if (in_array($key, $shown_widgets, true))
1198 1198
 			continue;
1199 1199
 
1200 1200
 		$number = preg_replace('/.+?-([0-9]+)$/', '$1', $key);
1201 1201
 
1202
-		if ( 2 > (int) $number )
1202
+		if (2 > (int) $number)
1203 1203
 			continue;
1204 1204
 
1205 1205
 		$lost_widgets[] = $key;
1206 1206
 	}
1207 1207
 
1208 1208
 	$sidebars_widgets['wp_inactive_widgets'] = array_merge($lost_widgets, (array) $sidebars_widgets['wp_inactive_widgets']);
1209
-	if ( 'customize' !== $theme_changed ) {
1210
-		wp_set_sidebars_widgets( $sidebars_widgets );
1209
+	if ('customize' !== $theme_changed) {
1210
+		wp_set_sidebars_widgets($sidebars_widgets);
1211 1211
 	}
1212 1212
 
1213 1213
 	return $sidebars_widgets;
@@ -1221,88 +1221,88 @@  discard block
 block discarded – undo
1221 1221
  * @param string|array|object $rss RSS url.
1222 1222
  * @param array $args Widget arguments.
1223 1223
  */
1224
-function wp_widget_rss_output( $rss, $args = array() ) {
1225
-	if ( is_string( $rss ) ) {
1224
+function wp_widget_rss_output($rss, $args = array()) {
1225
+	if (is_string($rss)) {
1226 1226
 		$rss = fetch_feed($rss);
1227
-	} elseif ( is_array($rss) && isset($rss['url']) ) {
1227
+	} elseif (is_array($rss) && isset($rss['url'])) {
1228 1228
 		$args = $rss;
1229 1229
 		$rss = fetch_feed($rss['url']);
1230
-	} elseif ( !is_object($rss) ) {
1230
+	} elseif ( ! is_object($rss)) {
1231 1231
 		return;
1232 1232
 	}
1233 1233
 
1234
-	if ( is_wp_error($rss) ) {
1235
-		if ( is_admin() || current_user_can('manage_options') )
1236
-			echo '<p><strong>' . __( 'RSS Error:' ) . '</strong> ' . $rss->get_error_message() . '</p>';
1234
+	if (is_wp_error($rss)) {
1235
+		if (is_admin() || current_user_can('manage_options'))
1236
+			echo '<p><strong>'.__('RSS Error:').'</strong> '.$rss->get_error_message().'</p>';
1237 1237
 		return;
1238 1238
 	}
1239 1239
 
1240
-	$default_args = array( 'show_author' => 0, 'show_date' => 0, 'show_summary' => 0, 'items' => 0 );
1241
-	$args = wp_parse_args( $args, $default_args );
1240
+	$default_args = array('show_author' => 0, 'show_date' => 0, 'show_summary' => 0, 'items' => 0);
1241
+	$args = wp_parse_args($args, $default_args);
1242 1242
 
1243 1243
 	$items = (int) $args['items'];
1244
-	if ( $items < 1 || 20 < $items )
1244
+	if ($items < 1 || 20 < $items)
1245 1245
 		$items = 10;
1246 1246
 	$show_summary  = (int) $args['show_summary'];
1247 1247
 	$show_author   = (int) $args['show_author'];
1248 1248
 	$show_date     = (int) $args['show_date'];
1249 1249
 
1250
-	if ( !$rss->get_item_quantity() ) {
1251
-		echo '<ul><li>' . __( 'An error has occurred, which probably means the feed is down. Try again later.' ) . '</li></ul>';
1250
+	if ( ! $rss->get_item_quantity()) {
1251
+		echo '<ul><li>'.__('An error has occurred, which probably means the feed is down. Try again later.').'</li></ul>';
1252 1252
 		$rss->__destruct();
1253 1253
 		unset($rss);
1254 1254
 		return;
1255 1255
 	}
1256 1256
 
1257 1257
 	echo '<ul>';
1258
-	foreach ( $rss->get_items( 0, $items ) as $item ) {
1258
+	foreach ($rss->get_items(0, $items) as $item) {
1259 1259
 		$link = $item->get_link();
1260
-		while ( stristr( $link, 'http' ) != $link ) {
1261
-			$link = substr( $link, 1 );
1260
+		while (stristr($link, 'http') != $link) {
1261
+			$link = substr($link, 1);
1262 1262
 		}
1263
-		$link = esc_url( strip_tags( $link ) );
1263
+		$link = esc_url(strip_tags($link));
1264 1264
 
1265
-		$title = esc_html( trim( strip_tags( $item->get_title() ) ) );
1266
-		if ( empty( $title ) ) {
1267
-			$title = __( 'Untitled' );
1265
+		$title = esc_html(trim(strip_tags($item->get_title())));
1266
+		if (empty($title)) {
1267
+			$title = __('Untitled');
1268 1268
 		}
1269 1269
 
1270
-		$desc = @html_entity_decode( $item->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) );
1271
-		$desc = esc_attr( wp_trim_words( $desc, 55, ' [&hellip;]' ) );
1270
+		$desc = @html_entity_decode($item->get_description(), ENT_QUOTES, get_option('blog_charset'));
1271
+		$desc = esc_attr(wp_trim_words($desc, 55, ' [&hellip;]'));
1272 1272
 
1273 1273
 		$summary = '';
1274
-		if ( $show_summary ) {
1274
+		if ($show_summary) {
1275 1275
 			$summary = $desc;
1276 1276
 
1277 1277
 			// Change existing [...] to [&hellip;].
1278
-			if ( '[...]' == substr( $summary, -5 ) ) {
1279
-				$summary = substr( $summary, 0, -5 ) . '[&hellip;]';
1278
+			if ('[...]' == substr($summary, -5)) {
1279
+				$summary = substr($summary, 0, -5).'[&hellip;]';
1280 1280
 			}
1281 1281
 
1282
-			$summary = '<div class="rssSummary">' . esc_html( $summary ) . '</div>';
1282
+			$summary = '<div class="rssSummary">'.esc_html($summary).'</div>';
1283 1283
 		}
1284 1284
 
1285 1285
 		$date = '';
1286
-		if ( $show_date ) {
1287
-			$date = $item->get_date( 'U' );
1286
+		if ($show_date) {
1287
+			$date = $item->get_date('U');
1288 1288
 
1289
-			if ( $date ) {
1290
-				$date = ' <span class="rss-date">' . date_i18n( get_option( 'date_format' ), $date ) . '</span>';
1289
+			if ($date) {
1290
+				$date = ' <span class="rss-date">'.date_i18n(get_option('date_format'), $date).'</span>';
1291 1291
 			}
1292 1292
 		}
1293 1293
 
1294 1294
 		$author = '';
1295
-		if ( $show_author ) {
1295
+		if ($show_author) {
1296 1296
 			$author = $item->get_author();
1297
-			if ( is_object($author) ) {
1297
+			if (is_object($author)) {
1298 1298
 				$author = $author->get_name();
1299
-				$author = ' <cite>' . esc_html( strip_tags( $author ) ) . '</cite>';
1299
+				$author = ' <cite>'.esc_html(strip_tags($author)).'</cite>';
1300 1300
 			}
1301 1301
 		}
1302 1302
 
1303
-		if ( $link == '' ) {
1303
+		if ($link == '') {
1304 1304
 			echo "<li>$title{$date}{$summary}{$author}</li>";
1305
-		} elseif ( $show_summary ) {
1305
+		} elseif ($show_summary) {
1306 1306
 			echo "<li><a class='rsswidget' href='$link'>$title</a>{$date}{$summary}{$author}</li>";
1307 1307
 		} else {
1308 1308
 			echo "<li><a class='rsswidget' href='$link'>$title</a>{$date}{$author}</li>";
@@ -1325,59 +1325,59 @@  discard block
 block discarded – undo
1325 1325
  * @param array|string $args Values for input fields.
1326 1326
  * @param array $inputs Override default display options.
1327 1327
  */
1328
-function wp_widget_rss_form( $args, $inputs = null ) {
1329
-	$default_inputs = array( 'url' => true, 'title' => true, 'items' => true, 'show_summary' => true, 'show_author' => true, 'show_date' => true );
1330
-	$inputs = wp_parse_args( $inputs, $default_inputs );
1328
+function wp_widget_rss_form($args, $inputs = null) {
1329
+	$default_inputs = array('url' => true, 'title' => true, 'items' => true, 'show_summary' => true, 'show_author' => true, 'show_date' => true);
1330
+	$inputs = wp_parse_args($inputs, $default_inputs);
1331 1331
 
1332
-	$args['title'] = isset( $args['title'] ) ? $args['title'] : '';
1333
-	$args['url'] = isset( $args['url'] ) ? $args['url'] : '';
1334
-	$args['items'] = isset( $args['items'] ) ? (int) $args['items'] : 0;
1332
+	$args['title'] = isset($args['title']) ? $args['title'] : '';
1333
+	$args['url'] = isset($args['url']) ? $args['url'] : '';
1334
+	$args['items'] = isset($args['items']) ? (int) $args['items'] : 0;
1335 1335
 
1336
-	if ( $args['items'] < 1 || 20 < $args['items'] ) {
1336
+	if ($args['items'] < 1 || 20 < $args['items']) {
1337 1337
 		$args['items'] = 10;
1338 1338
 	}
1339 1339
 
1340
-	$args['show_summary']   = isset( $args['show_summary'] ) ? (int) $args['show_summary'] : (int) $inputs['show_summary'];
1341
-	$args['show_author']    = isset( $args['show_author'] ) ? (int) $args['show_author'] : (int) $inputs['show_author'];
1342
-	$args['show_date']      = isset( $args['show_date'] ) ? (int) $args['show_date'] : (int) $inputs['show_date'];
1340
+	$args['show_summary']   = isset($args['show_summary']) ? (int) $args['show_summary'] : (int) $inputs['show_summary'];
1341
+	$args['show_author']    = isset($args['show_author']) ? (int) $args['show_author'] : (int) $inputs['show_author'];
1342
+	$args['show_date']      = isset($args['show_date']) ? (int) $args['show_date'] : (int) $inputs['show_date'];
1343 1343
 
1344
-	if ( ! empty( $args['error'] ) ) {
1345
-		echo '<p class="widget-error"><strong>' . __( 'RSS Error:' ) . '</strong> ' . $args['error'] . '</p>';
1344
+	if ( ! empty($args['error'])) {
1345
+		echo '<p class="widget-error"><strong>'.__('RSS Error:').'</strong> '.$args['error'].'</p>';
1346 1346
 	}
1347 1347
 
1348
-	$esc_number = esc_attr( $args['number'] );
1349
-	if ( $inputs['url'] ) :
1348
+	$esc_number = esc_attr($args['number']);
1349
+	if ($inputs['url']) :
1350 1350
 ?>
1351
-	<p><label for="rss-url-<?php echo $esc_number; ?>"><?php _e( 'Enter the RSS feed URL here:' ); ?></label>
1352
-	<input class="widefat" id="rss-url-<?php echo $esc_number; ?>" name="widget-rss[<?php echo $esc_number; ?>][url]" type="text" value="<?php echo esc_url( $args['url'] ); ?>" /></p>
1353
-<?php endif; if ( $inputs['title'] ) : ?>
1354
-	<p><label for="rss-title-<?php echo $esc_number; ?>"><?php _e( 'Give the feed a title (optional):' ); ?></label>
1355
-	<input class="widefat" id="rss-title-<?php echo $esc_number; ?>" name="widget-rss[<?php echo $esc_number; ?>][title]" type="text" value="<?php echo esc_attr( $args['title'] ); ?>" /></p>
1356
-<?php endif; if ( $inputs['items'] ) : ?>
1357
-	<p><label for="rss-items-<?php echo $esc_number; ?>"><?php _e( 'How many items would you like to display?' ); ?></label>
1351
+	<p><label for="rss-url-<?php echo $esc_number; ?>"><?php _e('Enter the RSS feed URL here:'); ?></label>
1352
+	<input class="widefat" id="rss-url-<?php echo $esc_number; ?>" name="widget-rss[<?php echo $esc_number; ?>][url]" type="text" value="<?php echo esc_url($args['url']); ?>" /></p>
1353
+<?php endif; if ($inputs['title']) : ?>
1354
+	<p><label for="rss-title-<?php echo $esc_number; ?>"><?php _e('Give the feed a title (optional):'); ?></label>
1355
+	<input class="widefat" id="rss-title-<?php echo $esc_number; ?>" name="widget-rss[<?php echo $esc_number; ?>][title]" type="text" value="<?php echo esc_attr($args['title']); ?>" /></p>
1356
+<?php endif; if ($inputs['items']) : ?>
1357
+	<p><label for="rss-items-<?php echo $esc_number; ?>"><?php _e('How many items would you like to display?'); ?></label>
1358 1358
 	<select id="rss-items-<?php echo $esc_number; ?>" name="widget-rss[<?php echo $esc_number; ?>][items]">
1359 1359
 	<?php
1360
-	for ( $i = 1; $i <= 20; ++$i ) {
1361
-		echo "<option value='$i' " . selected( $args['items'], $i, false ) . ">$i</option>";
1360
+	for ($i = 1; $i <= 20; ++$i) {
1361
+		echo "<option value='$i' ".selected($args['items'], $i, false).">$i</option>";
1362 1362
 	}
1363 1363
 	?>
1364 1364
 	</select></p>
1365
-<?php endif; if ( $inputs['show_summary'] ) : ?>
1366
-	<p><input id="rss-show-summary-<?php echo $esc_number; ?>" name="widget-rss[<?php echo $esc_number; ?>][show_summary]" type="checkbox" value="1" <?php checked( $args['show_summary'] ); ?> />
1367
-	<label for="rss-show-summary-<?php echo $esc_number; ?>"><?php _e( 'Display item content?' ); ?></label></p>
1368
-<?php endif; if ( $inputs['show_author'] ) : ?>
1369
-	<p><input id="rss-show-author-<?php echo $esc_number; ?>" name="widget-rss[<?php echo $esc_number; ?>][show_author]" type="checkbox" value="1" <?php checked( $args['show_author'] ); ?> />
1370
-	<label for="rss-show-author-<?php echo $esc_number; ?>"><?php _e( 'Display item author if available?' ); ?></label></p>
1371
-<?php endif; if ( $inputs['show_date'] ) : ?>
1372
-	<p><input id="rss-show-date-<?php echo $esc_number; ?>" name="widget-rss[<?php echo $esc_number; ?>][show_date]" type="checkbox" value="1" <?php checked( $args['show_date'] ); ?>/>
1373
-	<label for="rss-show-date-<?php echo $esc_number; ?>"><?php _e( 'Display item date?' ); ?></label></p>
1365
+<?php endif; if ($inputs['show_summary']) : ?>
1366
+	<p><input id="rss-show-summary-<?php echo $esc_number; ?>" name="widget-rss[<?php echo $esc_number; ?>][show_summary]" type="checkbox" value="1" <?php checked($args['show_summary']); ?> />
1367
+	<label for="rss-show-summary-<?php echo $esc_number; ?>"><?php _e('Display item content?'); ?></label></p>
1368
+<?php endif; if ($inputs['show_author']) : ?>
1369
+	<p><input id="rss-show-author-<?php echo $esc_number; ?>" name="widget-rss[<?php echo $esc_number; ?>][show_author]" type="checkbox" value="1" <?php checked($args['show_author']); ?> />
1370
+	<label for="rss-show-author-<?php echo $esc_number; ?>"><?php _e('Display item author if available?'); ?></label></p>
1371
+<?php endif; if ($inputs['show_date']) : ?>
1372
+	<p><input id="rss-show-date-<?php echo $esc_number; ?>" name="widget-rss[<?php echo $esc_number; ?>][show_date]" type="checkbox" value="1" <?php checked($args['show_date']); ?>/>
1373
+	<label for="rss-show-date-<?php echo $esc_number; ?>"><?php _e('Display item date?'); ?></label></p>
1374 1374
 <?php
1375 1375
 	endif;
1376
-	foreach ( array_keys($default_inputs) as $input ) :
1377
-		if ( 'hidden' === $inputs[$input] ) :
1378
-			$id = str_replace( '_', '-', $input );
1376
+	foreach (array_keys($default_inputs) as $input) :
1377
+		if ('hidden' === $inputs[$input]) :
1378
+			$id = str_replace('_', '-', $input);
1379 1379
 ?>
1380
-	<input type="hidden" id="rss-<?php echo esc_attr( $id ); ?>-<?php echo $esc_number; ?>" name="widget-rss[<?php echo $esc_number; ?>][<?php echo esc_attr( $input ); ?>]" value="<?php echo esc_attr( $args[ $input ] ); ?>" />
1380
+	<input type="hidden" id="rss-<?php echo esc_attr($id); ?>-<?php echo $esc_number; ?>" name="widget-rss[<?php echo $esc_number; ?>][<?php echo esc_attr($input); ?>]" value="<?php echo esc_attr($args[$input]); ?>" />
1381 1381
 <?php
1382 1382
 		endif;
1383 1383
 	endforeach;
@@ -1399,25 +1399,25 @@  discard block
 block discarded – undo
1399 1399
  * @param bool $check_feed Optional, default is true. Whether to check feed for errors.
1400 1400
  * @return array
1401 1401
  */
1402
-function wp_widget_rss_process( $widget_rss, $check_feed = true ) {
1402
+function wp_widget_rss_process($widget_rss, $check_feed = true) {
1403 1403
 	$items = (int) $widget_rss['items'];
1404
-	if ( $items < 1 || 20 < $items )
1404
+	if ($items < 1 || 20 < $items)
1405 1405
 		$items = 10;
1406
-	$url           = esc_url_raw( strip_tags( $widget_rss['url'] ) );
1407
-	$title         = isset( $widget_rss['title'] ) ? trim( strip_tags( $widget_rss['title'] ) ) : '';
1408
-	$show_summary  = isset( $widget_rss['show_summary'] ) ? (int) $widget_rss['show_summary'] : 0;
1409
-	$show_author   = isset( $widget_rss['show_author'] ) ? (int) $widget_rss['show_author'] :0;
1410
-	$show_date     = isset( $widget_rss['show_date'] ) ? (int) $widget_rss['show_date'] : 0;
1406
+	$url           = esc_url_raw(strip_tags($widget_rss['url']));
1407
+	$title         = isset($widget_rss['title']) ? trim(strip_tags($widget_rss['title'])) : '';
1408
+	$show_summary  = isset($widget_rss['show_summary']) ? (int) $widget_rss['show_summary'] : 0;
1409
+	$show_author   = isset($widget_rss['show_author']) ? (int) $widget_rss['show_author'] : 0;
1410
+	$show_date     = isset($widget_rss['show_date']) ? (int) $widget_rss['show_date'] : 0;
1411 1411
 
1412
-	if ( $check_feed ) {
1412
+	if ($check_feed) {
1413 1413
 		$rss = fetch_feed($url);
1414 1414
 		$error = false;
1415 1415
 		$link = '';
1416
-		if ( is_wp_error($rss) ) {
1416
+		if (is_wp_error($rss)) {
1417 1417
 			$error = $rss->get_error_message();
1418 1418
 		} else {
1419 1419
 			$link = esc_url(strip_tags($rss->get_permalink()));
1420
-			while ( stristr($link, 'http') != $link )
1420
+			while (stristr($link, 'http') != $link)
1421 1421
 				$link = substr($link, 1);
1422 1422
 
1423 1423
 			$rss->__destruct();
@@ -1425,7 +1425,7 @@  discard block
 block discarded – undo
1425 1425
 		}
1426 1426
 	}
1427 1427
 
1428
-	return compact( 'title', 'url', 'link', 'items', 'error', 'show_summary', 'show_author', 'show_date' );
1428
+	return compact('title', 'url', 'link', 'items', 'error', 'show_summary', 'show_author', 'show_date');
1429 1429
 }
1430 1430
 
1431 1431
 /**
@@ -1436,7 +1436,7 @@  discard block
 block discarded – undo
1436 1436
  * @since 2.2.0
1437 1437
  */
1438 1438
 function wp_widgets_init() {
1439
-	if ( !is_blog_installed() )
1439
+	if ( ! is_blog_installed())
1440 1440
 		return;
1441 1441
 
1442 1442
 	register_widget('WP_Widget_Pages');
@@ -1445,7 +1445,7 @@  discard block
 block discarded – undo
1445 1445
 
1446 1446
 	register_widget('WP_Widget_Archives');
1447 1447
 
1448
-	if ( get_option( 'link_manager_enabled' ) )
1448
+	if (get_option('link_manager_enabled'))
1449 1449
 		register_widget('WP_Widget_Links');
1450 1450
 
1451 1451
 	register_widget('WP_Widget_Meta');
@@ -1471,5 +1471,5 @@  discard block
 block discarded – undo
1471 1471
 	 *
1472 1472
 	 * @since 2.2.0
1473 1473
 	 */
1474
-	do_action( 'widgets_init' );
1474
+	do_action('widgets_init');
1475 1475
 }
Please login to merge, or discard this patch.
Braces   +120 added lines, -81 removed lines patch added patch discarded remove patch
@@ -163,16 +163,18 @@  discard block
 block discarded – undo
163 163
 	global $wp_registered_sidebars;
164 164
 	$number = (int) $number;
165 165
 
166
-	if ( is_string($args) )
167
-		parse_str($args, $args);
166
+	if ( is_string($args) ) {
167
+			parse_str($args, $args);
168
+	}
168 169
 
169 170
 	for ( $i = 1; $i <= $number; $i++ ) {
170 171
 		$_args = $args;
171 172
 
172
-		if ( $number > 1 )
173
-			$_args['name'] = isset($args['name']) ? sprintf($args['name'], $i) : sprintf(__('Sidebar %d'), $i);
174
-		else
175
-			$_args['name'] = isset($args['name']) ? $args['name'] : __('Sidebar');
173
+		if ( $number > 1 ) {
174
+					$_args['name'] = isset($args['name']) ? sprintf($args['name'], $i) : sprintf(__('Sidebar %d'), $i);
175
+		} else {
176
+					$_args['name'] = isset($args['name']) ? $args['name'] : __('Sidebar');
177
+		}
176 178
 
177 179
 		// Custom specified ID's are suffixed if they exist already.
178 180
 		// Automatically generated sidebar names need to be suffixed regardless starting at -0
@@ -388,14 +390,16 @@  discard block
 block discarded – undo
388 390
  * @return string|void Widget description, if available.
389 391
  */
390 392
 function wp_widget_description( $id ) {
391
-	if ( !is_scalar($id) )
392
-		return;
393
+	if ( !is_scalar($id) ) {
394
+			return;
395
+	}
393 396
 
394 397
 	global $wp_registered_widgets;
395 398
 
396
-	if ( isset($wp_registered_widgets[$id]['description']) )
397
-		return esc_html( $wp_registered_widgets[$id]['description'] );
398
-}
399
+	if ( isset($wp_registered_widgets[$id]['description']) ) {
400
+			return esc_html( $wp_registered_widgets[$id]['description'] );
401
+	}
402
+	}
399 403
 
400 404
 /**
401 405
  * Retrieve description for a sidebar.
@@ -411,14 +415,16 @@  discard block
 block discarded – undo
411 415
  * @return string|void Sidebar description, if available.
412 416
  */
413 417
 function wp_sidebar_description( $id ) {
414
-	if ( !is_scalar($id) )
415
-		return;
418
+	if ( !is_scalar($id) ) {
419
+			return;
420
+	}
416 421
 
417 422
 	global $wp_registered_sidebars;
418 423
 
419
-	if ( isset($wp_registered_sidebars[$id]['description']) )
420
-		return esc_html( $wp_registered_sidebars[$id]['description'] );
421
-}
424
+	if ( isset($wp_registered_sidebars[$id]['description']) ) {
425
+			return esc_html( $wp_registered_sidebars[$id]['description'] );
426
+	}
427
+	}
422 428
 
423 429
 /**
424 430
  * Remove widget from sidebar.
@@ -484,8 +490,9 @@  discard block
 block discarded – undo
484 490
 		return;
485 491
 	}
486 492
 
487
-	if ( isset($wp_registered_widget_controls[$id]) && !did_action( 'widgets_init' ) )
488
-		return;
493
+	if ( isset($wp_registered_widget_controls[$id]) && !did_action( 'widgets_init' ) ) {
494
+			return;
495
+	}
489 496
 
490 497
 	$defaults = array('width' => 250, 'height' => 200 ); // height is never used
491 498
 	$options = wp_parse_args($options, $defaults);
@@ -502,11 +509,13 @@  discard block
 block discarded – undo
502 509
 
503 510
 	$wp_registered_widget_controls[$id] = $widget;
504 511
 
505
-	if ( isset($wp_registered_widget_updates[$id_base]) )
506
-		return;
512
+	if ( isset($wp_registered_widget_updates[$id_base]) ) {
513
+			return;
514
+	}
507 515
 
508
-	if ( isset($widget['params'][0]['number']) )
509
-		$widget['params'][0]['number'] = -1;
516
+	if ( isset($widget['params'][0]['number']) ) {
517
+			$widget['params'][0]['number'] = -1;
518
+	}
510 519
 
511 520
 	unset($widget['width'], $widget['height'], $widget['name'], $widget['id']);
512 521
 	$wp_registered_widget_updates[$id_base] = $widget;
@@ -528,8 +537,9 @@  discard block
 block discarded – undo
528 537
 	global $wp_registered_widget_updates;
529 538
 
530 539
 	if ( isset($wp_registered_widget_updates[$id_base]) ) {
531
-		if ( empty($update_callback) )
532
-			unset($wp_registered_widget_updates[$id_base]);
540
+		if ( empty($update_callback) ) {
541
+					unset($wp_registered_widget_updates[$id_base]);
542
+		}
533 543
 		return;
534 544
 	}
535 545
 
@@ -565,8 +575,9 @@  discard block
 block discarded – undo
565 575
 		return;
566 576
 	}
567 577
 
568
-	if ( isset($wp_registered_widget_controls[$id]) && !did_action( 'widgets_init' ) )
569
-		return;
578
+	if ( isset($wp_registered_widget_controls[$id]) && !did_action( 'widgets_init' ) ) {
579
+			return;
580
+	}
570 581
 
571 582
 	$defaults = array('width' => 250, 'height' => 200 );
572 583
 	$options = wp_parse_args($options, $defaults);
@@ -653,7 +664,9 @@  discard block
 block discarded – undo
653 664
 	$did_one = false;
654 665
 	foreach ( (array) $sidebars_widgets[$index] as $id ) {
655 666
 
656
-		if ( !isset($wp_registered_widgets[$id]) ) continue;
667
+		if ( !isset($wp_registered_widgets[$id]) ) {
668
+			continue;
669
+		}
657 670
 
658 671
 		$params = array_merge(
659 672
 			array( array_merge( $sidebar, array('widget_id' => $id, 'widget_name' => $wp_registered_widgets[$id]['name']) ) ),
@@ -663,10 +676,11 @@  discard block
 block discarded – undo
663 676
 		// Substitute HTML id and class attributes into before_widget
664 677
 		$classname_ = '';
665 678
 		foreach ( (array) $wp_registered_widgets[$id]['classname'] as $cn ) {
666
-			if ( is_string($cn) )
667
-				$classname_ .= '_' . $cn;
668
-			elseif ( is_object($cn) )
669
-				$classname_ .= '_' . get_class($cn);
679
+			if ( is_string($cn) ) {
680
+							$classname_ .= '_' . $cn;
681
+			} elseif ( is_object($cn) ) {
682
+							$classname_ .= '_' . get_class($cn);
683
+			}
670 684
 		}
671 685
 		$classname_ = ltrim($classname_, '_');
672 686
 		$params[0]['before_widget'] = sprintf($params[0]['before_widget'], $id, $classname_);
@@ -806,8 +820,9 @@  discard block
 block discarded – undo
806 820
 			if ( is_array($widgets) ) {
807 821
 				foreach ( $widgets as $widget ) {
808 822
 					if ( ( $callback && isset($wp_registered_widgets[$widget]['callback']) && $wp_registered_widgets[$widget]['callback'] == $callback ) || ( $id_base && _get_widget_id_base($widget) == $id_base ) ) {
809
-						if ( !$widget_id || $widget_id == $wp_registered_widgets[$widget]['id'] )
810
-							return $sidebar;
823
+						if ( !$widget_id || $widget_id == $wp_registered_widgets[$widget]['id'] ) {
824
+													return $sidebar;
825
+						}
811 826
 					}
812 827
 				}
813 828
 			}
@@ -831,9 +846,10 @@  discard block
 block discarded – undo
831 846
 	$sidebars_widgets = get_option('sidebars_widgets');
832 847
 	foreach ( (array) $wp_registered_sidebars as $index => $sidebar ) {
833 848
 		if ( ! empty( $sidebars_widgets[ $index ] ) ) {
834
-			foreach ( (array) $sidebars_widgets[$index] as $widget )
835
-				if ( array_key_exists($widget, $wp_registered_widgets) )
849
+			foreach ( (array) $sidebars_widgets[$index] as $widget ) {
850
+							if ( array_key_exists($widget, $wp_registered_widgets) )
836 851
 					return true;
852
+			}
837 853
 		}
838 854
 	}
839 855
 	return false;
@@ -884,24 +900,27 @@  discard block
 block discarded – undo
884 900
  * @return array Upgraded list of widgets to version 3 array format when called from the admin.
885 901
  */
886 902
 function wp_get_sidebars_widgets( $deprecated = true ) {
887
-	if ( $deprecated !== true )
888
-		_deprecated_argument( __FUNCTION__, '2.8.1' );
903
+	if ( $deprecated !== true ) {
904
+			_deprecated_argument( __FUNCTION__, '2.8.1' );
905
+	}
889 906
 
890 907
 	global $_wp_sidebars_widgets, $sidebars_widgets;
891 908
 
892 909
 	// If loading from front page, consult $_wp_sidebars_widgets rather than options
893 910
 	// to see if wp_convert_widget_settings() has made manipulations in memory.
894 911
 	if ( !is_admin() ) {
895
-		if ( empty($_wp_sidebars_widgets) )
896
-			$_wp_sidebars_widgets = get_option('sidebars_widgets', array());
912
+		if ( empty($_wp_sidebars_widgets) ) {
913
+					$_wp_sidebars_widgets = get_option('sidebars_widgets', array());
914
+		}
897 915
 
898 916
 		$sidebars_widgets = $_wp_sidebars_widgets;
899 917
 	} else {
900 918
 		$sidebars_widgets = get_option('sidebars_widgets', array());
901 919
 	}
902 920
 
903
-	if ( is_array( $sidebars_widgets ) && isset($sidebars_widgets['array_version']) )
904
-		unset($sidebars_widgets['array_version']);
921
+	if ( is_array( $sidebars_widgets ) && isset($sidebars_widgets['array_version']) ) {
922
+			unset($sidebars_widgets['array_version']);
923
+	}
905 924
 
906 925
 	/**
907 926
 	 * Filters the list of sidebars and their widgets.
@@ -922,8 +941,9 @@  discard block
 block discarded – undo
922 941
  * @param array $sidebars_widgets Sidebar widgets and their settings.
923 942
  */
924 943
 function wp_set_sidebars_widgets( $sidebars_widgets ) {
925
-	if ( !isset( $sidebars_widgets['array_version'] ) )
926
-		$sidebars_widgets['array_version'] = 3;
944
+	if ( !isset( $sidebars_widgets['array_version'] ) ) {
945
+			$sidebars_widgets['array_version'] = 3;
946
+	}
927 947
 	update_option( 'sidebars_widgets', $sidebars_widgets );
928 948
 }
929 949
 
@@ -942,8 +962,9 @@  discard block
 block discarded – undo
942 962
 
943 963
 	$defaults = array();
944 964
 
945
-	foreach ( (array) $wp_registered_sidebars as $index => $sidebar )
946
-		$defaults[$index] = array();
965
+	foreach ( (array) $wp_registered_sidebars as $index => $sidebar ) {
966
+			$defaults[$index] = array();
967
+	}
947 968
 
948 969
 	return $defaults;
949 970
 }
@@ -967,8 +988,9 @@  discard block
 block discarded – undo
967 988
 		$single = true;
968 989
 	} else {
969 990
 		foreach ( array_keys($settings) as $number ) {
970
-			if ( 'number' == $number )
971
-				continue;
991
+			if ( 'number' == $number ) {
992
+							continue;
993
+			}
972 994
 			if ( !is_numeric($number) ) {
973 995
 				$single = true;
974 996
 				break;
@@ -983,8 +1005,9 @@  discard block
 block discarded – undo
983 1005
 		if ( is_admin() ) {
984 1006
 			$sidebars_widgets = get_option('sidebars_widgets');
985 1007
 		} else {
986
-			if ( empty($GLOBALS['_wp_sidebars_widgets']) )
987
-				$GLOBALS['_wp_sidebars_widgets'] = get_option('sidebars_widgets', array());
1008
+			if ( empty($GLOBALS['_wp_sidebars_widgets']) ) {
1009
+							$GLOBALS['_wp_sidebars_widgets'] = get_option('sidebars_widgets', array());
1010
+			}
988 1011
 			$sidebars_widgets = &$GLOBALS['_wp_sidebars_widgets'];
989 1012
 		}
990 1013
 
@@ -1000,13 +1023,15 @@  discard block
 block discarded – undo
1000 1023
 			}
1001 1024
 		}
1002 1025
 
1003
-		if ( is_admin() && $changed )
1004
-			update_option('sidebars_widgets', $sidebars_widgets);
1026
+		if ( is_admin() && $changed ) {
1027
+					update_option('sidebars_widgets', $sidebars_widgets);
1028
+		}
1005 1029
 	}
1006 1030
 
1007 1031
 	$settings['_multiwidget'] = 1;
1008
-	if ( is_admin() )
1009
-		update_option( $option_name, $settings );
1032
+	if ( is_admin() ) {
1033
+			update_option( $option_name, $settings );
1034
+	}
1010 1035
 
1011 1036
 	return $settings;
1012 1037
 }
@@ -1090,8 +1115,9 @@  discard block
 block discarded – undo
1090 1115
 function _wp_sidebars_changed() {
1091 1116
 	global $sidebars_widgets;
1092 1117
 
1093
-	if ( ! is_array( $sidebars_widgets ) )
1094
-		$sidebars_widgets = wp_get_sidebars_widgets();
1118
+	if ( ! is_array( $sidebars_widgets ) ) {
1119
+			$sidebars_widgets = wp_get_sidebars_widgets();
1120
+	}
1095 1121
 
1096 1122
 	retrieve_widgets(true);
1097 1123
 }
@@ -1135,8 +1161,9 @@  discard block
 block discarded – undo
1135 1161
 			}
1136 1162
 		}
1137 1163
 	} else {
1138
-		if ( empty( $sidebars_widgets ) )
1139
-			return;
1164
+		if ( empty( $sidebars_widgets ) ) {
1165
+					return;
1166
+		}
1140 1167
 
1141 1168
 		unset( $sidebars_widgets['array_version'] );
1142 1169
 
@@ -1144,8 +1171,9 @@  discard block
 block discarded – undo
1144 1171
 		sort($old);
1145 1172
 		sort($registered_sidebar_keys);
1146 1173
 
1147
-		if ( $old == $registered_sidebar_keys )
1148
-			return;
1174
+		if ( $old == $registered_sidebar_keys ) {
1175
+					return;
1176
+		}
1149 1177
 
1150 1178
 		$_sidebars_widgets = array(
1151 1179
 			'wp_inactive_widgets' => !empty( $sidebars_widgets['wp_inactive_widgets'] ) ? $sidebars_widgets['wp_inactive_widgets'] : array()
@@ -1166,8 +1194,9 @@  discard block
 block discarded – undo
1166 1194
 		}
1167 1195
 
1168 1196
 		foreach ( $sidebars_widgets as $val ) {
1169
-			if ( is_array($val) && ! empty( $val ) )
1170
-				$_sidebars_widgets['orphaned_widgets_' . ++$orphaned] = $val;
1197
+			if ( is_array($val) && ! empty( $val ) ) {
1198
+							$_sidebars_widgets['orphaned_widgets_' . ++$orphaned] = $val;
1199
+			}
1171 1200
 		}
1172 1201
 	}
1173 1202
 
@@ -1175,13 +1204,15 @@  discard block
 block discarded – undo
1175 1204
 	$shown_widgets = array();
1176 1205
 
1177 1206
 	foreach ( $_sidebars_widgets as $sidebar => $widgets ) {
1178
-		if ( !is_array($widgets) )
1179
-			continue;
1207
+		if ( !is_array($widgets) ) {
1208
+					continue;
1209
+		}
1180 1210
 
1181 1211
 		$_widgets = array();
1182 1212
 		foreach ( $widgets as $widget ) {
1183
-			if ( isset($wp_registered_widgets[$widget]) )
1184
-				$_widgets[] = $widget;
1213
+			if ( isset($wp_registered_widgets[$widget]) ) {
1214
+							$_widgets[] = $widget;
1215
+			}
1185 1216
 		}
1186 1217
 
1187 1218
 		$_sidebars_widgets[$sidebar] = $_widgets;
@@ -1194,13 +1225,15 @@  discard block
 block discarded – undo
1194 1225
 	// find hidden/lost multi-widget instances
1195 1226
 	$lost_widgets = array();
1196 1227
 	foreach ( $wp_registered_widgets as $key => $val ) {
1197
-		if ( in_array($key, $shown_widgets, true) )
1198
-			continue;
1228
+		if ( in_array($key, $shown_widgets, true) ) {
1229
+					continue;
1230
+		}
1199 1231
 
1200 1232
 		$number = preg_replace('/.+?-([0-9]+)$/', '$1', $key);
1201 1233
 
1202
-		if ( 2 > (int) $number )
1203
-			continue;
1234
+		if ( 2 > (int) $number ) {
1235
+					continue;
1236
+		}
1204 1237
 
1205 1238
 		$lost_widgets[] = $key;
1206 1239
 	}
@@ -1232,8 +1265,9 @@  discard block
 block discarded – undo
1232 1265
 	}
1233 1266
 
1234 1267
 	if ( is_wp_error($rss) ) {
1235
-		if ( is_admin() || current_user_can('manage_options') )
1236
-			echo '<p><strong>' . __( 'RSS Error:' ) . '</strong> ' . $rss->get_error_message() . '</p>';
1268
+		if ( is_admin() || current_user_can('manage_options') ) {
1269
+					echo '<p><strong>' . __( 'RSS Error:' ) . '</strong> ' . $rss->get_error_message() . '</p>';
1270
+		}
1237 1271
 		return;
1238 1272
 	}
1239 1273
 
@@ -1241,8 +1275,9 @@  discard block
 block discarded – undo
1241 1275
 	$args = wp_parse_args( $args, $default_args );
1242 1276
 
1243 1277
 	$items = (int) $args['items'];
1244
-	if ( $items < 1 || 20 < $items )
1245
-		$items = 10;
1278
+	if ( $items < 1 || 20 < $items ) {
1279
+			$items = 10;
1280
+	}
1246 1281
 	$show_summary  = (int) $args['show_summary'];
1247 1282
 	$show_author   = (int) $args['show_author'];
1248 1283
 	$show_date     = (int) $args['show_date'];
@@ -1401,8 +1436,9 @@  discard block
 block discarded – undo
1401 1436
  */
1402 1437
 function wp_widget_rss_process( $widget_rss, $check_feed = true ) {
1403 1438
 	$items = (int) $widget_rss['items'];
1404
-	if ( $items < 1 || 20 < $items )
1405
-		$items = 10;
1439
+	if ( $items < 1 || 20 < $items ) {
1440
+			$items = 10;
1441
+	}
1406 1442
 	$url           = esc_url_raw( strip_tags( $widget_rss['url'] ) );
1407 1443
 	$title         = isset( $widget_rss['title'] ) ? trim( strip_tags( $widget_rss['title'] ) ) : '';
1408 1444
 	$show_summary  = isset( $widget_rss['show_summary'] ) ? (int) $widget_rss['show_summary'] : 0;
@@ -1417,8 +1453,9 @@  discard block
 block discarded – undo
1417 1453
 			$error = $rss->get_error_message();
1418 1454
 		} else {
1419 1455
 			$link = esc_url(strip_tags($rss->get_permalink()));
1420
-			while ( stristr($link, 'http') != $link )
1421
-				$link = substr($link, 1);
1456
+			while ( stristr($link, 'http') != $link ) {
1457
+							$link = substr($link, 1);
1458
+			}
1422 1459
 
1423 1460
 			$rss->__destruct();
1424 1461
 			unset($rss);
@@ -1436,8 +1473,9 @@  discard block
 block discarded – undo
1436 1473
  * @since 2.2.0
1437 1474
  */
1438 1475
 function wp_widgets_init() {
1439
-	if ( !is_blog_installed() )
1440
-		return;
1476
+	if ( !is_blog_installed() ) {
1477
+			return;
1478
+	}
1441 1479
 
1442 1480
 	register_widget('WP_Widget_Pages');
1443 1481
 
@@ -1445,8 +1483,9 @@  discard block
 block discarded – undo
1445 1483
 
1446 1484
 	register_widget('WP_Widget_Archives');
1447 1485
 
1448
-	if ( get_option( 'link_manager_enabled' ) )
1449
-		register_widget('WP_Widget_Links');
1486
+	if ( get_option( 'link_manager_enabled' ) ) {
1487
+			register_widget('WP_Widget_Links');
1488
+	}
1450 1489
 
1451 1490
 	register_widget('WP_Widget_Meta');
1452 1491
 
Please login to merge, or discard this patch.
tools/i18n/makepot.php 3 patches
Doc Comments   +10 added lines patch added patch discarded remove patch
@@ -156,6 +156,9 @@  discard block
 block discarded – undo
156 156
 			unlink( $temp_file );
157 157
 	}
158 158
 
159
+	/**
160
+	 * @param string $file
161
+	 */
159 162
 	private function tempnam( $file ) {
160 163
 		$tempnam = tempnam( sys_get_temp_dir(), $file );
161 164
 		$this->temp_files[] = $tempnam;
@@ -235,6 +238,9 @@  discard block
 block discarded – undo
235 238
 		return $res;
236 239
 	}
237 240
 
241
+	/**
242
+	 * @param string $output
243
+	 */
238 244
 	public function wp_frontend( $dir, $output ) {
239 245
 		if ( ! file_exists( "$dir/wp-admin/user/about.php" ) ) {
240 246
 			return false;
@@ -255,6 +261,9 @@  discard block
 block discarded – undo
255 261
 		) );
256 262
 	}
257 263
 
264
+	/**
265
+	 * @param string $output
266
+	 */
258 267
 	public function wp_admin($dir, $output) {
259 268
 		$frontend_pot = $this->tempnam( 'frontend.pot' );
260 269
 		if ( false === $frontend_pot ) {
@@ -416,6 +425,7 @@  discard block
 block discarded – undo
416 425
 
417 426
 	/**
418 427
 	 * Removes any trailing closing comment / PHP tags from the header value
428
+	 * @param string $str
419 429
 	 */
420 430
 	private function _cleanup_header_comment( $str ) {
421 431
 		return trim( preg_replace( '/\s*(?:\*\/|\?>).*/', '', $str ) );
Please login to merge, or discard this patch.
Spacing   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2
-require_once dirname( __FILE__ ) . '/not-gettexted.php';
3
-require_once dirname( __FILE__ ) . '/pot-ext-meta.php';
4
-require_once dirname( __FILE__ ) . '/extract.php';
2
+require_once dirname(__FILE__).'/not-gettexted.php';
3
+require_once dirname(__FILE__).'/pot-ext-meta.php';
4
+require_once dirname(__FILE__).'/extract.php';
5 5
 
6
-if ( !defined( 'STDERR' ) ) {
7
-	define( 'STDERR', fopen( 'php://stderr', 'w' ) );
6
+if ( ! defined('STDERR')) {
7
+	define('STDERR', fopen('php://stderr', 'w'));
8 8
 }
9 9
 
10 10
 /**
@@ -148,16 +148,16 @@  discard block
 block discarded – undo
148 148
 	);
149 149
 
150 150
 	public function __construct($deprecated = true) {
151
-		$this->extractor = new StringExtractor( $this->rules );
151
+		$this->extractor = new StringExtractor($this->rules);
152 152
 	}
153 153
 
154 154
 	public function __destruct() {
155
-		foreach ( $this->temp_files as $temp_file )
156
-			unlink( $temp_file );
155
+		foreach ($this->temp_files as $temp_file)
156
+			unlink($temp_file);
157 157
 	}
158 158
 
159
-	private function tempnam( $file ) {
160
-		$tempnam = tempnam( sys_get_temp_dir(), $file );
159
+	private function tempnam($file) {
160
+		$tempnam = tempnam(sys_get_temp_dir(), $file);
161 161
 		$this->temp_files[] = $tempnam;
162 162
 		return $tempnam;
163 163
 	}
@@ -167,31 +167,31 @@  discard block
 block discarded – undo
167 167
 	}
168 168
 
169 169
 	private function xgettext($project, $dir, $output_file, $placeholders = array(), $excludes = array(), $includes = array()) {
170
-		$meta = array_merge( $this->meta['default'], $this->meta[$project] );
171
-		$placeholders = array_merge( $meta, $placeholders );
172
-		$meta['output'] = $this->realpath_missing( $output_file );
173
-		$placeholders['year'] = date( 'Y' );
174
-		$placeholder_keys = array_map( create_function( '$x', 'return "{".$x."}";' ), array_keys( $placeholders ) );
175
-		$placeholder_values = array_values( $placeholders );
176
-		foreach($meta as $key => $value) {
170
+		$meta = array_merge($this->meta['default'], $this->meta[$project]);
171
+		$placeholders = array_merge($meta, $placeholders);
172
+		$meta['output'] = $this->realpath_missing($output_file);
173
+		$placeholders['year'] = date('Y');
174
+		$placeholder_keys = array_map(create_function('$x', 'return "{".$x."}";'), array_keys($placeholders));
175
+		$placeholder_values = array_values($placeholders);
176
+		foreach ($meta as $key => $value) {
177 177
 			$meta[$key] = str_replace($placeholder_keys, $placeholder_values, $value);
178 178
 		}
179 179
 
180
-		$originals = $this->extractor->extract_from_directory( $dir, $excludes, $includes );
180
+		$originals = $this->extractor->extract_from_directory($dir, $excludes, $includes);
181 181
 		$pot = new PO;
182 182
 		$pot->entries = $originals->entries;
183 183
 
184
-		$pot->set_header( 'Project-Id-Version', $meta['package-name'].' '.$meta['package-version'] );
185
-		$pot->set_header( 'Report-Msgid-Bugs-To', $meta['msgid-bugs-address'] );
186
-		$pot->set_header( 'POT-Creation-Date', gmdate( 'Y-m-d H:i:s+00:00' ) );
187
-		$pot->set_header( 'MIME-Version', '1.0' );
188
-		$pot->set_header( 'Content-Type', 'text/plain; charset=UTF-8' );
189
-		$pot->set_header( 'Content-Transfer-Encoding', '8bit' );
190
-		$pot->set_header( 'PO-Revision-Date', date( 'Y') . '-MO-DA HO:MI+ZONE' );
191
-		$pot->set_header( 'Last-Translator', 'FULL NAME <EMAIL@ADDRESS>' );
192
-		$pot->set_header( 'Language-Team', 'LANGUAGE <[email protected]>' );
193
-		$pot->set_comment_before_headers( $meta['comments'] );
194
-		$pot->export_to_file( $output_file );
184
+		$pot->set_header('Project-Id-Version', $meta['package-name'].' '.$meta['package-version']);
185
+		$pot->set_header('Report-Msgid-Bugs-To', $meta['msgid-bugs-address']);
186
+		$pot->set_header('POT-Creation-Date', gmdate('Y-m-d H:i:s+00:00'));
187
+		$pot->set_header('MIME-Version', '1.0');
188
+		$pot->set_header('Content-Type', 'text/plain; charset=UTF-8');
189
+		$pot->set_header('Content-Transfer-Encoding', '8bit');
190
+		$pot->set_header('PO-Revision-Date', date('Y').'-MO-DA HO:MI+ZONE');
191
+		$pot->set_header('Last-Translator', 'FULL NAME <EMAIL@ADDRESS>');
192
+		$pot->set_header('Language-Team', 'LANGUAGE <[email protected]>');
193
+		$pot->set_comment_before_headers($meta['comments']);
194
+		$pot->export_to_file($output_file);
195 195
 		return true;
196 196
 	}
197 197
 
@@ -202,185 +202,185 @@  discard block
 block discarded – undo
202 202
 			'default_output' => 'wordpress.pot',
203 203
 			'includes' => array(),
204 204
 			'excludes' => array_merge(
205
-				array( 'wp-admin/includes/continents-cities\.php', 'wp-content/themes/twenty.*', ),
205
+				array('wp-admin/includes/continents-cities\.php', 'wp-content/themes/twenty.*',),
206 206
 				$this->ms_files
207 207
 			),
208 208
 			'extract_not_gettexted' => false,
209 209
 			'not_gettexted_files_filter' => false,
210 210
 		);
211
-		$args = array_merge( $defaults, $args );
212
-		extract( $args );
211
+		$args = array_merge($defaults, $args);
212
+		extract($args);
213 213
 		$placeholders = array();
214
-		if ( $wp_version = $this->wp_version( $dir ) )
214
+		if ($wp_version = $this->wp_version($dir))
215 215
 			$placeholders['version'] = $wp_version;
216 216
 		else
217 217
 			return false;
218
-		$output = is_null( $output )? $default_output : $output;
219
-		$res = $this->xgettext( $project, $dir, $output, $placeholders, $excludes, $includes );
220
-		if ( !$res ) return false;
218
+		$output = is_null($output) ? $default_output : $output;
219
+		$res = $this->xgettext($project, $dir, $output, $placeholders, $excludes, $includes);
220
+		if ( ! $res) return false;
221 221
 
222
-		if ( $extract_not_gettexted ) {
222
+		if ($extract_not_gettexted) {
223 223
 			$old_dir = getcwd();
224
-			$output = realpath( $output );
225
-			chdir( $dir );
224
+			$output = realpath($output);
225
+			chdir($dir);
226 226
 			$php_files = NotGettexted::list_php_files('.');
227
-			$php_files = array_filter( $php_files, $not_gettexted_files_filter );
227
+			$php_files = array_filter($php_files, $not_gettexted_files_filter);
228 228
 			$not_gettexted = new NotGettexted;
229
-			$res = $not_gettexted->command_extract( $output, $php_files );
230
-			chdir( $old_dir );
229
+			$res = $not_gettexted->command_extract($output, $php_files);
230
+			chdir($old_dir);
231 231
 			/* Adding non-gettexted strings can repeat some phrases */
232
-			$output_shell = escapeshellarg( $output );
233
-			system( "msguniq --use-first $output_shell -o $output_shell" );
232
+			$output_shell = escapeshellarg($output);
233
+			system("msguniq --use-first $output_shell -o $output_shell");
234 234
 		}
235 235
 		return $res;
236 236
 	}
237 237
 
238
-	public function wp_frontend( $dir, $output ) {
239
-		if ( ! file_exists( "$dir/wp-admin/user/about.php" ) ) {
238
+	public function wp_frontend($dir, $output) {
239
+		if ( ! file_exists("$dir/wp-admin/user/about.php")) {
240 240
 			return false;
241 241
 		}
242 242
 
243
-		$excludes = array( 'wp-admin/.*', 'wp-content/themes/.*', 'wp-includes/class-pop3\.php' );
243
+		$excludes = array('wp-admin/.*', 'wp-content/themes/.*', 'wp-includes/class-pop3\.php');
244 244
 
245 245
 		// Exclude Akismet all together for 3.9+.
246
-		if ( file_exists( "$dir/wp-admin/css/about.css" ) ) {
246
+		if (file_exists("$dir/wp-admin/css/about.css")) {
247 247
 			$excludes[] = 'wp-content/plugins/akismet/.*';
248 248
 		}
249 249
 
250
-		return $this->wp_generic( $dir, array(
250
+		return $this->wp_generic($dir, array(
251 251
 			'project' => 'wp-frontend', 'output' => $output,
252 252
 			'includes' => array(),
253 253
 			'excludes' => $excludes,
254 254
 			'default_output' => 'wordpress.pot',
255
-		) );
255
+		));
256 256
 	}
257 257
 
258 258
 	public function wp_admin($dir, $output) {
259
-		$frontend_pot = $this->tempnam( 'frontend.pot' );
260
-		if ( false === $frontend_pot ) {
259
+		$frontend_pot = $this->tempnam('frontend.pot');
260
+		if (false === $frontend_pot) {
261 261
 			return false;
262 262
 		}
263 263
 
264
-		$frontend_result = $this->wp_frontend( $dir, $frontend_pot );
265
-		if ( ! $frontend_result ) {
264
+		$frontend_result = $this->wp_frontend($dir, $frontend_pot);
265
+		if ( ! $frontend_result) {
266 266
 			return false;
267 267
 		}
268 268
 
269
-		$network_admin_files = $this->get_wp_network_admin_files( $dir );
269
+		$network_admin_files = $this->get_wp_network_admin_files($dir);
270 270
 
271
-		$result = $this->wp_generic( $dir, array(
271
+		$result = $this->wp_generic($dir, array(
272 272
 			'project' => 'wp-admin', 'output' => $output,
273
-			'includes' => array( 'wp-admin/.*' ),
274
-			'excludes' => array_merge( array( 'wp-admin/includes/continents-cities\.php' ), $network_admin_files ),
273
+			'includes' => array('wp-admin/.*'),
274
+			'excludes' => array_merge(array('wp-admin/includes/continents-cities\.php'), $network_admin_files),
275 275
 			'default_output' => 'wordpress-admin.pot',
276
-		) );
277
-		if ( ! $result ) {
276
+		));
277
+		if ( ! $result) {
278 278
 			return false;
279 279
 		}
280 280
 
281 281
 		$potextmeta = new PotExtMeta;
282 282
 
283
-		if ( ! file_exists( "$dir/wp-admin/css/about.css" ) ) { // < 3.9
284
-			$result = $potextmeta->append( "$dir/wp-content/plugins/akismet/akismet.php", $output );
285
-			if ( ! $result ) {
283
+		if ( ! file_exists("$dir/wp-admin/css/about.css")) { // < 3.9
284
+			$result = $potextmeta->append("$dir/wp-content/plugins/akismet/akismet.php", $output);
285
+			if ( ! $result) {
286 286
 				return false;
287 287
 			}
288 288
 		}
289 289
 
290
-		$result = $potextmeta->append( "$dir/wp-content/plugins/hello.php", $output );
291
-		if ( ! $result ) {
290
+		$result = $potextmeta->append("$dir/wp-content/plugins/hello.php", $output);
291
+		if ( ! $result) {
292 292
 			return false;
293 293
 		}
294 294
 
295 295
 		/* Adding non-gettexted strings can repeat some phrases */
296
-		$output_shell = escapeshellarg( $output );
297
-		system( "msguniq $output_shell -o $output_shell" );
296
+		$output_shell = escapeshellarg($output);
297
+		system("msguniq $output_shell -o $output_shell");
298 298
 
299
-		$common_pot = $this->tempnam( 'common.pot' );
300
-		if ( ! $common_pot ) {
299
+		$common_pot = $this->tempnam('common.pot');
300
+		if ( ! $common_pot) {
301 301
 			return false;
302 302
 		}
303
-		$admin_pot = realpath( is_null( $output ) ? 'wordpress-admin.pot' : $output );
304
-		system( "msgcat --more-than=1 --use-first $frontend_pot $admin_pot > $common_pot" );
305
-		system( "msgcat -u --use-first $admin_pot $common_pot -o $admin_pot" );
303
+		$admin_pot = realpath(is_null($output) ? 'wordpress-admin.pot' : $output);
304
+		system("msgcat --more-than=1 --use-first $frontend_pot $admin_pot > $common_pot");
305
+		system("msgcat -u --use-first $admin_pot $common_pot -o $admin_pot");
306 306
 		return true;
307 307
 	}
308 308
 
309 309
 	public function wp_network_admin($dir, $output) {
310
-		if ( ! file_exists( "$dir/wp-admin/user/about.php" ) ) return false;
310
+		if ( ! file_exists("$dir/wp-admin/user/about.php")) return false;
311 311
 
312
-		$frontend_pot = $this->tempnam( 'frontend.pot' );
313
-		if ( false === $frontend_pot ) return false;
312
+		$frontend_pot = $this->tempnam('frontend.pot');
313
+		if (false === $frontend_pot) return false;
314 314
 
315
-		$frontend_result = $this->wp_frontend( $dir, $frontend_pot );
316
-		if ( ! $frontend_result )
315
+		$frontend_result = $this->wp_frontend($dir, $frontend_pot);
316
+		if ( ! $frontend_result)
317 317
 			return false;
318 318
 
319
-		$admin_pot = $this->tempnam( 'admin.pot' );
320
-		if ( false === $admin_pot ) return false;
319
+		$admin_pot = $this->tempnam('admin.pot');
320
+		if (false === $admin_pot) return false;
321 321
 
322
-		$admin_result = $this->wp_admin( $dir, $admin_pot );
323
-		if ( ! $admin_result )
322
+		$admin_result = $this->wp_admin($dir, $admin_pot);
323
+		if ( ! $admin_result)
324 324
 			return false;
325 325
 
326
-		$result = $this->wp_generic( $dir, array(
326
+		$result = $this->wp_generic($dir, array(
327 327
 			'project' => 'wp-network-admin', 'output' => $output,
328
-			'includes' => $this->get_wp_network_admin_files( $dir ),
328
+			'includes' => $this->get_wp_network_admin_files($dir),
329 329
 			'excludes' => array(),
330 330
 			'default_output' => 'wordpress-admin-network.pot',
331
-		) );
331
+		));
332 332
 
333
-		if ( ! $result ) {
333
+		if ( ! $result) {
334 334
 			return false;
335 335
 		}
336 336
 
337
-		$common_pot = $this->tempnam( 'common.pot' );
338
-		if ( ! $common_pot )
337
+		$common_pot = $this->tempnam('common.pot');
338
+		if ( ! $common_pot)
339 339
 			return false;
340 340
 
341
-		$net_admin_pot = realpath( is_null( $output ) ? 'wordpress-network-admin.pot' : $output );
342
-		system( "msgcat --more-than=1 --use-first $frontend_pot $admin_pot $net_admin_pot > $common_pot" );
343
-		system( "msgcat -u --use-first $net_admin_pot $common_pot -o $net_admin_pot" );
341
+		$net_admin_pot = realpath(is_null($output) ? 'wordpress-network-admin.pot' : $output);
342
+		system("msgcat --more-than=1 --use-first $frontend_pot $admin_pot $net_admin_pot > $common_pot");
343
+		system("msgcat -u --use-first $net_admin_pot $common_pot -o $net_admin_pot");
344 344
 		return true;
345 345
 	}
346 346
 
347
-	private function get_wp_network_admin_files( $dir ) {
348
-		$wp_version = $this->wp_version( $dir );
347
+	private function get_wp_network_admin_files($dir) {
348
+		$wp_version = $this->wp_version($dir);
349 349
 
350 350
 		// https://core.trac.wordpress.org/ticket/19852
351
-		$files = array( 'wp-admin/network/.*', 'wp-admin/network.php' );
351
+		$files = array('wp-admin/network/.*', 'wp-admin/network.php');
352 352
 
353 353
 		// https://core.trac.wordpress.org/ticket/34910
354
-		if ( version_compare( $wp_version, '4.5-beta', '>=' ) ) {
355
-			$files = array_merge( $files, array(
354
+		if (version_compare($wp_version, '4.5-beta', '>=')) {
355
+			$files = array_merge($files, array(
356 356
 				'wp-admin/includes/class-wp-ms.*',
357 357
 				'wp-admin/includes/network.php',
358
-			) );
358
+			));
359 359
 		}
360 360
 
361 361
 		return $files;
362 362
 	}
363 363
 
364
-	public function wp_tz( $dir, $output ) {
365
-		return $this->wp_generic( $dir, array(
364
+	public function wp_tz($dir, $output) {
365
+		return $this->wp_generic($dir, array(
366 366
 			'project' => 'wp-tz', 'output' => $output,
367
-			'includes' => array( 'wp-admin/includes/continents-cities\.php' ),
367
+			'includes' => array('wp-admin/includes/continents-cities\.php'),
368 368
 			'excludes' => array(),
369 369
 			'default_output' => 'wordpress-continents-cities.pot',
370
-		) );
370
+		));
371 371
 	}
372 372
 
373
-	private function wp_version( $dir ) {
373
+	private function wp_version($dir) {
374 374
 		$version_php = $dir.'/wp-includes/version.php';
375
-		if ( !is_readable( $version_php ) ) return false;
376
-		return preg_match( '/\$wp_version\s*=\s*\'(.*?)\';/', file_get_contents( $version_php ), $matches )? $matches[1] : false;
375
+		if ( ! is_readable($version_php)) return false;
376
+		return preg_match('/\$wp_version\s*=\s*\'(.*?)\';/', file_get_contents($version_php), $matches) ? $matches[1] : false;
377 377
 	}
378 378
 
379 379
 	public function get_first_lines($filename, $lines = 30) {
380 380
 		$extf = fopen($filename, 'r');
381
-		if (!$extf) return false;
381
+		if ( ! $extf) return false;
382 382
 		$first_lines = '';
383
-		foreach(range(1, $lines) as $x) {
383
+		foreach (range(1, $lines) as $x) {
384 384
 			$line = fgets($extf);
385 385
 			if (feof($extf)) break;
386 386
 			if (false === $line) {
@@ -390,10 +390,10 @@  discard block
 block discarded – undo
390 390
 		}
391 391
 
392 392
 		// PHP will close file handle, but we are good citizens.
393
-		fclose( $extf );
393
+		fclose($extf);
394 394
 
395 395
 		// Make sure we catch CR-only line endings.
396
-		$first_lines = str_replace( "\r", "\n", $first_lines );
396
+		$first_lines = str_replace("\r", "\n", $first_lines);
397 397
 
398 398
 		return $first_lines;
399 399
 	}
@@ -407,8 +407,8 @@  discard block
 block discarded – undo
407 407
 		 * - '<?php // Header: Value ?>'
408 408
 		 * - '<?php /* Header: Value * / $foo='bar'; ?>'
409 409
 		 */
410
-		if ( preg_match( '/^(?:[ \t]*<\?php)?[ \t\/*#@]*' . preg_quote( $header, '/' ) . ':(.*)$/mi', $source, $matches ) ) {
411
-			return $this->_cleanup_header_comment( $matches[1] );
410
+		if (preg_match('/^(?:[ \t]*<\?php)?[ \t\/*#@]*'.preg_quote($header, '/').':(.*)$/mi', $source, $matches)) {
411
+			return $this->_cleanup_header_comment($matches[1]);
412 412
 		} else {
413 413
 			return false;
414 414
 		}
@@ -417,12 +417,12 @@  discard block
 block discarded – undo
417 417
 	/**
418 418
 	 * Removes any trailing closing comment / PHP tags from the header value
419 419
 	 */
420
-	private function _cleanup_header_comment( $str ) {
421
-		return trim( preg_replace( '/\s*(?:\*\/|\?>).*/', '', $str ) );
420
+	private function _cleanup_header_comment($str) {
421
+		return trim(preg_replace('/\s*(?:\*\/|\?>).*/', '', $str));
422 422
 	}
423 423
 
424 424
 	public function generic($dir, $output) {
425
-		$output = is_null($output)? "generic.pot" : $output;
425
+		$output = is_null($output) ? "generic.pot" : $output;
426 426
 		return $this->xgettext('generic', $dir, $output, array());
427 427
 	}
428 428
 
@@ -437,53 +437,53 @@  discard block
 block discarded – undo
437 437
 		return $slug;
438 438
 	}
439 439
 
440
-	public function wp_plugin( $dir, $output, $slug = null, $args = array() ) {
440
+	public function wp_plugin($dir, $output, $slug = null, $args = array()) {
441 441
 		$defaults = array(
442 442
 			'excludes' => array(),
443 443
 			'includes' => array(),
444 444
 		);
445
-		$args = array_merge( $defaults, $args );
445
+		$args = array_merge($defaults, $args);
446 446
 		$placeholders = array();
447 447
 		// guess plugin slug
448 448
 		if (is_null($slug)) {
449 449
 			$slug = $this->guess_plugin_slug($dir);
450 450
 		}
451 451
 
452
-		$plugins_dir = @opendir( $dir );
452
+		$plugins_dir = @opendir($dir);
453 453
 		$plugin_files = array();
454
-		if ( $plugins_dir ) {
455
-			while ( ( $file = readdir( $plugins_dir ) ) !== false ) {
456
-				if ( '.' === substr( $file, 0, 1 ) ) {
454
+		if ($plugins_dir) {
455
+			while (($file = readdir($plugins_dir)) !== false) {
456
+				if ('.' === substr($file, 0, 1)) {
457 457
 					continue;
458 458
 				}
459 459
 
460
-				if ( '.php' === substr( $file, -4 ) ) {
460
+				if ('.php' === substr($file, -4)) {
461 461
 					$plugin_files[] = $file;
462 462
 				}
463 463
 			}
464
-			closedir( $plugins_dir );
464
+			closedir($plugins_dir);
465 465
 		}
466 466
 
467
-		if ( empty( $plugin_files ) ) {
467
+		if (empty($plugin_files)) {
468 468
 			return false;
469 469
 		}
470 470
 
471 471
 		$main_file = '';
472
-		foreach ( $plugin_files as $plugin_file ) {
473
-			if ( ! is_readable( "$dir/$plugin_file" ) ) {
472
+		foreach ($plugin_files as $plugin_file) {
473
+			if ( ! is_readable("$dir/$plugin_file")) {
474 474
 				continue;
475 475
 			}
476 476
 
477
-			$source = $this->get_first_lines( "$dir/$plugin_file", $this->max_header_lines );
477
+			$source = $this->get_first_lines("$dir/$plugin_file", $this->max_header_lines);
478 478
 
479 479
 			// Stop when we find a file with a plugin name header in it.
480
-			if ( $this->get_addon_header( 'Plugin Name', $source ) != false ) {
480
+			if ($this->get_addon_header('Plugin Name', $source) != false) {
481 481
 				$main_file = "$dir/$plugin_file";
482 482
 				break;
483 483
 			}
484 484
 		}
485 485
 
486
-		if ( empty( $main_file ) ) {
486
+		if (empty($main_file)) {
487 487
 			return false;
488 488
 		}
489 489
 
@@ -492,9 +492,9 @@  discard block
 block discarded – undo
492 492
 		$placeholders['name'] = $this->get_addon_header('Plugin Name', $source);
493 493
 		$placeholders['slug'] = $slug;
494 494
 
495
-		$output = is_null($output)? "$slug.pot" : $output;
496
-		$res = $this->xgettext( 'wp-plugin', $dir, $output, $placeholders, $args['excludes'], $args['includes'] );
497
-		if (!$res) return false;
495
+		$output = is_null($output) ? "$slug.pot" : $output;
496
+		$res = $this->xgettext('wp-plugin', $dir, $output, $placeholders, $args['excludes'], $args['includes']);
497
+		if ( ! $res) return false;
498 498
 		$potextmeta = new PotExtMeta;
499 499
 		$res = $potextmeta->append($main_file, $output);
500 500
 		/* Adding non-gettexted strings can repeat some phrases */
@@ -517,37 +517,37 @@  discard block
 block discarded – undo
517 517
 		$placeholders['name'] = $this->get_addon_header('Theme Name', $source);
518 518
 		$placeholders['slug'] = $slug;
519 519
 
520
-		$license = $this->get_addon_header( 'License', $source );
521
-		if ( $license )
520
+		$license = $this->get_addon_header('License', $source);
521
+		if ($license)
522 522
 			$this->meta['wp-theme']['comments'] = "Copyright (C) {year} {author}\nThis file is distributed under the {$license}.";
523 523
 		else
524 524
 			$this->meta['wp-theme']['comments'] = "Copyright (C) {year} {author}\nThis file is distributed under the same license as the {package-name} package.";
525 525
 
526
-		$output = is_null($output)? "$slug.pot" : $output;
526
+		$output = is_null($output) ? "$slug.pot" : $output;
527 527
 		$res = $this->xgettext('wp-theme', $dir, $output, $placeholders);
528
-		if (! $res )
528
+		if ( ! $res)
529 529
 			return false;
530 530
 		$potextmeta = new PotExtMeta;
531
-		$res = $potextmeta->append( $main_file, $output, array( 'Theme Name', 'Theme URI', 'Description', 'Author', 'Author URI' ) );
532
-		if ( ! $res )
531
+		$res = $potextmeta->append($main_file, $output, array('Theme Name', 'Theme URI', 'Description', 'Author', 'Author URI'));
532
+		if ( ! $res)
533 533
 			return false;
534 534
 		// If we're dealing with a pre-3.4 default theme, don't extract page templates before 3.4.
535
-		$extract_templates = ! in_array( $slug, array( 'twentyten', 'twentyeleven', 'default', 'classic' ) );
536
-		if ( ! $extract_templates ) {
537
-			$wp_dir = dirname( dirname( dirname( $dir ) ) );
538
-			$extract_templates = file_exists( "$wp_dir/wp-admin/user/about.php" ) || ! file_exists( "$wp_dir/wp-load.php" );
535
+		$extract_templates = ! in_array($slug, array('twentyten', 'twentyeleven', 'default', 'classic'));
536
+		if ( ! $extract_templates) {
537
+			$wp_dir = dirname(dirname(dirname($dir)));
538
+			$extract_templates = file_exists("$wp_dir/wp-admin/user/about.php") || ! file_exists("$wp_dir/wp-load.php");
539 539
 		}
540
-		if ( $extract_templates ) {
541
-			$res = $potextmeta->append( $dir, $output, array( 'Template Name' ) );
542
-			if ( ! $res )
540
+		if ($extract_templates) {
541
+			$res = $potextmeta->append($dir, $output, array('Template Name'));
542
+			if ( ! $res)
543 543
 				return false;
544
-			$files = scandir( $dir );
545
-			foreach ( $files as $file ) {
546
-				if ( '.' == $file[0] || 'CVS' == $file )
544
+			$files = scandir($dir);
545
+			foreach ($files as $file) {
546
+				if ('.' == $file[0] || 'CVS' == $file)
547 547
 					continue;
548
-				if ( is_dir( $dir . '/' . $file ) ) {
549
-					$res = $potextmeta->append( $dir . '/' . $file, $output, array( 'Template Name' ) );
550
-					if ( ! $res )
548
+				if (is_dir($dir.'/'.$file)) {
549
+					$res = $potextmeta->append($dir.'/'.$file, $output, array('Template Name'));
550
+					if ( ! $res)
551 551
 						return false;
552 552
 				}
553 553
 			}
@@ -558,54 +558,54 @@  discard block
 block discarded – undo
558 558
 		return $res;
559 559
 	}
560 560
 
561
-	public function glotpress( $dir, $output ) {
562
-		$output = is_null( $output ) ? "glotpress.pot" : $output;
563
-		return $this->xgettext( 'glotpress', $dir, $output );
561
+	public function glotpress($dir, $output) {
562
+		$output = is_null($output) ? "glotpress.pot" : $output;
563
+		return $this->xgettext('glotpress', $dir, $output);
564 564
 	}
565 565
 
566
-	public function wporg_bb_forums( $dir, $output ) {
567
-		$output = is_null( $output ) ? 'wporg.pot' : $output;
568
-		return $this->xgettext( 'wporg-bb-forums', $dir, $output, array(), array(
566
+	public function wporg_bb_forums($dir, $output) {
567
+		$output = is_null($output) ? 'wporg.pot' : $output;
568
+		return $this->xgettext('wporg-bb-forums', $dir, $output, array(), array(
569 569
 			'bb-plugins/elfakismet/.*',
570 570
 			'bb-plugins/support-forum/.*',
571 571
 			'themes/.*',
572
-		) );
572
+		));
573 573
 	}
574 574
 
575
-	public function wporg_themes( $dir, $output ) {
576
-		$output = is_null( $output ) ? 'wporg-themes.pot' : $output;
577
-		return $this->xgettext( 'wporg', $dir, $output, array(), array(), array(
575
+	public function wporg_themes($dir, $output) {
576
+		$output = is_null($output) ? 'wporg-themes.pot' : $output;
577
+		return $this->xgettext('wporg', $dir, $output, array(), array(), array(
578 578
 			'plugins/theme-directory/.*',
579 579
 			'themes/pub/wporg-themes/.*'
580
-		) );
580
+		));
581 581
 	}
582 582
 
583
-	public function wporg_plugins( $dir, $output ) {
584
-		$output = is_null( $output ) ? 'wporg-plugins.pot' : $output;
585
-		return $this->xgettext( 'wporg', $dir, $output, array(), array(
583
+	public function wporg_plugins($dir, $output) {
584
+		$output = is_null($output) ? 'wporg-plugins.pot' : $output;
585
+		return $this->xgettext('wporg', $dir, $output, array(), array(
586 586
 			'plugins/svn-track/i18n-tools/.*'
587 587
 			), array(
588 588
 			'.*\.php',
589
-		) );
589
+		));
590 590
 	}
591 591
 
592
-	public function wporg_forums( $dir, $output ) {
593
-		$output = is_null( $output ) ? 'wporg-forums.pot' : $output;
594
-		return $this->xgettext( 'wporg', $dir, $output, array(), array(), array(
592
+	public function wporg_forums($dir, $output) {
593
+		$output = is_null($output) ? 'wporg-forums.pot' : $output;
594
+		return $this->xgettext('wporg', $dir, $output, array(), array(), array(
595 595
 			'.*\.php',
596
-		) );
596
+		));
597 597
 	}
598 598
 
599
-	public function wordcamporg( $dir, $output ) {
600
-		$output = is_null( $output ) ? 'wordcamporg.pot' : $output;
601
-		return $this->xgettext( 'wordcamporg', $dir, $output, array(), array(), array(
599
+	public function wordcamporg($dir, $output) {
600
+		$output = is_null($output) ? 'wordcamporg.pot' : $output;
601
+		return $this->xgettext('wordcamporg', $dir, $output, array(), array(), array(
602 602
 			'.*\.php',
603
-		) );
603
+		));
604 604
 	}
605 605
 
606
-	public function rosetta( $dir, $output ) {
607
-		$output = is_null( $output )? 'rosetta.pot' : $output;
608
-		return $this->xgettext( 'rosetta', $dir, $output, array(), array(
606
+	public function rosetta($dir, $output) {
607
+		$output = is_null($output) ? 'rosetta.pot' : $output;
608
+		return $this->xgettext('rosetta', $dir, $output, array(), array(
609 609
 			'mu-plugins/rosetta/i18n-tools/.*',
610 610
 			'mu-plugins/rosetta/locales/.*',
611 611
 			), array(
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 			'mu-plugins/rosetta/[^/]+\.php',
616 616
 			'mu-plugins/rosetta/tmpl/.*\.php',
617 617
 			'themes/rosetta/.*\.php',
618
-		) );
618
+		));
619 619
 	}
620 620
 }
621 621
 
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
 if ($included_files[0] == __FILE__) {
626 626
 	$makepot = new MakePOT;
627 627
 	if ((3 == count($argv) || 4 == count($argv)) && in_array($method = str_replace('-', '_', $argv[1]), get_class_methods($makepot))) {
628
-		$res = call_user_func(array($makepot, $method), realpath($argv[2]), isset($argv[3])? $argv[3] : null);
628
+		$res = call_user_func(array($makepot, $method), realpath($argv[2]), isset($argv[3]) ? $argv[3] : null);
629 629
 		if (false === $res) {
630 630
 			fwrite(STDERR, "Couldn't generate POT file!\n");
631 631
 		}
Please login to merge, or discard this patch.
Braces   +61 added lines, -34 removed lines patch added patch discarded remove patch
@@ -152,8 +152,9 @@  discard block
 block discarded – undo
152 152
 	}
153 153
 
154 154
 	public function __destruct() {
155
-		foreach ( $this->temp_files as $temp_file )
156
-			unlink( $temp_file );
155
+		foreach ( $this->temp_files as $temp_file ) {
156
+					unlink( $temp_file );
157
+		}
157 158
 	}
158 159
 
159 160
 	private function tempnam( $file ) {
@@ -211,13 +212,16 @@  discard block
 block discarded – undo
211 212
 		$args = array_merge( $defaults, $args );
212 213
 		extract( $args );
213 214
 		$placeholders = array();
214
-		if ( $wp_version = $this->wp_version( $dir ) )
215
-			$placeholders['version'] = $wp_version;
216
-		else
217
-			return false;
215
+		if ( $wp_version = $this->wp_version( $dir ) ) {
216
+					$placeholders['version'] = $wp_version;
217
+		} else {
218
+					return false;
219
+		}
218 220
 		$output = is_null( $output )? $default_output : $output;
219 221
 		$res = $this->xgettext( $project, $dir, $output, $placeholders, $excludes, $includes );
220
-		if ( !$res ) return false;
222
+		if ( !$res ) {
223
+			return false;
224
+		}
221 225
 
222 226
 		if ( $extract_not_gettexted ) {
223 227
 			$old_dir = getcwd();
@@ -307,21 +311,29 @@  discard block
 block discarded – undo
307 311
 	}
308 312
 
309 313
 	public function wp_network_admin($dir, $output) {
310
-		if ( ! file_exists( "$dir/wp-admin/user/about.php" ) ) return false;
314
+		if ( ! file_exists( "$dir/wp-admin/user/about.php" ) ) {
315
+			return false;
316
+		}
311 317
 
312 318
 		$frontend_pot = $this->tempnam( 'frontend.pot' );
313
-		if ( false === $frontend_pot ) return false;
319
+		if ( false === $frontend_pot ) {
320
+			return false;
321
+		}
314 322
 
315 323
 		$frontend_result = $this->wp_frontend( $dir, $frontend_pot );
316
-		if ( ! $frontend_result )
317
-			return false;
324
+		if ( ! $frontend_result ) {
325
+					return false;
326
+		}
318 327
 
319 328
 		$admin_pot = $this->tempnam( 'admin.pot' );
320
-		if ( false === $admin_pot ) return false;
329
+		if ( false === $admin_pot ) {
330
+			return false;
331
+		}
321 332
 
322 333
 		$admin_result = $this->wp_admin( $dir, $admin_pot );
323
-		if ( ! $admin_result )
324
-			return false;
334
+		if ( ! $admin_result ) {
335
+					return false;
336
+		}
325 337
 
326 338
 		$result = $this->wp_generic( $dir, array(
327 339
 			'project' => 'wp-network-admin', 'output' => $output,
@@ -335,8 +347,9 @@  discard block
 block discarded – undo
335 347
 		}
336 348
 
337 349
 		$common_pot = $this->tempnam( 'common.pot' );
338
-		if ( ! $common_pot )
339
-			return false;
350
+		if ( ! $common_pot ) {
351
+					return false;
352
+		}
340 353
 
341 354
 		$net_admin_pot = realpath( is_null( $output ) ? 'wordpress-network-admin.pot' : $output );
342 355
 		system( "msgcat --more-than=1 --use-first $frontend_pot $admin_pot $net_admin_pot > $common_pot" );
@@ -372,17 +385,23 @@  discard block
 block discarded – undo
372 385
 
373 386
 	private function wp_version( $dir ) {
374 387
 		$version_php = $dir.'/wp-includes/version.php';
375
-		if ( !is_readable( $version_php ) ) return false;
388
+		if ( !is_readable( $version_php ) ) {
389
+			return false;
390
+		}
376 391
 		return preg_match( '/\$wp_version\s*=\s*\'(.*?)\';/', file_get_contents( $version_php ), $matches )? $matches[1] : false;
377 392
 	}
378 393
 
379 394
 	public function get_first_lines($filename, $lines = 30) {
380 395
 		$extf = fopen($filename, 'r');
381
-		if (!$extf) return false;
396
+		if (!$extf) {
397
+			return false;
398
+		}
382 399
 		$first_lines = '';
383 400
 		foreach(range(1, $lines) as $x) {
384 401
 			$line = fgets($extf);
385
-			if (feof($extf)) break;
402
+			if (feof($extf)) {
403
+				break;
404
+			}
386 405
 			if (false === $line) {
387 406
 				return false;
388 407
 			}
@@ -494,7 +513,9 @@  discard block
 block discarded – undo
494 513
 
495 514
 		$output = is_null($output)? "$slug.pot" : $output;
496 515
 		$res = $this->xgettext( 'wp-plugin', $dir, $output, $placeholders, $args['excludes'], $args['includes'] );
497
-		if (!$res) return false;
516
+		if (!$res) {
517
+			return false;
518
+		}
498 519
 		$potextmeta = new PotExtMeta;
499 520
 		$res = $potextmeta->append($main_file, $output);
500 521
 		/* Adding non-gettexted strings can repeat some phrases */
@@ -518,19 +539,22 @@  discard block
 block discarded – undo
518 539
 		$placeholders['slug'] = $slug;
519 540
 
520 541
 		$license = $this->get_addon_header( 'License', $source );
521
-		if ( $license )
522
-			$this->meta['wp-theme']['comments'] = "Copyright (C) {year} {author}\nThis file is distributed under the {$license}.";
523
-		else
524
-			$this->meta['wp-theme']['comments'] = "Copyright (C) {year} {author}\nThis file is distributed under the same license as the {package-name} package.";
542
+		if ( $license ) {
543
+					$this->meta['wp-theme']['comments'] = "Copyright (C) {year} {author}\nThis file is distributed under the {$license}.";
544
+		} else {
545
+					$this->meta['wp-theme']['comments'] = "Copyright (C) {year} {author}\nThis file is distributed under the same license as the {package-name} package.";
546
+		}
525 547
 
526 548
 		$output = is_null($output)? "$slug.pot" : $output;
527 549
 		$res = $this->xgettext('wp-theme', $dir, $output, $placeholders);
528
-		if (! $res )
529
-			return false;
550
+		if (! $res ) {
551
+					return false;
552
+		}
530 553
 		$potextmeta = new PotExtMeta;
531 554
 		$res = $potextmeta->append( $main_file, $output, array( 'Theme Name', 'Theme URI', 'Description', 'Author', 'Author URI' ) );
532
-		if ( ! $res )
533
-			return false;
555
+		if ( ! $res ) {
556
+					return false;
557
+		}
534 558
 		// If we're dealing with a pre-3.4 default theme, don't extract page templates before 3.4.
535 559
 		$extract_templates = ! in_array( $slug, array( 'twentyten', 'twentyeleven', 'default', 'classic' ) );
536 560
 		if ( ! $extract_templates ) {
@@ -539,16 +563,19 @@  discard block
 block discarded – undo
539 563
 		}
540 564
 		if ( $extract_templates ) {
541 565
 			$res = $potextmeta->append( $dir, $output, array( 'Template Name' ) );
542
-			if ( ! $res )
543
-				return false;
566
+			if ( ! $res ) {
567
+							return false;
568
+			}
544 569
 			$files = scandir( $dir );
545 570
 			foreach ( $files as $file ) {
546
-				if ( '.' == $file[0] || 'CVS' == $file )
547
-					continue;
571
+				if ( '.' == $file[0] || 'CVS' == $file ) {
572
+									continue;
573
+				}
548 574
 				if ( is_dir( $dir . '/' . $file ) ) {
549 575
 					$res = $potextmeta->append( $dir . '/' . $file, $output, array( 'Template Name' ) );
550
-					if ( ! $res )
551
-						return false;
576
+					if ( ! $res ) {
577
+											return false;
578
+					}
552 579
 				}
553 580
 			}
554 581
 		}
Please login to merge, or discard this patch.
tools/i18n/add-textdomain.php 2 patches
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  */
8 8
 error_reporting(E_ALL);
9 9
 
10
-require_once dirname( __FILE__ ) . '/makepot.php';
10
+require_once dirname(__FILE__).'/makepot.php';
11 11
 
12 12
 class AddTextdomain {
13 13
 
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	 */
20 20
 	public function __construct() {
21 21
 		$makepot = new MakePOT;
22
-		$this->funcs = array_keys( $makepot->rules );
22
+		$this->funcs = array_keys($makepot->rules);
23 23
 		$this->funcs[] = 'translate_nooped_plural';
24 24
 	}
25 25
 
@@ -41,13 +41,13 @@  discard block
 block discarded – undo
41 41
 	 * @param string $source_filename Filename with optional path.
42 42
 	 * @param bool   $inplace         True to modifies the PHP file in place. False to print to standard output.
43 43
 	 */
44
-	public function process_file( $domain, $source_filename, $inplace ) {
45
-		$new_source = $this->process_string( $domain, file_get_contents( $source_filename ) );
44
+	public function process_file($domain, $source_filename, $inplace) {
45
+		$new_source = $this->process_string($domain, file_get_contents($source_filename));
46 46
 
47
-		if ( $inplace ) {
48
-			$f = fopen( $source_filename, 'w' );
49
-			fwrite( $f, $new_source );
50
-			fclose( $f );
47
+		if ($inplace) {
48
+			$f = fopen($source_filename, 'w');
49
+			fwrite($f, $new_source);
50
+			fclose($f);
51 51
 		} else {
52 52
 			echo $new_source;
53 53
 		}
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
 	 * @param string $string PHP code to parse.
65 65
 	 * @return string Modified source.
66 66
 	 */
67
-	public function process_string( $domain, $string ) {
68
-		$tokens = token_get_all( $string );
69
-		return $this->process_tokens( $domain, $tokens );
67
+	public function process_string($domain, $string) {
68
+		$tokens = token_get_all($string);
69
+		return $this->process_tokens($domain, $tokens);
70 70
 	}
71 71
 
72 72
 	/**
@@ -79,16 +79,16 @@  discard block
 block discarded – undo
79 79
 	 *                       number in element 2.
80 80
 	 * @return string Modified source.
81 81
 	 */
82
-	public function process_tokens( $domain, $tokens ) {
82
+	public function process_tokens($domain, $tokens) {
83 83
 		$this->modified_contents = '';
84
-		$domain = addslashes( $domain );
84
+		$domain = addslashes($domain);
85 85
 
86 86
 		$in_func = false;
87 87
 		$args_started = false;
88 88
 		$parens_balance = 0;
89 89
 		$found_domain = false;
90 90
 
91
-		foreach($tokens as $index => $token) {
91
+		foreach ($tokens as $index => $token) {
92 92
 			$string_success = false;
93 93
 			if (is_array($token)) {
94 94
 				list($id, $text) = $token;
@@ -103,18 +103,18 @@  discard block
 block discarded – undo
103 103
 					}
104 104
 				}
105 105
 				$token = $text;
106
-			} elseif ('(' == $token){
106
+			} elseif ('(' == $token) {
107 107
 				$args_started = true;
108 108
 				++$parens_balance;
109 109
 			} elseif (')' == $token) {
110 110
 				--$parens_balance;
111 111
 				if ($in_func && 0 == $parens_balance) {
112
-					if ( ! $found_domain ) {
112
+					if ( ! $found_domain) {
113 113
 						$token = ", '$domain'";
114
-						if ( T_WHITESPACE == $tokens[ $index - 1 ][0] ) {
114
+						if (T_WHITESPACE == $tokens[$index - 1][0]) {
115 115
 							$token .= ' '; // Maintain code standards if previously present
116 116
 							// Remove previous whitespace token to account for it.
117
-							$this->modified_contents = trim( $this->modified_contents );
117
+							$this->modified_contents = trim($this->modified_contents);
118 118
 						}
119 119
 						$token .= ')';
120 120
 					}
@@ -135,26 +135,26 @@  discard block
 block discarded – undo
135 135
 if ($included_files[0] == __FILE__) {
136 136
 	$adddomain = new AddTextdomain();
137 137
 
138
-	if (!isset($argv[1]) || !isset($argv[2])) {
138
+	if ( ! isset($argv[1]) || ! isset($argv[2])) {
139 139
 		$adddomain->usage();
140 140
 	}
141 141
 
142 142
 	$inplace = false;
143 143
 	if ('-i' == $argv[1]) {
144 144
 		$inplace = true;
145
-		if (!isset($argv[3])) $adddomain->usage();
145
+		if ( ! isset($argv[3])) $adddomain->usage();
146 146
 		array_shift($argv);
147 147
 	}
148 148
 
149
-	if ( is_dir( $argv[2] ) ) {
150
-		$directory = new RecursiveDirectoryIterator( $argv[2], RecursiveDirectoryIterator::SKIP_DOTS );
151
-		$files = new RecursiveIteratorIterator( $directory );
152
-		foreach ( $files as $file ) {
153
-			if ( 'php' === $file->getExtension() ) {
154
-				$adddomain->process_file( $argv[1], $file->getPathname(), $inplace );
149
+	if (is_dir($argv[2])) {
150
+		$directory = new RecursiveDirectoryIterator($argv[2], RecursiveDirectoryIterator::SKIP_DOTS);
151
+		$files = new RecursiveIteratorIterator($directory);
152
+		foreach ($files as $file) {
153
+			if ('php' === $file->getExtension()) {
154
+				$adddomain->process_file($argv[1], $file->getPathname(), $inplace);
155 155
 			}
156 156
 		}
157 157
 	} else {
158
-		$adddomain->process_file( $argv[1], $argv[2], $inplace );
158
+		$adddomain->process_file($argv[1], $argv[2], $inplace);
159 159
 	}
160 160
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -142,7 +142,9 @@
 block discarded – undo
142 142
 	$inplace = false;
143 143
 	if ('-i' == $argv[1]) {
144 144
 		$inplace = true;
145
-		if (!isset($argv[3])) $adddomain->usage();
145
+		if (!isset($argv[3])) {
146
+			$adddomain->usage();
147
+		}
146 148
 		array_shift($argv);
147 149
 	}
148 150
 
Please login to merge, or discard this patch.
tools/i18n/t/AddTextdomainTest.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -5,8 +5,8 @@  discard block
 block discarded – undo
5 5
  * @package wordpress-i18n
6 6
  * @subpackage tools
7 7
  */
8
-error_reporting( E_ALL );
9
-require_once dirname( dirname( __FILE__ ) ) . '/add-textdomain.php';
8
+error_reporting(E_ALL);
9
+require_once dirname(dirname(__FILE__)).'/add-textdomain.php';
10 10
 
11 11
 class AddTextDomainTest extends PHPUnit_Framework_TestCase {
12 12
 
@@ -17,30 +17,30 @@  discard block
 block discarded – undo
17 17
 
18 18
 	function test_add() {
19 19
 		// Copy to a new file, so that we don't corrupt the old one.
20
-		copy( 'data/add-textdomain-0.php', 'data/add-textdomain-0-work.php' );
21
-		$this->atd->process_file( 'test-domain', 'data/add-textdomain-0-work.php', true );
22
-		$this->assertEquals( file_get_contents( 'data/add-textdomain-0-result.php' ), file_get_contents( 'data/add-textdomain-0-work.php' ) );
23
-		unlink( 'data/add-textdomain-0-work.php' );
20
+		copy('data/add-textdomain-0.php', 'data/add-textdomain-0-work.php');
21
+		$this->atd->process_file('test-domain', 'data/add-textdomain-0-work.php', true);
22
+		$this->assertEquals(file_get_contents('data/add-textdomain-0-result.php'), file_get_contents('data/add-textdomain-0-work.php'));
23
+		unlink('data/add-textdomain-0-work.php');
24 24
 	}
25 25
 
26 26
 	/**
27 27
 	 * @dataProvider data_textdomain_sources
28 28
 	 */
29
-	function test_basic_add_textdomain( $source, $expected ) {
30
-		$tokens = token_get_all( $source );
31
-		$result = $this->atd->process_tokens( 'foo', $tokens );
32
-		$this->assertEquals( $expected, $result );
29
+	function test_basic_add_textdomain($source, $expected) {
30
+		$tokens = token_get_all($source);
31
+		$result = $this->atd->process_tokens('foo', $tokens);
32
+		$this->assertEquals($expected, $result);
33 33
 	}
34 34
 
35 35
 	function data_textdomain_sources() {
36 36
 		return array(
37
-			array( "<?php __('string'); ?>", "<?php __('string', 'foo'); ?>" ), // Simple single quotes
38
-			array( '<?php __("string"); ?>', "<?php __(\"string\", 'foo'); ?>" ), // Simple double quotes
39
-			array( "<?php __( 'string' ); ?>", "<?php __( 'string', 'foo' ); ?>" ), // Simple single quotes CS
40
-			array( '<?php __( "string" ); ?>', "<?php __( \"string\", 'foo' ); ?>" ), // Simple double quotes CS
41
-			array( "<?php __( 'string', 'string2' ); ?>", "<?php __( 'string', 'string2', 'foo' ); ?>" ), // Multiple string args
42
-			array( '<?php __( \'string\', $var ); ?>', '<?php __( \'string\', $var, \'foo\' ); ?>' ), // Multiple string / var args
43
-			array( "<?php __( 'string', 'foo' ); ?>", "<?php __( 'string', 'foo' ); ?>" ), // Existing textdomain
37
+			array("<?php __('string'); ?>", "<?php __('string', 'foo'); ?>"), // Simple single quotes
38
+			array('<?php __("string"); ?>', "<?php __(\"string\", 'foo'); ?>"), // Simple double quotes
39
+			array("<?php __( 'string' ); ?>", "<?php __( 'string', 'foo' ); ?>"), // Simple single quotes CS
40
+			array('<?php __( "string" ); ?>', "<?php __( \"string\", 'foo' ); ?>"), // Simple double quotes CS
41
+			array("<?php __( 'string', 'string2' ); ?>", "<?php __( 'string', 'string2', 'foo' ); ?>"), // Multiple string args
42
+			array('<?php __( \'string\', $var ); ?>', '<?php __( \'string\', $var, \'foo\' ); ?>'), // Multiple string / var args
43
+			array("<?php __( 'string', 'foo' ); ?>", "<?php __( 'string', 'foo' ); ?>"), // Existing textdomain
44 44
 		);
45 45
 	}
46 46
 }
Please login to merge, or discard this patch.
tools/i18n/t/ExtractTest.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-require_once dirname( dirname( __FILE__ ) ) . '/extract.php';
3
+require_once dirname(dirname(__FILE__)).'/extract.php';
4 4
 
5 5
 class ExtractTest extends PHPUnit_Framework_TestCase {
6 6
 
@@ -12,126 +12,126 @@  discard block
 block discarded – undo
12 12
 	}
13 13
 
14 14
 	function test_with_just_a_string() {
15
-		$expected = new Translation_Entry( array( 'singular' => 'baba', 'references' => array('baba.php:1') ) );
16
-		$result = $this->extractor->extract_from_code('<?php __("baba"); ?>', 'baba.php' );
17
-		$this->assertEquals( $expected, $result->entries['baba'] );
15
+		$expected = new Translation_Entry(array('singular' => 'baba', 'references' => array('baba.php:1')));
16
+		$result = $this->extractor->extract_from_code('<?php __("baba"); ?>', 'baba.php');
17
+		$this->assertEquals($expected, $result->entries['baba']);
18 18
 	}
19 19
 
20 20
 	function test_entry_from_call_simple() {
21
-		$entry = $this->extractor->entry_from_call( array( 'name' => '__', 'args' => array('baba') ), 'baba.php' );
22
-		$this->assertEquals( $entry, new Translation_Entry( array( 'singular' => 'baba' ) ) );
21
+		$entry = $this->extractor->entry_from_call(array('name' => '__', 'args' => array('baba')), 'baba.php');
22
+		$this->assertEquals($entry, new Translation_Entry(array('singular' => 'baba')));
23 23
 	}
24 24
 
25 25
 	function test_entry_from_call_nonexisting_function() {
26
-		$entry = $this->extractor->entry_from_call( array( 'name' => 'f', 'args' => array('baba') ), 'baba.php' );
27
-		$this->assertEquals( $entry, null );
26
+		$entry = $this->extractor->entry_from_call(array('name' => 'f', 'args' => array('baba')), 'baba.php');
27
+		$this->assertEquals($entry, null);
28 28
 	}
29 29
 
30 30
 	function test_entry_from_call_too_few_args() {
31
-		$entry = $this->extractor->entry_from_call( array( 'name' => '__', 'args' => array() ), 'baba.php' );
32
-		$this->assertEquals( $entry, null );
31
+		$entry = $this->extractor->entry_from_call(array('name' => '__', 'args' => array()), 'baba.php');
32
+		$this->assertEquals($entry, null);
33 33
 	}
34 34
 
35 35
 	function test_entry_from_call_non_expected_null_arg() {
36
-		$this->extractor->rules = array( '_nx' => array( 'singular', 'plural', 'context' ) );
37
-		$entry = $this->extractor->entry_from_call( array( 'name' => '_nx', 'args' => array('%s baba', null, 'noun') ), 'baba.php' );
38
-		$this->assertEquals( $entry, null );
36
+		$this->extractor->rules = array('_nx' => array('singular', 'plural', 'context'));
37
+		$entry = $this->extractor->entry_from_call(array('name' => '_nx', 'args' => array('%s baba', null, 'noun')), 'baba.php');
38
+		$this->assertEquals($entry, null);
39 39
 	}
40 40
 
41 41
 	function test_entry_from_call_more_args_should_be_ok() {
42
-		$this->extractor->rules = array( '__' => array('string') );
43
-		$entry = $this->extractor->entry_from_call( array( 'name' => '__', 'args' => array('baba', 5, 'pijo', null) ), 'baba.php' );
44
-		$this->assertEquals( $entry, new Translation_Entry( array( 'singular' => 'baba' ) ) );
42
+		$this->extractor->rules = array('__' => array('string'));
43
+		$entry = $this->extractor->entry_from_call(array('name' => '__', 'args' => array('baba', 5, 'pijo', null)), 'baba.php');
44
+		$this->assertEquals($entry, new Translation_Entry(array('singular' => 'baba')));
45 45
 	}
46 46
 
47 47
 
48 48
 	function test_entry_from_call_context() {
49
-		$this->extractor->rules = array( '_x' => array( 'string', 'context' ) );
50
-		$entry = $this->extractor->entry_from_call( array( 'name' => '_x', 'args' => array('baba', 'noun') ), 'baba.php' );
51
-		$this->assertEquals( $entry, new Translation_Entry( array( 'singular' => 'baba', 'context' => 'noun' ) ) );
49
+		$this->extractor->rules = array('_x' => array('string', 'context'));
50
+		$entry = $this->extractor->entry_from_call(array('name' => '_x', 'args' => array('baba', 'noun')), 'baba.php');
51
+		$this->assertEquals($entry, new Translation_Entry(array('singular' => 'baba', 'context' => 'noun')));
52 52
 	}
53 53
 
54 54
 	function test_entry_from_call_plural() {
55
-		$this->extractor->rules = array( '_n' => array( 'singular', 'plural' ) );
56
-		$entry = $this->extractor->entry_from_call( array( 'name' => '_n', 'args' => array('%s baba', '%s babas') ), 'baba.php' );
57
-		$this->assertEquals( $entry, new Translation_Entry( array( 'singular' => '%s baba', 'plural' => '%s babas' ) ) );
55
+		$this->extractor->rules = array('_n' => array('singular', 'plural'));
56
+		$entry = $this->extractor->entry_from_call(array('name' => '_n', 'args' => array('%s baba', '%s babas')), 'baba.php');
57
+		$this->assertEquals($entry, new Translation_Entry(array('singular' => '%s baba', 'plural' => '%s babas')));
58 58
 	}
59 59
 
60 60
 	function test_entry_from_call_plural_and_context() {
61
-		$this->extractor->rules = array( '_nx' => array( 'singular', 'plural', 'context' ) );
62
-		$entry = $this->extractor->entry_from_call( array( 'name' => '_nx', 'args' => array('%s baba', '%s babas', 'noun') ), 'baba.php' );
63
-		$this->assertEquals( $entry, new Translation_Entry( array( 'singular' => '%s baba', 'plural' => '%s babas', 'context' => 'noun' ) ) );
61
+		$this->extractor->rules = array('_nx' => array('singular', 'plural', 'context'));
62
+		$entry = $this->extractor->entry_from_call(array('name' => '_nx', 'args' => array('%s baba', '%s babas', 'noun')), 'baba.php');
63
+		$this->assertEquals($entry, new Translation_Entry(array('singular' => '%s baba', 'plural' => '%s babas', 'context' => 'noun')));
64 64
 	}
65 65
 
66 66
 	function test_entry_from_call_extracted_comment() {
67
-		$entry = $this->extractor->entry_from_call( array( 'name' => '__', 'args' => array('baba'), 'comment' => 'translators: give me back my pants!' ), 'baba.php' );
68
-		$this->assertEquals( $entry, new Translation_Entry( array( 'singular' => 'baba', 'extracted_comments' => "translators: give me back my pants!\n" ) ) );
67
+		$entry = $this->extractor->entry_from_call(array('name' => '__', 'args' => array('baba'), 'comment' => 'translators: give me back my pants!'), 'baba.php');
68
+		$this->assertEquals($entry, new Translation_Entry(array('singular' => 'baba', 'extracted_comments' => "translators: give me back my pants!\n")));
69 69
 	}
70 70
 
71 71
 	function test_entry_from_call_line_number() {
72
-		$entry = $this->extractor->entry_from_call( array( 'name' => '__', 'args' => array('baba'), 'line' => 10 ), 'baba.php' );
73
-		$this->assertEquals( $entry, new Translation_Entry( array( 'singular' => 'baba', 'references' => array('baba.php:10') ) ) );
72
+		$entry = $this->extractor->entry_from_call(array('name' => '__', 'args' => array('baba'), 'line' => 10), 'baba.php');
73
+		$this->assertEquals($entry, new Translation_Entry(array('singular' => 'baba', 'references' => array('baba.php:10'))));
74 74
 	}
75 75
 
76 76
 	function test_entry_from_call_zero() {
77
-		$entry = $this->extractor->entry_from_call( array( 'name' => '__', 'args' => array('0') ), 'baba.php' );
78
-		$this->assertEquals( $entry, new Translation_Entry( array( 'singular' => '0' ) ) );
77
+		$entry = $this->extractor->entry_from_call(array('name' => '__', 'args' => array('0')), 'baba.php');
78
+		$this->assertEquals($entry, new Translation_Entry(array('singular' => '0')));
79 79
 	}
80 80
 
81 81
 	function test_entry_from_call_multiple() {
82
-		$this->extractor->rules = array( 'c' => array( 'string', 'singular', 'plural' ) );
83
-		$entries = $this->extractor->entry_from_call( array( 'name' => 'c', 'args' => array('baba', 'dyado', 'dyados') ), 'baba.php' );
84
-		$this->assertEquals( array(
85
-				new Translation_Entry( array( 'singular' => 'baba' ) ), new Translation_Entry( array( 'singular' => 'dyado', 'plural' => 'dyados' ) ) ), $entries );
82
+		$this->extractor->rules = array('c' => array('string', 'singular', 'plural'));
83
+		$entries = $this->extractor->entry_from_call(array('name' => 'c', 'args' => array('baba', 'dyado', 'dyados')), 'baba.php');
84
+		$this->assertEquals(array(
85
+				new Translation_Entry(array('singular' => 'baba')), new Translation_Entry(array('singular' => 'dyado', 'plural' => 'dyados')) ), $entries);
86 86
 	}
87 87
 
88 88
 	function test_entry_from_call_multiple_first_plural_then_two_strings() {
89
-		$this->extractor->rules = array( 'c' => array( 'singular', 'plural', null, 'string', 'string' ) );
90
-		$entries = $this->extractor->entry_from_call( array( 'name' => 'c', 'args' => array('dyado', 'dyados', 'baba', 'foo', 'bar') ), 'baba.php' );
91
-		$this->assertEquals( array(
92
-				new Translation_Entry( array( 'singular' => 'dyado', 'plural' => 'dyados' ) ),
93
-				new Translation_Entry( array( 'singular' => 'foo' ) ),
94
-				new Translation_Entry( array( 'singular' => 'bar' ) ) ), $entries );
89
+		$this->extractor->rules = array('c' => array('singular', 'plural', null, 'string', 'string'));
90
+		$entries = $this->extractor->entry_from_call(array('name' => 'c', 'args' => array('dyado', 'dyados', 'baba', 'foo', 'bar')), 'baba.php');
91
+		$this->assertEquals(array(
92
+				new Translation_Entry(array('singular' => 'dyado', 'plural' => 'dyados')),
93
+				new Translation_Entry(array('singular' => 'foo')),
94
+				new Translation_Entry(array('singular' => 'bar')) ), $entries);
95 95
 	}
96 96
 
97 97
 	function test_find_function_calls_one_arg_literal() {
98
-		$this->assertEquals( array( array( 'name' => '__', 'args' => array( 'baba' ), 'line' => 1 ) ), $this->extractor->find_function_calls( array('__'), '<?php __("baba"); ?>' ) );
98
+		$this->assertEquals(array(array('name' => '__', 'args' => array('baba'), 'line' => 1)), $this->extractor->find_function_calls(array('__'), '<?php __("baba"); ?>'));
99 99
 	}
100 100
 
101 101
 	function test_find_function_calls_one_arg_zero() {
102
-		$this->assertEquals( array( array( 'name' => '__', 'args' => array( '0' ), 'line' => 1 ) ), $this->extractor->find_function_calls( array('__'), '<?php __("0"); ?>' ) );
102
+		$this->assertEquals(array(array('name' => '__', 'args' => array('0'), 'line' => 1)), $this->extractor->find_function_calls(array('__'), '<?php __("0"); ?>'));
103 103
 	}
104 104
 
105 105
 	function test_find_function_calls_one_arg_non_literal() {
106
-		$this->assertEquals( array( array( 'name' => '__', 'args' => array( null ), 'line' => 1 ) ), $this->extractor->find_function_calls( array('__'), '<?php __("baba" . "dudu"); ?>' ) );
106
+		$this->assertEquals(array(array('name' => '__', 'args' => array(null), 'line' => 1)), $this->extractor->find_function_calls(array('__'), '<?php __("baba" . "dudu"); ?>'));
107 107
 	}
108 108
 
109 109
 	function test_find_function_calls_shouldnt_be_mistaken_by_a_class() {
110
-		$this->assertEquals( array(), $this->extractor->find_function_calls( array('__'), '<?php class __ { }; ("dyado");' ) );
110
+		$this->assertEquals(array(), $this->extractor->find_function_calls(array('__'), '<?php class __ { }; ("dyado");'));
111 111
 	}
112 112
 
113 113
 	function test_find_function_calls_2_args_bad_literal() {
114
-		$this->assertEquals( array( array( 'name' => 'f', 'args' => array( null, "baba" ), 'line' => 1 ) ), $this->extractor->find_function_calls( array('f'), '<?php f(5, "baba" ); ' ) );
114
+		$this->assertEquals(array(array('name' => 'f', 'args' => array(null, "baba"), 'line' => 1)), $this->extractor->find_function_calls(array('f'), '<?php f(5, "baba" ); '));
115 115
 	}
116 116
 
117 117
 	function test_find_function_calls_2_args_bad_literal_bad() {
118
-		$this->assertEquals( array( array( 'name' => 'f', 'args' => array( null, "baba", null ), 'line' => 1 ) ), $this->extractor->find_function_calls( array('f'), '<?php f(5, "baba", 5 ); ' ) );
118
+		$this->assertEquals(array(array('name' => 'f', 'args' => array(null, "baba", null), 'line' => 1)), $this->extractor->find_function_calls(array('f'), '<?php f(5, "baba", 5 ); '));
119 119
 	}
120 120
 
121 121
 	function test_find_function_calls_1_arg_bad_concat() {
122
-		$this->assertEquals( array( array( 'name' => 'f', 'args' => array( null ), 'line' => 1 ) ), $this->extractor->find_function_calls( array('f'), '<?php f( "baba" . "baba" ); ' ) );
122
+		$this->assertEquals(array(array('name' => 'f', 'args' => array(null), 'line' => 1)), $this->extractor->find_function_calls(array('f'), '<?php f( "baba" . "baba" ); '));
123 123
 	}
124 124
 
125 125
 	function test_find_function_calls_1_arg_bad_function_call() {
126
-		$this->assertEquals( array( array( 'name' => 'f', 'args' => array( null ), 'line' => 1 ) ), $this->extractor->find_function_calls( array('f'), '<?php f( g( "baba" ) ); ' ) );
126
+		$this->assertEquals(array(array('name' => 'f', 'args' => array(null), 'line' => 1)), $this->extractor->find_function_calls(array('f'), '<?php f( g( "baba" ) ); '));
127 127
 	}
128 128
 
129 129
 	function test_find_function_calls_2_arg_literal_bad() {
130
-		$this->assertEquals( array( array( 'name' => 'f', 'args' => array( "baba", null ), 'line' => 1 ) ), $this->extractor->find_function_calls( array('f'), '<?php f( "baba", null ); ' ) );
130
+		$this->assertEquals(array(array('name' => 'f', 'args' => array("baba", null), 'line' => 1)), $this->extractor->find_function_calls(array('f'), '<?php f( "baba", null ); '));
131 131
 	}
132 132
 
133 133
 	function test_find_function_calls_2_arg_bad_with_parens_literal() {
134
-		$this->assertEquals( array( array( 'name' => 'f', 'args' => array( null, "baba" ), 'line' => 1 ) ), $this->extractor->find_function_calls( array('f'), '<?php f( g( "dyado", "chicho", "lelya "), "baba" ); ' ) );
134
+		$this->assertEquals(array(array('name' => 'f', 'args' => array(null, "baba"), 'line' => 1)), $this->extractor->find_function_calls(array('f'), '<?php f( g( "dyado", "chicho", "lelya "), "baba" ); '));
135 135
 	}
136 136
 
137 137
 	/**
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
 	 */
140 140
 	function test_find_function_calls_with_comment() {
141 141
 		$this->assertEquals(
142
-			array( array( 'name' => 'f', 'args' => array( 'baba' ), 'line' => 1, 'comment' => 'translators: let your ears fly!' ) ),
143
-			$this->extractor->find_function_calls( array('f'), '<?php /* translators: let your ears fly! */ f( "baba" ); ' )
142
+			array(array('name' => 'f', 'args' => array('baba'), 'line' => 1, 'comment' => 'translators: let your ears fly!')),
143
+			$this->extractor->find_function_calls(array('f'), '<?php /* translators: let your ears fly! */ f( "baba" ); ')
144 144
 		);
145 145
 	}
146 146
 
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
 	 */
150 150
 	function test_find_function_calls_with_not_immediate_comment() {
151 151
 		$this->assertEquals(
152
-			array( array( 'name' => 'f', 'args' => array( 'baba' ), 'line' => 1, 'comment' => 'translators: let your ears fly!' ) ),
153
-			$this->extractor->find_function_calls( array('f'), '<?php /* translators: let your ears fly! */ $foo = g ( f( "baba" ) ); ' )
152
+			array(array('name' => 'f', 'args' => array('baba'), 'line' => 1, 'comment' => 'translators: let your ears fly!')),
153
+			$this->extractor->find_function_calls(array('f'), '<?php /* translators: let your ears fly! */ $foo = g ( f( "baba" ) ); ')
154 154
 		);
155 155
 	}
156 156
 
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
 	 */
160 160
 	function test_find_function_calls_with_not_immediate_comment_include_only_latest() {
161 161
 		$this->assertEquals(
162
-			array( array( 'name' => 'f', 'args' => array( 'baba' ), 'line' => 1, 'comment' => 'translators: let your ears fly!' ) ),
163
-			$this->extractor->find_function_calls( array('f'), '<?php /* translators: boo */ /* translators: let your ears fly! */ /* baba */ $foo = g ( f( "baba" ) ); ' )
162
+			array(array('name' => 'f', 'args' => array('baba'), 'line' => 1, 'comment' => 'translators: let your ears fly!')),
163
+			$this->extractor->find_function_calls(array('f'), '<?php /* translators: boo */ /* translators: let your ears fly! */ /* baba */ $foo = g ( f( "baba" ) ); ')
164 164
 		);
165 165
 	}
166 166
 
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
 	 * @group comment
169 169
 	 */
170 170
 	function test_find_function_calls_with_multi_line_comment() {
171
-		$this->assertEquals( array( array(
172
-				'name' => '__', 'args' => array( 'on' ), 'line' => 6,
171
+		$this->assertEquals(array(array(
172
+				'name' => '__', 'args' => array('on'), 'line' => 6,
173 173
 				'comment' => "Translators: If there are characters in your language that are not supported by Lato, translate this to 'off'. Do not translate into your own language."
174
-			) ),
175
-			$this->extractor->find_function_calls( array( '__' ),
174
+			)),
175
+			$this->extractor->find_function_calls(array('__'),
176 176
 				"<?php
177 177
 				/*
178 178
 				 * Translators: If there are characters in your language that are not supported
@@ -187,11 +187,11 @@  discard block
 block discarded – undo
187 187
 	 * @group comment
188 188
 	 */
189 189
 	function test_find_function_calls_with_c_style_comment() {
190
-		$this->assertEquals( array( array(
191
-				'name' => '__', 'args' => array( 'on' ), 'line' => 3,
190
+		$this->assertEquals(array(array(
191
+				'name' => '__', 'args' => array('on'), 'line' => 3,
192 192
 				'comment' => 'translators: let your ears fly!'
193
-			) ),
194
-			$this->extractor->find_function_calls( array( '__' ),
193
+			)),
194
+			$this->extractor->find_function_calls(array('__'),
195 195
 				"<?php
196 196
 				// translators: let your ears fly!
197 197
 				__( 'on' );"
@@ -203,11 +203,11 @@  discard block
 block discarded – undo
203 203
 	 * @group comment
204 204
 	 */
205 205
 	function test_find_function_calls_with_url_in_comment() {
206
-		$this->assertEquals( array( array(
207
-				'name' => '__', 'args' => array( 'F j, Y g:i a' ), 'line' => 3,
206
+		$this->assertEquals(array(array(
207
+				'name' => '__', 'args' => array('F j, Y g:i a'), 'line' => 3,
208 208
 				'comment' => 'translators: localized date and time format, see http://php.net/date'
209
-			) ),
210
-			$this->extractor->find_function_calls( array( '__' ),
209
+			)),
210
+			$this->extractor->find_function_calls(array('__'),
211 211
 				"<?php
212 212
 				/* translators: localized date and time format, see http://php.net/date */
213 213
 				__( 'F j, Y g:i a' );"
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
 	 */
221 221
 	function test_comment_prefix_should_be_case_insensitive() {
222 222
 		$this->assertEquals(
223
-			array( array( 'name' => 'f', 'args' => array( 'baba' ), 'line' => 1, 'comment' => 'Translators: let your ears fly!' ) ),
224
-			$this->extractor->find_function_calls( array('f'), '<?php /* Translators: let your ears fly! */ f( "baba" ); ' )
223
+			array(array('name' => 'f', 'args' => array('baba'), 'line' => 1, 'comment' => 'Translators: let your ears fly!')),
224
+			$this->extractor->find_function_calls(array('f'), '<?php /* Translators: let your ears fly! */ f( "baba" ); ')
225 225
 		);
226 226
 	}
227 227
 }
Please login to merge, or discard this patch.
tools/i18n/t/data/add-textdomain-0-result.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@
 block discarded – undo
1 1
 <?php
2 2
 function call_some_i18n_methods() {
3
-	__( 'Hello World', 'test-domain' );
4
-	_e( 'Hello World', 'test-domain' );
5
-	_n( 'Single', 'Plural', 1, 'test-domain' );
6
-	_n_noop( 'Single Noop', 'Plural Noop', 1, 'test-domain' );
7
-	_x( 'Hello World', 'Testing', 'test-domain' );
8
-	_ex( 'Hello World', 'Testing', 'test-domain' );
9
-	_nx( 'Hello World', 'Testing', 'test-domain' );
10
-	_nx_noop( 'Hello World Noop', 'Testing', 'test-domain' );
11
-	esc_attr__( 'Attribute', 'test-domain' );
12
-	esc_html__( 'HTML', 'test-domain' );
13
-	esc_attr_e( 'Attribute', 'test-domain' );
14
-	esc_html_e( 'HTML', 'test-domain' );
15
-	esc_attr_x( 'Attribute', 'Testing', 'test-domain' );
16
-	esc_html_x( 'HTML', 'Testing', 'test-domain' );
17
-	translate_nooped_plural( 'Plural Noop', 2, 'test-domain' );
3
+	__('Hello World', 'test-domain');
4
+	_e('Hello World', 'test-domain');
5
+	_n('Single', 'Plural', 1, 'test-domain');
6
+	_n_noop('Single Noop', 'Plural Noop', 1, 'test-domain');
7
+	_x('Hello World', 'Testing', 'test-domain');
8
+	_ex('Hello World', 'Testing', 'test-domain');
9
+	_nx('Hello World', 'Testing', 'test-domain');
10
+	_nx_noop('Hello World Noop', 'Testing', 'test-domain');
11
+	esc_attr__('Attribute', 'test-domain');
12
+	esc_html__('HTML', 'test-domain');
13
+	esc_attr_e('Attribute', 'test-domain');
14
+	esc_html_e('HTML', 'test-domain');
15
+	esc_attr_x('Attribute', 'Testing', 'test-domain');
16
+	esc_html_x('HTML', 'Testing', 'test-domain');
17
+	translate_nooped_plural('Plural Noop', 2, 'test-domain');
18 18
 }
Please login to merge, or discard this patch.