Skip to:
Content

BuddyPress.org

Changeset 6399


Ignore:
Timestamp:
10/13/2012 06:29:56 AM (13 years ago)
Author:
r-a-y
Message:

Theme Compat:

  • Introduce bp_enable_theme_compat() function - this should be used to see if theme compatibility is enabled.
  • In BP_Legacy class, switch out template / stylesheet check for bp_enable_theme_compat().
  • In bp_has_custom_signup_page(), use bp_enable_theme_compat(). Use bp_has_custom_signup_page() in bp_core_wpsignup_redirect().
  • Change BBP references to BP.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-theme-compatibility.php

    r6390 r6399  
    3333 *
    3434 * @since BuddyPress (1.7)
     35 * @todo We should probably do something similar to BP_Component::start()
    3536 */
    3637class BP_Theme_Compat {
     
    5657     * @param array $properties
    5758     */
    58     public function __construct( Array $properties = array() ) {
     59        public function __construct( Array $properties = array() ) {
    5960        $this->_data = $properties;
    6061    }
     
    9192 *
    9293 * @since BuddyPress (1.7)
    93  * @param BBP_Theme_Compat $theme
     94 * @param BP_Theme_Compat $theme
    9495 */
    9596function bp_setup_theme_compat( $theme = '' ) {
     
    176177
    177178/**
    178  * Gets true/false if page is currently inside theme compatibility
     179 * See whether BuddyPress' theme compatibility is enabled or not.
     180 *
     181 * This differs from {@link bp_is_theme_compat_active()} as this function
     182 * checks to see if theme compat is enabled across the active blog.
     183 *
     184 * @since BuddyPress (1.7)
     185 * @uses wp_get_theme()
     186 * @uses apply_filters()
     187 * @return bool
     188 */
     189function bp_enable_theme_compat() {
     190
     191    // default is theme compat should be enabled
     192    $retval = true;
     193
     194    // get current theme
     195    $theme = wp_get_theme();
     196
     197    // get current theme's tags
     198    $theme_tags = ! empty( $theme->tags ) ? $theme->tags : array();
     199
     200    // check to see if the 'buddypress' tag is in the theme
     201    // or if stylesheet is 'bp-default'
     202    $backpat = in_array( 'buddypress', $theme_tags ) || $theme->get_stylesheet() == 'bp-default';
     203   
     204    // if we're already using a BP-compatible theme, disable theme compat
     205    if ( $backpat ) {
     206        $retval = false;
     207
     208    // if theme compat should still be enabled, do some other checks
     209    // @todo what about themes that copied bp-default without using a child theme?
     210    } elseif ( $retval ) {
     211        // BP Template Pack check
     212        // if TPack exists, we should disable theme compat
     213        if ( function_exists( 'bp_tpack_theme_setup' ) ) {
     214            $retval = false;
     215        }
     216    }
     217
     218    return apply_filters( 'bp_enable_theme_compat', $retval );
     219}
     220
     221/**
     222 * Gets true/false if the current, loaded page uses theme compatibility
    179223 *
    180224 * @since BuddyPress (1.7)
     
    270314function bp_register_theme_package( $theme = array(), $override = true ) {
    271315
    272     // Create new BBP_Theme_Compat object from the $theme array
     316    // Create new BP_Theme_Compat object from the $theme array
    273317    if ( is_array( $theme ) )
    274318        $theme = new BP_Theme_Compat( $theme );
  • trunk/bp-members/bp-members-functions.php

    r6342 r6399  
    13961396        return;
    13971397
    1398     // Redirect to sign-up page
    1399     if ( locate_template( array( 'registration/register.php' ), false ) || locate_template( array( 'register.php' ), false ) )
     1398    // Redirect to sign-up page if a custom signup page exists
     1399    if ( bp_has_custom_signup_page() )
    14001400        bp_core_redirect( bp_get_signup_page() );
    14011401}
  • trunk/bp-members/bp-members-template.php

    r6368 r6399  
    968968
    969969function bp_has_custom_signup_page() {
     970    // if theme compat is enabled, we're already using our bundled templates
     971    if ( bp_enable_theme_compat() )
     972        return true;
     973
     974    // look in parent / child theme for custom registration templates
    970975    if ( locate_template( array( 'register.php' ), false ) || locate_template( array( '/registration/register.php' ), false ) )
    971976        return true;
  • trunk/bp-themes/bp-legacy/buddypress-functions.php

    r6387 r6399  
    4747    public function __construct() {
    4848
    49         // Bail if parent/child themes are bp-default
    50         if ( in_array( 'bp-default', array( get_template(), get_stylesheet() ) ) )
     49        // Bail if theme compat should be disabled
     50        if ( ! bp_enable_theme_compat() )
    5151            return;
    5252
Note: See TracChangeset for help on using the changeset viewer.