Skip to:
Content

BuddyPress.org

Changeset 6866


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

Location:
trunk
Files:
2 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    /**
  • trunk/bp-templates/bp-legacy/buddypress-functions.php

    r6850 r6866  
    4646     */
    4747    public function __construct() {
    48 
    49         // Bail if theme is a derivative of bp-default
    50         if ( in_array( 'bp-default', array( get_template(), get_stylesheet() ) ) ) {
    51             return;
    52         }
    53 
    54         // Or if the theme supports 'buddypress'
    55         if ( current_theme_supports( 'buddypress' ) ) {
    56             return;
    57         }
    58 
    59         $this->setup_globals();
    60         $this->setup_actions();
     48        parent::start();
    6149    }
    6250
    6351    /**
    6452     * Component global variables
    65      *
    66      * Note that this function is currently commented out in the constructor.
    67      * It will only be used if you copy this file into your current theme and
    68      * uncomment the line above.
    6953     *
    7054     * You'll want to customize the values in here, so they match whatever your
     
    7458     * @access private
    7559     */
    76     private function setup_globals() {
     60    protected function setup_globals() {
    7761        $bp            = buddypress();
    7862        $this->id      = 'legacy';
     
    9276     * @uses add_action() To add various actions
    9377     */
    94     private function setup_actions() {
     78    protected function setup_actions() {
    9579
    9680        // Template Output
Note: See TracChangeset for help on using the changeset viewer.