Skip to:
Content

bbPress.org


Ignore:
Timestamp:
05/31/2012 04:30:09 AM (14 years ago)
Author:
johnjamesjacoby
Message:

Theme Compatibility:

  • Introduce bbp_is_theme_compat_original_template() and bbp_set_theme_compat_original_template() functions, to allow the template loader to properly use custom post type templates.
  • Refactor BBP_Theme_Compat to use magic methods.
  • Reorder bbp_template_include_theme_supports() to put _edit() checks before single/archive checks, to prevent them from being stomped.
  • Clean up BBP_Theme_Compat usage to work with refactored approach.
  • Fixes #1833.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-template-loader.php

    r3922 r3927  
    1414 * Possibly intercept the template being loaded
    1515 *
    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
    2119 *
    2220 * @since bbPress (r3032)
     
    4644function bbp_template_include_theme_supports( $template = '' ) {
    4745
     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
    4858        // 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()      ) ) :
    5360
    5461        // Single View
    5562        elseif ( bbp_is_single_view()      && ( $new_template = bbp_get_single_view_template()      ) ) :
    5663
     64        // Forum edit
     65        elseif ( bbp_is_forum_edit()       && ( $new_template = bbp_get_forum_edit_template()       ) ) :
     66
    5767        // Single Forum
    5868        elseif ( bbp_is_single_forum()     && ( $new_template = bbp_get_single_forum_template()     ) ) :
     
    6171        elseif ( bbp_is_forum_archive()    && ( $new_template = bbp_get_forum_archive_template()    ) ) :
    6272
    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()       ) ) :
    6581
    6682        // Single Topic
     
    7086        elseif ( bbp_is_topic_archive()    && ( $new_template = bbp_get_topic_archive_template()    ) ) :
    7187
    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()       ) ) :
    8090
    8191        // Single Reply
    8292        elseif ( bbp_is_single_reply()     && ( $new_template = bbp_get_single_reply_template()     ) ) :
    8393
    84         // Editing a reply
    85         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()   ) ) :
    8696
    8797        // Viewing a topic tag
    8898        elseif ( bbp_is_topic_tag()        && ( $new_template = bbp_get_topic_tag_template()        ) ) :
    89 
    90         // Editing a topic tag
    91         elseif ( bbp_is_topic_tag_edit()   && ( $new_template = bbp_get_topic_tag_edit_template()   ) ) :
    9299        endif;
    93100
    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;
    96104
    97105        return apply_filters( 'bbp_template_include_theme_supports', $template );
     
    403411        $templates = array(
    404412                'bbpress.php',
     413                'forums.php',
    405414                'forum.php',
    406415                'page.php',
Note: See TracChangeset for help on using the changeset viewer.