The colors
handle is for the “Admin Color Scheme” stylesheet (see the Users → Profile page at wp-admin/profile.php
) and it’s registered via wp_default_styles()
, like so:
( $styles
is an instance of the WP_Styles
class which extends the WP_Dependencies
class which has an add()
method where the second parameter is the stylesheet path )
// Register a stylesheet for the selected admin color scheme.
$styles->add( 'colors', true, array( 'wp-admin', 'buttons' ) );
So the $wp_style->src
(or src
value for the colors
style) is a boolean true
, but because your code echo it, then PHP converts it to the string “1” and that’s why $wp_style->src
in your code outputted a 1
. If you did var_dump( $wp_style->src );
, then you would have noticed that it’s a boolean.
And the reason the stylesheet’s path or URL is not defined when it’s registered, is because it will be set/determined dynamically via wp_style_loader_src()
, which is hooked on style_loader_src
.
So for example, if I selected the “Sunrise” color scheme, then the above function might return a URL like https://example.com/wp-admin/css/colors/sunrise/colors.min.css
(or without the .min
part), if I was on an admin page.
And in your code, you could do like so which would return the proper path if you’re on an admin page:
$style_url = apply_filters( 'style_loader_src', $wp_style->src, $wp_style->handle );
Or for testing purposes, you could do wp_style_loader_src( true, 'colors' )
.. before your foreach
.