Skip to:
Content

bbPress.org

Changeset 3983


Ignore:
Timestamp:
06/18/2012 06:12:07 AM (9 years ago)
Author:
johnjamesjacoby
Message:

Theme Compatibility:

  • Move root-level templates into an /extras folder in bbp-theme-compat.
  • Revert extra logic introduced in r3971.
  • Theme compat can still allow for theme packs with root template files this way.
  • Replace reverted logic with 1 variable check, if a bbPress template file was found in the loader process.
  • See: #1854
Location:
branches/plugin
Files:
1 added
3 edited
24 moved

Legend:

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

    r3971 r3983  
    7777        if ( file_exists( trailingslashit( STYLESHEETPATH ) . $template_name ) ) {
    7878            $located = trailingslashit( STYLESHEETPATH ) . $template_name;
    79             bbp_set_the_content_override( false );
    8079            break;
    8180
     
    8382        } elseif ( file_exists( trailingslashit( TEMPLATEPATH ) . $template_name ) ) {
    8483            $located = trailingslashit( TEMPLATEPATH ) . $template_name;
    85             bbp_set_the_content_override( false );
    8684            break;
    8785
     
    8987        } elseif ( file_exists( trailingslashit( bbp_get_theme_compat_dir() ) . $template_name ) ) {
    9088            $located = trailingslashit( bbp_get_theme_compat_dir() ) . $template_name;
    91             bbp_set_the_content_override( true );
    9289            break;
    9390        }
     
    125122    // Set query_template to true to tell bbp_locate_template() we are trying
    126123    // to determine if 'the_content' should be overridden or not.
    127     bbpress()->theme_compat->query_template = true;
     124    bbpress()->theme_compat->query_template = $type;
    128125
    129126    // Filter possible templates, try to match one, and set any bbPress theme
  • branches/plugin/bbp-includes/bbp-template-loader.php

    r3966 r3983  
    1717 * template condition to be met. If one is met and the template file exists,
    1818 * it will be used; otherwise
     19 *
     20 * Note that the _edit() checks are ahead of their counterparts, to prevent them
     21 * from being stomped on accident.
    1922 *
    2023 * @since bbPress (r3032)
     
    4447function bbp_template_include_theme_supports( $template = '' ) {
    4548
    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 
    5549    // Editing a user
    5650    if     ( bbp_is_single_user_edit() && ( $new_template = bbp_get_single_user_edit_template() ) ) :
     
    10094
    10195    // bbPress template file exists
    102     if ( !empty( $new_template ) && ! bbp_is_theme_compat_original_template( $new_template ) )
     96    if ( !empty( $new_template ) ) {
     97
     98        // Override the WordPress template with a bbPress one
    10399        $template = $new_template;
     100
     101        // @see: bbp_template_include_theme_compat()
     102        bbpress()->theme_compat->bbpress_template = true;
     103    }
    104104
    105105    return apply_filters( 'bbp_template_include_theme_supports', $template );
  • branches/plugin/bbp-includes/bbp-theme-compatibility.php

    r3971 r3983  
    286286    }
    287287}
    288 
    289 /**
    290  * This is called from inside bbp_locate_template(). It sets whether or not
    291  * bbPress should override 'the_content' or if a root-level template was found
    292  * in either the current child or parent themes.
    293  *
    294  * @since bbPress (r3970)
    295  *
    296  * @param boolean $override
    297  * @return boolean
    298  */
    299 function bbp_set_the_content_override( $override = false ) {
    300     $bbp = bbpress();
    301 
    302     if ( empty( $bbp->theme_compat->query_template ) )
    303         return false;
    304 
    305     $bbp->theme_compat->replace_the_content = $override;
    306 
    307     return (bool) $bbp->theme_compat->replace_the_content;
    308 }
    309 
    310 /**
    311  * Should bbPress try to replace 'the_content' because a template file could
    312  * not be found in either the child or parent themes.
    313  *
    314  * @since bbPress (r3970)
    315  *
    316  * @return boolean
    317  */
    318 function bbp_is_the_content_override() {
    319     $bbp = bbpress();
    320 
    321     if ( empty( $bbp->theme_compat->replace_the_content ) )
    322         return false;
    323 
    324     return (bool) $bbp->theme_compat->replace_the_content;
    325 }
    326 
    327288/**
    328289 * This fun little function fills up some WordPress globals with dummy data to
     
    437398function bbp_template_include_theme_compat( $template = '' ) {
    438399
    439     // Bail if the template doesn't specifically match a bbPress template. This
    440     // includes archive-* and single-* WordPress post_type matches, allowing
    441     // themes to use the expected format.
    442     if ( bbp_is_theme_compat_original_template( $template ) )
    443         return $template;
    444 
    445     // If we know we are not going to override the_content with a bbPress
    446     // template part, bail early so we don't reset queries and hook filters in.
    447     if ( ! bbp_is_the_content_override() )
     400    // Bail if the template already matches a bbPress template. This includes
     401    // archive-* and single-* WordPress post_type matches (allowing
     402    // themes to use the expected format) as well as all bbPress-specific
     403    // template files for users, topics, forums, etc...
     404    if ( !empty( bbpress()->theme_compat->bbpress_template ) )
    448405        return $template;
    449406
Note: See TracChangeset for help on using the changeset viewer.