Ticket #7011 (closed enhancement: fixed)
Create wp_print_styles() to match wp_print_scripts()
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 2.6 |
| Component: | General | Version: | 2.5.1 |
| Severity: | normal | Keywords: | backpress has-patch |
| Cc: |
Description
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
Change History
As for file naming, we typically use class- and bundle wrapper functions in with the class. I haven't a strong preference, however.
7011.b.diff
- Adds wp_default_styles() that registers core CSS.
- 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.
- Adds support in WP_Styles for RTL stylesheets and conditionally loaded stylesheets.
- Switch from clean_url() to {{{attribute_escape()}} so that URLs could be relative. Bad idea?.
-
attachment
7011.c.diff
added
Same as .b.diff but uses clean_url() instead of attribute_escape()
- Owner changed from anonymous to mdawaffe
- Status changed from new to assigned
7011.d.diff
- Add $force_echo parameter to wp_admin_css().
- Add admin_print_styles action to a few files that don't use admin-header.php.
- Use the above 2 to fix style printing/queueing on files that don't use admin-header.php.
- Manually register colors-fresh for the sake of wp-login.php. colors-classic or others are not needed. Slightly hacky.
- Remove all one-off functions that add a wp_admin_css() call to admin_head or similar.
- Deprecated wp_admin_css( 'css/whatever' ) in favor of wp_admin_css( 'whatever' ).
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).
