Skip to:
Content

Changeset 5124


Ignore:
Timestamp:
09/07/11 23:13:36 (3 years ago)
Author:
boonebgorges
Message:

Modifies bp_dtheme_enqueue_styles() so that stylesheets of bp-default child themes are enqueued as bp-default dependent. This should maximize backward compatibility with the @import method, while providing maximum flexibility through the use of wp_enqueue_style(). Fixes #3389. Props johnjamesjacoby for the concept

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-themes/bp-default/functions.php

    r5056 r5124  
    166166 * Enqueue theme CSS safely 
    167167 * 
    168  * For maximum flexibility, BuddyPress Default's stylesheet is enqueued in the following fashion. 
    169  * If you're building a child theme of bp-default, you can prevent this enqueuing by overriding 
    170  * this function in your child theme's functions.php: 
    171  *   if ( !function_exists( 'bp_dtheme_enqueue_styles' ) ) : 
    172  *       function bp_dtheme_enqueue_styles() {} 
    173  *   endif; 
     168 * For maximum flexibility, BuddyPress Default's stylesheet is enqueued, using wp_enqueue_style(). 
     169 * If you're building a child theme of bp-default, your stylesheet will also be enqueued, 
     170 * automatically, as dependent on bp-default's CSS. For this reason, bp-default child themes are 
     171 * not recommended to include bp-default's stylesheet using @import. 
     172 * 
     173 * If you would prefer to use @import, or would like to change the way in which stylesheets are 
     174 * enqueued, you can override bp_dtheme_enqueue_styles() in your theme's functions.php file. 
    174175 * 
    175176 * @see http://codex.wordpress.org/Function_Reference/wp_enqueue_style 
     
    181182    $version = '20110830'; 
    182183 
    183     // Default CSS 
    184     wp_enqueue_style( 'bp-default-main', get_template_directory_uri() . '/_inc/css/default.css', array(), $version ); 
     184    // Register our main stylesheet 
     185    wp_register_style( 'bp-default-main', get_template_directory_uri() . '/_inc/css/default.css', array(), $version ); 
     186 
     187    // If the current theme is a child of bp-default, enqueue its stylesheet 
     188    if ( is_child_theme() && 'bp-default' == get_template() ) { 
     189        wp_enqueue_style( get_stylesheet(), get_stylesheet_uri(), array( 'bp-default-main' ), $version ); 
     190    } 
     191 
     192    // Enqueue the main stylesheet 
     193    wp_enqueue_style( 'bp-default-main' ); 
    185194 
    186195    // Default CSS RTL 
Note: See TracChangeset for help on using the changeset viewer.