Skip to:
Content

BuddyPress.org

Ticket #3389: 3389.03.patch

File 3389.03.patch, 1.6 KB (added by boonebgorges, 15 years ago)
  • bp-themes/bp-default/functions.php

    function bp_dtheme_enqueue_styles() {  
    180180        // Bump this when changes are made to bust cache
    181181        $version = '20110830';
    182182
    183         // Default CSS
    184         wp_enqueue_style( 'bp-default-main', get_template_directory_uri() . '/_inc/css/default.css', array(), $version );
     183        // We may flip this flag later
     184        $enqueue_default_stylesheet = false;
     185
     186        // Register the default CSS
     187        wp_register_style( 'bp-default-main', get_template_directory_uri() . '/_inc/css/default.css', array(), $version );
     188
     189        // Child themes of bp-default must have their styles enqueued manually
     190        if ( 'bp-default' == get_template() ) {
     191                // Pull only the first 8kiB of the file in. @imports should be near the top
     192                $file_data = file_get_contents( STYLESHEETPATH . '/style.css', 8192 );
     193
     194                $pattern = '|@import url\(\s*(\.\./)*plugins/buddypress/bp\-themes/bp\-default/_inc/css/default\.css|';
     195
     196                // If there's an @import rule, save an HTTP request and don't enqueue
     197                if ( preg_match( $pattern, $file_data ) ) {
     198                        // Enqueue the stylesheet
     199                        wp_enqueue_style( get_stylesheet(), get_stylesheet_uri(), array(), $version );
     200                        $enqueue_default_stylesheet = false;
     201                } else {
     202                        // Enqueue the stylesheet
     203                        wp_enqueue_style( get_stylesheet(), get_stylesheet_uri(), array( 'bp-default-main' ), $version );
     204                }
     205        }
     206
     207        if ( $enqueue_default_stylesheet )
     208                wp_enqueue_style( 'bp-default-main' );
    185209
    186210        // Default CSS RTL
    187211        if ( is_rtl() )