BP_Theme_Compat

Theme Compatibility base class.

Defined (1)

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

/bp-core/classes/class-bp-theme-compat.php  
  1. class BP_Theme_Compat { 
  2.  
  3. /** 
  4. * Template package properties, as passed to the constructor. 
  5. * @since 1.7.0 
  6. * @var array 
  7. */ 
  8. protected $_data = array(); 
  9.  
  10. /** 
  11. * Pass the $properties to the object on creation. 
  12. * @since 1.7.0 
  13. * @param array $properties Array of properties for BP_Theme_Compat. 
  14. */ 
  15. public function __construct( Array $properties = array() ) { 
  16. $this->_data = $properties; 
  17.  
  18. /** 
  19. * Set up the BuddyPress-specific theme compat methods. 
  20. * Themes should use this method in their constructor. 
  21. * @since 1.7.0 
  22. */ 
  23. protected function start() { 
  24. // Sanity check. 
  25. if ( ! bp_use_theme_compat_with_current_theme() ) { 
  26. return; 
  27.  
  28. // Setup methods. 
  29. $this->setup_globals(); 
  30. $this->setup_actions(); 
  31.  
  32. /** 
  33. * Set up global data for your template package. 
  34. * Meant to be overridden in your class. See 
  35. * {@link BP_Legacy::setup_globals()} for an example. 
  36. * @since 1.7.0 
  37. */ 
  38. protected function setup_globals() {} 
  39.  
  40. /** 
  41. * Set up theme hooks for your template package. 
  42. * Meant to be overridden in your class. See 
  43. * {@link BP_Legacy::setup_actions()} for an example. 
  44. * @since 1.7.0 
  45. */ 
  46. protected function setup_actions() {} 
  47.  
  48. /** 
  49. * Set a theme's property. 
  50. * @since 1.7.0 
  51. * @param string $property Property name. 
  52. * @param mixed $value Property value. 
  53. * @return bool True on success, false on failure. 
  54. */ 
  55. public function __set( $property, $value ) { 
  56. return $this->_data[$property] = $value; 
  57.  
  58. /** 
  59. * Get a theme's property. 
  60. * @since 1.7.0 
  61. * @param string $property Property name. 
  62. * @return mixed The value of the property if it exists, otherwise an 
  63. * empty string. 
  64. */ 
  65. public function __get( $property ) { 
  66. return array_key_exists( $property, $this->_data ) ? $this->_data[$property] : '';