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