bp_dtheme_custom_background_style

The style for the custom background image or colour.

Description

bp_dtheme_custom_background_style(); 

Referenced via add_custom_background() in bp_dtheme_setup().


Usage

  1. if ( !function_exists( 'bp_dtheme_custom_background_style' ) ) { 
  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_custom_background_style(); 
  7.  

Defined (1)

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

/bp-themes/bp-default/functions.php  
  1. function bp_dtheme_custom_background_style() { 
  2. $background = get_background_image(); 
  3. $color = get_background_color(); 
  4. if ( ! $background && ! $color ) 
  5. return; 
  6.  
  7. $style = $color ? "background-color: #$color;" : ''; 
  8.  
  9. if ( $style && !$background ) { 
  10. $style .= ' background-image: none;'; 
  11.  
  12. } elseif ( $background ) { 
  13. $image = " background-image: url('$background');"; 
  14.  
  15. $repeat = get_theme_mod( 'background_repeat', 'repeat' ); 
  16. if ( ! in_array( $repeat, array( 'no-repeat', 'repeat-x', 'repeat-y', 'repeat' ) ) ) 
  17. $repeat = 'repeat'; 
  18. $repeat = " background-repeat: $repeat;"; 
  19.  
  20. $position = get_theme_mod( 'background_position_x', 'left' ); 
  21. if ( ! in_array( $position, array( 'center', 'right', 'left' ) ) ) 
  22. $position = 'left'; 
  23. $position = " background-position: top $position;"; 
  24.  
  25. $attachment = get_theme_mod( 'background_attachment', 'scroll' ); 
  26. if ( ! in_array( $attachment, array( 'fixed', 'scroll' ) ) ) 
  27. $attachment = 'scroll'; 
  28. $attachment = " background-attachment: $attachment;"; 
  29.  
  30. $style .= $image . $repeat . $position . $attachment; 
  31. ?> 
  32. <style type="text/css"> 
  33. body { <?php echo trim( $style ); ?> } 
  34. </style> 
  35. <?php