Skip to:
Content

BuddyPress.org

Ticket #4869: 4869.01.patch

File 4869.01.patch, 3.3 KB (added by r-a-y, 12 years ago)
  • bp-core/bp-core-theme-compatibility.php

    class BP_Theme_Compat { 
    4848         * );
    4949         * @var array
    5050         */
    51         private $_data = array();
     51        protected $_data = array();
    5252
    5353        /**
    5454         * Pass the $properties to the object on creation.
    class BP_Theme_Compat { 
    6060                $this->_data = $properties;
    6161        }
    6262
     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                // Check for multisite and if BP is in multiblog mode
     76                if ( is_multisite() && ! bp_is_multiblog_mode() ) {
     77                        // If we're not in multiblog mode, check if we're on the root blog.
     78                        // If we're not on the root blog, we shouldn't load theme compat.
     79                        if ( ! bp_is_root_blog() ) {
     80                                return;
     81                        }
     82                }
     83
     84                // If the theme supports 'buddypress', bail.
     85                if ( current_theme_supports( 'buddypress' ) ) {
     86                        return;
     87
     88                // If the theme doesn't support BP, do some additional checks
     89                } else {
     90                        // Bail if theme is a derivative of bp-default
     91                        if ( in_array( 'bp-default', array( get_template(), get_stylesheet() ) ) ) {
     92                                return;
     93                        }
     94
     95                        // Bruteforce check for a BP template
     96                        // Examples are clones of bp-default
     97                        if ( locate_template( 'members/members-loop.php', false, false ) ) {
     98                                return;
     99                        }
     100                }
     101
     102                // Setup methods
     103                $this->setup_globals();
     104                $this->setup_actions();
     105        }
     106
     107        /**
     108         * Meant to be extended in your class.
     109         *
     110         * @since BuddyPress (1.7)
     111         */
     112        protected function setup_globals() {}
     113
     114        /**
     115         * Meant to be extended in your class.
     116         *
     117         * @since BuddyPress (1.7)
     118         */
     119        protected function setup_actions() {}
     120
    63121        /**
    64122         * Set a theme's property.
    65123         *
  • bp-templates/bp-legacy/buddypress-functions.php

    class BP_Legacy extends BP_Theme_Compat { 
    4545         * @uses BP_Legacy::setup_actions()
    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        /**
    class BP_Legacy extends BP_Theme_Compat { 
    7361         * @since BuddyPress (1.7)
    7462         * @access private
    7563         */
    76         private function setup_globals() {
     64        protected function setup_globals() {
    7765                $bp            = buddypress();
    7866                $this->id      = 'legacy';
    7967                $this->name    = __( 'BuddyPress Legacy', 'buddypress' );
    class BP_Legacy extends BP_Theme_Compat { 
    9179         * @uses add_filter() To add various filters
    9280         * @uses add_action() To add various actions
    9381         */
    94         private function setup_actions() {
     82        protected function setup_actions() {
    9583
    9684                // Template Output
    9785                add_filter( 'bp_get_activity_action_pre_meta', array( $this, 'secondary_avatars' ), 10, 2 );