| @@ -17,15 +17,15 @@ | ||
| 17 | 17 | * @subpackage BuddyPress |
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | 20 | // Exit if accessed directly |
| 21 | -if ( !defined( 'ABSPATH' ) ) exit; | |
| 21 | +defined( 'ABSPATH' ) || exit; | |
| 22 | 22 | |
| 23 | -if ( !class_exists( 'BBP_Forums_Component' ) ) : | |
| 23 | +if ( ! class_exists( 'BBP_Forums_Component' ) ) : | |
| 24 | 24 | /** |
| 25 | 25 | * Loads Forums Component |
| 26 | 26 | * |
| 27 | - * @since bbPress (r3552) | |
| 27 | + * @since 2.1.0 bbPress (r3552) | |
| 28 | 28 | * |
| 29 | 29 | * @package bbPress |
| 30 | 30 | * @subpackage BuddyPress |
| 31 | 31 | */ |
| @@ -31,22 +31,39 @@ | ||
| 31 | 31 | */ |
| 32 | 32 | class BBP_Forums_Component extends BP_Component { |
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | + * BuddyPress Members component shim | |
| 36 | + * | |
| 37 | + * @since 2.0.0 | |
| 38 | + * | |
| 39 | + * @var void|BBP_BuddyPress_Members | |
| 40 | + */ | |
| 41 | + public $members; | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * BuddyPress Activity component shim | |
| 45 | + * | |
| 46 | + * @since 2.0.0 | |
| 47 | + * | |
| 48 | + * @var void|BBP_BuddyPress_Members | |
| 49 | + */ | |
| 50 | + public $activity; | |
| 51 | + | |
| 52 | + /** | |
| 35 | 53 | * Start the forums component creation process |
| 36 | 54 | * |
| 37 | - * @since bbPress (r3552) | |
| 55 | + * @since 2.1.0 bbPress (r3552) | |
| 38 | 56 | */ |
| 39 | 57 | public function __construct() { |
| 40 | 58 | parent::start( |
| 41 | 59 | 'forums', |
| 42 | - __( 'Forums', 'bbpress' ), | |
| 43 | - BP_PLUGIN_DIR | |
| 60 | + esc_html__( 'Forums', 'bbpress' ), | |
| 61 | + bbpress()->includes_dir . 'extend/buddypress/' | |
| 44 | 62 | ); |
| 45 | 63 | $this->includes(); |
| 46 | 64 | $this->setup_globals(); |
| 47 | 65 | $this->setup_actions(); |
| 48 | - $this->setup_nav(); | |
| 49 | 66 | $this->fully_loaded(); |
| 50 | 67 | } |
| 51 | 68 | |
| 52 | 69 | /** |
| @@ -51,25 +68,44 @@ | ||
| 51 | 68 | |
| 52 | 69 | /** |
| 53 | 70 | * Include BuddyPress classes and functions |
| 54 | 71 | */ |
| 55 | - public function includes() { | |
| 72 | + public function includes( $includes = array() ) { | |
| 56 | 73 | |
| 57 | 74 | // Helper BuddyPress functions |
| 58 | - require( bbpress()->includes_dir . 'extend/buddypress/functions.php' ); | |
| 75 | + $includes[] = 'functions.php'; | |
| 59 | 76 | |
| 60 | 77 | // Members modifications |
| 61 | - require( bbpress()->includes_dir . 'extend/buddypress/members.php' ); | |
| 78 | + $includes[] = 'members.php'; | |
| 62 | 79 | |
| 80 | + // BuddyPress Notfications Extension functions | |
| 81 | + if ( bp_is_active( 'notifications' ) ) { | |
| 82 | + $includes[] = 'notifications.php'; | |
| 83 | + } | |
| 84 | + | |
| 63 | 85 | // BuddyPress Activity Extension class |
| 64 | 86 | if ( bp_is_active( 'activity' ) ) { |
| 65 | - require( bbpress()->includes_dir . 'extend/buddypress/activity.php' ); | |
| 87 | + $includes[] = 'activity.php'; | |
| 66 | 88 | } |
| 67 | 89 | |
| 68 | 90 | // BuddyPress Group Extension class |
| 69 | 91 | if ( bbp_is_group_forums_active() && bp_is_active( 'groups' ) ) { |
| 70 | - require( bbpress()->includes_dir . 'extend/buddypress/group.php' ); | |
| 92 | + $includes[] = 'groups.php'; | |
| 71 | 93 | } |
| 94 | + | |
| 95 | + // Require files if they exist | |
| 96 | + foreach ( $includes as $file ) { | |
| 97 | + if ( @is_file( $this->path . $file ) ) { | |
| 98 | + require $this->path . $file; | |
| 99 | + } | |
| 100 | + } | |
| 101 | + | |
| 102 | + /** | |
| 103 | + * Hook for plugins to include files, if necessary. | |
| 104 | + * | |
| 105 | + * @since 2.6.0 bbPress (r3552) | |
| 106 | + */ | |
| 107 | + do_action( "bp_{$this->id}_includes" ); | |
| 72 | 108 | } |
| 73 | 109 | |
| 74 | 110 | /** |
| 75 | 111 | * Setup globals |
| @@ -76,47 +112,64 @@ | ||
| 76 | 112 | * |
| 77 | 113 | * The BP_FORUMS_SLUG constant is deprecated, and only used here for |
| 78 | 114 | * backwards compatibility. |
| 79 | 115 | * |
| 80 | - * @since bbPress (r3552) | |
| 116 | + * @since 2.1.0 bbPress (r3552) | |
| 81 | 117 | */ |
| 82 | - public function setup_globals() { | |
| 118 | + public function setup_globals( $args = array() ) { | |
| 83 | 119 | $bp = buddypress(); |
| 84 | 120 | |
| 85 | 121 | // Define the parent forum ID |
| 86 | - if ( !defined( 'BP_FORUMS_PARENT_FORUM_ID' ) ) | |
| 122 | + if ( ! defined( 'BP_FORUMS_PARENT_FORUM_ID' ) ) { | |
| 87 | 123 | define( 'BP_FORUMS_PARENT_FORUM_ID', 1 ); |
| 124 | + } | |
| 88 | 125 | |
| 89 | 126 | // Define a slug, if necessary |
| 90 | - if ( !defined( 'BP_FORUMS_SLUG' ) ) | |
| 127 | + if ( ! defined( 'BP_FORUMS_SLUG' ) ) { | |
| 91 | 128 | define( 'BP_FORUMS_SLUG', $this->id ); |
| 129 | + } | |
| 92 | 130 | |
| 93 | - // All globals for messaging component. | |
| 94 | - $globals = array( | |
| 95 | - 'path' => BP_PLUGIN_DIR, | |
| 96 | - 'slug' => BP_FORUMS_SLUG, | |
| 97 | - 'root_slug' => isset( $bp->pages->forums->slug ) ? $bp->pages->forums->slug : BP_FORUMS_SLUG, | |
| 98 | - 'has_directory' => false, | |
| 99 | - 'notification_callback' => 'messages_format_notifications', | |
| 100 | - 'search_string' => __( 'Search Forums...', 'bbpress' ), | |
| 131 | + // All arguments for forums component | |
| 132 | + $args = array( | |
| 133 | + 'path' => BP_PLUGIN_DIR, | |
| 134 | + 'slug' => BP_FORUMS_SLUG, | |
| 135 | + 'root_slug' => isset( $bp->pages->forums->slug ) ? $bp->pages->forums->slug : BP_FORUMS_SLUG, | |
| 136 | + 'has_directory' => false, | |
| 137 | + 'search_string' => esc_html__( 'Search Forums...', 'bbpress' ), | |
| 101 | 138 | ); |
| 102 | 139 | |
| 103 | - parent::setup_globals( $globals ); | |
| 140 | + parent::setup_globals( $args ); | |
| 104 | 141 | } |
| 105 | 142 | |
| 106 | 143 | /** |
| 144 | + * Setup the actions | |
| 145 | + * | |
| 146 | + * @since 2.0.0 bbPress (r3395) | |
| 147 | + * | |
| 148 | + * @access private | |
| 149 | + * @link https://bbpress.trac.wordpress.org/ticket/2176 | |
| 150 | + */ | |
| 151 | + public function setup_actions() { | |
| 152 | + | |
| 153 | + // Setup the components | |
| 154 | + add_action( 'bp_init', array( $this, 'setup_components' ), 7 ); | |
| 155 | + | |
| 156 | + parent::setup_actions(); | |
| 157 | + } | |
| 158 | + | |
| 159 | + /** | |
| 107 | 160 | * Instantiate classes for BuddyPress integration |
| 108 | 161 | * |
| 109 | - * @since bbPress (r3395) | |
| 162 | + * @since 2.0.0 bbPress (r3395) | |
| 110 | 163 | */ |
| 111 | 164 | public function setup_components() { |
| 112 | 165 | |
| 113 | 166 | // Always load the members component |
| 114 | - bbpress()->extend->buddypress->members = new BBP_BuddyPress_Members; | |
| 167 | + bbpress()->extend->buddypress->members = new BBP_BuddyPress_Members(); | |
| 115 | 168 | |
| 116 | 169 | // Create new activity class |
| 117 | 170 | if ( bp_is_active( 'activity' ) ) { |
| 118 | - bbpress()->extend->buddypress->activity = new BBP_BuddyPress_Activity; | |
| 171 | + bbpress()->extend->buddypress->activity = new BBP_BuddyPress_Activity(); | |
| 119 | 172 | } |
| 120 | 173 | |
| 121 | 174 | // Register the group extension only if groups are active |
| 122 | 175 | if ( bbp_is_group_forums_active() && bp_is_active( 'groups' ) ) { |
| @@ -124,28 +177,12 @@ | ||
| 124 | 177 | } |
| 125 | 178 | } |
| 126 | 179 | |
| 127 | 180 | /** |
| 128 | - * Setup the actions | |
| 129 | - * | |
| 130 | - * @since bbPress (r3395) | |
| 131 | - * @access private | |
| 132 | - * @uses add_filter() To add various filters | |
| 133 | - * @uses add_action() To add various actions | |
| 134 | - */ | |
| 135 | - public function setup_actions() { | |
| 136 | - | |
| 137 | - // Setup the components | |
| 138 | - add_action( 'bp_init', array( $this, 'setup_components' ) ); | |
| 139 | - | |
| 140 | - parent::setup_actions(); | |
| 141 | - } | |
| 142 | - | |
| 143 | - /** | |
| 144 | 181 | * Allow the variables, actions, and filters to be modified by third party |
| 145 | 182 | * plugins and themes. |
| 146 | 183 | * |
| 147 | - * @since bbPress (r3902) | |
| 184 | + * @since 2.1.0 bbPress (r3902) | |
| 148 | 185 | */ |
| 149 | 186 | private function fully_loaded() { |
| 150 | 187 | do_action_ref_array( 'bbp_buddypress_loaded', array( $this ) ); |
| 151 | 188 | } |
| @@ -152,37 +189,38 @@ | ||
| 152 | 189 | |
| 153 | 190 | /** |
| 154 | 191 | * Setup BuddyBar navigation |
| 155 | 192 | * |
| 156 | - * @since bbPress (r3552) | |
| 193 | + * @since 2.1.0 bbPress (r3552) | |
| 157 | 194 | */ |
| 158 | - public function setup_nav() { | |
| 195 | + public function setup_nav( $main_nav = array(), $sub_nav = array() ) { | |
| 159 | 196 | |
| 160 | 197 | // Stop if there is no user displayed or logged in |
| 161 | - if ( !is_user_logged_in() && !bp_displayed_user_id() ) | |
| 198 | + if ( ! is_user_logged_in() && ! bp_displayed_user_id() ) { | |
| 162 | 199 | return; |
| 200 | + } | |
| 163 | 201 | |
| 164 | 202 | // Define local variable(s) |
| 165 | - $sub_nav = array(); | |
| 166 | 203 | $user_domain = ''; |
| 167 | 204 | |
| 168 | 205 | // Add 'Forums' to the main navigation |
| 169 | 206 | $main_nav = array( |
| 170 | - 'name' => __( 'Forums', 'bbpress' ), | |
| 207 | + 'name' => esc_html__( 'Forums', 'bbpress' ), | |
| 171 | 208 | 'slug' => $this->slug, |
| 172 | 209 | 'position' => 80, |
| 173 | 210 | 'screen_function' => 'bbp_member_forums_screen_topics', |
| 174 | - 'default_subnav_slug' => 'topics', | |
| 211 | + 'default_subnav_slug' => bbp_get_topic_archive_slug(), | |
| 175 | 212 | 'item_css_id' => $this->id |
| 176 | 213 | ); |
| 177 | 214 | |
| 178 | 215 | // Determine user to use |
| 179 | - if ( bp_displayed_user_id() ) | |
| 216 | + if ( bp_displayed_user_id() ) { | |
| 180 | 217 | $user_domain = bp_displayed_user_domain(); |
| 181 | - elseif ( bp_loggedin_user_domain() ) | |
| 218 | + } elseif ( bp_loggedin_user_domain() ) { | |
| 182 | 219 | $user_domain = bp_loggedin_user_domain(); |
| 183 | - else | |
| 220 | + } else { | |
| 184 | 221 | return; |
| 222 | + } | |
| 185 | 223 | |
| 186 | 224 | // User link |
| 187 | 225 | $forums_link = trailingslashit( $user_domain . $this->slug ); |
| 188 | 226 | |
| @@ -187,10 +225,10 @@ | ||
| 187 | 225 | $forums_link = trailingslashit( $user_domain . $this->slug ); |
| 188 | 226 | |
| 189 | 227 | // Topics started |
| 190 | 228 | $sub_nav[] = array( |
| 191 | - 'name' => __( 'Topics Started', 'bbpress' ), | |
| 192 | - 'slug' => 'topics', | |
| 229 | + 'name' => esc_html__( 'Topics Started', 'bbpress' ), | |
| 230 | + 'slug' => bbp_get_topic_archive_slug(), | |
| 193 | 231 | 'parent_url' => $forums_link, |
| 194 | 232 | 'parent_slug' => $this->slug, |
| 195 | 233 | 'screen_function' => 'bbp_member_forums_screen_topics', |
| 196 | 234 | 'position' => 20, |
| @@ -198,10 +236,10 @@ | ||
| 198 | 236 | ); |
| 199 | 237 | |
| 200 | 238 | // Replies to topics |
| 201 | 239 | $sub_nav[] = array( |
| 202 | - 'name' => __( 'Replies Created', 'bbpress' ), | |
| 203 | - 'slug' => 'replies', | |
| 240 | + 'name' => esc_html__( 'Replies Created', 'bbpress' ), | |
| 241 | + 'slug' => bbp_get_reply_archive_slug(), | |
| 204 | 242 | 'parent_url' => $forums_link, |
| 205 | 243 | 'parent_slug' => $this->slug, |
| 206 | 244 | 'screen_function' => 'bbp_member_forums_screen_replies', |
| 207 | 245 | 'position' => 40, |
| @@ -207,28 +245,43 @@ | ||
| 207 | 245 | 'position' => 40, |
| 208 | 246 | 'item_css_id' => 'replies' |
| 209 | 247 | ); |
| 210 | 248 | |
| 249 | + // Engagements | |
| 250 | + if ( bbp_is_engagements_active() ) { | |
| 251 | + $sub_nav[] = array( | |
| 252 | + 'name' => esc_html__( 'Engagements', 'bbpress' ), | |
| 253 | + 'slug' => bbp_get_user_engagements_slug(), | |
| 254 | + 'parent_url' => $forums_link, | |
| 255 | + 'parent_slug' => $this->slug, | |
| 256 | + 'screen_function' => 'bbp_member_forums_screen_engagements', | |
| 257 | + 'position' => 60, | |
| 258 | + 'item_css_id' => 'engagements' | |
| 259 | + ); | |
| 260 | + } | |
| 261 | + | |
| 211 | 262 | // Favorite topics |
| 212 | - $sub_nav[] = array( | |
| 213 | - 'name' => __( 'Favorites', 'bbpress' ), | |
| 214 | - 'slug' => 'favorites', | |
| 215 | - 'parent_url' => $forums_link, | |
| 216 | - 'parent_slug' => $this->slug, | |
| 217 | - 'screen_function' => 'bbp_member_forums_screen_favorites', | |
| 218 | - 'position' => 60, | |
| 219 | - 'item_css_id' => 'favorites' | |
| 220 | - ); | |
| 263 | + if ( bbp_is_favorites_active() ) { | |
| 264 | + $sub_nav[] = array( | |
| 265 | + 'name' => esc_html__( 'Favorites', 'bbpress' ), | |
| 266 | + 'slug' => bbp_get_user_favorites_slug(), | |
| 267 | + 'parent_url' => $forums_link, | |
| 268 | + 'parent_slug' => $this->slug, | |
| 269 | + 'screen_function' => 'bbp_member_forums_screen_favorites', | |
| 270 | + 'position' => 80, | |
| 271 | + 'item_css_id' => 'favorites' | |
| 272 | + ); | |
| 273 | + } | |
| 221 | 274 | |
| 222 | 275 | // Subscribed topics (my profile only) |
| 223 | - if ( bp_is_my_profile() ) { | |
| 276 | + if ( bp_is_my_profile() && bbp_is_subscriptions_active() ) { | |
| 224 | 277 | $sub_nav[] = array( |
| 225 | - 'name' => __( 'Subscriptions', 'bbpress' ), | |
| 226 | - 'slug' => 'subscriptions', | |
| 278 | + 'name' => esc_html__( 'Subscriptions', 'bbpress' ), | |
| 279 | + 'slug' => bbp_get_user_subscriptions_slug(), | |
| 227 | 280 | 'parent_url' => $forums_link, |
| 228 | 281 | 'parent_slug' => $this->slug, |
| 229 | 282 | 'screen_function' => 'bbp_member_forums_screen_subscriptions', |
| 230 | - 'position' => 60, | |
| 283 | + 'position' => 100, | |
| 231 | 284 | 'item_css_id' => 'subscriptions' |
| 232 | 285 | ); |
| 233 | 286 | } |
| 234 | 287 | |
| @@ -237,28 +290,45 @@ | ||
| 237 | 290 | |
| 238 | 291 | /** |
| 239 | 292 | * Set up the admin bar |
| 240 | 293 | * |
| 241 | - * @since bbPress (r3552) | |
| 294 | + * @since 2.1.0 bbPress (r3552) | |
| 242 | 295 | */ |
| 243 | - public function setup_admin_bar() { | |
| 296 | + public function setup_admin_bar( $wp_admin_nav = array() ) { | |
| 244 | 297 | |
| 245 | - // Prevent debug notices | |
| 246 | - $wp_admin_nav = array(); | |
| 247 | - | |
| 248 | 298 | // Menus for logged in user |
| 249 | 299 | if ( is_user_logged_in() ) { |
| 250 | 300 | |
| 251 | - // Setup the logged in user variables | |
| 252 | - $user_domain = bp_loggedin_user_domain(); | |
| 253 | - $forums_link = trailingslashit( $user_domain . $this->slug ); | |
| 301 | + // If BuddyPress is network activated and bbPress is | |
| 302 | + // not activated on a the root blog but on any child one | |
| 303 | + if ( ! bp_is_root_blog() ) { | |
| 304 | + $user_id = bbp_get_current_user_id(); | |
| 305 | + $my_account_link = bbp_get_user_profile_url( $user_id ); | |
| 306 | + $my_topics_link = bbp_get_user_topics_created_url( $user_id ); | |
| 307 | + $my_replies_link = bbp_get_user_replies_created_url( $user_id ); | |
| 308 | + $my_engagements_link = bbp_get_user_engagements_url( $user_id ); | |
| 309 | + $my_favorites_link = bbp_get_favorites_permalink( $user_id ); | |
| 310 | + $my_subscriptions_link = bbp_get_subscriptions_permalink( $user_id ); | |
| 311 | + } else { | |
| 254 | 312 | |
| 313 | + // Setup the logged in user variables | |
| 314 | + $user_domain = bp_loggedin_user_domain(); | |
| 315 | + $forums_link = trailingslashit( $user_domain . $this->slug ); | |
| 316 | + | |
| 317 | + $my_account_link = trailingslashit( $forums_link ); | |
| 318 | + $my_topics_link = trailingslashit( $forums_link . bbp_get_topic_archive_slug() ); | |
| 319 | + $my_replies_link = trailingslashit( $forums_link . bbp_get_reply_archive_slug() ); | |
| 320 | + $my_engagements_link = trailingslashit( $forums_link . bbp_get_user_engagements_slug() ); | |
| 321 | + $my_favorites_link = trailingslashit( $forums_link . bbp_get_user_favorites_slug() ); | |
| 322 | + $my_subscriptions_link = trailingslashit( $forums_link . bbp_get_user_subscriptions_slug() ); | |
| 323 | + } | |
| 324 | + | |
| 255 | 325 | // Add the "My Account" sub menus |
| 256 | 326 | $wp_admin_nav[] = array( |
| 257 | 327 | 'parent' => buddypress()->my_account_menu_id, |
| 258 | 328 | 'id' => 'my-account-' . $this->id, |
| 259 | - 'title' => __( 'Forums', 'bbpress' ), | |
| 260 | - 'href' => trailingslashit( $forums_link ) | |
| 329 | + 'title' => esc_html__( 'Forums', 'bbpress' ), | |
| 330 | + 'href' => $my_account_link | |
| 261 | 331 | ); |
| 262 | 332 | |
| 263 | 333 | // Topics |
| 264 | 334 | $wp_admin_nav[] = array( |
| @@ -263,10 +333,10 @@ | ||
| 263 | 333 | // Topics |
| 264 | 334 | $wp_admin_nav[] = array( |
| 265 | 335 | 'parent' => 'my-account-' . $this->id, |
| 266 | 336 | 'id' => 'my-account-' . $this->id . '-topics', |
| 267 | - 'title' => __( 'Topics Started', 'bbpress' ), | |
| 268 | - 'href' => trailingslashit( $forums_link . 'topics' ) | |
| 337 | + 'title' => esc_html__( 'Topics Started', 'bbpress' ), | |
| 338 | + 'href' => $my_topics_link | |
| 269 | 339 | ); |
| 270 | 340 | |
| 271 | 341 | // Replies |
| 272 | 342 | $wp_admin_nav[] = array( |
| @@ -271,27 +341,41 @@ | ||
| 271 | 341 | // Replies |
| 272 | 342 | $wp_admin_nav[] = array( |
| 273 | 343 | 'parent' => 'my-account-' . $this->id, |
| 274 | 344 | 'id' => 'my-account-' . $this->id . '-replies', |
| 275 | - 'title' => __( 'Replies Created', 'bbpress' ), | |
| 276 | - 'href' => trailingslashit( $forums_link . 'replies' ) | |
| 345 | + 'title' => esc_html__( 'Replies Created', 'bbpress' ), | |
| 346 | + 'href' => $my_replies_link | |
| 277 | 347 | ); |
| 278 | 348 | |
| 349 | + // Engagements | |
| 350 | + if ( bbp_is_engagements_active() ) { | |
| 351 | + $wp_admin_nav[] = array( | |
| 352 | + 'parent' => 'my-account-' . $this->id, | |
| 353 | + 'id' => 'my-account-' . $this->id . '-engagements', | |
| 354 | + 'title' => esc_html__( 'Engagements', 'bbpress' ), | |
| 355 | + 'href' => $my_engagements_link | |
| 356 | + ); | |
| 357 | + } | |
| 358 | + | |
| 279 | 359 | // Favorites |
| 280 | - $wp_admin_nav[] = array( | |
| 281 | - 'parent' => 'my-account-' . $this->id, | |
| 282 | - 'id' => 'my-account-' . $this->id . '-favorites', | |
| 283 | - 'title' => __( 'Favorite Topics', 'bbpress' ), | |
| 284 | - 'href' => trailingslashit( $forums_link . 'favorites' ) | |
| 285 | - ); | |
| 360 | + if ( bbp_is_favorites_active() ) { | |
| 361 | + $wp_admin_nav[] = array( | |
| 362 | + 'parent' => 'my-account-' . $this->id, | |
| 363 | + 'id' => 'my-account-' . $this->id . '-favorites', | |
| 364 | + 'title' => esc_html__( 'Favorite Topics', 'bbpress' ), | |
| 365 | + 'href' => $my_favorites_link | |
| 366 | + ); | |
| 367 | + } | |
| 286 | 368 | |
| 287 | 369 | // Subscriptions |
| 288 | - $wp_admin_nav[] = array( | |
| 289 | - 'parent' => 'my-account-' . $this->id, | |
| 290 | - 'id' => 'my-account-' . $this->id . '-subscriptions', | |
| 291 | - 'title' => __( 'Subscribed Topics', 'bbpress' ), | |
| 292 | - 'href' => trailingslashit( $forums_link . 'subscriptions' ) | |
| 293 | - ); | |
| 370 | + if ( bbp_is_subscriptions_active() ) { | |
| 371 | + $wp_admin_nav[] = array( | |
| 372 | + 'parent' => 'my-account-' . $this->id, | |
| 373 | + 'id' => 'my-account-' . $this->id . '-subscriptions', | |
| 374 | + 'title' => esc_html__( 'Subscribed Topics', 'bbpress' ), | |
| 375 | + 'href' => $my_subscriptions_link | |
| 376 | + ); | |
| 377 | + } | |
| 294 | 378 | } |
| 295 | 379 | |
| 296 | 380 | parent::setup_admin_bar( $wp_admin_nav ); |
| 297 | 381 | } |
| @@ -298,9 +382,9 @@ | ||
| 298 | 382 | |
| 299 | 383 | /** |
| 300 | 384 | * Sets up the title for pages and <title> |
| 301 | 385 | * |
| 302 | - * @since bbPress (r3552) | |
| 386 | + * @since 2.1.0 bbPress (r3552) | |
| 303 | 387 | */ |
| 304 | 388 | public function setup_title() { |
| 305 | 389 | $bp = buddypress(); |
| 306 | 390 | |
| @@ -306,15 +390,17 @@ | ||
| 306 | 390 | |
| 307 | 391 | // Adjust title based on view |
| 308 | 392 | if ( bp_is_forums_component() ) { |
| 309 | 393 | if ( bp_is_my_profile() ) { |
| 310 | - $bp->bp_options_title = __( 'Forums', 'bbpress' ); | |
| 394 | + $bp->bp_options_title = esc_html__( 'Forums', 'bbpress' ); | |
| 311 | 395 | } elseif ( bp_is_user() ) { |
| 312 | - $bp->bp_options_avatar = bp_core_fetch_avatar( array( | |
| 313 | - 'item_id' => bp_displayed_user_id(), | |
| 314 | - 'type' => 'thumb' | |
| 315 | - ) ); | |
| 316 | - $bp->bp_options_title = bp_get_displayed_user_fullname(); | |
| 396 | + $bp->bp_options_avatar = bp_core_fetch_avatar( | |
| 397 | + array( | |
| 398 | + 'item_id' => bp_displayed_user_id(), | |
| 399 | + 'type' => 'thumb' | |
| 400 | + ) | |
| 401 | + ); | |
| 402 | + $bp->bp_options_title = bp_get_displayed_user_fullname(); | |
| 317 | 403 | } |
| 318 | 404 | } |
| 319 | 405 | |
| 320 | 406 | parent::setup_title(); |