Coding Standards: Fix WPCS issues in `wp-admin/includes/misc.php`.
* Use strict comparison in various conditions. * Fix a `Variable "$system_webServer_node" is not in valid snake_case format` WPCS warning. Includes minor code layout fixes for better readability. Follow-up to [10607], [11350], [22253], [26137]. Props azouamauriac, SergeyBiryukov. See #54728. Built from https://develop.svn.wordpress.org/trunk@52721 git-svn-id: http://core.svn.wordpress.org/trunk@52310 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
77b1aa0cf3
commit
556d42ac71
|
@ -74,16 +74,20 @@ function extract_from_markers( $filename, $marker ) {
|
||||||
$markerdata = explode( "\n", implode( '', file( $filename ) ) );
|
$markerdata = explode( "\n", implode( '', file( $filename ) ) );
|
||||||
|
|
||||||
$state = false;
|
$state = false;
|
||||||
|
|
||||||
foreach ( $markerdata as $markerline ) {
|
foreach ( $markerdata as $markerline ) {
|
||||||
if ( false !== strpos( $markerline, '# END ' . $marker ) ) {
|
if ( false !== strpos( $markerline, '# END ' . $marker ) ) {
|
||||||
$state = false;
|
$state = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $state ) {
|
if ( $state ) {
|
||||||
if ( '#' === substr( $markerline, 0, 1 ) ) {
|
if ( '#' === substr( $markerline, 0, 1 ) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result[] = $markerline;
|
$result[] = $markerline;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( false !== strpos( $markerline, '# BEGIN ' . $marker ) ) {
|
if ( false !== strpos( $markerline, '# BEGIN ' . $marker ) ) {
|
||||||
$state = true;
|
$state = true;
|
||||||
}
|
}
|
||||||
|
@ -118,6 +122,7 @@ function insert_with_markers( $filename, $marker, $insertion ) {
|
||||||
|
|
||||||
// Make sure the file is created with a minimum set of permissions.
|
// Make sure the file is created with a minimum set of permissions.
|
||||||
$perms = fileperms( $filename );
|
$perms = fileperms( $filename );
|
||||||
|
|
||||||
if ( $perms ) {
|
if ( $perms ) {
|
||||||
chmod( $filename, $perms | 0644 );
|
chmod( $filename, $perms | 0644 );
|
||||||
}
|
}
|
||||||
|
@ -142,6 +147,7 @@ Any changes to the directives between these markers will be overwritten.'
|
||||||
);
|
);
|
||||||
|
|
||||||
$instructions = explode( "\n", $instructions );
|
$instructions = explode( "\n", $instructions );
|
||||||
|
|
||||||
foreach ( $instructions as $line => $text ) {
|
foreach ( $instructions as $line => $text ) {
|
||||||
$instructions[ $line ] = '# ' . $text;
|
$instructions[ $line ] = '# ' . $text;
|
||||||
}
|
}
|
||||||
|
@ -166,6 +172,7 @@ Any changes to the directives between these markers will be overwritten.'
|
||||||
$end_marker = "# END {$marker}";
|
$end_marker = "# END {$marker}";
|
||||||
|
|
||||||
$fp = fopen( $filename, 'r+' );
|
$fp = fopen( $filename, 'r+' );
|
||||||
|
|
||||||
if ( ! $fp ) {
|
if ( ! $fp ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -174,6 +181,7 @@ Any changes to the directives between these markers will be overwritten.'
|
||||||
flock( $fp, LOCK_EX );
|
flock( $fp, LOCK_EX );
|
||||||
|
|
||||||
$lines = array();
|
$lines = array();
|
||||||
|
|
||||||
while ( ! feof( $fp ) ) {
|
while ( ! feof( $fp ) ) {
|
||||||
$lines[] = rtrim( fgets( $fp ), "\r\n" );
|
$lines[] = rtrim( fgets( $fp ), "\r\n" );
|
||||||
}
|
}
|
||||||
|
@ -184,6 +192,7 @@ Any changes to the directives between these markers will be overwritten.'
|
||||||
$existing_lines = array();
|
$existing_lines = array();
|
||||||
$found_marker = false;
|
$found_marker = false;
|
||||||
$found_end_marker = false;
|
$found_end_marker = false;
|
||||||
|
|
||||||
foreach ( $lines as $line ) {
|
foreach ( $lines as $line ) {
|
||||||
if ( ! $found_marker && false !== strpos( $line, $start_marker ) ) {
|
if ( ! $found_marker && false !== strpos( $line, $start_marker ) ) {
|
||||||
$found_marker = true;
|
$found_marker = true;
|
||||||
|
@ -192,6 +201,7 @@ Any changes to the directives between these markers will be overwritten.'
|
||||||
$found_end_marker = true;
|
$found_end_marker = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $found_marker ) {
|
if ( ! $found_marker ) {
|
||||||
$pre_lines[] = $line;
|
$pre_lines[] = $line;
|
||||||
} elseif ( $found_marker && $found_end_marker ) {
|
} elseif ( $found_marker && $found_end_marker ) {
|
||||||
|
@ -224,9 +234,11 @@ Any changes to the directives between these markers will be overwritten.'
|
||||||
// Write to the start of the file, and truncate it to that length.
|
// Write to the start of the file, and truncate it to that length.
|
||||||
fseek( $fp, 0 );
|
fseek( $fp, 0 );
|
||||||
$bytes = fwrite( $fp, $new_file_data );
|
$bytes = fwrite( $fp, $new_file_data );
|
||||||
|
|
||||||
if ( $bytes ) {
|
if ( $bytes ) {
|
||||||
ftruncate( $fp, ftell( $fp ) );
|
ftruncate( $fp, ftell( $fp ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
fflush( $fp );
|
fflush( $fp );
|
||||||
flock( $fp, LOCK_UN );
|
flock( $fp, LOCK_UN );
|
||||||
fclose( $fp );
|
fclose( $fp );
|
||||||
|
@ -247,12 +259,12 @@ Any changes to the directives between these markers will be overwritten.'
|
||||||
* @return bool|null True on write success, false on failure. Null in multisite.
|
* @return bool|null True on write success, false on failure. Null in multisite.
|
||||||
*/
|
*/
|
||||||
function save_mod_rewrite_rules() {
|
function save_mod_rewrite_rules() {
|
||||||
|
global $wp_rewrite;
|
||||||
|
|
||||||
if ( is_multisite() ) {
|
if ( is_multisite() ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
global $wp_rewrite;
|
|
||||||
|
|
||||||
// Ensure get_home_path() is declared.
|
// Ensure get_home_path() is declared.
|
||||||
require_once ABSPATH . 'wp-admin/includes/file.php';
|
require_once ABSPATH . 'wp-admin/includes/file.php';
|
||||||
|
|
||||||
|
@ -263,9 +275,12 @@ function save_mod_rewrite_rules() {
|
||||||
* If the file doesn't already exist check for write access to the directory
|
* If the file doesn't already exist check for write access to the directory
|
||||||
* and whether we have some rules. Else check for write access to the file.
|
* and whether we have some rules. Else check for write access to the file.
|
||||||
*/
|
*/
|
||||||
if ( ( ! file_exists( $htaccess_file ) && is_writable( $home_path ) && $wp_rewrite->using_mod_rewrite_permalinks() ) || is_writable( $htaccess_file ) ) {
|
if ( ! file_exists( $htaccess_file ) && is_writable( $home_path ) && $wp_rewrite->using_mod_rewrite_permalinks()
|
||||||
|
|| is_writable( $htaccess_file )
|
||||||
|
) {
|
||||||
if ( got_mod_rewrite() ) {
|
if ( got_mod_rewrite() ) {
|
||||||
$rules = explode( "\n", $wp_rewrite->mod_rewrite_rules() );
|
$rules = explode( "\n", $wp_rewrite->mod_rewrite_rules() );
|
||||||
|
|
||||||
return insert_with_markers( $htaccess_file, 'WordPress', $rules );
|
return insert_with_markers( $htaccess_file, 'WordPress', $rules );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -284,12 +299,12 @@ function save_mod_rewrite_rules() {
|
||||||
* @return bool|null True on write success, false on failure. Null in multisite.
|
* @return bool|null True on write success, false on failure. Null in multisite.
|
||||||
*/
|
*/
|
||||||
function iis7_save_url_rewrite_rules() {
|
function iis7_save_url_rewrite_rules() {
|
||||||
|
global $wp_rewrite;
|
||||||
|
|
||||||
if ( is_multisite() ) {
|
if ( is_multisite() ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
global $wp_rewrite;
|
|
||||||
|
|
||||||
// Ensure get_home_path() is declared.
|
// Ensure get_home_path() is declared.
|
||||||
require_once ABSPATH . 'wp-admin/includes/file.php';
|
require_once ABSPATH . 'wp-admin/includes/file.php';
|
||||||
|
|
||||||
|
@ -297,14 +312,19 @@ function iis7_save_url_rewrite_rules() {
|
||||||
$web_config_file = $home_path . 'web.config';
|
$web_config_file = $home_path . 'web.config';
|
||||||
|
|
||||||
// Using win_is_writable() instead of is_writable() because of a bug in Windows PHP.
|
// Using win_is_writable() instead of is_writable() because of a bug in Windows PHP.
|
||||||
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 ) ) ) {
|
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 ) )
|
||||||
|
) {
|
||||||
$rule = $wp_rewrite->iis7_url_rewrite_rules( false );
|
$rule = $wp_rewrite->iis7_url_rewrite_rules( false );
|
||||||
|
|
||||||
if ( ! empty( $rule ) ) {
|
if ( ! empty( $rule ) ) {
|
||||||
return iis7_add_rewrite_rule( $web_config_file, $rule );
|
return iis7_add_rewrite_rule( $web_config_file, $rule );
|
||||||
} else {
|
} else {
|
||||||
return iis7_delete_rewrite_rule( $web_config_file );
|
return iis7_delete_rewrite_rule( $web_config_file );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,17 +337,20 @@ function iis7_save_url_rewrite_rules() {
|
||||||
*/
|
*/
|
||||||
function update_recently_edited( $file ) {
|
function update_recently_edited( $file ) {
|
||||||
$oldfiles = (array) get_option( 'recently_edited' );
|
$oldfiles = (array) get_option( 'recently_edited' );
|
||||||
|
|
||||||
if ( $oldfiles ) {
|
if ( $oldfiles ) {
|
||||||
$oldfiles = array_reverse( $oldfiles );
|
$oldfiles = array_reverse( $oldfiles );
|
||||||
$oldfiles[] = $file;
|
$oldfiles[] = $file;
|
||||||
$oldfiles = array_reverse( $oldfiles );
|
$oldfiles = array_reverse( $oldfiles );
|
||||||
$oldfiles = array_unique( $oldfiles );
|
$oldfiles = array_unique( $oldfiles );
|
||||||
|
|
||||||
if ( 5 < count( $oldfiles ) ) {
|
if ( 5 < count( $oldfiles ) ) {
|
||||||
array_pop( $oldfiles );
|
array_pop( $oldfiles );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$oldfiles[] = $file;
|
$oldfiles[] = $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
update_option( 'recently_edited', $oldfiles );
|
update_option( 'recently_edited', $oldfiles );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,14 +365,18 @@ function update_recently_edited( $file ) {
|
||||||
*/
|
*/
|
||||||
function wp_make_theme_file_tree( $allowed_files ) {
|
function wp_make_theme_file_tree( $allowed_files ) {
|
||||||
$tree_list = array();
|
$tree_list = array();
|
||||||
|
|
||||||
foreach ( $allowed_files as $file_name => $absolute_filename ) {
|
foreach ( $allowed_files as $file_name => $absolute_filename ) {
|
||||||
$list = explode( '/', $file_name );
|
$list = explode( '/', $file_name );
|
||||||
$last_dir = &$tree_list;
|
$last_dir = &$tree_list;
|
||||||
|
|
||||||
foreach ( $list as $dir ) {
|
foreach ( $list as $dir ) {
|
||||||
$last_dir =& $last_dir[ $dir ];
|
$last_dir =& $last_dir[ $dir ];
|
||||||
}
|
}
|
||||||
|
|
||||||
$last_dir = $file_name;
|
$last_dir = $file_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $tree_list;
|
return $tree_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,8 +401,10 @@ function wp_print_theme_file_tree( $tree, $level = 2, $size = 1, $index = 1 ) {
|
||||||
if ( is_array( $tree ) ) {
|
if ( is_array( $tree ) ) {
|
||||||
$index = 0;
|
$index = 0;
|
||||||
$size = count( $tree );
|
$size = count( $tree );
|
||||||
|
|
||||||
foreach ( $tree as $label => $theme_file ) :
|
foreach ( $tree as $label => $theme_file ) :
|
||||||
$index++;
|
$index++;
|
||||||
|
|
||||||
if ( ! is_array( $theme_file ) ) {
|
if ( ! is_array( $theme_file ) ) {
|
||||||
wp_print_theme_file_tree( $theme_file, $level, $index, $size );
|
wp_print_theme_file_tree( $theme_file, $level, $index, $size );
|
||||||
continue;
|
continue;
|
||||||
|
@ -408,6 +437,7 @@ function wp_print_theme_file_tree( $tree, $level = 2, $size = 1, $index = 1 ) {
|
||||||
aria-posinset="<?php echo esc_attr( $index ); ?>">
|
aria-posinset="<?php echo esc_attr( $index ); ?>">
|
||||||
<?php
|
<?php
|
||||||
$file_description = esc_html( get_file_description( $filename ) );
|
$file_description = esc_html( get_file_description( $filename ) );
|
||||||
|
|
||||||
if ( $file_description !== $filename && wp_basename( $filename ) !== $file_description ) {
|
if ( $file_description !== $filename && wp_basename( $filename ) !== $file_description ) {
|
||||||
$file_description .= '<br /><span class="nonessential">(' . esc_html( $filename ) . ')</span>';
|
$file_description .= '<br /><span class="nonessential">(' . esc_html( $filename ) . ')</span>';
|
||||||
}
|
}
|
||||||
|
@ -435,14 +465,18 @@ function wp_print_theme_file_tree( $tree, $level = 2, $size = 1, $index = 1 ) {
|
||||||
*/
|
*/
|
||||||
function wp_make_plugin_file_tree( $plugin_editable_files ) {
|
function wp_make_plugin_file_tree( $plugin_editable_files ) {
|
||||||
$tree_list = array();
|
$tree_list = array();
|
||||||
|
|
||||||
foreach ( $plugin_editable_files as $plugin_file ) {
|
foreach ( $plugin_editable_files as $plugin_file ) {
|
||||||
$list = explode( '/', preg_replace( '#^.+?/#', '', $plugin_file ) );
|
$list = explode( '/', preg_replace( '#^.+?/#', '', $plugin_file ) );
|
||||||
$last_dir = &$tree_list;
|
$last_dir = &$tree_list;
|
||||||
|
|
||||||
foreach ( $list as $dir ) {
|
foreach ( $list as $dir ) {
|
||||||
$last_dir =& $last_dir[ $dir ];
|
$last_dir =& $last_dir[ $dir ];
|
||||||
}
|
}
|
||||||
|
|
||||||
$last_dir = $plugin_file;
|
$last_dir = $plugin_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $tree_list;
|
return $tree_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -460,11 +494,14 @@ function wp_make_plugin_file_tree( $plugin_editable_files ) {
|
||||||
*/
|
*/
|
||||||
function wp_print_plugin_file_tree( $tree, $label = '', $level = 2, $size = 1, $index = 1 ) {
|
function wp_print_plugin_file_tree( $tree, $label = '', $level = 2, $size = 1, $index = 1 ) {
|
||||||
global $file, $plugin;
|
global $file, $plugin;
|
||||||
|
|
||||||
if ( is_array( $tree ) ) {
|
if ( is_array( $tree ) ) {
|
||||||
$index = 0;
|
$index = 0;
|
||||||
$size = count( $tree );
|
$size = count( $tree );
|
||||||
|
|
||||||
foreach ( $tree as $label => $plugin_file ) :
|
foreach ( $tree as $label => $plugin_file ) :
|
||||||
$index++;
|
$index++;
|
||||||
|
|
||||||
if ( ! is_array( $plugin_file ) ) {
|
if ( ! is_array( $plugin_file ) ) {
|
||||||
wp_print_plugin_file_tree( $plugin_file, $label, $level, $index, $size );
|
wp_print_plugin_file_tree( $plugin_file, $label, $level, $index, $size );
|
||||||
continue;
|
continue;
|
||||||
|
@ -568,6 +605,7 @@ function show_message( $message ) {
|
||||||
$message = $message->get_error_message();
|
$message = $message->get_error_message();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "<p>$message</p>\n";
|
echo "<p>$message</p>\n";
|
||||||
wp_ob_end_flush_all();
|
wp_ob_end_flush_all();
|
||||||
flush();
|
flush();
|
||||||
|
@ -592,18 +630,20 @@ function wp_doc_link_parse( $content ) {
|
||||||
$count = count( $tokens );
|
$count = count( $tokens );
|
||||||
$functions = array();
|
$functions = array();
|
||||||
$ignore_functions = array();
|
$ignore_functions = array();
|
||||||
|
|
||||||
for ( $t = 0; $t < $count - 2; $t++ ) {
|
for ( $t = 0; $t < $count - 2; $t++ ) {
|
||||||
if ( ! is_array( $tokens[ $t ] ) ) {
|
if ( ! is_array( $tokens[ $t ] ) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( T_STRING == $tokens[ $t ][0] && ( '(' === $tokens[ $t + 1 ] || '(' === $tokens[ $t + 2 ] ) ) {
|
if ( T_STRING === $tokens[ $t ][0] && ( '(' === $tokens[ $t + 1 ] || '(' === $tokens[ $t + 2 ] ) ) {
|
||||||
// If it's a function or class defined locally, there's not going to be any docs available.
|
// If it's a function or class defined locally, there's not going to be any docs available.
|
||||||
if ( ( isset( $tokens[ $t - 2 ][1] ) && in_array( $tokens[ $t - 2 ][1], array( 'function', 'class' ), true ) )
|
if ( ( isset( $tokens[ $t - 2 ][1] ) && in_array( $tokens[ $t - 2 ][1], array( 'function', 'class' ), true ) )
|
||||||
|| ( isset( $tokens[ $t - 2 ][0] ) && T_OBJECT_OPERATOR == $tokens[ $t - 1 ][0] )
|
|| ( isset( $tokens[ $t - 2 ][0] ) && T_OBJECT_OPERATOR === $tokens[ $t - 1 ][0] )
|
||||||
) {
|
) {
|
||||||
$ignore_functions[] = $tokens[ $t ][1];
|
$ignore_functions[] = $tokens[ $t ][1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add this to our stack of unique references.
|
// Add this to our stack of unique references.
|
||||||
$functions[] = $tokens[ $t ][1];
|
$functions[] = $tokens[ $t ][1];
|
||||||
}
|
}
|
||||||
|
@ -624,10 +664,12 @@ function wp_doc_link_parse( $content ) {
|
||||||
$ignore_functions = array_unique( $ignore_functions );
|
$ignore_functions = array_unique( $ignore_functions );
|
||||||
|
|
||||||
$out = array();
|
$out = array();
|
||||||
|
|
||||||
foreach ( $functions as $function ) {
|
foreach ( $functions as $function ) {
|
||||||
if ( in_array( $function, $ignore_functions, true ) ) {
|
if ( in_array( $function, $ignore_functions, true ) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$out[] = $function;
|
$out[] = $function;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -640,24 +682,29 @@ function wp_doc_link_parse( $content ) {
|
||||||
* @since 2.8.0
|
* @since 2.8.0
|
||||||
*/
|
*/
|
||||||
function set_screen_options() {
|
function set_screen_options() {
|
||||||
|
if ( ! isset( $_POST['wp_screen_options'] ) || ! is_array( $_POST['wp_screen_options'] ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( isset( $_POST['wp_screen_options'] ) && is_array( $_POST['wp_screen_options'] ) ) {
|
|
||||||
check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' );
|
check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' );
|
||||||
|
|
||||||
$user = wp_get_current_user();
|
$user = wp_get_current_user();
|
||||||
|
|
||||||
if ( ! $user ) {
|
if ( ! $user ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$option = $_POST['wp_screen_options']['option'];
|
$option = $_POST['wp_screen_options']['option'];
|
||||||
$value = $_POST['wp_screen_options']['value'];
|
$value = $_POST['wp_screen_options']['value'];
|
||||||
|
|
||||||
if ( sanitize_key( $option ) != $option ) {
|
if ( sanitize_key( $option ) !== $option ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$map_option = $option;
|
$map_option = $option;
|
||||||
$type = str_replace( 'edit_', '', $map_option );
|
$type = str_replace( 'edit_', '', $map_option );
|
||||||
$type = str_replace( '_per_page', '', $type );
|
$type = str_replace( '_per_page', '', $type );
|
||||||
|
|
||||||
if ( in_array( $type, get_taxonomies(), true ) ) {
|
if ( in_array( $type, get_taxonomies(), true ) ) {
|
||||||
$map_option = 'edit_tags_per_page';
|
$map_option = 'edit_tags_per_page';
|
||||||
} elseif ( in_array( $type, get_post_types(), true ) ) {
|
} elseif ( in_array( $type, get_post_types(), true ) ) {
|
||||||
|
@ -683,10 +730,13 @@ function set_screen_options() {
|
||||||
case 'themes_network_per_page':
|
case 'themes_network_per_page':
|
||||||
case 'site_themes_network_per_page':
|
case 'site_themes_network_per_page':
|
||||||
$value = (int) $value;
|
$value = (int) $value;
|
||||||
|
|
||||||
if ( $value < 1 || $value > 999 ) {
|
if ( $value < 1 || $value > 999 ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$screen_option = false;
|
$screen_option = false;
|
||||||
|
|
||||||
|
@ -734,12 +784,14 @@ function set_screen_options() {
|
||||||
if ( false === $value ) {
|
if ( false === $value ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
update_user_meta( $user->ID, $option, $value );
|
update_user_meta( $user->ID, $option, $value );
|
||||||
|
|
||||||
$url = remove_query_arg( array( 'pagenum', 'apage', 'paged' ), wp_get_referer() );
|
$url = remove_query_arg( array( 'pagenum', 'apage', 'paged' ), wp_get_referer() );
|
||||||
|
|
||||||
if ( isset( $_POST['mode'] ) ) {
|
if ( isset( $_POST['mode'] ) ) {
|
||||||
$url = add_query_arg( array( 'mode' => $_POST['mode'] ), $url );
|
$url = add_query_arg( array( 'mode' => $_POST['mode'] ), $url );
|
||||||
}
|
}
|
||||||
|
@ -747,35 +799,38 @@ function set_screen_options() {
|
||||||
wp_safe_redirect( $url );
|
wp_safe_redirect( $url );
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if rewrite rule for WordPress already exists in the IIS 7+ configuration file
|
* Check if rewrite rule for WordPress already exists in the IIS 7+ configuration file
|
||||||
*
|
*
|
||||||
* @since 2.8.0
|
* @since 2.8.0
|
||||||
*
|
*
|
||||||
* @return bool
|
|
||||||
* @param string $filename The file path to the configuration file
|
* @param string $filename The file path to the configuration file
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function iis7_rewrite_rule_exists( $filename ) {
|
function iis7_rewrite_rule_exists( $filename ) {
|
||||||
if ( ! file_exists( $filename ) ) {
|
if ( ! file_exists( $filename ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! class_exists( 'DOMDocument', false ) ) {
|
if ( ! class_exists( 'DOMDocument', false ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$doc = new DOMDocument();
|
$doc = new DOMDocument();
|
||||||
|
|
||||||
if ( $doc->load( $filename ) === false ) {
|
if ( $doc->load( $filename ) === false ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$xpath = new DOMXPath( $doc );
|
$xpath = new DOMXPath( $doc );
|
||||||
$rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]' );
|
$rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]' );
|
||||||
if ( 0 == $rules->length ) {
|
|
||||||
|
if ( 0 === $rules->length ) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -802,8 +857,10 @@ function iis7_delete_rewrite_rule( $filename ) {
|
||||||
if ( $doc->load( $filename ) === false ) {
|
if ( $doc->load( $filename ) === false ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$xpath = new DOMXPath( $doc );
|
$xpath = new DOMXPath( $doc );
|
||||||
$rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]' );
|
$rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]' );
|
||||||
|
|
||||||
if ( $rules->length > 0 ) {
|
if ( $rules->length > 0 ) {
|
||||||
$child = $rules->item( 0 );
|
$child = $rules->item( 0 );
|
||||||
$parent = $child->parentNode;
|
$parent = $child->parentNode;
|
||||||
|
@ -811,6 +868,7 @@ function iis7_delete_rewrite_rule( $filename ) {
|
||||||
$doc->formatOutput = true;
|
$doc->formatOutput = true;
|
||||||
saveDomDocument( $doc, $filename );
|
saveDomDocument( $doc, $filename );
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -846,18 +904,21 @@ function iis7_add_rewrite_rule( $filename, $rewrite_rule ) {
|
||||||
|
|
||||||
// First check if the rule already exists as in that case there is no need to re-add it.
|
// First check if the rule already exists as in that case there is no need to re-add it.
|
||||||
$wordpress_rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]' );
|
$wordpress_rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]' );
|
||||||
|
|
||||||
if ( $wordpress_rules->length > 0 ) {
|
if ( $wordpress_rules->length > 0 ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the XPath to the rewrite rule and create XML nodes if they do not exist.
|
// Check the XPath to the rewrite rule and create XML nodes if they do not exist.
|
||||||
$xmlnodes = $xpath->query( '/configuration/system.webServer/rewrite/rules' );
|
$xmlnodes = $xpath->query( '/configuration/system.webServer/rewrite/rules' );
|
||||||
|
|
||||||
if ( $xmlnodes->length > 0 ) {
|
if ( $xmlnodes->length > 0 ) {
|
||||||
$rules_node = $xmlnodes->item( 0 );
|
$rules_node = $xmlnodes->item( 0 );
|
||||||
} else {
|
} else {
|
||||||
$rules_node = $doc->createElement( 'rules' );
|
$rules_node = $doc->createElement( 'rules' );
|
||||||
|
|
||||||
$xmlnodes = $xpath->query( '/configuration/system.webServer/rewrite' );
|
$xmlnodes = $xpath->query( '/configuration/system.webServer/rewrite' );
|
||||||
|
|
||||||
if ( $xmlnodes->length > 0 ) {
|
if ( $xmlnodes->length > 0 ) {
|
||||||
$rewrite_node = $xmlnodes->item( 0 );
|
$rewrite_node = $xmlnodes->item( 0 );
|
||||||
$rewrite_node->appendChild( $rules_node );
|
$rewrite_node->appendChild( $rules_node );
|
||||||
|
@ -866,21 +927,23 @@ function iis7_add_rewrite_rule( $filename, $rewrite_rule ) {
|
||||||
$rewrite_node->appendChild( $rules_node );
|
$rewrite_node->appendChild( $rules_node );
|
||||||
|
|
||||||
$xmlnodes = $xpath->query( '/configuration/system.webServer' );
|
$xmlnodes = $xpath->query( '/configuration/system.webServer' );
|
||||||
|
|
||||||
if ( $xmlnodes->length > 0 ) {
|
if ( $xmlnodes->length > 0 ) {
|
||||||
$system_webServer_node = $xmlnodes->item( 0 );
|
$system_webserver_node = $xmlnodes->item( 0 );
|
||||||
$system_webServer_node->appendChild( $rewrite_node );
|
$system_webserver_node->appendChild( $rewrite_node );
|
||||||
} else {
|
} else {
|
||||||
$system_webServer_node = $doc->createElement( 'system.webServer' );
|
$system_webserver_node = $doc->createElement( 'system.webServer' );
|
||||||
$system_webServer_node->appendChild( $rewrite_node );
|
$system_webserver_node->appendChild( $rewrite_node );
|
||||||
|
|
||||||
$xmlnodes = $xpath->query( '/configuration' );
|
$xmlnodes = $xpath->query( '/configuration' );
|
||||||
|
|
||||||
if ( $xmlnodes->length > 0 ) {
|
if ( $xmlnodes->length > 0 ) {
|
||||||
$config_node = $xmlnodes->item( 0 );
|
$config_node = $xmlnodes->item( 0 );
|
||||||
$config_node->appendChild( $system_webServer_node );
|
$config_node->appendChild( $system_webserver_node );
|
||||||
} else {
|
} else {
|
||||||
$config_node = $doc->createElement( 'configuration' );
|
$config_node = $doc->createElement( 'configuration' );
|
||||||
$doc->appendChild( $config_node );
|
$doc->appendChild( $config_node );
|
||||||
$config_node->appendChild( $system_webServer_node );
|
$config_node->appendChild( $system_webserver_node );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -908,6 +971,7 @@ function iis7_add_rewrite_rule( $filename, $rewrite_rule ) {
|
||||||
function saveDomDocument( $doc, $filename ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
|
function saveDomDocument( $doc, $filename ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
|
||||||
$config = $doc->saveXML();
|
$config = $doc->saveXML();
|
||||||
$config = preg_replace( "/([^\r])\n/", "$1\r\n", $config );
|
$config = preg_replace( "/([^\r])\n/", "$1\r\n", $config );
|
||||||
|
|
||||||
$fp = fopen( $filename, 'w' );
|
$fp = fopen( $filename, 'w' );
|
||||||
fwrite( $fp, $config );
|
fwrite( $fp, $config );
|
||||||
fclose( $fp );
|
fclose( $fp );
|
||||||
|
@ -946,7 +1010,6 @@ function admin_color_scheme_picker( $user_id ) {
|
||||||
if ( empty( $current_color ) || ! isset( $_wp_admin_css_colors[ $current_color ] ) ) {
|
if ( empty( $current_color ) || ! isset( $_wp_admin_css_colors[ $current_color ] ) ) {
|
||||||
$current_color = 'fresh';
|
$current_color = 'fresh';
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<fieldset id="color-picker" class="scheme-list">
|
<fieldset id="color-picker" class="scheme-list">
|
||||||
<legend class="screen-reader-text"><span><?php _e( 'Admin Color Scheme' ); ?></span></legend>
|
<legend class="screen-reader-text"><span><?php _e( 'Admin Color Scheme' ); ?></span></legend>
|
||||||
|
@ -955,7 +1018,7 @@ function admin_color_scheme_picker( $user_id ) {
|
||||||
foreach ( $_wp_admin_css_colors as $color => $color_info ) :
|
foreach ( $_wp_admin_css_colors as $color => $color_info ) :
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<div class="color-option <?php echo ( $color == $current_color ) ? 'selected' : ''; ?>">
|
<div class="color-option <?php echo ( $color === $current_color ) ? 'selected' : ''; ?>">
|
||||||
<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 ); ?> />
|
<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 ); ?> />
|
||||||
<input type="hidden" class="css_url" value="<?php echo esc_url( $color_info->url ); ?>" />
|
<input type="hidden" class="css_url" value="<?php echo esc_url( $color_info->url ); ?>" />
|
||||||
<input type="hidden" class="icon_colors" value="<?php echo esc_attr( wp_json_encode( array( 'icons' => $color_info->icon_colors ) ) ); ?>" />
|
<input type="hidden" class="icon_colors" value="<?php echo esc_attr( wp_json_encode( array( 'icons' => $color_info->icon_colors ) ) ); ?>" />
|
||||||
|
@ -963,13 +1026,11 @@ function admin_color_scheme_picker( $user_id ) {
|
||||||
<table class="color-palette">
|
<table class="color-palette">
|
||||||
<tr>
|
<tr>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
foreach ( $color_info->colors as $html_color ) {
|
foreach ( $color_info->colors as $html_color ) {
|
||||||
?>
|
?>
|
||||||
<td style="background-color: <?php echo esc_attr( $html_color ); ?>"> </td>
|
<td style="background-color: <?php echo esc_attr( $html_color ); ?>"> </td>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
@ -977,7 +1038,6 @@ function admin_color_scheme_picker( $user_id ) {
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<?php
|
<?php
|
||||||
|
@ -1065,13 +1125,16 @@ function wp_check_locked_posts( $response, $data, $screen_id ) {
|
||||||
if ( array_key_exists( 'wp-check-locked-posts', $data ) && is_array( $data['wp-check-locked-posts'] ) ) {
|
if ( array_key_exists( 'wp-check-locked-posts', $data ) && is_array( $data['wp-check-locked-posts'] ) ) {
|
||||||
foreach ( $data['wp-check-locked-posts'] as $key ) {
|
foreach ( $data['wp-check-locked-posts'] as $key ) {
|
||||||
$post_id = absint( substr( $key, 5 ) );
|
$post_id = absint( substr( $key, 5 ) );
|
||||||
|
|
||||||
if ( ! $post_id ) {
|
if ( ! $post_id ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_id = wp_check_post_lock( $post_id );
|
$user_id = wp_check_post_lock( $post_id );
|
||||||
|
|
||||||
if ( $user_id ) {
|
if ( $user_id ) {
|
||||||
$user = get_userdata( $user_id );
|
$user = get_userdata( $user_id );
|
||||||
|
|
||||||
if ( $user && current_user_can( 'edit_post', $post_id ) ) {
|
if ( $user && current_user_can( 'edit_post', $post_id ) ) {
|
||||||
$send = array(
|
$send = array(
|
||||||
/* translators: %s: User's display name. */
|
/* translators: %s: User's display name. */
|
||||||
|
@ -1112,6 +1175,7 @@ function wp_refresh_post_lock( $response, $data, $screen_id ) {
|
||||||
$send = array();
|
$send = array();
|
||||||
|
|
||||||
$post_id = absint( $received['post_id'] );
|
$post_id = absint( $received['post_id'] );
|
||||||
|
|
||||||
if ( ! $post_id ) {
|
if ( ! $post_id ) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
@ -1122,6 +1186,7 @@ function wp_refresh_post_lock( $response, $data, $screen_id ) {
|
||||||
|
|
||||||
$user_id = wp_check_post_lock( $post_id );
|
$user_id = wp_check_post_lock( $post_id );
|
||||||
$user = get_userdata( $user_id );
|
$user = get_userdata( $user_id );
|
||||||
|
|
||||||
if ( $user ) {
|
if ( $user ) {
|
||||||
$error = array(
|
$error = array(
|
||||||
/* translators: %s: User's display name. */
|
/* translators: %s: User's display name. */
|
||||||
|
@ -1136,6 +1201,7 @@ function wp_refresh_post_lock( $response, $data, $screen_id ) {
|
||||||
$send['lock_error'] = $error;
|
$send['lock_error'] = $error;
|
||||||
} else {
|
} else {
|
||||||
$new_lock = wp_set_post_lock( $post_id );
|
$new_lock = wp_set_post_lock( $post_id );
|
||||||
|
|
||||||
if ( $new_lock ) {
|
if ( $new_lock ) {
|
||||||
$send['new_lock'] = implode( ':', $new_lock );
|
$send['new_lock'] = implode( ':', $new_lock );
|
||||||
}
|
}
|
||||||
|
@ -1160,9 +1226,11 @@ function wp_refresh_post_lock( $response, $data, $screen_id ) {
|
||||||
function wp_refresh_post_nonces( $response, $data, $screen_id ) {
|
function wp_refresh_post_nonces( $response, $data, $screen_id ) {
|
||||||
if ( array_key_exists( 'wp-refresh-post-nonces', $data ) ) {
|
if ( array_key_exists( 'wp-refresh-post-nonces', $data ) ) {
|
||||||
$received = $data['wp-refresh-post-nonces'];
|
$received = $data['wp-refresh-post-nonces'];
|
||||||
|
|
||||||
$response['wp-refresh-post-nonces'] = array( 'check' => 1 );
|
$response['wp-refresh-post-nonces'] = array( 'check' => 1 );
|
||||||
|
|
||||||
$post_id = absint( $received['post_id'] );
|
$post_id = absint( $received['post_id'] );
|
||||||
|
|
||||||
if ( ! $post_id ) {
|
if ( ! $post_id ) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
@ -1199,6 +1267,7 @@ function wp_refresh_heartbeat_nonces( $response ) {
|
||||||
|
|
||||||
// Refresh the Heartbeat nonce.
|
// Refresh the Heartbeat nonce.
|
||||||
$response['heartbeat_nonce'] = wp_create_nonce( 'heartbeat-nonce' );
|
$response['heartbeat_nonce'] = wp_create_nonce( 'heartbeat-nonce' );
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1451,8 +1520,10 @@ function wp_check_php_version() {
|
||||||
$key = md5( $version );
|
$key = md5( $version );
|
||||||
|
|
||||||
$response = get_site_transient( 'php_check_' . $key );
|
$response = get_site_transient( 'php_check_' . $key );
|
||||||
|
|
||||||
if ( false === $response ) {
|
if ( false === $response ) {
|
||||||
$url = 'http://api.wordpress.org/core/serve-happy/1.0/';
|
$url = 'http://api.wordpress.org/core/serve-happy/1.0/';
|
||||||
|
|
||||||
if ( wp_http_supports( array( 'ssl' ) ) ) {
|
if ( wp_http_supports( array( 'ssl' ) ) ) {
|
||||||
$url = set_url_scheme( $url, 'https' );
|
$url = set_url_scheme( $url, 'https' );
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.0-alpha-52719';
|
$wp_version = '6.0-alpha-52721';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue