@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | * |
| 190 | 190 | * @global WP_Rewrite $wp_rewrite |
| 191 | 191 | * |
| 192 | - * @return bool True if web.config was updated successfully |
|
| 192 | + * @return null|boolean True if web.config was updated successfully |
|
| 193 | 193 | */ |
| 194 | 194 | function iis7_save_url_rewrite_rules(){ |
| 195 | 195 | if ( is_multisite() ) |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | * |
| 276 | 276 | * @since 2.0.0 |
| 277 | 277 | * |
| 278 | - * @param array $vars An array of globals to reset. |
|
| 278 | + * @param string[] $vars An array of globals to reset. |
|
| 279 | 279 | */ |
| 280 | 280 | function wp_reset_vars( $vars ) { |
| 281 | 281 | foreach ( $vars as $var ) { |
@@ -1,10 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Misc WordPress Administration API. |
|
| 4 | - * |
|
| 5 | - * @package WordPress |
|
| 6 | - * @subpackage Administration |
|
| 7 | - */ |
|
| 3 | + * Misc WordPress Administration API. |
|
| 4 | + * |
|
| 5 | + * @package WordPress |
|
| 6 | + * @subpackage Administration |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Returns whether the server is running Apache with the mod_rewrite module loaded. |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @param bool $got_rewrite Whether Apache and mod_rewrite are present. |
| 30 | 30 | */ |
| 31 | - return apply_filters( 'got_rewrite', $got_rewrite ); |
|
| 31 | + return apply_filters('got_rewrite', $got_rewrite); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * @return bool Whether the server supports URL rewriting. |
| 44 | 44 | */ |
| 45 | 45 | function got_url_rewrite() { |
| 46 | - $got_url_rewrite = ( got_mod_rewrite() || $GLOBALS['is_nginx'] || iis7_supports_permalinks() ); |
|
| 46 | + $got_url_rewrite = (got_mod_rewrite() || $GLOBALS['is_nginx'] || iis7_supports_permalinks()); |
|
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * Filter whether URL rewriting is available. |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @param bool $got_url_rewrite Whether URL rewriting is available. |
| 54 | 54 | */ |
| 55 | - return apply_filters( 'got_url_rewrite', $got_url_rewrite ); |
|
| 55 | + return apply_filters('got_url_rewrite', $got_url_rewrite); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -64,22 +64,22 @@ discard block |
||
| 64 | 64 | * @param string $marker |
| 65 | 65 | * @return array An array of strings from a file (.htaccess ) from between BEGIN and END markers. |
| 66 | 66 | */ |
| 67 | -function extract_from_markers( $filename, $marker ) { |
|
| 68 | - $result = array (); |
|
| 67 | +function extract_from_markers($filename, $marker) { |
|
| 68 | + $result = array(); |
|
| 69 | 69 | |
| 70 | - if (!file_exists( $filename ) ) { |
|
| 70 | + if ( ! file_exists($filename)) { |
|
| 71 | 71 | return $result; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if ( $markerdata = explode( "\n", implode( '', file( $filename ) ) )); |
|
| 74 | + if ($markerdata = explode("\n", implode('', file($filename)))); |
|
| 75 | 75 | { |
| 76 | 76 | $state = false; |
| 77 | - foreach ( $markerdata as $markerline ) { |
|
| 78 | - if (strpos($markerline, '# END ' . $marker) !== false) |
|
| 77 | + foreach ($markerdata as $markerline) { |
|
| 78 | + if (strpos($markerline, '# END '.$marker) !== false) |
|
| 79 | 79 | $state = false; |
| 80 | - if ( $state ) |
|
| 80 | + if ($state) |
|
| 81 | 81 | $result[] = $markerline; |
| 82 | - if (strpos($markerline, '# BEGIN ' . $marker) !== false) |
|
| 82 | + if (strpos($markerline, '# BEGIN '.$marker) !== false) |
|
| 83 | 83 | $state = true; |
| 84 | 84 | } |
| 85 | 85 | } |
@@ -101,47 +101,47 @@ discard block |
||
| 101 | 101 | * @param array $insertion |
| 102 | 102 | * @return bool True on write success, false on failure. |
| 103 | 103 | */ |
| 104 | -function insert_with_markers( $filename, $marker, $insertion ) { |
|
| 105 | - if (!file_exists( $filename ) || is_writeable( $filename ) ) { |
|
| 106 | - if (!file_exists( $filename ) ) { |
|
| 104 | +function insert_with_markers($filename, $marker, $insertion) { |
|
| 105 | + if ( ! file_exists($filename) || is_writeable($filename)) { |
|
| 106 | + if ( ! file_exists($filename)) { |
|
| 107 | 107 | $markerdata = ''; |
| 108 | 108 | } else { |
| 109 | - $markerdata = explode( "\n", implode( '', file( $filename ) ) ); |
|
| 109 | + $markerdata = explode("\n", implode('', file($filename))); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - if ( !$f = @fopen( $filename, 'w' ) ) |
|
| 112 | + if ( ! $f = @fopen($filename, 'w')) |
|
| 113 | 113 | return false; |
| 114 | 114 | |
| 115 | 115 | $foundit = false; |
| 116 | - if ( $markerdata ) { |
|
| 116 | + if ($markerdata) { |
|
| 117 | 117 | $state = true; |
| 118 | - foreach ( $markerdata as $n => $markerline ) { |
|
| 119 | - if (strpos($markerline, '# BEGIN ' . $marker) !== false) |
|
| 118 | + foreach ($markerdata as $n => $markerline) { |
|
| 119 | + if (strpos($markerline, '# BEGIN '.$marker) !== false) |
|
| 120 | 120 | $state = false; |
| 121 | - if ( $state ) { |
|
| 122 | - if ( $n + 1 < count( $markerdata ) ) |
|
| 123 | - fwrite( $f, "{$markerline}\n" ); |
|
| 121 | + if ($state) { |
|
| 122 | + if ($n + 1 < count($markerdata)) |
|
| 123 | + fwrite($f, "{$markerline}\n"); |
|
| 124 | 124 | else |
| 125 | - fwrite( $f, "{$markerline}" ); |
|
| 125 | + fwrite($f, "{$markerline}"); |
|
| 126 | 126 | } |
| 127 | - if (strpos($markerline, '# END ' . $marker) !== false) { |
|
| 128 | - fwrite( $f, "# BEGIN {$marker}\n" ); |
|
| 129 | - if ( is_array( $insertion )) |
|
| 130 | - foreach ( $insertion as $insertline ) |
|
| 131 | - fwrite( $f, "{$insertline}\n" ); |
|
| 132 | - fwrite( $f, "# END {$marker}\n" ); |
|
| 127 | + if (strpos($markerline, '# END '.$marker) !== false) { |
|
| 128 | + fwrite($f, "# BEGIN {$marker}\n"); |
|
| 129 | + if (is_array($insertion)) |
|
| 130 | + foreach ($insertion as $insertline) |
|
| 131 | + fwrite($f, "{$insertline}\n"); |
|
| 132 | + fwrite($f, "# END {$marker}\n"); |
|
| 133 | 133 | $state = true; |
| 134 | 134 | $foundit = true; |
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | - if (!$foundit) { |
|
| 139 | - fwrite( $f, "\n# BEGIN {$marker}\n" ); |
|
| 140 | - foreach ( $insertion as $insertline ) |
|
| 141 | - fwrite( $f, "{$insertline}\n" ); |
|
| 142 | - fwrite( $f, "# END {$marker}\n" ); |
|
| 138 | + if ( ! $foundit) { |
|
| 139 | + fwrite($f, "\n# BEGIN {$marker}\n"); |
|
| 140 | + foreach ($insertion as $insertline) |
|
| 141 | + fwrite($f, "{$insertline}\n"); |
|
| 142 | + fwrite($f, "# END {$marker}\n"); |
|
| 143 | 143 | } |
| 144 | - fclose( $f ); |
|
| 144 | + fclose($f); |
|
| 145 | 145 | return true; |
| 146 | 146 | } else { |
| 147 | 147 | return false; |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | * @global WP_Rewrite $wp_rewrite |
| 160 | 160 | */ |
| 161 | 161 | function save_mod_rewrite_rules() { |
| 162 | - if ( is_multisite() ) |
|
| 162 | + if (is_multisite()) |
|
| 163 | 163 | return; |
| 164 | 164 | |
| 165 | 165 | global $wp_rewrite; |
@@ -171,10 +171,10 @@ discard block |
||
| 171 | 171 | * If the file doesn't already exist check for write access to the directory |
| 172 | 172 | * and whether we have some rules. Else check for write access to the file. |
| 173 | 173 | */ |
| 174 | - if ((!file_exists($htaccess_file) && is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks()) || is_writable($htaccess_file)) { |
|
| 175 | - if ( got_mod_rewrite() ) { |
|
| 176 | - $rules = explode( "\n", $wp_rewrite->mod_rewrite_rules() ); |
|
| 177 | - return insert_with_markers( $htaccess_file, 'WordPress', $rules ); |
|
| 174 | + if (( ! file_exists($htaccess_file) && is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks()) || is_writable($htaccess_file)) { |
|
| 175 | + if (got_mod_rewrite()) { |
|
| 176 | + $rules = explode("\n", $wp_rewrite->mod_rewrite_rules()); |
|
| 177 | + return insert_with_markers($htaccess_file, 'WordPress', $rules); |
|
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
@@ -191,19 +191,19 @@ discard block |
||
| 191 | 191 | * |
| 192 | 192 | * @return bool True if web.config was updated successfully |
| 193 | 193 | */ |
| 194 | -function iis7_save_url_rewrite_rules(){ |
|
| 195 | - if ( is_multisite() ) |
|
| 194 | +function iis7_save_url_rewrite_rules() { |
|
| 195 | + if (is_multisite()) |
|
| 196 | 196 | return; |
| 197 | 197 | |
| 198 | 198 | global $wp_rewrite; |
| 199 | 199 | |
| 200 | 200 | $home_path = get_home_path(); |
| 201 | - $web_config_file = $home_path . 'web.config'; |
|
| 201 | + $web_config_file = $home_path.'web.config'; |
|
| 202 | 202 | |
| 203 | 203 | // Using win_is_writable() instead of is_writable() because of a bug in Windows PHP |
| 204 | - if ( iis7_supports_permalinks() && ( ( ! file_exists($web_config_file) && win_is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks() ) || win_is_writable($web_config_file) ) ) { |
|
| 204 | + if (iis7_supports_permalinks() && (( ! file_exists($web_config_file) && win_is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks()) || win_is_writable($web_config_file))) { |
|
| 205 | 205 | $rule = $wp_rewrite->iis7_url_rewrite_rules(false, '', ''); |
| 206 | - if ( ! empty($rule) ) { |
|
| 206 | + if ( ! empty($rule)) { |
|
| 207 | 207 | return iis7_add_rewrite_rule($web_config_file, $rule); |
| 208 | 208 | } else { |
| 209 | 209 | return iis7_delete_rewrite_rule($web_config_file); |
@@ -219,19 +219,19 @@ discard block |
||
| 219 | 219 | * |
| 220 | 220 | * @param string $file |
| 221 | 221 | */ |
| 222 | -function update_recently_edited( $file ) { |
|
| 223 | - $oldfiles = (array ) get_option( 'recently_edited' ); |
|
| 224 | - if ( $oldfiles ) { |
|
| 225 | - $oldfiles = array_reverse( $oldfiles ); |
|
| 222 | +function update_recently_edited($file) { |
|
| 223 | + $oldfiles = (array) get_option('recently_edited'); |
|
| 224 | + if ($oldfiles) { |
|
| 225 | + $oldfiles = array_reverse($oldfiles); |
|
| 226 | 226 | $oldfiles[] = $file; |
| 227 | - $oldfiles = array_reverse( $oldfiles ); |
|
| 228 | - $oldfiles = array_unique( $oldfiles ); |
|
| 229 | - if ( 5 < count( $oldfiles )) |
|
| 230 | - array_pop( $oldfiles ); |
|
| 227 | + $oldfiles = array_reverse($oldfiles); |
|
| 228 | + $oldfiles = array_unique($oldfiles); |
|
| 229 | + if (5 < count($oldfiles)) |
|
| 230 | + array_pop($oldfiles); |
|
| 231 | 231 | } else { |
| 232 | 232 | $oldfiles[] = $file; |
| 233 | 233 | } |
| 234 | - update_option( 'recently_edited', $oldfiles ); |
|
| 234 | + update_option('recently_edited', $oldfiles); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /** |
@@ -242,8 +242,8 @@ discard block |
||
| 242 | 242 | * @param string $old_value |
| 243 | 243 | * @param string $value |
| 244 | 244 | */ |
| 245 | -function update_home_siteurl( $old_value, $value ) { |
|
| 246 | - if ( defined( "WP_INSTALLING" ) ) |
|
| 245 | +function update_home_siteurl($old_value, $value) { |
|
| 246 | + if (defined("WP_INSTALLING")) |
|
| 247 | 247 | return; |
| 248 | 248 | |
| 249 | 249 | // If home changed, write rewrite rules to new location. |
@@ -258,11 +258,11 @@ discard block |
||
| 258 | 258 | * @param string $url |
| 259 | 259 | * @return string |
| 260 | 260 | */ |
| 261 | -function url_shorten( $url ) { |
|
| 262 | - $short_url = str_replace( array( 'http://', 'www.' ), '', $url ); |
|
| 263 | - $short_url = untrailingslashit( $short_url ); |
|
| 264 | - if ( strlen( $short_url ) > 35 ) |
|
| 265 | - $short_url = substr( $short_url, 0, 32 ) . '…'; |
|
| 261 | +function url_shorten($url) { |
|
| 262 | + $short_url = str_replace(array('http://', 'www.'), '', $url); |
|
| 263 | + $short_url = untrailingslashit($short_url); |
|
| 264 | + if (strlen($short_url) > 35) |
|
| 265 | + $short_url = substr($short_url, 0, 32).'…'; |
|
| 266 | 266 | return $short_url; |
| 267 | 267 | } |
| 268 | 268 | |
@@ -277,16 +277,16 @@ discard block |
||
| 277 | 277 | * |
| 278 | 278 | * @param array $vars An array of globals to reset. |
| 279 | 279 | */ |
| 280 | -function wp_reset_vars( $vars ) { |
|
| 281 | - foreach ( $vars as $var ) { |
|
| 282 | - if ( empty( $_POST[ $var ] ) ) { |
|
| 283 | - if ( empty( $_GET[ $var ] ) ) { |
|
| 284 | - $GLOBALS[ $var ] = ''; |
|
| 280 | +function wp_reset_vars($vars) { |
|
| 281 | + foreach ($vars as $var) { |
|
| 282 | + if (empty($_POST[$var])) { |
|
| 283 | + if (empty($_GET[$var])) { |
|
| 284 | + $GLOBALS[$var] = ''; |
|
| 285 | 285 | } else { |
| 286 | - $GLOBALS[ $var ] = $_GET[ $var ]; |
|
| 286 | + $GLOBALS[$var] = $_GET[$var]; |
|
| 287 | 287 | } |
| 288 | 288 | } else { |
| 289 | - $GLOBALS[ $var ] = $_POST[ $var ]; |
|
| 289 | + $GLOBALS[$var] = $_POST[$var]; |
|
| 290 | 290 | } |
| 291 | 291 | } |
| 292 | 292 | } |
@@ -299,9 +299,9 @@ discard block |
||
| 299 | 299 | * @param string|WP_Error $message |
| 300 | 300 | */ |
| 301 | 301 | function show_message($message) { |
| 302 | - if ( is_wp_error($message) ){ |
|
| 303 | - if ( $message->get_error_data() && is_string( $message->get_error_data() ) ) |
|
| 304 | - $message = $message->get_error_message() . ': ' . $message->get_error_data(); |
|
| 302 | + if (is_wp_error($message)) { |
|
| 303 | + if ($message->get_error_data() && is_string($message->get_error_data())) |
|
| 304 | + $message = $message->get_error_message().': '.$message->get_error_data(); |
|
| 305 | 305 | else |
| 306 | 306 | $message = $message->get_error_message(); |
| 307 | 307 | } |
@@ -316,25 +316,25 @@ discard block |
||
| 316 | 316 | * @param string $content |
| 317 | 317 | * @return array |
| 318 | 318 | */ |
| 319 | -function wp_doc_link_parse( $content ) { |
|
| 320 | - if ( !is_string( $content ) || empty( $content ) ) |
|
| 319 | +function wp_doc_link_parse($content) { |
|
| 320 | + if ( ! is_string($content) || empty($content)) |
|
| 321 | 321 | return array(); |
| 322 | 322 | |
| 323 | - if ( !function_exists('token_get_all') ) |
|
| 323 | + if ( ! function_exists('token_get_all')) |
|
| 324 | 324 | return array(); |
| 325 | 325 | |
| 326 | - $tokens = token_get_all( $content ); |
|
| 327 | - $count = count( $tokens ); |
|
| 326 | + $tokens = token_get_all($content); |
|
| 327 | + $count = count($tokens); |
|
| 328 | 328 | $functions = array(); |
| 329 | 329 | $ignore_functions = array(); |
| 330 | - for ( $t = 0; $t < $count - 2; $t++ ) { |
|
| 331 | - if ( ! is_array( $tokens[ $t ] ) ) { |
|
| 330 | + for ($t = 0; $t < $count - 2; $t++) { |
|
| 331 | + if ( ! is_array($tokens[$t])) { |
|
| 332 | 332 | continue; |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | - if ( T_STRING == $tokens[ $t ][0] && ( '(' == $tokens[ $t + 1 ] || '(' == $tokens[ $t + 2 ] ) ) { |
|
| 335 | + if (T_STRING == $tokens[$t][0] && ('(' == $tokens[$t + 1] || '(' == $tokens[$t + 2])) { |
|
| 336 | 336 | // If it's a function or class defined locally, there's not going to be any docs available |
| 337 | - if ( ( isset( $tokens[ $t - 2 ][1] ) && in_array( $tokens[ $t - 2 ][1], array( 'function', 'class' ) ) ) || ( isset( $tokens[ $t - 2 ][0] ) && T_OBJECT_OPERATOR == $tokens[ $t - 1 ][0] ) ) { |
|
| 337 | + if ((isset($tokens[$t - 2][1]) && in_array($tokens[$t - 2][1], array('function', 'class'))) || (isset($tokens[$t - 2][0]) && T_OBJECT_OPERATOR == $tokens[$t - 1][0])) { |
|
| 338 | 338 | $ignore_functions[] = $tokens[$t][1]; |
| 339 | 339 | } |
| 340 | 340 | // Add this to our stack of unique references |
@@ -342,8 +342,8 @@ discard block |
||
| 342 | 342 | } |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | - $functions = array_unique( $functions ); |
|
| 346 | - sort( $functions ); |
|
| 345 | + $functions = array_unique($functions); |
|
| 346 | + sort($functions); |
|
| 347 | 347 | |
| 348 | 348 | /** |
| 349 | 349 | * Filter the list of functions and classes to be ignored from the documentation lookup. |
@@ -352,13 +352,13 @@ discard block |
||
| 352 | 352 | * |
| 353 | 353 | * @param array $ignore_functions Functions and classes to be ignored. |
| 354 | 354 | */ |
| 355 | - $ignore_functions = apply_filters( 'documentation_ignore_functions', $ignore_functions ); |
|
| 355 | + $ignore_functions = apply_filters('documentation_ignore_functions', $ignore_functions); |
|
| 356 | 356 | |
| 357 | - $ignore_functions = array_unique( $ignore_functions ); |
|
| 357 | + $ignore_functions = array_unique($ignore_functions); |
|
| 358 | 358 | |
| 359 | 359 | $out = array(); |
| 360 | - foreach ( $functions as $function ) { |
|
| 361 | - if ( in_array( $function, $ignore_functions ) ) |
|
| 360 | + foreach ($functions as $function) { |
|
| 361 | + if (in_array($function, $ignore_functions)) |
|
| 362 | 362 | continue; |
| 363 | 363 | $out[] = $function; |
| 364 | 364 | } |
@@ -373,28 +373,28 @@ discard block |
||
| 373 | 373 | */ |
| 374 | 374 | function set_screen_options() { |
| 375 | 375 | |
| 376 | - if ( isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options']) ) { |
|
| 377 | - check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' ); |
|
| 376 | + if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) { |
|
| 377 | + check_admin_referer('screen-options-nonce', 'screenoptionnonce'); |
|
| 378 | 378 | |
| 379 | - if ( !$user = wp_get_current_user() ) |
|
| 379 | + if ( ! $user = wp_get_current_user()) |
|
| 380 | 380 | return; |
| 381 | 381 | $option = $_POST['wp_screen_options']['option']; |
| 382 | 382 | $value = $_POST['wp_screen_options']['value']; |
| 383 | 383 | |
| 384 | - if ( $option != sanitize_key( $option ) ) |
|
| 384 | + if ($option != sanitize_key($option)) |
|
| 385 | 385 | return; |
| 386 | 386 | |
| 387 | 387 | $map_option = $option; |
| 388 | 388 | $type = str_replace('edit_', '', $map_option); |
| 389 | 389 | $type = str_replace('_per_page', '', $type); |
| 390 | - if ( in_array( $type, get_taxonomies() ) ) |
|
| 390 | + if (in_array($type, get_taxonomies())) |
|
| 391 | 391 | $map_option = 'edit_tags_per_page'; |
| 392 | - elseif ( in_array( $type, get_post_types() ) ) |
|
| 392 | + elseif (in_array($type, get_post_types())) |
|
| 393 | 393 | $map_option = 'edit_per_page'; |
| 394 | 394 | else |
| 395 | 395 | $option = str_replace('-', '_', $option); |
| 396 | 396 | |
| 397 | - switch ( $map_option ) { |
|
| 397 | + switch ($map_option) { |
|
| 398 | 398 | case 'edit_per_page': |
| 399 | 399 | case 'users_per_page': |
| 400 | 400 | case 'edit_comments_per_page': |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | case 'themes_network_per_page': |
| 410 | 410 | case 'site_themes_network_per_page': |
| 411 | 411 | $value = (int) $value; |
| 412 | - if ( $value < 1 || $value > 999 ) |
|
| 412 | + if ($value < 1 || $value > 999) |
|
| 413 | 413 | return; |
| 414 | 414 | break; |
| 415 | 415 | default: |
@@ -430,15 +430,15 @@ discard block |
||
| 430 | 430 | * @param string $option The option name. |
| 431 | 431 | * @param int $value The number of rows to use. |
| 432 | 432 | */ |
| 433 | - $value = apply_filters( 'set-screen-option', false, $option, $value ); |
|
| 433 | + $value = apply_filters('set-screen-option', false, $option, $value); |
|
| 434 | 434 | |
| 435 | - if ( false === $value ) |
|
| 435 | + if (false === $value) |
|
| 436 | 436 | return; |
| 437 | 437 | break; |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | update_user_meta($user->ID, $option, $value); |
| 441 | - wp_safe_redirect( remove_query_arg( array('pagenum', 'apage', 'paged'), wp_get_referer() ) ); |
|
| 441 | + wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer())); |
|
| 442 | 442 | exit; |
| 443 | 443 | } |
| 444 | 444 | } |
@@ -452,17 +452,17 @@ discard block |
||
| 452 | 452 | * @param string $filename The file path to the configuration file |
| 453 | 453 | */ |
| 454 | 454 | function iis7_rewrite_rule_exists($filename) { |
| 455 | - if ( ! file_exists($filename) ) |
|
| 455 | + if ( ! file_exists($filename)) |
|
| 456 | 456 | return false; |
| 457 | - if ( ! class_exists('DOMDocument') ) |
|
| 457 | + if ( ! class_exists('DOMDocument')) |
|
| 458 | 458 | return false; |
| 459 | 459 | |
| 460 | 460 | $doc = new DOMDocument(); |
| 461 | - if ( $doc->load($filename) === false ) |
|
| 461 | + if ($doc->load($filename) === false) |
|
| 462 | 462 | return false; |
| 463 | 463 | $xpath = new DOMXPath($doc); |
| 464 | 464 | $rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')]'); |
| 465 | - if ( $rules->length == 0 ) |
|
| 465 | + if ($rules->length == 0) |
|
| 466 | 466 | return false; |
| 467 | 467 | else |
| 468 | 468 | return true; |
@@ -478,20 +478,20 @@ discard block |
||
| 478 | 478 | */ |
| 479 | 479 | function iis7_delete_rewrite_rule($filename) { |
| 480 | 480 | // If configuration file does not exist then rules also do not exist so there is nothing to delete |
| 481 | - if ( ! file_exists($filename) ) |
|
| 481 | + if ( ! file_exists($filename)) |
|
| 482 | 482 | return true; |
| 483 | 483 | |
| 484 | - if ( ! class_exists('DOMDocument') ) |
|
| 484 | + if ( ! class_exists('DOMDocument')) |
|
| 485 | 485 | return false; |
| 486 | 486 | |
| 487 | 487 | $doc = new DOMDocument(); |
| 488 | 488 | $doc->preserveWhiteSpace = false; |
| 489 | 489 | |
| 490 | - if ( $doc -> load($filename) === false ) |
|
| 490 | + if ($doc -> load($filename) === false) |
|
| 491 | 491 | return false; |
| 492 | 492 | $xpath = new DOMXPath($doc); |
| 493 | 493 | $rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')]'); |
| 494 | - if ( $rules->length > 0 ) { |
|
| 494 | + if ($rules->length > 0) { |
|
| 495 | 495 | $child = $rules->item(0); |
| 496 | 496 | $parent = $child->parentNode; |
| 497 | 497 | $parent->removeChild($child); |
@@ -511,12 +511,12 @@ discard block |
||
| 511 | 511 | * @return bool |
| 512 | 512 | */ |
| 513 | 513 | function iis7_add_rewrite_rule($filename, $rewrite_rule) { |
| 514 | - if ( ! class_exists('DOMDocument') ) |
|
| 514 | + if ( ! class_exists('DOMDocument')) |
|
| 515 | 515 | return false; |
| 516 | 516 | |
| 517 | 517 | // If configuration file does not exist then we create one. |
| 518 | - if ( ! file_exists($filename) ) { |
|
| 519 | - $fp = fopen( $filename, 'w'); |
|
| 518 | + if ( ! file_exists($filename)) { |
|
| 519 | + $fp = fopen($filename, 'w'); |
|
| 520 | 520 | fwrite($fp, '<configuration/>'); |
| 521 | 521 | fclose($fp); |
| 522 | 522 | } |
@@ -524,25 +524,25 @@ discard block |
||
| 524 | 524 | $doc = new DOMDocument(); |
| 525 | 525 | $doc->preserveWhiteSpace = false; |
| 526 | 526 | |
| 527 | - if ( $doc->load($filename) === false ) |
|
| 527 | + if ($doc->load($filename) === false) |
|
| 528 | 528 | return false; |
| 529 | 529 | |
| 530 | 530 | $xpath = new DOMXPath($doc); |
| 531 | 531 | |
| 532 | 532 | // First check if the rule already exists as in that case there is no need to re-add it |
| 533 | 533 | $wordpress_rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')]'); |
| 534 | - if ( $wordpress_rules->length > 0 ) |
|
| 534 | + if ($wordpress_rules->length > 0) |
|
| 535 | 535 | return true; |
| 536 | 536 | |
| 537 | 537 | // Check the XPath to the rewrite rule and create XML nodes if they do not exist |
| 538 | 538 | $xmlnodes = $xpath->query('/configuration/system.webServer/rewrite/rules'); |
| 539 | - if ( $xmlnodes->length > 0 ) { |
|
| 539 | + if ($xmlnodes->length > 0) { |
|
| 540 | 540 | $rules_node = $xmlnodes->item(0); |
| 541 | 541 | } else { |
| 542 | 542 | $rules_node = $doc->createElement('rules'); |
| 543 | 543 | |
| 544 | 544 | $xmlnodes = $xpath->query('/configuration/system.webServer/rewrite'); |
| 545 | - if ( $xmlnodes->length > 0 ) { |
|
| 545 | + if ($xmlnodes->length > 0) { |
|
| 546 | 546 | $rewrite_node = $xmlnodes->item(0); |
| 547 | 547 | $rewrite_node->appendChild($rules_node); |
| 548 | 548 | } else { |
@@ -550,7 +550,7 @@ discard block |
||
| 550 | 550 | $rewrite_node->appendChild($rules_node); |
| 551 | 551 | |
| 552 | 552 | $xmlnodes = $xpath->query('/configuration/system.webServer'); |
| 553 | - if ( $xmlnodes->length > 0 ) { |
|
| 553 | + if ($xmlnodes->length > 0) { |
|
| 554 | 554 | $system_webServer_node = $xmlnodes->item(0); |
| 555 | 555 | $system_webServer_node->appendChild($rewrite_node); |
| 556 | 556 | } else { |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | $system_webServer_node->appendChild($rewrite_node); |
| 559 | 559 | |
| 560 | 560 | $xmlnodes = $xpath->query('/configuration'); |
| 561 | - if ( $xmlnodes->length > 0 ) { |
|
| 561 | + if ($xmlnodes->length > 0) { |
|
| 562 | 562 | $config_node = $xmlnodes->item(0); |
| 563 | 563 | $config_node->appendChild($system_webServer_node); |
| 564 | 564 | } else { |
@@ -604,42 +604,42 @@ discard block |
||
| 604 | 604 | * |
| 605 | 605 | * @global array $_wp_admin_css_colors |
| 606 | 606 | */ |
| 607 | -function admin_color_scheme_picker( $user_id ) { |
|
| 607 | +function admin_color_scheme_picker($user_id) { |
|
| 608 | 608 | global $_wp_admin_css_colors; |
| 609 | 609 | |
| 610 | - ksort( $_wp_admin_css_colors ); |
|
| 610 | + ksort($_wp_admin_css_colors); |
|
| 611 | 611 | |
| 612 | - if ( isset( $_wp_admin_css_colors['fresh'] ) ) { |
|
| 612 | + if (isset($_wp_admin_css_colors['fresh'])) { |
|
| 613 | 613 | // Set Default ('fresh') and Light should go first. |
| 614 | - $_wp_admin_css_colors = array_filter( array_merge( array( 'fresh' => '', 'light' => '' ), $_wp_admin_css_colors ) ); |
|
| 614 | + $_wp_admin_css_colors = array_filter(array_merge(array('fresh' => '', 'light' => ''), $_wp_admin_css_colors)); |
|
| 615 | 615 | } |
| 616 | 616 | |
| 617 | - $current_color = get_user_option( 'admin_color', $user_id ); |
|
| 617 | + $current_color = get_user_option('admin_color', $user_id); |
|
| 618 | 618 | |
| 619 | - if ( empty( $current_color ) || ! isset( $_wp_admin_css_colors[ $current_color ] ) ) { |
|
| 619 | + if (empty($current_color) || ! isset($_wp_admin_css_colors[$current_color])) { |
|
| 620 | 620 | $current_color = 'fresh'; |
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | ?> |
| 624 | 624 | <fieldset id="color-picker" class="scheme-list"> |
| 625 | - <legend class="screen-reader-text"><span><?php _e( 'Admin Color Scheme' ); ?></span></legend> |
|
| 625 | + <legend class="screen-reader-text"><span><?php _e('Admin Color Scheme'); ?></span></legend> |
|
| 626 | 626 | <?php |
| 627 | - wp_nonce_field( 'save-color-scheme', 'color-nonce', false ); |
|
| 628 | - foreach ( $_wp_admin_css_colors as $color => $color_info ) : |
|
| 627 | + wp_nonce_field('save-color-scheme', 'color-nonce', false); |
|
| 628 | + foreach ($_wp_admin_css_colors as $color => $color_info) : |
|
| 629 | 629 | |
| 630 | 630 | ?> |
| 631 | - <div class="color-option <?php echo ( $color == $current_color ) ? 'selected' : ''; ?>"> |
|
| 632 | - <input name="admin_color" id="admin_color_<?php echo esc_attr( $color ); ?>" type="radio" value="<?php echo esc_attr( $color ); ?>" class="tog" <?php checked( $color, $current_color ); ?> /> |
|
| 633 | - <input type="hidden" class="css_url" value="<?php echo esc_url( $color_info->url ); ?>" /> |
|
| 634 | - <input type="hidden" class="icon_colors" value="<?php echo esc_attr( wp_json_encode( array( 'icons' => $color_info->icon_colors ) ) ); ?>" /> |
|
| 635 | - <label for="admin_color_<?php echo esc_attr( $color ); ?>"><?php echo esc_html( $color_info->name ); ?></label> |
|
| 631 | + <div class="color-option <?php echo ($color == $current_color) ? 'selected' : ''; ?>"> |
|
| 632 | + <input name="admin_color" id="admin_color_<?php echo esc_attr($color); ?>" type="radio" value="<?php echo esc_attr($color); ?>" class="tog" <?php checked($color, $current_color); ?> /> |
|
| 633 | + <input type="hidden" class="css_url" value="<?php echo esc_url($color_info->url); ?>" /> |
|
| 634 | + <input type="hidden" class="icon_colors" value="<?php echo esc_attr(wp_json_encode(array('icons' => $color_info->icon_colors))); ?>" /> |
|
| 635 | + <label for="admin_color_<?php echo esc_attr($color); ?>"><?php echo esc_html($color_info->name); ?></label> |
|
| 636 | 636 | <table class="color-palette"> |
| 637 | 637 | <tr> |
| 638 | 638 | <?php |
| 639 | 639 | |
| 640 | - foreach ( $color_info->colors as $html_color ) { |
|
| 640 | + foreach ($color_info->colors as $html_color) { |
|
| 641 | 641 | ?> |
| 642 | - <td style="background-color: <?php echo esc_attr( $html_color ); ?>"> </td> |
|
| 642 | + <td style="background-color: <?php echo esc_attr($html_color); ?>"> </td> |
|
| 643 | 643 | <?php |
| 644 | 644 | } |
| 645 | 645 | |
@@ -663,30 +663,30 @@ discard block |
||
| 663 | 663 | function wp_color_scheme_settings() { |
| 664 | 664 | global $_wp_admin_css_colors; |
| 665 | 665 | |
| 666 | - $color_scheme = get_user_option( 'admin_color' ); |
|
| 666 | + $color_scheme = get_user_option('admin_color'); |
|
| 667 | 667 | |
| 668 | 668 | // It's possible to have a color scheme set that is no longer registered. |
| 669 | - if ( empty( $_wp_admin_css_colors[ $color_scheme ] ) ) { |
|
| 669 | + if (empty($_wp_admin_css_colors[$color_scheme])) { |
|
| 670 | 670 | $color_scheme = 'fresh'; |
| 671 | 671 | } |
| 672 | 672 | |
| 673 | - if ( ! empty( $_wp_admin_css_colors[ $color_scheme ]->icon_colors ) ) { |
|
| 674 | - $icon_colors = $_wp_admin_css_colors[ $color_scheme ]->icon_colors; |
|
| 675 | - } elseif ( ! empty( $_wp_admin_css_colors['fresh']->icon_colors ) ) { |
|
| 673 | + if ( ! empty($_wp_admin_css_colors[$color_scheme]->icon_colors)) { |
|
| 674 | + $icon_colors = $_wp_admin_css_colors[$color_scheme]->icon_colors; |
|
| 675 | + } elseif ( ! empty($_wp_admin_css_colors['fresh']->icon_colors)) { |
|
| 676 | 676 | $icon_colors = $_wp_admin_css_colors['fresh']->icon_colors; |
| 677 | 677 | } else { |
| 678 | 678 | // Fall back to the default set of icon colors if the default scheme is missing. |
| 679 | - $icon_colors = array( 'base' => '#999', 'focus' => '#00a0d2', 'current' => '#fff' ); |
|
| 679 | + $icon_colors = array('base' => '#999', 'focus' => '#00a0d2', 'current' => '#fff'); |
|
| 680 | 680 | } |
| 681 | 681 | |
| 682 | - echo '<script type="text/javascript">var _wpColorScheme = ' . wp_json_encode( array( 'icons' => $icon_colors ) ) . ";</script>\n"; |
|
| 682 | + echo '<script type="text/javascript">var _wpColorScheme = '.wp_json_encode(array('icons' => $icon_colors)).";</script>\n"; |
|
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | /** |
| 686 | 686 | * @since 3.3.0 |
| 687 | 687 | */ |
| 688 | 688 | function _ipad_meta() { |
| 689 | - if ( wp_is_mobile() ) { |
|
| 689 | + if (wp_is_mobile()) { |
|
| 690 | 690 | ?> |
| 691 | 691 | <meta name="viewport" id="viewport-meta" content="width=device-width, initial-scale=1"> |
| 692 | 692 | <?php |
@@ -698,18 +698,18 @@ discard block |
||
| 698 | 698 | * |
| 699 | 699 | * @since 3.6.0 |
| 700 | 700 | */ |
| 701 | -function wp_check_locked_posts( $response, $data, $screen_id ) { |
|
| 701 | +function wp_check_locked_posts($response, $data, $screen_id) { |
|
| 702 | 702 | $checked = array(); |
| 703 | 703 | |
| 704 | - if ( array_key_exists( 'wp-check-locked-posts', $data ) && is_array( $data['wp-check-locked-posts'] ) ) { |
|
| 705 | - foreach ( $data['wp-check-locked-posts'] as $key ) { |
|
| 706 | - if ( ! $post_id = absint( substr( $key, 5 ) ) ) |
|
| 704 | + if (array_key_exists('wp-check-locked-posts', $data) && is_array($data['wp-check-locked-posts'])) { |
|
| 705 | + foreach ($data['wp-check-locked-posts'] as $key) { |
|
| 706 | + if ( ! $post_id = absint(substr($key, 5))) |
|
| 707 | 707 | continue; |
| 708 | 708 | |
| 709 | - if ( ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) && current_user_can( 'edit_post', $post_id ) ) { |
|
| 710 | - $send = array( 'text' => sprintf( __( '%s is currently editing' ), $user->display_name ) ); |
|
| 709 | + if (($user_id = wp_check_post_lock($post_id)) && ($user = get_userdata($user_id)) && current_user_can('edit_post', $post_id)) { |
|
| 710 | + $send = array('text' => sprintf(__('%s is currently editing'), $user->display_name)); |
|
| 711 | 711 | |
| 712 | - if ( ( $avatar = get_avatar( $user->ID, 18 ) ) && preg_match( "|src='([^']+)'|", $avatar, $matches ) ) |
|
| 712 | + if (($avatar = get_avatar($user->ID, 18)) && preg_match("|src='([^']+)'|", $avatar, $matches)) |
|
| 713 | 713 | $send['avatar_src'] = $matches[1]; |
| 714 | 714 | |
| 715 | 715 | $checked[$key] = $send; |
@@ -717,7 +717,7 @@ discard block |
||
| 717 | 717 | } |
| 718 | 718 | } |
| 719 | 719 | |
| 720 | - if ( ! empty( $checked ) ) |
|
| 720 | + if ( ! empty($checked)) |
|
| 721 | 721 | $response['wp-check-locked-posts'] = $checked; |
| 722 | 722 | |
| 723 | 723 | return $response; |
@@ -728,31 +728,31 @@ discard block |
||
| 728 | 728 | * |
| 729 | 729 | * @since 3.6.0 |
| 730 | 730 | */ |
| 731 | -function wp_refresh_post_lock( $response, $data, $screen_id ) { |
|
| 732 | - if ( array_key_exists( 'wp-refresh-post-lock', $data ) ) { |
|
| 731 | +function wp_refresh_post_lock($response, $data, $screen_id) { |
|
| 732 | + if (array_key_exists('wp-refresh-post-lock', $data)) { |
|
| 733 | 733 | $received = $data['wp-refresh-post-lock']; |
| 734 | 734 | $send = array(); |
| 735 | 735 | |
| 736 | - if ( ! $post_id = absint( $received['post_id'] ) ) |
|
| 736 | + if ( ! $post_id = absint($received['post_id'])) |
|
| 737 | 737 | return $response; |
| 738 | 738 | |
| 739 | - if ( ! current_user_can('edit_post', $post_id) ) |
|
| 739 | + if ( ! current_user_can('edit_post', $post_id)) |
|
| 740 | 740 | return $response; |
| 741 | 741 | |
| 742 | - if ( ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) ) { |
|
| 742 | + if (($user_id = wp_check_post_lock($post_id)) && ($user = get_userdata($user_id))) { |
|
| 743 | 743 | $error = array( |
| 744 | - 'text' => sprintf( __( '%s has taken over and is currently editing.' ), $user->display_name ) |
|
| 744 | + 'text' => sprintf(__('%s has taken over and is currently editing.'), $user->display_name) |
|
| 745 | 745 | ); |
| 746 | 746 | |
| 747 | - if ( $avatar = get_avatar( $user->ID, 64 ) ) { |
|
| 748 | - if ( preg_match( "|src='([^']+)'|", $avatar, $matches ) ) |
|
| 747 | + if ($avatar = get_avatar($user->ID, 64)) { |
|
| 748 | + if (preg_match("|src='([^']+)'|", $avatar, $matches)) |
|
| 749 | 749 | $error['avatar_src'] = $matches[1]; |
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | $send['lock_error'] = $error; |
| 753 | 753 | } else { |
| 754 | - if ( $new_lock = wp_set_post_lock( $post_id ) ) |
|
| 755 | - $send['new_lock'] = implode( ':', $new_lock ); |
|
| 754 | + if ($new_lock = wp_set_post_lock($post_id)) |
|
| 755 | + $send['new_lock'] = implode(':', $new_lock); |
|
| 756 | 756 | } |
| 757 | 757 | |
| 758 | 758 | $response['wp-refresh-post-lock'] = $send; |
@@ -766,16 +766,16 @@ discard block |
||
| 766 | 766 | * |
| 767 | 767 | * @since 3.6.0 |
| 768 | 768 | */ |
| 769 | -function wp_refresh_post_nonces( $response, $data, $screen_id ) { |
|
| 770 | - if ( array_key_exists( 'wp-refresh-post-nonces', $data ) ) { |
|
| 769 | +function wp_refresh_post_nonces($response, $data, $screen_id) { |
|
| 770 | + if (array_key_exists('wp-refresh-post-nonces', $data)) { |
|
| 771 | 771 | $received = $data['wp-refresh-post-nonces']; |
| 772 | - $response['wp-refresh-post-nonces'] = array( 'check' => 1 ); |
|
| 772 | + $response['wp-refresh-post-nonces'] = array('check' => 1); |
|
| 773 | 773 | |
| 774 | - if ( ! $post_id = absint( $received['post_id'] ) ) { |
|
| 774 | + if ( ! $post_id = absint($received['post_id'])) { |
|
| 775 | 775 | return $response; |
| 776 | 776 | } |
| 777 | 777 | |
| 778 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
| 778 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
| 779 | 779 | return $response; |
| 780 | 780 | } |
| 781 | 781 | |
@@ -784,10 +784,10 @@ discard block |
||
| 784 | 784 | 'getpermalinknonce' => wp_create_nonce('getpermalink'), |
| 785 | 785 | 'samplepermalinknonce' => wp_create_nonce('samplepermalink'), |
| 786 | 786 | 'closedpostboxesnonce' => wp_create_nonce('closedpostboxes'), |
| 787 | - '_ajax_linking_nonce' => wp_create_nonce( 'internal-linking' ), |
|
| 788 | - '_wpnonce' => wp_create_nonce( 'update-post_' . $post_id ), |
|
| 787 | + '_ajax_linking_nonce' => wp_create_nonce('internal-linking'), |
|
| 788 | + '_wpnonce' => wp_create_nonce('update-post_'.$post_id), |
|
| 789 | 789 | ), |
| 790 | - 'heartbeatNonce' => wp_create_nonce( 'heartbeat-nonce' ), |
|
| 790 | + 'heartbeatNonce' => wp_create_nonce('heartbeat-nonce'), |
|
| 791 | 791 | ); |
| 792 | 792 | } |
| 793 | 793 | |
@@ -804,10 +804,10 @@ discard block |
||
| 804 | 804 | * @param array $settings An array of Heartbeat settings. |
| 805 | 805 | * @return array Filtered Heartbeat settings. |
| 806 | 806 | */ |
| 807 | -function wp_heartbeat_set_suspension( $settings ) { |
|
| 807 | +function wp_heartbeat_set_suspension($settings) { |
|
| 808 | 808 | global $pagenow; |
| 809 | 809 | |
| 810 | - if ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) { |
|
| 810 | + if ('post.php' === $pagenow || 'post-new.php' === $pagenow) { |
|
| 811 | 811 | $settings['suspension'] = 'disable'; |
| 812 | 812 | } |
| 813 | 813 | |
@@ -819,19 +819,19 @@ discard block |
||
| 819 | 819 | * |
| 820 | 820 | * @since 3.9.0 |
| 821 | 821 | */ |
| 822 | -function heartbeat_autosave( $response, $data ) { |
|
| 823 | - if ( ! empty( $data['wp_autosave'] ) ) { |
|
| 824 | - $saved = wp_autosave( $data['wp_autosave'] ); |
|
| 825 | - |
|
| 826 | - if ( is_wp_error( $saved ) ) { |
|
| 827 | - $response['wp_autosave'] = array( 'success' => false, 'message' => $saved->get_error_message() ); |
|
| 828 | - } elseif ( empty( $saved ) ) { |
|
| 829 | - $response['wp_autosave'] = array( 'success' => false, 'message' => __( 'Error while saving.' ) ); |
|
| 822 | +function heartbeat_autosave($response, $data) { |
|
| 823 | + if ( ! empty($data['wp_autosave'])) { |
|
| 824 | + $saved = wp_autosave($data['wp_autosave']); |
|
| 825 | + |
|
| 826 | + if (is_wp_error($saved)) { |
|
| 827 | + $response['wp_autosave'] = array('success' => false, 'message' => $saved->get_error_message()); |
|
| 828 | + } elseif (empty($saved)) { |
|
| 829 | + $response['wp_autosave'] = array('success' => false, 'message' => __('Error while saving.')); |
|
| 830 | 830 | } else { |
| 831 | 831 | /* translators: draft saved date format, see http://php.net/date */ |
| 832 | - $draft_saved_date_format = __( 'g:i:s a' ); |
|
| 832 | + $draft_saved_date_format = __('g:i:s a'); |
|
| 833 | 833 | /* translators: %s: date and time */ |
| 834 | - $response['wp_autosave'] = array( 'success' => true, 'message' => sprintf( __( 'Draft saved at %s.' ), date_i18n( $draft_saved_date_format ) ) ); |
|
| 834 | + $response['wp_autosave'] = array('success' => true, 'message' => sprintf(__('Draft saved at %s.'), date_i18n($draft_saved_date_format))); |
|
| 835 | 835 | } |
| 836 | 836 | } |
| 837 | 837 | |
@@ -851,7 +851,7 @@ discard block |
||
| 851 | 851 | function post_form_autocomplete_off() { |
| 852 | 852 | global $is_safari, $is_chrome; |
| 853 | 853 | |
| 854 | - if ( $is_safari || $is_chrome ) { |
|
| 854 | + if ($is_safari || $is_chrome) { |
|
| 855 | 855 | echo ' autocomplete="off"'; |
| 856 | 856 | } |
| 857 | 857 | } |
@@ -881,17 +881,17 @@ discard block |
||
| 881 | 881 | * |
| 882 | 882 | * @param array $removable_query_args An array of parameters to remove from the URL. |
| 883 | 883 | */ |
| 884 | - $removable_query_args = apply_filters( 'removable_query_args', $removable_query_args ); |
|
| 884 | + $removable_query_args = apply_filters('removable_query_args', $removable_query_args); |
|
| 885 | 885 | |
| 886 | - if ( empty( $removable_query_args ) ) { |
|
| 886 | + if (empty($removable_query_args)) { |
|
| 887 | 887 | return; |
| 888 | 888 | } |
| 889 | 889 | |
| 890 | 890 | // Ensure we're using an absolute URL. |
| 891 | - $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); |
|
| 892 | - $filtered_url = remove_query_arg( $removable_query_args, $current_url ); |
|
| 891 | + $current_url = set_url_scheme('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); |
|
| 892 | + $filtered_url = remove_query_arg($removable_query_args, $current_url); |
|
| 893 | 893 | ?> |
| 894 | - <link id="wp-admin-canonical" rel="canonical" href="<?php echo esc_url( $filtered_url ); ?>" /> |
|
| 894 | + <link id="wp-admin-canonical" rel="canonical" href="<?php echo esc_url($filtered_url); ?>" /> |
|
| 895 | 895 | <script> |
| 896 | 896 | if ( window.history.replaceState ) { |
| 897 | 897 | window.history.replaceState( null, null, document.getElementById( 'wp-admin-canonical' ).href + window.location.hash ); |
@@ -75,12 +75,15 @@ discard block |
||
| 75 | 75 | { |
| 76 | 76 | $state = false; |
| 77 | 77 | foreach ( $markerdata as $markerline ) { |
| 78 | - if (strpos($markerline, '# END ' . $marker) !== false) |
|
| 79 | - $state = false; |
|
| 80 | - if ( $state ) |
|
| 81 | - $result[] = $markerline; |
|
| 82 | - if (strpos($markerline, '# BEGIN ' . $marker) !== false) |
|
| 83 | - $state = true; |
|
| 78 | + if (strpos($markerline, '# END ' . $marker) !== false) { |
|
| 79 | + $state = false; |
|
| 80 | + } |
|
| 81 | + if ( $state ) { |
|
| 82 | + $result[] = $markerline; |
|
| 83 | + } |
|
| 84 | + if (strpos($markerline, '# BEGIN ' . $marker) !== false) { |
|
| 85 | + $state = true; |
|
| 86 | + } |
|
| 84 | 87 | } |
| 85 | 88 | } |
| 86 | 89 | |
@@ -109,26 +112,30 @@ discard block |
||
| 109 | 112 | $markerdata = explode( "\n", implode( '', file( $filename ) ) ); |
| 110 | 113 | } |
| 111 | 114 | |
| 112 | - if ( !$f = @fopen( $filename, 'w' ) ) |
|
| 113 | - return false; |
|
| 115 | + if ( !$f = @fopen( $filename, 'w' ) ) { |
|
| 116 | + return false; |
|
| 117 | + } |
|
| 114 | 118 | |
| 115 | 119 | $foundit = false; |
| 116 | 120 | if ( $markerdata ) { |
| 117 | 121 | $state = true; |
| 118 | 122 | foreach ( $markerdata as $n => $markerline ) { |
| 119 | - if (strpos($markerline, '# BEGIN ' . $marker) !== false) |
|
| 120 | - $state = false; |
|
| 123 | + if (strpos($markerline, '# BEGIN ' . $marker) !== false) { |
|
| 124 | + $state = false; |
|
| 125 | + } |
|
| 121 | 126 | if ( $state ) { |
| 122 | - if ( $n + 1 < count( $markerdata ) ) |
|
| 123 | - fwrite( $f, "{$markerline}\n" ); |
|
| 124 | - else |
|
| 125 | - fwrite( $f, "{$markerline}" ); |
|
| 127 | + if ( $n + 1 < count( $markerdata ) ) { |
|
| 128 | + fwrite( $f, "{$markerline}\n" ); |
|
| 129 | + } else { |
|
| 130 | + fwrite( $f, "{$markerline}" ); |
|
| 131 | + } |
|
| 126 | 132 | } |
| 127 | 133 | if (strpos($markerline, '# END ' . $marker) !== false) { |
| 128 | 134 | fwrite( $f, "# BEGIN {$marker}\n" ); |
| 129 | - if ( is_array( $insertion )) |
|
| 130 | - foreach ( $insertion as $insertline ) |
|
| 135 | + if ( is_array( $insertion )) { |
|
| 136 | + foreach ( $insertion as $insertline ) |
|
| 131 | 137 | fwrite( $f, "{$insertline}\n" ); |
| 138 | + } |
|
| 132 | 139 | fwrite( $f, "# END {$marker}\n" ); |
| 133 | 140 | $state = true; |
| 134 | 141 | $foundit = true; |
@@ -137,8 +144,9 @@ discard block |
||
| 137 | 144 | } |
| 138 | 145 | if (!$foundit) { |
| 139 | 146 | fwrite( $f, "\n# BEGIN {$marker}\n" ); |
| 140 | - foreach ( $insertion as $insertline ) |
|
| 141 | - fwrite( $f, "{$insertline}\n" ); |
|
| 147 | + foreach ( $insertion as $insertline ) { |
|
| 148 | + fwrite( $f, "{$insertline}\n" ); |
|
| 149 | + } |
|
| 142 | 150 | fwrite( $f, "# END {$marker}\n" ); |
| 143 | 151 | } |
| 144 | 152 | fclose( $f ); |
@@ -159,8 +167,9 @@ discard block |
||
| 159 | 167 | * @global WP_Rewrite $wp_rewrite |
| 160 | 168 | */ |
| 161 | 169 | function save_mod_rewrite_rules() { |
| 162 | - if ( is_multisite() ) |
|
| 163 | - return; |
|
| 170 | + if ( is_multisite() ) { |
|
| 171 | + return; |
|
| 172 | + } |
|
| 164 | 173 | |
| 165 | 174 | global $wp_rewrite; |
| 166 | 175 | |
@@ -192,8 +201,9 @@ discard block |
||
| 192 | 201 | * @return bool True if web.config was updated successfully |
| 193 | 202 | */ |
| 194 | 203 | function iis7_save_url_rewrite_rules(){ |
| 195 | - if ( is_multisite() ) |
|
| 196 | - return; |
|
| 204 | + if ( is_multisite() ) { |
|
| 205 | + return; |
|
| 206 | + } |
|
| 197 | 207 | |
| 198 | 208 | global $wp_rewrite; |
| 199 | 209 | |
@@ -226,8 +236,9 @@ discard block |
||
| 226 | 236 | $oldfiles[] = $file; |
| 227 | 237 | $oldfiles = array_reverse( $oldfiles ); |
| 228 | 238 | $oldfiles = array_unique( $oldfiles ); |
| 229 | - if ( 5 < count( $oldfiles )) |
|
| 230 | - array_pop( $oldfiles ); |
|
| 239 | + if ( 5 < count( $oldfiles )) { |
|
| 240 | + array_pop( $oldfiles ); |
|
| 241 | + } |
|
| 231 | 242 | } else { |
| 232 | 243 | $oldfiles[] = $file; |
| 233 | 244 | } |
@@ -243,8 +254,9 @@ discard block |
||
| 243 | 254 | * @param string $value |
| 244 | 255 | */ |
| 245 | 256 | function update_home_siteurl( $old_value, $value ) { |
| 246 | - if ( defined( "WP_INSTALLING" ) ) |
|
| 247 | - return; |
|
| 257 | + if ( defined( "WP_INSTALLING" ) ) { |
|
| 258 | + return; |
|
| 259 | + } |
|
| 248 | 260 | |
| 249 | 261 | // If home changed, write rewrite rules to new location. |
| 250 | 262 | flush_rewrite_rules(); |
@@ -261,8 +273,9 @@ discard block |
||
| 261 | 273 | function url_shorten( $url ) { |
| 262 | 274 | $short_url = str_replace( array( 'http://', 'www.' ), '', $url ); |
| 263 | 275 | $short_url = untrailingslashit( $short_url ); |
| 264 | - if ( strlen( $short_url ) > 35 ) |
|
| 265 | - $short_url = substr( $short_url, 0, 32 ) . '…'; |
|
| 276 | + if ( strlen( $short_url ) > 35 ) { |
|
| 277 | + $short_url = substr( $short_url, 0, 32 ) . '…'; |
|
| 278 | + } |
|
| 266 | 279 | return $short_url; |
| 267 | 280 | } |
| 268 | 281 | |
@@ -300,10 +313,11 @@ discard block |
||
| 300 | 313 | */ |
| 301 | 314 | function show_message($message) { |
| 302 | 315 | if ( is_wp_error($message) ){ |
| 303 | - if ( $message->get_error_data() && is_string( $message->get_error_data() ) ) |
|
| 304 | - $message = $message->get_error_message() . ': ' . $message->get_error_data(); |
|
| 305 | - else |
|
| 306 | - $message = $message->get_error_message(); |
|
| 316 | + if ( $message->get_error_data() && is_string( $message->get_error_data() ) ) { |
|
| 317 | + $message = $message->get_error_message() . ': ' . $message->get_error_data(); |
|
| 318 | + } else { |
|
| 319 | + $message = $message->get_error_message(); |
|
| 320 | + } |
|
| 307 | 321 | } |
| 308 | 322 | echo "<p>$message</p>\n"; |
| 309 | 323 | wp_ob_end_flush_all(); |
@@ -317,11 +331,13 @@ discard block |
||
| 317 | 331 | * @return array |
| 318 | 332 | */ |
| 319 | 333 | function wp_doc_link_parse( $content ) { |
| 320 | - if ( !is_string( $content ) || empty( $content ) ) |
|
| 321 | - return array(); |
|
| 334 | + if ( !is_string( $content ) || empty( $content ) ) { |
|
| 335 | + return array(); |
|
| 336 | + } |
|
| 322 | 337 | |
| 323 | - if ( !function_exists('token_get_all') ) |
|
| 324 | - return array(); |
|
| 338 | + if ( !function_exists('token_get_all') ) { |
|
| 339 | + return array(); |
|
| 340 | + } |
|
| 325 | 341 | |
| 326 | 342 | $tokens = token_get_all( $content ); |
| 327 | 343 | $count = count( $tokens ); |
@@ -358,8 +374,9 @@ discard block |
||
| 358 | 374 | |
| 359 | 375 | $out = array(); |
| 360 | 376 | foreach ( $functions as $function ) { |
| 361 | - if ( in_array( $function, $ignore_functions ) ) |
|
| 362 | - continue; |
|
| 377 | + if ( in_array( $function, $ignore_functions ) ) { |
|
| 378 | + continue; |
|
| 379 | + } |
|
| 363 | 380 | $out[] = $function; |
| 364 | 381 | } |
| 365 | 382 | |
@@ -376,23 +393,26 @@ discard block |
||
| 376 | 393 | if ( isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options']) ) { |
| 377 | 394 | check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' ); |
| 378 | 395 | |
| 379 | - if ( !$user = wp_get_current_user() ) |
|
| 380 | - return; |
|
| 396 | + if ( !$user = wp_get_current_user() ) { |
|
| 397 | + return; |
|
| 398 | + } |
|
| 381 | 399 | $option = $_POST['wp_screen_options']['option']; |
| 382 | 400 | $value = $_POST['wp_screen_options']['value']; |
| 383 | 401 | |
| 384 | - if ( $option != sanitize_key( $option ) ) |
|
| 385 | - return; |
|
| 402 | + if ( $option != sanitize_key( $option ) ) { |
|
| 403 | + return; |
|
| 404 | + } |
|
| 386 | 405 | |
| 387 | 406 | $map_option = $option; |
| 388 | 407 | $type = str_replace('edit_', '', $map_option); |
| 389 | 408 | $type = str_replace('_per_page', '', $type); |
| 390 | - if ( in_array( $type, get_taxonomies() ) ) |
|
| 391 | - $map_option = 'edit_tags_per_page'; |
|
| 392 | - elseif ( in_array( $type, get_post_types() ) ) |
|
| 393 | - $map_option = 'edit_per_page'; |
|
| 394 | - else |
|
| 395 | - $option = str_replace('-', '_', $option); |
|
| 409 | + if ( in_array( $type, get_taxonomies() ) ) { |
|
| 410 | + $map_option = 'edit_tags_per_page'; |
|
| 411 | + } elseif ( in_array( $type, get_post_types() ) ) { |
|
| 412 | + $map_option = 'edit_per_page'; |
|
| 413 | + } else { |
|
| 414 | + $option = str_replace('-', '_', $option); |
|
| 415 | + } |
|
| 396 | 416 | |
| 397 | 417 | switch ( $map_option ) { |
| 398 | 418 | case 'edit_per_page': |
@@ -409,8 +429,9 @@ discard block |
||
| 409 | 429 | case 'themes_network_per_page': |
| 410 | 430 | case 'site_themes_network_per_page': |
| 411 | 431 | $value = (int) $value; |
| 412 | - if ( $value < 1 || $value > 999 ) |
|
| 413 | - return; |
|
| 432 | + if ( $value < 1 || $value > 999 ) { |
|
| 433 | + return; |
|
| 434 | + } |
|
| 414 | 435 | break; |
| 415 | 436 | default: |
| 416 | 437 | |
@@ -432,8 +453,9 @@ discard block |
||
| 432 | 453 | */ |
| 433 | 454 | $value = apply_filters( 'set-screen-option', false, $option, $value ); |
| 434 | 455 | |
| 435 | - if ( false === $value ) |
|
| 436 | - return; |
|
| 456 | + if ( false === $value ) { |
|
| 457 | + return; |
|
| 458 | + } |
|
| 437 | 459 | break; |
| 438 | 460 | } |
| 439 | 461 | |
@@ -452,21 +474,25 @@ discard block |
||
| 452 | 474 | * @param string $filename The file path to the configuration file |
| 453 | 475 | */ |
| 454 | 476 | function iis7_rewrite_rule_exists($filename) { |
| 455 | - if ( ! file_exists($filename) ) |
|
| 456 | - return false; |
|
| 457 | - if ( ! class_exists('DOMDocument') ) |
|
| 458 | - return false; |
|
| 477 | + if ( ! file_exists($filename) ) { |
|
| 478 | + return false; |
|
| 479 | + } |
|
| 480 | + if ( ! class_exists('DOMDocument') ) { |
|
| 481 | + return false; |
|
| 482 | + } |
|
| 459 | 483 | |
| 460 | 484 | $doc = new DOMDocument(); |
| 461 | - if ( $doc->load($filename) === false ) |
|
| 462 | - return false; |
|
| 485 | + if ( $doc->load($filename) === false ) { |
|
| 486 | + return false; |
|
| 487 | + } |
|
| 463 | 488 | $xpath = new DOMXPath($doc); |
| 464 | 489 | $rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')]'); |
| 465 | - if ( $rules->length == 0 ) |
|
| 466 | - return false; |
|
| 467 | - else |
|
| 468 | - return true; |
|
| 469 | -} |
|
| 490 | + if ( $rules->length == 0 ) { |
|
| 491 | + return false; |
|
| 492 | + } else { |
|
| 493 | + return true; |
|
| 494 | + } |
|
| 495 | + } |
|
| 470 | 496 | |
| 471 | 497 | /** |
| 472 | 498 | * Delete WordPress rewrite rule from web.config file if it exists there |
@@ -478,17 +504,20 @@ discard block |
||
| 478 | 504 | */ |
| 479 | 505 | function iis7_delete_rewrite_rule($filename) { |
| 480 | 506 | // If configuration file does not exist then rules also do not exist so there is nothing to delete |
| 481 | - if ( ! file_exists($filename) ) |
|
| 482 | - return true; |
|
| 507 | + if ( ! file_exists($filename) ) { |
|
| 508 | + return true; |
|
| 509 | + } |
|
| 483 | 510 | |
| 484 | - if ( ! class_exists('DOMDocument') ) |
|
| 485 | - return false; |
|
| 511 | + if ( ! class_exists('DOMDocument') ) { |
|
| 512 | + return false; |
|
| 513 | + } |
|
| 486 | 514 | |
| 487 | 515 | $doc = new DOMDocument(); |
| 488 | 516 | $doc->preserveWhiteSpace = false; |
| 489 | 517 | |
| 490 | - if ( $doc -> load($filename) === false ) |
|
| 491 | - return false; |
|
| 518 | + if ( $doc -> load($filename) === false ) { |
|
| 519 | + return false; |
|
| 520 | + } |
|
| 492 | 521 | $xpath = new DOMXPath($doc); |
| 493 | 522 | $rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')]'); |
| 494 | 523 | if ( $rules->length > 0 ) { |
@@ -511,8 +540,9 @@ discard block |
||
| 511 | 540 | * @return bool |
| 512 | 541 | */ |
| 513 | 542 | function iis7_add_rewrite_rule($filename, $rewrite_rule) { |
| 514 | - if ( ! class_exists('DOMDocument') ) |
|
| 515 | - return false; |
|
| 543 | + if ( ! class_exists('DOMDocument') ) { |
|
| 544 | + return false; |
|
| 545 | + } |
|
| 516 | 546 | |
| 517 | 547 | // If configuration file does not exist then we create one. |
| 518 | 548 | if ( ! file_exists($filename) ) { |
@@ -524,15 +554,17 @@ discard block |
||
| 524 | 554 | $doc = new DOMDocument(); |
| 525 | 555 | $doc->preserveWhiteSpace = false; |
| 526 | 556 | |
| 527 | - if ( $doc->load($filename) === false ) |
|
| 528 | - return false; |
|
| 557 | + if ( $doc->load($filename) === false ) { |
|
| 558 | + return false; |
|
| 559 | + } |
|
| 529 | 560 | |
| 530 | 561 | $xpath = new DOMXPath($doc); |
| 531 | 562 | |
| 532 | 563 | // First check if the rule already exists as in that case there is no need to re-add it |
| 533 | 564 | $wordpress_rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')]'); |
| 534 | - if ( $wordpress_rules->length > 0 ) |
|
| 535 | - return true; |
|
| 565 | + if ( $wordpress_rules->length > 0 ) { |
|
| 566 | + return true; |
|
| 567 | + } |
|
| 536 | 568 | |
| 537 | 569 | // Check the XPath to the rewrite rule and create XML nodes if they do not exist |
| 538 | 570 | $xmlnodes = $xpath->query('/configuration/system.webServer/rewrite/rules'); |
@@ -703,22 +735,25 @@ discard block |
||
| 703 | 735 | |
| 704 | 736 | if ( array_key_exists( 'wp-check-locked-posts', $data ) && is_array( $data['wp-check-locked-posts'] ) ) { |
| 705 | 737 | foreach ( $data['wp-check-locked-posts'] as $key ) { |
| 706 | - if ( ! $post_id = absint( substr( $key, 5 ) ) ) |
|
| 707 | - continue; |
|
| 738 | + if ( ! $post_id = absint( substr( $key, 5 ) ) ) { |
|
| 739 | + continue; |
|
| 740 | + } |
|
| 708 | 741 | |
| 709 | 742 | if ( ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) && current_user_can( 'edit_post', $post_id ) ) { |
| 710 | 743 | $send = array( 'text' => sprintf( __( '%s is currently editing' ), $user->display_name ) ); |
| 711 | 744 | |
| 712 | - if ( ( $avatar = get_avatar( $user->ID, 18 ) ) && preg_match( "|src='([^']+)'|", $avatar, $matches ) ) |
|
| 713 | - $send['avatar_src'] = $matches[1]; |
|
| 745 | + if ( ( $avatar = get_avatar( $user->ID, 18 ) ) && preg_match( "|src='([^']+)'|", $avatar, $matches ) ) { |
|
| 746 | + $send['avatar_src'] = $matches[1]; |
|
| 747 | + } |
|
| 714 | 748 | |
| 715 | 749 | $checked[$key] = $send; |
| 716 | 750 | } |
| 717 | 751 | } |
| 718 | 752 | } |
| 719 | 753 | |
| 720 | - if ( ! empty( $checked ) ) |
|
| 721 | - $response['wp-check-locked-posts'] = $checked; |
|
| 754 | + if ( ! empty( $checked ) ) { |
|
| 755 | + $response['wp-check-locked-posts'] = $checked; |
|
| 756 | + } |
|
| 722 | 757 | |
| 723 | 758 | return $response; |
| 724 | 759 | } |
@@ -733,11 +768,13 @@ discard block |
||
| 733 | 768 | $received = $data['wp-refresh-post-lock']; |
| 734 | 769 | $send = array(); |
| 735 | 770 | |
| 736 | - if ( ! $post_id = absint( $received['post_id'] ) ) |
|
| 737 | - return $response; |
|
| 771 | + if ( ! $post_id = absint( $received['post_id'] ) ) { |
|
| 772 | + return $response; |
|
| 773 | + } |
|
| 738 | 774 | |
| 739 | - if ( ! current_user_can('edit_post', $post_id) ) |
|
| 740 | - return $response; |
|
| 775 | + if ( ! current_user_can('edit_post', $post_id) ) { |
|
| 776 | + return $response; |
|
| 777 | + } |
|
| 741 | 778 | |
| 742 | 779 | if ( ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) ) { |
| 743 | 780 | $error = array( |
@@ -745,14 +782,16 @@ discard block |
||
| 745 | 782 | ); |
| 746 | 783 | |
| 747 | 784 | if ( $avatar = get_avatar( $user->ID, 64 ) ) { |
| 748 | - if ( preg_match( "|src='([^']+)'|", $avatar, $matches ) ) |
|
| 749 | - $error['avatar_src'] = $matches[1]; |
|
| 785 | + if ( preg_match( "|src='([^']+)'|", $avatar, $matches ) ) { |
|
| 786 | + $error['avatar_src'] = $matches[1]; |
|
| 787 | + } |
|
| 750 | 788 | } |
| 751 | 789 | |
| 752 | 790 | $send['lock_error'] = $error; |
| 753 | 791 | } else { |
| 754 | - if ( $new_lock = wp_set_post_lock( $post_id ) ) |
|
| 755 | - $send['new_lock'] = implode( ':', $new_lock ); |
|
| 792 | + if ( $new_lock = wp_set_post_lock( $post_id ) ) { |
|
| 793 | + $send['new_lock'] = implode( ':', $new_lock ); |
|
| 794 | + } |
|
| 756 | 795 | } |
| 757 | 796 | |
| 758 | 797 | $response['wp-refresh-post-lock'] = $send; |
@@ -736,7 +736,7 @@ |
||
| 736 | 736 | * |
| 737 | 737 | * @global int $wp_db_version The version number of the database. |
| 738 | 738 | * |
| 739 | - * @return false False if the current user is not a super admin. |
|
| 739 | + * @return false|null False if the current user is not a super admin. |
|
| 740 | 740 | */ |
| 741 | 741 | function site_admin_notice() { |
| 742 | 742 | global $wp_db_version; |
@@ -1,11 +1,11 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Multisite administration functions. |
|
| 4 | - * |
|
| 5 | - * @package WordPress |
|
| 6 | - * @subpackage Multisite |
|
| 7 | - * @since 3.0.0 |
|
| 8 | - */ |
|
| 3 | + * Multisite administration functions. |
|
| 4 | + * |
|
| 5 | + * @package WordPress |
|
| 6 | + * @subpackage Multisite |
|
| 7 | + * @since 3.0.0 |
|
| 8 | + */ |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * Determine if uploaded file exceeds space quota. |
@@ -15,28 +15,28 @@ discard block |
||
| 15 | 15 | * @param array $file $_FILES array for a given file. |
| 16 | 16 | * @return array $_FILES array with 'error' key set if file exceeds quota. 'error' is empty otherwise. |
| 17 | 17 | */ |
| 18 | -function check_upload_size( $file ) { |
|
| 19 | - if ( get_site_option( 'upload_space_check_disabled' ) ) |
|
| 18 | +function check_upload_size($file) { |
|
| 19 | + if (get_site_option('upload_space_check_disabled')) |
|
| 20 | 20 | return $file; |
| 21 | 21 | |
| 22 | - if ( $file['error'] != '0' ) // there's already an error |
|
| 22 | + if ($file['error'] != '0') // there's already an error |
|
| 23 | 23 | return $file; |
| 24 | 24 | |
| 25 | - if ( defined( 'WP_IMPORTING' ) ) |
|
| 25 | + if (defined('WP_IMPORTING')) |
|
| 26 | 26 | return $file; |
| 27 | 27 | |
| 28 | 28 | $space_left = get_upload_space_available(); |
| 29 | 29 | |
| 30 | - $file_size = filesize( $file['tmp_name'] ); |
|
| 31 | - if ( $space_left < $file_size ) |
|
| 32 | - $file['error'] = sprintf( __( 'Not enough space to upload. %1$s KB needed.' ), number_format( ($file_size - $space_left) /1024 ) ); |
|
| 33 | - if ( $file_size > ( 1024 * get_site_option( 'fileupload_maxk', 1500 ) ) ) |
|
| 34 | - $file['error'] = sprintf(__('This file is too big. Files must be less than %1$s KB in size.'), get_site_option( 'fileupload_maxk', 1500 ) ); |
|
| 35 | - if ( upload_is_user_over_quota( false ) ) { |
|
| 36 | - $file['error'] = __( 'You have used your space quota. Please delete files before uploading.' ); |
|
| 30 | + $file_size = filesize($file['tmp_name']); |
|
| 31 | + if ($space_left < $file_size) |
|
| 32 | + $file['error'] = sprintf(__('Not enough space to upload. %1$s KB needed.'), number_format(($file_size - $space_left) / 1024)); |
|
| 33 | + if ($file_size > (1024 * get_site_option('fileupload_maxk', 1500))) |
|
| 34 | + $file['error'] = sprintf(__('This file is too big. Files must be less than %1$s KB in size.'), get_site_option('fileupload_maxk', 1500)); |
|
| 35 | + if (upload_is_user_over_quota(false)) { |
|
| 36 | + $file['error'] = __('You have used your space quota. Please delete files before uploading.'); |
|
| 37 | 37 | } |
| 38 | - if ( $file['error'] != '0' && ! isset( $_POST['html-upload'] ) && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) { |
|
| 39 | - wp_die( $file['error'] . ' <a href="javascript:history.go(-1)">' . __( 'Back' ) . '</a>' ); |
|
| 38 | + if ($file['error'] != '0' && ! isset($_POST['html-upload']) && ( ! defined('DOING_AJAX') || ! DOING_AJAX)) { |
|
| 39 | + wp_die($file['error'].' <a href="javascript:history.go(-1)">'.__('Back').'</a>'); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | return $file; |
@@ -52,16 +52,16 @@ discard block |
||
| 52 | 52 | * @param int $blog_id Blog ID. |
| 53 | 53 | * @param bool $drop True if blog's table should be dropped. Default is false. |
| 54 | 54 | */ |
| 55 | -function wpmu_delete_blog( $blog_id, $drop = false ) { |
|
| 55 | +function wpmu_delete_blog($blog_id, $drop = false) { |
|
| 56 | 56 | global $wpdb; |
| 57 | 57 | |
| 58 | 58 | $switch = false; |
| 59 | - if ( get_current_blog_id() != $blog_id ) { |
|
| 59 | + if (get_current_blog_id() != $blog_id) { |
|
| 60 | 60 | $switch = true; |
| 61 | - switch_to_blog( $blog_id ); |
|
| 61 | + switch_to_blog($blog_id); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - $blog = get_blog_details( $blog_id ); |
|
| 64 | + $blog = get_blog_details($blog_id); |
|
| 65 | 65 | /** |
| 66 | 66 | * Fires before a blog is deleted. |
| 67 | 67 | * |
@@ -70,42 +70,42 @@ discard block |
||
| 70 | 70 | * @param int $blog_id The blog ID. |
| 71 | 71 | * @param bool $drop True if blog's table should be dropped. Default is false. |
| 72 | 72 | */ |
| 73 | - do_action( 'delete_blog', $blog_id, $drop ); |
|
| 73 | + do_action('delete_blog', $blog_id, $drop); |
|
| 74 | 74 | |
| 75 | - $users = get_users( array( 'blog_id' => $blog_id, 'fields' => 'ids' ) ); |
|
| 75 | + $users = get_users(array('blog_id' => $blog_id, 'fields' => 'ids')); |
|
| 76 | 76 | |
| 77 | 77 | // Remove users from this blog. |
| 78 | - if ( ! empty( $users ) ) { |
|
| 79 | - foreach ( $users as $user_id ) { |
|
| 80 | - remove_user_from_blog( $user_id, $blog_id ); |
|
| 78 | + if ( ! empty($users)) { |
|
| 79 | + foreach ($users as $user_id) { |
|
| 80 | + remove_user_from_blog($user_id, $blog_id); |
|
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - update_blog_status( $blog_id, 'deleted', 1 ); |
|
| 84 | + update_blog_status($blog_id, 'deleted', 1); |
|
| 85 | 85 | |
| 86 | 86 | $current_site = get_current_site(); |
| 87 | 87 | |
| 88 | 88 | // If a full blog object is not available, do not destroy anything. |
| 89 | - if ( $drop && ! $blog ) { |
|
| 89 | + if ($drop && ! $blog) { |
|
| 90 | 90 | $drop = false; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | // Don't destroy the initial, main, or root blog. |
| 94 | - if ( $drop && ( 1 == $blog_id || is_main_site( $blog_id ) || ( $blog->path == $current_site->path && $blog->domain == $current_site->domain ) ) ) { |
|
| 94 | + if ($drop && (1 == $blog_id || is_main_site($blog_id) || ($blog->path == $current_site->path && $blog->domain == $current_site->domain))) { |
|
| 95 | 95 | $drop = false; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - $upload_path = trim( get_option( 'upload_path' ) ); |
|
| 98 | + $upload_path = trim(get_option('upload_path')); |
|
| 99 | 99 | |
| 100 | 100 | // If ms_files_rewriting is enabled and upload_path is empty, wp_upload_dir is not reliable. |
| 101 | - if ( $drop && get_site_option( 'ms_files_rewriting' ) && empty( $upload_path ) ) { |
|
| 101 | + if ($drop && get_site_option('ms_files_rewriting') && empty($upload_path)) { |
|
| 102 | 102 | $drop = false; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - if ( $drop ) { |
|
| 105 | + if ($drop) { |
|
| 106 | 106 | $uploads = wp_upload_dir(); |
| 107 | 107 | |
| 108 | - $tables = $wpdb->tables( 'blog' ); |
|
| 108 | + $tables = $wpdb->tables('blog'); |
|
| 109 | 109 | /** |
| 110 | 110 | * Filter the tables to drop when the blog is deleted. |
| 111 | 111 | * |
@@ -114,13 +114,13 @@ discard block |
||
| 114 | 114 | * @param array $tables The blog tables to be dropped. |
| 115 | 115 | * @param int $blog_id The ID of the blog to drop tables for. |
| 116 | 116 | */ |
| 117 | - $drop_tables = apply_filters( 'wpmu_drop_tables', $tables, $blog_id ); |
|
| 117 | + $drop_tables = apply_filters('wpmu_drop_tables', $tables, $blog_id); |
|
| 118 | 118 | |
| 119 | - foreach ( (array) $drop_tables as $table ) { |
|
| 120 | - $wpdb->query( "DROP TABLE IF EXISTS `$table`" ); |
|
| 119 | + foreach ((array) $drop_tables as $table) { |
|
| 120 | + $wpdb->query("DROP TABLE IF EXISTS `$table`"); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - $wpdb->delete( $wpdb->blogs, array( 'blog_id' => $blog_id ) ); |
|
| 123 | + $wpdb->delete($wpdb->blogs, array('blog_id' => $blog_id)); |
|
| 124 | 124 | |
| 125 | 125 | /** |
| 126 | 126 | * Filter the upload base directory to delete when the blog is deleted. |
@@ -130,43 +130,43 @@ discard block |
||
| 130 | 130 | * @param string $uploads['basedir'] Uploads path without subdirectory. @see wp_upload_dir() |
| 131 | 131 | * @param int $blog_id The blog ID. |
| 132 | 132 | */ |
| 133 | - $dir = apply_filters( 'wpmu_delete_blog_upload_dir', $uploads['basedir'], $blog_id ); |
|
| 134 | - $dir = rtrim( $dir, DIRECTORY_SEPARATOR ); |
|
| 133 | + $dir = apply_filters('wpmu_delete_blog_upload_dir', $uploads['basedir'], $blog_id); |
|
| 134 | + $dir = rtrim($dir, DIRECTORY_SEPARATOR); |
|
| 135 | 135 | $top_dir = $dir; |
| 136 | 136 | $stack = array($dir); |
| 137 | 137 | $index = 0; |
| 138 | 138 | |
| 139 | - while ( $index < count( $stack ) ) { |
|
| 139 | + while ($index < count($stack)) { |
|
| 140 | 140 | // Get indexed directory from stack |
| 141 | 141 | $dir = $stack[$index]; |
| 142 | 142 | |
| 143 | - $dh = @opendir( $dir ); |
|
| 144 | - if ( $dh ) { |
|
| 145 | - while ( ( $file = @readdir( $dh ) ) !== false ) { |
|
| 146 | - if ( $file == '.' || $file == '..' ) |
|
| 143 | + $dh = @opendir($dir); |
|
| 144 | + if ($dh) { |
|
| 145 | + while (($file = @readdir($dh)) !== false) { |
|
| 146 | + if ($file == '.' || $file == '..') |
|
| 147 | 147 | continue; |
| 148 | 148 | |
| 149 | - if ( @is_dir( $dir . DIRECTORY_SEPARATOR . $file ) ) { |
|
| 150 | - $stack[] = $dir . DIRECTORY_SEPARATOR . $file; |
|
| 151 | - } elseif ( @is_file( $dir . DIRECTORY_SEPARATOR . $file ) ) { |
|
| 152 | - @unlink( $dir . DIRECTORY_SEPARATOR . $file ); |
|
| 149 | + if (@is_dir($dir.DIRECTORY_SEPARATOR.$file)) { |
|
| 150 | + $stack[] = $dir.DIRECTORY_SEPARATOR.$file; |
|
| 151 | + } elseif (@is_file($dir.DIRECTORY_SEPARATOR.$file)) { |
|
| 152 | + @unlink($dir.DIRECTORY_SEPARATOR.$file); |
|
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | - @closedir( $dh ); |
|
| 155 | + @closedir($dh); |
|
| 156 | 156 | } |
| 157 | 157 | $index++; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - $stack = array_reverse( $stack ); // Last added dirs are deepest |
|
| 161 | - foreach( (array) $stack as $dir ) { |
|
| 162 | - if ( $dir != $top_dir) |
|
| 163 | - @rmdir( $dir ); |
|
| 160 | + $stack = array_reverse($stack); // Last added dirs are deepest |
|
| 161 | + foreach ((array) $stack as $dir) { |
|
| 162 | + if ($dir != $top_dir) |
|
| 163 | + @rmdir($dir); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - clean_blog_cache( $blog ); |
|
| 166 | + clean_blog_cache($blog); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - if ( $switch ) |
|
| 169 | + if ($switch) |
|
| 170 | 170 | restore_current_blog(); |
| 171 | 171 | } |
| 172 | 172 | |
@@ -182,18 +182,18 @@ discard block |
||
| 182 | 182 | * @param int $id The user ID. |
| 183 | 183 | * @return bool True if the user was deleted, otherwise false. |
| 184 | 184 | */ |
| 185 | -function wpmu_delete_user( $id ) { |
|
| 185 | +function wpmu_delete_user($id) { |
|
| 186 | 186 | global $wpdb; |
| 187 | 187 | |
| 188 | 188 | $id = (int) $id; |
| 189 | - $user = new WP_User( $id ); |
|
| 189 | + $user = new WP_User($id); |
|
| 190 | 190 | |
| 191 | - if ( !$user->exists() ) |
|
| 191 | + if ( ! $user->exists()) |
|
| 192 | 192 | return false; |
| 193 | 193 | |
| 194 | 194 | // Global super-administrators are protected, and cannot be deleted. |
| 195 | 195 | $_super_admins = get_super_admins(); |
| 196 | - if ( in_array( $user->user_login, $_super_admins, true ) ) { |
|
| 196 | + if (in_array($user->user_login, $_super_admins, true)) { |
|
| 197 | 197 | return false; |
| 198 | 198 | } |
| 199 | 199 | |
@@ -204,42 +204,42 @@ discard block |
||
| 204 | 204 | * |
| 205 | 205 | * @param int $id ID of the user about to be deleted from the network. |
| 206 | 206 | */ |
| 207 | - do_action( 'wpmu_delete_user', $id ); |
|
| 207 | + do_action('wpmu_delete_user', $id); |
|
| 208 | 208 | |
| 209 | - $blogs = get_blogs_of_user( $id ); |
|
| 209 | + $blogs = get_blogs_of_user($id); |
|
| 210 | 210 | |
| 211 | - if ( ! empty( $blogs ) ) { |
|
| 212 | - foreach ( $blogs as $blog ) { |
|
| 213 | - switch_to_blog( $blog->userblog_id ); |
|
| 214 | - remove_user_from_blog( $id, $blog->userblog_id ); |
|
| 211 | + if ( ! empty($blogs)) { |
|
| 212 | + foreach ($blogs as $blog) { |
|
| 213 | + switch_to_blog($blog->userblog_id); |
|
| 214 | + remove_user_from_blog($id, $blog->userblog_id); |
|
| 215 | 215 | |
| 216 | - $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id ) ); |
|
| 217 | - foreach ( (array) $post_ids as $post_id ) { |
|
| 218 | - wp_delete_post( $post_id ); |
|
| 216 | + $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id)); |
|
| 217 | + foreach ((array) $post_ids as $post_id) { |
|
| 218 | + wp_delete_post($post_id); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | // Clean links |
| 222 | - $link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) ); |
|
| 222 | + $link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id)); |
|
| 223 | 223 | |
| 224 | - if ( $link_ids ) { |
|
| 225 | - foreach ( $link_ids as $link_id ) |
|
| 226 | - wp_delete_link( $link_id ); |
|
| 224 | + if ($link_ids) { |
|
| 225 | + foreach ($link_ids as $link_id) |
|
| 226 | + wp_delete_link($link_id); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | restore_current_blog(); |
| 230 | 230 | } |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - $meta = $wpdb->get_col( $wpdb->prepare( "SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d", $id ) ); |
|
| 234 | - foreach ( $meta as $mid ) |
|
| 235 | - delete_metadata_by_mid( 'user', $mid ); |
|
| 233 | + $meta = $wpdb->get_col($wpdb->prepare("SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d", $id)); |
|
| 234 | + foreach ($meta as $mid) |
|
| 235 | + delete_metadata_by_mid('user', $mid); |
|
| 236 | 236 | |
| 237 | - $wpdb->delete( $wpdb->users, array( 'ID' => $id ) ); |
|
| 237 | + $wpdb->delete($wpdb->users, array('ID' => $id)); |
|
| 238 | 238 | |
| 239 | - clean_user_cache( $user ); |
|
| 239 | + clean_user_cache($user); |
|
| 240 | 240 | |
| 241 | 241 | /** This action is documented in wp-admin/includes/user.php */ |
| 242 | - do_action( 'deleted_user', $id ); |
|
| 242 | + do_action('deleted_user', $id); |
|
| 243 | 243 | |
| 244 | 244 | return true; |
| 245 | 245 | } |
@@ -252,19 +252,19 @@ discard block |
||
| 252 | 252 | * @param string $old_value The old email address. Not currently used. |
| 253 | 253 | * @param string $value The new email address. |
| 254 | 254 | */ |
| 255 | -function update_option_new_admin_email( $old_value, $value ) { |
|
| 256 | - if ( $value == get_option( 'admin_email' ) || !is_email( $value ) ) |
|
| 255 | +function update_option_new_admin_email($old_value, $value) { |
|
| 256 | + if ($value == get_option('admin_email') || ! is_email($value)) |
|
| 257 | 257 | return; |
| 258 | 258 | |
| 259 | - $hash = md5( $value. time() .mt_rand() ); |
|
| 259 | + $hash = md5($value.time().mt_rand()); |
|
| 260 | 260 | $new_admin_email = array( |
| 261 | 261 | 'hash' => $hash, |
| 262 | 262 | 'newemail' => $value |
| 263 | 263 | ); |
| 264 | - update_option( 'adminhash', $new_admin_email ); |
|
| 264 | + update_option('adminhash', $new_admin_email); |
|
| 265 | 265 | |
| 266 | 266 | /* translators: Do not translate USERNAME, ADMIN_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */ |
| 267 | - $email_text = __( 'Howdy ###USERNAME###, |
|
| 267 | + $email_text = __('Howdy ###USERNAME###, |
|
| 268 | 268 | |
| 269 | 269 | You recently requested to have the administration email address on |
| 270 | 270 | your site changed. |
@@ -296,16 +296,16 @@ discard block |
||
| 296 | 296 | * @param string $email_text Text in the email. |
| 297 | 297 | * @param string $new_admin_email New admin email that the current administration email was changed to. |
| 298 | 298 | */ |
| 299 | - $content = apply_filters( 'new_admin_email_content', $email_text, $new_admin_email ); |
|
| 299 | + $content = apply_filters('new_admin_email_content', $email_text, $new_admin_email); |
|
| 300 | 300 | |
| 301 | 301 | $current_user = wp_get_current_user(); |
| 302 | - $content = str_replace( '###USERNAME###', $current_user->user_login, $content ); |
|
| 303 | - $content = str_replace( '###ADMIN_URL###', esc_url( admin_url( 'options.php?adminhash='.$hash ) ), $content ); |
|
| 304 | - $content = str_replace( '###EMAIL###', $value, $content ); |
|
| 305 | - $content = str_replace( '###SITENAME###', get_site_option( 'site_name' ), $content ); |
|
| 306 | - $content = str_replace( '###SITEURL###', network_home_url(), $content ); |
|
| 302 | + $content = str_replace('###USERNAME###', $current_user->user_login, $content); |
|
| 303 | + $content = str_replace('###ADMIN_URL###', esc_url(admin_url('options.php?adminhash='.$hash)), $content); |
|
| 304 | + $content = str_replace('###EMAIL###', $value, $content); |
|
| 305 | + $content = str_replace('###SITENAME###', get_site_option('site_name'), $content); |
|
| 306 | + $content = str_replace('###SITEURL###', network_home_url(), $content); |
|
| 307 | 307 | |
| 308 | - wp_mail( $value, sprintf( __( '[%s] New Admin Email Address' ), wp_specialchars_decode( get_option( 'blogname' ) ) ), $content ); |
|
| 308 | + wp_mail($value, sprintf(__('[%s] New Admin Email Address'), wp_specialchars_decode(get_option('blogname'))), $content); |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | /** |
@@ -319,33 +319,33 @@ discard block |
||
| 319 | 319 | function send_confirmation_on_profile_email() { |
| 320 | 320 | global $errors, $wpdb; |
| 321 | 321 | $current_user = wp_get_current_user(); |
| 322 | - if ( ! is_object($errors) ) |
|
| 322 | + if ( ! is_object($errors)) |
|
| 323 | 323 | $errors = new WP_Error(); |
| 324 | 324 | |
| 325 | - if ( $current_user->ID != $_POST['user_id'] ) |
|
| 325 | + if ($current_user->ID != $_POST['user_id']) |
|
| 326 | 326 | return false; |
| 327 | 327 | |
| 328 | - if ( $current_user->user_email != $_POST['email'] ) { |
|
| 329 | - if ( !is_email( $_POST['email'] ) ) { |
|
| 330 | - $errors->add( 'user_email', __( "<strong>ERROR</strong>: The email address isn’t correct." ), array( 'form-field' => 'email' ) ); |
|
| 328 | + if ($current_user->user_email != $_POST['email']) { |
|
| 329 | + if ( ! is_email($_POST['email'])) { |
|
| 330 | + $errors->add('user_email', __("<strong>ERROR</strong>: The email address isn’t correct."), array('form-field' => 'email')); |
|
| 331 | 331 | return; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM {$wpdb->users} WHERE user_email=%s", $_POST['email'] ) ) ) { |
|
| 335 | - $errors->add( 'user_email', __( "<strong>ERROR</strong>: The email address is already used." ), array( 'form-field' => 'email' ) ); |
|
| 336 | - delete_option( $current_user->ID . '_new_email' ); |
|
| 334 | + if ($wpdb->get_var($wpdb->prepare("SELECT user_email FROM {$wpdb->users} WHERE user_email=%s", $_POST['email']))) { |
|
| 335 | + $errors->add('user_email', __("<strong>ERROR</strong>: The email address is already used."), array('form-field' => 'email')); |
|
| 336 | + delete_option($current_user->ID.'_new_email'); |
|
| 337 | 337 | return; |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - $hash = md5( $_POST['email'] . time() . mt_rand() ); |
|
| 340 | + $hash = md5($_POST['email'].time().mt_rand()); |
|
| 341 | 341 | $new_user_email = array( |
| 342 | 342 | 'hash' => $hash, |
| 343 | 343 | 'newemail' => $_POST['email'] |
| 344 | 344 | ); |
| 345 | - update_option( $current_user->ID . '_new_email', $new_user_email ); |
|
| 345 | + update_option($current_user->ID.'_new_email', $new_user_email); |
|
| 346 | 346 | |
| 347 | 347 | /* translators: Do not translate USERNAME, ADMIN_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */ |
| 348 | - $email_text = __( 'Howdy ###USERNAME###, |
|
| 348 | + $email_text = __('Howdy ###USERNAME###, |
|
| 349 | 349 | |
| 350 | 350 | You recently requested to have the email address on your account changed. |
| 351 | 351 | |
@@ -376,15 +376,15 @@ discard block |
||
| 376 | 376 | * @param string $email_text Text in the email. |
| 377 | 377 | * @param string $new_user_email New user email that the current user has changed to. |
| 378 | 378 | */ |
| 379 | - $content = apply_filters( 'new_user_email_content', $email_text, $new_user_email ); |
|
| 379 | + $content = apply_filters('new_user_email_content', $email_text, $new_user_email); |
|
| 380 | 380 | |
| 381 | - $content = str_replace( '###USERNAME###', $current_user->user_login, $content ); |
|
| 382 | - $content = str_replace( '###ADMIN_URL###', esc_url( admin_url( 'profile.php?newuseremail='.$hash ) ), $content ); |
|
| 383 | - $content = str_replace( '###EMAIL###', $_POST['email'], $content); |
|
| 384 | - $content = str_replace( '###SITENAME###', get_site_option( 'site_name' ), $content ); |
|
| 385 | - $content = str_replace( '###SITEURL###', network_home_url(), $content ); |
|
| 381 | + $content = str_replace('###USERNAME###', $current_user->user_login, $content); |
|
| 382 | + $content = str_replace('###ADMIN_URL###', esc_url(admin_url('profile.php?newuseremail='.$hash)), $content); |
|
| 383 | + $content = str_replace('###EMAIL###', $_POST['email'], $content); |
|
| 384 | + $content = str_replace('###SITENAME###', get_site_option('site_name'), $content); |
|
| 385 | + $content = str_replace('###SITEURL###', network_home_url(), $content); |
|
| 386 | 386 | |
| 387 | - wp_mail( $_POST['email'], sprintf( __( '[%s] New Email Address' ), wp_specialchars_decode( get_option( 'blogname' ) ) ), $content ); |
|
| 387 | + wp_mail($_POST['email'], sprintf(__('[%s] New Email Address'), wp_specialchars_decode(get_option('blogname'))), $content); |
|
| 388 | 388 | $_POST['email'] = $current_user->user_email; |
| 389 | 389 | } |
| 390 | 390 | } |
@@ -396,8 +396,8 @@ discard block |
||
| 396 | 396 | * @since 3.0.0 |
| 397 | 397 | */ |
| 398 | 398 | function new_user_email_admin_notice() { |
| 399 | - if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) && isset( $_GET['updated'] ) && $email = get_option( get_current_user_id() . '_new_email' ) ) |
|
| 400 | - echo "<div class='update-nag'>" . sprintf( __( "Your email address has not been updated yet. Please check your inbox at %s for a confirmation email." ), $email['newemail'] ) . "</div>"; |
|
| 399 | + if (strpos($_SERVER['PHP_SELF'], 'profile.php') && isset($_GET['updated']) && $email = get_option(get_current_user_id().'_new_email')) |
|
| 400 | + echo "<div class='update-nag'>".sprintf(__("Your email address has not been updated yet. Please check your inbox at %s for a confirmation email."), $email['newemail'])."</div>"; |
|
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | /** |
@@ -408,19 +408,19 @@ discard block |
||
| 408 | 408 | * @param bool $echo Optional. If $echo is set and the quota is exceeded, a warning message is echoed. Default is true. |
| 409 | 409 | * @return bool True if user is over upload space quota, otherwise false. |
| 410 | 410 | */ |
| 411 | -function upload_is_user_over_quota( $echo = true ) { |
|
| 412 | - if ( get_site_option( 'upload_space_check_disabled' ) ) |
|
| 411 | +function upload_is_user_over_quota($echo = true) { |
|
| 412 | + if (get_site_option('upload_space_check_disabled')) |
|
| 413 | 413 | return false; |
| 414 | 414 | |
| 415 | 415 | $space_allowed = get_space_allowed(); |
| 416 | - if ( empty( $space_allowed ) || !is_numeric( $space_allowed ) ) |
|
| 416 | + if (empty($space_allowed) || ! is_numeric($space_allowed)) |
|
| 417 | 417 | $space_allowed = 10; // Default space allowed is 10 MB |
| 418 | 418 | |
| 419 | 419 | $space_used = get_space_used(); |
| 420 | 420 | |
| 421 | - if ( ( $space_allowed - $space_used ) < 0 ) { |
|
| 422 | - if ( $echo ) |
|
| 423 | - _e( 'Sorry, you have used your space allocation. Please delete some files to upload more files.' ); |
|
| 421 | + if (($space_allowed - $space_used) < 0) { |
|
| 422 | + if ($echo) |
|
| 423 | + _e('Sorry, you have used your space allocation. Please delete some files to upload more files.'); |
|
| 424 | 424 | return true; |
| 425 | 425 | } else { |
| 426 | 426 | return false; |
@@ -436,19 +436,19 @@ discard block |
||
| 436 | 436 | $space_allowed = get_space_allowed(); |
| 437 | 437 | $space_used = get_space_used(); |
| 438 | 438 | |
| 439 | - $percent_used = ( $space_used / $space_allowed ) * 100; |
|
| 439 | + $percent_used = ($space_used / $space_allowed) * 100; |
|
| 440 | 440 | |
| 441 | - if ( $space_allowed > 1000 ) { |
|
| 442 | - $space = number_format( $space_allowed / 1024 ); |
|
| 441 | + if ($space_allowed > 1000) { |
|
| 442 | + $space = number_format($space_allowed / 1024); |
|
| 443 | 443 | /* translators: Gigabytes */ |
| 444 | - $space .= __( 'GB' ); |
|
| 444 | + $space .= __('GB'); |
|
| 445 | 445 | } else { |
| 446 | - $space = number_format( $space_allowed ); |
|
| 446 | + $space = number_format($space_allowed); |
|
| 447 | 447 | /* translators: Megabytes */ |
| 448 | - $space .= __( 'MB' ); |
|
| 448 | + $space .= __('MB'); |
|
| 449 | 449 | } |
| 450 | 450 | ?> |
| 451 | - <strong><?php printf( __( 'Used: %1$s%% of %2$s' ), number_format( $percent_used ), $space ); ?></strong> |
|
| 451 | + <strong><?php printf(__('Used: %1$s%% of %2$s'), number_format($percent_used), $space); ?></strong> |
|
| 452 | 452 | <?php |
| 453 | 453 | } |
| 454 | 454 | |
@@ -460,12 +460,12 @@ discard block |
||
| 460 | 460 | * @param int $size Current max size in bytes |
| 461 | 461 | * @return int Max size in bytes |
| 462 | 462 | */ |
| 463 | -function fix_import_form_size( $size ) { |
|
| 464 | - if ( upload_is_user_over_quota( false ) ) { |
|
| 463 | +function fix_import_form_size($size) { |
|
| 464 | + if (upload_is_user_over_quota(false)) { |
|
| 465 | 465 | return 0; |
| 466 | 466 | } |
| 467 | 467 | $available = get_upload_space_available(); |
| 468 | - return min( $size, $available ); |
|
| 468 | + return min($size, $available); |
|
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | /** |
@@ -475,20 +475,20 @@ discard block |
||
| 475 | 475 | * |
| 476 | 476 | * @param int $id The ID of the blog to display the setting for. |
| 477 | 477 | */ |
| 478 | -function upload_space_setting( $id ) { |
|
| 479 | - switch_to_blog( $id ); |
|
| 480 | - $quota = get_option( 'blog_upload_space' ); |
|
| 478 | +function upload_space_setting($id) { |
|
| 479 | + switch_to_blog($id); |
|
| 480 | + $quota = get_option('blog_upload_space'); |
|
| 481 | 481 | restore_current_blog(); |
| 482 | 482 | |
| 483 | - if ( !$quota ) |
|
| 483 | + if ( ! $quota) |
|
| 484 | 484 | $quota = ''; |
| 485 | 485 | |
| 486 | 486 | ?> |
| 487 | 487 | <tr> |
| 488 | - <th><label for="blog-upload-space-number"><?php _e( 'Site Upload Space Quota' ); ?></label></th> |
|
| 488 | + <th><label for="blog-upload-space-number"><?php _e('Site Upload Space Quota'); ?></label></th> |
|
| 489 | 489 | <td> |
| 490 | 490 | <input type="number" step="1" min="0" style="width: 100px" name="option[blog_upload_space]" id="blog-upload-space-number" aria-describedby="blog-upload-space-desc" value="<?php echo $quota; ?>" /> |
| 491 | - <span id="blog-upload-space-desc"><span class="screen-reader-text"><?php _e( 'Size in megabytes' ); ?></span> <?php _e( 'MB (Leave blank for network default)' ); ?></span> |
|
| 491 | + <span id="blog-upload-space-desc"><span class="screen-reader-text"><?php _e('Size in megabytes'); ?></span> <?php _e('MB (Leave blank for network default)'); ?></span> |
|
| 492 | 492 | </td> |
| 493 | 493 | </tr> |
| 494 | 494 | <?php |
@@ -510,19 +510,19 @@ discard block |
||
| 510 | 510 | * @param null $deprecated Deprecated as of 3.0.2 and should not be used. |
| 511 | 511 | * @return int The initially passed $value. |
| 512 | 512 | */ |
| 513 | -function update_user_status( $id, $pref, $value, $deprecated = null ) { |
|
| 513 | +function update_user_status($id, $pref, $value, $deprecated = null) { |
|
| 514 | 514 | global $wpdb; |
| 515 | 515 | |
| 516 | - if ( null !== $deprecated ) |
|
| 517 | - _deprecated_argument( __FUNCTION__, '3.1' ); |
|
| 516 | + if (null !== $deprecated) |
|
| 517 | + _deprecated_argument(__FUNCTION__, '3.1'); |
|
| 518 | 518 | |
| 519 | - $wpdb->update( $wpdb->users, array( sanitize_key( $pref ) => $value ), array( 'ID' => $id ) ); |
|
| 519 | + $wpdb->update($wpdb->users, array(sanitize_key($pref) => $value), array('ID' => $id)); |
|
| 520 | 520 | |
| 521 | - $user = new WP_User( $id ); |
|
| 522 | - clean_user_cache( $user ); |
|
| 521 | + $user = new WP_User($id); |
|
| 522 | + clean_user_cache($user); |
|
| 523 | 523 | |
| 524 | - if ( $pref == 'spam' ) { |
|
| 525 | - if ( $value == 1 ) { |
|
| 524 | + if ($pref == 'spam') { |
|
| 525 | + if ($value == 1) { |
|
| 526 | 526 | /** |
| 527 | 527 | * Fires after the user is marked as a SPAM user. |
| 528 | 528 | * |
@@ -530,7 +530,7 @@ discard block |
||
| 530 | 530 | * |
| 531 | 531 | * @param int $id ID of the user marked as SPAM. |
| 532 | 532 | */ |
| 533 | - do_action( 'make_spam_user', $id ); |
|
| 533 | + do_action('make_spam_user', $id); |
|
| 534 | 534 | } else { |
| 535 | 535 | /** |
| 536 | 536 | * Fires after the user is marked as a HAM user. Opposite of SPAM. |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | * |
| 540 | 540 | * @param int $id ID of the user marked as HAM. |
| 541 | 541 | */ |
| 542 | - do_action( 'make_ham_user', $id ); |
|
| 542 | + do_action('make_ham_user', $id); |
|
| 543 | 543 | } |
| 544 | 544 | } |
| 545 | 545 | |
@@ -554,13 +554,13 @@ discard block |
||
| 554 | 554 | * @param int $id The user ID. |
| 555 | 555 | * @return bool|int The ID of the refreshed user or false if the user does not exist. |
| 556 | 556 | */ |
| 557 | -function refresh_user_details( $id ) { |
|
| 557 | +function refresh_user_details($id) { |
|
| 558 | 558 | $id = (int) $id; |
| 559 | 559 | |
| 560 | - if ( !$user = get_userdata( $id ) ) |
|
| 560 | + if ( ! $user = get_userdata($id)) |
|
| 561 | 561 | return false; |
| 562 | 562 | |
| 563 | - clean_user_cache( $user ); |
|
| 563 | + clean_user_cache($user); |
|
| 564 | 564 | |
| 565 | 565 | return $id; |
| 566 | 566 | } |
@@ -574,8 +574,8 @@ discard block |
||
| 574 | 574 | * @return string The language corresponding to $code if it exists. If it does not exist, |
| 575 | 575 | * then the first two letters of $code is returned. |
| 576 | 576 | */ |
| 577 | -function format_code_lang( $code = '' ) { |
|
| 578 | - $code = strtolower( substr( $code, 0, 2 ) ); |
|
| 577 | +function format_code_lang($code = '') { |
|
| 578 | + $code = strtolower(substr($code, 0, 2)); |
|
| 579 | 579 | $lang_codes = array( |
| 580 | 580 | 'aa' => 'Afar', 'ab' => 'Abkhazian', 'af' => 'Afrikaans', 'ak' => 'Akan', 'sq' => 'Albanian', 'am' => 'Amharic', 'ar' => 'Arabic', 'an' => 'Aragonese', 'hy' => 'Armenian', 'as' => 'Assamese', 'av' => 'Avaric', 'ae' => 'Avestan', 'ay' => 'Aymara', 'az' => 'Azerbaijani', 'ba' => 'Bashkir', 'bm' => 'Bambara', 'eu' => 'Basque', 'be' => 'Belarusian', 'bn' => 'Bengali', |
| 581 | 581 | 'bh' => 'Bihari', 'bi' => 'Bislama', 'bs' => 'Bosnian', 'br' => 'Breton', 'bg' => 'Bulgarian', 'my' => 'Burmese', 'ca' => 'Catalan; Valencian', 'ch' => 'Chamorro', 'ce' => 'Chechen', 'zh' => 'Chinese', 'cu' => 'Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic', 'cv' => 'Chuvash', 'kw' => 'Cornish', 'co' => 'Corsican', 'cr' => 'Cree', |
@@ -587,7 +587,7 @@ discard block |
||
| 587 | 587 | 'no' => 'Norwegian', 'ny' => 'Chichewa; Chewa; Nyanja', 'oc' => 'Occitan, Provençal', 'oj' => 'Ojibwa', 'or' => 'Oriya', 'om' => 'Oromo', 'os' => 'Ossetian; Ossetic', 'pa' => 'Panjabi; Punjabi', 'fa' => 'Persian', 'pi' => 'Pali', 'pl' => 'Polish', 'pt' => 'Portuguese', 'ps' => 'Pushto', 'qu' => 'Quechua', 'rm' => 'Romansh', 'ro' => 'Romanian', 'rn' => 'Rundi', 'ru' => 'Russian', |
| 588 | 588 | 'sg' => 'Sango', 'sa' => 'Sanskrit', 'sr' => 'Serbian', 'hr' => 'Croatian', 'si' => 'Sinhala; Sinhalese', 'sk' => 'Slovak', 'sl' => 'Slovenian', 'se' => 'Northern Sami', 'sm' => 'Samoan', 'sn' => 'Shona', 'sd' => 'Sindhi', 'so' => 'Somali', 'st' => 'Sotho, Southern', 'es' => 'Spanish; Castilian', 'sc' => 'Sardinian', 'ss' => 'Swati', 'su' => 'Sundanese', 'sw' => 'Swahili', |
| 589 | 589 | 'sv' => 'Swedish', 'ty' => 'Tahitian', 'ta' => 'Tamil', 'tt' => 'Tatar', 'te' => 'Telugu', 'tg' => 'Tajik', 'tl' => 'Tagalog', 'th' => 'Thai', 'bo' => 'Tibetan', 'ti' => 'Tigrinya', 'to' => 'Tonga (Tonga Islands)', 'tn' => 'Tswana', 'ts' => 'Tsonga', 'tk' => 'Turkmen', 'tr' => 'Turkish', 'tw' => 'Twi', 'ug' => 'Uighur; Uyghur', 'uk' => 'Ukrainian', 'ur' => 'Urdu', 'uz' => 'Uzbek', |
| 590 | - 've' => 'Venda', 'vi' => 'Vietnamese', 'vo' => 'Volapük', 'cy' => 'Welsh','wa' => 'Walloon','wo' => 'Wolof', 'xh' => 'Xhosa', 'yi' => 'Yiddish', 'yo' => 'Yoruba', 'za' => 'Zhuang; Chuang', 'zu' => 'Zulu' ); |
|
| 590 | + 've' => 'Venda', 'vi' => 'Vietnamese', 'vo' => 'Volapük', 'cy' => 'Welsh', 'wa' => 'Walloon', 'wo' => 'Wolof', 'xh' => 'Xhosa', 'yi' => 'Yiddish', 'yo' => 'Yoruba', 'za' => 'Zhuang; Chuang', 'zu' => 'Zulu' ); |
|
| 591 | 591 | |
| 592 | 592 | /** |
| 593 | 593 | * Filter the language codes. |
@@ -597,8 +597,8 @@ discard block |
||
| 597 | 597 | * @param array $lang_codes Key/value pair of language codes where key is the short version. |
| 598 | 598 | * @param string $code A two-letter designation of the language. |
| 599 | 599 | */ |
| 600 | - $lang_codes = apply_filters( 'lang_codes', $lang_codes, $code ); |
|
| 601 | - return strtr( $code, $lang_codes ); |
|
| 600 | + $lang_codes = apply_filters('lang_codes', $lang_codes, $code); |
|
| 601 | + return strtr($code, $lang_codes); |
|
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | /** |
@@ -613,12 +613,12 @@ discard block |
||
| 613 | 613 | * @return object|array Returns `$term`, after filtering the 'slug' field with {@see sanitize_title()} |
| 614 | 614 | * if $taxonomy is 'category' or 'post_tag'. |
| 615 | 615 | */ |
| 616 | -function sync_category_tag_slugs( $term, $taxonomy ) { |
|
| 617 | - if ( global_terms_enabled() && ( $taxonomy == 'category' || $taxonomy == 'post_tag' ) ) { |
|
| 618 | - if ( is_object( $term ) ) { |
|
| 619 | - $term->slug = sanitize_title( $term->name ); |
|
| 616 | +function sync_category_tag_slugs($term, $taxonomy) { |
|
| 617 | + if (global_terms_enabled() && ($taxonomy == 'category' || $taxonomy == 'post_tag')) { |
|
| 618 | + if (is_object($term)) { |
|
| 619 | + $term->slug = sanitize_title($term->name); |
|
| 620 | 620 | } else { |
| 621 | - $term['slug'] = sanitize_title( $term['name'] ); |
|
| 621 | + $term['slug'] = sanitize_title($term['name']); |
|
| 622 | 622 | } |
| 623 | 623 | } |
| 624 | 624 | return $term; |
@@ -632,36 +632,36 @@ discard block |
||
| 632 | 632 | * @access private |
| 633 | 633 | */ |
| 634 | 634 | function _access_denied_splash() { |
| 635 | - if ( ! is_user_logged_in() || is_network_admin() ) |
|
| 635 | + if ( ! is_user_logged_in() || is_network_admin()) |
|
| 636 | 636 | return; |
| 637 | 637 | |
| 638 | - $blogs = get_blogs_of_user( get_current_user_id() ); |
|
| 638 | + $blogs = get_blogs_of_user(get_current_user_id()); |
|
| 639 | 639 | |
| 640 | - if ( wp_list_filter( $blogs, array( 'userblog_id' => get_current_blog_id() ) ) ) |
|
| 640 | + if (wp_list_filter($blogs, array('userblog_id' => get_current_blog_id()))) |
|
| 641 | 641 | return; |
| 642 | 642 | |
| 643 | - $blog_name = get_bloginfo( 'name' ); |
|
| 643 | + $blog_name = get_bloginfo('name'); |
|
| 644 | 644 | |
| 645 | - if ( empty( $blogs ) ) |
|
| 646 | - wp_die( sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ), 403 ); |
|
| 645 | + if (empty($blogs)) |
|
| 646 | + wp_die(sprintf(__('You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.'), $blog_name), 403); |
|
| 647 | 647 | |
| 648 | - $output = '<p>' . sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ) . '</p>'; |
|
| 649 | - $output .= '<p>' . __( 'If you reached this screen by accident and meant to visit one of your own sites, here are some shortcuts to help you find your way.' ) . '</p>'; |
|
| 648 | + $output = '<p>'.sprintf(__('You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.'), $blog_name).'</p>'; |
|
| 649 | + $output .= '<p>'.__('If you reached this screen by accident and meant to visit one of your own sites, here are some shortcuts to help you find your way.').'</p>'; |
|
| 650 | 650 | |
| 651 | - $output .= '<h3>' . __('Your Sites') . '</h3>'; |
|
| 651 | + $output .= '<h3>'.__('Your Sites').'</h3>'; |
|
| 652 | 652 | $output .= '<table>'; |
| 653 | 653 | |
| 654 | - foreach ( $blogs as $blog ) { |
|
| 654 | + foreach ($blogs as $blog) { |
|
| 655 | 655 | $output .= '<tr>'; |
| 656 | 656 | $output .= "<td>{$blog->blogname}</td>"; |
| 657 | - $output .= '<td><a href="' . esc_url( get_admin_url( $blog->userblog_id ) ) . '">' . __( 'Visit Dashboard' ) . '</a> | ' . |
|
| 658 | - '<a href="' . esc_url( get_home_url( $blog->userblog_id ) ). '">' . __( 'View Site' ) . '</a></td>'; |
|
| 657 | + $output .= '<td><a href="'.esc_url(get_admin_url($blog->userblog_id)).'">'.__('Visit Dashboard').'</a> | '. |
|
| 658 | + '<a href="'.esc_url(get_home_url($blog->userblog_id)).'">'.__('View Site').'</a></td>'; |
|
| 659 | 659 | $output .= '</tr>'; |
| 660 | 660 | } |
| 661 | 661 | |
| 662 | 662 | $output .= '</table>'; |
| 663 | 663 | |
| 664 | - wp_die( $output, 403 ); |
|
| 664 | + wp_die($output, 403); |
|
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | /** |
@@ -672,8 +672,8 @@ discard block |
||
| 672 | 672 | * @param string $permission A permission to be checked. Currently not used. |
| 673 | 673 | * @return bool True if the user has proper permissions, false if they do not. |
| 674 | 674 | */ |
| 675 | -function check_import_new_users( $permission ) { |
|
| 676 | - if ( !is_super_admin() ) |
|
| 675 | +function check_import_new_users($permission) { |
|
| 676 | + if ( ! is_super_admin()) |
|
| 677 | 677 | return false; |
| 678 | 678 | return true; |
| 679 | 679 | } |
@@ -687,33 +687,33 @@ discard block |
||
| 687 | 687 | * @param array $lang_files Optional. An array of the language files. Default empty array. |
| 688 | 688 | * @param string $current Optional. The current language code. Default empty. |
| 689 | 689 | */ |
| 690 | -function mu_dropdown_languages( $lang_files = array(), $current = '' ) { |
|
| 690 | +function mu_dropdown_languages($lang_files = array(), $current = '') { |
|
| 691 | 691 | $flag = false; |
| 692 | 692 | $output = array(); |
| 693 | 693 | |
| 694 | - foreach ( (array) $lang_files as $val ) { |
|
| 695 | - $code_lang = basename( $val, '.mo' ); |
|
| 694 | + foreach ((array) $lang_files as $val) { |
|
| 695 | + $code_lang = basename($val, '.mo'); |
|
| 696 | 696 | |
| 697 | - if ( $code_lang == 'en_US' ) { // American English |
|
| 697 | + if ($code_lang == 'en_US') { // American English |
|
| 698 | 698 | $flag = true; |
| 699 | - $ae = __( 'American English' ); |
|
| 700 | - $output[$ae] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . $ae . '</option>'; |
|
| 701 | - } elseif ( $code_lang == 'en_GB' ) { // British English |
|
| 699 | + $ae = __('American English'); |
|
| 700 | + $output[$ae] = '<option value="'.esc_attr($code_lang).'"'.selected($current, $code_lang, false).'> '.$ae.'</option>'; |
|
| 701 | + } elseif ($code_lang == 'en_GB') { // British English |
|
| 702 | 702 | $flag = true; |
| 703 | - $be = __( 'British English' ); |
|
| 704 | - $output[$be] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . $be . '</option>'; |
|
| 703 | + $be = __('British English'); |
|
| 704 | + $output[$be] = '<option value="'.esc_attr($code_lang).'"'.selected($current, $code_lang, false).'> '.$be.'</option>'; |
|
| 705 | 705 | } else { |
| 706 | - $translated = format_code_lang( $code_lang ); |
|
| 707 | - $output[$translated] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . esc_html ( $translated ) . '</option>'; |
|
| 706 | + $translated = format_code_lang($code_lang); |
|
| 707 | + $output[$translated] = '<option value="'.esc_attr($code_lang).'"'.selected($current, $code_lang, false).'> '.esc_html($translated).'</option>'; |
|
| 708 | 708 | } |
| 709 | 709 | |
| 710 | 710 | } |
| 711 | 711 | |
| 712 | - if ( $flag === false ) // WordPress english |
|
| 713 | - $output[] = '<option value=""' . selected( $current, '', false ) . '>' . __( 'English' ) . "</option>"; |
|
| 712 | + if ($flag === false) // WordPress english |
|
| 713 | + $output[] = '<option value=""'.selected($current, '', false).'>'.__('English')."</option>"; |
|
| 714 | 714 | |
| 715 | 715 | // Order by name |
| 716 | - uksort( $output, 'strnatcasecmp' ); |
|
| 716 | + uksort($output, 'strnatcasecmp'); |
|
| 717 | 717 | |
| 718 | 718 | /** |
| 719 | 719 | * Filter the languages available in the dropdown. |
@@ -724,9 +724,9 @@ discard block |
||
| 724 | 724 | * @param array $lang_files Available language files. |
| 725 | 725 | * @param string $current The current language code. |
| 726 | 726 | */ |
| 727 | - $output = apply_filters( 'mu_dropdown_languages', $output, $lang_files, $current ); |
|
| 727 | + $output = apply_filters('mu_dropdown_languages', $output, $lang_files, $current); |
|
| 728 | 728 | |
| 729 | - echo implode( "\n\t", $output ); |
|
| 729 | + echo implode("\n\t", $output); |
|
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | /** |
@@ -740,10 +740,10 @@ discard block |
||
| 740 | 740 | */ |
| 741 | 741 | function site_admin_notice() { |
| 742 | 742 | global $wp_db_version; |
| 743 | - if ( !is_super_admin() ) |
|
| 743 | + if ( ! is_super_admin()) |
|
| 744 | 744 | return false; |
| 745 | - if ( get_site_option( 'wpmu_upgrade_site' ) != $wp_db_version ) |
|
| 746 | - echo "<div class='update-nag'>" . sprintf( __( 'Thank you for Updating! Please visit the <a href="%s">Upgrade Network</a> page to update all your sites.' ), esc_url( network_admin_url( 'upgrade.php' ) ) ) . "</div>"; |
|
| 745 | + if (get_site_option('wpmu_upgrade_site') != $wp_db_version) |
|
| 746 | + echo "<div class='update-nag'>".sprintf(__('Thank you for Updating! Please visit the <a href="%s">Upgrade Network</a> page to update all your sites.'), esc_url(network_admin_url('upgrade.php')))."</div>"; |
|
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | /** |
@@ -758,23 +758,23 @@ discard block |
||
| 758 | 758 | * @param array $postarr An array of posts. Not currently used. |
| 759 | 759 | * @return array The new array of post data after checking for collisions. |
| 760 | 760 | */ |
| 761 | -function avoid_blog_page_permalink_collision( $data, $postarr ) { |
|
| 762 | - if ( is_subdomain_install() ) |
|
| 761 | +function avoid_blog_page_permalink_collision($data, $postarr) { |
|
| 762 | + if (is_subdomain_install()) |
|
| 763 | 763 | return $data; |
| 764 | - if ( $data['post_type'] != 'page' ) |
|
| 764 | + if ($data['post_type'] != 'page') |
|
| 765 | 765 | return $data; |
| 766 | - if ( !isset( $data['post_name'] ) || $data['post_name'] == '' ) |
|
| 766 | + if ( ! isset($data['post_name']) || $data['post_name'] == '') |
|
| 767 | 767 | return $data; |
| 768 | - if ( !is_main_site() ) |
|
| 768 | + if ( ! is_main_site()) |
|
| 769 | 769 | return $data; |
| 770 | 770 | |
| 771 | 771 | $post_name = $data['post_name']; |
| 772 | 772 | $c = 0; |
| 773 | - while( $c < 10 && get_id_from_blogname( $post_name ) ) { |
|
| 774 | - $post_name .= mt_rand( 1, 10 ); |
|
| 775 | - $c ++; |
|
| 773 | + while ($c < 10 && get_id_from_blogname($post_name)) { |
|
| 774 | + $post_name .= mt_rand(1, 10); |
|
| 775 | + $c++; |
|
| 776 | 776 | } |
| 777 | - if ( $post_name != $data['post_name'] ) { |
|
| 777 | + if ($post_name != $data['post_name']) { |
|
| 778 | 778 | $data['post_name'] = $post_name; |
| 779 | 779 | } |
| 780 | 780 | return $data; |
@@ -793,45 +793,45 @@ discard block |
||
| 793 | 793 | <table class="form-table"> |
| 794 | 794 | <tr> |
| 795 | 795 | <?php /* translators: My sites label */ ?> |
| 796 | - <th scope="row"><label for="primary_blog"><?php _e( 'Primary Site' ); ?></label></th> |
|
| 796 | + <th scope="row"><label for="primary_blog"><?php _e('Primary Site'); ?></label></th> |
|
| 797 | 797 | <td> |
| 798 | 798 | <?php |
| 799 | - $all_blogs = get_blogs_of_user( get_current_user_id() ); |
|
| 800 | - $primary_blog = get_user_meta( get_current_user_id(), 'primary_blog', true ); |
|
| 801 | - if ( count( $all_blogs ) > 1 ) { |
|
| 799 | + $all_blogs = get_blogs_of_user(get_current_user_id()); |
|
| 800 | + $primary_blog = get_user_meta(get_current_user_id(), 'primary_blog', true); |
|
| 801 | + if (count($all_blogs) > 1) { |
|
| 802 | 802 | $found = false; |
| 803 | 803 | ?> |
| 804 | 804 | <select name="primary_blog" id="primary_blog"> |
| 805 | - <?php foreach( (array) $all_blogs as $blog ) { |
|
| 806 | - if ( $primary_blog == $blog->userblog_id ) |
|
| 805 | + <?php foreach ((array) $all_blogs as $blog) { |
|
| 806 | + if ($primary_blog == $blog->userblog_id) |
|
| 807 | 807 | $found = true; |
| 808 | - ?><option value="<?php echo $blog->userblog_id ?>"<?php selected( $primary_blog, $blog->userblog_id ); ?>><?php echo esc_url( get_home_url( $blog->userblog_id ) ) ?></option><?php |
|
| 808 | + ?><option value="<?php echo $blog->userblog_id ?>"<?php selected($primary_blog, $blog->userblog_id); ?>><?php echo esc_url(get_home_url($blog->userblog_id)) ?></option><?php |
|
| 809 | 809 | } ?> |
| 810 | 810 | </select> |
| 811 | 811 | <?php |
| 812 | - if ( !$found ) { |
|
| 813 | - $blog = reset( $all_blogs ); |
|
| 814 | - update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id ); |
|
| 812 | + if ( ! $found) { |
|
| 813 | + $blog = reset($all_blogs); |
|
| 814 | + update_user_meta(get_current_user_id(), 'primary_blog', $blog->userblog_id); |
|
| 815 | 815 | } |
| 816 | - } elseif ( count( $all_blogs ) == 1 ) { |
|
| 817 | - $blog = reset( $all_blogs ); |
|
| 818 | - echo esc_url( get_home_url( $blog->userblog_id ) ); |
|
| 819 | - if ( $primary_blog != $blog->userblog_id ) // Set the primary blog again if it's out of sync with blog list. |
|
| 820 | - update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id ); |
|
| 816 | + } elseif (count($all_blogs) == 1) { |
|
| 817 | + $blog = reset($all_blogs); |
|
| 818 | + echo esc_url(get_home_url($blog->userblog_id)); |
|
| 819 | + if ($primary_blog != $blog->userblog_id) // Set the primary blog again if it's out of sync with blog list. |
|
| 820 | + update_user_meta(get_current_user_id(), 'primary_blog', $blog->userblog_id); |
|
| 821 | 821 | } else { |
| 822 | 822 | echo "N/A"; |
| 823 | 823 | } |
| 824 | 824 | ?> |
| 825 | 825 | </td> |
| 826 | 826 | </tr> |
| 827 | - <?php if ( in_array( get_site_option( 'registration' ), array( 'all', 'blog' ) ) ) : ?> |
|
| 827 | + <?php if (in_array(get_site_option('registration'), array('all', 'blog'))) : ?> |
|
| 828 | 828 | <tr> |
| 829 | 829 | <th scope="row" colspan="2" class="th-full"> |
| 830 | 830 | <?php |
| 831 | 831 | /** This filter is documented in wp-login.php */ |
| 832 | - $sign_up_url = apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) ); |
|
| 832 | + $sign_up_url = apply_filters('wp_signup_location', network_site_url('wp-signup.php')); |
|
| 833 | 833 | ?> |
| 834 | - <a href="<?php echo esc_url( $sign_up_url ); ?>"><?php _e( 'Create a New Site' ); ?></a> |
|
| 834 | + <a href="<?php echo esc_url($sign_up_url); ?>"><?php _e('Create a New Site'); ?></a> |
|
| 835 | 835 | </th> |
| 836 | 836 | </tr> |
| 837 | 837 | <?php endif; ?> |
@@ -850,9 +850,9 @@ discard block |
||
| 850 | 850 | * @return bool True on success, false on failure. This can fail when the user is |
| 851 | 851 | * already a super admin or when the `$super_admins` global is defined. |
| 852 | 852 | */ |
| 853 | -function grant_super_admin( $user_id ) { |
|
| 853 | +function grant_super_admin($user_id) { |
|
| 854 | 854 | // If global super_admins override is defined, there is nothing to do here. |
| 855 | - if ( isset( $GLOBALS['super_admins'] ) ) { |
|
| 855 | + if (isset($GLOBALS['super_admins'])) { |
|
| 856 | 856 | return false; |
| 857 | 857 | } |
| 858 | 858 | |
@@ -863,15 +863,15 @@ discard block |
||
| 863 | 863 | * |
| 864 | 864 | * @param int $user_id ID of the user that is about to be granted Super Admin privileges. |
| 865 | 865 | */ |
| 866 | - do_action( 'grant_super_admin', $user_id ); |
|
| 866 | + do_action('grant_super_admin', $user_id); |
|
| 867 | 867 | |
| 868 | 868 | // Directly fetch site_admins instead of using get_super_admins() |
| 869 | - $super_admins = get_site_option( 'site_admins', array( 'admin' ) ); |
|
| 869 | + $super_admins = get_site_option('site_admins', array('admin')); |
|
| 870 | 870 | |
| 871 | - $user = get_userdata( $user_id ); |
|
| 872 | - if ( $user && ! in_array( $user->user_login, $super_admins ) ) { |
|
| 871 | + $user = get_userdata($user_id); |
|
| 872 | + if ($user && ! in_array($user->user_login, $super_admins)) { |
|
| 873 | 873 | $super_admins[] = $user->user_login; |
| 874 | - update_site_option( 'site_admins' , $super_admins ); |
|
| 874 | + update_site_option('site_admins', $super_admins); |
|
| 875 | 875 | |
| 876 | 876 | /** |
| 877 | 877 | * Fires after the user is granted Super Admin privileges. |
@@ -880,7 +880,7 @@ discard block |
||
| 880 | 880 | * |
| 881 | 881 | * @param int $user_id ID of the user that was granted Super Admin privileges. |
| 882 | 882 | */ |
| 883 | - do_action( 'granted_super_admin', $user_id ); |
|
| 883 | + do_action('granted_super_admin', $user_id); |
|
| 884 | 884 | return true; |
| 885 | 885 | } |
| 886 | 886 | return false; |
@@ -897,9 +897,9 @@ discard block |
||
| 897 | 897 | * @return bool True on success, false on failure. This can fail when the user's email |
| 898 | 898 | * is the network admin email or when the `$super_admins` global is defined. |
| 899 | 899 | */ |
| 900 | -function revoke_super_admin( $user_id ) { |
|
| 900 | +function revoke_super_admin($user_id) { |
|
| 901 | 901 | // If global super_admins override is defined, there is nothing to do here. |
| 902 | - if ( isset( $GLOBALS['super_admins'] ) ) { |
|
| 902 | + if (isset($GLOBALS['super_admins'])) { |
|
| 903 | 903 | return false; |
| 904 | 904 | } |
| 905 | 905 | |
@@ -910,16 +910,16 @@ discard block |
||
| 910 | 910 | * |
| 911 | 911 | * @param int $user_id ID of the user Super Admin privileges are being revoked from. |
| 912 | 912 | */ |
| 913 | - do_action( 'revoke_super_admin', $user_id ); |
|
| 913 | + do_action('revoke_super_admin', $user_id); |
|
| 914 | 914 | |
| 915 | 915 | // Directly fetch site_admins instead of using get_super_admins() |
| 916 | - $super_admins = get_site_option( 'site_admins', array( 'admin' ) ); |
|
| 916 | + $super_admins = get_site_option('site_admins', array('admin')); |
|
| 917 | 917 | |
| 918 | - $user = get_userdata( $user_id ); |
|
| 919 | - if ( $user && 0 !== strcasecmp( $user->user_email, get_site_option( 'admin_email' ) ) ) { |
|
| 920 | - if ( false !== ( $key = array_search( $user->user_login, $super_admins ) ) ) { |
|
| 921 | - unset( $super_admins[$key] ); |
|
| 922 | - update_site_option( 'site_admins', $super_admins ); |
|
| 918 | + $user = get_userdata($user_id); |
|
| 919 | + if ($user && 0 !== strcasecmp($user->user_email, get_site_option('admin_email'))) { |
|
| 920 | + if (false !== ($key = array_search($user->user_login, $super_admins))) { |
|
| 921 | + unset($super_admins[$key]); |
|
| 922 | + update_site_option('site_admins', $super_admins); |
|
| 923 | 923 | |
| 924 | 924 | /** |
| 925 | 925 | * Fires after the user's Super Admin privileges are revoked. |
@@ -928,7 +928,7 @@ discard block |
||
| 928 | 928 | * |
| 929 | 929 | * @param int $user_id ID of the user Super Admin privileges were revoked from. |
| 930 | 930 | */ |
| 931 | - do_action( 'revoked_super_admin', $user_id ); |
|
| 931 | + do_action('revoked_super_admin', $user_id); |
|
| 932 | 932 | return true; |
| 933 | 933 | } |
| 934 | 934 | } |
@@ -948,10 +948,10 @@ discard block |
||
| 948 | 948 | * @param int $site_id The network/site ID to check. |
| 949 | 949 | * @return bool True if network can be edited, otherwise false. |
| 950 | 950 | */ |
| 951 | -function can_edit_network( $site_id ) { |
|
| 951 | +function can_edit_network($site_id) { |
|
| 952 | 952 | global $wpdb; |
| 953 | 953 | |
| 954 | - if ( $site_id == $wpdb->siteid ) |
|
| 954 | + if ($site_id == $wpdb->siteid) |
|
| 955 | 955 | $result = true; |
| 956 | 956 | else |
| 957 | 957 | $result = false; |
@@ -964,7 +964,7 @@ discard block |
||
| 964 | 964 | * @param bool $result Whether the network can be edited from this page. |
| 965 | 965 | * @param int $site_id The network/site ID to check. |
| 966 | 966 | */ |
| 967 | - return apply_filters( 'can_edit_network', $result, $site_id ); |
|
| 967 | + return apply_filters('can_edit_network', $result, $site_id); |
|
| 968 | 968 | } |
| 969 | 969 | |
| 970 | 970 | /** |
@@ -977,7 +977,7 @@ discard block |
||
| 977 | 977 | function _thickbox_path_admin_subfolder() { |
| 978 | 978 | ?> |
| 979 | 979 | <script type="text/javascript"> |
| 980 | -var tb_pathToImage = "<?php echo includes_url( 'js/thickbox/loadingAnimation.gif', 'relative' ); ?>"; |
|
| 980 | +var tb_pathToImage = "<?php echo includes_url('js/thickbox/loadingAnimation.gif', 'relative'); ?>"; |
|
| 981 | 981 | </script> |
| 982 | 982 | <?php |
| 983 | 983 | } |
@@ -16,22 +16,28 @@ discard block |
||
| 16 | 16 | * @return array $_FILES array with 'error' key set if file exceeds quota. 'error' is empty otherwise. |
| 17 | 17 | */ |
| 18 | 18 | function check_upload_size( $file ) { |
| 19 | - if ( get_site_option( 'upload_space_check_disabled' ) ) |
|
| 20 | - return $file; |
|
| 19 | + if ( get_site_option( 'upload_space_check_disabled' ) ) { |
|
| 20 | + return $file; |
|
| 21 | + } |
|
| 21 | 22 | |
| 22 | - if ( $file['error'] != '0' ) // there's already an error |
|
| 23 | + if ( $file['error'] != '0' ) { |
|
| 24 | + // there's already an error |
|
| 23 | 25 | return $file; |
| 26 | + } |
|
| 24 | 27 | |
| 25 | - if ( defined( 'WP_IMPORTING' ) ) |
|
| 26 | - return $file; |
|
| 28 | + if ( defined( 'WP_IMPORTING' ) ) { |
|
| 29 | + return $file; |
|
| 30 | + } |
|
| 27 | 31 | |
| 28 | 32 | $space_left = get_upload_space_available(); |
| 29 | 33 | |
| 30 | 34 | $file_size = filesize( $file['tmp_name'] ); |
| 31 | - if ( $space_left < $file_size ) |
|
| 32 | - $file['error'] = sprintf( __( 'Not enough space to upload. %1$s KB needed.' ), number_format( ($file_size - $space_left) /1024 ) ); |
|
| 33 | - if ( $file_size > ( 1024 * get_site_option( 'fileupload_maxk', 1500 ) ) ) |
|
| 34 | - $file['error'] = sprintf(__('This file is too big. Files must be less than %1$s KB in size.'), get_site_option( 'fileupload_maxk', 1500 ) ); |
|
| 35 | + if ( $space_left < $file_size ) { |
|
| 36 | + $file['error'] = sprintf( __( 'Not enough space to upload. %1$s KB needed.' ), number_format( ($file_size - $space_left) /1024 ) ); |
|
| 37 | + } |
|
| 38 | + if ( $file_size > ( 1024 * get_site_option( 'fileupload_maxk', 1500 ) ) ) { |
|
| 39 | + $file['error'] = sprintf(__('This file is too big. Files must be less than %1$s KB in size.'), get_site_option( 'fileupload_maxk', 1500 ) ); |
|
| 40 | + } |
|
| 35 | 41 | if ( upload_is_user_over_quota( false ) ) { |
| 36 | 42 | $file['error'] = __( 'You have used your space quota. Please delete files before uploading.' ); |
| 37 | 43 | } |
@@ -143,8 +149,9 @@ discard block |
||
| 143 | 149 | $dh = @opendir( $dir ); |
| 144 | 150 | if ( $dh ) { |
| 145 | 151 | while ( ( $file = @readdir( $dh ) ) !== false ) { |
| 146 | - if ( $file == '.' || $file == '..' ) |
|
| 147 | - continue; |
|
| 152 | + if ( $file == '.' || $file == '..' ) { |
|
| 153 | + continue; |
|
| 154 | + } |
|
| 148 | 155 | |
| 149 | 156 | if ( @is_dir( $dir . DIRECTORY_SEPARATOR . $file ) ) { |
| 150 | 157 | $stack[] = $dir . DIRECTORY_SEPARATOR . $file; |
@@ -159,16 +166,18 @@ discard block |
||
| 159 | 166 | |
| 160 | 167 | $stack = array_reverse( $stack ); // Last added dirs are deepest |
| 161 | 168 | foreach( (array) $stack as $dir ) { |
| 162 | - if ( $dir != $top_dir) |
|
| 163 | - @rmdir( $dir ); |
|
| 169 | + if ( $dir != $top_dir) { |
|
| 170 | + @rmdir( $dir ); |
|
| 171 | + } |
|
| 164 | 172 | } |
| 165 | 173 | |
| 166 | 174 | clean_blog_cache( $blog ); |
| 167 | 175 | } |
| 168 | 176 | |
| 169 | - if ( $switch ) |
|
| 170 | - restore_current_blog(); |
|
| 171 | -} |
|
| 177 | + if ( $switch ) { |
|
| 178 | + restore_current_blog(); |
|
| 179 | + } |
|
| 180 | + } |
|
| 172 | 181 | |
| 173 | 182 | /** |
| 174 | 183 | * Delete a user from the network and remove from all sites. |
@@ -188,8 +197,9 @@ discard block |
||
| 188 | 197 | $id = (int) $id; |
| 189 | 198 | $user = new WP_User( $id ); |
| 190 | 199 | |
| 191 | - if ( !$user->exists() ) |
|
| 192 | - return false; |
|
| 200 | + if ( !$user->exists() ) { |
|
| 201 | + return false; |
|
| 202 | + } |
|
| 193 | 203 | |
| 194 | 204 | // Global super-administrators are protected, and cannot be deleted. |
| 195 | 205 | $_super_admins = get_super_admins(); |
@@ -222,8 +232,9 @@ discard block |
||
| 222 | 232 | $link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) ); |
| 223 | 233 | |
| 224 | 234 | if ( $link_ids ) { |
| 225 | - foreach ( $link_ids as $link_id ) |
|
| 226 | - wp_delete_link( $link_id ); |
|
| 235 | + foreach ( $link_ids as $link_id ) { |
|
| 236 | + wp_delete_link( $link_id ); |
|
| 237 | + } |
|
| 227 | 238 | } |
| 228 | 239 | |
| 229 | 240 | restore_current_blog(); |
@@ -231,8 +242,9 @@ discard block |
||
| 231 | 242 | } |
| 232 | 243 | |
| 233 | 244 | $meta = $wpdb->get_col( $wpdb->prepare( "SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d", $id ) ); |
| 234 | - foreach ( $meta as $mid ) |
|
| 235 | - delete_metadata_by_mid( 'user', $mid ); |
|
| 245 | + foreach ( $meta as $mid ) { |
|
| 246 | + delete_metadata_by_mid( 'user', $mid ); |
|
| 247 | + } |
|
| 236 | 248 | |
| 237 | 249 | $wpdb->delete( $wpdb->users, array( 'ID' => $id ) ); |
| 238 | 250 | |
@@ -253,8 +265,9 @@ discard block |
||
| 253 | 265 | * @param string $value The new email address. |
| 254 | 266 | */ |
| 255 | 267 | function update_option_new_admin_email( $old_value, $value ) { |
| 256 | - if ( $value == get_option( 'admin_email' ) || !is_email( $value ) ) |
|
| 257 | - return; |
|
| 268 | + if ( $value == get_option( 'admin_email' ) || !is_email( $value ) ) { |
|
| 269 | + return; |
|
| 270 | + } |
|
| 258 | 271 | |
| 259 | 272 | $hash = md5( $value. time() .mt_rand() ); |
| 260 | 273 | $new_admin_email = array( |
@@ -319,11 +332,13 @@ discard block |
||
| 319 | 332 | function send_confirmation_on_profile_email() { |
| 320 | 333 | global $errors, $wpdb; |
| 321 | 334 | $current_user = wp_get_current_user(); |
| 322 | - if ( ! is_object($errors) ) |
|
| 323 | - $errors = new WP_Error(); |
|
| 335 | + if ( ! is_object($errors) ) { |
|
| 336 | + $errors = new WP_Error(); |
|
| 337 | + } |
|
| 324 | 338 | |
| 325 | - if ( $current_user->ID != $_POST['user_id'] ) |
|
| 326 | - return false; |
|
| 339 | + if ( $current_user->ID != $_POST['user_id'] ) { |
|
| 340 | + return false; |
|
| 341 | + } |
|
| 327 | 342 | |
| 328 | 343 | if ( $current_user->user_email != $_POST['email'] ) { |
| 329 | 344 | if ( !is_email( $_POST['email'] ) ) { |
@@ -396,9 +411,10 @@ discard block |
||
| 396 | 411 | * @since 3.0.0 |
| 397 | 412 | */ |
| 398 | 413 | function new_user_email_admin_notice() { |
| 399 | - if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) && isset( $_GET['updated'] ) && $email = get_option( get_current_user_id() . '_new_email' ) ) |
|
| 400 | - echo "<div class='update-nag'>" . sprintf( __( "Your email address has not been updated yet. Please check your inbox at %s for a confirmation email." ), $email['newemail'] ) . "</div>"; |
|
| 401 | -} |
|
| 414 | + if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) && isset( $_GET['updated'] ) && $email = get_option( get_current_user_id() . '_new_email' ) ) { |
|
| 415 | + echo "<div class='update-nag'>" . sprintf( __( "Your email address has not been updated yet. Please check your inbox at %s for a confirmation email." ), $email['newemail'] ) . "</div>"; |
|
| 416 | + } |
|
| 417 | + } |
|
| 402 | 418 | |
| 403 | 419 | /** |
| 404 | 420 | * Check whether a blog has used its allotted upload space. |
@@ -409,18 +425,22 @@ discard block |
||
| 409 | 425 | * @return bool True if user is over upload space quota, otherwise false. |
| 410 | 426 | */ |
| 411 | 427 | function upload_is_user_over_quota( $echo = true ) { |
| 412 | - if ( get_site_option( 'upload_space_check_disabled' ) ) |
|
| 413 | - return false; |
|
| 428 | + if ( get_site_option( 'upload_space_check_disabled' ) ) { |
|
| 429 | + return false; |
|
| 430 | + } |
|
| 414 | 431 | |
| 415 | 432 | $space_allowed = get_space_allowed(); |
| 416 | - if ( empty( $space_allowed ) || !is_numeric( $space_allowed ) ) |
|
| 417 | - $space_allowed = 10; // Default space allowed is 10 MB |
|
| 433 | + if ( empty( $space_allowed ) || !is_numeric( $space_allowed ) ) { |
|
| 434 | + $space_allowed = 10; |
|
| 435 | + } |
|
| 436 | + // Default space allowed is 10 MB |
|
| 418 | 437 | |
| 419 | 438 | $space_used = get_space_used(); |
| 420 | 439 | |
| 421 | 440 | if ( ( $space_allowed - $space_used ) < 0 ) { |
| 422 | - if ( $echo ) |
|
| 423 | - _e( 'Sorry, you have used your space allocation. Please delete some files to upload more files.' ); |
|
| 441 | + if ( $echo ) { |
|
| 442 | + _e( 'Sorry, you have used your space allocation. Please delete some files to upload more files.' ); |
|
| 443 | + } |
|
| 424 | 444 | return true; |
| 425 | 445 | } else { |
| 426 | 446 | return false; |
@@ -480,8 +500,9 @@ discard block |
||
| 480 | 500 | $quota = get_option( 'blog_upload_space' ); |
| 481 | 501 | restore_current_blog(); |
| 482 | 502 | |
| 483 | - if ( !$quota ) |
|
| 484 | - $quota = ''; |
|
| 503 | + if ( !$quota ) { |
|
| 504 | + $quota = ''; |
|
| 505 | + } |
|
| 485 | 506 | |
| 486 | 507 | ?> |
| 487 | 508 | <tr> |
@@ -513,8 +534,9 @@ discard block |
||
| 513 | 534 | function update_user_status( $id, $pref, $value, $deprecated = null ) { |
| 514 | 535 | global $wpdb; |
| 515 | 536 | |
| 516 | - if ( null !== $deprecated ) |
|
| 517 | - _deprecated_argument( __FUNCTION__, '3.1' ); |
|
| 537 | + if ( null !== $deprecated ) { |
|
| 538 | + _deprecated_argument( __FUNCTION__, '3.1' ); |
|
| 539 | + } |
|
| 518 | 540 | |
| 519 | 541 | $wpdb->update( $wpdb->users, array( sanitize_key( $pref ) => $value ), array( 'ID' => $id ) ); |
| 520 | 542 | |
@@ -557,8 +579,9 @@ discard block |
||
| 557 | 579 | function refresh_user_details( $id ) { |
| 558 | 580 | $id = (int) $id; |
| 559 | 581 | |
| 560 | - if ( !$user = get_userdata( $id ) ) |
|
| 561 | - return false; |
|
| 582 | + if ( !$user = get_userdata( $id ) ) { |
|
| 583 | + return false; |
|
| 584 | + } |
|
| 562 | 585 | |
| 563 | 586 | clean_user_cache( $user ); |
| 564 | 587 | |
@@ -632,18 +655,21 @@ discard block |
||
| 632 | 655 | * @access private |
| 633 | 656 | */ |
| 634 | 657 | function _access_denied_splash() { |
| 635 | - if ( ! is_user_logged_in() || is_network_admin() ) |
|
| 636 | - return; |
|
| 658 | + if ( ! is_user_logged_in() || is_network_admin() ) { |
|
| 659 | + return; |
|
| 660 | + } |
|
| 637 | 661 | |
| 638 | 662 | $blogs = get_blogs_of_user( get_current_user_id() ); |
| 639 | 663 | |
| 640 | - if ( wp_list_filter( $blogs, array( 'userblog_id' => get_current_blog_id() ) ) ) |
|
| 641 | - return; |
|
| 664 | + if ( wp_list_filter( $blogs, array( 'userblog_id' => get_current_blog_id() ) ) ) { |
|
| 665 | + return; |
|
| 666 | + } |
|
| 642 | 667 | |
| 643 | 668 | $blog_name = get_bloginfo( 'name' ); |
| 644 | 669 | |
| 645 | - if ( empty( $blogs ) ) |
|
| 646 | - wp_die( sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ), 403 ); |
|
| 670 | + if ( empty( $blogs ) ) { |
|
| 671 | + wp_die( sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ), 403 ); |
|
| 672 | + } |
|
| 647 | 673 | |
| 648 | 674 | $output = '<p>' . sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ) . '</p>'; |
| 649 | 675 | $output .= '<p>' . __( 'If you reached this screen by accident and meant to visit one of your own sites, here are some shortcuts to help you find your way.' ) . '</p>'; |
@@ -673,8 +699,9 @@ discard block |
||
| 673 | 699 | * @return bool True if the user has proper permissions, false if they do not. |
| 674 | 700 | */ |
| 675 | 701 | function check_import_new_users( $permission ) { |
| 676 | - if ( !is_super_admin() ) |
|
| 677 | - return false; |
|
| 702 | + if ( !is_super_admin() ) { |
|
| 703 | + return false; |
|
| 704 | + } |
|
| 678 | 705 | return true; |
| 679 | 706 | } |
| 680 | 707 | // See "import_allow_fetch_attachments" and "import_attachment_size_limit" filters too. |
@@ -709,8 +736,10 @@ discard block |
||
| 709 | 736 | |
| 710 | 737 | } |
| 711 | 738 | |
| 712 | - if ( $flag === false ) // WordPress english |
|
| 739 | + if ( $flag === false ) { |
|
| 740 | + // WordPress english |
|
| 713 | 741 | $output[] = '<option value=""' . selected( $current, '', false ) . '>' . __( 'English' ) . "</option>"; |
| 742 | + } |
|
| 714 | 743 | |
| 715 | 744 | // Order by name |
| 716 | 745 | uksort( $output, 'strnatcasecmp' ); |
@@ -740,11 +769,13 @@ discard block |
||
| 740 | 769 | */ |
| 741 | 770 | function site_admin_notice() { |
| 742 | 771 | global $wp_db_version; |
| 743 | - if ( !is_super_admin() ) |
|
| 744 | - return false; |
|
| 745 | - if ( get_site_option( 'wpmu_upgrade_site' ) != $wp_db_version ) |
|
| 746 | - echo "<div class='update-nag'>" . sprintf( __( 'Thank you for Updating! Please visit the <a href="%s">Upgrade Network</a> page to update all your sites.' ), esc_url( network_admin_url( 'upgrade.php' ) ) ) . "</div>"; |
|
| 747 | -} |
|
| 772 | + if ( !is_super_admin() ) { |
|
| 773 | + return false; |
|
| 774 | + } |
|
| 775 | + if ( get_site_option( 'wpmu_upgrade_site' ) != $wp_db_version ) { |
|
| 776 | + echo "<div class='update-nag'>" . sprintf( __( 'Thank you for Updating! Please visit the <a href="%s">Upgrade Network</a> page to update all your sites.' ), esc_url( network_admin_url( 'upgrade.php' ) ) ) . "</div>"; |
|
| 777 | + } |
|
| 778 | + } |
|
| 748 | 779 | |
| 749 | 780 | /** |
| 750 | 781 | * Avoids a collision between a site slug and a permalink slug. |
@@ -759,14 +790,18 @@ discard block |
||
| 759 | 790 | * @return array The new array of post data after checking for collisions. |
| 760 | 791 | */ |
| 761 | 792 | function avoid_blog_page_permalink_collision( $data, $postarr ) { |
| 762 | - if ( is_subdomain_install() ) |
|
| 763 | - return $data; |
|
| 764 | - if ( $data['post_type'] != 'page' ) |
|
| 765 | - return $data; |
|
| 766 | - if ( !isset( $data['post_name'] ) || $data['post_name'] == '' ) |
|
| 767 | - return $data; |
|
| 768 | - if ( !is_main_site() ) |
|
| 769 | - return $data; |
|
| 793 | + if ( is_subdomain_install() ) { |
|
| 794 | + return $data; |
|
| 795 | + } |
|
| 796 | + if ( $data['post_type'] != 'page' ) { |
|
| 797 | + return $data; |
|
| 798 | + } |
|
| 799 | + if ( !isset( $data['post_name'] ) || $data['post_name'] == '' ) { |
|
| 800 | + return $data; |
|
| 801 | + } |
|
| 802 | + if ( !is_main_site() ) { |
|
| 803 | + return $data; |
|
| 804 | + } |
|
| 770 | 805 | |
| 771 | 806 | $post_name = $data['post_name']; |
| 772 | 807 | $c = 0; |
@@ -803,8 +838,9 @@ discard block |
||
| 803 | 838 | ?> |
| 804 | 839 | <select name="primary_blog" id="primary_blog"> |
| 805 | 840 | <?php foreach( (array) $all_blogs as $blog ) { |
| 806 | - if ( $primary_blog == $blog->userblog_id ) |
|
| 807 | - $found = true; |
|
| 841 | + if ( $primary_blog == $blog->userblog_id ) { |
|
| 842 | + $found = true; |
|
| 843 | + } |
|
| 808 | 844 | ?><option value="<?php echo $blog->userblog_id ?>"<?php selected( $primary_blog, $blog->userblog_id ); ?>><?php echo esc_url( get_home_url( $blog->userblog_id ) ) ?></option><?php |
| 809 | 845 | } ?> |
| 810 | 846 | </select> |
@@ -816,8 +852,10 @@ discard block |
||
| 816 | 852 | } elseif ( count( $all_blogs ) == 1 ) { |
| 817 | 853 | $blog = reset( $all_blogs ); |
| 818 | 854 | echo esc_url( get_home_url( $blog->userblog_id ) ); |
| 819 | - if ( $primary_blog != $blog->userblog_id ) // Set the primary blog again if it's out of sync with blog list. |
|
| 855 | + if ( $primary_blog != $blog->userblog_id ) { |
|
| 856 | + // Set the primary blog again if it's out of sync with blog list. |
|
| 820 | 857 | update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id ); |
| 858 | + } |
|
| 821 | 859 | } else { |
| 822 | 860 | echo "N/A"; |
| 823 | 861 | } |
@@ -951,10 +989,11 @@ discard block |
||
| 951 | 989 | function can_edit_network( $site_id ) { |
| 952 | 990 | global $wpdb; |
| 953 | 991 | |
| 954 | - if ( $site_id == $wpdb->siteid ) |
|
| 955 | - $result = true; |
|
| 956 | - else |
|
| 957 | - $result = false; |
|
| 992 | + if ( $site_id == $wpdb->siteid ) { |
|
| 993 | + $result = true; |
|
| 994 | + } else { |
|
| 995 | + $result = false; |
|
| 996 | + } |
|
| 958 | 997 | |
| 959 | 998 | /** |
| 960 | 999 | * Filter whether this network can be edited from this page. |
@@ -1282,7 +1282,7 @@ |
||
| 1282 | 1282 | * |
| 1283 | 1283 | * @param int|string $nav_menu_selected_id (id, slug, or name ) of the currently-selected menu |
| 1284 | 1284 | * @param string $nav_menu_selected_title Title of the currently-selected menu |
| 1285 | - * @return array $messages The menu updated message |
|
| 1285 | + * @return string[] $messages The menu updated message |
|
| 1286 | 1286 | */ |
| 1287 | 1287 | function wp_nav_menu_update_menu_items ( $nav_menu_selected_id, $nav_menu_selected_title ) { |
| 1288 | 1288 | $unsorted_menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array( 'orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID', 'post_status' => 'draft,publish' ) ); |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * @param int $depth Depth of menu item. Used for padding. |
| 20 | 20 | * @param array $args Not used. |
| 21 | 21 | */ |
| 22 | - public function start_lvl( &$output, $depth = 0, $args = array() ) {} |
|
| 22 | + public function start_lvl(&$output, $depth = 0, $args = array()) {} |
|
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * Ends the list of after the elements are added. |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * @param int $depth Depth of menu item. Used for padding. |
| 33 | 33 | * @param array $args Not used. |
| 34 | 34 | */ |
| 35 | - public function end_lvl( &$output, $depth = 0, $args = array() ) {} |
|
| 35 | + public function end_lvl(&$output, $depth = 0, $args = array()) {} |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * Start the element output. |
@@ -48,12 +48,12 @@ discard block |
||
| 48 | 48 | * @param array $args Not used. |
| 49 | 49 | * @param int $id Not used. |
| 50 | 50 | */ |
| 51 | - public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { |
|
| 51 | + public function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { |
|
| 52 | 52 | global $_wp_nav_menu_max_depth; |
| 53 | 53 | $_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth; |
| 54 | 54 | |
| 55 | 55 | ob_start(); |
| 56 | - $item_id = esc_attr( $item->ID ); |
|
| 56 | + $item_id = esc_attr($item->ID); |
|
| 57 | 57 | $removed_args = array( |
| 58 | 58 | 'action', |
| 59 | 59 | 'customlink-tab', |
@@ -64,46 +64,46 @@ discard block |
||
| 64 | 64 | ); |
| 65 | 65 | |
| 66 | 66 | $original_title = ''; |
| 67 | - if ( 'taxonomy' == $item->type ) { |
|
| 68 | - $original_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' ); |
|
| 69 | - if ( is_wp_error( $original_title ) ) |
|
| 67 | + if ('taxonomy' == $item->type) { |
|
| 68 | + $original_title = get_term_field('name', $item->object_id, $item->object, 'raw'); |
|
| 69 | + if (is_wp_error($original_title)) |
|
| 70 | 70 | $original_title = false; |
| 71 | - } elseif ( 'post_type' == $item->type ) { |
|
| 72 | - $original_object = get_post( $item->object_id ); |
|
| 73 | - $original_title = get_the_title( $original_object->ID ); |
|
| 71 | + } elseif ('post_type' == $item->type) { |
|
| 72 | + $original_object = get_post($item->object_id); |
|
| 73 | + $original_title = get_the_title($original_object->ID); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | $classes = array( |
| 77 | - 'menu-item menu-item-depth-' . $depth, |
|
| 78 | - 'menu-item-' . esc_attr( $item->object ), |
|
| 79 | - 'menu-item-edit-' . ( ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? 'active' : 'inactive'), |
|
| 77 | + 'menu-item menu-item-depth-'.$depth, |
|
| 78 | + 'menu-item-'.esc_attr($item->object), |
|
| 79 | + 'menu-item-edit-'.((isset($_GET['edit-menu-item']) && $item_id == $_GET['edit-menu-item']) ? 'active' : 'inactive'), |
|
| 80 | 80 | ); |
| 81 | 81 | |
| 82 | 82 | $title = $item->title; |
| 83 | 83 | |
| 84 | - if ( ! empty( $item->_invalid ) ) { |
|
| 84 | + if ( ! empty($item->_invalid)) { |
|
| 85 | 85 | $classes[] = 'menu-item-invalid'; |
| 86 | 86 | /* translators: %s: title of menu item which is invalid */ |
| 87 | - $title = sprintf( __( '%s (Invalid)' ), $item->title ); |
|
| 88 | - } elseif ( isset( $item->post_status ) && 'draft' == $item->post_status ) { |
|
| 87 | + $title = sprintf(__('%s (Invalid)'), $item->title); |
|
| 88 | + } elseif (isset($item->post_status) && 'draft' == $item->post_status) { |
|
| 89 | 89 | $classes[] = 'pending'; |
| 90 | 90 | /* translators: %s: title of menu item in draft status */ |
| 91 | - $title = sprintf( __('%s (Pending)'), $item->title ); |
|
| 91 | + $title = sprintf(__('%s (Pending)'), $item->title); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - $title = ( ! isset( $item->label ) || '' == $item->label ) ? $title : $item->label; |
|
| 94 | + $title = ( ! isset($item->label) || '' == $item->label) ? $title : $item->label; |
|
| 95 | 95 | |
| 96 | 96 | $submenu_text = ''; |
| 97 | - if ( 0 == $depth ) |
|
| 97 | + if (0 == $depth) |
|
| 98 | 98 | $submenu_text = 'style="display: none;"'; |
| 99 | 99 | |
| 100 | 100 | ?> |
| 101 | - <li id="menu-item-<?php echo $item_id; ?>" class="<?php echo implode(' ', $classes ); ?>"> |
|
| 101 | + <li id="menu-item-<?php echo $item_id; ?>" class="<?php echo implode(' ', $classes); ?>"> |
|
| 102 | 102 | <div class="menu-item-bar"> |
| 103 | 103 | <div class="menu-item-handle"> |
| 104 | - <span class="item-title"><span class="menu-item-title"><?php echo esc_html( $title ); ?></span> <span class="is-submenu" <?php echo $submenu_text; ?>><?php _e( 'sub item' ); ?></span></span> |
|
| 104 | + <span class="item-title"><span class="menu-item-title"><?php echo esc_html($title); ?></span> <span class="is-submenu" <?php echo $submenu_text; ?>><?php _e('sub item'); ?></span></span> |
|
| 105 | 105 | <span class="item-controls"> |
| 106 | - <span class="item-type"><?php echo esc_html( $item->type_label ); ?></span> |
|
| 106 | + <span class="item-type"><?php echo esc_html($item->type_label); ?></span> |
|
| 107 | 107 | <span class="item-order hide-if-js"> |
| 108 | 108 | <a href="<?php |
| 109 | 109 | echo wp_nonce_url( |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | 'action' => 'move-up-menu-item', |
| 113 | 113 | 'menu-item' => $item_id, |
| 114 | 114 | ), |
| 115 | - remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) ) |
|
| 115 | + remove_query_arg($removed_args, admin_url('nav-menus.php')) |
|
| 116 | 116 | ), |
| 117 | 117 | 'move-menu_item' |
| 118 | 118 | ); |
@@ -125,81 +125,81 @@ discard block |
||
| 125 | 125 | 'action' => 'move-down-menu-item', |
| 126 | 126 | 'menu-item' => $item_id, |
| 127 | 127 | ), |
| 128 | - remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) ) |
|
| 128 | + remove_query_arg($removed_args, admin_url('nav-menus.php')) |
|
| 129 | 129 | ), |
| 130 | 130 | 'move-menu_item' |
| 131 | 131 | ); |
| 132 | 132 | ?>" class="item-move-down"><abbr title="<?php esc_attr_e('Move down'); ?>">↓</abbr></a> |
| 133 | 133 | </span> |
| 134 | 134 | <a class="item-edit" id="edit-<?php echo $item_id; ?>" title="<?php esc_attr_e('Edit Menu Item'); ?>" href="<?php |
| 135 | - echo ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? admin_url( 'nav-menus.php' ) : add_query_arg( 'edit-menu-item', $item_id, remove_query_arg( $removed_args, admin_url( 'nav-menus.php#menu-item-settings-' . $item_id ) ) ); |
|
| 136 | - ?>"><?php _e( 'Edit Menu Item' ); ?></a> |
|
| 135 | + echo (isset($_GET['edit-menu-item']) && $item_id == $_GET['edit-menu-item']) ? admin_url('nav-menus.php') : add_query_arg('edit-menu-item', $item_id, remove_query_arg($removed_args, admin_url('nav-menus.php#menu-item-settings-'.$item_id))); |
|
| 136 | + ?>"><?php _e('Edit Menu Item'); ?></a> |
|
| 137 | 137 | </span> |
| 138 | 138 | </div> |
| 139 | 139 | </div> |
| 140 | 140 | |
| 141 | 141 | <div class="menu-item-settings" id="menu-item-settings-<?php echo $item_id; ?>"> |
| 142 | - <?php if ( 'custom' == $item->type ) : ?> |
|
| 142 | + <?php if ('custom' == $item->type) : ?> |
|
| 143 | 143 | <p class="field-url description description-wide"> |
| 144 | 144 | <label for="edit-menu-item-url-<?php echo $item_id; ?>"> |
| 145 | - <?php _e( 'URL' ); ?><br /> |
|
| 146 | - <input type="text" id="edit-menu-item-url-<?php echo $item_id; ?>" class="widefat code edit-menu-item-url" name="menu-item-url[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->url ); ?>" /> |
|
| 145 | + <?php _e('URL'); ?><br /> |
|
| 146 | + <input type="text" id="edit-menu-item-url-<?php echo $item_id; ?>" class="widefat code edit-menu-item-url" name="menu-item-url[<?php echo $item_id; ?>]" value="<?php echo esc_attr($item->url); ?>" /> |
|
| 147 | 147 | </label> |
| 148 | 148 | </p> |
| 149 | 149 | <?php endif; ?> |
| 150 | 150 | <p class="description description-wide"> |
| 151 | 151 | <label for="edit-menu-item-title-<?php echo $item_id; ?>"> |
| 152 | - <?php _e( 'Navigation Label' ); ?><br /> |
|
| 153 | - <input type="text" id="edit-menu-item-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-title" name="menu-item-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->title ); ?>" /> |
|
| 152 | + <?php _e('Navigation Label'); ?><br /> |
|
| 153 | + <input type="text" id="edit-menu-item-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-title" name="menu-item-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr($item->title); ?>" /> |
|
| 154 | 154 | </label> |
| 155 | 155 | </p> |
| 156 | 156 | <p class="field-title-attribute description description-wide"> |
| 157 | 157 | <label for="edit-menu-item-attr-title-<?php echo $item_id; ?>"> |
| 158 | - <?php _e( 'Title Attribute' ); ?><br /> |
|
| 159 | - <input type="text" id="edit-menu-item-attr-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-attr-title" name="menu-item-attr-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->post_excerpt ); ?>" /> |
|
| 158 | + <?php _e('Title Attribute'); ?><br /> |
|
| 159 | + <input type="text" id="edit-menu-item-attr-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-attr-title" name="menu-item-attr-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr($item->post_excerpt); ?>" /> |
|
| 160 | 160 | </label> |
| 161 | 161 | </p> |
| 162 | 162 | <p class="field-link-target description"> |
| 163 | 163 | <label for="edit-menu-item-target-<?php echo $item_id; ?>"> |
| 164 | - <input type="checkbox" id="edit-menu-item-target-<?php echo $item_id; ?>" value="_blank" name="menu-item-target[<?php echo $item_id; ?>]"<?php checked( $item->target, '_blank' ); ?> /> |
|
| 165 | - <?php _e( 'Open link in a new window/tab' ); ?> |
|
| 164 | + <input type="checkbox" id="edit-menu-item-target-<?php echo $item_id; ?>" value="_blank" name="menu-item-target[<?php echo $item_id; ?>]"<?php checked($item->target, '_blank'); ?> /> |
|
| 165 | + <?php _e('Open link in a new window/tab'); ?> |
|
| 166 | 166 | </label> |
| 167 | 167 | </p> |
| 168 | 168 | <p class="field-css-classes description description-thin"> |
| 169 | 169 | <label for="edit-menu-item-classes-<?php echo $item_id; ?>"> |
| 170 | - <?php _e( 'CSS Classes (optional)' ); ?><br /> |
|
| 171 | - <input type="text" id="edit-menu-item-classes-<?php echo $item_id; ?>" class="widefat code edit-menu-item-classes" name="menu-item-classes[<?php echo $item_id; ?>]" value="<?php echo esc_attr( implode(' ', $item->classes ) ); ?>" /> |
|
| 170 | + <?php _e('CSS Classes (optional)'); ?><br /> |
|
| 171 | + <input type="text" id="edit-menu-item-classes-<?php echo $item_id; ?>" class="widefat code edit-menu-item-classes" name="menu-item-classes[<?php echo $item_id; ?>]" value="<?php echo esc_attr(implode(' ', $item->classes)); ?>" /> |
|
| 172 | 172 | </label> |
| 173 | 173 | </p> |
| 174 | 174 | <p class="field-xfn description description-thin"> |
| 175 | 175 | <label for="edit-menu-item-xfn-<?php echo $item_id; ?>"> |
| 176 | - <?php _e( 'Link Relationship (XFN)' ); ?><br /> |
|
| 177 | - <input type="text" id="edit-menu-item-xfn-<?php echo $item_id; ?>" class="widefat code edit-menu-item-xfn" name="menu-item-xfn[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->xfn ); ?>" /> |
|
| 176 | + <?php _e('Link Relationship (XFN)'); ?><br /> |
|
| 177 | + <input type="text" id="edit-menu-item-xfn-<?php echo $item_id; ?>" class="widefat code edit-menu-item-xfn" name="menu-item-xfn[<?php echo $item_id; ?>]" value="<?php echo esc_attr($item->xfn); ?>" /> |
|
| 178 | 178 | </label> |
| 179 | 179 | </p> |
| 180 | 180 | <p class="field-description description description-wide"> |
| 181 | 181 | <label for="edit-menu-item-description-<?php echo $item_id; ?>"> |
| 182 | - <?php _e( 'Description' ); ?><br /> |
|
| 183 | - <textarea id="edit-menu-item-description-<?php echo $item_id; ?>" class="widefat edit-menu-item-description" rows="3" cols="20" name="menu-item-description[<?php echo $item_id; ?>]"><?php echo esc_html( $item->description ); // textarea_escaped ?></textarea> |
|
| 182 | + <?php _e('Description'); ?><br /> |
|
| 183 | + <textarea id="edit-menu-item-description-<?php echo $item_id; ?>" class="widefat edit-menu-item-description" rows="3" cols="20" name="menu-item-description[<?php echo $item_id; ?>]"><?php echo esc_html($item->description); // textarea_escaped ?></textarea> |
|
| 184 | 184 | <span class="description"><?php _e('The description will be displayed in the menu if the current theme supports it.'); ?></span> |
| 185 | 185 | </label> |
| 186 | 186 | </p> |
| 187 | 187 | |
| 188 | 188 | <p class="field-move hide-if-no-js description description-wide"> |
| 189 | 189 | <label> |
| 190 | - <span><?php _e( 'Move' ); ?></span> |
|
| 191 | - <a href="#" class="menus-move menus-move-up" data-dir="up"><?php _e( 'Up one' ); ?></a> |
|
| 192 | - <a href="#" class="menus-move menus-move-down" data-dir="down"><?php _e( 'Down one' ); ?></a> |
|
| 190 | + <span><?php _e('Move'); ?></span> |
|
| 191 | + <a href="#" class="menus-move menus-move-up" data-dir="up"><?php _e('Up one'); ?></a> |
|
| 192 | + <a href="#" class="menus-move menus-move-down" data-dir="down"><?php _e('Down one'); ?></a> |
|
| 193 | 193 | <a href="#" class="menus-move menus-move-left" data-dir="left"></a> |
| 194 | 194 | <a href="#" class="menus-move menus-move-right" data-dir="right"></a> |
| 195 | - <a href="#" class="menus-move menus-move-top" data-dir="top"><?php _e( 'To the top' ); ?></a> |
|
| 195 | + <a href="#" class="menus-move menus-move-top" data-dir="top"><?php _e('To the top'); ?></a> |
|
| 196 | 196 | </label> |
| 197 | 197 | </p> |
| 198 | 198 | |
| 199 | 199 | <div class="menu-item-actions description-wide submitbox"> |
| 200 | - <?php if ( 'custom' != $item->type && $original_title !== false ) : ?> |
|
| 200 | + <?php if ('custom' != $item->type && $original_title !== false) : ?> |
|
| 201 | 201 | <p class="link-to-original"> |
| 202 | - <?php printf( __('Original: %s'), '<a href="' . esc_attr( $item->url ) . '">' . esc_html( $original_title ) . '</a>' ); ?> |
|
| 202 | + <?php printf(__('Original: %s'), '<a href="'.esc_attr($item->url).'">'.esc_html($original_title).'</a>'); ?> |
|
| 203 | 203 | </p> |
| 204 | 204 | <?php endif; ?> |
| 205 | 205 | <a class="item-delete submitdelete deletion" id="delete-<?php echo $item_id; ?>" href="<?php |
@@ -209,19 +209,19 @@ discard block |
||
| 209 | 209 | 'action' => 'delete-menu-item', |
| 210 | 210 | 'menu-item' => $item_id, |
| 211 | 211 | ), |
| 212 | - admin_url( 'nav-menus.php' ) |
|
| 212 | + admin_url('nav-menus.php') |
|
| 213 | 213 | ), |
| 214 | - 'delete-menu_item_' . $item_id |
|
| 215 | - ); ?>"><?php _e( 'Remove' ); ?></a> <span class="meta-sep hide-if-no-js"> | </span> <a class="item-cancel submitcancel hide-if-no-js" id="cancel-<?php echo $item_id; ?>" href="<?php echo esc_url( add_query_arg( array( 'edit-menu-item' => $item_id, 'cancel' => time() ), admin_url( 'nav-menus.php' ) ) ); |
|
| 214 | + 'delete-menu_item_'.$item_id |
|
| 215 | + ); ?>"><?php _e('Remove'); ?></a> <span class="meta-sep hide-if-no-js"> | </span> <a class="item-cancel submitcancel hide-if-no-js" id="cancel-<?php echo $item_id; ?>" href="<?php echo esc_url(add_query_arg(array('edit-menu-item' => $item_id, 'cancel' => time()), admin_url('nav-menus.php'))); |
|
| 216 | 216 | ?>#menu-item-settings-<?php echo $item_id; ?>"><?php _e('Cancel'); ?></a> |
| 217 | 217 | </div> |
| 218 | 218 | |
| 219 | 219 | <input class="menu-item-data-db-id" type="hidden" name="menu-item-db-id[<?php echo $item_id; ?>]" value="<?php echo $item_id; ?>" /> |
| 220 | - <input class="menu-item-data-object-id" type="hidden" name="menu-item-object-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object_id ); ?>" /> |
|
| 221 | - <input class="menu-item-data-object" type="hidden" name="menu-item-object[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object ); ?>" /> |
|
| 222 | - <input class="menu-item-data-parent-id" type="hidden" name="menu-item-parent-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_item_parent ); ?>" /> |
|
| 223 | - <input class="menu-item-data-position" type="hidden" name="menu-item-position[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_order ); ?>" /> |
|
| 224 | - <input class="menu-item-data-type" type="hidden" name="menu-item-type[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->type ); ?>" /> |
|
| 220 | + <input class="menu-item-data-object-id" type="hidden" name="menu-item-object-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr($item->object_id); ?>" /> |
|
| 221 | + <input class="menu-item-data-object" type="hidden" name="menu-item-object[<?php echo $item_id; ?>]" value="<?php echo esc_attr($item->object); ?>" /> |
|
| 222 | + <input class="menu-item-data-parent-id" type="hidden" name="menu-item-parent-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr($item->menu_item_parent); ?>" /> |
|
| 223 | + <input class="menu-item-data-position" type="hidden" name="menu-item-position[<?php echo $item_id; ?>]" value="<?php echo esc_attr($item->menu_order); ?>" /> |
|
| 224 | + <input class="menu-item-data-type" type="hidden" name="menu-item-type[<?php echo $item_id; ?>]" value="<?php echo esc_attr($item->type); ?>" /> |
|
| 225 | 225 | </div><!-- .menu-item-settings--> |
| 226 | 226 | <ul class="menu-item-transport"></ul> |
| 227 | 227 | <?php |
@@ -241,8 +241,8 @@ discard block |
||
| 241 | 241 | * |
| 242 | 242 | * @param array $fields |
| 243 | 243 | */ |
| 244 | - public function __construct( $fields = false ) { |
|
| 245 | - if ( $fields ) { |
|
| 244 | + public function __construct($fields = false) { |
|
| 245 | + if ($fields) { |
|
| 246 | 246 | $this->db_fields = $fields; |
| 247 | 247 | } |
| 248 | 248 | } |
@@ -258,8 +258,8 @@ discard block |
||
| 258 | 258 | * @param int $depth Depth of page. Used for padding. |
| 259 | 259 | * @param array $args Not used. |
| 260 | 260 | */ |
| 261 | - public function start_lvl( &$output, $depth = 0, $args = array() ) { |
|
| 262 | - $indent = str_repeat( "\t", $depth ); |
|
| 261 | + public function start_lvl(&$output, $depth = 0, $args = array()) { |
|
| 262 | + $indent = str_repeat("\t", $depth); |
|
| 263 | 263 | $output .= "\n$indent<ul class='children'>\n"; |
| 264 | 264 | } |
| 265 | 265 | |
@@ -274,8 +274,8 @@ discard block |
||
| 274 | 274 | * @param int $depth Depth of page. Used for padding. |
| 275 | 275 | * @param array $args Not used. |
| 276 | 276 | */ |
| 277 | - public function end_lvl( &$output, $depth = 0, $args = array() ) { |
|
| 278 | - $indent = str_repeat( "\t", $depth ); |
|
| 277 | + public function end_lvl(&$output, $depth = 0, $args = array()) { |
|
| 278 | + $indent = str_repeat("\t", $depth); |
|
| 279 | 279 | $output .= "\n$indent</ul>"; |
| 280 | 280 | } |
| 281 | 281 | |
@@ -294,47 +294,47 @@ discard block |
||
| 294 | 294 | * @param array $args Not used. |
| 295 | 295 | * @param int $id Not used. |
| 296 | 296 | */ |
| 297 | - public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { |
|
| 297 | + public function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { |
|
| 298 | 298 | global $_nav_menu_placeholder; |
| 299 | 299 | |
| 300 | - $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1; |
|
| 301 | - $possible_object_id = isset( $item->post_type ) && 'nav_menu_item' == $item->post_type ? $item->object_id : $_nav_menu_placeholder; |
|
| 302 | - $possible_db_id = ( ! empty( $item->ID ) ) && ( 0 < $possible_object_id ) ? (int) $item->ID : 0; |
|
| 300 | + $_nav_menu_placeholder = (0 > $_nav_menu_placeholder) ? intval($_nav_menu_placeholder) - 1 : -1; |
|
| 301 | + $possible_object_id = isset($item->post_type) && 'nav_menu_item' == $item->post_type ? $item->object_id : $_nav_menu_placeholder; |
|
| 302 | + $possible_db_id = ( ! empty($item->ID)) && (0 < $possible_object_id) ? (int) $item->ID : 0; |
|
| 303 | 303 | |
| 304 | - $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; |
|
| 304 | + $indent = ($depth) ? str_repeat("\t", $depth) : ''; |
|
| 305 | 305 | |
| 306 | - $output .= $indent . '<li>'; |
|
| 306 | + $output .= $indent.'<li>'; |
|
| 307 | 307 | $output .= '<label class="menu-item-title">'; |
| 308 | 308 | $output .= '<input type="checkbox" class="menu-item-checkbox'; |
| 309 | 309 | |
| 310 | - if ( ! empty( $item->front_or_home ) ) |
|
| 310 | + if ( ! empty($item->front_or_home)) |
|
| 311 | 311 | $output .= ' add-to-top'; |
| 312 | 312 | |
| 313 | - $output .= '" name="menu-item[' . $possible_object_id . '][menu-item-object-id]" value="'. esc_attr( $item->object_id ) .'" /> '; |
|
| 313 | + $output .= '" name="menu-item['.$possible_object_id.'][menu-item-object-id]" value="'.esc_attr($item->object_id).'" /> '; |
|
| 314 | 314 | |
| 315 | - if ( ! empty( $item->label ) ) { |
|
| 315 | + if ( ! empty($item->label)) { |
|
| 316 | 316 | $title = $item->label; |
| 317 | - } elseif ( isset( $item->post_type ) ) { |
|
| 317 | + } elseif (isset($item->post_type)) { |
|
| 318 | 318 | /** This filter is documented in wp-includes/post-template.php */ |
| 319 | - $title = apply_filters( 'the_title', $item->post_title, $item->ID ); |
|
| 320 | - if ( ! empty( $item->front_or_home ) && _x( 'Home', 'nav menu home label' ) !== $title ) |
|
| 321 | - $title = sprintf( _x( 'Home: %s', 'nav menu front page title' ), $title ); |
|
| 319 | + $title = apply_filters('the_title', $item->post_title, $item->ID); |
|
| 320 | + if ( ! empty($item->front_or_home) && _x('Home', 'nav menu home label') !== $title) |
|
| 321 | + $title = sprintf(_x('Home: %s', 'nav menu front page title'), $title); |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - $output .= isset( $title ) ? esc_html( $title ) : esc_html( $item->title ); |
|
| 324 | + $output .= isset($title) ? esc_html($title) : esc_html($item->title); |
|
| 325 | 325 | $output .= '</label>'; |
| 326 | 326 | |
| 327 | 327 | // Menu item hidden fields |
| 328 | - $output .= '<input type="hidden" class="menu-item-db-id" name="menu-item[' . $possible_object_id . '][menu-item-db-id]" value="' . $possible_db_id . '" />'; |
|
| 329 | - $output .= '<input type="hidden" class="menu-item-object" name="menu-item[' . $possible_object_id . '][menu-item-object]" value="'. esc_attr( $item->object ) .'" />'; |
|
| 330 | - $output .= '<input type="hidden" class="menu-item-parent-id" name="menu-item[' . $possible_object_id . '][menu-item-parent-id]" value="'. esc_attr( $item->menu_item_parent ) .'" />'; |
|
| 331 | - $output .= '<input type="hidden" class="menu-item-type" name="menu-item[' . $possible_object_id . '][menu-item-type]" value="'. esc_attr( $item->type ) .'" />'; |
|
| 332 | - $output .= '<input type="hidden" class="menu-item-title" name="menu-item[' . $possible_object_id . '][menu-item-title]" value="'. esc_attr( $item->title ) .'" />'; |
|
| 333 | - $output .= '<input type="hidden" class="menu-item-url" name="menu-item[' . $possible_object_id . '][menu-item-url]" value="'. esc_attr( $item->url ) .'" />'; |
|
| 334 | - $output .= '<input type="hidden" class="menu-item-target" name="menu-item[' . $possible_object_id . '][menu-item-target]" value="'. esc_attr( $item->target ) .'" />'; |
|
| 335 | - $output .= '<input type="hidden" class="menu-item-attr_title" name="menu-item[' . $possible_object_id . '][menu-item-attr_title]" value="'. esc_attr( $item->attr_title ) .'" />'; |
|
| 336 | - $output .= '<input type="hidden" class="menu-item-classes" name="menu-item[' . $possible_object_id . '][menu-item-classes]" value="'. esc_attr( implode( ' ', $item->classes ) ) .'" />'; |
|
| 337 | - $output .= '<input type="hidden" class="menu-item-xfn" name="menu-item[' . $possible_object_id . '][menu-item-xfn]" value="'. esc_attr( $item->xfn ) .'" />'; |
|
| 328 | + $output .= '<input type="hidden" class="menu-item-db-id" name="menu-item['.$possible_object_id.'][menu-item-db-id]" value="'.$possible_db_id.'" />'; |
|
| 329 | + $output .= '<input type="hidden" class="menu-item-object" name="menu-item['.$possible_object_id.'][menu-item-object]" value="'.esc_attr($item->object).'" />'; |
|
| 330 | + $output .= '<input type="hidden" class="menu-item-parent-id" name="menu-item['.$possible_object_id.'][menu-item-parent-id]" value="'.esc_attr($item->menu_item_parent).'" />'; |
|
| 331 | + $output .= '<input type="hidden" class="menu-item-type" name="menu-item['.$possible_object_id.'][menu-item-type]" value="'.esc_attr($item->type).'" />'; |
|
| 332 | + $output .= '<input type="hidden" class="menu-item-title" name="menu-item['.$possible_object_id.'][menu-item-title]" value="'.esc_attr($item->title).'" />'; |
|
| 333 | + $output .= '<input type="hidden" class="menu-item-url" name="menu-item['.$possible_object_id.'][menu-item-url]" value="'.esc_attr($item->url).'" />'; |
|
| 334 | + $output .= '<input type="hidden" class="menu-item-target" name="menu-item['.$possible_object_id.'][menu-item-target]" value="'.esc_attr($item->target).'" />'; |
|
| 335 | + $output .= '<input type="hidden" class="menu-item-attr_title" name="menu-item['.$possible_object_id.'][menu-item-attr_title]" value="'.esc_attr($item->attr_title).'" />'; |
|
| 336 | + $output .= '<input type="hidden" class="menu-item-classes" name="menu-item['.$possible_object_id.'][menu-item-classes]" value="'.esc_attr(implode(' ', $item->classes)).'" />'; |
|
| 337 | + $output .= '<input type="hidden" class="menu-item-xfn" name="menu-item['.$possible_object_id.'][menu-item-xfn]" value="'.esc_attr($item->xfn).'" />'; |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | } // Walker_Nav_Menu_Checklist |
@@ -346,41 +346,41 @@ discard block |
||
| 346 | 346 | * |
| 347 | 347 | * @param array $request The unsanitized request values. |
| 348 | 348 | */ |
| 349 | -function _wp_ajax_menu_quick_search( $request = array() ) { |
|
| 349 | +function _wp_ajax_menu_quick_search($request = array()) { |
|
| 350 | 350 | $args = array(); |
| 351 | - $type = isset( $request['type'] ) ? $request['type'] : ''; |
|
| 352 | - $object_type = isset( $request['object_type'] ) ? $request['object_type'] : ''; |
|
| 353 | - $query = isset( $request['q'] ) ? $request['q'] : ''; |
|
| 354 | - $response_format = isset( $request['response-format'] ) && in_array( $request['response-format'], array( 'json', 'markup' ) ) ? $request['response-format'] : 'json'; |
|
| 351 | + $type = isset($request['type']) ? $request['type'] : ''; |
|
| 352 | + $object_type = isset($request['object_type']) ? $request['object_type'] : ''; |
|
| 353 | + $query = isset($request['q']) ? $request['q'] : ''; |
|
| 354 | + $response_format = isset($request['response-format']) && in_array($request['response-format'], array('json', 'markup')) ? $request['response-format'] : 'json'; |
|
| 355 | 355 | |
| 356 | - if ( 'markup' == $response_format ) { |
|
| 356 | + if ('markup' == $response_format) { |
|
| 357 | 357 | $args['walker'] = new Walker_Nav_Menu_Checklist; |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - if ( 'get-post-item' == $type ) { |
|
| 361 | - if ( post_type_exists( $object_type ) ) { |
|
| 362 | - if ( isset( $request['ID'] ) ) { |
|
| 360 | + if ('get-post-item' == $type) { |
|
| 361 | + if (post_type_exists($object_type)) { |
|
| 362 | + if (isset($request['ID'])) { |
|
| 363 | 363 | $object_id = (int) $request['ID']; |
| 364 | - if ( 'markup' == $response_format ) { |
|
| 365 | - echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_post( $object_id ) ) ), 0, (object) $args ); |
|
| 366 | - } elseif ( 'json' == $response_format ) { |
|
| 364 | + if ('markup' == $response_format) { |
|
| 365 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', array(get_post($object_id))), 0, (object) $args); |
|
| 366 | + } elseif ('json' == $response_format) { |
|
| 367 | 367 | echo wp_json_encode( |
| 368 | 368 | array( |
| 369 | 369 | 'ID' => $object_id, |
| 370 | - 'post_title' => get_the_title( $object_id ), |
|
| 371 | - 'post_type' => get_post_type( $object_id ), |
|
| 370 | + 'post_title' => get_the_title($object_id), |
|
| 371 | + 'post_type' => get_post_type($object_id), |
|
| 372 | 372 | ) |
| 373 | 373 | ); |
| 374 | 374 | echo "\n"; |
| 375 | 375 | } |
| 376 | 376 | } |
| 377 | - } elseif ( taxonomy_exists( $object_type ) ) { |
|
| 378 | - if ( isset( $request['ID'] ) ) { |
|
| 377 | + } elseif (taxonomy_exists($object_type)) { |
|
| 378 | + if (isset($request['ID'])) { |
|
| 379 | 379 | $object_id = (int) $request['ID']; |
| 380 | - if ( 'markup' == $response_format ) { |
|
| 381 | - echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_term( $object_id, $object_type ) ) ), 0, (object) $args ); |
|
| 382 | - } elseif ( 'json' == $response_format ) { |
|
| 383 | - $post_obj = get_term( $object_id, $object_type ); |
|
| 380 | + if ('markup' == $response_format) { |
|
| 381 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', array(get_term($object_id, $object_type))), 0, (object) $args); |
|
| 382 | + } elseif ('json' == $response_format) { |
|
| 383 | + $post_obj = get_term($object_id, $object_type); |
|
| 384 | 384 | echo wp_json_encode( |
| 385 | 385 | array( |
| 386 | 386 | 'ID' => $object_id, |
@@ -394,21 +394,21 @@ discard block |
||
| 394 | 394 | |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - } elseif ( preg_match('/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*\b)/', $type, $matches) ) { |
|
| 398 | - if ( 'posttype' == $matches[1] && get_post_type_object( $matches[2] ) ) { |
|
| 397 | + } elseif (preg_match('/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*\b)/', $type, $matches)) { |
|
| 398 | + if ('posttype' == $matches[1] && get_post_type_object($matches[2])) { |
|
| 399 | 399 | query_posts(array( |
| 400 | 400 | 'posts_per_page' => 10, |
| 401 | 401 | 'post_type' => $matches[2], |
| 402 | 402 | 's' => $query, |
| 403 | 403 | )); |
| 404 | - if ( ! have_posts() ) |
|
| 404 | + if ( ! have_posts()) |
|
| 405 | 405 | return; |
| 406 | - while ( have_posts() ) { |
|
| 406 | + while (have_posts()) { |
|
| 407 | 407 | the_post(); |
| 408 | - if ( 'markup' == $response_format ) { |
|
| 408 | + if ('markup' == $response_format) { |
|
| 409 | 409 | $var_by_ref = get_the_ID(); |
| 410 | - echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_post( $var_by_ref ) ) ), 0, (object) $args ); |
|
| 411 | - } elseif ( 'json' == $response_format ) { |
|
| 410 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', array(get_post($var_by_ref))), 0, (object) $args); |
|
| 411 | + } elseif ('json' == $response_format) { |
|
| 412 | 412 | echo wp_json_encode( |
| 413 | 413 | array( |
| 414 | 414 | 'ID' => get_the_ID(), |
@@ -419,17 +419,17 @@ discard block |
||
| 419 | 419 | echo "\n"; |
| 420 | 420 | } |
| 421 | 421 | } |
| 422 | - } elseif ( 'taxonomy' == $matches[1] ) { |
|
| 423 | - $terms = get_terms( $matches[2], array( |
|
| 422 | + } elseif ('taxonomy' == $matches[1]) { |
|
| 423 | + $terms = get_terms($matches[2], array( |
|
| 424 | 424 | 'name__like' => $query, |
| 425 | 425 | 'number' => 10, |
| 426 | 426 | )); |
| 427 | - if ( empty( $terms ) || is_wp_error( $terms ) ) |
|
| 427 | + if (empty($terms) || is_wp_error($terms)) |
|
| 428 | 428 | return; |
| 429 | - foreach( (array) $terms as $term ) { |
|
| 430 | - if ( 'markup' == $response_format ) { |
|
| 431 | - echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args ); |
|
| 432 | - } elseif ( 'json' == $response_format ) { |
|
| 429 | + foreach ((array) $terms as $term) { |
|
| 430 | + if ('markup' == $response_format) { |
|
| 431 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', array($term)), 0, (object) $args); |
|
| 432 | + } elseif ('json' == $response_format) { |
|
| 433 | 433 | echo wp_json_encode( |
| 434 | 434 | array( |
| 435 | 435 | 'ID' => $term->term_id, |
@@ -452,17 +452,17 @@ discard block |
||
| 452 | 452 | function wp_nav_menu_setup() { |
| 453 | 453 | // Register meta boxes |
| 454 | 454 | wp_nav_menu_post_type_meta_boxes(); |
| 455 | - add_meta_box( 'add-custom-links', __( 'Custom Links' ), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' ); |
|
| 455 | + add_meta_box('add-custom-links', __('Custom Links'), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default'); |
|
| 456 | 456 | wp_nav_menu_taxonomy_meta_boxes(); |
| 457 | 457 | |
| 458 | 458 | // Register advanced menu items (columns) |
| 459 | - add_filter( 'manage_nav-menus_columns', 'wp_nav_menu_manage_columns' ); |
|
| 459 | + add_filter('manage_nav-menus_columns', 'wp_nav_menu_manage_columns'); |
|
| 460 | 460 | |
| 461 | 461 | // If first time editing, disable advanced items by default. |
| 462 | - if ( false === get_user_option( 'managenav-menuscolumnshidden' ) ) { |
|
| 462 | + if (false === get_user_option('managenav-menuscolumnshidden')) { |
|
| 463 | 463 | $user = wp_get_current_user(); |
| 464 | 464 | update_user_option($user->ID, 'managenav-menuscolumnshidden', |
| 465 | - array( 0 => 'link-target', 1 => 'css-classes', 2 => 'xfn', 3 => 'description', 4 => 'title-attribute', ), |
|
| 465 | + array(0 => 'link-target', 1 => 'css-classes', 2 => 'xfn', 3 => 'description', 4 => 'title-attribute',), |
|
| 466 | 466 | true); |
| 467 | 467 | } |
| 468 | 468 | } |
@@ -477,17 +477,17 @@ discard block |
||
| 477 | 477 | function wp_initial_nav_menu_meta_boxes() { |
| 478 | 478 | global $wp_meta_boxes; |
| 479 | 479 | |
| 480 | - if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array($wp_meta_boxes) ) |
|
| 480 | + if (get_user_option('metaboxhidden_nav-menus') !== false || ! is_array($wp_meta_boxes)) |
|
| 481 | 481 | return; |
| 482 | 482 | |
| 483 | - $initial_meta_boxes = array( 'add-page', 'add-post', 'add-custom-links', 'add-category' ); |
|
| 483 | + $initial_meta_boxes = array('add-page', 'add-post', 'add-custom-links', 'add-category'); |
|
| 484 | 484 | $hidden_meta_boxes = array(); |
| 485 | 485 | |
| 486 | - foreach ( array_keys($wp_meta_boxes['nav-menus']) as $context ) { |
|
| 487 | - foreach ( array_keys($wp_meta_boxes['nav-menus'][$context]) as $priority ) { |
|
| 488 | - foreach ( $wp_meta_boxes['nav-menus'][$context][$priority] as $box ) { |
|
| 489 | - if ( in_array( $box['id'], $initial_meta_boxes ) ) { |
|
| 490 | - unset( $box['id'] ); |
|
| 486 | + foreach (array_keys($wp_meta_boxes['nav-menus']) as $context) { |
|
| 487 | + foreach (array_keys($wp_meta_boxes['nav-menus'][$context]) as $priority) { |
|
| 488 | + foreach ($wp_meta_boxes['nav-menus'][$context][$priority] as $box) { |
|
| 489 | + if (in_array($box['id'], $initial_meta_boxes)) { |
|
| 490 | + unset($box['id']); |
|
| 491 | 491 | } else { |
| 492 | 492 | $hidden_meta_boxes[] = $box['id']; |
| 493 | 493 | } |
@@ -496,7 +496,7 @@ discard block |
||
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | $user = wp_get_current_user(); |
| 499 | - update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true ); |
|
| 499 | + update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
| 500 | 500 | } |
| 501 | 501 | |
| 502 | 502 | /** |
@@ -505,12 +505,12 @@ discard block |
||
| 505 | 505 | * @since 3.0.0 |
| 506 | 506 | */ |
| 507 | 507 | function wp_nav_menu_post_type_meta_boxes() { |
| 508 | - $post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'object' ); |
|
| 508 | + $post_types = get_post_types(array('show_in_nav_menus' => true), 'object'); |
|
| 509 | 509 | |
| 510 | - if ( ! $post_types ) |
|
| 510 | + if ( ! $post_types) |
|
| 511 | 511 | return; |
| 512 | 512 | |
| 513 | - foreach ( $post_types as $post_type ) { |
|
| 513 | + foreach ($post_types as $post_type) { |
|
| 514 | 514 | /** |
| 515 | 515 | * Filter whether a menu items meta box will be added for the current |
| 516 | 516 | * object type. |
@@ -523,12 +523,12 @@ discard block |
||
| 523 | 523 | * @param object $meta_box_object The current object to add a menu items |
| 524 | 524 | * meta box for. |
| 525 | 525 | */ |
| 526 | - $post_type = apply_filters( 'nav_menu_meta_box_object', $post_type ); |
|
| 527 | - if ( $post_type ) { |
|
| 526 | + $post_type = apply_filters('nav_menu_meta_box_object', $post_type); |
|
| 527 | + if ($post_type) { |
|
| 528 | 528 | $id = $post_type->name; |
| 529 | 529 | // Give pages a higher priority. |
| 530 | - $priority = ( 'page' == $post_type->name ? 'core' : 'default' ); |
|
| 531 | - add_meta_box( "add-{$id}", $post_type->labels->name, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', $priority, $post_type ); |
|
| 530 | + $priority = ('page' == $post_type->name ? 'core' : 'default'); |
|
| 531 | + add_meta_box("add-{$id}", $post_type->labels->name, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', $priority, $post_type); |
|
| 532 | 532 | } |
| 533 | 533 | } |
| 534 | 534 | } |
@@ -539,17 +539,17 @@ discard block |
||
| 539 | 539 | * @since 3.0.0 |
| 540 | 540 | */ |
| 541 | 541 | function wp_nav_menu_taxonomy_meta_boxes() { |
| 542 | - $taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'object' ); |
|
| 542 | + $taxonomies = get_taxonomies(array('show_in_nav_menus' => true), 'object'); |
|
| 543 | 543 | |
| 544 | - if ( !$taxonomies ) |
|
| 544 | + if ( ! $taxonomies) |
|
| 545 | 545 | return; |
| 546 | 546 | |
| 547 | - foreach ( $taxonomies as $tax ) { |
|
| 547 | + foreach ($taxonomies as $tax) { |
|
| 548 | 548 | /** This filter is documented in wp-admin/includes/nav-menu.php */ |
| 549 | - $tax = apply_filters( 'nav_menu_meta_box_object', $tax ); |
|
| 550 | - if ( $tax ) { |
|
| 549 | + $tax = apply_filters('nav_menu_meta_box_object', $tax); |
|
| 550 | + if ($tax) { |
|
| 551 | 551 | $id = $tax->name; |
| 552 | - add_meta_box( "add-{$id}", $tax->labels->name, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax ); |
|
| 552 | + add_meta_box("add-{$id}", $tax->labels->name, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax); |
|
| 553 | 553 | } |
| 554 | 554 | } |
| 555 | 555 | } |
@@ -564,13 +564,13 @@ discard block |
||
| 564 | 564 | * @param int|string $nav_menu_selected_id (id, name or slug) of the currently-selected menu |
| 565 | 565 | * @return string Disabled attribute if at least one menu exists, false if not |
| 566 | 566 | */ |
| 567 | -function wp_nav_menu_disabled_check( $nav_menu_selected_id ) { |
|
| 567 | +function wp_nav_menu_disabled_check($nav_menu_selected_id) { |
|
| 568 | 568 | global $one_theme_location_no_menus; |
| 569 | 569 | |
| 570 | - if ( $one_theme_location_no_menus ) |
|
| 570 | + if ($one_theme_location_no_menus) |
|
| 571 | 571 | return false; |
| 572 | 572 | |
| 573 | - return disabled( $nav_menu_selected_id, 0 ); |
|
| 573 | + return disabled($nav_menu_selected_id, 0); |
|
| 574 | 574 | } |
| 575 | 575 | |
| 576 | 576 | /** |
@@ -598,14 +598,14 @@ discard block |
||
| 598 | 598 | |
| 599 | 599 | <p id="menu-item-name-wrap"> |
| 600 | 600 | <label class="howto" for="custom-menu-item-name"> |
| 601 | - <span><?php _e( 'Link Text' ); ?></span> |
|
| 601 | + <span><?php _e('Link Text'); ?></span> |
|
| 602 | 602 | <input id="custom-menu-item-name" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-title]" type="text" class="regular-text menu-item-textbox input-with-default-title" title="<?php esc_attr_e('Menu Item'); ?>" /> |
| 603 | 603 | </label> |
| 604 | 604 | </p> |
| 605 | 605 | |
| 606 | 606 | <p class="button-controls"> |
| 607 | 607 | <span class="add-to-menu"> |
| 608 | - <input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-custom-menu-item" id="submit-customlinkdiv" /> |
|
| 608 | + <input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-custom-menu-item" id="submit-customlinkdiv" /> |
|
| 609 | 609 | <span class="spinner"></span> |
| 610 | 610 | </span> |
| 611 | 611 | </p> |
@@ -625,15 +625,15 @@ discard block |
||
| 625 | 625 | * @param string $object Not used. |
| 626 | 626 | * @param string $post_type The post type object. |
| 627 | 627 | */ |
| 628 | -function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) { |
|
| 628 | +function wp_nav_menu_item_post_type_meta_box($object, $post_type) { |
|
| 629 | 629 | global $_nav_menu_placeholder, $nav_menu_selected_id; |
| 630 | 630 | |
| 631 | 631 | $post_type_name = $post_type['args']->name; |
| 632 | 632 | |
| 633 | 633 | // Paginate browsing for large numbers of post objects. |
| 634 | 634 | $per_page = 50; |
| 635 | - $pagenum = isset( $_REQUEST[$post_type_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1; |
|
| 636 | - $offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0; |
|
| 635 | + $pagenum = isset($_REQUEST[$post_type_name.'-tab']) && isset($_REQUEST['paged']) ? absint($_REQUEST['paged']) : 1; |
|
| 636 | + $offset = 0 < $pagenum ? $per_page * ($pagenum - 1) : 0; |
|
| 637 | 637 | |
| 638 | 638 | $args = array( |
| 639 | 639 | 'offset' => $offset, |
@@ -646,23 +646,23 @@ discard block |
||
| 646 | 646 | 'update_post_meta_cache' => false |
| 647 | 647 | ); |
| 648 | 648 | |
| 649 | - if ( isset( $post_type['args']->_default_query ) ) |
|
| 650 | - $args = array_merge($args, (array) $post_type['args']->_default_query ); |
|
| 649 | + if (isset($post_type['args']->_default_query)) |
|
| 650 | + $args = array_merge($args, (array) $post_type['args']->_default_query); |
|
| 651 | 651 | |
| 652 | 652 | // @todo transient caching of these results with proper invalidation on updating of a post of this type |
| 653 | 653 | $get_posts = new WP_Query; |
| 654 | - $posts = $get_posts->query( $args ); |
|
| 655 | - if ( ! $get_posts->post_count ) { |
|
| 656 | - echo '<p>' . __( 'No items.' ) . '</p>'; |
|
| 654 | + $posts = $get_posts->query($args); |
|
| 655 | + if ( ! $get_posts->post_count) { |
|
| 656 | + echo '<p>'.__('No items.').'</p>'; |
|
| 657 | 657 | return; |
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | $num_pages = $get_posts->max_num_pages; |
| 661 | 661 | |
| 662 | - $page_links = paginate_links( array( |
|
| 662 | + $page_links = paginate_links(array( |
|
| 663 | 663 | 'base' => add_query_arg( |
| 664 | 664 | array( |
| 665 | - $post_type_name . '-tab' => 'all', |
|
| 665 | + $post_type_name.'-tab' => 'all', |
|
| 666 | 666 | 'paged' => '%#%', |
| 667 | 667 | 'item-type' => 'post_type', |
| 668 | 668 | 'item-object' => $post_type_name, |
@@ -676,18 +676,18 @@ discard block |
||
| 676 | 676 | )); |
| 677 | 677 | |
| 678 | 678 | $db_fields = false; |
| 679 | - if ( is_post_type_hierarchical( $post_type_name ) ) { |
|
| 680 | - $db_fields = array( 'parent' => 'post_parent', 'id' => 'ID' ); |
|
| 679 | + if (is_post_type_hierarchical($post_type_name)) { |
|
| 680 | + $db_fields = array('parent' => 'post_parent', 'id' => 'ID'); |
|
| 681 | 681 | } |
| 682 | 682 | |
| 683 | - $walker = new Walker_Nav_Menu_Checklist( $db_fields ); |
|
| 683 | + $walker = new Walker_Nav_Menu_Checklist($db_fields); |
|
| 684 | 684 | |
| 685 | 685 | $current_tab = 'most-recent'; |
| 686 | - if ( isset( $_REQUEST[$post_type_name . '-tab'] ) && in_array( $_REQUEST[$post_type_name . '-tab'], array('all', 'search') ) ) { |
|
| 687 | - $current_tab = $_REQUEST[$post_type_name . '-tab']; |
|
| 686 | + if (isset($_REQUEST[$post_type_name.'-tab']) && in_array($_REQUEST[$post_type_name.'-tab'], array('all', 'search'))) { |
|
| 687 | + $current_tab = $_REQUEST[$post_type_name.'-tab']; |
|
| 688 | 688 | } |
| 689 | 689 | |
| 690 | - if ( ! empty( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) { |
|
| 690 | + if ( ! empty($_REQUEST['quick-search-posttype-'.$post_type_name])) { |
|
| 691 | 691 | $current_tab = 'search'; |
| 692 | 692 | } |
| 693 | 693 | |
@@ -703,30 +703,30 @@ discard block |
||
| 703 | 703 | ?> |
| 704 | 704 | <div id="posttype-<?php echo $post_type_name; ?>" class="posttypediv"> |
| 705 | 705 | <ul id="posttype-<?php echo $post_type_name; ?>-tabs" class="posttype-tabs add-menu-item-tabs"> |
| 706 | - <li <?php echo ( 'most-recent' == $current_tab ? ' class="tabs"' : '' ); ?>> |
|
| 707 | - <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-most-recent" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'most-recent', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent"> |
|
| 708 | - <?php _e( 'Most Recent' ); ?> |
|
| 706 | + <li <?php echo ('most-recent' == $current_tab ? ' class="tabs"' : ''); ?>> |
|
| 707 | + <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr($post_type_name); ?>-most-recent" href="<?php if ($nav_menu_selected_id) echo esc_url(add_query_arg($post_type_name.'-tab', 'most-recent', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent"> |
|
| 708 | + <?php _e('Most Recent'); ?> |
|
| 709 | 709 | </a> |
| 710 | 710 | </li> |
| 711 | - <li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>> |
|
| 712 | - <a class="nav-tab-link" data-type="<?php echo esc_attr( $post_type_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'all', remove_query_arg($removed_args))); ?>#<?php echo $post_type_name; ?>-all"> |
|
| 713 | - <?php _e( 'View All' ); ?> |
|
| 711 | + <li <?php echo ('all' == $current_tab ? ' class="tabs"' : ''); ?>> |
|
| 712 | + <a class="nav-tab-link" data-type="<?php echo esc_attr($post_type_name); ?>-all" href="<?php if ($nav_menu_selected_id) echo esc_url(add_query_arg($post_type_name.'-tab', 'all', remove_query_arg($removed_args))); ?>#<?php echo $post_type_name; ?>-all"> |
|
| 713 | + <?php _e('View All'); ?> |
|
| 714 | 714 | </a> |
| 715 | 715 | </li> |
| 716 | - <li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>> |
|
| 717 | - <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-search" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search"> |
|
| 718 | - <?php _e( 'Search'); ?> |
|
| 716 | + <li <?php echo ('search' == $current_tab ? ' class="tabs"' : ''); ?>> |
|
| 717 | + <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr($post_type_name); ?>-search" href="<?php if ($nav_menu_selected_id) echo esc_url(add_query_arg($post_type_name.'-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search"> |
|
| 718 | + <?php _e('Search'); ?> |
|
| 719 | 719 | </a> |
| 720 | 720 | </li> |
| 721 | 721 | </ul><!-- .posttype-tabs --> |
| 722 | 722 | |
| 723 | 723 | <div id="tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent" class="tabs-panel <?php |
| 724 | - echo ( 'most-recent' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); |
|
| 724 | + echo ('most-recent' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
| 725 | 725 | ?>"> |
| 726 | 726 | <ul id="<?php echo $post_type_name; ?>checklist-most-recent" class="categorychecklist form-no-clear"> |
| 727 | 727 | <?php |
| 728 | - $recent_args = array_merge( $args, array( 'orderby' => 'post_date', 'order' => 'DESC', 'posts_per_page' => 15 ) ); |
|
| 729 | - $most_recent = $get_posts->query( $recent_args ); |
|
| 728 | + $recent_args = array_merge($args, array('orderby' => 'post_date', 'order' => 'DESC', 'posts_per_page' => 15)); |
|
| 729 | + $most_recent = $get_posts->query($recent_args); |
|
| 730 | 730 | $args['walker'] = $walker; |
| 731 | 731 | |
| 732 | 732 | /** |
@@ -741,20 +741,20 @@ discard block |
||
| 741 | 741 | * @param array $args An array of WP_Query arguments. |
| 742 | 742 | * @param object $post_type The current post type object for this menu item meta box. |
| 743 | 743 | */ |
| 744 | - $most_recent = apply_filters( "nav_menu_items_{$post_type_name}_recent", $most_recent, $args, $post_type ); |
|
| 744 | + $most_recent = apply_filters("nav_menu_items_{$post_type_name}_recent", $most_recent, $args, $post_type); |
|
| 745 | 745 | |
| 746 | - echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $most_recent), 0, (object) $args ); |
|
| 746 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $most_recent), 0, (object) $args); |
|
| 747 | 747 | ?> |
| 748 | 748 | </ul> |
| 749 | 749 | </div><!-- /.tabs-panel --> |
| 750 | 750 | |
| 751 | 751 | <div class="tabs-panel <?php |
| 752 | - echo ( 'search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); |
|
| 752 | + echo ('search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
| 753 | 753 | ?>" id="tabs-panel-posttype-<?php echo $post_type_name; ?>-search"> |
| 754 | 754 | <?php |
| 755 | - if ( isset( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) { |
|
| 756 | - $searched = esc_attr( $_REQUEST['quick-search-posttype-' . $post_type_name] ); |
|
| 757 | - $search_results = get_posts( array( 's' => $searched, 'post_type' => $post_type_name, 'fields' => 'all', 'order' => 'DESC', ) ); |
|
| 755 | + if (isset($_REQUEST['quick-search-posttype-'.$post_type_name])) { |
|
| 756 | + $searched = esc_attr($_REQUEST['quick-search-posttype-'.$post_type_name]); |
|
| 757 | + $search_results = get_posts(array('s' => $searched, 'post_type' => $post_type_name, 'fields' => 'all', 'order' => 'DESC',)); |
|
| 758 | 758 | } else { |
| 759 | 759 | $searched = ''; |
| 760 | 760 | $search_results = array(); |
@@ -763,27 +763,27 @@ discard block |
||
| 763 | 763 | <p class="quick-search-wrap"> |
| 764 | 764 | <input type="search" class="quick-search input-with-default-title" title="<?php esc_attr_e('Search'); ?>" value="<?php echo $searched; ?>" name="quick-search-posttype-<?php echo $post_type_name; ?>" /> |
| 765 | 765 | <span class="spinner"></span> |
| 766 | - <?php submit_button( __( 'Search' ), 'button-small quick-search-submit button-secondary hide-if-js', 'submit', false, array( 'id' => 'submit-quick-search-posttype-' . $post_type_name ) ); ?> |
|
| 766 | + <?php submit_button(__('Search'), 'button-small quick-search-submit button-secondary hide-if-js', 'submit', false, array('id' => 'submit-quick-search-posttype-'.$post_type_name)); ?> |
|
| 767 | 767 | </p> |
| 768 | 768 | |
| 769 | 769 | <ul id="<?php echo $post_type_name; ?>-search-checklist" data-wp-lists="list:<?php echo $post_type_name?>" class="categorychecklist form-no-clear"> |
| 770 | - <?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?> |
|
| 770 | + <?php if ( ! empty($search_results) && ! is_wp_error($search_results)) : ?> |
|
| 771 | 771 | <?php |
| 772 | 772 | $args['walker'] = $walker; |
| 773 | - echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args ); |
|
| 773 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args); |
|
| 774 | 774 | ?> |
| 775 | - <?php elseif ( is_wp_error( $search_results ) ) : ?> |
|
| 775 | + <?php elseif (is_wp_error($search_results)) : ?> |
|
| 776 | 776 | <li><?php echo $search_results->get_error_message(); ?></li> |
| 777 | - <?php elseif ( ! empty( $searched ) ) : ?> |
|
| 777 | + <?php elseif ( ! empty($searched)) : ?> |
|
| 778 | 778 | <li><?php _e('No results found.'); ?></li> |
| 779 | 779 | <?php endif; ?> |
| 780 | 780 | </ul> |
| 781 | 781 | </div><!-- /.tabs-panel --> |
| 782 | 782 | |
| 783 | 783 | <div id="<?php echo $post_type_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php |
| 784 | - echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); |
|
| 784 | + echo ('all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
| 785 | 785 | ?>"> |
| 786 | - <?php if ( ! empty( $page_links ) ) : ?> |
|
| 786 | + <?php if ( ! empty($page_links)) : ?> |
|
| 787 | 787 | <div class="add-menu-item-pagelinks"> |
| 788 | 788 | <?php echo $page_links; ?> |
| 789 | 789 | </div> |
@@ -796,15 +796,15 @@ discard block |
||
| 796 | 796 | * If we're dealing with pages, let's put a checkbox for the front |
| 797 | 797 | * page at the top of the list. |
| 798 | 798 | */ |
| 799 | - if ( 'page' == $post_type_name ) { |
|
| 800 | - $front_page = 'page' == get_option('show_on_front') ? (int) get_option( 'page_on_front' ) : 0; |
|
| 801 | - if ( ! empty( $front_page ) ) { |
|
| 802 | - $front_page_obj = get_post( $front_page ); |
|
| 799 | + if ('page' == $post_type_name) { |
|
| 800 | + $front_page = 'page' == get_option('show_on_front') ? (int) get_option('page_on_front') : 0; |
|
| 801 | + if ( ! empty($front_page)) { |
|
| 802 | + $front_page_obj = get_post($front_page); |
|
| 803 | 803 | $front_page_obj->front_or_home = true; |
| 804 | - array_unshift( $posts, $front_page_obj ); |
|
| 804 | + array_unshift($posts, $front_page_obj); |
|
| 805 | 805 | } else { |
| 806 | - $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1; |
|
| 807 | - array_unshift( $posts, (object) array( |
|
| 806 | + $_nav_menu_placeholder = (0 > $_nav_menu_placeholder) ? intval($_nav_menu_placeholder) - 1 : -1; |
|
| 807 | + array_unshift($posts, (object) array( |
|
| 808 | 808 | 'front_or_home' => true, |
| 809 | 809 | 'ID' => 0, |
| 810 | 810 | 'object_id' => $_nav_menu_placeholder, |
@@ -815,7 +815,7 @@ discard block |
||
| 815 | 815 | 'post_type' => 'nav_menu_item', |
| 816 | 816 | 'type' => 'custom', |
| 817 | 817 | 'url' => home_url('/'), |
| 818 | - ) ); |
|
| 818 | + )); |
|
| 819 | 819 | } |
| 820 | 820 | } |
| 821 | 821 | |
@@ -834,10 +834,10 @@ discard block |
||
| 834 | 834 | * @param array $args An array of WP_Query arguments. |
| 835 | 835 | * @param object $post_type The current post type object for this menu item meta box. |
| 836 | 836 | */ |
| 837 | - $posts = apply_filters( "nav_menu_items_{$post_type_name}", $posts, $args, $post_type ); |
|
| 838 | - $checkbox_items = walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $posts), 0, (object) $args ); |
|
| 837 | + $posts = apply_filters("nav_menu_items_{$post_type_name}", $posts, $args, $post_type); |
|
| 838 | + $checkbox_items = walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $posts), 0, (object) $args); |
|
| 839 | 839 | |
| 840 | - if ( 'all' == $current_tab && ! empty( $_REQUEST['selectall'] ) ) { |
|
| 840 | + if ('all' == $current_tab && ! empty($_REQUEST['selectall'])) { |
|
| 841 | 841 | $checkbox_items = preg_replace('/(type=(.)checkbox(\2))/', '$1 checked=$2checked$2', $checkbox_items); |
| 842 | 842 | |
| 843 | 843 | } |
@@ -845,7 +845,7 @@ discard block |
||
| 845 | 845 | echo $checkbox_items; |
| 846 | 846 | ?> |
| 847 | 847 | </ul> |
| 848 | - <?php if ( ! empty( $page_links ) ) : ?> |
|
| 848 | + <?php if ( ! empty($page_links)) : ?> |
|
| 849 | 849 | <div class="add-menu-item-pagelinks"> |
| 850 | 850 | <?php echo $page_links; ?> |
| 851 | 851 | </div> |
@@ -855,18 +855,18 @@ discard block |
||
| 855 | 855 | <p class="button-controls"> |
| 856 | 856 | <span class="list-controls"> |
| 857 | 857 | <a href="<?php |
| 858 | - echo esc_url( add_query_arg( |
|
| 858 | + echo esc_url(add_query_arg( |
|
| 859 | 859 | array( |
| 860 | - $post_type_name . '-tab' => 'all', |
|
| 860 | + $post_type_name.'-tab' => 'all', |
|
| 861 | 861 | 'selectall' => 1, |
| 862 | 862 | ), |
| 863 | - remove_query_arg( $removed_args ) |
|
| 863 | + remove_query_arg($removed_args) |
|
| 864 | 864 | )); |
| 865 | 865 | ?>#posttype-<?php echo $post_type_name; ?>" class="select-all"><?php _e('Select All'); ?></a> |
| 866 | 866 | </span> |
| 867 | 867 | |
| 868 | 868 | <span class="add-to-menu"> |
| 869 | - <input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" name="add-post-type-menu-item" id="<?php echo esc_attr( 'submit-posttype-' . $post_type_name ); ?>" /> |
|
| 869 | + <input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-post-type-menu-item" id="<?php echo esc_attr('submit-posttype-'.$post_type_name); ?>" /> |
|
| 870 | 870 | <span class="spinner"></span> |
| 871 | 871 | </span> |
| 872 | 872 | </p> |
@@ -885,14 +885,14 @@ discard block |
||
| 885 | 885 | * @param string $object Not used. |
| 886 | 886 | * @param string $taxonomy The taxonomy object. |
| 887 | 887 | */ |
| 888 | -function wp_nav_menu_item_taxonomy_meta_box( $object, $taxonomy ) { |
|
| 888 | +function wp_nav_menu_item_taxonomy_meta_box($object, $taxonomy) { |
|
| 889 | 889 | global $nav_menu_selected_id; |
| 890 | 890 | $taxonomy_name = $taxonomy['args']->name; |
| 891 | 891 | |
| 892 | 892 | // Paginate browsing for large numbers of objects. |
| 893 | 893 | $per_page = 50; |
| 894 | - $pagenum = isset( $_REQUEST[$taxonomy_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1; |
|
| 895 | - $offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0; |
|
| 894 | + $pagenum = isset($_REQUEST[$taxonomy_name.'-tab']) && isset($_REQUEST['paged']) ? absint($_REQUEST['paged']) : 1; |
|
| 895 | + $offset = 0 < $pagenum ? $per_page * ($pagenum - 1) : 0; |
|
| 896 | 896 | |
| 897 | 897 | $args = array( |
| 898 | 898 | 'child_of' => 0, |
@@ -907,19 +907,19 @@ discard block |
||
| 907 | 907 | 'pad_counts' => false, |
| 908 | 908 | ); |
| 909 | 909 | |
| 910 | - $terms = get_terms( $taxonomy_name, $args ); |
|
| 910 | + $terms = get_terms($taxonomy_name, $args); |
|
| 911 | 911 | |
| 912 | - if ( ! $terms || is_wp_error($terms) ) { |
|
| 913 | - echo '<p>' . __( 'No items.' ) . '</p>'; |
|
| 912 | + if ( ! $terms || is_wp_error($terms)) { |
|
| 913 | + echo '<p>'.__('No items.').'</p>'; |
|
| 914 | 914 | return; |
| 915 | 915 | } |
| 916 | 916 | |
| 917 | - $num_pages = ceil( wp_count_terms( $taxonomy_name , array_merge( $args, array('number' => '', 'offset' => '') ) ) / $per_page ); |
|
| 917 | + $num_pages = ceil(wp_count_terms($taxonomy_name, array_merge($args, array('number' => '', 'offset' => ''))) / $per_page); |
|
| 918 | 918 | |
| 919 | - $page_links = paginate_links( array( |
|
| 919 | + $page_links = paginate_links(array( |
|
| 920 | 920 | 'base' => add_query_arg( |
| 921 | 921 | array( |
| 922 | - $taxonomy_name . '-tab' => 'all', |
|
| 922 | + $taxonomy_name.'-tab' => 'all', |
|
| 923 | 923 | 'paged' => '%#%', |
| 924 | 924 | 'item-type' => 'taxonomy', |
| 925 | 925 | 'item-object' => $taxonomy_name, |
@@ -933,18 +933,18 @@ discard block |
||
| 933 | 933 | )); |
| 934 | 934 | |
| 935 | 935 | $db_fields = false; |
| 936 | - if ( is_taxonomy_hierarchical( $taxonomy_name ) ) { |
|
| 937 | - $db_fields = array( 'parent' => 'parent', 'id' => 'term_id' ); |
|
| 936 | + if (is_taxonomy_hierarchical($taxonomy_name)) { |
|
| 937 | + $db_fields = array('parent' => 'parent', 'id' => 'term_id'); |
|
| 938 | 938 | } |
| 939 | 939 | |
| 940 | - $walker = new Walker_Nav_Menu_Checklist( $db_fields ); |
|
| 940 | + $walker = new Walker_Nav_Menu_Checklist($db_fields); |
|
| 941 | 941 | |
| 942 | 942 | $current_tab = 'most-used'; |
| 943 | - if ( isset( $_REQUEST[$taxonomy_name . '-tab'] ) && in_array( $_REQUEST[$taxonomy_name . '-tab'], array('all', 'most-used', 'search') ) ) { |
|
| 944 | - $current_tab = $_REQUEST[$taxonomy_name . '-tab']; |
|
| 943 | + if (isset($_REQUEST[$taxonomy_name.'-tab']) && in_array($_REQUEST[$taxonomy_name.'-tab'], array('all', 'most-used', 'search'))) { |
|
| 944 | + $current_tab = $_REQUEST[$taxonomy_name.'-tab']; |
|
| 945 | 945 | } |
| 946 | 946 | |
| 947 | - if ( ! empty( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] ) ) { |
|
| 947 | + if ( ! empty($_REQUEST['quick-search-taxonomy-'.$taxonomy_name])) { |
|
| 948 | 948 | $current_tab = 'search'; |
| 949 | 949 | } |
| 950 | 950 | |
@@ -960,39 +960,39 @@ discard block |
||
| 960 | 960 | ?> |
| 961 | 961 | <div id="taxonomy-<?php echo $taxonomy_name; ?>" class="taxonomydiv"> |
| 962 | 962 | <ul id="taxonomy-<?php echo $taxonomy_name; ?>-tabs" class="taxonomy-tabs add-menu-item-tabs"> |
| 963 | - <li <?php echo ( 'most-used' == $current_tab ? ' class="tabs"' : '' ); ?>> |
|
| 964 | - <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-pop" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'most-used', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-pop"> |
|
| 965 | - <?php _e( 'Most Used' ); ?> |
|
| 963 | + <li <?php echo ('most-used' == $current_tab ? ' class="tabs"' : ''); ?>> |
|
| 964 | + <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr($taxonomy_name); ?>-pop" href="<?php if ($nav_menu_selected_id) echo esc_url(add_query_arg($taxonomy_name.'-tab', 'most-used', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-pop"> |
|
| 965 | + <?php _e('Most Used'); ?> |
|
| 966 | 966 | </a> |
| 967 | 967 | </li> |
| 968 | - <li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>> |
|
| 969 | - <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'all', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-all"> |
|
| 970 | - <?php _e( 'View All' ); ?> |
|
| 968 | + <li <?php echo ('all' == $current_tab ? ' class="tabs"' : ''); ?>> |
|
| 969 | + <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr($taxonomy_name); ?>-all" href="<?php if ($nav_menu_selected_id) echo esc_url(add_query_arg($taxonomy_name.'-tab', 'all', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-all"> |
|
| 970 | + <?php _e('View All'); ?> |
|
| 971 | 971 | </a> |
| 972 | 972 | </li> |
| 973 | - <li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>> |
|
| 974 | - <a class="nav-tab-link" data-type="tabs-panel-search-taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>"> |
|
| 975 | - <?php _e( 'Search' ); ?> |
|
| 973 | + <li <?php echo ('search' == $current_tab ? ' class="tabs"' : ''); ?>> |
|
| 974 | + <a class="nav-tab-link" data-type="tabs-panel-search-taxonomy-<?php echo esc_attr($taxonomy_name); ?>" href="<?php if ($nav_menu_selected_id) echo esc_url(add_query_arg($taxonomy_name.'-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>"> |
|
| 975 | + <?php _e('Search'); ?> |
|
| 976 | 976 | </a> |
| 977 | 977 | </li> |
| 978 | 978 | </ul><!-- .taxonomy-tabs --> |
| 979 | 979 | |
| 980 | 980 | <div id="tabs-panel-<?php echo $taxonomy_name; ?>-pop" class="tabs-panel <?php |
| 981 | - echo ( 'most-used' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); |
|
| 981 | + echo ('most-used' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
| 982 | 982 | ?>"> |
| 983 | 983 | <ul id="<?php echo $taxonomy_name; ?>checklist-pop" class="categorychecklist form-no-clear" > |
| 984 | 984 | <?php |
| 985 | - $popular_terms = get_terms( $taxonomy_name, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) ); |
|
| 985 | + $popular_terms = get_terms($taxonomy_name, array('orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false)); |
|
| 986 | 986 | $args['walker'] = $walker; |
| 987 | - echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $popular_terms), 0, (object) $args ); |
|
| 987 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $popular_terms), 0, (object) $args); |
|
| 988 | 988 | ?> |
| 989 | 989 | </ul> |
| 990 | 990 | </div><!-- /.tabs-panel --> |
| 991 | 991 | |
| 992 | 992 | <div id="tabs-panel-<?php echo $taxonomy_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php |
| 993 | - echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); |
|
| 993 | + echo ('all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
| 994 | 994 | ?>"> |
| 995 | - <?php if ( ! empty( $page_links ) ) : ?> |
|
| 995 | + <?php if ( ! empty($page_links)) : ?> |
|
| 996 | 996 | <div class="add-menu-item-pagelinks"> |
| 997 | 997 | <?php echo $page_links; ?> |
| 998 | 998 | </div> |
@@ -1000,10 +1000,10 @@ discard block |
||
| 1000 | 1000 | <ul id="<?php echo $taxonomy_name; ?>checklist" data-wp-lists="list:<?php echo $taxonomy_name?>" class="categorychecklist form-no-clear"> |
| 1001 | 1001 | <?php |
| 1002 | 1002 | $args['walker'] = $walker; |
| 1003 | - echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $terms), 0, (object) $args ); |
|
| 1003 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $terms), 0, (object) $args); |
|
| 1004 | 1004 | ?> |
| 1005 | 1005 | </ul> |
| 1006 | - <?php if ( ! empty( $page_links ) ) : ?> |
|
| 1006 | + <?php if ( ! empty($page_links)) : ?> |
|
| 1007 | 1007 | <div class="add-menu-item-pagelinks"> |
| 1008 | 1008 | <?php echo $page_links; ?> |
| 1009 | 1009 | </div> |
@@ -1011,12 +1011,12 @@ discard block |
||
| 1011 | 1011 | </div><!-- /.tabs-panel --> |
| 1012 | 1012 | |
| 1013 | 1013 | <div class="tabs-panel <?php |
| 1014 | - echo ( 'search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); |
|
| 1014 | + echo ('search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
| 1015 | 1015 | ?>" id="tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>"> |
| 1016 | 1016 | <?php |
| 1017 | - if ( isset( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] ) ) { |
|
| 1018 | - $searched = esc_attr( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] ); |
|
| 1019 | - $search_results = get_terms( $taxonomy_name, array( 'name__like' => $searched, 'fields' => 'all', 'orderby' => 'count', 'order' => 'DESC', 'hierarchical' => false ) ); |
|
| 1017 | + if (isset($_REQUEST['quick-search-taxonomy-'.$taxonomy_name])) { |
|
| 1018 | + $searched = esc_attr($_REQUEST['quick-search-taxonomy-'.$taxonomy_name]); |
|
| 1019 | + $search_results = get_terms($taxonomy_name, array('name__like' => $searched, 'fields' => 'all', 'orderby' => 'count', 'order' => 'DESC', 'hierarchical' => false)); |
|
| 1020 | 1020 | } else { |
| 1021 | 1021 | $searched = ''; |
| 1022 | 1022 | $search_results = array(); |
@@ -1025,18 +1025,18 @@ discard block |
||
| 1025 | 1025 | <p class="quick-search-wrap"> |
| 1026 | 1026 | <input type="search" class="quick-search input-with-default-title" title="<?php esc_attr_e('Search'); ?>" value="<?php echo $searched; ?>" name="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" /> |
| 1027 | 1027 | <span class="spinner"></span> |
| 1028 | - <?php submit_button( __( 'Search' ), 'button-small quick-search-submit button-secondary hide-if-js', 'submit', false, array( 'id' => 'submit-quick-search-taxonomy-' . $taxonomy_name ) ); ?> |
|
| 1028 | + <?php submit_button(__('Search'), 'button-small quick-search-submit button-secondary hide-if-js', 'submit', false, array('id' => 'submit-quick-search-taxonomy-'.$taxonomy_name)); ?> |
|
| 1029 | 1029 | </p> |
| 1030 | 1030 | |
| 1031 | 1031 | <ul id="<?php echo $taxonomy_name; ?>-search-checklist" data-wp-lists="list:<?php echo $taxonomy_name?>" class="categorychecklist form-no-clear"> |
| 1032 | - <?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?> |
|
| 1032 | + <?php if ( ! empty($search_results) && ! is_wp_error($search_results)) : ?> |
|
| 1033 | 1033 | <?php |
| 1034 | 1034 | $args['walker'] = $walker; |
| 1035 | - echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args ); |
|
| 1035 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args); |
|
| 1036 | 1036 | ?> |
| 1037 | - <?php elseif ( is_wp_error( $search_results ) ) : ?> |
|
| 1037 | + <?php elseif (is_wp_error($search_results)) : ?> |
|
| 1038 | 1038 | <li><?php echo $search_results->get_error_message(); ?></li> |
| 1039 | - <?php elseif ( ! empty( $searched ) ) : ?> |
|
| 1039 | + <?php elseif ( ! empty($searched)) : ?> |
|
| 1040 | 1040 | <li><?php _e('No results found.'); ?></li> |
| 1041 | 1041 | <?php endif; ?> |
| 1042 | 1042 | </ul> |
@@ -1047,7 +1047,7 @@ discard block |
||
| 1047 | 1047 | <a href="<?php |
| 1048 | 1048 | echo esc_url(add_query_arg( |
| 1049 | 1049 | array( |
| 1050 | - $taxonomy_name . '-tab' => 'all', |
|
| 1050 | + $taxonomy_name.'-tab' => 'all', |
|
| 1051 | 1051 | 'selectall' => 1, |
| 1052 | 1052 | ), |
| 1053 | 1053 | remove_query_arg($removed_args) |
@@ -1056,7 +1056,7 @@ discard block |
||
| 1056 | 1056 | </span> |
| 1057 | 1057 | |
| 1058 | 1058 | <span class="add-to-menu"> |
| 1059 | - <input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" name="add-taxonomy-menu-item" id="<?php echo esc_attr( 'submit-taxonomy-' . $taxonomy_name ); ?>" /> |
|
| 1059 | + <input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-taxonomy-menu-item" id="<?php echo esc_attr('submit-taxonomy-'.$taxonomy_name); ?>" /> |
|
| 1060 | 1060 | <span class="spinner"></span> |
| 1061 | 1061 | </span> |
| 1062 | 1062 | </p> |
@@ -1074,25 +1074,25 @@ discard block |
||
| 1074 | 1074 | * @param array $menu_data The unsanitized posted menu item data. |
| 1075 | 1075 | * @return array The database IDs of the items saved |
| 1076 | 1076 | */ |
| 1077 | -function wp_save_nav_menu_items( $menu_id = 0, $menu_data = array() ) { |
|
| 1077 | +function wp_save_nav_menu_items($menu_id = 0, $menu_data = array()) { |
|
| 1078 | 1078 | $menu_id = (int) $menu_id; |
| 1079 | 1079 | $items_saved = array(); |
| 1080 | 1080 | |
| 1081 | - if ( 0 == $menu_id || is_nav_menu( $menu_id ) ) { |
|
| 1081 | + if (0 == $menu_id || is_nav_menu($menu_id)) { |
|
| 1082 | 1082 | |
| 1083 | 1083 | // Loop through all the menu items' POST values. |
| 1084 | - foreach( (array) $menu_data as $_possible_db_id => $_item_object_data ) { |
|
| 1084 | + foreach ((array) $menu_data as $_possible_db_id => $_item_object_data) { |
|
| 1085 | 1085 | if ( |
| 1086 | 1086 | // Checkbox is not checked. |
| 1087 | - empty( $_item_object_data['menu-item-object-id'] ) && |
|
| 1087 | + empty($_item_object_data['menu-item-object-id']) && |
|
| 1088 | 1088 | ( |
| 1089 | 1089 | // And item type either isn't set. |
| 1090 | - ! isset( $_item_object_data['menu-item-type'] ) || |
|
| 1090 | + ! isset($_item_object_data['menu-item-type']) || |
|
| 1091 | 1091 | // Or URL is the default. |
| 1092 | - in_array( $_item_object_data['menu-item-url'], array( 'http://', '' ) ) || |
|
| 1093 | - ! ( 'custom' == $_item_object_data['menu-item-type'] && ! isset( $_item_object_data['menu-item-db-id'] ) ) || // or it's not a custom menu item (but not the custom home page) |
|
| 1092 | + in_array($_item_object_data['menu-item-url'], array('http://', '')) || |
|
| 1093 | + ! ('custom' == $_item_object_data['menu-item-type'] && ! isset($_item_object_data['menu-item-db-id'])) || // or it's not a custom menu item (but not the custom home page) |
|
| 1094 | 1094 | // Or it *is* a custom menu item that already exists. |
| 1095 | - ! empty( $_item_object_data['menu-item-db-id'] ) |
|
| 1095 | + ! empty($_item_object_data['menu-item-db-id']) |
|
| 1096 | 1096 | ) |
| 1097 | 1097 | ) { |
| 1098 | 1098 | // Then this potential menu item is not getting added to this menu. |
@@ -1101,8 +1101,8 @@ discard block |
||
| 1101 | 1101 | |
| 1102 | 1102 | // If this possible menu item doesn't actually have a menu database ID yet. |
| 1103 | 1103 | if ( |
| 1104 | - empty( $_item_object_data['menu-item-db-id'] ) || |
|
| 1105 | - ( 0 > $_possible_db_id ) || |
|
| 1104 | + empty($_item_object_data['menu-item-db-id']) || |
|
| 1105 | + (0 > $_possible_db_id) || |
|
| 1106 | 1106 | $_possible_db_id != $_item_object_data['menu-item-db-id'] |
| 1107 | 1107 | ) { |
| 1108 | 1108 | $_actual_db_id = 0; |
@@ -1111,22 +1111,22 @@ discard block |
||
| 1111 | 1111 | } |
| 1112 | 1112 | |
| 1113 | 1113 | $args = array( |
| 1114 | - 'menu-item-db-id' => ( isset( $_item_object_data['menu-item-db-id'] ) ? $_item_object_data['menu-item-db-id'] : '' ), |
|
| 1115 | - 'menu-item-object-id' => ( isset( $_item_object_data['menu-item-object-id'] ) ? $_item_object_data['menu-item-object-id'] : '' ), |
|
| 1116 | - 'menu-item-object' => ( isset( $_item_object_data['menu-item-object'] ) ? $_item_object_data['menu-item-object'] : '' ), |
|
| 1117 | - 'menu-item-parent-id' => ( isset( $_item_object_data['menu-item-parent-id'] ) ? $_item_object_data['menu-item-parent-id'] : '' ), |
|
| 1118 | - 'menu-item-position' => ( isset( $_item_object_data['menu-item-position'] ) ? $_item_object_data['menu-item-position'] : '' ), |
|
| 1119 | - 'menu-item-type' => ( isset( $_item_object_data['menu-item-type'] ) ? $_item_object_data['menu-item-type'] : '' ), |
|
| 1120 | - 'menu-item-title' => ( isset( $_item_object_data['menu-item-title'] ) ? $_item_object_data['menu-item-title'] : '' ), |
|
| 1121 | - 'menu-item-url' => ( isset( $_item_object_data['menu-item-url'] ) ? $_item_object_data['menu-item-url'] : '' ), |
|
| 1122 | - 'menu-item-description' => ( isset( $_item_object_data['menu-item-description'] ) ? $_item_object_data['menu-item-description'] : '' ), |
|
| 1123 | - 'menu-item-attr-title' => ( isset( $_item_object_data['menu-item-attr-title'] ) ? $_item_object_data['menu-item-attr-title'] : '' ), |
|
| 1124 | - 'menu-item-target' => ( isset( $_item_object_data['menu-item-target'] ) ? $_item_object_data['menu-item-target'] : '' ), |
|
| 1125 | - 'menu-item-classes' => ( isset( $_item_object_data['menu-item-classes'] ) ? $_item_object_data['menu-item-classes'] : '' ), |
|
| 1126 | - 'menu-item-xfn' => ( isset( $_item_object_data['menu-item-xfn'] ) ? $_item_object_data['menu-item-xfn'] : '' ), |
|
| 1114 | + 'menu-item-db-id' => (isset($_item_object_data['menu-item-db-id']) ? $_item_object_data['menu-item-db-id'] : ''), |
|
| 1115 | + 'menu-item-object-id' => (isset($_item_object_data['menu-item-object-id']) ? $_item_object_data['menu-item-object-id'] : ''), |
|
| 1116 | + 'menu-item-object' => (isset($_item_object_data['menu-item-object']) ? $_item_object_data['menu-item-object'] : ''), |
|
| 1117 | + 'menu-item-parent-id' => (isset($_item_object_data['menu-item-parent-id']) ? $_item_object_data['menu-item-parent-id'] : ''), |
|
| 1118 | + 'menu-item-position' => (isset($_item_object_data['menu-item-position']) ? $_item_object_data['menu-item-position'] : ''), |
|
| 1119 | + 'menu-item-type' => (isset($_item_object_data['menu-item-type']) ? $_item_object_data['menu-item-type'] : ''), |
|
| 1120 | + 'menu-item-title' => (isset($_item_object_data['menu-item-title']) ? $_item_object_data['menu-item-title'] : ''), |
|
| 1121 | + 'menu-item-url' => (isset($_item_object_data['menu-item-url']) ? $_item_object_data['menu-item-url'] : ''), |
|
| 1122 | + 'menu-item-description' => (isset($_item_object_data['menu-item-description']) ? $_item_object_data['menu-item-description'] : ''), |
|
| 1123 | + 'menu-item-attr-title' => (isset($_item_object_data['menu-item-attr-title']) ? $_item_object_data['menu-item-attr-title'] : ''), |
|
| 1124 | + 'menu-item-target' => (isset($_item_object_data['menu-item-target']) ? $_item_object_data['menu-item-target'] : ''), |
|
| 1125 | + 'menu-item-classes' => (isset($_item_object_data['menu-item-classes']) ? $_item_object_data['menu-item-classes'] : ''), |
|
| 1126 | + 'menu-item-xfn' => (isset($_item_object_data['menu-item-xfn']) ? $_item_object_data['menu-item-xfn'] : ''), |
|
| 1127 | 1127 | ); |
| 1128 | 1128 | |
| 1129 | - $items_saved[] = wp_update_nav_menu_item( $menu_id, $_actual_db_id, $args ); |
|
| 1129 | + $items_saved[] = wp_update_nav_menu_item($menu_id, $_actual_db_id, $args); |
|
| 1130 | 1130 | |
| 1131 | 1131 | } |
| 1132 | 1132 | } |
@@ -1143,23 +1143,23 @@ discard block |
||
| 1143 | 1143 | * @param object $object The post type or taxonomy meta-object. |
| 1144 | 1144 | * @return object The post type of taxonomy object. |
| 1145 | 1145 | */ |
| 1146 | -function _wp_nav_menu_meta_box_object( $object = null ) { |
|
| 1147 | - if ( isset( $object->name ) ) { |
|
| 1146 | +function _wp_nav_menu_meta_box_object($object = null) { |
|
| 1147 | + if (isset($object->name)) { |
|
| 1148 | 1148 | |
| 1149 | - if ( 'page' == $object->name ) { |
|
| 1149 | + if ('page' == $object->name) { |
|
| 1150 | 1150 | $object->_default_query = array( |
| 1151 | 1151 | 'orderby' => 'menu_order title', |
| 1152 | 1152 | 'post_status' => 'publish', |
| 1153 | 1153 | ); |
| 1154 | 1154 | |
| 1155 | 1155 | // Posts should show only published items. |
| 1156 | - } elseif ( 'post' == $object->name ) { |
|
| 1156 | + } elseif ('post' == $object->name) { |
|
| 1157 | 1157 | $object->_default_query = array( |
| 1158 | 1158 | 'post_status' => 'publish', |
| 1159 | 1159 | ); |
| 1160 | 1160 | |
| 1161 | 1161 | // Categories should be in reverse chronological order. |
| 1162 | - } elseif ( 'category' == $object->name ) { |
|
| 1162 | + } elseif ('category' == $object->name) { |
|
| 1163 | 1163 | $object->_default_query = array( |
| 1164 | 1164 | 'orderby' => 'id', |
| 1165 | 1165 | 'order' => 'DESC', |
@@ -1184,19 +1184,19 @@ discard block |
||
| 1184 | 1184 | * @param int $menu_id Optional. The ID of the menu to format. Default 0. |
| 1185 | 1185 | * @return string|WP_Error $output The menu formatted to edit or error object on failure. |
| 1186 | 1186 | */ |
| 1187 | -function wp_get_nav_menu_to_edit( $menu_id = 0 ) { |
|
| 1188 | - $menu = wp_get_nav_menu_object( $menu_id ); |
|
| 1187 | +function wp_get_nav_menu_to_edit($menu_id = 0) { |
|
| 1188 | + $menu = wp_get_nav_menu_object($menu_id); |
|
| 1189 | 1189 | |
| 1190 | 1190 | // If the menu exists, get its items. |
| 1191 | - if ( is_nav_menu( $menu ) ) { |
|
| 1192 | - $menu_items = wp_get_nav_menu_items( $menu->term_id, array('post_status' => 'any') ); |
|
| 1191 | + if (is_nav_menu($menu)) { |
|
| 1192 | + $menu_items = wp_get_nav_menu_items($menu->term_id, array('post_status' => 'any')); |
|
| 1193 | 1193 | $result = '<div id="menu-instructions" class="post-body-plain'; |
| 1194 | - $result .= ( ! empty($menu_items) ) ? ' menu-instructions-inactive">' : '">'; |
|
| 1195 | - $result .= '<p>' . __( 'Add menu items from the column on the left.' ) . '</p>'; |
|
| 1194 | + $result .= ( ! empty($menu_items)) ? ' menu-instructions-inactive">' : '">'; |
|
| 1195 | + $result .= '<p>'.__('Add menu items from the column on the left.').'</p>'; |
|
| 1196 | 1196 | $result .= '</div>'; |
| 1197 | 1197 | |
| 1198 | - if ( empty($menu_items) ) |
|
| 1199 | - return $result . ' <ul class="menu" id="menu-to-edit"> </ul>'; |
|
| 1198 | + if (empty($menu_items)) |
|
| 1199 | + return $result.' <ul class="menu" id="menu-to-edit"> </ul>'; |
|
| 1200 | 1200 | |
| 1201 | 1201 | /** |
| 1202 | 1202 | * Filter the Walker class used when adding nav menu items. |
@@ -1206,32 +1206,32 @@ discard block |
||
| 1206 | 1206 | * @param string $class The walker class to use. Default 'Walker_Nav_Menu_Edit'. |
| 1207 | 1207 | * @param int $menu_id ID of the menu being rendered. |
| 1208 | 1208 | */ |
| 1209 | - $walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id ); |
|
| 1209 | + $walker_class_name = apply_filters('wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id); |
|
| 1210 | 1210 | |
| 1211 | - if ( class_exists( $walker_class_name ) ) |
|
| 1211 | + if (class_exists($walker_class_name)) |
|
| 1212 | 1212 | $walker = new $walker_class_name; |
| 1213 | 1213 | else |
| 1214 | - return new WP_Error( 'menu_walker_not_exist', sprintf( __('The Walker class named <strong>%s</strong> does not exist.'), $walker_class_name ) ); |
|
| 1214 | + return new WP_Error('menu_walker_not_exist', sprintf(__('The Walker class named <strong>%s</strong> does not exist.'), $walker_class_name)); |
|
| 1215 | 1215 | |
| 1216 | 1216 | $some_pending_menu_items = $some_invalid_menu_items = false; |
| 1217 | - foreach( (array) $menu_items as $menu_item ) { |
|
| 1218 | - if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status ) |
|
| 1217 | + foreach ((array) $menu_items as $menu_item) { |
|
| 1218 | + if (isset($menu_item->post_status) && 'draft' == $menu_item->post_status) |
|
| 1219 | 1219 | $some_pending_menu_items = true; |
| 1220 | - if ( ! empty( $menu_item->_invalid ) ) |
|
| 1220 | + if ( ! empty($menu_item->_invalid)) |
|
| 1221 | 1221 | $some_invalid_menu_items = true; |
| 1222 | 1222 | } |
| 1223 | 1223 | |
| 1224 | - if ( $some_pending_menu_items ) |
|
| 1225 | - $result .= '<div class="updated inline"><p>' . __('Click Save Menu to make pending menu items public.') . '</p></div>'; |
|
| 1224 | + if ($some_pending_menu_items) |
|
| 1225 | + $result .= '<div class="updated inline"><p>'.__('Click Save Menu to make pending menu items public.').'</p></div>'; |
|
| 1226 | 1226 | |
| 1227 | - if ( $some_invalid_menu_items ) |
|
| 1228 | - $result .= '<div class="error inline"><p>' . __('There are some invalid menu items. Please check or delete them.') . '</p></div>'; |
|
| 1227 | + if ($some_invalid_menu_items) |
|
| 1228 | + $result .= '<div class="error inline"><p>'.__('There are some invalid menu items. Please check or delete them.').'</p></div>'; |
|
| 1229 | 1229 | |
| 1230 | 1230 | $result .= '<ul class="menu" id="menu-to-edit"> '; |
| 1231 | - $result .= walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker ) ); |
|
| 1231 | + $result .= walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker)); |
|
| 1232 | 1232 | $result .= ' </ul> '; |
| 1233 | 1233 | return $result; |
| 1234 | - } elseif ( is_wp_error( $menu ) ) { |
|
| 1234 | + } elseif (is_wp_error($menu)) { |
|
| 1235 | 1235 | return $menu; |
| 1236 | 1236 | } |
| 1237 | 1237 | |
@@ -1266,13 +1266,13 @@ discard block |
||
| 1266 | 1266 | */ |
| 1267 | 1267 | function _wp_delete_orphaned_draft_menu_items() { |
| 1268 | 1268 | global $wpdb; |
| 1269 | - $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ); |
|
| 1269 | + $delete_timestamp = time() - (DAY_IN_SECONDS * EMPTY_TRASH_DAYS); |
|
| 1270 | 1270 | |
| 1271 | 1271 | // Delete orphaned draft menu items. |
| 1272 | - $menu_items_to_delete = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'draft' AND meta_key = '_menu_item_orphaned' AND meta_value < '%d'", $delete_timestamp ) ); |
|
| 1272 | + $menu_items_to_delete = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'draft' AND meta_key = '_menu_item_orphaned' AND meta_value < '%d'", $delete_timestamp)); |
|
| 1273 | 1273 | |
| 1274 | - foreach( (array) $menu_items_to_delete as $menu_item_id ) |
|
| 1275 | - wp_delete_post( $menu_item_id, true ); |
|
| 1274 | + foreach ((array) $menu_items_to_delete as $menu_item_id) |
|
| 1275 | + wp_delete_post($menu_item_id, true); |
|
| 1276 | 1276 | } |
| 1277 | 1277 | |
| 1278 | 1278 | /** |
@@ -1284,12 +1284,12 @@ discard block |
||
| 1284 | 1284 | * @param string $nav_menu_selected_title Title of the currently-selected menu |
| 1285 | 1285 | * @return array $messages The menu updated message |
| 1286 | 1286 | */ |
| 1287 | -function wp_nav_menu_update_menu_items ( $nav_menu_selected_id, $nav_menu_selected_title ) { |
|
| 1288 | - $unsorted_menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array( 'orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID', 'post_status' => 'draft,publish' ) ); |
|
| 1287 | +function wp_nav_menu_update_menu_items($nav_menu_selected_id, $nav_menu_selected_title) { |
|
| 1288 | + $unsorted_menu_items = wp_get_nav_menu_items($nav_menu_selected_id, array('orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID', 'post_status' => 'draft,publish')); |
|
| 1289 | 1289 | $messages = array(); |
| 1290 | 1290 | $menu_items = array(); |
| 1291 | 1291 | // Index menu items by db ID |
| 1292 | - foreach ( $unsorted_menu_items as $_item ) |
|
| 1292 | + foreach ($unsorted_menu_items as $_item) |
|
| 1293 | 1293 | $menu_items[$_item->db_id] = $_item; |
| 1294 | 1294 | |
| 1295 | 1295 | $post_fields = array( |
@@ -1299,61 +1299,61 @@ discard block |
||
| 1299 | 1299 | 'menu-item-attr-title', 'menu-item-target', 'menu-item-classes', 'menu-item-xfn' |
| 1300 | 1300 | ); |
| 1301 | 1301 | |
| 1302 | - wp_defer_term_counting( true ); |
|
| 1302 | + wp_defer_term_counting(true); |
|
| 1303 | 1303 | // Loop through all the menu items' POST variables |
| 1304 | - if ( ! empty( $_POST['menu-item-db-id'] ) ) { |
|
| 1305 | - foreach( (array) $_POST['menu-item-db-id'] as $_key => $k ) { |
|
| 1304 | + if ( ! empty($_POST['menu-item-db-id'])) { |
|
| 1305 | + foreach ((array) $_POST['menu-item-db-id'] as $_key => $k) { |
|
| 1306 | 1306 | |
| 1307 | 1307 | // Menu item title can't be blank |
| 1308 | - if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] ) |
|
| 1308 | + if ( ! isset($_POST['menu-item-title'][$_key]) || '' == $_POST['menu-item-title'][$_key]) |
|
| 1309 | 1309 | continue; |
| 1310 | 1310 | |
| 1311 | 1311 | $args = array(); |
| 1312 | - foreach ( $post_fields as $field ) |
|
| 1313 | - $args[$field] = isset( $_POST[$field][$_key] ) ? $_POST[$field][$_key] : ''; |
|
| 1312 | + foreach ($post_fields as $field) |
|
| 1313 | + $args[$field] = isset($_POST[$field][$_key]) ? $_POST[$field][$_key] : ''; |
|
| 1314 | 1314 | |
| 1315 | - $menu_item_db_id = wp_update_nav_menu_item( $nav_menu_selected_id, ( $_POST['menu-item-db-id'][$_key] != $_key ? 0 : $_key ), $args ); |
|
| 1315 | + $menu_item_db_id = wp_update_nav_menu_item($nav_menu_selected_id, ($_POST['menu-item-db-id'][$_key] != $_key ? 0 : $_key), $args); |
|
| 1316 | 1316 | |
| 1317 | - if ( is_wp_error( $menu_item_db_id ) ) { |
|
| 1318 | - $messages[] = '<div id="message" class="error"><p>' . $menu_item_db_id->get_error_message() . '</p></div>'; |
|
| 1317 | + if (is_wp_error($menu_item_db_id)) { |
|
| 1318 | + $messages[] = '<div id="message" class="error"><p>'.$menu_item_db_id->get_error_message().'</p></div>'; |
|
| 1319 | 1319 | } else { |
| 1320 | - unset( $menu_items[ $menu_item_db_id ] ); |
|
| 1320 | + unset($menu_items[$menu_item_db_id]); |
|
| 1321 | 1321 | } |
| 1322 | 1322 | } |
| 1323 | 1323 | } |
| 1324 | 1324 | |
| 1325 | 1325 | // Remove menu items from the menu that weren't in $_POST |
| 1326 | - if ( ! empty( $menu_items ) ) { |
|
| 1327 | - foreach ( array_keys( $menu_items ) as $menu_item_id ) { |
|
| 1328 | - if ( is_nav_menu_item( $menu_item_id ) ) { |
|
| 1329 | - wp_delete_post( $menu_item_id ); |
|
| 1326 | + if ( ! empty($menu_items)) { |
|
| 1327 | + foreach (array_keys($menu_items) as $menu_item_id) { |
|
| 1328 | + if (is_nav_menu_item($menu_item_id)) { |
|
| 1329 | + wp_delete_post($menu_item_id); |
|
| 1330 | 1330 | } |
| 1331 | 1331 | } |
| 1332 | 1332 | } |
| 1333 | 1333 | |
| 1334 | 1334 | // Store 'auto-add' pages. |
| 1335 | - $auto_add = ! empty( $_POST['auto-add-pages'] ); |
|
| 1336 | - $nav_menu_option = (array) get_option( 'nav_menu_options' ); |
|
| 1337 | - if ( ! isset( $nav_menu_option['auto_add'] ) ) |
|
| 1335 | + $auto_add = ! empty($_POST['auto-add-pages']); |
|
| 1336 | + $nav_menu_option = (array) get_option('nav_menu_options'); |
|
| 1337 | + if ( ! isset($nav_menu_option['auto_add'])) |
|
| 1338 | 1338 | $nav_menu_option['auto_add'] = array(); |
| 1339 | - if ( $auto_add ) { |
|
| 1340 | - if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) |
|
| 1339 | + if ($auto_add) { |
|
| 1340 | + if ( ! in_array($nav_menu_selected_id, $nav_menu_option['auto_add'])) |
|
| 1341 | 1341 | $nav_menu_option['auto_add'][] = $nav_menu_selected_id; |
| 1342 | 1342 | } else { |
| 1343 | - if ( false !== ( $key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) ) |
|
| 1344 | - unset( $nav_menu_option['auto_add'][$key] ); |
|
| 1343 | + if (false !== ($key = array_search($nav_menu_selected_id, $nav_menu_option['auto_add']))) |
|
| 1344 | + unset($nav_menu_option['auto_add'][$key]); |
|
| 1345 | 1345 | } |
| 1346 | 1346 | // Remove nonexistent/deleted menus |
| 1347 | - $nav_menu_option['auto_add'] = array_intersect( $nav_menu_option['auto_add'], wp_get_nav_menus( array( 'fields' => 'ids' ) ) ); |
|
| 1348 | - update_option( 'nav_menu_options', $nav_menu_option ); |
|
| 1347 | + $nav_menu_option['auto_add'] = array_intersect($nav_menu_option['auto_add'], wp_get_nav_menus(array('fields' => 'ids'))); |
|
| 1348 | + update_option('nav_menu_options', $nav_menu_option); |
|
| 1349 | 1349 | |
| 1350 | - wp_defer_term_counting( false ); |
|
| 1350 | + wp_defer_term_counting(false); |
|
| 1351 | 1351 | |
| 1352 | 1352 | /** This action is documented in wp-includes/nav-menu.php */ |
| 1353 | - do_action( 'wp_update_nav_menu', $nav_menu_selected_id ); |
|
| 1353 | + do_action('wp_update_nav_menu', $nav_menu_selected_id); |
|
| 1354 | 1354 | |
| 1355 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( __( '<strong>%1$s</strong> has been updated.' ), $nav_menu_selected_title ) . '</p></div>'; |
|
| 1356 | - unset( $menu_items, $unsorted_menu_items ); |
|
| 1355 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>'.sprintf(__('<strong>%1$s</strong> has been updated.'), $nav_menu_selected_title).'</p></div>'; |
|
| 1356 | + unset($menu_items, $unsorted_menu_items); |
|
| 1357 | 1357 | |
| 1358 | 1358 | return $messages; |
| 1359 | 1359 | } |
@@ -66,8 +66,9 @@ discard block |
||
| 66 | 66 | $original_title = ''; |
| 67 | 67 | if ( 'taxonomy' == $item->type ) { |
| 68 | 68 | $original_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' ); |
| 69 | - if ( is_wp_error( $original_title ) ) |
|
| 70 | - $original_title = false; |
|
| 69 | + if ( is_wp_error( $original_title ) ) { |
|
| 70 | + $original_title = false; |
|
| 71 | + } |
|
| 71 | 72 | } elseif ( 'post_type' == $item->type ) { |
| 72 | 73 | $original_object = get_post( $item->object_id ); |
| 73 | 74 | $original_title = get_the_title( $original_object->ID ); |
@@ -94,8 +95,9 @@ discard block |
||
| 94 | 95 | $title = ( ! isset( $item->label ) || '' == $item->label ) ? $title : $item->label; |
| 95 | 96 | |
| 96 | 97 | $submenu_text = ''; |
| 97 | - if ( 0 == $depth ) |
|
| 98 | - $submenu_text = 'style="display: none;"'; |
|
| 98 | + if ( 0 == $depth ) { |
|
| 99 | + $submenu_text = 'style="display: none;"'; |
|
| 100 | + } |
|
| 99 | 101 | |
| 100 | 102 | ?> |
| 101 | 103 | <li id="menu-item-<?php echo $item_id; ?>" class="<?php echo implode(' ', $classes ); ?>"> |
@@ -307,8 +309,9 @@ discard block |
||
| 307 | 309 | $output .= '<label class="menu-item-title">'; |
| 308 | 310 | $output .= '<input type="checkbox" class="menu-item-checkbox'; |
| 309 | 311 | |
| 310 | - if ( ! empty( $item->front_or_home ) ) |
|
| 311 | - $output .= ' add-to-top'; |
|
| 312 | + if ( ! empty( $item->front_or_home ) ) { |
|
| 313 | + $output .= ' add-to-top'; |
|
| 314 | + } |
|
| 312 | 315 | |
| 313 | 316 | $output .= '" name="menu-item[' . $possible_object_id . '][menu-item-object-id]" value="'. esc_attr( $item->object_id ) .'" /> '; |
| 314 | 317 | |
@@ -317,8 +320,9 @@ discard block |
||
| 317 | 320 | } elseif ( isset( $item->post_type ) ) { |
| 318 | 321 | /** This filter is documented in wp-includes/post-template.php */ |
| 319 | 322 | $title = apply_filters( 'the_title', $item->post_title, $item->ID ); |
| 320 | - if ( ! empty( $item->front_or_home ) && _x( 'Home', 'nav menu home label' ) !== $title ) |
|
| 321 | - $title = sprintf( _x( 'Home: %s', 'nav menu front page title' ), $title ); |
|
| 323 | + if ( ! empty( $item->front_or_home ) && _x( 'Home', 'nav menu home label' ) !== $title ) { |
|
| 324 | + $title = sprintf( _x( 'Home: %s', 'nav menu front page title' ), $title ); |
|
| 325 | + } |
|
| 322 | 326 | } |
| 323 | 327 | |
| 324 | 328 | $output .= isset( $title ) ? esc_html( $title ) : esc_html( $item->title ); |
@@ -401,8 +405,9 @@ discard block |
||
| 401 | 405 | 'post_type' => $matches[2], |
| 402 | 406 | 's' => $query, |
| 403 | 407 | )); |
| 404 | - if ( ! have_posts() ) |
|
| 405 | - return; |
|
| 408 | + if ( ! have_posts() ) { |
|
| 409 | + return; |
|
| 410 | + } |
|
| 406 | 411 | while ( have_posts() ) { |
| 407 | 412 | the_post(); |
| 408 | 413 | if ( 'markup' == $response_format ) { |
@@ -424,8 +429,9 @@ discard block |
||
| 424 | 429 | 'name__like' => $query, |
| 425 | 430 | 'number' => 10, |
| 426 | 431 | )); |
| 427 | - if ( empty( $terms ) || is_wp_error( $terms ) ) |
|
| 428 | - return; |
|
| 432 | + if ( empty( $terms ) || is_wp_error( $terms ) ) { |
|
| 433 | + return; |
|
| 434 | + } |
|
| 429 | 435 | foreach( (array) $terms as $term ) { |
| 430 | 436 | if ( 'markup' == $response_format ) { |
| 431 | 437 | echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args ); |
@@ -477,8 +483,9 @@ discard block |
||
| 477 | 483 | function wp_initial_nav_menu_meta_boxes() { |
| 478 | 484 | global $wp_meta_boxes; |
| 479 | 485 | |
| 480 | - if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array($wp_meta_boxes) ) |
|
| 481 | - return; |
|
| 486 | + if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array($wp_meta_boxes) ) { |
|
| 487 | + return; |
|
| 488 | + } |
|
| 482 | 489 | |
| 483 | 490 | $initial_meta_boxes = array( 'add-page', 'add-post', 'add-custom-links', 'add-category' ); |
| 484 | 491 | $hidden_meta_boxes = array(); |
@@ -507,8 +514,9 @@ discard block |
||
| 507 | 514 | function wp_nav_menu_post_type_meta_boxes() { |
| 508 | 515 | $post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'object' ); |
| 509 | 516 | |
| 510 | - if ( ! $post_types ) |
|
| 511 | - return; |
|
| 517 | + if ( ! $post_types ) { |
|
| 518 | + return; |
|
| 519 | + } |
|
| 512 | 520 | |
| 513 | 521 | foreach ( $post_types as $post_type ) { |
| 514 | 522 | /** |
@@ -541,8 +549,9 @@ discard block |
||
| 541 | 549 | function wp_nav_menu_taxonomy_meta_boxes() { |
| 542 | 550 | $taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'object' ); |
| 543 | 551 | |
| 544 | - if ( !$taxonomies ) |
|
| 545 | - return; |
|
| 552 | + if ( !$taxonomies ) { |
|
| 553 | + return; |
|
| 554 | + } |
|
| 546 | 555 | |
| 547 | 556 | foreach ( $taxonomies as $tax ) { |
| 548 | 557 | /** This filter is documented in wp-admin/includes/nav-menu.php */ |
@@ -567,8 +576,9 @@ discard block |
||
| 567 | 576 | function wp_nav_menu_disabled_check( $nav_menu_selected_id ) { |
| 568 | 577 | global $one_theme_location_no_menus; |
| 569 | 578 | |
| 570 | - if ( $one_theme_location_no_menus ) |
|
| 571 | - return false; |
|
| 579 | + if ( $one_theme_location_no_menus ) { |
|
| 580 | + return false; |
|
| 581 | + } |
|
| 572 | 582 | |
| 573 | 583 | return disabled( $nav_menu_selected_id, 0 ); |
| 574 | 584 | } |
@@ -646,8 +656,9 @@ discard block |
||
| 646 | 656 | 'update_post_meta_cache' => false |
| 647 | 657 | ); |
| 648 | 658 | |
| 649 | - if ( isset( $post_type['args']->_default_query ) ) |
|
| 650 | - $args = array_merge($args, (array) $post_type['args']->_default_query ); |
|
| 659 | + if ( isset( $post_type['args']->_default_query ) ) { |
|
| 660 | + $args = array_merge($args, (array) $post_type['args']->_default_query ); |
|
| 661 | + } |
|
| 651 | 662 | |
| 652 | 663 | // @todo transient caching of these results with proper invalidation on updating of a post of this type |
| 653 | 664 | $get_posts = new WP_Query; |
@@ -704,17 +715,26 @@ discard block |
||
| 704 | 715 | <div id="posttype-<?php echo $post_type_name; ?>" class="posttypediv"> |
| 705 | 716 | <ul id="posttype-<?php echo $post_type_name; ?>-tabs" class="posttype-tabs add-menu-item-tabs"> |
| 706 | 717 | <li <?php echo ( 'most-recent' == $current_tab ? ' class="tabs"' : '' ); ?>> |
| 707 | - <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-most-recent" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'most-recent', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent"> |
|
| 718 | + <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-most-recent" href="<?php if ( $nav_menu_selected_id ) { |
|
| 719 | + echo esc_url(add_query_arg($post_type_name . '-tab', 'most-recent', remove_query_arg($removed_args))); |
|
| 720 | +} |
|
| 721 | +?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent"> |
|
| 708 | 722 | <?php _e( 'Most Recent' ); ?> |
| 709 | 723 | </a> |
| 710 | 724 | </li> |
| 711 | 725 | <li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>> |
| 712 | - <a class="nav-tab-link" data-type="<?php echo esc_attr( $post_type_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'all', remove_query_arg($removed_args))); ?>#<?php echo $post_type_name; ?>-all"> |
|
| 726 | + <a class="nav-tab-link" data-type="<?php echo esc_attr( $post_type_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) { |
|
| 727 | + echo esc_url(add_query_arg($post_type_name . '-tab', 'all', remove_query_arg($removed_args))); |
|
| 728 | +} |
|
| 729 | +?>#<?php echo $post_type_name; ?>-all"> |
|
| 713 | 730 | <?php _e( 'View All' ); ?> |
| 714 | 731 | </a> |
| 715 | 732 | </li> |
| 716 | 733 | <li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>> |
| 717 | - <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-search" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search"> |
|
| 734 | + <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-search" href="<?php if ( $nav_menu_selected_id ) { |
|
| 735 | + echo esc_url(add_query_arg($post_type_name . '-tab', 'search', remove_query_arg($removed_args))); |
|
| 736 | +} |
|
| 737 | +?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search"> |
|
| 718 | 738 | <?php _e( 'Search'); ?> |
| 719 | 739 | </a> |
| 720 | 740 | </li> |
@@ -961,17 +981,26 @@ discard block |
||
| 961 | 981 | <div id="taxonomy-<?php echo $taxonomy_name; ?>" class="taxonomydiv"> |
| 962 | 982 | <ul id="taxonomy-<?php echo $taxonomy_name; ?>-tabs" class="taxonomy-tabs add-menu-item-tabs"> |
| 963 | 983 | <li <?php echo ( 'most-used' == $current_tab ? ' class="tabs"' : '' ); ?>> |
| 964 | - <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-pop" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'most-used', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-pop"> |
|
| 984 | + <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-pop" href="<?php if ( $nav_menu_selected_id ) { |
|
| 985 | + echo esc_url(add_query_arg($taxonomy_name . '-tab', 'most-used', remove_query_arg($removed_args))); |
|
| 986 | +} |
|
| 987 | +?>#tabs-panel-<?php echo $taxonomy_name; ?>-pop"> |
|
| 965 | 988 | <?php _e( 'Most Used' ); ?> |
| 966 | 989 | </a> |
| 967 | 990 | </li> |
| 968 | 991 | <li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>> |
| 969 | - <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'all', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-all"> |
|
| 992 | + <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) { |
|
| 993 | + echo esc_url(add_query_arg($taxonomy_name . '-tab', 'all', remove_query_arg($removed_args))); |
|
| 994 | +} |
|
| 995 | +?>#tabs-panel-<?php echo $taxonomy_name; ?>-all"> |
|
| 970 | 996 | <?php _e( 'View All' ); ?> |
| 971 | 997 | </a> |
| 972 | 998 | </li> |
| 973 | 999 | <li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>> |
| 974 | - <a class="nav-tab-link" data-type="tabs-panel-search-taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>"> |
|
| 1000 | + <a class="nav-tab-link" data-type="tabs-panel-search-taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>" href="<?php if ( $nav_menu_selected_id ) { |
|
| 1001 | + echo esc_url(add_query_arg($taxonomy_name . '-tab', 'search', remove_query_arg($removed_args))); |
|
| 1002 | +} |
|
| 1003 | +?>#tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>"> |
|
| 975 | 1004 | <?php _e( 'Search' ); ?> |
| 976 | 1005 | </a> |
| 977 | 1006 | </li> |
@@ -1195,8 +1224,9 @@ discard block |
||
| 1195 | 1224 | $result .= '<p>' . __( 'Add menu items from the column on the left.' ) . '</p>'; |
| 1196 | 1225 | $result .= '</div>'; |
| 1197 | 1226 | |
| 1198 | - if ( empty($menu_items) ) |
|
| 1199 | - return $result . ' <ul class="menu" id="menu-to-edit"> </ul>'; |
|
| 1227 | + if ( empty($menu_items) ) { |
|
| 1228 | + return $result . ' <ul class="menu" id="menu-to-edit"> </ul>'; |
|
| 1229 | + } |
|
| 1200 | 1230 | |
| 1201 | 1231 | /** |
| 1202 | 1232 | * Filter the Walker class used when adding nav menu items. |
@@ -1208,24 +1238,29 @@ discard block |
||
| 1208 | 1238 | */ |
| 1209 | 1239 | $walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id ); |
| 1210 | 1240 | |
| 1211 | - if ( class_exists( $walker_class_name ) ) |
|
| 1212 | - $walker = new $walker_class_name; |
|
| 1213 | - else |
|
| 1214 | - return new WP_Error( 'menu_walker_not_exist', sprintf( __('The Walker class named <strong>%s</strong> does not exist.'), $walker_class_name ) ); |
|
| 1241 | + if ( class_exists( $walker_class_name ) ) { |
|
| 1242 | + $walker = new $walker_class_name; |
|
| 1243 | + } else { |
|
| 1244 | + return new WP_Error( 'menu_walker_not_exist', sprintf( __('The Walker class named <strong>%s</strong> does not exist.'), $walker_class_name ) ); |
|
| 1245 | + } |
|
| 1215 | 1246 | |
| 1216 | 1247 | $some_pending_menu_items = $some_invalid_menu_items = false; |
| 1217 | 1248 | foreach( (array) $menu_items as $menu_item ) { |
| 1218 | - if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status ) |
|
| 1219 | - $some_pending_menu_items = true; |
|
| 1220 | - if ( ! empty( $menu_item->_invalid ) ) |
|
| 1221 | - $some_invalid_menu_items = true; |
|
| 1249 | + if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status ) { |
|
| 1250 | + $some_pending_menu_items = true; |
|
| 1251 | + } |
|
| 1252 | + if ( ! empty( $menu_item->_invalid ) ) { |
|
| 1253 | + $some_invalid_menu_items = true; |
|
| 1254 | + } |
|
| 1222 | 1255 | } |
| 1223 | 1256 | |
| 1224 | - if ( $some_pending_menu_items ) |
|
| 1225 | - $result .= '<div class="updated inline"><p>' . __('Click Save Menu to make pending menu items public.') . '</p></div>'; |
|
| 1257 | + if ( $some_pending_menu_items ) { |
|
| 1258 | + $result .= '<div class="updated inline"><p>' . __('Click Save Menu to make pending menu items public.') . '</p></div>'; |
|
| 1259 | + } |
|
| 1226 | 1260 | |
| 1227 | - if ( $some_invalid_menu_items ) |
|
| 1228 | - $result .= '<div class="error inline"><p>' . __('There are some invalid menu items. Please check or delete them.') . '</p></div>'; |
|
| 1261 | + if ( $some_invalid_menu_items ) { |
|
| 1262 | + $result .= '<div class="error inline"><p>' . __('There are some invalid menu items. Please check or delete them.') . '</p></div>'; |
|
| 1263 | + } |
|
| 1229 | 1264 | |
| 1230 | 1265 | $result .= '<ul class="menu" id="menu-to-edit"> '; |
| 1231 | 1266 | $result .= walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker ) ); |
@@ -1271,9 +1306,10 @@ discard block |
||
| 1271 | 1306 | // Delete orphaned draft menu items. |
| 1272 | 1307 | $menu_items_to_delete = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'draft' AND meta_key = '_menu_item_orphaned' AND meta_value < '%d'", $delete_timestamp ) ); |
| 1273 | 1308 | |
| 1274 | - foreach( (array) $menu_items_to_delete as $menu_item_id ) |
|
| 1275 | - wp_delete_post( $menu_item_id, true ); |
|
| 1276 | -} |
|
| 1309 | + foreach( (array) $menu_items_to_delete as $menu_item_id ) { |
|
| 1310 | + wp_delete_post( $menu_item_id, true ); |
|
| 1311 | + } |
|
| 1312 | + } |
|
| 1277 | 1313 | |
| 1278 | 1314 | /** |
| 1279 | 1315 | * Saves nav menu items |
@@ -1289,8 +1325,9 @@ discard block |
||
| 1289 | 1325 | $messages = array(); |
| 1290 | 1326 | $menu_items = array(); |
| 1291 | 1327 | // Index menu items by db ID |
| 1292 | - foreach ( $unsorted_menu_items as $_item ) |
|
| 1293 | - $menu_items[$_item->db_id] = $_item; |
|
| 1328 | + foreach ( $unsorted_menu_items as $_item ) { |
|
| 1329 | + $menu_items[$_item->db_id] = $_item; |
|
| 1330 | + } |
|
| 1294 | 1331 | |
| 1295 | 1332 | $post_fields = array( |
| 1296 | 1333 | 'menu-item-db-id', 'menu-item-object-id', 'menu-item-object', |
@@ -1305,12 +1342,14 @@ discard block |
||
| 1305 | 1342 | foreach( (array) $_POST['menu-item-db-id'] as $_key => $k ) { |
| 1306 | 1343 | |
| 1307 | 1344 | // Menu item title can't be blank |
| 1308 | - if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] ) |
|
| 1309 | - continue; |
|
| 1345 | + if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] ) { |
|
| 1346 | + continue; |
|
| 1347 | + } |
|
| 1310 | 1348 | |
| 1311 | 1349 | $args = array(); |
| 1312 | - foreach ( $post_fields as $field ) |
|
| 1313 | - $args[$field] = isset( $_POST[$field][$_key] ) ? $_POST[$field][$_key] : ''; |
|
| 1350 | + foreach ( $post_fields as $field ) { |
|
| 1351 | + $args[$field] = isset( $_POST[$field][$_key] ) ? $_POST[$field][$_key] : ''; |
|
| 1352 | + } |
|
| 1314 | 1353 | |
| 1315 | 1354 | $menu_item_db_id = wp_update_nav_menu_item( $nav_menu_selected_id, ( $_POST['menu-item-db-id'][$_key] != $_key ? 0 : $_key ), $args ); |
| 1316 | 1355 | |
@@ -1334,14 +1373,17 @@ discard block |
||
| 1334 | 1373 | // Store 'auto-add' pages. |
| 1335 | 1374 | $auto_add = ! empty( $_POST['auto-add-pages'] ); |
| 1336 | 1375 | $nav_menu_option = (array) get_option( 'nav_menu_options' ); |
| 1337 | - if ( ! isset( $nav_menu_option['auto_add'] ) ) |
|
| 1338 | - $nav_menu_option['auto_add'] = array(); |
|
| 1376 | + if ( ! isset( $nav_menu_option['auto_add'] ) ) { |
|
| 1377 | + $nav_menu_option['auto_add'] = array(); |
|
| 1378 | + } |
|
| 1339 | 1379 | if ( $auto_add ) { |
| 1340 | - if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) |
|
| 1341 | - $nav_menu_option['auto_add'][] = $nav_menu_selected_id; |
|
| 1380 | + if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) { |
|
| 1381 | + $nav_menu_option['auto_add'][] = $nav_menu_selected_id; |
|
| 1382 | + } |
|
| 1342 | 1383 | } else { |
| 1343 | - if ( false !== ( $key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) ) |
|
| 1344 | - unset( $nav_menu_option['auto_add'][$key] ); |
|
| 1384 | + if ( false !== ( $key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) ) { |
|
| 1385 | + unset( $nav_menu_option['auto_add'][$key] ); |
|
| 1386 | + } |
|
| 1345 | 1387 | } |
| 1346 | 1388 | // Remove nonexistent/deleted menus |
| 1347 | 1389 | $nav_menu_option['auto_add'] = array_intersect( $nav_menu_option['auto_add'], wp_get_nav_menus( array( 'fields' => 'ids' ) ) ); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * @param string $plugin_file Path to the plugin file |
| 68 | 68 | * @param bool $markup Optional. If the returned data should have HTML markup applied. Defaults to true. |
| 69 | 69 | * @param bool $translate Optional. If the returned data should be translated. Defaults to true. |
| 70 | - * @return array See above for description. |
|
| 70 | + * @return string See above for description. |
|
| 71 | 71 | */ |
| 72 | 72 | function get_plugin_data( $plugin_file, $markup = true, $translate = true ) { |
| 73 | 73 | |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | * @since 2.8.0 |
| 181 | 181 | * |
| 182 | 182 | * @param string $plugin Plugin ID |
| 183 | - * @return array List of files relative to the plugin root. |
|
| 183 | + * @return string[] List of files relative to the plugin root. |
|
| 184 | 184 | */ |
| 185 | 185 | function get_plugin_files($plugin) { |
| 186 | 186 | $plugin_file = WP_PLUGIN_DIR . '/' . $plugin; |
@@ -948,7 +948,7 @@ discard block |
||
| 948 | 948 | * @since 2.7.0 |
| 949 | 949 | * |
| 950 | 950 | * @param string $plugin Relative plugin path from Plugin Directory. |
| 951 | - * @return true True if a plugin's uninstall.php file has been found and included. |
|
| 951 | + * @return boolean|null True if a plugin's uninstall.php file has been found and included. |
|
| 952 | 952 | */ |
| 953 | 953 | function uninstall_plugin($plugin) { |
| 954 | 954 | $file = plugin_basename($plugin); |
@@ -1521,6 +1521,7 @@ discard block |
||
| 1521 | 1521 | * @global string $_wp_real_parent_file |
| 1522 | 1522 | * @global array $_wp_menu_nopriv |
| 1523 | 1523 | * @global array $_wp_submenu_nopriv |
| 1524 | + * @return string |
|
| 1524 | 1525 | */ |
| 1525 | 1526 | function get_admin_page_parent( $parent = '' ) { |
| 1526 | 1527 | global $parent_file, $menu, $submenu, $pagenow, $typenow, |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * WordPress Plugin Administration API |
|
| 4 | - * |
|
| 5 | - * @package WordPress |
|
| 6 | - * @subpackage Administration |
|
| 7 | - */ |
|
| 3 | + * WordPress Plugin Administration API |
|
| 4 | + * |
|
| 5 | + * @package WordPress |
|
| 6 | + * @subpackage Administration |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Parse the plugin contents to retrieve plugin's metadata. |
@@ -1297,22 +1297,22 @@ discard block |
||
| 1297 | 1297 | return add_submenu_page( $parent, $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 1298 | 1298 | } |
| 1299 | 1299 | /** |
| 1300 | - * Add sub menu page to the Dashboard main menu. |
|
| 1301 | - * |
|
| 1302 | - * This function takes a capability which will be used to determine whether |
|
| 1303 | - * or not a page is included in the menu. |
|
| 1304 | - * |
|
| 1305 | - * The function which is hooked in to handle the output of the page must check |
|
| 1306 | - * that the user has the required capability as well. |
|
| 1307 | - * |
|
| 1308 | - * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected |
|
| 1309 | - * @param string $menu_title The text to be used for the menu |
|
| 1310 | - * @param string $capability The capability required for this menu to be displayed to the user. |
|
| 1311 | - * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) |
|
| 1312 | - * @param callback $function The function to be called to output the content for this page. |
|
| 1313 | - * |
|
| 1314 | - * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
|
| 1315 | - */ |
|
| 1300 | + * Add sub menu page to the Dashboard main menu. |
|
| 1301 | + * |
|
| 1302 | + * This function takes a capability which will be used to determine whether |
|
| 1303 | + * or not a page is included in the menu. |
|
| 1304 | + * |
|
| 1305 | + * The function which is hooked in to handle the output of the page must check |
|
| 1306 | + * that the user has the required capability as well. |
|
| 1307 | + * |
|
| 1308 | + * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected |
|
| 1309 | + * @param string $menu_title The text to be used for the menu |
|
| 1310 | + * @param string $capability The capability required for this menu to be displayed to the user. |
|
| 1311 | + * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) |
|
| 1312 | + * @param callback $function The function to be called to output the content for this page. |
|
| 1313 | + * |
|
| 1314 | + * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
|
| 1315 | + */ |
|
| 1316 | 1316 | function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
| 1317 | 1317 | return add_submenu_page( 'index.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 1318 | 1318 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @param bool $translate Optional. If the returned data should be translated. Defaults to true. |
| 70 | 70 | * @return array See above for description. |
| 71 | 71 | */ |
| 72 | -function get_plugin_data( $plugin_file, $markup = true, $translate = true ) { |
|
| 72 | +function get_plugin_data($plugin_file, $markup = true, $translate = true) { |
|
| 73 | 73 | |
| 74 | 74 | $default_headers = array( |
| 75 | 75 | 'Name' => 'Plugin Name', |
@@ -85,18 +85,18 @@ discard block |
||
| 85 | 85 | '_sitewide' => 'Site Wide Only', |
| 86 | 86 | ); |
| 87 | 87 | |
| 88 | - $plugin_data = get_file_data( $plugin_file, $default_headers, 'plugin' ); |
|
| 88 | + $plugin_data = get_file_data($plugin_file, $default_headers, 'plugin'); |
|
| 89 | 89 | |
| 90 | 90 | // Site Wide Only is the old header for Network |
| 91 | - if ( ! $plugin_data['Network'] && $plugin_data['_sitewide'] ) { |
|
| 92 | - _deprecated_argument( __FUNCTION__, '3.0', sprintf( __( 'The <code>%1$s</code> plugin header is deprecated. Use <code>%2$s</code> instead.' ), 'Site Wide Only: true', 'Network: true' ) ); |
|
| 91 | + if ( ! $plugin_data['Network'] && $plugin_data['_sitewide']) { |
|
| 92 | + _deprecated_argument(__FUNCTION__, '3.0', sprintf(__('The <code>%1$s</code> plugin header is deprecated. Use <code>%2$s</code> instead.'), 'Site Wide Only: true', 'Network: true')); |
|
| 93 | 93 | $plugin_data['Network'] = $plugin_data['_sitewide']; |
| 94 | 94 | } |
| 95 | - $plugin_data['Network'] = ( 'true' == strtolower( $plugin_data['Network'] ) ); |
|
| 96 | - unset( $plugin_data['_sitewide'] ); |
|
| 95 | + $plugin_data['Network'] = ('true' == strtolower($plugin_data['Network'])); |
|
| 96 | + unset($plugin_data['_sitewide']); |
|
| 97 | 97 | |
| 98 | - if ( $markup || $translate ) { |
|
| 99 | - $plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate ); |
|
| 98 | + if ($markup || $translate) { |
|
| 99 | + $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup, $translate); |
|
| 100 | 100 | } else { |
| 101 | 101 | $plugin_data['Title'] = $plugin_data['Name']; |
| 102 | 102 | $plugin_data['AuthorName'] = $plugin_data['Author']; |
@@ -112,63 +112,63 @@ discard block |
||
| 112 | 112 | * @access private |
| 113 | 113 | * @see get_plugin_data() |
| 114 | 114 | */ |
| 115 | -function _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup = true, $translate = true ) { |
|
| 115 | +function _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup = true, $translate = true) { |
|
| 116 | 116 | |
| 117 | 117 | // Sanitize the plugin filename to a WP_PLUGIN_DIR relative path |
| 118 | - $plugin_file = plugin_basename( $plugin_file ); |
|
| 118 | + $plugin_file = plugin_basename($plugin_file); |
|
| 119 | 119 | |
| 120 | 120 | // Translate fields |
| 121 | - if ( $translate ) { |
|
| 122 | - if ( $textdomain = $plugin_data['TextDomain'] ) { |
|
| 123 | - if ( $plugin_data['DomainPath'] ) |
|
| 124 | - load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) . $plugin_data['DomainPath'] ); |
|
| 121 | + if ($translate) { |
|
| 122 | + if ($textdomain = $plugin_data['TextDomain']) { |
|
| 123 | + if ($plugin_data['DomainPath']) |
|
| 124 | + load_plugin_textdomain($textdomain, false, dirname($plugin_file).$plugin_data['DomainPath']); |
|
| 125 | 125 | else |
| 126 | - load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) ); |
|
| 127 | - } elseif ( in_array( basename( $plugin_file ), array( 'hello.php', 'akismet.php' ) ) ) { |
|
| 126 | + load_plugin_textdomain($textdomain, false, dirname($plugin_file)); |
|
| 127 | + } elseif (in_array(basename($plugin_file), array('hello.php', 'akismet.php'))) { |
|
| 128 | 128 | $textdomain = 'default'; |
| 129 | 129 | } |
| 130 | - if ( $textdomain ) { |
|
| 131 | - foreach ( array( 'Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version' ) as $field ) |
|
| 132 | - $plugin_data[ $field ] = translate( $plugin_data[ $field ], $textdomain ); |
|
| 130 | + if ($textdomain) { |
|
| 131 | + foreach (array('Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version') as $field) |
|
| 132 | + $plugin_data[$field] = translate($plugin_data[$field], $textdomain); |
|
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | // Sanitize fields |
| 137 | 137 | $allowed_tags = $allowed_tags_in_links = array( |
| 138 | - 'abbr' => array( 'title' => true ), |
|
| 139 | - 'acronym' => array( 'title' => true ), |
|
| 138 | + 'abbr' => array('title' => true), |
|
| 139 | + 'acronym' => array('title' => true), |
|
| 140 | 140 | 'code' => true, |
| 141 | 141 | 'em' => true, |
| 142 | 142 | 'strong' => true, |
| 143 | 143 | ); |
| 144 | - $allowed_tags['a'] = array( 'href' => true, 'title' => true ); |
|
| 144 | + $allowed_tags['a'] = array('href' => true, 'title' => true); |
|
| 145 | 145 | |
| 146 | 146 | // Name is marked up inside <a> tags. Don't allow these. |
| 147 | 147 | // Author is too, but some plugins have used <a> here (omitting Author URI). |
| 148 | - $plugin_data['Name'] = wp_kses( $plugin_data['Name'], $allowed_tags_in_links ); |
|
| 149 | - $plugin_data['Author'] = wp_kses( $plugin_data['Author'], $allowed_tags ); |
|
| 148 | + $plugin_data['Name'] = wp_kses($plugin_data['Name'], $allowed_tags_in_links); |
|
| 149 | + $plugin_data['Author'] = wp_kses($plugin_data['Author'], $allowed_tags); |
|
| 150 | 150 | |
| 151 | - $plugin_data['Description'] = wp_kses( $plugin_data['Description'], $allowed_tags ); |
|
| 152 | - $plugin_data['Version'] = wp_kses( $plugin_data['Version'], $allowed_tags ); |
|
| 151 | + $plugin_data['Description'] = wp_kses($plugin_data['Description'], $allowed_tags); |
|
| 152 | + $plugin_data['Version'] = wp_kses($plugin_data['Version'], $allowed_tags); |
|
| 153 | 153 | |
| 154 | - $plugin_data['PluginURI'] = esc_url( $plugin_data['PluginURI'] ); |
|
| 155 | - $plugin_data['AuthorURI'] = esc_url( $plugin_data['AuthorURI'] ); |
|
| 154 | + $plugin_data['PluginURI'] = esc_url($plugin_data['PluginURI']); |
|
| 155 | + $plugin_data['AuthorURI'] = esc_url($plugin_data['AuthorURI']); |
|
| 156 | 156 | |
| 157 | 157 | $plugin_data['Title'] = $plugin_data['Name']; |
| 158 | 158 | $plugin_data['AuthorName'] = $plugin_data['Author']; |
| 159 | 159 | |
| 160 | 160 | // Apply markup |
| 161 | - if ( $markup ) { |
|
| 162 | - if ( $plugin_data['PluginURI'] && $plugin_data['Name'] ) |
|
| 163 | - $plugin_data['Title'] = '<a href="' . $plugin_data['PluginURI'] . '">' . $plugin_data['Name'] . '</a>'; |
|
| 161 | + if ($markup) { |
|
| 162 | + if ($plugin_data['PluginURI'] && $plugin_data['Name']) |
|
| 163 | + $plugin_data['Title'] = '<a href="'.$plugin_data['PluginURI'].'">'.$plugin_data['Name'].'</a>'; |
|
| 164 | 164 | |
| 165 | - if ( $plugin_data['AuthorURI'] && $plugin_data['Author'] ) |
|
| 166 | - $plugin_data['Author'] = '<a href="' . $plugin_data['AuthorURI'] . '">' . $plugin_data['Author'] . '</a>'; |
|
| 165 | + if ($plugin_data['AuthorURI'] && $plugin_data['Author']) |
|
| 166 | + $plugin_data['Author'] = '<a href="'.$plugin_data['AuthorURI'].'">'.$plugin_data['Author'].'</a>'; |
|
| 167 | 167 | |
| 168 | - $plugin_data['Description'] = wptexturize( $plugin_data['Description'] ); |
|
| 168 | + $plugin_data['Description'] = wptexturize($plugin_data['Description']); |
|
| 169 | 169 | |
| 170 | - if ( $plugin_data['Author'] ) |
|
| 171 | - $plugin_data['Description'] .= ' <cite>' . sprintf( __('By %s.'), $plugin_data['Author'] ) . '</cite>'; |
|
| 170 | + if ($plugin_data['Author']) |
|
| 171 | + $plugin_data['Description'] .= ' <cite>'.sprintf(__('By %s.'), $plugin_data['Author']).'</cite>'; |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | return $plugin_data; |
@@ -183,31 +183,31 @@ discard block |
||
| 183 | 183 | * @return array List of files relative to the plugin root. |
| 184 | 184 | */ |
| 185 | 185 | function get_plugin_files($plugin) { |
| 186 | - $plugin_file = WP_PLUGIN_DIR . '/' . $plugin; |
|
| 186 | + $plugin_file = WP_PLUGIN_DIR.'/'.$plugin; |
|
| 187 | 187 | $dir = dirname($plugin_file); |
| 188 | 188 | $plugin_files = array($plugin); |
| 189 | - if ( is_dir($dir) && $dir != WP_PLUGIN_DIR ) { |
|
| 190 | - $plugins_dir = @ opendir( $dir ); |
|
| 191 | - if ( $plugins_dir ) { |
|
| 192 | - while (($file = readdir( $plugins_dir ) ) !== false ) { |
|
| 193 | - if ( substr($file, 0, 1) == '.' ) |
|
| 189 | + if (is_dir($dir) && $dir != WP_PLUGIN_DIR) { |
|
| 190 | + $plugins_dir = @ opendir($dir); |
|
| 191 | + if ($plugins_dir) { |
|
| 192 | + while (($file = readdir($plugins_dir)) !== false) { |
|
| 193 | + if (substr($file, 0, 1) == '.') |
|
| 194 | 194 | continue; |
| 195 | - if ( is_dir( $dir . '/' . $file ) ) { |
|
| 196 | - $plugins_subdir = @ opendir( $dir . '/' . $file ); |
|
| 197 | - if ( $plugins_subdir ) { |
|
| 198 | - while (($subfile = readdir( $plugins_subdir ) ) !== false ) { |
|
| 199 | - if ( substr($subfile, 0, 1) == '.' ) |
|
| 195 | + if (is_dir($dir.'/'.$file)) { |
|
| 196 | + $plugins_subdir = @ opendir($dir.'/'.$file); |
|
| 197 | + if ($plugins_subdir) { |
|
| 198 | + while (($subfile = readdir($plugins_subdir)) !== false) { |
|
| 199 | + if (substr($subfile, 0, 1) == '.') |
|
| 200 | 200 | continue; |
| 201 | 201 | $plugin_files[] = plugin_basename("$dir/$file/$subfile"); |
| 202 | 202 | } |
| 203 | - @closedir( $plugins_subdir ); |
|
| 203 | + @closedir($plugins_subdir); |
|
| 204 | 204 | } |
| 205 | 205 | } else { |
| 206 | - if ( plugin_basename("$dir/$file") != $plugin ) |
|
| 206 | + if (plugin_basename("$dir/$file") != $plugin) |
|
| 207 | 207 | $plugin_files[] = plugin_basename("$dir/$file"); |
| 208 | 208 | } |
| 209 | 209 | } |
| 210 | - @closedir( $plugins_dir ); |
|
| 210 | + @closedir($plugins_dir); |
|
| 211 | 211 | } |
| 212 | 212 | } |
| 213 | 213 | |
@@ -236,61 +236,61 @@ discard block |
||
| 236 | 236 | */ |
| 237 | 237 | function get_plugins($plugin_folder = '') { |
| 238 | 238 | |
| 239 | - if ( ! $cache_plugins = wp_cache_get('plugins', 'plugins') ) |
|
| 239 | + if ( ! $cache_plugins = wp_cache_get('plugins', 'plugins')) |
|
| 240 | 240 | $cache_plugins = array(); |
| 241 | 241 | |
| 242 | - if ( isset($cache_plugins[ $plugin_folder ]) ) |
|
| 243 | - return $cache_plugins[ $plugin_folder ]; |
|
| 242 | + if (isset($cache_plugins[$plugin_folder])) |
|
| 243 | + return $cache_plugins[$plugin_folder]; |
|
| 244 | 244 | |
| 245 | - $wp_plugins = array (); |
|
| 245 | + $wp_plugins = array(); |
|
| 246 | 246 | $plugin_root = WP_PLUGIN_DIR; |
| 247 | - if ( !empty($plugin_folder) ) |
|
| 247 | + if ( ! empty($plugin_folder)) |
|
| 248 | 248 | $plugin_root .= $plugin_folder; |
| 249 | 249 | |
| 250 | 250 | // Files in wp-content/plugins directory |
| 251 | - $plugins_dir = @ opendir( $plugin_root); |
|
| 251 | + $plugins_dir = @ opendir($plugin_root); |
|
| 252 | 252 | $plugin_files = array(); |
| 253 | - if ( $plugins_dir ) { |
|
| 254 | - while (($file = readdir( $plugins_dir ) ) !== false ) { |
|
| 255 | - if ( substr($file, 0, 1) == '.' ) |
|
| 253 | + if ($plugins_dir) { |
|
| 254 | + while (($file = readdir($plugins_dir)) !== false) { |
|
| 255 | + if (substr($file, 0, 1) == '.') |
|
| 256 | 256 | continue; |
| 257 | - if ( is_dir( $plugin_root.'/'.$file ) ) { |
|
| 258 | - $plugins_subdir = @ opendir( $plugin_root.'/'.$file ); |
|
| 259 | - if ( $plugins_subdir ) { |
|
| 260 | - while (($subfile = readdir( $plugins_subdir ) ) !== false ) { |
|
| 261 | - if ( substr($subfile, 0, 1) == '.' ) |
|
| 257 | + if (is_dir($plugin_root.'/'.$file)) { |
|
| 258 | + $plugins_subdir = @ opendir($plugin_root.'/'.$file); |
|
| 259 | + if ($plugins_subdir) { |
|
| 260 | + while (($subfile = readdir($plugins_subdir)) !== false) { |
|
| 261 | + if (substr($subfile, 0, 1) == '.') |
|
| 262 | 262 | continue; |
| 263 | - if ( substr($subfile, -4) == '.php' ) |
|
| 263 | + if (substr($subfile, -4) == '.php') |
|
| 264 | 264 | $plugin_files[] = "$file/$subfile"; |
| 265 | 265 | } |
| 266 | - closedir( $plugins_subdir ); |
|
| 266 | + closedir($plugins_subdir); |
|
| 267 | 267 | } |
| 268 | 268 | } else { |
| 269 | - if ( substr($file, -4) == '.php' ) |
|
| 269 | + if (substr($file, -4) == '.php') |
|
| 270 | 270 | $plugin_files[] = $file; |
| 271 | 271 | } |
| 272 | 272 | } |
| 273 | - closedir( $plugins_dir ); |
|
| 273 | + closedir($plugins_dir); |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - if ( empty($plugin_files) ) |
|
| 276 | + if (empty($plugin_files)) |
|
| 277 | 277 | return $wp_plugins; |
| 278 | 278 | |
| 279 | - foreach ( $plugin_files as $plugin_file ) { |
|
| 280 | - if ( !is_readable( "$plugin_root/$plugin_file" ) ) |
|
| 279 | + foreach ($plugin_files as $plugin_file) { |
|
| 280 | + if ( ! is_readable("$plugin_root/$plugin_file")) |
|
| 281 | 281 | continue; |
| 282 | 282 | |
| 283 | - $plugin_data = get_plugin_data( "$plugin_root/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached. |
|
| 283 | + $plugin_data = get_plugin_data("$plugin_root/$plugin_file", false, false); //Do not apply markup/translate as it'll be cached. |
|
| 284 | 284 | |
| 285 | - if ( empty ( $plugin_data['Name'] ) ) |
|
| 285 | + if (empty ($plugin_data['Name'])) |
|
| 286 | 286 | continue; |
| 287 | 287 | |
| 288 | - $wp_plugins[plugin_basename( $plugin_file )] = $plugin_data; |
|
| 288 | + $wp_plugins[plugin_basename($plugin_file)] = $plugin_data; |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - uasort( $wp_plugins, '_sort_uname_callback' ); |
|
| 291 | + uasort($wp_plugins, '_sort_uname_callback'); |
|
| 292 | 292 | |
| 293 | - $cache_plugins[ $plugin_folder ] = $wp_plugins; |
|
| 293 | + $cache_plugins[$plugin_folder] = $wp_plugins; |
|
| 294 | 294 | wp_cache_set('plugins', $cache_plugins, 'plugins'); |
| 295 | 295 | |
| 296 | 296 | return $wp_plugins; |
@@ -309,38 +309,38 @@ discard block |
||
| 309 | 309 | // Files in wp-content/mu-plugins directory |
| 310 | 310 | $plugin_files = array(); |
| 311 | 311 | |
| 312 | - if ( ! is_dir( WPMU_PLUGIN_DIR ) ) |
|
| 312 | + if ( ! is_dir(WPMU_PLUGIN_DIR)) |
|
| 313 | 313 | return $wp_plugins; |
| 314 | - if ( $plugins_dir = @ opendir( WPMU_PLUGIN_DIR ) ) { |
|
| 315 | - while ( ( $file = readdir( $plugins_dir ) ) !== false ) { |
|
| 316 | - if ( substr( $file, -4 ) == '.php' ) |
|
| 314 | + if ($plugins_dir = @ opendir(WPMU_PLUGIN_DIR)) { |
|
| 315 | + while (($file = readdir($plugins_dir)) !== false) { |
|
| 316 | + if (substr($file, -4) == '.php') |
|
| 317 | 317 | $plugin_files[] = $file; |
| 318 | 318 | } |
| 319 | 319 | } else { |
| 320 | 320 | return $wp_plugins; |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | - @closedir( $plugins_dir ); |
|
| 323 | + @closedir($plugins_dir); |
|
| 324 | 324 | |
| 325 | - if ( empty($plugin_files) ) |
|
| 325 | + if (empty($plugin_files)) |
|
| 326 | 326 | return $wp_plugins; |
| 327 | 327 | |
| 328 | - foreach ( $plugin_files as $plugin_file ) { |
|
| 329 | - if ( !is_readable( WPMU_PLUGIN_DIR . "/$plugin_file" ) ) |
|
| 328 | + foreach ($plugin_files as $plugin_file) { |
|
| 329 | + if ( ! is_readable(WPMU_PLUGIN_DIR."/$plugin_file")) |
|
| 330 | 330 | continue; |
| 331 | 331 | |
| 332 | - $plugin_data = get_plugin_data( WPMU_PLUGIN_DIR . "/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached. |
|
| 332 | + $plugin_data = get_plugin_data(WPMU_PLUGIN_DIR."/$plugin_file", false, false); //Do not apply markup/translate as it'll be cached. |
|
| 333 | 333 | |
| 334 | - if ( empty ( $plugin_data['Name'] ) ) |
|
| 334 | + if (empty ($plugin_data['Name'])) |
|
| 335 | 335 | $plugin_data['Name'] = $plugin_file; |
| 336 | 336 | |
| 337 | - $wp_plugins[ $plugin_file ] = $plugin_data; |
|
| 337 | + $wp_plugins[$plugin_file] = $plugin_data; |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - if ( isset( $wp_plugins['index.php'] ) && filesize( WPMU_PLUGIN_DIR . '/index.php') <= 30 ) // silence is golden |
|
| 341 | - unset( $wp_plugins['index.php'] ); |
|
| 340 | + if (isset($wp_plugins['index.php']) && filesize(WPMU_PLUGIN_DIR.'/index.php') <= 30) // silence is golden |
|
| 341 | + unset($wp_plugins['index.php']); |
|
| 342 | 342 | |
| 343 | - uasort( $wp_plugins, '_sort_uname_callback' ); |
|
| 343 | + uasort($wp_plugins, '_sort_uname_callback'); |
|
| 344 | 344 | |
| 345 | 345 | return $wp_plugins; |
| 346 | 346 | } |
@@ -351,8 +351,8 @@ discard block |
||
| 351 | 351 | * @since 3.1.0 |
| 352 | 352 | * @access private |
| 353 | 353 | */ |
| 354 | -function _sort_uname_callback( $a, $b ) { |
|
| 355 | - return strnatcasecmp( $a['Name'], $b['Name'] ); |
|
| 354 | +function _sort_uname_callback($a, $b) { |
|
| 355 | + return strnatcasecmp($a['Name'], $b['Name']); |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | /** |
@@ -368,30 +368,30 @@ discard block |
||
| 368 | 368 | $_dropins = _get_dropins(); |
| 369 | 369 | |
| 370 | 370 | // These exist in the wp-content directory |
| 371 | - if ( $plugins_dir = @ opendir( WP_CONTENT_DIR ) ) { |
|
| 372 | - while ( ( $file = readdir( $plugins_dir ) ) !== false ) { |
|
| 373 | - if ( isset( $_dropins[ $file ] ) ) |
|
| 371 | + if ($plugins_dir = @ opendir(WP_CONTENT_DIR)) { |
|
| 372 | + while (($file = readdir($plugins_dir)) !== false) { |
|
| 373 | + if (isset($_dropins[$file])) |
|
| 374 | 374 | $plugin_files[] = $file; |
| 375 | 375 | } |
| 376 | 376 | } else { |
| 377 | 377 | return $dropins; |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | - @closedir( $plugins_dir ); |
|
| 380 | + @closedir($plugins_dir); |
|
| 381 | 381 | |
| 382 | - if ( empty($plugin_files) ) |
|
| 382 | + if (empty($plugin_files)) |
|
| 383 | 383 | return $dropins; |
| 384 | 384 | |
| 385 | - foreach ( $plugin_files as $plugin_file ) { |
|
| 386 | - if ( !is_readable( WP_CONTENT_DIR . "/$plugin_file" ) ) |
|
| 385 | + foreach ($plugin_files as $plugin_file) { |
|
| 386 | + if ( ! is_readable(WP_CONTENT_DIR."/$plugin_file")) |
|
| 387 | 387 | continue; |
| 388 | - $plugin_data = get_plugin_data( WP_CONTENT_DIR . "/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached. |
|
| 389 | - if ( empty( $plugin_data['Name'] ) ) |
|
| 388 | + $plugin_data = get_plugin_data(WP_CONTENT_DIR."/$plugin_file", false, false); //Do not apply markup/translate as it'll be cached. |
|
| 389 | + if (empty($plugin_data['Name'])) |
|
| 390 | 390 | $plugin_data['Name'] = $plugin_file; |
| 391 | - $dropins[ $plugin_file ] = $plugin_data; |
|
| 391 | + $dropins[$plugin_file] = $plugin_data; |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | - uksort( $dropins, 'strnatcasecmp' ); |
|
| 394 | + uksort($dropins, 'strnatcasecmp'); |
|
| 395 | 395 | |
| 396 | 396 | return $dropins; |
| 397 | 397 | } |
@@ -408,19 +408,19 @@ discard block |
||
| 408 | 408 | */ |
| 409 | 409 | function _get_dropins() { |
| 410 | 410 | $dropins = array( |
| 411 | - 'advanced-cache.php' => array( __( 'Advanced caching plugin.' ), 'WP_CACHE' ), // WP_CACHE |
|
| 412 | - 'db.php' => array( __( 'Custom database class.' ), true ), // auto on load |
|
| 413 | - 'db-error.php' => array( __( 'Custom database error message.' ), true ), // auto on error |
|
| 414 | - 'install.php' => array( __( 'Custom install script.' ), true ), // auto on install |
|
| 415 | - 'maintenance.php' => array( __( 'Custom maintenance message.' ), true ), // auto on maintenance |
|
| 416 | - 'object-cache.php' => array( __( 'External object cache.' ), true ), // auto on load |
|
| 411 | + 'advanced-cache.php' => array(__('Advanced caching plugin.'), 'WP_CACHE'), // WP_CACHE |
|
| 412 | + 'db.php' => array(__('Custom database class.'), true), // auto on load |
|
| 413 | + 'db-error.php' => array(__('Custom database error message.'), true), // auto on error |
|
| 414 | + 'install.php' => array(__('Custom install script.'), true), // auto on install |
|
| 415 | + 'maintenance.php' => array(__('Custom maintenance message.'), true), // auto on maintenance |
|
| 416 | + 'object-cache.php' => array(__('External object cache.'), true), // auto on load |
|
| 417 | 417 | ); |
| 418 | 418 | |
| 419 | - if ( is_multisite() ) { |
|
| 420 | - $dropins['sunrise.php' ] = array( __( 'Executed before Multisite is loaded.' ), 'SUNRISE' ); // SUNRISE |
|
| 421 | - $dropins['blog-deleted.php' ] = array( __( 'Custom site deleted message.' ), true ); // auto on deleted blog |
|
| 422 | - $dropins['blog-inactive.php' ] = array( __( 'Custom site inactive message.' ), true ); // auto on inactive blog |
|
| 423 | - $dropins['blog-suspended.php'] = array( __( 'Custom site suspended message.' ), true ); // auto on archived or spammed blog |
|
| 419 | + if (is_multisite()) { |
|
| 420 | + $dropins['sunrise.php'] = array(__('Executed before Multisite is loaded.'), 'SUNRISE'); // SUNRISE |
|
| 421 | + $dropins['blog-deleted.php'] = array(__('Custom site deleted message.'), true); // auto on deleted blog |
|
| 422 | + $dropins['blog-inactive.php'] = array(__('Custom site inactive message.'), true); // auto on inactive blog |
|
| 423 | + $dropins['blog-suspended.php'] = array(__('Custom site suspended message.'), true); // auto on archived or spammed blog |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | return $dropins; |
@@ -434,8 +434,8 @@ discard block |
||
| 434 | 434 | * @param string $plugin Base plugin path from plugins directory. |
| 435 | 435 | * @return bool True, if in the active plugins list. False, not in the list. |
| 436 | 436 | */ |
| 437 | -function is_plugin_active( $plugin ) { |
|
| 438 | - return in_array( $plugin, (array) get_option( 'active_plugins', array() ) ) || is_plugin_active_for_network( $plugin ); |
|
| 437 | +function is_plugin_active($plugin) { |
|
| 438 | + return in_array($plugin, (array) get_option('active_plugins', array())) || is_plugin_active_for_network($plugin); |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | /** |
@@ -449,8 +449,8 @@ discard block |
||
| 449 | 449 | * @param string $plugin Base plugin path from plugins directory. |
| 450 | 450 | * @return bool True if inactive. False if active. |
| 451 | 451 | */ |
| 452 | -function is_plugin_inactive( $plugin ) { |
|
| 453 | - return ! is_plugin_active( $plugin ); |
|
| 452 | +function is_plugin_inactive($plugin) { |
|
| 453 | + return ! is_plugin_active($plugin); |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | /** |
@@ -461,12 +461,12 @@ discard block |
||
| 461 | 461 | * @param string $plugin Base plugin path from plugins directory. |
| 462 | 462 | * @return bool True, if active for the network, otherwise false. |
| 463 | 463 | */ |
| 464 | -function is_plugin_active_for_network( $plugin ) { |
|
| 465 | - if ( !is_multisite() ) |
|
| 464 | +function is_plugin_active_for_network($plugin) { |
|
| 465 | + if ( ! is_multisite()) |
|
| 466 | 466 | return false; |
| 467 | 467 | |
| 468 | - $plugins = get_site_option( 'active_sitewide_plugins'); |
|
| 469 | - if ( isset($plugins[$plugin]) ) |
|
| 468 | + $plugins = get_site_option('active_sitewide_plugins'); |
|
| 469 | + if (isset($plugins[$plugin])) |
|
| 470 | 470 | return true; |
| 471 | 471 | |
| 472 | 472 | return false; |
@@ -484,9 +484,9 @@ discard block |
||
| 484 | 484 | * @param string $plugin Plugin to check |
| 485 | 485 | * @return bool True if plugin is network only, false otherwise. |
| 486 | 486 | */ |
| 487 | -function is_network_only_plugin( $plugin ) { |
|
| 488 | - $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); |
|
| 489 | - if ( $plugin_data ) |
|
| 487 | +function is_network_only_plugin($plugin) { |
|
| 488 | + $plugin_data = get_plugin_data(WP_PLUGIN_DIR.'/'.$plugin); |
|
| 489 | + if ($plugin_data) |
|
| 490 | 490 | return $plugin_data['Network']; |
| 491 | 491 | return false; |
| 492 | 492 | } |
@@ -518,31 +518,31 @@ discard block |
||
| 518 | 518 | * @param bool $silent Prevent calling activation hooks. Optional, default is false. |
| 519 | 519 | * @return WP_Error|null WP_Error on invalid file or null on success. |
| 520 | 520 | */ |
| 521 | -function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silent = false ) { |
|
| 522 | - $plugin = plugin_basename( trim( $plugin ) ); |
|
| 521 | +function activate_plugin($plugin, $redirect = '', $network_wide = false, $silent = false) { |
|
| 522 | + $plugin = plugin_basename(trim($plugin)); |
|
| 523 | 523 | |
| 524 | - if ( is_multisite() && ( $network_wide || is_network_only_plugin($plugin) ) ) { |
|
| 524 | + if (is_multisite() && ($network_wide || is_network_only_plugin($plugin))) { |
|
| 525 | 525 | $network_wide = true; |
| 526 | - $current = get_site_option( 'active_sitewide_plugins', array() ); |
|
| 526 | + $current = get_site_option('active_sitewide_plugins', array()); |
|
| 527 | 527 | $_GET['networkwide'] = 1; // Back compat for plugins looking for this value. |
| 528 | 528 | } else { |
| 529 | - $current = get_option( 'active_plugins', array() ); |
|
| 529 | + $current = get_option('active_plugins', array()); |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | $valid = validate_plugin($plugin); |
| 533 | - if ( is_wp_error($valid) ) |
|
| 533 | + if (is_wp_error($valid)) |
|
| 534 | 534 | return $valid; |
| 535 | 535 | |
| 536 | - if ( ( $network_wide && ! isset( $current[ $plugin ] ) ) || ( ! $network_wide && ! in_array( $plugin, $current ) ) ) { |
|
| 537 | - if ( !empty($redirect) ) |
|
| 538 | - wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); // we'll override this later if the plugin can be included without fatal error |
|
| 536 | + if (($network_wide && ! isset($current[$plugin])) || ( ! $network_wide && ! in_array($plugin, $current))) { |
|
| 537 | + if ( ! empty($redirect)) |
|
| 538 | + wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_'.$plugin), $redirect)); // we'll override this later if the plugin can be included without fatal error |
|
| 539 | 539 | ob_start(); |
| 540 | - wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin ); |
|
| 540 | + wp_register_plugin_realpath(WP_PLUGIN_DIR.'/'.$plugin); |
|
| 541 | 541 | $_wp_plugin_file = $plugin; |
| 542 | - include_once( WP_PLUGIN_DIR . '/' . $plugin ); |
|
| 542 | + include_once(WP_PLUGIN_DIR.'/'.$plugin); |
|
| 543 | 543 | $plugin = $_wp_plugin_file; // Avoid stomping of the $plugin variable in a plugin. |
| 544 | 544 | |
| 545 | - if ( ! $silent ) { |
|
| 545 | + if ( ! $silent) { |
|
| 546 | 546 | /** |
| 547 | 547 | * Fires before a plugin is activated. |
| 548 | 548 | * |
@@ -555,7 +555,7 @@ discard block |
||
| 555 | 555 | * @param bool $network_wide Whether to enable the plugin for all sites in the network |
| 556 | 556 | * or just the current site. Multisite only. Default is false. |
| 557 | 557 | */ |
| 558 | - do_action( 'activate_plugin', $plugin, $network_wide ); |
|
| 558 | + do_action('activate_plugin', $plugin, $network_wide); |
|
| 559 | 559 | |
| 560 | 560 | /** |
| 561 | 561 | * Fires as a specific plugin is being activated. |
@@ -572,21 +572,21 @@ discard block |
||
| 572 | 572 | * @param bool $network_wide Whether to enable the plugin for all sites in the network |
| 573 | 573 | * or just the current site. Multisite only. Default is false. |
| 574 | 574 | */ |
| 575 | - do_action( 'activate_' . $plugin, $network_wide ); |
|
| 575 | + do_action('activate_'.$plugin, $network_wide); |
|
| 576 | 576 | } |
| 577 | 577 | |
| 578 | - if ( $network_wide ) { |
|
| 579 | - $current = get_site_option( 'active_sitewide_plugins', array() ); |
|
| 578 | + if ($network_wide) { |
|
| 579 | + $current = get_site_option('active_sitewide_plugins', array()); |
|
| 580 | 580 | $current[$plugin] = time(); |
| 581 | - update_site_option( 'active_sitewide_plugins', $current ); |
|
| 581 | + update_site_option('active_sitewide_plugins', $current); |
|
| 582 | 582 | } else { |
| 583 | - $current = get_option( 'active_plugins', array() ); |
|
| 583 | + $current = get_option('active_plugins', array()); |
|
| 584 | 584 | $current[] = $plugin; |
| 585 | 585 | sort($current); |
| 586 | 586 | update_option('active_plugins', $current); |
| 587 | 587 | } |
| 588 | 588 | |
| 589 | - if ( ! $silent ) { |
|
| 589 | + if ( ! $silent) { |
|
| 590 | 590 | /** |
| 591 | 591 | * Fires after a plugin has been activated. |
| 592 | 592 | * |
@@ -599,10 +599,10 @@ discard block |
||
| 599 | 599 | * @param bool $network_wide Whether to enable the plugin for all sites in the network |
| 600 | 600 | * or just the current site. Multisite only. Default is false. |
| 601 | 601 | */ |
| 602 | - do_action( 'activated_plugin', $plugin, $network_wide ); |
|
| 602 | + do_action('activated_plugin', $plugin, $network_wide); |
|
| 603 | 603 | } |
| 604 | 604 | |
| 605 | - if ( ob_get_length() > 0 ) { |
|
| 605 | + if (ob_get_length() > 0) { |
|
| 606 | 606 | $output = ob_get_clean(); |
| 607 | 607 | return new WP_Error('unexpected_output', __('The plugin generated unexpected output.'), $output); |
| 608 | 608 | } |
@@ -625,20 +625,20 @@ discard block |
||
| 625 | 625 | * @param mixed $network_wide Whether to deactivate the plugin for all sites in the network. |
| 626 | 626 | * A value of null (the default) will deactivate plugins for both the site and the network. |
| 627 | 627 | */ |
| 628 | -function deactivate_plugins( $plugins, $silent = false, $network_wide = null ) { |
|
| 629 | - if ( is_multisite() ) |
|
| 630 | - $network_current = get_site_option( 'active_sitewide_plugins', array() ); |
|
| 631 | - $current = get_option( 'active_plugins', array() ); |
|
| 628 | +function deactivate_plugins($plugins, $silent = false, $network_wide = null) { |
|
| 629 | + if (is_multisite()) |
|
| 630 | + $network_current = get_site_option('active_sitewide_plugins', array()); |
|
| 631 | + $current = get_option('active_plugins', array()); |
|
| 632 | 632 | $do_blog = $do_network = false; |
| 633 | 633 | |
| 634 | - foreach ( (array) $plugins as $plugin ) { |
|
| 635 | - $plugin = plugin_basename( trim( $plugin ) ); |
|
| 636 | - if ( ! is_plugin_active($plugin) ) |
|
| 634 | + foreach ((array) $plugins as $plugin) { |
|
| 635 | + $plugin = plugin_basename(trim($plugin)); |
|
| 636 | + if ( ! is_plugin_active($plugin)) |
|
| 637 | 637 | continue; |
| 638 | 638 | |
| 639 | - $network_deactivating = false !== $network_wide && is_plugin_active_for_network( $plugin ); |
|
| 639 | + $network_deactivating = false !== $network_wide && is_plugin_active_for_network($plugin); |
|
| 640 | 640 | |
| 641 | - if ( ! $silent ) { |
|
| 641 | + if ( ! $silent) { |
|
| 642 | 642 | /** |
| 643 | 643 | * Fires before a plugin is deactivated. |
| 644 | 644 | * |
@@ -651,27 +651,27 @@ discard block |
||
| 651 | 651 | * @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network |
| 652 | 652 | * or just the current site. Multisite only. Default is false. |
| 653 | 653 | */ |
| 654 | - do_action( 'deactivate_plugin', $plugin, $network_deactivating ); |
|
| 654 | + do_action('deactivate_plugin', $plugin, $network_deactivating); |
|
| 655 | 655 | } |
| 656 | 656 | |
| 657 | - if ( false !== $network_wide ) { |
|
| 658 | - if ( is_plugin_active_for_network( $plugin ) ) { |
|
| 657 | + if (false !== $network_wide) { |
|
| 658 | + if (is_plugin_active_for_network($plugin)) { |
|
| 659 | 659 | $do_network = true; |
| 660 | - unset( $network_current[ $plugin ] ); |
|
| 661 | - } elseif ( $network_wide ) { |
|
| 660 | + unset($network_current[$plugin]); |
|
| 661 | + } elseif ($network_wide) { |
|
| 662 | 662 | continue; |
| 663 | 663 | } |
| 664 | 664 | } |
| 665 | 665 | |
| 666 | - if ( true !== $network_wide ) { |
|
| 667 | - $key = array_search( $plugin, $current ); |
|
| 668 | - if ( false !== $key ) { |
|
| 666 | + if (true !== $network_wide) { |
|
| 667 | + $key = array_search($plugin, $current); |
|
| 668 | + if (false !== $key) { |
|
| 669 | 669 | $do_blog = true; |
| 670 | - unset( $current[ $key ] ); |
|
| 670 | + unset($current[$key]); |
|
| 671 | 671 | } |
| 672 | 672 | } |
| 673 | 673 | |
| 674 | - if ( ! $silent ) { |
|
| 674 | + if ( ! $silent) { |
|
| 675 | 675 | /** |
| 676 | 676 | * Fires as a specific plugin is being deactivated. |
| 677 | 677 | * |
@@ -687,7 +687,7 @@ discard block |
||
| 687 | 687 | * @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network |
| 688 | 688 | * or just the current site. Multisite only. Default is false. |
| 689 | 689 | */ |
| 690 | - do_action( 'deactivate_' . $plugin, $network_deactivating ); |
|
| 690 | + do_action('deactivate_'.$plugin, $network_deactivating); |
|
| 691 | 691 | |
| 692 | 692 | /** |
| 693 | 693 | * Fires after a plugin is deactivated. |
@@ -701,14 +701,14 @@ discard block |
||
| 701 | 701 | * @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network |
| 702 | 702 | * or just the current site. Multisite only. Default false. |
| 703 | 703 | */ |
| 704 | - do_action( 'deactivated_plugin', $plugin, $network_deactivating ); |
|
| 704 | + do_action('deactivated_plugin', $plugin, $network_deactivating); |
|
| 705 | 705 | } |
| 706 | 706 | } |
| 707 | 707 | |
| 708 | - if ( $do_blog ) |
|
| 708 | + if ($do_blog) |
|
| 709 | 709 | update_option('active_plugins', $current); |
| 710 | - if ( $do_network ) |
|
| 711 | - update_site_option( 'active_sitewide_plugins', $network_current ); |
|
| 710 | + if ($do_network) |
|
| 711 | + update_site_option('active_sitewide_plugins', $network_current); |
|
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | /** |
@@ -727,20 +727,20 @@ discard block |
||
| 727 | 727 | * @param bool $silent Prevent calling activation hooks. Default is false. |
| 728 | 728 | * @return bool|WP_Error True when finished or WP_Error if there were errors during a plugin activation. |
| 729 | 729 | */ |
| 730 | -function activate_plugins( $plugins, $redirect = '', $network_wide = false, $silent = false ) { |
|
| 731 | - if ( !is_array($plugins) ) |
|
| 730 | +function activate_plugins($plugins, $redirect = '', $network_wide = false, $silent = false) { |
|
| 731 | + if ( ! is_array($plugins)) |
|
| 732 | 732 | $plugins = array($plugins); |
| 733 | 733 | |
| 734 | 734 | $errors = array(); |
| 735 | - foreach ( $plugins as $plugin ) { |
|
| 736 | - if ( !empty($redirect) ) |
|
| 735 | + foreach ($plugins as $plugin) { |
|
| 736 | + if ( ! empty($redirect)) |
|
| 737 | 737 | $redirect = add_query_arg('plugin', $plugin, $redirect); |
| 738 | 738 | $result = activate_plugin($plugin, $redirect, $network_wide, $silent); |
| 739 | - if ( is_wp_error($result) ) |
|
| 739 | + if (is_wp_error($result)) |
|
| 740 | 740 | $errors[$plugin] = $result; |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | - if ( !empty($errors) ) |
|
| 743 | + if ( ! empty($errors)) |
|
| 744 | 744 | return new WP_Error('plugins_invalid', __('One of the plugins is invalid.'), $errors); |
| 745 | 745 | |
| 746 | 746 | return true; |
@@ -758,106 +758,106 @@ discard block |
||
| 758 | 758 | * @return bool|null|WP_Error True on success, false is $plugins is empty, WP_Error on failure. |
| 759 | 759 | * Null if filesystem credentials are required to proceed. |
| 760 | 760 | */ |
| 761 | -function delete_plugins( $plugins, $deprecated = '' ) { |
|
| 761 | +function delete_plugins($plugins, $deprecated = '') { |
|
| 762 | 762 | global $wp_filesystem; |
| 763 | 763 | |
| 764 | - if ( empty($plugins) ) |
|
| 764 | + if (empty($plugins)) |
|
| 765 | 765 | return false; |
| 766 | 766 | |
| 767 | 767 | $checked = array(); |
| 768 | - foreach( $plugins as $plugin ) |
|
| 769 | - $checked[] = 'checked[]=' . $plugin; |
|
| 768 | + foreach ($plugins as $plugin) |
|
| 769 | + $checked[] = 'checked[]='.$plugin; |
|
| 770 | 770 | |
| 771 | 771 | ob_start(); |
| 772 | - $url = wp_nonce_url('plugins.php?action=delete-selected&verify-delete=1&' . implode('&', $checked), 'bulk-plugins'); |
|
| 773 | - if ( false === ($credentials = request_filesystem_credentials($url)) ) { |
|
| 772 | + $url = wp_nonce_url('plugins.php?action=delete-selected&verify-delete=1&'.implode('&', $checked), 'bulk-plugins'); |
|
| 773 | + if (false === ($credentials = request_filesystem_credentials($url))) { |
|
| 774 | 774 | $data = ob_get_clean(); |
| 775 | 775 | |
| 776 | - if ( ! empty($data) ){ |
|
| 777 | - include_once( ABSPATH . 'wp-admin/admin-header.php'); |
|
| 776 | + if ( ! empty($data)) { |
|
| 777 | + include_once(ABSPATH.'wp-admin/admin-header.php'); |
|
| 778 | 778 | echo $data; |
| 779 | - include( ABSPATH . 'wp-admin/admin-footer.php'); |
|
| 779 | + include(ABSPATH.'wp-admin/admin-footer.php'); |
|
| 780 | 780 | exit; |
| 781 | 781 | } |
| 782 | 782 | return; |
| 783 | 783 | } |
| 784 | 784 | |
| 785 | - if ( ! WP_Filesystem($credentials) ) { |
|
| 785 | + if ( ! WP_Filesystem($credentials)) { |
|
| 786 | 786 | request_filesystem_credentials($url, '', true); //Failed to connect, Error and request again |
| 787 | 787 | $data = ob_get_clean(); |
| 788 | 788 | |
| 789 | - if ( ! empty($data) ){ |
|
| 790 | - include_once( ABSPATH . 'wp-admin/admin-header.php'); |
|
| 789 | + if ( ! empty($data)) { |
|
| 790 | + include_once(ABSPATH.'wp-admin/admin-header.php'); |
|
| 791 | 791 | echo $data; |
| 792 | - include( ABSPATH . 'wp-admin/admin-footer.php'); |
|
| 792 | + include(ABSPATH.'wp-admin/admin-footer.php'); |
|
| 793 | 793 | exit; |
| 794 | 794 | } |
| 795 | 795 | return; |
| 796 | 796 | } |
| 797 | 797 | |
| 798 | - if ( ! is_object($wp_filesystem) ) |
|
| 798 | + if ( ! is_object($wp_filesystem)) |
|
| 799 | 799 | return new WP_Error('fs_unavailable', __('Could not access filesystem.')); |
| 800 | 800 | |
| 801 | - if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() ) |
|
| 801 | + if (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) |
|
| 802 | 802 | return new WP_Error('fs_error', __('Filesystem error.'), $wp_filesystem->errors); |
| 803 | 803 | |
| 804 | 804 | // Get the base plugin folder. |
| 805 | 805 | $plugins_dir = $wp_filesystem->wp_plugins_dir(); |
| 806 | - if ( empty( $plugins_dir ) ) { |
|
| 807 | - return new WP_Error( 'fs_no_plugins_dir', __( 'Unable to locate WordPress Plugin directory.' ) ); |
|
| 806 | + if (empty($plugins_dir)) { |
|
| 807 | + return new WP_Error('fs_no_plugins_dir', __('Unable to locate WordPress Plugin directory.')); |
|
| 808 | 808 | } |
| 809 | 809 | |
| 810 | - $plugins_dir = trailingslashit( $plugins_dir ); |
|
| 810 | + $plugins_dir = trailingslashit($plugins_dir); |
|
| 811 | 811 | |
| 812 | - $plugin_translations = wp_get_installed_translations( 'plugins' ); |
|
| 812 | + $plugin_translations = wp_get_installed_translations('plugins'); |
|
| 813 | 813 | |
| 814 | 814 | $errors = array(); |
| 815 | 815 | |
| 816 | - foreach( $plugins as $plugin_file ) { |
|
| 816 | + foreach ($plugins as $plugin_file) { |
|
| 817 | 817 | // Run Uninstall hook. |
| 818 | - if ( is_uninstallable_plugin( $plugin_file ) ) { |
|
| 818 | + if (is_uninstallable_plugin($plugin_file)) { |
|
| 819 | 819 | uninstall_plugin($plugin_file); |
| 820 | 820 | } |
| 821 | 821 | |
| 822 | - $this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin_file ) ); |
|
| 822 | + $this_plugin_dir = trailingslashit(dirname($plugins_dir.$plugin_file)); |
|
| 823 | 823 | // If plugin is in its own directory, recursively delete the directory. |
| 824 | - if ( strpos( $plugin_file, '/' ) && $this_plugin_dir != $plugins_dir ) { //base check on if plugin includes directory separator AND that it's not the root plugin folder |
|
| 825 | - $deleted = $wp_filesystem->delete( $this_plugin_dir, true ); |
|
| 824 | + if (strpos($plugin_file, '/') && $this_plugin_dir != $plugins_dir) { //base check on if plugin includes directory separator AND that it's not the root plugin folder |
|
| 825 | + $deleted = $wp_filesystem->delete($this_plugin_dir, true); |
|
| 826 | 826 | } else { |
| 827 | - $deleted = $wp_filesystem->delete( $plugins_dir . $plugin_file ); |
|
| 827 | + $deleted = $wp_filesystem->delete($plugins_dir.$plugin_file); |
|
| 828 | 828 | } |
| 829 | 829 | |
| 830 | - if ( ! $deleted ) { |
|
| 830 | + if ( ! $deleted) { |
|
| 831 | 831 | $errors[] = $plugin_file; |
| 832 | 832 | continue; |
| 833 | 833 | } |
| 834 | 834 | |
| 835 | 835 | // Remove language files, silently. |
| 836 | - $plugin_slug = dirname( $plugin_file ); |
|
| 837 | - if ( '.' !== $plugin_slug && ! empty( $plugin_translations[ $plugin_slug ] ) ) { |
|
| 838 | - $translations = $plugin_translations[ $plugin_slug ]; |
|
| 836 | + $plugin_slug = dirname($plugin_file); |
|
| 837 | + if ('.' !== $plugin_slug && ! empty($plugin_translations[$plugin_slug])) { |
|
| 838 | + $translations = $plugin_translations[$plugin_slug]; |
|
| 839 | 839 | |
| 840 | - foreach ( $translations as $translation => $data ) { |
|
| 841 | - $wp_filesystem->delete( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '.po' ); |
|
| 842 | - $wp_filesystem->delete( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '.mo' ); |
|
| 840 | + foreach ($translations as $translation => $data) { |
|
| 841 | + $wp_filesystem->delete(WP_LANG_DIR.'/plugins/'.$plugin_slug.'-'.$translation.'.po'); |
|
| 842 | + $wp_filesystem->delete(WP_LANG_DIR.'/plugins/'.$plugin_slug.'-'.$translation.'.mo'); |
|
| 843 | 843 | } |
| 844 | 844 | } |
| 845 | 845 | } |
| 846 | 846 | |
| 847 | 847 | // Remove deleted plugins from the plugin updates list. |
| 848 | - if ( $current = get_site_transient('update_plugins') ) { |
|
| 848 | + if ($current = get_site_transient('update_plugins')) { |
|
| 849 | 849 | // Don't remove the plugins that weren't deleted. |
| 850 | - $deleted = array_diff( $plugins, $errors ); |
|
| 850 | + $deleted = array_diff($plugins, $errors); |
|
| 851 | 851 | |
| 852 | - foreach ( $deleted as $plugin_file ) { |
|
| 853 | - unset( $current->response[ $plugin_file ] ); |
|
| 852 | + foreach ($deleted as $plugin_file) { |
|
| 853 | + unset($current->response[$plugin_file]); |
|
| 854 | 854 | } |
| 855 | 855 | |
| 856 | - set_site_transient( 'update_plugins', $current ); |
|
| 856 | + set_site_transient('update_plugins', $current); |
|
| 857 | 857 | } |
| 858 | 858 | |
| 859 | - if ( ! empty($errors) ) |
|
| 860 | - return new WP_Error('could_not_remove_plugin', sprintf(__('Could not fully remove the plugin(s) %s.'), implode(', ', $errors)) ); |
|
| 859 | + if ( ! empty($errors)) |
|
| 860 | + return new WP_Error('could_not_remove_plugin', sprintf(__('Could not fully remove the plugin(s) %s.'), implode(', ', $errors))); |
|
| 861 | 861 | |
| 862 | 862 | return true; |
| 863 | 863 | } |
@@ -872,29 +872,29 @@ discard block |
||
| 872 | 872 | * @return array invalid plugins, plugin as key, error as value |
| 873 | 873 | */ |
| 874 | 874 | function validate_active_plugins() { |
| 875 | - $plugins = get_option( 'active_plugins', array() ); |
|
| 875 | + $plugins = get_option('active_plugins', array()); |
|
| 876 | 876 | // Validate vartype: array. |
| 877 | - if ( ! is_array( $plugins ) ) { |
|
| 878 | - update_option( 'active_plugins', array() ); |
|
| 877 | + if ( ! is_array($plugins)) { |
|
| 878 | + update_option('active_plugins', array()); |
|
| 879 | 879 | $plugins = array(); |
| 880 | 880 | } |
| 881 | 881 | |
| 882 | - if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) { |
|
| 883 | - $network_plugins = (array) get_site_option( 'active_sitewide_plugins', array() ); |
|
| 884 | - $plugins = array_merge( $plugins, array_keys( $network_plugins ) ); |
|
| 882 | + if (is_multisite() && current_user_can('manage_network_plugins')) { |
|
| 883 | + $network_plugins = (array) get_site_option('active_sitewide_plugins', array()); |
|
| 884 | + $plugins = array_merge($plugins, array_keys($network_plugins)); |
|
| 885 | 885 | } |
| 886 | 886 | |
| 887 | - if ( empty( $plugins ) ) |
|
| 887 | + if (empty($plugins)) |
|
| 888 | 888 | return array(); |
| 889 | 889 | |
| 890 | 890 | $invalid = array(); |
| 891 | 891 | |
| 892 | 892 | // Invalid plugins get deactivated. |
| 893 | - foreach ( $plugins as $plugin ) { |
|
| 894 | - $result = validate_plugin( $plugin ); |
|
| 895 | - if ( is_wp_error( $result ) ) { |
|
| 893 | + foreach ($plugins as $plugin) { |
|
| 894 | + $result = validate_plugin($plugin); |
|
| 895 | + if (is_wp_error($result)) { |
|
| 896 | 896 | $invalid[$plugin] = $result; |
| 897 | - deactivate_plugins( $plugin, true ); |
|
| 897 | + deactivate_plugins($plugin, true); |
|
| 898 | 898 | } |
| 899 | 899 | } |
| 900 | 900 | return $invalid; |
@@ -911,13 +911,13 @@ discard block |
||
| 911 | 911 | * @return WP_Error|int 0 on success, WP_Error on failure. |
| 912 | 912 | */ |
| 913 | 913 | function validate_plugin($plugin) { |
| 914 | - if ( validate_file($plugin) ) |
|
| 914 | + if (validate_file($plugin)) |
|
| 915 | 915 | return new WP_Error('plugin_invalid', __('Invalid plugin path.')); |
| 916 | - if ( ! file_exists(WP_PLUGIN_DIR . '/' . $plugin) ) |
|
| 916 | + if ( ! file_exists(WP_PLUGIN_DIR.'/'.$plugin)) |
|
| 917 | 917 | return new WP_Error('plugin_not_found', __('Plugin file does not exist.')); |
| 918 | 918 | |
| 919 | 919 | $installed_plugins = get_plugins(); |
| 920 | - if ( ! isset($installed_plugins[$plugin]) ) |
|
| 920 | + if ( ! isset($installed_plugins[$plugin])) |
|
| 921 | 921 | return new WP_Error('no_plugin_header', __('The plugin does not have a valid header.')); |
| 922 | 922 | return 0; |
| 923 | 923 | } |
@@ -934,7 +934,7 @@ discard block |
||
| 934 | 934 | $file = plugin_basename($plugin); |
| 935 | 935 | |
| 936 | 936 | $uninstallable_plugins = (array) get_option('uninstall_plugins'); |
| 937 | - if ( isset( $uninstallable_plugins[$file] ) || file_exists( WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php' ) ) |
|
| 937 | + if (isset($uninstallable_plugins[$file]) || file_exists(WP_PLUGIN_DIR.'/'.dirname($file).'/uninstall.php')) |
|
| 938 | 938 | return true; |
| 939 | 939 | |
| 940 | 940 | return false; |
@@ -954,30 +954,30 @@ discard block |
||
| 954 | 954 | $file = plugin_basename($plugin); |
| 955 | 955 | |
| 956 | 956 | $uninstallable_plugins = (array) get_option('uninstall_plugins'); |
| 957 | - if ( file_exists( WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php' ) ) { |
|
| 958 | - if ( isset( $uninstallable_plugins[$file] ) ) { |
|
| 957 | + if (file_exists(WP_PLUGIN_DIR.'/'.dirname($file).'/uninstall.php')) { |
|
| 958 | + if (isset($uninstallable_plugins[$file])) { |
|
| 959 | 959 | unset($uninstallable_plugins[$file]); |
| 960 | 960 | update_option('uninstall_plugins', $uninstallable_plugins); |
| 961 | 961 | } |
| 962 | 962 | unset($uninstallable_plugins); |
| 963 | 963 | |
| 964 | 964 | define('WP_UNINSTALL_PLUGIN', $file); |
| 965 | - wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . dirname( $file ) ); |
|
| 966 | - include( WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php' ); |
|
| 965 | + wp_register_plugin_realpath(WP_PLUGIN_DIR.'/'.dirname($file)); |
|
| 966 | + include(WP_PLUGIN_DIR.'/'.dirname($file).'/uninstall.php'); |
|
| 967 | 967 | |
| 968 | 968 | return true; |
| 969 | 969 | } |
| 970 | 970 | |
| 971 | - if ( isset( $uninstallable_plugins[$file] ) ) { |
|
| 971 | + if (isset($uninstallable_plugins[$file])) { |
|
| 972 | 972 | $callable = $uninstallable_plugins[$file]; |
| 973 | 973 | unset($uninstallable_plugins[$file]); |
| 974 | 974 | update_option('uninstall_plugins', $uninstallable_plugins); |
| 975 | 975 | unset($uninstallable_plugins); |
| 976 | 976 | |
| 977 | - wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $file ); |
|
| 978 | - include( WP_PLUGIN_DIR . '/' . $file ); |
|
| 977 | + wp_register_plugin_realpath(WP_PLUGIN_DIR.'/'.$file); |
|
| 978 | + include(WP_PLUGIN_DIR.'/'.$file); |
|
| 979 | 979 | |
| 980 | - add_action( 'uninstall_' . $file, $callable ); |
|
| 980 | + add_action('uninstall_'.$file, $callable); |
|
| 981 | 981 | |
| 982 | 982 | /** |
| 983 | 983 | * Fires in uninstall_plugin() once the plugin has been uninstalled. |
@@ -987,7 +987,7 @@ discard block |
||
| 987 | 987 | * |
| 988 | 988 | * @since 2.7.0 |
| 989 | 989 | */ |
| 990 | - do_action( 'uninstall_' . $file ); |
|
| 990 | + do_action('uninstall_'.$file); |
|
| 991 | 991 | } |
| 992 | 992 | } |
| 993 | 993 | |
@@ -1023,29 +1023,29 @@ discard block |
||
| 1023 | 1023 | * |
| 1024 | 1024 | * @return string The resulting page's hook_suffix |
| 1025 | 1025 | */ |
| 1026 | -function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '', $position = null ) { |
|
| 1026 | +function add_menu_page($page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '', $position = null) { |
|
| 1027 | 1027 | global $menu, $admin_page_hooks, $_registered_pages, $_parent_pages; |
| 1028 | 1028 | |
| 1029 | - $menu_slug = plugin_basename( $menu_slug ); |
|
| 1029 | + $menu_slug = plugin_basename($menu_slug); |
|
| 1030 | 1030 | |
| 1031 | - $admin_page_hooks[$menu_slug] = sanitize_title( $menu_title ); |
|
| 1031 | + $admin_page_hooks[$menu_slug] = sanitize_title($menu_title); |
|
| 1032 | 1032 | |
| 1033 | - $hookname = get_plugin_page_hookname( $menu_slug, '' ); |
|
| 1033 | + $hookname = get_plugin_page_hookname($menu_slug, ''); |
|
| 1034 | 1034 | |
| 1035 | - if ( !empty( $function ) && !empty( $hookname ) && current_user_can( $capability ) ) |
|
| 1036 | - add_action( $hookname, $function ); |
|
| 1035 | + if ( ! empty($function) && ! empty($hookname) && current_user_can($capability)) |
|
| 1036 | + add_action($hookname, $function); |
|
| 1037 | 1037 | |
| 1038 | - if ( empty($icon_url) ) { |
|
| 1038 | + if (empty($icon_url)) { |
|
| 1039 | 1039 | $icon_url = 'dashicons-admin-generic'; |
| 1040 | 1040 | $icon_class = 'menu-icon-generic '; |
| 1041 | 1041 | } else { |
| 1042 | - $icon_url = set_url_scheme( $icon_url ); |
|
| 1042 | + $icon_url = set_url_scheme($icon_url); |
|
| 1043 | 1043 | $icon_class = ''; |
| 1044 | 1044 | } |
| 1045 | 1045 | |
| 1046 | - $new_menu = array( $menu_title, $capability, $menu_slug, $page_title, 'menu-top ' . $icon_class . $hookname, $hookname, $icon_url ); |
|
| 1046 | + $new_menu = array($menu_title, $capability, $menu_slug, $page_title, 'menu-top '.$icon_class.$hookname, $hookname, $icon_url); |
|
| 1047 | 1047 | |
| 1048 | - if ( null === $position ) |
|
| 1048 | + if (null === $position) |
|
| 1049 | 1049 | $menu[] = $new_menu; |
| 1050 | 1050 | else |
| 1051 | 1051 | $menu[$position] = $new_menu; |
@@ -1078,7 +1078,7 @@ discard block |
||
| 1078 | 1078 | * |
| 1079 | 1079 | * @return string The resulting page's hook_suffix |
| 1080 | 1080 | */ |
| 1081 | -function add_object_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '') { |
|
| 1081 | +function add_object_page($page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '') { |
|
| 1082 | 1082 | global $_wp_last_object_menu; |
| 1083 | 1083 | |
| 1084 | 1084 | $_wp_last_object_menu++; |
@@ -1106,7 +1106,7 @@ discard block |
||
| 1106 | 1106 | * |
| 1107 | 1107 | * @return string The resulting page's hook_suffix |
| 1108 | 1108 | */ |
| 1109 | -function add_utility_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '') { |
|
| 1109 | +function add_utility_page($page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '') { |
|
| 1110 | 1110 | global $_wp_last_utility_menu; |
| 1111 | 1111 | |
| 1112 | 1112 | $_wp_last_utility_menu++; |
@@ -1139,17 +1139,17 @@ discard block |
||
| 1139 | 1139 | * |
| 1140 | 1140 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
| 1141 | 1141 | */ |
| 1142 | -function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
|
| 1142 | +function add_submenu_page($parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '') { |
|
| 1143 | 1143 | global $submenu, $menu, $_wp_real_parent_file, $_wp_submenu_nopriv, |
| 1144 | 1144 | $_registered_pages, $_parent_pages; |
| 1145 | 1145 | |
| 1146 | - $menu_slug = plugin_basename( $menu_slug ); |
|
| 1147 | - $parent_slug = plugin_basename( $parent_slug); |
|
| 1146 | + $menu_slug = plugin_basename($menu_slug); |
|
| 1147 | + $parent_slug = plugin_basename($parent_slug); |
|
| 1148 | 1148 | |
| 1149 | - if ( isset( $_wp_real_parent_file[$parent_slug] ) ) |
|
| 1149 | + if (isset($_wp_real_parent_file[$parent_slug])) |
|
| 1150 | 1150 | $parent_slug = $_wp_real_parent_file[$parent_slug]; |
| 1151 | 1151 | |
| 1152 | - if ( !current_user_can( $capability ) ) { |
|
| 1152 | + if ( ! current_user_can($capability)) { |
|
| 1153 | 1153 | $_wp_submenu_nopriv[$parent_slug][$menu_slug] = true; |
| 1154 | 1154 | return false; |
| 1155 | 1155 | } |
@@ -1160,18 +1160,18 @@ discard block |
||
| 1160 | 1160 | * parent file someone is trying to link back to the parent manually. In |
| 1161 | 1161 | * this case, don't automatically add a link back to avoid duplication. |
| 1162 | 1162 | */ |
| 1163 | - if (!isset( $submenu[$parent_slug] ) && $menu_slug != $parent_slug ) { |
|
| 1164 | - foreach ( (array)$menu as $parent_menu ) { |
|
| 1165 | - if ( $parent_menu[2] == $parent_slug && current_user_can( $parent_menu[1] ) ) |
|
| 1166 | - $submenu[$parent_slug][] = array_slice( $parent_menu, 0, 4 ); |
|
| 1163 | + if ( ! isset($submenu[$parent_slug]) && $menu_slug != $parent_slug) { |
|
| 1164 | + foreach ((array) $menu as $parent_menu) { |
|
| 1165 | + if ($parent_menu[2] == $parent_slug && current_user_can($parent_menu[1])) |
|
| 1166 | + $submenu[$parent_slug][] = array_slice($parent_menu, 0, 4); |
|
| 1167 | 1167 | } |
| 1168 | 1168 | } |
| 1169 | 1169 | |
| 1170 | - $submenu[$parent_slug][] = array ( $menu_title, $capability, $menu_slug, $page_title ); |
|
| 1170 | + $submenu[$parent_slug][] = array($menu_title, $capability, $menu_slug, $page_title); |
|
| 1171 | 1171 | |
| 1172 | - $hookname = get_plugin_page_hookname( $menu_slug, $parent_slug); |
|
| 1173 | - if (!empty ( $function ) && !empty ( $hookname )) |
|
| 1174 | - add_action( $hookname, $function ); |
|
| 1172 | + $hookname = get_plugin_page_hookname($menu_slug, $parent_slug); |
|
| 1173 | + if ( ! empty ($function) && ! empty ($hookname)) |
|
| 1174 | + add_action($hookname, $function); |
|
| 1175 | 1175 | |
| 1176 | 1176 | $_registered_pages[$hookname] = true; |
| 1177 | 1177 | |
@@ -1179,8 +1179,8 @@ discard block |
||
| 1179 | 1179 | * Backward-compatibility for plugins using add_management page. |
| 1180 | 1180 | * See wp-admin/admin.php for redirect from edit.php to tools.php |
| 1181 | 1181 | */ |
| 1182 | - if ( 'tools.php' == $parent_slug ) |
|
| 1183 | - $_registered_pages[get_plugin_page_hookname( $menu_slug, 'edit.php')] = true; |
|
| 1182 | + if ('tools.php' == $parent_slug) |
|
| 1183 | + $_registered_pages[get_plugin_page_hookname($menu_slug, 'edit.php')] = true; |
|
| 1184 | 1184 | |
| 1185 | 1185 | // No parent as top level. |
| 1186 | 1186 | $_parent_pages[$menu_slug] = $parent_slug; |
@@ -1205,8 +1205,8 @@ discard block |
||
| 1205 | 1205 | * |
| 1206 | 1206 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
| 1207 | 1207 | */ |
| 1208 | -function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
|
| 1209 | - return add_submenu_page( 'tools.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
|
| 1208 | +function add_management_page($page_title, $menu_title, $capability, $menu_slug, $function = '') { |
|
| 1209 | + return add_submenu_page('tools.php', $page_title, $menu_title, $capability, $menu_slug, $function); |
|
| 1210 | 1210 | } |
| 1211 | 1211 | |
| 1212 | 1212 | /** |
@@ -1226,8 +1226,8 @@ discard block |
||
| 1226 | 1226 | * |
| 1227 | 1227 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
| 1228 | 1228 | */ |
| 1229 | -function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
|
| 1230 | - return add_submenu_page( 'options-general.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
|
| 1229 | +function add_options_page($page_title, $menu_title, $capability, $menu_slug, $function = '') { |
|
| 1230 | + return add_submenu_page('options-general.php', $page_title, $menu_title, $capability, $menu_slug, $function); |
|
| 1231 | 1231 | } |
| 1232 | 1232 | |
| 1233 | 1233 | /** |
@@ -1247,8 +1247,8 @@ discard block |
||
| 1247 | 1247 | * |
| 1248 | 1248 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
| 1249 | 1249 | */ |
| 1250 | -function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
|
| 1251 | - return add_submenu_page( 'themes.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
|
| 1250 | +function add_theme_page($page_title, $menu_title, $capability, $menu_slug, $function = '') { |
|
| 1251 | + return add_submenu_page('themes.php', $page_title, $menu_title, $capability, $menu_slug, $function); |
|
| 1252 | 1252 | } |
| 1253 | 1253 | |
| 1254 | 1254 | /** |
@@ -1268,8 +1268,8 @@ discard block |
||
| 1268 | 1268 | * |
| 1269 | 1269 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
| 1270 | 1270 | */ |
| 1271 | -function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
|
| 1272 | - return add_submenu_page( 'plugins.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
|
| 1271 | +function add_plugins_page($page_title, $menu_title, $capability, $menu_slug, $function = '') { |
|
| 1272 | + return add_submenu_page('plugins.php', $page_title, $menu_title, $capability, $menu_slug, $function); |
|
| 1273 | 1273 | } |
| 1274 | 1274 | |
| 1275 | 1275 | /** |
@@ -1289,12 +1289,12 @@ discard block |
||
| 1289 | 1289 | * |
| 1290 | 1290 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
| 1291 | 1291 | */ |
| 1292 | -function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
|
| 1293 | - if ( current_user_can('edit_users') ) |
|
| 1292 | +function add_users_page($page_title, $menu_title, $capability, $menu_slug, $function = '') { |
|
| 1293 | + if (current_user_can('edit_users')) |
|
| 1294 | 1294 | $parent = 'users.php'; |
| 1295 | 1295 | else |
| 1296 | 1296 | $parent = 'profile.php'; |
| 1297 | - return add_submenu_page( $parent, $page_title, $menu_title, $capability, $menu_slug, $function ); |
|
| 1297 | + return add_submenu_page($parent, $page_title, $menu_title, $capability, $menu_slug, $function); |
|
| 1298 | 1298 | } |
| 1299 | 1299 | /** |
| 1300 | 1300 | * Add sub menu page to the Dashboard main menu. |
@@ -1313,8 +1313,8 @@ discard block |
||
| 1313 | 1313 | * |
| 1314 | 1314 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
| 1315 | 1315 | */ |
| 1316 | -function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
|
| 1317 | - return add_submenu_page( 'index.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
|
| 1316 | +function add_dashboard_page($page_title, $menu_title, $capability, $menu_slug, $function = '') { |
|
| 1317 | + return add_submenu_page('index.php', $page_title, $menu_title, $capability, $menu_slug, $function); |
|
| 1318 | 1318 | } |
| 1319 | 1319 | |
| 1320 | 1320 | /** |
@@ -1334,8 +1334,8 @@ discard block |
||
| 1334 | 1334 | * |
| 1335 | 1335 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
| 1336 | 1336 | */ |
| 1337 | -function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
|
| 1338 | - return add_submenu_page( 'edit.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
|
| 1337 | +function add_posts_page($page_title, $menu_title, $capability, $menu_slug, $function = '') { |
|
| 1338 | + return add_submenu_page('edit.php', $page_title, $menu_title, $capability, $menu_slug, $function); |
|
| 1339 | 1339 | } |
| 1340 | 1340 | |
| 1341 | 1341 | /** |
@@ -1355,8 +1355,8 @@ discard block |
||
| 1355 | 1355 | * |
| 1356 | 1356 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
| 1357 | 1357 | */ |
| 1358 | -function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
|
| 1359 | - return add_submenu_page( 'upload.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
|
| 1358 | +function add_media_page($page_title, $menu_title, $capability, $menu_slug, $function = '') { |
|
| 1359 | + return add_submenu_page('upload.php', $page_title, $menu_title, $capability, $menu_slug, $function); |
|
| 1360 | 1360 | } |
| 1361 | 1361 | |
| 1362 | 1362 | /** |
@@ -1376,8 +1376,8 @@ discard block |
||
| 1376 | 1376 | * |
| 1377 | 1377 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
| 1378 | 1378 | */ |
| 1379 | -function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
|
| 1380 | - return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
|
| 1379 | +function add_links_page($page_title, $menu_title, $capability, $menu_slug, $function = '') { |
|
| 1380 | + return add_submenu_page('link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $function); |
|
| 1381 | 1381 | } |
| 1382 | 1382 | |
| 1383 | 1383 | /** |
@@ -1397,8 +1397,8 @@ discard block |
||
| 1397 | 1397 | * |
| 1398 | 1398 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
| 1399 | 1399 | */ |
| 1400 | -function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
|
| 1401 | - return add_submenu_page( 'edit.php?post_type=page', $page_title, $menu_title, $capability, $menu_slug, $function ); |
|
| 1400 | +function add_pages_page($page_title, $menu_title, $capability, $menu_slug, $function = '') { |
|
| 1401 | + return add_submenu_page('edit.php?post_type=page', $page_title, $menu_title, $capability, $menu_slug, $function); |
|
| 1402 | 1402 | } |
| 1403 | 1403 | |
| 1404 | 1404 | /** |
@@ -1418,8 +1418,8 @@ discard block |
||
| 1418 | 1418 | * |
| 1419 | 1419 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
| 1420 | 1420 | */ |
| 1421 | -function add_comments_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
|
| 1422 | - return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $function ); |
|
| 1421 | +function add_comments_page($page_title, $menu_title, $capability, $menu_slug, $function = '') { |
|
| 1422 | + return add_submenu_page('edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $function); |
|
| 1423 | 1423 | } |
| 1424 | 1424 | |
| 1425 | 1425 | /** |
@@ -1432,12 +1432,12 @@ discard block |
||
| 1432 | 1432 | * @param string $menu_slug The slug of the menu |
| 1433 | 1433 | * @return array|bool The removed menu on success, False if not found |
| 1434 | 1434 | */ |
| 1435 | -function remove_menu_page( $menu_slug ) { |
|
| 1435 | +function remove_menu_page($menu_slug) { |
|
| 1436 | 1436 | global $menu; |
| 1437 | 1437 | |
| 1438 | - foreach ( $menu as $i => $item ) { |
|
| 1439 | - if ( $menu_slug == $item[2] ) { |
|
| 1440 | - unset( $menu[$i] ); |
|
| 1438 | + foreach ($menu as $i => $item) { |
|
| 1439 | + if ($menu_slug == $item[2]) { |
|
| 1440 | + unset($menu[$i]); |
|
| 1441 | 1441 | return $item; |
| 1442 | 1442 | } |
| 1443 | 1443 | } |
@@ -1456,15 +1456,15 @@ discard block |
||
| 1456 | 1456 | * @param string $submenu_slug The slug of the submenu |
| 1457 | 1457 | * @return array|bool The removed submenu on success, False if not found |
| 1458 | 1458 | */ |
| 1459 | -function remove_submenu_page( $menu_slug, $submenu_slug ) { |
|
| 1459 | +function remove_submenu_page($menu_slug, $submenu_slug) { |
|
| 1460 | 1460 | global $submenu; |
| 1461 | 1461 | |
| 1462 | - if ( !isset( $submenu[$menu_slug] ) ) |
|
| 1462 | + if ( ! isset($submenu[$menu_slug])) |
|
| 1463 | 1463 | return false; |
| 1464 | 1464 | |
| 1465 | - foreach ( $submenu[$menu_slug] as $i => $item ) { |
|
| 1466 | - if ( $submenu_slug == $item[2] ) { |
|
| 1467 | - unset( $submenu[$menu_slug][$i] ); |
|
| 1465 | + foreach ($submenu[$menu_slug] as $i => $item) { |
|
| 1466 | + if ($submenu_slug == $item[2]) { |
|
| 1467 | + unset($submenu[$menu_slug][$i]); |
|
| 1468 | 1468 | return $item; |
| 1469 | 1469 | } |
| 1470 | 1470 | } |
@@ -1488,12 +1488,12 @@ discard block |
||
| 1488 | 1488 | function menu_page_url($menu_slug, $echo = true) { |
| 1489 | 1489 | global $_parent_pages; |
| 1490 | 1490 | |
| 1491 | - if ( isset( $_parent_pages[$menu_slug] ) ) { |
|
| 1491 | + if (isset($_parent_pages[$menu_slug])) { |
|
| 1492 | 1492 | $parent_slug = $_parent_pages[$menu_slug]; |
| 1493 | - if ( $parent_slug && ! isset( $_parent_pages[$parent_slug] ) ) { |
|
| 1494 | - $url = admin_url( add_query_arg( 'page', $menu_slug, $parent_slug ) ); |
|
| 1493 | + if ($parent_slug && ! isset($_parent_pages[$parent_slug])) { |
|
| 1494 | + $url = admin_url(add_query_arg('page', $menu_slug, $parent_slug)); |
|
| 1495 | 1495 | } else { |
| 1496 | - $url = admin_url( 'admin.php?page=' . $menu_slug ); |
|
| 1496 | + $url = admin_url('admin.php?page='.$menu_slug); |
|
| 1497 | 1497 | } |
| 1498 | 1498 | } else { |
| 1499 | 1499 | $url = ''; |
@@ -1501,7 +1501,7 @@ discard block |
||
| 1501 | 1501 | |
| 1502 | 1502 | $url = esc_url($url); |
| 1503 | 1503 | |
| 1504 | - if ( $echo ) |
|
| 1504 | + if ($echo) |
|
| 1505 | 1505 | echo $url; |
| 1506 | 1506 | |
| 1507 | 1507 | return $url; |
@@ -1522,58 +1522,58 @@ discard block |
||
| 1522 | 1522 | * @global array $_wp_menu_nopriv |
| 1523 | 1523 | * @global array $_wp_submenu_nopriv |
| 1524 | 1524 | */ |
| 1525 | -function get_admin_page_parent( $parent = '' ) { |
|
| 1525 | +function get_admin_page_parent($parent = '') { |
|
| 1526 | 1526 | global $parent_file, $menu, $submenu, $pagenow, $typenow, |
| 1527 | 1527 | $plugin_page, $_wp_real_parent_file, $_wp_menu_nopriv, $_wp_submenu_nopriv; |
| 1528 | 1528 | |
| 1529 | - if ( !empty ( $parent ) && 'admin.php' != $parent ) { |
|
| 1530 | - if ( isset( $_wp_real_parent_file[$parent] ) ) |
|
| 1529 | + if ( ! empty ($parent) && 'admin.php' != $parent) { |
|
| 1530 | + if (isset($_wp_real_parent_file[$parent])) |
|
| 1531 | 1531 | $parent = $_wp_real_parent_file[$parent]; |
| 1532 | 1532 | return $parent; |
| 1533 | 1533 | } |
| 1534 | 1534 | |
| 1535 | - if ( $pagenow == 'admin.php' && isset( $plugin_page ) ) { |
|
| 1536 | - foreach ( (array)$menu as $parent_menu ) { |
|
| 1537 | - if ( $parent_menu[2] == $plugin_page ) { |
|
| 1535 | + if ($pagenow == 'admin.php' && isset($plugin_page)) { |
|
| 1536 | + foreach ((array) $menu as $parent_menu) { |
|
| 1537 | + if ($parent_menu[2] == $plugin_page) { |
|
| 1538 | 1538 | $parent_file = $plugin_page; |
| 1539 | - if ( isset( $_wp_real_parent_file[$parent_file] ) ) |
|
| 1539 | + if (isset($_wp_real_parent_file[$parent_file])) |
|
| 1540 | 1540 | $parent_file = $_wp_real_parent_file[$parent_file]; |
| 1541 | 1541 | return $parent_file; |
| 1542 | 1542 | } |
| 1543 | 1543 | } |
| 1544 | - if ( isset( $_wp_menu_nopriv[$plugin_page] ) ) { |
|
| 1544 | + if (isset($_wp_menu_nopriv[$plugin_page])) { |
|
| 1545 | 1545 | $parent_file = $plugin_page; |
| 1546 | - if ( isset( $_wp_real_parent_file[$parent_file] ) ) |
|
| 1546 | + if (isset($_wp_real_parent_file[$parent_file])) |
|
| 1547 | 1547 | $parent_file = $_wp_real_parent_file[$parent_file]; |
| 1548 | 1548 | return $parent_file; |
| 1549 | 1549 | } |
| 1550 | 1550 | } |
| 1551 | 1551 | |
| 1552 | - if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) ) { |
|
| 1552 | + if (isset($plugin_page) && isset($_wp_submenu_nopriv[$pagenow][$plugin_page])) { |
|
| 1553 | 1553 | $parent_file = $pagenow; |
| 1554 | - if ( isset( $_wp_real_parent_file[$parent_file] ) ) |
|
| 1554 | + if (isset($_wp_real_parent_file[$parent_file])) |
|
| 1555 | 1555 | $parent_file = $_wp_real_parent_file[$parent_file]; |
| 1556 | 1556 | return $parent_file; |
| 1557 | 1557 | } |
| 1558 | 1558 | |
| 1559 | - foreach (array_keys( (array)$submenu ) as $parent) { |
|
| 1560 | - foreach ( $submenu[$parent] as $submenu_array ) { |
|
| 1561 | - if ( isset( $_wp_real_parent_file[$parent] ) ) |
|
| 1559 | + foreach (array_keys((array) $submenu) as $parent) { |
|
| 1560 | + foreach ($submenu[$parent] as $submenu_array) { |
|
| 1561 | + if (isset($_wp_real_parent_file[$parent])) |
|
| 1562 | 1562 | $parent = $_wp_real_parent_file[$parent]; |
| 1563 | - if ( !empty($typenow) && ($submenu_array[2] == "$pagenow?post_type=$typenow") ) { |
|
| 1563 | + if ( ! empty($typenow) && ($submenu_array[2] == "$pagenow?post_type=$typenow")) { |
|
| 1564 | 1564 | $parent_file = $parent; |
| 1565 | 1565 | return $parent; |
| 1566 | - } elseif ( $submenu_array[2] == $pagenow && empty($typenow) && ( empty($parent_file) || false === strpos($parent_file, '?') ) ) { |
|
| 1566 | + } elseif ($submenu_array[2] == $pagenow && empty($typenow) && (empty($parent_file) || false === strpos($parent_file, '?'))) { |
|
| 1567 | 1567 | $parent_file = $parent; |
| 1568 | 1568 | return $parent; |
| 1569 | - } elseif ( isset( $plugin_page ) && ($plugin_page == $submenu_array[2] ) ) { |
|
| 1569 | + } elseif (isset($plugin_page) && ($plugin_page == $submenu_array[2])) { |
|
| 1570 | 1570 | $parent_file = $parent; |
| 1571 | 1571 | return $parent; |
| 1572 | 1572 | } |
| 1573 | 1573 | } |
| 1574 | 1574 | } |
| 1575 | 1575 | |
| 1576 | - if ( empty($parent_file) ) |
|
| 1576 | + if (empty($parent_file)) |
|
| 1577 | 1577 | $parent_file = ''; |
| 1578 | 1578 | return ''; |
| 1579 | 1579 | } |
@@ -1590,20 +1590,20 @@ discard block |
||
| 1590 | 1590 | function get_admin_page_title() { |
| 1591 | 1591 | global $title, $menu, $submenu, $pagenow, $plugin_page, $typenow; |
| 1592 | 1592 | |
| 1593 | - if ( ! empty ( $title ) ) |
|
| 1593 | + if ( ! empty ($title)) |
|
| 1594 | 1594 | return $title; |
| 1595 | 1595 | |
| 1596 | - $hook = get_plugin_page_hook( $plugin_page, $pagenow ); |
|
| 1596 | + $hook = get_plugin_page_hook($plugin_page, $pagenow); |
|
| 1597 | 1597 | |
| 1598 | 1598 | $parent = $parent1 = get_admin_page_parent(); |
| 1599 | 1599 | |
| 1600 | - if ( empty ( $parent) ) { |
|
| 1601 | - foreach ( (array)$menu as $menu_array ) { |
|
| 1602 | - if ( isset( $menu_array[3] ) ) { |
|
| 1603 | - if ( $menu_array[2] == $pagenow ) { |
|
| 1600 | + if (empty ($parent)) { |
|
| 1601 | + foreach ((array) $menu as $menu_array) { |
|
| 1602 | + if (isset($menu_array[3])) { |
|
| 1603 | + if ($menu_array[2] == $pagenow) { |
|
| 1604 | 1604 | $title = $menu_array[3]; |
| 1605 | 1605 | return $menu_array[3]; |
| 1606 | - } elseif ( isset( $plugin_page ) && ($plugin_page == $menu_array[2] ) && ($hook == $menu_array[3] ) ) { |
|
| 1606 | + } elseif (isset($plugin_page) && ($plugin_page == $menu_array[2]) && ($hook == $menu_array[3])) { |
|
| 1607 | 1607 | $title = $menu_array[3]; |
| 1608 | 1608 | return $menu_array[3]; |
| 1609 | 1609 | } |
@@ -1613,26 +1613,26 @@ discard block |
||
| 1613 | 1613 | } |
| 1614 | 1614 | } |
| 1615 | 1615 | } else { |
| 1616 | - foreach ( array_keys( $submenu ) as $parent ) { |
|
| 1617 | - foreach ( $submenu[$parent] as $submenu_array ) { |
|
| 1618 | - if ( isset( $plugin_page ) && |
|
| 1619 | - ( $plugin_page == $submenu_array[2] ) && |
|
| 1616 | + foreach (array_keys($submenu) as $parent) { |
|
| 1617 | + foreach ($submenu[$parent] as $submenu_array) { |
|
| 1618 | + if (isset($plugin_page) && |
|
| 1619 | + ($plugin_page == $submenu_array[2]) && |
|
| 1620 | 1620 | ( |
| 1621 | - ( $parent == $pagenow ) || |
|
| 1622 | - ( $parent == $plugin_page ) || |
|
| 1623 | - ( $plugin_page == $hook ) || |
|
| 1624 | - ( $pagenow == 'admin.php' && $parent1 != $submenu_array[2] ) || |
|
| 1625 | - ( !empty($typenow) && $parent == $pagenow . '?post_type=' . $typenow) |
|
| 1621 | + ($parent == $pagenow) || |
|
| 1622 | + ($parent == $plugin_page) || |
|
| 1623 | + ($plugin_page == $hook) || |
|
| 1624 | + ($pagenow == 'admin.php' && $parent1 != $submenu_array[2]) || |
|
| 1625 | + ( ! empty($typenow) && $parent == $pagenow.'?post_type='.$typenow) |
|
| 1626 | 1626 | ) |
| 1627 | 1627 | ) { |
| 1628 | 1628 | $title = $submenu_array[3]; |
| 1629 | 1629 | return $submenu_array[3]; |
| 1630 | 1630 | } |
| 1631 | 1631 | |
| 1632 | - if ( $submenu_array[2] != $pagenow || isset( $_GET['page'] ) ) // not the current page |
|
| 1632 | + if ($submenu_array[2] != $pagenow || isset($_GET['page'])) // not the current page |
|
| 1633 | 1633 | continue; |
| 1634 | 1634 | |
| 1635 | - if ( isset( $submenu_array[3] ) ) { |
|
| 1635 | + if (isset($submenu_array[3])) { |
|
| 1636 | 1636 | $title = $submenu_array[3]; |
| 1637 | 1637 | return $submenu_array[3]; |
| 1638 | 1638 | } else { |
@@ -1641,12 +1641,12 @@ discard block |
||
| 1641 | 1641 | } |
| 1642 | 1642 | } |
| 1643 | 1643 | } |
| 1644 | - if ( empty ( $title ) ) { |
|
| 1645 | - foreach ( $menu as $menu_array ) { |
|
| 1646 | - if ( isset( $plugin_page ) && |
|
| 1647 | - ( $plugin_page == $menu_array[2] ) && |
|
| 1648 | - ( $pagenow == 'admin.php' ) && |
|
| 1649 | - ( $parent1 == $menu_array[2] ) ) |
|
| 1644 | + if (empty ($title)) { |
|
| 1645 | + foreach ($menu as $menu_array) { |
|
| 1646 | + if (isset($plugin_page) && |
|
| 1647 | + ($plugin_page == $menu_array[2]) && |
|
| 1648 | + ($pagenow == 'admin.php') && |
|
| 1649 | + ($parent1 == $menu_array[2])) |
|
| 1650 | 1650 | { |
| 1651 | 1651 | $title = $menu_array[3]; |
| 1652 | 1652 | return $menu_array[3]; |
@@ -1665,9 +1665,9 @@ discard block |
||
| 1665 | 1665 | * @param string $parent_page |
| 1666 | 1666 | * @return string|null |
| 1667 | 1667 | */ |
| 1668 | -function get_plugin_page_hook( $plugin_page, $parent_page ) { |
|
| 1669 | - $hook = get_plugin_page_hookname( $plugin_page, $parent_page ); |
|
| 1670 | - if ( has_action($hook) ) |
|
| 1668 | +function get_plugin_page_hook($plugin_page, $parent_page) { |
|
| 1669 | + $hook = get_plugin_page_hookname($plugin_page, $parent_page); |
|
| 1670 | + if (has_action($hook)) |
|
| 1671 | 1671 | return $hook; |
| 1672 | 1672 | else |
| 1673 | 1673 | return null; |
@@ -1679,25 +1679,25 @@ discard block |
||
| 1679 | 1679 | * @param string $plugin_page |
| 1680 | 1680 | * @param string $parent_page |
| 1681 | 1681 | */ |
| 1682 | -function get_plugin_page_hookname( $plugin_page, $parent_page ) { |
|
| 1682 | +function get_plugin_page_hookname($plugin_page, $parent_page) { |
|
| 1683 | 1683 | global $admin_page_hooks; |
| 1684 | 1684 | |
| 1685 | - $parent = get_admin_page_parent( $parent_page ); |
|
| 1685 | + $parent = get_admin_page_parent($parent_page); |
|
| 1686 | 1686 | |
| 1687 | 1687 | $page_type = 'admin'; |
| 1688 | - if ( empty ( $parent_page ) || 'admin.php' == $parent_page || isset( $admin_page_hooks[$plugin_page] ) ) { |
|
| 1689 | - if ( isset( $admin_page_hooks[$plugin_page] ) ) { |
|
| 1688 | + if (empty ($parent_page) || 'admin.php' == $parent_page || isset($admin_page_hooks[$plugin_page])) { |
|
| 1689 | + if (isset($admin_page_hooks[$plugin_page])) { |
|
| 1690 | 1690 | $page_type = 'toplevel'; |
| 1691 | - } elseif ( isset( $admin_page_hooks[$parent] )) { |
|
| 1691 | + } elseif (isset($admin_page_hooks[$parent])) { |
|
| 1692 | 1692 | $page_type = $admin_page_hooks[$parent]; |
| 1693 | 1693 | } |
| 1694 | - } elseif ( isset( $admin_page_hooks[$parent] ) ) { |
|
| 1694 | + } elseif (isset($admin_page_hooks[$parent])) { |
|
| 1695 | 1695 | $page_type = $admin_page_hooks[$parent]; |
| 1696 | 1696 | } |
| 1697 | 1697 | |
| 1698 | - $plugin_name = preg_replace( '!\.php!', '', $plugin_page ); |
|
| 1698 | + $plugin_name = preg_replace('!\.php!', '', $plugin_page); |
|
| 1699 | 1699 | |
| 1700 | - return $page_type . '_page_' . $plugin_name; |
|
| 1700 | + return $page_type.'_page_'.$plugin_name; |
|
| 1701 | 1701 | } |
| 1702 | 1702 | |
| 1703 | 1703 | /** |
@@ -1716,49 +1716,49 @@ discard block |
||
| 1716 | 1716 | |
| 1717 | 1717 | $parent = get_admin_page_parent(); |
| 1718 | 1718 | |
| 1719 | - if ( !isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$parent][$pagenow] ) ) |
|
| 1719 | + if ( ! isset($plugin_page) && isset($_wp_submenu_nopriv[$parent][$pagenow])) |
|
| 1720 | 1720 | return false; |
| 1721 | 1721 | |
| 1722 | - if ( isset( $plugin_page ) ) { |
|
| 1723 | - if ( isset( $_wp_submenu_nopriv[$parent][$plugin_page] ) ) |
|
| 1722 | + if (isset($plugin_page)) { |
|
| 1723 | + if (isset($_wp_submenu_nopriv[$parent][$plugin_page])) |
|
| 1724 | 1724 | return false; |
| 1725 | 1725 | |
| 1726 | 1726 | $hookname = get_plugin_page_hookname($plugin_page, $parent); |
| 1727 | 1727 | |
| 1728 | - if ( !isset($_registered_pages[$hookname]) ) |
|
| 1728 | + if ( ! isset($_registered_pages[$hookname])) |
|
| 1729 | 1729 | return false; |
| 1730 | 1730 | } |
| 1731 | 1731 | |
| 1732 | - if ( empty( $parent) ) { |
|
| 1733 | - if ( isset( $_wp_menu_nopriv[$pagenow] ) ) |
|
| 1732 | + if (empty($parent)) { |
|
| 1733 | + if (isset($_wp_menu_nopriv[$pagenow])) |
|
| 1734 | 1734 | return false; |
| 1735 | - if ( isset( $_wp_submenu_nopriv[$pagenow][$pagenow] ) ) |
|
| 1735 | + if (isset($_wp_submenu_nopriv[$pagenow][$pagenow])) |
|
| 1736 | 1736 | return false; |
| 1737 | - if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) ) |
|
| 1737 | + if (isset($plugin_page) && isset($_wp_submenu_nopriv[$pagenow][$plugin_page])) |
|
| 1738 | 1738 | return false; |
| 1739 | - if ( isset( $plugin_page ) && isset( $_wp_menu_nopriv[$plugin_page] ) ) |
|
| 1739 | + if (isset($plugin_page) && isset($_wp_menu_nopriv[$plugin_page])) |
|
| 1740 | 1740 | return false; |
| 1741 | - foreach (array_keys( $_wp_submenu_nopriv ) as $key ) { |
|
| 1742 | - if ( isset( $_wp_submenu_nopriv[$key][$pagenow] ) ) |
|
| 1741 | + foreach (array_keys($_wp_submenu_nopriv) as $key) { |
|
| 1742 | + if (isset($_wp_submenu_nopriv[$key][$pagenow])) |
|
| 1743 | 1743 | return false; |
| 1744 | - if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$key][$plugin_page] ) ) |
|
| 1744 | + if (isset($plugin_page) && isset($_wp_submenu_nopriv[$key][$plugin_page])) |
|
| 1745 | 1745 | return false; |
| 1746 | 1746 | } |
| 1747 | 1747 | return true; |
| 1748 | 1748 | } |
| 1749 | 1749 | |
| 1750 | - if ( isset( $plugin_page ) && ( $plugin_page == $parent ) && isset( $_wp_menu_nopriv[$plugin_page] ) ) |
|
| 1750 | + if (isset($plugin_page) && ($plugin_page == $parent) && isset($_wp_menu_nopriv[$plugin_page])) |
|
| 1751 | 1751 | return false; |
| 1752 | 1752 | |
| 1753 | - if ( isset( $submenu[$parent] ) ) { |
|
| 1754 | - foreach ( $submenu[$parent] as $submenu_array ) { |
|
| 1755 | - if ( isset( $plugin_page ) && ( $submenu_array[2] == $plugin_page ) ) { |
|
| 1756 | - if ( current_user_can( $submenu_array[1] )) |
|
| 1753 | + if (isset($submenu[$parent])) { |
|
| 1754 | + foreach ($submenu[$parent] as $submenu_array) { |
|
| 1755 | + if (isset($plugin_page) && ($submenu_array[2] == $plugin_page)) { |
|
| 1756 | + if (current_user_can($submenu_array[1])) |
|
| 1757 | 1757 | return true; |
| 1758 | 1758 | else |
| 1759 | 1759 | return false; |
| 1760 | - } elseif ( $submenu_array[2] == $pagenow ) { |
|
| 1761 | - if ( current_user_can( $submenu_array[1] )) |
|
| 1760 | + } elseif ($submenu_array[2] == $pagenow) { |
|
| 1761 | + if (current_user_can($submenu_array[1])) |
|
| 1762 | 1762 | return true; |
| 1763 | 1763 | else |
| 1764 | 1764 | return false; |
@@ -1766,9 +1766,9 @@ discard block |
||
| 1766 | 1766 | } |
| 1767 | 1767 | } |
| 1768 | 1768 | |
| 1769 | - foreach ( $menu as $menu_array ) { |
|
| 1770 | - if ( $menu_array[2] == $parent) { |
|
| 1771 | - if ( current_user_can( $menu_array[1] )) |
|
| 1769 | + foreach ($menu as $menu_array) { |
|
| 1770 | + if ($menu_array[2] == $parent) { |
|
| 1771 | + if (current_user_can($menu_array[1])) |
|
| 1772 | 1772 | return true; |
| 1773 | 1773 | else |
| 1774 | 1774 | return false; |
@@ -1792,22 +1792,22 @@ discard block |
||
| 1792 | 1792 | * @param string $option_name The name of an option to sanitize and save. |
| 1793 | 1793 | * @param callable $sanitize_callback A callback function that sanitizes the option's value. |
| 1794 | 1794 | */ |
| 1795 | -function register_setting( $option_group, $option_name, $sanitize_callback = '' ) { |
|
| 1795 | +function register_setting($option_group, $option_name, $sanitize_callback = '') { |
|
| 1796 | 1796 | global $new_whitelist_options; |
| 1797 | 1797 | |
| 1798 | - if ( 'misc' == $option_group ) { |
|
| 1799 | - _deprecated_argument( __FUNCTION__, '3.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'misc' ) ); |
|
| 1798 | + if ('misc' == $option_group) { |
|
| 1799 | + _deprecated_argument(__FUNCTION__, '3.0', sprintf(__('The "%s" options group has been removed. Use another settings group.'), 'misc')); |
|
| 1800 | 1800 | $option_group = 'general'; |
| 1801 | 1801 | } |
| 1802 | 1802 | |
| 1803 | - if ( 'privacy' == $option_group ) { |
|
| 1804 | - _deprecated_argument( __FUNCTION__, '3.5', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'privacy' ) ); |
|
| 1803 | + if ('privacy' == $option_group) { |
|
| 1804 | + _deprecated_argument(__FUNCTION__, '3.5', sprintf(__('The "%s" options group has been removed. Use another settings group.'), 'privacy')); |
|
| 1805 | 1805 | $option_group = 'reading'; |
| 1806 | 1806 | } |
| 1807 | 1807 | |
| 1808 | - $new_whitelist_options[ $option_group ][] = $option_name; |
|
| 1809 | - if ( $sanitize_callback != '' ) |
|
| 1810 | - add_filter( "sanitize_option_{$option_name}", $sanitize_callback ); |
|
| 1808 | + $new_whitelist_options[$option_group][] = $option_name; |
|
| 1809 | + if ($sanitize_callback != '') |
|
| 1810 | + add_filter("sanitize_option_{$option_name}", $sanitize_callback); |
|
| 1811 | 1811 | } |
| 1812 | 1812 | |
| 1813 | 1813 | /** |
@@ -1821,24 +1821,24 @@ discard block |
||
| 1821 | 1821 | * @param string $option_name |
| 1822 | 1822 | * @param callable $sanitize_callback |
| 1823 | 1823 | */ |
| 1824 | -function unregister_setting( $option_group, $option_name, $sanitize_callback = '' ) { |
|
| 1824 | +function unregister_setting($option_group, $option_name, $sanitize_callback = '') { |
|
| 1825 | 1825 | global $new_whitelist_options; |
| 1826 | 1826 | |
| 1827 | - if ( 'misc' == $option_group ) { |
|
| 1828 | - _deprecated_argument( __FUNCTION__, '3.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'misc' ) ); |
|
| 1827 | + if ('misc' == $option_group) { |
|
| 1828 | + _deprecated_argument(__FUNCTION__, '3.0', sprintf(__('The "%s" options group has been removed. Use another settings group.'), 'misc')); |
|
| 1829 | 1829 | $option_group = 'general'; |
| 1830 | 1830 | } |
| 1831 | 1831 | |
| 1832 | - if ( 'privacy' == $option_group ) { |
|
| 1833 | - _deprecated_argument( __FUNCTION__, '3.5', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'privacy' ) ); |
|
| 1832 | + if ('privacy' == $option_group) { |
|
| 1833 | + _deprecated_argument(__FUNCTION__, '3.5', sprintf(__('The "%s" options group has been removed. Use another settings group.'), 'privacy')); |
|
| 1834 | 1834 | $option_group = 'reading'; |
| 1835 | 1835 | } |
| 1836 | 1836 | |
| 1837 | - $pos = array_search( $option_name, (array) $new_whitelist_options[ $option_group ] ); |
|
| 1838 | - if ( $pos !== false ) |
|
| 1839 | - unset( $new_whitelist_options[ $option_group ][ $pos ] ); |
|
| 1840 | - if ( $sanitize_callback != '' ) |
|
| 1841 | - remove_filter( "sanitize_option_{$option_name}", $sanitize_callback ); |
|
| 1837 | + $pos = array_search($option_name, (array) $new_whitelist_options[$option_group]); |
|
| 1838 | + if ($pos !== false) |
|
| 1839 | + unset($new_whitelist_options[$option_group][$pos]); |
|
| 1840 | + if ($sanitize_callback != '') |
|
| 1841 | + remove_filter("sanitize_option_{$option_name}", $sanitize_callback); |
|
| 1842 | 1842 | } |
| 1843 | 1843 | |
| 1844 | 1844 | /** |
@@ -1851,11 +1851,11 @@ discard block |
||
| 1851 | 1851 | * @param array $options |
| 1852 | 1852 | * @return array |
| 1853 | 1853 | */ |
| 1854 | -function option_update_filter( $options ) { |
|
| 1854 | +function option_update_filter($options) { |
|
| 1855 | 1855 | global $new_whitelist_options; |
| 1856 | 1856 | |
| 1857 | - if ( is_array( $new_whitelist_options ) ) |
|
| 1858 | - $options = add_option_whitelist( $new_whitelist_options, $options ); |
|
| 1857 | + if (is_array($new_whitelist_options)) |
|
| 1858 | + $options = add_option_whitelist($new_whitelist_options, $options); |
|
| 1859 | 1859 | |
| 1860 | 1860 | return $options; |
| 1861 | 1861 | } |
@@ -1871,21 +1871,21 @@ discard block |
||
| 1871 | 1871 | * @param string|array $options |
| 1872 | 1872 | * @return array |
| 1873 | 1873 | */ |
| 1874 | -function add_option_whitelist( $new_options, $options = '' ) { |
|
| 1875 | - if ( $options == '' ) |
|
| 1874 | +function add_option_whitelist($new_options, $options = '') { |
|
| 1875 | + if ($options == '') |
|
| 1876 | 1876 | global $whitelist_options; |
| 1877 | 1877 | else |
| 1878 | 1878 | $whitelist_options = $options; |
| 1879 | 1879 | |
| 1880 | - foreach ( $new_options as $page => $keys ) { |
|
| 1881 | - foreach ( $keys as $key ) { |
|
| 1882 | - if ( !isset($whitelist_options[ $page ]) || !is_array($whitelist_options[ $page ]) ) { |
|
| 1883 | - $whitelist_options[ $page ] = array(); |
|
| 1884 | - $whitelist_options[ $page ][] = $key; |
|
| 1880 | + foreach ($new_options as $page => $keys) { |
|
| 1881 | + foreach ($keys as $key) { |
|
| 1882 | + if ( ! isset($whitelist_options[$page]) || ! is_array($whitelist_options[$page])) { |
|
| 1883 | + $whitelist_options[$page] = array(); |
|
| 1884 | + $whitelist_options[$page][] = $key; |
|
| 1885 | 1885 | } else { |
| 1886 | - $pos = array_search( $key, $whitelist_options[ $page ] ); |
|
| 1887 | - if ( $pos === false ) |
|
| 1888 | - $whitelist_options[ $page ][] = $key; |
|
| 1886 | + $pos = array_search($key, $whitelist_options[$page]); |
|
| 1887 | + if ($pos === false) |
|
| 1888 | + $whitelist_options[$page][] = $key; |
|
| 1889 | 1889 | } |
| 1890 | 1890 | } |
| 1891 | 1891 | } |
@@ -1904,18 +1904,18 @@ discard block |
||
| 1904 | 1904 | * @param string|array $options |
| 1905 | 1905 | * @return array |
| 1906 | 1906 | */ |
| 1907 | -function remove_option_whitelist( $del_options, $options = '' ) { |
|
| 1908 | - if ( $options == '' ) |
|
| 1907 | +function remove_option_whitelist($del_options, $options = '') { |
|
| 1908 | + if ($options == '') |
|
| 1909 | 1909 | global $whitelist_options; |
| 1910 | 1910 | else |
| 1911 | 1911 | $whitelist_options = $options; |
| 1912 | 1912 | |
| 1913 | - foreach ( $del_options as $page => $keys ) { |
|
| 1914 | - foreach ( $keys as $key ) { |
|
| 1915 | - if ( isset($whitelist_options[ $page ]) && is_array($whitelist_options[ $page ]) ) { |
|
| 1916 | - $pos = array_search( $key, $whitelist_options[ $page ] ); |
|
| 1917 | - if ( $pos !== false ) |
|
| 1918 | - unset( $whitelist_options[ $page ][ $pos ] ); |
|
| 1913 | + foreach ($del_options as $page => $keys) { |
|
| 1914 | + foreach ($keys as $key) { |
|
| 1915 | + if (isset($whitelist_options[$page]) && is_array($whitelist_options[$page])) { |
|
| 1916 | + $pos = array_search($key, $whitelist_options[$page]); |
|
| 1917 | + if ($pos !== false) |
|
| 1918 | + unset($whitelist_options[$page][$pos]); |
|
| 1919 | 1919 | } |
| 1920 | 1920 | } |
| 1921 | 1921 | } |
@@ -1931,7 +1931,7 @@ discard block |
||
| 1931 | 1931 | * @param string $option_group A settings group name. This should match the group name used in register_setting(). |
| 1932 | 1932 | */ |
| 1933 | 1933 | function settings_fields($option_group) { |
| 1934 | - echo "<input type='hidden' name='option_page' value='" . esc_attr($option_group) . "' />"; |
|
| 1934 | + echo "<input type='hidden' name='option_page' value='".esc_attr($option_group)."' />"; |
|
| 1935 | 1935 | echo '<input type="hidden" name="action" value="update" />'; |
| 1936 | 1936 | wp_nonce_field("$option_group-options"); |
| 1937 | 1937 | } |
@@ -1943,8 +1943,8 @@ discard block |
||
| 1943 | 1943 | * |
| 1944 | 1944 | * @param bool $clear_update_cache Whether to clear the Plugin updates cache |
| 1945 | 1945 | */ |
| 1946 | -function wp_clean_plugins_cache( $clear_update_cache = true ) { |
|
| 1947 | - if ( $clear_update_cache ) |
|
| 1948 | - delete_site_transient( 'update_plugins' ); |
|
| 1949 | - wp_cache_delete( 'plugins', 'plugins' ); |
|
| 1946 | +function wp_clean_plugins_cache($clear_update_cache = true) { |
|
| 1947 | + if ($clear_update_cache) |
|
| 1948 | + delete_site_transient('update_plugins'); |
|
| 1949 | + wp_cache_delete('plugins', 'plugins'); |
|
| 1950 | 1950 | } |
@@ -120,16 +120,18 @@ discard block |
||
| 120 | 120 | // Translate fields |
| 121 | 121 | if ( $translate ) { |
| 122 | 122 | if ( $textdomain = $plugin_data['TextDomain'] ) { |
| 123 | - if ( $plugin_data['DomainPath'] ) |
|
| 124 | - load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) . $plugin_data['DomainPath'] ); |
|
| 125 | - else |
|
| 126 | - load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) ); |
|
| 123 | + if ( $plugin_data['DomainPath'] ) { |
|
| 124 | + load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) . $plugin_data['DomainPath'] ); |
|
| 125 | + } else { |
|
| 126 | + load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) ); |
|
| 127 | + } |
|
| 127 | 128 | } elseif ( in_array( basename( $plugin_file ), array( 'hello.php', 'akismet.php' ) ) ) { |
| 128 | 129 | $textdomain = 'default'; |
| 129 | 130 | } |
| 130 | 131 | if ( $textdomain ) { |
| 131 | - foreach ( array( 'Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version' ) as $field ) |
|
| 132 | - $plugin_data[ $field ] = translate( $plugin_data[ $field ], $textdomain ); |
|
| 132 | + foreach ( array( 'Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version' ) as $field ) { |
|
| 133 | + $plugin_data[ $field ] = translate( $plugin_data[ $field ], $textdomain ); |
|
| 134 | + } |
|
| 133 | 135 | } |
| 134 | 136 | } |
| 135 | 137 | |
@@ -159,16 +161,19 @@ discard block |
||
| 159 | 161 | |
| 160 | 162 | // Apply markup |
| 161 | 163 | if ( $markup ) { |
| 162 | - if ( $plugin_data['PluginURI'] && $plugin_data['Name'] ) |
|
| 163 | - $plugin_data['Title'] = '<a href="' . $plugin_data['PluginURI'] . '">' . $plugin_data['Name'] . '</a>'; |
|
| 164 | + if ( $plugin_data['PluginURI'] && $plugin_data['Name'] ) { |
|
| 165 | + $plugin_data['Title'] = '<a href="' . $plugin_data['PluginURI'] . '">' . $plugin_data['Name'] . '</a>'; |
|
| 166 | + } |
|
| 164 | 167 | |
| 165 | - if ( $plugin_data['AuthorURI'] && $plugin_data['Author'] ) |
|
| 166 | - $plugin_data['Author'] = '<a href="' . $plugin_data['AuthorURI'] . '">' . $plugin_data['Author'] . '</a>'; |
|
| 168 | + if ( $plugin_data['AuthorURI'] && $plugin_data['Author'] ) { |
|
| 169 | + $plugin_data['Author'] = '<a href="' . $plugin_data['AuthorURI'] . '">' . $plugin_data['Author'] . '</a>'; |
|
| 170 | + } |
|
| 167 | 171 | |
| 168 | 172 | $plugin_data['Description'] = wptexturize( $plugin_data['Description'] ); |
| 169 | 173 | |
| 170 | - if ( $plugin_data['Author'] ) |
|
| 171 | - $plugin_data['Description'] .= ' <cite>' . sprintf( __('By %s.'), $plugin_data['Author'] ) . '</cite>'; |
|
| 174 | + if ( $plugin_data['Author'] ) { |
|
| 175 | + $plugin_data['Description'] .= ' <cite>' . sprintf( __('By %s.'), $plugin_data['Author'] ) . '</cite>'; |
|
| 176 | + } |
|
| 172 | 177 | } |
| 173 | 178 | |
| 174 | 179 | return $plugin_data; |
@@ -190,21 +195,24 @@ discard block |
||
| 190 | 195 | $plugins_dir = @ opendir( $dir ); |
| 191 | 196 | if ( $plugins_dir ) { |
| 192 | 197 | while (($file = readdir( $plugins_dir ) ) !== false ) { |
| 193 | - if ( substr($file, 0, 1) == '.' ) |
|
| 194 | - continue; |
|
| 198 | + if ( substr($file, 0, 1) == '.' ) { |
|
| 199 | + continue; |
|
| 200 | + } |
|
| 195 | 201 | if ( is_dir( $dir . '/' . $file ) ) { |
| 196 | 202 | $plugins_subdir = @ opendir( $dir . '/' . $file ); |
| 197 | 203 | if ( $plugins_subdir ) { |
| 198 | 204 | while (($subfile = readdir( $plugins_subdir ) ) !== false ) { |
| 199 | - if ( substr($subfile, 0, 1) == '.' ) |
|
| 200 | - continue; |
|
| 205 | + if ( substr($subfile, 0, 1) == '.' ) { |
|
| 206 | + continue; |
|
| 207 | + } |
|
| 201 | 208 | $plugin_files[] = plugin_basename("$dir/$file/$subfile"); |
| 202 | 209 | } |
| 203 | 210 | @closedir( $plugins_subdir ); |
| 204 | 211 | } |
| 205 | 212 | } else { |
| 206 | - if ( plugin_basename("$dir/$file") != $plugin ) |
|
| 207 | - $plugin_files[] = plugin_basename("$dir/$file"); |
|
| 213 | + if ( plugin_basename("$dir/$file") != $plugin ) { |
|
| 214 | + $plugin_files[] = plugin_basename("$dir/$file"); |
|
| 215 | + } |
|
| 208 | 216 | } |
| 209 | 217 | } |
| 210 | 218 | @closedir( $plugins_dir ); |
@@ -236,54 +244,64 @@ discard block |
||
| 236 | 244 | */ |
| 237 | 245 | function get_plugins($plugin_folder = '') { |
| 238 | 246 | |
| 239 | - if ( ! $cache_plugins = wp_cache_get('plugins', 'plugins') ) |
|
| 240 | - $cache_plugins = array(); |
|
| 247 | + if ( ! $cache_plugins = wp_cache_get('plugins', 'plugins') ) { |
|
| 248 | + $cache_plugins = array(); |
|
| 249 | + } |
|
| 241 | 250 | |
| 242 | - if ( isset($cache_plugins[ $plugin_folder ]) ) |
|
| 243 | - return $cache_plugins[ $plugin_folder ]; |
|
| 251 | + if ( isset($cache_plugins[ $plugin_folder ]) ) { |
|
| 252 | + return $cache_plugins[ $plugin_folder ]; |
|
| 253 | + } |
|
| 244 | 254 | |
| 245 | 255 | $wp_plugins = array (); |
| 246 | 256 | $plugin_root = WP_PLUGIN_DIR; |
| 247 | - if ( !empty($plugin_folder) ) |
|
| 248 | - $plugin_root .= $plugin_folder; |
|
| 257 | + if ( !empty($plugin_folder) ) { |
|
| 258 | + $plugin_root .= $plugin_folder; |
|
| 259 | + } |
|
| 249 | 260 | |
| 250 | 261 | // Files in wp-content/plugins directory |
| 251 | 262 | $plugins_dir = @ opendir( $plugin_root); |
| 252 | 263 | $plugin_files = array(); |
| 253 | 264 | if ( $plugins_dir ) { |
| 254 | 265 | while (($file = readdir( $plugins_dir ) ) !== false ) { |
| 255 | - if ( substr($file, 0, 1) == '.' ) |
|
| 256 | - continue; |
|
| 266 | + if ( substr($file, 0, 1) == '.' ) { |
|
| 267 | + continue; |
|
| 268 | + } |
|
| 257 | 269 | if ( is_dir( $plugin_root.'/'.$file ) ) { |
| 258 | 270 | $plugins_subdir = @ opendir( $plugin_root.'/'.$file ); |
| 259 | 271 | if ( $plugins_subdir ) { |
| 260 | 272 | while (($subfile = readdir( $plugins_subdir ) ) !== false ) { |
| 261 | - if ( substr($subfile, 0, 1) == '.' ) |
|
| 262 | - continue; |
|
| 263 | - if ( substr($subfile, -4) == '.php' ) |
|
| 264 | - $plugin_files[] = "$file/$subfile"; |
|
| 273 | + if ( substr($subfile, 0, 1) == '.' ) { |
|
| 274 | + continue; |
|
| 275 | + } |
|
| 276 | + if ( substr($subfile, -4) == '.php' ) { |
|
| 277 | + $plugin_files[] = "$file/$subfile"; |
|
| 278 | + } |
|
| 265 | 279 | } |
| 266 | 280 | closedir( $plugins_subdir ); |
| 267 | 281 | } |
| 268 | 282 | } else { |
| 269 | - if ( substr($file, -4) == '.php' ) |
|
| 270 | - $plugin_files[] = $file; |
|
| 283 | + if ( substr($file, -4) == '.php' ) { |
|
| 284 | + $plugin_files[] = $file; |
|
| 285 | + } |
|
| 271 | 286 | } |
| 272 | 287 | } |
| 273 | 288 | closedir( $plugins_dir ); |
| 274 | 289 | } |
| 275 | 290 | |
| 276 | - if ( empty($plugin_files) ) |
|
| 277 | - return $wp_plugins; |
|
| 291 | + if ( empty($plugin_files) ) { |
|
| 292 | + return $wp_plugins; |
|
| 293 | + } |
|
| 278 | 294 | |
| 279 | 295 | foreach ( $plugin_files as $plugin_file ) { |
| 280 | - if ( !is_readable( "$plugin_root/$plugin_file" ) ) |
|
| 281 | - continue; |
|
| 296 | + if ( !is_readable( "$plugin_root/$plugin_file" ) ) { |
|
| 297 | + continue; |
|
| 298 | + } |
|
| 282 | 299 | |
| 283 | 300 | $plugin_data = get_plugin_data( "$plugin_root/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached. |
| 284 | 301 | |
| 285 | - if ( empty ( $plugin_data['Name'] ) ) |
|
| 286 | - continue; |
|
| 302 | + if ( empty ( $plugin_data['Name'] ) ) { |
|
| 303 | + continue; |
|
| 304 | + } |
|
| 287 | 305 | |
| 288 | 306 | $wp_plugins[plugin_basename( $plugin_file )] = $plugin_data; |
| 289 | 307 | } |
@@ -309,12 +327,14 @@ discard block |
||
| 309 | 327 | // Files in wp-content/mu-plugins directory |
| 310 | 328 | $plugin_files = array(); |
| 311 | 329 | |
| 312 | - if ( ! is_dir( WPMU_PLUGIN_DIR ) ) |
|
| 313 | - return $wp_plugins; |
|
| 330 | + if ( ! is_dir( WPMU_PLUGIN_DIR ) ) { |
|
| 331 | + return $wp_plugins; |
|
| 332 | + } |
|
| 314 | 333 | if ( $plugins_dir = @ opendir( WPMU_PLUGIN_DIR ) ) { |
| 315 | 334 | while ( ( $file = readdir( $plugins_dir ) ) !== false ) { |
| 316 | - if ( substr( $file, -4 ) == '.php' ) |
|
| 317 | - $plugin_files[] = $file; |
|
| 335 | + if ( substr( $file, -4 ) == '.php' ) { |
|
| 336 | + $plugin_files[] = $file; |
|
| 337 | + } |
|
| 318 | 338 | } |
| 319 | 339 | } else { |
| 320 | 340 | return $wp_plugins; |
@@ -322,23 +342,28 @@ discard block |
||
| 322 | 342 | |
| 323 | 343 | @closedir( $plugins_dir ); |
| 324 | 344 | |
| 325 | - if ( empty($plugin_files) ) |
|
| 326 | - return $wp_plugins; |
|
| 345 | + if ( empty($plugin_files) ) { |
|
| 346 | + return $wp_plugins; |
|
| 347 | + } |
|
| 327 | 348 | |
| 328 | 349 | foreach ( $plugin_files as $plugin_file ) { |
| 329 | - if ( !is_readable( WPMU_PLUGIN_DIR . "/$plugin_file" ) ) |
|
| 330 | - continue; |
|
| 350 | + if ( !is_readable( WPMU_PLUGIN_DIR . "/$plugin_file" ) ) { |
|
| 351 | + continue; |
|
| 352 | + } |
|
| 331 | 353 | |
| 332 | 354 | $plugin_data = get_plugin_data( WPMU_PLUGIN_DIR . "/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached. |
| 333 | 355 | |
| 334 | - if ( empty ( $plugin_data['Name'] ) ) |
|
| 335 | - $plugin_data['Name'] = $plugin_file; |
|
| 356 | + if ( empty ( $plugin_data['Name'] ) ) { |
|
| 357 | + $plugin_data['Name'] = $plugin_file; |
|
| 358 | + } |
|
| 336 | 359 | |
| 337 | 360 | $wp_plugins[ $plugin_file ] = $plugin_data; |
| 338 | 361 | } |
| 339 | 362 | |
| 340 | - if ( isset( $wp_plugins['index.php'] ) && filesize( WPMU_PLUGIN_DIR . '/index.php') <= 30 ) // silence is golden |
|
| 363 | + if ( isset( $wp_plugins['index.php'] ) && filesize( WPMU_PLUGIN_DIR . '/index.php') <= 30 ) { |
|
| 364 | + // silence is golden |
|
| 341 | 365 | unset( $wp_plugins['index.php'] ); |
| 366 | + } |
|
| 342 | 367 | |
| 343 | 368 | uasort( $wp_plugins, '_sort_uname_callback' ); |
| 344 | 369 | |
@@ -370,8 +395,9 @@ discard block |
||
| 370 | 395 | // These exist in the wp-content directory |
| 371 | 396 | if ( $plugins_dir = @ opendir( WP_CONTENT_DIR ) ) { |
| 372 | 397 | while ( ( $file = readdir( $plugins_dir ) ) !== false ) { |
| 373 | - if ( isset( $_dropins[ $file ] ) ) |
|
| 374 | - $plugin_files[] = $file; |
|
| 398 | + if ( isset( $_dropins[ $file ] ) ) { |
|
| 399 | + $plugin_files[] = $file; |
|
| 400 | + } |
|
| 375 | 401 | } |
| 376 | 402 | } else { |
| 377 | 403 | return $dropins; |
@@ -379,15 +405,18 @@ discard block |
||
| 379 | 405 | |
| 380 | 406 | @closedir( $plugins_dir ); |
| 381 | 407 | |
| 382 | - if ( empty($plugin_files) ) |
|
| 383 | - return $dropins; |
|
| 408 | + if ( empty($plugin_files) ) { |
|
| 409 | + return $dropins; |
|
| 410 | + } |
|
| 384 | 411 | |
| 385 | 412 | foreach ( $plugin_files as $plugin_file ) { |
| 386 | - if ( !is_readable( WP_CONTENT_DIR . "/$plugin_file" ) ) |
|
| 387 | - continue; |
|
| 413 | + if ( !is_readable( WP_CONTENT_DIR . "/$plugin_file" ) ) { |
|
| 414 | + continue; |
|
| 415 | + } |
|
| 388 | 416 | $plugin_data = get_plugin_data( WP_CONTENT_DIR . "/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached. |
| 389 | - if ( empty( $plugin_data['Name'] ) ) |
|
| 390 | - $plugin_data['Name'] = $plugin_file; |
|
| 417 | + if ( empty( $plugin_data['Name'] ) ) { |
|
| 418 | + $plugin_data['Name'] = $plugin_file; |
|
| 419 | + } |
|
| 391 | 420 | $dropins[ $plugin_file ] = $plugin_data; |
| 392 | 421 | } |
| 393 | 422 | |
@@ -462,12 +491,14 @@ discard block |
||
| 462 | 491 | * @return bool True, if active for the network, otherwise false. |
| 463 | 492 | */ |
| 464 | 493 | function is_plugin_active_for_network( $plugin ) { |
| 465 | - if ( !is_multisite() ) |
|
| 466 | - return false; |
|
| 494 | + if ( !is_multisite() ) { |
|
| 495 | + return false; |
|
| 496 | + } |
|
| 467 | 497 | |
| 468 | 498 | $plugins = get_site_option( 'active_sitewide_plugins'); |
| 469 | - if ( isset($plugins[$plugin]) ) |
|
| 470 | - return true; |
|
| 499 | + if ( isset($plugins[$plugin]) ) { |
|
| 500 | + return true; |
|
| 501 | + } |
|
| 471 | 502 | |
| 472 | 503 | return false; |
| 473 | 504 | } |
@@ -486,8 +517,9 @@ discard block |
||
| 486 | 517 | */ |
| 487 | 518 | function is_network_only_plugin( $plugin ) { |
| 488 | 519 | $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); |
| 489 | - if ( $plugin_data ) |
|
| 490 | - return $plugin_data['Network']; |
|
| 520 | + if ( $plugin_data ) { |
|
| 521 | + return $plugin_data['Network']; |
|
| 522 | + } |
|
| 491 | 523 | return false; |
| 492 | 524 | } |
| 493 | 525 | |
@@ -530,12 +562,15 @@ discard block |
||
| 530 | 562 | } |
| 531 | 563 | |
| 532 | 564 | $valid = validate_plugin($plugin); |
| 533 | - if ( is_wp_error($valid) ) |
|
| 534 | - return $valid; |
|
| 565 | + if ( is_wp_error($valid) ) { |
|
| 566 | + return $valid; |
|
| 567 | + } |
|
| 535 | 568 | |
| 536 | 569 | if ( ( $network_wide && ! isset( $current[ $plugin ] ) ) || ( ! $network_wide && ! in_array( $plugin, $current ) ) ) { |
| 537 | - if ( !empty($redirect) ) |
|
| 538 | - wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); // we'll override this later if the plugin can be included without fatal error |
|
| 570 | + if ( !empty($redirect) ) { |
|
| 571 | + wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); |
|
| 572 | + } |
|
| 573 | + // we'll override this later if the plugin can be included without fatal error |
|
| 539 | 574 | ob_start(); |
| 540 | 575 | wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin ); |
| 541 | 576 | $_wp_plugin_file = $plugin; |
@@ -626,15 +661,17 @@ discard block |
||
| 626 | 661 | * A value of null (the default) will deactivate plugins for both the site and the network. |
| 627 | 662 | */ |
| 628 | 663 | function deactivate_plugins( $plugins, $silent = false, $network_wide = null ) { |
| 629 | - if ( is_multisite() ) |
|
| 630 | - $network_current = get_site_option( 'active_sitewide_plugins', array() ); |
|
| 664 | + if ( is_multisite() ) { |
|
| 665 | + $network_current = get_site_option( 'active_sitewide_plugins', array() ); |
|
| 666 | + } |
|
| 631 | 667 | $current = get_option( 'active_plugins', array() ); |
| 632 | 668 | $do_blog = $do_network = false; |
| 633 | 669 | |
| 634 | 670 | foreach ( (array) $plugins as $plugin ) { |
| 635 | 671 | $plugin = plugin_basename( trim( $plugin ) ); |
| 636 | - if ( ! is_plugin_active($plugin) ) |
|
| 637 | - continue; |
|
| 672 | + if ( ! is_plugin_active($plugin) ) { |
|
| 673 | + continue; |
|
| 674 | + } |
|
| 638 | 675 | |
| 639 | 676 | $network_deactivating = false !== $network_wide && is_plugin_active_for_network( $plugin ); |
| 640 | 677 | |
@@ -705,11 +742,13 @@ discard block |
||
| 705 | 742 | } |
| 706 | 743 | } |
| 707 | 744 | |
| 708 | - if ( $do_blog ) |
|
| 709 | - update_option('active_plugins', $current); |
|
| 710 | - if ( $do_network ) |
|
| 711 | - update_site_option( 'active_sitewide_plugins', $network_current ); |
|
| 712 | -} |
|
| 745 | + if ( $do_blog ) { |
|
| 746 | + update_option('active_plugins', $current); |
|
| 747 | + } |
|
| 748 | + if ( $do_network ) { |
|
| 749 | + update_site_option( 'active_sitewide_plugins', $network_current ); |
|
| 750 | + } |
|
| 751 | + } |
|
| 713 | 752 | |
| 714 | 753 | /** |
| 715 | 754 | * Activate multiple plugins. |
@@ -728,20 +767,24 @@ discard block |
||
| 728 | 767 | * @return bool|WP_Error True when finished or WP_Error if there were errors during a plugin activation. |
| 729 | 768 | */ |
| 730 | 769 | function activate_plugins( $plugins, $redirect = '', $network_wide = false, $silent = false ) { |
| 731 | - if ( !is_array($plugins) ) |
|
| 732 | - $plugins = array($plugins); |
|
| 770 | + if ( !is_array($plugins) ) { |
|
| 771 | + $plugins = array($plugins); |
|
| 772 | + } |
|
| 733 | 773 | |
| 734 | 774 | $errors = array(); |
| 735 | 775 | foreach ( $plugins as $plugin ) { |
| 736 | - if ( !empty($redirect) ) |
|
| 737 | - $redirect = add_query_arg('plugin', $plugin, $redirect); |
|
| 776 | + if ( !empty($redirect) ) { |
|
| 777 | + $redirect = add_query_arg('plugin', $plugin, $redirect); |
|
| 778 | + } |
|
| 738 | 779 | $result = activate_plugin($plugin, $redirect, $network_wide, $silent); |
| 739 | - if ( is_wp_error($result) ) |
|
| 740 | - $errors[$plugin] = $result; |
|
| 780 | + if ( is_wp_error($result) ) { |
|
| 781 | + $errors[$plugin] = $result; |
|
| 782 | + } |
|
| 741 | 783 | } |
| 742 | 784 | |
| 743 | - if ( !empty($errors) ) |
|
| 744 | - return new WP_Error('plugins_invalid', __('One of the plugins is invalid.'), $errors); |
|
| 785 | + if ( !empty($errors) ) { |
|
| 786 | + return new WP_Error('plugins_invalid', __('One of the plugins is invalid.'), $errors); |
|
| 787 | + } |
|
| 745 | 788 | |
| 746 | 789 | return true; |
| 747 | 790 | } |
@@ -761,12 +804,14 @@ discard block |
||
| 761 | 804 | function delete_plugins( $plugins, $deprecated = '' ) { |
| 762 | 805 | global $wp_filesystem; |
| 763 | 806 | |
| 764 | - if ( empty($plugins) ) |
|
| 765 | - return false; |
|
| 807 | + if ( empty($plugins) ) { |
|
| 808 | + return false; |
|
| 809 | + } |
|
| 766 | 810 | |
| 767 | 811 | $checked = array(); |
| 768 | - foreach( $plugins as $plugin ) |
|
| 769 | - $checked[] = 'checked[]=' . $plugin; |
|
| 812 | + foreach( $plugins as $plugin ) { |
|
| 813 | + $checked[] = 'checked[]=' . $plugin; |
|
| 814 | + } |
|
| 770 | 815 | |
| 771 | 816 | ob_start(); |
| 772 | 817 | $url = wp_nonce_url('plugins.php?action=delete-selected&verify-delete=1&' . implode('&', $checked), 'bulk-plugins'); |
@@ -795,11 +840,13 @@ discard block |
||
| 795 | 840 | return; |
| 796 | 841 | } |
| 797 | 842 | |
| 798 | - if ( ! is_object($wp_filesystem) ) |
|
| 799 | - return new WP_Error('fs_unavailable', __('Could not access filesystem.')); |
|
| 843 | + if ( ! is_object($wp_filesystem) ) { |
|
| 844 | + return new WP_Error('fs_unavailable', __('Could not access filesystem.')); |
|
| 845 | + } |
|
| 800 | 846 | |
| 801 | - if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() ) |
|
| 802 | - return new WP_Error('fs_error', __('Filesystem error.'), $wp_filesystem->errors); |
|
| 847 | + if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() ) { |
|
| 848 | + return new WP_Error('fs_error', __('Filesystem error.'), $wp_filesystem->errors); |
|
| 849 | + } |
|
| 803 | 850 | |
| 804 | 851 | // Get the base plugin folder. |
| 805 | 852 | $plugins_dir = $wp_filesystem->wp_plugins_dir(); |
@@ -856,8 +903,9 @@ discard block |
||
| 856 | 903 | set_site_transient( 'update_plugins', $current ); |
| 857 | 904 | } |
| 858 | 905 | |
| 859 | - if ( ! empty($errors) ) |
|
| 860 | - return new WP_Error('could_not_remove_plugin', sprintf(__('Could not fully remove the plugin(s) %s.'), implode(', ', $errors)) ); |
|
| 906 | + if ( ! empty($errors) ) { |
|
| 907 | + return new WP_Error('could_not_remove_plugin', sprintf(__('Could not fully remove the plugin(s) %s.'), implode(', ', $errors)) ); |
|
| 908 | + } |
|
| 861 | 909 | |
| 862 | 910 | return true; |
| 863 | 911 | } |
@@ -884,8 +932,9 @@ discard block |
||
| 884 | 932 | $plugins = array_merge( $plugins, array_keys( $network_plugins ) ); |
| 885 | 933 | } |
| 886 | 934 | |
| 887 | - if ( empty( $plugins ) ) |
|
| 888 | - return array(); |
|
| 935 | + if ( empty( $plugins ) ) { |
|
| 936 | + return array(); |
|
| 937 | + } |
|
| 889 | 938 | |
| 890 | 939 | $invalid = array(); |
| 891 | 940 | |
@@ -911,14 +960,17 @@ discard block |
||
| 911 | 960 | * @return WP_Error|int 0 on success, WP_Error on failure. |
| 912 | 961 | */ |
| 913 | 962 | function validate_plugin($plugin) { |
| 914 | - if ( validate_file($plugin) ) |
|
| 915 | - return new WP_Error('plugin_invalid', __('Invalid plugin path.')); |
|
| 916 | - if ( ! file_exists(WP_PLUGIN_DIR . '/' . $plugin) ) |
|
| 917 | - return new WP_Error('plugin_not_found', __('Plugin file does not exist.')); |
|
| 963 | + if ( validate_file($plugin) ) { |
|
| 964 | + return new WP_Error('plugin_invalid', __('Invalid plugin path.')); |
|
| 965 | + } |
|
| 966 | + if ( ! file_exists(WP_PLUGIN_DIR . '/' . $plugin) ) { |
|
| 967 | + return new WP_Error('plugin_not_found', __('Plugin file does not exist.')); |
|
| 968 | + } |
|
| 918 | 969 | |
| 919 | 970 | $installed_plugins = get_plugins(); |
| 920 | - if ( ! isset($installed_plugins[$plugin]) ) |
|
| 921 | - return new WP_Error('no_plugin_header', __('The plugin does not have a valid header.')); |
|
| 971 | + if ( ! isset($installed_plugins[$plugin]) ) { |
|
| 972 | + return new WP_Error('no_plugin_header', __('The plugin does not have a valid header.')); |
|
| 973 | + } |
|
| 922 | 974 | return 0; |
| 923 | 975 | } |
| 924 | 976 | |
@@ -934,8 +986,9 @@ discard block |
||
| 934 | 986 | $file = plugin_basename($plugin); |
| 935 | 987 | |
| 936 | 988 | $uninstallable_plugins = (array) get_option('uninstall_plugins'); |
| 937 | - if ( isset( $uninstallable_plugins[$file] ) || file_exists( WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php' ) ) |
|
| 938 | - return true; |
|
| 989 | + if ( isset( $uninstallable_plugins[$file] ) || file_exists( WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php' ) ) { |
|
| 990 | + return true; |
|
| 991 | + } |
|
| 939 | 992 | |
| 940 | 993 | return false; |
| 941 | 994 | } |
@@ -1032,8 +1085,9 @@ discard block |
||
| 1032 | 1085 | |
| 1033 | 1086 | $hookname = get_plugin_page_hookname( $menu_slug, '' ); |
| 1034 | 1087 | |
| 1035 | - if ( !empty( $function ) && !empty( $hookname ) && current_user_can( $capability ) ) |
|
| 1036 | - add_action( $hookname, $function ); |
|
| 1088 | + if ( !empty( $function ) && !empty( $hookname ) && current_user_can( $capability ) ) { |
|
| 1089 | + add_action( $hookname, $function ); |
|
| 1090 | + } |
|
| 1037 | 1091 | |
| 1038 | 1092 | if ( empty($icon_url) ) { |
| 1039 | 1093 | $icon_url = 'dashicons-admin-generic'; |
@@ -1045,10 +1099,11 @@ discard block |
||
| 1045 | 1099 | |
| 1046 | 1100 | $new_menu = array( $menu_title, $capability, $menu_slug, $page_title, 'menu-top ' . $icon_class . $hookname, $hookname, $icon_url ); |
| 1047 | 1101 | |
| 1048 | - if ( null === $position ) |
|
| 1049 | - $menu[] = $new_menu; |
|
| 1050 | - else |
|
| 1051 | - $menu[$position] = $new_menu; |
|
| 1102 | + if ( null === $position ) { |
|
| 1103 | + $menu[] = $new_menu; |
|
| 1104 | + } else { |
|
| 1105 | + $menu[$position] = $new_menu; |
|
| 1106 | + } |
|
| 1052 | 1107 | |
| 1053 | 1108 | $_registered_pages[$hookname] = true; |
| 1054 | 1109 | |
@@ -1146,8 +1201,9 @@ discard block |
||
| 1146 | 1201 | $menu_slug = plugin_basename( $menu_slug ); |
| 1147 | 1202 | $parent_slug = plugin_basename( $parent_slug); |
| 1148 | 1203 | |
| 1149 | - if ( isset( $_wp_real_parent_file[$parent_slug] ) ) |
|
| 1150 | - $parent_slug = $_wp_real_parent_file[$parent_slug]; |
|
| 1204 | + if ( isset( $_wp_real_parent_file[$parent_slug] ) ) { |
|
| 1205 | + $parent_slug = $_wp_real_parent_file[$parent_slug]; |
|
| 1206 | + } |
|
| 1151 | 1207 | |
| 1152 | 1208 | if ( !current_user_can( $capability ) ) { |
| 1153 | 1209 | $_wp_submenu_nopriv[$parent_slug][$menu_slug] = true; |
@@ -1162,16 +1218,18 @@ discard block |
||
| 1162 | 1218 | */ |
| 1163 | 1219 | if (!isset( $submenu[$parent_slug] ) && $menu_slug != $parent_slug ) { |
| 1164 | 1220 | foreach ( (array)$menu as $parent_menu ) { |
| 1165 | - if ( $parent_menu[2] == $parent_slug && current_user_can( $parent_menu[1] ) ) |
|
| 1166 | - $submenu[$parent_slug][] = array_slice( $parent_menu, 0, 4 ); |
|
| 1221 | + if ( $parent_menu[2] == $parent_slug && current_user_can( $parent_menu[1] ) ) { |
|
| 1222 | + $submenu[$parent_slug][] = array_slice( $parent_menu, 0, 4 ); |
|
| 1223 | + } |
|
| 1167 | 1224 | } |
| 1168 | 1225 | } |
| 1169 | 1226 | |
| 1170 | 1227 | $submenu[$parent_slug][] = array ( $menu_title, $capability, $menu_slug, $page_title ); |
| 1171 | 1228 | |
| 1172 | 1229 | $hookname = get_plugin_page_hookname( $menu_slug, $parent_slug); |
| 1173 | - if (!empty ( $function ) && !empty ( $hookname )) |
|
| 1174 | - add_action( $hookname, $function ); |
|
| 1230 | + if (!empty ( $function ) && !empty ( $hookname )) { |
|
| 1231 | + add_action( $hookname, $function ); |
|
| 1232 | + } |
|
| 1175 | 1233 | |
| 1176 | 1234 | $_registered_pages[$hookname] = true; |
| 1177 | 1235 | |
@@ -1179,8 +1237,9 @@ discard block |
||
| 1179 | 1237 | * Backward-compatibility for plugins using add_management page. |
| 1180 | 1238 | * See wp-admin/admin.php for redirect from edit.php to tools.php |
| 1181 | 1239 | */ |
| 1182 | - if ( 'tools.php' == $parent_slug ) |
|
| 1183 | - $_registered_pages[get_plugin_page_hookname( $menu_slug, 'edit.php')] = true; |
|
| 1240 | + if ( 'tools.php' == $parent_slug ) { |
|
| 1241 | + $_registered_pages[get_plugin_page_hookname( $menu_slug, 'edit.php')] = true; |
|
| 1242 | + } |
|
| 1184 | 1243 | |
| 1185 | 1244 | // No parent as top level. |
| 1186 | 1245 | $_parent_pages[$menu_slug] = $parent_slug; |
@@ -1290,10 +1349,11 @@ discard block |
||
| 1290 | 1349 | * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. |
| 1291 | 1350 | */ |
| 1292 | 1351 | function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { |
| 1293 | - if ( current_user_can('edit_users') ) |
|
| 1294 | - $parent = 'users.php'; |
|
| 1295 | - else |
|
| 1296 | - $parent = 'profile.php'; |
|
| 1352 | + if ( current_user_can('edit_users') ) { |
|
| 1353 | + $parent = 'users.php'; |
|
| 1354 | + } else { |
|
| 1355 | + $parent = 'profile.php'; |
|
| 1356 | + } |
|
| 1297 | 1357 | return add_submenu_page( $parent, $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 1298 | 1358 | } |
| 1299 | 1359 | /** |
@@ -1459,8 +1519,9 @@ discard block |
||
| 1459 | 1519 | function remove_submenu_page( $menu_slug, $submenu_slug ) { |
| 1460 | 1520 | global $submenu; |
| 1461 | 1521 | |
| 1462 | - if ( !isset( $submenu[$menu_slug] ) ) |
|
| 1463 | - return false; |
|
| 1522 | + if ( !isset( $submenu[$menu_slug] ) ) { |
|
| 1523 | + return false; |
|
| 1524 | + } |
|
| 1464 | 1525 | |
| 1465 | 1526 | foreach ( $submenu[$menu_slug] as $i => $item ) { |
| 1466 | 1527 | if ( $submenu_slug == $item[2] ) { |
@@ -1501,8 +1562,9 @@ discard block |
||
| 1501 | 1562 | |
| 1502 | 1563 | $url = esc_url($url); |
| 1503 | 1564 | |
| 1504 | - if ( $echo ) |
|
| 1505 | - echo $url; |
|
| 1565 | + if ( $echo ) { |
|
| 1566 | + echo $url; |
|
| 1567 | + } |
|
| 1506 | 1568 | |
| 1507 | 1569 | return $url; |
| 1508 | 1570 | } |
@@ -1527,8 +1589,9 @@ discard block |
||
| 1527 | 1589 | $plugin_page, $_wp_real_parent_file, $_wp_menu_nopriv, $_wp_submenu_nopriv; |
| 1528 | 1590 | |
| 1529 | 1591 | if ( !empty ( $parent ) && 'admin.php' != $parent ) { |
| 1530 | - if ( isset( $_wp_real_parent_file[$parent] ) ) |
|
| 1531 | - $parent = $_wp_real_parent_file[$parent]; |
|
| 1592 | + if ( isset( $_wp_real_parent_file[$parent] ) ) { |
|
| 1593 | + $parent = $_wp_real_parent_file[$parent]; |
|
| 1594 | + } |
|
| 1532 | 1595 | return $parent; |
| 1533 | 1596 | } |
| 1534 | 1597 | |
@@ -1536,30 +1599,34 @@ discard block |
||
| 1536 | 1599 | foreach ( (array)$menu as $parent_menu ) { |
| 1537 | 1600 | if ( $parent_menu[2] == $plugin_page ) { |
| 1538 | 1601 | $parent_file = $plugin_page; |
| 1539 | - if ( isset( $_wp_real_parent_file[$parent_file] ) ) |
|
| 1540 | - $parent_file = $_wp_real_parent_file[$parent_file]; |
|
| 1602 | + if ( isset( $_wp_real_parent_file[$parent_file] ) ) { |
|
| 1603 | + $parent_file = $_wp_real_parent_file[$parent_file]; |
|
| 1604 | + } |
|
| 1541 | 1605 | return $parent_file; |
| 1542 | 1606 | } |
| 1543 | 1607 | } |
| 1544 | 1608 | if ( isset( $_wp_menu_nopriv[$plugin_page] ) ) { |
| 1545 | 1609 | $parent_file = $plugin_page; |
| 1546 | - if ( isset( $_wp_real_parent_file[$parent_file] ) ) |
|
| 1547 | - $parent_file = $_wp_real_parent_file[$parent_file]; |
|
| 1610 | + if ( isset( $_wp_real_parent_file[$parent_file] ) ) { |
|
| 1611 | + $parent_file = $_wp_real_parent_file[$parent_file]; |
|
| 1612 | + } |
|
| 1548 | 1613 | return $parent_file; |
| 1549 | 1614 | } |
| 1550 | 1615 | } |
| 1551 | 1616 | |
| 1552 | 1617 | if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) ) { |
| 1553 | 1618 | $parent_file = $pagenow; |
| 1554 | - if ( isset( $_wp_real_parent_file[$parent_file] ) ) |
|
| 1555 | - $parent_file = $_wp_real_parent_file[$parent_file]; |
|
| 1619 | + if ( isset( $_wp_real_parent_file[$parent_file] ) ) { |
|
| 1620 | + $parent_file = $_wp_real_parent_file[$parent_file]; |
|
| 1621 | + } |
|
| 1556 | 1622 | return $parent_file; |
| 1557 | 1623 | } |
| 1558 | 1624 | |
| 1559 | 1625 | foreach (array_keys( (array)$submenu ) as $parent) { |
| 1560 | 1626 | foreach ( $submenu[$parent] as $submenu_array ) { |
| 1561 | - if ( isset( $_wp_real_parent_file[$parent] ) ) |
|
| 1562 | - $parent = $_wp_real_parent_file[$parent]; |
|
| 1627 | + if ( isset( $_wp_real_parent_file[$parent] ) ) { |
|
| 1628 | + $parent = $_wp_real_parent_file[$parent]; |
|
| 1629 | + } |
|
| 1563 | 1630 | if ( !empty($typenow) && ($submenu_array[2] == "$pagenow?post_type=$typenow") ) { |
| 1564 | 1631 | $parent_file = $parent; |
| 1565 | 1632 | return $parent; |
@@ -1573,8 +1640,9 @@ discard block |
||
| 1573 | 1640 | } |
| 1574 | 1641 | } |
| 1575 | 1642 | |
| 1576 | - if ( empty($parent_file) ) |
|
| 1577 | - $parent_file = ''; |
|
| 1643 | + if ( empty($parent_file) ) { |
|
| 1644 | + $parent_file = ''; |
|
| 1645 | + } |
|
| 1578 | 1646 | return ''; |
| 1579 | 1647 | } |
| 1580 | 1648 | |
@@ -1590,8 +1658,9 @@ discard block |
||
| 1590 | 1658 | function get_admin_page_title() { |
| 1591 | 1659 | global $title, $menu, $submenu, $pagenow, $plugin_page, $typenow; |
| 1592 | 1660 | |
| 1593 | - if ( ! empty ( $title ) ) |
|
| 1594 | - return $title; |
|
| 1661 | + if ( ! empty ( $title ) ) { |
|
| 1662 | + return $title; |
|
| 1663 | + } |
|
| 1595 | 1664 | |
| 1596 | 1665 | $hook = get_plugin_page_hook( $plugin_page, $pagenow ); |
| 1597 | 1666 | |
@@ -1629,8 +1698,10 @@ discard block |
||
| 1629 | 1698 | return $submenu_array[3]; |
| 1630 | 1699 | } |
| 1631 | 1700 | |
| 1632 | - if ( $submenu_array[2] != $pagenow || isset( $_GET['page'] ) ) // not the current page |
|
| 1701 | + if ( $submenu_array[2] != $pagenow || isset( $_GET['page'] ) ) { |
|
| 1702 | + // not the current page |
|
| 1633 | 1703 | continue; |
| 1704 | + } |
|
| 1634 | 1705 | |
| 1635 | 1706 | if ( isset( $submenu_array[3] ) ) { |
| 1636 | 1707 | $title = $submenu_array[3]; |
@@ -1667,11 +1738,12 @@ discard block |
||
| 1667 | 1738 | */ |
| 1668 | 1739 | function get_plugin_page_hook( $plugin_page, $parent_page ) { |
| 1669 | 1740 | $hook = get_plugin_page_hookname( $plugin_page, $parent_page ); |
| 1670 | - if ( has_action($hook) ) |
|
| 1671 | - return $hook; |
|
| 1672 | - else |
|
| 1673 | - return null; |
|
| 1674 | -} |
|
| 1741 | + if ( has_action($hook) ) { |
|
| 1742 | + return $hook; |
|
| 1743 | + } else { |
|
| 1744 | + return null; |
|
| 1745 | + } |
|
| 1746 | + } |
|
| 1675 | 1747 | |
| 1676 | 1748 | /** |
| 1677 | 1749 | * |
@@ -1716,62 +1788,75 @@ discard block |
||
| 1716 | 1788 | |
| 1717 | 1789 | $parent = get_admin_page_parent(); |
| 1718 | 1790 | |
| 1719 | - if ( !isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$parent][$pagenow] ) ) |
|
| 1720 | - return false; |
|
| 1791 | + if ( !isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$parent][$pagenow] ) ) { |
|
| 1792 | + return false; |
|
| 1793 | + } |
|
| 1721 | 1794 | |
| 1722 | 1795 | if ( isset( $plugin_page ) ) { |
| 1723 | - if ( isset( $_wp_submenu_nopriv[$parent][$plugin_page] ) ) |
|
| 1724 | - return false; |
|
| 1796 | + if ( isset( $_wp_submenu_nopriv[$parent][$plugin_page] ) ) { |
|
| 1797 | + return false; |
|
| 1798 | + } |
|
| 1725 | 1799 | |
| 1726 | 1800 | $hookname = get_plugin_page_hookname($plugin_page, $parent); |
| 1727 | 1801 | |
| 1728 | - if ( !isset($_registered_pages[$hookname]) ) |
|
| 1729 | - return false; |
|
| 1802 | + if ( !isset($_registered_pages[$hookname]) ) { |
|
| 1803 | + return false; |
|
| 1804 | + } |
|
| 1730 | 1805 | } |
| 1731 | 1806 | |
| 1732 | 1807 | if ( empty( $parent) ) { |
| 1733 | - if ( isset( $_wp_menu_nopriv[$pagenow] ) ) |
|
| 1734 | - return false; |
|
| 1735 | - if ( isset( $_wp_submenu_nopriv[$pagenow][$pagenow] ) ) |
|
| 1736 | - return false; |
|
| 1737 | - if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) ) |
|
| 1738 | - return false; |
|
| 1739 | - if ( isset( $plugin_page ) && isset( $_wp_menu_nopriv[$plugin_page] ) ) |
|
| 1740 | - return false; |
|
| 1808 | + if ( isset( $_wp_menu_nopriv[$pagenow] ) ) { |
|
| 1809 | + return false; |
|
| 1810 | + } |
|
| 1811 | + if ( isset( $_wp_submenu_nopriv[$pagenow][$pagenow] ) ) { |
|
| 1812 | + return false; |
|
| 1813 | + } |
|
| 1814 | + if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) ) { |
|
| 1815 | + return false; |
|
| 1816 | + } |
|
| 1817 | + if ( isset( $plugin_page ) && isset( $_wp_menu_nopriv[$plugin_page] ) ) { |
|
| 1818 | + return false; |
|
| 1819 | + } |
|
| 1741 | 1820 | foreach (array_keys( $_wp_submenu_nopriv ) as $key ) { |
| 1742 | - if ( isset( $_wp_submenu_nopriv[$key][$pagenow] ) ) |
|
| 1743 | - return false; |
|
| 1744 | - if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$key][$plugin_page] ) ) |
|
| 1745 | - return false; |
|
| 1821 | + if ( isset( $_wp_submenu_nopriv[$key][$pagenow] ) ) { |
|
| 1822 | + return false; |
|
| 1823 | + } |
|
| 1824 | + if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$key][$plugin_page] ) ) { |
|
| 1825 | + return false; |
|
| 1826 | + } |
|
| 1746 | 1827 | } |
| 1747 | 1828 | return true; |
| 1748 | 1829 | } |
| 1749 | 1830 | |
| 1750 | - if ( isset( $plugin_page ) && ( $plugin_page == $parent ) && isset( $_wp_menu_nopriv[$plugin_page] ) ) |
|
| 1751 | - return false; |
|
| 1831 | + if ( isset( $plugin_page ) && ( $plugin_page == $parent ) && isset( $_wp_menu_nopriv[$plugin_page] ) ) { |
|
| 1832 | + return false; |
|
| 1833 | + } |
|
| 1752 | 1834 | |
| 1753 | 1835 | if ( isset( $submenu[$parent] ) ) { |
| 1754 | 1836 | foreach ( $submenu[$parent] as $submenu_array ) { |
| 1755 | 1837 | if ( isset( $plugin_page ) && ( $submenu_array[2] == $plugin_page ) ) { |
| 1756 | - if ( current_user_can( $submenu_array[1] )) |
|
| 1757 | - return true; |
|
| 1758 | - else |
|
| 1759 | - return false; |
|
| 1838 | + if ( current_user_can( $submenu_array[1] )) { |
|
| 1839 | + return true; |
|
| 1840 | + } else { |
|
| 1841 | + return false; |
|
| 1842 | + } |
|
| 1760 | 1843 | } elseif ( $submenu_array[2] == $pagenow ) { |
| 1761 | - if ( current_user_can( $submenu_array[1] )) |
|
| 1762 | - return true; |
|
| 1763 | - else |
|
| 1764 | - return false; |
|
| 1844 | + if ( current_user_can( $submenu_array[1] )) { |
|
| 1845 | + return true; |
|
| 1846 | + } else { |
|
| 1847 | + return false; |
|
| 1848 | + } |
|
| 1765 | 1849 | } |
| 1766 | 1850 | } |
| 1767 | 1851 | } |
| 1768 | 1852 | |
| 1769 | 1853 | foreach ( $menu as $menu_array ) { |
| 1770 | 1854 | if ( $menu_array[2] == $parent) { |
| 1771 | - if ( current_user_can( $menu_array[1] )) |
|
| 1772 | - return true; |
|
| 1773 | - else |
|
| 1774 | - return false; |
|
| 1855 | + if ( current_user_can( $menu_array[1] )) { |
|
| 1856 | + return true; |
|
| 1857 | + } else { |
|
| 1858 | + return false; |
|
| 1859 | + } |
|
| 1775 | 1860 | } |
| 1776 | 1861 | } |
| 1777 | 1862 | |
@@ -1806,9 +1891,10 @@ discard block |
||
| 1806 | 1891 | } |
| 1807 | 1892 | |
| 1808 | 1893 | $new_whitelist_options[ $option_group ][] = $option_name; |
| 1809 | - if ( $sanitize_callback != '' ) |
|
| 1810 | - add_filter( "sanitize_option_{$option_name}", $sanitize_callback ); |
|
| 1811 | -} |
|
| 1894 | + if ( $sanitize_callback != '' ) { |
|
| 1895 | + add_filter( "sanitize_option_{$option_name}", $sanitize_callback ); |
|
| 1896 | + } |
|
| 1897 | + } |
|
| 1812 | 1898 | |
| 1813 | 1899 | /** |
| 1814 | 1900 | * Unregister a setting |
@@ -1835,11 +1921,13 @@ discard block |
||
| 1835 | 1921 | } |
| 1836 | 1922 | |
| 1837 | 1923 | $pos = array_search( $option_name, (array) $new_whitelist_options[ $option_group ] ); |
| 1838 | - if ( $pos !== false ) |
|
| 1839 | - unset( $new_whitelist_options[ $option_group ][ $pos ] ); |
|
| 1840 | - if ( $sanitize_callback != '' ) |
|
| 1841 | - remove_filter( "sanitize_option_{$option_name}", $sanitize_callback ); |
|
| 1842 | -} |
|
| 1924 | + if ( $pos !== false ) { |
|
| 1925 | + unset( $new_whitelist_options[ $option_group ][ $pos ] ); |
|
| 1926 | + } |
|
| 1927 | + if ( $sanitize_callback != '' ) { |
|
| 1928 | + remove_filter( "sanitize_option_{$option_name}", $sanitize_callback ); |
|
| 1929 | + } |
|
| 1930 | + } |
|
| 1843 | 1931 | |
| 1844 | 1932 | /** |
| 1845 | 1933 | * {@internal Missing Short Description}} |
@@ -1854,8 +1942,9 @@ discard block |
||
| 1854 | 1942 | function option_update_filter( $options ) { |
| 1855 | 1943 | global $new_whitelist_options; |
| 1856 | 1944 | |
| 1857 | - if ( is_array( $new_whitelist_options ) ) |
|
| 1858 | - $options = add_option_whitelist( $new_whitelist_options, $options ); |
|
| 1945 | + if ( is_array( $new_whitelist_options ) ) { |
|
| 1946 | + $options = add_option_whitelist( $new_whitelist_options, $options ); |
|
| 1947 | + } |
|
| 1859 | 1948 | |
| 1860 | 1949 | return $options; |
| 1861 | 1950 | } |
@@ -1872,10 +1961,11 @@ discard block |
||
| 1872 | 1961 | * @return array |
| 1873 | 1962 | */ |
| 1874 | 1963 | function add_option_whitelist( $new_options, $options = '' ) { |
| 1875 | - if ( $options == '' ) |
|
| 1876 | - global $whitelist_options; |
|
| 1877 | - else |
|
| 1878 | - $whitelist_options = $options; |
|
| 1964 | + if ( $options == '' ) { |
|
| 1965 | + global $whitelist_options; |
|
| 1966 | + } else { |
|
| 1967 | + $whitelist_options = $options; |
|
| 1968 | + } |
|
| 1879 | 1969 | |
| 1880 | 1970 | foreach ( $new_options as $page => $keys ) { |
| 1881 | 1971 | foreach ( $keys as $key ) { |
@@ -1884,8 +1974,9 @@ discard block |
||
| 1884 | 1974 | $whitelist_options[ $page ][] = $key; |
| 1885 | 1975 | } else { |
| 1886 | 1976 | $pos = array_search( $key, $whitelist_options[ $page ] ); |
| 1887 | - if ( $pos === false ) |
|
| 1888 | - $whitelist_options[ $page ][] = $key; |
|
| 1977 | + if ( $pos === false ) { |
|
| 1978 | + $whitelist_options[ $page ][] = $key; |
|
| 1979 | + } |
|
| 1889 | 1980 | } |
| 1890 | 1981 | } |
| 1891 | 1982 | } |
@@ -1905,17 +1996,19 @@ discard block |
||
| 1905 | 1996 | * @return array |
| 1906 | 1997 | */ |
| 1907 | 1998 | function remove_option_whitelist( $del_options, $options = '' ) { |
| 1908 | - if ( $options == '' ) |
|
| 1909 | - global $whitelist_options; |
|
| 1910 | - else |
|
| 1911 | - $whitelist_options = $options; |
|
| 1999 | + if ( $options == '' ) { |
|
| 2000 | + global $whitelist_options; |
|
| 2001 | + } else { |
|
| 2002 | + $whitelist_options = $options; |
|
| 2003 | + } |
|
| 1912 | 2004 | |
| 1913 | 2005 | foreach ( $del_options as $page => $keys ) { |
| 1914 | 2006 | foreach ( $keys as $key ) { |
| 1915 | 2007 | if ( isset($whitelist_options[ $page ]) && is_array($whitelist_options[ $page ]) ) { |
| 1916 | 2008 | $pos = array_search( $key, $whitelist_options[ $page ] ); |
| 1917 | - if ( $pos !== false ) |
|
| 1918 | - unset( $whitelist_options[ $page ][ $pos ] ); |
|
| 2009 | + if ( $pos !== false ) { |
|
| 2010 | + unset( $whitelist_options[ $page ][ $pos ] ); |
|
| 2011 | + } |
|
| 1919 | 2012 | } |
| 1920 | 2013 | } |
| 1921 | 2014 | } |
@@ -1944,7 +2037,8 @@ discard block |
||
| 1944 | 2037 | * @param bool $clear_update_cache Whether to clear the Plugin updates cache |
| 1945 | 2038 | */ |
| 1946 | 2039 | function wp_clean_plugins_cache( $clear_update_cache = true ) { |
| 1947 | - if ( $clear_update_cache ) |
|
| 1948 | - delete_site_transient( 'update_plugins' ); |
|
| 2040 | + if ( $clear_update_cache ) { |
|
| 2041 | + delete_site_transient( 'update_plugins' ); |
|
| 2042 | + } |
|
| 1949 | 2043 | wp_cache_delete( 'plugins', 'plugins' ); |
| 1950 | 2044 | } |
@@ -746,10 +746,10 @@ discard block |
||
| 746 | 746 | * @global WP_Locale $wp_locale |
| 747 | 747 | * @global object $comment |
| 748 | 748 | * |
| 749 | - * @param int|bool $edit Accepts 1|true for editing the date, 0|false for adding the date. |
|
| 750 | - * @param int|bool $for_post Accepts 1|true for applying the date to a post, 0|false for a comment. |
|
| 749 | + * @param integer $edit Accepts 1|true for editing the date, 0|false for adding the date. |
|
| 750 | + * @param integer $for_post Accepts 1|true for applying the date to a post, 0|false for a comment. |
|
| 751 | 751 | * @param int $tab_index The tabindex attribute to add. Default 0. |
| 752 | - * @param int|bool $multi Optional. Whether the additional fields and buttons should be added. |
|
| 752 | + * @param integer $multi Optional. Whether the additional fields and buttons should be added. |
|
| 753 | 753 | * Default 0|false. |
| 754 | 754 | */ |
| 755 | 755 | function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) { |
@@ -1039,9 +1039,9 @@ discard block |
||
| 1039 | 1039 | * @global array $wp_meta_boxes |
| 1040 | 1040 | * |
| 1041 | 1041 | * @staticvar bool $already_sorted |
| 1042 | - * @param string|WP_Screen $screen Screen identifier |
|
| 1042 | + * @param string $screen Screen identifier |
|
| 1043 | 1043 | * @param string $context box context |
| 1044 | - * @param mixed $object gets passed to the box callback function as first parameter |
|
| 1044 | + * @param string $object gets passed to the box callback function as first parameter |
|
| 1045 | 1045 | * @return int number of meta_boxes |
| 1046 | 1046 | */ |
| 1047 | 1047 | function do_meta_boxes( $screen, $context, $object ) { |
@@ -1567,7 +1567,7 @@ discard block |
||
| 1567 | 1567 | * |
| 1568 | 1568 | * @since 2.7.0 |
| 1569 | 1569 | * |
| 1570 | - * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. |
|
| 1570 | + * @param integer $post Optional. Post ID or WP_Post object. Default is global $post. |
|
| 1571 | 1571 | * @return string The post title if set. |
| 1572 | 1572 | */ |
| 1573 | 1573 | function _draft_or_post_title( $post = 0 ) { |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | class Walker_Category_Checklist extends Walker { |
| 25 | 25 | public $tree_type = 'category'; |
| 26 | - public $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this |
|
| 26 | + public $db_fields = array('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this |
|
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * Starts the list before the elements are added. |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * @param int $depth Depth of category. Used for tab indentation. |
| 37 | 37 | * @param array $args An array of arguments. @see wp_terms_checklist() |
| 38 | 38 | */ |
| 39 | - public function start_lvl( &$output, $depth = 0, $args = array() ) { |
|
| 39 | + public function start_lvl(&$output, $depth = 0, $args = array()) { |
|
| 40 | 40 | $indent = str_repeat("\t", $depth); |
| 41 | 41 | $output .= "$indent<ul class='children'>\n"; |
| 42 | 42 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * @param int $depth Depth of category. Used for tab indentation. |
| 53 | 53 | * @param array $args An array of arguments. @see wp_terms_checklist() |
| 54 | 54 | */ |
| 55 | - public function end_lvl( &$output, $depth = 0, $args = array() ) { |
|
| 55 | + public function end_lvl(&$output, $depth = 0, $args = array()) { |
|
| 56 | 56 | $indent = str_repeat("\t", $depth); |
| 57 | 57 | $output .= "$indent</ul>\n"; |
| 58 | 58 | } |
@@ -70,44 +70,44 @@ discard block |
||
| 70 | 70 | * @param array $args An array of arguments. @see wp_terms_checklist() |
| 71 | 71 | * @param int $id ID of the current term. |
| 72 | 72 | */ |
| 73 | - public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) { |
|
| 74 | - if ( empty( $args['taxonomy'] ) ) { |
|
| 73 | + public function start_el(&$output, $category, $depth = 0, $args = array(), $id = 0) { |
|
| 74 | + if (empty($args['taxonomy'])) { |
|
| 75 | 75 | $taxonomy = 'category'; |
| 76 | 76 | } else { |
| 77 | 77 | $taxonomy = $args['taxonomy']; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - if ( $taxonomy == 'category' ) { |
|
| 80 | + if ($taxonomy == 'category') { |
|
| 81 | 81 | $name = 'post_category'; |
| 82 | 82 | } else { |
| 83 | - $name = 'tax_input[' . $taxonomy . ']'; |
|
| 83 | + $name = 'tax_input['.$taxonomy.']'; |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - $args['popular_cats'] = empty( $args['popular_cats'] ) ? array() : $args['popular_cats']; |
|
| 87 | - $class = in_array( $category->term_id, $args['popular_cats'] ) ? ' class="popular-category"' : ''; |
|
| 86 | + $args['popular_cats'] = empty($args['popular_cats']) ? array() : $args['popular_cats']; |
|
| 87 | + $class = in_array($category->term_id, $args['popular_cats']) ? ' class="popular-category"' : ''; |
|
| 88 | 88 | |
| 89 | - $args['selected_cats'] = empty( $args['selected_cats'] ) ? array() : $args['selected_cats']; |
|
| 89 | + $args['selected_cats'] = empty($args['selected_cats']) ? array() : $args['selected_cats']; |
|
| 90 | 90 | |
| 91 | 91 | /** This filter is documented in wp-includes/category-template.php */ |
| 92 | - if ( ! empty( $args['list_only'] ) ) { |
|
| 92 | + if ( ! empty($args['list_only'])) { |
|
| 93 | 93 | $aria_cheched = 'false'; |
| 94 | 94 | $inner_class = 'category'; |
| 95 | 95 | |
| 96 | - if ( in_array( $category->term_id, $args['selected_cats'] ) ) { |
|
| 96 | + if (in_array($category->term_id, $args['selected_cats'])) { |
|
| 97 | 97 | $inner_class .= ' selected'; |
| 98 | 98 | $aria_cheched = 'true'; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - $output .= "\n" . '<li' . $class . '>' . |
|
| 102 | - '<div class="' . $inner_class . '" data-term-id=' . $category->term_id . |
|
| 103 | - ' tabindex="0" role="checkbox" aria-checked="' . $aria_cheched . '">' . |
|
| 104 | - esc_html( apply_filters( 'the_category', $category->name ) ) . '</div>'; |
|
| 101 | + $output .= "\n".'<li'.$class.'>'. |
|
| 102 | + '<div class="'.$inner_class.'" data-term-id='.$category->term_id. |
|
| 103 | + ' tabindex="0" role="checkbox" aria-checked="'.$aria_cheched.'">'. |
|
| 104 | + esc_html(apply_filters('the_category', $category->name)).'</div>'; |
|
| 105 | 105 | } else { |
| 106 | - $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" . |
|
| 107 | - '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' . $category->term_id . '"' . |
|
| 108 | - checked( in_array( $category->term_id, $args['selected_cats'] ), true, false ) . |
|
| 109 | - disabled( empty( $args['disabled'] ), false, false ) . ' /> ' . |
|
| 110 | - esc_html( apply_filters( 'the_category', $category->name ) ) . '</label>'; |
|
| 106 | + $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>". |
|
| 107 | + '<label class="selectit"><input value="'.$category->term_id.'" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-'.$category->term_id.'"'. |
|
| 108 | + checked(in_array($category->term_id, $args['selected_cats']), true, false). |
|
| 109 | + disabled(empty($args['disabled']), false, false).' /> '. |
|
| 110 | + esc_html(apply_filters('the_category', $category->name)).'</label>'; |
|
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | * @param int $depth Depth of the term in reference to parents. Default 0. |
| 124 | 124 | * @param array $args An array of arguments. @see wp_terms_checklist() |
| 125 | 125 | */ |
| 126 | - public function end_el( &$output, $category, $depth = 0, $args = array() ) { |
|
| 126 | + public function end_el(&$output, $category, $depth = 0, $args = array()) { |
|
| 127 | 127 | $output .= "</li>\n"; |
| 128 | 128 | } |
| 129 | 129 | } |
@@ -147,15 +147,15 @@ discard block |
||
| 147 | 147 | * @param bool $checked_ontop Optional. Whether to move checked items out of the hierarchy and to |
| 148 | 148 | * the top of the list. Default true. |
| 149 | 149 | */ |
| 150 | -function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) { |
|
| 151 | - wp_terms_checklist( $post_id, array( |
|
| 150 | +function wp_category_checklist($post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true) { |
|
| 151 | + wp_terms_checklist($post_id, array( |
|
| 152 | 152 | 'taxonomy' => 'category', |
| 153 | 153 | 'descendants_and_self' => $descendants_and_self, |
| 154 | 154 | 'selected_cats' => $selected_cats, |
| 155 | 155 | 'popular_cats' => $popular_cats, |
| 156 | 156 | 'walker' => $walker, |
| 157 | 157 | 'checked_ontop' => $checked_ontop |
| 158 | - ) ); |
|
| 158 | + )); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /** |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | * the top of the list. Default true. |
| 182 | 182 | * } |
| 183 | 183 | */ |
| 184 | -function wp_terms_checklist( $post_id = 0, $args = array() ) { |
|
| 184 | +function wp_terms_checklist($post_id = 0, $args = array()) { |
|
| 185 | 185 | $defaults = array( |
| 186 | 186 | 'descendants_and_self' => 0, |
| 187 | 187 | 'selected_cats' => false, |
@@ -201,11 +201,11 @@ discard block |
||
| 201 | 201 | * @param array $args An array of arguments. |
| 202 | 202 | * @param int $post_id The post ID. |
| 203 | 203 | */ |
| 204 | - $params = apply_filters( 'wp_terms_checklist_args', $args, $post_id ); |
|
| 204 | + $params = apply_filters('wp_terms_checklist_args', $args, $post_id); |
|
| 205 | 205 | |
| 206 | - $r = wp_parse_args( $params, $defaults ); |
|
| 206 | + $r = wp_parse_args($params, $defaults); |
|
| 207 | 207 | |
| 208 | - if ( empty( $r['walker'] ) || ! ( $r['walker'] instanceof Walker ) ) { |
|
| 208 | + if (empty($r['walker']) || ! ($r['walker'] instanceof Walker)) { |
|
| 209 | 209 | $walker = new Walker_Category_Checklist; |
| 210 | 210 | } else { |
| 211 | 211 | $walker = $r['walker']; |
@@ -214,60 +214,60 @@ discard block |
||
| 214 | 214 | $taxonomy = $r['taxonomy']; |
| 215 | 215 | $descendants_and_self = (int) $r['descendants_and_self']; |
| 216 | 216 | |
| 217 | - $args = array( 'taxonomy' => $taxonomy ); |
|
| 217 | + $args = array('taxonomy' => $taxonomy); |
|
| 218 | 218 | |
| 219 | - $tax = get_taxonomy( $taxonomy ); |
|
| 220 | - $args['disabled'] = ! current_user_can( $tax->cap->assign_terms ); |
|
| 219 | + $tax = get_taxonomy($taxonomy); |
|
| 220 | + $args['disabled'] = ! current_user_can($tax->cap->assign_terms); |
|
| 221 | 221 | |
| 222 | - $args['list_only'] = ! empty( $r['list_only'] ); |
|
| 222 | + $args['list_only'] = ! empty($r['list_only']); |
|
| 223 | 223 | |
| 224 | - if ( is_array( $r['selected_cats'] ) ) { |
|
| 224 | + if (is_array($r['selected_cats'])) { |
|
| 225 | 225 | $args['selected_cats'] = $r['selected_cats']; |
| 226 | - } elseif ( $post_id ) { |
|
| 227 | - $args['selected_cats'] = wp_get_object_terms( $post_id, $taxonomy, array_merge( $args, array( 'fields' => 'ids' ) ) ); |
|
| 226 | + } elseif ($post_id) { |
|
| 227 | + $args['selected_cats'] = wp_get_object_terms($post_id, $taxonomy, array_merge($args, array('fields' => 'ids'))); |
|
| 228 | 228 | } else { |
| 229 | 229 | $args['selected_cats'] = array(); |
| 230 | 230 | } |
| 231 | - if ( is_array( $r['popular_cats'] ) ) { |
|
| 231 | + if (is_array($r['popular_cats'])) { |
|
| 232 | 232 | $args['popular_cats'] = $r['popular_cats']; |
| 233 | 233 | } else { |
| 234 | - $args['popular_cats'] = get_terms( $taxonomy, array( |
|
| 234 | + $args['popular_cats'] = get_terms($taxonomy, array( |
|
| 235 | 235 | 'fields' => 'ids', |
| 236 | 236 | 'orderby' => 'count', |
| 237 | 237 | 'order' => 'DESC', |
| 238 | 238 | 'number' => 10, |
| 239 | 239 | 'hierarchical' => false |
| 240 | - ) ); |
|
| 240 | + )); |
|
| 241 | 241 | } |
| 242 | - if ( $descendants_and_self ) { |
|
| 243 | - $categories = (array) get_terms( $taxonomy, array( |
|
| 242 | + if ($descendants_and_self) { |
|
| 243 | + $categories = (array) get_terms($taxonomy, array( |
|
| 244 | 244 | 'child_of' => $descendants_and_self, |
| 245 | 245 | 'hierarchical' => 0, |
| 246 | 246 | 'hide_empty' => 0 |
| 247 | - ) ); |
|
| 248 | - $self = get_term( $descendants_and_self, $taxonomy ); |
|
| 249 | - array_unshift( $categories, $self ); |
|
| 247 | + )); |
|
| 248 | + $self = get_term($descendants_and_self, $taxonomy); |
|
| 249 | + array_unshift($categories, $self); |
|
| 250 | 250 | } else { |
| 251 | - $categories = (array) get_terms( $taxonomy, array( 'get' => 'all' ) ); |
|
| 251 | + $categories = (array) get_terms($taxonomy, array('get' => 'all')); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - if ( $r['checked_ontop'] ) { |
|
| 254 | + if ($r['checked_ontop']) { |
|
| 255 | 255 | // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache) |
| 256 | 256 | $checked_categories = array(); |
| 257 | - $keys = array_keys( $categories ); |
|
| 257 | + $keys = array_keys($categories); |
|
| 258 | 258 | |
| 259 | - foreach( $keys as $k ) { |
|
| 260 | - if ( in_array( $categories[$k]->term_id, $args['selected_cats'] ) ) { |
|
| 259 | + foreach ($keys as $k) { |
|
| 260 | + if (in_array($categories[$k]->term_id, $args['selected_cats'])) { |
|
| 261 | 261 | $checked_categories[] = $categories[$k]; |
| 262 | - unset( $categories[$k] ); |
|
| 262 | + unset($categories[$k]); |
|
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | // Put checked cats on top |
| 267 | - echo call_user_func_array( array( $walker, 'walk' ), array( $checked_categories, 0, $args ) ); |
|
| 267 | + echo call_user_func_array(array($walker, 'walk'), array($checked_categories, 0, $args)); |
|
| 268 | 268 | } |
| 269 | 269 | // Then the rest of them |
| 270 | - echo call_user_func_array( array( $walker, 'walk' ), array( $categories, 0, $args ) ); |
|
| 270 | + echo call_user_func_array(array($walker, 'walk'), array($categories, 0, $args)); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | /** |
@@ -286,33 +286,33 @@ discard block |
||
| 286 | 286 | * @param bool $echo Optionally output the list as well. Defaults to true. |
| 287 | 287 | * @return array List of popular term IDs. |
| 288 | 288 | */ |
| 289 | -function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) { |
|
| 289 | +function wp_popular_terms_checklist($taxonomy, $default = 0, $number = 10, $echo = true) { |
|
| 290 | 290 | $post = get_post(); |
| 291 | 291 | |
| 292 | - if ( $post && $post->ID ) |
|
| 292 | + if ($post && $post->ID) |
|
| 293 | 293 | $checked_terms = wp_get_object_terms($post->ID, $taxonomy, array('fields'=>'ids')); |
| 294 | 294 | else |
| 295 | 295 | $checked_terms = array(); |
| 296 | 296 | |
| 297 | - $terms = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) ); |
|
| 297 | + $terms = get_terms($taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false)); |
|
| 298 | 298 | |
| 299 | 299 | $tax = get_taxonomy($taxonomy); |
| 300 | 300 | |
| 301 | 301 | $popular_ids = array(); |
| 302 | - foreach ( (array) $terms as $term ) { |
|
| 302 | + foreach ((array) $terms as $term) { |
|
| 303 | 303 | $popular_ids[] = $term->term_id; |
| 304 | - if ( !$echo ) // hack for AJAX use |
|
| 304 | + if ( ! $echo) // hack for AJAX use |
|
| 305 | 305 | continue; |
| 306 | 306 | $id = "popular-$taxonomy-$term->term_id"; |
| 307 | - $checked = in_array( $term->term_id, $checked_terms ) ? 'checked="checked"' : ''; |
|
| 307 | + $checked = in_array($term->term_id, $checked_terms) ? 'checked="checked"' : ''; |
|
| 308 | 308 | ?> |
| 309 | 309 | |
| 310 | 310 | <li id="<?php echo $id; ?>" class="popular-category"> |
| 311 | 311 | <label class="selectit"> |
| 312 | - <input id="in-<?php echo $id; ?>" type="checkbox" <?php echo $checked; ?> value="<?php echo (int) $term->term_id; ?>" <?php disabled( ! current_user_can( $tax->cap->assign_terms ) ); ?> /> |
|
| 312 | + <input id="in-<?php echo $id; ?>" type="checkbox" <?php echo $checked; ?> value="<?php echo (int) $term->term_id; ?>" <?php disabled( ! current_user_can($tax->cap->assign_terms)); ?> /> |
|
| 313 | 313 | <?php |
| 314 | 314 | /** This filter is documented in wp-includes/category-template.php */ |
| 315 | - echo esc_html( apply_filters( 'the_category', $term->name ) ); |
|
| 315 | + echo esc_html(apply_filters('the_category', $term->name)); |
|
| 316 | 316 | ?> |
| 317 | 317 | </label> |
| 318 | 318 | </li> |
@@ -329,32 +329,32 @@ discard block |
||
| 329 | 329 | * |
| 330 | 330 | * @param int $link_id |
| 331 | 331 | */ |
| 332 | -function wp_link_category_checklist( $link_id = 0 ) { |
|
| 332 | +function wp_link_category_checklist($link_id = 0) { |
|
| 333 | 333 | $default = 1; |
| 334 | 334 | |
| 335 | 335 | $checked_categories = array(); |
| 336 | 336 | |
| 337 | - if ( $link_id ) { |
|
| 338 | - $checked_categories = wp_get_link_cats( $link_id ); |
|
| 337 | + if ($link_id) { |
|
| 338 | + $checked_categories = wp_get_link_cats($link_id); |
|
| 339 | 339 | // No selected categories, strange |
| 340 | - if ( ! count( $checked_categories ) ) { |
|
| 340 | + if ( ! count($checked_categories)) { |
|
| 341 | 341 | $checked_categories[] = $default; |
| 342 | 342 | } |
| 343 | 343 | } else { |
| 344 | 344 | $checked_categories[] = $default; |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - $categories = get_terms( 'link_category', array( 'orderby' => 'name', 'hide_empty' => 0 ) ); |
|
| 347 | + $categories = get_terms('link_category', array('orderby' => 'name', 'hide_empty' => 0)); |
|
| 348 | 348 | |
| 349 | - if ( empty( $categories ) ) |
|
| 349 | + if (empty($categories)) |
|
| 350 | 350 | return; |
| 351 | 351 | |
| 352 | - foreach ( $categories as $category ) { |
|
| 352 | + foreach ($categories as $category) { |
|
| 353 | 353 | $cat_id = $category->term_id; |
| 354 | 354 | |
| 355 | 355 | /** This filter is documented in wp-includes/category-template.php */ |
| 356 | - $name = esc_html( apply_filters( 'the_category', $category->name ) ); |
|
| 357 | - $checked = in_array( $cat_id, $checked_categories ) ? ' checked="checked"' : ''; |
|
| 356 | + $name = esc_html(apply_filters('the_category', $category->name)); |
|
| 357 | + $checked = in_array($cat_id, $checked_categories) ? ' checked="checked"' : ''; |
|
| 358 | 358 | echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', $checked, '/> ', $name, "</label></li>"; |
| 359 | 359 | } |
| 360 | 360 | } |
@@ -368,65 +368,65 @@ discard block |
||
| 368 | 368 | */ |
| 369 | 369 | function get_inline_data($post) { |
| 370 | 370 | $post_type_object = get_post_type_object($post->post_type); |
| 371 | - if ( ! current_user_can( 'edit_post', $post->ID ) ) |
|
| 371 | + if ( ! current_user_can('edit_post', $post->ID)) |
|
| 372 | 372 | return; |
| 373 | 373 | |
| 374 | - $title = esc_textarea( trim( $post->post_title ) ); |
|
| 374 | + $title = esc_textarea(trim($post->post_title)); |
|
| 375 | 375 | |
| 376 | 376 | /** This filter is documented in wp-admin/edit-tag-form.php */ |
| 377 | 377 | echo ' |
| 378 | -<div class="hidden" id="inline_' . $post->ID . '"> |
|
| 379 | - <div class="post_title">' . $title . '</div> |
|
| 380 | - <div class="post_name">' . apply_filters( 'editable_slug', $post->post_name ) . '</div> |
|
| 381 | - <div class="post_author">' . $post->post_author . '</div> |
|
| 382 | - <div class="comment_status">' . esc_html( $post->comment_status ) . '</div> |
|
| 383 | - <div class="ping_status">' . esc_html( $post->ping_status ) . '</div> |
|
| 384 | - <div class="_status">' . esc_html( $post->post_status ) . '</div> |
|
| 385 | - <div class="jj">' . mysql2date( 'd', $post->post_date, false ) . '</div> |
|
| 386 | - <div class="mm">' . mysql2date( 'm', $post->post_date, false ) . '</div> |
|
| 387 | - <div class="aa">' . mysql2date( 'Y', $post->post_date, false ) . '</div> |
|
| 388 | - <div class="hh">' . mysql2date( 'H', $post->post_date, false ) . '</div> |
|
| 389 | - <div class="mn">' . mysql2date( 'i', $post->post_date, false ) . '</div> |
|
| 390 | - <div class="ss">' . mysql2date( 's', $post->post_date, false ) . '</div> |
|
| 391 | - <div class="post_password">' . esc_html( $post->post_password ) . '</div>'; |
|
| 392 | - |
|
| 393 | - if ( $post_type_object->hierarchical ) |
|
| 394 | - echo '<div class="post_parent">' . $post->post_parent . '</div>'; |
|
| 395 | - |
|
| 396 | - if ( $post->post_type == 'page' ) |
|
| 397 | - echo '<div class="page_template">' . esc_html( get_post_meta( $post->ID, '_wp_page_template', true ) ) . '</div>'; |
|
| 398 | - |
|
| 399 | - if ( post_type_supports( $post->post_type, 'page-attributes' ) ) |
|
| 400 | - echo '<div class="menu_order">' . $post->menu_order . '</div>'; |
|
| 401 | - |
|
| 402 | - $taxonomy_names = get_object_taxonomies( $post->post_type ); |
|
| 403 | - foreach ( $taxonomy_names as $taxonomy_name) { |
|
| 404 | - $taxonomy = get_taxonomy( $taxonomy_name ); |
|
| 405 | - |
|
| 406 | - if ( $taxonomy->hierarchical && $taxonomy->show_ui ) { |
|
| 407 | - |
|
| 408 | - $terms = get_object_term_cache( $post->ID, $taxonomy_name ); |
|
| 409 | - if ( false === $terms ) { |
|
| 410 | - $terms = wp_get_object_terms( $post->ID, $taxonomy_name ); |
|
| 411 | - wp_cache_add( $post->ID, $terms, $taxonomy_name . '_relationships' ); |
|
| 378 | +<div class="hidden" id="inline_' . $post->ID.'"> |
|
| 379 | + <div class="post_title">' . $title.'</div> |
|
| 380 | + <div class="post_name">' . apply_filters('editable_slug', $post->post_name).'</div> |
|
| 381 | + <div class="post_author">' . $post->post_author.'</div> |
|
| 382 | + <div class="comment_status">' . esc_html($post->comment_status).'</div> |
|
| 383 | + <div class="ping_status">' . esc_html($post->ping_status).'</div> |
|
| 384 | + <div class="_status">' . esc_html($post->post_status).'</div> |
|
| 385 | + <div class="jj">' . mysql2date('d', $post->post_date, false).'</div> |
|
| 386 | + <div class="mm">' . mysql2date('m', $post->post_date, false).'</div> |
|
| 387 | + <div class="aa">' . mysql2date('Y', $post->post_date, false).'</div> |
|
| 388 | + <div class="hh">' . mysql2date('H', $post->post_date, false).'</div> |
|
| 389 | + <div class="mn">' . mysql2date('i', $post->post_date, false).'</div> |
|
| 390 | + <div class="ss">' . mysql2date('s', $post->post_date, false).'</div> |
|
| 391 | + <div class="post_password">' . esc_html($post->post_password).'</div>'; |
|
| 392 | + |
|
| 393 | + if ($post_type_object->hierarchical) |
|
| 394 | + echo '<div class="post_parent">'.$post->post_parent.'</div>'; |
|
| 395 | + |
|
| 396 | + if ($post->post_type == 'page') |
|
| 397 | + echo '<div class="page_template">'.esc_html(get_post_meta($post->ID, '_wp_page_template', true)).'</div>'; |
|
| 398 | + |
|
| 399 | + if (post_type_supports($post->post_type, 'page-attributes')) |
|
| 400 | + echo '<div class="menu_order">'.$post->menu_order.'</div>'; |
|
| 401 | + |
|
| 402 | + $taxonomy_names = get_object_taxonomies($post->post_type); |
|
| 403 | + foreach ($taxonomy_names as $taxonomy_name) { |
|
| 404 | + $taxonomy = get_taxonomy($taxonomy_name); |
|
| 405 | + |
|
| 406 | + if ($taxonomy->hierarchical && $taxonomy->show_ui) { |
|
| 407 | + |
|
| 408 | + $terms = get_object_term_cache($post->ID, $taxonomy_name); |
|
| 409 | + if (false === $terms) { |
|
| 410 | + $terms = wp_get_object_terms($post->ID, $taxonomy_name); |
|
| 411 | + wp_cache_add($post->ID, $terms, $taxonomy_name.'_relationships'); |
|
| 412 | 412 | } |
| 413 | - $term_ids = empty( $terms ) ? array() : wp_list_pluck( $terms, 'term_id' ); |
|
| 413 | + $term_ids = empty($terms) ? array() : wp_list_pluck($terms, 'term_id'); |
|
| 414 | 414 | |
| 415 | - echo '<div class="post_category" id="' . $taxonomy_name . '_' . $post->ID . '">' . implode( ',', $term_ids ) . '</div>'; |
|
| 415 | + echo '<div class="post_category" id="'.$taxonomy_name.'_'.$post->ID.'">'.implode(',', $term_ids).'</div>'; |
|
| 416 | 416 | |
| 417 | - } elseif ( $taxonomy->show_ui ) { |
|
| 417 | + } elseif ($taxonomy->show_ui) { |
|
| 418 | 418 | |
| 419 | 419 | echo '<div class="tags_input" id="'.$taxonomy_name.'_'.$post->ID.'">' |
| 420 | - . esc_html( str_replace( ',', ', ', get_terms_to_edit( $post->ID, $taxonomy_name ) ) ) . '</div>'; |
|
| 420 | + . esc_html(str_replace(',', ', ', get_terms_to_edit($post->ID, $taxonomy_name))).'</div>'; |
|
| 421 | 421 | |
| 422 | 422 | } |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | - if ( !$post_type_object->hierarchical ) |
|
| 426 | - echo '<div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>'; |
|
| 425 | + if ( ! $post_type_object->hierarchical) |
|
| 426 | + echo '<div class="sticky">'.(is_sticky($post->ID) ? 'sticky' : '').'</div>'; |
|
| 427 | 427 | |
| 428 | - if ( post_type_supports( $post->post_type, 'post-formats' ) ) |
|
| 429 | - echo '<div class="post_format">' . esc_html( get_post_format( $post->ID ) ) . '</div>'; |
|
| 428 | + if (post_type_supports($post->post_type, 'post-formats')) |
|
| 429 | + echo '<div class="post_format">'.esc_html(get_post_format($post->ID)).'</div>'; |
|
| 430 | 430 | |
| 431 | 431 | echo '</div>'; |
| 432 | 432 | } |
@@ -443,7 +443,7 @@ discard block |
||
| 443 | 443 | * @param string $mode |
| 444 | 444 | * @param bool $table_row |
| 445 | 445 | */ |
| 446 | -function wp_comment_reply( $position = 1, $checkbox = false, $mode = 'single', $table_row = true ) { |
|
| 446 | +function wp_comment_reply($position = 1, $checkbox = false, $mode = 'single', $table_row = true) { |
|
| 447 | 447 | global $wp_list_table; |
| 448 | 448 | /** |
| 449 | 449 | * Filter the in-line comment reply-to form output in the Comments |
@@ -460,15 +460,15 @@ discard block |
||
| 460 | 460 | * @param string $content The reply-to form content. |
| 461 | 461 | * @param array $args An array of default args. |
| 462 | 462 | */ |
| 463 | - $content = apply_filters( 'wp_comment_reply', '', array( 'position' => $position, 'checkbox' => $checkbox, 'mode' => $mode ) ); |
|
| 463 | + $content = apply_filters('wp_comment_reply', '', array('position' => $position, 'checkbox' => $checkbox, 'mode' => $mode)); |
|
| 464 | 464 | |
| 465 | - if ( ! empty($content) ) { |
|
| 465 | + if ( ! empty($content)) { |
|
| 466 | 466 | echo $content; |
| 467 | 467 | return; |
| 468 | 468 | } |
| 469 | 469 | |
| 470 | - if ( ! $wp_list_table ) { |
|
| 471 | - if ( $mode == 'single' ) { |
|
| 470 | + if ( ! $wp_list_table) { |
|
| 471 | + if ($mode == 'single') { |
|
| 472 | 472 | $wp_list_table = _get_list_table('WP_Post_Comments_List_Table'); |
| 473 | 473 | } else { |
| 474 | 474 | $wp_list_table = _get_list_table('WP_Comments_List_Table'); |
@@ -477,12 +477,12 @@ discard block |
||
| 477 | 477 | |
| 478 | 478 | ?> |
| 479 | 479 | <form method="get"> |
| 480 | -<?php if ( $table_row ) : ?> |
|
| 480 | +<?php if ($table_row) : ?> |
|
| 481 | 481 | <table style="display:none;"><tbody id="com-reply"><tr id="replyrow" style="display:none;"><td colspan="<?php echo $wp_list_table->get_column_count(); ?>" class="colspanchange"> |
| 482 | 482 | <?php else : ?> |
| 483 | 483 | <div id="com-reply" style="display:none;"><div id="replyrow" style="display:none;"> |
| 484 | 484 | <?php endif; ?> |
| 485 | - <div id="replyhead" style="display:none;"><h5><?php _e( 'Reply to Comment' ); ?></h5></div> |
|
| 485 | + <div id="replyhead" style="display:none;"><h5><?php _e('Reply to Comment'); ?></h5></div> |
|
| 486 | 486 | <div id="addhead" style="display:none;"><h5><?php _e('Add new Comment'); ?></h5></div> |
| 487 | 487 | <div id="edithead" style="display:none;"> |
| 488 | 488 | <div class="inside"> |
@@ -504,8 +504,8 @@ discard block |
||
| 504 | 504 | |
| 505 | 505 | <div id="replycontainer"> |
| 506 | 506 | <?php |
| 507 | - $quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' ); |
|
| 508 | - wp_editor( '', 'replycontent', array( 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings ) ); |
|
| 507 | + $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close'); |
|
| 508 | + wp_editor('', 'replycontent', array('media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings)); |
|
| 509 | 509 | ?> |
| 510 | 510 | </div> |
| 511 | 511 | |
@@ -528,11 +528,11 @@ discard block |
||
| 528 | 528 | <input type="hidden" name="checkbox" id="checkbox" value="<?php echo $checkbox ? 1 : 0; ?>" /> |
| 529 | 529 | <input type="hidden" name="mode" id="mode" value="<?php echo esc_attr($mode); ?>" /> |
| 530 | 530 | <?php |
| 531 | - wp_nonce_field( 'replyto-comment', '_ajax_nonce-replyto-comment', false ); |
|
| 532 | - if ( current_user_can( 'unfiltered_html' ) ) |
|
| 533 | - wp_nonce_field( 'unfiltered-html-comment', '_wp_unfiltered_html_comment', false ); |
|
| 531 | + wp_nonce_field('replyto-comment', '_ajax_nonce-replyto-comment', false); |
|
| 532 | + if (current_user_can('unfiltered_html')) |
|
| 533 | + wp_nonce_field('unfiltered-html-comment', '_wp_unfiltered_html_comment', false); |
|
| 534 | 534 | ?> |
| 535 | -<?php if ( $table_row ) : ?> |
|
| 535 | +<?php if ($table_row) : ?> |
|
| 536 | 536 | </td></tr></tbody></table> |
| 537 | 537 | <?php else : ?> |
| 538 | 538 | </div></div> |
@@ -564,15 +564,15 @@ discard block |
||
| 564 | 564 | * |
| 565 | 565 | * @param array $meta |
| 566 | 566 | */ |
| 567 | -function list_meta( $meta ) { |
|
| 567 | +function list_meta($meta) { |
|
| 568 | 568 | // Exit if no meta |
| 569 | - if ( ! $meta ) { |
|
| 569 | + if ( ! $meta) { |
|
| 570 | 570 | echo ' |
| 571 | 571 | <table id="list-table" style="display: none;"> |
| 572 | 572 | <thead> |
| 573 | 573 | <tr> |
| 574 | - <th class="left">' . _x( 'Name', 'meta name' ) . '</th> |
|
| 575 | - <th>' . __( 'Value' ) . '</th> |
|
| 574 | + <th class="left">' . _x('Name', 'meta name').'</th> |
|
| 575 | + <th>' . __('Value').'</th> |
|
| 576 | 576 | </tr> |
| 577 | 577 | </thead> |
| 578 | 578 | <tbody id="the-list" data-wp-lists="list:meta"> |
@@ -586,14 +586,14 @@ discard block |
||
| 586 | 586 | <table id="list-table"> |
| 587 | 587 | <thead> |
| 588 | 588 | <tr> |
| 589 | - <th class="left"><?php _ex( 'Name', 'meta name' ) ?></th> |
|
| 590 | - <th><?php _e( 'Value' ) ?></th> |
|
| 589 | + <th class="left"><?php _ex('Name', 'meta name') ?></th> |
|
| 590 | + <th><?php _e('Value') ?></th> |
|
| 591 | 591 | </tr> |
| 592 | 592 | </thead> |
| 593 | 593 | <tbody id='the-list' data-wp-lists='list:meta'> |
| 594 | 594 | <?php |
| 595 | - foreach ( $meta as $entry ) |
|
| 596 | - echo _list_meta_row( $entry, $count ); |
|
| 595 | + foreach ($meta as $entry) |
|
| 596 | + echo _list_meta_row($entry, $count); |
|
| 597 | 597 | ?> |
| 598 | 598 | </tbody> |
| 599 | 599 | </table> |
@@ -611,22 +611,22 @@ discard block |
||
| 611 | 611 | * @param int $count |
| 612 | 612 | * @return string |
| 613 | 613 | */ |
| 614 | -function _list_meta_row( $entry, &$count ) { |
|
| 614 | +function _list_meta_row($entry, &$count) { |
|
| 615 | 615 | static $update_nonce = ''; |
| 616 | 616 | |
| 617 | - if ( is_protected_meta( $entry['meta_key'], 'post' ) ) |
|
| 617 | + if (is_protected_meta($entry['meta_key'], 'post')) |
|
| 618 | 618 | return ''; |
| 619 | 619 | |
| 620 | - if ( ! $update_nonce ) |
|
| 621 | - $update_nonce = wp_create_nonce( 'add-meta' ); |
|
| 620 | + if ( ! $update_nonce) |
|
| 621 | + $update_nonce = wp_create_nonce('add-meta'); |
|
| 622 | 622 | |
| 623 | 623 | $r = ''; |
| 624 | - ++ $count; |
|
| 624 | + ++$count; |
|
| 625 | 625 | |
| 626 | - if ( is_serialized( $entry['meta_value'] ) ) { |
|
| 627 | - if ( is_serialized_string( $entry['meta_value'] ) ) { |
|
| 626 | + if (is_serialized($entry['meta_value'])) { |
|
| 627 | + if (is_serialized_string($entry['meta_value'])) { |
|
| 628 | 628 | // This is a serialized string, so we should display it. |
| 629 | - $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] ); |
|
| 629 | + $entry['meta_value'] = maybe_unserialize($entry['meta_value']); |
|
| 630 | 630 | } else { |
| 631 | 631 | // This is a serialized array/object so we should NOT display it. |
| 632 | 632 | --$count; |
@@ -635,23 +635,23 @@ discard block |
||
| 635 | 635 | } |
| 636 | 636 | |
| 637 | 637 | $entry['meta_key'] = esc_attr($entry['meta_key']); |
| 638 | - $entry['meta_value'] = esc_textarea( $entry['meta_value'] ); // using a <textarea /> |
|
| 638 | + $entry['meta_value'] = esc_textarea($entry['meta_value']); // using a <textarea /> |
|
| 639 | 639 | $entry['meta_id'] = (int) $entry['meta_id']; |
| 640 | 640 | |
| 641 | - $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] ); |
|
| 641 | + $delete_nonce = wp_create_nonce('delete-meta_'.$entry['meta_id']); |
|
| 642 | 642 | |
| 643 | 643 | $r .= "\n\t<tr id='meta-{$entry['meta_id']}'>"; |
| 644 | - $r .= "\n\t\t<td class='left'><label class='screen-reader-text' for='meta-{$entry['meta_id']}-key'>" . __( 'Key' ) . "</label><input name='meta[{$entry['meta_id']}][key]' id='meta-{$entry['meta_id']}-key' type='text' size='20' value='{$entry['meta_key']}' />"; |
|
| 644 | + $r .= "\n\t\t<td class='left'><label class='screen-reader-text' for='meta-{$entry['meta_id']}-key'>".__('Key')."</label><input name='meta[{$entry['meta_id']}][key]' id='meta-{$entry['meta_id']}-key' type='text' size='20' value='{$entry['meta_key']}' />"; |
|
| 645 | 645 | |
| 646 | 646 | $r .= "\n\t\t<div class='submit'>"; |
| 647 | - $r .= get_submit_button( __( 'Delete' ), 'deletemeta small', "deletemeta[{$entry['meta_id']}]", false, array( 'data-wp-lists' => "delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce" ) ); |
|
| 647 | + $r .= get_submit_button(__('Delete'), 'deletemeta small', "deletemeta[{$entry['meta_id']}]", false, array('data-wp-lists' => "delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce")); |
|
| 648 | 648 | $r .= "\n\t\t"; |
| 649 | - $r .= get_submit_button( __( 'Update' ), 'updatemeta small', "meta-{$entry['meta_id']}-submit", false, array( 'data-wp-lists' => "add:the-list:meta-{$entry['meta_id']}::_ajax_nonce-add-meta=$update_nonce" ) ); |
|
| 649 | + $r .= get_submit_button(__('Update'), 'updatemeta small', "meta-{$entry['meta_id']}-submit", false, array('data-wp-lists' => "add:the-list:meta-{$entry['meta_id']}::_ajax_nonce-add-meta=$update_nonce")); |
|
| 650 | 650 | $r .= "</div>"; |
| 651 | - $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false ); |
|
| 651 | + $r .= wp_nonce_field('change-meta', '_ajax_nonce', false, false); |
|
| 652 | 652 | $r .= "</td>"; |
| 653 | 653 | |
| 654 | - $r .= "\n\t\t<td><label class='screen-reader-text' for='meta-{$entry['meta_id']}-value'>" . __( 'Value' ) . "</label><textarea name='meta[{$entry['meta_id']}][value]' id='meta-{$entry['meta_id']}-value' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>\n\t</tr>"; |
|
| 654 | + $r .= "\n\t\t<td><label class='screen-reader-text' for='meta-{$entry['meta_id']}-value'>".__('Value')."</label><textarea name='meta[{$entry['meta_id']}][value]' id='meta-{$entry['meta_id']}-value' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>\n\t</tr>"; |
|
| 655 | 655 | return $r; |
| 656 | 656 | } |
| 657 | 657 | |
@@ -664,9 +664,9 @@ discard block |
||
| 664 | 664 | * |
| 665 | 665 | * @param WP_Post $post Optional. The post being edited. |
| 666 | 666 | */ |
| 667 | -function meta_form( $post = null ) { |
|
| 667 | +function meta_form($post = null) { |
|
| 668 | 668 | global $wpdb; |
| 669 | - $post = get_post( $post ); |
|
| 669 | + $post = get_post($post); |
|
| 670 | 670 | |
| 671 | 671 | /** |
| 672 | 672 | * Filter the number of custom fields to retrieve for the drop-down |
@@ -676,42 +676,42 @@ discard block |
||
| 676 | 676 | * |
| 677 | 677 | * @param int $limit Number of custom fields to retrieve. Default 30. |
| 678 | 678 | */ |
| 679 | - $limit = apply_filters( 'postmeta_form_limit', 30 ); |
|
| 679 | + $limit = apply_filters('postmeta_form_limit', 30); |
|
| 680 | 680 | $sql = "SELECT DISTINCT meta_key |
| 681 | 681 | FROM $wpdb->postmeta |
| 682 | 682 | WHERE meta_key NOT BETWEEN '_' AND '_z' |
| 683 | 683 | HAVING meta_key NOT LIKE %s |
| 684 | 684 | ORDER BY meta_key |
| 685 | 685 | LIMIT %d"; |
| 686 | - $keys = $wpdb->get_col( $wpdb->prepare( $sql, $wpdb->esc_like( '_' ) . '%', $limit ) ); |
|
| 687 | - if ( $keys ) { |
|
| 688 | - natcasesort( $keys ); |
|
| 686 | + $keys = $wpdb->get_col($wpdb->prepare($sql, $wpdb->esc_like('_').'%', $limit)); |
|
| 687 | + if ($keys) { |
|
| 688 | + natcasesort($keys); |
|
| 689 | 689 | $meta_key_input_id = 'metakeyselect'; |
| 690 | 690 | } else { |
| 691 | 691 | $meta_key_input_id = 'metakeyinput'; |
| 692 | 692 | } |
| 693 | 693 | ?> |
| 694 | -<p><strong><?php _e( 'Add New Custom Field:' ) ?></strong></p> |
|
| 694 | +<p><strong><?php _e('Add New Custom Field:') ?></strong></p> |
|
| 695 | 695 | <table id="newmeta"> |
| 696 | 696 | <thead> |
| 697 | 697 | <tr> |
| 698 | -<th class="left"><label for="<?php echo $meta_key_input_id; ?>"><?php _ex( 'Name', 'meta name' ) ?></label></th> |
|
| 699 | -<th><label for="metavalue"><?php _e( 'Value' ) ?></label></th> |
|
| 698 | +<th class="left"><label for="<?php echo $meta_key_input_id; ?>"><?php _ex('Name', 'meta name') ?></label></th> |
|
| 699 | +<th><label for="metavalue"><?php _e('Value') ?></label></th> |
|
| 700 | 700 | </tr> |
| 701 | 701 | </thead> |
| 702 | 702 | |
| 703 | 703 | <tbody> |
| 704 | 704 | <tr> |
| 705 | 705 | <td id="newmetaleft" class="left"> |
| 706 | -<?php if ( $keys ) { ?> |
|
| 706 | +<?php if ($keys) { ?> |
|
| 707 | 707 | <select id="metakeyselect" name="metakeyselect"> |
| 708 | -<option value="#NONE#"><?php _e( '— Select —' ); ?></option> |
|
| 708 | +<option value="#NONE#"><?php _e('— Select —'); ?></option> |
|
| 709 | 709 | <?php |
| 710 | 710 | |
| 711 | - foreach ( $keys as $key ) { |
|
| 712 | - if ( is_protected_meta( $key, 'post' ) || ! current_user_can( 'add_post_meta', $post->ID, $key ) ) |
|
| 711 | + foreach ($keys as $key) { |
|
| 712 | + if (is_protected_meta($key, 'post') || ! current_user_can('add_post_meta', $post->ID, $key)) |
|
| 713 | 713 | continue; |
| 714 | - echo "\n<option value='" . esc_attr($key) . "'>" . esc_html($key) . "</option>"; |
|
| 714 | + echo "\n<option value='".esc_attr($key)."'>".esc_html($key)."</option>"; |
|
| 715 | 715 | } |
| 716 | 716 | ?> |
| 717 | 717 | </select> |
@@ -728,9 +728,9 @@ discard block |
||
| 728 | 728 | |
| 729 | 729 | <tr><td colspan="2"> |
| 730 | 730 | <div class="submit"> |
| 731 | -<?php submit_button( __( 'Add Custom Field' ), 'secondary', 'addmeta', false, array( 'id' => 'newmeta-submit', 'data-wp-lists' => 'add:the-list:newmeta' ) ); ?> |
|
| 731 | +<?php submit_button(__('Add Custom Field'), 'secondary', 'addmeta', false, array('id' => 'newmeta-submit', 'data-wp-lists' => 'add:the-list:newmeta')); ?> |
|
| 732 | 732 | </div> |
| 733 | -<?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?> |
|
| 733 | +<?php wp_nonce_field('add-meta', '_ajax_nonce-add-meta', false); ?> |
|
| 734 | 734 | </td></tr> |
| 735 | 735 | </tbody> |
| 736 | 736 | </table> |
@@ -752,15 +752,15 @@ discard block |
||
| 752 | 752 | * @param int|bool $multi Optional. Whether the additional fields and buttons should be added. |
| 753 | 753 | * Default 0|false. |
| 754 | 754 | */ |
| 755 | -function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) { |
|
| 755 | +function touch_time($edit = 1, $for_post = 1, $tab_index = 0, $multi = 0) { |
|
| 756 | 756 | global $wp_locale, $comment; |
| 757 | 757 | $post = get_post(); |
| 758 | 758 | |
| 759 | - if ( $for_post ) |
|
| 760 | - $edit = ! ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) ); |
|
| 759 | + if ($for_post) |
|
| 760 | + $edit = ! (in_array($post->post_status, array('draft', 'pending')) && ( ! $post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt)); |
|
| 761 | 761 | |
| 762 | 762 | $tab_index_attribute = ''; |
| 763 | - if ( (int) $tab_index > 0 ) |
|
| 763 | + if ((int) $tab_index > 0) |
|
| 764 | 764 | $tab_index_attribute = " tabindex=\"$tab_index\""; |
| 765 | 765 | |
| 766 | 766 | // todo: Remove this? |
@@ -768,56 +768,56 @@ discard block |
||
| 768 | 768 | |
| 769 | 769 | $time_adj = current_time('timestamp'); |
| 770 | 770 | $post_date = ($for_post) ? $post->post_date : $comment->comment_date; |
| 771 | - $jj = ($edit) ? mysql2date( 'd', $post_date, false ) : gmdate( 'd', $time_adj ); |
|
| 772 | - $mm = ($edit) ? mysql2date( 'm', $post_date, false ) : gmdate( 'm', $time_adj ); |
|
| 773 | - $aa = ($edit) ? mysql2date( 'Y', $post_date, false ) : gmdate( 'Y', $time_adj ); |
|
| 774 | - $hh = ($edit) ? mysql2date( 'H', $post_date, false ) : gmdate( 'H', $time_adj ); |
|
| 775 | - $mn = ($edit) ? mysql2date( 'i', $post_date, false ) : gmdate( 'i', $time_adj ); |
|
| 776 | - $ss = ($edit) ? mysql2date( 's', $post_date, false ) : gmdate( 's', $time_adj ); |
|
| 777 | - |
|
| 778 | - $cur_jj = gmdate( 'd', $time_adj ); |
|
| 779 | - $cur_mm = gmdate( 'm', $time_adj ); |
|
| 780 | - $cur_aa = gmdate( 'Y', $time_adj ); |
|
| 781 | - $cur_hh = gmdate( 'H', $time_adj ); |
|
| 782 | - $cur_mn = gmdate( 'i', $time_adj ); |
|
| 783 | - |
|
| 784 | - $month = '<label><span class="screen-reader-text">' . __( 'Month' ) . '</span><select ' . ( $multi ? '' : 'id="mm" ' ) . 'name="mm"' . $tab_index_attribute . ">\n"; |
|
| 785 | - for ( $i = 1; $i < 13; $i = $i +1 ) { |
|
| 771 | + $jj = ($edit) ? mysql2date('d', $post_date, false) : gmdate('d', $time_adj); |
|
| 772 | + $mm = ($edit) ? mysql2date('m', $post_date, false) : gmdate('m', $time_adj); |
|
| 773 | + $aa = ($edit) ? mysql2date('Y', $post_date, false) : gmdate('Y', $time_adj); |
|
| 774 | + $hh = ($edit) ? mysql2date('H', $post_date, false) : gmdate('H', $time_adj); |
|
| 775 | + $mn = ($edit) ? mysql2date('i', $post_date, false) : gmdate('i', $time_adj); |
|
| 776 | + $ss = ($edit) ? mysql2date('s', $post_date, false) : gmdate('s', $time_adj); |
|
| 777 | + |
|
| 778 | + $cur_jj = gmdate('d', $time_adj); |
|
| 779 | + $cur_mm = gmdate('m', $time_adj); |
|
| 780 | + $cur_aa = gmdate('Y', $time_adj); |
|
| 781 | + $cur_hh = gmdate('H', $time_adj); |
|
| 782 | + $cur_mn = gmdate('i', $time_adj); |
|
| 783 | + |
|
| 784 | + $month = '<label><span class="screen-reader-text">'.__('Month').'</span><select '.($multi ? '' : 'id="mm" ').'name="mm"'.$tab_index_attribute.">\n"; |
|
| 785 | + for ($i = 1; $i < 13; $i = $i + 1) { |
|
| 786 | 786 | $monthnum = zeroise($i, 2); |
| 787 | - $monthtext = $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ); |
|
| 788 | - $month .= "\t\t\t" . '<option value="' . $monthnum . '" data-text="' . $monthtext . '" ' . selected( $monthnum, $mm, false ) . '>'; |
|
| 787 | + $monthtext = $wp_locale->get_month_abbrev($wp_locale->get_month($i)); |
|
| 788 | + $month .= "\t\t\t".'<option value="'.$monthnum.'" data-text="'.$monthtext.'" '.selected($monthnum, $mm, false).'>'; |
|
| 789 | 789 | /* translators: 1: month number (01, 02, etc.), 2: month abbreviation */ |
| 790 | - $month .= sprintf( __( '%1$s-%2$s' ), $monthnum, $monthtext ) . "</option>\n"; |
|
| 790 | + $month .= sprintf(__('%1$s-%2$s'), $monthnum, $monthtext)."</option>\n"; |
|
| 791 | 791 | } |
| 792 | 792 | $month .= '</select></label>'; |
| 793 | 793 | |
| 794 | - $day = '<label><span class="screen-reader-text">' . __( 'Day' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" /></label>'; |
|
| 795 | - $year = '<label><span class="screen-reader-text">' . __( 'Year' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" /></label>'; |
|
| 796 | - $hour = '<label><span class="screen-reader-text">' . __( 'Hour' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" /></label>'; |
|
| 797 | - $minute = '<label><span class="screen-reader-text">' . __( 'Minute' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" /></label>'; |
|
| 794 | + $day = '<label><span class="screen-reader-text">'.__('Day').'</span><input type="text" '.($multi ? '' : 'id="jj" ').'name="jj" value="'.$jj.'" size="2" maxlength="2"'.$tab_index_attribute.' autocomplete="off" /></label>'; |
|
| 795 | + $year = '<label><span class="screen-reader-text">'.__('Year').'</span><input type="text" '.($multi ? '' : 'id="aa" ').'name="aa" value="'.$aa.'" size="4" maxlength="4"'.$tab_index_attribute.' autocomplete="off" /></label>'; |
|
| 796 | + $hour = '<label><span class="screen-reader-text">'.__('Hour').'</span><input type="text" '.($multi ? '' : 'id="hh" ').'name="hh" value="'.$hh.'" size="2" maxlength="2"'.$tab_index_attribute.' autocomplete="off" /></label>'; |
|
| 797 | + $minute = '<label><span class="screen-reader-text">'.__('Minute').'</span><input type="text" '.($multi ? '' : 'id="mn" ').'name="mn" value="'.$mn.'" size="2" maxlength="2"'.$tab_index_attribute.' autocomplete="off" /></label>'; |
|
| 798 | 798 | |
| 799 | 799 | echo '<div class="timestamp-wrap">'; |
| 800 | 800 | /* translators: 1: month, 2: day, 3: year, 4: hour, 5: minute */ |
| 801 | - printf( __( '%1$s %2$s, %3$s @ %4$s:%5$s' ), $month, $day, $year, $hour, $minute ); |
|
| 801 | + printf(__('%1$s %2$s, %3$s @ %4$s:%5$s'), $month, $day, $year, $hour, $minute); |
|
| 802 | 802 | |
| 803 | - echo '</div><input type="hidden" id="ss" name="ss" value="' . $ss . '" />'; |
|
| 803 | + echo '</div><input type="hidden" id="ss" name="ss" value="'.$ss.'" />'; |
|
| 804 | 804 | |
| 805 | - if ( $multi ) return; |
|
| 805 | + if ($multi) return; |
|
| 806 | 806 | |
| 807 | 807 | echo "\n\n"; |
| 808 | 808 | $map = array( |
| 809 | - 'mm' => array( $mm, $cur_mm ), |
|
| 810 | - 'jj' => array( $jj, $cur_jj ), |
|
| 811 | - 'aa' => array( $aa, $cur_aa ), |
|
| 812 | - 'hh' => array( $hh, $cur_hh ), |
|
| 813 | - 'mn' => array( $mn, $cur_mn ), |
|
| 809 | + 'mm' => array($mm, $cur_mm), |
|
| 810 | + 'jj' => array($jj, $cur_jj), |
|
| 811 | + 'aa' => array($aa, $cur_aa), |
|
| 812 | + 'hh' => array($hh, $cur_hh), |
|
| 813 | + 'mn' => array($mn, $cur_mn), |
|
| 814 | 814 | ); |
| 815 | - foreach ( $map as $timeunit => $value ) { |
|
| 816 | - list( $unit, $curr ) = $value; |
|
| 815 | + foreach ($map as $timeunit => $value) { |
|
| 816 | + list($unit, $curr) = $value; |
|
| 817 | 817 | |
| 818 | - echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $unit . '" />' . "\n"; |
|
| 819 | - $cur_timeunit = 'cur_' . $timeunit; |
|
| 820 | - echo '<input type="hidden" id="' . $cur_timeunit . '" name="' . $cur_timeunit . '" value="' . $curr . '" />' . "\n"; |
|
| 818 | + echo '<input type="hidden" id="hidden_'.$timeunit.'" name="hidden_'.$timeunit.'" value="'.$unit.'" />'."\n"; |
|
| 819 | + $cur_timeunit = 'cur_'.$timeunit; |
|
| 820 | + echo '<input type="hidden" id="'.$cur_timeunit.'" name="'.$cur_timeunit.'" value="'.$curr.'" />'."\n"; |
|
| 821 | 821 | } |
| 822 | 822 | ?> |
| 823 | 823 | |
@@ -835,12 +835,12 @@ discard block |
||
| 835 | 835 | * |
| 836 | 836 | * @param string $default Optional. The template file name. Default empty. |
| 837 | 837 | */ |
| 838 | -function page_template_dropdown( $default = '' ) { |
|
| 839 | - $templates = get_page_templates( get_post() ); |
|
| 840 | - ksort( $templates ); |
|
| 841 | - foreach ( array_keys( $templates ) as $template ) { |
|
| 842 | - $selected = selected( $default, $templates[ $template ], false ); |
|
| 843 | - echo "\n\t<option value='" . $templates[ $template ] . "' $selected>$template</option>"; |
|
| 838 | +function page_template_dropdown($default = '') { |
|
| 839 | + $templates = get_page_templates(get_post()); |
|
| 840 | + ksort($templates); |
|
| 841 | + foreach (array_keys($templates) as $template) { |
|
| 842 | + $selected = selected($default, $templates[$template], false); |
|
| 843 | + echo "\n\t<option value='".$templates[$template]."' $selected>$template</option>"; |
|
| 844 | 844 | } |
| 845 | 845 | } |
| 846 | 846 | |
@@ -857,22 +857,22 @@ discard block |
||
| 857 | 857 | * |
| 858 | 858 | * @return null|false Boolean False if page has no children, otherwise print out html elements |
| 859 | 859 | */ |
| 860 | -function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) { |
|
| 860 | +function parent_dropdown($default = 0, $parent = 0, $level = 0) { |
|
| 861 | 861 | global $wpdb; |
| 862 | 862 | $post = get_post(); |
| 863 | - $items = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order", $parent) ); |
|
| 863 | + $items = $wpdb->get_results($wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order", $parent)); |
|
| 864 | 864 | |
| 865 | - if ( $items ) { |
|
| 866 | - foreach ( $items as $item ) { |
|
| 865 | + if ($items) { |
|
| 866 | + foreach ($items as $item) { |
|
| 867 | 867 | // A page cannot be its own parent. |
| 868 | - if ( $post && $post->ID && $item->ID == $post->ID ) |
|
| 868 | + if ($post && $post->ID && $item->ID == $post->ID) |
|
| 869 | 869 | continue; |
| 870 | 870 | |
| 871 | - $pad = str_repeat( ' ', $level * 3 ); |
|
| 872 | - $selected = selected( $default, $item->ID, false ); |
|
| 871 | + $pad = str_repeat(' ', $level * 3); |
|
| 872 | + $selected = selected($default, $item->ID, false); |
|
| 873 | 873 | |
| 874 | - echo "\n\t<option class='level-$level' value='$item->ID' $selected>$pad " . esc_html($item->post_title) . "</option>"; |
|
| 875 | - parent_dropdown( $default, $item->ID, $level +1 ); |
|
| 874 | + echo "\n\t<option class='level-$level' value='$item->ID' $selected>$pad ".esc_html($item->post_title)."</option>"; |
|
| 875 | + parent_dropdown($default, $item->ID, $level + 1); |
|
| 876 | 876 | } |
| 877 | 877 | } else { |
| 878 | 878 | return false; |
@@ -886,20 +886,20 @@ discard block |
||
| 886 | 886 | * |
| 887 | 887 | * @param string $selected Slug for the role that should be already selected. |
| 888 | 888 | */ |
| 889 | -function wp_dropdown_roles( $selected = '' ) { |
|
| 889 | +function wp_dropdown_roles($selected = '') { |
|
| 890 | 890 | $p = ''; |
| 891 | 891 | $r = ''; |
| 892 | 892 | |
| 893 | - $editable_roles = array_reverse( get_editable_roles() ); |
|
| 893 | + $editable_roles = array_reverse(get_editable_roles()); |
|
| 894 | 894 | |
| 895 | - foreach ( $editable_roles as $role => $details ) { |
|
| 896 | - $name = translate_user_role($details['name'] ); |
|
| 897 | - if ( $selected == $role ) // preselect specified role |
|
| 898 | - $p = "\n\t<option selected='selected' value='" . esc_attr($role) . "'>$name</option>"; |
|
| 895 | + foreach ($editable_roles as $role => $details) { |
|
| 896 | + $name = translate_user_role($details['name']); |
|
| 897 | + if ($selected == $role) // preselect specified role |
|
| 898 | + $p = "\n\t<option selected='selected' value='".esc_attr($role)."'>$name</option>"; |
|
| 899 | 899 | else |
| 900 | - $r .= "\n\t<option value='" . esc_attr($role) . "'>$name</option>"; |
|
| 900 | + $r .= "\n\t<option value='".esc_attr($role)."'>$name</option>"; |
|
| 901 | 901 | } |
| 902 | - echo $p . $r; |
|
| 902 | + echo $p.$r; |
|
| 903 | 903 | } |
| 904 | 904 | |
| 905 | 905 | /** |
@@ -909,7 +909,7 @@ discard block |
||
| 909 | 909 | * |
| 910 | 910 | * @param string $action The action attribute for the form. |
| 911 | 911 | */ |
| 912 | -function wp_import_upload_form( $action ) { |
|
| 912 | +function wp_import_upload_form($action) { |
|
| 913 | 913 | |
| 914 | 914 | /** |
| 915 | 915 | * Filter the maximum allowed upload size for import files. |
@@ -920,22 +920,22 @@ discard block |
||
| 920 | 920 | * |
| 921 | 921 | * @param int $max_upload_size Allowed upload size. Default 1 MB. |
| 922 | 922 | */ |
| 923 | - $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() ); |
|
| 924 | - $size = size_format( $bytes ); |
|
| 923 | + $bytes = apply_filters('import_upload_size_limit', wp_max_upload_size()); |
|
| 924 | + $size = size_format($bytes); |
|
| 925 | 925 | $upload_dir = wp_upload_dir(); |
| 926 | - if ( ! empty( $upload_dir['error'] ) ) : |
|
| 926 | + if ( ! empty($upload_dir['error'])) : |
|
| 927 | 927 | ?><div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:'); ?></p> |
| 928 | 928 | <p><strong><?php echo $upload_dir['error']; ?></strong></p></div><?php |
| 929 | 929 | else : |
| 930 | 930 | ?> |
| 931 | -<form enctype="multipart/form-data" id="import-upload-form" method="post" class="wp-upload-form" action="<?php echo esc_url( wp_nonce_url( $action, 'import-upload' ) ); ?>"> |
|
| 931 | +<form enctype="multipart/form-data" id="import-upload-form" method="post" class="wp-upload-form" action="<?php echo esc_url(wp_nonce_url($action, 'import-upload')); ?>"> |
|
| 932 | 932 | <p> |
| 933 | -<label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>) |
|
| 933 | +<label for="upload"><?php _e('Choose a file from your computer:'); ?></label> (<?php printf(__('Maximum size: %s'), $size); ?>) |
|
| 934 | 934 | <input type="file" id="upload" name="import" size="25" /> |
| 935 | 935 | <input type="hidden" name="action" value="save" /> |
| 936 | 936 | <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" /> |
| 937 | 937 | </p> |
| 938 | -<?php submit_button( __('Upload file and import'), 'button' ); ?> |
|
| 938 | +<?php submit_button(__('Upload file and import'), 'button'); ?> |
|
| 939 | 939 | </form> |
| 940 | 940 | <?php |
| 941 | 941 | endif; |
@@ -966,66 +966,66 @@ discard block |
||
| 966 | 966 | * of the box array (which is the second parameter passed |
| 967 | 967 | * to your callback). Default null. |
| 968 | 968 | */ |
| 969 | -function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advanced', $priority = 'default', $callback_args = null ) { |
|
| 969 | +function add_meta_box($id, $title, $callback, $screen = null, $context = 'advanced', $priority = 'default', $callback_args = null) { |
|
| 970 | 970 | global $wp_meta_boxes; |
| 971 | 971 | |
| 972 | - if ( empty( $screen ) ) |
|
| 972 | + if (empty($screen)) |
|
| 973 | 973 | $screen = get_current_screen(); |
| 974 | - elseif ( is_string( $screen ) ) |
|
| 975 | - $screen = convert_to_screen( $screen ); |
|
| 974 | + elseif (is_string($screen)) |
|
| 975 | + $screen = convert_to_screen($screen); |
|
| 976 | 976 | |
| 977 | 977 | $page = $screen->id; |
| 978 | 978 | |
| 979 | - if ( !isset($wp_meta_boxes) ) |
|
| 979 | + if ( ! isset($wp_meta_boxes)) |
|
| 980 | 980 | $wp_meta_boxes = array(); |
| 981 | - if ( !isset($wp_meta_boxes[$page]) ) |
|
| 981 | + if ( ! isset($wp_meta_boxes[$page])) |
|
| 982 | 982 | $wp_meta_boxes[$page] = array(); |
| 983 | - if ( !isset($wp_meta_boxes[$page][$context]) ) |
|
| 983 | + if ( ! isset($wp_meta_boxes[$page][$context])) |
|
| 984 | 984 | $wp_meta_boxes[$page][$context] = array(); |
| 985 | 985 | |
| 986 | - foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) { |
|
| 987 | - foreach ( array('high', 'core', 'default', 'low') as $a_priority ) { |
|
| 988 | - if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) ) |
|
| 986 | + foreach (array_keys($wp_meta_boxes[$page]) as $a_context) { |
|
| 987 | + foreach (array('high', 'core', 'default', 'low') as $a_priority) { |
|
| 988 | + if ( ! isset($wp_meta_boxes[$page][$a_context][$a_priority][$id])) |
|
| 989 | 989 | continue; |
| 990 | 990 | |
| 991 | 991 | // If a core box was previously added or removed by a plugin, don't add. |
| 992 | - if ( 'core' == $priority ) { |
|
| 992 | + if ('core' == $priority) { |
|
| 993 | 993 | // If core box previously deleted, don't add |
| 994 | - if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] ) |
|
| 994 | + if (false === $wp_meta_boxes[$page][$a_context][$a_priority][$id]) |
|
| 995 | 995 | return; |
| 996 | 996 | |
| 997 | 997 | /* |
| 998 | 998 | * If box was added with default priority, give it core priority to |
| 999 | 999 | * maintain sort order. |
| 1000 | 1000 | */ |
| 1001 | - if ( 'default' == $a_priority ) { |
|
| 1001 | + if ('default' == $a_priority) { |
|
| 1002 | 1002 | $wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id]; |
| 1003 | 1003 | unset($wp_meta_boxes[$page][$a_context]['default'][$id]); |
| 1004 | 1004 | } |
| 1005 | 1005 | return; |
| 1006 | 1006 | } |
| 1007 | 1007 | // If no priority given and id already present, use existing priority. |
| 1008 | - if ( empty($priority) ) { |
|
| 1008 | + if (empty($priority)) { |
|
| 1009 | 1009 | $priority = $a_priority; |
| 1010 | 1010 | /* |
| 1011 | 1011 | * Else, if we're adding to the sorted priority, we don't know the title |
| 1012 | 1012 | * or callback. Grab them from the previously added context/priority. |
| 1013 | 1013 | */ |
| 1014 | - } elseif ( 'sorted' == $priority ) { |
|
| 1014 | + } elseif ('sorted' == $priority) { |
|
| 1015 | 1015 | $title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title']; |
| 1016 | 1016 | $callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback']; |
| 1017 | 1017 | $callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args']; |
| 1018 | 1018 | } |
| 1019 | 1019 | // An id can be in only one priority and one context. |
| 1020 | - if ( $priority != $a_priority || $context != $a_context ) |
|
| 1020 | + if ($priority != $a_priority || $context != $a_context) |
|
| 1021 | 1021 | unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]); |
| 1022 | 1022 | } |
| 1023 | 1023 | } |
| 1024 | 1024 | |
| 1025 | - if ( empty($priority) ) |
|
| 1025 | + if (empty($priority)) |
|
| 1026 | 1026 | $priority = 'low'; |
| 1027 | 1027 | |
| 1028 | - if ( !isset($wp_meta_boxes[$page][$context][$priority]) ) |
|
| 1028 | + if ( ! isset($wp_meta_boxes[$page][$context][$priority])) |
|
| 1029 | 1029 | $wp_meta_boxes[$page][$context][$priority] = array(); |
| 1030 | 1030 | |
| 1031 | 1031 | $wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $callback_args); |
@@ -1044,27 +1044,27 @@ discard block |
||
| 1044 | 1044 | * @param mixed $object gets passed to the box callback function as first parameter |
| 1045 | 1045 | * @return int number of meta_boxes |
| 1046 | 1046 | */ |
| 1047 | -function do_meta_boxes( $screen, $context, $object ) { |
|
| 1047 | +function do_meta_boxes($screen, $context, $object) { |
|
| 1048 | 1048 | global $wp_meta_boxes; |
| 1049 | 1049 | static $already_sorted = false; |
| 1050 | 1050 | |
| 1051 | - if ( empty( $screen ) ) |
|
| 1051 | + if (empty($screen)) |
|
| 1052 | 1052 | $screen = get_current_screen(); |
| 1053 | - elseif ( is_string( $screen ) ) |
|
| 1054 | - $screen = convert_to_screen( $screen ); |
|
| 1053 | + elseif (is_string($screen)) |
|
| 1054 | + $screen = convert_to_screen($screen); |
|
| 1055 | 1055 | |
| 1056 | 1056 | $page = $screen->id; |
| 1057 | 1057 | |
| 1058 | - $hidden = get_hidden_meta_boxes( $screen ); |
|
| 1058 | + $hidden = get_hidden_meta_boxes($screen); |
|
| 1059 | 1059 | |
| 1060 | 1060 | printf('<div id="%s-sortables" class="meta-box-sortables">', htmlspecialchars($context)); |
| 1061 | 1061 | |
| 1062 | 1062 | // Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose |
| 1063 | - if ( ! $already_sorted && $sorted = get_user_option( "meta-box-order_$page" ) ) { |
|
| 1064 | - foreach ( $sorted as $box_context => $ids ) { |
|
| 1065 | - foreach ( explode( ',', $ids ) as $id ) { |
|
| 1066 | - if ( $id && 'dashboard_browser_nag' !== $id ) { |
|
| 1067 | - add_meta_box( $id, null, null, $screen, $box_context, 'sorted' ); |
|
| 1063 | + if ( ! $already_sorted && $sorted = get_user_option("meta-box-order_$page")) { |
|
| 1064 | + foreach ($sorted as $box_context => $ids) { |
|
| 1065 | + foreach (explode(',', $ids) as $id) { |
|
| 1066 | + if ($id && 'dashboard_browser_nag' !== $id) { |
|
| 1067 | + add_meta_box($id, null, null, $screen, $box_context, 'sorted'); |
|
| 1068 | 1068 | } |
| 1069 | 1069 | } |
| 1070 | 1070 | } |
@@ -1074,19 +1074,19 @@ discard block |
||
| 1074 | 1074 | |
| 1075 | 1075 | $i = 0; |
| 1076 | 1076 | |
| 1077 | - if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) { |
|
| 1078 | - foreach ( array( 'high', 'sorted', 'core', 'default', 'low' ) as $priority ) { |
|
| 1079 | - if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ]) ) { |
|
| 1080 | - foreach ( (array) $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
| 1081 | - if ( false == $box || ! $box['title'] ) |
|
| 1077 | + if (isset($wp_meta_boxes[$page][$context])) { |
|
| 1078 | + foreach (array('high', 'sorted', 'core', 'default', 'low') as $priority) { |
|
| 1079 | + if (isset($wp_meta_boxes[$page][$context][$priority])) { |
|
| 1080 | + foreach ((array) $wp_meta_boxes[$page][$context][$priority] as $box) { |
|
| 1081 | + if (false == $box || ! $box['title']) |
|
| 1082 | 1082 | continue; |
| 1083 | 1083 | $i++; |
| 1084 | 1084 | $hidden_class = in_array($box['id'], $hidden) ? ' hide-if-js' : ''; |
| 1085 | - echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . $hidden_class . '" ' . '>' . "\n"; |
|
| 1086 | - if ( 'dashboard_browser_nag' != $box['id'] ) |
|
| 1087 | - echo '<div class="handlediv" title="' . esc_attr__('Click to toggle') . '"><br /></div>'; |
|
| 1085 | + echo '<div id="'.$box['id'].'" class="postbox '.postbox_classes($box['id'], $page).$hidden_class.'" '.'>'."\n"; |
|
| 1086 | + if ('dashboard_browser_nag' != $box['id']) |
|
| 1087 | + echo '<div class="handlediv" title="'.esc_attr__('Click to toggle').'"><br /></div>'; |
|
| 1088 | 1088 | echo "<h3 class='hndle'><span>{$box['title']}</span></h3>\n"; |
| 1089 | - echo '<div class="inside">' . "\n"; |
|
| 1089 | + echo '<div class="inside">'."\n"; |
|
| 1090 | 1090 | call_user_func($box['callback'], $object, $box); |
| 1091 | 1091 | echo "</div>\n"; |
| 1092 | 1092 | echo "</div>\n"; |
@@ -1115,21 +1115,21 @@ discard block |
||
| 1115 | 1115 | function remove_meta_box($id, $screen, $context) { |
| 1116 | 1116 | global $wp_meta_boxes; |
| 1117 | 1117 | |
| 1118 | - if ( empty( $screen ) ) |
|
| 1118 | + if (empty($screen)) |
|
| 1119 | 1119 | $screen = get_current_screen(); |
| 1120 | - elseif ( is_string( $screen ) ) |
|
| 1121 | - $screen = convert_to_screen( $screen ); |
|
| 1120 | + elseif (is_string($screen)) |
|
| 1121 | + $screen = convert_to_screen($screen); |
|
| 1122 | 1122 | |
| 1123 | 1123 | $page = $screen->id; |
| 1124 | 1124 | |
| 1125 | - if ( !isset($wp_meta_boxes) ) |
|
| 1125 | + if ( ! isset($wp_meta_boxes)) |
|
| 1126 | 1126 | $wp_meta_boxes = array(); |
| 1127 | - if ( !isset($wp_meta_boxes[$page]) ) |
|
| 1127 | + if ( ! isset($wp_meta_boxes[$page])) |
|
| 1128 | 1128 | $wp_meta_boxes[$page] = array(); |
| 1129 | - if ( !isset($wp_meta_boxes[$page][$context]) ) |
|
| 1129 | + if ( ! isset($wp_meta_boxes[$page][$context])) |
|
| 1130 | 1130 | $wp_meta_boxes[$page][$context] = array(); |
| 1131 | 1131 | |
| 1132 | - foreach ( array('high', 'core', 'default', 'low') as $priority ) |
|
| 1132 | + foreach (array('high', 'core', 'default', 'low') as $priority) |
|
| 1133 | 1133 | $wp_meta_boxes[$page][$context][$priority][$id] = false; |
| 1134 | 1134 | } |
| 1135 | 1135 | |
@@ -1149,19 +1149,19 @@ discard block |
||
| 1149 | 1149 | * @param mixed $object gets passed to the section callback function as first parameter. |
| 1150 | 1150 | * @return int number of meta boxes as accordion sections. |
| 1151 | 1151 | */ |
| 1152 | -function do_accordion_sections( $screen, $context, $object ) { |
|
| 1152 | +function do_accordion_sections($screen, $context, $object) { |
|
| 1153 | 1153 | global $wp_meta_boxes; |
| 1154 | 1154 | |
| 1155 | - wp_enqueue_script( 'accordion' ); |
|
| 1155 | + wp_enqueue_script('accordion'); |
|
| 1156 | 1156 | |
| 1157 | - if ( empty( $screen ) ) |
|
| 1157 | + if (empty($screen)) |
|
| 1158 | 1158 | $screen = get_current_screen(); |
| 1159 | - elseif ( is_string( $screen ) ) |
|
| 1160 | - $screen = convert_to_screen( $screen ); |
|
| 1159 | + elseif (is_string($screen)) |
|
| 1160 | + $screen = convert_to_screen($screen); |
|
| 1161 | 1161 | |
| 1162 | 1162 | $page = $screen->id; |
| 1163 | 1163 | |
| 1164 | - $hidden = get_hidden_meta_boxes( $screen ); |
|
| 1164 | + $hidden = get_hidden_meta_boxes($screen); |
|
| 1165 | 1165 | ?> |
| 1166 | 1166 | <div id="side-sortables" class="accordion-container"> |
| 1167 | 1167 | <ul class="outer-border"> |
@@ -1169,29 +1169,29 @@ discard block |
||
| 1169 | 1169 | $i = 0; |
| 1170 | 1170 | $first_open = false; |
| 1171 | 1171 | |
| 1172 | - if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) { |
|
| 1173 | - foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
|
| 1174 | - if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
|
| 1175 | - foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
| 1176 | - if ( false == $box || ! $box['title'] ) |
|
| 1172 | + if (isset($wp_meta_boxes[$page][$context])) { |
|
| 1173 | + foreach (array('high', 'core', 'default', 'low') as $priority) { |
|
| 1174 | + if (isset($wp_meta_boxes[$page][$context][$priority])) { |
|
| 1175 | + foreach ($wp_meta_boxes[$page][$context][$priority] as $box) { |
|
| 1176 | + if (false == $box || ! $box['title']) |
|
| 1177 | 1177 | continue; |
| 1178 | 1178 | $i++; |
| 1179 | - $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
|
| 1179 | + $hidden_class = in_array($box['id'], $hidden) ? 'hide-if-js' : ''; |
|
| 1180 | 1180 | |
| 1181 | 1181 | $open_class = ''; |
| 1182 | - if ( ! $first_open && empty( $hidden_class ) ) { |
|
| 1182 | + if ( ! $first_open && empty($hidden_class)) { |
|
| 1183 | 1183 | $first_open = true; |
| 1184 | 1184 | $open_class = 'open'; |
| 1185 | 1185 | } |
| 1186 | 1186 | ?> |
| 1187 | - <li class="control-section accordion-section <?php echo $hidden_class; ?> <?php echo $open_class; ?> <?php echo esc_attr( $box['id'] ); ?>" id="<?php echo esc_attr( $box['id'] ); ?>"> |
|
| 1187 | + <li class="control-section accordion-section <?php echo $hidden_class; ?> <?php echo $open_class; ?> <?php echo esc_attr($box['id']); ?>" id="<?php echo esc_attr($box['id']); ?>"> |
|
| 1188 | 1188 | <h3 class="accordion-section-title hndle" tabindex="0"> |
| 1189 | - <?php echo esc_html( $box['title'] ); ?> |
|
| 1190 | - <span class="screen-reader-text"><?php _e( 'Press return or enter to expand' ); ?></span> |
|
| 1189 | + <?php echo esc_html($box['title']); ?> |
|
| 1190 | + <span class="screen-reader-text"><?php _e('Press return or enter to expand'); ?></span> |
|
| 1191 | 1191 | </h3> |
| 1192 | - <div class="accordion-section-content <?php postbox_classes( $box['id'], $page ); ?>"> |
|
| 1192 | + <div class="accordion-section-content <?php postbox_classes($box['id'], $page); ?>"> |
|
| 1193 | 1193 | <div class="inside"> |
| 1194 | - <?php call_user_func( $box['callback'], $object, $box ); ?> |
|
| 1194 | + <?php call_user_func($box['callback'], $object, $box); ?> |
|
| 1195 | 1195 | </div><!-- .inside --> |
| 1196 | 1196 | </div><!-- .accordion-section-content --> |
| 1197 | 1197 | </li><!-- .accordion-section --> |
@@ -1230,13 +1230,13 @@ discard block |
||
| 1230 | 1230 | function add_settings_section($id, $title, $callback, $page) { |
| 1231 | 1231 | global $wp_settings_sections; |
| 1232 | 1232 | |
| 1233 | - if ( 'misc' == $page ) { |
|
| 1234 | - _deprecated_argument( __FUNCTION__, '3.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'misc' ) ); |
|
| 1233 | + if ('misc' == $page) { |
|
| 1234 | + _deprecated_argument(__FUNCTION__, '3.0', sprintf(__('The "%s" options group has been removed. Use another settings group.'), 'misc')); |
|
| 1235 | 1235 | $page = 'general'; |
| 1236 | 1236 | } |
| 1237 | 1237 | |
| 1238 | - if ( 'privacy' == $page ) { |
|
| 1239 | - _deprecated_argument( __FUNCTION__, '3.5', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'privacy' ) ); |
|
| 1238 | + if ('privacy' == $page) { |
|
| 1239 | + _deprecated_argument(__FUNCTION__, '3.5', sprintf(__('The "%s" options group has been removed. Use another settings group.'), 'privacy')); |
|
| 1240 | 1240 | $page = 'reading'; |
| 1241 | 1241 | } |
| 1242 | 1242 | |
@@ -1281,13 +1281,13 @@ discard block |
||
| 1281 | 1281 | function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) { |
| 1282 | 1282 | global $wp_settings_fields; |
| 1283 | 1283 | |
| 1284 | - if ( 'misc' == $page ) { |
|
| 1285 | - _deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) ); |
|
| 1284 | + if ('misc' == $page) { |
|
| 1285 | + _deprecated_argument(__FUNCTION__, '3.0', __('The miscellaneous options group has been removed. Use another settings group.')); |
|
| 1286 | 1286 | $page = 'general'; |
| 1287 | 1287 | } |
| 1288 | 1288 | |
| 1289 | - if ( 'privacy' == $page ) { |
|
| 1290 | - _deprecated_argument( __FUNCTION__, '3.5', __( 'The privacy options group has been removed. Use another settings group.' ) ); |
|
| 1289 | + if ('privacy' == $page) { |
|
| 1290 | + _deprecated_argument(__FUNCTION__, '3.5', __('The privacy options group has been removed. Use another settings group.')); |
|
| 1291 | 1291 | $page = 'reading'; |
| 1292 | 1292 | } |
| 1293 | 1293 | |
@@ -1307,23 +1307,23 @@ discard block |
||
| 1307 | 1307 | * |
| 1308 | 1308 | * @param string $page The slug name of the page whos settings sections you want to output |
| 1309 | 1309 | */ |
| 1310 | -function do_settings_sections( $page ) { |
|
| 1310 | +function do_settings_sections($page) { |
|
| 1311 | 1311 | global $wp_settings_sections, $wp_settings_fields; |
| 1312 | 1312 | |
| 1313 | - if ( ! isset( $wp_settings_sections[$page] ) ) |
|
| 1313 | + if ( ! isset($wp_settings_sections[$page])) |
|
| 1314 | 1314 | return; |
| 1315 | 1315 | |
| 1316 | - foreach ( (array) $wp_settings_sections[$page] as $section ) { |
|
| 1317 | - if ( $section['title'] ) |
|
| 1316 | + foreach ((array) $wp_settings_sections[$page] as $section) { |
|
| 1317 | + if ($section['title']) |
|
| 1318 | 1318 | echo "<h3>{$section['title']}</h3>\n"; |
| 1319 | 1319 | |
| 1320 | - if ( $section['callback'] ) |
|
| 1321 | - call_user_func( $section['callback'], $section ); |
|
| 1320 | + if ($section['callback']) |
|
| 1321 | + call_user_func($section['callback'], $section); |
|
| 1322 | 1322 | |
| 1323 | - if ( ! isset( $wp_settings_fields ) || !isset( $wp_settings_fields[$page] ) || !isset( $wp_settings_fields[$page][$section['id']] ) ) |
|
| 1323 | + if ( ! isset($wp_settings_fields) || ! isset($wp_settings_fields[$page]) || ! isset($wp_settings_fields[$page][$section['id']])) |
|
| 1324 | 1324 | continue; |
| 1325 | 1325 | echo '<table class="form-table">'; |
| 1326 | - do_settings_fields( $page, $section['id'] ); |
|
| 1326 | + do_settings_fields($page, $section['id']); |
|
| 1327 | 1327 | echo '</table>'; |
| 1328 | 1328 | } |
| 1329 | 1329 | } |
@@ -1345,22 +1345,22 @@ discard block |
||
| 1345 | 1345 | function do_settings_fields($page, $section) { |
| 1346 | 1346 | global $wp_settings_fields; |
| 1347 | 1347 | |
| 1348 | - if ( ! isset( $wp_settings_fields[$page][$section] ) ) |
|
| 1348 | + if ( ! isset($wp_settings_fields[$page][$section])) |
|
| 1349 | 1349 | return; |
| 1350 | 1350 | |
| 1351 | - foreach ( (array) $wp_settings_fields[$page][$section] as $field ) { |
|
| 1351 | + foreach ((array) $wp_settings_fields[$page][$section] as $field) { |
|
| 1352 | 1352 | $class = ''; |
| 1353 | 1353 | |
| 1354 | - if ( ! empty( $field['args']['class'] ) ) { |
|
| 1355 | - $class = ' class="' . esc_attr( $field['args']['class'] ) . '"'; |
|
| 1354 | + if ( ! empty($field['args']['class'])) { |
|
| 1355 | + $class = ' class="'.esc_attr($field['args']['class']).'"'; |
|
| 1356 | 1356 | } |
| 1357 | 1357 | |
| 1358 | 1358 | echo "<tr{$class}>"; |
| 1359 | 1359 | |
| 1360 | - if ( ! empty( $field['args']['label_for'] ) ) { |
|
| 1361 | - echo '<th scope="row"><label for="' . esc_attr( $field['args']['label_for'] ) . '">' . $field['title'] . '</label></th>'; |
|
| 1360 | + if ( ! empty($field['args']['label_for'])) { |
|
| 1361 | + echo '<th scope="row"><label for="'.esc_attr($field['args']['label_for']).'">'.$field['title'].'</label></th>'; |
|
| 1362 | 1362 | } else { |
| 1363 | - echo '<th scope="row">' . $field['title'] . '</th>'; |
|
| 1363 | + echo '<th scope="row">'.$field['title'].'</th>'; |
|
| 1364 | 1364 | } |
| 1365 | 1365 | |
| 1366 | 1366 | echo '<td>'; |
@@ -1394,7 +1394,7 @@ discard block |
||
| 1394 | 1394 | * @param string $type Optional. Message type, controls HTML class. Accepts 'error' or 'updated'. |
| 1395 | 1395 | * Default 'error'. |
| 1396 | 1396 | */ |
| 1397 | -function add_settings_error( $setting, $code, $message, $type = 'error' ) { |
|
| 1397 | +function add_settings_error($setting, $code, $message, $type = 'error') { |
|
| 1398 | 1398 | global $wp_settings_errors; |
| 1399 | 1399 | |
| 1400 | 1400 | $wp_settings_errors[] = array( |
@@ -1427,7 +1427,7 @@ discard block |
||
| 1427 | 1427 | * @param boolean $sanitize Whether to re-sanitize the setting value before returning errors. |
| 1428 | 1428 | * @return array Array of settings errors |
| 1429 | 1429 | */ |
| 1430 | -function get_settings_errors( $setting = '', $sanitize = false ) { |
|
| 1430 | +function get_settings_errors($setting = '', $sanitize = false) { |
|
| 1431 | 1431 | global $wp_settings_errors; |
| 1432 | 1432 | |
| 1433 | 1433 | /* |
@@ -1435,24 +1435,24 @@ discard block |
||
| 1435 | 1435 | * This allows the $sanitize_callback from register_setting() to run, adding |
| 1436 | 1436 | * any settings errors you want to show by default. |
| 1437 | 1437 | */ |
| 1438 | - if ( $sanitize ) |
|
| 1439 | - sanitize_option( $setting, get_option( $setting ) ); |
|
| 1438 | + if ($sanitize) |
|
| 1439 | + sanitize_option($setting, get_option($setting)); |
|
| 1440 | 1440 | |
| 1441 | 1441 | // If settings were passed back from options.php then use them. |
| 1442 | - if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] && get_transient( 'settings_errors' ) ) { |
|
| 1443 | - $wp_settings_errors = array_merge( (array) $wp_settings_errors, get_transient( 'settings_errors' ) ); |
|
| 1444 | - delete_transient( 'settings_errors' ); |
|
| 1442 | + if (isset($_GET['settings-updated']) && $_GET['settings-updated'] && get_transient('settings_errors')) { |
|
| 1443 | + $wp_settings_errors = array_merge((array) $wp_settings_errors, get_transient('settings_errors')); |
|
| 1444 | + delete_transient('settings_errors'); |
|
| 1445 | 1445 | } |
| 1446 | 1446 | |
| 1447 | 1447 | // Check global in case errors have been added on this pageload. |
| 1448 | - if ( ! count( $wp_settings_errors ) ) |
|
| 1448 | + if ( ! count($wp_settings_errors)) |
|
| 1449 | 1449 | return array(); |
| 1450 | 1450 | |
| 1451 | 1451 | // Filter the results to those of a specific setting if one was set. |
| 1452 | - if ( $setting ) { |
|
| 1452 | + if ($setting) { |
|
| 1453 | 1453 | $setting_errors = array(); |
| 1454 | - foreach ( (array) $wp_settings_errors as $key => $details ) { |
|
| 1455 | - if ( $setting == $details['setting'] ) |
|
| 1454 | + foreach ((array) $wp_settings_errors as $key => $details) { |
|
| 1455 | + if ($setting == $details['setting']) |
|
| 1456 | 1456 | $setting_errors[] = $wp_settings_errors[$key]; |
| 1457 | 1457 | } |
| 1458 | 1458 | return $setting_errors; |
@@ -1487,20 +1487,20 @@ discard block |
||
| 1487 | 1487 | * @param bool $sanitize Whether to re-sanitize the setting value before returning errors. |
| 1488 | 1488 | * @param bool $hide_on_update If set to true errors will not be shown if the settings page has already been submitted. |
| 1489 | 1489 | */ |
| 1490 | -function settings_errors( $setting = '', $sanitize = false, $hide_on_update = false ) { |
|
| 1490 | +function settings_errors($setting = '', $sanitize = false, $hide_on_update = false) { |
|
| 1491 | 1491 | |
| 1492 | - if ( $hide_on_update && ! empty( $_GET['settings-updated'] ) ) |
|
| 1492 | + if ($hide_on_update && ! empty($_GET['settings-updated'])) |
|
| 1493 | 1493 | return; |
| 1494 | 1494 | |
| 1495 | - $settings_errors = get_settings_errors( $setting, $sanitize ); |
|
| 1495 | + $settings_errors = get_settings_errors($setting, $sanitize); |
|
| 1496 | 1496 | |
| 1497 | - if ( empty( $settings_errors ) ) |
|
| 1497 | + if (empty($settings_errors)) |
|
| 1498 | 1498 | return; |
| 1499 | 1499 | |
| 1500 | 1500 | $output = ''; |
| 1501 | - foreach ( $settings_errors as $key => $details ) { |
|
| 1502 | - $css_id = 'setting-error-' . $details['code']; |
|
| 1503 | - $css_class = $details['type'] . ' settings-error notice is-dismissible'; |
|
| 1501 | + foreach ($settings_errors as $key => $details) { |
|
| 1502 | + $css_id = 'setting-error-'.$details['code']; |
|
| 1503 | + $css_class = $details['type'].' settings-error notice is-dismissible'; |
|
| 1504 | 1504 | $output .= "<div id='$css_id' class='$css_class'> \n"; |
| 1505 | 1505 | $output .= "<p><strong>{$details['message']}</strong></p>"; |
| 1506 | 1506 | $output .= "</div> \n"; |
@@ -1519,26 +1519,26 @@ discard block |
||
| 1519 | 1519 | ?> |
| 1520 | 1520 | <div id="find-posts" class="find-box" style="display: none;"> |
| 1521 | 1521 | <div id="find-posts-head" class="find-box-head"> |
| 1522 | - <?php _e( 'Find Posts or Pages' ); ?> |
|
| 1522 | + <?php _e('Find Posts or Pages'); ?> |
|
| 1523 | 1523 | <div id="find-posts-close"></div> |
| 1524 | 1524 | </div> |
| 1525 | 1525 | <div class="find-box-inside"> |
| 1526 | 1526 | <div class="find-box-search"> |
| 1527 | - <?php if ( $found_action ) { ?> |
|
| 1527 | + <?php if ($found_action) { ?> |
|
| 1528 | 1528 | <input type="hidden" name="found_action" value="<?php echo esc_attr($found_action); ?>" /> |
| 1529 | 1529 | <?php } ?> |
| 1530 | 1530 | <input type="hidden" name="affected" id="affected" value="" /> |
| 1531 | - <?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?> |
|
| 1532 | - <label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label> |
|
| 1531 | + <?php wp_nonce_field('find-posts', '_ajax_nonce', false); ?> |
|
| 1532 | + <label class="screen-reader-text" for="find-posts-input"><?php _e('Search'); ?></label> |
|
| 1533 | 1533 | <input type="text" id="find-posts-input" name="ps" value="" /> |
| 1534 | 1534 | <span class="spinner"></span> |
| 1535 | - <input type="button" id="find-posts-search" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /> |
|
| 1535 | + <input type="button" id="find-posts-search" value="<?php esc_attr_e('Search'); ?>" class="button" /> |
|
| 1536 | 1536 | <div class="clear"></div> |
| 1537 | 1537 | </div> |
| 1538 | 1538 | <div id="find-posts-response"></div> |
| 1539 | 1539 | </div> |
| 1540 | 1540 | <div class="find-box-buttons"> |
| 1541 | - <?php submit_button( __( 'Select' ), 'button-primary alignright', 'find-posts-submit', false ); ?> |
|
| 1541 | + <?php submit_button(__('Select'), 'button-primary alignright', 'find-posts-submit', false); ?> |
|
| 1542 | 1542 | <div class="clear"></div> |
| 1543 | 1543 | </div> |
| 1544 | 1544 | </div> |
@@ -1555,8 +1555,8 @@ discard block |
||
| 1555 | 1555 | */ |
| 1556 | 1556 | function the_post_password() { |
| 1557 | 1557 | $post = get_post(); |
| 1558 | - if ( isset( $post->post_password ) ) |
|
| 1559 | - echo esc_attr( $post->post_password ); |
|
| 1558 | + if (isset($post->post_password)) |
|
| 1559 | + echo esc_attr($post->post_password); |
|
| 1560 | 1560 | } |
| 1561 | 1561 | |
| 1562 | 1562 | /** |
@@ -1570,11 +1570,11 @@ discard block |
||
| 1570 | 1570 | * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. |
| 1571 | 1571 | * @return string The post title if set. |
| 1572 | 1572 | */ |
| 1573 | -function _draft_or_post_title( $post = 0 ) { |
|
| 1574 | - $title = get_the_title( $post ); |
|
| 1575 | - if ( empty( $title ) ) |
|
| 1576 | - $title = __( '(no title)' ); |
|
| 1577 | - return esc_html( $title ); |
|
| 1573 | +function _draft_or_post_title($post = 0) { |
|
| 1574 | + $title = get_the_title($post); |
|
| 1575 | + if (empty($title)) |
|
| 1576 | + $title = __('(no title)'); |
|
| 1577 | + return esc_html($title); |
|
| 1578 | 1578 | } |
| 1579 | 1579 | |
| 1580 | 1580 | /** |
@@ -1586,7 +1586,7 @@ discard block |
||
| 1586 | 1586 | * @since 2.7.0 |
| 1587 | 1587 | */ |
| 1588 | 1588 | function _admin_search_query() { |
| 1589 | - echo isset($_REQUEST['s']) ? esc_attr( wp_unslash( $_REQUEST['s'] ) ) : ''; |
|
| 1589 | + echo isset($_REQUEST['s']) ? esc_attr(wp_unslash($_REQUEST['s'])) : ''; |
|
| 1590 | 1590 | } |
| 1591 | 1591 | |
| 1592 | 1592 | /** |
@@ -1601,69 +1601,69 @@ discard block |
||
| 1601 | 1601 | * @param string $title Optional. Title of the Iframe page. Default empty. |
| 1602 | 1602 | * @param bool $deprecated Not used. |
| 1603 | 1603 | */ |
| 1604 | -function iframe_header( $title = '', $deprecated = false ) { |
|
| 1605 | - show_admin_bar( false ); |
|
| 1604 | +function iframe_header($title = '', $deprecated = false) { |
|
| 1605 | + show_admin_bar(false); |
|
| 1606 | 1606 | global $hook_suffix, $admin_body_class, $wp_locale; |
| 1607 | 1607 | $admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix); |
| 1608 | 1608 | |
| 1609 | 1609 | $current_screen = get_current_screen(); |
| 1610 | 1610 | |
| 1611 | - @header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) ); |
|
| 1611 | + @header('Content-Type: '.get_option('html_type').'; charset='.get_option('blog_charset')); |
|
| 1612 | 1612 | _wp_admin_html_begin(); |
| 1613 | 1613 | ?> |
| 1614 | 1614 | <title><?php bloginfo('name') ?> › <?php echo $title ?> — <?php _e('WordPress'); ?></title> |
| 1615 | 1615 | <?php |
| 1616 | -wp_enqueue_style( 'colors' ); |
|
| 1616 | +wp_enqueue_style('colors'); |
|
| 1617 | 1617 | ?> |
| 1618 | 1618 | <script type="text/javascript"> |
| 1619 | 1619 | 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();}}}; |
| 1620 | 1620 | function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();} |
| 1621 | -var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>', |
|
| 1621 | +var ajaxurl = '<?php echo admin_url('admin-ajax.php', 'relative'); ?>', |
|
| 1622 | 1622 | pagenow = '<?php echo $current_screen->id; ?>', |
| 1623 | 1623 | typenow = '<?php echo $current_screen->post_type; ?>', |
| 1624 | 1624 | adminpage = '<?php echo $admin_body_class; ?>', |
| 1625 | - thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>', |
|
| 1626 | - decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>', |
|
| 1625 | + thousandsSeparator = '<?php echo addslashes($wp_locale->number_format['thousands_sep']); ?>', |
|
| 1626 | + decimalPoint = '<?php echo addslashes($wp_locale->number_format['decimal_point']); ?>', |
|
| 1627 | 1627 | isRtl = <?php echo (int) is_rtl(); ?>; |
| 1628 | 1628 | </script> |
| 1629 | 1629 | <?php |
| 1630 | 1630 | /** This action is documented in wp-admin/admin-header.php */ |
| 1631 | -do_action( 'admin_enqueue_scripts', $hook_suffix ); |
|
| 1631 | +do_action('admin_enqueue_scripts', $hook_suffix); |
|
| 1632 | 1632 | |
| 1633 | 1633 | /** This action is documented in wp-admin/admin-header.php */ |
| 1634 | -do_action( "admin_print_styles-$hook_suffix" ); |
|
| 1634 | +do_action("admin_print_styles-$hook_suffix"); |
|
| 1635 | 1635 | |
| 1636 | 1636 | /** This action is documented in wp-admin/admin-header.php */ |
| 1637 | -do_action( 'admin_print_styles' ); |
|
| 1637 | +do_action('admin_print_styles'); |
|
| 1638 | 1638 | |
| 1639 | 1639 | /** This action is documented in wp-admin/admin-header.php */ |
| 1640 | -do_action( "admin_print_scripts-$hook_suffix" ); |
|
| 1640 | +do_action("admin_print_scripts-$hook_suffix"); |
|
| 1641 | 1641 | |
| 1642 | 1642 | /** This action is documented in wp-admin/admin-header.php */ |
| 1643 | -do_action( 'admin_print_scripts' ); |
|
| 1643 | +do_action('admin_print_scripts'); |
|
| 1644 | 1644 | |
| 1645 | 1645 | /** This action is documented in wp-admin/admin-header.php */ |
| 1646 | -do_action( "admin_head-$hook_suffix" ); |
|
| 1646 | +do_action("admin_head-$hook_suffix"); |
|
| 1647 | 1647 | |
| 1648 | 1648 | /** This action is documented in wp-admin/admin-header.php */ |
| 1649 | -do_action( 'admin_head' ); |
|
| 1649 | +do_action('admin_head'); |
|
| 1650 | 1650 | |
| 1651 | -$admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) ); |
|
| 1651 | +$admin_body_class .= ' locale-'.sanitize_html_class(strtolower(str_replace('_', '-', get_locale()))); |
|
| 1652 | 1652 | |
| 1653 | -if ( is_rtl() ) |
|
| 1653 | +if (is_rtl()) |
|
| 1654 | 1654 | $admin_body_class .= ' rtl'; |
| 1655 | 1655 | |
| 1656 | 1656 | ?> |
| 1657 | 1657 | </head> |
| 1658 | 1658 | <?php |
| 1659 | 1659 | /** This filter is documented in wp-admin/admin-header.php */ |
| 1660 | -$admin_body_classes = apply_filters( 'admin_body_class', '' ); |
|
| 1660 | +$admin_body_classes = apply_filters('admin_body_class', ''); |
|
| 1661 | 1661 | ?> |
| 1662 | 1662 | <body<?php |
| 1663 | 1663 | /** |
| 1664 | 1664 | * @global string $body_id |
| 1665 | 1665 | */ |
| 1666 | -if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?> class="wp-admin wp-core-ui no-js iframe <?php echo $admin_body_classes . ' ' . $admin_body_class; ?>"> |
|
| 1666 | +if (isset($GLOBALS['body_id'])) echo ' id="'.$GLOBALS['body_id'].'"'; ?> class="wp-admin wp-core-ui no-js iframe <?php echo $admin_body_classes.' '.$admin_body_class; ?>"> |
|
| 1667 | 1667 | <script type="text/javascript"> |
| 1668 | 1668 | (function(){ |
| 1669 | 1669 | var c = document.body.className; |
@@ -1689,10 +1689,10 @@ discard block |
||
| 1689 | 1689 | <div class="hidden"> |
| 1690 | 1690 | <?php |
| 1691 | 1691 | /** This action is documented in wp-admin/admin-footer.php */ |
| 1692 | - do_action( 'admin_footer', '' ); |
|
| 1692 | + do_action('admin_footer', ''); |
|
| 1693 | 1693 | |
| 1694 | 1694 | /** This action is documented in wp-admin/admin-footer.php */ |
| 1695 | - do_action( 'admin_print_footer_scripts' ); |
|
| 1695 | + do_action('admin_print_footer_scripts'); |
|
| 1696 | 1696 | ?> |
| 1697 | 1697 | </div> |
| 1698 | 1698 | <script type="text/javascript">if(typeof wpOnload=="function")wpOnload();</script> |
@@ -1707,33 +1707,33 @@ discard block |
||
| 1707 | 1707 | */ |
| 1708 | 1708 | function _post_states($post) { |
| 1709 | 1709 | $post_states = array(); |
| 1710 | - if ( isset( $_REQUEST['post_status'] ) ) |
|
| 1710 | + if (isset($_REQUEST['post_status'])) |
|
| 1711 | 1711 | $post_status = $_REQUEST['post_status']; |
| 1712 | 1712 | else |
| 1713 | 1713 | $post_status = ''; |
| 1714 | 1714 | |
| 1715 | - if ( !empty($post->post_password) ) |
|
| 1715 | + if ( ! empty($post->post_password)) |
|
| 1716 | 1716 | $post_states['protected'] = __('Password protected'); |
| 1717 | - if ( 'private' == $post->post_status && 'private' != $post_status ) |
|
| 1717 | + if ('private' == $post->post_status && 'private' != $post_status) |
|
| 1718 | 1718 | $post_states['private'] = __('Private'); |
| 1719 | - if ( 'draft' == $post->post_status && 'draft' != $post_status ) |
|
| 1719 | + if ('draft' == $post->post_status && 'draft' != $post_status) |
|
| 1720 | 1720 | $post_states['draft'] = __('Draft'); |
| 1721 | - if ( 'pending' == $post->post_status && 'pending' != $post_status ) |
|
| 1721 | + if ('pending' == $post->post_status && 'pending' != $post_status) |
|
| 1722 | 1722 | /* translators: post state */ |
| 1723 | 1723 | $post_states['pending'] = _x('Pending', 'post state'); |
| 1724 | - if ( is_sticky($post->ID) ) |
|
| 1724 | + if (is_sticky($post->ID)) |
|
| 1725 | 1725 | $post_states['sticky'] = __('Sticky'); |
| 1726 | 1726 | |
| 1727 | - if ( 'future' === $post->post_status ) { |
|
| 1728 | - $post_states['scheduled'] = __( 'Scheduled' ); |
|
| 1727 | + if ('future' === $post->post_status) { |
|
| 1728 | + $post_states['scheduled'] = __('Scheduled'); |
|
| 1729 | 1729 | } |
| 1730 | 1730 | |
| 1731 | - if ( get_option( 'page_on_front' ) == $post->ID ) { |
|
| 1732 | - $post_states['page_on_front'] = __( 'Front Page' ); |
|
| 1731 | + if (get_option('page_on_front') == $post->ID) { |
|
| 1732 | + $post_states['page_on_front'] = __('Front Page'); |
|
| 1733 | 1733 | } |
| 1734 | 1734 | |
| 1735 | - if ( get_option( 'page_for_posts' ) == $post->ID ) { |
|
| 1736 | - $post_states['page_for_posts'] = __( 'Posts Page' ); |
|
| 1735 | + if (get_option('page_for_posts') == $post->ID) { |
|
| 1736 | + $post_states['page_for_posts'] = __('Posts Page'); |
|
| 1737 | 1737 | } |
| 1738 | 1738 | |
| 1739 | 1739 | /** |
@@ -1744,15 +1744,15 @@ discard block |
||
| 1744 | 1744 | * @param array $post_states An array of post display states. |
| 1745 | 1745 | * @param int $post The post ID. |
| 1746 | 1746 | */ |
| 1747 | - $post_states = apply_filters( 'display_post_states', $post_states, $post ); |
|
| 1747 | + $post_states = apply_filters('display_post_states', $post_states, $post); |
|
| 1748 | 1748 | |
| 1749 | - if ( ! empty($post_states) ) { |
|
| 1749 | + if ( ! empty($post_states)) { |
|
| 1750 | 1750 | $state_count = count($post_states); |
| 1751 | 1751 | $i = 0; |
| 1752 | 1752 | echo ' - '; |
| 1753 | - foreach ( $post_states as $state ) { |
|
| 1753 | + foreach ($post_states as $state) { |
|
| 1754 | 1754 | ++$i; |
| 1755 | - ( $i == $state_count ) ? $sep = '' : $sep = ', '; |
|
| 1755 | + ($i == $state_count) ? $sep = '' : $sep = ', '; |
|
| 1756 | 1756 | echo "<span class='post-state'>$state$sep</span>"; |
| 1757 | 1757 | } |
| 1758 | 1758 | } |
@@ -1763,24 +1763,24 @@ discard block |
||
| 1763 | 1763 | * |
| 1764 | 1764 | * @param WP_Post $post |
| 1765 | 1765 | */ |
| 1766 | -function _media_states( $post ) { |
|
| 1766 | +function _media_states($post) { |
|
| 1767 | 1767 | $media_states = array(); |
| 1768 | 1768 | $stylesheet = get_option('stylesheet'); |
| 1769 | 1769 | |
| 1770 | - if ( current_theme_supports( 'custom-header') ) { |
|
| 1771 | - $meta_header = get_post_meta($post->ID, '_wp_attachment_is_custom_header', true ); |
|
| 1772 | - if ( ! empty( $meta_header ) && $meta_header == $stylesheet ) |
|
| 1773 | - $media_states[] = __( 'Header Image' ); |
|
| 1770 | + if (current_theme_supports('custom-header')) { |
|
| 1771 | + $meta_header = get_post_meta($post->ID, '_wp_attachment_is_custom_header', true); |
|
| 1772 | + if ( ! empty($meta_header) && $meta_header == $stylesheet) |
|
| 1773 | + $media_states[] = __('Header Image'); |
|
| 1774 | 1774 | } |
| 1775 | 1775 | |
| 1776 | - if ( current_theme_supports( 'custom-background') ) { |
|
| 1777 | - $meta_background = get_post_meta($post->ID, '_wp_attachment_is_custom_background', true ); |
|
| 1778 | - if ( ! empty( $meta_background ) && $meta_background == $stylesheet ) |
|
| 1779 | - $media_states[] = __( 'Background Image' ); |
|
| 1776 | + if (current_theme_supports('custom-background')) { |
|
| 1777 | + $meta_background = get_post_meta($post->ID, '_wp_attachment_is_custom_background', true); |
|
| 1778 | + if ( ! empty($meta_background) && $meta_background == $stylesheet) |
|
| 1779 | + $media_states[] = __('Background Image'); |
|
| 1780 | 1780 | } |
| 1781 | 1781 | |
| 1782 | - if ( $post->ID == get_option( 'site_icon' ) ) { |
|
| 1783 | - $media_states[] = __( 'Site Icon' ); |
|
| 1782 | + if ($post->ID == get_option('site_icon')) { |
|
| 1783 | + $media_states[] = __('Site Icon'); |
|
| 1784 | 1784 | } |
| 1785 | 1785 | |
| 1786 | 1786 | /** |
@@ -1791,15 +1791,15 @@ discard block |
||
| 1791 | 1791 | * @param array $media_states An array of media states. Default 'Header Image', |
| 1792 | 1792 | * 'Background Image', 'Site Icon'. |
| 1793 | 1793 | */ |
| 1794 | - $media_states = apply_filters( 'display_media_states', $media_states ); |
|
| 1794 | + $media_states = apply_filters('display_media_states', $media_states); |
|
| 1795 | 1795 | |
| 1796 | - if ( ! empty( $media_states ) ) { |
|
| 1797 | - $state_count = count( $media_states ); |
|
| 1796 | + if ( ! empty($media_states)) { |
|
| 1797 | + $state_count = count($media_states); |
|
| 1798 | 1798 | $i = 0; |
| 1799 | 1799 | echo ' - '; |
| 1800 | - foreach ( $media_states as $state ) { |
|
| 1800 | + foreach ($media_states as $state) { |
|
| 1801 | 1801 | ++$i; |
| 1802 | - ( $i == $state_count ) ? $sep = '' : $sep = ', '; |
|
| 1802 | + ($i == $state_count) ? $sep = '' : $sep = ', '; |
|
| 1803 | 1803 | echo "<span class='post-state'>$state$sep</span>"; |
| 1804 | 1804 | } |
| 1805 | 1805 | } |
@@ -1890,8 +1890,8 @@ discard block |
||
| 1890 | 1890 | * as a string such as 'tabindex="1"', though the array format is |
| 1891 | 1891 | * preferred. Default null. |
| 1892 | 1892 | */ |
| 1893 | -function submit_button( $text = null, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = null ) { |
|
| 1894 | - echo get_submit_button( $text, $type, $name, $wrap, $other_attributes ); |
|
| 1893 | +function submit_button($text = null, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = null) { |
|
| 1894 | + echo get_submit_button($text, $type, $name, $wrap, $other_attributes); |
|
| 1895 | 1895 | } |
| 1896 | 1896 | |
| 1897 | 1897 | /** |
@@ -1915,49 +1915,49 @@ discard block |
||
| 1915 | 1915 | * Default empty. |
| 1916 | 1916 | * @return string Submit button HTML. |
| 1917 | 1917 | */ |
| 1918 | -function get_submit_button( $text = '', $type = 'primary large', $name = 'submit', $wrap = true, $other_attributes = '' ) { |
|
| 1919 | - if ( ! is_array( $type ) ) |
|
| 1920 | - $type = explode( ' ', $type ); |
|
| 1921 | - |
|
| 1922 | - $button_shorthand = array( 'primary', 'small', 'large' ); |
|
| 1923 | - $classes = array( 'button' ); |
|
| 1924 | - foreach ( $type as $t ) { |
|
| 1925 | - if ( 'secondary' === $t || 'button-secondary' === $t ) |
|
| 1918 | +function get_submit_button($text = '', $type = 'primary large', $name = 'submit', $wrap = true, $other_attributes = '') { |
|
| 1919 | + if ( ! is_array($type)) |
|
| 1920 | + $type = explode(' ', $type); |
|
| 1921 | + |
|
| 1922 | + $button_shorthand = array('primary', 'small', 'large'); |
|
| 1923 | + $classes = array('button'); |
|
| 1924 | + foreach ($type as $t) { |
|
| 1925 | + if ('secondary' === $t || 'button-secondary' === $t) |
|
| 1926 | 1926 | continue; |
| 1927 | - $classes[] = in_array( $t, $button_shorthand ) ? 'button-' . $t : $t; |
|
| 1927 | + $classes[] = in_array($t, $button_shorthand) ? 'button-'.$t : $t; |
|
| 1928 | 1928 | } |
| 1929 | - $class = implode( ' ', array_unique( $classes ) ); |
|
| 1929 | + $class = implode(' ', array_unique($classes)); |
|
| 1930 | 1930 | |
| 1931 | - if ( 'delete' === $type ) |
|
| 1931 | + if ('delete' === $type) |
|
| 1932 | 1932 | $class = 'button-secondary delete'; |
| 1933 | 1933 | |
| 1934 | - $text = $text ? $text : __( 'Save Changes' ); |
|
| 1934 | + $text = $text ? $text : __('Save Changes'); |
|
| 1935 | 1935 | |
| 1936 | 1936 | // Default the id attribute to $name unless an id was specifically provided in $other_attributes |
| 1937 | 1937 | $id = $name; |
| 1938 | - if ( is_array( $other_attributes ) && isset( $other_attributes['id'] ) ) { |
|
| 1938 | + if (is_array($other_attributes) && isset($other_attributes['id'])) { |
|
| 1939 | 1939 | $id = $other_attributes['id']; |
| 1940 | - unset( $other_attributes['id'] ); |
|
| 1940 | + unset($other_attributes['id']); |
|
| 1941 | 1941 | } |
| 1942 | 1942 | |
| 1943 | 1943 | $attributes = ''; |
| 1944 | - if ( is_array( $other_attributes ) ) { |
|
| 1945 | - foreach ( $other_attributes as $attribute => $value ) { |
|
| 1946 | - $attributes .= $attribute . '="' . esc_attr( $value ) . '" '; // Trailing space is important |
|
| 1944 | + if (is_array($other_attributes)) { |
|
| 1945 | + foreach ($other_attributes as $attribute => $value) { |
|
| 1946 | + $attributes .= $attribute.'="'.esc_attr($value).'" '; // Trailing space is important |
|
| 1947 | 1947 | } |
| 1948 | - } elseif ( ! empty( $other_attributes ) ) { // Attributes provided as a string |
|
| 1948 | + } elseif ( ! empty($other_attributes)) { // Attributes provided as a string |
|
| 1949 | 1949 | $attributes = $other_attributes; |
| 1950 | 1950 | } |
| 1951 | 1951 | |
| 1952 | 1952 | // Don't output empty name and id attributes. |
| 1953 | - $name_attr = $name ? ' name="' . esc_attr( $name ) . '"' : ''; |
|
| 1954 | - $id_attr = $id ? ' id="' . esc_attr( $id ) . '"' : ''; |
|
| 1953 | + $name_attr = $name ? ' name="'.esc_attr($name).'"' : ''; |
|
| 1954 | + $id_attr = $id ? ' id="'.esc_attr($id).'"' : ''; |
|
| 1955 | 1955 | |
| 1956 | - $button = '<input type="submit"' . $name_attr . $id_attr . ' class="' . esc_attr( $class ); |
|
| 1957 | - $button .= '" value="' . esc_attr( $text ) . '" ' . $attributes . ' />'; |
|
| 1956 | + $button = '<input type="submit"'.$name_attr.$id_attr.' class="'.esc_attr($class); |
|
| 1957 | + $button .= '" value="'.esc_attr($text).'" '.$attributes.' />'; |
|
| 1958 | 1958 | |
| 1959 | - if ( $wrap ) { |
|
| 1960 | - $button = '<p class="submit">' . $button . '</p>'; |
|
| 1959 | + if ($wrap) { |
|
| 1960 | + $button = '<p class="submit">'.$button.'</p>'; |
|
| 1961 | 1961 | } |
| 1962 | 1962 | |
| 1963 | 1963 | return $button; |
@@ -1970,9 +1970,9 @@ discard block |
||
| 1970 | 1970 | function _wp_admin_html_begin() { |
| 1971 | 1971 | global $is_IE; |
| 1972 | 1972 | |
| 1973 | - $admin_html_class = ( is_admin_bar_showing() ) ? 'wp-toolbar' : ''; |
|
| 1973 | + $admin_html_class = (is_admin_bar_showing()) ? 'wp-toolbar' : ''; |
|
| 1974 | 1974 | |
| 1975 | - if ( $is_IE ) |
|
| 1975 | + if ($is_IE) |
|
| 1976 | 1976 | @header('X-UA-Compatible: IE=edge'); |
| 1977 | 1977 | |
| 1978 | 1978 | ?> |
@@ -1984,13 +1984,13 @@ discard block |
||
| 1984 | 1984 | * |
| 1985 | 1985 | * @since 2.2.0 |
| 1986 | 1986 | */ |
| 1987 | - do_action( 'admin_xml_ns' ); |
|
| 1987 | + do_action('admin_xml_ns'); |
|
| 1988 | 1988 | ?> <?php language_attributes(); ?>> |
| 1989 | 1989 | <![endif]--> |
| 1990 | 1990 | <!--[if !(IE 8) ]><!--> |
| 1991 | 1991 | <html xmlns="http://www.w3.org/1999/xhtml" class="<?php echo $admin_html_class; ?>" <?php |
| 1992 | 1992 | /** This action is documented in wp-admin/includes/template.php */ |
| 1993 | - do_action( 'admin_xml_ns' ); |
|
| 1993 | + do_action('admin_xml_ns'); |
|
| 1994 | 1994 | ?> <?php language_attributes(); ?>> |
| 1995 | 1995 | <!--<![endif]--> |
| 1996 | 1996 | <head> |
@@ -2014,7 +2014,7 @@ discard block |
||
| 2014 | 2014 | * |
| 2015 | 2015 | * @param string $hook_suffix The current admin page. |
| 2016 | 2016 | */ |
| 2017 | - public static function enqueue_scripts( $hook_suffix ) { |
|
| 2017 | + public static function enqueue_scripts($hook_suffix) { |
|
| 2018 | 2018 | /* |
| 2019 | 2019 | * Register feature pointers |
| 2020 | 2020 | * |
@@ -2033,10 +2033,10 @@ discard block |
||
| 2033 | 2033 | ); |
| 2034 | 2034 | |
| 2035 | 2035 | // Check if screen related pointer is registered |
| 2036 | - if ( empty( $registered_pointers[ $hook_suffix ] ) ) |
|
| 2036 | + if (empty($registered_pointers[$hook_suffix])) |
|
| 2037 | 2037 | return; |
| 2038 | 2038 | |
| 2039 | - $pointers = (array) $registered_pointers[ $hook_suffix ]; |
|
| 2039 | + $pointers = (array) $registered_pointers[$hook_suffix]; |
|
| 2040 | 2040 | |
| 2041 | 2041 | /* |
| 2042 | 2042 | * Specify required capabilities for feature pointers |
@@ -2056,28 +2056,28 @@ discard block |
||
| 2056 | 2056 | ); |
| 2057 | 2057 | |
| 2058 | 2058 | // Get dismissed pointers |
| 2059 | - $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ); |
|
| 2059 | + $dismissed = explode(',', (string) get_user_meta(get_current_user_id(), 'dismissed_wp_pointers', true)); |
|
| 2060 | 2060 | |
| 2061 | 2061 | $got_pointers = false; |
| 2062 | - foreach ( array_diff( $pointers, $dismissed ) as $pointer ) { |
|
| 2063 | - if ( isset( $caps_required[ $pointer ] ) ) { |
|
| 2064 | - foreach ( $caps_required[ $pointer ] as $cap ) { |
|
| 2065 | - if ( ! current_user_can( $cap ) ) |
|
| 2062 | + foreach (array_diff($pointers, $dismissed) as $pointer) { |
|
| 2063 | + if (isset($caps_required[$pointer])) { |
|
| 2064 | + foreach ($caps_required[$pointer] as $cap) { |
|
| 2065 | + if ( ! current_user_can($cap)) |
|
| 2066 | 2066 | continue 2; |
| 2067 | 2067 | } |
| 2068 | 2068 | } |
| 2069 | 2069 | |
| 2070 | 2070 | // Bind pointer print function |
| 2071 | - add_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_' . $pointer ) ); |
|
| 2071 | + add_action('admin_print_footer_scripts', array('WP_Internal_Pointers', 'pointer_'.$pointer)); |
|
| 2072 | 2072 | $got_pointers = true; |
| 2073 | 2073 | } |
| 2074 | 2074 | |
| 2075 | - if ( ! $got_pointers ) |
|
| 2075 | + if ( ! $got_pointers) |
|
| 2076 | 2076 | return; |
| 2077 | 2077 | |
| 2078 | 2078 | // Add pointers script and style to queue |
| 2079 | - wp_enqueue_style( 'wp-pointer' ); |
|
| 2080 | - wp_enqueue_script( 'wp-pointer' ); |
|
| 2079 | + wp_enqueue_style('wp-pointer'); |
|
| 2080 | + wp_enqueue_script('wp-pointer'); |
|
| 2081 | 2081 | } |
| 2082 | 2082 | |
| 2083 | 2083 | /** |
@@ -2091,14 +2091,14 @@ discard block |
||
| 2091 | 2091 | * @param string $selector The HTML elements, on which the pointer should be attached. |
| 2092 | 2092 | * @param array $args Arguments to be passed to the pointer JS (see wp-pointer.js). |
| 2093 | 2093 | */ |
| 2094 | - private static function print_js( $pointer_id, $selector, $args ) { |
|
| 2095 | - if ( empty( $pointer_id ) || empty( $selector ) || empty( $args ) || empty( $args['content'] ) ) |
|
| 2094 | + private static function print_js($pointer_id, $selector, $args) { |
|
| 2095 | + if (empty($pointer_id) || empty($selector) || empty($args) || empty($args['content'])) |
|
| 2096 | 2096 | return; |
| 2097 | 2097 | |
| 2098 | 2098 | ?> |
| 2099 | 2099 | <script type="text/javascript"> |
| 2100 | 2100 | (function($){ |
| 2101 | - var options = <?php echo wp_json_encode( $args ); ?>, setup; |
|
| 2101 | + var options = <?php echo wp_json_encode($args); ?>, setup; |
|
| 2102 | 2102 | |
| 2103 | 2103 | if ( ! options ) |
| 2104 | 2104 | return; |
@@ -2146,8 +2146,8 @@ discard block |
||
| 2146 | 2146 | * |
| 2147 | 2147 | * @param int $user_id User ID. |
| 2148 | 2148 | */ |
| 2149 | - public static function dismiss_pointers_for_new_users( $user_id ) { |
|
| 2150 | - add_user_meta( $user_id, 'dismissed_wp_pointers', '' ); |
|
| 2149 | + public static function dismiss_pointers_for_new_users($user_id) { |
|
| 2150 | + add_user_meta($user_id, 'dismissed_wp_pointers', ''); |
|
| 2151 | 2151 | } |
| 2152 | 2152 | } |
| 2153 | 2153 | |
@@ -2159,13 +2159,13 @@ discard block |
||
| 2159 | 2159 | * @param string $hook_name The hook name (also known as the hook suffix) used to determine the screen. |
| 2160 | 2160 | * @return WP_Screen Screen object. |
| 2161 | 2161 | */ |
| 2162 | -function convert_to_screen( $hook_name ) { |
|
| 2163 | - if ( ! class_exists( 'WP_Screen' ) ) { |
|
| 2164 | - _doing_it_wrong( 'convert_to_screen(), add_meta_box()', __( "Likely direct inclusion of wp-admin/includes/template.php in order to use add_meta_box(). This is very wrong. Hook the add_meta_box() call into the add_meta_boxes action instead." ), '3.3' ); |
|
| 2165 | - return (object) array( 'id' => '_invalid', 'base' => '_are_belong_to_us' ); |
|
| 2162 | +function convert_to_screen($hook_name) { |
|
| 2163 | + if ( ! class_exists('WP_Screen')) { |
|
| 2164 | + _doing_it_wrong('convert_to_screen(), add_meta_box()', __("Likely direct inclusion of wp-admin/includes/template.php in order to use add_meta_box(). This is very wrong. Hook the add_meta_box() call into the add_meta_boxes action instead."), '3.3'); |
|
| 2165 | + return (object) array('id' => '_invalid', 'base' => '_are_belong_to_us'); |
|
| 2166 | 2166 | } |
| 2167 | 2167 | |
| 2168 | - return WP_Screen::get( $hook_name ); |
|
| 2168 | + return WP_Screen::get($hook_name); |
|
| 2169 | 2169 | } |
| 2170 | 2170 | |
| 2171 | 2171 | /** |
@@ -2207,41 +2207,41 @@ discard block |
||
| 2207 | 2207 | * @type int $number The number of ratings that makes up this rating. Default 0. |
| 2208 | 2208 | * } |
| 2209 | 2209 | */ |
| 2210 | -function wp_star_rating( $args = array() ) { |
|
| 2210 | +function wp_star_rating($args = array()) { |
|
| 2211 | 2211 | $defaults = array( |
| 2212 | 2212 | 'rating' => 0, |
| 2213 | 2213 | 'type' => 'rating', |
| 2214 | 2214 | 'number' => 0, |
| 2215 | 2215 | ); |
| 2216 | - $r = wp_parse_args( $args, $defaults ); |
|
| 2216 | + $r = wp_parse_args($args, $defaults); |
|
| 2217 | 2217 | |
| 2218 | 2218 | // Non-english decimal places when the $rating is coming from a string |
| 2219 | - $rating = str_replace( ',', '.', $r['rating'] ); |
|
| 2219 | + $rating = str_replace(',', '.', $r['rating']); |
|
| 2220 | 2220 | |
| 2221 | 2221 | // Convert Percentage to star rating, 0..5 in .5 increments |
| 2222 | - if ( 'percent' == $r['type'] ) { |
|
| 2223 | - $rating = round( $rating / 10, 0 ) / 2; |
|
| 2222 | + if ('percent' == $r['type']) { |
|
| 2223 | + $rating = round($rating / 10, 0) / 2; |
|
| 2224 | 2224 | } |
| 2225 | 2225 | |
| 2226 | 2226 | // Calculate the number of each type of star needed |
| 2227 | - $full_stars = floor( $rating ); |
|
| 2228 | - $half_stars = ceil( $rating - $full_stars ); |
|
| 2227 | + $full_stars = floor($rating); |
|
| 2228 | + $half_stars = ceil($rating - $full_stars); |
|
| 2229 | 2229 | $empty_stars = 5 - $full_stars - $half_stars; |
| 2230 | 2230 | |
| 2231 | - if ( $r['number'] ) { |
|
| 2231 | + if ($r['number']) { |
|
| 2232 | 2232 | /* translators: 1: The rating, 2: The number of ratings */ |
| 2233 | - $format = _n( '%1$s rating based on %2$s rating', '%1$s rating based on %2$s ratings', $r['number'] ); |
|
| 2234 | - $title = sprintf( $format, number_format_i18n( $rating, 1 ), number_format_i18n( $r['number'] ) ); |
|
| 2233 | + $format = _n('%1$s rating based on %2$s rating', '%1$s rating based on %2$s ratings', $r['number']); |
|
| 2234 | + $title = sprintf($format, number_format_i18n($rating, 1), number_format_i18n($r['number'])); |
|
| 2235 | 2235 | } else { |
| 2236 | 2236 | /* translators: 1: The rating */ |
| 2237 | - $title = sprintf( __( '%s rating' ), number_format_i18n( $rating, 1 ) ); |
|
| 2237 | + $title = sprintf(__('%s rating'), number_format_i18n($rating, 1)); |
|
| 2238 | 2238 | } |
| 2239 | 2239 | |
| 2240 | - echo '<div class="star-rating" title="' . esc_attr( $title ) . '">'; |
|
| 2241 | - echo '<span class="screen-reader-text">' . $title . '</span>'; |
|
| 2242 | - echo str_repeat( '<div class="star star-full"></div>', $full_stars ); |
|
| 2243 | - echo str_repeat( '<div class="star star-half"></div>', $half_stars ); |
|
| 2244 | - echo str_repeat( '<div class="star star-empty"></div>', $empty_stars); |
|
| 2240 | + echo '<div class="star-rating" title="'.esc_attr($title).'">'; |
|
| 2241 | + echo '<span class="screen-reader-text">'.$title.'</span>'; |
|
| 2242 | + echo str_repeat('<div class="star star-full"></div>', $full_stars); |
|
| 2243 | + echo str_repeat('<div class="star star-half"></div>', $half_stars); |
|
| 2244 | + echo str_repeat('<div class="star star-empty"></div>', $empty_stars); |
|
| 2245 | 2245 | echo '</div>'; |
| 2246 | 2246 | } |
| 2247 | 2247 | |
@@ -2252,5 +2252,5 @@ discard block |
||
| 2252 | 2252 | * @since 4.2.0 |
| 2253 | 2253 | */ |
| 2254 | 2254 | function _wp_posts_page_notice() { |
| 2255 | - echo '<div class="notice notice-warning inline"><p>' . __( 'You are currently editing the page that shows your latest posts.' ) . '</p></div>'; |
|
| 2255 | + echo '<div class="notice notice-warning inline"><p>'.__('You are currently editing the page that shows your latest posts.').'</p></div>'; |
|
| 2256 | 2256 | } |
@@ -289,10 +289,11 @@ discard block |
||
| 289 | 289 | function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) { |
| 290 | 290 | $post = get_post(); |
| 291 | 291 | |
| 292 | - if ( $post && $post->ID ) |
|
| 293 | - $checked_terms = wp_get_object_terms($post->ID, $taxonomy, array('fields'=>'ids')); |
|
| 294 | - else |
|
| 295 | - $checked_terms = array(); |
|
| 292 | + if ( $post && $post->ID ) { |
|
| 293 | + $checked_terms = wp_get_object_terms($post->ID, $taxonomy, array('fields'=>'ids')); |
|
| 294 | + } else { |
|
| 295 | + $checked_terms = array(); |
|
| 296 | + } |
|
| 296 | 297 | |
| 297 | 298 | $terms = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) ); |
| 298 | 299 | |
@@ -301,8 +302,10 @@ discard block |
||
| 301 | 302 | $popular_ids = array(); |
| 302 | 303 | foreach ( (array) $terms as $term ) { |
| 303 | 304 | $popular_ids[] = $term->term_id; |
| 304 | - if ( !$echo ) // hack for AJAX use |
|
| 305 | + if ( !$echo ) { |
|
| 306 | + // hack for AJAX use |
|
| 305 | 307 | continue; |
| 308 | + } |
|
| 306 | 309 | $id = "popular-$taxonomy-$term->term_id"; |
| 307 | 310 | $checked = in_array( $term->term_id, $checked_terms ) ? 'checked="checked"' : ''; |
| 308 | 311 | ?> |
@@ -346,8 +349,9 @@ discard block |
||
| 346 | 349 | |
| 347 | 350 | $categories = get_terms( 'link_category', array( 'orderby' => 'name', 'hide_empty' => 0 ) ); |
| 348 | 351 | |
| 349 | - if ( empty( $categories ) ) |
|
| 350 | - return; |
|
| 352 | + if ( empty( $categories ) ) { |
|
| 353 | + return; |
|
| 354 | + } |
|
| 351 | 355 | |
| 352 | 356 | foreach ( $categories as $category ) { |
| 353 | 357 | $cat_id = $category->term_id; |
@@ -368,8 +372,9 @@ discard block |
||
| 368 | 372 | */ |
| 369 | 373 | function get_inline_data($post) { |
| 370 | 374 | $post_type_object = get_post_type_object($post->post_type); |
| 371 | - if ( ! current_user_can( 'edit_post', $post->ID ) ) |
|
| 372 | - return; |
|
| 375 | + if ( ! current_user_can( 'edit_post', $post->ID ) ) { |
|
| 376 | + return; |
|
| 377 | + } |
|
| 373 | 378 | |
| 374 | 379 | $title = esc_textarea( trim( $post->post_title ) ); |
| 375 | 380 | |
@@ -390,14 +395,17 @@ discard block |
||
| 390 | 395 | <div class="ss">' . mysql2date( 's', $post->post_date, false ) . '</div> |
| 391 | 396 | <div class="post_password">' . esc_html( $post->post_password ) . '</div>'; |
| 392 | 397 | |
| 393 | - if ( $post_type_object->hierarchical ) |
|
| 394 | - echo '<div class="post_parent">' . $post->post_parent . '</div>'; |
|
| 398 | + if ( $post_type_object->hierarchical ) { |
|
| 399 | + echo '<div class="post_parent">' . $post->post_parent . '</div>'; |
|
| 400 | + } |
|
| 395 | 401 | |
| 396 | - if ( $post->post_type == 'page' ) |
|
| 397 | - echo '<div class="page_template">' . esc_html( get_post_meta( $post->ID, '_wp_page_template', true ) ) . '</div>'; |
|
| 402 | + if ( $post->post_type == 'page' ) { |
|
| 403 | + echo '<div class="page_template">' . esc_html( get_post_meta( $post->ID, '_wp_page_template', true ) ) . '</div>'; |
|
| 404 | + } |
|
| 398 | 405 | |
| 399 | - if ( post_type_supports( $post->post_type, 'page-attributes' ) ) |
|
| 400 | - echo '<div class="menu_order">' . $post->menu_order . '</div>'; |
|
| 406 | + if ( post_type_supports( $post->post_type, 'page-attributes' ) ) { |
|
| 407 | + echo '<div class="menu_order">' . $post->menu_order . '</div>'; |
|
| 408 | + } |
|
| 401 | 409 | |
| 402 | 410 | $taxonomy_names = get_object_taxonomies( $post->post_type ); |
| 403 | 411 | foreach ( $taxonomy_names as $taxonomy_name) { |
@@ -422,11 +430,13 @@ discard block |
||
| 422 | 430 | } |
| 423 | 431 | } |
| 424 | 432 | |
| 425 | - if ( !$post_type_object->hierarchical ) |
|
| 426 | - echo '<div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>'; |
|
| 433 | + if ( !$post_type_object->hierarchical ) { |
|
| 434 | + echo '<div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>'; |
|
| 435 | + } |
|
| 427 | 436 | |
| 428 | - if ( post_type_supports( $post->post_type, 'post-formats' ) ) |
|
| 429 | - echo '<div class="post_format">' . esc_html( get_post_format( $post->ID ) ) . '</div>'; |
|
| 437 | + if ( post_type_supports( $post->post_type, 'post-formats' ) ) { |
|
| 438 | + echo '<div class="post_format">' . esc_html( get_post_format( $post->ID ) ) . '</div>'; |
|
| 439 | + } |
|
| 430 | 440 | |
| 431 | 441 | echo '</div>'; |
| 432 | 442 | } |
@@ -479,9 +489,12 @@ discard block |
||
| 479 | 489 | <form method="get"> |
| 480 | 490 | <?php if ( $table_row ) : ?> |
| 481 | 491 | <table style="display:none;"><tbody id="com-reply"><tr id="replyrow" style="display:none;"><td colspan="<?php echo $wp_list_table->get_column_count(); ?>" class="colspanchange"> |
| 482 | -<?php else : ?> |
|
| 492 | +<?php else { |
|
| 493 | + : ?> |
|
| 483 | 494 | <div id="com-reply" style="display:none;"><div id="replyrow" style="display:none;"> |
| 484 | -<?php endif; ?> |
|
| 495 | +<?php endif; |
|
| 496 | +} |
|
| 497 | +?> |
|
| 485 | 498 | <div id="replyhead" style="display:none;"><h5><?php _e( 'Reply to Comment' ); ?></h5></div> |
| 486 | 499 | <div id="addhead" style="display:none;"><h5><?php _e('Add new Comment'); ?></h5></div> |
| 487 | 500 | <div id="edithead" style="display:none;"> |
@@ -529,14 +542,18 @@ discard block |
||
| 529 | 542 | <input type="hidden" name="mode" id="mode" value="<?php echo esc_attr($mode); ?>" /> |
| 530 | 543 | <?php |
| 531 | 544 | wp_nonce_field( 'replyto-comment', '_ajax_nonce-replyto-comment', false ); |
| 532 | - if ( current_user_can( 'unfiltered_html' ) ) |
|
| 533 | - wp_nonce_field( 'unfiltered-html-comment', '_wp_unfiltered_html_comment', false ); |
|
| 545 | + if ( current_user_can( 'unfiltered_html' ) ) { |
|
| 546 | + wp_nonce_field( 'unfiltered-html-comment', '_wp_unfiltered_html_comment', false ); |
|
| 547 | + } |
|
| 534 | 548 | ?> |
| 535 | 549 | <?php if ( $table_row ) : ?> |
| 536 | 550 | </td></tr></tbody></table> |
| 537 | -<?php else : ?> |
|
| 551 | +<?php else { |
|
| 552 | + : ?> |
|
| 538 | 553 | </div></div> |
| 539 | -<?php endif; ?> |
|
| 554 | +<?php endif; |
|
| 555 | +} |
|
| 556 | +?> |
|
| 540 | 557 | </form> |
| 541 | 558 | <?php |
| 542 | 559 | } |
@@ -592,9 +609,10 @@ discard block |
||
| 592 | 609 | </thead> |
| 593 | 610 | <tbody id='the-list' data-wp-lists='list:meta'> |
| 594 | 611 | <?php |
| 595 | - foreach ( $meta as $entry ) |
|
| 596 | - echo _list_meta_row( $entry, $count ); |
|
| 597 | -?> |
|
| 612 | + foreach ( $meta as $entry ) { |
|
| 613 | + echo _list_meta_row( $entry, $count ); |
|
| 614 | + } |
|
| 615 | + ?> |
|
| 598 | 616 | </tbody> |
| 599 | 617 | </table> |
| 600 | 618 | <?php |
@@ -614,11 +632,13 @@ discard block |
||
| 614 | 632 | function _list_meta_row( $entry, &$count ) { |
| 615 | 633 | static $update_nonce = ''; |
| 616 | 634 | |
| 617 | - if ( is_protected_meta( $entry['meta_key'], 'post' ) ) |
|
| 618 | - return ''; |
|
| 635 | + if ( is_protected_meta( $entry['meta_key'], 'post' ) ) { |
|
| 636 | + return ''; |
|
| 637 | + } |
|
| 619 | 638 | |
| 620 | - if ( ! $update_nonce ) |
|
| 621 | - $update_nonce = wp_create_nonce( 'add-meta' ); |
|
| 639 | + if ( ! $update_nonce ) { |
|
| 640 | + $update_nonce = wp_create_nonce( 'add-meta' ); |
|
| 641 | + } |
|
| 622 | 642 | |
| 623 | 643 | $r = ''; |
| 624 | 644 | ++ $count; |
@@ -709,8 +729,9 @@ discard block |
||
| 709 | 729 | <?php |
| 710 | 730 | |
| 711 | 731 | foreach ( $keys as $key ) { |
| 712 | - if ( is_protected_meta( $key, 'post' ) || ! current_user_can( 'add_post_meta', $post->ID, $key ) ) |
|
| 713 | - continue; |
|
| 732 | + if ( is_protected_meta( $key, 'post' ) || ! current_user_can( 'add_post_meta', $post->ID, $key ) ) { |
|
| 733 | + continue; |
|
| 734 | + } |
|
| 714 | 735 | echo "\n<option value='" . esc_attr($key) . "'>" . esc_html($key) . "</option>"; |
| 715 | 736 | } |
| 716 | 737 | ?> |
@@ -756,12 +777,14 @@ discard block |
||
| 756 | 777 | global $wp_locale, $comment; |
| 757 | 778 | $post = get_post(); |
| 758 | 779 | |
| 759 | - if ( $for_post ) |
|
| 760 | - $edit = ! ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) ); |
|
| 780 | + if ( $for_post ) { |
|
| 781 | + $edit = ! ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) ); |
|
| 782 | + } |
|
| 761 | 783 | |
| 762 | 784 | $tab_index_attribute = ''; |
| 763 | - if ( (int) $tab_index > 0 ) |
|
| 764 | - $tab_index_attribute = " tabindex=\"$tab_index\""; |
|
| 785 | + if ( (int) $tab_index > 0 ) { |
|
| 786 | + $tab_index_attribute = " tabindex=\"$tab_index\""; |
|
| 787 | + } |
|
| 765 | 788 | |
| 766 | 789 | // todo: Remove this? |
| 767 | 790 | // echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />'; |
@@ -802,7 +825,9 @@ discard block |
||
| 802 | 825 | |
| 803 | 826 | echo '</div><input type="hidden" id="ss" name="ss" value="' . $ss . '" />'; |
| 804 | 827 | |
| 805 | - if ( $multi ) return; |
|
| 828 | + if ( $multi ) { |
|
| 829 | + return; |
|
| 830 | + } |
|
| 806 | 831 | |
| 807 | 832 | echo "\n\n"; |
| 808 | 833 | $map = array( |
@@ -865,8 +890,9 @@ discard block |
||
| 865 | 890 | if ( $items ) { |
| 866 | 891 | foreach ( $items as $item ) { |
| 867 | 892 | // A page cannot be its own parent. |
| 868 | - if ( $post && $post->ID && $item->ID == $post->ID ) |
|
| 869 | - continue; |
|
| 893 | + if ( $post && $post->ID && $item->ID == $post->ID ) { |
|
| 894 | + continue; |
|
| 895 | + } |
|
| 870 | 896 | |
| 871 | 897 | $pad = str_repeat( ' ', $level * 3 ); |
| 872 | 898 | $selected = selected( $default, $item->ID, false ); |
@@ -894,10 +920,12 @@ discard block |
||
| 894 | 920 | |
| 895 | 921 | foreach ( $editable_roles as $role => $details ) { |
| 896 | 922 | $name = translate_user_role($details['name'] ); |
| 897 | - if ( $selected == $role ) // preselect specified role |
|
| 923 | + if ( $selected == $role ) { |
|
| 924 | + // preselect specified role |
|
| 898 | 925 | $p = "\n\t<option selected='selected' value='" . esc_attr($role) . "'>$name</option>"; |
| 899 | - else |
|
| 900 | - $r .= "\n\t<option value='" . esc_attr($role) . "'>$name</option>"; |
|
| 926 | + } else { |
|
| 927 | + $r .= "\n\t<option value='" . esc_attr($role) . "'>$name</option>"; |
|
| 928 | + } |
|
| 901 | 929 | } |
| 902 | 930 | echo $p . $r; |
| 903 | 931 | } |
@@ -926,9 +954,12 @@ discard block |
||
| 926 | 954 | if ( ! empty( $upload_dir['error'] ) ) : |
| 927 | 955 | ?><div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:'); ?></p> |
| 928 | 956 | <p><strong><?php echo $upload_dir['error']; ?></strong></p></div><?php |
| 929 | - else : |
|
| 957 | + else { |
|
| 958 | + : |
|
| 930 | 959 | ?> |
| 931 | -<form enctype="multipart/form-data" id="import-upload-form" method="post" class="wp-upload-form" action="<?php echo esc_url( wp_nonce_url( $action, 'import-upload' ) ); ?>"> |
|
| 960 | +<form enctype="multipart/form-data" id="import-upload-form" method="post" class="wp-upload-form" action="<?php echo esc_url( wp_nonce_url( $action, 'import-upload' ) ); |
|
| 961 | + } |
|
| 962 | + ?>"> |
|
| 932 | 963 | <p> |
| 933 | 964 | <label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>) |
| 934 | 965 | <input type="file" id="upload" name="import" size="25" /> |
@@ -969,30 +1000,36 @@ discard block |
||
| 969 | 1000 | function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advanced', $priority = 'default', $callback_args = null ) { |
| 970 | 1001 | global $wp_meta_boxes; |
| 971 | 1002 | |
| 972 | - if ( empty( $screen ) ) |
|
| 973 | - $screen = get_current_screen(); |
|
| 974 | - elseif ( is_string( $screen ) ) |
|
| 975 | - $screen = convert_to_screen( $screen ); |
|
| 1003 | + if ( empty( $screen ) ) { |
|
| 1004 | + $screen = get_current_screen(); |
|
| 1005 | + } elseif ( is_string( $screen ) ) { |
|
| 1006 | + $screen = convert_to_screen( $screen ); |
|
| 1007 | + } |
|
| 976 | 1008 | |
| 977 | 1009 | $page = $screen->id; |
| 978 | 1010 | |
| 979 | - if ( !isset($wp_meta_boxes) ) |
|
| 980 | - $wp_meta_boxes = array(); |
|
| 981 | - if ( !isset($wp_meta_boxes[$page]) ) |
|
| 982 | - $wp_meta_boxes[$page] = array(); |
|
| 983 | - if ( !isset($wp_meta_boxes[$page][$context]) ) |
|
| 984 | - $wp_meta_boxes[$page][$context] = array(); |
|
| 1011 | + if ( !isset($wp_meta_boxes) ) { |
|
| 1012 | + $wp_meta_boxes = array(); |
|
| 1013 | + } |
|
| 1014 | + if ( !isset($wp_meta_boxes[$page]) ) { |
|
| 1015 | + $wp_meta_boxes[$page] = array(); |
|
| 1016 | + } |
|
| 1017 | + if ( !isset($wp_meta_boxes[$page][$context]) ) { |
|
| 1018 | + $wp_meta_boxes[$page][$context] = array(); |
|
| 1019 | + } |
|
| 985 | 1020 | |
| 986 | 1021 | foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) { |
| 987 | 1022 | foreach ( array('high', 'core', 'default', 'low') as $a_priority ) { |
| 988 | - if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) ) |
|
| 989 | - continue; |
|
| 1023 | + if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) ) { |
|
| 1024 | + continue; |
|
| 1025 | + } |
|
| 990 | 1026 | |
| 991 | 1027 | // If a core box was previously added or removed by a plugin, don't add. |
| 992 | 1028 | if ( 'core' == $priority ) { |
| 993 | 1029 | // If core box previously deleted, don't add |
| 994 | - if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] ) |
|
| 995 | - return; |
|
| 1030 | + if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] ) { |
|
| 1031 | + return; |
|
| 1032 | + } |
|
| 996 | 1033 | |
| 997 | 1034 | /* |
| 998 | 1035 | * If box was added with default priority, give it core priority to |
@@ -1017,16 +1054,19 @@ discard block |
||
| 1017 | 1054 | $callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args']; |
| 1018 | 1055 | } |
| 1019 | 1056 | // An id can be in only one priority and one context. |
| 1020 | - if ( $priority != $a_priority || $context != $a_context ) |
|
| 1021 | - unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]); |
|
| 1057 | + if ( $priority != $a_priority || $context != $a_context ) { |
|
| 1058 | + unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]); |
|
| 1059 | + } |
|
| 1022 | 1060 | } |
| 1023 | 1061 | } |
| 1024 | 1062 | |
| 1025 | - if ( empty($priority) ) |
|
| 1026 | - $priority = 'low'; |
|
| 1063 | + if ( empty($priority) ) { |
|
| 1064 | + $priority = 'low'; |
|
| 1065 | + } |
|
| 1027 | 1066 | |
| 1028 | - if ( !isset($wp_meta_boxes[$page][$context][$priority]) ) |
|
| 1029 | - $wp_meta_boxes[$page][$context][$priority] = array(); |
|
| 1067 | + if ( !isset($wp_meta_boxes[$page][$context][$priority]) ) { |
|
| 1068 | + $wp_meta_boxes[$page][$context][$priority] = array(); |
|
| 1069 | + } |
|
| 1030 | 1070 | |
| 1031 | 1071 | $wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $callback_args); |
| 1032 | 1072 | } |
@@ -1048,10 +1088,11 @@ discard block |
||
| 1048 | 1088 | global $wp_meta_boxes; |
| 1049 | 1089 | static $already_sorted = false; |
| 1050 | 1090 | |
| 1051 | - if ( empty( $screen ) ) |
|
| 1052 | - $screen = get_current_screen(); |
|
| 1053 | - elseif ( is_string( $screen ) ) |
|
| 1054 | - $screen = convert_to_screen( $screen ); |
|
| 1091 | + if ( empty( $screen ) ) { |
|
| 1092 | + $screen = get_current_screen(); |
|
| 1093 | + } elseif ( is_string( $screen ) ) { |
|
| 1094 | + $screen = convert_to_screen( $screen ); |
|
| 1095 | + } |
|
| 1055 | 1096 | |
| 1056 | 1097 | $page = $screen->id; |
| 1057 | 1098 | |
@@ -1078,13 +1119,15 @@ discard block |
||
| 1078 | 1119 | foreach ( array( 'high', 'sorted', 'core', 'default', 'low' ) as $priority ) { |
| 1079 | 1120 | if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ]) ) { |
| 1080 | 1121 | foreach ( (array) $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
| 1081 | - if ( false == $box || ! $box['title'] ) |
|
| 1082 | - continue; |
|
| 1122 | + if ( false == $box || ! $box['title'] ) { |
|
| 1123 | + continue; |
|
| 1124 | + } |
|
| 1083 | 1125 | $i++; |
| 1084 | 1126 | $hidden_class = in_array($box['id'], $hidden) ? ' hide-if-js' : ''; |
| 1085 | 1127 | echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . $hidden_class . '" ' . '>' . "\n"; |
| 1086 | - if ( 'dashboard_browser_nag' != $box['id'] ) |
|
| 1087 | - echo '<div class="handlediv" title="' . esc_attr__('Click to toggle') . '"><br /></div>'; |
|
| 1128 | + if ( 'dashboard_browser_nag' != $box['id'] ) { |
|
| 1129 | + echo '<div class="handlediv" title="' . esc_attr__('Click to toggle') . '"><br /></div>'; |
|
| 1130 | + } |
|
| 1088 | 1131 | echo "<h3 class='hndle'><span>{$box['title']}</span></h3>\n"; |
| 1089 | 1132 | echo '<div class="inside">' . "\n"; |
| 1090 | 1133 | call_user_func($box['callback'], $object, $box); |
@@ -1115,23 +1158,28 @@ discard block |
||
| 1115 | 1158 | function remove_meta_box($id, $screen, $context) { |
| 1116 | 1159 | global $wp_meta_boxes; |
| 1117 | 1160 | |
| 1118 | - if ( empty( $screen ) ) |
|
| 1119 | - $screen = get_current_screen(); |
|
| 1120 | - elseif ( is_string( $screen ) ) |
|
| 1121 | - $screen = convert_to_screen( $screen ); |
|
| 1161 | + if ( empty( $screen ) ) { |
|
| 1162 | + $screen = get_current_screen(); |
|
| 1163 | + } elseif ( is_string( $screen ) ) { |
|
| 1164 | + $screen = convert_to_screen( $screen ); |
|
| 1165 | + } |
|
| 1122 | 1166 | |
| 1123 | 1167 | $page = $screen->id; |
| 1124 | 1168 | |
| 1125 | - if ( !isset($wp_meta_boxes) ) |
|
| 1126 | - $wp_meta_boxes = array(); |
|
| 1127 | - if ( !isset($wp_meta_boxes[$page]) ) |
|
| 1128 | - $wp_meta_boxes[$page] = array(); |
|
| 1129 | - if ( !isset($wp_meta_boxes[$page][$context]) ) |
|
| 1130 | - $wp_meta_boxes[$page][$context] = array(); |
|
| 1169 | + if ( !isset($wp_meta_boxes) ) { |
|
| 1170 | + $wp_meta_boxes = array(); |
|
| 1171 | + } |
|
| 1172 | + if ( !isset($wp_meta_boxes[$page]) ) { |
|
| 1173 | + $wp_meta_boxes[$page] = array(); |
|
| 1174 | + } |
|
| 1175 | + if ( !isset($wp_meta_boxes[$page][$context]) ) { |
|
| 1176 | + $wp_meta_boxes[$page][$context] = array(); |
|
| 1177 | + } |
|
| 1131 | 1178 | |
| 1132 | - foreach ( array('high', 'core', 'default', 'low') as $priority ) |
|
| 1133 | - $wp_meta_boxes[$page][$context][$priority][$id] = false; |
|
| 1134 | -} |
|
| 1179 | + foreach ( array('high', 'core', 'default', 'low') as $priority ) { |
|
| 1180 | + $wp_meta_boxes[$page][$context][$priority][$id] = false; |
|
| 1181 | + } |
|
| 1182 | + } |
|
| 1135 | 1183 | |
| 1136 | 1184 | /** |
| 1137 | 1185 | * Meta Box Accordion Template Function |
@@ -1154,10 +1202,11 @@ discard block |
||
| 1154 | 1202 | |
| 1155 | 1203 | wp_enqueue_script( 'accordion' ); |
| 1156 | 1204 | |
| 1157 | - if ( empty( $screen ) ) |
|
| 1158 | - $screen = get_current_screen(); |
|
| 1159 | - elseif ( is_string( $screen ) ) |
|
| 1160 | - $screen = convert_to_screen( $screen ); |
|
| 1205 | + if ( empty( $screen ) ) { |
|
| 1206 | + $screen = get_current_screen(); |
|
| 1207 | + } elseif ( is_string( $screen ) ) { |
|
| 1208 | + $screen = convert_to_screen( $screen ); |
|
| 1209 | + } |
|
| 1161 | 1210 | |
| 1162 | 1211 | $page = $screen->id; |
| 1163 | 1212 | |
@@ -1173,8 +1222,9 @@ discard block |
||
| 1173 | 1222 | foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
| 1174 | 1223 | if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
| 1175 | 1224 | foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
| 1176 | - if ( false == $box || ! $box['title'] ) |
|
| 1177 | - continue; |
|
| 1225 | + if ( false == $box || ! $box['title'] ) { |
|
| 1226 | + continue; |
|
| 1227 | + } |
|
| 1178 | 1228 | $i++; |
| 1179 | 1229 | $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
| 1180 | 1230 | |
@@ -1310,18 +1360,22 @@ discard block |
||
| 1310 | 1360 | function do_settings_sections( $page ) { |
| 1311 | 1361 | global $wp_settings_sections, $wp_settings_fields; |
| 1312 | 1362 | |
| 1313 | - if ( ! isset( $wp_settings_sections[$page] ) ) |
|
| 1314 | - return; |
|
| 1363 | + if ( ! isset( $wp_settings_sections[$page] ) ) { |
|
| 1364 | + return; |
|
| 1365 | + } |
|
| 1315 | 1366 | |
| 1316 | 1367 | foreach ( (array) $wp_settings_sections[$page] as $section ) { |
| 1317 | - if ( $section['title'] ) |
|
| 1318 | - echo "<h3>{$section['title']}</h3>\n"; |
|
| 1368 | + if ( $section['title'] ) { |
|
| 1369 | + echo "<h3>{$section['title']}</h3>\n"; |
|
| 1370 | + } |
|
| 1319 | 1371 | |
| 1320 | - if ( $section['callback'] ) |
|
| 1321 | - call_user_func( $section['callback'], $section ); |
|
| 1372 | + if ( $section['callback'] ) { |
|
| 1373 | + call_user_func( $section['callback'], $section ); |
|
| 1374 | + } |
|
| 1322 | 1375 | |
| 1323 | - if ( ! isset( $wp_settings_fields ) || !isset( $wp_settings_fields[$page] ) || !isset( $wp_settings_fields[$page][$section['id']] ) ) |
|
| 1324 | - continue; |
|
| 1376 | + if ( ! isset( $wp_settings_fields ) || !isset( $wp_settings_fields[$page] ) || !isset( $wp_settings_fields[$page][$section['id']] ) ) { |
|
| 1377 | + continue; |
|
| 1378 | + } |
|
| 1325 | 1379 | echo '<table class="form-table">'; |
| 1326 | 1380 | do_settings_fields( $page, $section['id'] ); |
| 1327 | 1381 | echo '</table>'; |
@@ -1345,8 +1399,9 @@ discard block |
||
| 1345 | 1399 | function do_settings_fields($page, $section) { |
| 1346 | 1400 | global $wp_settings_fields; |
| 1347 | 1401 | |
| 1348 | - if ( ! isset( $wp_settings_fields[$page][$section] ) ) |
|
| 1349 | - return; |
|
| 1402 | + if ( ! isset( $wp_settings_fields[$page][$section] ) ) { |
|
| 1403 | + return; |
|
| 1404 | + } |
|
| 1350 | 1405 | |
| 1351 | 1406 | foreach ( (array) $wp_settings_fields[$page][$section] as $field ) { |
| 1352 | 1407 | $class = ''; |
@@ -1435,8 +1490,9 @@ discard block |
||
| 1435 | 1490 | * This allows the $sanitize_callback from register_setting() to run, adding |
| 1436 | 1491 | * any settings errors you want to show by default. |
| 1437 | 1492 | */ |
| 1438 | - if ( $sanitize ) |
|
| 1439 | - sanitize_option( $setting, get_option( $setting ) ); |
|
| 1493 | + if ( $sanitize ) { |
|
| 1494 | + sanitize_option( $setting, get_option( $setting ) ); |
|
| 1495 | + } |
|
| 1440 | 1496 | |
| 1441 | 1497 | // If settings were passed back from options.php then use them. |
| 1442 | 1498 | if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] && get_transient( 'settings_errors' ) ) { |
@@ -1445,15 +1501,17 @@ discard block |
||
| 1445 | 1501 | } |
| 1446 | 1502 | |
| 1447 | 1503 | // Check global in case errors have been added on this pageload. |
| 1448 | - if ( ! count( $wp_settings_errors ) ) |
|
| 1449 | - return array(); |
|
| 1504 | + if ( ! count( $wp_settings_errors ) ) { |
|
| 1505 | + return array(); |
|
| 1506 | + } |
|
| 1450 | 1507 | |
| 1451 | 1508 | // Filter the results to those of a specific setting if one was set. |
| 1452 | 1509 | if ( $setting ) { |
| 1453 | 1510 | $setting_errors = array(); |
| 1454 | 1511 | foreach ( (array) $wp_settings_errors as $key => $details ) { |
| 1455 | - if ( $setting == $details['setting'] ) |
|
| 1456 | - $setting_errors[] = $wp_settings_errors[$key]; |
|
| 1512 | + if ( $setting == $details['setting'] ) { |
|
| 1513 | + $setting_errors[] = $wp_settings_errors[$key]; |
|
| 1514 | + } |
|
| 1457 | 1515 | } |
| 1458 | 1516 | return $setting_errors; |
| 1459 | 1517 | } |
@@ -1489,13 +1547,15 @@ discard block |
||
| 1489 | 1547 | */ |
| 1490 | 1548 | function settings_errors( $setting = '', $sanitize = false, $hide_on_update = false ) { |
| 1491 | 1549 | |
| 1492 | - if ( $hide_on_update && ! empty( $_GET['settings-updated'] ) ) |
|
| 1493 | - return; |
|
| 1550 | + if ( $hide_on_update && ! empty( $_GET['settings-updated'] ) ) { |
|
| 1551 | + return; |
|
| 1552 | + } |
|
| 1494 | 1553 | |
| 1495 | 1554 | $settings_errors = get_settings_errors( $setting, $sanitize ); |
| 1496 | 1555 | |
| 1497 | - if ( empty( $settings_errors ) ) |
|
| 1498 | - return; |
|
| 1556 | + if ( empty( $settings_errors ) ) { |
|
| 1557 | + return; |
|
| 1558 | + } |
|
| 1499 | 1559 | |
| 1500 | 1560 | $output = ''; |
| 1501 | 1561 | foreach ( $settings_errors as $key => $details ) { |
@@ -1555,9 +1615,10 @@ discard block |
||
| 1555 | 1615 | */ |
| 1556 | 1616 | function the_post_password() { |
| 1557 | 1617 | $post = get_post(); |
| 1558 | - if ( isset( $post->post_password ) ) |
|
| 1559 | - echo esc_attr( $post->post_password ); |
|
| 1560 | -} |
|
| 1618 | + if ( isset( $post->post_password ) ) { |
|
| 1619 | + echo esc_attr( $post->post_password ); |
|
| 1620 | + } |
|
| 1621 | + } |
|
| 1561 | 1622 | |
| 1562 | 1623 | /** |
| 1563 | 1624 | * Get the post title. |
@@ -1572,8 +1633,9 @@ discard block |
||
| 1572 | 1633 | */ |
| 1573 | 1634 | function _draft_or_post_title( $post = 0 ) { |
| 1574 | 1635 | $title = get_the_title( $post ); |
| 1575 | - if ( empty( $title ) ) |
|
| 1576 | - $title = __( '(no title)' ); |
|
| 1636 | + if ( empty( $title ) ) { |
|
| 1637 | + $title = __( '(no title)' ); |
|
| 1638 | + } |
|
| 1577 | 1639 | return esc_html( $title ); |
| 1578 | 1640 | } |
| 1579 | 1641 | |
@@ -1650,8 +1712,9 @@ discard block |
||
| 1650 | 1712 | |
| 1651 | 1713 | $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) ); |
| 1652 | 1714 | |
| 1653 | -if ( is_rtl() ) |
|
| 1715 | +if ( is_rtl() ) { |
|
| 1654 | 1716 | $admin_body_class .= ' rtl'; |
| 1717 | +} |
|
| 1655 | 1718 | |
| 1656 | 1719 | ?> |
| 1657 | 1720 | </head> |
@@ -1663,7 +1726,10 @@ discard block |
||
| 1663 | 1726 | /** |
| 1664 | 1727 | * @global string $body_id |
| 1665 | 1728 | */ |
| 1666 | -if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?> class="wp-admin wp-core-ui no-js iframe <?php echo $admin_body_classes . ' ' . $admin_body_class; ?>"> |
|
| 1729 | +if ( isset($GLOBALS['body_id']) ) { |
|
| 1730 | + echo ' id="' . $GLOBALS['body_id'] . '"'; |
|
| 1731 | +} |
|
| 1732 | +?> class="wp-admin wp-core-ui no-js iframe <?php echo $admin_body_classes . ' ' . $admin_body_class; ?>"> |
|
| 1667 | 1733 | <script type="text/javascript"> |
| 1668 | 1734 | (function(){ |
| 1669 | 1735 | var c = document.body.className; |
@@ -1707,22 +1773,28 @@ discard block |
||
| 1707 | 1773 | */ |
| 1708 | 1774 | function _post_states($post) { |
| 1709 | 1775 | $post_states = array(); |
| 1710 | - if ( isset( $_REQUEST['post_status'] ) ) |
|
| 1711 | - $post_status = $_REQUEST['post_status']; |
|
| 1712 | - else |
|
| 1713 | - $post_status = ''; |
|
| 1714 | - |
|
| 1715 | - if ( !empty($post->post_password) ) |
|
| 1716 | - $post_states['protected'] = __('Password protected'); |
|
| 1717 | - if ( 'private' == $post->post_status && 'private' != $post_status ) |
|
| 1718 | - $post_states['private'] = __('Private'); |
|
| 1719 | - if ( 'draft' == $post->post_status && 'draft' != $post_status ) |
|
| 1720 | - $post_states['draft'] = __('Draft'); |
|
| 1721 | - if ( 'pending' == $post->post_status && 'pending' != $post_status ) |
|
| 1722 | - /* translators: post state */ |
|
| 1776 | + if ( isset( $_REQUEST['post_status'] ) ) { |
|
| 1777 | + $post_status = $_REQUEST['post_status']; |
|
| 1778 | + } else { |
|
| 1779 | + $post_status = ''; |
|
| 1780 | + } |
|
| 1781 | + |
|
| 1782 | + if ( !empty($post->post_password) ) { |
|
| 1783 | + $post_states['protected'] = __('Password protected'); |
|
| 1784 | + } |
|
| 1785 | + if ( 'private' == $post->post_status && 'private' != $post_status ) { |
|
| 1786 | + $post_states['private'] = __('Private'); |
|
| 1787 | + } |
|
| 1788 | + if ( 'draft' == $post->post_status && 'draft' != $post_status ) { |
|
| 1789 | + $post_states['draft'] = __('Draft'); |
|
| 1790 | + } |
|
| 1791 | + if ( 'pending' == $post->post_status && 'pending' != $post_status ) { |
|
| 1792 | + /* translators: post state */ |
|
| 1723 | 1793 | $post_states['pending'] = _x('Pending', 'post state'); |
| 1724 | - if ( is_sticky($post->ID) ) |
|
| 1725 | - $post_states['sticky'] = __('Sticky'); |
|
| 1794 | + } |
|
| 1795 | + if ( is_sticky($post->ID) ) { |
|
| 1796 | + $post_states['sticky'] = __('Sticky'); |
|
| 1797 | + } |
|
| 1726 | 1798 | |
| 1727 | 1799 | if ( 'future' === $post->post_status ) { |
| 1728 | 1800 | $post_states['scheduled'] = __( 'Scheduled' ); |
@@ -1769,14 +1841,16 @@ discard block |
||
| 1769 | 1841 | |
| 1770 | 1842 | if ( current_theme_supports( 'custom-header') ) { |
| 1771 | 1843 | $meta_header = get_post_meta($post->ID, '_wp_attachment_is_custom_header', true ); |
| 1772 | - if ( ! empty( $meta_header ) && $meta_header == $stylesheet ) |
|
| 1773 | - $media_states[] = __( 'Header Image' ); |
|
| 1844 | + if ( ! empty( $meta_header ) && $meta_header == $stylesheet ) { |
|
| 1845 | + $media_states[] = __( 'Header Image' ); |
|
| 1846 | + } |
|
| 1774 | 1847 | } |
| 1775 | 1848 | |
| 1776 | 1849 | if ( current_theme_supports( 'custom-background') ) { |
| 1777 | 1850 | $meta_background = get_post_meta($post->ID, '_wp_attachment_is_custom_background', true ); |
| 1778 | - if ( ! empty( $meta_background ) && $meta_background == $stylesheet ) |
|
| 1779 | - $media_states[] = __( 'Background Image' ); |
|
| 1851 | + if ( ! empty( $meta_background ) && $meta_background == $stylesheet ) { |
|
| 1852 | + $media_states[] = __( 'Background Image' ); |
|
| 1853 | + } |
|
| 1780 | 1854 | } |
| 1781 | 1855 | |
| 1782 | 1856 | if ( $post->ID == get_option( 'site_icon' ) ) { |
@@ -1916,20 +1990,23 @@ discard block |
||
| 1916 | 1990 | * @return string Submit button HTML. |
| 1917 | 1991 | */ |
| 1918 | 1992 | function get_submit_button( $text = '', $type = 'primary large', $name = 'submit', $wrap = true, $other_attributes = '' ) { |
| 1919 | - if ( ! is_array( $type ) ) |
|
| 1920 | - $type = explode( ' ', $type ); |
|
| 1993 | + if ( ! is_array( $type ) ) { |
|
| 1994 | + $type = explode( ' ', $type ); |
|
| 1995 | + } |
|
| 1921 | 1996 | |
| 1922 | 1997 | $button_shorthand = array( 'primary', 'small', 'large' ); |
| 1923 | 1998 | $classes = array( 'button' ); |
| 1924 | 1999 | foreach ( $type as $t ) { |
| 1925 | - if ( 'secondary' === $t || 'button-secondary' === $t ) |
|
| 1926 | - continue; |
|
| 2000 | + if ( 'secondary' === $t || 'button-secondary' === $t ) { |
|
| 2001 | + continue; |
|
| 2002 | + } |
|
| 1927 | 2003 | $classes[] = in_array( $t, $button_shorthand ) ? 'button-' . $t : $t; |
| 1928 | 2004 | } |
| 1929 | 2005 | $class = implode( ' ', array_unique( $classes ) ); |
| 1930 | 2006 | |
| 1931 | - if ( 'delete' === $type ) |
|
| 1932 | - $class = 'button-secondary delete'; |
|
| 2007 | + if ( 'delete' === $type ) { |
|
| 2008 | + $class = 'button-secondary delete'; |
|
| 2009 | + } |
|
| 1933 | 2010 | |
| 1934 | 2011 | $text = $text ? $text : __( 'Save Changes' ); |
| 1935 | 2012 | |
@@ -1972,8 +2049,9 @@ discard block |
||
| 1972 | 2049 | |
| 1973 | 2050 | $admin_html_class = ( is_admin_bar_showing() ) ? 'wp-toolbar' : ''; |
| 1974 | 2051 | |
| 1975 | - if ( $is_IE ) |
|
| 1976 | - @header('X-UA-Compatible: IE=edge'); |
|
| 2052 | + if ( $is_IE ) { |
|
| 2053 | + @header('X-UA-Compatible: IE=edge'); |
|
| 2054 | + } |
|
| 1977 | 2055 | |
| 1978 | 2056 | ?> |
| 1979 | 2057 | <!DOCTYPE html> |
@@ -2033,8 +2111,9 @@ discard block |
||
| 2033 | 2111 | ); |
| 2034 | 2112 | |
| 2035 | 2113 | // Check if screen related pointer is registered |
| 2036 | - if ( empty( $registered_pointers[ $hook_suffix ] ) ) |
|
| 2037 | - return; |
|
| 2114 | + if ( empty( $registered_pointers[ $hook_suffix ] ) ) { |
|
| 2115 | + return; |
|
| 2116 | + } |
|
| 2038 | 2117 | |
| 2039 | 2118 | $pointers = (array) $registered_pointers[ $hook_suffix ]; |
| 2040 | 2119 | |
@@ -2062,8 +2141,9 @@ discard block |
||
| 2062 | 2141 | foreach ( array_diff( $pointers, $dismissed ) as $pointer ) { |
| 2063 | 2142 | if ( isset( $caps_required[ $pointer ] ) ) { |
| 2064 | 2143 | foreach ( $caps_required[ $pointer ] as $cap ) { |
| 2065 | - if ( ! current_user_can( $cap ) ) |
|
| 2066 | - continue 2; |
|
| 2144 | + if ( ! current_user_can( $cap ) ) { |
|
| 2145 | + continue 2; |
|
| 2146 | + } |
|
| 2067 | 2147 | } |
| 2068 | 2148 | } |
| 2069 | 2149 | |
@@ -2072,8 +2152,9 @@ discard block |
||
| 2072 | 2152 | $got_pointers = true; |
| 2073 | 2153 | } |
| 2074 | 2154 | |
| 2075 | - if ( ! $got_pointers ) |
|
| 2076 | - return; |
|
| 2155 | + if ( ! $got_pointers ) { |
|
| 2156 | + return; |
|
| 2157 | + } |
|
| 2077 | 2158 | |
| 2078 | 2159 | // Add pointers script and style to queue |
| 2079 | 2160 | wp_enqueue_style( 'wp-pointer' ); |
@@ -2092,8 +2173,9 @@ discard block |
||
| 2092 | 2173 | * @param array $args Arguments to be passed to the pointer JS (see wp-pointer.js). |
| 2093 | 2174 | */ |
| 2094 | 2175 | private static function print_js( $pointer_id, $selector, $args ) { |
| 2095 | - if ( empty( $pointer_id ) || empty( $selector ) || empty( $args ) || empty( $args['content'] ) ) |
|
| 2096 | - return; |
|
| 2176 | + if ( empty( $pointer_id ) || empty( $selector ) || empty( $args ) || empty( $args['content'] ) ) { |
|
| 2177 | + return; |
|
| 2178 | + } |
|
| 2097 | 2179 | |
| 2098 | 2180 | ?> |
| 2099 | 2181 | <script type="text/javascript"> |
@@ -1795,7 +1795,7 @@ discard block |
||
| 1795 | 1795 | * |
| 1796 | 1796 | * @param string $table Database table name. |
| 1797 | 1797 | * @param string $index Index name to drop. |
| 1798 | - * @return true True, when finished. |
|
| 1798 | + * @return boolean True, when finished. |
|
| 1799 | 1799 | */ |
| 1800 | 1800 | function drop_index($table, $index) { |
| 1801 | 1801 | global $wpdb; |
@@ -1818,7 +1818,7 @@ discard block |
||
| 1818 | 1818 | * |
| 1819 | 1819 | * @param string $table Database table name. |
| 1820 | 1820 | * @param string $index Database table index column. |
| 1821 | - * @return true True, when done with execution. |
|
| 1821 | + * @return boolean True, when done with execution. |
|
| 1822 | 1822 | */ |
| 1823 | 1823 | function add_clean_index($table, $index) { |
| 1824 | 1824 | global $wpdb; |
@@ -1,12 +1,12 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * WordPress Upgrade API |
|
| 4 | - * |
|
| 5 | - * Most of the functions are pluggable and can be overwritten. |
|
| 6 | - * |
|
| 7 | - * @package WordPress |
|
| 8 | - * @subpackage Administration |
|
| 9 | - */ |
|
| 3 | + * WordPress Upgrade API |
|
| 4 | + * |
|
| 5 | + * Most of the functions are pluggable and can be overwritten. |
|
| 6 | + * |
|
| 7 | + * @package WordPress |
|
| 8 | + * @subpackage Administration |
|
| 9 | + */ |
|
| 10 | 10 | |
| 11 | 11 | /** Include user install customize script. */ |
| 12 | 12 | if ( file_exists(WP_CONTENT_DIR . '/install.php') ) |
@@ -2005,7 +2005,7 @@ discard block |
||
| 2005 | 2005 | global $wpdb; |
| 2006 | 2006 | |
| 2007 | 2007 | if ( in_array( $queries, array( '', 'all', 'blog', 'global', 'ms_global' ), true ) ) |
| 2008 | - $queries = wp_get_db_schema( $queries ); |
|
| 2008 | + $queries = wp_get_db_schema( $queries ); |
|
| 2009 | 2009 | |
| 2010 | 2010 | // Separate individual queries into an array |
| 2011 | 2011 | if ( !is_array($queries) ) { |
@@ -2103,15 +2103,15 @@ discard block |
||
| 2103 | 2103 | // Verify the found field name. |
| 2104 | 2104 | $validfield = true; |
| 2105 | 2105 | switch (strtolower($fieldname)) { |
| 2106 | - case '': |
|
| 2107 | - case 'primary': |
|
| 2108 | - case 'index': |
|
| 2109 | - case 'fulltext': |
|
| 2110 | - case 'unique': |
|
| 2111 | - case 'key': |
|
| 2112 | - $validfield = false; |
|
| 2113 | - $indices[] = trim(trim($fld), ", \n"); |
|
| 2114 | - break; |
|
| 2106 | + case '': |
|
| 2107 | + case 'primary': |
|
| 2108 | + case 'index': |
|
| 2109 | + case 'fulltext': |
|
| 2110 | + case 'unique': |
|
| 2111 | + case 'key': |
|
| 2112 | + $validfield = false; |
|
| 2113 | + $indices[] = trim(trim($fld), ", \n"); |
|
| 2114 | + break; |
|
| 2115 | 2115 | } |
| 2116 | 2116 | $fld = trim($fld); |
| 2117 | 2117 | |
@@ -2495,22 +2495,22 @@ discard block |
||
| 2495 | 2495 | */ |
| 2496 | 2496 | function translate_level_to_role($level) { |
| 2497 | 2497 | switch ($level) { |
| 2498 | - case 10: |
|
| 2499 | - case 9: |
|
| 2500 | - case 8: |
|
| 2501 | - return 'administrator'; |
|
| 2502 | - case 7: |
|
| 2503 | - case 6: |
|
| 2504 | - case 5: |
|
| 2505 | - return 'editor'; |
|
| 2506 | - case 4: |
|
| 2507 | - case 3: |
|
| 2508 | - case 2: |
|
| 2509 | - return 'author'; |
|
| 2510 | - case 1: |
|
| 2511 | - return 'contributor'; |
|
| 2512 | - case 0: |
|
| 2513 | - return 'subscriber'; |
|
| 2498 | + case 10: |
|
| 2499 | + case 9: |
|
| 2500 | + case 8: |
|
| 2501 | + return 'administrator'; |
|
| 2502 | + case 7: |
|
| 2503 | + case 6: |
|
| 2504 | + case 5: |
|
| 2505 | + return 'editor'; |
|
| 2506 | + case 4: |
|
| 2507 | + case 3: |
|
| 2508 | + case 2: |
|
| 2509 | + return 'author'; |
|
| 2510 | + case 1: |
|
| 2511 | + return 'contributor'; |
|
| 2512 | + case 0: |
|
| 2513 | + return 'subscriber'; |
|
| 2514 | 2514 | } |
| 2515 | 2515 | } |
| 2516 | 2516 | |
@@ -9,16 +9,16 @@ discard block |
||
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | /** Include user install customize script. */ |
| 12 | -if ( file_exists(WP_CONTENT_DIR . '/install.php') ) |
|
| 13 | - require (WP_CONTENT_DIR . '/install.php'); |
|
| 12 | +if (file_exists(WP_CONTENT_DIR.'/install.php')) |
|
| 13 | + require (WP_CONTENT_DIR.'/install.php'); |
|
| 14 | 14 | |
| 15 | 15 | /** WordPress Administration API */ |
| 16 | -require_once(ABSPATH . 'wp-admin/includes/admin.php'); |
|
| 16 | +require_once(ABSPATH.'wp-admin/includes/admin.php'); |
|
| 17 | 17 | |
| 18 | 18 | /** WordPress Schema API */ |
| 19 | -require_once(ABSPATH . 'wp-admin/includes/schema.php'); |
|
| 19 | +require_once(ABSPATH.'wp-admin/includes/schema.php'); |
|
| 20 | 20 | |
| 21 | -if ( !function_exists('wp_install') ) : |
|
| 21 | +if ( ! function_exists('wp_install')) : |
|
| 22 | 22 | /** |
| 23 | 23 | * Installs the site. |
| 24 | 24 | * |
@@ -36,9 +36,9 @@ discard block |
||
| 36 | 36 | * @param string $language Optional. Language chosen. Default empty. |
| 37 | 37 | * @return array Array keys 'url', 'user_id', 'password', and 'password_message'. |
| 38 | 38 | */ |
| 39 | -function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '', $language = '' ) { |
|
| 40 | - if ( !empty( $deprecated ) ) |
|
| 41 | - _deprecated_argument( __FUNCTION__, '2.6' ); |
|
| 39 | +function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '', $language = '') { |
|
| 40 | + if ( ! empty($deprecated)) |
|
| 41 | + _deprecated_argument(__FUNCTION__, '2.6'); |
|
| 42 | 42 | |
| 43 | 43 | wp_check_mysql_version(); |
| 44 | 44 | wp_cache_flush(); |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | update_option('admin_email', $user_email); |
| 51 | 51 | update_option('blog_public', $public); |
| 52 | 52 | |
| 53 | - if ( $language ) { |
|
| 54 | - update_option( 'WPLANG', $language ); |
|
| 53 | + if ($language) { |
|
| 54 | + update_option('WPLANG', $language); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | $guessurl = wp_guess_url(); |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | update_option('siteurl', $guessurl); |
| 60 | 60 | |
| 61 | 61 | // If not a public blog, don't ping. |
| 62 | - if ( ! $public ) |
|
| 62 | + if ( ! $public) |
|
| 63 | 63 | update_option('default_pingback_flag', 0); |
| 64 | 64 | |
| 65 | 65 | /* |
@@ -69,13 +69,13 @@ discard block |
||
| 69 | 69 | $user_id = username_exists($user_name); |
| 70 | 70 | $user_password = trim($user_password); |
| 71 | 71 | $email_password = false; |
| 72 | - if ( !$user_id && empty($user_password) ) { |
|
| 73 | - $user_password = wp_generate_password( 12, false ); |
|
| 72 | + if ( ! $user_id && empty($user_password)) { |
|
| 73 | + $user_password = wp_generate_password(12, false); |
|
| 74 | 74 | $message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.'); |
| 75 | 75 | $user_id = wp_create_user($user_name, $user_password, $user_email); |
| 76 | 76 | update_user_option($user_id, 'default_password_nag', true, true); |
| 77 | 77 | $email_password = true; |
| 78 | - } elseif ( ! $user_id ) { |
|
| 78 | + } elseif ( ! $user_id) { |
|
| 79 | 79 | // Password has been provided |
| 80 | 80 | $message = '<em>'.__('Your chosen password.').'</em>'; |
| 81 | 81 | $user_id = wp_create_user($user_name, $user_password, $user_email); |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | flush_rewrite_rules(); |
| 94 | 94 | |
| 95 | - wp_new_blog_notification($blog_title, $guessurl, $user_id, ($email_password ? $user_password : __('The password you chose during the install.') ) ); |
|
| 95 | + wp_new_blog_notification($blog_title, $guessurl, $user_id, ($email_password ? $user_password : __('The password you chose during the install.'))); |
|
| 96 | 96 | |
| 97 | 97 | wp_cache_flush(); |
| 98 | 98 | |
@@ -103,13 +103,13 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @param WP_User $user The site owner. |
| 105 | 105 | */ |
| 106 | - do_action( 'wp_install', $user ); |
|
| 106 | + do_action('wp_install', $user); |
|
| 107 | 107 | |
| 108 | 108 | return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message); |
| 109 | 109 | } |
| 110 | 110 | endif; |
| 111 | 111 | |
| 112 | -if ( !function_exists('wp_install_defaults') ) : |
|
| 112 | +if ( ! function_exists('wp_install_defaults')) : |
|
| 113 | 113 | /** |
| 114 | 114 | * Creates the initial content for a newly-installed site. |
| 115 | 115 | * |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | * |
| 125 | 125 | * @param int $user_id User ID. |
| 126 | 126 | */ |
| 127 | -function wp_install_defaults( $user_id ) { |
|
| 127 | +function wp_install_defaults($user_id) { |
|
| 128 | 128 | global $wpdb, $wp_rewrite, $table_prefix; |
| 129 | 129 | |
| 130 | 130 | // Default category |
@@ -132,10 +132,10 @@ discard block |
||
| 132 | 132 | /* translators: Default category slug */ |
| 133 | 133 | $cat_slug = sanitize_title(_x('Uncategorized', 'Default category slug')); |
| 134 | 134 | |
| 135 | - if ( global_terms_enabled() ) { |
|
| 136 | - $cat_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) ); |
|
| 137 | - if ( $cat_id == null ) { |
|
| 138 | - $wpdb->insert( $wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)) ); |
|
| 135 | + if (global_terms_enabled()) { |
|
| 136 | + $cat_id = $wpdb->get_var($wpdb->prepare("SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug)); |
|
| 137 | + if ($cat_id == null) { |
|
| 138 | + $wpdb->insert($wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true))); |
|
| 139 | 139 | $cat_id = $wpdb->insert_id; |
| 140 | 140 | } |
| 141 | 141 | update_option('default_category', $cat_id); |
@@ -143,28 +143,28 @@ discard block |
||
| 143 | 143 | $cat_id = 1; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - $wpdb->insert( $wpdb->terms, array('term_id' => $cat_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0) ); |
|
| 147 | - $wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1)); |
|
| 146 | + $wpdb->insert($wpdb->terms, array('term_id' => $cat_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0)); |
|
| 147 | + $wpdb->insert($wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1)); |
|
| 148 | 148 | $cat_tt_id = $wpdb->insert_id; |
| 149 | 149 | |
| 150 | 150 | // First post |
| 151 | - $now = current_time( 'mysql' ); |
|
| 152 | - $now_gmt = current_time( 'mysql', 1 ); |
|
| 153 | - $first_post_guid = get_option( 'home' ) . '/?p=1'; |
|
| 151 | + $now = current_time('mysql'); |
|
| 152 | + $now_gmt = current_time('mysql', 1); |
|
| 153 | + $first_post_guid = get_option('home').'/?p=1'; |
|
| 154 | 154 | |
| 155 | - if ( is_multisite() ) { |
|
| 156 | - $first_post = get_site_option( 'first_post' ); |
|
| 155 | + if (is_multisite()) { |
|
| 156 | + $first_post = get_site_option('first_post'); |
|
| 157 | 157 | |
| 158 | - if ( empty($first_post) ) |
|
| 159 | - $first_post = __( 'Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start writing!' ); |
|
| 158 | + if (empty($first_post)) |
|
| 159 | + $first_post = __('Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start writing!'); |
|
| 160 | 160 | |
| 161 | - $first_post = str_replace( "SITE_URL", esc_url( network_home_url() ), $first_post ); |
|
| 162 | - $first_post = str_replace( "SITE_NAME", get_current_site()->site_name, $first_post ); |
|
| 161 | + $first_post = str_replace("SITE_URL", esc_url(network_home_url()), $first_post); |
|
| 162 | + $first_post = str_replace("SITE_NAME", get_current_site()->site_name, $first_post); |
|
| 163 | 163 | } else { |
| 164 | - $first_post = __( 'Welcome to WordPress. This is your first post. Edit or delete it, then start writing!' ); |
|
| 164 | + $first_post = __('Welcome to WordPress. This is your first post. Edit or delete it, then start writing!'); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - $wpdb->insert( $wpdb->posts, array( |
|
| 167 | + $wpdb->insert($wpdb->posts, array( |
|
| 168 | 168 | 'post_author' => $user_id, |
| 169 | 169 | 'post_date' => $now, |
| 170 | 170 | 'post_date_gmt' => $now_gmt, |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | 'post_excerpt' => '', |
| 173 | 173 | 'post_title' => __('Hello world!'), |
| 174 | 174 | /* translators: Default post slug */ |
| 175 | - 'post_name' => sanitize_title( _x('hello-world', 'Default post slug') ), |
|
| 175 | + 'post_name' => sanitize_title(_x('hello-world', 'Default post slug')), |
|
| 176 | 176 | 'post_modified' => $now, |
| 177 | 177 | 'post_modified_gmt' => $now_gmt, |
| 178 | 178 | 'guid' => $first_post_guid, |
@@ -181,19 +181,19 @@ discard block |
||
| 181 | 181 | 'pinged' => '', |
| 182 | 182 | 'post_content_filtered' => '' |
| 183 | 183 | )); |
| 184 | - $wpdb->insert( $wpdb->term_relationships, array('term_taxonomy_id' => $cat_tt_id, 'object_id' => 1) ); |
|
| 184 | + $wpdb->insert($wpdb->term_relationships, array('term_taxonomy_id' => $cat_tt_id, 'object_id' => 1)); |
|
| 185 | 185 | |
| 186 | 186 | // Default comment |
| 187 | 187 | $first_comment_author = __('Mr WordPress'); |
| 188 | 188 | $first_comment_url = 'https://wordpress.org/'; |
| 189 | 189 | $first_comment = __('Hi, this is a comment. |
| 190 | 190 | To delete a comment, just log in and view the post's comments. There you will have the option to edit or delete them.'); |
| 191 | - if ( is_multisite() ) { |
|
| 192 | - $first_comment_author = get_site_option( 'first_comment_author', $first_comment_author ); |
|
| 193 | - $first_comment_url = get_site_option( 'first_comment_url', network_home_url() ); |
|
| 194 | - $first_comment = get_site_option( 'first_comment', $first_comment ); |
|
| 191 | + if (is_multisite()) { |
|
| 192 | + $first_comment_author = get_site_option('first_comment_author', $first_comment_author); |
|
| 193 | + $first_comment_url = get_site_option('first_comment_url', network_home_url()); |
|
| 194 | + $first_comment = get_site_option('first_comment', $first_comment); |
|
| 195 | 195 | } |
| 196 | - $wpdb->insert( $wpdb->comments, array( |
|
| 196 | + $wpdb->insert($wpdb->comments, array( |
|
| 197 | 197 | 'comment_post_ID' => 1, |
| 198 | 198 | 'comment_author' => $first_comment_author, |
| 199 | 199 | 'comment_author_email' => '', |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | )); |
| 205 | 205 | |
| 206 | 206 | // First Page |
| 207 | - $first_page = sprintf( __( "This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this: |
|
| 207 | + $first_page = sprintf(__("This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this: |
|
| 208 | 208 | |
| 209 | 209 | <blockquote>Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like piña coladas. (And gettin' caught in the rain.)</blockquote> |
| 210 | 210 | |
@@ -212,19 +212,19 @@ discard block |
||
| 212 | 212 | |
| 213 | 213 | <blockquote>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</blockquote> |
| 214 | 214 | |
| 215 | -As a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to delete this page and create new pages for your content. Have fun!" ), admin_url() ); |
|
| 216 | - if ( is_multisite() ) |
|
| 217 | - $first_page = get_site_option( 'first_page', $first_page ); |
|
| 218 | - $first_post_guid = get_option('home') . '/?page_id=2'; |
|
| 219 | - $wpdb->insert( $wpdb->posts, array( |
|
| 215 | +As a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to delete this page and create new pages for your content. Have fun!" ), admin_url()); |
|
| 216 | + if (is_multisite()) |
|
| 217 | + $first_page = get_site_option('first_page', $first_page); |
|
| 218 | + $first_post_guid = get_option('home').'/?page_id=2'; |
|
| 219 | + $wpdb->insert($wpdb->posts, array( |
|
| 220 | 220 | 'post_author' => $user_id, |
| 221 | 221 | 'post_date' => $now, |
| 222 | 222 | 'post_date_gmt' => $now_gmt, |
| 223 | 223 | 'post_content' => $first_page, |
| 224 | 224 | 'post_excerpt' => '', |
| 225 | - 'post_title' => __( 'Sample Page' ), |
|
| 225 | + 'post_title' => __('Sample Page'), |
|
| 226 | 226 | /* translators: Default page slug */ |
| 227 | - 'post_name' => __( 'sample-page' ), |
|
| 227 | + 'post_name' => __('sample-page'), |
|
| 228 | 228 | 'post_modified' => $now, |
| 229 | 229 | 'post_modified_gmt' => $now_gmt, |
| 230 | 230 | 'guid' => $first_post_guid, |
@@ -233,37 +233,37 @@ discard block |
||
| 233 | 233 | 'pinged' => '', |
| 234 | 234 | 'post_content_filtered' => '' |
| 235 | 235 | )); |
| 236 | - $wpdb->insert( $wpdb->postmeta, array( 'post_id' => 2, 'meta_key' => '_wp_page_template', 'meta_value' => 'default' ) ); |
|
| 236 | + $wpdb->insert($wpdb->postmeta, array('post_id' => 2, 'meta_key' => '_wp_page_template', 'meta_value' => 'default')); |
|
| 237 | 237 | |
| 238 | 238 | // Set up default widgets for default theme. |
| 239 | - update_option( 'widget_search', array ( 2 => array ( 'title' => '' ), '_multiwidget' => 1 ) ); |
|
| 240 | - update_option( 'widget_recent-posts', array ( 2 => array ( 'title' => '', 'number' => 5 ), '_multiwidget' => 1 ) ); |
|
| 241 | - update_option( 'widget_recent-comments', array ( 2 => array ( 'title' => '', 'number' => 5 ), '_multiwidget' => 1 ) ); |
|
| 242 | - update_option( 'widget_archives', array ( 2 => array ( 'title' => '', 'count' => 0, 'dropdown' => 0 ), '_multiwidget' => 1 ) ); |
|
| 243 | - update_option( 'widget_categories', array ( 2 => array ( 'title' => '', 'count' => 0, 'hierarchical' => 0, 'dropdown' => 0 ), '_multiwidget' => 1 ) ); |
|
| 244 | - update_option( 'widget_meta', array ( 2 => array ( 'title' => '' ), '_multiwidget' => 1 ) ); |
|
| 245 | - update_option( 'sidebars_widgets', array ( 'wp_inactive_widgets' => array (), 'sidebar-1' => array ( 0 => 'search-2', 1 => 'recent-posts-2', 2 => 'recent-comments-2', 3 => 'archives-2', 4 => 'categories-2', 5 => 'meta-2', ), 'array_version' => 3 ) ); |
|
| 246 | - |
|
| 247 | - if ( ! is_multisite() ) |
|
| 248 | - update_user_meta( $user_id, 'show_welcome_panel', 1 ); |
|
| 249 | - elseif ( ! is_super_admin( $user_id ) && ! metadata_exists( 'user', $user_id, 'show_welcome_panel' ) ) |
|
| 250 | - update_user_meta( $user_id, 'show_welcome_panel', 2 ); |
|
| 251 | - |
|
| 252 | - if ( is_multisite() ) { |
|
| 239 | + update_option('widget_search', array(2 => array('title' => ''), '_multiwidget' => 1)); |
|
| 240 | + update_option('widget_recent-posts', array(2 => array('title' => '', 'number' => 5), '_multiwidget' => 1)); |
|
| 241 | + update_option('widget_recent-comments', array(2 => array('title' => '', 'number' => 5), '_multiwidget' => 1)); |
|
| 242 | + update_option('widget_archives', array(2 => array('title' => '', 'count' => 0, 'dropdown' => 0), '_multiwidget' => 1)); |
|
| 243 | + update_option('widget_categories', array(2 => array('title' => '', 'count' => 0, 'hierarchical' => 0, 'dropdown' => 0), '_multiwidget' => 1)); |
|
| 244 | + update_option('widget_meta', array(2 => array('title' => ''), '_multiwidget' => 1)); |
|
| 245 | + update_option('sidebars_widgets', array('wp_inactive_widgets' => array(), 'sidebar-1' => array(0 => 'search-2', 1 => 'recent-posts-2', 2 => 'recent-comments-2', 3 => 'archives-2', 4 => 'categories-2', 5 => 'meta-2',), 'array_version' => 3)); |
|
| 246 | + |
|
| 247 | + if ( ! is_multisite()) |
|
| 248 | + update_user_meta($user_id, 'show_welcome_panel', 1); |
|
| 249 | + elseif ( ! is_super_admin($user_id) && ! metadata_exists('user', $user_id, 'show_welcome_panel')) |
|
| 250 | + update_user_meta($user_id, 'show_welcome_panel', 2); |
|
| 251 | + |
|
| 252 | + if (is_multisite()) { |
|
| 253 | 253 | // Flush rules to pick up the new page. |
| 254 | 254 | $wp_rewrite->init(); |
| 255 | 255 | $wp_rewrite->flush_rules(); |
| 256 | 256 | |
| 257 | 257 | $user = new WP_User($user_id); |
| 258 | - $wpdb->update( $wpdb->options, array('option_value' => $user->user_email), array('option_name' => 'admin_email') ); |
|
| 258 | + $wpdb->update($wpdb->options, array('option_value' => $user->user_email), array('option_name' => 'admin_email')); |
|
| 259 | 259 | |
| 260 | 260 | // Remove all perms except for the login user. |
| 261 | - $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'user_level') ); |
|
| 262 | - $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'capabilities') ); |
|
| 261 | + $wpdb->query($wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'user_level')); |
|
| 262 | + $wpdb->query($wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'capabilities')); |
|
| 263 | 263 | |
| 264 | 264 | // Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id. |
| 265 | - if ( !is_super_admin( $user_id ) && $user_id != 1 ) |
|
| 266 | - $wpdb->delete( $wpdb->usermeta, array( 'user_id' => $user_id , 'meta_key' => $wpdb->base_prefix.'1_capabilities' ) ); |
|
| 265 | + if ( ! is_super_admin($user_id) && $user_id != 1) |
|
| 266 | + $wpdb->delete($wpdb->usermeta, array('user_id' => $user_id, 'meta_key' => $wpdb->base_prefix.'1_capabilities')); |
|
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | 269 | endif; |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | global $wp_rewrite; |
| 284 | 284 | |
| 285 | 285 | // Bail if a permalink structure is already enabled. |
| 286 | - if ( get_option( 'permalink_structure' ) ) { |
|
| 286 | + if (get_option('permalink_structure')) { |
|
| 287 | 287 | return true; |
| 288 | 288 | } |
| 289 | 289 | |
@@ -300,20 +300,20 @@ discard block |
||
| 300 | 300 | '/index.php/%year%/%monthnum%/%day%/%postname%/' |
| 301 | 301 | ); |
| 302 | 302 | |
| 303 | - foreach ( (array) $permalink_structures as $permalink_structure ) { |
|
| 304 | - $wp_rewrite->set_permalink_structure( $permalink_structure ); |
|
| 303 | + foreach ((array) $permalink_structures as $permalink_structure) { |
|
| 304 | + $wp_rewrite->set_permalink_structure($permalink_structure); |
|
| 305 | 305 | |
| 306 | 306 | /* |
| 307 | 307 | * Flush rules with the hard option to force refresh of the web-server's |
| 308 | 308 | * rewrite config file (e.g. .htaccess or web.config). |
| 309 | 309 | */ |
| 310 | - $wp_rewrite->flush_rules( true ); |
|
| 310 | + $wp_rewrite->flush_rules(true); |
|
| 311 | 311 | |
| 312 | 312 | // Test against a real WordPress Post, or if none were created, a random 404 page. |
| 313 | - $test_url = get_permalink( 1 ); |
|
| 313 | + $test_url = get_permalink(1); |
|
| 314 | 314 | |
| 315 | - if ( ! $test_url ) { |
|
| 316 | - $test_url = home_url( '/wordpress-check-for-rewrites/' ); |
|
| 315 | + if ( ! $test_url) { |
|
| 316 | + $test_url = home_url('/wordpress-check-for-rewrites/'); |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | /* |
@@ -323,11 +323,11 @@ discard block |
||
| 323 | 323 | * Uses wp_remote_get() instead of wp_remote_head() because web servers |
| 324 | 324 | * can block head requests. |
| 325 | 325 | */ |
| 326 | - $response = wp_remote_get( $test_url, array( 'timeout' => 5 ) ); |
|
| 327 | - $x_pingback_header = wp_remote_retrieve_header( $response, 'x-pingback' ); |
|
| 328 | - $pretty_permalinks = $x_pingback_header && $x_pingback_header === get_bloginfo( 'pingback_url' ); |
|
| 326 | + $response = wp_remote_get($test_url, array('timeout' => 5)); |
|
| 327 | + $x_pingback_header = wp_remote_retrieve_header($response, 'x-pingback'); |
|
| 328 | + $pretty_permalinks = $x_pingback_header && $x_pingback_header === get_bloginfo('pingback_url'); |
|
| 329 | 329 | |
| 330 | - if ( $pretty_permalinks ) { |
|
| 330 | + if ($pretty_permalinks) { |
|
| 331 | 331 | return true; |
| 332 | 332 | } |
| 333 | 333 | } |
@@ -336,13 +336,13 @@ discard block |
||
| 336 | 336 | * If it makes it this far, pretty permalinks failed. |
| 337 | 337 | * Fallback to query-string permalinks. |
| 338 | 338 | */ |
| 339 | - $wp_rewrite->set_permalink_structure( '' ); |
|
| 340 | - $wp_rewrite->flush_rules( true ); |
|
| 339 | + $wp_rewrite->set_permalink_structure(''); |
|
| 340 | + $wp_rewrite->flush_rules(true); |
|
| 341 | 341 | |
| 342 | 342 | return false; |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | -if ( !function_exists('wp_new_blog_notification') ) : |
|
| 345 | +if ( ! function_exists('wp_new_blog_notification')) : |
|
| 346 | 346 | /** |
| 347 | 347 | * Notifies the site admin that the setup is complete. |
| 348 | 348 | * |
@@ -357,11 +357,11 @@ discard block |
||
| 357 | 357 | * @param string $password User's Password. |
| 358 | 358 | */ |
| 359 | 359 | function wp_new_blog_notification($blog_title, $blog_url, $user_id, $password) { |
| 360 | - $user = new WP_User( $user_id ); |
|
| 360 | + $user = new WP_User($user_id); |
|
| 361 | 361 | $email = $user->user_email; |
| 362 | 362 | $name = $user->user_login; |
| 363 | 363 | $login_url = wp_login_url(); |
| 364 | - $message = sprintf( __( "Your new WordPress site has been successfully set up at: |
|
| 364 | + $message = sprintf(__("Your new WordPress site has been successfully set up at: |
|
| 365 | 365 | |
| 366 | 366 | %1\$s |
| 367 | 367 | |
@@ -375,13 +375,13 @@ discard block |
||
| 375 | 375 | |
| 376 | 376 | --The WordPress Team |
| 377 | 377 | https://wordpress.org/ |
| 378 | -"), $blog_url, $name, $password, $login_url ); |
|
| 378 | +"), $blog_url, $name, $password, $login_url); |
|
| 379 | 379 | |
| 380 | 380 | @wp_mail($email, __('New WordPress Site'), $message); |
| 381 | 381 | } |
| 382 | 382 | endif; |
| 383 | 383 | |
| 384 | -if ( !function_exists('wp_upgrade') ) : |
|
| 384 | +if ( ! function_exists('wp_upgrade')) : |
|
| 385 | 385 | /** |
| 386 | 386 | * Runs WordPress Upgrade functions. |
| 387 | 387 | * |
@@ -399,10 +399,10 @@ discard block |
||
| 399 | 399 | $wp_current_db_version = __get_option('db_version'); |
| 400 | 400 | |
| 401 | 401 | // We are up-to-date. Nothing to do. |
| 402 | - if ( $wp_db_version == $wp_current_db_version ) |
|
| 402 | + if ($wp_db_version == $wp_current_db_version) |
|
| 403 | 403 | return; |
| 404 | 404 | |
| 405 | - if ( ! is_blog_installed() ) |
|
| 405 | + if ( ! is_blog_installed()) |
|
| 406 | 406 | return; |
| 407 | 407 | |
| 408 | 408 | wp_check_mysql_version(); |
@@ -410,15 +410,15 @@ discard block |
||
| 410 | 410 | pre_schema_upgrade(); |
| 411 | 411 | make_db_current_silent(); |
| 412 | 412 | upgrade_all(); |
| 413 | - if ( is_multisite() && is_main_site() ) |
|
| 413 | + if (is_multisite() && is_main_site()) |
|
| 414 | 414 | upgrade_network(); |
| 415 | 415 | wp_cache_flush(); |
| 416 | 416 | |
| 417 | - if ( is_multisite() ) { |
|
| 418 | - if ( $wpdb->get_row( "SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'" ) ) |
|
| 419 | - $wpdb->query( "UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'" ); |
|
| 417 | + if (is_multisite()) { |
|
| 418 | + if ($wpdb->get_row("SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'")) |
|
| 419 | + $wpdb->query("UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'"); |
|
| 420 | 420 | else |
| 421 | - $wpdb->query( "INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());" ); |
|
| 421 | + $wpdb->query("INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());"); |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | /** |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | * @param int $wp_db_version The new $wp_db_version. |
| 430 | 430 | * @param int $wp_current_db_version The old (current) $wp_db_version. |
| 431 | 431 | */ |
| 432 | - do_action( 'wp_upgrade', $wp_db_version, $wp_current_db_version ); |
|
| 432 | + do_action('wp_upgrade', $wp_db_version, $wp_current_db_version); |
|
| 433 | 433 | } |
| 434 | 434 | endif; |
| 435 | 435 | |
@@ -449,100 +449,100 @@ discard block |
||
| 449 | 449 | $wp_current_db_version = __get_option('db_version'); |
| 450 | 450 | |
| 451 | 451 | // We are up-to-date. Nothing to do. |
| 452 | - if ( $wp_db_version == $wp_current_db_version ) |
|
| 452 | + if ($wp_db_version == $wp_current_db_version) |
|
| 453 | 453 | return; |
| 454 | 454 | |
| 455 | 455 | // If the version is not set in the DB, try to guess the version. |
| 456 | - if ( empty($wp_current_db_version) ) { |
|
| 456 | + if (empty($wp_current_db_version)) { |
|
| 457 | 457 | $wp_current_db_version = 0; |
| 458 | 458 | |
| 459 | 459 | // If the template option exists, we have 1.5. |
| 460 | 460 | $template = __get_option('template'); |
| 461 | - if ( !empty($template) ) |
|
| 461 | + if ( ! empty($template)) |
|
| 462 | 462 | $wp_current_db_version = 2541; |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | - if ( $wp_current_db_version < 6039 ) |
|
| 465 | + if ($wp_current_db_version < 6039) |
|
| 466 | 466 | upgrade_230_options_table(); |
| 467 | 467 | |
| 468 | 468 | populate_options(); |
| 469 | 469 | |
| 470 | - if ( $wp_current_db_version < 2541 ) { |
|
| 470 | + if ($wp_current_db_version < 2541) { |
|
| 471 | 471 | upgrade_100(); |
| 472 | 472 | upgrade_101(); |
| 473 | 473 | upgrade_110(); |
| 474 | 474 | upgrade_130(); |
| 475 | 475 | } |
| 476 | 476 | |
| 477 | - if ( $wp_current_db_version < 3308 ) |
|
| 477 | + if ($wp_current_db_version < 3308) |
|
| 478 | 478 | upgrade_160(); |
| 479 | 479 | |
| 480 | - if ( $wp_current_db_version < 4772 ) |
|
| 480 | + if ($wp_current_db_version < 4772) |
|
| 481 | 481 | upgrade_210(); |
| 482 | 482 | |
| 483 | - if ( $wp_current_db_version < 4351 ) |
|
| 483 | + if ($wp_current_db_version < 4351) |
|
| 484 | 484 | upgrade_old_slugs(); |
| 485 | 485 | |
| 486 | - if ( $wp_current_db_version < 5539 ) |
|
| 486 | + if ($wp_current_db_version < 5539) |
|
| 487 | 487 | upgrade_230(); |
| 488 | 488 | |
| 489 | - if ( $wp_current_db_version < 6124 ) |
|
| 489 | + if ($wp_current_db_version < 6124) |
|
| 490 | 490 | upgrade_230_old_tables(); |
| 491 | 491 | |
| 492 | - if ( $wp_current_db_version < 7499 ) |
|
| 492 | + if ($wp_current_db_version < 7499) |
|
| 493 | 493 | upgrade_250(); |
| 494 | 494 | |
| 495 | - if ( $wp_current_db_version < 7935 ) |
|
| 495 | + if ($wp_current_db_version < 7935) |
|
| 496 | 496 | upgrade_252(); |
| 497 | 497 | |
| 498 | - if ( $wp_current_db_version < 8201 ) |
|
| 498 | + if ($wp_current_db_version < 8201) |
|
| 499 | 499 | upgrade_260(); |
| 500 | 500 | |
| 501 | - if ( $wp_current_db_version < 8989 ) |
|
| 501 | + if ($wp_current_db_version < 8989) |
|
| 502 | 502 | upgrade_270(); |
| 503 | 503 | |
| 504 | - if ( $wp_current_db_version < 10360 ) |
|
| 504 | + if ($wp_current_db_version < 10360) |
|
| 505 | 505 | upgrade_280(); |
| 506 | 506 | |
| 507 | - if ( $wp_current_db_version < 11958 ) |
|
| 507 | + if ($wp_current_db_version < 11958) |
|
| 508 | 508 | upgrade_290(); |
| 509 | 509 | |
| 510 | - if ( $wp_current_db_version < 15260 ) |
|
| 510 | + if ($wp_current_db_version < 15260) |
|
| 511 | 511 | upgrade_300(); |
| 512 | 512 | |
| 513 | - if ( $wp_current_db_version < 19389 ) |
|
| 513 | + if ($wp_current_db_version < 19389) |
|
| 514 | 514 | upgrade_330(); |
| 515 | 515 | |
| 516 | - if ( $wp_current_db_version < 20080 ) |
|
| 516 | + if ($wp_current_db_version < 20080) |
|
| 517 | 517 | upgrade_340(); |
| 518 | 518 | |
| 519 | - if ( $wp_current_db_version < 22422 ) |
|
| 519 | + if ($wp_current_db_version < 22422) |
|
| 520 | 520 | upgrade_350(); |
| 521 | 521 | |
| 522 | - if ( $wp_current_db_version < 25824 ) |
|
| 522 | + if ($wp_current_db_version < 25824) |
|
| 523 | 523 | upgrade_370(); |
| 524 | 524 | |
| 525 | - if ( $wp_current_db_version < 26148 ) |
|
| 525 | + if ($wp_current_db_version < 26148) |
|
| 526 | 526 | upgrade_372(); |
| 527 | 527 | |
| 528 | - if ( $wp_current_db_version < 26691 ) |
|
| 528 | + if ($wp_current_db_version < 26691) |
|
| 529 | 529 | upgrade_380(); |
| 530 | 530 | |
| 531 | - if ( $wp_current_db_version < 29630 ) |
|
| 531 | + if ($wp_current_db_version < 29630) |
|
| 532 | 532 | upgrade_400(); |
| 533 | 533 | |
| 534 | - if ( $wp_current_db_version < 33055 ) |
|
| 534 | + if ($wp_current_db_version < 33055) |
|
| 535 | 535 | upgrade_430(); |
| 536 | 536 | |
| 537 | - if ( $wp_current_db_version < 33056 ) |
|
| 537 | + if ($wp_current_db_version < 33056) |
|
| 538 | 538 | upgrade_431(); |
| 539 | 539 | |
| 540 | 540 | maybe_disable_link_manager(); |
| 541 | 541 | |
| 542 | 542 | maybe_disable_automattic_widgets(); |
| 543 | 543 | |
| 544 | - update_option( 'db_version', $wp_db_version ); |
|
| 545 | - update_option( 'db_upgraded', true ); |
|
| 544 | + update_option('db_version', $wp_db_version); |
|
| 545 | + update_option('db_upgraded', true); |
|
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | /** |
@@ -558,10 +558,10 @@ discard block |
||
| 558 | 558 | // Get the title and ID of every post, post_name to check if it already has a value |
| 559 | 559 | $posts = $wpdb->get_results("SELECT ID, post_title, post_name FROM $wpdb->posts WHERE post_name = ''"); |
| 560 | 560 | if ($posts) { |
| 561 | - foreach($posts as $post) { |
|
| 561 | + foreach ($posts as $post) { |
|
| 562 | 562 | if ('' == $post->post_name) { |
| 563 | 563 | $newtitle = sanitize_title($post->post_title); |
| 564 | - $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_name = %s WHERE ID = %d", $newtitle, $post->ID) ); |
|
| 564 | + $wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET post_name = %s WHERE ID = %d", $newtitle, $post->ID)); |
|
| 565 | 565 | } |
| 566 | 566 | } |
| 567 | 567 | } |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | foreach ($categories as $category) { |
| 571 | 571 | if ('' == $category->category_nicename) { |
| 572 | 572 | $newtitle = sanitize_title($category->cat_name); |
| 573 | - $wpdb->update( $wpdb->categories, array('category_nicename' => $newtitle), array('cat_ID' => $category->cat_ID) ); |
|
| 573 | + $wpdb->update($wpdb->categories, array('category_nicename' => $newtitle), array('cat_ID' => $category->cat_ID)); |
|
| 574 | 574 | } |
| 575 | 575 | } |
| 576 | 576 | |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | SET option_value = REPLACE(option_value, 'wp-links/links-images/', 'wp-images/links/') |
| 579 | 579 | WHERE option_name LIKE %s |
| 580 | 580 | AND option_value LIKE %s"; |
| 581 | - $wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( 'links_rating_image' ) . '%', $wpdb->esc_like( 'wp-links/links-images/' ) . '%' ) ); |
|
| 581 | + $wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('links_rating_image').'%', $wpdb->esc_like('wp-links/links-images/').'%')); |
|
| 582 | 582 | |
| 583 | 583 | $done_ids = $wpdb->get_results("SELECT DISTINCT post_id FROM $wpdb->post2cat"); |
| 584 | 584 | if ($done_ids) : |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | foreach ($done_ids as $done_id) : |
| 587 | 587 | $done_posts[] = $done_id->post_id; |
| 588 | 588 | endforeach; |
| 589 | - $catwhere = ' AND ID NOT IN (' . implode(',', $done_posts) . ')'; |
|
| 589 | + $catwhere = ' AND ID NOT IN ('.implode(',', $done_posts).')'; |
|
| 590 | 590 | else: |
| 591 | 591 | $catwhere = ''; |
| 592 | 592 | endif; |
@@ -595,9 +595,9 @@ discard block |
||
| 595 | 595 | if ($allposts) : |
| 596 | 596 | foreach ($allposts as $post) { |
| 597 | 597 | // Check to see if it's already been imported |
| 598 | - $cat = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->post2cat WHERE post_id = %d AND category_id = %d", $post->ID, $post->post_category) ); |
|
| 599 | - if (!$cat && 0 != $post->post_category) { // If there's no result |
|
| 600 | - $wpdb->insert( $wpdb->post2cat, array('post_id' => $post->ID, 'category_id' => $post->post_category) ); |
|
| 598 | + $cat = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->post2cat WHERE post_id = %d AND category_id = %d", $post->ID, $post->post_category)); |
|
| 599 | + if ( ! $cat && 0 != $post->post_category) { // If there's no result |
|
| 600 | + $wpdb->insert($wpdb->post2cat, array('post_id' => $post->ID, 'category_id' => $post->post_category)); |
|
| 601 | 601 | } |
| 602 | 602 | } |
| 603 | 603 | endif; |
@@ -619,8 +619,8 @@ discard block |
||
| 619 | 619 | add_clean_index($wpdb->categories, 'category_nicename'); |
| 620 | 620 | add_clean_index($wpdb->comments, 'comment_approved'); |
| 621 | 621 | add_clean_index($wpdb->comments, 'comment_post_ID'); |
| 622 | - add_clean_index($wpdb->links , 'link_category'); |
|
| 623 | - add_clean_index($wpdb->links , 'link_visible'); |
|
| 622 | + add_clean_index($wpdb->links, 'link_category'); |
|
| 623 | + add_clean_index($wpdb->links, 'link_visible'); |
|
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | /** |
@@ -638,14 +638,14 @@ discard block |
||
| 638 | 638 | foreach ($users as $user) { |
| 639 | 639 | if ('' == $user->user_nicename) { |
| 640 | 640 | $newname = sanitize_title($user->user_nickname); |
| 641 | - $wpdb->update( $wpdb->users, array('user_nicename' => $newname), array('ID' => $user->ID) ); |
|
| 641 | + $wpdb->update($wpdb->users, array('user_nicename' => $newname), array('ID' => $user->ID)); |
|
| 642 | 642 | } |
| 643 | 643 | } |
| 644 | 644 | |
| 645 | 645 | $users = $wpdb->get_results("SELECT ID, user_pass from $wpdb->users"); |
| 646 | 646 | foreach ($users as $row) { |
| 647 | - if (!preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) { |
|
| 648 | - $wpdb->update( $wpdb->users, array('user_pass' => md5($row->user_pass)), array('ID' => $row->ID) ); |
|
| 647 | + if ( ! preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) { |
|
| 648 | + $wpdb->update($wpdb->users, array('user_pass' => md5($row->user_pass)), array('ID' => $row->ID)); |
|
| 649 | 649 | } |
| 650 | 650 | } |
| 651 | 651 | |
@@ -654,7 +654,7 @@ discard block |
||
| 654 | 654 | |
| 655 | 655 | $time_difference = $all_options->time_difference; |
| 656 | 656 | |
| 657 | - $server_time = time()+date('Z'); |
|
| 657 | + $server_time = time() + date('Z'); |
|
| 658 | 658 | $weblogger_time = $server_time + $time_difference * HOUR_IN_SECONDS; |
| 659 | 659 | $gmt_time = time(); |
| 660 | 660 | |
@@ -671,7 +671,7 @@ discard block |
||
| 671 | 671 | // <michel_v> I just slapped myself silly for not thinking about it earlier |
| 672 | 672 | $got_gmt_fields = ! ($wpdb->get_var("SELECT MAX(post_date_gmt) FROM $wpdb->posts") == '0000-00-00 00:00:00'); |
| 673 | 673 | |
| 674 | - if (!$got_gmt_fields) { |
|
| 674 | + if ( ! $got_gmt_fields) { |
|
| 675 | 675 | |
| 676 | 676 | // Add or subtract time to all dates, to get GMT dates |
| 677 | 677 | $add_hours = intval($diff_gmt_weblogger); |
@@ -698,16 +698,16 @@ discard block |
||
| 698 | 698 | // Remove extraneous backslashes. |
| 699 | 699 | $posts = $wpdb->get_results("SELECT ID, post_title, post_content, post_excerpt, guid, post_date, post_name, post_status, post_author FROM $wpdb->posts"); |
| 700 | 700 | if ($posts) { |
| 701 | - foreach($posts as $post) { |
|
| 701 | + foreach ($posts as $post) { |
|
| 702 | 702 | $post_content = addslashes(deslash($post->post_content)); |
| 703 | 703 | $post_title = addslashes(deslash($post->post_title)); |
| 704 | 704 | $post_excerpt = addslashes(deslash($post->post_excerpt)); |
| 705 | - if ( empty($post->guid) ) |
|
| 705 | + if (empty($post->guid)) |
|
| 706 | 706 | $guid = get_permalink($post->ID); |
| 707 | 707 | else |
| 708 | 708 | $guid = $post->guid; |
| 709 | 709 | |
| 710 | - $wpdb->update( $wpdb->posts, compact('post_title', 'post_content', 'post_excerpt', 'guid'), array('ID' => $post->ID) ); |
|
| 710 | + $wpdb->update($wpdb->posts, compact('post_title', 'post_content', 'post_excerpt', 'guid'), array('ID' => $post->ID)); |
|
| 711 | 711 | |
| 712 | 712 | } |
| 713 | 713 | } |
@@ -715,22 +715,22 @@ discard block |
||
| 715 | 715 | // Remove extraneous backslashes. |
| 716 | 716 | $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_content FROM $wpdb->comments"); |
| 717 | 717 | if ($comments) { |
| 718 | - foreach($comments as $comment) { |
|
| 718 | + foreach ($comments as $comment) { |
|
| 719 | 719 | $comment_content = deslash($comment->comment_content); |
| 720 | 720 | $comment_author = deslash($comment->comment_author); |
| 721 | 721 | |
| 722 | - $wpdb->update($wpdb->comments, compact('comment_content', 'comment_author'), array('comment_ID' => $comment->comment_ID) ); |
|
| 722 | + $wpdb->update($wpdb->comments, compact('comment_content', 'comment_author'), array('comment_ID' => $comment->comment_ID)); |
|
| 723 | 723 | } |
| 724 | 724 | } |
| 725 | 725 | |
| 726 | 726 | // Remove extraneous backslashes. |
| 727 | 727 | $links = $wpdb->get_results("SELECT link_id, link_name, link_description FROM $wpdb->links"); |
| 728 | 728 | if ($links) { |
| 729 | - foreach($links as $link) { |
|
| 729 | + foreach ($links as $link) { |
|
| 730 | 730 | $link_name = deslash($link->link_name); |
| 731 | 731 | $link_description = deslash($link->link_description); |
| 732 | 732 | |
| 733 | - $wpdb->update( $wpdb->links, compact('link_name', 'link_description'), array('link_id' => $link->link_id) ); |
|
| 733 | + $wpdb->update($wpdb->links, compact('link_name', 'link_description'), array('link_id' => $link->link_id)); |
|
| 734 | 734 | } |
| 735 | 735 | } |
| 736 | 736 | |
@@ -740,16 +740,16 @@ discard block |
||
| 740 | 740 | * If plugins are not stored in an array, they're stored in the old |
| 741 | 741 | * newline separated format. Convert to new format. |
| 742 | 742 | */ |
| 743 | - if ( !is_array( $active_plugins ) ) { |
|
| 743 | + if ( ! is_array($active_plugins)) { |
|
| 744 | 744 | $active_plugins = explode("\n", trim($active_plugins)); |
| 745 | 745 | update_option('active_plugins', $active_plugins); |
| 746 | 746 | } |
| 747 | 747 | |
| 748 | 748 | // Obsolete tables |
| 749 | - $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optionvalues'); |
|
| 750 | - $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiontypes'); |
|
| 751 | - $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroups'); |
|
| 752 | - $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroup_options'); |
|
| 749 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'optionvalues'); |
|
| 750 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'optiontypes'); |
|
| 751 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'optiongroups'); |
|
| 752 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'optiongroup_options'); |
|
| 753 | 753 | |
| 754 | 754 | // Update comments table to use comment_type |
| 755 | 755 | $wpdb->query("UPDATE $wpdb->comments SET comment_type='trackback', comment_content = REPLACE(comment_content, '<trackback />', '') WHERE comment_content LIKE '<trackback />%'"); |
@@ -757,11 +757,11 @@ discard block |
||
| 757 | 757 | |
| 758 | 758 | // Some versions have multiple duplicate option_name rows with the same values |
| 759 | 759 | $options = $wpdb->get_results("SELECT option_name, COUNT(option_name) AS dupes FROM `$wpdb->options` GROUP BY option_name"); |
| 760 | - foreach ( $options as $option ) { |
|
| 761 | - if ( 1 != $option->dupes ) { // Could this be done in the query? |
|
| 760 | + foreach ($options as $option) { |
|
| 761 | + if (1 != $option->dupes) { // Could this be done in the query? |
|
| 762 | 762 | $limit = $option->dupes - 1; |
| 763 | - $dupe_ids = $wpdb->get_col( $wpdb->prepare("SELECT option_id FROM $wpdb->options WHERE option_name = %s LIMIT %d", $option->option_name, $limit) ); |
|
| 764 | - if ( $dupe_ids ) { |
|
| 763 | + $dupe_ids = $wpdb->get_col($wpdb->prepare("SELECT option_id FROM $wpdb->options WHERE option_name = %s LIMIT %d", $option->option_name, $limit)); |
|
| 764 | + if ($dupe_ids) { |
|
| 765 | 765 | $dupe_ids = join($dupe_ids, ','); |
| 766 | 766 | $wpdb->query("DELETE FROM $wpdb->options WHERE option_id IN ($dupe_ids)"); |
| 767 | 767 | } |
@@ -785,27 +785,27 @@ discard block |
||
| 785 | 785 | populate_roles_160(); |
| 786 | 786 | |
| 787 | 787 | $users = $wpdb->get_results("SELECT * FROM $wpdb->users"); |
| 788 | - foreach ( $users as $user ) : |
|
| 789 | - if ( !empty( $user->user_firstname ) ) |
|
| 790 | - update_user_meta( $user->ID, 'first_name', wp_slash($user->user_firstname) ); |
|
| 791 | - if ( !empty( $user->user_lastname ) ) |
|
| 792 | - update_user_meta( $user->ID, 'last_name', wp_slash($user->user_lastname) ); |
|
| 793 | - if ( !empty( $user->user_nickname ) ) |
|
| 794 | - update_user_meta( $user->ID, 'nickname', wp_slash($user->user_nickname) ); |
|
| 795 | - if ( !empty( $user->user_level ) ) |
|
| 796 | - update_user_meta( $user->ID, $wpdb->prefix . 'user_level', $user->user_level ); |
|
| 797 | - if ( !empty( $user->user_icq ) ) |
|
| 798 | - update_user_meta( $user->ID, 'icq', wp_slash($user->user_icq) ); |
|
| 799 | - if ( !empty( $user->user_aim ) ) |
|
| 800 | - update_user_meta( $user->ID, 'aim', wp_slash($user->user_aim) ); |
|
| 801 | - if ( !empty( $user->user_msn ) ) |
|
| 802 | - update_user_meta( $user->ID, 'msn', wp_slash($user->user_msn) ); |
|
| 803 | - if ( !empty( $user->user_yim ) ) |
|
| 804 | - update_user_meta( $user->ID, 'yim', wp_slash($user->user_icq) ); |
|
| 805 | - if ( !empty( $user->user_description ) ) |
|
| 806 | - update_user_meta( $user->ID, 'description', wp_slash($user->user_description) ); |
|
| 807 | - |
|
| 808 | - if ( isset( $user->user_idmode ) ): |
|
| 788 | + foreach ($users as $user) : |
|
| 789 | + if ( ! empty($user->user_firstname)) |
|
| 790 | + update_user_meta($user->ID, 'first_name', wp_slash($user->user_firstname)); |
|
| 791 | + if ( ! empty($user->user_lastname)) |
|
| 792 | + update_user_meta($user->ID, 'last_name', wp_slash($user->user_lastname)); |
|
| 793 | + if ( ! empty($user->user_nickname)) |
|
| 794 | + update_user_meta($user->ID, 'nickname', wp_slash($user->user_nickname)); |
|
| 795 | + if ( ! empty($user->user_level)) |
|
| 796 | + update_user_meta($user->ID, $wpdb->prefix.'user_level', $user->user_level); |
|
| 797 | + if ( ! empty($user->user_icq)) |
|
| 798 | + update_user_meta($user->ID, 'icq', wp_slash($user->user_icq)); |
|
| 799 | + if ( ! empty($user->user_aim)) |
|
| 800 | + update_user_meta($user->ID, 'aim', wp_slash($user->user_aim)); |
|
| 801 | + if ( ! empty($user->user_msn)) |
|
| 802 | + update_user_meta($user->ID, 'msn', wp_slash($user->user_msn)); |
|
| 803 | + if ( ! empty($user->user_yim)) |
|
| 804 | + update_user_meta($user->ID, 'yim', wp_slash($user->user_icq)); |
|
| 805 | + if ( ! empty($user->user_description)) |
|
| 806 | + update_user_meta($user->ID, 'description', wp_slash($user->user_description)); |
|
| 807 | + |
|
| 808 | + if (isset($user->user_idmode)): |
|
| 809 | 809 | $idmode = $user->user_idmode; |
| 810 | 810 | if ($idmode == 'nickname') $id = $user->user_nickname; |
| 811 | 811 | if ($idmode == 'login') $id = $user->user_login; |
@@ -813,46 +813,46 @@ discard block |
||
| 813 | 813 | if ($idmode == 'lastname') $id = $user->user_lastname; |
| 814 | 814 | if ($idmode == 'namefl') $id = $user->user_firstname.' '.$user->user_lastname; |
| 815 | 815 | if ($idmode == 'namelf') $id = $user->user_lastname.' '.$user->user_firstname; |
| 816 | - if (!$idmode) $id = $user->user_nickname; |
|
| 817 | - $wpdb->update( $wpdb->users, array('display_name' => $id), array('ID' => $user->ID) ); |
|
| 816 | + if ( ! $idmode) $id = $user->user_nickname; |
|
| 817 | + $wpdb->update($wpdb->users, array('display_name' => $id), array('ID' => $user->ID)); |
|
| 818 | 818 | endif; |
| 819 | 819 | |
| 820 | 820 | // FIXME: RESET_CAPS is temporary code to reset roles and caps if flag is set. |
| 821 | - $caps = get_user_meta( $user->ID, $wpdb->prefix . 'capabilities'); |
|
| 822 | - if ( empty($caps) || defined('RESET_CAPS') ) { |
|
| 823 | - $level = get_user_meta($user->ID, $wpdb->prefix . 'user_level', true); |
|
| 821 | + $caps = get_user_meta($user->ID, $wpdb->prefix.'capabilities'); |
|
| 822 | + if (empty($caps) || defined('RESET_CAPS')) { |
|
| 823 | + $level = get_user_meta($user->ID, $wpdb->prefix.'user_level', true); |
|
| 824 | 824 | $role = translate_level_to_role($level); |
| 825 | - update_user_meta( $user->ID, $wpdb->prefix . 'capabilities', array($role => true) ); |
|
| 825 | + update_user_meta($user->ID, $wpdb->prefix.'capabilities', array($role => true)); |
|
| 826 | 826 | } |
| 827 | 827 | |
| 828 | 828 | endforeach; |
| 829 | - $old_user_fields = array( 'user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level' ); |
|
| 829 | + $old_user_fields = array('user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level'); |
|
| 830 | 830 | $wpdb->hide_errors(); |
| 831 | - foreach ( $old_user_fields as $old ) |
|
| 831 | + foreach ($old_user_fields as $old) |
|
| 832 | 832 | $wpdb->query("ALTER TABLE $wpdb->users DROP $old"); |
| 833 | 833 | $wpdb->show_errors(); |
| 834 | 834 | |
| 835 | 835 | // Populate comment_count field of posts table. |
| 836 | - $comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" ); |
|
| 837 | - if ( is_array( $comments ) ) |
|
| 836 | + $comments = $wpdb->get_results("SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID"); |
|
| 837 | + if (is_array($comments)) |
|
| 838 | 838 | foreach ($comments as $comment) |
| 839 | - $wpdb->update( $wpdb->posts, array('comment_count' => $comment->c), array('ID' => $comment->comment_post_ID) ); |
|
| 839 | + $wpdb->update($wpdb->posts, array('comment_count' => $comment->c), array('ID' => $comment->comment_post_ID)); |
|
| 840 | 840 | |
| 841 | 841 | /* |
| 842 | 842 | * Some alpha versions used a post status of object instead of attachment |
| 843 | 843 | * and put the mime type in post_type instead of post_mime_type. |
| 844 | 844 | */ |
| 845 | - if ( $wp_current_db_version > 2541 && $wp_current_db_version <= 3091 ) { |
|
| 845 | + if ($wp_current_db_version > 2541 && $wp_current_db_version <= 3091) { |
|
| 846 | 846 | $objects = $wpdb->get_results("SELECT ID, post_type FROM $wpdb->posts WHERE post_status = 'object'"); |
| 847 | 847 | foreach ($objects as $object) { |
| 848 | - $wpdb->update( $wpdb->posts, array( 'post_status' => 'attachment', |
|
| 848 | + $wpdb->update($wpdb->posts, array('post_status' => 'attachment', |
|
| 849 | 849 | 'post_mime_type' => $object->post_type, |
| 850 | 850 | 'post_type' => ''), |
| 851 | - array( 'ID' => $object->ID ) ); |
|
| 851 | + array('ID' => $object->ID)); |
|
| 852 | 852 | |
| 853 | 853 | $meta = get_post_meta($object->ID, 'imagedata', true); |
| 854 | - if ( ! empty($meta['file']) ) |
|
| 855 | - update_attached_file( $object->ID, $meta['file'] ); |
|
| 854 | + if ( ! empty($meta['file'])) |
|
| 855 | + update_attached_file($object->ID, $meta['file']); |
|
| 856 | 856 | } |
| 857 | 857 | } |
| 858 | 858 | } |
@@ -868,38 +868,38 @@ discard block |
||
| 868 | 868 | function upgrade_210() { |
| 869 | 869 | global $wpdb, $wp_current_db_version; |
| 870 | 870 | |
| 871 | - if ( $wp_current_db_version < 3506 ) { |
|
| 871 | + if ($wp_current_db_version < 3506) { |
|
| 872 | 872 | // Update status and type. |
| 873 | 873 | $posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts"); |
| 874 | 874 | |
| 875 | - if ( ! empty($posts) ) foreach ($posts as $post) { |
|
| 875 | + if ( ! empty($posts)) foreach ($posts as $post) { |
|
| 876 | 876 | $status = $post->post_status; |
| 877 | 877 | $type = 'post'; |
| 878 | 878 | |
| 879 | - if ( 'static' == $status ) { |
|
| 879 | + if ('static' == $status) { |
|
| 880 | 880 | $status = 'publish'; |
| 881 | 881 | $type = 'page'; |
| 882 | - } elseif ( 'attachment' == $status ) { |
|
| 882 | + } elseif ('attachment' == $status) { |
|
| 883 | 883 | $status = 'inherit'; |
| 884 | 884 | $type = 'attachment'; |
| 885 | 885 | } |
| 886 | 886 | |
| 887 | - $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_status = %s, post_type = %s WHERE ID = %d", $status, $type, $post->ID) ); |
|
| 887 | + $wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET post_status = %s, post_type = %s WHERE ID = %d", $status, $type, $post->ID)); |
|
| 888 | 888 | } |
| 889 | 889 | } |
| 890 | 890 | |
| 891 | - if ( $wp_current_db_version < 3845 ) { |
|
| 891 | + if ($wp_current_db_version < 3845) { |
|
| 892 | 892 | populate_roles_210(); |
| 893 | 893 | } |
| 894 | 894 | |
| 895 | - if ( $wp_current_db_version < 3531 ) { |
|
| 895 | + if ($wp_current_db_version < 3531) { |
|
| 896 | 896 | // Give future posts a post_status of future. |
| 897 | 897 | $now = gmdate('Y-m-d H:i:59'); |
| 898 | - $wpdb->query ("UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'"); |
|
| 898 | + $wpdb->query("UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'"); |
|
| 899 | 899 | |
| 900 | 900 | $posts = $wpdb->get_results("SELECT ID, post_date FROM $wpdb->posts WHERE post_status ='future'"); |
| 901 | - if ( !empty($posts) ) |
|
| 902 | - foreach ( $posts as $post ) |
|
| 901 | + if ( ! empty($posts)) |
|
| 902 | + foreach ($posts as $post) |
|
| 903 | 903 | wp_schedule_single_event(mysql2date('U', $post->post_date, false), 'publish_future_post', array($post->ID)); |
| 904 | 904 | } |
| 905 | 905 | } |
@@ -915,7 +915,7 @@ discard block |
||
| 915 | 915 | function upgrade_230() { |
| 916 | 916 | global $wp_current_db_version, $wpdb; |
| 917 | 917 | |
| 918 | - if ( $wp_current_db_version < 5200 ) { |
|
| 918 | + if ($wp_current_db_version < 5200) { |
|
| 919 | 919 | populate_roles_230(); |
| 920 | 920 | } |
| 921 | 921 | |
@@ -932,78 +932,78 @@ discard block |
||
| 932 | 932 | $term_group = 0; |
| 933 | 933 | |
| 934 | 934 | // Associate terms with the same slug in a term group and make slugs unique. |
| 935 | - if ( $exists = $wpdb->get_results( $wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug) ) ) { |
|
| 935 | + if ($exists = $wpdb->get_results($wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug))) { |
|
| 936 | 936 | $term_group = $exists[0]->term_group; |
| 937 | 937 | $id = $exists[0]->term_id; |
| 938 | 938 | $num = 2; |
| 939 | 939 | do { |
| 940 | - $alt_slug = $slug . "-$num"; |
|
| 940 | + $alt_slug = $slug."-$num"; |
|
| 941 | 941 | $num++; |
| 942 | - $slug_check = $wpdb->get_var( $wpdb->prepare("SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug) ); |
|
| 943 | - } while ( $slug_check ); |
|
| 942 | + $slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug)); |
|
| 943 | + } while ($slug_check); |
|
| 944 | 944 | |
| 945 | 945 | $slug = $alt_slug; |
| 946 | 946 | |
| 947 | - if ( empty( $term_group ) ) { |
|
| 947 | + if (empty($term_group)) { |
|
| 948 | 948 | $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms GROUP BY term_group") + 1; |
| 949 | - $wpdb->query( $wpdb->prepare("UPDATE $wpdb->terms SET term_group = %d WHERE term_id = %d", $term_group, $id) ); |
|
| 949 | + $wpdb->query($wpdb->prepare("UPDATE $wpdb->terms SET term_group = %d WHERE term_id = %d", $term_group, $id)); |
|
| 950 | 950 | } |
| 951 | 951 | } |
| 952 | 952 | |
| 953 | - $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->terms (term_id, name, slug, term_group) VALUES |
|
| 954 | - (%d, %s, %s, %d)", $term_id, $name, $slug, $term_group) ); |
|
| 953 | + $wpdb->query($wpdb->prepare("INSERT INTO $wpdb->terms (term_id, name, slug, term_group) VALUES |
|
| 954 | + (%d, %s, %s, %d)", $term_id, $name, $slug, $term_group)); |
|
| 955 | 955 | |
| 956 | 956 | $count = 0; |
| 957 | - if ( !empty($category->category_count) ) { |
|
| 957 | + if ( ! empty($category->category_count)) { |
|
| 958 | 958 | $count = (int) $category->category_count; |
| 959 | 959 | $taxonomy = 'category'; |
| 960 | - $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count) ); |
|
| 960 | + $wpdb->query($wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count)); |
|
| 961 | 961 | $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id; |
| 962 | 962 | } |
| 963 | 963 | |
| 964 | - if ( !empty($category->link_count) ) { |
|
| 964 | + if ( ! empty($category->link_count)) { |
|
| 965 | 965 | $count = (int) $category->link_count; |
| 966 | 966 | $taxonomy = 'link_category'; |
| 967 | - $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count) ); |
|
| 967 | + $wpdb->query($wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count)); |
|
| 968 | 968 | $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id; |
| 969 | 969 | } |
| 970 | 970 | |
| 971 | - if ( !empty($category->tag_count) ) { |
|
| 971 | + if ( ! empty($category->tag_count)) { |
|
| 972 | 972 | $have_tags = true; |
| 973 | 973 | $count = (int) $category->tag_count; |
| 974 | 974 | $taxonomy = 'post_tag'; |
| 975 | - $wpdb->insert( $wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count') ); |
|
| 975 | + $wpdb->insert($wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count')); |
|
| 976 | 976 | $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id; |
| 977 | 977 | } |
| 978 | 978 | |
| 979 | - if ( empty($count) ) { |
|
| 979 | + if (empty($count)) { |
|
| 980 | 980 | $count = 0; |
| 981 | 981 | $taxonomy = 'category'; |
| 982 | - $wpdb->insert( $wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count') ); |
|
| 982 | + $wpdb->insert($wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count')); |
|
| 983 | 983 | $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id; |
| 984 | 984 | } |
| 985 | 985 | } |
| 986 | 986 | |
| 987 | 987 | $select = 'post_id, category_id'; |
| 988 | - if ( $have_tags ) |
|
| 988 | + if ($have_tags) |
|
| 989 | 989 | $select .= ', rel_type'; |
| 990 | 990 | |
| 991 | 991 | $posts = $wpdb->get_results("SELECT $select FROM $wpdb->post2cat GROUP BY post_id, category_id"); |
| 992 | - foreach ( $posts as $post ) { |
|
| 992 | + foreach ($posts as $post) { |
|
| 993 | 993 | $post_id = (int) $post->post_id; |
| 994 | 994 | $term_id = (int) $post->category_id; |
| 995 | 995 | $taxonomy = 'category'; |
| 996 | - if ( !empty($post->rel_type) && 'tag' == $post->rel_type) |
|
| 996 | + if ( ! empty($post->rel_type) && 'tag' == $post->rel_type) |
|
| 997 | 997 | $taxonomy = 'tag'; |
| 998 | 998 | $tt_id = $tt_ids[$term_id][$taxonomy]; |
| 999 | - if ( empty($tt_id) ) |
|
| 999 | + if (empty($tt_id)) |
|
| 1000 | 1000 | continue; |
| 1001 | 1001 | |
| 1002 | - $wpdb->insert( $wpdb->term_relationships, array('object_id' => $post_id, 'term_taxonomy_id' => $tt_id) ); |
|
| 1002 | + $wpdb->insert($wpdb->term_relationships, array('object_id' => $post_id, 'term_taxonomy_id' => $tt_id)); |
|
| 1003 | 1003 | } |
| 1004 | 1004 | |
| 1005 | 1005 | // < 3570 we used linkcategories. >= 3570 we used categories and link2cat. |
| 1006 | - if ( $wp_current_db_version < 3570 ) { |
|
| 1006 | + if ($wp_current_db_version < 3570) { |
|
| 1007 | 1007 | /* |
| 1008 | 1008 | * Create link_category terms for link categories. Create a map of link |
| 1009 | 1009 | * cat IDs to link_category terms. |
@@ -1011,8 +1011,8 @@ discard block |
||
| 1011 | 1011 | $link_cat_id_map = array(); |
| 1012 | 1012 | $default_link_cat = 0; |
| 1013 | 1013 | $tt_ids = array(); |
| 1014 | - $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM " . $wpdb->prefix . 'linkcategories'); |
|
| 1015 | - foreach ( $link_cats as $category) { |
|
| 1014 | + $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM ".$wpdb->prefix.'linkcategories'); |
|
| 1015 | + foreach ($link_cats as $category) { |
|
| 1016 | 1016 | $cat_id = (int) $category->cat_id; |
| 1017 | 1017 | $term_id = 0; |
| 1018 | 1018 | $name = wp_slash($category->cat_name); |
@@ -1020,66 +1020,66 @@ discard block |
||
| 1020 | 1020 | $term_group = 0; |
| 1021 | 1021 | |
| 1022 | 1022 | // Associate terms with the same slug in a term group and make slugs unique. |
| 1023 | - if ( $exists = $wpdb->get_results( $wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug) ) ) { |
|
| 1023 | + if ($exists = $wpdb->get_results($wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug))) { |
|
| 1024 | 1024 | $term_group = $exists[0]->term_group; |
| 1025 | 1025 | $term_id = $exists[0]->term_id; |
| 1026 | 1026 | } |
| 1027 | 1027 | |
| 1028 | - if ( empty($term_id) ) { |
|
| 1029 | - $wpdb->insert( $wpdb->terms, compact('name', 'slug', 'term_group') ); |
|
| 1028 | + if (empty($term_id)) { |
|
| 1029 | + $wpdb->insert($wpdb->terms, compact('name', 'slug', 'term_group')); |
|
| 1030 | 1030 | $term_id = (int) $wpdb->insert_id; |
| 1031 | 1031 | } |
| 1032 | 1032 | |
| 1033 | 1033 | $link_cat_id_map[$cat_id] = $term_id; |
| 1034 | 1034 | $default_link_cat = $term_id; |
| 1035 | 1035 | |
| 1036 | - $wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $term_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 0) ); |
|
| 1036 | + $wpdb->insert($wpdb->term_taxonomy, array('term_id' => $term_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 0)); |
|
| 1037 | 1037 | $tt_ids[$term_id] = (int) $wpdb->insert_id; |
| 1038 | 1038 | } |
| 1039 | 1039 | |
| 1040 | 1040 | // Associate links to cats. |
| 1041 | 1041 | $links = $wpdb->get_results("SELECT link_id, link_category FROM $wpdb->links"); |
| 1042 | - if ( !empty($links) ) foreach ( $links as $link ) { |
|
| 1043 | - if ( 0 == $link->link_category ) |
|
| 1042 | + if ( ! empty($links)) foreach ($links as $link) { |
|
| 1043 | + if (0 == $link->link_category) |
|
| 1044 | 1044 | continue; |
| 1045 | - if ( ! isset($link_cat_id_map[$link->link_category]) ) |
|
| 1045 | + if ( ! isset($link_cat_id_map[$link->link_category])) |
|
| 1046 | 1046 | continue; |
| 1047 | 1047 | $term_id = $link_cat_id_map[$link->link_category]; |
| 1048 | 1048 | $tt_id = $tt_ids[$term_id]; |
| 1049 | - if ( empty($tt_id) ) |
|
| 1049 | + if (empty($tt_id)) |
|
| 1050 | 1050 | continue; |
| 1051 | 1051 | |
| 1052 | - $wpdb->insert( $wpdb->term_relationships, array('object_id' => $link->link_id, 'term_taxonomy_id' => $tt_id) ); |
|
| 1052 | + $wpdb->insert($wpdb->term_relationships, array('object_id' => $link->link_id, 'term_taxonomy_id' => $tt_id)); |
|
| 1053 | 1053 | } |
| 1054 | 1054 | |
| 1055 | 1055 | // Set default to the last category we grabbed during the upgrade loop. |
| 1056 | 1056 | update_option('default_link_category', $default_link_cat); |
| 1057 | 1057 | } else { |
| 1058 | 1058 | $links = $wpdb->get_results("SELECT link_id, category_id FROM $wpdb->link2cat GROUP BY link_id, category_id"); |
| 1059 | - foreach ( $links as $link ) { |
|
| 1059 | + foreach ($links as $link) { |
|
| 1060 | 1060 | $link_id = (int) $link->link_id; |
| 1061 | 1061 | $term_id = (int) $link->category_id; |
| 1062 | 1062 | $taxonomy = 'link_category'; |
| 1063 | 1063 | $tt_id = $tt_ids[$term_id][$taxonomy]; |
| 1064 | - if ( empty($tt_id) ) |
|
| 1064 | + if (empty($tt_id)) |
|
| 1065 | 1065 | continue; |
| 1066 | - $wpdb->insert( $wpdb->term_relationships, array('object_id' => $link_id, 'term_taxonomy_id' => $tt_id) ); |
|
| 1066 | + $wpdb->insert($wpdb->term_relationships, array('object_id' => $link_id, 'term_taxonomy_id' => $tt_id)); |
|
| 1067 | 1067 | } |
| 1068 | 1068 | } |
| 1069 | 1069 | |
| 1070 | - if ( $wp_current_db_version < 4772 ) { |
|
| 1070 | + if ($wp_current_db_version < 4772) { |
|
| 1071 | 1071 | // Obsolete linkcategories table |
| 1072 | - $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'linkcategories'); |
|
| 1072 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'linkcategories'); |
|
| 1073 | 1073 | } |
| 1074 | 1074 | |
| 1075 | 1075 | // Recalculate all counts |
| 1076 | 1076 | $terms = $wpdb->get_results("SELECT term_taxonomy_id, taxonomy FROM $wpdb->term_taxonomy"); |
| 1077 | - foreach ( (array) $terms as $term ) { |
|
| 1078 | - if ( ('post_tag' == $term->taxonomy) || ('category' == $term->taxonomy) ) |
|
| 1079 | - $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term->term_taxonomy_id) ); |
|
| 1077 | + foreach ((array) $terms as $term) { |
|
| 1078 | + if (('post_tag' == $term->taxonomy) || ('category' == $term->taxonomy)) |
|
| 1079 | + $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term->term_taxonomy_id)); |
|
| 1080 | 1080 | else |
| 1081 | - $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id) ); |
|
| 1082 | - $wpdb->update( $wpdb->term_taxonomy, array('count' => $count), array('term_taxonomy_id' => $term->term_taxonomy_id) ); |
|
| 1081 | + $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id)); |
|
| 1082 | + $wpdb->update($wpdb->term_taxonomy, array('count' => $count), array('term_taxonomy_id' => $term->term_taxonomy_id)); |
|
| 1083 | 1083 | } |
| 1084 | 1084 | } |
| 1085 | 1085 | |
@@ -1092,9 +1092,9 @@ discard block |
||
| 1092 | 1092 | */ |
| 1093 | 1093 | function upgrade_230_options_table() { |
| 1094 | 1094 | global $wpdb; |
| 1095 | - $old_options_fields = array( 'option_can_override', 'option_type', 'option_width', 'option_height', 'option_description', 'option_admin_level' ); |
|
| 1095 | + $old_options_fields = array('option_can_override', 'option_type', 'option_width', 'option_height', 'option_description', 'option_admin_level'); |
|
| 1096 | 1096 | $wpdb->hide_errors(); |
| 1097 | - foreach ( $old_options_fields as $old ) |
|
| 1097 | + foreach ($old_options_fields as $old) |
|
| 1098 | 1098 | $wpdb->query("ALTER TABLE $wpdb->options DROP $old"); |
| 1099 | 1099 | $wpdb->show_errors(); |
| 1100 | 1100 | } |
@@ -1108,9 +1108,9 @@ discard block |
||
| 1108 | 1108 | */ |
| 1109 | 1109 | function upgrade_230_old_tables() { |
| 1110 | 1110 | global $wpdb; |
| 1111 | - $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'categories'); |
|
| 1112 | - $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'link2cat'); |
|
| 1113 | - $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'post2cat'); |
|
| 1111 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'categories'); |
|
| 1112 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'link2cat'); |
|
| 1113 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'post2cat'); |
|
| 1114 | 1114 | } |
| 1115 | 1115 | |
| 1116 | 1116 | /** |
@@ -1136,7 +1136,7 @@ discard block |
||
| 1136 | 1136 | function upgrade_250() { |
| 1137 | 1137 | global $wp_current_db_version; |
| 1138 | 1138 | |
| 1139 | - if ( $wp_current_db_version < 6689 ) { |
|
| 1139 | + if ($wp_current_db_version < 6689) { |
|
| 1140 | 1140 | populate_roles_250(); |
| 1141 | 1141 | } |
| 1142 | 1142 | |
@@ -1165,7 +1165,7 @@ discard block |
||
| 1165 | 1165 | function upgrade_260() { |
| 1166 | 1166 | global $wp_current_db_version; |
| 1167 | 1167 | |
| 1168 | - if ( $wp_current_db_version < 8000 ) |
|
| 1168 | + if ($wp_current_db_version < 8000) |
|
| 1169 | 1169 | populate_roles_260(); |
| 1170 | 1170 | } |
| 1171 | 1171 | |
@@ -1180,12 +1180,12 @@ discard block |
||
| 1180 | 1180 | function upgrade_270() { |
| 1181 | 1181 | global $wpdb, $wp_current_db_version; |
| 1182 | 1182 | |
| 1183 | - if ( $wp_current_db_version < 8980 ) |
|
| 1183 | + if ($wp_current_db_version < 8980) |
|
| 1184 | 1184 | populate_roles_270(); |
| 1185 | 1185 | |
| 1186 | 1186 | // Update post_date for unpublished posts with empty timestamp |
| 1187 | - if ( $wp_current_db_version < 8921 ) |
|
| 1188 | - $wpdb->query( "UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'" ); |
|
| 1187 | + if ($wp_current_db_version < 8921) |
|
| 1188 | + $wpdb->query("UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'"); |
|
| 1189 | 1189 | } |
| 1190 | 1190 | |
| 1191 | 1191 | /** |
@@ -1199,22 +1199,22 @@ discard block |
||
| 1199 | 1199 | function upgrade_280() { |
| 1200 | 1200 | global $wp_current_db_version, $wpdb; |
| 1201 | 1201 | |
| 1202 | - if ( $wp_current_db_version < 10360 ) |
|
| 1202 | + if ($wp_current_db_version < 10360) |
|
| 1203 | 1203 | populate_roles_280(); |
| 1204 | - if ( is_multisite() ) { |
|
| 1204 | + if (is_multisite()) { |
|
| 1205 | 1205 | $start = 0; |
| 1206 | - while( $rows = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20" ) ) { |
|
| 1207 | - foreach( $rows as $row ) { |
|
| 1206 | + while ($rows = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20")) { |
|
| 1207 | + foreach ($rows as $row) { |
|
| 1208 | 1208 | $value = $row->option_value; |
| 1209 | - if ( !@unserialize( $value ) ) |
|
| 1210 | - $value = stripslashes( $value ); |
|
| 1211 | - if ( $value !== $row->option_value ) { |
|
| 1212 | - update_option( $row->option_name, $value ); |
|
| 1209 | + if ( ! @unserialize($value)) |
|
| 1210 | + $value = stripslashes($value); |
|
| 1211 | + if ($value !== $row->option_value) { |
|
| 1212 | + update_option($row->option_name, $value); |
|
| 1213 | 1213 | } |
| 1214 | 1214 | } |
| 1215 | 1215 | $start += 20; |
| 1216 | 1216 | } |
| 1217 | - refresh_blog_details( $wpdb->blogid ); |
|
| 1217 | + refresh_blog_details($wpdb->blogid); |
|
| 1218 | 1218 | } |
| 1219 | 1219 | } |
| 1220 | 1220 | |
@@ -1228,11 +1228,11 @@ discard block |
||
| 1228 | 1228 | function upgrade_290() { |
| 1229 | 1229 | global $wp_current_db_version; |
| 1230 | 1230 | |
| 1231 | - if ( $wp_current_db_version < 11958 ) { |
|
| 1231 | + if ($wp_current_db_version < 11958) { |
|
| 1232 | 1232 | // Previously, setting depth to 1 would redundantly disable threading, but now 2 is the minimum depth to avoid confusion |
| 1233 | - if ( get_option( 'thread_comments_depth' ) == '1' ) { |
|
| 1234 | - update_option( 'thread_comments_depth', 2 ); |
|
| 1235 | - update_option( 'thread_comments', 0 ); |
|
| 1233 | + if (get_option('thread_comments_depth') == '1') { |
|
| 1234 | + update_option('thread_comments_depth', 2); |
|
| 1235 | + update_option('thread_comments', 0); |
|
| 1236 | 1236 | } |
| 1237 | 1237 | } |
| 1238 | 1238 | } |
@@ -1248,14 +1248,14 @@ discard block |
||
| 1248 | 1248 | function upgrade_300() { |
| 1249 | 1249 | global $wp_current_db_version, $wpdb; |
| 1250 | 1250 | |
| 1251 | - if ( $wp_current_db_version < 15093 ) |
|
| 1251 | + if ($wp_current_db_version < 15093) |
|
| 1252 | 1252 | populate_roles_300(); |
| 1253 | 1253 | |
| 1254 | - if ( $wp_current_db_version < 14139 && is_multisite() && is_main_site() && ! defined( 'MULTISITE' ) && get_site_option( 'siteurl' ) === false ) |
|
| 1255 | - add_site_option( 'siteurl', '' ); |
|
| 1254 | + if ($wp_current_db_version < 14139 && is_multisite() && is_main_site() && ! defined('MULTISITE') && get_site_option('siteurl') === false) |
|
| 1255 | + add_site_option('siteurl', ''); |
|
| 1256 | 1256 | |
| 1257 | 1257 | // 3.0 screen options key name changes. |
| 1258 | - if ( wp_should_upgrade_global_tables() ) { |
|
| 1258 | + if (wp_should_upgrade_global_tables()) { |
|
| 1259 | 1259 | $sql = "DELETE FROM $wpdb->usermeta |
| 1260 | 1260 | WHERE meta_key LIKE %s |
| 1261 | 1261 | OR meta_key LIKE %s |
@@ -1269,15 +1269,15 @@ discard block |
||
| 1269 | 1269 | OR meta_key = 'manageeditcolumnshidden' |
| 1270 | 1270 | OR meta_key = 'categories_per_page' |
| 1271 | 1271 | OR meta_key = 'edit_tags_per_page'"; |
| 1272 | - $prefix = $wpdb->esc_like( $wpdb->base_prefix ); |
|
| 1273 | - $wpdb->query( $wpdb->prepare( $sql, |
|
| 1274 | - $prefix . '%' . $wpdb->esc_like( 'meta-box-hidden' ) . '%', |
|
| 1275 | - $prefix . '%' . $wpdb->esc_like( 'closedpostboxes' ) . '%', |
|
| 1276 | - $prefix . '%' . $wpdb->esc_like( 'manage-' ) . '%' . $wpdb->esc_like( '-columns-hidden' ) . '%', |
|
| 1277 | - $prefix . '%' . $wpdb->esc_like( 'meta-box-order' ) . '%', |
|
| 1278 | - $prefix . '%' . $wpdb->esc_like( 'metaboxorder' ) . '%', |
|
| 1279 | - $prefix . '%' . $wpdb->esc_like( 'screen_layout' ) . '%' |
|
| 1280 | - ) ); |
|
| 1272 | + $prefix = $wpdb->esc_like($wpdb->base_prefix); |
|
| 1273 | + $wpdb->query($wpdb->prepare($sql, |
|
| 1274 | + $prefix.'%'.$wpdb->esc_like('meta-box-hidden').'%', |
|
| 1275 | + $prefix.'%'.$wpdb->esc_like('closedpostboxes').'%', |
|
| 1276 | + $prefix.'%'.$wpdb->esc_like('manage-').'%'.$wpdb->esc_like('-columns-hidden').'%', |
|
| 1277 | + $prefix.'%'.$wpdb->esc_like('meta-box-order').'%', |
|
| 1278 | + $prefix.'%'.$wpdb->esc_like('metaboxorder').'%', |
|
| 1279 | + $prefix.'%'.$wpdb->esc_like('screen_layout').'%' |
|
| 1280 | + )); |
|
| 1281 | 1281 | } |
| 1282 | 1282 | |
| 1283 | 1283 | } |
@@ -1295,52 +1295,52 @@ discard block |
||
| 1295 | 1295 | function upgrade_330() { |
| 1296 | 1296 | global $wp_current_db_version, $wpdb, $wp_registered_widgets, $sidebars_widgets; |
| 1297 | 1297 | |
| 1298 | - if ( $wp_current_db_version < 19061 && wp_should_upgrade_global_tables() ) { |
|
| 1299 | - $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key IN ('show_admin_bar_admin', 'plugins_last_view')" ); |
|
| 1298 | + if ($wp_current_db_version < 19061 && wp_should_upgrade_global_tables()) { |
|
| 1299 | + $wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key IN ('show_admin_bar_admin', 'plugins_last_view')"); |
|
| 1300 | 1300 | } |
| 1301 | 1301 | |
| 1302 | - if ( $wp_current_db_version >= 11548 ) |
|
| 1302 | + if ($wp_current_db_version >= 11548) |
|
| 1303 | 1303 | return; |
| 1304 | 1304 | |
| 1305 | - $sidebars_widgets = get_option( 'sidebars_widgets', array() ); |
|
| 1305 | + $sidebars_widgets = get_option('sidebars_widgets', array()); |
|
| 1306 | 1306 | $_sidebars_widgets = array(); |
| 1307 | 1307 | |
| 1308 | - if ( isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets) ) |
|
| 1308 | + if (isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets)) |
|
| 1309 | 1309 | $sidebars_widgets['array_version'] = 3; |
| 1310 | - elseif ( !isset($sidebars_widgets['array_version']) ) |
|
| 1310 | + elseif ( ! isset($sidebars_widgets['array_version'])) |
|
| 1311 | 1311 | $sidebars_widgets['array_version'] = 1; |
| 1312 | 1312 | |
| 1313 | - switch ( $sidebars_widgets['array_version'] ) { |
|
| 1313 | + switch ($sidebars_widgets['array_version']) { |
|
| 1314 | 1314 | case 1 : |
| 1315 | - foreach ( (array) $sidebars_widgets as $index => $sidebar ) |
|
| 1316 | - if ( is_array($sidebar) ) |
|
| 1317 | - foreach ( (array) $sidebar as $i => $name ) { |
|
| 1315 | + foreach ((array) $sidebars_widgets as $index => $sidebar) |
|
| 1316 | + if (is_array($sidebar)) |
|
| 1317 | + foreach ((array) $sidebar as $i => $name) { |
|
| 1318 | 1318 | $id = strtolower($name); |
| 1319 | - if ( isset($wp_registered_widgets[$id]) ) { |
|
| 1319 | + if (isset($wp_registered_widgets[$id])) { |
|
| 1320 | 1320 | $_sidebars_widgets[$index][$i] = $id; |
| 1321 | 1321 | continue; |
| 1322 | 1322 | } |
| 1323 | 1323 | $id = sanitize_title($name); |
| 1324 | - if ( isset($wp_registered_widgets[$id]) ) { |
|
| 1324 | + if (isset($wp_registered_widgets[$id])) { |
|
| 1325 | 1325 | $_sidebars_widgets[$index][$i] = $id; |
| 1326 | 1326 | continue; |
| 1327 | 1327 | } |
| 1328 | 1328 | |
| 1329 | 1329 | $found = false; |
| 1330 | 1330 | |
| 1331 | - foreach ( $wp_registered_widgets as $widget_id => $widget ) { |
|
| 1332 | - if ( strtolower($widget['name']) == strtolower($name) ) { |
|
| 1331 | + foreach ($wp_registered_widgets as $widget_id => $widget) { |
|
| 1332 | + if (strtolower($widget['name']) == strtolower($name)) { |
|
| 1333 | 1333 | $_sidebars_widgets[$index][$i] = $widget['id']; |
| 1334 | 1334 | $found = true; |
| 1335 | 1335 | break; |
| 1336 | - } elseif ( sanitize_title($widget['name']) == sanitize_title($name) ) { |
|
| 1336 | + } elseif (sanitize_title($widget['name']) == sanitize_title($name)) { |
|
| 1337 | 1337 | $_sidebars_widgets[$index][$i] = $widget['id']; |
| 1338 | 1338 | $found = true; |
| 1339 | 1339 | break; |
| 1340 | 1340 | } |
| 1341 | 1341 | } |
| 1342 | 1342 | |
| 1343 | - if ( $found ) |
|
| 1343 | + if ($found) |
|
| 1344 | 1344 | continue; |
| 1345 | 1345 | |
| 1346 | 1346 | unset($_sidebars_widgets[$index][$i]); |
@@ -1352,7 +1352,7 @@ discard block |
||
| 1352 | 1352 | case 2 : |
| 1353 | 1353 | $sidebars_widgets = retrieve_widgets(); |
| 1354 | 1354 | $sidebars_widgets['array_version'] = 3; |
| 1355 | - update_option( 'sidebars_widgets', $sidebars_widgets ); |
|
| 1355 | + update_option('sidebars_widgets', $sidebars_widgets); |
|
| 1356 | 1356 | } |
| 1357 | 1357 | } |
| 1358 | 1358 | |
@@ -1367,27 +1367,27 @@ discard block |
||
| 1367 | 1367 | function upgrade_340() { |
| 1368 | 1368 | global $wp_current_db_version, $wpdb; |
| 1369 | 1369 | |
| 1370 | - if ( $wp_current_db_version < 19798 ) { |
|
| 1370 | + if ($wp_current_db_version < 19798) { |
|
| 1371 | 1371 | $wpdb->hide_errors(); |
| 1372 | - $wpdb->query( "ALTER TABLE $wpdb->options DROP COLUMN blog_id" ); |
|
| 1372 | + $wpdb->query("ALTER TABLE $wpdb->options DROP COLUMN blog_id"); |
|
| 1373 | 1373 | $wpdb->show_errors(); |
| 1374 | 1374 | } |
| 1375 | 1375 | |
| 1376 | - if ( $wp_current_db_version < 19799 ) { |
|
| 1376 | + if ($wp_current_db_version < 19799) { |
|
| 1377 | 1377 | $wpdb->hide_errors(); |
| 1378 | 1378 | $wpdb->query("ALTER TABLE $wpdb->comments DROP INDEX comment_approved"); |
| 1379 | 1379 | $wpdb->show_errors(); |
| 1380 | 1380 | } |
| 1381 | 1381 | |
| 1382 | - if ( $wp_current_db_version < 20022 && wp_should_upgrade_global_tables() ) { |
|
| 1383 | - $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key = 'themes_last_view'" ); |
|
| 1382 | + if ($wp_current_db_version < 20022 && wp_should_upgrade_global_tables()) { |
|
| 1383 | + $wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key = 'themes_last_view'"); |
|
| 1384 | 1384 | } |
| 1385 | 1385 | |
| 1386 | - if ( $wp_current_db_version < 20080 ) { |
|
| 1387 | - if ( 'yes' == $wpdb->get_var( "SELECT autoload FROM $wpdb->options WHERE option_name = 'uninstall_plugins'" ) ) { |
|
| 1388 | - $uninstall_plugins = get_option( 'uninstall_plugins' ); |
|
| 1389 | - delete_option( 'uninstall_plugins' ); |
|
| 1390 | - add_option( 'uninstall_plugins', $uninstall_plugins, null, 'no' ); |
|
| 1386 | + if ($wp_current_db_version < 20080) { |
|
| 1387 | + if ('yes' == $wpdb->get_var("SELECT autoload FROM $wpdb->options WHERE option_name = 'uninstall_plugins'")) { |
|
| 1388 | + $uninstall_plugins = get_option('uninstall_plugins'); |
|
| 1389 | + delete_option('uninstall_plugins'); |
|
| 1390 | + add_option('uninstall_plugins', $uninstall_plugins, null, 'no'); |
|
| 1391 | 1391 | } |
| 1392 | 1392 | } |
| 1393 | 1393 | } |
@@ -1403,23 +1403,23 @@ discard block |
||
| 1403 | 1403 | function upgrade_350() { |
| 1404 | 1404 | global $wp_current_db_version, $wpdb; |
| 1405 | 1405 | |
| 1406 | - if ( $wp_current_db_version < 22006 && $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) ) |
|
| 1407 | - update_option( 'link_manager_enabled', 1 ); // Previously set to 0 by populate_options() |
|
| 1406 | + if ($wp_current_db_version < 22006 && $wpdb->get_var("SELECT link_id FROM $wpdb->links LIMIT 1")) |
|
| 1407 | + update_option('link_manager_enabled', 1); // Previously set to 0 by populate_options() |
|
| 1408 | 1408 | |
| 1409 | - if ( $wp_current_db_version < 21811 && wp_should_upgrade_global_tables() ) { |
|
| 1409 | + if ($wp_current_db_version < 21811 && wp_should_upgrade_global_tables()) { |
|
| 1410 | 1410 | $meta_keys = array(); |
| 1411 | - foreach ( array_merge( get_post_types(), get_taxonomies() ) as $name ) { |
|
| 1412 | - if ( false !== strpos( $name, '-' ) ) |
|
| 1413 | - $meta_keys[] = 'edit_' . str_replace( '-', '_', $name ) . '_per_page'; |
|
| 1411 | + foreach (array_merge(get_post_types(), get_taxonomies()) as $name) { |
|
| 1412 | + if (false !== strpos($name, '-')) |
|
| 1413 | + $meta_keys[] = 'edit_'.str_replace('-', '_', $name).'_per_page'; |
|
| 1414 | 1414 | } |
| 1415 | - if ( $meta_keys ) { |
|
| 1416 | - $meta_keys = implode( "', '", $meta_keys ); |
|
| 1417 | - $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key IN ('$meta_keys')" ); |
|
| 1415 | + if ($meta_keys) { |
|
| 1416 | + $meta_keys = implode("', '", $meta_keys); |
|
| 1417 | + $wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key IN ('$meta_keys')"); |
|
| 1418 | 1418 | } |
| 1419 | 1419 | } |
| 1420 | 1420 | |
| 1421 | - if ( $wp_current_db_version < 22422 && $term = get_term_by( 'slug', 'post-format-standard', 'post_format' ) ) |
|
| 1422 | - wp_delete_term( $term->term_id, 'post_format' ); |
|
| 1421 | + if ($wp_current_db_version < 22422 && $term = get_term_by('slug', 'post-format-standard', 'post_format')) |
|
| 1422 | + wp_delete_term($term->term_id, 'post_format'); |
|
| 1423 | 1423 | } |
| 1424 | 1424 | |
| 1425 | 1425 | /** |
@@ -1431,8 +1431,8 @@ discard block |
||
| 1431 | 1431 | */ |
| 1432 | 1432 | function upgrade_370() { |
| 1433 | 1433 | global $wp_current_db_version; |
| 1434 | - if ( $wp_current_db_version < 25824 ) |
|
| 1435 | - wp_clear_scheduled_hook( 'wp_auto_updates_maybe_update' ); |
|
| 1434 | + if ($wp_current_db_version < 25824) |
|
| 1435 | + wp_clear_scheduled_hook('wp_auto_updates_maybe_update'); |
|
| 1436 | 1436 | } |
| 1437 | 1437 | |
| 1438 | 1438 | /** |
@@ -1445,8 +1445,8 @@ discard block |
||
| 1445 | 1445 | */ |
| 1446 | 1446 | function upgrade_372() { |
| 1447 | 1447 | global $wp_current_db_version; |
| 1448 | - if ( $wp_current_db_version < 26148 ) |
|
| 1449 | - wp_clear_scheduled_hook( 'wp_maybe_auto_update' ); |
|
| 1448 | + if ($wp_current_db_version < 26148) |
|
| 1449 | + wp_clear_scheduled_hook('wp_maybe_auto_update'); |
|
| 1450 | 1450 | } |
| 1451 | 1451 | |
| 1452 | 1452 | /** |
@@ -1458,8 +1458,8 @@ discard block |
||
| 1458 | 1458 | */ |
| 1459 | 1459 | function upgrade_380() { |
| 1460 | 1460 | global $wp_current_db_version; |
| 1461 | - if ( $wp_current_db_version < 26691 ) { |
|
| 1462 | - deactivate_plugins( array( 'mp6/mp6.php' ), true ); |
|
| 1461 | + if ($wp_current_db_version < 26691) { |
|
| 1462 | + deactivate_plugins(array('mp6/mp6.php'), true); |
|
| 1463 | 1463 | } |
| 1464 | 1464 | } |
| 1465 | 1465 | |
@@ -1472,12 +1472,12 @@ discard block |
||
| 1472 | 1472 | */ |
| 1473 | 1473 | function upgrade_400() { |
| 1474 | 1474 | global $wp_current_db_version; |
| 1475 | - if ( $wp_current_db_version < 29630 ) { |
|
| 1476 | - if ( ! is_multisite() && false === get_option( 'WPLANG' ) ) { |
|
| 1477 | - if ( defined( 'WPLANG' ) && ( '' !== WPLANG ) && in_array( WPLANG, get_available_languages() ) ) { |
|
| 1478 | - update_option( 'WPLANG', WPLANG ); |
|
| 1475 | + if ($wp_current_db_version < 29630) { |
|
| 1476 | + if ( ! is_multisite() && false === get_option('WPLANG')) { |
|
| 1477 | + if (defined('WPLANG') && ('' !== WPLANG) && in_array(WPLANG, get_available_languages())) { |
|
| 1478 | + update_option('WPLANG', WPLANG); |
|
| 1479 | 1479 | } else { |
| 1480 | - update_option( 'WPLANG', '' ); |
|
| 1480 | + update_option('WPLANG', ''); |
|
| 1481 | 1481 | } |
| 1482 | 1482 | } |
| 1483 | 1483 | } |
@@ -1504,29 +1504,29 @@ discard block |
||
| 1504 | 1504 | function upgrade_430() { |
| 1505 | 1505 | global $wp_current_db_version, $wpdb; |
| 1506 | 1506 | |
| 1507 | - if ( $wp_current_db_version < 32364 ) { |
|
| 1507 | + if ($wp_current_db_version < 32364) { |
|
| 1508 | 1508 | upgrade_430_fix_comments(); |
| 1509 | 1509 | } |
| 1510 | 1510 | |
| 1511 | 1511 | // Shared terms are split in a separate process. |
| 1512 | - if ( $wp_current_db_version < 32814 ) { |
|
| 1513 | - update_option( 'finished_splitting_shared_terms', 0 ); |
|
| 1514 | - wp_schedule_single_event( time() + ( 1 * MINUTE_IN_SECONDS ), 'wp_split_shared_term_batch' ); |
|
| 1512 | + if ($wp_current_db_version < 32814) { |
|
| 1513 | + update_option('finished_splitting_shared_terms', 0); |
|
| 1514 | + wp_schedule_single_event(time() + (1 * MINUTE_IN_SECONDS), 'wp_split_shared_term_batch'); |
|
| 1515 | 1515 | } |
| 1516 | 1516 | |
| 1517 | - if ( $wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset ) { |
|
| 1518 | - if ( is_multisite() ) { |
|
| 1519 | - $tables = $wpdb->tables( 'blog' ); |
|
| 1517 | + if ($wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset) { |
|
| 1518 | + if (is_multisite()) { |
|
| 1519 | + $tables = $wpdb->tables('blog'); |
|
| 1520 | 1520 | } else { |
| 1521 | - $tables = $wpdb->tables( 'all' ); |
|
| 1522 | - if ( ! wp_should_upgrade_global_tables() ) { |
|
| 1523 | - $global_tables = $wpdb->tables( 'global' ); |
|
| 1524 | - $tables = array_diff_assoc( $tables, $global_tables ); |
|
| 1521 | + $tables = $wpdb->tables('all'); |
|
| 1522 | + if ( ! wp_should_upgrade_global_tables()) { |
|
| 1523 | + $global_tables = $wpdb->tables('global'); |
|
| 1524 | + $tables = array_diff_assoc($tables, $global_tables); |
|
| 1525 | 1525 | } |
| 1526 | 1526 | } |
| 1527 | 1527 | |
| 1528 | - foreach ( $tables as $table ) { |
|
| 1529 | - maybe_convert_table_to_utf8mb4( $table ); |
|
| 1528 | + foreach ($tables as $table) { |
|
| 1529 | + maybe_convert_table_to_utf8mb4($table); |
|
| 1530 | 1530 | } |
| 1531 | 1531 | } |
| 1532 | 1532 | } |
@@ -1542,18 +1542,18 @@ discard block |
||
| 1542 | 1542 | function upgrade_430_fix_comments() { |
| 1543 | 1543 | global $wp_current_db_version, $wpdb; |
| 1544 | 1544 | |
| 1545 | - $content_length = $wpdb->get_col_length( $wpdb->comments, 'comment_content' ); |
|
| 1545 | + $content_length = $wpdb->get_col_length($wpdb->comments, 'comment_content'); |
|
| 1546 | 1546 | |
| 1547 | - if ( is_wp_error( $content_length ) ) { |
|
| 1547 | + if (is_wp_error($content_length)) { |
|
| 1548 | 1548 | return; |
| 1549 | 1549 | } |
| 1550 | 1550 | |
| 1551 | - if ( false === $content_length ) { |
|
| 1551 | + if (false === $content_length) { |
|
| 1552 | 1552 | $content_length = array( |
| 1553 | 1553 | 'type' => 'byte', |
| 1554 | 1554 | 'length' => 65535, |
| 1555 | 1555 | ); |
| 1556 | - } elseif ( ! is_array( $content_length ) ) { |
|
| 1556 | + } elseif ( ! is_array($content_length)) { |
|
| 1557 | 1557 | $length = (int) $content_length > 0 ? (int) $content_length : 65535; |
| 1558 | 1558 | $content_length = array( |
| 1559 | 1559 | 'type' => 'byte', |
@@ -1561,12 +1561,12 @@ discard block |
||
| 1561 | 1561 | ); |
| 1562 | 1562 | } |
| 1563 | 1563 | |
| 1564 | - if ( 'byte' !== $content_length['type'] || 0 === $content_length['length'] ) { |
|
| 1564 | + if ('byte' !== $content_length['type'] || 0 === $content_length['length']) { |
|
| 1565 | 1565 | // Sites with malformed DB schemas are on their own. |
| 1566 | 1566 | return; |
| 1567 | 1567 | } |
| 1568 | 1568 | |
| 1569 | - $allowed_length = intval( $content_length['length'] ) - 10; |
|
| 1569 | + $allowed_length = intval($content_length['length']) - 10; |
|
| 1570 | 1570 | |
| 1571 | 1571 | $comments = $wpdb->get_results( |
| 1572 | 1572 | "SELECT `comment_ID` FROM `{$wpdb->comments}` |
@@ -1575,8 +1575,8 @@ discard block |
||
| 1575 | 1575 | AND ( `comment_content` LIKE '%<%' OR `comment_content` LIKE '%>%' )" |
| 1576 | 1576 | ); |
| 1577 | 1577 | |
| 1578 | - foreach ( $comments as $comment ) { |
|
| 1579 | - wp_delete_comment( $comment->comment_ID, true ); |
|
| 1578 | + foreach ($comments as $comment) { |
|
| 1579 | + wp_delete_comment($comment->comment_ID, true); |
|
| 1580 | 1580 | } |
| 1581 | 1581 | } |
| 1582 | 1582 | |
@@ -1588,10 +1588,10 @@ discard block |
||
| 1588 | 1588 | function upgrade_431() { |
| 1589 | 1589 | // Fix incorrect cron entries for term splitting |
| 1590 | 1590 | $cron_array = _get_cron_array(); |
| 1591 | - if ( isset( $cron_array['wp_batch_split_terms'] ) ) { |
|
| 1592 | - foreach ( $cron_array['wp_batch_split_terms'] as $timestamp_hook => $cron_data ) { |
|
| 1593 | - foreach ( $cron_data as $key => $args ) { |
|
| 1594 | - wp_unschedule_event( 'wp_batch_split_terms', $timestamp_hook, $args['args'] ); |
|
| 1591 | + if (isset($cron_array['wp_batch_split_terms'])) { |
|
| 1592 | + foreach ($cron_array['wp_batch_split_terms'] as $timestamp_hook => $cron_data) { |
|
| 1593 | + foreach ($cron_data as $key => $args) { |
|
| 1594 | + wp_unschedule_event('wp_batch_split_terms', $timestamp_hook, $args['args']); |
|
| 1595 | 1595 | } |
| 1596 | 1596 | } |
| 1597 | 1597 | } |
@@ -1609,7 +1609,7 @@ discard block |
||
| 1609 | 1609 | global $wp_current_db_version, $wpdb; |
| 1610 | 1610 | |
| 1611 | 1611 | // Always. |
| 1612 | - if ( is_main_network() ) { |
|
| 1612 | + if (is_main_network()) { |
|
| 1613 | 1613 | /* |
| 1614 | 1614 | * Deletes all expired transients. The multi-table delete syntax is used |
| 1615 | 1615 | * to delete the transient record from table a, and the corresponding |
@@ -1621,32 +1621,32 @@ discard block |
||
| 1621 | 1621 | AND a.meta_key NOT LIKE %s |
| 1622 | 1622 | AND b.meta_key = CONCAT( '_site_transient_timeout_', SUBSTRING( a.meta_key, 17 ) ) |
| 1623 | 1623 | AND b.meta_value < %d"; |
| 1624 | - $wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( '_site_transient_' ) . '%', $wpdb->esc_like ( '_site_transient_timeout_' ) . '%', $time ) ); |
|
| 1624 | + $wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('_site_transient_').'%', $wpdb->esc_like('_site_transient_timeout_').'%', $time)); |
|
| 1625 | 1625 | } |
| 1626 | 1626 | |
| 1627 | 1627 | // 2.8. |
| 1628 | - if ( $wp_current_db_version < 11549 ) { |
|
| 1629 | - $wpmu_sitewide_plugins = get_site_option( 'wpmu_sitewide_plugins' ); |
|
| 1630 | - $active_sitewide_plugins = get_site_option( 'active_sitewide_plugins' ); |
|
| 1631 | - if ( $wpmu_sitewide_plugins ) { |
|
| 1632 | - if ( !$active_sitewide_plugins ) |
|
| 1628 | + if ($wp_current_db_version < 11549) { |
|
| 1629 | + $wpmu_sitewide_plugins = get_site_option('wpmu_sitewide_plugins'); |
|
| 1630 | + $active_sitewide_plugins = get_site_option('active_sitewide_plugins'); |
|
| 1631 | + if ($wpmu_sitewide_plugins) { |
|
| 1632 | + if ( ! $active_sitewide_plugins) |
|
| 1633 | 1633 | $sitewide_plugins = (array) $wpmu_sitewide_plugins; |
| 1634 | 1634 | else |
| 1635 | - $sitewide_plugins = array_merge( (array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins ); |
|
| 1635 | + $sitewide_plugins = array_merge((array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins); |
|
| 1636 | 1636 | |
| 1637 | - update_site_option( 'active_sitewide_plugins', $sitewide_plugins ); |
|
| 1637 | + update_site_option('active_sitewide_plugins', $sitewide_plugins); |
|
| 1638 | 1638 | } |
| 1639 | - delete_site_option( 'wpmu_sitewide_plugins' ); |
|
| 1640 | - delete_site_option( 'deactivated_sitewide_plugins' ); |
|
| 1639 | + delete_site_option('wpmu_sitewide_plugins'); |
|
| 1640 | + delete_site_option('deactivated_sitewide_plugins'); |
|
| 1641 | 1641 | |
| 1642 | 1642 | $start = 0; |
| 1643 | - while( $rows = $wpdb->get_results( "SELECT meta_key, meta_value FROM {$wpdb->sitemeta} ORDER BY meta_id LIMIT $start, 20" ) ) { |
|
| 1644 | - foreach( $rows as $row ) { |
|
| 1643 | + while ($rows = $wpdb->get_results("SELECT meta_key, meta_value FROM {$wpdb->sitemeta} ORDER BY meta_id LIMIT $start, 20")) { |
|
| 1644 | + foreach ($rows as $row) { |
|
| 1645 | 1645 | $value = $row->meta_value; |
| 1646 | - if ( !@unserialize( $value ) ) |
|
| 1647 | - $value = stripslashes( $value ); |
|
| 1648 | - if ( $value !== $row->meta_value ) { |
|
| 1649 | - update_site_option( $row->meta_key, $value ); |
|
| 1646 | + if ( ! @unserialize($value)) |
|
| 1647 | + $value = stripslashes($value); |
|
| 1648 | + if ($value !== $row->meta_value) { |
|
| 1649 | + update_site_option($row->meta_key, $value); |
|
| 1650 | 1650 | } |
| 1651 | 1651 | } |
| 1652 | 1652 | $start += 20; |
@@ -1654,95 +1654,95 @@ discard block |
||
| 1654 | 1654 | } |
| 1655 | 1655 | |
| 1656 | 1656 | // 3.0 |
| 1657 | - if ( $wp_current_db_version < 13576 ) |
|
| 1658 | - update_site_option( 'global_terms_enabled', '1' ); |
|
| 1657 | + if ($wp_current_db_version < 13576) |
|
| 1658 | + update_site_option('global_terms_enabled', '1'); |
|
| 1659 | 1659 | |
| 1660 | 1660 | // 3.3 |
| 1661 | - if ( $wp_current_db_version < 19390 ) |
|
| 1662 | - update_site_option( 'initial_db_version', $wp_current_db_version ); |
|
| 1661 | + if ($wp_current_db_version < 19390) |
|
| 1662 | + update_site_option('initial_db_version', $wp_current_db_version); |
|
| 1663 | 1663 | |
| 1664 | - if ( $wp_current_db_version < 19470 ) { |
|
| 1665 | - if ( false === get_site_option( 'active_sitewide_plugins' ) ) |
|
| 1666 | - update_site_option( 'active_sitewide_plugins', array() ); |
|
| 1664 | + if ($wp_current_db_version < 19470) { |
|
| 1665 | + if (false === get_site_option('active_sitewide_plugins')) |
|
| 1666 | + update_site_option('active_sitewide_plugins', array()); |
|
| 1667 | 1667 | } |
| 1668 | 1668 | |
| 1669 | 1669 | // 3.4 |
| 1670 | - if ( $wp_current_db_version < 20148 ) { |
|
| 1670 | + if ($wp_current_db_version < 20148) { |
|
| 1671 | 1671 | // 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name. |
| 1672 | - $allowedthemes = get_site_option( 'allowedthemes' ); |
|
| 1673 | - $allowed_themes = get_site_option( 'allowed_themes' ); |
|
| 1674 | - if ( false === $allowedthemes && is_array( $allowed_themes ) && $allowed_themes ) { |
|
| 1672 | + $allowedthemes = get_site_option('allowedthemes'); |
|
| 1673 | + $allowed_themes = get_site_option('allowed_themes'); |
|
| 1674 | + if (false === $allowedthemes && is_array($allowed_themes) && $allowed_themes) { |
|
| 1675 | 1675 | $converted = array(); |
| 1676 | 1676 | $themes = wp_get_themes(); |
| 1677 | - foreach ( $themes as $stylesheet => $theme_data ) { |
|
| 1678 | - if ( isset( $allowed_themes[ $theme_data->get('Name') ] ) ) |
|
| 1679 | - $converted[ $stylesheet ] = true; |
|
| 1677 | + foreach ($themes as $stylesheet => $theme_data) { |
|
| 1678 | + if (isset($allowed_themes[$theme_data->get('Name')])) |
|
| 1679 | + $converted[$stylesheet] = true; |
|
| 1680 | 1680 | } |
| 1681 | - update_site_option( 'allowedthemes', $converted ); |
|
| 1682 | - delete_site_option( 'allowed_themes' ); |
|
| 1681 | + update_site_option('allowedthemes', $converted); |
|
| 1682 | + delete_site_option('allowed_themes'); |
|
| 1683 | 1683 | } |
| 1684 | 1684 | } |
| 1685 | 1685 | |
| 1686 | 1686 | // 3.5 |
| 1687 | - if ( $wp_current_db_version < 21823 ) |
|
| 1688 | - update_site_option( 'ms_files_rewriting', '1' ); |
|
| 1687 | + if ($wp_current_db_version < 21823) |
|
| 1688 | + update_site_option('ms_files_rewriting', '1'); |
|
| 1689 | 1689 | |
| 1690 | 1690 | // 3.5.2 |
| 1691 | - if ( $wp_current_db_version < 24448 ) { |
|
| 1692 | - $illegal_names = get_site_option( 'illegal_names' ); |
|
| 1693 | - if ( is_array( $illegal_names ) && count( $illegal_names ) === 1 ) { |
|
| 1694 | - $illegal_name = reset( $illegal_names ); |
|
| 1695 | - $illegal_names = explode( ' ', $illegal_name ); |
|
| 1696 | - update_site_option( 'illegal_names', $illegal_names ); |
|
| 1691 | + if ($wp_current_db_version < 24448) { |
|
| 1692 | + $illegal_names = get_site_option('illegal_names'); |
|
| 1693 | + if (is_array($illegal_names) && count($illegal_names) === 1) { |
|
| 1694 | + $illegal_name = reset($illegal_names); |
|
| 1695 | + $illegal_names = explode(' ', $illegal_name); |
|
| 1696 | + update_site_option('illegal_names', $illegal_names); |
|
| 1697 | 1697 | } |
| 1698 | 1698 | } |
| 1699 | 1699 | |
| 1700 | 1700 | // 4.2 |
| 1701 | - if ( $wp_current_db_version < 31351 && $wpdb->charset === 'utf8mb4' ) { |
|
| 1702 | - if ( wp_should_upgrade_global_tables() ) { |
|
| 1703 | - $wpdb->query( "ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" ); |
|
| 1704 | - $wpdb->query( "ALTER TABLE $wpdb->site DROP INDEX domain, ADD INDEX domain(domain(140),path(51))" ); |
|
| 1705 | - $wpdb->query( "ALTER TABLE $wpdb->sitemeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" ); |
|
| 1706 | - $wpdb->query( "ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))" ); |
|
| 1701 | + if ($wp_current_db_version < 31351 && $wpdb->charset === 'utf8mb4') { |
|
| 1702 | + if (wp_should_upgrade_global_tables()) { |
|
| 1703 | + $wpdb->query("ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))"); |
|
| 1704 | + $wpdb->query("ALTER TABLE $wpdb->site DROP INDEX domain, ADD INDEX domain(domain(140),path(51))"); |
|
| 1705 | + $wpdb->query("ALTER TABLE $wpdb->sitemeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))"); |
|
| 1706 | + $wpdb->query("ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))"); |
|
| 1707 | 1707 | |
| 1708 | - $tables = $wpdb->tables( 'global' ); |
|
| 1708 | + $tables = $wpdb->tables('global'); |
|
| 1709 | 1709 | |
| 1710 | 1710 | // sitecategories may not exist. |
| 1711 | - if ( ! $wpdb->get_var( "SHOW TABLES LIKE '{$tables['sitecategories']}'" ) ) { |
|
| 1712 | - unset( $tables['sitecategories'] ); |
|
| 1711 | + if ( ! $wpdb->get_var("SHOW TABLES LIKE '{$tables['sitecategories']}'")) { |
|
| 1712 | + unset($tables['sitecategories']); |
|
| 1713 | 1713 | } |
| 1714 | 1714 | |
| 1715 | - foreach ( $tables as $table ) { |
|
| 1716 | - maybe_convert_table_to_utf8mb4( $table ); |
|
| 1715 | + foreach ($tables as $table) { |
|
| 1716 | + maybe_convert_table_to_utf8mb4($table); |
|
| 1717 | 1717 | } |
| 1718 | 1718 | } |
| 1719 | 1719 | } |
| 1720 | 1720 | |
| 1721 | 1721 | // 4.3 |
| 1722 | - if ( $wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset ) { |
|
| 1723 | - if ( wp_should_upgrade_global_tables() ) { |
|
| 1722 | + if ($wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset) { |
|
| 1723 | + if (wp_should_upgrade_global_tables()) { |
|
| 1724 | 1724 | $upgrade = false; |
| 1725 | - $indexes = $wpdb->get_results( "SHOW INDEXES FROM $wpdb->signups" ); |
|
| 1726 | - foreach( $indexes as $index ) { |
|
| 1727 | - if ( 'domain_path' == $index->Key_name && 'domain' == $index->Column_name && 140 != $index->Sub_part ) { |
|
| 1725 | + $indexes = $wpdb->get_results("SHOW INDEXES FROM $wpdb->signups"); |
|
| 1726 | + foreach ($indexes as $index) { |
|
| 1727 | + if ('domain_path' == $index->Key_name && 'domain' == $index->Column_name && 140 != $index->Sub_part) { |
|
| 1728 | 1728 | $upgrade = true; |
| 1729 | 1729 | break; |
| 1730 | 1730 | } |
| 1731 | 1731 | } |
| 1732 | 1732 | |
| 1733 | - if ( $upgrade ) { |
|
| 1734 | - $wpdb->query( "ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))" ); |
|
| 1733 | + if ($upgrade) { |
|
| 1734 | + $wpdb->query("ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))"); |
|
| 1735 | 1735 | } |
| 1736 | 1736 | |
| 1737 | - $tables = $wpdb->tables( 'global' ); |
|
| 1737 | + $tables = $wpdb->tables('global'); |
|
| 1738 | 1738 | |
| 1739 | 1739 | // sitecategories may not exist. |
| 1740 | - if ( ! $wpdb->get_var( "SHOW TABLES LIKE '{$tables['sitecategories']}'" ) ) { |
|
| 1741 | - unset( $tables['sitecategories'] ); |
|
| 1740 | + if ( ! $wpdb->get_var("SHOW TABLES LIKE '{$tables['sitecategories']}'")) { |
|
| 1741 | + unset($tables['sitecategories']); |
|
| 1742 | 1742 | } |
| 1743 | 1743 | |
| 1744 | - foreach ( $tables as $table ) { |
|
| 1745 | - maybe_convert_table_to_utf8mb4( $table ); |
|
| 1744 | + foreach ($tables as $table) { |
|
| 1745 | + maybe_convert_table_to_utf8mb4($table); |
|
| 1746 | 1746 | } |
| 1747 | 1747 | } |
| 1748 | 1748 | } |
@@ -1770,9 +1770,9 @@ discard block |
||
| 1770 | 1770 | function maybe_create_table($table_name, $create_ddl) { |
| 1771 | 1771 | global $wpdb; |
| 1772 | 1772 | |
| 1773 | - $query = $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $table_name ) ); |
|
| 1773 | + $query = $wpdb->prepare("SHOW TABLES LIKE %s", $wpdb->esc_like($table_name)); |
|
| 1774 | 1774 | |
| 1775 | - if ( $wpdb->get_var( $query ) == $table_name ) { |
|
| 1775 | + if ($wpdb->get_var($query) == $table_name) { |
|
| 1776 | 1776 | return true; |
| 1777 | 1777 | } |
| 1778 | 1778 | |
@@ -1780,7 +1780,7 @@ discard block |
||
| 1780 | 1780 | $wpdb->query($create_ddl); |
| 1781 | 1781 | |
| 1782 | 1782 | // We cannot directly tell that whether this succeeded! |
| 1783 | - if ( $wpdb->get_var( $query ) == $table_name ) { |
|
| 1783 | + if ($wpdb->get_var($query) == $table_name) { |
|
| 1784 | 1784 | return true; |
| 1785 | 1785 | } |
| 1786 | 1786 | return false; |
@@ -1841,7 +1841,7 @@ discard block |
||
| 1841 | 1841 | */ |
| 1842 | 1842 | function maybe_add_column($table_name, $column_name, $create_ddl) { |
| 1843 | 1843 | global $wpdb; |
| 1844 | - foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) { |
|
| 1844 | + foreach ($wpdb->get_col("DESC $table_name", 0) as $column) { |
|
| 1845 | 1845 | if ($column == $column_name) { |
| 1846 | 1846 | return true; |
| 1847 | 1847 | } |
@@ -1851,7 +1851,7 @@ discard block |
||
| 1851 | 1851 | $wpdb->query($create_ddl); |
| 1852 | 1852 | |
| 1853 | 1853 | // We cannot directly tell that whether this succeeded! |
| 1854 | - foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) { |
|
| 1854 | + foreach ($wpdb->get_col("DESC $table_name", 0) as $column) { |
|
| 1855 | 1855 | if ($column == $column_name) { |
| 1856 | 1856 | return true; |
| 1857 | 1857 | } |
@@ -1869,37 +1869,37 @@ discard block |
||
| 1869 | 1869 | * @param string $table The table to convert. |
| 1870 | 1870 | * @return bool true if the table was converted, false if it wasn't. |
| 1871 | 1871 | */ |
| 1872 | -function maybe_convert_table_to_utf8mb4( $table ) { |
|
| 1872 | +function maybe_convert_table_to_utf8mb4($table) { |
|
| 1873 | 1873 | global $wpdb; |
| 1874 | 1874 | |
| 1875 | - $results = $wpdb->get_results( "SHOW FULL COLUMNS FROM `$table`" ); |
|
| 1876 | - if ( ! $results ) { |
|
| 1875 | + $results = $wpdb->get_results("SHOW FULL COLUMNS FROM `$table`"); |
|
| 1876 | + if ( ! $results) { |
|
| 1877 | 1877 | return false; |
| 1878 | 1878 | } |
| 1879 | 1879 | |
| 1880 | - foreach ( $results as $column ) { |
|
| 1881 | - if ( $column->Collation ) { |
|
| 1882 | - list( $charset ) = explode( '_', $column->Collation ); |
|
| 1883 | - $charset = strtolower( $charset ); |
|
| 1884 | - if ( 'utf8' !== $charset && 'utf8mb4' !== $charset ) { |
|
| 1880 | + foreach ($results as $column) { |
|
| 1881 | + if ($column->Collation) { |
|
| 1882 | + list($charset) = explode('_', $column->Collation); |
|
| 1883 | + $charset = strtolower($charset); |
|
| 1884 | + if ('utf8' !== $charset && 'utf8mb4' !== $charset) { |
|
| 1885 | 1885 | // Don't upgrade tables that have non-utf8 columns. |
| 1886 | 1886 | return false; |
| 1887 | 1887 | } |
| 1888 | 1888 | } |
| 1889 | 1889 | } |
| 1890 | 1890 | |
| 1891 | - $table_details = $wpdb->get_row( "SHOW TABLE STATUS LIKE '$table'" ); |
|
| 1892 | - if ( ! $table_details ) { |
|
| 1891 | + $table_details = $wpdb->get_row("SHOW TABLE STATUS LIKE '$table'"); |
|
| 1892 | + if ( ! $table_details) { |
|
| 1893 | 1893 | return false; |
| 1894 | 1894 | } |
| 1895 | 1895 | |
| 1896 | - list( $table_charset ) = explode( '_', $table_details->Collation ); |
|
| 1897 | - $table_charset = strtolower( $table_charset ); |
|
| 1898 | - if ( 'utf8mb4' === $table_charset ) { |
|
| 1896 | + list($table_charset) = explode('_', $table_details->Collation); |
|
| 1897 | + $table_charset = strtolower($table_charset); |
|
| 1898 | + if ('utf8mb4' === $table_charset) { |
|
| 1899 | 1899 | return true; |
| 1900 | 1900 | } |
| 1901 | 1901 | |
| 1902 | - return $wpdb->query( "ALTER TABLE $table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci" ); |
|
| 1902 | + return $wpdb->query("ALTER TABLE $table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); |
|
| 1903 | 1903 | } |
| 1904 | 1904 | |
| 1905 | 1905 | /** |
@@ -1914,11 +1914,11 @@ discard block |
||
| 1914 | 1914 | function get_alloptions_110() { |
| 1915 | 1915 | global $wpdb; |
| 1916 | 1916 | $all_options = new stdClass; |
| 1917 | - if ( $options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ) ) { |
|
| 1918 | - foreach ( $options as $option ) { |
|
| 1919 | - if ( 'siteurl' == $option->option_name || 'home' == $option->option_name || 'category_base' == $option->option_name ) |
|
| 1920 | - $option->option_value = untrailingslashit( $option->option_value ); |
|
| 1921 | - $all_options->{$option->option_name} = stripslashes( $option->option_value ); |
|
| 1917 | + if ($options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options")) { |
|
| 1918 | + foreach ($options as $option) { |
|
| 1919 | + if ('siteurl' == $option->option_name || 'home' == $option->option_name || 'category_base' == $option->option_name) |
|
| 1920 | + $option->option_value = untrailingslashit($option->option_value); |
|
| 1921 | + $all_options->{$option->option_name} = stripslashes($option->option_value); |
|
| 1922 | 1922 | } |
| 1923 | 1923 | } |
| 1924 | 1924 | return $all_options; |
@@ -1939,21 +1939,21 @@ discard block |
||
| 1939 | 1939 | function __get_option($setting) { |
| 1940 | 1940 | global $wpdb; |
| 1941 | 1941 | |
| 1942 | - if ( $setting == 'home' && defined( 'WP_HOME' ) ) |
|
| 1943 | - return untrailingslashit( WP_HOME ); |
|
| 1942 | + if ($setting == 'home' && defined('WP_HOME')) |
|
| 1943 | + return untrailingslashit(WP_HOME); |
|
| 1944 | 1944 | |
| 1945 | - if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) ) |
|
| 1946 | - return untrailingslashit( WP_SITEURL ); |
|
| 1945 | + if ($setting == 'siteurl' && defined('WP_SITEURL')) |
|
| 1946 | + return untrailingslashit(WP_SITEURL); |
|
| 1947 | 1947 | |
| 1948 | - $option = $wpdb->get_var( $wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s", $setting ) ); |
|
| 1948 | + $option = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s", $setting)); |
|
| 1949 | 1949 | |
| 1950 | - if ( 'home' == $setting && '' == $option ) |
|
| 1951 | - return __get_option( 'siteurl' ); |
|
| 1950 | + if ('home' == $setting && '' == $option) |
|
| 1951 | + return __get_option('siteurl'); |
|
| 1952 | 1952 | |
| 1953 | - if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting || 'tag_base' == $setting ) |
|
| 1954 | - $option = untrailingslashit( $option ); |
|
| 1953 | + if ('siteurl' == $setting || 'home' == $setting || 'category_base' == $setting || 'tag_base' == $setting) |
|
| 1954 | + $option = untrailingslashit($option); |
|
| 1955 | 1955 | |
| 1956 | - return maybe_unserialize( $option ); |
|
| 1956 | + return maybe_unserialize($option); |
|
| 1957 | 1957 | } |
| 1958 | 1958 | |
| 1959 | 1959 | /** |
@@ -2001,16 +2001,16 @@ discard block |
||
| 2001 | 2001 | * Default true. |
| 2002 | 2002 | * @return array Strings containing the results of the various update queries. |
| 2003 | 2003 | */ |
| 2004 | -function dbDelta( $queries = '', $execute = true ) { |
|
| 2004 | +function dbDelta($queries = '', $execute = true) { |
|
| 2005 | 2005 | global $wpdb; |
| 2006 | 2006 | |
| 2007 | - if ( in_array( $queries, array( '', 'all', 'blog', 'global', 'ms_global' ), true ) ) |
|
| 2008 | - $queries = wp_get_db_schema( $queries ); |
|
| 2007 | + if (in_array($queries, array('', 'all', 'blog', 'global', 'ms_global'), true)) |
|
| 2008 | + $queries = wp_get_db_schema($queries); |
|
| 2009 | 2009 | |
| 2010 | 2010 | // Separate individual queries into an array |
| 2011 | - if ( !is_array($queries) ) { |
|
| 2012 | - $queries = explode( ';', $queries ); |
|
| 2013 | - $queries = array_filter( $queries ); |
|
| 2011 | + if ( ! is_array($queries)) { |
|
| 2012 | + $queries = explode(';', $queries); |
|
| 2013 | + $queries = array_filter($queries); |
|
| 2014 | 2014 | } |
| 2015 | 2015 | |
| 2016 | 2016 | /** |
@@ -2020,22 +2020,22 @@ discard block |
||
| 2020 | 2020 | * |
| 2021 | 2021 | * @param array $queries An array of dbDelta SQL queries. |
| 2022 | 2022 | */ |
| 2023 | - $queries = apply_filters( 'dbdelta_queries', $queries ); |
|
| 2023 | + $queries = apply_filters('dbdelta_queries', $queries); |
|
| 2024 | 2024 | |
| 2025 | 2025 | $cqueries = array(); // Creation Queries |
| 2026 | 2026 | $iqueries = array(); // Insertion Queries |
| 2027 | 2027 | $for_update = array(); |
| 2028 | 2028 | |
| 2029 | 2029 | // Create a tablename index for an array ($cqueries) of queries |
| 2030 | - foreach($queries as $qry) { |
|
| 2031 | - if ( preg_match( "|CREATE TABLE ([^ ]*)|", $qry, $matches ) ) { |
|
| 2032 | - $cqueries[ trim( $matches[1], '`' ) ] = $qry; |
|
| 2030 | + foreach ($queries as $qry) { |
|
| 2031 | + if (preg_match("|CREATE TABLE ([^ ]*)|", $qry, $matches)) { |
|
| 2032 | + $cqueries[trim($matches[1], '`')] = $qry; |
|
| 2033 | 2033 | $for_update[$matches[1]] = 'Created table '.$matches[1]; |
| 2034 | - } elseif ( preg_match( "|CREATE DATABASE ([^ ]*)|", $qry, $matches ) ) { |
|
| 2035 | - array_unshift( $cqueries, $qry ); |
|
| 2036 | - } elseif ( preg_match( "|INSERT INTO ([^ ]*)|", $qry, $matches ) ) { |
|
| 2034 | + } elseif (preg_match("|CREATE DATABASE ([^ ]*)|", $qry, $matches)) { |
|
| 2035 | + array_unshift($cqueries, $qry); |
|
| 2036 | + } elseif (preg_match("|INSERT INTO ([^ ]*)|", $qry, $matches)) { |
|
| 2037 | 2037 | $iqueries[] = $qry; |
| 2038 | - } elseif ( preg_match( "|UPDATE ([^ ]*)|", $qry, $matches ) ) { |
|
| 2038 | + } elseif (preg_match("|UPDATE ([^ ]*)|", $qry, $matches)) { |
|
| 2039 | 2039 | $iqueries[] = $qry; |
| 2040 | 2040 | } else { |
| 2041 | 2041 | // Unrecognized query type |
@@ -2051,7 +2051,7 @@ discard block |
||
| 2051 | 2051 | * |
| 2052 | 2052 | * @param array $cqueries An array of dbDelta create SQL queries. |
| 2053 | 2053 | */ |
| 2054 | - $cqueries = apply_filters( 'dbdelta_create_queries', $cqueries ); |
|
| 2054 | + $cqueries = apply_filters('dbdelta_create_queries', $cqueries); |
|
| 2055 | 2055 | |
| 2056 | 2056 | /** |
| 2057 | 2057 | * Filter the dbDelta SQL queries for inserting or updating. |
@@ -2062,22 +2062,22 @@ discard block |
||
| 2062 | 2062 | * |
| 2063 | 2063 | * @param array $iqueries An array of dbDelta insert or update SQL queries. |
| 2064 | 2064 | */ |
| 2065 | - $iqueries = apply_filters( 'dbdelta_insert_queries', $iqueries ); |
|
| 2065 | + $iqueries = apply_filters('dbdelta_insert_queries', $iqueries); |
|
| 2066 | 2066 | |
| 2067 | - $global_tables = $wpdb->tables( 'global' ); |
|
| 2068 | - foreach ( $cqueries as $table => $qry ) { |
|
| 2067 | + $global_tables = $wpdb->tables('global'); |
|
| 2068 | + foreach ($cqueries as $table => $qry) { |
|
| 2069 | 2069 | // Upgrade global tables only for the main site. Don't upgrade at all if conditions are not optimal. |
| 2070 | - if ( in_array( $table, $global_tables ) && ! wp_should_upgrade_global_tables() ) { |
|
| 2071 | - unset( $cqueries[ $table ], $for_update[ $table ] ); |
|
| 2070 | + if (in_array($table, $global_tables) && ! wp_should_upgrade_global_tables()) { |
|
| 2071 | + unset($cqueries[$table], $for_update[$table]); |
|
| 2072 | 2072 | continue; |
| 2073 | 2073 | } |
| 2074 | 2074 | |
| 2075 | 2075 | // Fetch the table column structure from the database |
| 2076 | 2076 | $suppress = $wpdb->suppress_errors(); |
| 2077 | 2077 | $tablefields = $wpdb->get_results("DESCRIBE {$table};"); |
| 2078 | - $wpdb->suppress_errors( $suppress ); |
|
| 2078 | + $wpdb->suppress_errors($suppress); |
|
| 2079 | 2079 | |
| 2080 | - if ( ! $tablefields ) |
|
| 2080 | + if ( ! $tablefields) |
|
| 2081 | 2081 | continue; |
| 2082 | 2082 | |
| 2083 | 2083 | // Clear the field and index arrays. |
@@ -2098,7 +2098,7 @@ discard block |
||
| 2098 | 2098 | |
| 2099 | 2099 | // Extract the field name. |
| 2100 | 2100 | preg_match("|^([^ ]*)|", trim($fld), $fvals); |
| 2101 | - $fieldname = trim( $fvals[1], '`' ); |
|
| 2101 | + $fieldname = trim($fvals[1], '`'); |
|
| 2102 | 2102 | |
| 2103 | 2103 | // Verify the found field name. |
| 2104 | 2104 | $validfield = true; |
@@ -2134,7 +2134,7 @@ discard block |
||
| 2134 | 2134 | // Is actual field type different from the field type in query? |
| 2135 | 2135 | if ($tablefield->Type != $fieldtype) { |
| 2136 | 2136 | // Add a query to change the column type |
| 2137 | - $cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN {$tablefield->Field} " . $cfields[strtolower($tablefield->Field)]; |
|
| 2137 | + $cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN {$tablefield->Field} ".$cfields[strtolower($tablefield->Field)]; |
|
| 2138 | 2138 | $for_update[$table.'.'.$tablefield->Field] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}"; |
| 2139 | 2139 | } |
| 2140 | 2140 | |
@@ -2177,7 +2177,7 @@ discard block |
||
| 2177 | 2177 | // Add the index to the index data array. |
| 2178 | 2178 | $keyname = $tableindex->Key_name; |
| 2179 | 2179 | $index_ary[$keyname]['columns'][] = array('fieldname' => $tableindex->Column_name, 'subpart' => $tableindex->Sub_part); |
| 2180 | - $index_ary[$keyname]['unique'] = ($tableindex->Non_unique == 0)?true:false; |
|
| 2180 | + $index_ary[$keyname]['unique'] = ($tableindex->Non_unique == 0) ? true : false; |
|
| 2181 | 2181 | } |
| 2182 | 2182 | |
| 2183 | 2183 | // For each actual index in the index array. |
@@ -2187,7 +2187,7 @@ discard block |
||
| 2187 | 2187 | $index_string = ''; |
| 2188 | 2188 | if ($index_name == 'PRIMARY') { |
| 2189 | 2189 | $index_string .= 'PRIMARY '; |
| 2190 | - } elseif ( $index_data['unique'] ) { |
|
| 2190 | + } elseif ($index_data['unique']) { |
|
| 2191 | 2191 | $index_string .= 'UNIQUE '; |
| 2192 | 2192 | } |
| 2193 | 2193 | $index_string .= 'KEY '; |
@@ -2208,7 +2208,7 @@ discard block |
||
| 2208 | 2208 | } |
| 2209 | 2209 | |
| 2210 | 2210 | // The alternative index string doesn't care about subparts |
| 2211 | - $alt_index_columns = preg_replace( '/\([^)]*\)/', '', $index_columns ); |
|
| 2211 | + $alt_index_columns = preg_replace('/\([^)]*\)/', '', $index_columns); |
|
| 2212 | 2212 | |
| 2213 | 2213 | // Add the column list to the index create string. |
| 2214 | 2214 | $index_strings = array( |
@@ -2216,9 +2216,9 @@ discard block |
||
| 2216 | 2216 | "$index_string ($alt_index_columns)", |
| 2217 | 2217 | ); |
| 2218 | 2218 | |
| 2219 | - foreach( $index_strings as $index_string ) { |
|
| 2220 | - if ( ! ( ( $aindex = array_search( $index_string, $indices ) ) === false ) ) { |
|
| 2221 | - unset( $indices[ $aindex ] ); |
|
| 2219 | + foreach ($index_strings as $index_string) { |
|
| 2220 | + if ( ! (($aindex = array_search($index_string, $indices)) === false)) { |
|
| 2221 | + unset($indices[$aindex]); |
|
| 2222 | 2222 | break; |
| 2223 | 2223 | // todo: Remove this? |
| 2224 | 2224 | //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br />Found index:".$index_string."</pre>\n"; |
@@ -2230,14 +2230,14 @@ discard block |
||
| 2230 | 2230 | } |
| 2231 | 2231 | |
| 2232 | 2232 | // For every remaining index specified for the table. |
| 2233 | - foreach ( (array) $indices as $index ) { |
|
| 2233 | + foreach ((array) $indices as $index) { |
|
| 2234 | 2234 | // Push a query line into $cqueries that adds the index to that table. |
| 2235 | 2235 | $cqueries[] = "ALTER TABLE {$table} ADD $index"; |
| 2236 | - $for_update[] = 'Added index ' . $table . ' ' . $index; |
|
| 2236 | + $for_update[] = 'Added index '.$table.' '.$index; |
|
| 2237 | 2237 | } |
| 2238 | 2238 | |
| 2239 | 2239 | // Remove the original table creation query from processing. |
| 2240 | - unset( $cqueries[ $table ], $for_update[ $table ] ); |
|
| 2240 | + unset($cqueries[$table], $for_update[$table]); |
|
| 2241 | 2241 | } |
| 2242 | 2242 | |
| 2243 | 2243 | $allqueries = array_merge($cqueries, $iqueries); |
@@ -2264,10 +2264,10 @@ discard block |
||
| 2264 | 2264 | * |
| 2265 | 2265 | * @param string $tables Optional. Which set of tables to update. Default is 'all'. |
| 2266 | 2266 | */ |
| 2267 | -function make_db_current( $tables = 'all' ) { |
|
| 2268 | - $alterations = dbDelta( $tables ); |
|
| 2267 | +function make_db_current($tables = 'all') { |
|
| 2268 | + $alterations = dbDelta($tables); |
|
| 2269 | 2269 | echo "<ol>\n"; |
| 2270 | - foreach($alterations as $alteration) echo "<li>$alteration</li>\n"; |
|
| 2270 | + foreach ($alterations as $alteration) echo "<li>$alteration</li>\n"; |
|
| 2271 | 2271 | echo "</ol>\n"; |
| 2272 | 2272 | } |
| 2273 | 2273 | |
@@ -2283,8 +2283,8 @@ discard block |
||
| 2283 | 2283 | * |
| 2284 | 2284 | * @param string $tables Optional. Which set of tables to update. Default is 'all'. |
| 2285 | 2285 | */ |
| 2286 | -function make_db_current_silent( $tables = 'all' ) { |
|
| 2287 | - dbDelta( $tables ); |
|
| 2286 | +function make_db_current_silent($tables = 'all') { |
|
| 2287 | + dbDelta($tables); |
|
| 2288 | 2288 | } |
| 2289 | 2289 | |
| 2290 | 2290 | /** |
@@ -2300,9 +2300,9 @@ discard block |
||
| 2300 | 2300 | */ |
| 2301 | 2301 | function make_site_theme_from_oldschool($theme_name, $template) { |
| 2302 | 2302 | $home_path = get_home_path(); |
| 2303 | - $site_dir = WP_CONTENT_DIR . "/themes/$template"; |
|
| 2303 | + $site_dir = WP_CONTENT_DIR."/themes/$template"; |
|
| 2304 | 2304 | |
| 2305 | - if (! file_exists("$home_path/index.php")) |
|
| 2305 | + if ( ! file_exists("$home_path/index.php")) |
|
| 2306 | 2306 | return false; |
| 2307 | 2307 | |
| 2308 | 2308 | /* |
@@ -2321,7 +2321,7 @@ discard block |
||
| 2321 | 2321 | if ($oldfile == 'index.php') { |
| 2322 | 2322 | $index = implode('', file("$oldpath/$oldfile")); |
| 2323 | 2323 | if (strpos($index, 'WP_USE_THEMES') !== false) { |
| 2324 | - if (! @copy(WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME . '/index.php', "$site_dir/$newfile")) |
|
| 2324 | + if ( ! @copy(WP_CONTENT_DIR.'/themes/'.WP_DEFAULT_THEME.'/index.php', "$site_dir/$newfile")) |
|
| 2325 | 2325 | return false; |
| 2326 | 2326 | |
| 2327 | 2327 | // Don't copy anything. |
@@ -2329,7 +2329,7 @@ discard block |
||
| 2329 | 2329 | } |
| 2330 | 2330 | } |
| 2331 | 2331 | |
| 2332 | - if (! @copy("$oldpath/$oldfile", "$site_dir/$newfile")) |
|
| 2332 | + if ( ! @copy("$oldpath/$oldfile", "$site_dir/$newfile")) |
|
| 2333 | 2333 | return false; |
| 2334 | 2334 | |
| 2335 | 2335 | chmod("$site_dir/$newfile", 0777); |
@@ -2341,7 +2341,7 @@ discard block |
||
| 2341 | 2341 | |
| 2342 | 2342 | foreach ($lines as $line) { |
| 2343 | 2343 | if (preg_match('/require.*wp-blog-header/', $line)) |
| 2344 | - $line = '//' . $line; |
|
| 2344 | + $line = '//'.$line; |
|
| 2345 | 2345 | |
| 2346 | 2346 | // Update stylesheet references. |
| 2347 | 2347 | $line = str_replace("<?php echo __get_option('siteurl'); ?>/wp-layout.css", "<?php bloginfo('stylesheet_url'); ?>", $line); |
@@ -2356,7 +2356,7 @@ discard block |
||
| 2356 | 2356 | } |
| 2357 | 2357 | |
| 2358 | 2358 | // Add a theme header. |
| 2359 | - $header = "/*\nTheme Name: $theme_name\nTheme URI: " . __get_option('siteurl') . "\nDescription: A theme automatically created by the update.\nVersion: 1.0\nAuthor: Moi\n*/\n"; |
|
| 2359 | + $header = "/*\nTheme Name: $theme_name\nTheme URI: ".__get_option('siteurl')."\nDescription: A theme automatically created by the update.\nVersion: 1.0\nAuthor: Moi\n*/\n"; |
|
| 2360 | 2360 | |
| 2361 | 2361 | $stylelines = file_get_contents("$site_dir/style.css"); |
| 2362 | 2362 | if ($stylelines) { |
@@ -2382,18 +2382,18 @@ discard block |
||
| 2382 | 2382 | * @return false|void |
| 2383 | 2383 | */ |
| 2384 | 2384 | function make_site_theme_from_default($theme_name, $template) { |
| 2385 | - $site_dir = WP_CONTENT_DIR . "/themes/$template"; |
|
| 2386 | - $default_dir = WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME; |
|
| 2385 | + $site_dir = WP_CONTENT_DIR."/themes/$template"; |
|
| 2386 | + $default_dir = WP_CONTENT_DIR.'/themes/'.WP_DEFAULT_THEME; |
|
| 2387 | 2387 | |
| 2388 | 2388 | // Copy files from the default theme to the site theme. |
| 2389 | 2389 | //$files = array('index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css'); |
| 2390 | 2390 | |
| 2391 | 2391 | $theme_dir = @ opendir($default_dir); |
| 2392 | 2392 | if ($theme_dir) { |
| 2393 | - while(($theme_file = readdir( $theme_dir )) !== false) { |
|
| 2393 | + while (($theme_file = readdir($theme_dir)) !== false) { |
|
| 2394 | 2394 | if (is_dir("$default_dir/$theme_file")) |
| 2395 | 2395 | continue; |
| 2396 | - if (! @copy("$default_dir/$theme_file", "$site_dir/$theme_file")) |
|
| 2396 | + if ( ! @copy("$default_dir/$theme_file", "$site_dir/$theme_file")) |
|
| 2397 | 2397 | return; |
| 2398 | 2398 | chmod("$site_dir/$theme_file", 0777); |
| 2399 | 2399 | } |
@@ -2406,28 +2406,28 @@ discard block |
||
| 2406 | 2406 | $f = fopen("$site_dir/style.css", 'w'); |
| 2407 | 2407 | |
| 2408 | 2408 | foreach ($stylelines as $line) { |
| 2409 | - if (strpos($line, 'Theme Name:') !== false) $line = 'Theme Name: ' . $theme_name; |
|
| 2410 | - elseif (strpos($line, 'Theme URI:') !== false) $line = 'Theme URI: ' . __get_option('url'); |
|
| 2409 | + if (strpos($line, 'Theme Name:') !== false) $line = 'Theme Name: '.$theme_name; |
|
| 2410 | + elseif (strpos($line, 'Theme URI:') !== false) $line = 'Theme URI: '.__get_option('url'); |
|
| 2411 | 2411 | elseif (strpos($line, 'Description:') !== false) $line = 'Description: Your theme.'; |
| 2412 | 2412 | elseif (strpos($line, 'Version:') !== false) $line = 'Version: 1'; |
| 2413 | 2413 | elseif (strpos($line, 'Author:') !== false) $line = 'Author: You'; |
| 2414 | - fwrite($f, $line . "\n"); |
|
| 2414 | + fwrite($f, $line."\n"); |
|
| 2415 | 2415 | } |
| 2416 | 2416 | fclose($f); |
| 2417 | 2417 | } |
| 2418 | 2418 | |
| 2419 | 2419 | // Copy the images. |
| 2420 | 2420 | umask(0); |
| 2421 | - if (! mkdir("$site_dir/images", 0777)) { |
|
| 2421 | + if ( ! mkdir("$site_dir/images", 0777)) { |
|
| 2422 | 2422 | return false; |
| 2423 | 2423 | } |
| 2424 | 2424 | |
| 2425 | 2425 | $images_dir = @ opendir("$default_dir/images"); |
| 2426 | 2426 | if ($images_dir) { |
| 2427 | - while(($image = readdir($images_dir)) !== false) { |
|
| 2427 | + while (($image = readdir($images_dir)) !== false) { |
|
| 2428 | 2428 | if (is_dir("$default_dir/images/$image")) |
| 2429 | 2429 | continue; |
| 2430 | - if (! @copy("$default_dir/images/$image", "$site_dir/images/$image")) |
|
| 2430 | + if ( ! @copy("$default_dir/images/$image", "$site_dir/images/$image")) |
|
| 2431 | 2431 | return; |
| 2432 | 2432 | chmod("$site_dir/images/$image", 0777); |
| 2433 | 2433 | } |
@@ -2448,30 +2448,30 @@ discard block |
||
| 2448 | 2448 | // Name the theme after the blog. |
| 2449 | 2449 | $theme_name = __get_option('blogname'); |
| 2450 | 2450 | $template = sanitize_title($theme_name); |
| 2451 | - $site_dir = WP_CONTENT_DIR . "/themes/$template"; |
|
| 2451 | + $site_dir = WP_CONTENT_DIR."/themes/$template"; |
|
| 2452 | 2452 | |
| 2453 | 2453 | // If the theme already exists, nothing to do. |
| 2454 | - if ( is_dir($site_dir)) { |
|
| 2454 | + if (is_dir($site_dir)) { |
|
| 2455 | 2455 | return false; |
| 2456 | 2456 | } |
| 2457 | 2457 | |
| 2458 | 2458 | // We must be able to write to the themes dir. |
| 2459 | - if (! is_writable(WP_CONTENT_DIR . "/themes")) { |
|
| 2459 | + if ( ! is_writable(WP_CONTENT_DIR."/themes")) { |
|
| 2460 | 2460 | return false; |
| 2461 | 2461 | } |
| 2462 | 2462 | |
| 2463 | 2463 | umask(0); |
| 2464 | - if (! mkdir($site_dir, 0777)) { |
|
| 2464 | + if ( ! mkdir($site_dir, 0777)) { |
|
| 2465 | 2465 | return false; |
| 2466 | 2466 | } |
| 2467 | 2467 | |
| 2468 | - if (file_exists(ABSPATH . 'wp-layout.css')) { |
|
| 2469 | - if (! make_site_theme_from_oldschool($theme_name, $template)) { |
|
| 2468 | + if (file_exists(ABSPATH.'wp-layout.css')) { |
|
| 2469 | + if ( ! make_site_theme_from_oldschool($theme_name, $template)) { |
|
| 2470 | 2470 | // TODO: rm -rf the site theme directory. |
| 2471 | 2471 | return false; |
| 2472 | 2472 | } |
| 2473 | 2473 | } else { |
| 2474 | - if (! make_site_theme_from_default($theme_name, $template)) |
|
| 2474 | + if ( ! make_site_theme_from_default($theme_name, $template)) |
|
| 2475 | 2475 | // TODO: rm -rf the site theme directory. |
| 2476 | 2476 | return false; |
| 2477 | 2477 | } |
@@ -2524,8 +2524,8 @@ discard block |
||
| 2524 | 2524 | function wp_check_mysql_version() { |
| 2525 | 2525 | global $wpdb; |
| 2526 | 2526 | $result = $wpdb->check_database_version(); |
| 2527 | - if ( is_wp_error( $result ) ) |
|
| 2528 | - die( $result->get_error_message() ); |
|
| 2527 | + if (is_wp_error($result)) |
|
| 2528 | + die($result->get_error_message()); |
|
| 2529 | 2529 | } |
| 2530 | 2530 | |
| 2531 | 2531 | /** |
@@ -2534,12 +2534,12 @@ discard block |
||
| 2534 | 2534 | * @since 2.2.0 |
| 2535 | 2535 | */ |
| 2536 | 2536 | function maybe_disable_automattic_widgets() { |
| 2537 | - $plugins = __get_option( 'active_plugins' ); |
|
| 2537 | + $plugins = __get_option('active_plugins'); |
|
| 2538 | 2538 | |
| 2539 | - foreach ( (array) $plugins as $plugin ) { |
|
| 2540 | - if ( basename( $plugin ) == 'widgets.php' ) { |
|
| 2541 | - array_splice( $plugins, array_search( $plugin, $plugins ), 1 ); |
|
| 2542 | - update_option( 'active_plugins', $plugins ); |
|
| 2539 | + foreach ((array) $plugins as $plugin) { |
|
| 2540 | + if (basename($plugin) == 'widgets.php') { |
|
| 2541 | + array_splice($plugins, array_search($plugin, $plugins), 1); |
|
| 2542 | + update_option('active_plugins', $plugins); |
|
| 2543 | 2543 | break; |
| 2544 | 2544 | } |
| 2545 | 2545 | } |
@@ -2556,8 +2556,8 @@ discard block |
||
| 2556 | 2556 | function maybe_disable_link_manager() { |
| 2557 | 2557 | global $wp_current_db_version, $wpdb; |
| 2558 | 2558 | |
| 2559 | - if ( $wp_current_db_version >= 22006 && get_option( 'link_manager_enabled' ) && ! $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) ) |
|
| 2560 | - update_option( 'link_manager_enabled', 0 ); |
|
| 2559 | + if ($wp_current_db_version >= 22006 && get_option('link_manager_enabled') && ! $wpdb->get_var("SELECT link_id FROM $wpdb->links LIMIT 1")) |
|
| 2560 | + update_option('link_manager_enabled', 0); |
|
| 2561 | 2561 | } |
| 2562 | 2562 | |
| 2563 | 2563 | /** |
@@ -2572,7 +2572,7 @@ discard block |
||
| 2572 | 2572 | global $wp_current_db_version, $wpdb; |
| 2573 | 2573 | |
| 2574 | 2574 | // Upgrade versions prior to 2.9 |
| 2575 | - if ( $wp_current_db_version < 11557 ) { |
|
| 2575 | + if ($wp_current_db_version < 11557) { |
|
| 2576 | 2576 | // Delete duplicate options. Keep the option with the highest option_id. |
| 2577 | 2577 | $wpdb->query("DELETE o1 FROM $wpdb->options AS o1 JOIN $wpdb->options AS o2 USING (`option_name`) WHERE o2.option_id > o1.option_id"); |
| 2578 | 2578 | |
@@ -2584,32 +2584,32 @@ discard block |
||
| 2584 | 2584 | } |
| 2585 | 2585 | |
| 2586 | 2586 | // Multisite schema upgrades. |
| 2587 | - if ( $wp_current_db_version < 25448 && is_multisite() && wp_should_upgrade_global_tables() ) { |
|
| 2587 | + if ($wp_current_db_version < 25448 && is_multisite() && wp_should_upgrade_global_tables()) { |
|
| 2588 | 2588 | |
| 2589 | 2589 | // Upgrade verions prior to 3.7 |
| 2590 | - if ( $wp_current_db_version < 25179 ) { |
|
| 2590 | + if ($wp_current_db_version < 25179) { |
|
| 2591 | 2591 | // New primary key for signups. |
| 2592 | - $wpdb->query( "ALTER TABLE $wpdb->signups ADD signup_id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST" ); |
|
| 2593 | - $wpdb->query( "ALTER TABLE $wpdb->signups DROP INDEX domain" ); |
|
| 2592 | + $wpdb->query("ALTER TABLE $wpdb->signups ADD signup_id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST"); |
|
| 2593 | + $wpdb->query("ALTER TABLE $wpdb->signups DROP INDEX domain"); |
|
| 2594 | 2594 | } |
| 2595 | 2595 | |
| 2596 | - if ( $wp_current_db_version < 25448 ) { |
|
| 2596 | + if ($wp_current_db_version < 25448) { |
|
| 2597 | 2597 | // Convert archived from enum to tinyint. |
| 2598 | - $wpdb->query( "ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived varchar(1) NOT NULL default '0'" ); |
|
| 2599 | - $wpdb->query( "ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived tinyint(2) NOT NULL default 0" ); |
|
| 2598 | + $wpdb->query("ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived varchar(1) NOT NULL default '0'"); |
|
| 2599 | + $wpdb->query("ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived tinyint(2) NOT NULL default 0"); |
|
| 2600 | 2600 | } |
| 2601 | 2601 | } |
| 2602 | 2602 | |
| 2603 | 2603 | // Upgrade versions prior to 4.2. |
| 2604 | - if ( $wp_current_db_version < 31351 ) { |
|
| 2605 | - if ( ! is_multisite() && wp_should_upgrade_global_tables() ) { |
|
| 2606 | - $wpdb->query( "ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" ); |
|
| 2604 | + if ($wp_current_db_version < 31351) { |
|
| 2605 | + if ( ! is_multisite() && wp_should_upgrade_global_tables()) { |
|
| 2606 | + $wpdb->query("ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))"); |
|
| 2607 | 2607 | } |
| 2608 | - $wpdb->query( "ALTER TABLE $wpdb->terms DROP INDEX slug, ADD INDEX slug(slug(191))" ); |
|
| 2609 | - $wpdb->query( "ALTER TABLE $wpdb->terms DROP INDEX name, ADD INDEX name(name(191))" ); |
|
| 2610 | - $wpdb->query( "ALTER TABLE $wpdb->commentmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" ); |
|
| 2611 | - $wpdb->query( "ALTER TABLE $wpdb->postmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" ); |
|
| 2612 | - $wpdb->query( "ALTER TABLE $wpdb->posts DROP INDEX post_name, ADD INDEX post_name(post_name(191))" ); |
|
| 2608 | + $wpdb->query("ALTER TABLE $wpdb->terms DROP INDEX slug, ADD INDEX slug(slug(191))"); |
|
| 2609 | + $wpdb->query("ALTER TABLE $wpdb->terms DROP INDEX name, ADD INDEX name(name(191))"); |
|
| 2610 | + $wpdb->query("ALTER TABLE $wpdb->commentmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))"); |
|
| 2611 | + $wpdb->query("ALTER TABLE $wpdb->postmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))"); |
|
| 2612 | + $wpdb->query("ALTER TABLE $wpdb->posts DROP INDEX post_name, ADD INDEX post_name(post_name(191))"); |
|
| 2613 | 2613 | } |
| 2614 | 2614 | } |
| 2615 | 2615 | |
@@ -2621,7 +2621,7 @@ discard block |
||
| 2621 | 2621 | * @global wpdb $wpdb |
| 2622 | 2622 | * @global string $charset_collate |
| 2623 | 2623 | */ |
| 2624 | -if ( !function_exists( 'install_global_terms' ) ) : |
|
| 2624 | +if ( ! function_exists('install_global_terms')) : |
|
| 2625 | 2625 | function install_global_terms() { |
| 2626 | 2626 | global $wpdb, $charset_collate; |
| 2627 | 2627 | $ms_queries = " |
@@ -2636,7 +2636,7 @@ discard block |
||
| 2636 | 2636 | ) $charset_collate; |
| 2637 | 2637 | "; |
| 2638 | 2638 | // now create tables |
| 2639 | - dbDelta( $ms_queries ); |
|
| 2639 | + dbDelta($ms_queries); |
|
| 2640 | 2640 | } |
| 2641 | 2641 | endif; |
| 2642 | 2642 | |
@@ -2661,7 +2661,7 @@ discard block |
||
| 2661 | 2661 | function wp_should_upgrade_global_tables() { |
| 2662 | 2662 | |
| 2663 | 2663 | // Return false early if explicitly not upgrading |
| 2664 | - if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) { |
|
| 2664 | + if (defined('DO_NOT_UPGRADE_GLOBAL_TABLES')) { |
|
| 2665 | 2665 | return false; |
| 2666 | 2666 | } |
| 2667 | 2667 | |
@@ -2669,12 +2669,12 @@ discard block |
||
| 2669 | 2669 | $should_upgrade = true; |
| 2670 | 2670 | |
| 2671 | 2671 | // Set to false if not on main network (does not matter if not multi-network) |
| 2672 | - if ( ! is_main_network() ) { |
|
| 2672 | + if ( ! is_main_network()) { |
|
| 2673 | 2673 | $should_upgrade = false; |
| 2674 | 2674 | } |
| 2675 | 2675 | |
| 2676 | 2676 | // Set to false if not on main site of current network (does not matter if not multi-site) |
| 2677 | - if ( ! is_main_site() ) { |
|
| 2677 | + if ( ! is_main_site()) { |
|
| 2678 | 2678 | $should_upgrade = false; |
| 2679 | 2679 | } |
| 2680 | 2680 | |
@@ -2683,5 +2683,5 @@ discard block |
||
| 2683 | 2683 | * |
| 2684 | 2684 | * @param bool $should_upgrade Whether to run the upgrade routines on global tables. |
| 2685 | 2685 | */ |
| 2686 | - return apply_filters( 'wp_should_upgrade_global_tables', $should_upgrade ); |
|
| 2686 | + return apply_filters('wp_should_upgrade_global_tables', $should_upgrade); |
|
| 2687 | 2687 | } |
@@ -9,8 +9,9 @@ discard block |
||
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | /** Include user install customize script. */ |
| 12 | -if ( file_exists(WP_CONTENT_DIR . '/install.php') ) |
|
| 12 | +if ( file_exists(WP_CONTENT_DIR . '/install.php') ) { |
|
| 13 | 13 | require (WP_CONTENT_DIR . '/install.php'); |
| 14 | +} |
|
| 14 | 15 | |
| 15 | 16 | /** WordPress Administration API */ |
| 16 | 17 | require_once(ABSPATH . 'wp-admin/includes/admin.php'); |
@@ -37,8 +38,9 @@ discard block |
||
| 37 | 38 | * @return array Array keys 'url', 'user_id', 'password', and 'password_message'. |
| 38 | 39 | */ |
| 39 | 40 | function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '', $language = '' ) { |
| 40 | - if ( !empty( $deprecated ) ) |
|
| 41 | - _deprecated_argument( __FUNCTION__, '2.6' ); |
|
| 41 | + if ( !empty( $deprecated ) ) { |
|
| 42 | + _deprecated_argument( __FUNCTION__, '2.6' ); |
|
| 43 | + } |
|
| 42 | 44 | |
| 43 | 45 | wp_check_mysql_version(); |
| 44 | 46 | wp_cache_flush(); |
@@ -59,8 +61,9 @@ discard block |
||
| 59 | 61 | update_option('siteurl', $guessurl); |
| 60 | 62 | |
| 61 | 63 | // If not a public blog, don't ping. |
| 62 | - if ( ! $public ) |
|
| 63 | - update_option('default_pingback_flag', 0); |
|
| 64 | + if ( ! $public ) { |
|
| 65 | + update_option('default_pingback_flag', 0); |
|
| 66 | + } |
|
| 64 | 67 | |
| 65 | 68 | /* |
| 66 | 69 | * Create default user. If the user already exists, the user tables are |
@@ -155,8 +158,9 @@ discard block |
||
| 155 | 158 | if ( is_multisite() ) { |
| 156 | 159 | $first_post = get_site_option( 'first_post' ); |
| 157 | 160 | |
| 158 | - if ( empty($first_post) ) |
|
| 159 | - $first_post = __( 'Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start writing!' ); |
|
| 161 | + if ( empty($first_post) ) { |
|
| 162 | + $first_post = __( 'Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start writing!' ); |
|
| 163 | + } |
|
| 160 | 164 | |
| 161 | 165 | $first_post = str_replace( "SITE_URL", esc_url( network_home_url() ), $first_post ); |
| 162 | 166 | $first_post = str_replace( "SITE_NAME", get_current_site()->site_name, $first_post ); |
@@ -213,8 +217,9 @@ discard block |
||
| 213 | 217 | <blockquote>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</blockquote> |
| 214 | 218 | |
| 215 | 219 | As a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to delete this page and create new pages for your content. Have fun!" ), admin_url() ); |
| 216 | - if ( is_multisite() ) |
|
| 217 | - $first_page = get_site_option( 'first_page', $first_page ); |
|
| 220 | + if ( is_multisite() ) { |
|
| 221 | + $first_page = get_site_option( 'first_page', $first_page ); |
|
| 222 | + } |
|
| 218 | 223 | $first_post_guid = get_option('home') . '/?page_id=2'; |
| 219 | 224 | $wpdb->insert( $wpdb->posts, array( |
| 220 | 225 | 'post_author' => $user_id, |
@@ -244,10 +249,11 @@ discard block |
||
| 244 | 249 | update_option( 'widget_meta', array ( 2 => array ( 'title' => '' ), '_multiwidget' => 1 ) ); |
| 245 | 250 | update_option( 'sidebars_widgets', array ( 'wp_inactive_widgets' => array (), 'sidebar-1' => array ( 0 => 'search-2', 1 => 'recent-posts-2', 2 => 'recent-comments-2', 3 => 'archives-2', 4 => 'categories-2', 5 => 'meta-2', ), 'array_version' => 3 ) ); |
| 246 | 251 | |
| 247 | - if ( ! is_multisite() ) |
|
| 248 | - update_user_meta( $user_id, 'show_welcome_panel', 1 ); |
|
| 249 | - elseif ( ! is_super_admin( $user_id ) && ! metadata_exists( 'user', $user_id, 'show_welcome_panel' ) ) |
|
| 250 | - update_user_meta( $user_id, 'show_welcome_panel', 2 ); |
|
| 252 | + if ( ! is_multisite() ) { |
|
| 253 | + update_user_meta( $user_id, 'show_welcome_panel', 1 ); |
|
| 254 | + } elseif ( ! is_super_admin( $user_id ) && ! metadata_exists( 'user', $user_id, 'show_welcome_panel' ) ) { |
|
| 255 | + update_user_meta( $user_id, 'show_welcome_panel', 2 ); |
|
| 256 | + } |
|
| 251 | 257 | |
| 252 | 258 | if ( is_multisite() ) { |
| 253 | 259 | // Flush rules to pick up the new page. |
@@ -262,8 +268,9 @@ discard block |
||
| 262 | 268 | $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'capabilities') ); |
| 263 | 269 | |
| 264 | 270 | // Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id. |
| 265 | - if ( !is_super_admin( $user_id ) && $user_id != 1 ) |
|
| 266 | - $wpdb->delete( $wpdb->usermeta, array( 'user_id' => $user_id , 'meta_key' => $wpdb->base_prefix.'1_capabilities' ) ); |
|
| 271 | + if ( !is_super_admin( $user_id ) && $user_id != 1 ) { |
|
| 272 | + $wpdb->delete( $wpdb->usermeta, array( 'user_id' => $user_id , 'meta_key' => $wpdb->base_prefix.'1_capabilities' ) ); |
|
| 273 | + } |
|
| 267 | 274 | } |
| 268 | 275 | } |
| 269 | 276 | endif; |
@@ -399,26 +406,30 @@ discard block |
||
| 399 | 406 | $wp_current_db_version = __get_option('db_version'); |
| 400 | 407 | |
| 401 | 408 | // We are up-to-date. Nothing to do. |
| 402 | - if ( $wp_db_version == $wp_current_db_version ) |
|
| 403 | - return; |
|
| 409 | + if ( $wp_db_version == $wp_current_db_version ) { |
|
| 410 | + return; |
|
| 411 | + } |
|
| 404 | 412 | |
| 405 | - if ( ! is_blog_installed() ) |
|
| 406 | - return; |
|
| 413 | + if ( ! is_blog_installed() ) { |
|
| 414 | + return; |
|
| 415 | + } |
|
| 407 | 416 | |
| 408 | 417 | wp_check_mysql_version(); |
| 409 | 418 | wp_cache_flush(); |
| 410 | 419 | pre_schema_upgrade(); |
| 411 | 420 | make_db_current_silent(); |
| 412 | 421 | upgrade_all(); |
| 413 | - if ( is_multisite() && is_main_site() ) |
|
| 414 | - upgrade_network(); |
|
| 422 | + if ( is_multisite() && is_main_site() ) { |
|
| 423 | + upgrade_network(); |
|
| 424 | + } |
|
| 415 | 425 | wp_cache_flush(); |
| 416 | 426 | |
| 417 | 427 | if ( is_multisite() ) { |
| 418 | - if ( $wpdb->get_row( "SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'" ) ) |
|
| 419 | - $wpdb->query( "UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'" ); |
|
| 420 | - else |
|
| 421 | - $wpdb->query( "INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());" ); |
|
| 428 | + if ( $wpdb->get_row( "SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'" ) ) { |
|
| 429 | + $wpdb->query( "UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'" ); |
|
| 430 | + } else { |
|
| 431 | + $wpdb->query( "INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());" ); |
|
| 432 | + } |
|
| 422 | 433 | } |
| 423 | 434 | |
| 424 | 435 | /** |
@@ -449,8 +460,9 @@ discard block |
||
| 449 | 460 | $wp_current_db_version = __get_option('db_version'); |
| 450 | 461 | |
| 451 | 462 | // We are up-to-date. Nothing to do. |
| 452 | - if ( $wp_db_version == $wp_current_db_version ) |
|
| 453 | - return; |
|
| 463 | + if ( $wp_db_version == $wp_current_db_version ) { |
|
| 464 | + return; |
|
| 465 | + } |
|
| 454 | 466 | |
| 455 | 467 | // If the version is not set in the DB, try to guess the version. |
| 456 | 468 | if ( empty($wp_current_db_version) ) { |
@@ -458,12 +470,14 @@ discard block |
||
| 458 | 470 | |
| 459 | 471 | // If the template option exists, we have 1.5. |
| 460 | 472 | $template = __get_option('template'); |
| 461 | - if ( !empty($template) ) |
|
| 462 | - $wp_current_db_version = 2541; |
|
| 473 | + if ( !empty($template) ) { |
|
| 474 | + $wp_current_db_version = 2541; |
|
| 475 | + } |
|
| 463 | 476 | } |
| 464 | 477 | |
| 465 | - if ( $wp_current_db_version < 6039 ) |
|
| 466 | - upgrade_230_options_table(); |
|
| 478 | + if ( $wp_current_db_version < 6039 ) { |
|
| 479 | + upgrade_230_options_table(); |
|
| 480 | + } |
|
| 467 | 481 | |
| 468 | 482 | populate_options(); |
| 469 | 483 | |
@@ -474,68 +488,89 @@ discard block |
||
| 474 | 488 | upgrade_130(); |
| 475 | 489 | } |
| 476 | 490 | |
| 477 | - if ( $wp_current_db_version < 3308 ) |
|
| 478 | - upgrade_160(); |
|
| 491 | + if ( $wp_current_db_version < 3308 ) { |
|
| 492 | + upgrade_160(); |
|
| 493 | + } |
|
| 479 | 494 | |
| 480 | - if ( $wp_current_db_version < 4772 ) |
|
| 481 | - upgrade_210(); |
|
| 495 | + if ( $wp_current_db_version < 4772 ) { |
|
| 496 | + upgrade_210(); |
|
| 497 | + } |
|
| 482 | 498 | |
| 483 | - if ( $wp_current_db_version < 4351 ) |
|
| 484 | - upgrade_old_slugs(); |
|
| 499 | + if ( $wp_current_db_version < 4351 ) { |
|
| 500 | + upgrade_old_slugs(); |
|
| 501 | + } |
|
| 485 | 502 | |
| 486 | - if ( $wp_current_db_version < 5539 ) |
|
| 487 | - upgrade_230(); |
|
| 503 | + if ( $wp_current_db_version < 5539 ) { |
|
| 504 | + upgrade_230(); |
|
| 505 | + } |
|
| 488 | 506 | |
| 489 | - if ( $wp_current_db_version < 6124 ) |
|
| 490 | - upgrade_230_old_tables(); |
|
| 507 | + if ( $wp_current_db_version < 6124 ) { |
|
| 508 | + upgrade_230_old_tables(); |
|
| 509 | + } |
|
| 491 | 510 | |
| 492 | - if ( $wp_current_db_version < 7499 ) |
|
| 493 | - upgrade_250(); |
|
| 511 | + if ( $wp_current_db_version < 7499 ) { |
|
| 512 | + upgrade_250(); |
|
| 513 | + } |
|
| 494 | 514 | |
| 495 | - if ( $wp_current_db_version < 7935 ) |
|
| 496 | - upgrade_252(); |
|
| 515 | + if ( $wp_current_db_version < 7935 ) { |
|
| 516 | + upgrade_252(); |
|
| 517 | + } |
|
| 497 | 518 | |
| 498 | - if ( $wp_current_db_version < 8201 ) |
|
| 499 | - upgrade_260(); |
|
| 519 | + if ( $wp_current_db_version < 8201 ) { |
|
| 520 | + upgrade_260(); |
|
| 521 | + } |
|
| 500 | 522 | |
| 501 | - if ( $wp_current_db_version < 8989 ) |
|
| 502 | - upgrade_270(); |
|
| 523 | + if ( $wp_current_db_version < 8989 ) { |
|
| 524 | + upgrade_270(); |
|
| 525 | + } |
|
| 503 | 526 | |
| 504 | - if ( $wp_current_db_version < 10360 ) |
|
| 505 | - upgrade_280(); |
|
| 527 | + if ( $wp_current_db_version < 10360 ) { |
|
| 528 | + upgrade_280(); |
|
| 529 | + } |
|
| 506 | 530 | |
| 507 | - if ( $wp_current_db_version < 11958 ) |
|
| 508 | - upgrade_290(); |
|
| 531 | + if ( $wp_current_db_version < 11958 ) { |
|
| 532 | + upgrade_290(); |
|
| 533 | + } |
|
| 509 | 534 | |
| 510 | - if ( $wp_current_db_version < 15260 ) |
|
| 511 | - upgrade_300(); |
|
| 535 | + if ( $wp_current_db_version < 15260 ) { |
|
| 536 | + upgrade_300(); |
|
| 537 | + } |
|
| 512 | 538 | |
| 513 | - if ( $wp_current_db_version < 19389 ) |
|
| 514 | - upgrade_330(); |
|
| 539 | + if ( $wp_current_db_version < 19389 ) { |
|
| 540 | + upgrade_330(); |
|
| 541 | + } |
|
| 515 | 542 | |
| 516 | - if ( $wp_current_db_version < 20080 ) |
|
| 517 | - upgrade_340(); |
|
| 543 | + if ( $wp_current_db_version < 20080 ) { |
|
| 544 | + upgrade_340(); |
|
| 545 | + } |
|
| 518 | 546 | |
| 519 | - if ( $wp_current_db_version < 22422 ) |
|
| 520 | - upgrade_350(); |
|
| 547 | + if ( $wp_current_db_version < 22422 ) { |
|
| 548 | + upgrade_350(); |
|
| 549 | + } |
|
| 521 | 550 | |
| 522 | - if ( $wp_current_db_version < 25824 ) |
|
| 523 | - upgrade_370(); |
|
| 551 | + if ( $wp_current_db_version < 25824 ) { |
|
| 552 | + upgrade_370(); |
|
| 553 | + } |
|
| 524 | 554 | |
| 525 | - if ( $wp_current_db_version < 26148 ) |
|
| 526 | - upgrade_372(); |
|
| 555 | + if ( $wp_current_db_version < 26148 ) { |
|
| 556 | + upgrade_372(); |
|
| 557 | + } |
|
| 527 | 558 | |
| 528 | - if ( $wp_current_db_version < 26691 ) |
|
| 529 | - upgrade_380(); |
|
| 559 | + if ( $wp_current_db_version < 26691 ) { |
|
| 560 | + upgrade_380(); |
|
| 561 | + } |
|
| 530 | 562 | |
| 531 | - if ( $wp_current_db_version < 29630 ) |
|
| 532 | - upgrade_400(); |
|
| 563 | + if ( $wp_current_db_version < 29630 ) { |
|
| 564 | + upgrade_400(); |
|
| 565 | + } |
|
| 533 | 566 | |
| 534 | - if ( $wp_current_db_version < 33055 ) |
|
| 535 | - upgrade_430(); |
|
| 567 | + if ( $wp_current_db_version < 33055 ) { |
|
| 568 | + upgrade_430(); |
|
| 569 | + } |
|
| 536 | 570 | |
| 537 | - if ( $wp_current_db_version < 33056 ) |
|
| 538 | - upgrade_431(); |
|
| 571 | + if ( $wp_current_db_version < 33056 ) { |
|
| 572 | + upgrade_431(); |
|
| 573 | + } |
|
| 539 | 574 | |
| 540 | 575 | maybe_disable_link_manager(); |
| 541 | 576 | |
@@ -587,8 +622,10 @@ discard block |
||
| 587 | 622 | $done_posts[] = $done_id->post_id; |
| 588 | 623 | endforeach; |
| 589 | 624 | $catwhere = ' AND ID NOT IN (' . implode(',', $done_posts) . ')'; |
| 590 | - else: |
|
| 625 | + else { |
|
| 626 | + : |
|
| 591 | 627 | $catwhere = ''; |
| 628 | + } |
|
| 592 | 629 | endif; |
| 593 | 630 | |
| 594 | 631 | $allposts = $wpdb->get_results("SELECT ID, post_category FROM $wpdb->posts WHERE post_category != '0' $catwhere"); |
@@ -702,10 +739,11 @@ discard block |
||
| 702 | 739 | $post_content = addslashes(deslash($post->post_content)); |
| 703 | 740 | $post_title = addslashes(deslash($post->post_title)); |
| 704 | 741 | $post_excerpt = addslashes(deslash($post->post_excerpt)); |
| 705 | - if ( empty($post->guid) ) |
|
| 706 | - $guid = get_permalink($post->ID); |
|
| 707 | - else |
|
| 708 | - $guid = $post->guid; |
|
| 742 | + if ( empty($post->guid) ) { |
|
| 743 | + $guid = get_permalink($post->ID); |
|
| 744 | + } else { |
|
| 745 | + $guid = $post->guid; |
|
| 746 | + } |
|
| 709 | 747 | |
| 710 | 748 | $wpdb->update( $wpdb->posts, compact('post_title', 'post_content', 'post_excerpt', 'guid'), array('ID' => $post->ID) ); |
| 711 | 749 | |
@@ -786,34 +824,57 @@ discard block |
||
| 786 | 824 | |
| 787 | 825 | $users = $wpdb->get_results("SELECT * FROM $wpdb->users"); |
| 788 | 826 | foreach ( $users as $user ) : |
| 789 | - if ( !empty( $user->user_firstname ) ) |
|
| 790 | - update_user_meta( $user->ID, 'first_name', wp_slash($user->user_firstname) ); |
|
| 791 | - if ( !empty( $user->user_lastname ) ) |
|
| 792 | - update_user_meta( $user->ID, 'last_name', wp_slash($user->user_lastname) ); |
|
| 793 | - if ( !empty( $user->user_nickname ) ) |
|
| 794 | - update_user_meta( $user->ID, 'nickname', wp_slash($user->user_nickname) ); |
|
| 795 | - if ( !empty( $user->user_level ) ) |
|
| 796 | - update_user_meta( $user->ID, $wpdb->prefix . 'user_level', $user->user_level ); |
|
| 797 | - if ( !empty( $user->user_icq ) ) |
|
| 798 | - update_user_meta( $user->ID, 'icq', wp_slash($user->user_icq) ); |
|
| 799 | - if ( !empty( $user->user_aim ) ) |
|
| 800 | - update_user_meta( $user->ID, 'aim', wp_slash($user->user_aim) ); |
|
| 801 | - if ( !empty( $user->user_msn ) ) |
|
| 802 | - update_user_meta( $user->ID, 'msn', wp_slash($user->user_msn) ); |
|
| 803 | - if ( !empty( $user->user_yim ) ) |
|
| 804 | - update_user_meta( $user->ID, 'yim', wp_slash($user->user_icq) ); |
|
| 805 | - if ( !empty( $user->user_description ) ) |
|
| 806 | - update_user_meta( $user->ID, 'description', wp_slash($user->user_description) ); |
|
| 827 | + if ( !empty( $user->user_firstname ) ) { |
|
| 828 | + update_user_meta( $user->ID, 'first_name', wp_slash($user->user_firstname) ); |
|
| 829 | + } |
|
| 830 | + if ( !empty( $user->user_lastname ) ) { |
|
| 831 | + update_user_meta( $user->ID, 'last_name', wp_slash($user->user_lastname) ); |
|
| 832 | + } |
|
| 833 | + if ( !empty( $user->user_nickname ) ) { |
|
| 834 | + update_user_meta( $user->ID, 'nickname', wp_slash($user->user_nickname) ); |
|
| 835 | + } |
|
| 836 | + if ( !empty( $user->user_level ) ) { |
|
| 837 | + update_user_meta( $user->ID, $wpdb->prefix . 'user_level', $user->user_level ); |
|
| 838 | + } |
|
| 839 | + if ( !empty( $user->user_icq ) ) { |
|
| 840 | + update_user_meta( $user->ID, 'icq', wp_slash($user->user_icq) ); |
|
| 841 | + } |
|
| 842 | + if ( !empty( $user->user_aim ) ) { |
|
| 843 | + update_user_meta( $user->ID, 'aim', wp_slash($user->user_aim) ); |
|
| 844 | + } |
|
| 845 | + if ( !empty( $user->user_msn ) ) { |
|
| 846 | + update_user_meta( $user->ID, 'msn', wp_slash($user->user_msn) ); |
|
| 847 | + } |
|
| 848 | + if ( !empty( $user->user_yim ) ) { |
|
| 849 | + update_user_meta( $user->ID, 'yim', wp_slash($user->user_icq) ); |
|
| 850 | + } |
|
| 851 | + if ( !empty( $user->user_description ) ) { |
|
| 852 | + update_user_meta( $user->ID, 'description', wp_slash($user->user_description) ); |
|
| 853 | + } |
|
| 807 | 854 | |
| 808 | 855 | if ( isset( $user->user_idmode ) ): |
| 809 | 856 | $idmode = $user->user_idmode; |
| 810 | - if ($idmode == 'nickname') $id = $user->user_nickname; |
|
| 811 | - if ($idmode == 'login') $id = $user->user_login; |
|
| 812 | - if ($idmode == 'firstname') $id = $user->user_firstname; |
|
| 813 | - if ($idmode == 'lastname') $id = $user->user_lastname; |
|
| 814 | - if ($idmode == 'namefl') $id = $user->user_firstname.' '.$user->user_lastname; |
|
| 815 | - if ($idmode == 'namelf') $id = $user->user_lastname.' '.$user->user_firstname; |
|
| 816 | - if (!$idmode) $id = $user->user_nickname; |
|
| 857 | + if ($idmode == 'nickname') { |
|
| 858 | + $id = $user->user_nickname; |
|
| 859 | + } |
|
| 860 | + if ($idmode == 'login') { |
|
| 861 | + $id = $user->user_login; |
|
| 862 | + } |
|
| 863 | + if ($idmode == 'firstname') { |
|
| 864 | + $id = $user->user_firstname; |
|
| 865 | + } |
|
| 866 | + if ($idmode == 'lastname') { |
|
| 867 | + $id = $user->user_lastname; |
|
| 868 | + } |
|
| 869 | + if ($idmode == 'namefl') { |
|
| 870 | + $id = $user->user_firstname.' '.$user->user_lastname; |
|
| 871 | + } |
|
| 872 | + if ($idmode == 'namelf') { |
|
| 873 | + $id = $user->user_lastname.' '.$user->user_firstname; |
|
| 874 | + } |
|
| 875 | + if (!$idmode) { |
|
| 876 | + $id = $user->user_nickname; |
|
| 877 | + } |
|
| 817 | 878 | $wpdb->update( $wpdb->users, array('display_name' => $id), array('ID' => $user->ID) ); |
| 818 | 879 | endif; |
| 819 | 880 | |
@@ -828,15 +889,17 @@ discard block |
||
| 828 | 889 | endforeach; |
| 829 | 890 | $old_user_fields = array( 'user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level' ); |
| 830 | 891 | $wpdb->hide_errors(); |
| 831 | - foreach ( $old_user_fields as $old ) |
|
| 832 | - $wpdb->query("ALTER TABLE $wpdb->users DROP $old"); |
|
| 892 | + foreach ( $old_user_fields as $old ) { |
|
| 893 | + $wpdb->query("ALTER TABLE $wpdb->users DROP $old"); |
|
| 894 | + } |
|
| 833 | 895 | $wpdb->show_errors(); |
| 834 | 896 | |
| 835 | 897 | // Populate comment_count field of posts table. |
| 836 | 898 | $comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" ); |
| 837 | - if ( is_array( $comments ) ) |
|
| 838 | - foreach ($comments as $comment) |
|
| 899 | + if ( is_array( $comments ) ) { |
|
| 900 | + foreach ($comments as $comment) |
|
| 839 | 901 | $wpdb->update( $wpdb->posts, array('comment_count' => $comment->c), array('ID' => $comment->comment_post_ID) ); |
| 902 | + } |
|
| 840 | 903 | |
| 841 | 904 | /* |
| 842 | 905 | * Some alpha versions used a post status of object instead of attachment |
@@ -851,8 +914,9 @@ discard block |
||
| 851 | 914 | array( 'ID' => $object->ID ) ); |
| 852 | 915 | |
| 853 | 916 | $meta = get_post_meta($object->ID, 'imagedata', true); |
| 854 | - if ( ! empty($meta['file']) ) |
|
| 855 | - update_attached_file( $object->ID, $meta['file'] ); |
|
| 917 | + if ( ! empty($meta['file']) ) { |
|
| 918 | + update_attached_file( $object->ID, $meta['file'] ); |
|
| 919 | + } |
|
| 856 | 920 | } |
| 857 | 921 | } |
| 858 | 922 | } |
@@ -872,8 +936,10 @@ discard block |
||
| 872 | 936 | // Update status and type. |
| 873 | 937 | $posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts"); |
| 874 | 938 | |
| 875 | - if ( ! empty($posts) ) foreach ($posts as $post) { |
|
| 939 | + if ( ! empty($posts) ) { |
|
| 940 | + foreach ($posts as $post) { |
|
| 876 | 941 | $status = $post->post_status; |
| 942 | + } |
|
| 877 | 943 | $type = 'post'; |
| 878 | 944 | |
| 879 | 945 | if ( 'static' == $status ) { |
@@ -898,9 +964,10 @@ discard block |
||
| 898 | 964 | $wpdb->query ("UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'"); |
| 899 | 965 | |
| 900 | 966 | $posts = $wpdb->get_results("SELECT ID, post_date FROM $wpdb->posts WHERE post_status ='future'"); |
| 901 | - if ( !empty($posts) ) |
|
| 902 | - foreach ( $posts as $post ) |
|
| 967 | + if ( !empty($posts) ) { |
|
| 968 | + foreach ( $posts as $post ) |
|
| 903 | 969 | wp_schedule_single_event(mysql2date('U', $post->post_date, false), 'publish_future_post', array($post->ID)); |
| 970 | + } |
|
| 904 | 971 | } |
| 905 | 972 | } |
| 906 | 973 | |
@@ -985,19 +1052,22 @@ discard block |
||
| 985 | 1052 | } |
| 986 | 1053 | |
| 987 | 1054 | $select = 'post_id, category_id'; |
| 988 | - if ( $have_tags ) |
|
| 989 | - $select .= ', rel_type'; |
|
| 1055 | + if ( $have_tags ) { |
|
| 1056 | + $select .= ', rel_type'; |
|
| 1057 | + } |
|
| 990 | 1058 | |
| 991 | 1059 | $posts = $wpdb->get_results("SELECT $select FROM $wpdb->post2cat GROUP BY post_id, category_id"); |
| 992 | 1060 | foreach ( $posts as $post ) { |
| 993 | 1061 | $post_id = (int) $post->post_id; |
| 994 | 1062 | $term_id = (int) $post->category_id; |
| 995 | 1063 | $taxonomy = 'category'; |
| 996 | - if ( !empty($post->rel_type) && 'tag' == $post->rel_type) |
|
| 997 | - $taxonomy = 'tag'; |
|
| 1064 | + if ( !empty($post->rel_type) && 'tag' == $post->rel_type) { |
|
| 1065 | + $taxonomy = 'tag'; |
|
| 1066 | + } |
|
| 998 | 1067 | $tt_id = $tt_ids[$term_id][$taxonomy]; |
| 999 | - if ( empty($tt_id) ) |
|
| 1000 | - continue; |
|
| 1068 | + if ( empty($tt_id) ) { |
|
| 1069 | + continue; |
|
| 1070 | + } |
|
| 1001 | 1071 | |
| 1002 | 1072 | $wpdb->insert( $wpdb->term_relationships, array('object_id' => $post_id, 'term_taxonomy_id' => $tt_id) ); |
| 1003 | 1073 | } |
@@ -1039,15 +1109,19 @@ discard block |
||
| 1039 | 1109 | |
| 1040 | 1110 | // Associate links to cats. |
| 1041 | 1111 | $links = $wpdb->get_results("SELECT link_id, link_category FROM $wpdb->links"); |
| 1042 | - if ( !empty($links) ) foreach ( $links as $link ) { |
|
| 1112 | + if ( !empty($links) ) { |
|
| 1113 | + foreach ( $links as $link ) { |
|
| 1043 | 1114 | if ( 0 == $link->link_category ) |
| 1044 | 1115 | continue; |
| 1045 | - if ( ! isset($link_cat_id_map[$link->link_category]) ) |
|
| 1046 | - continue; |
|
| 1116 | + } |
|
| 1117 | + if ( ! isset($link_cat_id_map[$link->link_category]) ) { |
|
| 1118 | + continue; |
|
| 1119 | + } |
|
| 1047 | 1120 | $term_id = $link_cat_id_map[$link->link_category]; |
| 1048 | 1121 | $tt_id = $tt_ids[$term_id]; |
| 1049 | - if ( empty($tt_id) ) |
|
| 1050 | - continue; |
|
| 1122 | + if ( empty($tt_id) ) { |
|
| 1123 | + continue; |
|
| 1124 | + } |
|
| 1051 | 1125 | |
| 1052 | 1126 | $wpdb->insert( $wpdb->term_relationships, array('object_id' => $link->link_id, 'term_taxonomy_id' => $tt_id) ); |
| 1053 | 1127 | } |
@@ -1061,8 +1135,9 @@ discard block |
||
| 1061 | 1135 | $term_id = (int) $link->category_id; |
| 1062 | 1136 | $taxonomy = 'link_category'; |
| 1063 | 1137 | $tt_id = $tt_ids[$term_id][$taxonomy]; |
| 1064 | - if ( empty($tt_id) ) |
|
| 1065 | - continue; |
|
| 1138 | + if ( empty($tt_id) ) { |
|
| 1139 | + continue; |
|
| 1140 | + } |
|
| 1066 | 1141 | $wpdb->insert( $wpdb->term_relationships, array('object_id' => $link_id, 'term_taxonomy_id' => $tt_id) ); |
| 1067 | 1142 | } |
| 1068 | 1143 | } |
@@ -1075,10 +1150,11 @@ discard block |
||
| 1075 | 1150 | // Recalculate all counts |
| 1076 | 1151 | $terms = $wpdb->get_results("SELECT term_taxonomy_id, taxonomy FROM $wpdb->term_taxonomy"); |
| 1077 | 1152 | foreach ( (array) $terms as $term ) { |
| 1078 | - if ( ('post_tag' == $term->taxonomy) || ('category' == $term->taxonomy) ) |
|
| 1079 | - $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term->term_taxonomy_id) ); |
|
| 1080 | - else |
|
| 1081 | - $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id) ); |
|
| 1153 | + if ( ('post_tag' == $term->taxonomy) || ('category' == $term->taxonomy) ) { |
|
| 1154 | + $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term->term_taxonomy_id) ); |
|
| 1155 | + } else { |
|
| 1156 | + $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id) ); |
|
| 1157 | + } |
|
| 1082 | 1158 | $wpdb->update( $wpdb->term_taxonomy, array('count' => $count), array('term_taxonomy_id' => $term->term_taxonomy_id) ); |
| 1083 | 1159 | } |
| 1084 | 1160 | } |
@@ -1094,8 +1170,9 @@ discard block |
||
| 1094 | 1170 | global $wpdb; |
| 1095 | 1171 | $old_options_fields = array( 'option_can_override', 'option_type', 'option_width', 'option_height', 'option_description', 'option_admin_level' ); |
| 1096 | 1172 | $wpdb->hide_errors(); |
| 1097 | - foreach ( $old_options_fields as $old ) |
|
| 1098 | - $wpdb->query("ALTER TABLE $wpdb->options DROP $old"); |
|
| 1173 | + foreach ( $old_options_fields as $old ) { |
|
| 1174 | + $wpdb->query("ALTER TABLE $wpdb->options DROP $old"); |
|
| 1175 | + } |
|
| 1099 | 1176 | $wpdb->show_errors(); |
| 1100 | 1177 | } |
| 1101 | 1178 | |
@@ -1165,9 +1242,10 @@ discard block |
||
| 1165 | 1242 | function upgrade_260() { |
| 1166 | 1243 | global $wp_current_db_version; |
| 1167 | 1244 | |
| 1168 | - if ( $wp_current_db_version < 8000 ) |
|
| 1169 | - populate_roles_260(); |
|
| 1170 | -} |
|
| 1245 | + if ( $wp_current_db_version < 8000 ) { |
|
| 1246 | + populate_roles_260(); |
|
| 1247 | + } |
|
| 1248 | + } |
|
| 1171 | 1249 | |
| 1172 | 1250 | /** |
| 1173 | 1251 | * Execute changes made in WordPress 2.7. |
@@ -1180,13 +1258,15 @@ discard block |
||
| 1180 | 1258 | function upgrade_270() { |
| 1181 | 1259 | global $wpdb, $wp_current_db_version; |
| 1182 | 1260 | |
| 1183 | - if ( $wp_current_db_version < 8980 ) |
|
| 1184 | - populate_roles_270(); |
|
| 1261 | + if ( $wp_current_db_version < 8980 ) { |
|
| 1262 | + populate_roles_270(); |
|
| 1263 | + } |
|
| 1185 | 1264 | |
| 1186 | 1265 | // Update post_date for unpublished posts with empty timestamp |
| 1187 | - if ( $wp_current_db_version < 8921 ) |
|
| 1188 | - $wpdb->query( "UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'" ); |
|
| 1189 | -} |
|
| 1266 | + if ( $wp_current_db_version < 8921 ) { |
|
| 1267 | + $wpdb->query( "UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'" ); |
|
| 1268 | + } |
|
| 1269 | + } |
|
| 1190 | 1270 | |
| 1191 | 1271 | /** |
| 1192 | 1272 | * Execute changes made in WordPress 2.8. |
@@ -1199,15 +1279,17 @@ discard block |
||
| 1199 | 1279 | function upgrade_280() { |
| 1200 | 1280 | global $wp_current_db_version, $wpdb; |
| 1201 | 1281 | |
| 1202 | - if ( $wp_current_db_version < 10360 ) |
|
| 1203 | - populate_roles_280(); |
|
| 1282 | + if ( $wp_current_db_version < 10360 ) { |
|
| 1283 | + populate_roles_280(); |
|
| 1284 | + } |
|
| 1204 | 1285 | if ( is_multisite() ) { |
| 1205 | 1286 | $start = 0; |
| 1206 | 1287 | while( $rows = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20" ) ) { |
| 1207 | 1288 | foreach( $rows as $row ) { |
| 1208 | 1289 | $value = $row->option_value; |
| 1209 | - if ( !@unserialize( $value ) ) |
|
| 1210 | - $value = stripslashes( $value ); |
|
| 1290 | + if ( !@unserialize( $value ) ) { |
|
| 1291 | + $value = stripslashes( $value ); |
|
| 1292 | + } |
|
| 1211 | 1293 | if ( $value !== $row->option_value ) { |
| 1212 | 1294 | update_option( $row->option_name, $value ); |
| 1213 | 1295 | } |
@@ -1248,11 +1330,13 @@ discard block |
||
| 1248 | 1330 | function upgrade_300() { |
| 1249 | 1331 | global $wp_current_db_version, $wpdb; |
| 1250 | 1332 | |
| 1251 | - if ( $wp_current_db_version < 15093 ) |
|
| 1252 | - populate_roles_300(); |
|
| 1333 | + if ( $wp_current_db_version < 15093 ) { |
|
| 1334 | + populate_roles_300(); |
|
| 1335 | + } |
|
| 1253 | 1336 | |
| 1254 | - if ( $wp_current_db_version < 14139 && is_multisite() && is_main_site() && ! defined( 'MULTISITE' ) && get_site_option( 'siteurl' ) === false ) |
|
| 1255 | - add_site_option( 'siteurl', '' ); |
|
| 1337 | + if ( $wp_current_db_version < 14139 && is_multisite() && is_main_site() && ! defined( 'MULTISITE' ) && get_site_option( 'siteurl' ) === false ) { |
|
| 1338 | + add_site_option( 'siteurl', '' ); |
|
| 1339 | + } |
|
| 1256 | 1340 | |
| 1257 | 1341 | // 3.0 screen options key name changes. |
| 1258 | 1342 | if ( wp_should_upgrade_global_tables() ) { |
@@ -1299,23 +1383,26 @@ discard block |
||
| 1299 | 1383 | $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key IN ('show_admin_bar_admin', 'plugins_last_view')" ); |
| 1300 | 1384 | } |
| 1301 | 1385 | |
| 1302 | - if ( $wp_current_db_version >= 11548 ) |
|
| 1303 | - return; |
|
| 1386 | + if ( $wp_current_db_version >= 11548 ) { |
|
| 1387 | + return; |
|
| 1388 | + } |
|
| 1304 | 1389 | |
| 1305 | 1390 | $sidebars_widgets = get_option( 'sidebars_widgets', array() ); |
| 1306 | 1391 | $_sidebars_widgets = array(); |
| 1307 | 1392 | |
| 1308 | - if ( isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets) ) |
|
| 1309 | - $sidebars_widgets['array_version'] = 3; |
|
| 1310 | - elseif ( !isset($sidebars_widgets['array_version']) ) |
|
| 1311 | - $sidebars_widgets['array_version'] = 1; |
|
| 1393 | + if ( isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets) ) { |
|
| 1394 | + $sidebars_widgets['array_version'] = 3; |
|
| 1395 | + } elseif ( !isset($sidebars_widgets['array_version']) ) { |
|
| 1396 | + $sidebars_widgets['array_version'] = 1; |
|
| 1397 | + } |
|
| 1312 | 1398 | |
| 1313 | 1399 | switch ( $sidebars_widgets['array_version'] ) { |
| 1314 | 1400 | case 1 : |
| 1315 | - foreach ( (array) $sidebars_widgets as $index => $sidebar ) |
|
| 1316 | - if ( is_array($sidebar) ) |
|
| 1401 | + foreach ( (array) $sidebars_widgets as $index => $sidebar ) { |
|
| 1402 | + if ( is_array($sidebar) ) |
|
| 1317 | 1403 | foreach ( (array) $sidebar as $i => $name ) { |
| 1318 | 1404 | $id = strtolower($name); |
| 1405 | + } |
|
| 1319 | 1406 | if ( isset($wp_registered_widgets[$id]) ) { |
| 1320 | 1407 | $_sidebars_widgets[$index][$i] = $id; |
| 1321 | 1408 | continue; |
@@ -1340,8 +1427,9 @@ discard block |
||
| 1340 | 1427 | } |
| 1341 | 1428 | } |
| 1342 | 1429 | |
| 1343 | - if ( $found ) |
|
| 1344 | - continue; |
|
| 1430 | + if ( $found ) { |
|
| 1431 | + continue; |
|
| 1432 | + } |
|
| 1345 | 1433 | |
| 1346 | 1434 | unset($_sidebars_widgets[$index][$i]); |
| 1347 | 1435 | } |
@@ -1403,14 +1491,17 @@ discard block |
||
| 1403 | 1491 | function upgrade_350() { |
| 1404 | 1492 | global $wp_current_db_version, $wpdb; |
| 1405 | 1493 | |
| 1406 | - if ( $wp_current_db_version < 22006 && $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) ) |
|
| 1407 | - update_option( 'link_manager_enabled', 1 ); // Previously set to 0 by populate_options() |
|
| 1494 | + if ( $wp_current_db_version < 22006 && $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) ) { |
|
| 1495 | + update_option( 'link_manager_enabled', 1 ); |
|
| 1496 | + } |
|
| 1497 | + // Previously set to 0 by populate_options() |
|
| 1408 | 1498 | |
| 1409 | 1499 | if ( $wp_current_db_version < 21811 && wp_should_upgrade_global_tables() ) { |
| 1410 | 1500 | $meta_keys = array(); |
| 1411 | 1501 | foreach ( array_merge( get_post_types(), get_taxonomies() ) as $name ) { |
| 1412 | - if ( false !== strpos( $name, '-' ) ) |
|
| 1413 | - $meta_keys[] = 'edit_' . str_replace( '-', '_', $name ) . '_per_page'; |
|
| 1502 | + if ( false !== strpos( $name, '-' ) ) { |
|
| 1503 | + $meta_keys[] = 'edit_' . str_replace( '-', '_', $name ) . '_per_page'; |
|
| 1504 | + } |
|
| 1414 | 1505 | } |
| 1415 | 1506 | if ( $meta_keys ) { |
| 1416 | 1507 | $meta_keys = implode( "', '", $meta_keys ); |
@@ -1418,9 +1509,10 @@ discard block |
||
| 1418 | 1509 | } |
| 1419 | 1510 | } |
| 1420 | 1511 | |
| 1421 | - if ( $wp_current_db_version < 22422 && $term = get_term_by( 'slug', 'post-format-standard', 'post_format' ) ) |
|
| 1422 | - wp_delete_term( $term->term_id, 'post_format' ); |
|
| 1423 | -} |
|
| 1512 | + if ( $wp_current_db_version < 22422 && $term = get_term_by( 'slug', 'post-format-standard', 'post_format' ) ) { |
|
| 1513 | + wp_delete_term( $term->term_id, 'post_format' ); |
|
| 1514 | + } |
|
| 1515 | + } |
|
| 1424 | 1516 | |
| 1425 | 1517 | /** |
| 1426 | 1518 | * Execute changes made in WordPress 3.7. |
@@ -1431,9 +1523,10 @@ discard block |
||
| 1431 | 1523 | */ |
| 1432 | 1524 | function upgrade_370() { |
| 1433 | 1525 | global $wp_current_db_version; |
| 1434 | - if ( $wp_current_db_version < 25824 ) |
|
| 1435 | - wp_clear_scheduled_hook( 'wp_auto_updates_maybe_update' ); |
|
| 1436 | -} |
|
| 1526 | + if ( $wp_current_db_version < 25824 ) { |
|
| 1527 | + wp_clear_scheduled_hook( 'wp_auto_updates_maybe_update' ); |
|
| 1528 | + } |
|
| 1529 | + } |
|
| 1437 | 1530 | |
| 1438 | 1531 | /** |
| 1439 | 1532 | * Execute changes made in WordPress 3.7.2. |
@@ -1445,9 +1538,10 @@ discard block |
||
| 1445 | 1538 | */ |
| 1446 | 1539 | function upgrade_372() { |
| 1447 | 1540 | global $wp_current_db_version; |
| 1448 | - if ( $wp_current_db_version < 26148 ) |
|
| 1449 | - wp_clear_scheduled_hook( 'wp_maybe_auto_update' ); |
|
| 1450 | -} |
|
| 1541 | + if ( $wp_current_db_version < 26148 ) { |
|
| 1542 | + wp_clear_scheduled_hook( 'wp_maybe_auto_update' ); |
|
| 1543 | + } |
|
| 1544 | + } |
|
| 1451 | 1545 | |
| 1452 | 1546 | /** |
| 1453 | 1547 | * Execute changes made in WordPress 3.8.0. |
@@ -1629,10 +1723,11 @@ discard block |
||
| 1629 | 1723 | $wpmu_sitewide_plugins = get_site_option( 'wpmu_sitewide_plugins' ); |
| 1630 | 1724 | $active_sitewide_plugins = get_site_option( 'active_sitewide_plugins' ); |
| 1631 | 1725 | if ( $wpmu_sitewide_plugins ) { |
| 1632 | - if ( !$active_sitewide_plugins ) |
|
| 1633 | - $sitewide_plugins = (array) $wpmu_sitewide_plugins; |
|
| 1634 | - else |
|
| 1635 | - $sitewide_plugins = array_merge( (array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins ); |
|
| 1726 | + if ( !$active_sitewide_plugins ) { |
|
| 1727 | + $sitewide_plugins = (array) $wpmu_sitewide_plugins; |
|
| 1728 | + } else { |
|
| 1729 | + $sitewide_plugins = array_merge( (array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins ); |
|
| 1730 | + } |
|
| 1636 | 1731 | |
| 1637 | 1732 | update_site_option( 'active_sitewide_plugins', $sitewide_plugins ); |
| 1638 | 1733 | } |
@@ -1643,8 +1738,9 @@ discard block |
||
| 1643 | 1738 | while( $rows = $wpdb->get_results( "SELECT meta_key, meta_value FROM {$wpdb->sitemeta} ORDER BY meta_id LIMIT $start, 20" ) ) { |
| 1644 | 1739 | foreach( $rows as $row ) { |
| 1645 | 1740 | $value = $row->meta_value; |
| 1646 | - if ( !@unserialize( $value ) ) |
|
| 1647 | - $value = stripslashes( $value ); |
|
| 1741 | + if ( !@unserialize( $value ) ) { |
|
| 1742 | + $value = stripslashes( $value ); |
|
| 1743 | + } |
|
| 1648 | 1744 | if ( $value !== $row->meta_value ) { |
| 1649 | 1745 | update_site_option( $row->meta_key, $value ); |
| 1650 | 1746 | } |
@@ -1654,16 +1750,19 @@ discard block |
||
| 1654 | 1750 | } |
| 1655 | 1751 | |
| 1656 | 1752 | // 3.0 |
| 1657 | - if ( $wp_current_db_version < 13576 ) |
|
| 1658 | - update_site_option( 'global_terms_enabled', '1' ); |
|
| 1753 | + if ( $wp_current_db_version < 13576 ) { |
|
| 1754 | + update_site_option( 'global_terms_enabled', '1' ); |
|
| 1755 | + } |
|
| 1659 | 1756 | |
| 1660 | 1757 | // 3.3 |
| 1661 | - if ( $wp_current_db_version < 19390 ) |
|
| 1662 | - update_site_option( 'initial_db_version', $wp_current_db_version ); |
|
| 1758 | + if ( $wp_current_db_version < 19390 ) { |
|
| 1759 | + update_site_option( 'initial_db_version', $wp_current_db_version ); |
|
| 1760 | + } |
|
| 1663 | 1761 | |
| 1664 | 1762 | if ( $wp_current_db_version < 19470 ) { |
| 1665 | - if ( false === get_site_option( 'active_sitewide_plugins' ) ) |
|
| 1666 | - update_site_option( 'active_sitewide_plugins', array() ); |
|
| 1763 | + if ( false === get_site_option( 'active_sitewide_plugins' ) ) { |
|
| 1764 | + update_site_option( 'active_sitewide_plugins', array() ); |
|
| 1765 | + } |
|
| 1667 | 1766 | } |
| 1668 | 1767 | |
| 1669 | 1768 | // 3.4 |
@@ -1675,8 +1774,9 @@ discard block |
||
| 1675 | 1774 | $converted = array(); |
| 1676 | 1775 | $themes = wp_get_themes(); |
| 1677 | 1776 | foreach ( $themes as $stylesheet => $theme_data ) { |
| 1678 | - if ( isset( $allowed_themes[ $theme_data->get('Name') ] ) ) |
|
| 1679 | - $converted[ $stylesheet ] = true; |
|
| 1777 | + if ( isset( $allowed_themes[ $theme_data->get('Name') ] ) ) { |
|
| 1778 | + $converted[ $stylesheet ] = true; |
|
| 1779 | + } |
|
| 1680 | 1780 | } |
| 1681 | 1781 | update_site_option( 'allowedthemes', $converted ); |
| 1682 | 1782 | delete_site_option( 'allowed_themes' ); |
@@ -1684,8 +1784,9 @@ discard block |
||
| 1684 | 1784 | } |
| 1685 | 1785 | |
| 1686 | 1786 | // 3.5 |
| 1687 | - if ( $wp_current_db_version < 21823 ) |
|
| 1688 | - update_site_option( 'ms_files_rewriting', '1' ); |
|
| 1787 | + if ( $wp_current_db_version < 21823 ) { |
|
| 1788 | + update_site_option( 'ms_files_rewriting', '1' ); |
|
| 1789 | + } |
|
| 1689 | 1790 | |
| 1690 | 1791 | // 3.5.2 |
| 1691 | 1792 | if ( $wp_current_db_version < 24448 ) { |
@@ -1916,8 +2017,9 @@ discard block |
||
| 1916 | 2017 | $all_options = new stdClass; |
| 1917 | 2018 | if ( $options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ) ) { |
| 1918 | 2019 | foreach ( $options as $option ) { |
| 1919 | - if ( 'siteurl' == $option->option_name || 'home' == $option->option_name || 'category_base' == $option->option_name ) |
|
| 1920 | - $option->option_value = untrailingslashit( $option->option_value ); |
|
| 2020 | + if ( 'siteurl' == $option->option_name || 'home' == $option->option_name || 'category_base' == $option->option_name ) { |
|
| 2021 | + $option->option_value = untrailingslashit( $option->option_value ); |
|
| 2022 | + } |
|
| 1921 | 2023 | $all_options->{$option->option_name} = stripslashes( $option->option_value ); |
| 1922 | 2024 | } |
| 1923 | 2025 | } |
@@ -1939,19 +2041,23 @@ discard block |
||
| 1939 | 2041 | function __get_option($setting) { |
| 1940 | 2042 | global $wpdb; |
| 1941 | 2043 | |
| 1942 | - if ( $setting == 'home' && defined( 'WP_HOME' ) ) |
|
| 1943 | - return untrailingslashit( WP_HOME ); |
|
| 2044 | + if ( $setting == 'home' && defined( 'WP_HOME' ) ) { |
|
| 2045 | + return untrailingslashit( WP_HOME ); |
|
| 2046 | + } |
|
| 1944 | 2047 | |
| 1945 | - if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) ) |
|
| 1946 | - return untrailingslashit( WP_SITEURL ); |
|
| 2048 | + if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) ) { |
|
| 2049 | + return untrailingslashit( WP_SITEURL ); |
|
| 2050 | + } |
|
| 1947 | 2051 | |
| 1948 | 2052 | $option = $wpdb->get_var( $wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s", $setting ) ); |
| 1949 | 2053 | |
| 1950 | - if ( 'home' == $setting && '' == $option ) |
|
| 1951 | - return __get_option( 'siteurl' ); |
|
| 2054 | + if ( 'home' == $setting && '' == $option ) { |
|
| 2055 | + return __get_option( 'siteurl' ); |
|
| 2056 | + } |
|
| 1952 | 2057 | |
| 1953 | - if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting || 'tag_base' == $setting ) |
|
| 1954 | - $option = untrailingslashit( $option ); |
|
| 2058 | + if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting || 'tag_base' == $setting ) { |
|
| 2059 | + $option = untrailingslashit( $option ); |
|
| 2060 | + } |
|
| 1955 | 2061 | |
| 1956 | 2062 | return maybe_unserialize( $option ); |
| 1957 | 2063 | } |
@@ -2004,8 +2110,9 @@ discard block |
||
| 2004 | 2110 | function dbDelta( $queries = '', $execute = true ) { |
| 2005 | 2111 | global $wpdb; |
| 2006 | 2112 | |
| 2007 | - if ( in_array( $queries, array( '', 'all', 'blog', 'global', 'ms_global' ), true ) ) |
|
| 2008 | - $queries = wp_get_db_schema( $queries ); |
|
| 2113 | + if ( in_array( $queries, array( '', 'all', 'blog', 'global', 'ms_global' ), true ) ) { |
|
| 2114 | + $queries = wp_get_db_schema( $queries ); |
|
| 2115 | + } |
|
| 2009 | 2116 | |
| 2010 | 2117 | // Separate individual queries into an array |
| 2011 | 2118 | if ( !is_array($queries) ) { |
@@ -2077,8 +2184,9 @@ discard block |
||
| 2077 | 2184 | $tablefields = $wpdb->get_results("DESCRIBE {$table};"); |
| 2078 | 2185 | $wpdb->suppress_errors( $suppress ); |
| 2079 | 2186 | |
| 2080 | - if ( ! $tablefields ) |
|
| 2081 | - continue; |
|
| 2187 | + if ( ! $tablefields ) { |
|
| 2188 | + continue; |
|
| 2189 | + } |
|
| 2082 | 2190 | |
| 2083 | 2191 | // Clear the field and index arrays. |
| 2084 | 2192 | $cfields = $indices = array(); |
@@ -2198,7 +2306,9 @@ discard block |
||
| 2198 | 2306 | |
| 2199 | 2307 | // For each column in the index. |
| 2200 | 2308 | foreach ($index_data['columns'] as $column_data) { |
| 2201 | - if ($index_columns != '') $index_columns .= ','; |
|
| 2309 | + if ($index_columns != '') { |
|
| 2310 | + $index_columns .= ','; |
|
| 2311 | + } |
|
| 2202 | 2312 | |
| 2203 | 2313 | // Add the field to the column list string. |
| 2204 | 2314 | $index_columns .= $column_data['fieldname']; |
@@ -2267,7 +2377,9 @@ discard block |
||
| 2267 | 2377 | function make_db_current( $tables = 'all' ) { |
| 2268 | 2378 | $alterations = dbDelta( $tables ); |
| 2269 | 2379 | echo "<ol>\n"; |
| 2270 | - foreach($alterations as $alteration) echo "<li>$alteration</li>\n"; |
|
| 2380 | + foreach($alterations as $alteration) { |
|
| 2381 | + echo "<li>$alteration</li>\n"; |
|
| 2382 | + } |
|
| 2271 | 2383 | echo "</ol>\n"; |
| 2272 | 2384 | } |
| 2273 | 2385 | |
@@ -2302,8 +2414,9 @@ discard block |
||
| 2302 | 2414 | $home_path = get_home_path(); |
| 2303 | 2415 | $site_dir = WP_CONTENT_DIR . "/themes/$template"; |
| 2304 | 2416 | |
| 2305 | - if (! file_exists("$home_path/index.php")) |
|
| 2306 | - return false; |
|
| 2417 | + if (! file_exists("$home_path/index.php")) { |
|
| 2418 | + return false; |
|
| 2419 | + } |
|
| 2307 | 2420 | |
| 2308 | 2421 | /* |
| 2309 | 2422 | * Copy files from the old locations to the site theme. |
@@ -2312,25 +2425,28 @@ discard block |
||
| 2312 | 2425 | $files = array('index.php' => 'index.php', 'wp-layout.css' => 'style.css', 'wp-comments.php' => 'comments.php', 'wp-comments-popup.php' => 'comments-popup.php'); |
| 2313 | 2426 | |
| 2314 | 2427 | foreach ($files as $oldfile => $newfile) { |
| 2315 | - if ($oldfile == 'index.php') |
|
| 2316 | - $oldpath = $home_path; |
|
| 2317 | - else |
|
| 2318 | - $oldpath = ABSPATH; |
|
| 2428 | + if ($oldfile == 'index.php') { |
|
| 2429 | + $oldpath = $home_path; |
|
| 2430 | + } else { |
|
| 2431 | + $oldpath = ABSPATH; |
|
| 2432 | + } |
|
| 2319 | 2433 | |
| 2320 | 2434 | // Check to make sure it's not a new index. |
| 2321 | 2435 | if ($oldfile == 'index.php') { |
| 2322 | 2436 | $index = implode('', file("$oldpath/$oldfile")); |
| 2323 | 2437 | if (strpos($index, 'WP_USE_THEMES') !== false) { |
| 2324 | - if (! @copy(WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME . '/index.php', "$site_dir/$newfile")) |
|
| 2325 | - return false; |
|
| 2438 | + if (! @copy(WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME . '/index.php', "$site_dir/$newfile")) { |
|
| 2439 | + return false; |
|
| 2440 | + } |
|
| 2326 | 2441 | |
| 2327 | 2442 | // Don't copy anything. |
| 2328 | 2443 | continue; |
| 2329 | 2444 | } |
| 2330 | 2445 | } |
| 2331 | 2446 | |
| 2332 | - if (! @copy("$oldpath/$oldfile", "$site_dir/$newfile")) |
|
| 2333 | - return false; |
|
| 2447 | + if (! @copy("$oldpath/$oldfile", "$site_dir/$newfile")) { |
|
| 2448 | + return false; |
|
| 2449 | + } |
|
| 2334 | 2450 | |
| 2335 | 2451 | chmod("$site_dir/$newfile", 0777); |
| 2336 | 2452 | |
@@ -2340,8 +2456,9 @@ discard block |
||
| 2340 | 2456 | $f = fopen("$site_dir/$newfile", 'w'); |
| 2341 | 2457 | |
| 2342 | 2458 | foreach ($lines as $line) { |
| 2343 | - if (preg_match('/require.*wp-blog-header/', $line)) |
|
| 2344 | - $line = '//' . $line; |
|
| 2459 | + if (preg_match('/require.*wp-blog-header/', $line)) { |
|
| 2460 | + $line = '//' . $line; |
|
| 2461 | + } |
|
| 2345 | 2462 | |
| 2346 | 2463 | // Update stylesheet references. |
| 2347 | 2464 | $line = str_replace("<?php echo __get_option('siteurl'); ?>/wp-layout.css", "<?php bloginfo('stylesheet_url'); ?>", $line); |
@@ -2391,10 +2508,12 @@ discard block |
||
| 2391 | 2508 | $theme_dir = @ opendir($default_dir); |
| 2392 | 2509 | if ($theme_dir) { |
| 2393 | 2510 | while(($theme_file = readdir( $theme_dir )) !== false) { |
| 2394 | - if (is_dir("$default_dir/$theme_file")) |
|
| 2395 | - continue; |
|
| 2396 | - if (! @copy("$default_dir/$theme_file", "$site_dir/$theme_file")) |
|
| 2397 | - return; |
|
| 2511 | + if (is_dir("$default_dir/$theme_file")) { |
|
| 2512 | + continue; |
|
| 2513 | + } |
|
| 2514 | + if (! @copy("$default_dir/$theme_file", "$site_dir/$theme_file")) { |
|
| 2515 | + return; |
|
| 2516 | + } |
|
| 2398 | 2517 | chmod("$site_dir/$theme_file", 0777); |
| 2399 | 2518 | } |
| 2400 | 2519 | } |
@@ -2406,11 +2525,17 @@ discard block |
||
| 2406 | 2525 | $f = fopen("$site_dir/style.css", 'w'); |
| 2407 | 2526 | |
| 2408 | 2527 | foreach ($stylelines as $line) { |
| 2409 | - if (strpos($line, 'Theme Name:') !== false) $line = 'Theme Name: ' . $theme_name; |
|
| 2410 | - elseif (strpos($line, 'Theme URI:') !== false) $line = 'Theme URI: ' . __get_option('url'); |
|
| 2411 | - elseif (strpos($line, 'Description:') !== false) $line = 'Description: Your theme.'; |
|
| 2412 | - elseif (strpos($line, 'Version:') !== false) $line = 'Version: 1'; |
|
| 2413 | - elseif (strpos($line, 'Author:') !== false) $line = 'Author: You'; |
|
| 2528 | + if (strpos($line, 'Theme Name:') !== false) { |
|
| 2529 | + $line = 'Theme Name: ' . $theme_name; |
|
| 2530 | + } elseif (strpos($line, 'Theme URI:') !== false) { |
|
| 2531 | + $line = 'Theme URI: ' . __get_option('url'); |
|
| 2532 | + } elseif (strpos($line, 'Description:') !== false) { |
|
| 2533 | + $line = 'Description: Your theme.'; |
|
| 2534 | + } elseif (strpos($line, 'Version:') !== false) { |
|
| 2535 | + $line = 'Version: 1'; |
|
| 2536 | + } elseif (strpos($line, 'Author:') !== false) { |
|
| 2537 | + $line = 'Author: You'; |
|
| 2538 | + } |
|
| 2414 | 2539 | fwrite($f, $line . "\n"); |
| 2415 | 2540 | } |
| 2416 | 2541 | fclose($f); |
@@ -2425,10 +2550,12 @@ discard block |
||
| 2425 | 2550 | $images_dir = @ opendir("$default_dir/images"); |
| 2426 | 2551 | if ($images_dir) { |
| 2427 | 2552 | while(($image = readdir($images_dir)) !== false) { |
| 2428 | - if (is_dir("$default_dir/images/$image")) |
|
| 2429 | - continue; |
|
| 2430 | - if (! @copy("$default_dir/images/$image", "$site_dir/images/$image")) |
|
| 2431 | - return; |
|
| 2553 | + if (is_dir("$default_dir/images/$image")) { |
|
| 2554 | + continue; |
|
| 2555 | + } |
|
| 2556 | + if (! @copy("$default_dir/images/$image", "$site_dir/images/$image")) { |
|
| 2557 | + return; |
|
| 2558 | + } |
|
| 2432 | 2559 | chmod("$site_dir/images/$image", 0777); |
| 2433 | 2560 | } |
| 2434 | 2561 | } |
@@ -2471,9 +2598,10 @@ discard block |
||
| 2471 | 2598 | return false; |
| 2472 | 2599 | } |
| 2473 | 2600 | } else { |
| 2474 | - if (! make_site_theme_from_default($theme_name, $template)) |
|
| 2475 | - // TODO: rm -rf the site theme directory. |
|
| 2601 | + if (! make_site_theme_from_default($theme_name, $template)) { |
|
| 2602 | + // TODO: rm -rf the site theme directory. |
|
| 2476 | 2603 | return false; |
| 2604 | + } |
|
| 2477 | 2605 | } |
| 2478 | 2606 | |
| 2479 | 2607 | // Make the new site theme active. |
@@ -2524,9 +2652,10 @@ discard block |
||
| 2524 | 2652 | function wp_check_mysql_version() { |
| 2525 | 2653 | global $wpdb; |
| 2526 | 2654 | $result = $wpdb->check_database_version(); |
| 2527 | - if ( is_wp_error( $result ) ) |
|
| 2528 | - die( $result->get_error_message() ); |
|
| 2529 | -} |
|
| 2655 | + if ( is_wp_error( $result ) ) { |
|
| 2656 | + die( $result->get_error_message() ); |
|
| 2657 | + } |
|
| 2658 | + } |
|
| 2530 | 2659 | |
| 2531 | 2660 | /** |
| 2532 | 2661 | * Disables the Automattic widgets plugin, which was merged into core. |
@@ -2556,9 +2685,10 @@ discard block |
||
| 2556 | 2685 | function maybe_disable_link_manager() { |
| 2557 | 2686 | global $wp_current_db_version, $wpdb; |
| 2558 | 2687 | |
| 2559 | - if ( $wp_current_db_version >= 22006 && get_option( 'link_manager_enabled' ) && ! $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) ) |
|
| 2560 | - update_option( 'link_manager_enabled', 0 ); |
|
| 2561 | -} |
|
| 2688 | + if ( $wp_current_db_version >= 22006 && get_option( 'link_manager_enabled' ) && ! $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) ) { |
|
| 2689 | + update_option( 'link_manager_enabled', 0 ); |
|
| 2690 | + } |
|
| 2691 | + } |
|
| 2562 | 2692 | |
| 2563 | 2693 | /** |
| 2564 | 2694 | * Runs before the schema is upgraded. |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | * @since Twenty Eleven 1.0 |
| 388 | 388 | * |
| 389 | 389 | * @param string $more The Read More text. |
| 390 | - * @return The filtered Read More text. |
|
| 390 | + * @return string filtered Read More text. |
|
| 391 | 391 | */ |
| 392 | 392 | function twentyeleven_auto_excerpt_more( $more ) { |
| 393 | 393 | if ( ! is_admin() ) { |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | * |
| 541 | 541 | * @since Twenty Eleven 1.0 |
| 542 | 542 | * |
| 543 | - * @return string|bool URL or false when no link is present. |
|
| 543 | + * @return false|string URL or false when no link is present. |
|
| 544 | 544 | */ |
| 545 | 545 | function twentyeleven_url_grabber() { |
| 546 | 546 | if ( ! preg_match( '/<a\s[^>]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches ) ) |
@@ -39,15 +39,15 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | |
| 41 | 41 | // Set the content width based on the theme's design and stylesheet. |
| 42 | -if ( ! isset( $content_width ) ) |
|
| 42 | +if ( ! isset($content_width)) |
|
| 43 | 43 | $content_width = 584; |
| 44 | 44 | |
| 45 | 45 | /* |
| 46 | 46 | * Tell WordPress to run twentyeleven_setup() when the 'after_setup_theme' hook is run. |
| 47 | 47 | */ |
| 48 | -add_action( 'after_setup_theme', 'twentyeleven_setup' ); |
|
| 48 | +add_action('after_setup_theme', 'twentyeleven_setup'); |
|
| 49 | 49 | |
| 50 | -if ( ! function_exists( 'twentyeleven_setup' ) ): |
|
| 50 | +if ( ! function_exists('twentyeleven_setup')): |
|
| 51 | 51 | /** |
| 52 | 52 | * Set up theme defaults and registers support for various WordPress features. |
| 53 | 53 | * |
@@ -77,43 +77,43 @@ discard block |
||
| 77 | 77 | * a find and replace to change 'twentyeleven' to the name |
| 78 | 78 | * of your theme in all the template files. |
| 79 | 79 | */ |
| 80 | - load_theme_textdomain( 'twentyeleven', get_template_directory() . '/languages' ); |
|
| 80 | + load_theme_textdomain('twentyeleven', get_template_directory().'/languages'); |
|
| 81 | 81 | |
| 82 | 82 | // This theme styles the visual editor with editor-style.css to match the theme style. |
| 83 | 83 | add_editor_style(); |
| 84 | 84 | |
| 85 | 85 | // Load up our theme options page and related code. |
| 86 | - require( get_template_directory() . '/inc/theme-options.php' ); |
|
| 86 | + require(get_template_directory().'/inc/theme-options.php'); |
|
| 87 | 87 | |
| 88 | 88 | // Grab Twenty Eleven's Ephemera widget. |
| 89 | - require( get_template_directory() . '/inc/widgets.php' ); |
|
| 89 | + require(get_template_directory().'/inc/widgets.php'); |
|
| 90 | 90 | |
| 91 | 91 | // Add default posts and comments RSS feed links to <head>. |
| 92 | - add_theme_support( 'automatic-feed-links' ); |
|
| 92 | + add_theme_support('automatic-feed-links'); |
|
| 93 | 93 | |
| 94 | 94 | // This theme uses wp_nav_menu() in one location. |
| 95 | - register_nav_menu( 'primary', __( 'Primary Menu', 'twentyeleven' ) ); |
|
| 95 | + register_nav_menu('primary', __('Primary Menu', 'twentyeleven')); |
|
| 96 | 96 | |
| 97 | 97 | // Add support for a variety of post formats |
| 98 | - add_theme_support( 'post-formats', array( 'aside', 'link', 'gallery', 'status', 'quote', 'image' ) ); |
|
| 98 | + add_theme_support('post-formats', array('aside', 'link', 'gallery', 'status', 'quote', 'image')); |
|
| 99 | 99 | |
| 100 | 100 | $theme_options = twentyeleven_get_theme_options(); |
| 101 | - if ( 'dark' == $theme_options['color_scheme'] ) |
|
| 101 | + if ('dark' == $theme_options['color_scheme']) |
|
| 102 | 102 | $default_background_color = '1d1d1d'; |
| 103 | 103 | else |
| 104 | 104 | $default_background_color = 'e2e2e2'; |
| 105 | 105 | |
| 106 | 106 | // Add support for custom backgrounds. |
| 107 | - add_theme_support( 'custom-background', array( |
|
| 107 | + add_theme_support('custom-background', array( |
|
| 108 | 108 | /* |
| 109 | 109 | * Let WordPress know what our default background color is. |
| 110 | 110 | * This is dependent on our current color scheme. |
| 111 | 111 | */ |
| 112 | 112 | 'default-color' => $default_background_color, |
| 113 | - ) ); |
|
| 113 | + )); |
|
| 114 | 114 | |
| 115 | 115 | // This theme uses Featured Images (also known as post thumbnails) for per-post/per-page Custom Header images |
| 116 | - add_theme_support( 'post-thumbnails' ); |
|
| 116 | + add_theme_support('post-thumbnails'); |
|
| 117 | 117 | |
| 118 | 118 | // Add support for custom headers. |
| 119 | 119 | $custom_header_support = array( |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * |
| 128 | 128 | * @param int The default header image width in pixels. Default 1000. |
| 129 | 129 | */ |
| 130 | - 'width' => apply_filters( 'twentyeleven_header_image_width', 1000 ), |
|
| 130 | + 'width' => apply_filters('twentyeleven_header_image_width', 1000), |
|
| 131 | 131 | /** |
| 132 | 132 | * Filter the Twenty Eleven default header image height. |
| 133 | 133 | * |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | * |
| 136 | 136 | * @param int The default header image height in pixels. Default 288. |
| 137 | 137 | */ |
| 138 | - 'height' => apply_filters( 'twentyeleven_header_image_height', 288 ), |
|
| 138 | + 'height' => apply_filters('twentyeleven_header_image_height', 288), |
|
| 139 | 139 | // Support flexible heights. |
| 140 | 140 | 'flex-height' => true, |
| 141 | 141 | // Random image rotation by default. |
@@ -148,15 +148,15 @@ discard block |
||
| 148 | 148 | 'admin-preview-callback' => 'twentyeleven_admin_header_image', |
| 149 | 149 | ); |
| 150 | 150 | |
| 151 | - add_theme_support( 'custom-header', $custom_header_support ); |
|
| 151 | + add_theme_support('custom-header', $custom_header_support); |
|
| 152 | 152 | |
| 153 | - if ( ! function_exists( 'get_custom_header' ) ) { |
|
| 153 | + if ( ! function_exists('get_custom_header')) { |
|
| 154 | 154 | // This is all for compatibility with versions of WordPress prior to 3.4. |
| 155 | - define( 'HEADER_TEXTCOLOR', $custom_header_support['default-text-color'] ); |
|
| 156 | - define( 'HEADER_IMAGE', '' ); |
|
| 157 | - define( 'HEADER_IMAGE_WIDTH', $custom_header_support['width'] ); |
|
| 158 | - define( 'HEADER_IMAGE_HEIGHT', $custom_header_support['height'] ); |
|
| 159 | - add_custom_image_header( $custom_header_support['wp-head-callback'], $custom_header_support['admin-head-callback'], $custom_header_support['admin-preview-callback'] ); |
|
| 155 | + define('HEADER_TEXTCOLOR', $custom_header_support['default-text-color']); |
|
| 156 | + define('HEADER_IMAGE', ''); |
|
| 157 | + define('HEADER_IMAGE_WIDTH', $custom_header_support['width']); |
|
| 158 | + define('HEADER_IMAGE_HEIGHT', $custom_header_support['height']); |
|
| 159 | + add_custom_image_header($custom_header_support['wp-head-callback'], $custom_header_support['admin-head-callback'], $custom_header_support['admin-preview-callback']); |
|
| 160 | 160 | add_custom_background(); |
| 161 | 161 | } |
| 162 | 162 | |
@@ -165,71 +165,71 @@ discard block |
||
| 165 | 165 | * We want them to be the size of the header image that we just defined. |
| 166 | 166 | * Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php. |
| 167 | 167 | */ |
| 168 | - set_post_thumbnail_size( $custom_header_support['width'], $custom_header_support['height'], true ); |
|
| 168 | + set_post_thumbnail_size($custom_header_support['width'], $custom_header_support['height'], true); |
|
| 169 | 169 | |
| 170 | 170 | /* |
| 171 | 171 | * Add Twenty Eleven's custom image sizes. |
| 172 | 172 | * Used for large feature (header) images. |
| 173 | 173 | */ |
| 174 | - add_image_size( 'large-feature', $custom_header_support['width'], $custom_header_support['height'], true ); |
|
| 174 | + add_image_size('large-feature', $custom_header_support['width'], $custom_header_support['height'], true); |
|
| 175 | 175 | // Used for featured posts if a large-feature doesn't exist. |
| 176 | - add_image_size( 'small-feature', 500, 300 ); |
|
| 176 | + add_image_size('small-feature', 500, 300); |
|
| 177 | 177 | |
| 178 | 178 | // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI. |
| 179 | - register_default_headers( array( |
|
| 179 | + register_default_headers(array( |
|
| 180 | 180 | 'wheel' => array( |
| 181 | 181 | 'url' => '%s/images/headers/wheel.jpg', |
| 182 | 182 | 'thumbnail_url' => '%s/images/headers/wheel-thumbnail.jpg', |
| 183 | 183 | /* translators: header image description */ |
| 184 | - 'description' => __( 'Wheel', 'twentyeleven' ) |
|
| 184 | + 'description' => __('Wheel', 'twentyeleven') |
|
| 185 | 185 | ), |
| 186 | 186 | 'shore' => array( |
| 187 | 187 | 'url' => '%s/images/headers/shore.jpg', |
| 188 | 188 | 'thumbnail_url' => '%s/images/headers/shore-thumbnail.jpg', |
| 189 | 189 | /* translators: header image description */ |
| 190 | - 'description' => __( 'Shore', 'twentyeleven' ) |
|
| 190 | + 'description' => __('Shore', 'twentyeleven') |
|
| 191 | 191 | ), |
| 192 | 192 | 'trolley' => array( |
| 193 | 193 | 'url' => '%s/images/headers/trolley.jpg', |
| 194 | 194 | 'thumbnail_url' => '%s/images/headers/trolley-thumbnail.jpg', |
| 195 | 195 | /* translators: header image description */ |
| 196 | - 'description' => __( 'Trolley', 'twentyeleven' ) |
|
| 196 | + 'description' => __('Trolley', 'twentyeleven') |
|
| 197 | 197 | ), |
| 198 | 198 | 'pine-cone' => array( |
| 199 | 199 | 'url' => '%s/images/headers/pine-cone.jpg', |
| 200 | 200 | 'thumbnail_url' => '%s/images/headers/pine-cone-thumbnail.jpg', |
| 201 | 201 | /* translators: header image description */ |
| 202 | - 'description' => __( 'Pine Cone', 'twentyeleven' ) |
|
| 202 | + 'description' => __('Pine Cone', 'twentyeleven') |
|
| 203 | 203 | ), |
| 204 | 204 | 'chessboard' => array( |
| 205 | 205 | 'url' => '%s/images/headers/chessboard.jpg', |
| 206 | 206 | 'thumbnail_url' => '%s/images/headers/chessboard-thumbnail.jpg', |
| 207 | 207 | /* translators: header image description */ |
| 208 | - 'description' => __( 'Chessboard', 'twentyeleven' ) |
|
| 208 | + 'description' => __('Chessboard', 'twentyeleven') |
|
| 209 | 209 | ), |
| 210 | 210 | 'lanterns' => array( |
| 211 | 211 | 'url' => '%s/images/headers/lanterns.jpg', |
| 212 | 212 | 'thumbnail_url' => '%s/images/headers/lanterns-thumbnail.jpg', |
| 213 | 213 | /* translators: header image description */ |
| 214 | - 'description' => __( 'Lanterns', 'twentyeleven' ) |
|
| 214 | + 'description' => __('Lanterns', 'twentyeleven') |
|
| 215 | 215 | ), |
| 216 | 216 | 'willow' => array( |
| 217 | 217 | 'url' => '%s/images/headers/willow.jpg', |
| 218 | 218 | 'thumbnail_url' => '%s/images/headers/willow-thumbnail.jpg', |
| 219 | 219 | /* translators: header image description */ |
| 220 | - 'description' => __( 'Willow', 'twentyeleven' ) |
|
| 220 | + 'description' => __('Willow', 'twentyeleven') |
|
| 221 | 221 | ), |
| 222 | 222 | 'hanoi' => array( |
| 223 | 223 | 'url' => '%s/images/headers/hanoi.jpg', |
| 224 | 224 | 'thumbnail_url' => '%s/images/headers/hanoi-thumbnail.jpg', |
| 225 | 225 | /* translators: header image description */ |
| 226 | - 'description' => __( 'Hanoi Plant', 'twentyeleven' ) |
|
| 226 | + 'description' => __('Hanoi Plant', 'twentyeleven') |
|
| 227 | 227 | ) |
| 228 | - ) ); |
|
| 228 | + )); |
|
| 229 | 229 | } |
| 230 | 230 | endif; // twentyeleven_setup |
| 231 | 231 | |
| 232 | -if ( ! function_exists( 'twentyeleven_header_style' ) ) : |
|
| 232 | +if ( ! function_exists('twentyeleven_header_style')) : |
|
| 233 | 233 | /** |
| 234 | 234 | * Styles the header image and text displayed on the blog. |
| 235 | 235 | * |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | $text_color = get_header_textcolor(); |
| 240 | 240 | |
| 241 | 241 | // If no custom options for text are set, let's bail. |
| 242 | - if ( $text_color == HEADER_TEXTCOLOR ) |
|
| 242 | + if ($text_color == HEADER_TEXTCOLOR) |
|
| 243 | 243 | return; |
| 244 | 244 | |
| 245 | 245 | // If we get this far, we have custom styles. Let's do this. |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | <style type="text/css" id="twentyeleven-header-css"> |
| 248 | 248 | <?php |
| 249 | 249 | // Has the text been hidden? |
| 250 | - if ( 'blank' == $text_color ) : |
|
| 250 | + if ('blank' == $text_color) : |
|
| 251 | 251 | ?> |
| 252 | 252 | #site-title, |
| 253 | 253 | #site-description { |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | } |
| 270 | 270 | endif; // twentyeleven_header_style |
| 271 | 271 | |
| 272 | -if ( ! function_exists( 'twentyeleven_admin_header_style' ) ) : |
|
| 272 | +if ( ! function_exists('twentyeleven_admin_header_style')) : |
|
| 273 | 273 | /** |
| 274 | 274 | * Styles the header image displayed on the Appearance > Header admin panel. |
| 275 | 275 | * |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | } |
| 303 | 303 | <?php |
| 304 | 304 | // If the user has set a custom color for the text use that |
| 305 | - if ( get_header_textcolor() != HEADER_TEXTCOLOR ) : |
|
| 305 | + if (get_header_textcolor() != HEADER_TEXTCOLOR) : |
|
| 306 | 306 | ?> |
| 307 | 307 | #site-title a, |
| 308 | 308 | #site-description { |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | } |
| 320 | 320 | endif; // twentyeleven_admin_header_style |
| 321 | 321 | |
| 322 | -if ( ! function_exists( 'twentyeleven_admin_header_image' ) ) : |
|
| 322 | +if ( ! function_exists('twentyeleven_admin_header_image')) : |
|
| 323 | 323 | /** |
| 324 | 324 | * Custom header image markup displayed on the Appearance > Header admin panel. |
| 325 | 325 | * |
@@ -333,14 +333,14 @@ discard block |
||
| 333 | 333 | $color = get_header_textcolor(); |
| 334 | 334 | $image = get_header_image(); |
| 335 | 335 | $style = 'display: none;'; |
| 336 | - if ( $color && $color != 'blank' ) { |
|
| 337 | - $style = 'color: #' . $color . ';'; |
|
| 336 | + if ($color && $color != 'blank') { |
|
| 337 | + $style = 'color: #'.$color.';'; |
|
| 338 | 338 | } |
| 339 | 339 | ?> |
| 340 | - <h1 class="displaying-header-text"><a id="name" style="<?php echo esc_attr( $style ); ?>" onclick="return false;" href="<?php echo esc_url( home_url( '/' ) ); ?>" tabindex="-1"><?php bloginfo( 'name' ); ?></a></h1> |
|
| 341 | - <div id="desc" class="displaying-header-text" style="<?php echo esc_attr( $style ); ?>"><?php bloginfo( 'description' ); ?></div> |
|
| 342 | - <?php if ( $image ) : ?> |
|
| 343 | - <img src="<?php echo esc_url( $image ); ?>" alt="" /> |
|
| 340 | + <h1 class="displaying-header-text"><a id="name" style="<?php echo esc_attr($style); ?>" onclick="return false;" href="<?php echo esc_url(home_url('/')); ?>" tabindex="-1"><?php bloginfo('name'); ?></a></h1> |
|
| 341 | + <div id="desc" class="displaying-header-text" style="<?php echo esc_attr($style); ?>"><?php bloginfo('description'); ?></div> |
|
| 342 | + <?php if ($image) : ?> |
|
| 343 | + <img src="<?php echo esc_url($image); ?>" alt="" /> |
|
| 344 | 344 | <?php endif; ?> |
| 345 | 345 | </div> |
| 346 | 346 | <?php } |
@@ -358,12 +358,12 @@ discard block |
||
| 358 | 358 | * @param int $length The number of excerpt characters. |
| 359 | 359 | * @return int The filtered number of characters. |
| 360 | 360 | */ |
| 361 | -function twentyeleven_excerpt_length( $length ) { |
|
| 361 | +function twentyeleven_excerpt_length($length) { |
|
| 362 | 362 | return 40; |
| 363 | 363 | } |
| 364 | -add_filter( 'excerpt_length', 'twentyeleven_excerpt_length' ); |
|
| 364 | +add_filter('excerpt_length', 'twentyeleven_excerpt_length'); |
|
| 365 | 365 | |
| 366 | -if ( ! function_exists( 'twentyeleven_continue_reading_link' ) ) : |
|
| 366 | +if ( ! function_exists('twentyeleven_continue_reading_link')) : |
|
| 367 | 367 | /** |
| 368 | 368 | * Return a "Continue Reading" link for excerpts |
| 369 | 369 | * |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | * @return string The "Continue Reading" HTML link. |
| 373 | 373 | */ |
| 374 | 374 | function twentyeleven_continue_reading_link() { |
| 375 | - return ' <a href="'. esc_url( get_permalink() ) . '">' . __( 'Continue reading <span class="meta-nav">→</span>', 'twentyeleven' ) . '</a>'; |
|
| 375 | + return ' <a href="'.esc_url(get_permalink()).'">'.__('Continue reading <span class="meta-nav">→</span>', 'twentyeleven').'</a>'; |
|
| 376 | 376 | } |
| 377 | 377 | endif; // twentyeleven_continue_reading_link |
| 378 | 378 | |
@@ -389,13 +389,13 @@ discard block |
||
| 389 | 389 | * @param string $more The Read More text. |
| 390 | 390 | * @return The filtered Read More text. |
| 391 | 391 | */ |
| 392 | -function twentyeleven_auto_excerpt_more( $more ) { |
|
| 393 | - if ( ! is_admin() ) { |
|
| 394 | - return ' …' . twentyeleven_continue_reading_link(); |
|
| 392 | +function twentyeleven_auto_excerpt_more($more) { |
|
| 393 | + if ( ! is_admin()) { |
|
| 394 | + return ' …'.twentyeleven_continue_reading_link(); |
|
| 395 | 395 | } |
| 396 | 396 | return $more; |
| 397 | 397 | } |
| 398 | -add_filter( 'excerpt_more', 'twentyeleven_auto_excerpt_more' ); |
|
| 398 | +add_filter('excerpt_more', 'twentyeleven_auto_excerpt_more'); |
|
| 399 | 399 | |
| 400 | 400 | /** |
| 401 | 401 | * Add a pretty "Continue Reading" link to custom post excerpts. |
@@ -408,13 +408,13 @@ discard block |
||
| 408 | 408 | * @param string $output The "Continue Reading" link. |
| 409 | 409 | * @return string The filtered "Continue Reading" link. |
| 410 | 410 | */ |
| 411 | -function twentyeleven_custom_excerpt_more( $output ) { |
|
| 412 | - if ( has_excerpt() && ! is_attachment() && ! is_admin() ) { |
|
| 411 | +function twentyeleven_custom_excerpt_more($output) { |
|
| 412 | + if (has_excerpt() && ! is_attachment() && ! is_admin()) { |
|
| 413 | 413 | $output .= twentyeleven_continue_reading_link(); |
| 414 | 414 | } |
| 415 | 415 | return $output; |
| 416 | 416 | } |
| 417 | -add_filter( 'get_the_excerpt', 'twentyeleven_custom_excerpt_more' ); |
|
| 417 | +add_filter('get_the_excerpt', 'twentyeleven_custom_excerpt_more'); |
|
| 418 | 418 | |
| 419 | 419 | /** |
| 420 | 420 | * Show a home link for the wp_nav_menu() fallback, wp_page_menu(). |
@@ -424,12 +424,12 @@ discard block |
||
| 424 | 424 | * @param array $args The page menu arguments. @see wp_page_menu() |
| 425 | 425 | * @return array The filtered page menu arguments. |
| 426 | 426 | */ |
| 427 | -function twentyeleven_page_menu_args( $args ) { |
|
| 428 | - if ( ! isset( $args['show_home'] ) ) |
|
| 427 | +function twentyeleven_page_menu_args($args) { |
|
| 428 | + if ( ! isset($args['show_home'])) |
|
| 429 | 429 | $args['show_home'] = true; |
| 430 | 430 | return $args; |
| 431 | 431 | } |
| 432 | -add_filter( 'wp_page_menu_args', 'twentyeleven_page_menu_args' ); |
|
| 432 | +add_filter('wp_page_menu_args', 'twentyeleven_page_menu_args'); |
|
| 433 | 433 | |
| 434 | 434 | /** |
| 435 | 435 | * Register sidebars and widgetized areas. |
@@ -440,60 +440,60 @@ discard block |
||
| 440 | 440 | */ |
| 441 | 441 | function twentyeleven_widgets_init() { |
| 442 | 442 | |
| 443 | - register_widget( 'Twenty_Eleven_Ephemera_Widget' ); |
|
| 443 | + register_widget('Twenty_Eleven_Ephemera_Widget'); |
|
| 444 | 444 | |
| 445 | - register_sidebar( array( |
|
| 446 | - 'name' => __( 'Main Sidebar', 'twentyeleven' ), |
|
| 445 | + register_sidebar(array( |
|
| 446 | + 'name' => __('Main Sidebar', 'twentyeleven'), |
|
| 447 | 447 | 'id' => 'sidebar-1', |
| 448 | 448 | 'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
| 449 | 449 | 'after_widget' => '</aside>', |
| 450 | 450 | 'before_title' => '<h3 class="widget-title">', |
| 451 | 451 | 'after_title' => '</h3>', |
| 452 | - ) ); |
|
| 452 | + )); |
|
| 453 | 453 | |
| 454 | - register_sidebar( array( |
|
| 455 | - 'name' => __( 'Showcase Sidebar', 'twentyeleven' ), |
|
| 454 | + register_sidebar(array( |
|
| 455 | + 'name' => __('Showcase Sidebar', 'twentyeleven'), |
|
| 456 | 456 | 'id' => 'sidebar-2', |
| 457 | - 'description' => __( 'The sidebar for the optional Showcase Template', 'twentyeleven' ), |
|
| 457 | + 'description' => __('The sidebar for the optional Showcase Template', 'twentyeleven'), |
|
| 458 | 458 | 'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
| 459 | 459 | 'after_widget' => '</aside>', |
| 460 | 460 | 'before_title' => '<h3 class="widget-title">', |
| 461 | 461 | 'after_title' => '</h3>', |
| 462 | - ) ); |
|
| 462 | + )); |
|
| 463 | 463 | |
| 464 | - register_sidebar( array( |
|
| 465 | - 'name' => __( 'Footer Area One', 'twentyeleven' ), |
|
| 464 | + register_sidebar(array( |
|
| 465 | + 'name' => __('Footer Area One', 'twentyeleven'), |
|
| 466 | 466 | 'id' => 'sidebar-3', |
| 467 | - 'description' => __( 'An optional widget area for your site footer', 'twentyeleven' ), |
|
| 467 | + 'description' => __('An optional widget area for your site footer', 'twentyeleven'), |
|
| 468 | 468 | 'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
| 469 | 469 | 'after_widget' => '</aside>', |
| 470 | 470 | 'before_title' => '<h3 class="widget-title">', |
| 471 | 471 | 'after_title' => '</h3>', |
| 472 | - ) ); |
|
| 472 | + )); |
|
| 473 | 473 | |
| 474 | - register_sidebar( array( |
|
| 475 | - 'name' => __( 'Footer Area Two', 'twentyeleven' ), |
|
| 474 | + register_sidebar(array( |
|
| 475 | + 'name' => __('Footer Area Two', 'twentyeleven'), |
|
| 476 | 476 | 'id' => 'sidebar-4', |
| 477 | - 'description' => __( 'An optional widget area for your site footer', 'twentyeleven' ), |
|
| 477 | + 'description' => __('An optional widget area for your site footer', 'twentyeleven'), |
|
| 478 | 478 | 'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
| 479 | 479 | 'after_widget' => '</aside>', |
| 480 | 480 | 'before_title' => '<h3 class="widget-title">', |
| 481 | 481 | 'after_title' => '</h3>', |
| 482 | - ) ); |
|
| 482 | + )); |
|
| 483 | 483 | |
| 484 | - register_sidebar( array( |
|
| 485 | - 'name' => __( 'Footer Area Three', 'twentyeleven' ), |
|
| 484 | + register_sidebar(array( |
|
| 485 | + 'name' => __('Footer Area Three', 'twentyeleven'), |
|
| 486 | 486 | 'id' => 'sidebar-5', |
| 487 | - 'description' => __( 'An optional widget area for your site footer', 'twentyeleven' ), |
|
| 487 | + 'description' => __('An optional widget area for your site footer', 'twentyeleven'), |
|
| 488 | 488 | 'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
| 489 | 489 | 'after_widget' => '</aside>', |
| 490 | 490 | 'before_title' => '<h3 class="widget-title">', |
| 491 | 491 | 'after_title' => '</h3>', |
| 492 | - ) ); |
|
| 492 | + )); |
|
| 493 | 493 | } |
| 494 | -add_action( 'widgets_init', 'twentyeleven_widgets_init' ); |
|
| 494 | +add_action('widgets_init', 'twentyeleven_widgets_init'); |
|
| 495 | 495 | |
| 496 | -if ( ! function_exists( 'twentyeleven_content_nav' ) ) : |
|
| 496 | +if ( ! function_exists('twentyeleven_content_nav')) : |
|
| 497 | 497 | /** |
| 498 | 498 | * Display navigation to next/previous pages when applicable. |
| 499 | 499 | * |
@@ -501,14 +501,14 @@ discard block |
||
| 501 | 501 | * |
| 502 | 502 | * @param string $html_id The HTML id attribute. |
| 503 | 503 | */ |
| 504 | -function twentyeleven_content_nav( $html_id ) { |
|
| 504 | +function twentyeleven_content_nav($html_id) { |
|
| 505 | 505 | global $wp_query; |
| 506 | 506 | |
| 507 | - if ( $wp_query->max_num_pages > 1 ) : ?> |
|
| 508 | - <nav id="<?php echo esc_attr( $html_id ); ?>"> |
|
| 509 | - <h3 class="assistive-text"><?php _e( 'Post navigation', 'twentyeleven' ); ?></h3> |
|
| 510 | - <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentyeleven' ) ); ?></div> |
|
| 511 | - <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'twentyeleven' ) ); ?></div> |
|
| 507 | + if ($wp_query->max_num_pages > 1) : ?> |
|
| 508 | + <nav id="<?php echo esc_attr($html_id); ?>"> |
|
| 509 | + <h3 class="assistive-text"><?php _e('Post navigation', 'twentyeleven'); ?></h3> |
|
| 510 | + <div class="nav-previous"><?php next_posts_link(__('<span class="meta-nav">←</span> Older posts', 'twentyeleven')); ?></div> |
|
| 511 | + <div class="nav-next"><?php previous_posts_link(__('Newer posts <span class="meta-nav">→</span>', 'twentyeleven')); ?></div> |
|
| 512 | 512 | </nav><!-- #nav-above --> |
| 513 | 513 | <?php endif; |
| 514 | 514 | } |
@@ -526,13 +526,13 @@ discard block |
||
| 526 | 526 | */ |
| 527 | 527 | function twentyeleven_get_first_url() { |
| 528 | 528 | $content = get_the_content(); |
| 529 | - $has_url = function_exists( 'get_url_in_content' ) ? get_url_in_content( $content ) : false; |
|
| 529 | + $has_url = function_exists('get_url_in_content') ? get_url_in_content($content) : false; |
|
| 530 | 530 | |
| 531 | - if ( ! $has_url ) |
|
| 531 | + if ( ! $has_url) |
|
| 532 | 532 | $has_url = twentyeleven_url_grabber(); |
| 533 | 533 | |
| 534 | 534 | /** This filter is documented in wp-includes/link-template.php */ |
| 535 | - return ( $has_url ) ? $has_url : apply_filters( 'the_permalink', get_permalink() ); |
|
| 535 | + return ($has_url) ? $has_url : apply_filters('the_permalink', get_permalink()); |
|
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | /** |
@@ -543,10 +543,10 @@ discard block |
||
| 543 | 543 | * @return string|bool URL or false when no link is present. |
| 544 | 544 | */ |
| 545 | 545 | function twentyeleven_url_grabber() { |
| 546 | - if ( ! preg_match( '/<a\s[^>]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches ) ) |
|
| 546 | + if ( ! preg_match('/<a\s[^>]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches)) |
|
| 547 | 547 | return false; |
| 548 | 548 | |
| 549 | - return esc_url_raw( $matches[1] ); |
|
| 549 | + return esc_url_raw($matches[1]); |
|
| 550 | 550 | } |
| 551 | 551 | |
| 552 | 552 | /** |
@@ -557,18 +557,18 @@ discard block |
||
| 557 | 557 | function twentyeleven_footer_sidebar_class() { |
| 558 | 558 | $count = 0; |
| 559 | 559 | |
| 560 | - if ( is_active_sidebar( 'sidebar-3' ) ) |
|
| 560 | + if (is_active_sidebar('sidebar-3')) |
|
| 561 | 561 | $count++; |
| 562 | 562 | |
| 563 | - if ( is_active_sidebar( 'sidebar-4' ) ) |
|
| 563 | + if (is_active_sidebar('sidebar-4')) |
|
| 564 | 564 | $count++; |
| 565 | 565 | |
| 566 | - if ( is_active_sidebar( 'sidebar-5' ) ) |
|
| 566 | + if (is_active_sidebar('sidebar-5')) |
|
| 567 | 567 | $count++; |
| 568 | 568 | |
| 569 | 569 | $class = ''; |
| 570 | 570 | |
| 571 | - switch ( $count ) { |
|
| 571 | + switch ($count) { |
|
| 572 | 572 | case '1': |
| 573 | 573 | $class = 'one'; |
| 574 | 574 | break; |
@@ -580,11 +580,11 @@ discard block |
||
| 580 | 580 | break; |
| 581 | 581 | } |
| 582 | 582 | |
| 583 | - if ( $class ) |
|
| 584 | - echo 'class="' . esc_attr( $class ) . '"'; |
|
| 583 | + if ($class) |
|
| 584 | + echo 'class="'.esc_attr($class).'"'; |
|
| 585 | 585 | } |
| 586 | 586 | |
| 587 | -if ( ! function_exists( 'twentyeleven_comment' ) ) : |
|
| 587 | +if ( ! function_exists('twentyeleven_comment')) : |
|
| 588 | 588 | /** |
| 589 | 589 | * Template for comments and pingbacks. |
| 590 | 590 | * |
@@ -599,14 +599,14 @@ discard block |
||
| 599 | 599 | * @param array $args An array of comment arguments. @see get_comment_reply_link() |
| 600 | 600 | * @param int $depth The depth of the comment. |
| 601 | 601 | */ |
| 602 | -function twentyeleven_comment( $comment, $args, $depth ) { |
|
| 602 | +function twentyeleven_comment($comment, $args, $depth) { |
|
| 603 | 603 | $GLOBALS['comment'] = $comment; |
| 604 | - switch ( $comment->comment_type ) : |
|
| 604 | + switch ($comment->comment_type) : |
|
| 605 | 605 | case 'pingback' : |
| 606 | 606 | case 'trackback' : |
| 607 | 607 | ?> |
| 608 | 608 | <li class="post pingback"> |
| 609 | - <p><?php _e( 'Pingback:', 'twentyeleven' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?></p> |
|
| 609 | + <p><?php _e('Pingback:', 'twentyeleven'); ?> <?php comment_author_link(); ?><?php edit_comment_link(__('Edit', 'twentyeleven'), '<span class="edit-link">', '</span>'); ?></p> |
|
| 610 | 610 | <?php |
| 611 | 611 | break; |
| 612 | 612 | default : |
@@ -617,28 +617,28 @@ discard block |
||
| 617 | 617 | <div class="comment-author vcard"> |
| 618 | 618 | <?php |
| 619 | 619 | $avatar_size = 68; |
| 620 | - if ( '0' != $comment->comment_parent ) |
|
| 620 | + if ('0' != $comment->comment_parent) |
|
| 621 | 621 | $avatar_size = 39; |
| 622 | 622 | |
| 623 | - echo get_avatar( $comment, $avatar_size ); |
|
| 623 | + echo get_avatar($comment, $avatar_size); |
|
| 624 | 624 | |
| 625 | 625 | /* translators: 1: comment author, 2: date and time */ |
| 626 | - printf( __( '%1$s on %2$s <span class="says">said:</span>', 'twentyeleven' ), |
|
| 627 | - sprintf( '<span class="fn">%s</span>', get_comment_author_link() ), |
|
| 628 | - sprintf( '<a href="%1$s"><time datetime="%2$s">%3$s</time></a>', |
|
| 629 | - esc_url( get_comment_link( $comment->comment_ID ) ), |
|
| 630 | - get_comment_time( 'c' ), |
|
| 626 | + printf(__('%1$s on %2$s <span class="says">said:</span>', 'twentyeleven'), |
|
| 627 | + sprintf('<span class="fn">%s</span>', get_comment_author_link()), |
|
| 628 | + sprintf('<a href="%1$s"><time datetime="%2$s">%3$s</time></a>', |
|
| 629 | + esc_url(get_comment_link($comment->comment_ID)), |
|
| 630 | + get_comment_time('c'), |
|
| 631 | 631 | /* translators: 1: date, 2: time */ |
| 632 | - sprintf( __( '%1$s at %2$s', 'twentyeleven' ), get_comment_date(), get_comment_time() ) |
|
| 632 | + sprintf(__('%1$s at %2$s', 'twentyeleven'), get_comment_date(), get_comment_time()) |
|
| 633 | 633 | ) |
| 634 | 634 | ); |
| 635 | 635 | ?> |
| 636 | 636 | |
| 637 | - <?php edit_comment_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?> |
|
| 637 | + <?php edit_comment_link(__('Edit', 'twentyeleven'), '<span class="edit-link">', '</span>'); ?> |
|
| 638 | 638 | </div><!-- .comment-author .vcard --> |
| 639 | 639 | |
| 640 | - <?php if ( $comment->comment_approved == '0' ) : ?> |
|
| 641 | - <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'twentyeleven' ); ?></em> |
|
| 640 | + <?php if ($comment->comment_approved == '0') : ?> |
|
| 641 | + <em class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation.', 'twentyeleven'); ?></em> |
|
| 642 | 642 | <br /> |
| 643 | 643 | <?php endif; ?> |
| 644 | 644 | |
@@ -647,7 +647,7 @@ discard block |
||
| 647 | 647 | <div class="comment-content"><?php comment_text(); ?></div> |
| 648 | 648 | |
| 649 | 649 | <div class="reply"> |
| 650 | - <?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply <span>↓</span>', 'twentyeleven' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?> |
|
| 650 | + <?php comment_reply_link(array_merge($args, array('reply_text' => __('Reply <span>↓</span>', 'twentyeleven'), 'depth' => $depth, 'max_depth' => $args['max_depth']))); ?> |
|
| 651 | 651 | </div><!-- .reply --> |
| 652 | 652 | </article><!-- #comment-## --> |
| 653 | 653 | |
@@ -657,7 +657,7 @@ discard block |
||
| 657 | 657 | } |
| 658 | 658 | endif; // ends check for twentyeleven_comment() |
| 659 | 659 | |
| 660 | -if ( ! function_exists( 'twentyeleven_posted_on' ) ) : |
|
| 660 | +if ( ! function_exists('twentyeleven_posted_on')) : |
|
| 661 | 661 | /** |
| 662 | 662 | * Print HTML with meta information for the current post-date/time and author. |
| 663 | 663 | * |
@@ -666,13 +666,13 @@ discard block |
||
| 666 | 666 | * @since Twenty Eleven 1.0 |
| 667 | 667 | */ |
| 668 | 668 | function twentyeleven_posted_on() { |
| 669 | - printf( __( '<span class="sep">Posted on </span><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>', 'twentyeleven' ), |
|
| 670 | - esc_url( get_permalink() ), |
|
| 671 | - esc_attr( get_the_time() ), |
|
| 672 | - esc_attr( get_the_date( 'c' ) ), |
|
| 673 | - esc_html( get_the_date() ), |
|
| 674 | - esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), |
|
| 675 | - esc_attr( sprintf( __( 'View all posts by %s', 'twentyeleven' ), get_the_author() ) ), |
|
| 669 | + printf(__('<span class="sep">Posted on </span><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>', 'twentyeleven'), |
|
| 670 | + esc_url(get_permalink()), |
|
| 671 | + esc_attr(get_the_time()), |
|
| 672 | + esc_attr(get_the_date('c')), |
|
| 673 | + esc_html(get_the_date()), |
|
| 674 | + esc_url(get_author_posts_url(get_the_author_meta('ID'))), |
|
| 675 | + esc_attr(sprintf(__('View all posts by %s', 'twentyeleven'), get_the_author())), |
|
| 676 | 676 | get_the_author() |
| 677 | 677 | ); |
| 678 | 678 | } |
@@ -689,17 +689,17 @@ discard block |
||
| 689 | 689 | * @param array $classes Existing body classes. |
| 690 | 690 | * @return array The filtered array of body classes. |
| 691 | 691 | */ |
| 692 | -function twentyeleven_body_classes( $classes ) { |
|
| 692 | +function twentyeleven_body_classes($classes) { |
|
| 693 | 693 | |
| 694 | - if ( function_exists( 'is_multi_author' ) && ! is_multi_author() ) |
|
| 694 | + if (function_exists('is_multi_author') && ! is_multi_author()) |
|
| 695 | 695 | $classes[] = 'single-author'; |
| 696 | 696 | |
| 697 | - if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) ) |
|
| 697 | + if (is_singular() && ! is_home() && ! is_page_template('showcase.php') && ! is_page_template('sidebar-page.php')) |
|
| 698 | 698 | $classes[] = 'singular'; |
| 699 | 699 | |
| 700 | 700 | return $classes; |
| 701 | 701 | } |
| 702 | -add_filter( 'body_class', 'twentyeleven_body_classes' ); |
|
| 702 | +add_filter('body_class', 'twentyeleven_body_classes'); |
|
| 703 | 703 | |
| 704 | 704 | /** |
| 705 | 705 | * Retrieve the IDs for images in a gallery. |
@@ -714,20 +714,20 @@ discard block |
||
| 714 | 714 | function twentyeleven_get_gallery_images() { |
| 715 | 715 | $images = array(); |
| 716 | 716 | |
| 717 | - if ( function_exists( 'get_post_galleries' ) ) { |
|
| 718 | - $galleries = get_post_galleries( get_the_ID(), false ); |
|
| 719 | - if ( isset( $galleries[0]['ids'] ) ) |
|
| 720 | - $images = explode( ',', $galleries[0]['ids'] ); |
|
| 717 | + if (function_exists('get_post_galleries')) { |
|
| 718 | + $galleries = get_post_galleries(get_the_ID(), false); |
|
| 719 | + if (isset($galleries[0]['ids'])) |
|
| 720 | + $images = explode(',', $galleries[0]['ids']); |
|
| 721 | 721 | } else { |
| 722 | 722 | $pattern = get_shortcode_regex(); |
| 723 | - preg_match( "/$pattern/s", get_the_content(), $match ); |
|
| 724 | - $atts = shortcode_parse_atts( $match[3] ); |
|
| 725 | - if ( isset( $atts['ids'] ) ) |
|
| 726 | - $images = explode( ',', $atts['ids'] ); |
|
| 723 | + preg_match("/$pattern/s", get_the_content(), $match); |
|
| 724 | + $atts = shortcode_parse_atts($match[3]); |
|
| 725 | + if (isset($atts['ids'])) |
|
| 726 | + $images = explode(',', $atts['ids']); |
|
| 727 | 727 | } |
| 728 | 728 | |
| 729 | - if ( ! $images ) { |
|
| 730 | - $images = get_posts( array( |
|
| 729 | + if ( ! $images) { |
|
| 730 | + $images = get_posts(array( |
|
| 731 | 731 | 'fields' => 'ids', |
| 732 | 732 | 'numberposts' => 999, |
| 733 | 733 | 'order' => 'ASC', |
@@ -735,7 +735,7 @@ discard block |
||
| 735 | 735 | 'post_mime_type' => 'image', |
| 736 | 736 | 'post_parent' => get_the_ID(), |
| 737 | 737 | 'post_type' => 'attachment', |
| 738 | - ) ); |
|
| 738 | + )); |
|
| 739 | 739 | } |
| 740 | 740 | |
| 741 | 741 | return $images; |
@@ -39,8 +39,9 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | |
| 41 | 41 | // Set the content width based on the theme's design and stylesheet. |
| 42 | -if ( ! isset( $content_width ) ) |
|
| 42 | +if ( ! isset( $content_width ) ) { |
|
| 43 | 43 | $content_width = 584; |
| 44 | +} |
|
| 44 | 45 | |
| 45 | 46 | /* |
| 46 | 47 | * Tell WordPress to run twentyeleven_setup() when the 'after_setup_theme' hook is run. |
@@ -98,10 +99,11 @@ discard block |
||
| 98 | 99 | add_theme_support( 'post-formats', array( 'aside', 'link', 'gallery', 'status', 'quote', 'image' ) ); |
| 99 | 100 | |
| 100 | 101 | $theme_options = twentyeleven_get_theme_options(); |
| 101 | - if ( 'dark' == $theme_options['color_scheme'] ) |
|
| 102 | - $default_background_color = '1d1d1d'; |
|
| 103 | - else |
|
| 104 | - $default_background_color = 'e2e2e2'; |
|
| 102 | + if ( 'dark' == $theme_options['color_scheme'] ) { |
|
| 103 | + $default_background_color = '1d1d1d'; |
|
| 104 | + } else { |
|
| 105 | + $default_background_color = 'e2e2e2'; |
|
| 106 | + } |
|
| 105 | 107 | |
| 106 | 108 | // Add support for custom backgrounds. |
| 107 | 109 | add_theme_support( 'custom-background', array( |
@@ -239,8 +241,9 @@ discard block |
||
| 239 | 241 | $text_color = get_header_textcolor(); |
| 240 | 242 | |
| 241 | 243 | // If no custom options for text are set, let's bail. |
| 242 | - if ( $text_color == HEADER_TEXTCOLOR ) |
|
| 243 | - return; |
|
| 244 | + if ( $text_color == HEADER_TEXTCOLOR ) { |
|
| 245 | + return; |
|
| 246 | + } |
|
| 244 | 247 | |
| 245 | 248 | // If we get this far, we have custom styles. Let's do this. |
| 246 | 249 | ?> |
@@ -257,11 +260,14 @@ discard block |
||
| 257 | 260 | } |
| 258 | 261 | <?php |
| 259 | 262 | // If the user has set a custom color for the text use that |
| 260 | - else : |
|
| 263 | + else { |
|
| 264 | + : |
|
| 261 | 265 | ?> |
| 262 | 266 | #site-title a, |
| 263 | 267 | #site-description { |
| 264 | - color: #<?php echo $text_color; ?>; |
|
| 268 | + color: #<?php echo $text_color; |
|
| 269 | + } |
|
| 270 | + ?>; |
|
| 265 | 271 | } |
| 266 | 272 | <?php endif; ?> |
| 267 | 273 | </style> |
@@ -425,8 +431,9 @@ discard block |
||
| 425 | 431 | * @return array The filtered page menu arguments. |
| 426 | 432 | */ |
| 427 | 433 | function twentyeleven_page_menu_args( $args ) { |
| 428 | - if ( ! isset( $args['show_home'] ) ) |
|
| 429 | - $args['show_home'] = true; |
|
| 434 | + if ( ! isset( $args['show_home'] ) ) { |
|
| 435 | + $args['show_home'] = true; |
|
| 436 | + } |
|
| 430 | 437 | return $args; |
| 431 | 438 | } |
| 432 | 439 | add_filter( 'wp_page_menu_args', 'twentyeleven_page_menu_args' ); |
@@ -528,8 +535,9 @@ discard block |
||
| 528 | 535 | $content = get_the_content(); |
| 529 | 536 | $has_url = function_exists( 'get_url_in_content' ) ? get_url_in_content( $content ) : false; |
| 530 | 537 | |
| 531 | - if ( ! $has_url ) |
|
| 532 | - $has_url = twentyeleven_url_grabber(); |
|
| 538 | + if ( ! $has_url ) { |
|
| 539 | + $has_url = twentyeleven_url_grabber(); |
|
| 540 | + } |
|
| 533 | 541 | |
| 534 | 542 | /** This filter is documented in wp-includes/link-template.php */ |
| 535 | 543 | return ( $has_url ) ? $has_url : apply_filters( 'the_permalink', get_permalink() ); |
@@ -543,8 +551,9 @@ discard block |
||
| 543 | 551 | * @return string|bool URL or false when no link is present. |
| 544 | 552 | */ |
| 545 | 553 | function twentyeleven_url_grabber() { |
| 546 | - if ( ! preg_match( '/<a\s[^>]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches ) ) |
|
| 547 | - return false; |
|
| 554 | + if ( ! preg_match( '/<a\s[^>]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches ) ) { |
|
| 555 | + return false; |
|
| 556 | + } |
|
| 548 | 557 | |
| 549 | 558 | return esc_url_raw( $matches[1] ); |
| 550 | 559 | } |
@@ -557,14 +566,17 @@ discard block |
||
| 557 | 566 | function twentyeleven_footer_sidebar_class() { |
| 558 | 567 | $count = 0; |
| 559 | 568 | |
| 560 | - if ( is_active_sidebar( 'sidebar-3' ) ) |
|
| 561 | - $count++; |
|
| 569 | + if ( is_active_sidebar( 'sidebar-3' ) ) { |
|
| 570 | + $count++; |
|
| 571 | + } |
|
| 562 | 572 | |
| 563 | - if ( is_active_sidebar( 'sidebar-4' ) ) |
|
| 564 | - $count++; |
|
| 573 | + if ( is_active_sidebar( 'sidebar-4' ) ) { |
|
| 574 | + $count++; |
|
| 575 | + } |
|
| 565 | 576 | |
| 566 | - if ( is_active_sidebar( 'sidebar-5' ) ) |
|
| 567 | - $count++; |
|
| 577 | + if ( is_active_sidebar( 'sidebar-5' ) ) { |
|
| 578 | + $count++; |
|
| 579 | + } |
|
| 568 | 580 | |
| 569 | 581 | $class = ''; |
| 570 | 582 | |
@@ -580,9 +592,10 @@ discard block |
||
| 580 | 592 | break; |
| 581 | 593 | } |
| 582 | 594 | |
| 583 | - if ( $class ) |
|
| 584 | - echo 'class="' . esc_attr( $class ) . '"'; |
|
| 585 | -} |
|
| 595 | + if ( $class ) { |
|
| 596 | + echo 'class="' . esc_attr( $class ) . '"'; |
|
| 597 | + } |
|
| 598 | + } |
|
| 586 | 599 | |
| 587 | 600 | if ( ! function_exists( 'twentyeleven_comment' ) ) : |
| 588 | 601 | /** |
@@ -617,8 +630,9 @@ discard block |
||
| 617 | 630 | <div class="comment-author vcard"> |
| 618 | 631 | <?php |
| 619 | 632 | $avatar_size = 68; |
| 620 | - if ( '0' != $comment->comment_parent ) |
|
| 621 | - $avatar_size = 39; |
|
| 633 | + if ( '0' != $comment->comment_parent ) { |
|
| 634 | + $avatar_size = 39; |
|
| 635 | + } |
|
| 622 | 636 | |
| 623 | 637 | echo get_avatar( $comment, $avatar_size ); |
| 624 | 638 | |
@@ -691,11 +705,13 @@ discard block |
||
| 691 | 705 | */ |
| 692 | 706 | function twentyeleven_body_classes( $classes ) { |
| 693 | 707 | |
| 694 | - if ( function_exists( 'is_multi_author' ) && ! is_multi_author() ) |
|
| 695 | - $classes[] = 'single-author'; |
|
| 708 | + if ( function_exists( 'is_multi_author' ) && ! is_multi_author() ) { |
|
| 709 | + $classes[] = 'single-author'; |
|
| 710 | + } |
|
| 696 | 711 | |
| 697 | - if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) ) |
|
| 698 | - $classes[] = 'singular'; |
|
| 712 | + if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) ) { |
|
| 713 | + $classes[] = 'singular'; |
|
| 714 | + } |
|
| 699 | 715 | |
| 700 | 716 | return $classes; |
| 701 | 717 | } |
@@ -716,14 +732,16 @@ discard block |
||
| 716 | 732 | |
| 717 | 733 | if ( function_exists( 'get_post_galleries' ) ) { |
| 718 | 734 | $galleries = get_post_galleries( get_the_ID(), false ); |
| 719 | - if ( isset( $galleries[0]['ids'] ) ) |
|
| 720 | - $images = explode( ',', $galleries[0]['ids'] ); |
|
| 735 | + if ( isset( $galleries[0]['ids'] ) ) { |
|
| 736 | + $images = explode( ',', $galleries[0]['ids'] ); |
|
| 737 | + } |
|
| 721 | 738 | } else { |
| 722 | 739 | $pattern = get_shortcode_regex(); |
| 723 | 740 | preg_match( "/$pattern/s", get_the_content(), $match ); |
| 724 | 741 | $atts = shortcode_parse_atts( $match[3] ); |
| 725 | - if ( isset( $atts['ids'] ) ) |
|
| 726 | - $images = explode( ',', $atts['ids'] ); |
|
| 742 | + if ( isset( $atts['ids'] ) ) { |
|
| 743 | + $images = explode( ',', $atts['ids'] ); |
|
| 744 | + } |
|
| 727 | 745 | } |
| 728 | 746 | |
| 729 | 747 | if ( ! $images ) { |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | * |
| 14 | 14 | * @global wpdb $wpdb WordPress database abstraction object. |
| 15 | 15 | * |
| 16 | - * @param int|stdClass $bookmark |
|
| 16 | + * @param integer|null $bookmark |
|
| 17 | 17 | * @param string $output Optional. Either OBJECT, ARRAY_N, or ARRAY_A constant |
| 18 | 18 | * @param string $filter Optional, default is 'raw'. |
| 19 | 19 | * @return array|object|null Type returned depends on $output value. |
@@ -1,10 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Link/Bookmark API |
|
| 4 | - * |
|
| 5 | - * @package WordPress |
|
| 6 | - * @subpackage Bookmark |
|
| 7 | - */ |
|
| 3 | + * Link/Bookmark API |
|
| 4 | + * |
|
| 5 | + * @package WordPress |
|
| 6 | + * @subpackage Bookmark |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Retrieve Bookmark data |
@@ -354,24 +354,24 @@ |
||
| 354 | 354 | */ |
| 355 | 355 | function sanitize_bookmark_field($field, $value, $bookmark_id, $context) { |
| 356 | 356 | switch ( $field ) { |
| 357 | - case 'link_id' : // ints |
|
| 358 | - case 'link_rating' : |
|
| 359 | - $value = (int) $value; |
|
| 360 | - break; |
|
| 361 | - case 'link_category' : // array( ints ) |
|
| 362 | - $value = array_map('absint', (array) $value); |
|
| 363 | - // We return here so that the categories aren't filtered. |
|
| 364 | - // The 'link_category' filter is for the name of a link category, not an array of a link's link categories |
|
| 365 | - return $value; |
|
| 366 | - |
|
| 367 | - case 'link_visible' : // bool stored as Y|N |
|
| 368 | - $value = preg_replace('/[^YNyn]/', '', $value); |
|
| 369 | - break; |
|
| 370 | - case 'link_target' : // "enum" |
|
| 371 | - $targets = array('_top', '_blank'); |
|
| 372 | - if ( ! in_array($value, $targets) ) |
|
| 373 | - $value = ''; |
|
| 374 | - break; |
|
| 357 | + case 'link_id' : // ints |
|
| 358 | + case 'link_rating' : |
|
| 359 | + $value = (int) $value; |
|
| 360 | + break; |
|
| 361 | + case 'link_category' : // array( ints ) |
|
| 362 | + $value = array_map('absint', (array) $value); |
|
| 363 | + // We return here so that the categories aren't filtered. |
|
| 364 | + // The 'link_category' filter is for the name of a link category, not an array of a link's link categories |
|
| 365 | + return $value; |
|
| 366 | + |
|
| 367 | + case 'link_visible' : // bool stored as Y|N |
|
| 368 | + $value = preg_replace('/[^YNyn]/', '', $value); |
|
| 369 | + break; |
|
| 370 | + case 'link_target' : // "enum" |
|
| 371 | + $targets = array('_top', '_blank'); |
|
| 372 | + if ( ! in_array($value, $targets) ) |
|
| 373 | + $value = ''; |
|
| 374 | + break; |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | if ( 'raw' == $context ) |
@@ -21,36 +21,36 @@ discard block |
||
| 21 | 21 | function get_bookmark($bookmark, $output = OBJECT, $filter = 'raw') { |
| 22 | 22 | global $wpdb; |
| 23 | 23 | |
| 24 | - if ( empty($bookmark) ) { |
|
| 25 | - if ( isset($GLOBALS['link']) ) |
|
| 24 | + if (empty($bookmark)) { |
|
| 25 | + if (isset($GLOBALS['link'])) |
|
| 26 | 26 | $_bookmark = & $GLOBALS['link']; |
| 27 | 27 | else |
| 28 | 28 | $_bookmark = null; |
| 29 | - } elseif ( is_object($bookmark) ) { |
|
| 29 | + } elseif (is_object($bookmark)) { |
|
| 30 | 30 | wp_cache_add($bookmark->link_id, $bookmark, 'bookmark'); |
| 31 | 31 | $_bookmark = $bookmark; |
| 32 | 32 | } else { |
| 33 | - if ( isset($GLOBALS['link']) && ($GLOBALS['link']->link_id == $bookmark) ) { |
|
| 33 | + if (isset($GLOBALS['link']) && ($GLOBALS['link']->link_id == $bookmark)) { |
|
| 34 | 34 | $_bookmark = & $GLOBALS['link']; |
| 35 | - } elseif ( ! $_bookmark = wp_cache_get($bookmark, 'bookmark') ) { |
|
| 35 | + } elseif ( ! $_bookmark = wp_cache_get($bookmark, 'bookmark')) { |
|
| 36 | 36 | $_bookmark = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->links WHERE link_id = %d LIMIT 1", $bookmark)); |
| 37 | - if ( $_bookmark ) { |
|
| 38 | - $_bookmark->link_category = array_unique( wp_get_object_terms( $_bookmark->link_id, 'link_category', array( 'fields' => 'ids' ) ) ); |
|
| 39 | - wp_cache_add( $_bookmark->link_id, $_bookmark, 'bookmark' ); |
|
| 37 | + if ($_bookmark) { |
|
| 38 | + $_bookmark->link_category = array_unique(wp_get_object_terms($_bookmark->link_id, 'link_category', array('fields' => 'ids'))); |
|
| 39 | + wp_cache_add($_bookmark->link_id, $_bookmark, 'bookmark'); |
|
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - if ( ! $_bookmark ) |
|
| 44 | + if ( ! $_bookmark) |
|
| 45 | 45 | return $_bookmark; |
| 46 | 46 | |
| 47 | 47 | $_bookmark = sanitize_bookmark($_bookmark, $filter); |
| 48 | 48 | |
| 49 | - if ( $output == OBJECT ) { |
|
| 49 | + if ($output == OBJECT) { |
|
| 50 | 50 | return $_bookmark; |
| 51 | - } elseif ( $output == ARRAY_A ) { |
|
| 51 | + } elseif ($output == ARRAY_A) { |
|
| 52 | 52 | return get_object_vars($_bookmark); |
| 53 | - } elseif ( $output == ARRAY_N ) { |
|
| 53 | + } elseif ($output == ARRAY_N) { |
|
| 54 | 54 | return array_values(get_object_vars($_bookmark)); |
| 55 | 55 | } else { |
| 56 | 56 | return $_bookmark; |
@@ -67,17 +67,17 @@ discard block |
||
| 67 | 67 | * @param string $context Optional. The context of how the field will be used. |
| 68 | 68 | * @return string|WP_Error |
| 69 | 69 | */ |
| 70 | -function get_bookmark_field( $field, $bookmark, $context = 'display' ) { |
|
| 70 | +function get_bookmark_field($field, $bookmark, $context = 'display') { |
|
| 71 | 71 | $bookmark = (int) $bookmark; |
| 72 | - $bookmark = get_bookmark( $bookmark ); |
|
| 72 | + $bookmark = get_bookmark($bookmark); |
|
| 73 | 73 | |
| 74 | - if ( is_wp_error($bookmark) ) |
|
| 74 | + if (is_wp_error($bookmark)) |
|
| 75 | 75 | return $bookmark; |
| 76 | 76 | |
| 77 | - if ( !is_object($bookmark) ) |
|
| 77 | + if ( ! is_object($bookmark)) |
|
| 78 | 78 | return ''; |
| 79 | 79 | |
| 80 | - if ( !isset($bookmark->$field) ) |
|
| 80 | + if ( ! isset($bookmark->$field)) |
|
| 81 | 81 | return ''; |
| 82 | 82 | |
| 83 | 83 | return sanitize_bookmark_field($field, $bookmark->$field, $bookmark->link_id, $context); |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * } |
| 115 | 115 | * @return array List of bookmark row objects. |
| 116 | 116 | */ |
| 117 | -function get_bookmarks( $args = '' ) { |
|
| 117 | +function get_bookmarks($args = '') { |
|
| 118 | 118 | global $wpdb; |
| 119 | 119 | |
| 120 | 120 | $defaults = array( |
@@ -125,12 +125,12 @@ discard block |
||
| 125 | 125 | 'exclude' => '', 'search' => '' |
| 126 | 126 | ); |
| 127 | 127 | |
| 128 | - $r = wp_parse_args( $args, $defaults ); |
|
| 128 | + $r = wp_parse_args($args, $defaults); |
|
| 129 | 129 | |
| 130 | - $key = md5( serialize( $r ) ); |
|
| 131 | - if ( $cache = wp_cache_get( 'get_bookmarks', 'bookmark' ) ) { |
|
| 132 | - if ( is_array( $cache ) && isset( $cache[ $key ] ) ) { |
|
| 133 | - $bookmarks = $cache[ $key ]; |
|
| 130 | + $key = md5(serialize($r)); |
|
| 131 | + if ($cache = wp_cache_get('get_bookmarks', 'bookmark')) { |
|
| 132 | + if (is_array($cache) && isset($cache[$key])) { |
|
| 133 | + $bookmarks = $cache[$key]; |
|
| 134 | 134 | /** |
| 135 | 135 | * Filter the returned list of bookmarks. |
| 136 | 136 | * |
@@ -146,98 +146,98 @@ discard block |
||
| 146 | 146 | * @param array $bookmarks List of the cached bookmarks. |
| 147 | 147 | * @param array $r An array of bookmark query arguments. |
| 148 | 148 | */ |
| 149 | - return apply_filters( 'get_bookmarks', $bookmarks, $r ); |
|
| 149 | + return apply_filters('get_bookmarks', $bookmarks, $r); |
|
| 150 | 150 | } |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - if ( ! is_array( $cache ) ) { |
|
| 153 | + if ( ! is_array($cache)) { |
|
| 154 | 154 | $cache = array(); |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | $inclusions = ''; |
| 158 | - if ( ! empty( $r['include'] ) ) { |
|
| 159 | - $r['exclude'] = ''; //ignore exclude, category, and category_name params if using include |
|
| 158 | + if ( ! empty($r['include'])) { |
|
| 159 | + $r['exclude'] = ''; //ignore exclude, category, and category_name params if using include |
|
| 160 | 160 | $r['category'] = ''; |
| 161 | 161 | $r['category_name'] = ''; |
| 162 | - $inclinks = preg_split( '/[\s,]+/', $r['include'] ); |
|
| 163 | - if ( count( $inclinks ) ) { |
|
| 164 | - foreach ( $inclinks as $inclink ) { |
|
| 165 | - if ( empty( $inclusions ) ) { |
|
| 166 | - $inclusions = ' AND ( link_id = ' . intval( $inclink ) . ' '; |
|
| 162 | + $inclinks = preg_split('/[\s,]+/', $r['include']); |
|
| 163 | + if (count($inclinks)) { |
|
| 164 | + foreach ($inclinks as $inclink) { |
|
| 165 | + if (empty($inclusions)) { |
|
| 166 | + $inclusions = ' AND ( link_id = '.intval($inclink).' '; |
|
| 167 | 167 | } else { |
| 168 | - $inclusions .= ' OR link_id = ' . intval( $inclink ) . ' '; |
|
| 168 | + $inclusions .= ' OR link_id = '.intval($inclink).' '; |
|
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | - if (! empty( $inclusions ) ) { |
|
| 173 | + if ( ! empty($inclusions)) { |
|
| 174 | 174 | $inclusions .= ')'; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | $exclusions = ''; |
| 178 | - if ( ! empty( $r['exclude'] ) ) { |
|
| 179 | - $exlinks = preg_split( '/[\s,]+/', $r['exclude'] ); |
|
| 180 | - if ( count( $exlinks ) ) { |
|
| 181 | - foreach ( $exlinks as $exlink ) { |
|
| 182 | - if ( empty( $exclusions ) ) { |
|
| 183 | - $exclusions = ' AND ( link_id <> ' . intval( $exlink ) . ' '; |
|
| 178 | + if ( ! empty($r['exclude'])) { |
|
| 179 | + $exlinks = preg_split('/[\s,]+/', $r['exclude']); |
|
| 180 | + if (count($exlinks)) { |
|
| 181 | + foreach ($exlinks as $exlink) { |
|
| 182 | + if (empty($exclusions)) { |
|
| 183 | + $exclusions = ' AND ( link_id <> '.intval($exlink).' '; |
|
| 184 | 184 | } else { |
| 185 | - $exclusions .= ' AND link_id <> ' . intval( $exlink ) . ' '; |
|
| 185 | + $exclusions .= ' AND link_id <> '.intval($exlink).' '; |
|
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | } |
| 190 | - if ( ! empty( $exclusions ) ) { |
|
| 190 | + if ( ! empty($exclusions)) { |
|
| 191 | 191 | $exclusions .= ')'; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - if ( ! empty( $r['category_name'] ) ) { |
|
| 195 | - if ( $r['category'] = get_term_by('name', $r['category_name'], 'link_category') ) { |
|
| 194 | + if ( ! empty($r['category_name'])) { |
|
| 195 | + if ($r['category'] = get_term_by('name', $r['category_name'], 'link_category')) { |
|
| 196 | 196 | $r['category'] = $r['category']->term_id; |
| 197 | 197 | } else { |
| 198 | - $cache[ $key ] = array(); |
|
| 199 | - wp_cache_set( 'get_bookmarks', $cache, 'bookmark' ); |
|
| 198 | + $cache[$key] = array(); |
|
| 199 | + wp_cache_set('get_bookmarks', $cache, 'bookmark'); |
|
| 200 | 200 | /** This filter is documented in wp-includes/bookmark.php */ |
| 201 | - return apply_filters( 'get_bookmarks', array(), $r ); |
|
| 201 | + return apply_filters('get_bookmarks', array(), $r); |
|
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | $search = ''; |
| 206 | - if ( ! empty( $r['search'] ) ) { |
|
| 207 | - $like = '%' . $wpdb->esc_like( $r['search'] ) . '%'; |
|
| 208 | - $search = $wpdb->prepare(" AND ( (link_url LIKE %s) OR (link_name LIKE %s) OR (link_description LIKE %s) ) ", $like, $like, $like ); |
|
| 206 | + if ( ! empty($r['search'])) { |
|
| 207 | + $like = '%'.$wpdb->esc_like($r['search']).'%'; |
|
| 208 | + $search = $wpdb->prepare(" AND ( (link_url LIKE %s) OR (link_name LIKE %s) OR (link_description LIKE %s) ) ", $like, $like, $like); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | $category_query = ''; |
| 212 | 212 | $join = ''; |
| 213 | - if ( ! empty( $r['category'] ) ) { |
|
| 214 | - $incategories = preg_split( '/[\s,]+/', $r['category'] ); |
|
| 215 | - if ( count($incategories) ) { |
|
| 216 | - foreach ( $incategories as $incat ) { |
|
| 217 | - if ( empty( $category_query ) ) { |
|
| 218 | - $category_query = ' AND ( tt.term_id = ' . intval( $incat ) . ' '; |
|
| 213 | + if ( ! empty($r['category'])) { |
|
| 214 | + $incategories = preg_split('/[\s,]+/', $r['category']); |
|
| 215 | + if (count($incategories)) { |
|
| 216 | + foreach ($incategories as $incat) { |
|
| 217 | + if (empty($category_query)) { |
|
| 218 | + $category_query = ' AND ( tt.term_id = '.intval($incat).' '; |
|
| 219 | 219 | } else { |
| 220 | - $category_query .= ' OR tt.term_id = ' . intval( $incat ) . ' '; |
|
| 220 | + $category_query .= ' OR tt.term_id = '.intval($incat).' '; |
|
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | 223 | } |
| 224 | 224 | } |
| 225 | - if ( ! empty( $category_query ) ) { |
|
| 225 | + if ( ! empty($category_query)) { |
|
| 226 | 226 | $category_query .= ") AND taxonomy = 'link_category'"; |
| 227 | 227 | $join = " INNER JOIN $wpdb->term_relationships AS tr ON ($wpdb->links.link_id = tr.object_id) INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_taxonomy_id = tr.term_taxonomy_id"; |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - if ( $r['show_updated'] ) { |
|
| 230 | + if ($r['show_updated']) { |
|
| 231 | 231 | $recently_updated_test = ", IF (DATE_ADD(link_updated, INTERVAL 120 MINUTE) >= NOW(), 1,0) as recently_updated "; |
| 232 | 232 | } else { |
| 233 | 233 | $recently_updated_test = ''; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - $get_updated = ( $r['show_updated'] ) ? ', UNIX_TIMESTAMP(link_updated) AS link_updated_f ' : ''; |
|
| 236 | + $get_updated = ($r['show_updated']) ? ', UNIX_TIMESTAMP(link_updated) AS link_updated_f ' : ''; |
|
| 237 | 237 | |
| 238 | - $orderby = strtolower( $r['orderby'] ); |
|
| 238 | + $orderby = strtolower($r['orderby']); |
|
| 239 | 239 | $length = ''; |
| 240 | - switch ( $orderby ) { |
|
| 240 | + switch ($orderby) { |
|
| 241 | 241 | case 'length': |
| 242 | 242 | $length = ", CHAR_LENGTH(link_name) AS length"; |
| 243 | 243 | break; |
@@ -249,47 +249,47 @@ discard block |
||
| 249 | 249 | break; |
| 250 | 250 | default: |
| 251 | 251 | $orderparams = array(); |
| 252 | - $keys = array( 'link_id', 'link_name', 'link_url', 'link_visible', 'link_rating', 'link_owner', 'link_updated', 'link_notes', 'link_description' ); |
|
| 253 | - foreach ( explode( ',', $orderby ) as $ordparam ) { |
|
| 254 | - $ordparam = trim( $ordparam ); |
|
| 252 | + $keys = array('link_id', 'link_name', 'link_url', 'link_visible', 'link_rating', 'link_owner', 'link_updated', 'link_notes', 'link_description'); |
|
| 253 | + foreach (explode(',', $orderby) as $ordparam) { |
|
| 254 | + $ordparam = trim($ordparam); |
|
| 255 | 255 | |
| 256 | - if ( in_array( 'link_' . $ordparam, $keys ) ) { |
|
| 257 | - $orderparams[] = 'link_' . $ordparam; |
|
| 258 | - } elseif ( in_array( $ordparam, $keys ) ) { |
|
| 256 | + if (in_array('link_'.$ordparam, $keys)) { |
|
| 257 | + $orderparams[] = 'link_'.$ordparam; |
|
| 258 | + } elseif (in_array($ordparam, $keys)) { |
|
| 259 | 259 | $orderparams[] = $ordparam; |
| 260 | 260 | } |
| 261 | 261 | } |
| 262 | - $orderby = implode( ',', $orderparams ); |
|
| 262 | + $orderby = implode(',', $orderparams); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - if ( empty( $orderby ) ) { |
|
| 265 | + if (empty($orderby)) { |
|
| 266 | 266 | $orderby = 'link_name'; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - $order = strtoupper( $r['order'] ); |
|
| 270 | - if ( '' !== $order && ! in_array( $order, array( 'ASC', 'DESC' ) ) ) { |
|
| 269 | + $order = strtoupper($r['order']); |
|
| 270 | + if ('' !== $order && ! in_array($order, array('ASC', 'DESC'))) { |
|
| 271 | 271 | $order = 'ASC'; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | $visible = ''; |
| 275 | - if ( $r['hide_invisible'] ) { |
|
| 275 | + if ($r['hide_invisible']) { |
|
| 276 | 276 | $visible = "AND link_visible = 'Y'"; |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | $query = "SELECT * $length $recently_updated_test $get_updated FROM $wpdb->links $join WHERE 1=1 $visible $category_query"; |
| 280 | 280 | $query .= " $exclusions $inclusions $search"; |
| 281 | 281 | $query .= " ORDER BY $orderby $order"; |
| 282 | - if ( $r['limit'] != -1 ) { |
|
| 283 | - $query .= ' LIMIT ' . $r['limit']; |
|
| 282 | + if ($r['limit'] != -1) { |
|
| 283 | + $query .= ' LIMIT '.$r['limit']; |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - $results = $wpdb->get_results( $query ); |
|
| 286 | + $results = $wpdb->get_results($query); |
|
| 287 | 287 | |
| 288 | - $cache[ $key ] = $results; |
|
| 289 | - wp_cache_set( 'get_bookmarks', $cache, 'bookmark' ); |
|
| 288 | + $cache[$key] = $results; |
|
| 289 | + wp_cache_set('get_bookmarks', $cache, 'bookmark'); |
|
| 290 | 290 | |
| 291 | 291 | /** This filter is documented in wp-includes/bookmark.php */ |
| 292 | - return apply_filters( 'get_bookmarks', $results, $r ); |
|
| 292 | + return apply_filters('get_bookmarks', $results, $r); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | /** |
@@ -305,9 +305,9 @@ discard block |
||
| 305 | 305 | function sanitize_bookmark($bookmark, $context = 'display') { |
| 306 | 306 | $fields = array('link_id', 'link_url', 'link_name', 'link_image', 'link_target', 'link_category', |
| 307 | 307 | 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_updated', |
| 308 | - 'link_rel', 'link_notes', 'link_rss', ); |
|
| 308 | + 'link_rel', 'link_notes', 'link_rss',); |
|
| 309 | 309 | |
| 310 | - if ( is_object($bookmark) ) { |
|
| 310 | + if (is_object($bookmark)) { |
|
| 311 | 311 | $do_object = true; |
| 312 | 312 | $link_id = $bookmark->link_id; |
| 313 | 313 | } else { |
@@ -315,12 +315,12 @@ discard block |
||
| 315 | 315 | $link_id = $bookmark['link_id']; |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - foreach ( $fields as $field ) { |
|
| 319 | - if ( $do_object ) { |
|
| 320 | - if ( isset($bookmark->$field) ) |
|
| 318 | + foreach ($fields as $field) { |
|
| 319 | + if ($do_object) { |
|
| 320 | + if (isset($bookmark->$field)) |
|
| 321 | 321 | $bookmark->$field = sanitize_bookmark_field($field, $bookmark->$field, $link_id, $context); |
| 322 | 322 | } else { |
| 323 | - if ( isset($bookmark[$field]) ) |
|
| 323 | + if (isset($bookmark[$field])) |
|
| 324 | 324 | $bookmark[$field] = sanitize_bookmark_field($field, $bookmark[$field], $link_id, $context); |
| 325 | 325 | } |
| 326 | 326 | } |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | * @return mixed The filtered value |
| 354 | 354 | */ |
| 355 | 355 | function sanitize_bookmark_field($field, $value, $bookmark_id, $context) { |
| 356 | - switch ( $field ) { |
|
| 356 | + switch ($field) { |
|
| 357 | 357 | case 'link_id' : // ints |
| 358 | 358 | case 'link_rating' : |
| 359 | 359 | $value = (int) $value; |
@@ -369,34 +369,34 @@ discard block |
||
| 369 | 369 | break; |
| 370 | 370 | case 'link_target' : // "enum" |
| 371 | 371 | $targets = array('_top', '_blank'); |
| 372 | - if ( ! in_array($value, $targets) ) |
|
| 372 | + if ( ! in_array($value, $targets)) |
|
| 373 | 373 | $value = ''; |
| 374 | 374 | break; |
| 375 | 375 | } |
| 376 | 376 | |
| 377 | - if ( 'raw' == $context ) |
|
| 377 | + if ('raw' == $context) |
|
| 378 | 378 | return $value; |
| 379 | 379 | |
| 380 | - if ( 'edit' == $context ) { |
|
| 380 | + if ('edit' == $context) { |
|
| 381 | 381 | /** This filter is documented in wp-includes/post.php */ |
| 382 | - $value = apply_filters( "edit_$field", $value, $bookmark_id ); |
|
| 382 | + $value = apply_filters("edit_$field", $value, $bookmark_id); |
|
| 383 | 383 | |
| 384 | - if ( 'link_notes' == $field ) { |
|
| 385 | - $value = esc_html( $value ); // textarea_escaped |
|
| 384 | + if ('link_notes' == $field) { |
|
| 385 | + $value = esc_html($value); // textarea_escaped |
|
| 386 | 386 | } else { |
| 387 | 387 | $value = esc_attr($value); |
| 388 | 388 | } |
| 389 | - } elseif ( 'db' == $context ) { |
|
| 389 | + } elseif ('db' == $context) { |
|
| 390 | 390 | /** This filter is documented in wp-includes/post.php */ |
| 391 | - $value = apply_filters( "pre_$field", $value ); |
|
| 391 | + $value = apply_filters("pre_$field", $value); |
|
| 392 | 392 | } else { |
| 393 | 393 | /** This filter is documented in wp-includes/post.php */ |
| 394 | - $value = apply_filters( $field, $value, $bookmark_id, $context ); |
|
| 394 | + $value = apply_filters($field, $value, $bookmark_id, $context); |
|
| 395 | 395 | |
| 396 | - if ( 'attribute' == $context ) { |
|
| 397 | - $value = esc_attr( $value ); |
|
| 398 | - } elseif ( 'js' == $context ) { |
|
| 399 | - $value = esc_js( $value ); |
|
| 396 | + if ('attribute' == $context) { |
|
| 397 | + $value = esc_attr($value); |
|
| 398 | + } elseif ('js' == $context) { |
|
| 399 | + $value = esc_js($value); |
|
| 400 | 400 | } |
| 401 | 401 | } |
| 402 | 402 | |
@@ -408,8 +408,8 @@ discard block |
||
| 408 | 408 | * |
| 409 | 409 | * @since 2.7.0 |
| 410 | 410 | */ |
| 411 | -function clean_bookmark_cache( $bookmark_id ) { |
|
| 412 | - wp_cache_delete( $bookmark_id, 'bookmark' ); |
|
| 413 | - wp_cache_delete( 'get_bookmarks', 'bookmark' ); |
|
| 414 | - clean_object_term_cache( $bookmark_id, 'link'); |
|
| 411 | +function clean_bookmark_cache($bookmark_id) { |
|
| 412 | + wp_cache_delete($bookmark_id, 'bookmark'); |
|
| 413 | + wp_cache_delete('get_bookmarks', 'bookmark'); |
|
| 414 | + clean_object_term_cache($bookmark_id, 'link'); |
|
| 415 | 415 | } |
@@ -22,10 +22,11 @@ discard block |
||
| 22 | 22 | global $wpdb; |
| 23 | 23 | |
| 24 | 24 | if ( empty($bookmark) ) { |
| 25 | - if ( isset($GLOBALS['link']) ) |
|
| 26 | - $_bookmark = & $GLOBALS['link']; |
|
| 27 | - else |
|
| 28 | - $_bookmark = null; |
|
| 25 | + if ( isset($GLOBALS['link']) ) { |
|
| 26 | + $_bookmark = & $GLOBALS['link']; |
|
| 27 | + } else { |
|
| 28 | + $_bookmark = null; |
|
| 29 | + } |
|
| 29 | 30 | } elseif ( is_object($bookmark) ) { |
| 30 | 31 | wp_cache_add($bookmark->link_id, $bookmark, 'bookmark'); |
| 31 | 32 | $_bookmark = $bookmark; |
@@ -41,8 +42,9 @@ discard block |
||
| 41 | 42 | } |
| 42 | 43 | } |
| 43 | 44 | |
| 44 | - if ( ! $_bookmark ) |
|
| 45 | - return $_bookmark; |
|
| 45 | + if ( ! $_bookmark ) { |
|
| 46 | + return $_bookmark; |
|
| 47 | + } |
|
| 46 | 48 | |
| 47 | 49 | $_bookmark = sanitize_bookmark($_bookmark, $filter); |
| 48 | 50 | |
@@ -71,14 +73,17 @@ discard block |
||
| 71 | 73 | $bookmark = (int) $bookmark; |
| 72 | 74 | $bookmark = get_bookmark( $bookmark ); |
| 73 | 75 | |
| 74 | - if ( is_wp_error($bookmark) ) |
|
| 75 | - return $bookmark; |
|
| 76 | + if ( is_wp_error($bookmark) ) { |
|
| 77 | + return $bookmark; |
|
| 78 | + } |
|
| 76 | 79 | |
| 77 | - if ( !is_object($bookmark) ) |
|
| 78 | - return ''; |
|
| 80 | + if ( !is_object($bookmark) ) { |
|
| 81 | + return ''; |
|
| 82 | + } |
|
| 79 | 83 | |
| 80 | - if ( !isset($bookmark->$field) ) |
|
| 81 | - return ''; |
|
| 84 | + if ( !isset($bookmark->$field) ) { |
|
| 85 | + return ''; |
|
| 86 | + } |
|
| 82 | 87 | |
| 83 | 88 | return sanitize_bookmark_field($field, $bookmark->$field, $bookmark->link_id, $context); |
| 84 | 89 | } |
@@ -317,11 +322,13 @@ discard block |
||
| 317 | 322 | |
| 318 | 323 | foreach ( $fields as $field ) { |
| 319 | 324 | if ( $do_object ) { |
| 320 | - if ( isset($bookmark->$field) ) |
|
| 321 | - $bookmark->$field = sanitize_bookmark_field($field, $bookmark->$field, $link_id, $context); |
|
| 325 | + if ( isset($bookmark->$field) ) { |
|
| 326 | + $bookmark->$field = sanitize_bookmark_field($field, $bookmark->$field, $link_id, $context); |
|
| 327 | + } |
|
| 322 | 328 | } else { |
| 323 | - if ( isset($bookmark[$field]) ) |
|
| 324 | - $bookmark[$field] = sanitize_bookmark_field($field, $bookmark[$field], $link_id, $context); |
|
| 329 | + if ( isset($bookmark[$field]) ) { |
|
| 330 | + $bookmark[$field] = sanitize_bookmark_field($field, $bookmark[$field], $link_id, $context); |
|
| 331 | + } |
|
| 325 | 332 | } |
| 326 | 333 | } |
| 327 | 334 | |
@@ -369,13 +376,15 @@ discard block |
||
| 369 | 376 | break; |
| 370 | 377 | case 'link_target' : // "enum" |
| 371 | 378 | $targets = array('_top', '_blank'); |
| 372 | - if ( ! in_array($value, $targets) ) |
|
| 373 | - $value = ''; |
|
| 379 | + if ( ! in_array($value, $targets) ) { |
|
| 380 | + $value = ''; |
|
| 381 | + } |
|
| 374 | 382 | break; |
| 375 | 383 | } |
| 376 | 384 | |
| 377 | - if ( 'raw' == $context ) |
|
| 378 | - return $value; |
|
| 385 | + if ( 'raw' == $context ) { |
|
| 386 | + return $value; |
|
| 387 | + } |
|
| 379 | 388 | |
| 380 | 389 | if ( 'edit' == $context ) { |
| 381 | 390 | /** This filter is documented in wp-includes/post.php */ |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * |
| 38 | 38 | * @since 2.0.0 |
| 39 | 39 | * |
| 40 | - * @return true Always returns True |
|
| 40 | + * @return boolean Always returns True |
|
| 41 | 41 | */ |
| 42 | 42 | function wp_cache_close() { |
| 43 | 43 | return true; |
@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | * |
| 484 | 484 | * @since 2.0.0 |
| 485 | 485 | * |
| 486 | - * @return true Always returns true |
|
| 486 | + * @return boolean Always returns true |
|
| 487 | 487 | */ |
| 488 | 488 | public function flush() { |
| 489 | 489 | $this->cache = array(); |
@@ -623,7 +623,7 @@ discard block |
||
| 623 | 623 | * @param mixed $data The contents to store in the cache |
| 624 | 624 | * @param string $group Where to group the cache contents |
| 625 | 625 | * @param int $expire Not Used |
| 626 | - * @return true Always returns true |
|
| 626 | + * @return boolean Always returns true |
|
| 627 | 627 | */ |
| 628 | 628 | public function set( $key, $data, $group = 'default', $expire = 0 ) { |
| 629 | 629 | if ( empty( $group ) ) |
@@ -715,7 +715,7 @@ discard block |
||
| 715 | 715 | * |
| 716 | 716 | * @since 2.0.8 |
| 717 | 717 | * |
| 718 | - * @return true True value. Won't be used by PHP |
|
| 718 | + * @return boolean True value. Won't be used by PHP |
|
| 719 | 719 | */ |
| 720 | 720 | public function __destruct() { |
| 721 | 721 | return true; |
@@ -692,7 +692,7 @@ |
||
| 692 | 692 | * |
| 693 | 693 | * @since 2.0.8 |
| 694 | 694 | * |
| 695 | - * @global int $blog_id |
|
| 695 | + * @global int $blog_id |
|
| 696 | 696 | */ |
| 697 | 697 | public function __construct() { |
| 698 | 698 | global $blog_id; |
@@ -21,10 +21,10 @@ discard block |
||
| 21 | 21 | * @param int $expire When the cache data should be expired |
| 22 | 22 | * @return bool False if cache key and group already exist, true on success |
| 23 | 23 | */ |
| 24 | -function wp_cache_add( $key, $data, $group = '', $expire = 0 ) { |
|
| 24 | +function wp_cache_add($key, $data, $group = '', $expire = 0) { |
|
| 25 | 25 | global $wp_object_cache; |
| 26 | 26 | |
| 27 | - return $wp_object_cache->add( $key, $data, $group, (int) $expire ); |
|
| 27 | + return $wp_object_cache->add($key, $data, $group, (int) $expire); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -55,10 +55,10 @@ discard block |
||
| 55 | 55 | * @param string $group The group the key is in. |
| 56 | 56 | * @return false|int False on failure, the item's new value on success. |
| 57 | 57 | */ |
| 58 | -function wp_cache_decr( $key, $offset = 1, $group = '' ) { |
|
| 58 | +function wp_cache_decr($key, $offset = 1, $group = '') { |
|
| 59 | 59 | global $wp_object_cache; |
| 60 | 60 | |
| 61 | - return $wp_object_cache->decr( $key, $offset, $group ); |
|
| 61 | + return $wp_object_cache->decr($key, $offset, $group); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -107,10 +107,10 @@ discard block |
||
| 107 | 107 | * @return bool|mixed False on failure to retrieve contents or the cache |
| 108 | 108 | * contents on success |
| 109 | 109 | */ |
| 110 | -function wp_cache_get( $key, $group = '', $force = false, &$found = null ) { |
|
| 110 | +function wp_cache_get($key, $group = '', $force = false, &$found = null) { |
|
| 111 | 111 | global $wp_object_cache; |
| 112 | 112 | |
| 113 | - return $wp_object_cache->get( $key, $group, $force, $found ); |
|
| 113 | + return $wp_object_cache->get($key, $group, $force, $found); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -125,10 +125,10 @@ discard block |
||
| 125 | 125 | * @param string $group The group the key is in. |
| 126 | 126 | * @return false|int False on failure, the item's new value on success. |
| 127 | 127 | */ |
| 128 | -function wp_cache_incr( $key, $offset = 1, $group = '' ) { |
|
| 128 | +function wp_cache_incr($key, $offset = 1, $group = '') { |
|
| 129 | 129 | global $wp_object_cache; |
| 130 | 130 | |
| 131 | - return $wp_object_cache->incr( $key, $offset, $group ); |
|
| 131 | + return $wp_object_cache->incr($key, $offset, $group); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -155,10 +155,10 @@ discard block |
||
| 155 | 155 | * @param int $expire When to expire the cache contents |
| 156 | 156 | * @return bool False if not exists, true if contents were replaced |
| 157 | 157 | */ |
| 158 | -function wp_cache_replace( $key, $data, $group = '', $expire = 0 ) { |
|
| 158 | +function wp_cache_replace($key, $data, $group = '', $expire = 0) { |
|
| 159 | 159 | global $wp_object_cache; |
| 160 | 160 | |
| 161 | - return $wp_object_cache->replace( $key, $data, $group, (int) $expire ); |
|
| 161 | + return $wp_object_cache->replace($key, $data, $group, (int) $expire); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -174,10 +174,10 @@ discard block |
||
| 174 | 174 | * @param int $expire When to expire the cache contents |
| 175 | 175 | * @return bool False on failure, true on success |
| 176 | 176 | */ |
| 177 | -function wp_cache_set( $key, $data, $group = '', $expire = 0 ) { |
|
| 177 | +function wp_cache_set($key, $data, $group = '', $expire = 0) { |
|
| 178 | 178 | global $wp_object_cache; |
| 179 | 179 | |
| 180 | - return $wp_object_cache->set( $key, $data, $group, (int) $expire ); |
|
| 180 | + return $wp_object_cache->set($key, $data, $group, (int) $expire); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /** |
@@ -191,10 +191,10 @@ discard block |
||
| 191 | 191 | * |
| 192 | 192 | * @param int $blog_id Blog ID |
| 193 | 193 | */ |
| 194 | -function wp_cache_switch_to_blog( $blog_id ) { |
|
| 194 | +function wp_cache_switch_to_blog($blog_id) { |
|
| 195 | 195 | global $wp_object_cache; |
| 196 | 196 | |
| 197 | - $wp_object_cache->switch_to_blog( $blog_id ); |
|
| 197 | + $wp_object_cache->switch_to_blog($blog_id); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | /** |
@@ -206,10 +206,10 @@ discard block |
||
| 206 | 206 | * |
| 207 | 207 | * @param string|array $groups A group or an array of groups to add |
| 208 | 208 | */ |
| 209 | -function wp_cache_add_global_groups( $groups ) { |
|
| 209 | +function wp_cache_add_global_groups($groups) { |
|
| 210 | 210 | global $wp_object_cache; |
| 211 | 211 | |
| 212 | - $wp_object_cache->add_global_groups( $groups ); |
|
| 212 | + $wp_object_cache->add_global_groups($groups); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | * |
| 220 | 220 | * @param string|array $groups A group or an array of groups to add |
| 221 | 221 | */ |
| 222 | -function wp_cache_add_non_persistent_groups( $groups ) { |
|
| 222 | +function wp_cache_add_non_persistent_groups($groups) { |
|
| 223 | 223 | // Default cache doesn't persist so nothing to do here. |
| 224 | 224 | } |
| 225 | 225 | |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | * @global WP_Object_Cache $wp_object_cache |
| 242 | 242 | */ |
| 243 | 243 | function wp_cache_reset() { |
| 244 | - _deprecated_function( __FUNCTION__, '3.5' ); |
|
| 244 | + _deprecated_function(__FUNCTION__, '3.5'); |
|
| 245 | 245 | |
| 246 | 246 | global $wp_object_cache; |
| 247 | 247 | |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | * @param string $name Property to get. |
| 330 | 330 | * @return mixed Property. |
| 331 | 331 | */ |
| 332 | - public function __get( $name ) { |
|
| 332 | + public function __get($name) { |
|
| 333 | 333 | return $this->$name; |
| 334 | 334 | } |
| 335 | 335 | |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | * @param mixed $value Property value. |
| 344 | 344 | * @return mixed Newly-set property. |
| 345 | 345 | */ |
| 346 | - public function __set( $name, $value ) { |
|
| 346 | + public function __set($name, $value) { |
|
| 347 | 347 | return $this->$name = $value; |
| 348 | 348 | } |
| 349 | 349 | |
@@ -356,8 +356,8 @@ discard block |
||
| 356 | 356 | * @param string $name Property to check if set. |
| 357 | 357 | * @return bool Whether the property is set. |
| 358 | 358 | */ |
| 359 | - public function __isset( $name ) { |
|
| 360 | - return isset( $this->$name ); |
|
| 359 | + public function __isset($name) { |
|
| 360 | + return isset($this->$name); |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | /** |
@@ -368,8 +368,8 @@ discard block |
||
| 368 | 368 | * |
| 369 | 369 | * @param string $name Property to unset. |
| 370 | 370 | */ |
| 371 | - public function __unset( $name ) { |
|
| 372 | - unset( $this->$name ); |
|
| 371 | + public function __unset($name) { |
|
| 372 | + unset($this->$name); |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | /** |
@@ -387,21 +387,21 @@ discard block |
||
| 387 | 387 | * @param int $expire When to expire the cache contents |
| 388 | 388 | * @return bool False if cache key and group already exist, true on success |
| 389 | 389 | */ |
| 390 | - public function add( $key, $data, $group = 'default', $expire = 0 ) { |
|
| 391 | - if ( wp_suspend_cache_addition() ) |
|
| 390 | + public function add($key, $data, $group = 'default', $expire = 0) { |
|
| 391 | + if (wp_suspend_cache_addition()) |
|
| 392 | 392 | return false; |
| 393 | 393 | |
| 394 | - if ( empty( $group ) ) |
|
| 394 | + if (empty($group)) |
|
| 395 | 395 | $group = 'default'; |
| 396 | 396 | |
| 397 | 397 | $id = $key; |
| 398 | - if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) |
|
| 399 | - $id = $this->blog_prefix . $key; |
|
| 398 | + if ($this->multisite && ! isset($this->global_groups[$group])) |
|
| 399 | + $id = $this->blog_prefix.$key; |
|
| 400 | 400 | |
| 401 | - if ( $this->_exists( $id, $group ) ) |
|
| 401 | + if ($this->_exists($id, $group)) |
|
| 402 | 402 | return false; |
| 403 | 403 | |
| 404 | - return $this->set( $key, $data, $group, (int) $expire ); |
|
| 404 | + return $this->set($key, $data, $group, (int) $expire); |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | /** |
@@ -411,11 +411,11 @@ discard block |
||
| 411 | 411 | * |
| 412 | 412 | * @param array $groups List of groups that are global. |
| 413 | 413 | */ |
| 414 | - public function add_global_groups( $groups ) { |
|
| 414 | + public function add_global_groups($groups) { |
|
| 415 | 415 | $groups = (array) $groups; |
| 416 | 416 | |
| 417 | - $groups = array_fill_keys( $groups, true ); |
|
| 418 | - $this->global_groups = array_merge( $this->global_groups, $groups ); |
|
| 417 | + $groups = array_fill_keys($groups, true); |
|
| 418 | + $this->global_groups = array_merge($this->global_groups, $groups); |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | /** |
@@ -428,27 +428,27 @@ discard block |
||
| 428 | 428 | * @param string $group The group the key is in. |
| 429 | 429 | * @return false|int False on failure, the item's new value on success. |
| 430 | 430 | */ |
| 431 | - public function decr( $key, $offset = 1, $group = 'default' ) { |
|
| 432 | - if ( empty( $group ) ) |
|
| 431 | + public function decr($key, $offset = 1, $group = 'default') { |
|
| 432 | + if (empty($group)) |
|
| 433 | 433 | $group = 'default'; |
| 434 | 434 | |
| 435 | - if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) |
|
| 436 | - $key = $this->blog_prefix . $key; |
|
| 435 | + if ($this->multisite && ! isset($this->global_groups[$group])) |
|
| 436 | + $key = $this->blog_prefix.$key; |
|
| 437 | 437 | |
| 438 | - if ( ! $this->_exists( $key, $group ) ) |
|
| 438 | + if ( ! $this->_exists($key, $group)) |
|
| 439 | 439 | return false; |
| 440 | 440 | |
| 441 | - if ( ! is_numeric( $this->cache[ $group ][ $key ] ) ) |
|
| 442 | - $this->cache[ $group ][ $key ] = 0; |
|
| 441 | + if ( ! is_numeric($this->cache[$group][$key])) |
|
| 442 | + $this->cache[$group][$key] = 0; |
|
| 443 | 443 | |
| 444 | 444 | $offset = (int) $offset; |
| 445 | 445 | |
| 446 | - $this->cache[ $group ][ $key ] -= $offset; |
|
| 446 | + $this->cache[$group][$key] -= $offset; |
|
| 447 | 447 | |
| 448 | - if ( $this->cache[ $group ][ $key ] < 0 ) |
|
| 449 | - $this->cache[ $group ][ $key ] = 0; |
|
| 448 | + if ($this->cache[$group][$key] < 0) |
|
| 449 | + $this->cache[$group][$key] = 0; |
|
| 450 | 450 | |
| 451 | - return $this->cache[ $group ][ $key ]; |
|
| 451 | + return $this->cache[$group][$key]; |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | /** |
@@ -464,17 +464,17 @@ discard block |
||
| 464 | 464 | * |
| 465 | 465 | * @return bool False if the contents weren't deleted and true on success |
| 466 | 466 | */ |
| 467 | - public function delete( $key, $group = 'default', $deprecated = false ) { |
|
| 468 | - if ( empty( $group ) ) |
|
| 467 | + public function delete($key, $group = 'default', $deprecated = false) { |
|
| 468 | + if (empty($group)) |
|
| 469 | 469 | $group = 'default'; |
| 470 | 470 | |
| 471 | - if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) |
|
| 472 | - $key = $this->blog_prefix . $key; |
|
| 471 | + if ($this->multisite && ! isset($this->global_groups[$group])) |
|
| 472 | + $key = $this->blog_prefix.$key; |
|
| 473 | 473 | |
| 474 | - if ( ! $this->_exists( $key, $group ) ) |
|
| 474 | + if ( ! $this->_exists($key, $group)) |
|
| 475 | 475 | return false; |
| 476 | 476 | |
| 477 | - unset( $this->cache[$group][$key] ); |
|
| 477 | + unset($this->cache[$group][$key]); |
|
| 478 | 478 | return true; |
| 479 | 479 | } |
| 480 | 480 | |
@@ -508,17 +508,17 @@ discard block |
||
| 508 | 508 | * @return false|mixed False on failure to retrieve contents or the cache |
| 509 | 509 | * contents on success |
| 510 | 510 | */ |
| 511 | - public function get( $key, $group = 'default', $force = false, &$found = null ) { |
|
| 512 | - if ( empty( $group ) ) |
|
| 511 | + public function get($key, $group = 'default', $force = false, &$found = null) { |
|
| 512 | + if (empty($group)) |
|
| 513 | 513 | $group = 'default'; |
| 514 | 514 | |
| 515 | - if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) |
|
| 516 | - $key = $this->blog_prefix . $key; |
|
| 515 | + if ($this->multisite && ! isset($this->global_groups[$group])) |
|
| 516 | + $key = $this->blog_prefix.$key; |
|
| 517 | 517 | |
| 518 | - if ( $this->_exists( $key, $group ) ) { |
|
| 518 | + if ($this->_exists($key, $group)) { |
|
| 519 | 519 | $found = true; |
| 520 | 520 | $this->cache_hits += 1; |
| 521 | - if ( is_object($this->cache[$group][$key]) ) |
|
| 521 | + if (is_object($this->cache[$group][$key])) |
|
| 522 | 522 | return clone $this->cache[$group][$key]; |
| 523 | 523 | else |
| 524 | 524 | return $this->cache[$group][$key]; |
@@ -539,27 +539,27 @@ discard block |
||
| 539 | 539 | * @param string $group The group the key is in. |
| 540 | 540 | * @return false|int False on failure, the item's new value on success. |
| 541 | 541 | */ |
| 542 | - public function incr( $key, $offset = 1, $group = 'default' ) { |
|
| 543 | - if ( empty( $group ) ) |
|
| 542 | + public function incr($key, $offset = 1, $group = 'default') { |
|
| 543 | + if (empty($group)) |
|
| 544 | 544 | $group = 'default'; |
| 545 | 545 | |
| 546 | - if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) |
|
| 547 | - $key = $this->blog_prefix . $key; |
|
| 546 | + if ($this->multisite && ! isset($this->global_groups[$group])) |
|
| 547 | + $key = $this->blog_prefix.$key; |
|
| 548 | 548 | |
| 549 | - if ( ! $this->_exists( $key, $group ) ) |
|
| 549 | + if ( ! $this->_exists($key, $group)) |
|
| 550 | 550 | return false; |
| 551 | 551 | |
| 552 | - if ( ! is_numeric( $this->cache[ $group ][ $key ] ) ) |
|
| 553 | - $this->cache[ $group ][ $key ] = 0; |
|
| 552 | + if ( ! is_numeric($this->cache[$group][$key])) |
|
| 553 | + $this->cache[$group][$key] = 0; |
|
| 554 | 554 | |
| 555 | 555 | $offset = (int) $offset; |
| 556 | 556 | |
| 557 | - $this->cache[ $group ][ $key ] += $offset; |
|
| 557 | + $this->cache[$group][$key] += $offset; |
|
| 558 | 558 | |
| 559 | - if ( $this->cache[ $group ][ $key ] < 0 ) |
|
| 560 | - $this->cache[ $group ][ $key ] = 0; |
|
| 559 | + if ($this->cache[$group][$key] < 0) |
|
| 560 | + $this->cache[$group][$key] = 0; |
|
| 561 | 561 | |
| 562 | - return $this->cache[ $group ][ $key ]; |
|
| 562 | + return $this->cache[$group][$key]; |
|
| 563 | 563 | } |
| 564 | 564 | |
| 565 | 565 | /** |
@@ -574,18 +574,18 @@ discard block |
||
| 574 | 574 | * @param int $expire When to expire the cache contents |
| 575 | 575 | * @return bool False if not exists, true if contents were replaced |
| 576 | 576 | */ |
| 577 | - public function replace( $key, $data, $group = 'default', $expire = 0 ) { |
|
| 578 | - if ( empty( $group ) ) |
|
| 577 | + public function replace($key, $data, $group = 'default', $expire = 0) { |
|
| 578 | + if (empty($group)) |
|
| 579 | 579 | $group = 'default'; |
| 580 | 580 | |
| 581 | 581 | $id = $key; |
| 582 | - if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) |
|
| 583 | - $id = $this->blog_prefix . $key; |
|
| 582 | + if ($this->multisite && ! isset($this->global_groups[$group])) |
|
| 583 | + $id = $this->blog_prefix.$key; |
|
| 584 | 584 | |
| 585 | - if ( ! $this->_exists( $id, $group ) ) |
|
| 585 | + if ( ! $this->_exists($id, $group)) |
|
| 586 | 586 | return false; |
| 587 | 587 | |
| 588 | - return $this->set( $key, $data, $group, (int) $expire ); |
|
| 588 | + return $this->set($key, $data, $group, (int) $expire); |
|
| 589 | 589 | } |
| 590 | 590 | |
| 591 | 591 | /** |
@@ -596,12 +596,12 @@ discard block |
||
| 596 | 596 | * @see switch_to_blog() |
| 597 | 597 | */ |
| 598 | 598 | public function reset() { |
| 599 | - _deprecated_function( __FUNCTION__, '3.5', 'switch_to_blog()' ); |
|
| 599 | + _deprecated_function(__FUNCTION__, '3.5', 'switch_to_blog()'); |
|
| 600 | 600 | |
| 601 | 601 | // Clear out non-global caches since the blog ID has changed. |
| 602 | - foreach ( array_keys( $this->cache ) as $group ) { |
|
| 603 | - if ( ! isset( $this->global_groups[ $group ] ) ) |
|
| 604 | - unset( $this->cache[ $group ] ); |
|
| 602 | + foreach (array_keys($this->cache) as $group) { |
|
| 603 | + if ( ! isset($this->global_groups[$group])) |
|
| 604 | + unset($this->cache[$group]); |
|
| 605 | 605 | } |
| 606 | 606 | } |
| 607 | 607 | |
@@ -625,14 +625,14 @@ discard block |
||
| 625 | 625 | * @param int $expire Not Used |
| 626 | 626 | * @return true Always returns true |
| 627 | 627 | */ |
| 628 | - public function set( $key, $data, $group = 'default', $expire = 0 ) { |
|
| 629 | - if ( empty( $group ) ) |
|
| 628 | + public function set($key, $data, $group = 'default', $expire = 0) { |
|
| 629 | + if (empty($group)) |
|
| 630 | 630 | $group = 'default'; |
| 631 | 631 | |
| 632 | - if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) |
|
| 633 | - $key = $this->blog_prefix . $key; |
|
| 632 | + if ($this->multisite && ! isset($this->global_groups[$group])) |
|
| 633 | + $key = $this->blog_prefix.$key; |
|
| 634 | 634 | |
| 635 | - if ( is_object( $data ) ) |
|
| 635 | + if (is_object($data)) |
|
| 636 | 636 | $data = clone $data; |
| 637 | 637 | |
| 638 | 638 | $this->cache[$group][$key] = $data; |
@@ -654,7 +654,7 @@ discard block |
||
| 654 | 654 | echo "</p>"; |
| 655 | 655 | echo '<ul>'; |
| 656 | 656 | foreach ($this->cache as $group => $cache) { |
| 657 | - echo "<li><strong>Group:</strong> $group - ( " . number_format( strlen( serialize( $cache ) ) / 1024, 2 ) . 'k )</li>'; |
|
| 657 | + echo "<li><strong>Group:</strong> $group - ( ".number_format(strlen(serialize($cache)) / 1024, 2).'k )</li>'; |
|
| 658 | 658 | } |
| 659 | 659 | echo '</ul>'; |
| 660 | 660 | } |
@@ -668,9 +668,9 @@ discard block |
||
| 668 | 668 | * |
| 669 | 669 | * @param int $blog_id Blog ID |
| 670 | 670 | */ |
| 671 | - public function switch_to_blog( $blog_id ) { |
|
| 671 | + public function switch_to_blog($blog_id) { |
|
| 672 | 672 | $blog_id = (int) $blog_id; |
| 673 | - $this->blog_prefix = $this->multisite ? $blog_id . ':' : ''; |
|
| 673 | + $this->blog_prefix = $this->multisite ? $blog_id.':' : ''; |
|
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | /** |
@@ -683,8 +683,8 @@ discard block |
||
| 683 | 683 | * @param string $group |
| 684 | 684 | * @return bool |
| 685 | 685 | */ |
| 686 | - protected function _exists( $key, $group ) { |
|
| 687 | - return isset( $this->cache[ $group ] ) && ( isset( $this->cache[ $group ][ $key ] ) || array_key_exists( $key, $this->cache[ $group ] ) ); |
|
| 686 | + protected function _exists($key, $group) { |
|
| 687 | + return isset($this->cache[$group]) && (isset($this->cache[$group][$key]) || array_key_exists($key, $this->cache[$group])); |
|
| 688 | 688 | } |
| 689 | 689 | |
| 690 | 690 | /** |
@@ -698,14 +698,14 @@ discard block |
||
| 698 | 698 | global $blog_id; |
| 699 | 699 | |
| 700 | 700 | $this->multisite = is_multisite(); |
| 701 | - $this->blog_prefix = $this->multisite ? $blog_id . ':' : ''; |
|
| 701 | + $this->blog_prefix = $this->multisite ? $blog_id.':' : ''; |
|
| 702 | 702 | |
| 703 | 703 | |
| 704 | 704 | /** |
| 705 | 705 | * @todo This should be moved to the PHP4 style constructor, PHP5 |
| 706 | 706 | * already calls __destruct() |
| 707 | 707 | */ |
| 708 | - register_shutdown_function( array( $this, '__destruct' ) ); |
|
| 708 | + register_shutdown_function(array($this, '__destruct')); |
|
| 709 | 709 | } |
| 710 | 710 | |
| 711 | 711 | /** |
@@ -388,18 +388,22 @@ discard block |
||
| 388 | 388 | * @return bool False if cache key and group already exist, true on success |
| 389 | 389 | */ |
| 390 | 390 | public function add( $key, $data, $group = 'default', $expire = 0 ) { |
| 391 | - if ( wp_suspend_cache_addition() ) |
|
| 392 | - return false; |
|
| 391 | + if ( wp_suspend_cache_addition() ) { |
|
| 392 | + return false; |
|
| 393 | + } |
|
| 393 | 394 | |
| 394 | - if ( empty( $group ) ) |
|
| 395 | - $group = 'default'; |
|
| 395 | + if ( empty( $group ) ) { |
|
| 396 | + $group = 'default'; |
|
| 397 | + } |
|
| 396 | 398 | |
| 397 | 399 | $id = $key; |
| 398 | - if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) |
|
| 399 | - $id = $this->blog_prefix . $key; |
|
| 400 | + if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) { |
|
| 401 | + $id = $this->blog_prefix . $key; |
|
| 402 | + } |
|
| 400 | 403 | |
| 401 | - if ( $this->_exists( $id, $group ) ) |
|
| 402 | - return false; |
|
| 404 | + if ( $this->_exists( $id, $group ) ) { |
|
| 405 | + return false; |
|
| 406 | + } |
|
| 403 | 407 | |
| 404 | 408 | return $this->set( $key, $data, $group, (int) $expire ); |
| 405 | 409 | } |
@@ -429,24 +433,29 @@ discard block |
||
| 429 | 433 | * @return false|int False on failure, the item's new value on success. |
| 430 | 434 | */ |
| 431 | 435 | public function decr( $key, $offset = 1, $group = 'default' ) { |
| 432 | - if ( empty( $group ) ) |
|
| 433 | - $group = 'default'; |
|
| 436 | + if ( empty( $group ) ) { |
|
| 437 | + $group = 'default'; |
|
| 438 | + } |
|
| 434 | 439 | |
| 435 | - if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) |
|
| 436 | - $key = $this->blog_prefix . $key; |
|
| 440 | + if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) { |
|
| 441 | + $key = $this->blog_prefix . $key; |
|
| 442 | + } |
|
| 437 | 443 | |
| 438 | - if ( ! $this->_exists( $key, $group ) ) |
|
| 439 | - return false; |
|
| 444 | + if ( ! $this->_exists( $key, $group ) ) { |
|
| 445 | + return false; |
|
| 446 | + } |
|
| 440 | 447 | |
| 441 | - if ( ! is_numeric( $this->cache[ $group ][ $key ] ) ) |
|
| 442 | - $this->cache[ $group ][ $key ] = 0; |
|
| 448 | + if ( ! is_numeric( $this->cache[ $group ][ $key ] ) ) { |
|
| 449 | + $this->cache[ $group ][ $key ] = 0; |
|
| 450 | + } |
|
| 443 | 451 | |
| 444 | 452 | $offset = (int) $offset; |
| 445 | 453 | |
| 446 | 454 | $this->cache[ $group ][ $key ] -= $offset; |
| 447 | 455 | |
| 448 | - if ( $this->cache[ $group ][ $key ] < 0 ) |
|
| 449 | - $this->cache[ $group ][ $key ] = 0; |
|
| 456 | + if ( $this->cache[ $group ][ $key ] < 0 ) { |
|
| 457 | + $this->cache[ $group ][ $key ] = 0; |
|
| 458 | + } |
|
| 450 | 459 | |
| 451 | 460 | return $this->cache[ $group ][ $key ]; |
| 452 | 461 | } |
@@ -465,14 +474,17 @@ discard block |
||
| 465 | 474 | * @return bool False if the contents weren't deleted and true on success |
| 466 | 475 | */ |
| 467 | 476 | public function delete( $key, $group = 'default', $deprecated = false ) { |
| 468 | - if ( empty( $group ) ) |
|
| 469 | - $group = 'default'; |
|
| 477 | + if ( empty( $group ) ) { |
|
| 478 | + $group = 'default'; |
|
| 479 | + } |
|
| 470 | 480 | |
| 471 | - if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) |
|
| 472 | - $key = $this->blog_prefix . $key; |
|
| 481 | + if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) { |
|
| 482 | + $key = $this->blog_prefix . $key; |
|
| 483 | + } |
|
| 473 | 484 | |
| 474 | - if ( ! $this->_exists( $key, $group ) ) |
|
| 475 | - return false; |
|
| 485 | + if ( ! $this->_exists( $key, $group ) ) { |
|
| 486 | + return false; |
|
| 487 | + } |
|
| 476 | 488 | |
| 477 | 489 | unset( $this->cache[$group][$key] ); |
| 478 | 490 | return true; |
@@ -509,19 +521,22 @@ discard block |
||
| 509 | 521 | * contents on success |
| 510 | 522 | */ |
| 511 | 523 | public function get( $key, $group = 'default', $force = false, &$found = null ) { |
| 512 | - if ( empty( $group ) ) |
|
| 513 | - $group = 'default'; |
|
| 524 | + if ( empty( $group ) ) { |
|
| 525 | + $group = 'default'; |
|
| 526 | + } |
|
| 514 | 527 | |
| 515 | - if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) |
|
| 516 | - $key = $this->blog_prefix . $key; |
|
| 528 | + if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) { |
|
| 529 | + $key = $this->blog_prefix . $key; |
|
| 530 | + } |
|
| 517 | 531 | |
| 518 | 532 | if ( $this->_exists( $key, $group ) ) { |
| 519 | 533 | $found = true; |
| 520 | 534 | $this->cache_hits += 1; |
| 521 | - if ( is_object($this->cache[$group][$key]) ) |
|
| 522 | - return clone $this->cache[$group][$key]; |
|
| 523 | - else |
|
| 524 | - return $this->cache[$group][$key]; |
|
| 535 | + if ( is_object($this->cache[$group][$key]) ) { |
|
| 536 | + return clone $this->cache[$group][$key]; |
|
| 537 | + } else { |
|
| 538 | + return $this->cache[$group][$key]; |
|
| 539 | + } |
|
| 525 | 540 | } |
| 526 | 541 | |
| 527 | 542 | $found = false; |
@@ -540,24 +555,29 @@ discard block |
||
| 540 | 555 | * @return false|int False on failure, the item's new value on success. |
| 541 | 556 | */ |
| 542 | 557 | public function incr( $key, $offset = 1, $group = 'default' ) { |
| 543 | - if ( empty( $group ) ) |
|
| 544 | - $group = 'default'; |
|
| 558 | + if ( empty( $group ) ) { |
|
| 559 | + $group = 'default'; |
|
| 560 | + } |
|
| 545 | 561 | |
| 546 | - if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) |
|
| 547 | - $key = $this->blog_prefix . $key; |
|
| 562 | + if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) { |
|
| 563 | + $key = $this->blog_prefix . $key; |
|
| 564 | + } |
|
| 548 | 565 | |
| 549 | - if ( ! $this->_exists( $key, $group ) ) |
|
| 550 | - return false; |
|
| 566 | + if ( ! $this->_exists( $key, $group ) ) { |
|
| 567 | + return false; |
|
| 568 | + } |
|
| 551 | 569 | |
| 552 | - if ( ! is_numeric( $this->cache[ $group ][ $key ] ) ) |
|
| 553 | - $this->cache[ $group ][ $key ] = 0; |
|
| 570 | + if ( ! is_numeric( $this->cache[ $group ][ $key ] ) ) { |
|
| 571 | + $this->cache[ $group ][ $key ] = 0; |
|
| 572 | + } |
|
| 554 | 573 | |
| 555 | 574 | $offset = (int) $offset; |
| 556 | 575 | |
| 557 | 576 | $this->cache[ $group ][ $key ] += $offset; |
| 558 | 577 | |
| 559 | - if ( $this->cache[ $group ][ $key ] < 0 ) |
|
| 560 | - $this->cache[ $group ][ $key ] = 0; |
|
| 578 | + if ( $this->cache[ $group ][ $key ] < 0 ) { |
|
| 579 | + $this->cache[ $group ][ $key ] = 0; |
|
| 580 | + } |
|
| 561 | 581 | |
| 562 | 582 | return $this->cache[ $group ][ $key ]; |
| 563 | 583 | } |
@@ -575,15 +595,18 @@ discard block |
||
| 575 | 595 | * @return bool False if not exists, true if contents were replaced |
| 576 | 596 | */ |
| 577 | 597 | public function replace( $key, $data, $group = 'default', $expire = 0 ) { |
| 578 | - if ( empty( $group ) ) |
|
| 579 | - $group = 'default'; |
|
| 598 | + if ( empty( $group ) ) { |
|
| 599 | + $group = 'default'; |
|
| 600 | + } |
|
| 580 | 601 | |
| 581 | 602 | $id = $key; |
| 582 | - if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) |
|
| 583 | - $id = $this->blog_prefix . $key; |
|
| 603 | + if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) { |
|
| 604 | + $id = $this->blog_prefix . $key; |
|
| 605 | + } |
|
| 584 | 606 | |
| 585 | - if ( ! $this->_exists( $id, $group ) ) |
|
| 586 | - return false; |
|
| 607 | + if ( ! $this->_exists( $id, $group ) ) { |
|
| 608 | + return false; |
|
| 609 | + } |
|
| 587 | 610 | |
| 588 | 611 | return $this->set( $key, $data, $group, (int) $expire ); |
| 589 | 612 | } |
@@ -600,8 +623,9 @@ discard block |
||
| 600 | 623 | |
| 601 | 624 | // Clear out non-global caches since the blog ID has changed. |
| 602 | 625 | foreach ( array_keys( $this->cache ) as $group ) { |
| 603 | - if ( ! isset( $this->global_groups[ $group ] ) ) |
|
| 604 | - unset( $this->cache[ $group ] ); |
|
| 626 | + if ( ! isset( $this->global_groups[ $group ] ) ) { |
|
| 627 | + unset( $this->cache[ $group ] ); |
|
| 628 | + } |
|
| 605 | 629 | } |
| 606 | 630 | } |
| 607 | 631 | |
@@ -626,14 +650,17 @@ discard block |
||
| 626 | 650 | * @return true Always returns true |
| 627 | 651 | */ |
| 628 | 652 | public function set( $key, $data, $group = 'default', $expire = 0 ) { |
| 629 | - if ( empty( $group ) ) |
|
| 630 | - $group = 'default'; |
|
| 653 | + if ( empty( $group ) ) { |
|
| 654 | + $group = 'default'; |
|
| 655 | + } |
|
| 631 | 656 | |
| 632 | - if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) |
|
| 633 | - $key = $this->blog_prefix . $key; |
|
| 657 | + if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) { |
|
| 658 | + $key = $this->blog_prefix . $key; |
|
| 659 | + } |
|
| 634 | 660 | |
| 635 | - if ( is_object( $data ) ) |
|
| 636 | - $data = clone $data; |
|
| 661 | + if ( is_object( $data ) ) { |
|
| 662 | + $data = clone $data; |
|
| 663 | + } |
|
| 637 | 664 | |
| 638 | 665 | $this->cache[$group][$key] = $data; |
| 639 | 666 | return true; |