Skip to content

Commit ce14af6

Browse files
committed
Merge remote-tracking branch 'upstream/trunk' into add/archives-filter-limit
2 parents 9ee87b6 + 6b7adc0 commit ce14af6

File tree

6 files changed

+94
-38
lines changed

6 files changed

+94
-38
lines changed

src/wp-admin/includes/ajax-actions.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4804,6 +4804,8 @@ function wp_ajax_search_plugins() {
48044804
// Ensure after_plugin_row_{$plugin_file} gets hooked.
48054805
wp_plugin_update_rows();
48064806

4807+
WP_Plugin_Dependencies::initialize();
4808+
48074809
$pagenow = isset( $_POST['pagenow'] ) ? sanitize_key( $_POST['pagenow'] ) : '';
48084810
if ( 'plugins-network' === $pagenow || 'plugins' === $pagenow ) {
48094811
set_current_screen( $pagenow );

src/wp-admin/includes/class-wp-filesystem-ftpext.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ public function chmod( $file, $mode = false, $recursive = false ) {
299299
public function owner( $file ) {
300300
$dir = $this->dirlist( $file );
301301

302-
return $dir[ $file ]['owner'];
302+
return $dir[ $file ]['owner'] ?? '';
303303
}
304304

305305
/**
@@ -313,7 +313,7 @@ public function owner( $file ) {
313313
public function getchmod( $file ) {
314314
$dir = $this->dirlist( $file );
315315

316-
return $dir[ $file ]['permsn'];
316+
return $dir[ $file ]['permsn'] ?? '';
317317
}
318318

319319
/**
@@ -327,7 +327,7 @@ public function getchmod( $file ) {
327327
public function group( $file ) {
328328
$dir = $this->dirlist( $file );
329329

330-
return $dir[ $file ]['group'];
330+
return $dir[ $file ]['group'] ?? '';
331331
}
332332

333333
/**

src/wp-admin/includes/class-wp-filesystem-ftpsockets.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ public function chmod( $file, $mode = false, $recursive = false ) {
309309
public function owner( $file ) {
310310
$dir = $this->dirlist( $file );
311311

312-
return $dir[ $file ]['owner'];
312+
return $dir[ $file ]['owner'] ?? '';
313313
}
314314

315315
/**
@@ -323,7 +323,7 @@ public function owner( $file ) {
323323
public function getchmod( $file ) {
324324
$dir = $this->dirlist( $file );
325325

326-
return $dir[ $file ]['permsn'];
326+
return $dir[ $file ]['permsn'] ?? '';
327327
}
328328

329329
/**
@@ -337,7 +337,7 @@ public function getchmod( $file ) {
337337
public function group( $file ) {
338338
$dir = $this->dirlist( $file );
339339

340-
return $dir[ $file ]['group'];
340+
return $dir[ $file ]['group'] ?? '';
341341
}
342342

343343
/**

src/wp-content/themes/twentyeleven/inc/theme-options.php

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
/**
11-
* Properly enqueues styles and scripts for our theme options page.
11+
* Enqueues styles and scripts for the theme options page.
1212
*
1313
* This function is attached to the admin_enqueue_scripts action hook.
1414
*
@@ -75,6 +75,8 @@ function twentyeleven_theme_options_init() {
7575
* By default, only administrators have either of these capabilities, but the desire here is
7676
* to allow for finer-grained control for roles and users.
7777
*
78+
* @since Twenty Eleven 1.1
79+
*
7880
* @param string $capability The capability used for the page, which is manage_options by default.
7981
* @return string The capability to actually use.
8082
*/
@@ -84,7 +86,7 @@ function twentyeleven_option_page_capability( $capability ) {
8486
add_filter( 'option_page_capability_twentyeleven_options', 'twentyeleven_option_page_capability' );
8587

8688
/**
87-
* Adds a theme options page to the admin menu, including some help documentation.
89+
* Adds the theme options page to the admin menu, including help documentation.
8890
*
8991
* This function is attached to the admin_menu action hook.
9092
*
@@ -107,6 +109,11 @@ function twentyeleven_theme_options_add_page() {
107109
}
108110
add_action( 'admin_menu', 'twentyeleven_theme_options_add_page' );
109111

112+
/**
113+
* Adds help documentation to the theme options page.
114+
*
115+
* @since Twenty Eleven 1.3
116+
*/
110117
function twentyeleven_theme_options_help() {
111118

112119
$help = '<p>' . __( 'Some themes provide customization options that are grouped together on a Theme Options screen. If you change themes, options may change or disappear, as they are theme-specific. Your current theme, Twenty Eleven, provides the following Theme Options:', 'twentyeleven' ) . '</p>' .
@@ -144,6 +151,8 @@ function twentyeleven_theme_options_help() {
144151
* Returns an array of color schemes registered for Twenty Eleven.
145152
*
146153
* @since Twenty Eleven 1.0
154+
*
155+
* @return array<string, array<string, string>> An associative array of color scheme options.
147156
*/
148157
function twentyeleven_color_schemes() {
149158
$color_scheme_options = array(
@@ -166,7 +175,7 @@ function twentyeleven_color_schemes() {
166175
*
167176
* @since Twenty Eleven 1.0
168177
*
169-
* @param array $color_scheme_options An associative array of color scheme options.
178+
* @param array<string, array<string, string>> $color_scheme_options An associative array of color scheme options.
170179
*/
171180
return apply_filters( 'twentyeleven_color_schemes', $color_scheme_options );
172181
}
@@ -175,6 +184,8 @@ function twentyeleven_color_schemes() {
175184
* Returns an array of layout options registered for Twenty Eleven.
176185
*
177186
* @since Twenty Eleven 1.0
187+
*
188+
* @return array<string, array<string, string>> An associative array of layout options.
178189
*/
179190
function twentyeleven_layouts() {
180191
$layout_options = array(
@@ -200,7 +211,7 @@ function twentyeleven_layouts() {
200211
*
201212
* @since Twenty Eleven 1.0
202213
*
203-
* @param array $layout_options An associative array of layout options.
214+
* @param array<string, array<string, string>> $layout_options An associative array of layout options.
204215
*/
205216
return apply_filters( 'twentyeleven_layouts', $layout_options );
206217
}
@@ -210,7 +221,7 @@ function twentyeleven_layouts() {
210221
*
211222
* @since Twenty Eleven 1.0
212223
*
213-
* @return array An array of default theme options.
224+
* @return array<string, string> An array of default theme options.
214225
*/
215226
function twentyeleven_get_default_theme_options() {
216227
$default_theme_options = array(
@@ -228,7 +239,7 @@ function twentyeleven_get_default_theme_options() {
228239
*
229240
* @since Twenty Eleven 1.0
230241
*
231-
* @param array $default_theme_options An array of default theme options.
242+
* @param array<string, string> $default_theme_options An array of default theme options.
232243
*/
233244
return apply_filters( 'twentyeleven_default_theme_options', $default_theme_options );
234245
}
@@ -240,7 +251,7 @@ function twentyeleven_get_default_theme_options() {
240251
*
241252
* @param string $color_scheme Optional. Color scheme.
242253
* Default null (or the active color scheme).
243-
* @return string The default link color.
254+
* @return string|false The default link color, or false if not set.
244255
*/
245256
function twentyeleven_get_default_link_color( $color_scheme = null ) {
246257
if ( null === $color_scheme ) {
@@ -260,6 +271,8 @@ function twentyeleven_get_default_link_color( $color_scheme = null ) {
260271
* Returns the options array for Twenty Eleven.
261272
*
262273
* @since Twenty Eleven 1.0
274+
*
275+
* @return array<string, string> The theme options array.
263276
*/
264277
function twentyeleven_get_theme_options() {
265278
return get_option( 'twentyeleven_theme_options', twentyeleven_get_default_theme_options() );
@@ -372,6 +385,7 @@ function twentyeleven_theme_options_render_page() {
372385
* @since Twenty Eleven 1.0
373386
*
374387
* @param array $input An array of form input.
388+
* @return array<string, string> An array of sanitized and validated form output.
375389
*/
376390
function twentyeleven_theme_options_validate( $input ) {
377391
$defaults = twentyeleven_get_default_theme_options();
@@ -401,9 +415,9 @@ function twentyeleven_theme_options_validate( $input ) {
401415
*
402416
* @since Twenty Eleven 1.0
403417
*
404-
* @param array $output An array of sanitized form output.
405-
* @param array $input An array of un-sanitized form input.
406-
* @param array $defaults An array of default theme options.
418+
* @param array<string, string> $output An array of sanitized form output.
419+
* @param array $input An array of un-sanitized form input.
420+
* @param array<string, string> $defaults An array of default theme options.
407421
*/
408422
return apply_filters( 'twentyeleven_theme_options_validate', $output, $input, $defaults );
409423
}
@@ -486,7 +500,8 @@ function twentyeleven_print_link_color_style() {
486500
*
487501
* @since Twenty Eleven 1.0
488502
*
489-
* @param array $existing_classes An array of existing body classes.
503+
* @param string[] $existing_classes An array of existing body classes.
504+
* @return string[] The filtered array of body classes.
490505
*/
491506
function twentyeleven_layout_classes( $existing_classes ) {
492507
$options = twentyeleven_get_theme_options();
@@ -511,8 +526,8 @@ function twentyeleven_layout_classes( $existing_classes ) {
511526
*
512527
* @since Twenty Eleven 1.0
513528
*
514-
* @param array $classes An array of body classes.
515-
* @param string $current_layout The current theme layout.
529+
* @param string[] $classes An array of body classes.
530+
* @param string $current_layout The current theme layout.
516531
*/
517532
$classes = apply_filters( 'twentyeleven_layout_classes', $classes, $current_layout );
518533

@@ -521,7 +536,7 @@ function twentyeleven_layout_classes( $existing_classes ) {
521536
add_filter( 'body_class', 'twentyeleven_layout_classes' );
522537

523538
/**
524-
* Implements Twenty Eleven theme options into Customizer
539+
* Implements Twenty Eleven theme options into Customizer.
525540
*
526541
* @since Twenty Eleven 1.3
527542
*

src/wp-content/themes/twentyeleven/inc/widgets.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ public function Twenty_Eleven_Ephemera_Widget() {
4949
*
5050
* @since Twenty Eleven 1.0
5151
*
52-
* @param array $args An array of standard parameters for widgets in this theme.
53-
* @param array $instance An array of settings for this widget instance.
52+
* @param array $args An array of standard parameters for widgets in this theme.
53+
* @param array<string, string|int> $instance An array of settings for this widget instance.
5454
*/
5555
public function widget( $args, $instance ) {
5656
$cache = wp_cache_get( 'widget_twentyeleven_ephemera', 'widget' );
@@ -156,6 +156,10 @@ public function widget( $args, $instance ) {
156156
* where any validation should be dealt with.
157157
*
158158
* @since Twenty Eleven 1.0
159+
*
160+
* @param array $new_instance New widget instance.
161+
* @param array $old_instance Original widget instance.
162+
* @return array<string, string|int> Updated widget instance.
159163
*/
160164
public function update( $new_instance, $old_instance ) {
161165
$instance = $old_instance;

src/wp-includes/script-loader.php

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3438,26 +3438,67 @@ function wp_enqueue_command_palette_assets() {
34383438
'is_network_admin' => is_network_admin(),
34393439
);
34403440

3441+
/**
3442+
* Extracts root-level text nodes from HTML string.
3443+
*
3444+
* @ignore
3445+
* @param string $label HTML string to extract text from.
3446+
* @return string Extracted text content, trimmed.
3447+
*/
3448+
$extract_root_text = static function ( string $label ): string {
3449+
if ( '' === $label ) {
3450+
return '';
3451+
}
3452+
3453+
$processor = new WP_HTML_Tag_Processor( $label );
3454+
$text_parts = array();
3455+
$depth = 0;
3456+
3457+
while ( $processor->next_token() ) {
3458+
$token_type = $processor->get_token_type();
3459+
3460+
if ( '#text' === $token_type ) {
3461+
if ( 0 === $depth ) {
3462+
$text_parts[] = $processor->get_modifiable_text();
3463+
}
3464+
continue;
3465+
}
3466+
3467+
if ( '#tag' !== $token_type ) {
3468+
continue;
3469+
}
3470+
3471+
if ( $processor->is_tag_closer() ) {
3472+
if ( $depth > 0 ) {
3473+
--$depth;
3474+
}
3475+
continue;
3476+
}
3477+
3478+
$token_name = $processor->get_tag();
3479+
if ( $token_name && ! WP_HTML_Processor::is_void( $token_name ) ) {
3480+
++$depth;
3481+
}
3482+
}
3483+
3484+
return trim( implode( '', $text_parts ) );
3485+
};
3486+
34413487
if ( $menu ) {
34423488
$menu_commands = array();
34433489
foreach ( $menu as $menu_item ) {
3444-
if ( empty( $menu_item[0] ) || ! empty( $menu_item[1] ) && ! current_user_can( $menu_item[1] ) ) {
3490+
if ( empty( $menu_item[0] ) || ! is_string( $menu_item[0] ) || ! empty( $menu_item[1] ) && ! current_user_can( $menu_item[1] ) ) {
34453491
continue;
34463492
}
34473493

3448-
// Remove all HTML tags and their contents.
3449-
$menu_label = $menu_item[0];
3450-
while ( preg_match( '/<[^>]*>/', $menu_label ) ) {
3451-
$menu_label = preg_replace( '/<[^>]*>.*?<\/[^>]*>|<[^>]*\/>|<[^>]*>/s', '', $menu_label );
3452-
}
3453-
$menu_label = trim( $menu_label );
3494+
$menu_label = $extract_root_text( $menu_item[0] );
34543495
$menu_url = '';
34553496
$menu_slug = $menu_item[2];
34563497

34573498
if ( preg_match( '/\.php($|\?)/', $menu_slug ) || wp_http_validate_url( $menu_slug ) ) {
34583499
$menu_url = $menu_slug;
34593500
} elseif ( ! empty( menu_page_url( $menu_slug, false ) ) ) {
3460-
$menu_url = html_entity_decode( menu_page_url( $menu_slug, false ), ENT_QUOTES, get_bloginfo( 'charset' ) );
3501+
$menu_url = WP_HTML_Decoder::decode_attribute( menu_page_url( $menu_slug, false ) );
34613502
}
34623503

34633504
if ( $menu_url ) {
@@ -3474,21 +3515,15 @@ function wp_enqueue_command_palette_assets() {
34743515
continue;
34753516
}
34763517

3477-
// Remove all HTML tags and their contents.
3478-
$submenu_label = $submenu_item[0];
3479-
while ( preg_match( '/<[^>]*>/', $submenu_label ) ) {
3480-
$submenu_label = preg_replace( '/<[^>]*>.*?<\/[^>]*>|<[^>]*\/>|<[^>]*>/s', '', $submenu_label );
3481-
}
3482-
$submenu_label = trim( $submenu_label );
3518+
$submenu_label = $extract_root_text( $submenu_item[0] );
34833519
$submenu_url = '';
34843520
$submenu_slug = $submenu_item[2];
34853521

34863522
if ( preg_match( '/\.php($|\?)/', $submenu_slug ) || wp_http_validate_url( $submenu_slug ) ) {
34873523
$submenu_url = $submenu_slug;
34883524
} elseif ( ! empty( menu_page_url( $submenu_slug, false ) ) ) {
3489-
$submenu_url = html_entity_decode( menu_page_url( $submenu_slug, false ), ENT_QUOTES, get_bloginfo( 'charset' ) );
3525+
$submenu_url = WP_HTML_Decoder::decode_attribute( menu_page_url( $submenu_slug, false ) );
34903526
}
3491-
34923527
if ( $submenu_url ) {
34933528
$menu_commands[] = array(
34943529
'label' => sprintf(

0 commit comments

Comments
 (0)