Completed
Push — master ( d99bf9...491baf )
by Stephen
13:47
created
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/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.
tools/i18n/t/data/add-textdomain-0.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' );
4
-	_e( 'Hello World' );
5
-	_n( 'Single', 'Plural', 1 );
6
-	_n_noop( 'Single Noop', 'Plural Noop', 1 );
7
-	_x( 'Hello World', 'Testing' );
8
-	_ex( 'Hello World', 'Testing' );
9
-	_nx( 'Hello World', 'Testing' );
10
-	_nx_noop( 'Hello World Noop', 'Testing' );
11
-	esc_attr__( 'Attribute' );
12
-	esc_html__( 'HTML' );
13
-	esc_attr_e( 'Attribute' );
14
-	esc_html_e( 'HTML' );
15
-	esc_attr_x( 'Attribute', 'Testing' );
16
-	esc_html_x( 'HTML', 'Testing' );
17
-	translate_nooped_plural( 'Plural Noop', 2 );
3
+	__('Hello World');
4
+	_e('Hello World');
5
+	_n('Single', 'Plural', 1);
6
+	_n_noop('Single Noop', 'Plural Noop', 1);
7
+	_x('Hello World', 'Testing');
8
+	_ex('Hello World', 'Testing');
9
+	_nx('Hello World', 'Testing');
10
+	_nx_noop('Hello World Noop', 'Testing');
11
+	esc_attr__('Attribute');
12
+	esc_html__('HTML');
13
+	esc_attr_e('Attribute');
14
+	esc_html_e('HTML');
15
+	esc_attr_x('Attribute', 'Testing');
16
+	esc_html_x('HTML', 'Testing');
17
+	translate_nooped_plural('Plural Noop', 2);
18 18
 }
Please login to merge, or discard this patch.
src/wp-content/themes/twentythirteen/footer.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,11 +12,11 @@
 block discarded – undo
12 12
 
13 13
 		</div><!-- #main -->
14 14
 		<footer id="colophon" class="site-footer" role="contentinfo">
15
-			<?php get_sidebar( 'main' ); ?>
15
+			<?php get_sidebar('main'); ?>
16 16
 
17 17
 			<div class="site-info">
18
-				<?php do_action( 'twentythirteen_credits' ); ?>
19
-				<a href="<?php echo esc_url( __( 'https://wordpress.org/', 'twentythirteen' ) ); ?>"><?php printf( __( 'Proudly powered by %s', 'twentythirteen' ), 'WordPress' ); ?></a>
18
+				<?php do_action('twentythirteen_credits'); ?>
19
+				<a href="<?php echo esc_url(__('https://wordpress.org/', 'twentythirteen')); ?>"><?php printf(__('Proudly powered by %s', 'twentythirteen'), 'WordPress'); ?></a>
20 20
 			</div><!-- .site-info -->
21 21
 		</footer><!-- #colophon -->
22 22
 	</div><!-- #page -->
Please login to merge, or discard this patch.
src/wp-content/themes/twentyfifteen/inc/customizer.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -14,73 +14,73 @@  discard block
 block discarded – undo
14 14
  *
15 15
  * @param WP_Customize_Manager $wp_customize Customizer object.
16 16
  */
17
-function twentyfifteen_customize_register( $wp_customize ) {
17
+function twentyfifteen_customize_register($wp_customize) {
18 18
 	$color_scheme = twentyfifteen_get_color_scheme();
19 19
 
20
-	$wp_customize->get_setting( 'blogname' )->transport        = 'postMessage';
21
-	$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
20
+	$wp_customize->get_setting('blogname')->transport        = 'postMessage';
21
+	$wp_customize->get_setting('blogdescription')->transport = 'postMessage';
22 22
 
23
-	if ( isset( $wp_customize->selective_refresh ) ) {
24
-		$wp_customize->selective_refresh->add_partial( 'blogname', array(
23
+	if (isset($wp_customize->selective_refresh)) {
24
+		$wp_customize->selective_refresh->add_partial('blogname', array(
25 25
 			'selector' => '.site-title a',
26 26
 			'container_inclusive' => false,
27 27
 			'render_callback' => 'twentyfifteen_customize_partial_blogname',
28
-		) );
29
-		$wp_customize->selective_refresh->add_partial( 'blogdescription', array(
28
+		));
29
+		$wp_customize->selective_refresh->add_partial('blogdescription', array(
30 30
 			'selector' => '.site-description',
31 31
 			'container_inclusive' => false,
32 32
 			'render_callback' => 'twentyfifteen_customize_partial_blogdescription',
33
-		) );
33
+		));
34 34
 	}
35 35
 
36 36
 	// Add color scheme setting and control.
37
-	$wp_customize->add_setting( 'color_scheme', array(
37
+	$wp_customize->add_setting('color_scheme', array(
38 38
 		'default'           => 'default',
39 39
 		'sanitize_callback' => 'twentyfifteen_sanitize_color_scheme',
40 40
 		'transport'         => 'postMessage',
41
-	) );
41
+	));
42 42
 
43
-	$wp_customize->add_control( 'color_scheme', array(
44
-		'label'    => __( 'Base Color Scheme', 'twentyfifteen' ),
43
+	$wp_customize->add_control('color_scheme', array(
44
+		'label'    => __('Base Color Scheme', 'twentyfifteen'),
45 45
 		'section'  => 'colors',
46 46
 		'type'     => 'select',
47 47
 		'choices'  => twentyfifteen_get_color_scheme_choices(),
48 48
 		'priority' => 1,
49
-	) );
49
+	));
50 50
 
51 51
 	// Add custom header and sidebar text color setting and control.
52
-	$wp_customize->add_setting( 'sidebar_textcolor', array(
52
+	$wp_customize->add_setting('sidebar_textcolor', array(
53 53
 		'default'           => $color_scheme[4],
54 54
 		'sanitize_callback' => 'sanitize_hex_color',
55 55
 		'transport'         => 'postMessage',
56
-	) );
56
+	));
57 57
 
58
-	$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'sidebar_textcolor', array(
59
-		'label'       => __( 'Header and Sidebar Text Color', 'twentyfifteen' ),
60
-		'description' => __( 'Applied to the header on small screens and the sidebar on wide screens.', 'twentyfifteen' ),
58
+	$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'sidebar_textcolor', array(
59
+		'label'       => __('Header and Sidebar Text Color', 'twentyfifteen'),
60
+		'description' => __('Applied to the header on small screens and the sidebar on wide screens.', 'twentyfifteen'),
61 61
 		'section'     => 'colors',
62
-	) ) );
62
+	)));
63 63
 
64 64
 	// Remove the core header textcolor control, as it shares the sidebar text color.
65
-	$wp_customize->remove_control( 'header_textcolor' );
65
+	$wp_customize->remove_control('header_textcolor');
66 66
 
67 67
 	// Add custom header and sidebar background color setting and control.
68
-	$wp_customize->add_setting( 'header_background_color', array(
68
+	$wp_customize->add_setting('header_background_color', array(
69 69
 		'default'           => $color_scheme[1],
70 70
 		'sanitize_callback' => 'sanitize_hex_color',
71 71
 		'transport'         => 'postMessage',
72
-	) );
72
+	));
73 73
 
74
-	$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'header_background_color', array(
75
-		'label'       => __( 'Header and Sidebar Background Color', 'twentyfifteen' ),
76
-		'description' => __( 'Applied to the header on small screens and the sidebar on wide screens.', 'twentyfifteen' ),
74
+	$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'header_background_color', array(
75
+		'label'       => __('Header and Sidebar Background Color', 'twentyfifteen'),
76
+		'description' => __('Applied to the header on small screens and the sidebar on wide screens.', 'twentyfifteen'),
77 77
 		'section'     => 'colors',
78
-	) ) );
78
+	)));
79 79
 
80 80
 	// Add an additional description to the header image section.
81
-	$wp_customize->get_section( 'header_image' )->description = __( 'Applied to the header on small screens and the sidebar on wide screens.', 'twentyfifteen' );
81
+	$wp_customize->get_section('header_image')->description = __('Applied to the header on small screens and the sidebar on wide screens.', 'twentyfifteen');
82 82
 }
83
-add_action( 'customize_register', 'twentyfifteen_customize_register', 11 );
83
+add_action('customize_register', 'twentyfifteen_customize_register', 11);
84 84
 
85 85
 /**
86 86
  * Render the site title for the selective refresh partial.
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
  * @return void
92 92
  */
93 93
 function twentyfifteen_customize_partial_blogname() {
94
-	bloginfo( 'name' );
94
+	bloginfo('name');
95 95
 }
96 96
 
97 97
 /**
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
  * @return void
104 104
  */
105 105
 function twentyfifteen_customize_partial_blogdescription() {
106
-	bloginfo( 'description' );
106
+	bloginfo('description');
107 107
 }
108 108
 
109 109
 /**
@@ -145,9 +145,9 @@  discard block
 block discarded – undo
145 145
 	 *     }
146 146
 	 * }
147 147
 	 */
148
-	return apply_filters( 'twentyfifteen_color_schemes', array(
148
+	return apply_filters('twentyfifteen_color_schemes', array(
149 149
 		'default' => array(
150
-			'label'  => __( 'Default', 'twentyfifteen' ),
150
+			'label'  => __('Default', 'twentyfifteen'),
151 151
 			'colors' => array(
152 152
 				'#f1f1f1',
153 153
 				'#ffffff',
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 			),
159 159
 		),
160 160
 		'dark'    => array(
161
-			'label'  => __( 'Dark', 'twentyfifteen' ),
161
+			'label'  => __('Dark', 'twentyfifteen'),
162 162
 			'colors' => array(
163 163
 				'#111111',
164 164
 				'#202020',
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 			),
170 170
 		),
171 171
 		'yellow'  => array(
172
-			'label'  => __( 'Yellow', 'twentyfifteen' ),
172
+			'label'  => __('Yellow', 'twentyfifteen'),
173 173
 			'colors' => array(
174 174
 				'#f4ca16',
175 175
 				'#ffdf00',
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 			),
181 181
 		),
182 182
 		'pink'    => array(
183
-			'label'  => __( 'Pink', 'twentyfifteen' ),
183
+			'label'  => __('Pink', 'twentyfifteen'),
184 184
 			'colors' => array(
185 185
 				'#ffe5d1',
186 186
 				'#e53b51',
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 			),
192 192
 		),
193 193
 		'purple'  => array(
194
-			'label'  => __( 'Purple', 'twentyfifteen' ),
194
+			'label'  => __('Purple', 'twentyfifteen'),
195 195
 			'colors' => array(
196 196
 				'#674970',
197 197
 				'#2e2256',
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 			),
203 203
 		),
204 204
 		'blue'   => array(
205
-			'label'  => __( 'Blue', 'twentyfifteen' ),
205
+			'label'  => __('Blue', 'twentyfifteen'),
206 206
 			'colors' => array(
207 207
 				'#e9f2f9',
208 208
 				'#55c3dc',
@@ -212,10 +212,10 @@  discard block
 block discarded – undo
212 212
 				'#f1f1f1',
213 213
 			),
214 214
 		),
215
-	) );
215
+	));
216 216
 }
217 217
 
218
-if ( ! function_exists( 'twentyfifteen_get_color_scheme' ) ) :
218
+if ( ! function_exists('twentyfifteen_get_color_scheme')) :
219 219
 /**
220 220
  * Get the current Twenty Fifteen color scheme.
221 221
  *
@@ -224,18 +224,18 @@  discard block
 block discarded – undo
224 224
  * @return array An associative array of either the current or default color scheme hex values.
225 225
  */
226 226
 function twentyfifteen_get_color_scheme() {
227
-	$color_scheme_option = get_theme_mod( 'color_scheme', 'default' );
227
+	$color_scheme_option = get_theme_mod('color_scheme', 'default');
228 228
 	$color_schemes       = twentyfifteen_get_color_schemes();
229 229
 
230
-	if ( array_key_exists( $color_scheme_option, $color_schemes ) ) {
231
-		return $color_schemes[ $color_scheme_option ]['colors'];
230
+	if (array_key_exists($color_scheme_option, $color_schemes)) {
231
+		return $color_schemes[$color_scheme_option]['colors'];
232 232
 	}
233 233
 
234 234
 	return $color_schemes['default']['colors'];
235 235
 }
236 236
 endif; // twentyfifteen_get_color_scheme
237 237
 
238
-if ( ! function_exists( 'twentyfifteen_get_color_scheme_choices' ) ) :
238
+if ( ! function_exists('twentyfifteen_get_color_scheme_choices')) :
239 239
 /**
240 240
  * Returns an array of color scheme choices registered for Twenty Fifteen.
241 241
  *
@@ -247,15 +247,15 @@  discard block
 block discarded – undo
247 247
 	$color_schemes                = twentyfifteen_get_color_schemes();
248 248
 	$color_scheme_control_options = array();
249 249
 
250
-	foreach ( $color_schemes as $color_scheme => $value ) {
251
-		$color_scheme_control_options[ $color_scheme ] = $value['label'];
250
+	foreach ($color_schemes as $color_scheme => $value) {
251
+		$color_scheme_control_options[$color_scheme] = $value['label'];
252 252
 	}
253 253
 
254 254
 	return $color_scheme_control_options;
255 255
 }
256 256
 endif; // twentyfifteen_get_color_scheme_choices
257 257
 
258
-if ( ! function_exists( 'twentyfifteen_sanitize_color_scheme' ) ) :
258
+if ( ! function_exists('twentyfifteen_sanitize_color_scheme')) :
259 259
 /**
260 260
  * Sanitization callback for color schemes.
261 261
  *
@@ -264,10 +264,10 @@  discard block
 block discarded – undo
264 264
  * @param string $value Color scheme name value.
265 265
  * @return string Color scheme name.
266 266
  */
267
-function twentyfifteen_sanitize_color_scheme( $value ) {
267
+function twentyfifteen_sanitize_color_scheme($value) {
268 268
 	$color_schemes = twentyfifteen_get_color_scheme_choices();
269 269
 
270
-	if ( ! array_key_exists( $value, $color_schemes ) ) {
270
+	if ( ! array_key_exists($value, $color_schemes)) {
271 271
 		$value = 'default';
272 272
 	}
273 273
 
@@ -283,38 +283,38 @@  discard block
 block discarded – undo
283 283
  * @see wp_add_inline_style()
284 284
  */
285 285
 function twentyfifteen_color_scheme_css() {
286
-	$color_scheme_option = get_theme_mod( 'color_scheme', 'default' );
286
+	$color_scheme_option = get_theme_mod('color_scheme', 'default');
287 287
 
288 288
 	// Don't do anything if the default color scheme is selected.
289
-	if ( 'default' === $color_scheme_option ) {
289
+	if ('default' === $color_scheme_option) {
290 290
 		return;
291 291
 	}
292 292
 
293 293
 	$color_scheme = twentyfifteen_get_color_scheme();
294 294
 
295 295
 	// Convert main and sidebar text hex color to rgba.
296
-	$color_textcolor_rgb         = twentyfifteen_hex2rgb( $color_scheme[3] );
297
-	$color_sidebar_textcolor_rgb = twentyfifteen_hex2rgb( $color_scheme[4] );
296
+	$color_textcolor_rgb         = twentyfifteen_hex2rgb($color_scheme[3]);
297
+	$color_sidebar_textcolor_rgb = twentyfifteen_hex2rgb($color_scheme[4]);
298 298
 	$colors = array(
299 299
 		'background_color'            => $color_scheme[0],
300 300
 		'header_background_color'     => $color_scheme[1],
301 301
 		'box_background_color'        => $color_scheme[2],
302 302
 		'textcolor'                   => $color_scheme[3],
303
-		'secondary_textcolor'         => vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.7)', $color_textcolor_rgb ),
304
-		'border_color'                => vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.1)', $color_textcolor_rgb ),
305
-		'border_focus_color'          => vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.3)', $color_textcolor_rgb ),
303
+		'secondary_textcolor'         => vsprintf('rgba( %1$s, %2$s, %3$s, 0.7)', $color_textcolor_rgb),
304
+		'border_color'                => vsprintf('rgba( %1$s, %2$s, %3$s, 0.1)', $color_textcolor_rgb),
305
+		'border_focus_color'          => vsprintf('rgba( %1$s, %2$s, %3$s, 0.3)', $color_textcolor_rgb),
306 306
 		'sidebar_textcolor'           => $color_scheme[4],
307
-		'sidebar_border_color'        => vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.1)', $color_sidebar_textcolor_rgb ),
308
-		'sidebar_border_focus_color'  => vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.3)', $color_sidebar_textcolor_rgb ),
309
-		'secondary_sidebar_textcolor' => vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.7)', $color_sidebar_textcolor_rgb ),
307
+		'sidebar_border_color'        => vsprintf('rgba( %1$s, %2$s, %3$s, 0.1)', $color_sidebar_textcolor_rgb),
308
+		'sidebar_border_focus_color'  => vsprintf('rgba( %1$s, %2$s, %3$s, 0.3)', $color_sidebar_textcolor_rgb),
309
+		'secondary_sidebar_textcolor' => vsprintf('rgba( %1$s, %2$s, %3$s, 0.7)', $color_sidebar_textcolor_rgb),
310 310
 		'meta_box_background_color'   => $color_scheme[5],
311 311
 	);
312 312
 
313
-	$color_scheme_css = twentyfifteen_get_color_scheme_css( $colors );
313
+	$color_scheme_css = twentyfifteen_get_color_scheme_css($colors);
314 314
 
315
-	wp_add_inline_style( 'twentyfifteen-style', $color_scheme_css );
315
+	wp_add_inline_style('twentyfifteen-style', $color_scheme_css);
316 316
 }
317
-add_action( 'wp_enqueue_scripts', 'twentyfifteen_color_scheme_css' );
317
+add_action('wp_enqueue_scripts', 'twentyfifteen_color_scheme_css');
318 318
 
319 319
 /**
320 320
  * Binds JS listener to make Customizer color_scheme control.
@@ -324,10 +324,10 @@  discard block
 block discarded – undo
324 324
  * @since Twenty Fifteen 1.0
325 325
  */
326 326
 function twentyfifteen_customize_control_js() {
327
-	wp_enqueue_script( 'color-scheme-control', get_template_directory_uri() . '/js/color-scheme-control.js', array( 'customize-controls', 'iris', 'underscore', 'wp-util' ), '20141216', true );
328
-	wp_localize_script( 'color-scheme-control', 'colorScheme', twentyfifteen_get_color_schemes() );
327
+	wp_enqueue_script('color-scheme-control', get_template_directory_uri().'/js/color-scheme-control.js', array('customize-controls', 'iris', 'underscore', 'wp-util'), '20141216', true);
328
+	wp_localize_script('color-scheme-control', 'colorScheme', twentyfifteen_get_color_schemes());
329 329
 }
330
-add_action( 'customize_controls_enqueue_scripts', 'twentyfifteen_customize_control_js' );
330
+add_action('customize_controls_enqueue_scripts', 'twentyfifteen_customize_control_js');
331 331
 
332 332
 /**
333 333
  * Binds JS handlers to make the Customizer preview reload changes asynchronously.
@@ -335,9 +335,9 @@  discard block
 block discarded – undo
335 335
  * @since Twenty Fifteen 1.0
336 336
  */
337 337
 function twentyfifteen_customize_preview_js() {
338
-	wp_enqueue_script( 'twentyfifteen-customize-preview', get_template_directory_uri() . '/js/customize-preview.js', array( 'customize-preview' ), '20141216', true );
338
+	wp_enqueue_script('twentyfifteen-customize-preview', get_template_directory_uri().'/js/customize-preview.js', array('customize-preview'), '20141216', true);
339 339
 }
340
-add_action( 'customize_preview_init', 'twentyfifteen_customize_preview_js' );
340
+add_action('customize_preview_init', 'twentyfifteen_customize_preview_js');
341 341
 
342 342
 /**
343 343
  * Returns CSS for the color schemes.
@@ -347,8 +347,8 @@  discard block
 block discarded – undo
347 347
  * @param array $colors Color scheme colors.
348 348
  * @return string Color scheme CSS.
349 349
  */
350
-function twentyfifteen_get_color_scheme_css( $colors ) {
351
-	$colors = wp_parse_args( $colors, array(
350
+function twentyfifteen_get_color_scheme_css($colors) {
351
+	$colors = wp_parse_args($colors, array(
352 352
 		'background_color'            => '',
353 353
 		'header_background_color'     => '',
354 354
 		'box_background_color'        => '',
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 		'sidebar_border_focus_color'  => '',
362 362
 		'secondary_sidebar_textcolor' => '',
363 363
 		'meta_box_background_color'   => '',
364
-	) );
364
+	));
365 365
 
366 366
 	$css = <<<CSS
367 367
 	/* Color Scheme */
@@ -766,8 +766,8 @@  discard block
 block discarded – undo
766 766
 	);
767 767
 	?>
768 768
 	<script type="text/html" id="tmpl-twentyfifteen-color-scheme">
769
-		<?php echo twentyfifteen_get_color_scheme_css( $colors ); ?>
769
+		<?php echo twentyfifteen_get_color_scheme_css($colors); ?>
770 770
 	</script>
771 771
 	<?php
772 772
 }
773
-add_action( 'customize_controls_print_footer_scripts', 'twentyfifteen_color_scheme_css_template' );
773
+add_action('customize_controls_print_footer_scripts', 'twentyfifteen_color_scheme_css_template');
Please login to merge, or discard this patch.
src/wp-admin/widgets.php 2 patches
Braces   +45 added lines, -30 removed lines patch added patch discarded remove patch
@@ -31,9 +31,10 @@  discard block
 block discarded – undo
31 31
 } else {
32 32
 	wp_enqueue_script('admin-widgets');
33 33
 
34
-	if ( wp_is_mobile() )
35
-		wp_enqueue_script( 'jquery-touch-punch' );
36
-}
34
+	if ( wp_is_mobile() ) {
35
+			wp_enqueue_script( 'jquery-touch-punch' );
36
+	}
37
+	}
37 38
 
38 39
 /**
39 40
  * Fires early before the Widgets administration screen loads,
@@ -82,12 +83,14 @@  discard block
 block discarded – undo
82 83
 // These are the widgets grouped by sidebar
83 84
 $sidebars_widgets = wp_get_sidebars_widgets();
84 85
 
85
-if ( empty( $sidebars_widgets ) )
86
+if ( empty( $sidebars_widgets ) ) {
86 87
 	$sidebars_widgets = wp_get_widget_defaults();
88
+}
87 89
 
88 90
 foreach ( $sidebars_widgets as $sidebar_id => $widgets ) {
89
-	if ( 'wp_inactive_widgets' == $sidebar_id )
90
-		continue;
91
+	if ( 'wp_inactive_widgets' == $sidebar_id ) {
92
+			continue;
93
+	}
91 94
 
92 95
 	if ( ! is_registered_sidebar( $sidebar_id ) ) {
93 96
 		if ( ! empty( $widgets ) ) { // register the inactive_widgets area as sidebar
@@ -168,8 +171,9 @@  discard block
 block discarded – undo
168 171
 	$_POST['widget-id'] = $sidebar;
169 172
 
170 173
 	foreach ( (array) $wp_registered_widget_updates as $name => $control ) {
171
-		if ( $name != $id_base || !is_callable($control['callback']) )
172
-			continue;
174
+		if ( $name != $id_base || !is_callable($control['callback']) ) {
175
+					continue;
176
+		}
173 177
 
174 178
 		ob_start();
175 179
 			call_user_func_array( $control['callback'], $control['params'] );
@@ -183,8 +187,9 @@  discard block
 block discarded – undo
183 187
 	// Remove old position.
184 188
 	if ( !isset($_POST['delete_widget']) ) {
185 189
 		foreach ( $sidebars_widgets as $key => $sb ) {
186
-			if ( is_array($sb) )
187
-				$sidebars_widgets[$key] = array_diff( $sb, array($widget_id) );
190
+			if ( is_array($sb) ) {
191
+							$sidebars_widgets[$key] = array_diff( $sb, array($widget_id) );
192
+			}
188 193
 		}
189 194
 		array_splice( $sidebars_widgets[$sidebar_id], $position, 0, $widget_id );
190 195
 	}
@@ -247,14 +252,17 @@  discard block
 block discarded – undo
247 252
 		$name = esc_html( strip_tags($wp_registered_widgets[$widget_id]['name']) );
248 253
 	}
249 254
 
250
-	if ( !isset($name) )
251
-		$name = esc_html( strip_tags($control['name']) );
255
+	if ( !isset($name) ) {
256
+			$name = esc_html( strip_tags($control['name']) );
257
+	}
252 258
 
253
-	if ( !isset($sidebar) )
254
-		$sidebar = isset($_GET['sidebar']) ? $_GET['sidebar'] : 'wp_inactive_widgets';
259
+	if ( !isset($sidebar) ) {
260
+			$sidebar = isset($_GET['sidebar']) ? $_GET['sidebar'] : 'wp_inactive_widgets';
261
+	}
255 262
 
256
-	if ( !isset($multi_number) )
257
-		$multi_number = isset($control['params'][0]['number']) ? $control['params'][0]['number'] : '';
263
+	if ( !isset($multi_number) ) {
264
+			$multi_number = isset($control['params'][0]['number']) ? $control['params'][0]['number'] : '';
265
+	}
258 266
 
259 267
 	$id_base = isset($control['id_base']) ? $control['id_base'] : $control['id'];
260 268
 
@@ -271,10 +279,12 @@  discard block
 block discarded – undo
271 279
 	<form action="widgets.php" method="post">
272 280
 	<div class="widget-inside">
273 281
 <?php
274
-	if ( is_callable( $control_callback ) )
275
-		call_user_func_array( $control_callback, $control['params'] );
276
-	else
277
-		echo '<p>' . __('There are no options for this widget.') . "</p>\n"; ?>
282
+	if ( is_callable( $control_callback ) ) {
283
+			call_user_func_array( $control_callback, $control['params'] );
284
+	} else {
285
+			echo '<p>' . __('There are no options for this widget.') . "</p>\n";
286
+	}
287
+	?>
278 288
 	</div>
279 289
 
280 290
 	<p class="describe"><?php _e('Select both the sidebar for this widget and the position of the widget in that sidebar.'); ?></p>
@@ -291,15 +301,17 @@  discard block
 block discarded – undo
291 301
 				$sidebars_widgets[$sbname] = array();
292 302
 			} else {
293 303
 				$j = count($sidebars_widgets[$sbname]);
294
-				if ( isset($_GET['addnew']) || !in_array($widget_id, $sidebars_widgets[$sbname], true) )
295
-					$j++;
304
+				if ( isset($_GET['addnew']) || !in_array($widget_id, $sidebars_widgets[$sbname], true) ) {
305
+									$j++;
306
+				}
296 307
 			}
297 308
 			$selected = '';
298 309
 			echo "\t\t<select name='{$sbname}_position'>\n";
299 310
 			echo "\t\t<option value=''>" . __('&mdash; Select &mdash;') . "</option>\n";
300 311
 			for ( $i = 1; $i <= $j; $i++ ) {
301
-				if ( in_array($widget_id, $sidebars_widgets[$sbname], true) )
302
-					$selected = selected( $i, $key + 1, false );
312
+				if ( in_array($widget_id, $sidebars_widgets[$sbname], true) ) {
313
+									$selected = selected( $i, $key + 1, false );
314
+				}
303 315
 				echo "\t\t<option value='$i'$selected> $i </option>\n";
304 316
 			}
305 317
 			echo "\t\t</select>\n";
@@ -403,8 +415,9 @@  discard block
 block discarded – undo
403 415
 foreach ( $wp_registered_sidebars as $sidebar => $registered_sidebar ) {
404 416
 	if ( false !== strpos( $registered_sidebar['class'], 'inactive-sidebar' ) || 'orphaned_widgets' == substr( $sidebar, 0, 16 ) ) {
405 417
 		$wrap_class = 'widgets-holder-wrap';
406
-		if ( !empty( $registered_sidebar['class'] ) )
407
-			$wrap_class .= ' ' . $registered_sidebar['class'];
418
+		if ( !empty( $registered_sidebar['class'] ) ) {
419
+					$wrap_class .= ' ' . $registered_sidebar['class'];
420
+		}
408 421
 
409 422
 		$is_inactive_widgets = 'wp_inactive_widgets' == $registered_sidebar['id'];
410 423
 		?>
@@ -466,11 +479,13 @@  discard block
 block discarded – undo
466 479
 
467 480
 foreach ( $theme_sidebars as $sidebar => $registered_sidebar ) {
468 481
 	$wrap_class = 'widgets-holder-wrap';
469
-	if ( !empty( $registered_sidebar['class'] ) )
470
-		$wrap_class .= ' sidebar-' . $registered_sidebar['class'];
482
+	if ( !empty( $registered_sidebar['class'] ) ) {
483
+			$wrap_class .= ' sidebar-' . $registered_sidebar['class'];
484
+	}
471 485
 
472
-	if ( $i > 0 )
473
-		$wrap_class .= ' closed';
486
+	if ( $i > 0 ) {
487
+			$wrap_class .= ' closed';
488
+	}
474 489
 
475 490
 	if ( $split && $i == $split ) {
476 491
 		?>
Please login to merge, or discard this patch.
Spacing   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -7,34 +7,34 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 /** WordPress Administration Bootstrap */
10
-require_once( dirname( __FILE__ ) . '/admin.php' );
10
+require_once(dirname(__FILE__).'/admin.php');
11 11
 
12 12
 /** WordPress Administration Widgets API */
13
-require_once(ABSPATH . 'wp-admin/includes/widgets.php');
13
+require_once(ABSPATH.'wp-admin/includes/widgets.php');
14 14
 
15
-if ( ! current_user_can( 'edit_theme_options' ) ) {
15
+if ( ! current_user_can('edit_theme_options')) {
16 16
 	wp_die(
17
-		'<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
18
-		'<p>' . __( 'Sorry, you are not allowed to edit theme options on this site.' ) . '</p>',
17
+		'<h1>'.__('Cheatin&#8217; uh?').'</h1>'.
18
+		'<p>'.__('Sorry, you are not allowed to edit theme options on this site.').'</p>',
19 19
 		403
20 20
 	);
21 21
 }
22 22
 
23
-$widgets_access = get_user_setting( 'widgets_access' );
24
-if ( isset($_GET['widgets-access']) ) {
25
-	check_admin_referer( 'widgets-access' );
23
+$widgets_access = get_user_setting('widgets_access');
24
+if (isset($_GET['widgets-access'])) {
25
+	check_admin_referer('widgets-access');
26 26
 
27 27
 	$widgets_access = 'on' == $_GET['widgets-access'] ? 'on' : 'off';
28
-	set_user_setting( 'widgets_access', $widgets_access );
28
+	set_user_setting('widgets_access', $widgets_access);
29 29
 }
30 30
 
31
-if ( 'on' == $widgets_access ) {
32
-	add_filter( 'admin_body_class', 'wp_widgets_access_body_class' );
31
+if ('on' == $widgets_access) {
32
+	add_filter('admin_body_class', 'wp_widgets_access_body_class');
33 33
 } else {
34 34
 	wp_enqueue_script('admin-widgets');
35 35
 
36
-	if ( wp_is_mobile() )
37
-		wp_enqueue_script( 'jquery-touch-punch' );
36
+	if (wp_is_mobile())
37
+		wp_enqueue_script('jquery-touch-punch');
38 38
 }
39 39
 
40 40
 /**
@@ -43,68 +43,68 @@  discard block
 block discarded – undo
43 43
  *
44 44
  * @since 2.2.0
45 45
  */
46
-do_action( 'sidebar_admin_setup' );
46
+do_action('sidebar_admin_setup');
47 47
 
48
-$title = __( 'Widgets' );
48
+$title = __('Widgets');
49 49
 $parent_file = 'themes.php';
50 50
 
51
-get_current_screen()->add_help_tab( array(
51
+get_current_screen()->add_help_tab(array(
52 52
 'id'		=> 'overview',
53 53
 'title'		=> __('Overview'),
54 54
 'content'	=>
55
-	'<p>' . __('Widgets are independent sections of content that can be placed into any widgetized area provided by your theme (commonly called sidebars). To populate your sidebars/widget areas with individual widgets, drag and drop the title bars into the desired area. By default, only the first widget area is expanded. To populate additional widget areas, click on their title bars to expand them.') . '</p>
56
-	<p>' . __('The Available Widgets section contains all the widgets you can choose from. Once you drag a widget into a sidebar, it will open to allow you to configure its settings. When you are happy with the widget settings, click the Save button and the widget will go live on your site. If you click Delete, it will remove the widget.') . '</p>'
57
-) );
58
-get_current_screen()->add_help_tab( array(
55
+	'<p>'.__('Widgets are independent sections of content that can be placed into any widgetized area provided by your theme (commonly called sidebars). To populate your sidebars/widget areas with individual widgets, drag and drop the title bars into the desired area. By default, only the first widget area is expanded. To populate additional widget areas, click on their title bars to expand them.').'</p>
56
+	<p>' . __('The Available Widgets section contains all the widgets you can choose from. Once you drag a widget into a sidebar, it will open to allow you to configure its settings. When you are happy with the widget settings, click the Save button and the widget will go live on your site. If you click Delete, it will remove the widget.').'</p>'
57
+));
58
+get_current_screen()->add_help_tab(array(
59 59
 'id'		=> 'removing-reusing',
60 60
 'title'		=> __('Removing and Reusing'),
61 61
 'content'	=>
62
-	'<p>' . __('If you want to remove the widget but save its setting for possible future use, just drag it into the Inactive Widgets area. You can add them back anytime from there. This is especially helpful when you switch to a theme with fewer or different widget areas.') . '</p>
63
-	<p>' . __('Widgets may be used multiple times. You can give each widget a title, to display on your site, but it&#8217;s not required.') . '</p>
64
-	<p>' . __('Enabling Accessibility Mode, via Screen Options, allows you to use Add and Edit buttons instead of using drag and drop.') . '</p>'
65
-) );
66
-get_current_screen()->add_help_tab( array(
62
+	'<p>'.__('If you want to remove the widget but save its setting for possible future use, just drag it into the Inactive Widgets area. You can add them back anytime from there. This is especially helpful when you switch to a theme with fewer or different widget areas.').'</p>
63
+	<p>' . __('Widgets may be used multiple times. You can give each widget a title, to display on your site, but it&#8217;s not required.').'</p>
64
+	<p>' . __('Enabling Accessibility Mode, via Screen Options, allows you to use Add and Edit buttons instead of using drag and drop.').'</p>'
65
+));
66
+get_current_screen()->add_help_tab(array(
67 67
 'id'		=> 'missing-widgets',
68 68
 'title'		=> __('Missing Widgets'),
69 69
 'content'	=>
70
-	'<p>' . __('Many themes show some sidebar widgets by default until you edit your sidebars, but they are not automatically displayed in your sidebar management tool. After you make your first widget change, you can re-add the default widgets by adding them from the Available Widgets area.') . '</p>' .
71
-		'<p>' . __('When changing themes, there is often some variation in the number and setup of widget areas/sidebars and sometimes these conflicts make the transition a bit less smooth. If you changed themes and seem to be missing widgets, scroll down on this screen to the Inactive Widgets area, where all of your widgets and their settings will have been saved.') . '</p>'
72
-) );
70
+	'<p>'.__('Many themes show some sidebar widgets by default until you edit your sidebars, but they are not automatically displayed in your sidebar management tool. After you make your first widget change, you can re-add the default widgets by adding them from the Available Widgets area.').'</p>'.
71
+		'<p>'.__('When changing themes, there is often some variation in the number and setup of widget areas/sidebars and sometimes these conflicts make the transition a bit less smooth. If you changed themes and seem to be missing widgets, scroll down on this screen to the Inactive Widgets area, where all of your widgets and their settings will have been saved.').'</p>'
72
+));
73 73
 
74 74
 get_current_screen()->set_help_sidebar(
75
-	'<p><strong>' . __('For more information:') . '</strong></p>' .
76
-	'<p>' . __('<a href="https://codex.wordpress.org/Appearance_Widgets_Screen">Documentation on Widgets</a>') . '</p>' .
77
-	'<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
75
+	'<p><strong>'.__('For more information:').'</strong></p>'.
76
+	'<p>'.__('<a href="https://codex.wordpress.org/Appearance_Widgets_Screen">Documentation on Widgets</a>').'</p>'.
77
+	'<p>'.__('<a href="https://wordpress.org/support/">Support Forums</a>').'</p>'
78 78
 );
79 79
 
80
-if ( ! current_theme_supports( 'widgets' ) ) {
81
-	wp_die( __( 'The theme you are currently using isn&#8217;t widget-aware, meaning that it has no sidebars that you are able to change. For information on making your theme widget-aware, please <a href="https://codex.wordpress.org/Widgetizing_Themes">follow these instructions</a>.' ) );
80
+if ( ! current_theme_supports('widgets')) {
81
+	wp_die(__('The theme you are currently using isn&#8217;t widget-aware, meaning that it has no sidebars that you are able to change. For information on making your theme widget-aware, please <a href="https://codex.wordpress.org/Widgetizing_Themes">follow these instructions</a>.'));
82 82
 }
83 83
 
84 84
 // These are the widgets grouped by sidebar
85 85
 $sidebars_widgets = wp_get_sidebars_widgets();
86 86
 
87
-if ( empty( $sidebars_widgets ) )
87
+if (empty($sidebars_widgets))
88 88
 	$sidebars_widgets = wp_get_widget_defaults();
89 89
 
90
-foreach ( $sidebars_widgets as $sidebar_id => $widgets ) {
91
-	if ( 'wp_inactive_widgets' == $sidebar_id )
90
+foreach ($sidebars_widgets as $sidebar_id => $widgets) {
91
+	if ('wp_inactive_widgets' == $sidebar_id)
92 92
 		continue;
93 93
 
94
-	if ( ! is_registered_sidebar( $sidebar_id ) ) {
95
-		if ( ! empty( $widgets ) ) { // register the inactive_widgets area as sidebar
94
+	if ( ! is_registered_sidebar($sidebar_id)) {
95
+		if ( ! empty($widgets)) { // register the inactive_widgets area as sidebar
96 96
 			register_sidebar(array(
97
-				'name' => __( 'Inactive Sidebar (not used)' ),
97
+				'name' => __('Inactive Sidebar (not used)'),
98 98
 				'id' => $sidebar_id,
99 99
 				'class' => 'inactive-sidebar orphan-sidebar',
100
-				'description' => __( 'This sidebar is no longer available and does not show anywhere on your site. Remove each of the widgets below to fully remove this inactive sidebar.' ),
100
+				'description' => __('This sidebar is no longer available and does not show anywhere on your site. Remove each of the widgets below to fully remove this inactive sidebar.'),
101 101
 				'before_widget' => '',
102 102
 				'after_widget' => '',
103 103
 				'before_title' => '',
104 104
 				'after_title' => '',
105 105
 			));
106 106
 		} else {
107
-			unset( $sidebars_widgets[ $sidebar_id ] );
107
+			unset($sidebars_widgets[$sidebar_id]);
108 108
 		}
109 109
 	}
110 110
 }
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	'name' => __('Inactive Widgets'),
115 115
 	'id' => 'wp_inactive_widgets',
116 116
 	'class' => 'inactive-sidebar',
117
-	'description' => __( 'Drag widgets here to remove them from the sidebar but keep their settings.' ),
117
+	'description' => __('Drag widgets here to remove them from the sidebar but keep their settings.'),
118 118
 	'before_widget' => '',
119 119
 	'after_widget' => '',
120 120
 	'before_title' => '',
@@ -124,36 +124,36 @@  discard block
 block discarded – undo
124 124
 retrieve_widgets();
125 125
 
126 126
 // We're saving a widget without js
127
-if ( isset($_POST['savewidget']) || isset($_POST['removewidget']) ) {
127
+if (isset($_POST['savewidget']) || isset($_POST['removewidget'])) {
128 128
 	$widget_id = $_POST['widget-id'];
129 129
 	check_admin_referer("save-delete-widget-$widget_id");
130 130
 
131 131
 	$number = isset($_POST['multi_number']) ? (int) $_POST['multi_number'] : '';
132
-	if ( $number ) {
133
-		foreach ( $_POST as $key => $val ) {
134
-			if ( is_array($val) && preg_match('/__i__|%i%/', key($val)) ) {
135
-				$_POST[$key] = array( $number => array_shift($val) );
132
+	if ($number) {
133
+		foreach ($_POST as $key => $val) {
134
+			if (is_array($val) && preg_match('/__i__|%i%/', key($val))) {
135
+				$_POST[$key] = array($number => array_shift($val));
136 136
 				break;
137 137
 			}
138 138
 		}
139 139
 	}
140 140
 
141 141
 	$sidebar_id = $_POST['sidebar'];
142
-	$position = isset($_POST[$sidebar_id . '_position']) ? (int) $_POST[$sidebar_id . '_position'] - 1 : 0;
142
+	$position = isset($_POST[$sidebar_id.'_position']) ? (int) $_POST[$sidebar_id.'_position'] - 1 : 0;
143 143
 
144 144
 	$id_base = $_POST['id_base'];
145 145
 	$sidebar = isset($sidebars_widgets[$sidebar_id]) ? $sidebars_widgets[$sidebar_id] : array();
146 146
 
147 147
 	// Delete.
148
-	if ( isset($_POST['removewidget']) && $_POST['removewidget'] ) {
148
+	if (isset($_POST['removewidget']) && $_POST['removewidget']) {
149 149
 
150
-		if ( !in_array($widget_id, $sidebar, true) ) {
151
-			wp_redirect( admin_url('widgets.php?error=0') );
150
+		if ( ! in_array($widget_id, $sidebar, true)) {
151
+			wp_redirect(admin_url('widgets.php?error=0'));
152 152
 			exit;
153 153
 		}
154 154
 
155
-		$sidebar = array_diff( $sidebar, array($widget_id) );
156
-		$_POST = array('sidebar' => $sidebar_id, 'widget-' . $id_base => array(), 'the-widget-id' => $widget_id, 'delete_widget' => '1');
155
+		$sidebar = array_diff($sidebar, array($widget_id));
156
+		$_POST = array('sidebar' => $sidebar_id, 'widget-'.$id_base => array(), 'the-widget-id' => $widget_id, 'delete_widget' => '1');
157 157
 
158 158
 		/**
159 159
 		 * Fires immediately after a widget has been marked for deletion.
@@ -164,17 +164,17 @@  discard block
 block discarded – undo
164 164
 		 * @param string $sidebar_id ID of the sidebar the widget was deleted from.
165 165
 		 * @param string $id_base    ID base for the widget.
166 166
 		 */
167
-		do_action( 'delete_widget', $widget_id, $sidebar_id, $id_base );
167
+		do_action('delete_widget', $widget_id, $sidebar_id, $id_base);
168 168
 	}
169 169
 
170 170
 	$_POST['widget-id'] = $sidebar;
171 171
 
172
-	foreach ( (array) $wp_registered_widget_updates as $name => $control ) {
173
-		if ( $name != $id_base || !is_callable($control['callback']) )
172
+	foreach ((array) $wp_registered_widget_updates as $name => $control) {
173
+		if ($name != $id_base || ! is_callable($control['callback']))
174 174
 			continue;
175 175
 
176 176
 		ob_start();
177
-			call_user_func_array( $control['callback'], $control['params'] );
177
+			call_user_func_array($control['callback'], $control['params']);
178 178
 		ob_end_clean();
179 179
 
180 180
 		break;
@@ -183,58 +183,58 @@  discard block
 block discarded – undo
183 183
 	$sidebars_widgets[$sidebar_id] = $sidebar;
184 184
 
185 185
 	// Remove old position.
186
-	if ( !isset($_POST['delete_widget']) ) {
187
-		foreach ( $sidebars_widgets as $key => $sb ) {
188
-			if ( is_array($sb) )
189
-				$sidebars_widgets[$key] = array_diff( $sb, array($widget_id) );
186
+	if ( ! isset($_POST['delete_widget'])) {
187
+		foreach ($sidebars_widgets as $key => $sb) {
188
+			if (is_array($sb))
189
+				$sidebars_widgets[$key] = array_diff($sb, array($widget_id));
190 190
 		}
191
-		array_splice( $sidebars_widgets[$sidebar_id], $position, 0, $widget_id );
191
+		array_splice($sidebars_widgets[$sidebar_id], $position, 0, $widget_id);
192 192
 	}
193 193
 
194 194
 	wp_set_sidebars_widgets($sidebars_widgets);
195
-	wp_redirect( admin_url('widgets.php?message=0') );
195
+	wp_redirect(admin_url('widgets.php?message=0'));
196 196
 	exit;
197 197
 }
198 198
 
199 199
 // Remove inactive widgets without js
200
-if ( isset( $_POST['removeinactivewidgets'] ) ) {
201
-	check_admin_referer( 'remove-inactive-widgets', '_wpnonce_remove_inactive_widgets' );
202
-
203
-	if ( $_POST['removeinactivewidgets'] ) {
204
-		foreach ( $sidebars_widgets['wp_inactive_widgets'] as $key => $widget_id ) {
205
-			$pieces = explode( '-', $widget_id );
206
-			$multi_number = array_pop( $pieces );
207
-			$id_base = implode( '-', $pieces );
208
-			$widget = get_option( 'widget_' . $id_base );
209
-			unset( $widget[$multi_number] );
210
-			update_option( 'widget_' . $id_base, $widget );
211
-			unset( $sidebars_widgets['wp_inactive_widgets'][$key] );
200
+if (isset($_POST['removeinactivewidgets'])) {
201
+	check_admin_referer('remove-inactive-widgets', '_wpnonce_remove_inactive_widgets');
202
+
203
+	if ($_POST['removeinactivewidgets']) {
204
+		foreach ($sidebars_widgets['wp_inactive_widgets'] as $key => $widget_id) {
205
+			$pieces = explode('-', $widget_id);
206
+			$multi_number = array_pop($pieces);
207
+			$id_base = implode('-', $pieces);
208
+			$widget = get_option('widget_'.$id_base);
209
+			unset($widget[$multi_number]);
210
+			update_option('widget_'.$id_base, $widget);
211
+			unset($sidebars_widgets['wp_inactive_widgets'][$key]);
212 212
 		}
213 213
 
214
-		wp_set_sidebars_widgets( $sidebars_widgets );
214
+		wp_set_sidebars_widgets($sidebars_widgets);
215 215
 	}
216 216
 
217
-	wp_redirect( admin_url( 'widgets.php?message=0' ) );
217
+	wp_redirect(admin_url('widgets.php?message=0'));
218 218
 	exit;
219 219
 }
220 220
 
221 221
 // Output the widget form without js
222
-if ( isset($_GET['editwidget']) && $_GET['editwidget'] ) {
222
+if (isset($_GET['editwidget']) && $_GET['editwidget']) {
223 223
 	$widget_id = $_GET['editwidget'];
224 224
 
225
-	if ( isset($_GET['addnew']) ) {
225
+	if (isset($_GET['addnew'])) {
226 226
 		// Default to the first sidebar
227
-		$keys = array_keys( $wp_registered_sidebars );
228
-		$sidebar = reset( $keys );
227
+		$keys = array_keys($wp_registered_sidebars);
228
+		$sidebar = reset($keys);
229 229
 
230
-		if ( isset($_GET['base']) && isset($_GET['num']) ) { // multi-widget
230
+		if (isset($_GET['base']) && isset($_GET['num'])) { // multi-widget
231 231
 			// Copy minimal info from an existing instance of this widget to a new instance
232
-			foreach ( $wp_registered_widget_controls as $control ) {
233
-				if ( $_GET['base'] === $control['id_base'] ) {
232
+			foreach ($wp_registered_widget_controls as $control) {
233
+				if ($_GET['base'] === $control['id_base']) {
234 234
 					$control_callback = $control['callback'];
235 235
 					$multi_number = (int) $_GET['num'];
236 236
 					$control['params'][0]['number'] = -1;
237
-					$widget_id = $control['id'] = $control['id_base'] . '-' . $multi_number;
237
+					$widget_id = $control['id'] = $control['id_base'].'-'.$multi_number;
238 238
 					$wp_registered_widget_controls[$control['id']] = $control;
239 239
 					break;
240 240
 				}
@@ -242,66 +242,66 @@  discard block
 block discarded – undo
242 242
 		}
243 243
 	}
244 244
 
245
-	if ( isset($wp_registered_widget_controls[$widget_id]) && !isset($control) ) {
245
+	if (isset($wp_registered_widget_controls[$widget_id]) && ! isset($control)) {
246 246
 		$control = $wp_registered_widget_controls[$widget_id];
247 247
 		$control_callback = $control['callback'];
248
-	} elseif ( !isset($wp_registered_widget_controls[$widget_id]) && isset($wp_registered_widgets[$widget_id]) ) {
249
-		$name = esc_html( strip_tags($wp_registered_widgets[$widget_id]['name']) );
248
+	} elseif ( ! isset($wp_registered_widget_controls[$widget_id]) && isset($wp_registered_widgets[$widget_id])) {
249
+		$name = esc_html(strip_tags($wp_registered_widgets[$widget_id]['name']));
250 250
 	}
251 251
 
252
-	if ( !isset($name) )
253
-		$name = esc_html( strip_tags($control['name']) );
252
+	if ( ! isset($name))
253
+		$name = esc_html(strip_tags($control['name']));
254 254
 
255
-	if ( !isset($sidebar) )
255
+	if ( ! isset($sidebar))
256 256
 		$sidebar = isset($_GET['sidebar']) ? $_GET['sidebar'] : 'wp_inactive_widgets';
257 257
 
258
-	if ( !isset($multi_number) )
258
+	if ( ! isset($multi_number))
259 259
 		$multi_number = isset($control['params'][0]['number']) ? $control['params'][0]['number'] : '';
260 260
 
261 261
 	$id_base = isset($control['id_base']) ? $control['id_base'] : $control['id'];
262 262
 
263 263
 	// Show the widget form.
264
-	$width = ' style="width:' . max($control['width'], 350) . 'px"';
264
+	$width = ' style="width:'.max($control['width'], 350).'px"';
265 265
 	$key = isset($_GET['key']) ? (int) $_GET['key'] : 0;
266 266
 
267
-	require_once( ABSPATH . 'wp-admin/admin-header.php' ); ?>
267
+	require_once(ABSPATH.'wp-admin/admin-header.php'); ?>
268 268
 	<div class="wrap">
269
-	<h1><?php echo esc_html( $title ); ?></h1>
269
+	<h1><?php echo esc_html($title); ?></h1>
270 270
 	<div class="editwidget"<?php echo $width; ?>>
271
-	<h2><?php printf( __( 'Widget %s' ), $name ); ?></h2>
271
+	<h2><?php printf(__('Widget %s'), $name); ?></h2>
272 272
 
273 273
 	<form action="widgets.php" method="post">
274 274
 	<div class="widget-inside">
275 275
 <?php
276
-	if ( is_callable( $control_callback ) )
277
-		call_user_func_array( $control_callback, $control['params'] );
276
+	if (is_callable($control_callback))
277
+		call_user_func_array($control_callback, $control['params']);
278 278
 	else
279
-		echo '<p>' . __('There are no options for this widget.') . "</p>\n"; ?>
279
+		echo '<p>'.__('There are no options for this widget.')."</p>\n"; ?>
280 280
 	</div>
281 281
 
282 282
 	<p class="describe"><?php _e('Select both the sidebar for this widget and the position of the widget in that sidebar.'); ?></p>
283 283
 	<div class="widget-position">
284 284
 	<table class="widefat"><thead><tr><th><?php _e('Sidebar'); ?></th><th><?php _e('Position'); ?></th></tr></thead><tbody>
285 285
 <?php
286
-	foreach ( $wp_registered_sidebars as $sbname => $sbvalue ) {
287
-		echo "\t\t<tr><td><label><input type='radio' name='sidebar' value='" . esc_attr($sbname) . "'" . checked( $sbname, $sidebar, false ) . " /> $sbvalue[name]</label></td><td>";
288
-		if ( 'wp_inactive_widgets' == $sbname || 'orphaned_widgets' == substr( $sbname, 0, 16 ) ) {
286
+	foreach ($wp_registered_sidebars as $sbname => $sbvalue) {
287
+		echo "\t\t<tr><td><label><input type='radio' name='sidebar' value='".esc_attr($sbname)."'".checked($sbname, $sidebar, false)." /> $sbvalue[name]</label></td><td>";
288
+		if ('wp_inactive_widgets' == $sbname || 'orphaned_widgets' == substr($sbname, 0, 16)) {
289 289
 			echo '&nbsp;';
290 290
 		} else {
291
-			if ( !isset($sidebars_widgets[$sbname]) || !is_array($sidebars_widgets[$sbname]) ) {
291
+			if ( ! isset($sidebars_widgets[$sbname]) || ! is_array($sidebars_widgets[$sbname])) {
292 292
 				$j = 1;
293 293
 				$sidebars_widgets[$sbname] = array();
294 294
 			} else {
295 295
 				$j = count($sidebars_widgets[$sbname]);
296
-				if ( isset($_GET['addnew']) || !in_array($widget_id, $sidebars_widgets[$sbname], true) )
296
+				if (isset($_GET['addnew']) || ! in_array($widget_id, $sidebars_widgets[$sbname], true))
297 297
 					$j++;
298 298
 			}
299 299
 			$selected = '';
300 300
 			echo "\t\t<select name='{$sbname}_position'>\n";
301
-			echo "\t\t<option value=''>" . __('&mdash; Select &mdash;') . "</option>\n";
302
-			for ( $i = 1; $i <= $j; $i++ ) {
303
-				if ( in_array($widget_id, $sidebars_widgets[$sbname], true) )
304
-					$selected = selected( $i, $key + 1, false );
301
+			echo "\t\t<option value=''>".__('&mdash; Select &mdash;')."</option>\n";
302
+			for ($i = 1; $i <= $j; $i++) {
303
+				if (in_array($widget_id, $sidebars_widgets[$sbname], true))
304
+					$selected = selected($i, $key + 1, false);
305 305
 				echo "\t\t<option value='$i'$selected> $i </option>\n";
306 306
 			}
307 307
 			echo "\t\t</select>\n";
@@ -313,13 +313,13 @@  discard block
 block discarded – undo
313 313
 
314 314
 	<div class="widget-control-actions">
315 315
 <?php
316
-	if ( isset($_GET['addnew']) ) { ?>
316
+	if (isset($_GET['addnew'])) { ?>
317 317
 	<a href="widgets.php" class="button alignleft"><?php _e('Cancel'); ?></a>
318 318
 <?php
319 319
 	} else {
320
-		submit_button( __( 'Delete' ), 'alignleft', 'removewidget', false );
320
+		submit_button(__('Delete'), 'alignleft', 'removewidget', false);
321 321
 	}
322
-	submit_button( __( 'Save Widget' ), 'primary alignright', 'savewidget', false ); ?>
322
+	submit_button(__('Save Widget'), 'primary alignright', 'savewidget', false); ?>
323 323
 	<input type="hidden" name="widget-id" class="widget-id" value="<?php echo esc_attr($widget_id); ?>" />
324 324
 	<input type="hidden" name="id_base" class="id_base" value="<?php echo esc_attr($id_base); ?>" />
325 325
 	<input type="hidden" name="multi_number" class="multi_number" value="<?php echo esc_attr($multi_number); ?>" />
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	</div>
331 331
 	</div>
332 332
 <?php
333
-	require_once( ABSPATH . 'wp-admin/admin-footer.php' );
333
+	require_once(ABSPATH.'wp-admin/admin-footer.php');
334 334
 	exit;
335 335
 }
336 336
 
@@ -343,35 +343,35 @@  discard block
 block discarded – undo
343 343
 	__('Error in displaying the widget settings form.')
344 344
 );
345 345
 
346
-require_once( ABSPATH . 'wp-admin/admin-header.php' ); ?>
346
+require_once(ABSPATH.'wp-admin/admin-header.php'); ?>
347 347
 
348 348
 <div class="wrap">
349 349
 <h1 class="wp-heading-inline"><?php
350
-echo esc_html( $title );
350
+echo esc_html($title);
351 351
 ?></h1>
352 352
 
353 353
 <?php
354
-if ( current_user_can( 'customize' ) ) {
354
+if (current_user_can('customize')) {
355 355
 	printf(
356 356
 		' <a class="page-title-action hide-if-no-customize" href="%1$s">%2$s</a>',
357
-		esc_url( add_query_arg(
357
+		esc_url(add_query_arg(
358 358
 			array(
359
-				array( 'autofocus' => array( 'panel' => 'widgets' ) ),
360
-				'return' => urlencode( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) )
359
+				array('autofocus' => array('panel' => 'widgets')),
360
+				'return' => urlencode(remove_query_arg(wp_removable_query_args(), wp_unslash($_SERVER['REQUEST_URI'])))
361 361
 			),
362
-			admin_url( 'customize.php' )
363
-		) ),
364
-		__( 'Manage with Live Preview' )
362
+			admin_url('customize.php')
363
+		)),
364
+		__('Manage with Live Preview')
365 365
 	);
366 366
 }
367 367
 ?>
368 368
 
369 369
 <hr class="wp-header-end">
370 370
 
371
-<?php if ( isset($_GET['message']) && isset($messages[$_GET['message']]) ) { ?>
371
+<?php if (isset($_GET['message']) && isset($messages[$_GET['message']])) { ?>
372 372
 <div id="message" class="updated notice is-dismissible"><p><?php echo $messages[$_GET['message']]; ?></p></div>
373 373
 <?php } ?>
374
-<?php if ( isset($_GET['error']) && isset($errors[$_GET['error']]) ) { ?>
374
+<?php if (isset($_GET['error']) && isset($errors[$_GET['error']])) { ?>
375 375
 <div id="message" class="error"><p><?php echo $errors[$_GET['error']]; ?></p></div>
376 376
 <?php } ?>
377 377
 
@@ -381,14 +381,14 @@  discard block
 block discarded – undo
381 381
  *
382 382
  * @since 3.0.0
383 383
  */
384
-do_action( 'widgets_admin_page' ); ?>
384
+do_action('widgets_admin_page'); ?>
385 385
 
386 386
 <div class="widget-liquid-left">
387 387
 <div id="widgets-left">
388 388
 	<div id="available-widgets" class="widgets-holder-wrap">
389 389
 		<div class="sidebar-name">
390 390
 			<div class="sidebar-name-arrow"><br /></div>
391
-			<h2><?php _e( 'Available Widgets' ); ?> <span id="removing-widget"><?php _ex( 'Deactivate', 'removing-widget' ); ?> <span></span></span></h2>
391
+			<h2><?php _e('Available Widgets'); ?> <span id="removing-widget"><?php _ex('Deactivate', 'removing-widget'); ?> <span></span></span></h2>
392 392
 		</div>
393 393
 		<div class="widget-holder">
394 394
 			<div class="sidebar-description">
@@ -405,40 +405,40 @@  discard block
 block discarded – undo
405 405
 <?php
406 406
 
407 407
 $theme_sidebars = array();
408
-foreach ( $wp_registered_sidebars as $sidebar => $registered_sidebar ) {
409
-	if ( false !== strpos( $registered_sidebar['class'], 'inactive-sidebar' ) || 'orphaned_widgets' == substr( $sidebar, 0, 16 ) ) {
408
+foreach ($wp_registered_sidebars as $sidebar => $registered_sidebar) {
409
+	if (false !== strpos($registered_sidebar['class'], 'inactive-sidebar') || 'orphaned_widgets' == substr($sidebar, 0, 16)) {
410 410
 		$wrap_class = 'widgets-holder-wrap';
411
-		if ( !empty( $registered_sidebar['class'] ) )
412
-			$wrap_class .= ' ' . $registered_sidebar['class'];
411
+		if ( ! empty($registered_sidebar['class']))
412
+			$wrap_class .= ' '.$registered_sidebar['class'];
413 413
 
414 414
 		$is_inactive_widgets = 'wp_inactive_widgets' == $registered_sidebar['id'];
415 415
 		?>
416
-		<div class="<?php echo esc_attr( $wrap_class ); ?>">
416
+		<div class="<?php echo esc_attr($wrap_class); ?>">
417 417
 			<div class="widget-holder inactive">
418
-				<?php wp_list_widget_controls( $registered_sidebar['id'], $registered_sidebar['name'] ); ?>
418
+				<?php wp_list_widget_controls($registered_sidebar['id'], $registered_sidebar['name']); ?>
419 419
 
420
-				<?php if ( $is_inactive_widgets ) { ?>
420
+				<?php if ($is_inactive_widgets) { ?>
421 421
 				<div class="remove-inactive-widgets">
422 422
 					<form action="" method="post">
423 423
 						<p>
424 424
 							<?php
425
-							$attributes = array( 'id' => 'inactive-widgets-control-remove' );
425
+							$attributes = array('id' => 'inactive-widgets-control-remove');
426 426
 
427
-							if ( empty($sidebars_widgets['wp_inactive_widgets']) ) {
427
+							if (empty($sidebars_widgets['wp_inactive_widgets'])) {
428 428
 								$attributes['disabled'] = '';
429 429
 							}
430 430
 
431
-							submit_button( __( 'Clear Inactive Widgets' ), 'delete', 'removeinactivewidgets', false, $attributes );
431
+							submit_button(__('Clear Inactive Widgets'), 'delete', 'removeinactivewidgets', false, $attributes);
432 432
 							?>
433 433
 							<span class="spinner"></span>
434 434
 						</p>
435
-						<?php wp_nonce_field( 'remove-inactive-widgets', '_wpnonce_remove_inactive_widgets' ); ?>
435
+						<?php wp_nonce_field('remove-inactive-widgets', '_wpnonce_remove_inactive_widgets'); ?>
436 436
 					</form>
437 437
 				</div>
438 438
 				<?php } ?>
439 439
 			</div>
440
-			<?php if ( $is_inactive_widgets ) { ?>
441
-			<p class="description"><?php _e( 'This will clear all items from the inactive widgets list. You will not be able to restore any customizations.' ); ?></p>
440
+			<?php if ($is_inactive_widgets) { ?>
441
+			<p class="description"><?php _e('This will clear all items from the inactive widgets list. You will not be able to restore any customizations.'); ?></p>
442 442
 			<?php } ?>
443 443
 		</div>
444 444
 		<?php
@@ -455,10 +455,10 @@  discard block
 block discarded – undo
455 455
 
456 456
 $i = $split = 0;
457 457
 $single_sidebar_class = '';
458
-$sidebars_count = count( $theme_sidebars );
458
+$sidebars_count = count($theme_sidebars);
459 459
 
460
-if ( $sidebars_count > 1 ) {
461
-	$split = ceil( $sidebars_count / 2 );
460
+if ($sidebars_count > 1) {
461
+	$split = ceil($sidebars_count / 2);
462 462
 } else {
463 463
 	$single_sidebar_class = ' single-sidebar';
464 464
 }
@@ -469,23 +469,23 @@  discard block
 block discarded – undo
469 469
 <div class="sidebars-column-1">
470 470
 <?php
471 471
 
472
-foreach ( $theme_sidebars as $sidebar => $registered_sidebar ) {
472
+foreach ($theme_sidebars as $sidebar => $registered_sidebar) {
473 473
 	$wrap_class = 'widgets-holder-wrap';
474
-	if ( !empty( $registered_sidebar['class'] ) )
475
-		$wrap_class .= ' sidebar-' . $registered_sidebar['class'];
474
+	if ( ! empty($registered_sidebar['class']))
475
+		$wrap_class .= ' sidebar-'.$registered_sidebar['class'];
476 476
 
477
-	if ( $i > 0 )
477
+	if ($i > 0)
478 478
 		$wrap_class .= ' closed';
479 479
 
480
-	if ( $split && $i == $split ) {
480
+	if ($split && $i == $split) {
481 481
 		?>
482 482
 		</div><div class="sidebars-column-2">
483 483
 		<?php
484 484
 	}
485 485
 
486 486
 	?>
487
-	<div class="<?php echo esc_attr( $wrap_class ); ?>">
488
-		<?php wp_list_widget_controls( $sidebar, $registered_sidebar['name'] ); // Show the control forms for each of the widgets in this sidebar ?>
487
+	<div class="<?php echo esc_attr($wrap_class); ?>">
488
+		<?php wp_list_widget_controls($sidebar, $registered_sidebar['name']); // Show the control forms for each of the widgets in this sidebar ?>
489 489
 	</div>
490 490
 	<?php
491 491
 
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 </div>
498 498
 </div>
499 499
 <form method="post">
500
-<?php wp_nonce_field( 'save-sidebar-widgets', '_wpnonce_widgets', false ); ?>
500
+<?php wp_nonce_field('save-sidebar-widgets', '_wpnonce_widgets', false); ?>
501 501
 </form>
502 502
 <br class="clear" />
503 503
 </div>
@@ -505,8 +505,8 @@  discard block
 block discarded – undo
505 505
 <div class="widgets-chooser">
506 506
 	<ul class="widgets-chooser-sidebars"></ul>
507 507
 	<div class="widgets-chooser-actions">
508
-		<button class="button widgets-chooser-cancel"><?php _e( 'Cancel' ); ?></button>
509
-		<button class="button button-primary widgets-chooser-add"><?php _e( 'Add Widget' ); ?></button>
508
+		<button class="button widgets-chooser-cancel"><?php _e('Cancel'); ?></button>
509
+		<button class="button button-primary widgets-chooser-add"><?php _e('Add Widget'); ?></button>
510 510
 	</div>
511 511
 </div>
512 512
 
@@ -517,5 +517,5 @@  discard block
 block discarded – undo
517 517
  *
518 518
  * @since 2.2.0
519 519
  */
520
-do_action( 'sidebar_admin_page' );
521
-require_once( ABSPATH . 'wp-admin/admin-footer.php' );
520
+do_action('sidebar_admin_page');
521
+require_once(ABSPATH.'wp-admin/admin-footer.php');
Please login to merge, or discard this patch.
src/wp-admin/load-styles.php 2 patches
Braces   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,8 +22,9 @@  discard block
 block discarded – undo
22 22
 $load = preg_replace( '/[^a-z0-9,_-]+/i', '', $load );
23 23
 $load = array_unique( explode( ',', $load ) );
24 24
 
25
-if ( empty($load) )
25
+if ( empty($load) ) {
26 26
 	exit;
27
+}
27 28
 
28 29
 $compress = ( isset($_GET['c']) && $_GET['c'] );
29 30
 $force_gzip = ( $compress && 'gzip' == $_GET['c'] );
@@ -44,8 +45,9 @@  discard block
 block discarded – undo
44 45
 }
45 46
 
46 47
 foreach ( $load as $handle ) {
47
-	if ( !array_key_exists($handle, $wp_styles->registered) )
48
-		continue;
48
+	if ( !array_key_exists($handle, $wp_styles->registered) ) {
49
+			continue;
50
+	}
49 51
 
50 52
 	$style = $wp_styles->registered[$handle];
51 53
 
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -8,86 +8,86 @@
 block discarded – undo
8 8
 error_reporting(0);
9 9
 
10 10
 /** Set ABSPATH for execution */
11
-if ( ! defined( 'ABSPATH' ) ) {
12
-	define( 'ABSPATH', dirname( dirname( __FILE__ ) ) . '/' );
11
+if ( ! defined('ABSPATH')) {
12
+	define('ABSPATH', dirname(dirname(__FILE__)).'/');
13 13
 }
14 14
 
15
-define( 'WPINC', 'wp-includes' );
15
+define('WPINC', 'wp-includes');
16 16
 
17
-require( ABSPATH . 'wp-admin/includes/noop.php' );
18
-require( ABSPATH . WPINC . '/script-loader.php' );
19
-require( ABSPATH . WPINC . '/version.php' );
17
+require(ABSPATH.'wp-admin/includes/noop.php');
18
+require(ABSPATH.WPINC.'/script-loader.php');
19
+require(ABSPATH.WPINC.'/version.php');
20 20
 
21 21
 $load = $_GET['load'];
22
-if ( is_array( $load ) ) {
23
-	$load = implode( '', $load );
22
+if (is_array($load)) {
23
+	$load = implode('', $load);
24 24
 }
25
-$load = preg_replace( '/[^a-z0-9,_-]+/i', '', $load );
26
-$load = array_unique( explode( ',', $load ) );
25
+$load = preg_replace('/[^a-z0-9,_-]+/i', '', $load);
26
+$load = array_unique(explode(',', $load));
27 27
 
28
-if ( empty($load) )
28
+if (empty($load))
29 29
 	exit;
30 30
 
31
-$compress = ( isset($_GET['c']) && $_GET['c'] );
32
-$force_gzip = ( $compress && 'gzip' == $_GET['c'] );
33
-$rtl = ( isset($_GET['dir']) && 'rtl' == $_GET['dir'] );
31
+$compress = (isset($_GET['c']) && $_GET['c']);
32
+$force_gzip = ($compress && 'gzip' == $_GET['c']);
33
+$rtl = (isset($_GET['dir']) && 'rtl' == $_GET['dir']);
34 34
 $expires_offset = 31536000; // 1 year
35 35
 $out = '';
36 36
 
37 37
 $wp_styles = new WP_Styles();
38 38
 wp_default_styles($wp_styles);
39 39
 
40
-if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) && stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) === $wp_version ) {
40
+if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) === $wp_version) {
41 41
 	$protocol = $_SERVER['SERVER_PROTOCOL'];
42
-	if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ) ) ) {
42
+	if ( ! in_array($protocol, array('HTTP/1.1', 'HTTP/2', 'HTTP/2.0'))) {
43 43
 		$protocol = 'HTTP/1.0';
44 44
 	}
45
-	header( "$protocol 304 Not Modified" );
45
+	header("$protocol 304 Not Modified");
46 46
 	exit();
47 47
 }
48 48
 
49
-foreach ( $load as $handle ) {
50
-	if ( !array_key_exists($handle, $wp_styles->registered) )
49
+foreach ($load as $handle) {
50
+	if ( ! array_key_exists($handle, $wp_styles->registered))
51 51
 		continue;
52 52
 
53 53
 	$style = $wp_styles->registered[$handle];
54 54
 
55
-	if ( empty( $style->src ) ) {
55
+	if (empty($style->src)) {
56 56
 		continue;
57 57
 	}
58 58
 
59
-	$path = ABSPATH . $style->src;
59
+	$path = ABSPATH.$style->src;
60 60
 
61
-	if ( $rtl && ! empty( $style->extra['rtl'] ) ) {
61
+	if ($rtl && ! empty($style->extra['rtl'])) {
62 62
 		// All default styles have fully independent RTL files.
63
-		$path = str_replace( '.min.css', '-rtl.min.css', $path );
63
+		$path = str_replace('.min.css', '-rtl.min.css', $path);
64 64
 	}
65 65
 
66
-	$content = get_file( $path ) . "\n";
66
+	$content = get_file($path)."\n";
67 67
 
68
-	if ( strpos( $style->src, '/' . WPINC . '/css/' ) === 0 ) {
69
-		$content = str_replace( '../images/', '../' . WPINC . '/images/', $content );
70
-		$content = str_replace( '../js/tinymce/', '../' . WPINC . '/js/tinymce/', $content );
71
-		$content = str_replace( '../fonts/', '../' . WPINC . '/fonts/', $content );
68
+	if (strpos($style->src, '/'.WPINC.'/css/') === 0) {
69
+		$content = str_replace('../images/', '../'.WPINC.'/images/', $content);
70
+		$content = str_replace('../js/tinymce/', '../'.WPINC.'/js/tinymce/', $content);
71
+		$content = str_replace('../fonts/', '../'.WPINC.'/fonts/', $content);
72 72
 		$out .= $content;
73 73
 	} else {
74
-		$out .= str_replace( '../images/', 'images/', $content );
74
+		$out .= str_replace('../images/', 'images/', $content);
75 75
 	}
76 76
 }
77 77
 
78 78
 header("Etag: $wp_version");
79 79
 header('Content-Type: text/css; charset=UTF-8');
80
-header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');
80
+header('Expires: '.gmdate("D, d M Y H:i:s", time() + $expires_offset).' GMT');
81 81
 header("Cache-Control: public, max-age=$expires_offset");
82 82
 
83
-if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {
83
+if ($compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING'])) {
84 84
 	header('Vary: Accept-Encoding'); // Handle proxies
85
-	if ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {
85
+	if (false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip) {
86 86
 		header('Content-Encoding: deflate');
87
-		$out = gzdeflate( $out, 3 );
88
-	} elseif ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) {
87
+		$out = gzdeflate($out, 3);
88
+	} elseif (false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode')) {
89 89
 		header('Content-Encoding: gzip');
90
-		$out = gzencode( $out, 3 );
90
+		$out = gzencode($out, 3);
91 91
 	}
92 92
 }
93 93
 
Please login to merge, or discard this patch.