Skip to:
Content

bbPress.org

Ticket #2818: bbpress-add-link.patch

File bbpress-add-link.patch, 6.2 KB (added by axelskynet, 5 years ago)

File members.php , string 115

  • wp-content/plugins/bbpress/includes/extend/buddypress/members.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>windows-1251
    Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
    <+><?php\n\n/**\n * bbPress BuddyPress Members Class\n *\n * @package bbPress\n * @subpackage BuddyPress\n */\n\n// Exit if accessed directly\nif ( !defined( 'ABSPATH' ) ) exit;\n\nif ( !class_exists( 'BBP_Forums_Members' ) ) :\n/**\n * Member profile modifications\n *\n * @since bbPress (r4395)\n *\n * @package bbPress\n * @subpackage BuddyPress\n */\nclass BBP_BuddyPress_Members {\n\n\t/**\n\t * Main constructor for modifying bbPress profile links\n\t *\n\t * @since bbPress (r4395)\n\t */\n\tpublic function __construct() {\n\t\t$this->setup_actions();\n\t\t$this->setup_filters();\n\t}\n\n\t/**\n\t * Setup the actions\n\t *\n\t * @since bbPress (r4395)\n\t *\n\t * @access private\n\t * @uses add_filter() To add various filters\n\t * @uses add_action() To add various actions\n\t */\n\tprivate function setup_actions() {\n\n\t\t// Allow unsubscribe/unfavorite links to work\n\t\tadd_action( 'bp_template_redirect', array( $this, 'set_member_forum_query_vars' ) );\n\n\t\t/** Favorites *********************************************************/\n\n\t\t// Move handler to 'bp_actions' - BuddyPress bypasses template_loader\n\t\tremove_action( 'template_redirect', 'bbp_favorites_handler', 1 );\n\t\tadd_action(    'bp_actions',        'bbp_favorites_handler', 1 );\n\n\t\t/** Subscriptions *****************************************************/\n\n\t\t// Move handler to 'bp_actions' - BuddyPress bypasses template_loader\n\t\tremove_action( 'template_redirect', 'bbp_subscriptions_handler', 1 );\n\t\tadd_action(    'bp_actions',        'bbp_subscriptions_handler', 1 );\n\t}\n\n\t/**\n\t * Setup the filters\n\t *\n\t * @since bbPress (r4395)\n\t *\n\t * @access private\n\t * @uses add_filter() To add various filters\n\t * @uses add_action() To add various actions\n\t */\n\tprivate function setup_filters() {\n\t\tadd_filter( 'bbp_pre_get_user_profile_url',    array( $this, 'user_profile_url'            )        );\n\t\tadd_filter( 'bbp_get_favorites_permalink',     array( $this, 'get_favorites_permalink'     ), 10, 2 );\n\t\tadd_filter( 'bbp_get_subscriptions_permalink', array( $this, 'get_subscriptions_permalink' ), 10, 2 );\n\t}\n\n\t/** Filters ***************************************************************/\n\n\t/**\n\t * Override bbPress profile URL with BuddyPress profile URL\n\t *\n\t * @since bbPress (r3401)\n\t * @param string $url\n\t * @param int $user_id\n\t * @param string $user_nicename\n\t * @return string\n\t */\n\tpublic function user_profile_url( $user_id ) {\n\n\t\t// Define local variable(s)\n\t\t$profile_url    = '';\n\t\t$component_slug = bbpress()->extend->buddypress->slug;\n\n\t\t// Special handling for forum component\n\t\tif ( bp_is_current_component( $component_slug ) ) {\n\n\t\t\t// Empty action or 'topics' action\n\t\t\tif ( !bp_current_action() || bp_is_current_action( bbp_get_topic_archive_slug() ) ) {\n\t\t\t\t$profile_url = bp_core_get_user_domain( $user_id ) . $component_slug . '/' . bbp_get_topic_archive_slug();\n\n\t\t\t// Empty action or 'topics' action\n\t\t\t} elseif ( bp_is_current_action( bbp_get_reply_archive_slug() ) ) {\n\t\t\t\t$profile_url = bp_core_get_user_domain( $user_id ) . $component_slug . '/' . bbp_get_reply_archive_slug();\n\n\t\t\t// 'favorites' action\n\t\t\t} elseif ( bbp_is_favorites_active() && bp_is_current_action( bbp_get_user_favorites_slug() ) ) {\n\t\t\t\t$profile_url = $this->get_favorites_permalink( '', $user_id );\n\n\t\t\t// 'subscriptions' action\n\t\t\t} elseif ( bbp_is_subscriptions_active() && bp_is_current_action( bbp_get_user_subscriptions_slug() ) ) {\n\t\t\t\t$profile_url = $this->get_subscriptions_permalink( '', $user_id );\n\t\t\t}\n\n\t\t// Not in users' forums area\n\t\t} else {\n\t\t\t$profile_url = bp_core_get_user_domain( $user_id ).'forums/';\n\t\t}\n\n\t\treturn trailingslashit( $profile_url );\n\t}\n\n\t/**\n\t * Override bbPress favorites URL with BuddyPress profile URL\n\t *\n\t * @since bbPress (r3721)\n\t * @param string $url\n\t * @param int $user_id\n\t * @return string\n\t */\n\tpublic function get_favorites_permalink( $url, $user_id ) {\n\t\t$component_slug = bbpress()->extend->buddypress->slug;\n\t\t$url            = trailingslashit( bp_core_get_user_domain( $user_id ) . $component_slug . '/' . bbp_get_user_favorites_slug() );\n\t\treturn $url;\n\t}\n\n\t/**\n\t * Override bbPress subscriptions URL with BuddyPress profile URL\n\t *\n\t * @since bbPress (r3721)\n\t * @param string $url\n\t * @param int $user_id\n\t * @return string\n\t */\n\tpublic function get_subscriptions_permalink( $url, $user_id ) {\n\t\t$component_slug = bbpress()->extend->buddypress->slug;\n\t\t$url            = trailingslashit( bp_core_get_user_domain( $user_id ) . $component_slug . '/' . bbp_get_user_subscriptions_slug() );\n\t\treturn $url;\n\t}\n\n\t/**\n\t * Set favorites and subscriptions query variables if viewing member profile\n\t * pages.\n\t *\n\t * @since bbPress (r4615)\n\t *\n\t * @global WP_Query $wp_query\n\t * @return If not viewing your own profile\n\t */\n\tpublic function set_member_forum_query_vars() {\n\n\t\t// Special handling for forum component\n\t\tif ( ! bp_is_my_profile() )\n\t\t\treturn;\n\n\t\tglobal $wp_query;\n\n\t\t// 'favorites' action\n\t\tif ( bbp_is_favorites_active() && bp_is_current_action( bbp_get_user_favorites_slug() ) ) {\n\t\t\t$wp_query->bbp_is_single_user_favs = true;\n\n\t\t// 'subscriptions' action\n\t\t} elseif ( bbp_is_subscriptions_active() && bp_is_current_action( bbp_get_user_subscriptions_slug() ) ) {\n\t\t\t$wp_query->bbp_is_single_user_subs = true;\n\t\t}\n\t}\n}\nendif;\n
     
    112112
    113113                // Not in users' forums area
    114114                } else {
    115                         $profile_url = bp_core_get_user_domain( $user_id ).'forums/';
     115                         $profile_url = bp_core_get_user_domain( $user_id ).'forums/';
    116116                }
    117117
    118118                return trailingslashit( $profile_url );