Make WordPress Core

Opened 8 years ago

Closed 7 years ago

#7011 closed enhancement (fixed)

Create wp_print_styles() to match wp_print_scripts()

Reported by: mdawaffe Owned by: mdawaffe
Milestone: 2.6 Priority: normal
Severity: normal Version: 2.5.1
Component: General Keywords: backpress has-patch
Focuses: Cc:


I've just updated backPress to include both WP_Scripts and WP_Styles both of which inherit from WP_Dependencies (a generic "this thing depends on that thing" class).

Attached is a patch that converts WP over to the backPress classes.

Scripts work just fine; the API has not changed, and the class methods themselves are all backward compatible. Styles are there, but nothing uses them right now. WP should probably have a wp_default_styles() function (analogous to the patch's wp_default_scripts() function).

I don't know if we'll use the dependency functionality much for stylesheets (like we do for scripts), or if we just want to use it as a stylesheet queue/loader.

The new files have names that adhere to the backPress naming "standard" (a made up, arbitrary standard). We can name them whatever we like.

svn stat

A      wp-includes/class.wp-dependencies.php
A      wp-includes/class.wp-scripts.php
A      wp-includes/class.wp-styles.php
A      wp-includes/functions.wp-scripts.php
A      wp-includes/functions.wp-styles.php

M      wp-includes/default-filters.php
M      wp-includes/script-loader.php
M      wp-admin/admin-header.php

Attachments (4)

7011.diff (47.2 KB) - added by mdawaffe 8 years ago.
7011.b.diff (8.9 KB) - added by mdawaffe 8 years ago.
add wp_default_styles(), convert wp_admin_css()
7011.c.diff (8.9 KB) - added by mdawaffe 8 years ago.
Same as .b.diff but uses clean_url() instead of attribute_escape()
7011.d.diff (10.7 KB) - added by mdawaffe 8 years ago.
bug fixes, eliminate one-offs

Download all attachments as: .zip

Change History (13)

8 years ago

#1 @ryan
8 years ago

(In [7970]) Style loader from mdawaffe. see #7011

#2 @ryan
8 years ago

As for file naming, we typically use class- and bundle wrapper functions in with the class. I haven't a strong preference, however.

8 years ago

add wp_default_styles(), convert wp_admin_css()

#3 @mdawaffe
8 years ago


  1. Adds wp_default_styles() that registers core CSS.
  2. Converts wp_admin_css() which now *enqueues* if possible, and prints if we've already printed the queue. No more annoying one off functions adding a call to wp_admin_css() in admin_head.
  3. Adds support in WP_Styles for RTL stylesheets and conditionally loaded stylesheets.
  4. Switch from clean_url() to {{{attribute_escape()}} so that URLs could be relative. Bad idea?.

8 years ago

Same as .b.diff but uses clean_url() instead of attribute_escape()

#4 @ryan
8 years ago

(In [7976]) Add wp_default_styles(), convert wp_admin_css(). Props mdawaffe. see #7011

8 years ago

bug fixes, eliminate one-offs

#5 @mdawaffe
8 years ago

  • Owner changed from anonymous to mdawaffe
  • Status changed from new to assigned


  1. Add $force_echo parameter to wp_admin_css().
  2. Add admin_print_styles action to a few files that don't use admin-header.php.
  3. Use the above 2 to fix style printing/queueing on files that don't use admin-header.php.
  4. Manually register colors-fresh for the sake of wp-login.php. colors-classic or others are not needed. Slightly hacky.
  5. Remove all one-off functions that add a wp_admin_css() call to admin_head or similar.
  6. Deprecated wp_admin_css( 'css/whatever' ) in favor of wp_admin_css( 'whatever' ).

#6 @ryan
8 years ago

(In [7979]) wp_admin_css() improvements. Props mdawaffe. see #7011

#7 @azaozz
8 years ago

All works very well, now css files can be registered, deregistered, enqueued, etc. like the js files.

A small side note: the way the RTL css files are added in script-loader.php is a bit hard to read. Perhaps we could add them one by one under each corresponding css file, with paths, like wp-admin.css. It will make it slightly bulkier, but would be a lot easier to read/edit (and the conditional is_bool() can be removed from class.wp-styles.php).

#8 @ryan
7 years ago

  • Milestone changed from 2.9 to 2.6

#9 @ryan
7 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.