<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[52721] trunk/src/wp-admin/includes/misc.php: Coding Standards: Fix WPCS issues in `wp-admin/includes/misc.php`.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/52721">52721</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/52721","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>SergeyBiryukov</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2022-02-13 17:07:09 +0000 (Sun, 13 Feb 2022)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>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 <a href="https://core.trac.wordpress.org/changeset/10607">[10607]</a>, <a href="https://core.trac.wordpress.org/changeset/11350">[11350]</a>, <a href="https://core.trac.wordpress.org/changeset/22253">[22253]</a>, <a href="https://core.trac.wordpress.org/changeset/26137">[26137]</a>.
Props azouamauriac, SergeyBiryukov.
See <a href="https://core.trac.wordpress.org/ticket/54728">#54728</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludesmiscphp">trunk/src/wp-admin/includes/misc.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminincludesmiscphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/misc.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/misc.php 2022-02-12 15:10:54 UTC (rev 52720)
+++ trunk/src/wp-admin/includes/misc.php 2022-02-13 17:07:09 UTC (rev 52721)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -74,16 +74,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $markerdata = explode( "\n", implode( '', file( $filename ) ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $state = false;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $markerdata as $markerline ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( false !== strpos( $markerline, '# END ' . $marker ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $state = false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $state ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( '#' === substr( $markerline, 0, 1 ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $result[] = $markerline;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( false !== strpos( $markerline, '# BEGIN ' . $marker ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $state = true;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -118,6 +122,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Make sure the file is created with a minimum set of permissions.
</span><span class="cx" style="display: block; padding: 0 10px"> $perms = fileperms( $filename );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $perms ) {
</span><span class="cx" style="display: block; padding: 0 10px"> chmod( $filename, $perms | 0644 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -142,6 +147,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $instructions = explode( "\n", $instructions );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $instructions as $line => $text ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $instructions[ $line ] = '# ' . $text;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -166,6 +172,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $end_marker = "# END {$marker}";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $fp = fopen( $filename, 'r+' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $fp ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -174,6 +181,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> flock( $fp, LOCK_EX );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $lines = array();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> while ( ! feof( $fp ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $lines[] = rtrim( fgets( $fp ), "\r\n" );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -184,6 +192,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $existing_lines = array();
</span><span class="cx" style="display: block; padding: 0 10px"> $found_marker = false;
</span><span class="cx" style="display: block; padding: 0 10px"> $found_end_marker = false;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $lines as $line ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $found_marker && false !== strpos( $line, $start_marker ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $found_marker = true;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -192,6 +201,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $found_end_marker = true;
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $found_marker ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $pre_lines[] = $line;
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( $found_marker && $found_end_marker ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -224,9 +234,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Write to the start of the file, and truncate it to that length.
</span><span class="cx" style="display: block; padding: 0 10px"> fseek( $fp, 0 );
</span><span class="cx" style="display: block; padding: 0 10px"> $bytes = fwrite( $fp, $new_file_data );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $bytes ) {
</span><span class="cx" style="display: block; padding: 0 10px"> ftruncate( $fp, ftell( $fp ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> fflush( $fp );
</span><span class="cx" style="display: block; padding: 0 10px"> flock( $fp, LOCK_UN );
</span><span class="cx" style="display: block; padding: 0 10px"> fclose( $fp );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -247,12 +259,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return bool|null True on write success, false on failure. Null in multisite.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function save_mod_rewrite_rules() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $wp_rewrite;
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( is_multisite() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wp_rewrite;
-
</del><span class="cx" style="display: block; padding: 0 10px"> // Ensure get_home_path() is declared.
</span><span class="cx" style="display: block; padding: 0 10px"> require_once ABSPATH . 'wp-admin/includes/file.php';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -263,9 +275,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * If the file doesn't already exist check for write access to the directory
</span><span class="cx" style="display: block; padding: 0 10px"> * and whether we have some rules. Else check for write access to the file.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ( ! file_exists( $htaccess_file ) && is_writable( $home_path ) && $wp_rewrite->using_mod_rewrite_permalinks() ) || is_writable( $htaccess_file ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! file_exists( $htaccess_file ) && is_writable( $home_path ) && $wp_rewrite->using_mod_rewrite_permalinks()
+ || is_writable( $htaccess_file )
+ ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( got_mod_rewrite() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $rules = explode( "\n", $wp_rewrite->mod_rewrite_rules() );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> return insert_with_markers( $htaccess_file, 'WordPress', $rules );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -284,12 +299,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return bool|null True on write success, false on failure. Null in multisite.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function iis7_save_url_rewrite_rules() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $wp_rewrite;
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( is_multisite() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wp_rewrite;
-
</del><span class="cx" style="display: block; padding: 0 10px"> // Ensure get_home_path() is declared.
</span><span class="cx" style="display: block; padding: 0 10px"> require_once ABSPATH . 'wp-admin/includes/file.php';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -297,8 +312,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $web_config_file = $home_path . 'web.config';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Using win_is_writable() instead of is_writable() because of a bug in Windows PHP.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 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 ) ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 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 ) )
+ ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $rule = $wp_rewrite->iis7_url_rewrite_rules( false );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $rule ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return iis7_add_rewrite_rule( $web_config_file, $rule );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -305,6 +324,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return iis7_delete_rewrite_rule( $web_config_file );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -317,11 +337,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function update_recently_edited( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $oldfiles = (array) get_option( 'recently_edited' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $oldfiles ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $oldfiles = array_reverse( $oldfiles );
</span><span class="cx" style="display: block; padding: 0 10px"> $oldfiles[] = $file;
</span><span class="cx" style="display: block; padding: 0 10px"> $oldfiles = array_reverse( $oldfiles );
</span><span class="cx" style="display: block; padding: 0 10px"> $oldfiles = array_unique( $oldfiles );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( 5 < count( $oldfiles ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> array_pop( $oldfiles );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -328,6 +350,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $oldfiles[] = $file;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> update_option( 'recently_edited', $oldfiles );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -342,14 +365,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_make_theme_file_tree( $allowed_files ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $tree_list = array();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $allowed_files as $file_name => $absolute_filename ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $list = explode( '/', $file_name );
</span><span class="cx" style="display: block; padding: 0 10px"> $last_dir = &$tree_list;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $list as $dir ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $last_dir =& $last_dir[ $dir ];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $last_dir = $file_name;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> return $tree_list;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -374,8 +401,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_array( $tree ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $index = 0;
</span><span class="cx" style="display: block; padding: 0 10px"> $size = count( $tree );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $tree as $label => $theme_file ) :
</span><span class="cx" style="display: block; padding: 0 10px"> $index++;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! is_array( $theme_file ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_print_theme_file_tree( $theme_file, $level, $index, $size );
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -408,6 +437,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> aria-posinset="<?php echo esc_attr( $index ); ?>">
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> $file_description = esc_html( get_file_description( $filename ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $file_description !== $filename && wp_basename( $filename ) !== $file_description ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $file_description .= '<br /><span class="nonessential">(' . esc_html( $filename ) . ')</span>';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -435,14 +465,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_make_plugin_file_tree( $plugin_editable_files ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $tree_list = array();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $plugin_editable_files as $plugin_file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $list = explode( '/', preg_replace( '#^.+?/#', '', $plugin_file ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $last_dir = &$tree_list;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $list as $dir ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $last_dir =& $last_dir[ $dir ];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $last_dir = $plugin_file;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> return $tree_list;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -460,11 +494,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_print_plugin_file_tree( $tree, $label = '', $level = 2, $size = 1, $index = 1 ) {
</span><span class="cx" style="display: block; padding: 0 10px"> global $file, $plugin;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( is_array( $tree ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $index = 0;
</span><span class="cx" style="display: block; padding: 0 10px"> $size = count( $tree );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $tree as $label => $plugin_file ) :
</span><span class="cx" style="display: block; padding: 0 10px"> $index++;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! is_array( $plugin_file ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_print_plugin_file_tree( $plugin_file, $label, $level, $index, $size );
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -568,6 +605,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $message = $message->get_error_message();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> echo "<p>$message</p>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> wp_ob_end_flush_all();
</span><span class="cx" style="display: block; padding: 0 10px"> flush();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -592,18 +630,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $count = count( $tokens );
</span><span class="cx" style="display: block; padding: 0 10px"> $functions = array();
</span><span class="cx" style="display: block; padding: 0 10px"> $ignore_functions = array();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> for ( $t = 0; $t < $count - 2; $t++ ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! is_array( $tokens[ $t ] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( T_STRING == $tokens[ $t ][0] && ( '(' === $tokens[ $t + 1 ] || '(' === $tokens[ $t + 2 ] ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( T_STRING === $tokens[ $t ][0] && ( '(' === $tokens[ $t + 1 ] || '(' === $tokens[ $t + 2 ] ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> // If it's a function or class defined locally, there's not going to be any docs available.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ( isset( $tokens[ $t - 2 ][1] ) && in_array( $tokens[ $t - 2 ][1], array( 'function', 'class' ), true ) )
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- || ( isset( $tokens[ $t - 2 ][0] ) && T_OBJECT_OPERATOR == $tokens[ $t - 1 ][0] )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ || ( isset( $tokens[ $t - 2 ][0] ) && T_OBJECT_OPERATOR === $tokens[ $t - 1 ][0] )
</ins><span class="cx" style="display: block; padding: 0 10px"> ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $ignore_functions[] = $tokens[ $t ][1];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Add this to our stack of unique references.
</span><span class="cx" style="display: block; padding: 0 10px"> $functions[] = $tokens[ $t ][1];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -624,10 +664,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $ignore_functions = array_unique( $ignore_functions );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $out = array();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $functions as $function ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( in_array( $function, $ignore_functions, true ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $out[] = $function;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -640,113 +682,122 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.8.0
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function set_screen_options() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! isset( $_POST['wp_screen_options'] ) || ! is_array( $_POST['wp_screen_options'] ) ) {
+ return;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( isset( $_POST['wp_screen_options'] ) && is_array( $_POST['wp_screen_options'] ) ) {
- check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user = wp_get_current_user();
- if ( ! $user ) {
- return;
- }
- $option = $_POST['wp_screen_options']['option'];
- $value = $_POST['wp_screen_options']['value'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user = wp_get_current_user();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( sanitize_key( $option ) != $option ) {
- return;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! $user ) {
+ return;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $map_option = $option;
- $type = str_replace( 'edit_', '', $map_option );
- $type = str_replace( '_per_page', '', $type );
- if ( in_array( $type, get_taxonomies(), true ) ) {
- $map_option = 'edit_tags_per_page';
- } elseif ( in_array( $type, get_post_types(), true ) ) {
- $map_option = 'edit_per_page';
- } else {
- $option = str_replace( '-', '_', $option );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $option = $_POST['wp_screen_options']['option'];
+ $value = $_POST['wp_screen_options']['value'];
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- switch ( $map_option ) {
- case 'edit_per_page':
- case 'users_per_page':
- case 'edit_comments_per_page':
- case 'upload_per_page':
- case 'edit_tags_per_page':
- case 'plugins_per_page':
- case 'export_personal_data_requests_per_page':
- case 'remove_personal_data_requests_per_page':
- // Network admin.
- case 'sites_network_per_page':
- case 'users_network_per_page':
- case 'site_users_network_per_page':
- case 'plugins_network_per_page':
- case 'themes_network_per_page':
- case 'site_themes_network_per_page':
- $value = (int) $value;
- if ( $value < 1 || $value > 999 ) {
- return;
- }
- break;
- default:
- $screen_option = false;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( sanitize_key( $option ) !== $option ) {
+ return;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( '_page' === substr( $option, -5 ) || 'layout_columns' === $option ) {
- /**
- * Filters a screen option value before it is set.
- *
- * The filter can also be used to modify non-standard [items]_per_page
- * settings. See the parent function for a full list of standard options.
- *
- * Returning false from the filter will skip saving the current option.
- *
- * @since 2.8.0
- * @since 5.4.2 Only applied to options ending with '_page',
- * or the 'layout_columns' option.
- *
- * @see set_screen_options()
- *
- * @param mixed $screen_option The value to save instead of the option value.
- * Default false (to skip saving the current option).
- * @param string $option The option name.
- * @param int $value The option value.
- */
- $screen_option = apply_filters( 'set-screen-option', $screen_option, $option, $value ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $map_option = $option;
+ $type = str_replace( 'edit_', '', $map_option );
+ $type = str_replace( '_per_page', '', $type );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( in_array( $type, get_taxonomies(), true ) ) {
+ $map_option = 'edit_tags_per_page';
+ } elseif ( in_array( $type, get_post_types(), true ) ) {
+ $map_option = 'edit_per_page';
+ } else {
+ $option = str_replace( '-', '_', $option );
+ }
+
+ switch ( $map_option ) {
+ case 'edit_per_page':
+ case 'users_per_page':
+ case 'edit_comments_per_page':
+ case 'upload_per_page':
+ case 'edit_tags_per_page':
+ case 'plugins_per_page':
+ case 'export_personal_data_requests_per_page':
+ case 'remove_personal_data_requests_per_page':
+ // Network admin.
+ case 'sites_network_per_page':
+ case 'users_network_per_page':
+ case 'site_users_network_per_page':
+ case 'plugins_network_per_page':
+ case 'themes_network_per_page':
+ case 'site_themes_network_per_page':
+ $value = (int) $value;
+
+ if ( $value < 1 || $value > 999 ) {
+ return;
+ }
+
+ break;
+
+ default:
+ $screen_option = false;
+
+ if ( '_page' === substr( $option, -5 ) || 'layout_columns' === $option ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Filters a screen option value before it is set.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * The dynamic portion of the hook name, `$option`, refers to the option name.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * The filter can also be used to modify non-standard [items]_per_page
+ * settings. See the parent function for a full list of standard options.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Returning false from the filter will skip saving the current option.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 5.4.2
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.8.0
+ * @since 5.4.2 Only applied to options ending with '_page',
+ * or the 'layout_columns' option.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @see set_screen_options()
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param mixed $screen_option The value to save instead of the option value.
- * Default false (to skip saving the current option).
- * @param string $option The option name.
- * @param int $value The option value.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param mixed $screen_option The value to save instead of the option value.
+ * Default false (to skip saving the current option).
+ * @param string $option The option name.
+ * @param int $value The option value.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $value = apply_filters( "set_screen_option_{$option}", $screen_option, $option, $value );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $screen_option = apply_filters( 'set-screen-option', $screen_option, $option, $value ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( false === $value ) {
- return;
- }
- break;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Filters a screen option value before it is set.
+ *
+ * The dynamic portion of the hook name, `$option`, refers to the option name.
+ *
+ * Returning false from the filter will skip saving the current option.
+ *
+ * @since 5.4.2
+ *
+ * @see set_screen_options()
+ *
+ * @param mixed $screen_option The value to save instead of the option value.
+ * Default false (to skip saving the current option).
+ * @param string $option The option name.
+ * @param int $value The option value.
+ */
+ $value = apply_filters( "set_screen_option_{$option}", $screen_option, $option, $value );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_user_meta( $user->ID, $option, $value );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( false === $value ) {
+ return;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $url = remove_query_arg( array( 'pagenum', 'apage', 'paged' ), wp_get_referer() );
- if ( isset( $_POST['mode'] ) ) {
- $url = add_query_arg( array( 'mode' => $_POST['mode'] ), $url );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ break;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_safe_redirect( $url );
- exit;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_user_meta( $user->ID, $option, $value );
+
+ $url = remove_query_arg( array( 'pagenum', 'apage', 'paged' ), wp_get_referer() );
+
+ if ( isset( $_POST['mode'] ) ) {
+ $url = add_query_arg( array( 'mode' => $_POST['mode'] ), $url );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ wp_safe_redirect( $url );
+ exit;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -754,28 +805,32 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.8.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $filename The file path to the configuration file
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return bool
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $filename The file path to the configuration file
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function iis7_rewrite_rule_exists( $filename ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! file_exists( $filename ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! class_exists( 'DOMDocument', false ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $doc = new DOMDocument();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $doc->load( $filename ) === false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $xpath = new DOMXPath( $doc );
</span><span class="cx" style="display: block; padding: 0 10px"> $rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( 0 == $rules->length ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ if ( 0 === $rules->length ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } else {
- return true;
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ return true;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -802,8 +857,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $doc->load( $filename ) === false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $xpath = new DOMXPath( $doc );
</span><span class="cx" style="display: block; padding: 0 10px"> $rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $rules->length > 0 ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $child = $rules->item( 0 );
</span><span class="cx" style="display: block; padding: 0 10px"> $parent = $child->parentNode;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -811,6 +868,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $doc->formatOutput = true;
</span><span class="cx" style="display: block; padding: 0 10px"> saveDomDocument( $doc, $filename );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -846,6 +904,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // First check if the rule already exists as in that case there is no need to re-add it.
</span><span class="cx" style="display: block; padding: 0 10px"> $wordpress_rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $wordpress_rules->length > 0 ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -852,6 +911,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Check the XPath to the rewrite rule and create XML nodes if they do not exist.
</span><span class="cx" style="display: block; padding: 0 10px"> $xmlnodes = $xpath->query( '/configuration/system.webServer/rewrite/rules' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $xmlnodes->length > 0 ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $rules_node = $xmlnodes->item( 0 );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -858,6 +918,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $rules_node = $doc->createElement( 'rules' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $xmlnodes = $xpath->query( '/configuration/system.webServer/rewrite' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $xmlnodes->length > 0 ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $rewrite_node = $xmlnodes->item( 0 );
</span><span class="cx" style="display: block; padding: 0 10px"> $rewrite_node->appendChild( $rules_node );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -866,21 +927,23 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $rewrite_node->appendChild( $rules_node );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $xmlnodes = $xpath->query( '/configuration/system.webServer' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $xmlnodes->length > 0 ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $system_webServer_node = $xmlnodes->item( 0 );
- $system_webServer_node->appendChild( $rewrite_node );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $system_webserver_node = $xmlnodes->item( 0 );
+ $system_webserver_node->appendChild( $rewrite_node );
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $system_webServer_node = $doc->createElement( 'system.webServer' );
- $system_webServer_node->appendChild( $rewrite_node );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $system_webserver_node = $doc->createElement( 'system.webServer' );
+ $system_webserver_node->appendChild( $rewrite_node );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $xmlnodes = $xpath->query( '/configuration' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $xmlnodes->length > 0 ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $config_node = $xmlnodes->item( 0 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $config_node->appendChild( $system_webServer_node );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $config_node->appendChild( $system_webserver_node );
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $config_node = $doc->createElement( 'configuration' );
</span><span class="cx" style="display: block; padding: 0 10px"> $doc->appendChild( $config_node );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $config_node->appendChild( $system_webServer_node );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $config_node->appendChild( $system_webserver_node );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -908,7 +971,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function saveDomDocument( $doc, $filename ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
</span><span class="cx" style="display: block; padding: 0 10px"> $config = $doc->saveXML();
</span><span class="cx" style="display: block; padding: 0 10px"> $config = preg_replace( "/([^\r])\n/", "$1\r\n", $config );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $fp = fopen( $filename, 'w' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ $fp = fopen( $filename, 'w' );
</ins><span class="cx" style="display: block; padding: 0 10px"> fwrite( $fp, $config );
</span><span class="cx" style="display: block; padding: 0 10px"> fclose( $fp );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -946,7 +1010,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $current_color ) || ! isset( $_wp_admin_css_colors[ $current_color ] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $current_color = 'fresh';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <fieldset id="color-picker" class="scheme-list">
</span><span class="cx" style="display: block; padding: 0 10px"> <legend class="screen-reader-text"><span><?php _e( 'Admin Color Scheme' ); ?></span></legend>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -955,7 +1018,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $_wp_admin_css_colors as $color => $color_info ) :
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <div class="color-option <?php echo ( $color == $current_color ) ? 'selected' : ''; ?>">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <div class="color-option <?php echo ( $color === $current_color ) ? 'selected' : ''; ?>">
</ins><span class="cx" style="display: block; padding: 0 10px"> <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 ); ?> />
</span><span class="cx" style="display: block; padding: 0 10px"> <input type="hidden" class="css_url" value="<?php echo esc_url( $color_info->url ); ?>" />
</span><span class="cx" style="display: block; padding: 0 10px"> <input type="hidden" class="icon_colors" value="<?php echo esc_attr( wp_json_encode( array( 'icons' => $color_info->icon_colors ) ) ); ?>" />
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -963,13 +1026,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <table class="color-palette">
</span><span class="cx" style="display: block; padding: 0 10px"> <tr>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> foreach ( $color_info->colors as $html_color ) {
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <td style="background-color: <?php echo esc_attr( $html_color ); ?>"> </td>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> </tr>
</span><span class="cx" style="display: block; padding: 0 10px"> </table>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -977,7 +1038,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> endforeach;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> </fieldset>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1065,13 +1125,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( array_key_exists( 'wp-check-locked-posts', $data ) && is_array( $data['wp-check-locked-posts'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $data['wp-check-locked-posts'] as $key ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = absint( substr( $key, 5 ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $post_id ) {
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $user_id = wp_check_post_lock( $post_id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $user_id ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $user = get_userdata( $user_id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $user && current_user_can( 'edit_post', $post_id ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $send = array(
</span><span class="cx" style="display: block; padding: 0 10px"> /* translators: %s: User's display name. */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1112,6 +1175,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $send = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = absint( $received['post_id'] );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $post_id ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return $response;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1122,6 +1186,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $user_id = wp_check_post_lock( $post_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $user = get_userdata( $user_id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $user ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $error = array(
</span><span class="cx" style="display: block; padding: 0 10px"> /* translators: %s: User's display name. */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1136,6 +1201,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $send['lock_error'] = $error;
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $new_lock = wp_set_post_lock( $post_id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $new_lock ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $send['new_lock'] = implode( ':', $new_lock );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1159,10 +1225,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_refresh_post_nonces( $response, $data, $screen_id ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( array_key_exists( 'wp-refresh-post-nonces', $data ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $received = $data['wp-refresh-post-nonces'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $received = $data['wp-refresh-post-nonces'];
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $response['wp-refresh-post-nonces'] = array( 'check' => 1 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = absint( $received['post_id'] );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $post_id ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return $response;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1199,6 +1267,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Refresh the Heartbeat nonce.
</span><span class="cx" style="display: block; padding: 0 10px"> $response['heartbeat_nonce'] = wp_create_nonce( 'heartbeat-nonce' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> return $response;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1451,8 +1520,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $key = md5( $version );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = get_site_transient( 'php_check_' . $key );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( false === $response ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $url = 'http://api.wordpress.org/core/serve-happy/1.0/';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( wp_http_supports( array( 'ssl' ) ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $url = set_url_scheme( $url, 'https' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>
</body>
</html>