diff -r c7c0fbc09788 -r 5e8dcbe22c24 web/wp-content/plugins/bbpress/includes/extend/buddypress/members.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/wp-content/plugins/bbpress/includes/extend/buddypress/members.php Tue Dec 04 18:43:10 2012 -0800 @@ -0,0 +1,143 @@ +setup_actions(); + $this->setup_filters(); + } + + /** + * Setup the actions + * + * @since bbPress (r4395) + * + * @access private + * @uses add_filter() To add various filters + * @uses add_action() To add various actions + */ + private function setup_actions() { + + /** Favorites *********************************************************/ + + // Move handler to 'bp_actions' - BuddyPress bypasses template_loader + remove_action( 'template_redirect', 'bbp_favorites_handler', 1 ); + add_action( 'bp_actions', 'bbp_favorites_handler', 1 ); + + /** Subscriptions *****************************************************/ + + // Move handler to 'bp_actions' - BuddyPress bypasses template_loader + remove_action( 'template_redirect', 'bbp_subscriptions_handler', 1 ); + add_action( 'bp_actions', 'bbp_subscriptions_handler', 1 ); + } + + /** + * Setup the filters + * + * @since bbPress (r4395) + * + * @access private + * @uses add_filter() To add various filters + * @uses add_action() To add various actions + */ + private function setup_filters() { + add_filter( 'bbp_pre_get_user_profile_url', array( $this, 'user_profile_url' ) ); + add_filter( 'bbp_get_favorites_permalink', array( $this, 'get_favorites_permalink' ), 10, 2 ); + add_filter( 'bbp_get_subscriptions_permalink', array( $this, 'get_subscriptions_permalink' ), 10, 2 ); + } + + /** Filters ***************************************************************/ + + /** + * Override bbPress profile URL with BuddyPress profile URL + * + * @since bbPress (r3401) + * @param string $url + * @param int $user_id + * @param string $user_nicename + * @return string + */ + public function user_profile_url( $user_id ) { + + // Define local variable(s) + $profile_url = ''; + + // Special handling for forum component + if ( bp_is_current_component( 'forums' ) ) { + + // Empty action or 'topics' action + if ( !bp_current_action() || bp_is_current_action( 'topics' ) ) { + $profile_url = bp_core_get_user_domain( $user_id ) . 'forums/topics'; + + // Empty action or 'topics' action + } elseif ( bp_is_current_action( 'replies' ) ) { + $profile_url = bp_core_get_user_domain( $user_id ) . 'forums/replies'; + + // 'favorites' action + } elseif ( bbp_is_favorites_active() && bp_is_current_action( 'favorites' ) ) { + $profile_url = $this->get_favorites_permalink( '', $user_id ); + + // 'subscriptions' action + } elseif ( bbp_is_subscriptions_active() && bp_is_current_action( 'subscriptions' ) ) { + $profile_url = $this->get_subscriptions_permalink( '', $user_id ); + } + + // Not in users' forums area + } else { + $profile_url = bp_core_get_user_domain( $user_id ); + } + + return trailingslashit( $profile_url ); + } + + /** + * Override bbPress favorites URL with BuddyPress profile URL + * + * @since bbPress (r3721) + * @param string $url + * @param int $user_id + * @return string + */ + public function get_favorites_permalink( $url, $user_id ) { + $url = trailingslashit( bp_core_get_user_domain( $user_id ) . 'forums/favorites' ); + return $url; + } + + /** + * Override bbPress subscriptions URL with BuddyPress profile URL + * + * @since bbPress (r3721) + * @param string $url + * @param int $user_id + * @return string + */ + public function get_subscriptions_permalink( $url, $user_id ) { + $url = trailingslashit( bp_core_get_user_domain( $user_id ) . 'forums/subscriptions' ); + return $url; + } +} +endif;