[wp-trac] [WordPress Trac] #10024: Duplicate css file includes for
some wp_register_style() dependencies
WordPress Trac
wp-trac at lists.automattic.com
Wed Jun 3 18:29:51 GMT 2009
#10024: Duplicate css file includes for some wp_register_style() dependencies
--------------------------+-------------------------------------------------
Reporter: archon810 | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone:
Component: General | Version: 2.7.1
Severity: normal | Keywords: wp_register_style, wp_enqueue_style, wp_admin_css_color, css
--------------------------+-------------------------------------------------
I think there is a bug in the logic that handles dependencies for styles.
Allow me to demonstrate.
I am registering a new style for my admin plugin and I want it to load
after certain css files, using the dependency method that
wp_register_style() offers. I want my css to load after wp-admin.css and
colors-classic.css.
{{{
wp_register_style('test_css', "http://test.com/wp-content/my-plugin/css
/my-plugin-admin.css", array('wp-admin', 'colors-classic'));
wp_enqueue_style('test_css');
}}}
This works just fine and my css indeed loads AFTER the 2 dependencies,
except there it is followed by a duplicate
{{{
<link rel='stylesheet' href='http://test.com/wp-admin/css/colors-
classic.css?ver=20081210' type='text/css' media='all' />
}}}
I traced it down to line 41 in wp-admin/admin.php:
{{{
wp_admin_css_color('classic', __('Blue'), admin_url("css/colors-
classic.css"), array('#073447', '#21759B', '#EAF3FA', '#BBD8E7'));
}}}
Apparently wp_admin_css_color() doesn't play well with dependency handling
and inserts an extra colors-classic.css anyway, even though it's already
been inserted, thus creating a duplicate as well as overriding my styles
all over again.
This is what the final output looks like right now:
{{{
<link rel='stylesheet' href='http://test.com/wp-admin/wp-
admin.css?ver=20081210' type='text/css' media='all' />
<link rel='stylesheet' href='http://test.com/wp-admin/css/colors-
classic.css?ver=20081210' type='text/css' media='all' />
<link rel='stylesheet' href='http://test.com/wp-content/my-plugin/css/my-
plugin-admin.css?ver=2.7.1' type='text/css' media='all' />
<link rel='stylesheet' href='http://test.com/wp-
admin/css/global.css?ver=20081210' type='text/css' media='all' />
<link rel='stylesheet' href='http://test.com/wp-admin/css/colors-
classic.css?ver=20081210' type='text/css' media='all' />
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/10024>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list