[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * BuddyPress Core Theme Compatibility Base Class. 4 * 5 * @package BuddyPress 6 * @subpackage ThemeCompatibility 7 * @since 1.7.0 8 */ 9 10 // Exit if accessed directly. 11 defined( 'ABSPATH' ) || exit; 12 13 /** 14 * Theme Compatibility base class. 15 * 16 * This is only intended to be extended, and is included here as a basic guide 17 * for future Theme Packs to use. {@link BP_Legacy} is a good example of 18 * extending this class. 19 * 20 * @since 1.7.0 21 * 22 * @todo We should probably do something similar to BP_Component::start(). 23 * @todo If this is only intended to be extended, it should be abstract. 24 * 25 * @param array $properties { 26 * An array of properties describing the theme compat package. 27 * @type string $id ID of the package. Must be unique. 28 * @type string $name Name of the theme. This should match the name given 29 * in style.css. 30 * @type string $version Theme version. Used for busting script and style 31 * browser caches. 32 * @type string $dir Filesystem path of the theme. 33 * @type string $url Base URL of the theme. 34 * } 35 */ 36 class BP_Theme_Compat { 37 38 /** 39 * Template package properties, as passed to the constructor. 40 * 41 * @since 1.7.0 42 * @var array 43 */ 44 protected $_data = array(); 45 46 /** 47 * Pass the $properties to the object on creation. 48 * 49 * @since 1.7.0 50 * 51 * @param array $properties Array of properties for BP_Theme_Compat. 52 */ 53 public function __construct( Array $properties = array() ) { 54 $this->_data = $properties; 55 } 56 57 /** 58 * Set up the BuddyPress-specific theme compat methods. 59 * 60 * Themes should use this method in their constructor. 61 * 62 * @since 1.7.0 63 */ 64 protected function start() { 65 // Sanity check. 66 if ( ! bp_use_theme_compat_with_current_theme() ) { 67 return; 68 } 69 70 // Setup methods. 71 $this->setup_globals(); 72 $this->setup_actions(); 73 } 74 75 /** 76 * Set up global data for your template package. 77 * 78 * Meant to be overridden in your class. See 79 * {@link BP_Legacy::setup_globals()} for an example. 80 * 81 * @since 1.7.0 82 */ 83 protected function setup_globals() {} 84 85 /** 86 * Set up theme hooks for your template package. 87 * 88 * Meant to be overridden in your class. See 89 * {@link BP_Legacy::setup_actions()} for an example. 90 * 91 * @since 1.7.0 92 */ 93 protected function setup_actions() {} 94 95 /** 96 * Set a theme's property. 97 * 98 * @since 1.7.0 99 * 100 * @param string $property Property name. 101 * @param mixed $value Property value. 102 * @return bool True on success, false on failure. 103 */ 104 public function __set( $property, $value ) { 105 return $this->_data[$property] = $value; 106 } 107 108 /** 109 * Get a theme's property. 110 * 111 * @since 1.7.0 112 * 113 * @param string $property Property name. 114 * @return mixed The value of the property if it exists, otherwise an 115 * empty string. 116 */ 117 public function __get( $property ) { 118 return array_key_exists( $property, $this->_data ) ? $this->_data[$property] : ''; 119 } 120 121 /** 122 * Check a theme's property exists. 123 * 124 * @since 9.0.0 125 * 126 * @param string $property Property name. 127 * @return bool True if the property exists. False otherwise. 128 */ 129 public function __isset( $property ) { 130 return array_key_exists( $property, $this->_data ); 131 } 132 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Dec 22 01:00:54 2024 | Cross-referenced by PHPXref 0.7.1 |