Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/06/2015 04:04:09 AM (9 years ago)
Author:
r-a-y
Message:

bp-legacy: For AJAX private message reply, use the message loop.

When making a reply to a private message thread, our AJAX message output
should use the message loop and all related message template functions.

Previously, we did a workaround fix for zebra-striping (see r6548) and did
not use native template functions such as bp_the_thread_message_css_class()
(see r8604) or bp_the_thread_message_content() during AJAX.

Fixes #6321.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-templates/bp-legacy/buddypress-functions.php

    r9819 r9838  
    14841484    if ( !empty( $result ) ) {
    14851485
    1486         // Get the zebra line classes correct on ajax requests
     1486        // pretend we're in the message loop
    14871487        global $thread_template;
    14881488
    14891489        bp_thread_has_messages( array( 'thread_id' => (int) $_REQUEST['thread_id'] ) );
    14901490
     1491        // set the current message to the 2nd last
     1492        $thread_template->message = end( $thread_template->thread->messages );
     1493        $thread_template->message = prev( $thread_template->thread->messages );
     1494
     1495        // set current message to current key
     1496        $thread_template->current_message = key( $thread_template->thread->messages );
     1497
     1498        // now manually iterate message like we're in the loop
    14911499        bp_thread_the_message();
    14921500
    1493         if ( $thread_template->message_count % 2 == 1 ) {
    1494             $class = 'odd';
    1495         } else {
    1496             $class = 'even alt';
    1497         } ?>
    1498 
    1499         <div class="message-box new-message <?php echo $class; ?>">
     1501        // manually call oEmbed
     1502        // this is needed because we're not at the beginning of the loop
     1503        bp_messages_embed()
     1504    ?>
     1505
     1506        <div class="message-box new-message <?php bp_the_thread_message_css_class(); ?>">
    15001507            <div class="message-metadata">
    15011508                <?php
    15021509
    15031510                /**
    1504                  * Fires before the notifications for private messages.
     1511                 * Fires before the single message header is displayed.
    15051512                 *
    15061513                 * @since BuddyPress (1.1.0)
     
    15141521
    15151522                /**
    1516                  * Fires after the notifications for private messages.
     1523                 * Fires after the single message header is displayed.
    15171524                 *
    15181525                 * @since BuddyPress (1.1.0)
     
    15311538
    15321539            <div class="message-content">
    1533                 <?php
    1534 
    1535                 /** This filter is documented in bp-messages/bp-messages-template.php */
    1536                 echo stripslashes( apply_filters( 'bp_get_the_thread_message_content', $_REQUEST['content'] ) ); ?>
     1540                <?php bp_the_thread_message_content(); ?>
    15371541            </div>
    15381542
     
    15491553        </div>
    15501554    <?php
     1555        // clean up the loop
     1556        bp_thread_messages();
     1557
    15511558    } else {
    15521559        echo "-1<div id='message' class='error'><p>" . __( 'There was a problem sending that reply. Please try again.', 'buddypress' ) . '</p></div>';
Note: See TracChangeset for help on using the changeset viewer.