diff --git src/bp-messages/bp-messages-template.php src/bp-messages/bp-messages-template.php
index ad380b132..812629611 100644
|
|
|
function bp_message_thread_to() {
|
| 273 | 273 | /** |
| 274 | 274 | * Output the permalink for a particular thread. |
| 275 | 275 | * |
| | 276 | * @since 2.9.0 Introduced `$user_id` parameter. |
| | 277 | * |
| 276 | 278 | * @param int $thread_id Optional. ID of the thread. Default: current thread |
| 277 | 279 | * being iterated on in the loop. |
| | 280 | * @param int $user_id Optional. ID of the user relative to whom the link |
| | 281 | * should be generated. Default: ID of logged-in user. |
| 278 | 282 | */ |
| 279 | | function bp_message_thread_view_link( $thread_id = 0 ) { |
| 280 | | echo bp_get_message_thread_view_link( $thread_id ); |
| | 283 | function bp_message_thread_view_link( $thread_id = 0, $user_id = null ) { |
| | 284 | echo bp_get_message_thread_view_link( $thread_id, $user_id ); |
| 281 | 285 | } |
| 282 | 286 | /** |
| 283 | 287 | * Get the permalink of a particular thread. |
| 284 | 288 | * |
| | 289 | * @since 2.9.0 Introduced `$user_id` parameter. |
| | 290 | * |
| 285 | 291 | * @param int $thread_id Optional. ID of the thread. Default: current |
| 286 | 292 | * thread being iterated on in the loop. |
| | 293 | * @param int $user_id Optional. ID of the user relative to whom the link |
| | 294 | * should be generated. Default: ID of logged-in user. |
| 287 | 295 | * @return string |
| 288 | 296 | */ |
| 289 | | function bp_get_message_thread_view_link( $thread_id = 0 ) { |
| | 297 | function bp_get_message_thread_view_link( $thread_id = 0, $user_id = null ) { |
| 290 | 298 | global $messages_template; |
| 291 | 299 | |
| 292 | 300 | if ( empty( $messages_template ) && (int) $thread_id > 0 ) { |
| … |
… |
function bp_message_thread_view_link( $thread_id = 0 ) {
|
| 295 | 303 | $thread_id = $messages_template->thread->thread_id; |
| 296 | 304 | } |
| 297 | 305 | |
| | 306 | if ( null === $user_id ) { |
| | 307 | $user_id = bp_loggedin_user_id(); |
| | 308 | } |
| | 309 | |
| | 310 | $domain = bp_core_get_user_domain( $user_id ); |
| | 311 | |
| 298 | 312 | /** |
| 299 | 313 | * Filters the permalink of a particular thread. |
| 300 | 314 | * |
| 301 | 315 | * @since 1.0.0 |
| 302 | 316 | * @since 2.6.0 Added the `$thread_id` parameter. |
| | 317 | * @since 2.9.0 Added the `$user_id` parameter. |
| 303 | 318 | * |
| 304 | 319 | * @param string $value Permalink of a particular thread. |
| 305 | 320 | * @param int $thread_id ID of the thread. |
| 306 | 321 | */ |
| 307 | | return apply_filters( 'bp_get_message_thread_view_link', trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/view/' . $thread_id ), $thread_id ); |
| | 322 | return apply_filters( 'bp_get_message_thread_view_link', trailingslashit( $domain . bp_get_messages_slug() . '/view/' . $thread_id ), $thread_id, $user_id ); |
| 308 | 323 | } |
| 309 | 324 | |
| 310 | 325 | /** |
| 311 | 326 | * Output the URL for deleting the current thread. |
| | 327 | * |
| | 328 | * @since 2.9.0 Introduced `$user_id` parameter. |
| | 329 | * |
| | 330 | * @param int $user_id Optional. ID of the user relative to whom the link |
| | 331 | * should be generated. Default: ID of logged-in user. |
| 312 | 332 | */ |
| 313 | | function bp_message_thread_delete_link() { |
| 314 | | echo esc_url( bp_get_message_thread_delete_link() ); |
| | 333 | function bp_message_thread_delete_link( $user_id = null ) { |
| | 334 | echo esc_url( bp_get_message_thread_delete_link( $user_id ) ); |
| 315 | 335 | } |
| 316 | 336 | /** |
| 317 | 337 | * Generate the URL for deleting the current thread. |
| 318 | 338 | * |
| | 339 | * @since 2.9.0 Introduced `$user_id` parameter. |
| | 340 | * |
| | 341 | * @param int $user_id Optional. ID of the user relative to whom the link |
| | 342 | * should be generated. Default: ID of logged-in user. |
| 319 | 343 | * @return string |
| 320 | 344 | */ |
| 321 | | function bp_get_message_thread_delete_link() { |
| | 345 | function bp_get_message_thread_delete_link( $user_id = null ) { |
| 322 | 346 | global $messages_template; |
| 323 | 347 | |
| | 348 | if ( null === $user_id ) { |
| | 349 | $user_id = bp_loggedin_user_id(); |
| | 350 | } |
| | 351 | |
| | 352 | $domain = bp_core_get_user_domain( $user_id ); |
| | 353 | |
| 324 | 354 | /** |
| 325 | 355 | * Filters the URL for deleting the current thread. |
| 326 | 356 | * |
| … |
… |
function bp_message_thread_delete_link() {
|
| 329 | 359 | * @param string $value URL for deleting the current thread. |
| 330 | 360 | * @param string $value Text indicating action being executed. |
| 331 | 361 | */ |
| 332 | | return apply_filters( 'bp_get_message_thread_delete_link', wp_nonce_url( trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/delete/' . $messages_template->thread->thread_id ), 'messages_delete_thread' ) ); |
| | 362 | return apply_filters( 'bp_get_message_thread_delete_link', wp_nonce_url( trailingslashit( $domain . bp_get_messages_slug() . '/' . bp_current_action() . '/delete/' . $messages_template->thread->thread_id ), 'messages_delete_thread' ) ); |
| 333 | 363 | } |
| 334 | 364 | |
| 335 | 365 | /** |
| … |
… |
function bp_message_thread_delete_link() {
|
| 338 | 368 | * Since this function directly outputs a URL, it is escaped. |
| 339 | 369 | * |
| 340 | 370 | * @since 2.2.0 |
| | 371 | * @since 2.9.0 Introduced `$user_id` parameter. |
| | 372 | * |
| | 373 | * @param int $user_id Optional. ID of the user relative to whom the link |
| | 374 | * should be generated. Default: ID of logged-in user. |
| 341 | 375 | */ |
| 342 | | function bp_the_message_thread_mark_unread_url() { |
| 343 | | echo esc_url( bp_get_the_message_thread_mark_unread_url() ); |
| | 376 | function bp_the_message_thread_mark_unread_url( $user_id = null ) { |
| | 377 | echo esc_url( bp_get_the_message_thread_mark_unread_url( $user_id ) ); |
| 344 | 378 | } |
| 345 | 379 | /** |
| 346 | 380 | * Return the URL used for marking a single message thread as unread. |
| 347 | 381 | * |
| 348 | 382 | * @since 2.2.0 |
| | 383 | * @since 2.9.0 Introduced `$user_id` parameter. |
| 349 | 384 | * |
| | 385 | * @param int $user_id Optional. ID of the user relative to whom the link |
| | 386 | * should be generated. Default: ID of logged-in user. |
| 350 | 387 | * @return string |
| 351 | 388 | */ |
| 352 | | function bp_get_the_message_thread_mark_unread_url() { |
| | 389 | function bp_get_the_message_thread_mark_unread_url( $user_id = null ) { |
| 353 | 390 | |
| 354 | 391 | // Get the message ID. |
| 355 | 392 | $id = bp_get_message_thread_id(); |
| … |
… |
function bp_the_message_thread_mark_unread_url() {
|
| 360 | 397 | 'message_id' => $id |
| 361 | 398 | ); |
| 362 | 399 | |
| | 400 | if ( null === $user_id ) { |
| | 401 | $user_id = bp_loggedin_user_id(); |
| | 402 | } |
| | 403 | |
| | 404 | $domain = bp_core_get_user_domain( $user_id ); |
| | 405 | |
| 363 | 406 | // Base unread URL. |
| 364 | | $url = trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/unread' ); |
| | 407 | $url = trailingslashit( $domain . bp_get_messages_slug() . '/' . bp_current_action() . '/unread' ); |
| 365 | 408 | |
| 366 | 409 | // Add the args to the URL. |
| 367 | 410 | $url = add_query_arg( $args, $url ); |
| … |
… |
function bp_the_message_thread_mark_unread_url() {
|
| 385 | 428 | * Since this function directly outputs a URL, it is escaped. |
| 386 | 429 | * |
| 387 | 430 | * @since 2.2.0 |
| | 431 | * @since 2.9.0 Introduced `$user_id` parameter. |
| | 432 | * |
| | 433 | * @param int $user_id Optional. ID of the user relative to whom the link |
| | 434 | * should be generated. Default: ID of logged-in user. |
| 388 | 435 | */ |
| 389 | | function bp_the_message_thread_mark_read_url() { |
| 390 | | echo esc_url( bp_get_the_message_thread_mark_read_url() ); |
| | 436 | function bp_the_message_thread_mark_read_url( $user_id = null ) { |
| | 437 | echo esc_url( bp_get_the_message_thread_mark_read_url( $user_id ) ); |
| 391 | 438 | } |
| 392 | 439 | /** |
| 393 | 440 | * Return the URL used for marking a single message thread as read. |
| 394 | 441 | * |
| 395 | 442 | * @since 2.2.0 |
| | 443 | * @since 2.9.0 Introduced `$user_id` parameter. |
| 396 | 444 | * |
| | 445 | * @param int $user_id Optional. ID of the user relative to whom the link |
| | 446 | * should be generated. Default: ID of logged-in user. |
| 397 | 447 | * @return string |
| 398 | 448 | */ |
| 399 | | function bp_get_the_message_thread_mark_read_url() { |
| | 449 | function bp_get_the_message_thread_mark_read_url( $user_id = null ) { |
| 400 | 450 | |
| 401 | 451 | // Get the message ID. |
| 402 | 452 | $id = bp_get_message_thread_id(); |
| … |
… |
function bp_the_message_thread_mark_read_url() {
|
| 407 | 457 | 'message_id' => $id |
| 408 | 458 | ); |
| 409 | 459 | |
| | 460 | if ( null === $user_id ) { |
| | 461 | $user_id = bp_loggedin_user_id(); |
| | 462 | } |
| | 463 | |
| | 464 | $domain = bp_core_get_user_domain( $user_id ); |
| | 465 | |
| 410 | 466 | // Base read URL. |
| 411 | | $url = trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/read' ); |
| | 467 | $url = trailingslashit( $domain . bp_get_messages_slug() . '/' . bp_current_action() . '/read' ); |
| 412 | 468 | |
| 413 | 469 | // Add the args to the URL. |
| 414 | 470 | $url = add_query_arg( $args, $url ); |
diff --git src/bp-templates/bp-legacy/buddypress/members/single/messages/messages-loop.php src/bp-templates/bp-legacy/buddypress/members/single/messages/messages-loop.php
index d71ded236..7720e99fc 100644
|
|
|
do_action( 'bp_before_member_messages_loop' ); ?>
|
| 115 | 115 | <?php endif; ?> |
| 116 | 116 | |
| 117 | 117 | <td class="thread-info"> |
| 118 | | <p><a href="<?php bp_message_thread_view_link(); ?>" class="bp-tooltip" data-bp-tooltip="<?php esc_attr_e( "View Message", 'buddypress' ); ?>" aria-label="<?php esc_attr_e( "View Message", 'buddypress' ); ?>"><?php bp_message_thread_subject(); ?></a></p> |
| | 118 | <p><a href="<?php bp_message_thread_view_link( bp_get_message_thread_id(), bp_displayed_user_id() ); ?>" class="bp-tooltip" data-bp-tooltip="<?php esc_attr_e( "View Message", 'buddypress' ); ?>" aria-label="<?php esc_attr_e( "View Message", 'buddypress' ); ?>"><?php bp_message_thread_subject(); ?></a></p> |
| 119 | 119 | <p class="thread-excerpt"><?php bp_message_thread_excerpt(); ?></p> |
| 120 | 120 | </td> |
| 121 | 121 | |
| … |
… |
do_action( 'bp_before_member_messages_loop' ); ?>
|
| 139 | 139 | |
| 140 | 140 | <td class="thread-options"> |
| 141 | 141 | <?php if ( bp_message_thread_has_unread() ) : ?> |
| 142 | | <a class="read" href="<?php bp_the_message_thread_mark_read_url();?>"><?php _e( 'Read', 'buddypress' ); ?></a> |
| | 142 | <a class="read" href="<?php bp_the_message_thread_mark_read_url( bp_displayed_user_id() );?>"><?php _e( 'Read', 'buddypress' ); ?></a> |
| 143 | 143 | <?php else : ?> |
| 144 | | <a class="unread" href="<?php bp_the_message_thread_mark_unread_url();?>"><?php _e( 'Unread', 'buddypress' ); ?></a> |
| | 144 | <a class="unread" href="<?php bp_the_message_thread_mark_unread_url( bp_displayed_user_id() );?>"><?php _e( 'Unread', 'buddypress' ); ?></a> |
| 145 | 145 | <?php endif; ?> |
| 146 | 146 | | |
| 147 | | <a class="delete" href="<?php bp_message_thread_delete_link(); ?>"><?php _e( 'Delete', 'buddypress' ); ?></a> |
| | 147 | <a class="delete" href="<?php bp_message_thread_delete_link( bp_displayed_user_id() ); ?>"><?php _e( 'Delete', 'buddypress' ); ?></a> |
| 148 | 148 | |
| 149 | 149 | <?php |
| 150 | 150 | |