Ticket #4869: 4869.01.patch
File 4869.01.patch, 3.3 KB (added by , 12 years ago) |
---|
-
bp-core/bp-core-theme-compatibility.php
class BP_Theme_Compat { 48 48 * ); 49 49 * @var array 50 50 */ 51 pr ivate$_data = array();51 protected $_data = array(); 52 52 53 53 /** 54 54 * Pass the $properties to the object on creation. … … class BP_Theme_Compat { 60 60 $this->_data = $properties; 61 61 } 62 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 // 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 63 121 /** 64 122 * Set a theme's property. 65 123 * -
bp-templates/bp-legacy/buddypress-functions.php
class BP_Legacy extends BP_Theme_Compat { 45 45 * @uses BP_Legacy::setup_actions() 46 46 */ 47 47 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(); 61 49 } 62 50 63 51 /** … … class BP_Legacy extends BP_Theme_Compat { 73 61 * @since BuddyPress (1.7) 74 62 * @access private 75 63 */ 76 pr ivatefunction setup_globals() {64 protected function setup_globals() { 77 65 $bp = buddypress(); 78 66 $this->id = 'legacy'; 79 67 $this->name = __( 'BuddyPress Legacy', 'buddypress' ); … … class BP_Legacy extends BP_Theme_Compat { 91 79 * @uses add_filter() To add various filters 92 80 * @uses add_action() To add various actions 93 81 */ 94 pr ivatefunction setup_actions() {82 protected function setup_actions() { 95 83 96 84 // Template Output 97 85 add_filter( 'bp_get_activity_action_pre_meta', array( $this, 'secondary_avatars' ), 10, 2 );