@@ -38,7 +38,9 @@ discard block |
||
| 38 | 38 | $po = new PO; |
| 39 | 39 | foreach($this->headers as $header) { |
| 40 | 40 | $string = $makepot->get_addon_header($header, $source); |
| 41 | - if (!$string) continue; |
|
| 41 | + if (!$string) { |
|
| 42 | + continue; |
|
| 43 | + } |
|
| 42 | 44 | $args = array( |
| 43 | 45 | 'singular' => $string, |
| 44 | 46 | 'extracted_comments' => $header.' of the plugin/theme', |
@@ -50,17 +52,22 @@ discard block |
||
| 50 | 52 | } |
| 51 | 53 | |
| 52 | 54 | function append( $ext_filename, $pot_filename, $headers = null ) { |
| 53 | - if ( $headers ) |
|
| 54 | - $this->headers = (array) $headers; |
|
| 55 | + if ( $headers ) { |
|
| 56 | + $this->headers = (array) $headers; |
|
| 57 | + } |
|
| 55 | 58 | if ( is_dir( $ext_filename ) ) { |
| 56 | 59 | $pot = implode('', array_map(array($this, 'load_from_file'), glob("$ext_filename/*.php"))); |
| 57 | 60 | } else { |
| 58 | 61 | $pot = $this->load_from_file($ext_filename); |
| 59 | 62 | } |
| 60 | 63 | $potf = '-' == $pot_filename? STDOUT : fopen($pot_filename, 'a'); |
| 61 | - if (!$potf) return false; |
|
| 64 | + if (!$potf) { |
|
| 65 | + return false; |
|
| 66 | + } |
|
| 62 | 67 | fwrite($potf, $pot); |
| 63 | - if ('-' != $pot_filename) fclose($potf); |
|
| 68 | + if ('-' != $pot_filename) { |
|
| 69 | + fclose($potf); |
|
| 70 | + } |
|
| 64 | 71 | return true; |
| 65 | 72 | } |
| 66 | 73 | } |
@@ -7,10 +7,11 @@ discard block |
||
| 7 | 7 | * @subpackage tools |
| 8 | 8 | */ |
| 9 | 9 | // see: http://php.net/tokenizer |
| 10 | -if ( ! defined( 'T_ML_COMMENT' ) ) |
|
| 10 | +if ( ! defined( 'T_ML_COMMENT' ) ) { |
|
| 11 | 11 | define( 'T_ML_COMMENT', T_COMMENT ); |
| 12 | -else |
|
| 12 | +} else { |
|
| 13 | 13 | define( 'T_DOC_COMMENT', T_ML_COMMENT ); |
| 14 | +} |
|
| 14 | 15 | |
| 15 | 16 | $pomo = dirname( dirname( dirname( __FILE__ ) ) ) . '/src/wp-includes/pomo'; |
| 16 | 17 | require_once "$pomo/po.php"; |
@@ -31,7 +32,9 @@ discard block |
||
| 31 | 32 | |
| 32 | 33 | function logmsg() { |
| 33 | 34 | $args = func_get_args(); |
| 34 | - if ($this->enable_logging) error_log(implode(' ', $args)); |
|
| 35 | + if ($this->enable_logging) { |
|
| 36 | + error_log(implode(' ', $args)); |
|
| 37 | + } |
|
| 35 | 38 | } |
| 36 | 39 | |
| 37 | 40 | function stderr($msg, $nl=true) { |
@@ -56,12 +59,15 @@ discard block |
||
| 56 | 59 | $items = scandir( $dir ); |
| 57 | 60 | foreach ( (array) $items as $item ) { |
| 58 | 61 | $full_item = $dir . '/' . $item; |
| 59 | - if ('.' == $item || '..' == $item) |
|
| 60 | - continue; |
|
| 61 | - if ('.php' == substr($item, -4)) |
|
| 62 | - $files[] = $full_item; |
|
| 63 | - if (is_dir($full_item)) |
|
| 64 | - $files += array_merge($files, NotGettexted::list_php_files($full_item, $files)); |
|
| 62 | + if ('.' == $item || '..' == $item) { |
|
| 63 | + continue; |
|
| 64 | + } |
|
| 65 | + if ('.php' == substr($item, -4)) { |
|
| 66 | + $files[] = $full_item; |
|
| 67 | + } |
|
| 68 | + if (is_dir($full_item)) { |
|
| 69 | + $files += array_merge($files, NotGettexted::list_php_files($full_item, $files)); |
|
| 70 | + } |
|
| 65 | 71 | } |
| 66 | 72 | return $files; |
| 67 | 73 | } |
@@ -102,7 +108,9 @@ discard block |
||
| 102 | 108 | $stage = $this->STAGE_END_COMMENT; |
| 103 | 109 | $this->logmsg('end comment', $current_comment_id); |
| 104 | 110 | $result .= call_user_func($other_action, $token); |
| 105 | - if (!is_null($register_action)) call_user_func($register_action, $current_string, $current_comment_id, $current_string_line); |
|
| 111 | + if (!is_null($register_action)) { |
|
| 112 | + call_user_func($register_action, $current_string, $current_comment_id, $current_string_line); |
|
| 113 | + } |
|
| 106 | 114 | continue; |
| 107 | 115 | } |
| 108 | 116 | } else if (T_CONSTANT_ENCAPSED_STRING == $id) { |
@@ -141,10 +149,11 @@ discard block |
||
| 141 | 149 | function command_extract() { |
| 142 | 150 | $args = func_get_args(); |
| 143 | 151 | $pot_filename = $args[0]; |
| 144 | - if (isset($args[1]) && is_array($args[1])) |
|
| 145 | - $filenames = $args[1]; |
|
| 146 | - else |
|
| 147 | - $filenames = array_slice($args, 1); |
|
| 152 | + if (isset($args[1]) && is_array($args[1])) { |
|
| 153 | + $filenames = $args[1]; |
|
| 154 | + } else { |
|
| 155 | + $filenames = array_slice($args, 1); |
|
| 156 | + } |
|
| 148 | 157 | |
| 149 | 158 | $global_name = '__entries_'.mt_rand(1, 1000); |
| 150 | 159 | $GLOBALS[$global_name] = array(); |
@@ -172,17 +181,20 @@ discard block |
||
| 172 | 181 | $entry = new Translation_Entry($args); |
| 173 | 182 | fwrite($potf, "\n".PO::export_entry($entry)."\n"); |
| 174 | 183 | } |
| 175 | - if ('-' != $pot_filename) fclose($potf); |
|
| 184 | + if ('-' != $pot_filename) { |
|
| 185 | + fclose($potf); |
|
| 186 | + } |
|
| 176 | 187 | return true; |
| 177 | 188 | } |
| 178 | 189 | |
| 179 | 190 | function command_replace() { |
| 180 | 191 | $args = func_get_args(); |
| 181 | 192 | $mo_filename = $args[0]; |
| 182 | - if (isset($args[1]) && is_array($args[1])) |
|
| 183 | - $filenames = $args[1]; |
|
| 184 | - else |
|
| 185 | - $filenames = array_slice($args, 1); |
|
| 193 | + if (isset($args[1]) && is_array($args[1])) { |
|
| 194 | + $filenames = $args[1]; |
|
| 195 | + } else { |
|
| 196 | + $filenames = array_slice($args, 1); |
|
| 197 | + } |
|
| 186 | 198 | |
| 187 | 199 | $global_name = '__mo_'.mt_rand(1, 1000); |
| 188 | 200 | $GLOBALS[$global_name] = new MO(); |
@@ -194,7 +206,9 @@ discard block |
||
| 194 | 206 | } |
| 195 | 207 | foreach($filenames as $filename) { |
| 196 | 208 | $source = file_get_contents($filename); |
| 197 | - if ( strlen($source) > 150000 ) continue; |
|
| 209 | + if ( strlen($source) > 150000 ) { |
|
| 210 | + continue; |
|
| 211 | + } |
|
| 198 | 212 | $tokens = token_get_all($source); |
| 199 | 213 | $new_file = $this->walk_tokens($tokens, $replacer, array($this, 'unchanged_token')); |
| 200 | 214 | $f = fopen($filename, 'w'); |
@@ -2,8 +2,11 @@ |
||
| 2 | 2 | |
| 3 | 3 | if (! isset($wp_did_header)): |
| 4 | 4 | if ( !file_exists( dirname(__FILE__) . '/wp-config.php') ) { |
| 5 | - if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) $path = ''; |
|
| 6 | - else $path = 'wp-admin/'; |
|
| 5 | + if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) { |
|
| 6 | + $path = ''; |
|
| 7 | + } else { |
|
| 8 | + $path = 'wp-admin/'; |
|
| 9 | + } |
|
| 7 | 10 | |
| 8 | 11 | require_once( dirname(__FILE__) . '/wp-includes/classes.php'); |
| 9 | 12 | require_once( dirname(__FILE__) . '/wp-includes/functions.php'); |
@@ -2,8 +2,11 @@ |
||
| 2 | 2 | |
| 3 | 3 | if (! isset($wp_did_header)): |
| 4 | 4 | if ( !file_exists( dirname(__FILE__) . '/wp-config.php') ) { |
| 5 | - if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) $path = ''; |
|
| 6 | - else $path = 'wp-admin/'; |
|
| 5 | + if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) { |
|
| 6 | + $path = ''; |
|
| 7 | + } else { |
|
| 8 | + $path = 'wp-admin/'; |
|
| 9 | + } |
|
| 7 | 10 | |
| 8 | 11 | require_once( dirname(__FILE__) . '/wp-includes/classes.php'); |
| 9 | 12 | require_once( dirname(__FILE__) . '/wp-includes/functions.php'); |
@@ -36,10 +36,11 @@ discard block |
||
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | function process_token($token_text, $inplace) { |
| 39 | - if ($inplace) |
|
| 40 | - $this->modified_contents .= $token_text; |
|
| 41 | - else |
|
| 42 | - echo $token_text; |
|
| 39 | + if ($inplace) { |
|
| 40 | + $this->modified_contents .= $token_text; |
|
| 41 | + } else { |
|
| 42 | + echo $token_text; |
|
| 43 | + } |
|
| 43 | 44 | } |
| 44 | 45 | |
| 45 | 46 | |
@@ -108,7 +109,9 @@ discard block |
||
| 108 | 109 | $inplace = false; |
| 109 | 110 | if ('-i' == $argv[1]) { |
| 110 | 111 | $inplace = true; |
| 111 | - if (!isset($argv[3])) $adddomain->usage(); |
|
| 112 | + if (!isset($argv[3])) { |
|
| 113 | + $adddomain->usage(); |
|
| 114 | + } |
|
| 112 | 115 | array_shift($argv); |
| 113 | 116 | } |
| 114 | 117 | |
@@ -149,8 +149,9 @@ discard block |
||
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | function __destruct() { |
| 152 | - foreach ( $this->temp_files as $temp_file ) |
|
| 153 | - unlink( $temp_file ); |
|
| 152 | + foreach ( $this->temp_files as $temp_file ) { |
|
| 153 | + unlink( $temp_file ); |
|
| 154 | + } |
|
| 154 | 155 | } |
| 155 | 156 | |
| 156 | 157 | function tempnam( $file ) { |
@@ -208,13 +209,16 @@ discard block |
||
| 208 | 209 | $args = array_merge( $defaults, $args ); |
| 209 | 210 | extract( $args ); |
| 210 | 211 | $placeholders = array(); |
| 211 | - if ( $wp_version = $this->wp_version( $dir ) ) |
|
| 212 | - $placeholders['version'] = $wp_version; |
|
| 213 | - else |
|
| 214 | - return false; |
|
| 212 | + if ( $wp_version = $this->wp_version( $dir ) ) { |
|
| 213 | + $placeholders['version'] = $wp_version; |
|
| 214 | + } else { |
|
| 215 | + return false; |
|
| 216 | + } |
|
| 215 | 217 | $output = is_null( $output )? $default_output : $output; |
| 216 | 218 | $res = $this->xgettext( $project, $dir, $output, $placeholders, $excludes, $includes ); |
| 217 | - if ( !$res ) return false; |
|
| 219 | + if ( !$res ) { |
|
| 220 | + return false; |
|
| 221 | + } |
|
| 218 | 222 | |
| 219 | 223 | if ( $extract_not_gettexted ) { |
| 220 | 224 | $old_dir = getcwd(); |
@@ -233,7 +237,9 @@ discard block |
||
| 233 | 237 | } |
| 234 | 238 | |
| 235 | 239 | function wp_core($dir, $output) { |
| 236 | - if ( file_exists( "$dir/wp-admin/user/about.php" ) ) return false; |
|
| 240 | + if ( file_exists( "$dir/wp-admin/user/about.php" ) ) { |
|
| 241 | + return false; |
|
| 242 | + } |
|
| 237 | 243 | |
| 238 | 244 | return $this->wp_generic( $dir, array( |
| 239 | 245 | 'project' => 'wp-core', 'output' => $output, |
@@ -316,21 +322,29 @@ discard block |
||
| 316 | 322 | } |
| 317 | 323 | |
| 318 | 324 | function wp_network_admin($dir, $output) { |
| 319 | - if ( ! file_exists( "$dir/wp-admin/user/about.php" ) ) return false; |
|
| 325 | + if ( ! file_exists( "$dir/wp-admin/user/about.php" ) ) { |
|
| 326 | + return false; |
|
| 327 | + } |
|
| 320 | 328 | |
| 321 | 329 | $frontend_pot = $this->tempnam( 'frontend.pot' ); |
| 322 | - if ( false === $frontend_pot ) return false; |
|
| 330 | + if ( false === $frontend_pot ) { |
|
| 331 | + return false; |
|
| 332 | + } |
|
| 323 | 333 | |
| 324 | 334 | $frontend_result = $this->wp_frontend( $dir, $frontend_pot ); |
| 325 | - if ( ! $frontend_result ) |
|
| 326 | - return false; |
|
| 335 | + if ( ! $frontend_result ) { |
|
| 336 | + return false; |
|
| 337 | + } |
|
| 327 | 338 | |
| 328 | 339 | $admin_pot = $this->tempnam( 'admin.pot' ); |
| 329 | - if ( false === $admin_pot ) return false; |
|
| 340 | + if ( false === $admin_pot ) { |
|
| 341 | + return false; |
|
| 342 | + } |
|
| 330 | 343 | |
| 331 | 344 | $admin_result = $this->wp_admin( $dir, $admin_pot ); |
| 332 | - if ( ! $admin_result ) |
|
| 333 | - return false; |
|
| 345 | + if ( ! $admin_result ) { |
|
| 346 | + return false; |
|
| 347 | + } |
|
| 334 | 348 | |
| 335 | 349 | $result = $this->wp_generic( $dir, array( |
| 336 | 350 | 'project' => 'wp-network-admin', 'output' => $output, |
@@ -344,8 +358,9 @@ discard block |
||
| 344 | 358 | } |
| 345 | 359 | |
| 346 | 360 | $common_pot = $this->tempnam( 'common.pot' ); |
| 347 | - if ( ! $common_pot ) |
|
| 348 | - return false; |
|
| 361 | + if ( ! $common_pot ) { |
|
| 362 | + return false; |
|
| 363 | + } |
|
| 349 | 364 | |
| 350 | 365 | $net_admin_pot = realpath( is_null( $output ) ? 'wordpress-network-admin.pot' : $output ); |
| 351 | 366 | system( "msgcat --more-than=1 --use-first $frontend_pot $admin_pot $net_admin_pot > $common_pot" ); |
@@ -354,13 +369,20 @@ discard block |
||
| 354 | 369 | } |
| 355 | 370 | |
| 356 | 371 | function wp_ms($dir, $output) { |
| 357 | - if ( file_exists( "$dir/wp-admin/user/about.php" ) ) return false; |
|
| 358 | - if ( !is_file("$dir/wp-admin/ms-users.php") ) return false; |
|
| 372 | + if ( file_exists( "$dir/wp-admin/user/about.php" ) ) { |
|
| 373 | + return false; |
|
| 374 | + } |
|
| 375 | + if ( !is_file("$dir/wp-admin/ms-users.php") ) { |
|
| 376 | + return false; |
|
| 377 | + } |
|
| 359 | 378 | $core_pot = $this->tempnam( 'wordpress.pot' ); |
| 360 | - if ( false === $core_pot ) return false; |
|
| 361 | - $core_result = $this->wp_core( $dir, $core_pot ); |
|
| 362 | - if ( ! $core_result ) |
|
| 379 | + if ( false === $core_pot ) { |
|
| 363 | 380 | return false; |
| 381 | + } |
|
| 382 | + $core_result = $this->wp_core( $dir, $core_pot ); |
|
| 383 | + if ( ! $core_result ) { |
|
| 384 | + return false; |
|
| 385 | + } |
|
| 364 | 386 | $ms_result = $this->wp_generic( $dir, array( |
| 365 | 387 | 'project' => 'wp-ms', 'output' => $output, |
| 366 | 388 | 'includes' => $this->ms_files, |
@@ -373,8 +395,9 @@ discard block |
||
| 373 | 395 | return false; |
| 374 | 396 | } |
| 375 | 397 | $common_pot = $this->tempnam( 'common.pot' ); |
| 376 | - if ( ! $common_pot ) |
|
| 377 | - return false; |
|
| 398 | + if ( ! $common_pot ) { |
|
| 399 | + return false; |
|
| 400 | + } |
|
| 378 | 401 | $ms_pot = realpath( is_null( $output )? 'wordpress-ms.pot' : $output ); |
| 379 | 402 | system( "msgcat --more-than=1 --use-first $core_pot $ms_pot > $common_pot" ); |
| 380 | 403 | system( "msgcat -u --use-first $ms_pot $common_pot -o $ms_pot" ); |
@@ -383,7 +406,9 @@ discard block |
||
| 383 | 406 | |
| 384 | 407 | function wp_tz($dir, $output) { |
| 385 | 408 | $continents_path = 'wp-admin/includes/continents-cities.php'; |
| 386 | - if ( !file_exists( "$dir/$continents_path" ) ) return false; |
|
| 409 | + if ( !file_exists( "$dir/$continents_path" ) ) { |
|
| 410 | + return false; |
|
| 411 | + } |
|
| 387 | 412 | return $this->wp_generic( $dir, array( |
| 388 | 413 | 'project' => 'wp-tz', 'output' => $output, |
| 389 | 414 | 'includes' => array( $continents_path ), |
@@ -394,7 +419,9 @@ discard block |
||
| 394 | 419 | |
| 395 | 420 | function wp_version($dir) { |
| 396 | 421 | $version_php = $dir.'/wp-includes/version.php'; |
| 397 | - if ( !is_readable( $version_php ) ) return false; |
|
| 422 | + if ( !is_readable( $version_php ) ) { |
|
| 423 | + return false; |
|
| 424 | + } |
|
| 398 | 425 | return preg_match( '/\$wp_version\s*=\s*\'(.*?)\';/', file_get_contents( $version_php ), $matches )? $matches[1] : false; |
| 399 | 426 | } |
| 400 | 427 | |
@@ -418,11 +445,15 @@ discard block |
||
| 418 | 445 | |
| 419 | 446 | function get_first_lines($filename, $lines = 30) { |
| 420 | 447 | $extf = fopen($filename, 'r'); |
| 421 | - if (!$extf) return false; |
|
| 448 | + if (!$extf) { |
|
| 449 | + return false; |
|
| 450 | + } |
|
| 422 | 451 | $first_lines = ''; |
| 423 | 452 | foreach(range(1, $lines) as $x) { |
| 424 | 453 | $line = fgets($extf); |
| 425 | - if (feof($extf)) break; |
|
| 454 | + if (feof($extf)) { |
|
| 455 | + break; |
|
| 456 | + } |
|
| 426 | 457 | if (false === $line) { |
| 427 | 458 | return false; |
| 428 | 459 | } |
@@ -433,10 +464,11 @@ discard block |
||
| 433 | 464 | |
| 434 | 465 | |
| 435 | 466 | function get_addon_header($header, &$source) { |
| 436 | - if (preg_match('|'.$header.':(.*)$|mi', $source, $matches)) |
|
| 437 | - return trim($matches[1]); |
|
| 438 | - else |
|
| 439 | - return false; |
|
| 467 | + if (preg_match('|'.$header.':(.*)$|mi', $source, $matches)) { |
|
| 468 | + return trim($matches[1]); |
|
| 469 | + } else { |
|
| 470 | + return false; |
|
| 471 | + } |
|
| 440 | 472 | } |
| 441 | 473 | |
| 442 | 474 | function generic($dir, $output) { |
@@ -507,7 +539,9 @@ discard block |
||
| 507 | 539 | |
| 508 | 540 | $output = is_null($output)? "$slug.pot" : $output; |
| 509 | 541 | $res = $this->xgettext('wp-plugin', $dir, $output, $placeholders); |
| 510 | - if (!$res) return false; |
|
| 542 | + if (!$res) { |
|
| 543 | + return false; |
|
| 544 | + } |
|
| 511 | 545 | $potextmeta = new PotExtMeta; |
| 512 | 546 | $res = $potextmeta->append($main_file, $output); |
| 513 | 547 | /* Adding non-gettexted strings can repeat some phrases */ |
@@ -531,19 +565,22 @@ discard block |
||
| 531 | 565 | $placeholders['slug'] = $slug; |
| 532 | 566 | |
| 533 | 567 | $license = $this->get_addon_header( 'License', $source ); |
| 534 | - if ( $license ) |
|
| 535 | - $this->meta['wp-theme']['comments'] = "Copyright (C) {year} {author}\nThis file is distributed under the {$license}."; |
|
| 536 | - else |
|
| 537 | - $this->meta['wp-theme']['comments'] = "Copyright (C) {year} {author}\nThis file is distributed under the same license as the {package-name} package."; |
|
| 568 | + if ( $license ) { |
|
| 569 | + $this->meta['wp-theme']['comments'] = "Copyright (C) {year} {author}\nThis file is distributed under the {$license}."; |
|
| 570 | + } else { |
|
| 571 | + $this->meta['wp-theme']['comments'] = "Copyright (C) {year} {author}\nThis file is distributed under the same license as the {package-name} package."; |
|
| 572 | + } |
|
| 538 | 573 | |
| 539 | 574 | $output = is_null($output)? "$slug.pot" : $output; |
| 540 | 575 | $res = $this->xgettext('wp-theme', $dir, $output, $placeholders); |
| 541 | - if (! $res ) |
|
| 542 | - return false; |
|
| 576 | + if (! $res ) { |
|
| 577 | + return false; |
|
| 578 | + } |
|
| 543 | 579 | $potextmeta = new PotExtMeta; |
| 544 | 580 | $res = $potextmeta->append( $main_file, $output, array( 'Theme Name', 'Theme URI', 'Description', 'Author', 'Author URI' ) ); |
| 545 | - if ( ! $res ) |
|
| 546 | - return false; |
|
| 581 | + if ( ! $res ) { |
|
| 582 | + return false; |
|
| 583 | + } |
|
| 547 | 584 | // If we're dealing with a pre-3.4 default theme, don't extract page templates before 3.4. |
| 548 | 585 | $extract_templates = ! in_array( $slug, array( 'twentyten', 'twentyeleven', 'default', 'classic' ) ); |
| 549 | 586 | if ( ! $extract_templates ) { |
@@ -552,16 +589,19 @@ discard block |
||
| 552 | 589 | } |
| 553 | 590 | if ( $extract_templates ) { |
| 554 | 591 | $res = $potextmeta->append( $dir, $output, array( 'Template Name' ) ); |
| 555 | - if ( ! $res ) |
|
| 556 | - return false; |
|
| 592 | + if ( ! $res ) { |
|
| 593 | + return false; |
|
| 594 | + } |
|
| 557 | 595 | $files = scandir( $dir ); |
| 558 | 596 | foreach ( $files as $file ) { |
| 559 | - if ( '.' == $file[0] || 'CVS' == $file ) |
|
| 560 | - continue; |
|
| 597 | + if ( '.' == $file[0] || 'CVS' == $file ) { |
|
| 598 | + continue; |
|
| 599 | + } |
|
| 561 | 600 | if ( is_dir( $dir . '/' . $file ) ) { |
| 562 | 601 | $res = $potextmeta->append( $dir . '/' . $file, $output, array( 'Template Name' ) ); |
| 563 | - if ( ! $res ) |
|
| 564 | - return false; |
|
| 602 | + if ( ! $res ) { |
|
| 603 | + return false; |
|
| 604 | + } |
|
| 565 | 605 | } |
| 566 | 606 | } |
| 567 | 607 | } |
@@ -603,9 +643,10 @@ discard block |
||
| 603 | 643 | function is_ms_file( $file_name ) { |
| 604 | 644 | $is_ms_file = false; |
| 605 | 645 | $prefix = substr( $file_name, 0, 2 ) === './'? '\./' : ''; |
| 606 | - foreach( $this->ms_files as $ms_file ) |
|
| 607 | - if ( preg_match( '|^'.$prefix.$ms_file.'$|', $file_name ) ) { |
|
| 646 | + foreach( $this->ms_files as $ms_file ) { |
|
| 647 | + if ( preg_match( '|^'.$prefix.$ms_file.'$|', $file_name ) ) { |
|
| 608 | 648 | $is_ms_file = true; |
| 649 | + } |
|
| 609 | 650 | break; |
| 610 | 651 | } |
| 611 | 652 | return $is_ms_file; |
@@ -26,7 +26,9 @@ discard block |
||
| 26 | 26 | $translations = new Translations; |
| 27 | 27 | $file_names = (array) scandir( '.' ); |
| 28 | 28 | foreach ( $file_names as $file_name ) { |
| 29 | - if ( '.' == $file_name || '..' == $file_name ) continue; |
|
| 29 | + if ( '.' == $file_name || '..' == $file_name ) { |
|
| 30 | + continue; |
|
| 31 | + } |
|
| 30 | 32 | if ( preg_match( '/\.php$/', $file_name ) && $this->does_file_name_match( $prefix . $file_name, $excludes, $includes ) ) { |
| 31 | 33 | $extracted = $this->extract_from_file( $file_name, $prefix ); |
| 32 | 34 | $translations->merge_originals_with( $extracted ); |
@@ -54,7 +56,9 @@ discard block |
||
| 54 | 56 | break; |
| 55 | 57 | } |
| 56 | 58 | } |
| 57 | - if ( !$matched_any_include ) return false; |
|
| 59 | + if ( !$matched_any_include ) { |
|
| 60 | + return false; |
|
| 61 | + } |
|
| 58 | 62 | } |
| 59 | 63 | if ( $excludes ) { |
| 60 | 64 | foreach( $excludes as $exclude ) { |
@@ -68,12 +72,16 @@ discard block |
||
| 68 | 72 | |
| 69 | 73 | function entry_from_call( $call, $file_name ) { |
| 70 | 74 | $rule = isset( $this->rules[$call['name']] )? $this->rules[$call['name']] : null; |
| 71 | - if ( !$rule ) return null; |
|
| 75 | + if ( !$rule ) { |
|
| 76 | + return null; |
|
| 77 | + } |
|
| 72 | 78 | $entry = new Translation_Entry; |
| 73 | 79 | $multiple = array(); |
| 74 | 80 | $complete = false; |
| 75 | 81 | for( $i = 0; $i < count( $rule ); ++$i ) { |
| 76 | - if ( $rule[$i] && ( !isset( $call['args'][$i] ) || !is_string( $call['args'][$i] ) || '' == $call['args'][$i] ) ) return false; |
|
| 82 | + if ( $rule[$i] && ( !isset( $call['args'][$i] ) || !is_string( $call['args'][$i] ) || '' == $call['args'][$i] ) ) { |
|
| 83 | + return false; |
|
| 84 | + } |
|
| 77 | 85 | switch( $rule[$i] ) { |
| 78 | 86 | case 'string': |
| 79 | 87 | if ( $complete ) { |
@@ -133,11 +141,12 @@ discard block |
||
| 133 | 141 | $function_calls = $this->find_function_calls( array_keys( $this->rules ), $code ); |
| 134 | 142 | foreach( $function_calls as $call ) { |
| 135 | 143 | $entry = $this->entry_from_call( $call, $file_name ); |
| 136 | - if ( is_array( $entry ) ) |
|
| 137 | - foreach( $entry as $single_entry ) |
|
| 144 | + if ( is_array( $entry ) ) { |
|
| 145 | + foreach( $entry as $single_entry ) |
|
| 138 | 146 | $translations->add_entry_or_merge( $single_entry ); |
| 139 | - elseif ( $entry) |
|
| 140 | - $translations->add_entry_or_merge( $entry ); |
|
| 147 | + } elseif ( $entry) { |
|
| 148 | + $translations->add_entry_or_merge( $entry ); |
|
| 149 | + } |
|
| 141 | 150 | } |
| 142 | 151 | return $translations; |
| 143 | 152 | } |
@@ -155,8 +164,12 @@ discard block |
||
| 155 | 164 | $in_func = false; |
| 156 | 165 | foreach( $tokens as $token ) { |
| 157 | 166 | $id = $text = null; |
| 158 | - if ( is_array( $token ) ) list( $id, $text, $line ) = $token; |
|
| 159 | - if ( T_WHITESPACE == $id ) continue; |
|
| 167 | + if ( is_array( $token ) ) { |
|
| 168 | + list( $id, $text, $line ) = $token; |
|
| 169 | + } |
|
| 170 | + if ( T_WHITESPACE == $id ) { |
|
| 171 | + continue; |
|
| 172 | + } |
|
| 160 | 173 | if ( T_STRING == $id && in_array( $text, $function_names ) && !$in_func ) { |
| 161 | 174 | $in_func = true; |
| 162 | 175 | $paren_level = -1; |
@@ -177,7 +190,9 @@ discard block |
||
| 177 | 190 | $latest_comment = $text; |
| 178 | 191 | } |
| 179 | 192 | } |
| 180 | - if ( !$in_func ) continue; |
|
| 193 | + if ( !$in_func ) { |
|
| 194 | + continue; |
|
| 195 | + } |
|
| 181 | 196 | if ( '(' == $token ) { |
| 182 | 197 | $paren_level++; |
| 183 | 198 | if ( 0 == $paren_level ) { // start of first argument |
@@ -197,7 +212,9 @@ discard block |
||
| 197 | 212 | $in_func = false; |
| 198 | 213 | $args[] = $current_argument; |
| 199 | 214 | $call = array( 'name' => $func_name, 'args' => $args, 'line' => $func_line ); |
| 200 | - if ( $func_comment ) $call['comment'] = $func_comment; |
|
| 215 | + if ( $func_comment ) { |
|
| 216 | + $call['comment'] = $func_comment; |
|
| 217 | + } |
|
| 201 | 218 | $function_calls[] = $call; |
| 202 | 219 | } |
| 203 | 220 | $paren_level--; |
@@ -36,11 +36,13 @@ discard block |
||
| 36 | 36 | // Don't index any of these forms |
| 37 | 37 | add_action( 'login_head', 'wp_no_robots' ); |
| 38 | 38 | |
| 39 | - if ( wp_is_mobile() ) |
|
| 40 | - add_action( 'login_head', 'wp_login_viewport_meta' ); |
|
| 39 | + if ( wp_is_mobile() ) { |
|
| 40 | + add_action( 'login_head', 'wp_login_viewport_meta' ); |
|
| 41 | + } |
|
| 41 | 42 | |
| 42 | - if ( empty($wp_error) ) |
|
| 43 | - $wp_error = new WP_Error(); |
|
| 43 | + if ( empty($wp_error) ) { |
|
| 44 | + $wp_error = new WP_Error(); |
|
| 45 | + } |
|
| 44 | 46 | |
| 45 | 47 | // Shake it! |
| 46 | 48 | $shake_error_codes = array( 'empty_password', 'empty_email', 'invalid_email', 'invalidcombo', 'empty_username', 'invalid_username', 'incorrect_password' ); |
@@ -53,8 +55,9 @@ discard block |
||
| 53 | 55 | */ |
| 54 | 56 | $shake_error_codes = apply_filters( 'shake_error_codes', $shake_error_codes ); |
| 55 | 57 | |
| 56 | - if ( $shake_error_codes && $wp_error->get_error_code() && in_array( $wp_error->get_error_code(), $shake_error_codes ) ) |
|
| 57 | - add_action( 'login_head', 'wp_shake_js', 12 ); |
|
| 58 | + if ( $shake_error_codes && $wp_error->get_error_code() && in_array( $wp_error->get_error_code(), $shake_error_codes ) ) { |
|
| 59 | + add_action( 'login_head', 'wp_shake_js', 12 ); |
|
| 60 | + } |
|
| 58 | 61 | |
| 59 | 62 | ?><!DOCTYPE html> |
| 60 | 63 | <!--[if IE 8]> |
@@ -120,18 +123,21 @@ discard block |
||
| 120 | 123 | $login_header_title = apply_filters( 'login_headertitle', $login_header_title ); |
| 121 | 124 | |
| 122 | 125 | $classes = array( 'login-action-' . $action, 'wp-core-ui' ); |
| 123 | - if ( wp_is_mobile() ) |
|
| 124 | - $classes[] = 'mobile'; |
|
| 125 | - if ( is_rtl() ) |
|
| 126 | - $classes[] = 'rtl'; |
|
| 126 | + if ( wp_is_mobile() ) { |
|
| 127 | + $classes[] = 'mobile'; |
|
| 128 | + } |
|
| 129 | + if ( is_rtl() ) { |
|
| 130 | + $classes[] = 'rtl'; |
|
| 131 | + } |
|
| 127 | 132 | if ( $interim_login ) { |
| 128 | 133 | $classes[] = 'interim-login'; |
| 129 | 134 | ?> |
| 130 | 135 | <style type="text/css">html{background-color: transparent;}</style> |
| 131 | 136 | <?php |
| 132 | 137 | |
| 133 | - if ( 'success' === $interim_login ) |
|
| 134 | - $classes[] = 'interim-login-success'; |
|
| 138 | + if ( 'success' === $interim_login ) { |
|
| 139 | + $classes[] = 'interim-login-success'; |
|
| 140 | + } |
|
| 135 | 141 | } |
| 136 | 142 | $classes[] =' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) ); |
| 137 | 143 | |
@@ -162,8 +168,9 @@ discard block |
||
| 162 | 168 | * @param string $message Login message text. |
| 163 | 169 | */ |
| 164 | 170 | $message = apply_filters( 'login_message', $message ); |
| 165 | - if ( !empty( $message ) ) |
|
| 166 | - echo $message . "\n"; |
|
| 171 | + if ( !empty( $message ) ) { |
|
| 172 | + echo $message . "\n"; |
|
| 173 | + } |
|
| 167 | 174 | |
| 168 | 175 | // In case a plugin uses $error rather than the $wp_errors object |
| 169 | 176 | if ( !empty( $error ) ) { |
@@ -177,10 +184,11 @@ discard block |
||
| 177 | 184 | foreach ( $wp_error->get_error_codes() as $code ) { |
| 178 | 185 | $severity = $wp_error->get_error_data( $code ); |
| 179 | 186 | foreach ( $wp_error->get_error_messages( $code ) as $error_message ) { |
| 180 | - if ( 'message' == $severity ) |
|
| 181 | - $messages .= ' ' . $error_message . "<br />\n"; |
|
| 182 | - else |
|
| 183 | - $errors .= ' ' . $error_message . "<br />\n"; |
|
| 187 | + if ( 'message' == $severity ) { |
|
| 188 | + $messages .= ' ' . $error_message . "<br />\n"; |
|
| 189 | + } else { |
|
| 190 | + $errors .= ' ' . $error_message . "<br />\n"; |
|
| 191 | + } |
|
| 184 | 192 | } |
| 185 | 193 | } |
| 186 | 194 | if ( ! empty( $errors ) ) { |
@@ -245,9 +253,10 @@ discard block |
||
| 245 | 253 | * @since 3.0.0 |
| 246 | 254 | */ |
| 247 | 255 | function wp_shake_js() { |
| 248 | - if ( wp_is_mobile() ) |
|
| 249 | - return; |
|
| 250 | -?> |
|
| 256 | + if ( wp_is_mobile() ) { |
|
| 257 | + return; |
|
| 258 | + } |
|
| 259 | + ?> |
|
| 251 | 260 | <script type="text/javascript"> |
| 252 | 261 | addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}; |
| 253 | 262 | function s(id,pos){g(id).left=pos+'px';} |
@@ -284,8 +293,9 @@ discard block |
||
| 284 | 293 | $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.')); |
| 285 | 294 | } elseif ( strpos( $_POST['user_login'], '@' ) ) { |
| 286 | 295 | $user_data = get_user_by( 'email', trim( $_POST['user_login'] ) ); |
| 287 | - if ( empty( $user_data ) ) |
|
| 288 | - $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.')); |
|
| 296 | + if ( empty( $user_data ) ) { |
|
| 297 | + $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.')); |
|
| 298 | + } |
|
| 289 | 299 | } else { |
| 290 | 300 | $login = trim($_POST['user_login']); |
| 291 | 301 | $user_data = get_user_by('login', $login); |
@@ -298,8 +308,9 @@ discard block |
||
| 298 | 308 | */ |
| 299 | 309 | do_action( 'lostpassword_post' ); |
| 300 | 310 | |
| 301 | - if ( $errors->get_error_code() ) |
|
| 302 | - return $errors; |
|
| 311 | + if ( $errors->get_error_code() ) { |
|
| 312 | + return $errors; |
|
| 313 | + } |
|
| 303 | 314 | |
| 304 | 315 | if ( !$user_data ) { |
| 305 | 316 | $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.')); |
@@ -373,14 +384,15 @@ discard block |
||
| 373 | 384 | $message .= __('To reset your password, visit the following address:') . "\r\n\r\n"; |
| 374 | 385 | $message .= '<' . network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . ">\r\n"; |
| 375 | 386 | |
| 376 | - if ( is_multisite() ) |
|
| 377 | - $blogname = $GLOBALS['current_site']->site_name; |
|
| 378 | - else |
|
| 379 | - /* |
|
| 387 | + if ( is_multisite() ) { |
|
| 388 | + $blogname = $GLOBALS['current_site']->site_name; |
|
| 389 | + } else { |
|
| 390 | + /* |
|
| 380 | 391 | * The blogname option is escaped with esc_html on the way into the database |
| 381 | 392 | * in sanitize_option we want to reverse this for the plain text arena of emails. |
| 382 | 393 | */ |
| 383 | 394 | $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
| 395 | + } |
|
| 384 | 396 | |
| 385 | 397 | $title = sprintf( __('[%s] Password Reset'), $blogname ); |
| 386 | 398 | |
@@ -406,8 +418,9 @@ discard block |
||
| 406 | 418 | */ |
| 407 | 419 | $message = apply_filters( 'retrieve_password_message', $message, $key, $user_login, $user_data ); |
| 408 | 420 | |
| 409 | - if ( $message && !wp_mail( $user_email, wp_specialchars_decode( $title ), $message ) ) |
|
| 410 | - wp_die( __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function.') ); |
|
| 421 | + if ( $message && !wp_mail( $user_email, wp_specialchars_decode( $title ), $message ) ) { |
|
| 422 | + wp_die( __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function.') ); |
|
| 423 | + } |
|
| 411 | 424 | |
| 412 | 425 | return true; |
| 413 | 426 | } |
@@ -419,31 +432,36 @@ discard block |
||
| 419 | 432 | $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'login'; |
| 420 | 433 | $errors = new WP_Error(); |
| 421 | 434 | |
| 422 | -if ( isset($_GET['key']) ) |
|
| 435 | +if ( isset($_GET['key']) ) { |
|
| 423 | 436 | $action = 'resetpass'; |
| 437 | +} |
|
| 424 | 438 | |
| 425 | 439 | // validate action so as to default to the login screen |
| 426 | -if ( !in_array( $action, array( 'postpass', 'logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login' ), true ) && false === has_filter( 'login_form_' . $action ) ) |
|
| 440 | +if ( !in_array( $action, array( 'postpass', 'logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login' ), true ) && false === has_filter( 'login_form_' . $action ) ) { |
|
| 427 | 441 | $action = 'login'; |
| 442 | +} |
|
| 428 | 443 | |
| 429 | 444 | nocache_headers(); |
| 430 | 445 | |
| 431 | 446 | header('Content-Type: '.get_bloginfo('html_type').'; charset='.get_bloginfo('charset')); |
| 432 | 447 | |
| 433 | 448 | if ( defined( 'RELOCATE' ) && RELOCATE ) { // Move flag is set |
| 434 | - if ( isset( $_SERVER['PATH_INFO'] ) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF']) ) |
|
| 435 | - $_SERVER['PHP_SELF'] = str_replace( $_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF'] ); |
|
| 449 | + if ( isset( $_SERVER['PATH_INFO'] ) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF']) ) { |
|
| 450 | + $_SERVER['PHP_SELF'] = str_replace( $_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF'] ); |
|
| 451 | + } |
|
| 436 | 452 | |
| 437 | 453 | $url = dirname( set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] ) ); |
| 438 | - if ( $url != get_option( 'siteurl' ) ) |
|
| 439 | - update_option( 'siteurl', $url ); |
|
| 440 | -} |
|
| 454 | + if ( $url != get_option( 'siteurl' ) ) { |
|
| 455 | + update_option( 'siteurl', $url ); |
|
| 456 | + } |
|
| 457 | + } |
|
| 441 | 458 | |
| 442 | 459 | //Set a cookie now to see if they are supported by the browser. |
| 443 | 460 | $secure = ( 'https' === parse_url( site_url(), PHP_URL_SCHEME ) && 'https' === parse_url( home_url(), PHP_URL_SCHEME ) ); |
| 444 | 461 | setcookie( TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN, $secure ); |
| 445 | -if ( SITECOOKIEPATH != COOKIEPATH ) |
|
| 462 | +if ( SITECOOKIEPATH != COOKIEPATH ) { |
|
| 446 | 463 | setcookie( TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN, $secure ); |
| 464 | +} |
|
| 447 | 465 | |
| 448 | 466 | /** |
| 449 | 467 | * Fires when the login form is initialized. |
@@ -613,17 +631,19 @@ discard block |
||
| 613 | 631 | |
| 614 | 632 | if ( ! $user || is_wp_error( $user ) ) { |
| 615 | 633 | setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true ); |
| 616 | - if ( $user && $user->get_error_code() === 'expired_key' ) |
|
| 617 | - wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=expiredkey' ) ); |
|
| 618 | - else |
|
| 619 | - wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=invalidkey' ) ); |
|
| 634 | + if ( $user && $user->get_error_code() === 'expired_key' ) { |
|
| 635 | + wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=expiredkey' ) ); |
|
| 636 | + } else { |
|
| 637 | + wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=invalidkey' ) ); |
|
| 638 | + } |
|
| 620 | 639 | exit; |
| 621 | 640 | } |
| 622 | 641 | |
| 623 | 642 | $errors = new WP_Error(); |
| 624 | 643 | |
| 625 | - if ( isset($_POST['pass1']) && $_POST['pass1'] != $_POST['pass2'] ) |
|
| 626 | - $errors->add( 'password_reset_mismatch', __( 'The passwords do not match.' ) ); |
|
| 644 | + if ( isset($_POST['pass1']) && $_POST['pass1'] != $_POST['pass2'] ) { |
|
| 645 | + $errors->add( 'password_reset_mismatch', __( 'The passwords do not match.' ) ); |
|
| 646 | + } |
|
| 627 | 647 | |
| 628 | 648 | /** |
| 629 | 649 | * Fires before the password reset procedure is validated. |
@@ -778,8 +798,9 @@ discard block |
||
| 778 | 798 | default: |
| 779 | 799 | $secure_cookie = ''; |
| 780 | 800 | $customize_login = isset( $_REQUEST['customize-login'] ); |
| 781 | - if ( $customize_login ) |
|
| 782 | - wp_enqueue_script( 'customize-base' ); |
|
| 801 | + if ( $customize_login ) { |
|
| 802 | + wp_enqueue_script( 'customize-base' ); |
|
| 803 | + } |
|
| 783 | 804 | |
| 784 | 805 | // If the user wants ssl but the session is not ssl, force a secure cookie. |
| 785 | 806 | if ( !empty($_POST['log']) && !force_ssl_admin() ) { |
@@ -795,8 +816,9 @@ discard block |
||
| 795 | 816 | if ( isset( $_REQUEST['redirect_to'] ) ) { |
| 796 | 817 | $redirect_to = $_REQUEST['redirect_to']; |
| 797 | 818 | // Redirect to https if user wants ssl |
| 798 | - if ( $secure_cookie && false !== strpos($redirect_to, 'wp-admin') ) |
|
| 799 | - $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to); |
|
| 819 | + if ( $secure_cookie && false !== strpos($redirect_to, 'wp-admin') ) { |
|
| 820 | + $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to); |
|
| 821 | + } |
|
| 800 | 822 | } else { |
| 801 | 823 | $redirect_to = admin_url(); |
| 802 | 824 | } |
@@ -846,12 +868,13 @@ discard block |
||
| 846 | 868 | |
| 847 | 869 | if ( ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) ) { |
| 848 | 870 | // If the user doesn't belong to a blog, send them to user admin. If the user can't edit posts, send them to their profile. |
| 849 | - if ( is_multisite() && !get_active_blog_for_user($user->ID) && !is_super_admin( $user->ID ) ) |
|
| 850 | - $redirect_to = user_admin_url(); |
|
| 851 | - elseif ( is_multisite() && !$user->has_cap('read') ) |
|
| 852 | - $redirect_to = get_dashboard_url( $user->ID ); |
|
| 853 | - elseif ( !$user->has_cap('edit_posts') ) |
|
| 854 | - $redirect_to = admin_url('profile.php'); |
|
| 871 | + if ( is_multisite() && !get_active_blog_for_user($user->ID) && !is_super_admin( $user->ID ) ) { |
|
| 872 | + $redirect_to = user_admin_url(); |
|
| 873 | + } elseif ( is_multisite() && !$user->has_cap('read') ) { |
|
| 874 | + $redirect_to = get_dashboard_url( $user->ID ); |
|
| 875 | + } elseif ( !$user->has_cap('edit_posts') ) { |
|
| 876 | + $redirect_to = admin_url('profile.php'); |
|
| 877 | + } |
|
| 855 | 878 | } |
| 856 | 879 | wp_safe_redirect($redirect_to); |
| 857 | 880 | exit(); |
@@ -859,26 +882,29 @@ discard block |
||
| 859 | 882 | |
| 860 | 883 | $errors = $user; |
| 861 | 884 | // Clear errors if loggedout is set. |
| 862 | - if ( !empty($_GET['loggedout']) || $reauth ) |
|
| 863 | - $errors = new WP_Error(); |
|
| 885 | + if ( !empty($_GET['loggedout']) || $reauth ) { |
|
| 886 | + $errors = new WP_Error(); |
|
| 887 | + } |
|
| 864 | 888 | |
| 865 | 889 | if ( $interim_login ) { |
| 866 | - if ( ! $errors->get_error_code() ) |
|
| 867 | - $errors->add('expired', __('Session expired. Please log in again. You will not move away from this page.'), 'message'); |
|
| 890 | + if ( ! $errors->get_error_code() ) { |
|
| 891 | + $errors->add('expired', __('Session expired. Please log in again. You will not move away from this page.'), 'message'); |
|
| 892 | + } |
|
| 868 | 893 | } else { |
| 869 | 894 | // Some parts of this script use the main login form to display a message |
| 870 | - if ( isset($_GET['loggedout']) && true == $_GET['loggedout'] ) |
|
| 871 | - $errors->add('loggedout', __('You are now logged out.'), 'message'); |
|
| 872 | - elseif ( isset($_GET['registration']) && 'disabled' == $_GET['registration'] ) |
|
| 873 | - $errors->add('registerdisabled', __('User registration is currently not allowed.')); |
|
| 874 | - elseif ( isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail'] ) |
|
| 875 | - $errors->add('confirm', __('Check your e-mail for the confirmation link.'), 'message'); |
|
| 876 | - elseif ( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] ) |
|
| 877 | - $errors->add('newpass', __('Check your e-mail for your new password.'), 'message'); |
|
| 878 | - elseif ( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] ) |
|
| 879 | - $errors->add('registered', __('Registration complete. Please check your e-mail.'), 'message'); |
|
| 880 | - elseif ( strpos( $redirect_to, 'about.php?updated' ) ) |
|
| 881 | - $errors->add('updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to see what’s new.' ), 'message' ); |
|
| 895 | + if ( isset($_GET['loggedout']) && true == $_GET['loggedout'] ) { |
|
| 896 | + $errors->add('loggedout', __('You are now logged out.'), 'message'); |
|
| 897 | + } elseif ( isset($_GET['registration']) && 'disabled' == $_GET['registration'] ) { |
|
| 898 | + $errors->add('registerdisabled', __('User registration is currently not allowed.')); |
|
| 899 | + } elseif ( isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail'] ) { |
|
| 900 | + $errors->add('confirm', __('Check your e-mail for the confirmation link.'), 'message'); |
|
| 901 | + } elseif ( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] ) { |
|
| 902 | + $errors->add('newpass', __('Check your e-mail for your new password.'), 'message'); |
|
| 903 | + } elseif ( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] ) { |
|
| 904 | + $errors->add('registered', __('Registration complete. Please check your e-mail.'), 'message'); |
|
| 905 | + } elseif ( strpos( $redirect_to, 'about.php?updated' ) ) { |
|
| 906 | + $errors->add('updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to see what’s new.' ), 'message' ); |
|
| 907 | + } |
|
| 882 | 908 | } |
| 883 | 909 | |
| 884 | 910 | /** |
@@ -892,13 +918,15 @@ discard block |
||
| 892 | 918 | $errors = apply_filters( 'wp_login_errors', $errors, $redirect_to ); |
| 893 | 919 | |
| 894 | 920 | // Clear any stale cookies. |
| 895 | - if ( $reauth ) |
|
| 896 | - wp_clear_auth_cookie(); |
|
| 921 | + if ( $reauth ) { |
|
| 922 | + wp_clear_auth_cookie(); |
|
| 923 | + } |
|
| 897 | 924 | |
| 898 | 925 | login_header(__('Log In'), '', $errors); |
| 899 | 926 | |
| 900 | - if ( isset($_POST['log']) ) |
|
| 901 | - $user_login = ( 'incorrect_password' == $errors->get_error_code() || 'empty_password' == $errors->get_error_code() ) ? esc_attr(wp_unslash($_POST['log'])) : ''; |
|
| 927 | + if ( isset($_POST['log']) ) { |
|
| 928 | + $user_login = ( 'incorrect_password' == $errors->get_error_code() || 'empty_password' == $errors->get_error_code() ) ? esc_attr(wp_unslash($_POST['log'])) : ''; |
|
| 929 | + } |
|
| 902 | 930 | $rememberme = ! empty( $_POST['rememberme'] ); |
| 903 | 931 | |
| 904 | 932 | if ( ! empty( $errors->errors ) ) { |
@@ -22,8 +22,9 @@ discard block |
||
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | // fix for mozBlog and other cases where '<?xml' isn't on the very first line |
| 25 | -if ( isset($HTTP_RAW_POST_DATA) ) |
|
| 25 | +if ( isset($HTTP_RAW_POST_DATA) ) { |
|
| 26 | 26 | $HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA); |
| 27 | +} |
|
| 27 | 28 | |
| 28 | 29 | /** Include the bootstrap for setting up WordPress environment */ |
| 29 | 30 | include( dirname( __FILE__ ) . '/wp-load.php' ); |
@@ -96,6 +97,7 @@ discard block |
||
| 96 | 97 | */ |
| 97 | 98 | function logIO( $io, $msg ) { |
| 98 | 99 | _deprecated_function( __FUNCTION__, '3.4', 'error_log()' ); |
| 99 | - if ( ! empty( $GLOBALS['xmlrpc_logging'] ) ) |
|
| 100 | - error_log( $io . ' - ' . $msg ); |
|
| 101 | -} |
|
| 102 | 100 | \ No newline at end of file |
| 101 | + if ( ! empty( $GLOBALS['xmlrpc_logging'] ) ) { |
|
| 102 | + error_log( $io . ' - ' . $msg ); |
|
| 103 | + } |
|
| 104 | + } |
|
| 103 | 105 | \ No newline at end of file |