WordPress Field Guide. It is overflowing with detailed developer notes to help you build with WordPress.' ),
- __( 'https://make.wordpress.org/core/2023/07/18/wordpress-6-3-field-guide/' )
+ /* translators: 1: WordPress Field Guide link, 2: WordPress version number. */
+ __( 'Explore the WordPress %2$s Field Guide . Learn about the changes in this release with detailed developer notes to help you build with WordPress.' ),
+ esc_url( __( 'https://make.wordpress.org/core/wordpress-6-5-field-guide/' ) ),
+ '6.5'
);
?>
@@ -335,22 +265,22 @@
Read the WordPress %2$s Release Notes for more information on the included enhancements and issues fixed, installation information, developer notes and resources, release contributors, and the list of file changes in this release.' ),
+ __( 'Read the WordPress %2$s Release Notes for information on installation, enhancements, fixed issues, release contributors, learning resources, and the list of file changes.' ),
sprintf(
/* translators: %s: WordPress version number. */
esc_url( __( 'https://wordpress.org/documentation/wordpress-version/version-%s/' ) ),
- '6-3'
+ '6-5'
),
- '6.3'
+ '6.5'
);
?>
diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php
index fb1911002..b6645fd5c 100644
--- a/wp-admin/admin-ajax.php
+++ b/wp-admin/admin-ajax.php
@@ -117,6 +117,7 @@
'parse-media-shortcode',
'destroy-sessions',
'install-plugin',
+ 'activate-plugin',
'update-plugin',
'crop-image',
'generate-password',
@@ -169,6 +170,9 @@
add_action( 'wp_ajax_nopriv_heartbeat', 'wp_ajax_nopriv_heartbeat', 1 );
+// Register Plugin Dependencies Ajax calls.
+add_action( 'wp_ajax_check_plugin_dependencies', array( 'WP_Plugin_Dependencies', 'check_plugin_dependencies_during_ajax' ) );
+
$action = $_REQUEST['action'];
if ( is_user_logged_in() ) {
diff --git a/wp-admin/async-upload.php b/wp-admin/async-upload.php
index f0f6dd007..864f2be65 100644
--- a/wp-admin/async-upload.php
+++ b/wp-admin/async-upload.php
@@ -113,8 +113,8 @@
$id = media_handle_upload( 'async-upload', $post_id );
if ( is_wp_error( $id ) ) {
- printf(
- '
%s %s %s
',
+ $message = sprintf(
+ '%s
%s %s',
sprintf(
'
%s ',
__( 'Dismiss' )
@@ -126,6 +126,13 @@
),
esc_html( $id->get_error_message() )
);
+ wp_admin_notice(
+ $message,
+ array(
+ 'additional_classes' => array( 'error-div', 'error' ),
+ 'paragraph_wrap' => false,
+ )
+ );
exit;
}
diff --git a/wp-admin/authorize-application.php b/wp-admin/authorize-application.php
index 1eabb9633..8d931f466 100644
--- a/wp-admin/authorize-application.php
+++ b/wp-admin/authorize-application.php
@@ -137,9 +137,16 @@
-
-
-
+ get_error_message(),
+ array(
+ 'type' => 'error',
+ )
+ );
+ }
+ ?>
@@ -194,24 +201,25 @@
}
?>
-
-
-
-
- ' . esc_html( $app_name ) . ''
- );
- ?>
-
-
-
-
-
+
+
' . sprintf(
+ /* translators: %s: Application name. */
+ esc_html__( 'Your new password for %s is:' ),
+ '' . esc_html( $app_name ) . ' '
+ ) . '
+
+
+
+
' . __( 'Be sure to save this in a safe location. You will not be able to retrieve it.' ) . '
';
+ $args = array(
+ 'type' => 'success',
+ 'additional_classes' => array( 'notice-alt', 'below-h2' ),
+ 'paragraph_wrap' => false,
+ );
+ wp_admin_notice( $message, $args );
-
-
diff --git a/wp-admin/includes/class-wp-theme-install-list-table.php b/wp-admin/includes/class-wp-theme-install-list-table.php
index 318d8d872..945fb6e9e 100644
--- a/wp-admin/includes/class-wp-theme-install-list-table.php
+++ b/wp-admin/includes/class-wp-theme-install-list-table.php
@@ -333,7 +333,7 @@ public function single_row( $theme ) {
esc_url( wp_nonce_url( $install_url, 'install-theme_' . $theme->slug ) ),
/* translators: %s: Theme name. */
esc_attr( sprintf( _x( 'Install %s', 'theme' ), $name ) ),
- __( 'Install Now' )
+ _x( 'Install Now', 'theme' )
);
break;
}
diff --git a/wp-admin/includes/class-wp-themes-list-table.php b/wp-admin/includes/class-wp-themes-list-table.php
index 8d385f9a7..fce362011 100644
--- a/wp-admin/includes/class-wp-themes-list-table.php
+++ b/wp-admin/includes/class-wp-themes-list-table.php
@@ -212,7 +212,7 @@ public function display_rows() {
$activate_link,
/* translators: %s: Theme name. */
esc_attr( sprintf( _x( 'Activate “%s”', 'theme' ), $title ) ),
- __( 'Activate' )
+ _x( 'Activate', 'theme' )
);
if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
diff --git a/wp-admin/includes/class-wp-upgrader-skin.php b/wp-admin/includes/class-wp-upgrader-skin.php
index 598724f61..83b4ba472 100644
--- a/wp-admin/includes/class-wp-upgrader-skin.php
+++ b/wp-admin/includes/class-wp-upgrader-skin.php
@@ -240,7 +240,14 @@ protected function decrement_update_count( $type ) {
if ( defined( 'IFRAME_REQUEST' ) ) {
echo '';
} else {
diff --git a/wp-admin/includes/class-wp-upgrader.php b/wp-admin/includes/class-wp-upgrader.php
index 078c80e1c..6a6135d90 100644
--- a/wp-admin/includes/class-wp-upgrader.php
+++ b/wp-admin/includes/class-wp-upgrader.php
@@ -185,10 +185,11 @@ protected function schedule_temp_backup_cleanup() {
* @since 2.8.0
*/
public function generic_strings() {
- $this->strings['bad_request'] = __( 'Invalid data provided.' );
- $this->strings['fs_unavailable'] = __( 'Could not access filesystem.' );
- $this->strings['fs_error'] = __( 'Filesystem error.' );
- $this->strings['fs_no_root_dir'] = __( 'Unable to locate WordPress root directory.' );
+ $this->strings['bad_request'] = __( 'Invalid data provided.' );
+ $this->strings['fs_unavailable'] = __( 'Could not access filesystem.' );
+ $this->strings['fs_error'] = __( 'Filesystem error.' );
+ $this->strings['fs_no_root_dir'] = __( 'Unable to locate WordPress root directory.' );
+ /* translators: %s: Directory name. */
$this->strings['fs_no_content_dir'] = sprintf( __( 'Unable to locate WordPress content directory (%s).' ), 'wp-content' );
$this->strings['fs_no_plugins_dir'] = __( 'Unable to locate WordPress plugin directory.' );
$this->strings['fs_no_themes_dir'] = __( 'Unable to locate WordPress theme directory.' );
diff --git a/wp-admin/includes/class-wp-users-list-table.php b/wp-admin/includes/class-wp-users-list-table.php
index 43abd608a..8dfe3ce1a 100644
--- a/wp-admin/includes/class-wp-users-list-table.php
+++ b/wp-admin/includes/class-wp-users-list-table.php
@@ -163,7 +163,7 @@ public function no_items() {
* with this table.
*
* Provides a list of roles and user count for that role for easy
- * Filtersing of the user table.
+ * filtering of the user table.
*
* @since 3.1.0
*
@@ -524,12 +524,12 @@ public function single_row( $user_object, $style = '', $role = '', $numposts = 0
// Set up the checkbox (because the user is editable, otherwise it's empty).
$checkbox = sprintf(
- '
%2$s ' .
- '
',
+ '
' .
+ '
%3$s ',
$user_object->ID,
+ $role_classes,
/* translators: Hidden accessibility text. %s: User login. */
- sprintf( __( 'Select %s' ), $user_object->user_login ),
- $role_classes
+ sprintf( __( 'Select %s' ), $user_object->user_login )
);
} else {
@@ -680,5 +680,4 @@ protected function get_role_list( $user_object ) {
*/
return apply_filters( 'get_role_list', $role_list, $user_object );
}
-
}
diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php
index d745e72a5..2aeaa24e4 100644
--- a/wp-admin/includes/dashboard.php
+++ b/wp-admin/includes/dashboard.php
@@ -284,7 +284,6 @@ function wp_dashboard() {
" method="post" id="quick-press" class="initial-form hide-if-no-js">
-
-
-
+ array( 'error' ),
+ )
+ );
+ }
+ ?>
@@ -1082,7 +1088,11 @@ function wp_dashboard_recent_comments( $total_items = 5 ) {
}
foreach ( $possible as $comment ) {
- if ( ! current_user_can( 'read_post', $comment->comment_post_ID ) ) {
+ if ( ! current_user_can( 'edit_post', $comment->comment_post_ID )
+ && ( post_password_required( $comment->comment_post_ID )
+ || ! current_user_can( 'read_post', $comment->comment_post_ID ) )
+ ) {
+ // The user has no access to the post and thus cannot see the comments.
continue;
}
@@ -1103,16 +1113,7 @@ function wp_dashboard_recent_comments( $total_items = 5 ) {
echo '';
@@ -1167,8 +1168,15 @@ function wp_dashboard_rss_output( $widget_id ) {
* @return bool True on success, false on failure.
*/
function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array(), ...$args ) {
- $loading = '' . __( 'Loading…' ) . '
' . __( 'This widget requires JavaScript.' ) . '
';
$doing_ajax = wp_doing_ajax();
+ $loading = '' . __( 'Loading…' ) . '
';
+ $loading .= wp_get_admin_notice(
+ __( 'This widget requires JavaScript.' ),
+ array(
+ 'type' => 'error',
+ 'additional_classes' => array( 'inline', 'hide-if-js' ),
+ )
+ );
if ( empty( $check_urls ) ) {
$widgets = get_option( 'dashboard_widget_options' );
@@ -1350,25 +1358,19 @@ function wp_dashboard_events_news() {
* @since 4.8.0
*/
function wp_print_community_events_markup() {
- ?>
-
-
+ $community_events_notice = '' . ( 'This widget requires JavaScript.' ) . '
';
+ $community_events_notice .= '';
+ $community_events_notice .= '';
-
+ wp_admin_notice(
+ $community_events_notice,
+ array(
+ 'type' => 'error',
+ 'additional_classes' => array( 'community-events-errors', 'inline', 'hide-if-js' ),
+ 'paragraph_wrap' => false,
+ )
+ );
-
{{ event.title }}
+ <# if ( event.type ) {
+ const titleCaseEventType = event.type.replace(
+ /\w\S*/g,
+ function ( type ) { return type.charAt(0).toUpperCase() + type.substr(1).toLowerCase(); }
+ );
+ #>
+ {{ 'wordcamp' === event.type ? 'WordCamp' : titleCaseEventType }}
+
+ <# } #>
{{ event.location.location }}
@@ -1561,7 +1572,11 @@ function wp_dashboard_primary() {
*
* @param string $link The widget's secondary link URL.
*/
- 'link' => apply_filters( 'dashboard_secondary_link', __( 'https://planet.wordpress.org/' ) ),
+ 'link' => apply_filters(
+ 'dashboard_secondary_link',
+ /* translators: Link to the Planet website of the locale. */
+ __( 'https://planet.wordpress.org/' )
+ ),
/**
* Filters the secondary feed URL for the 'WordPress Events and News' dashboard widget.
@@ -1570,7 +1585,11 @@ function wp_dashboard_primary() {
*
* @param string $url The widget's secondary feed URL.
*/
- 'url' => apply_filters( 'dashboard_secondary_feed', __( 'https://planet.wordpress.org/feed/' ) ),
+ 'url' => apply_filters(
+ 'dashboard_secondary_feed',
+ /* translators: Link to the Planet feed of the locale. */
+ __( 'https://planet.wordpress.org/feed/' )
+ ),
/**
* Filters the secondary link title for the 'WordPress Events and News' dashboard widget.
diff --git a/wp-admin/includes/deprecated.php b/wp-admin/includes/deprecated.php
index 4d00161d6..2e192ccea 100644
--- a/wp-admin/includes/deprecated.php
+++ b/wp-admin/includes/deprecated.php
@@ -493,7 +493,7 @@ class WP_User_Search {
* @return WP_User_Search
*/
function __construct( $search_term = '', $page = '', $role = '' ) {
- _deprecated_function( __FUNCTION__, '3.1.0', 'WP_User_Query' );
+ _deprecated_class( 'WP_User_Search', '3.1.0', 'WP_User_Query' );
$this->search_term = wp_unslash( $search_term );
$this->raw_page = ( '' == $page ) ? false : (int) $page;
@@ -516,6 +516,7 @@ function __construct( $search_term = '', $page = '', $role = '' ) {
* @return WP_User_Search
*/
public function WP_User_Search( $search_term = '', $page = '', $role = '' ) {
+ _deprecated_constructor( 'WP_User_Search', '3.1.0', get_class( $this ) );
self::__construct( $search_term, $page, $role );
}
@@ -1155,7 +1156,7 @@ function wp_nav_menu_locations_meta_box() {
/**
* This was once used to kick-off the Core Updater.
*
- * Deprecated in favor of instantating a Core_Upgrader instance directly,
+ * Deprecated in favor of instantiating a Core_Upgrader instance directly,
* and calling the 'upgrade' method.
*
* @since 2.7.0
@@ -1177,7 +1178,7 @@ function wp_update_core($current, $feedback = '') {
/**
* This was once used to kick-off the Plugin Updater.
*
- * Deprecated in favor of instantating a Plugin_Upgrader instance directly,
+ * Deprecated in favor of instantiating a Plugin_Upgrader instance directly,
* and calling the 'upgrade' method.
* Unused since 2.8.0.
*
diff --git a/wp-admin/includes/export.php b/wp-admin/includes/export.php
index 9610ac8c9..d05f98f73 100644
--- a/wp-admin/includes/export.php
+++ b/wp-admin/includes/export.php
@@ -144,6 +144,52 @@ function export_wp( $args = array() ) {
// Grab a snapshot of post IDs, just in case it changes during the export.
$post_ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} $join WHERE $where" );
+ // Get IDs for the attachments of each post, unless all content is already being exported.
+ if ( ! in_array( $args['content'], array( 'all', 'attachment' ), true ) ) {
+ // Array to hold all additional IDs (attachments and thumbnails).
+ $additional_ids = array();
+
+ // Create a copy of the post IDs array to avoid modifying the original array.
+ $processing_ids = $post_ids;
+
+ while ( $next_posts = array_splice( $processing_ids, 0, 20 ) ) {
+ $posts_in = array_map( 'absint', $next_posts );
+ $placeholders = array_fill( 0, count( $posts_in ), '%d' );
+
+ // Create a string for the placeholders.
+ $in_placeholder = implode( ',', $placeholders );
+
+ // Prepare the SQL statement for attachment ids.
+ $attachment_ids = $wpdb->get_col(
+ $wpdb->prepare(
+ "
+ SELECT ID
+ FROM $wpdb->posts
+ WHERE post_parent IN ($in_placeholder) AND post_type = 'attachment'
+ ",
+ $posts_in
+ )
+ );
+
+ $thumbnails_ids = $wpdb->get_col(
+ $wpdb->prepare(
+ "
+ SELECT meta_value
+ FROM $wpdb->postmeta
+ WHERE $wpdb->postmeta.post_id IN ($in_placeholder)
+ AND $wpdb->postmeta.meta_key = '_thumbnail_id'
+ ",
+ $posts_in
+ )
+ );
+
+ $additional_ids = array_merge( $additional_ids, $attachment_ids, $thumbnails_ids );
+ }
+
+ // Merge the additional IDs back with the original post IDs after processing all posts
+ $post_ids = array_unique( array_merge( $post_ids, $additional_ids ) );
+ }
+
/*
* Get the requested terms ready, empty unless posts filtered by category
* or all content.
diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php
index b9f58b32a..583256955 100644
--- a/wp-admin/includes/file.php
+++ b/wp-admin/includes/file.php
@@ -656,7 +656,7 @@ function wp_edit_theme_plugin_file( $args ) {
/**
* Returns a filename of a temporary unique file.
*
- * Please note that the calling function must unlink() this itself.
+ * Please note that the calling function must delete or move the file.
*
* The filename is based off the passed parameter or defaults to the current unix timestamp,
* while the directory can either be passed as well, or by leaving it blank, default to a writable
@@ -777,9 +777,9 @@ function validate_file_to_edit( $file, $allowed_files = array() ) {
* An array of override parameters for this file, or boolean false if none are provided.
*
* @type callable $upload_error_handler Function to call when there is an error during the upload process.
- * @see wp_handle_upload_error().
+ * See {@see wp_handle_upload_error()}.
* @type callable $unique_filename_callback Function to call when determining a unique file name for the file.
- * @see wp_unique_filename().
+ * See {@see wp_unique_filename()}.
* @type string[] $upload_error_strings The strings that describe the error indicated in
* `$_FILES[{form field}]['error']`.
* @type bool $test_form Whether to test that the `$_POST['action']` parameter is as expected.
@@ -845,7 +845,7 @@ function wp_handle_upload_error( &$file, $message ) {
* @since 5.7.0
*
* @param array|false $overrides An array of override parameters for this file. Boolean false if none are
- * provided. @see _wp_handle_upload().
+ * provided. See {@see _wp_handle_upload()}.
* @param array $file {
* Reference to a single element from `$_FILES`.
*
@@ -1139,7 +1139,7 @@ function wp_handle_sideload( &$file, $overrides = false, $time = null ) {
/**
* Downloads a URL to a local temporary file using the WordPress HTTP API.
*
- * Please note that the calling function must unlink() the file.
+ * Please note that the calling function must delete or move the file.
*
* @since 2.5.0
* @since 5.2.0 Signature Verification with SoftFail was added.
@@ -1153,7 +1153,7 @@ function wp_handle_sideload( &$file, $overrides = false, $time = null ) {
* @return string|WP_Error Filename on success, WP_Error on failure.
*/
function download_url( $url, $timeout = 300, $signature_verification = false ) {
- // WARNING: The file is not automatically deleted, the script must unlink() the file.
+ // WARNING: The file is not automatically deleted, the script must delete or move the file.
if ( ! $url ) {
return new WP_Error( 'http_no_url', __( 'Invalid URL Provided.' ) );
}
@@ -1266,7 +1266,7 @@ function download_url( $url, $timeout = 300, $signature_verification = false ) {
$signature_verification = in_array( parse_url( $url, PHP_URL_HOST ), $signed_hostnames, true );
}
- // Perform signature valiation if supported.
+ // Perform signature validation if supported.
if ( $signature_verification ) {
$signature = wp_remote_retrieve_header( $response, 'X-Content-Signature' );
@@ -1493,7 +1493,7 @@ function verify_file_signature( $filename, $signatures, $filename_for_errors = f
// Ensure only valid-length signatures are considered.
if ( SODIUM_CRYPTO_SIGN_BYTES !== strlen( $signature_raw ) ) {
- $skipped_signature++;
+ ++$skipped_signature;
continue;
}
@@ -1502,7 +1502,7 @@ function verify_file_signature( $filename, $signatures, $filename_for_errors = f
// Only pass valid public keys through.
if ( SODIUM_CRYPTO_SIGN_PUBLICKEYBYTES !== strlen( $key_raw ) ) {
- $skipped_key++;
+ ++$skipped_key;
continue;
}
@@ -1563,6 +1563,37 @@ function wp_trusted_keys() {
return apply_filters( 'wp_trusted_keys', $trusted_keys );
}
+/**
+ * Determines whether the given file is a valid ZIP file.
+ *
+ * This function does not test to ensure that a file exists. Non-existent files
+ * are not valid ZIPs, so those will also return false.
+ *
+ * @since 6.4.4
+ *
+ * @param string $file Full path to the ZIP file.
+ * @return bool Whether the file is a valid ZIP file.
+ */
+function wp_zip_file_is_valid( $file ) {
+ /** This filter is documented in wp-admin/includes/file.php */
+ if ( class_exists( 'ZipArchive', false ) && apply_filters( 'unzip_file_use_ziparchive', true ) ) {
+ $archive = new ZipArchive();
+ $archive_is_valid = $archive->open( $file, ZipArchive::CHECKCONS );
+ if ( true === $archive_is_valid ) {
+ $archive->close();
+ return true;
+ }
+ }
+
+ // Fall through to PclZip if ZipArchive is not available, or encountered an error opening the file.
+ require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
+
+ $archive = new PclZip( $file );
+ $archive_is_valid = is_array( $archive->properties() );
+
+ return $archive_is_valid;
+}
+
/**
* Unzips a specified ZIP file to a location on the filesystem via the WordPress
* Filesystem Abstraction.
@@ -1672,6 +1703,7 @@ function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) {
$info = $z->statIndex( $i );
if ( ! $info ) {
+ $z->close();
return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) );
}
@@ -1697,6 +1729,9 @@ function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) {
}
}
+ // Enough space to unzip the file and copy its contents, with a 10% buffer.
+ $required_space = $uncompressed_size * 2.1;
+
/*
* disk_free_space() could return false. Assume that any falsey value is an error.
* A disk that has zero free bytes has bigger problems.
@@ -1705,7 +1740,8 @@ function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) {
if ( wp_doing_cron() ) {
$available_space = function_exists( 'disk_free_space' ) ? @disk_free_space( WP_CONTENT_DIR ) : false;
- if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) {
+ if ( $available_space && ( $required_space > $available_space ) ) {
+ $z->close();
return new WP_Error(
'disk_full_unzip_file',
__( 'Could not copy files. You may have run out of disk space.' ),
@@ -1743,15 +1779,36 @@ function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) {
foreach ( $needed_dirs as $_dir ) {
// Only check to see if the Dir exists upon creation failure. Less I/O this way.
if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) ) {
+ $z->close();
return new WP_Error( 'mkdir_failed_ziparchive', __( 'Could not create directory.' ), $_dir );
}
}
- unset( $needed_dirs );
+
+ /**
+ * Filters archive unzipping to override with a custom process.
+ *
+ * @since 6.4.0
+ *
+ * @param null|true|WP_Error $result The result of the override. True on success, otherwise WP Error. Default null.
+ * @param string $file Full path and filename of ZIP archive.
+ * @param string $to Full path on the filesystem to extract archive to.
+ * @param string[] $needed_dirs A full list of required folders that need to be created.
+ * @param float $required_space The space required to unzip the file and copy its contents, with a 10% buffer.
+ */
+ $pre = apply_filters( 'pre_unzip_file', null, $file, $to, $needed_dirs, $required_space );
+
+ if ( null !== $pre ) {
+ // Ensure the ZIP file archive has been closed.
+ $z->close();
+
+ return $pre;
+ }
for ( $i = 0; $i < $z->numFiles; $i++ ) {
$info = $z->statIndex( $i );
if ( ! $info ) {
+ $z->close();
return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) );
}
@@ -1771,17 +1828,34 @@ function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) {
$contents = $z->getFromIndex( $i );
if ( false === $contents ) {
+ $z->close();
return new WP_Error( 'extract_failed_ziparchive', __( 'Could not extract file from archive.' ), $info['name'] );
}
if ( ! $wp_filesystem->put_contents( $to . $info['name'], $contents, FS_CHMOD_FILE ) ) {
+ $z->close();
return new WP_Error( 'copy_failed_ziparchive', __( 'Could not copy file.' ), $info['name'] );
}
}
$z->close();
- return true;
+ /**
+ * Filters the result of unzipping an archive.
+ *
+ * @since 6.4.0
+ *
+ * @param true|WP_Error $result The result of unzipping the archive. True on success, otherwise WP_Error. Default true.
+ * @param string $file Full path and filename of ZIP archive.
+ * @param string $to Full path on the filesystem the archive was extracted to.
+ * @param string[] $needed_dirs A full list of required folders that were created.
+ * @param float $required_space The space required to unzip the file and copy its contents, with a 10% buffer.
+ */
+ $result = apply_filters( 'unzip_file', true, $file, $to, $needed_dirs, $required_space );
+
+ unset( $needed_dirs );
+
+ return $result;
}
/**
@@ -1838,6 +1912,9 @@ function _unzip_file_pclzip( $file, $to, $needed_dirs = array() ) {
$needed_dirs[] = $to . untrailingslashit( $file['folder'] ? $file['filename'] : dirname( $file['filename'] ) );
}
+ // Enough space to unzip the file and copy its contents, with a 10% buffer.
+ $required_space = $uncompressed_size * 2.1;
+
/*
* disk_free_space() could return false. Assume that any falsey value is an error.
* A disk that has zero free bytes has bigger problems.
@@ -1846,7 +1923,7 @@ function _unzip_file_pclzip( $file, $to, $needed_dirs = array() ) {
if ( wp_doing_cron() ) {
$available_space = function_exists( 'disk_free_space' ) ? @disk_free_space( WP_CONTENT_DIR ) : false;
- if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) {
+ if ( $available_space && ( $required_space > $available_space ) ) {
return new WP_Error(
'disk_full_unzip_file',
__( 'Could not copy files. You may have run out of disk space.' ),
@@ -1887,7 +1964,13 @@ function _unzip_file_pclzip( $file, $to, $needed_dirs = array() ) {
return new WP_Error( 'mkdir_failed_pclzip', __( 'Could not create directory.' ), $_dir );
}
}
- unset( $needed_dirs );
+
+ /** This filter is documented in src/wp-admin/includes/file.php */
+ $pre = apply_filters( 'pre_unzip_file', null, $file, $to, $needed_dirs, $required_space );
+
+ if ( null !== $pre ) {
+ return $pre;
+ }
// Extract the files from the zip.
foreach ( $archive_files as $file ) {
@@ -1909,7 +1992,12 @@ function _unzip_file_pclzip( $file, $to, $needed_dirs = array() ) {
}
}
- return true;
+ /** This action is documented in src/wp-admin/includes/file.php */
+ $result = apply_filters( 'unzip_file', true, $file, $to, $needed_dirs, $required_space );
+
+ unset( $needed_dirs );
+
+ return $result;
}
/**
@@ -2426,7 +2514,13 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false,
if ( is_wp_error( $error ) ) {
$error_string = esc_html( $error->get_error_message() );
}
- echo '
';
+ wp_admin_notice(
+ $error_string,
+ array(
+ 'id' => 'message',
+ 'additional_classes' => array( 'error' ),
+ )
+ );
}
$types = array();
@@ -2701,7 +2795,6 @@ function wp_opcache_invalidate_directory( $dir ) {
__( '%s expects a non-empty string.' ),
'
wp_opcache_invalidate_directory()
'
);
- // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
trigger_error( $error_message );
}
return;
@@ -2726,7 +2819,7 @@ function wp_opcache_invalidate_directory( $dir ) {
* with sub-directories represented as nested arrays.
* @param string $path Absolute path to the directory.
*/
- $invalidate_directory = static function( $dirlist, $path ) use ( &$invalidate_directory ) {
+ $invalidate_directory = static function ( $dirlist, $path ) use ( &$invalidate_directory ) {
$path = trailingslashit( $path );
foreach ( $dirlist as $name => $details ) {
diff --git a/wp-admin/includes/image-edit.php b/wp-admin/includes/image-edit.php
index 55d7070a9..2d150e691 100644
--- a/wp-admin/includes/image-edit.php
+++ b/wp-admin/includes/image-edit.php
@@ -32,15 +32,16 @@ function wp_image_editor( $post_id, $msg = false ) {
$backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );
$can_restore = false;
+
if ( ! empty( $backup_sizes ) && isset( $backup_sizes['full-orig'], $meta['file'] ) ) {
$can_restore = wp_basename( $meta['file'] ) !== $backup_sizes['full-orig']['file'];
}
if ( $msg ) {
if ( isset( $msg->error ) ) {
- $note = "
";
+ $note = "
";
} elseif ( isset( $msg->msg ) ) {
- $note = "
";
+ $note = "
";
}
}
@@ -62,7 +63,7 @@ function wp_image_editor( $post_id, $msg = false ) {
, this );" aria-expanded="false" aria-controls="imgedit-crop" class="imgedit-crop button disabled" disabled>
@@ -389,6 +390,12 @@ function wp_stream_image( $image, $mime_type, $attachment_id ) {
return imagewebp( $image, null, 90 );
}
return false;
+ case 'image/avif':
+ if ( function_exists( 'imageavif' ) ) {
+ header( 'Content-Type: image/avif' );
+ return imageavif( $image, null, 90 );
+ }
+ return false;
default:
return false;
}
@@ -493,6 +500,11 @@ function wp_save_image_file( $filename, $image, $mime_type, $post_id ) {
return imagewebp( $image, $filename );
}
return false;
+ case 'image/avif':
+ if ( function_exists( 'imageavif' ) ) {
+ return imageavif( $image, $filename );
+ }
+ return false;
default:
return false;
}
@@ -636,15 +648,18 @@ function image_edit_apply_changes( $image, $changes ) {
$obj->sel = $obj->c;
unset( $obj->c );
}
+
$changes[ $key ] = $obj;
}
// Combine operations.
if ( count( $changes ) > 1 ) {
$filtered = array( $changes[0] );
+
for ( $i = 0, $j = 1, $c = count( $changes ); $j < $c; $j++ ) {
$combined = false;
- if ( $filtered[ $i ]->type == $changes[ $j ]->type ) {
+
+ if ( $filtered[ $i ]->type === $changes[ $j ]->type ) {
switch ( $filtered[ $i ]->type ) {
case 'rotate':
$filtered[ $i ]->angle += $changes[ $j ]->angle;
@@ -656,10 +671,12 @@ function image_edit_apply_changes( $image, $changes ) {
break;
}
}
+
if ( ! $combined ) {
$filtered[ ++$i ] = $changes[ $j ];
}
}
+
$changes = $filtered;
unset( $filtered );
}
@@ -693,7 +710,7 @@ function image_edit_apply_changes( $image, $changes ) {
foreach ( $changes as $operation ) {
switch ( $operation->type ) {
case 'rotate':
- if ( 0 != $operation->angle ) {
+ if ( 0 !== $operation->angle ) {
if ( $image instanceof WP_Image_Editor ) {
$image->rotate( $operation->angle );
} else {
@@ -702,11 +719,11 @@ function image_edit_apply_changes( $image, $changes ) {
}
break;
case 'flip':
- if ( 0 != $operation->axis ) {
+ if ( 0 !== $operation->axis ) {
if ( $image instanceof WP_Image_Editor ) {
- $image->flip( ( $operation->axis & 1 ) != 0, ( $operation->axis & 2 ) != 0 );
+ $image->flip( ( $operation->axis & 1 ) !== 0, ( $operation->axis & 2 ) !== 0 );
} else {
- $image = _flip_image_resource( $image, ( $operation->axis & 1 ) != 0, ( $operation->axis & 2 ) != 0 );
+ $image = _flip_image_resource( $image, ( $operation->axis & 1 ) !== 0, ( $operation->axis & 2 ) !== 0 );
}
}
break;
@@ -801,9 +818,8 @@ function wp_restore_image( $post_id ) {
if ( isset( $backup_sizes['full-orig'] ) && is_array( $backup_sizes['full-orig'] ) ) {
$data = $backup_sizes['full-orig'];
- if ( $parts['basename'] != $data['file'] ) {
+ if ( $parts['basename'] !== $data['file'] ) {
if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE ) {
-
// Delete only if it's an edited image.
if ( preg_match( '/-e[0-9]{13}\./', $parts['basename'] ) ) {
wp_delete_file( $file );
@@ -828,9 +844,9 @@ function wp_restore_image( $post_id ) {
foreach ( $default_sizes as $default_size ) {
if ( isset( $backup_sizes[ "$default_size-orig" ] ) ) {
$data = $backup_sizes[ "$default_size-orig" ];
- if ( isset( $meta['sizes'][ $default_size ] ) && $meta['sizes'][ $default_size ]['file'] != $data['file'] ) {
- if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE ) {
+ if ( isset( $meta['sizes'][ $default_size ] ) && $meta['sizes'][ $default_size ]['file'] !== $data['file'] ) {
+ if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE ) {
// Delete only if it's an edited image.
if ( preg_match( '/-e[0-9]{13}-/', $meta['sizes'][ $default_size ]['file'] ) ) {
$delete_file = path_join( $parts['dirname'], $meta['sizes'][ $default_size ]['file'] );
@@ -847,9 +863,9 @@ function wp_restore_image( $post_id ) {
}
}
- if ( ! wp_update_attachment_metadata( $post_id, $meta ) ||
- ( $old_backup_sizes !== $backup_sizes && ! update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes ) ) ) {
-
+ if ( ! wp_update_attachment_metadata( $post_id, $meta )
+ || ( $old_backup_sizes !== $backup_sizes && ! update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes ) )
+ ) {
$msg->error = __( 'Cannot save image metadata.' );
return $msg;
}
@@ -858,6 +874,7 @@ function wp_restore_image( $post_id ) {
$msg->error = __( 'Image metadata is inconsistent.' );
} else {
$msg->msg = __( 'Image restored successfully.' );
+
if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE ) {
delete_post_meta( $post_id, '_wp_attachment_backup_sizes' );
}
@@ -886,35 +903,36 @@ function wp_save_image( $post_id ) {
$post = get_post( $post_id );
$img = wp_get_image_editor( _load_image_to_edit_path( $post_id, 'full' ) );
+
if ( is_wp_error( $img ) ) {
$return->error = esc_js( __( 'Unable to create new image.' ) );
return $return;
}
- $fwidth = ! empty( $_REQUEST['fwidth'] ) ? (int) $_REQUEST['fwidth'] : 0;
- $fheight = ! empty( $_REQUEST['fheight'] ) ? (int) $_REQUEST['fheight'] : 0;
- $target = ! empty( $_REQUEST['target'] ) ? preg_replace( '/[^a-z0-9_-]+/i', '', $_REQUEST['target'] ) : '';
- $scale = ! empty( $_REQUEST['do'] ) && 'scale' === $_REQUEST['do'];
+ $full_width = ! empty( $_REQUEST['fwidth'] ) ? (int) $_REQUEST['fwidth'] : 0;
+ $full_height = ! empty( $_REQUEST['fheight'] ) ? (int) $_REQUEST['fheight'] : 0;
+ $target = ! empty( $_REQUEST['target'] ) ? preg_replace( '/[^a-z0-9_-]+/i', '', $_REQUEST['target'] ) : '';
+ $scale = ! empty( $_REQUEST['do'] ) && 'scale' === $_REQUEST['do'];
/** This filter is documented in wp-admin/includes/image-edit.php */
$edit_thumbnails_separately = (bool) apply_filters( 'image_edit_thumbnails_separately', false );
if ( $scale ) {
- $size = $img->get_size();
- $sX = $size['width'];
- $sY = $size['height'];
+ $size = $img->get_size();
+ $original_width = $size['width'];
+ $original_height = $size['height'];
- if ( $sX < $fwidth || $sY < $fheight ) {
+ if ( $full_width > $original_width || $full_height > $original_height ) {
$return->error = esc_js( __( 'Images cannot be scaled to a size larger than the original.' ) );
return $return;
}
- if ( $fwidth > 0 && $fheight > 0 ) {
+ if ( $full_width > 0 && $full_height > 0 ) {
// Check if it has roughly the same w / h ratio.
- $diff = round( $sX / $sY, 2 ) - round( $fwidth / $fheight, 2 );
+ $diff = round( $original_width / $original_height, 2 ) - round( $full_width / $full_height, 2 );
if ( -0.1 < $diff && $diff < 0.1 ) {
// Scale the full size image.
- if ( $img->resize( $fwidth, $fheight ) ) {
+ if ( $img->resize( $full_width, $full_height ) ) {
$scaled = true;
}
}
@@ -955,8 +973,9 @@ function wp_save_image( $post_id ) {
$filename = pathinfo( $path, PATHINFO_FILENAME );
$suffix = time() . rand( 100, 999 );
- if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE &&
- isset( $backup_sizes['full-orig'] ) && $backup_sizes['full-orig']['file'] != $basename ) {
+ if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE
+ && isset( $backup_sizes['full-orig'] ) && $backup_sizes['full-orig']['file'] !== $basename
+ ) {
if ( $edit_thumbnails_separately && 'thumbnail' === $target ) {
$new_path = "{$dirname}/{$filename}-temp.{$ext}";
@@ -969,8 +988,9 @@ function wp_save_image( $post_id ) {
$filename .= "-e{$suffix}";
$new_filename = "{$filename}.{$ext}";
$new_path = "{$dirname}/$new_filename";
+
if ( file_exists( $new_path ) ) {
- $suffix++;
+ ++$suffix;
} else {
break;
}
@@ -985,8 +1005,11 @@ function wp_save_image( $post_id ) {
if ( 'nothumb' === $target || 'all' === $target || 'full' === $target || $scaled ) {
$tag = false;
+
if ( isset( $backup_sizes['full-orig'] ) ) {
- if ( ( ! defined( 'IMAGE_EDIT_OVERWRITE' ) || ! IMAGE_EDIT_OVERWRITE ) && $backup_sizes['full-orig']['file'] !== $basename ) {
+ if ( ( ! defined( 'IMAGE_EDIT_OVERWRITE' ) || ! IMAGE_EDIT_OVERWRITE )
+ && $backup_sizes['full-orig']['file'] !== $basename
+ ) {
$tag = "full-$suffix";
}
} else {
@@ -1000,6 +1023,7 @@ function wp_save_image( $post_id ) {
'file' => $basename,
);
}
+
$success = ( $path === $new_path ) || update_attached_file( $post_id, $new_path );
$meta['file'] = _wp_relative_upload_path( $new_path );
@@ -1045,9 +1069,12 @@ function wp_save_image( $post_id ) {
foreach ( $sizes as $size ) {
$tag = false;
+
if ( isset( $meta['sizes'][ $size ] ) ) {
if ( isset( $backup_sizes[ "$size-orig" ] ) ) {
- if ( ( ! defined( 'IMAGE_EDIT_OVERWRITE' ) || ! IMAGE_EDIT_OVERWRITE ) && $backup_sizes[ "$size-orig" ]['file'] != $meta['sizes'][ $size ]['file'] ) {
+ if ( ( ! defined( 'IMAGE_EDIT_OVERWRITE' ) || ! IMAGE_EDIT_OVERWRITE )
+ && $backup_sizes[ "$size-orig" ]['file'] !== $meta['sizes'][ $size ]['file']
+ ) {
$tag = "$size-$suffix";
}
} else {
@@ -1088,10 +1115,12 @@ function wp_save_image( $post_id ) {
if ( 'thumbnail' === $target || 'all' === $target || 'full' === $target ) {
// Check if it's an image edit from attachment edit screen.
if ( ! empty( $_REQUEST['context'] ) && 'edit-attachment' === $_REQUEST['context'] ) {
- $thumb_url = wp_get_attachment_image_src( $post_id, array( 900, 600 ), true );
+ $thumb_url = wp_get_attachment_image_src( $post_id, array( 900, 600 ), true );
+
$return->thumbnail = $thumb_url[0];
} else {
$file_url = wp_get_attachment_url( $post_id );
+
if ( ! empty( $meta['sizes']['thumbnail'] ) ) {
$thumb = $meta['sizes']['thumbnail'];
$return->thumbnail = path_join( dirname( $file_url ), $thumb['file'] );
@@ -1109,5 +1138,6 @@ function wp_save_image( $post_id ) {
}
$return->msg = esc_js( __( 'Image saved' ) );
+
return $return;
}
diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php
index fabe9da7c..69f58d52e 100644
--- a/wp-admin/includes/image.php
+++ b/wp-admin/includes/image.php
@@ -482,6 +482,62 @@ function _wp_make_subsizes( $new_sizes, $file, $image_meta, $attachment_id ) {
return $image_meta;
}
+/**
+ * Copy parent attachment properties to newly cropped image.
+ *
+ * @since 6.5.0
+ *
+ * @param string $cropped Path to the cropped image file.
+ * @param int $parent_attachment_id Parent file Attachment ID.
+ * @param string $context Control calling the function.
+ * @return array Properties of attachment.
+ */
+function wp_copy_parent_attachment_properties( $cropped, $parent_attachment_id, $context = '' ) {
+ $parent = get_post( $parent_attachment_id );
+ $parent_url = wp_get_attachment_url( $parent->ID );
+ $parent_basename = wp_basename( $parent_url );
+ $url = str_replace( wp_basename( $parent_url ), wp_basename( $cropped ), $parent_url );
+
+ $size = wp_getimagesize( $cropped );
+ $image_type = $size ? $size['mime'] : 'image/jpeg';
+
+ $sanitized_post_title = sanitize_file_name( $parent->post_title );
+ $use_original_title = (
+ ( '' !== trim( $parent->post_title ) ) &&
+ /*
+ * Check if the original image has a title other than the "filename" default,
+ * meaning the image had a title when originally uploaded or its title was edited.
+ */
+ ( $parent_basename !== $sanitized_post_title ) &&
+ ( pathinfo( $parent_basename, PATHINFO_FILENAME ) !== $sanitized_post_title )
+ );
+ $use_original_description = ( '' !== trim( $parent->post_content ) );
+
+ $attachment = array(
+ 'post_title' => $use_original_title ? $parent->post_title : wp_basename( $cropped ),
+ 'post_content' => $use_original_description ? $parent->post_content : $url,
+ 'post_mime_type' => $image_type,
+ 'guid' => $url,
+ 'context' => $context,
+ );
+
+ // Copy the image caption attribute (post_excerpt field) from the original image.
+ if ( '' !== trim( $parent->post_excerpt ) ) {
+ $attachment['post_excerpt'] = $parent->post_excerpt;
+ }
+
+ // Copy the image alt text attribute from the original image.
+ if ( '' !== trim( $parent->_wp_attachment_image_alt ) ) {
+ $attachment['meta_input'] = array(
+ '_wp_attachment_image_alt' => wp_slash( $parent->_wp_attachment_image_alt ),
+ );
+ }
+
+ $attachment['post_parent'] = $parent_attachment_id;
+
+ return $attachment;
+}
+
/**
* Generates attachment meta data and create image sub-sizes for images.
*
@@ -700,7 +756,7 @@ function wp_exif_frac2dec( $str ) {
}
// The denominator must not be zero.
- if ( 0 == $denominator ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- Deliberate loose comparison.
+ if ( 0 == $denominator ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual -- Deliberate loose comparison.
return 0;
}
@@ -782,7 +838,7 @@ function wp_read_image_metadata( $file ) {
) {
$iptc = iptcparse( $info['APP13'] );
} else {
- // phpcs:ignore WordPress.PHP.NoSilencedErrors -- Silencing notice and warning is intentional. See https://core.trac.wordpress.org/ticket/42480
+ // Silencing notice and warning is intentional. See https://core.trac.wordpress.org/ticket/42480
$iptc = @iptcparse( $info['APP13'] );
}
@@ -855,7 +911,7 @@ function wp_read_image_metadata( $file ) {
) {
$exif = exif_read_data( $file );
} else {
- // phpcs:ignore WordPress.PHP.NoSilencedErrors -- Silencing notice and warning is intentional. See https://core.trac.wordpress.org/ticket/42480
+ // Silencing notice and warning is intentional. See https://core.trac.wordpress.org/ticket/42480
$exif = @exif_read_data( $file );
}
@@ -863,22 +919,51 @@ function wp_read_image_metadata( $file ) {
$exif = array();
}
+ $exif_description = '';
+ $exif_usercomment = '';
if ( ! empty( $exif['ImageDescription'] ) ) {
+ $exif_description = trim( $exif['ImageDescription'] );
+ }
+
+ if ( ! empty( $exif['COMPUTED']['UserComment'] ) ) {
+ $exif_usercomment = trim( $exif['COMPUTED']['UserComment'] );
+ }
+
+ if ( $exif_description ) {
mbstring_binary_safe_encoding();
- $description_length = strlen( $exif['ImageDescription'] );
+ $description_length = strlen( $exif_description );
reset_mbstring_encoding();
-
if ( empty( $meta['title'] ) && $description_length < 80 ) {
// Assume the title is stored in ImageDescription.
- $meta['title'] = trim( $exif['ImageDescription'] );
+ $meta['title'] = $exif_description;
}
- if ( empty( $meta['caption'] ) && ! empty( $exif['COMPUTED']['UserComment'] ) ) {
- $meta['caption'] = trim( $exif['COMPUTED']['UserComment'] );
+ // If both user comments and description are present.
+ if ( empty( $meta['caption'] ) && $exif_description && $exif_usercomment ) {
+ if ( ! empty( $meta['title'] ) && $exif_description === $meta['title'] ) {
+ $caption = $exif_usercomment;
+ } else {
+ if ( $exif_description === $exif_usercomment ) {
+ $caption = $exif_description;
+ } else {
+ $caption = trim( $exif_description . ' ' . $exif_usercomment );
+ }
+ }
+ $meta['caption'] = $caption;
+ }
+
+ if ( empty( $meta['caption'] ) && $exif_usercomment ) {
+ $meta['caption'] = $exif_usercomment;
}
if ( empty( $meta['caption'] ) ) {
- $meta['caption'] = trim( $exif['ImageDescription'] );
+ $meta['caption'] = $exif_description;
+ }
+ } elseif ( empty( $meta['caption'] ) && $exif_usercomment ) {
+ $meta['caption'] = $exif_usercomment;
+ $description_length = strlen( $exif_usercomment );
+ if ( empty( $meta['title'] ) && $description_length < 80 ) {
+ $meta['title'] = trim( $exif_usercomment );
}
} elseif ( empty( $meta['caption'] ) && ! empty( $exif['Comments'] ) ) {
$meta['caption'] = trim( $exif['Comments'] );
@@ -953,7 +1038,6 @@ function wp_read_image_metadata( $file ) {
* @param array $exif EXIF data.
*/
return apply_filters( 'wp_read_image_metadata', $meta, $file, $image_type, $iptc, $exif );
-
}
/**
@@ -978,7 +1062,7 @@ function file_is_valid_image( $path ) {
* @return bool True if suitable, false if not suitable.
*/
function file_is_displayable_image( $path ) {
- $displayable_image_types = array( IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_ICO, IMAGETYPE_WEBP );
+ $displayable_image_types = array( IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_ICO, IMAGETYPE_WEBP, IMAGETYPE_AVIF );
$info = wp_getimagesize( $path );
if ( empty( $info ) ) {
diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php
index 6eb41b027..bbd2299af 100644
--- a/wp-admin/includes/media.php
+++ b/wp-admin/includes/media.php
@@ -527,12 +527,14 @@ function media_handle_sideload( $file_array, $post_id = 0, $desc = null, $post_d
* @since 5.3.0 Formalized the existing and already documented `...$args` parameter
* by adding it to the function signature.
*
- * @global int $body_id
+ * @global string $body_id
*
* @param callable $content_func Function that outputs the content.
* @param mixed ...$args Optional additional parameters to pass to the callback function when it's called.
*/
function wp_iframe( $content_func, ...$args ) {
+ global $body_id;
+
_wp_admin_html_begin();
?>
› —
@@ -603,8 +605,8 @@ function wp_iframe( $content_func, ...$args ) {
$body_id_attr = '';
- if ( isset( $GLOBALS['body_id'] ) ) {
- $body_id_attr = ' id="' . $GLOBALS['body_id'] . '"';
+ if ( isset( $body_id ) ) {
+ $body_id_attr = ' id="' . $body_id . '"';
}
?>
@@ -638,7 +640,7 @@ function wp_iframe( $content_func, ...$args ) {
*/
function media_buttons( $editor_id = 'content' ) {
static $instance = 0;
- $instance++;
+ ++$instance;
$post = get_post();
@@ -2083,13 +2085,11 @@ function media_upload_header() {
*
* @global string $type
* @global string $tab
- * @global bool $is_IE
- * @global bool $is_opera
*
* @param array $errors
*/
function media_upload_form( $errors = null ) {
- global $type, $tab, $is_IE, $is_opera;
+ global $type, $tab;
if ( ! _device_can_upload() ) {
echo '
' . sprintf(
@@ -2198,6 +2198,11 @@ function media_upload_form( $errors = null ) {
$plupload_init['webp_upload_error'] = true;
}
+ // Check if AVIF images can be edited.
+ if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/avif' ) ) ) {
+ $plupload_init['avif_upload_error'] = true;
+ }
+
/**
* Filters the default Plupload settings.
*
@@ -2828,7 +2833,7 @@ function media_upload_library_form( $errors ) {
'format' => '',
'prev_text' => __( '«' ),
'next_text' => __( '»' ),
- 'total' => ceil( $wp_query->found_posts / 10 ),
+ 'total' => (int) ceil( $wp_query->found_posts / 10 ),
'current' => $q['paged'],
)
);
diff --git a/wp-admin/includes/menu.php b/wp-admin/includes/menu.php
index ae8e06be6..3cf4a5fdd 100644
--- a/wp-admin/includes/menu.php
+++ b/wp-admin/includes/menu.php
@@ -13,8 +13,8 @@
*
* The hook fires before menus and sub-menus are removed based on user privileges.
*
- * @private
* @since 3.1.0
+ * @access private
*/
do_action( '_network_admin_menu' );
} elseif ( is_user_admin() ) {
@@ -24,8 +24,8 @@
*
* The hook fires before menus and sub-menus are removed based on user privileges.
*
- * @private
* @since 3.1.0
+ * @access private
*/
do_action( '_user_admin_menu' );
} else {
@@ -35,8 +35,8 @@
*
* The hook fires before menus and sub-menus are removed based on user privileges.
*
- * @private
* @since 2.2.0
+ * @access private
*/
do_action( '_admin_menu' );
}
@@ -228,7 +228,7 @@ function add_menu_classes( $menu ) {
$i = 0;
foreach ( $menu as $order => $top ) {
- $i++;
+ ++$i;
if ( 0 === $order ) { // Dashboard is always shown/single.
$menu[0][4] = add_cssclass( 'menu-top-first', $top[4] );
diff --git a/wp-admin/includes/meta-boxes.php b/wp-admin/includes/meta-boxes.php
index 79f45d3e4..9e09957e8 100644
--- a/wp-admin/includes/meta-boxes.php
+++ b/wp-admin/includes/meta-boxes.php
@@ -311,25 +311,24 @@ function post_submit_meta_box( $post, $args = array() ) {
endif;
if ( 'draft' === $post->post_status && get_post_meta( $post_id, '_customize_changeset_uuid', true ) ) :
- ?>
-
-
- unpublished customization changes. You can edit, but there is no need to publish now. It will be published automatically with those changes.' ),
- esc_url(
- add_query_arg(
- 'changeset_uuid',
- rawurlencode( get_post_meta( $post_id, '_customize_changeset_uuid', true ) ),
- admin_url( 'customize.php' )
- )
- )
- );
- ?>
-
-
- unpublished customization changes. You can edit, but there is no need to publish now. It will be published automatically with those changes.' ),
+ esc_url(
+ add_query_arg(
+ 'changeset_uuid',
+ rawurlencode( get_post_meta( $post_id, '_customize_changeset_uuid', true ) ),
+ admin_url( 'customize.php' )
+ )
+ )
+ );
+ wp_admin_notice(
+ $message,
+ array(
+ 'type' => 'info',
+ 'additional_classes' => array( 'notice-alt', 'inline' ),
+ )
+ );
endif;
/**
@@ -435,7 +434,7 @@ function attachment_submit_meta_box( $post ) {
post_date ) ),
@@ -902,8 +901,8 @@ function post_comment_meta_box( $post ) {
$total = get_comments(
array(
'post_id' => $post->ID,
- 'number' => 1,
'count' => true,
+ 'orderby' => 'none',
)
);
$wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table' );
@@ -1033,7 +1032,7 @@ function page_attributes_meta_box( $post ) {
endif; // End empty pages check.
endif; // End hierarchical check.
- if ( count( get_page_templates( $post ) ) > 0 && get_option( 'page_for_posts' ) != $post->ID ) :
+ if ( count( get_page_templates( $post ) ) > 0 && (int) get_option( 'page_for_posts' ) !== $post->ID ) :
$template = ! empty( $post->page_template ) ? $post->page_template : false;
?>
@@ -1496,7 +1495,7 @@ function link_advanced_meta_box( $link ) {
link_rating ) && $link->link_rating == $rating ) {
+ if ( isset( $link->link_rating ) && $link->link_rating === $rating ) {
echo ' selected="selected"';
}
echo '>' . $rating . '';
diff --git a/wp-admin/includes/misc.php b/wp-admin/includes/misc.php
index da7d51c45..8c76e800a 100644
--- a/wp-admin/includes/misc.php
+++ b/wp-admin/includes/misc.php
@@ -39,11 +39,12 @@ function got_mod_rewrite() {
* @since 3.7.0
*
* @global bool $is_nginx
+ * @global bool $is_caddy
*
* @return bool Whether the server supports URL rewriting.
*/
function got_url_rewrite() {
- $got_url_rewrite = ( got_mod_rewrite() || $GLOBALS['is_nginx'] || iis7_supports_permalinks() );
+ $got_url_rewrite = ( got_mod_rewrite() || $GLOBALS['is_nginx'] || $GLOBALS['is_caddy'] || iis7_supports_permalinks() );
/**
* Filters whether URL rewriting is available.
@@ -403,7 +404,7 @@ function wp_print_theme_file_tree( $tree, $level = 2, $size = 1, $index = 1 ) {
$size = count( $tree );
foreach ( $tree as $label => $theme_file ) :
- $index++;
+ ++$index;
if ( ! is_array( $theme_file ) ) {
wp_print_theme_file_tree( $theme_file, $level, $index, $size );
@@ -505,7 +506,7 @@ function wp_print_plugin_file_tree( $tree, $label = '', $level = 2, $size = 1, $
$size = count( $tree );
foreach ( $tree as $label => $plugin_file ) :
- $index++;
+ ++$index;
if ( ! is_array( $plugin_file ) ) {
wp_print_plugin_file_tree( $plugin_file, $label, $level, $index, $size );
@@ -1038,17 +1039,15 @@ function admin_color_scheme_picker( $user_id ) {
name ); ?>
-
-
- colors as $html_color ) {
- ?>
-
-
+ colors as $html_color ) {
?>
-
-
+
+
+