Skip to:
Content

bbPress.org

Changeset 3721


Ignore:
Timestamp:
01/29/2012 10:05:33 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Filter links to user subscriptions and favorites, and return them to their BuddyPress profile equivalents. See #1669.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-extend-buddypress.php

    r3720 r3721  
    186186
    187187        // Override bbPress user profile URL with BuddyPress profile URL
    188         add_filter( 'bbp_pre_get_user_profile_url', array( $this, 'user_profile_url' ) );
     188        add_filter( 'bbp_pre_get_user_profile_url',    array( $this, 'user_profile_url'            )        );
     189        add_filter( 'bbp_get_favorites_permalink',     array( $this, 'get_favorites_permalink'     ), 10, 2 );
     190        add_filter( 'bbp_get_subscriptions_permalink', array( $this, 'get_subscriptions_permalink' ), 10, 2 );
    189191
    190192        /** Mentions **********************************************************/
     
    342344     *
    343345     * @global BP_Activity_Template $activities_template
    344      * @global BuddyPress $bp
    345346     * @param boolean $can_comment
    346347     * @uses bp_get_activity_action_name()
     
    348349     */
    349350    public function activity_can_comment( $can_comment = true ) {
    350         global $activities_template, $bp;
     351        global $activities_template;
    351352
    352353        // Already forced off, so comply
     
    444445            // 'favorites' action
    445446            } elseif ( bbp_is_favorites_active() && bp_is_current_action( 'favorites' ) ) {
    446                 $profile_url = bp_core_get_user_domain( $user_id ) . 'forums/favorites';
     447                $profile_url = $this->get_favorites_permalink( '', $user_id );
    447448
    448449            // 'subscriptions' action
    449450            } elseif ( bbp_is_subscriptions_active() && bp_is_current_action( 'subscriptions' ) ) {
    450                 $profile_url = bp_core_get_user_domain( $user_id ) . 'forums/subscriptions';
     451                $profile_url = $this->get_subscriptions_permalink( '', $user_id );
    451452            }
    452453
     
    456457        }
    457458
    458         return $profile_url;
     459        return trailingslashit( $profile_url );
     460    }
     461   
     462    /**
     463     * Override bbPress favorites URL with BuddyPress profile URL
     464     *
     465     * @since bbPress (r3721)
     466     *
     467     * @param string $url
     468     * @param int $user_id
     469     *
     470     * @return string
     471     */
     472    public function get_favorites_permalink( $url, $user_id ) {
     473        $url = trailingslashit( bp_core_get_user_domain( $user_id ) . 'forums/favorites' );
     474        return $url;
     475    }
     476
     477    /**
     478     * Override bbPress subscriptions URL with BuddyPress profile URL
     479     *
     480     * @since bbPress (r3721)
     481     *
     482     * @param string $url
     483     * @param int $user_id
     484     *
     485     * @return string
     486     */
     487    public function get_subscriptions_permalink( $url, $user_id ) {
     488        $url = trailingslashit( bp_core_get_user_domain( $user_id ) . 'forums/subscriptions' );
     489        return $url;
    459490    }
    460491
Note: See TracChangeset for help on using the changeset viewer.