bp_dtheme_enqueue_styles

Enqueue theme CSS safely.

Description

bp_dtheme_enqueue_styles(); 

For maximum flexibility, BuddyPress Default's stylesheet is enqueued, using wp_enqueue_style(). If you're building a child theme of bp-default, your stylesheet will also be enqueued, automatically, as dependent on bp-default's CSS. For this reason, bp-default child themes are not recommended to include bp-default's stylesheet using @import.

If you would prefer to use @import, or would like to change the way in which stylesheets are enqueued, you can override bp_dtheme_enqueue_styles() in your theme's functions.php file.


Usage

  1. if ( !function_exists( 'bp_dtheme_enqueue_styles' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-themes/bp-default/functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bp_dtheme_enqueue_styles(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/bp-themes/bp-default/functions.php  
  1. function bp_dtheme_enqueue_styles() { 
  2.  
  3. // Register our main stylesheet 
  4. wp_register_style( 'bp-default-main', get_template_directory_uri() . '/_inc/css/default.css', array(), bp_get_version() ); 
  5.  
  6. // If the current theme is a child of bp-default, enqueue its stylesheet 
  7. if ( is_child_theme() && 'bp-default' == get_template() ) { 
  8. wp_enqueue_style( get_stylesheet(), get_stylesheet_uri(), array( 'bp-default-main' ), bp_get_version() ); 
  9.  
  10. // Enqueue the main stylesheet 
  11. wp_enqueue_style( 'bp-default-main' ); 
  12.  
  13. // Default CSS RTL 
  14. if ( is_rtl() ) 
  15. wp_enqueue_style( 'bp-default-main-rtl', get_template_directory_uri() . '/_inc/css/default-rtl.css', array( 'bp-default-main' ), bp_get_version() ); 
  16.  
  17. // Responsive layout 
  18. if ( current_theme_supports( 'bp-default-responsive' ) ) { 
  19. wp_enqueue_style( 'bp-default-responsive', get_template_directory_uri() . '/_inc/css/responsive.css', array( 'bp-default-main' ), bp_get_version() ); 
  20.  
  21. if ( is_rtl() ) { 
  22. wp_enqueue_style( 'bp-default-responsive-rtl', get_template_directory_uri() . '/_inc/css/responsive-rtl.css', array( 'bp-default-responsive' ), bp_get_version() );