@@ -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 ;
@@ -118,9 +123,15 @@ class WP_Styles extends WP_Dependencies {
118123 */
119124 public function __construct () {
120125 if (
121- function_exists ( 'is_admin ' ) && ! is_admin ()
122- &&
123- function_exists ( 'current_theme_supports ' ) && ! current_theme_supports ( 'html5 ' , 'style ' )
126+ (
127+ function_exists ( 'is_admin ' ) &&
128+ ! is_admin ()
129+ )
130+ &&
131+ (
132+ function_exists ( 'current_theme_supports ' ) &&
133+ ! current_theme_supports ( 'html5 ' , 'style ' )
134+ )
124135 ) {
125136 $ this ->type_attr = " type='text/css' " ;
126137 }
@@ -212,7 +223,7 @@ public function do_item( $handle, $group = false ) {
212223 return true ;
213224 }
214225
215- $ href = $ this ->_css_href ( $ src , $ ver , $ handle );
226+ $ href = $ this ->_css_href ( $ src , $ obj -> ver , $ handle );
216227 if ( ! $ href ) {
217228 return true ;
218229 }
@@ -419,19 +430,29 @@ public function all_deps( $handles, $recursion = false, $group = false ) {
419430 *
420431 * @since 2.6.0
421432 *
422- * @param string $src The source of the enqueued style.
423- * @param string $ver The version of the enqueued style.
424- * @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.
425436 * @return string Style's fully-qualified URL.
426437 */
427438 public function _css_href ( $ src , $ ver , $ handle ) {
428439 if ( ! is_bool ( $ src ) && ! preg_match ( '|^(https?:)?//| ' , $ src ) && ! ( $ this ->content_url && str_starts_with ( $ src , $ this ->content_url ) ) ) {
429440 $ src = $ this ->base_url . $ src ;
430441 }
431442
432- if ( ! empty ( $ ver ) ) {
433- $ 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+ }
434454 }
455+ $ src = add_query_arg ( rawurlencode_deep ( $ query_args ), $ src );
435456
436457 /**
437458 * Filters an enqueued style's fully-qualified URL.
0 commit comments