Ticket #7011 (assigned enhancement)

Opened 6 months ago

Last modified 6 months ago

Create wp_print_styles() to match wp_print_scripts()

Reported by: mdawaffe Assigned to: mdawaffe (accepted)
Priority: normal Milestone: 2.9
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

7011.diff (47.2 kB) - added by mdawaffe on 05/21/08 01:05:39.
7011.b.diff (8.9 kB) - added by mdawaffe on 05/21/08 22:59:08.
add wp_default_styles(), convert wp_admin_css()
7011.c.diff (8.9 kB) - added by mdawaffe on 05/21/08 23:15:21.
Same as .b.diff but uses clean_url() instead of attribute_escape()
7011.d.diff (10.7 kB) - added by mdawaffe on 05/21/08 23:58:00.
bug fixes, eliminate one-offs

Change History

05/21/08 01:05:39 changed by mdawaffe

  • attachment 7011.diff added.

05/21/08 05:56:06 changed by ryan

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

05/21/08 16:28:09 changed by ryan

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

05/21/08 22:59:08 changed by mdawaffe

  • attachment 7011.b.diff added.

add wp_default_styles(), convert wp_admin_css()

05/21/08 23:04:28 changed by mdawaffe

7011.b.diff

  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?.

05/21/08 23:15:21 changed by mdawaffe

  • attachment 7011.c.diff added.

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

05/21/08 23:24:23 changed by ryan

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

05/21/08 23:58:00 changed by mdawaffe

  • attachment 7011.d.diff added.

bug fixes, eliminate one-offs

05/22/08 00:03:21 changed by mdawaffe

  • owner changed from anonymous to mdawaffe.
  • status changed from new to assigned.

7011.d.diff

  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' ).

05/22/08 00:06:41 changed by ryan

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

05/25/08 20:13:18 changed by azaozz

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).