Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/25/2013 08:00:06 PM (12 years ago)
Author:
boonebgorges
Message:

Moves some core theme compatibility logic to the BP_Theme_Compat parent class

Since every new BP template pack will need to do the same kinds of checks
before starting the theme compat process (is this a child theme of bp-default,
etc), it makes sense for a parent::start() method to handle the logic, rather
than requiring individual template packs to reproduce it in their child
classes.

In addition, this changeset introduces a fallback check for legacy BuddyPress
themes. For themes that are not child themes of bp-default and also have not
declared current_theme_supports( 'buddypress' ), BP_Theme_Compat::start() now
checks for the existence of members/members-loop.php in the current theme, and
if found, it interprets it as a sign that the current theme does indeed support
BuddyPress, and that theme compatibility should be aborted. Theme authors are
still urged to use current_theme_supports( 'buddypress' ) in their template
packs.

Fixes #4869

Props r-a-y

File:
1 edited

Legend:

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

    r6658 r6866  
    4949     * @var array
    5050     */
    51     private $_data = array();
     51    protected $_data = array();
    5252
    5353    /**
     
    6060        $this->_data = $properties;
    6161    }
     62
     63
     64    /**
     65     * Themes shoud use this method in their constructor.
     66     *
     67     * In this method, we check all types of conditions where theme compatibility
     68     * should *not* run.
     69     *
     70     * If we pass all conditions, then we setup some additional methods to use.
     71     *
     72     * @since BuddyPress (1.7)
     73     */
     74    protected function start() {
     75
     76        // If the theme supports 'buddypress', bail.
     77        if ( current_theme_supports( 'buddypress' ) ) {
     78            return;
     79
     80        // If the theme doesn't support BP, do some additional checks
     81        } else {
     82            // Bail if theme is a derivative of bp-default
     83            if ( in_array( 'bp-default', array( get_template(), get_stylesheet() ) ) ) {
     84                return;
     85            }
     86
     87            // Bruteforce check for a BP template
     88            // Examples are clones of bp-default
     89            if ( locate_template( 'members/members-loop.php', false, false ) ) {
     90                return;
     91            }
     92        }
     93
     94        // Setup methods
     95        $this->setup_globals();
     96        $this->setup_actions();
     97    }
     98
     99    /**
     100     * Meant to be extended in your class.
     101     *
     102     * @since BuddyPress (1.7)
     103     */
     104    protected function setup_globals() {}
     105
     106    /**
     107     * Meant to be extended in your class.
     108     *
     109     * @since BuddyPress (1.7)
     110     */
     111    protected function setup_actions() {}
    62112
    63113    /**
Note: See TracChangeset for help on using the changeset viewer.