Skip to content

Commit 55d4e47

Browse files
committed
Merge branch 'trunk' into html-api/auto-escape-javascript-json
2 parents 369eefc + 9074e4e commit 55d4e47

File tree

12 files changed

+351
-83
lines changed

12 files changed

+351
-83
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,15 +249,18 @@ public function owner( $file ) {
249249
/**
250250
* Gets the permissions of the specified file or filepath in their octal format.
251251
*
252-
* FIXME does not handle errors in fileperms()
253-
*
254252
* @since 2.5.0
255253
*
256254
* @param string $file Path to the file.
257-
* @return string Mode of the file (the last 3 digits).
255+
* @return string Mode of the file (the last 3 digits), or the string "0" on failure.
258256
*/
259257
public function getchmod( $file ) {
260-
return substr( decoct( @fileperms( $file ) ), -3 );
258+
$perms = @fileperms( $file );
259+
if ( false === $perms ) {
260+
return '0';
261+
}
262+
263+
return substr( decoct( $perms ), -3 );
261264
}
262265

263266
/**

src/wp-admin/widgets-form.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,9 @@
187187

188188
// Remove old position.
189189
if ( ! isset( $_POST['delete_widget'] ) ) {
190-
foreach ( $sidebars_widgets as $sidebar_id => $sidebar ) {
191-
if ( is_array( $sidebar ) ) {
192-
$sidebars_widgets[ $sidebar_id ] = array_diff( $sidebar, array( $widget_id ) );
190+
foreach ( $sidebars_widgets as $sidebar_widget_id => $sidebar_widget ) {
191+
if ( is_array( $sidebar_widget ) ) {
192+
$sidebars_widgets[ $sidebar_widget_id ] = array_diff( $sidebar_widget, array( $widget_id ) );
193193
}
194194
}
195195

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

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,26 @@ class WP_Scripts extends WP_Dependencies {
2222
* Full URL with trailing slash.
2323
*
2424
* @since 2.6.0
25-
* @var string
25+
* @see wp_default_scripts()
26+
* @var string|null
2627
*/
2728
public $base_url;
2829

2930
/**
3031
* URL of the content directory.
3132
*
3233
* @since 2.8.0
33-
* @var string
34+
* @see wp_default_scripts()
35+
* @var string|null
3436
*/
3537
public $content_url;
3638

3739
/**
3840
* Default version string for scripts.
3941
*
4042
* @since 2.6.0
41-
* @var string
43+
* @see wp_default_scripts()
44+
* @var string|null
4245
*/
4346
public $default_version;
4447

@@ -118,6 +121,7 @@ class WP_Scripts extends WP_Dependencies {
118121
* List of default directories.
119122
*
120123
* @since 2.8.0
124+
* @see wp_default_scripts()
121125
* @var string[]|null
122126
*/
123127
public $default_dirs;
@@ -413,9 +417,19 @@ public function do_item( $handle, $group = false ) {
413417
$src = $this->base_url . $src;
414418
}
415419

416-
if ( ! empty( $ver ) ) {
417-
$src = add_query_arg( 'ver', $ver, $src );
420+
$query_args = array();
421+
if ( empty( $obj->ver ) && null !== $obj->ver && is_string( $this->default_version ) ) {
422+
$query_args['ver'] = $this->default_version;
423+
} elseif ( is_scalar( $obj->ver ) ) {
424+
$query_args['ver'] = (string) $obj->ver;
425+
}
426+
if ( isset( $this->args[ $handle ] ) ) {
427+
parse_str( $this->args[ $handle ], $parsed_args );
428+
if ( $parsed_args ) {
429+
$query_args = array_merge( $query_args, $parsed_args );
430+
}
418431
}
432+
$src = add_query_arg( rawurlencode_deep( $query_args ), $src );
419433

420434
/** This filter is documented in wp-includes/class-wp-scripts.php */
421435
$src = esc_url_raw( apply_filters( 'script_loader_src', $src, $handle ) );

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

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,34 @@ class WP_Styles extends WP_Dependencies {
2222
* Full URL with trailing slash.
2323
*
2424
* @since 2.6.0
25-
* @var string
25+
* @see wp_default_styles()
26+
* @var string|null
2627
*/
2728
public $base_url;
2829

2930
/**
3031
* URL of the content directory.
3132
*
3233
* @since 2.8.0
33-
* @var string
34+
* @see wp_default_styles()
35+
* @var string|null
3436
*/
3537
public $content_url;
3638

3739
/**
3840
* Default version string for stylesheets.
3941
*
4042
* @since 2.6.0
41-
* @var string
43+
* @see wp_default_styles()
44+
* @var string|null
4245
*/
4346
public $default_version;
4447

4548
/**
4649
* The current text direction.
4750
*
4851
* @since 2.6.0
52+
* @see wp_default_styles()
4953
* @var string
5054
*/
5155
public $text_direction = 'ltr';
@@ -96,6 +100,7 @@ class WP_Styles extends WP_Dependencies {
96100
* List of default directories.
97101
*
98102
* @since 2.8.0
103+
* @see wp_default_styles()
99104
* @var string[]|null
100105
*/
101106
public $default_dirs;
@@ -218,7 +223,7 @@ public function do_item( $handle, $group = false ) {
218223
return true;
219224
}
220225

221-
$href = $this->_css_href( $src, $ver, $handle );
226+
$href = $this->_css_href( $src, $obj->ver, $handle );
222227
if ( ! $href ) {
223228
return true;
224229
}
@@ -425,19 +430,29 @@ public function all_deps( $handles, $recursion = false, $group = false ) {
425430
*
426431
* @since 2.6.0
427432
*
428-
* @param string $src The source of the enqueued style.
429-
* @param string $ver The version of the enqueued style.
430-
* @param string $handle The style's registered handle.
433+
* @param string $src The source of the enqueued style.
434+
* @param string|false|null $ver The version of the enqueued style.
435+
* @param string $handle The style's registered handle.
431436
* @return string Style's fully-qualified URL.
432437
*/
433438
public function _css_href( $src, $ver, $handle ) {
434439
if ( ! is_bool( $src ) && ! preg_match( '|^(https?:)?//|', $src ) && ! ( $this->content_url && str_starts_with( $src, $this->content_url ) ) ) {
435440
$src = $this->base_url . $src;
436441
}
437442

438-
if ( ! empty( $ver ) ) {
439-
$src = add_query_arg( 'ver', $ver, $src );
443+
$query_args = array();
444+
if ( empty( $ver ) && null !== $ver && is_string( $this->default_version ) ) {
445+
$query_args['ver'] = $this->default_version;
446+
} elseif ( is_scalar( $ver ) ) {
447+
$query_args['ver'] = (string) $ver;
448+
}
449+
if ( isset( $this->args[ $handle ] ) ) {
450+
parse_str( $this->args[ $handle ], $parsed_args );
451+
if ( $parsed_args ) {
452+
$query_args = array_merge( $query_args, $parsed_args );
453+
}
440454
}
455+
$src = add_query_arg( rawurlencode_deep( $query_args ), $src );
441456

442457
/**
443458
* Filters an enqueued style's fully-qualified URL.

0 commit comments

Comments
 (0)