Skip to:
Content

BuddyPress.org

Ticket #3389: 3389.02.patch

File 3389.02.patch, 1.8 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                // Now we test to see whether the stylesheet does @import for bp-default's CSS
     192                // Open the child theme's stylesheet
     193                $fp = fopen( STYLESHEETPATH . '/style.css', 'r' );
     194
     195                // Pull only the first 8kiB of the file in. @imports should be near the top
     196                $file_data = fread( $fp, 8192 );
     197
     198                // PHP will close file handle, but we are good citizens.
     199                fclose( $fp );
     200
     201                $pattern = '|@import url\(\s*(\.\./)*plugins/buddypress/bp\-themes/bp\-default/_inc/css/default\.css|';
     202
     203                // If there's an @import rule, save an HTTP request and don't enqueue
     204                if ( preg_match( $pattern, $file_data ) ) {
     205                        // Enqueue the stylesheet
     206                        wp_enqueue_style( get_stylesheet(), get_stylesheet_uri(), array(), $version );
     207                        $enqueue_default_stylesheet = false;
     208                } else {
     209                        // Enqueue the stylesheet
     210                        wp_enqueue_style( get_stylesheet(), get_stylesheet_uri(), array( 'bp-default-main' ), $version );
     211                }
     212        }
     213
     214        if ( $enqueue_default_stylesheet )
     215                wp_enqueue_style( 'bp-default-main' );
    185216
    186217        // Default CSS RTL
    187218        if ( is_rtl() )