Changeset 3927
- Timestamp:
- 05/31/2012 04:30:09 AM (14 years ago)
- Location:
- branches/plugin
- Files:
-
- 3 edited
-
bbp-includes/bbp-template-loader.php (modified) (5 diffs)
-
bbp-includes/bbp-theme-compatibility.php (modified) (4 diffs)
-
bbpress.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-includes/bbp-template-loader.php
r3922 r3927 14 14 * Possibly intercept the template being loaded 15 15 * 16 * Listens to the 'template_include' filter and waits for a bbPress post_type 17 * to appear. If the current theme does not explicitly support bbPress, it 18 * intercepts the page template and uses one served from the bbPress compatable 19 * theme, set in the $bbp->theme_compat global. If the current theme does 20 * support bbPress, we'll explore the template hierarchy and try to locate one. 16 * Listens to the 'template_include' filter and waits for any bbPress specific 17 * template condition to be met. If one is met and the template file exists, 18 * it will be used; otherwise 21 19 * 22 20 * @since bbPress (r3032) … … 46 44 function bbp_template_include_theme_supports( $template = '' ) { 47 45 46 // Set the original template that WordPress found so we can compare the 47 // one bbPress find's in bbp_template_include_theme_compat(). 48 bbp_set_theme_compat_original_template( $template ); 49 50 /** bbPress Templates *****************************************************/ 51 52 // Note that the _edit() checks are ahead of their counterparts, to 53 // prevent them from being stomped on accident. 54 55 // Editing a user 56 if ( bbp_is_single_user_edit() && ( $new_template = bbp_get_single_user_edit_template() ) ) : 57 48 58 // Viewing a user 49 if ( bbp_is_single_user() && ( $new_template = bbp_get_single_user_template() ) ) : 50 51 // Editing a user 52 elseif ( bbp_is_single_user_edit() && ( $new_template = bbp_get_single_user_edit_template() ) ) : 59 elseif ( bbp_is_single_user() && ( $new_template = bbp_get_single_user_template() ) ) : 53 60 54 61 // Single View 55 62 elseif ( bbp_is_single_view() && ( $new_template = bbp_get_single_view_template() ) ) : 56 63 64 // Forum edit 65 elseif ( bbp_is_forum_edit() && ( $new_template = bbp_get_forum_edit_template() ) ) : 66 57 67 // Single Forum 58 68 elseif ( bbp_is_single_forum() && ( $new_template = bbp_get_single_forum_template() ) ) : … … 61 71 elseif ( bbp_is_forum_archive() && ( $new_template = bbp_get_forum_archive_template() ) ) : 62 72 63 // Forum edit 64 elseif ( bbp_is_forum_edit() && ( $new_template = bbp_get_forum_edit_template() ) ) : 73 // Topic merge 74 elseif ( bbp_is_topic_merge() && ( $new_template = bbp_get_topic_merge_template() ) ) : 75 76 // Topic split 77 elseif ( bbp_is_topic_split() && ( $new_template = bbp_get_topic_split_template() ) ) : 78 79 // Topic edit 80 elseif ( bbp_is_topic_edit() && ( $new_template = bbp_get_topic_edit_template() ) ) : 65 81 66 82 // Single Topic … … 70 86 elseif ( bbp_is_topic_archive() && ( $new_template = bbp_get_topic_archive_template() ) ) : 71 87 72 // Topic merge 73 elseif ( bbp_is_topic_merge() && ( $new_template = bbp_get_topic_merge_template() ) ) : 74 75 // Topic split 76 elseif ( bbp_is_topic_split() && ( $new_template = bbp_get_topic_split_template() ) ) : 77 78 // Topic edit 79 elseif ( bbp_is_topic_edit() && ( $new_template = bbp_get_topic_edit_template() ) ) : 88 // Editing a reply 89 elseif ( bbp_is_reply_edit() && ( $new_template = bbp_get_reply_edit_template() ) ) : 80 90 81 91 // Single Reply 82 92 elseif ( bbp_is_single_reply() && ( $new_template = bbp_get_single_reply_template() ) ) : 83 93 84 // Editing a reply85 elseif ( bbp_is_ reply_edit() && ( $new_template = bbp_get_reply_edit_template()) ) :94 // Editing a topic tag 95 elseif ( bbp_is_topic_tag_edit() && ( $new_template = bbp_get_topic_tag_edit_template() ) ) : 86 96 87 97 // Viewing a topic tag 88 98 elseif ( bbp_is_topic_tag() && ( $new_template = bbp_get_topic_tag_template() ) ) : 89 90 // Editing a topic tag91 elseif ( bbp_is_topic_tag_edit() && ( $new_template = bbp_get_topic_tag_edit_template() ) ) :92 99 endif; 93 100 94 // Custom template file exists 95 $template = !empty( $new_template ) ? $new_template : $template; 101 // bbPress template file exists 102 if ( !empty( $new_template ) && ! bbp_is_theme_compat_original_template( $new_template ) ) 103 $template = $new_template; 96 104 97 105 return apply_filters( 'bbp_template_include_theme_supports', $template ); … … 403 411 $templates = array( 404 412 'bbpress.php', 413 'forums.php', 405 414 'forum.php', 406 415 'page.php', -
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 -
branches/plugin/bbpress.php
r3920 r3927 533 533 /** Default Theme *****************************************************/ 534 534 535 $theme = new BBP_Theme_Compat(); 536 $theme->id = 'default'; 537 $theme->name = __( 'bbPress Default', 'bbpress' ); 538 $theme->version = bbp_get_version(); 539 $theme->dir = trailingslashit( $this->plugin_dir . 'bbp-theme-compat' ); 540 $theme->url = trailingslashit( $this->plugin_url . 'bbp-theme-compat' ); 541 542 bbp_register_theme_package( $theme ); 543 544 /** Default Theme *****************************************************/ 545 546 $theme = new BBP_Theme_Compat(); 547 $theme->id = 'bbp-twentyten'; 548 $theme->name = __( 'Twenty Ten (bbPress)', 'bbpress' ) ; 549 $theme->version = bbp_get_version(); 550 $theme->dir = trailingslashit( $this->themes_dir . 'bbp-twentyten' ); 551 $theme->url = trailingslashit( $this->themes_url . 'bbp-twentyten' ); 552 553 bbp_register_theme_package( $theme ); 535 bbp_register_theme_package( new BBP_Theme_Compat( array( 536 'id' => 'default', 537 'name' => __( 'bbPress Default', 'bbpress' ), 538 'version' => bbp_get_version(), 539 'dir' => trailingslashit( $this->plugin_dir . 'bbp-theme-compat' ), 540 'url' => trailingslashit( $this->plugin_url . 'bbp-theme-compat' ) 541 ) ) ); 542 543 /** Twenty Ten ********************************************************/ 544 545 bbp_register_theme_package( new BBP_Theme_Compat( array( 546 'id' => 'bbp-twentyten', 547 'name' => __( 'Twenty Ten (bbPress)', 'bbpress' ), 548 'version' => bbp_get_version(), 549 'dir' => trailingslashit( $this->themes_dir . 'bbp-twentyten' ), 550 'url' => trailingslashit( $this->themes_url . 'bbp-twentyten' ) 551 ) ) ); 554 552 } 555 553
Note: See TracChangeset
for help on using the changeset viewer.