Skip to content

Commit 51f6c5d

Browse files
committed
Merge branch 'trunk' of https://github.com/WordPress/wordpress-develop into add/dependent-fetchpriority-harmony
2 parents 98abb51 + 9d03e8e commit 51f6c5d

File tree

9 files changed

+922
-539
lines changed

9 files changed

+922
-539
lines changed

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ services:
7070
- wpdevnet
7171

7272
ports:
73-
- "3306"
73+
- "${LOCAL_DB_PORTS-3306}"
7474

7575
environment:
7676
MYSQL_ROOT_PASSWORD: password

src/wp-admin/plugin-editor.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,11 @@
9393
$posted_content = null;
9494

9595
if ( 'POST' === $_SERVER['REQUEST_METHOD'] ) {
96-
$r = wp_edit_theme_plugin_file( wp_unslash( $_POST ) );
97-
if ( is_wp_error( $r ) ) {
98-
$edit_error = $r;
96+
$edit_result = wp_edit_theme_plugin_file( wp_unslash( $_POST ) );
97+
98+
if ( is_wp_error( $edit_result ) ) {
99+
$edit_error = $edit_result;
100+
99101
if ( check_ajax_referer( 'edit-plugin_' . $file, 'nonce', false ) && isset( $_POST['newcontent'] ) ) {
100102
$posted_content = wp_unslash( $_POST['newcontent'] );
101103
}
@@ -122,9 +124,10 @@
122124
} else {
123125
// Get the extension of the file.
124126
if ( preg_match( '/\.([^.]+)$/', $real_file, $matches ) ) {
125-
$ext = strtolower( $matches[1] );
127+
$extension = strtolower( $matches[1] );
128+
126129
// If extension is not in the acceptable list, skip it.
127-
if ( ! in_array( $ext, $editable_extensions, true ) ) {
130+
if ( ! in_array( $extension, $editable_extensions, true ) ) {
128131
wp_die( sprintf( '<p>%s</p>', __( 'Files of this type are not editable.' ) ) );
129132
}
130133
}

src/wp-admin/plugins.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
$action = $wp_list_table->current_action();
2020

21-
$plugin = isset( $_REQUEST['plugin'] ) ? wp_unslash( $_REQUEST['plugin'] ) : '';
22-
$search_term = isset( $_REQUEST['s'] ) ? urlencode( wp_unslash( $_REQUEST['s'] ) ) : '';
21+
$plugin = isset( $_REQUEST['plugin'] ) ? wp_unslash( $_REQUEST['plugin'] ) : '';
22+
$s = isset( $_REQUEST['s'] ) ? urlencode( wp_unslash( $_REQUEST['s'] ) ) : '';
2323

2424
// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
2525
$query_args_to_remove = array(
@@ -51,7 +51,7 @@
5151
}
5252

5353
if ( is_multisite() && ! is_network_admin() && is_network_only_plugin( $plugin ) ) {
54-
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$search_term" ) );
54+
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
5555
exit;
5656
}
5757

@@ -60,7 +60,7 @@
6060
$result = activate_plugin( $plugin, self_admin_url( 'plugins.php?error=true&plugin=' . urlencode( $plugin ) ), is_network_admin() );
6161
if ( is_wp_error( $result ) ) {
6262
if ( 'unexpected_output' === $result->get_error_code() ) {
63-
$redirect = self_admin_url( 'plugins.php?error=true&charsout=' . strlen( $result->get_error_data() ) . '&plugin=' . urlencode( $plugin ) . "&plugin_status=$status&paged=$page&s=$search_term" );
63+
$redirect = self_admin_url( 'plugins.php?error=true&charsout=' . strlen( $result->get_error_data() ) . '&plugin=' . urlencode( $plugin ) . "&plugin_status=$status&paged=$page&s=$s" );
6464
wp_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-activation-error_' . $plugin ), $redirect ) );
6565
exit;
6666
} else {
@@ -85,7 +85,7 @@
8585
wp_redirect( self_admin_url( 'press-this.php' ) );
8686
} else {
8787
// Overrides the ?error=true one above.
88-
wp_redirect( self_admin_url( "plugins.php?activate=true&plugin_status=$status&paged=$page&s=$search_term" ) );
88+
wp_redirect( self_admin_url( "plugins.php?activate=true&plugin_status=$status&paged=$page&s=$s" ) );
8989
}
9090
exit;
9191

@@ -119,7 +119,7 @@
119119
}
120120

121121
if ( empty( $plugins ) ) {
122-
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$search_term" ) );
122+
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
123123
exit;
124124
}
125125

@@ -141,7 +141,7 @@
141141
update_site_option( 'recently_activated', $recent );
142142
}
143143

144-
wp_redirect( self_admin_url( "plugins.php?activate-multi=true&plugin_status=$status&paged=$page&s=$search_term" ) );
144+
wp_redirect( self_admin_url( "plugins.php?activate-multi=true&plugin_status=$status&paged=$page&s=$s" ) );
145145
exit;
146146

147147
case 'update-selected':
@@ -204,7 +204,7 @@
204204
check_admin_referer( 'deactivate-plugin_' . $plugin );
205205

206206
if ( ! is_network_admin() && is_plugin_active_for_network( $plugin ) ) {
207-
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$search_term" ) );
207+
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
208208
exit;
209209
}
210210

@@ -217,9 +217,9 @@
217217
}
218218

219219
if ( headers_sent() ) {
220-
echo "<meta http-equiv='refresh' content='" . esc_attr( "0;url=plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$search_term" ) . "' />";
220+
echo "<meta http-equiv='refresh' content='" . esc_attr( "0;url=plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s" ) . "' />";
221221
} else {
222-
wp_redirect( self_admin_url( "plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$search_term" ) );
222+
wp_redirect( self_admin_url( "plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s" ) );
223223
}
224224
exit;
225225

@@ -246,7 +246,7 @@
246246
}
247247
}
248248
if ( empty( $plugins ) ) {
249-
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$search_term" ) );
249+
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
250250
exit;
251251
}
252252

@@ -263,7 +263,7 @@
263263
update_site_option( 'recently_activated', $deactivated + (array) get_site_option( 'recently_activated' ) );
264264
}
265265

266-
wp_redirect( self_admin_url( "plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page&s=$search_term" ) );
266+
wp_redirect( self_admin_url( "plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page&s=$s" ) );
267267
exit;
268268

269269
case 'delete-selected':
@@ -276,21 +276,21 @@
276276
// $_POST = from the plugin form; $_GET = from the FTP details screen.
277277
$plugins = isset( $_REQUEST['checked'] ) ? (array) wp_unslash( $_REQUEST['checked'] ) : array();
278278
if ( empty( $plugins ) ) {
279-
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$search_term" ) );
279+
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
280280
exit;
281281
}
282282

283283
$plugins = array_filter( $plugins, 'is_plugin_inactive' ); // Do not allow to delete activated plugins.
284284
if ( empty( $plugins ) ) {
285-
wp_redirect( self_admin_url( "plugins.php?error=true&main=true&plugin_status=$status&paged=$page&s=$search_term" ) );
285+
wp_redirect( self_admin_url( "plugins.php?error=true&main=true&plugin_status=$status&paged=$page&s=$s" ) );
286286
exit;
287287
}
288288

289289
// Bail on all if any paths are invalid.
290290
// validate_file() returns truthy for invalid files.
291291
$invalid_plugin_files = array_filter( $plugins, 'validate_file' );
292292
if ( $invalid_plugin_files ) {
293-
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$search_term" ) );
293+
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
294294
exit;
295295
}
296296

@@ -432,7 +432,7 @@
432432
// Store the result in an option rather than a URL param due to object type & length.
433433
// Cannot use transient/cache, as that could get flushed if any plugin flushes data on uninstall/delete.
434434
update_option( 'plugins_delete_result_' . $user_ID, $delete_result, false );
435-
wp_redirect( self_admin_url( "plugins.php?deleted=$plugins_to_delete&plugin_status=$status&paged=$page&s=$search_term" ) );
435+
wp_redirect( self_admin_url( "plugins.php?deleted=$plugins_to_delete&plugin_status=$status&paged=$page&s=$s" ) );
436436
exit;
437437
case 'clear-recent-list':
438438
if ( ! is_network_admin() ) {
@@ -453,13 +453,13 @@
453453

454454
check_admin_referer( 'resume-plugin_' . $plugin );
455455

456-
$result = resume_plugin( $plugin, self_admin_url( "plugins.php?error=resuming&plugin_status=$status&paged=$page&s=$search_term" ) );
456+
$result = resume_plugin( $plugin, self_admin_url( "plugins.php?error=resuming&plugin_status=$status&paged=$page&s=$s" ) );
457457

458458
if ( is_wp_error( $result ) ) {
459459
wp_die( $result );
460460
}
461461

462-
wp_redirect( self_admin_url( "plugins.php?resume=true&plugin_status=$status&paged=$page&s=$search_term" ) );
462+
wp_redirect( self_admin_url( "plugins.php?resume=true&plugin_status=$status&paged=$page&s=$s" ) );
463463
exit;
464464
case 'enable-auto-update':
465465
case 'disable-auto-update':
@@ -473,7 +473,7 @@
473473
wp_die( __( 'Please connect to your network admin to manage plugins automatic updates.' ) );
474474
}
475475

476-
$redirect = self_admin_url( "plugins.php?plugin_status={$status}&paged={$page}&s={$search_term}" );
476+
$redirect = self_admin_url( "plugins.php?plugin_status={$status}&paged={$page}&s={$s}" );
477477

478478
if ( 'enable-auto-update' === $action || 'disable-auto-update' === $action ) {
479479
if ( empty( $plugin ) ) {
@@ -771,12 +771,12 @@
771771
<?php
772772
}
773773

774-
if ( strlen( $search_term ) ) {
774+
if ( strlen( $s ) ) {
775775
echo '<span class="subtitle">';
776776
printf(
777777
/* translators: %s: Search query. */
778778
__( 'Search results for: %s' ),
779-
'<strong>' . esc_html( urldecode( $search_term ) ) . '</strong>'
779+
'<strong>' . esc_html( urldecode( $s ) ) . '</strong>'
780780
);
781781
echo '</span>';
782782
}

src/wp-includes/class-wp-block.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,14 @@ public function replace_rich_text( $rich_text ) {
492492
public function render( $options = array() ) {
493493
global $post;
494494

495+
// Capture the current assets queues and then clear out to capture the diff of what was introduced by rendering.
496+
$before_styles_queue = wp_styles()->queue;
497+
$before_scripts_queue = wp_scripts()->queue;
498+
$before_script_modules_queue = wp_script_modules()->queue;
499+
wp_styles()->queue = array();
500+
wp_scripts()->queue = array();
501+
wp_script_modules()->queue = array();
502+
495503
/*
496504
* There can be only one root interactive block at a time because the rendered HTML of that block contains
497505
* the rendered HTML of all its inner blocks, including any interactive block.
@@ -661,6 +669,44 @@ public function render( $options = array() ) {
661669
$root_interactive_block = null;
662670
}
663671

672+
// Capture the new assets enqueued during rendering, and restore the queues the state prior to rendering.
673+
$new_styles_queue = wp_styles()->queue;
674+
$new_scripts_queue = wp_scripts()->queue;
675+
$new_script_modules_queue = wp_script_modules()->queue;
676+
wp_styles()->queue = $before_styles_queue;
677+
wp_scripts()->queue = $before_scripts_queue;
678+
wp_script_modules()->queue = $before_script_modules_queue;
679+
$has_new_styles = count( $new_styles_queue ) > 0;
680+
$has_new_scripts = count( $new_scripts_queue ) > 0;
681+
$has_new_script_modules = count( $new_script_modules_queue ) > 0;
682+
683+
// Merge the newly enqueued assets with the existing assets if the rendered block is not empty.
684+
if (
685+
( $has_new_styles || $has_new_scripts || $has_new_script_modules ) &&
686+
(
687+
trim( $block_content ) !== '' ||
688+
/**
689+
* Filters whether to enqueue assets for a block which has no rendered content.
690+
*
691+
* @since 6.9.0
692+
*
693+
* @param bool $enqueue Whether to enqueue assets.
694+
* @param string $block_name Block name.
695+
*/
696+
(bool) apply_filters( 'enqueue_empty_block_content_assets', false, $this->name )
697+
)
698+
) {
699+
if ( $has_new_styles ) {
700+
wp_styles()->queue = array_unique( array_merge( wp_styles()->queue, $new_styles_queue ) );
701+
}
702+
if ( $has_new_scripts ) {
703+
wp_scripts()->queue = array_unique( array_merge( wp_scripts()->queue, $new_scripts_queue ) );
704+
}
705+
if ( $has_new_script_modules ) {
706+
wp_script_modules()->queue = array_unique( array_merge( wp_script_modules()->queue, $new_script_modules_queue ) );
707+
}
708+
}
709+
664710
return $block_content;
665711
}
666712
}

0 commit comments

Comments
 (0)