<!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>[48164] trunk/src/wp-admin/includes/file.php: Docs: Improve DocBlocks in `wp-admin/includes/file.php` per the documentation standards.</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/48164">48164</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/48164","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>2020-06-25 09:37:25 +0000 (Thu, 25 Jun 2020)</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'>Docs: Improve DocBlocks in `wp-admin/includes/file.php` per the documentation standards.
See <a href="https://core.trac.wordpress.org/ticket/49572">#49572</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludesfilephp">trunk/src/wp-admin/includes/file.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminincludesfilephp"></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/file.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/file.php 2020-06-25 09:29:19 UTC (rev 48163)
+++ trunk/src/wp-admin/includes/file.php 2020-06-25 09:37:25 UTC (rev 48164)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -65,27 +65,28 @@
</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"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Get the description for standard WordPress theme files and other various standard
- * WordPress files
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the description for standard WordPress theme files.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 1.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @global array $wp_file_descriptions Theme file descriptions.
</span><span class="cx" style="display: block; padding: 0 10px"> * @global array $allowed_files List of allowed files.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file Filesystem path or filename
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
+ * @param string $file Filesystem path or filename.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return string Description of file from $wp_file_descriptions or basename of $file if description doesn't exist.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Appends 'Page Template' to basename of $file if the file is a page template
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Appends 'Page Template' to basename of $file if the file is a page template.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function get_file_description( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> global $wp_file_descriptions, $allowed_files;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $dirname = pathinfo( $file, PATHINFO_DIRNAME );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $dirname = pathinfo( $file, PATHINFO_DIRNAME );
+ $file_path = $allowed_files[ $file ];
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $file_path = $allowed_files[ $file ];
</del><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $wp_file_descriptions[ basename( $file ) ] ) && '.' === $dirname ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return $wp_file_descriptions[ basename( $file ) ];
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( file_exists( $file_path ) && is_file( $file_path ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $template_data = implode( '', file( $file_path ) );
</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 ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> /* translators: %s: Template name. */
</span><span class="cx" style="display: block; padding: 0 10px"> return sprintf( __( '%s Page Template' ), _cleanup_header_comment( $name[1] ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -96,15 +97,16 @@
</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"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Get the absolute filesystem path to the root of the WordPress installation
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the absolute filesystem path to the root of the WordPress installation.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 1.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return string Full filesystem path to the root of the WordPress installation
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return string Full filesystem path to the root of the WordPress installation.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function get_home_path() {
</span><span class="cx" style="display: block; padding: 0 10px"> $home = set_url_scheme( get_option( 'home' ), 'http' );
</span><span class="cx" style="display: block; padding: 0 10px"> $siteurl = set_url_scheme( get_option( 'siteurl' ), 'http' );
</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( $home ) && 0 !== strcasecmp( $home, $siteurl ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_path_rel_to_home = str_ireplace( $home, '', $siteurl ); /* $siteurl - $home */
</span><span class="cx" style="display: block; padding: 0 10px"> $pos = strripos( str_replace( '\\', '/', $_SERVER['SCRIPT_FILENAME'] ), trailingslashit( $wp_path_rel_to_home ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -119,6 +121,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"> * Returns a listing of all files in the specified folder and all subdirectories up to 100 levels deep.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * The depth of the recursiveness can be controlled by the $levels param.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.6.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -292,7 +295,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"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Print file editor templates (for plugins and themes).
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Prints file editor templates (for plugins and themes).
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.9.0
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -342,7 +345,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"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Attempt to edit a file for a theme or plugin.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Attempts to edit a file for a theme or plugin.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * When editing a PHP file, loopback requests will be made to the admin and the homepage
</span><span class="cx" style="display: block; padding: 0 10px"> * to attempt to see if there is a fatal error introduced. If so, the PHP change will be
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -500,6 +503,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( false === $written ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return new WP_Error( 'unable_to_write', __( 'Unable to write to 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"> wp_opcache_invalidate( $real_file, true );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $is_active && 'php' === $extension ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -629,17 +633,19 @@
</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"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Returns a filename of a Temporary unique file.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Returns a filename of a temporary unique file.
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * Please note that the calling function must unlink() this itself.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * The filename is based off the passed parameter or defaults to the current unix timestamp,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * while the directory can either be passed as well, or by leaving it blank, default to a writable temporary directory.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * while the directory can either be passed as well, or by leaving it blank, default to a writable
+ * temporary directory.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.6.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $filename Optional. Filename to base the Unique file off. Default empty.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $dir Optional. Directory to store the file in. Default empty.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return string a writable filename
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return string A writable filename.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_tempnam( $filename = '', $dir = '' ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $dir ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -683,7 +689,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 1.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $file File the user is attempting to edit.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string[] $allowed_files Optional. Array of allowed files to edit. `$file` must match an entry exactly.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string[] $allowed_files Optional. Array of allowed files to edit.
+ * `$file` must match an entry exactly.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return string|void Returns the file name on success, dies on failure.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function validate_file_to_edit( $file, $allowed_files = array() ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -706,20 +713,25 @@
</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"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Handle PHP uploads in WordPress, sanitizing file names, checking extensions for mime type,
- * and moving the file to the appropriate directory within the uploads directory.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Handles PHP uploads in WordPress.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Sanitizes file names, checks extensions for mime type, and moves the file
+ * to the appropriate directory within the uploads directory.
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access private
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.0.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @see wp_handle_upload_error
</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 string[] $file Reference to a single element of `$_FILES`. Call the function once for each uploaded file.
- * @param string[]|false $overrides An associative array of names => values to override default variables. Default false.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string[] $file Reference to a single element of `$_FILES`.
+ * Call the function once for each uploaded file.
+ * @param string[]|false $overrides An associative array of names => values
+ * to override default variables. Default false.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $time Time formatted in 'yyyy/mm'.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $action Expected value for `$_POST['action']`.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return string[] On success, returns an associative array of file attributes. On failure, returns
- * `$overrides['upload_error_handler']( &$file, $message )` or `array( 'error' => $message )`.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return string[] On success, returns an associative array of file attributes.
+ * On failure, returns `$overrides['upload_error_handler']( &$file, $message )`
+ * or `array( 'error' => $message )`.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function _wp_handle_upload( &$file, $overrides, $time, $action ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // The default error handler.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -953,13 +965,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @see _wp_handle_upload()
</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 array $file Reference to a single element of `$_FILES`. Call the function once for
- * each uploaded file.
- * @param array|bool $overrides Optional. An associative array of names=>values to override default
- * variables. Default false.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param array $file Reference to a single element of `$_FILES`.
+ * Call the function once for each uploaded file.
+ * @param array|bool $overrides Optional. An associative array of names => values
+ * to override default variables. Default false.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $time Optional. Time formatted in 'yyyy/mm'. Default null.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return array On success, returns an associative array of file attributes. On failure, returns
- * $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ).
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return array On success, returns an associative array of file attributes.
+ * On failure, returns `$overrides['upload_error_handler']( &$file, $message )`
+ * or `array( 'error' => $message )`.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_handle_upload( &$file, $overrides = false, $time = null ) {
</span><span class="cx" style="display: block; padding: 0 10px"> /*
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -983,12 +996,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @see _wp_handle_upload()
</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 array $file An array similar to that of a PHP `$_FILES` POST array
- * @param array|bool $overrides Optional. An associative array of names=>values to override default
- * variables. Default false.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param array $file Reference to a single element of `$_FILES`.
+ * Call the function once for each uploaded file.
+ * @param array|bool $overrides Optional. An associative array of names => values
+ * to override default variables. Default false.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $time Optional. Time formatted in 'yyyy/mm'. Default null.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return array On success, returns an associative array of file attributes. On failure, returns
- * $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ).
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return array On success, returns an associative array of file attributes.
+ * On failure, returns `$overrides['upload_error_handler']( &$file, $message )`
+ * or `array( 'error' => $message )`.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_handle_sideload( &$file, $overrides = false, $time = null ) {
</span><span class="cx" style="display: block; padding: 0 10px"> /*
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -999,6 +1014,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $overrides['action'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $action = $overrides['action'];
</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 _wp_handle_upload( $file, $overrides, $time, $action );
</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">@@ -1011,8 +1027,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.2.0 Signature Verification with SoftFail was added.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $url The URL of the file to download.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param int $timeout The timeout for the request to download the file. Default 300 seconds.
- * @param bool $signature_verification Whether to perform Signature Verification. Default false.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int $timeout The timeout for the request to download the file.
+ * Default 300 seconds.
+ * @param bool $signature_verification Whether to perform Signature Verification.
+ * Default false.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return string|WP_Error Filename on success, WP_Error on failure.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function download_url( $url, $timeout = 300, $signature_verification = false ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1359,7 +1377,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"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Retrieve the list of signing keys trusted by WordPress.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Retrieves the list of signing keys trusted by WordPress.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.2.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1741,6 +1759,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return new WP_Error( 'copy_failed_copy_dir', __( 'Could not copy file.' ), $to . $filename );
</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"> wp_opcache_invalidate( $to . $filename );
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( 'd' === $fileinfo['type'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $wp_filesystem->is_dir( $to . $filename ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1779,11 +1798,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
</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 array|false $args Optional. Connection args, These are passed directly to
- * the `WP_Filesystem_*()` classes. Default false.
- * @param string|false $context Optional. Context for get_filesystem_method(). Default false.
- * @param bool $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable. Default false.
- * @return bool|null True on success, false on failure, null if the filesystem method class file does not exist.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param array|false $args Optional. Connection args, These are passed
+ * directly to the `WP_Filesystem_*()` classes.
+ * Default false.
+ * @param string|false $context Optional. Context for get_filesystem_method().
+ * Default false.
+ * @param bool $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable.
+ * Default false.
+ * @return bool|null True on success, false on failure,
+ * null if the filesystem method class file does not exist.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function WP_Filesystem( $args = false, $context = false, $allow_relaxed_file_ownership = false ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
</span><span class="cx" style="display: block; padding: 0 10px"> global $wp_filesystem;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1942,9 +1965,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.6.0
</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 string $method Filesystem method to return.
- * @param array $args An array of connection details for the method.
- * @param string $context Full path to the directory that is tested for being writable.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $method Filesystem method to return.
+ * @param array $args An array of connection details for the method.
+ * @param string $context Full path to the directory that is tested for being writable.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param bool $allow_relaxed_file_ownership Whether to allow Group/World writable.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> return apply_filters( 'filesystem_method', $method, $args, $context, $allow_relaxed_file_ownership );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1968,15 +1991,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $form_post The URL to post the form to.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $type Optional. Chosen type of filesystem. Default empty.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param bool|WP_Error $error Optional. Whether the current request has failed to connect,
- * or an error object. Default false.
- * @param string $context Optional. Full path to the directory that is tested for being
- * writable. Default empty.
- * @param array $extra_fields Optional. Extra `POST` fields to be checked for inclusion in
- * the post. Default null.
- * @param bool $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable. Default false.
- * @return bool|array True if no filesystem credentials are required, false if they are required but have not been
- * provided, array of credentials if they are required and have been provided.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param bool|WP_Error $error Optional. Whether the current request has failed
+ * to connect, or an error object. Default false.
+ * @param string $context Optional. Full path to the directory that is tested
+ * for being writable. Default empty.
+ * @param array $extra_fields Optional. Extra `POST` fields to be checked
+ * for inclusion in the post. Default null.
+ * @param bool $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable.
+ * Default false.
+ * @return bool|array True if no filesystem credentials are required,
+ * false if they are required but have not been provided,
+ * array of credentials if they are required and have been provided.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function request_filesystem_credentials( $form_post, $type = '', $error = false, $context = '', $extra_fields = null, $allow_relaxed_file_ownership = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> global $pagenow;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2250,7 +2275,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"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Print the filesystem credentials modal when needed.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Prints the filesystem credentials modal when needed.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.2.0
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2278,7 +2303,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"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Attempt to clear the opcode cache for an individual PHP file.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Attempts to clear the opcode cache for an individual PHP file.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * This function can be called safely without having to check the file extension
</span><span class="cx" style="display: block; padding: 0 10px"> * or availability of the OPcache extension.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2285,15 +2310,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Whether or not invalidation is possible is cached to improve performance.
</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.5
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.5.0
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @link https://www.php.net/manual/en/function.opcache-invalidate.php
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $filepath Path to the file, including extension, for which the opcode cache is to be cleared.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param bool $force Invalidate even if the modification time is not newer than the file in cache. Default `false`.
- *
- * @return bool `true` if opcache was invalidated for `$filepath`, or there was nothing to invalidate.
- * `false` if opcache invalidation is not available, or is disabled via filter.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param bool $force Invalidate even if the modification time is not newer than the file in cache.
+ * Default false.
+ * @return bool True if opcache was invalidated for `$filepath`, or there was nothing to invalidate.
+ * False if opcache invalidation is not available, or is disabled via filter.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_opcache_invalidate( $filepath, $force = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> static $can_invalidate = null;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2309,9 +2334,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * If the host has this set, check whether the path in `opcache.restrict_api` matches
</span><span class="cx" style="display: block; padding: 0 10px"> * the beginning of the path of the origin 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">- * `$_SERVER['SCRIPT_FILENAME']` approximates the origin file's path, but
- * `realpath()` is necessary because `SCRIPT_FILENAME` can be a relative path
- * when run from CLI.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * `$_SERVER['SCRIPT_FILENAME']` approximates the origin file's path, but `realpath()`
+ * is necessary because `SCRIPT_FILENAME` can be a relative path when run from CLI.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * For more details, see:
</span><span class="cx" style="display: block; padding: 0 10px"> * - https://www.php.net/manual/en/opcache.configuration.php
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2318,10 +2342,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * - https://www.php.net/manual/en/reserved.variables.server.php
</span><span class="cx" style="display: block; padding: 0 10px"> * - https://core.trac.wordpress.org/ticket/36455
</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 ( null === $can_invalidate ) {
- $can_invalidate = function_exists( 'opcache_invalidate' ) &&
- ( ! ini_get( 'opcache.restrict_api' ) ||
- stripos( realpath( $_SERVER['SCRIPT_FILENAME'] ), ini_get( 'opcache.restrict_api' ) ) === 0 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( null === $can_invalidate
+ && function_exists( 'opcache_invalidate' )
+ && ( ! ini_get( 'opcache.restrict_api' )
+ || stripos( realpath( $_SERVER['SCRIPT_FILENAME'] ), ini_get( 'opcache.restrict_api' ) ) === 0 )
+ ) {
+ $can_invalidate = 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"> // If invalidation is not available, return early.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2337,9 +2363,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Filters whether to invalidate a file from the opcode cache.
</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.5
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.5.0
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param bool $will_invalidate Whether WordPress will invalidate `$filename`. Default `true`.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param bool $will_invalidate Whether WordPress will invalidate `$filename`. Default true.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $filename The PHP filename to invalidate.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> if ( apply_filters( 'wp_opcache_invalidate_file', true, $filepath ) ) {
</span></span></pre>
</div>
</div>
</body>
</html>