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