diff --git a/src/js/_enqueues/lib/auth-check.js b/src/js/_enqueues/lib/auth-check.js
index 44ff15a153410..ff64573639a25 100644
--- a/src/js/_enqueues/lib/auth-check.js
+++ b/src/js/_enqueues/lib/auth-check.js
@@ -159,12 +159,23 @@
setShowTimeout();
});
}).on( 'heartbeat-tick.wp-auth-check', function( e, data ) {
- if ( 'wp-auth-check' in data ) {
+ if ( ! ( 'wp-auth-check' in data ) ) {
+ return;
+ }
+
+ var showOrHide = function () {
if ( ! data['wp-auth-check'] && wrap.hasClass( 'hidden' ) && ! tempHidden ) {
show();
} else if ( data['wp-auth-check'] && ! wrap.hasClass( 'hidden' ) ) {
hide();
}
+ };
+
+ // This is necessary due to a race condition where the heartbeat-tick event may fire before DOMContentLoaded.
+ if ( wrap ) {
+ showOrHide();
+ } else {
+ $( showOrHide );
}
});
diff --git a/src/wp-admin/includes/file.php b/src/wp-admin/includes/file.php
index 0658662126a59..3627a16d3ecda 100644
--- a/src/wp-admin/includes/file.php
+++ b/src/wp-admin/includes/file.php
@@ -1896,14 +1896,14 @@ function _unzip_file_pclzip( $file, $to, $needed_dirs = array() ) {
$uncompressed_size = 0;
// Determine any children directories needed (From within the archive).
- foreach ( $archive_files as $file ) {
- if ( str_starts_with( $file['filename'], '__MACOSX/' ) ) { // Skip the OS X-created __MACOSX directory.
+ foreach ( $archive_files as $archive_file ) {
+ if ( str_starts_with( $archive_file['filename'], '__MACOSX/' ) ) { // Skip the OS X-created __MACOSX directory.
continue;
}
- $uncompressed_size += $file['size'];
+ $uncompressed_size += $archive_file['size'];
- $needed_dirs[] = $to . untrailingslashit( $file['folder'] ? $file['filename'] : dirname( $file['filename'] ) );
+ $needed_dirs[] = $to . untrailingslashit( $archive_file['folder'] ? $archive_file['filename'] : dirname( $archive_file['filename'] ) );
}
// Enough space to unzip the file and copy its contents, with a 10% buffer.
@@ -1967,22 +1967,22 @@ function _unzip_file_pclzip( $file, $to, $needed_dirs = array() ) {
}
// Extract the files from the zip.
- foreach ( $archive_files as $file ) {
- if ( $file['folder'] ) {
+ foreach ( $archive_files as $archive_file ) {
+ if ( $archive_file['folder'] ) {
continue;
}
- if ( str_starts_with( $file['filename'], '__MACOSX/' ) ) { // Don't extract the OS X-created __MACOSX directory files.
+ if ( str_starts_with( $archive_file['filename'], '__MACOSX/' ) ) { // Don't extract the OS X-created __MACOSX directory files.
continue;
}
// Don't extract invalid files:
- if ( 0 !== validate_file( $file['filename'] ) ) {
+ if ( 0 !== validate_file( $archive_file['filename'] ) ) {
continue;
}
- if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE ) ) {
- return new WP_Error( 'copy_failed_pclzip', __( 'Could not copy file.' ), $file['filename'] );
+ if ( ! $wp_filesystem->put_contents( $to . $archive_file['filename'], $archive_file['content'], FS_CHMOD_FILE ) ) {
+ return new WP_Error( 'copy_failed_pclzip', __( 'Could not copy file.' ), $archive_file['filename'] );
}
}
diff --git a/src/wp-admin/includes/media.php b/src/wp-admin/includes/media.php
index 8436bde73b7fa..210539681ad56 100644
--- a/src/wp-admin/includes/media.php
+++ b/src/wp-admin/includes/media.php
@@ -3769,8 +3769,8 @@ function wp_read_audio_metadata( $file ) {
* @link https://github.com/JamesHeinrich/getID3/blob/master/structure.txt
*
* @param array $metadata The metadata returned by getID3::analyze().
- * @return int|false A UNIX timestamp for the media's creation date if available
- * or a boolean FALSE if a timestamp could not be determined.
+ * @return int|false A Unix timestamp for the media's creation date if available
+ * or a boolean false if the timestamp could not be determined.
*/
function wp_get_media_creation_timestamp( $metadata ) {
$creation_date = false;
diff --git a/src/wp-includes/block-editor.php b/src/wp-includes/block-editor.php
index 6f5720ec21c9d..d2beae38ece76 100644
--- a/src/wp-includes/block-editor.php
+++ b/src/wp-includes/block-editor.php
@@ -774,7 +774,7 @@ function block_editor_rest_api_preload( array $preload_paths, $block_editor_cont
'wp-api-fetch',
sprintf(
'wp.apiFetch.use( wp.apiFetch.createPreloadingMiddleware( %s ) );',
- wp_json_encode( $preload_data, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES )
+ wp_json_encode( $preload_data, JSON_UNESCAPED_SLASHES )
),
'after'
);
diff --git a/src/wp-includes/functions.wp-scripts.php b/src/wp-includes/functions.wp-scripts.php
index f86b456d5f69a..fea535a3d12fd 100644
--- a/src/wp-includes/functions.wp-scripts.php
+++ b/src/wp-includes/functions.wp-scripts.php
@@ -130,18 +130,42 @@ function wp_print_scripts( $handles = false ) {
function wp_add_inline_script( $handle, $data, $position = 'after' ) {
_wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle );
- if ( false !== stripos( $data, '' ) ) {
- _doing_it_wrong(
- __FUNCTION__,
- sprintf(
- /* translators: 1: #is', '$1', $data ) );
+ /*
+ * Check whether the script data appears to be enclosed in an HTML ` could close the SCRIPT element prematurely.
*
- * More thorough analysis could track the HTML tokenizer states
- * and to ensure that the SCRIPT element closes at the expected
- * SCRIPT close tag as is done in {@see ::skip_script_data()}.
+ * The text ``. A SCRIPT element could be prevented from
- * closing by contents like `' => array( '', 'Comments end in -->' ),
- 'Comment with --!>' => array( '', 'Invalid but legitimate comments end in --!>' ),
- 'SCRIPT with ' => array( '', 'Just a ' ),
- 'SCRIPT with ' => array( '', 'beforeafter' ),
- 'SCRIPT with "', '' => array( '', 'Comments end in -->' ),
+ 'Comment with --!>' => array( '', 'Invalid but legitimate comments end in --!>' ),
+ 'Non-JS SCRIPT with ', '