[buddypress-trac] [BuddyPress] #3389: Enqueueing CSS of bp-default breaks child theme layouts
buddypress-trac at lists.automattic.com
buddypress-trac at lists.automattic.com
Wed Aug 31 16:35:14 UTC 2011
#3389: Enqueueing CSS of bp-default breaks child theme layouts
-----------------------+------------------
Reporter: mercime | Owner:
Type: defect | Status: new
Priority: normal | Milestone: 1.5
Component: Theme | Version:
Severity: normal | Resolution:
Keywords: has-patch |
-----------------------+------------------
Changes (by boonebgorges):
* keywords: close => has-patch
Comment:
As I looked into the issue I think I came to understand it a bit better.
3389.02.patch is a suggested fix, more or less along the lines of one of
jjj's suggestions.
Essentially, 3389.02.patch enqueues the child theme's stylesheet manually.
There are a few additional niceties involved. I open the stylesheet to see
if there is an @import rule for bp-default's default.css. (1) If YES, then
I enqueue the child theme's stylesheet and block bp-default from enqueuing
its own styles (thus saving an HTTP request, as default.css will only be
fetched once). (2) If NO, then I enqueue the child theme's stylesheet,
with a dependency on bp-default's default.css, and then allow bp-default
to enqueue it's own style.
There is a bit of overhead involved in the fread() method, but I think
it's better than attempting to load default.css twice over HTTP.
Here's how this pans out for different kinds of child themes:
(a) Existing child themes, and child themes in the future that use the
@import method, will fall into category (1) above. Thus they will continue
to work, unmodified. In this case, you lose the advantages of enqueuing,
but you get the benefit that you don't break the whole theme :)
(b) Child themes that use the previously suggested method of overriding
the pluggable function {{{bp_dtheme_enqueue_styles()}}} will continue to
work as expected - they avoid this new logic altogether, because the
function is never called.
With this fix, I suggest that we keep recommending child theme authors to
use the {{{bp_dtheme_enqueue_styles()}}} override method for building
their themes. It will eliminate the unnecessary overhead of using fread()
on the child theme stylesheet, and it will take full advantage of WP's
enqueuing architecture.
I like this solution, because it maintains 100% compatibility with old
themes (at least as far as this enqueuing business is concerned ;) ) but
ensures that the new enqueue method will get used as much as possible. (To
be honest, I think that WP's core child theme infrastructure should do
something along these lines.)
Feedback?
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/3389#comment:39>
BuddyPress <http://buddypress.org/>
BuddyPress
More information about the buddypress-trac
mailing list