Skip to:
Content

BuddyPress.org

Ticket #7096: 7096.diff

File 7096.diff, 3.6 KB (added by boonebgorges, 7 years ago)
  • src/bp-messages/bp-messages-template.php

    diff --git src/bp-messages/bp-messages-template.php src/bp-messages/bp-messages-template.php
    index ad380b132..c28fbedbd 100644
    function bp_message_thread_to() { 
    273273/**
    274274 * Output the permalink for a particular thread.
    275275 *
     276 * @since 2.9.0 Introduced `$user_id` parameter.
     277 *
    276278 * @param int $thread_id Optional. ID of the thread. Default: current thread
    277279 *                       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.
    278282 */
    279 function bp_message_thread_view_link( $thread_id = 0 ) {
    280         echo bp_get_message_thread_view_link( $thread_id );
     283function bp_message_thread_view_link( $thread_id = 0, $user_id = null ) {
     284        echo bp_get_message_thread_view_link( $thread_id, $user_id );
    281285}
    282286        /**
    283287         * Get the permalink of a particular thread.
    284288         *
     289         * @since 2.9.0 Introduced `$user_id` parameter.
     290         *
    285291         * @param int $thread_id Optional. ID of the thread. Default: current
    286292         *                       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.
    287295         * @return string
    288296         */
    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 ) {
    290298                global $messages_template;
    291299
    292300                if ( empty( $messages_template ) && (int) $thread_id > 0 ) {
    function bp_message_thread_view_link( $thread_id = 0 ) { 
    295303                        $thread_id = $messages_template->thread->thread_id;
    296304                }
    297305
     306                if ( null === $user_id ) {
     307                        $user_id = bp_loggedin_user_id();
     308                }
     309
     310                $domain = bp_core_get_user_domain( $user_id );
     311
    298312                /**
    299313                 * Filters the permalink of a particular thread.
    300314                 *
    301315                 * @since 1.0.0
    302316                 * @since 2.6.0 Added the `$thread_id` parameter.
     317                 * @since 2.9.0 Added the `$user_id` parameter.
    303318                 *
    304319                 * @param string $value     Permalink of a particular thread.
    305320                 * @param int    $thread_id ID of the thread.
    306321                 */
    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 );
    308323        }
    309324
    310325/**
  • src/bp-templates/bp-legacy/buddypress/members/single/messages/messages-loop.php

    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..9e0dded3c 100644
    do_action( 'bp_before_member_messages_loop' ); ?> 
    115115                                                <?php endif; ?>
    116116
    117117                                                <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>
    119119                                                        <p class="thread-excerpt"><?php bp_message_thread_excerpt(); ?></p>
    120120                                                </td>
    121121