Changeset 3927 for branches/plugin/bbp-includes/bbp-theme-compatibility.php
- Timestamp:
- 05/31/2012 04:30:09 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-includes/bbp-theme-compatibility.php
r3923 r3927 37 37 38 38 /** 39 * @var string ID of the theme (should be unique) 39 * Should be like: 40 * 41 * array( 42 * 'id' => ID of the theme (should be unique) 43 * 'name' => Name of the theme (should match style.css) 44 * 'version' => Theme version for cache busting scripts and styling 45 * 'dir' => Path to theme 46 * 'url' => URL to theme 47 * ); 48 * @var array 40 49 */ 41 p ublic $id = '';50 private $_data = array(); 42 51 43 52 /** 44 * @var string Name of the theme (should match style.css) 53 * Pass the $properties to the object on creation. 54 * 55 * @since bbPress (r3926) 56 * @param array $properties 45 57 */ 46 public $name = ''; 58 public function __construct( Array $properties = array() ) { 59 $this->_data = $properties; 60 } 47 61 48 62 /** 49 * @var string Theme version for cache busting scripts and styling 63 * Set a theme's property. 64 * 65 * @since bbPress (r3926) 66 * @param string $property 67 * @param mixed $value 68 * @return mixed 50 69 */ 51 public $version = ''; 70 public function __set( $property, $value ) { 71 return $this->_data[$property] = $value; 72 } 52 73 53 74 /** 54 * @var string Path to theme 75 * Get a theme's property. 76 * 77 * @since bbPress (r3926) 78 * @param string $property 79 * @param mixed $value 80 * @return mixed 55 81 */ 56 public $dir = ''; 57 58 /** 59 * @var string URL to theme 60 */ 61 public $url = ''; 82 public function __get( $property ) { 83 return array_key_exists( $property, $this->_data ) ? $this->_data[$property] : ''; 84 } 62 85 } 63 86 … … 206 229 207 230 return bbpress()->theme_compat->template; 231 } 232 233 /** 234 * Set the theme compat original_template global 235 * 236 * Stash the original template file for the current query. Useful for checking 237 * if bbPress was able to find a more appropriate template. 238 * 239 * @since bbPress (r3926) 240 */ 241 function bbp_set_theme_compat_original_template( $template = '' ) { 242 bbpress()->theme_compat->original_template = $template; 243 244 return bbpress()->theme_compat->original_template; 245 } 246 247 /** 248 * Set the theme compat original_template global 249 * 250 * Stash the original template file for the current query. Useful for checking 251 * if bbPress was able to find a more appropriate template. 252 * 253 * @since bbPress (r3926) 254 */ 255 function bbp_is_theme_compat_original_template( $template = '' ) { 256 $bbp = bbpress(); 257 258 if ( empty( $bbp->theme_compat->original_template ) ) 259 return false; 260 261 return (bool) ( $bbp->theme_compat->original_template == $template ); 208 262 } 209 263 … … 341 395 function bbp_template_include_theme_compat( $template = '' ) { 342 396 343 // Only filter the main query 344 if ( ! is_main_query() ) 397 // Bail if the template doesn't specifically match a bbPress template. This 398 // includes archive-* and single-* WordPress post_type matches, allowing 399 // themes to use the expected format. 400 if ( bbp_is_theme_compat_original_template( $template ) ) 345 401 return $template; 346 402 … … 739 795 if ( !apply_filters( 'bbp_spill_the_beans', false ) ) { 740 796 741 // Setup the chopping block 742 global $withcomments, $post; 743 744 // Empty out globals that aren't being used in this loop anymore 745 $withcomments = $post = false; 797 // Empty globals that aren't being used in this loop anymore 798 $GLOBALS['withcomments'] = false; 799 $GLOBALS['post'] = false; 746 800 747 801 // Reset the post data when the next sidebar is fired
Note: See TracChangeset
for help on using the changeset viewer.