Skip to:
Content

BuddyPress.org

Changeset 9095


Ignore:
Timestamp:
10/28/2014 05:12:35 PM (6 years ago)
Author:
boonebgorges
Message:

Rework the building of the recipient list on single messages.

  • Deprecate bp_get_the_thread_recipients().
  • Move the recipient count logic into the members/single/messages/single.php template.
  • Introduce bp_get_thread_recipients_count() and bp_get_thread_recipients_list() to separate the logic of the deprecated function.

Props joshshashaty, Clean-Cole.
Fixes #5327.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-messages/bp-messages-template.php

    r8931 r9095  
    14991499
    15001500/**
     1501 * Get a list of thread recipients or a "x recipients" string.
     1502 *
     1503 * In BuddyPress 2.2.0, this parts of this functionality were moved into the
     1504 * members/single/messages/single.php template. This function is no longer used
     1505 * by BuddyPress.
     1506 *
     1507 * @return string
     1508 */
     1509function bp_get_the_thread_recipients(){
     1510    if ( 5 <= bp_get_thread_recipients_count() ) {
     1511        $recipients = sprintf( __( '%s recipients', 'buddypress' ), number_format_i18n( bp_get_thread_recipients_count() ) );
     1512    } else {
     1513        $recipients = bp_get_thread_recipients_list();
     1514    }
     1515
     1516    return apply_filters( 'bp_get_the_thread_recipients', $recipients );
     1517}
     1518
     1519/**
     1520 * Get the number of recipients in the current thread.
     1521 *
     1522 * @since BuddyPress (2.2.0)
     1523 *
     1524 * @return int
     1525 */
     1526function bp_get_thread_recipients_count() {
     1527    global $thread_template;
     1528    return count( $thread_template->thread->recipients );
     1529}
     1530
     1531/**
    15011532 * Output HTML links to recipients in the current thread.
    1502  */
    1503 function bp_the_thread_recipients() {
    1504     echo bp_get_the_thread_recipients();
     1533 *
     1534 * @since BuddyPress (2.2.0)
     1535 */
     1536function bp_the_thread_recipients_list() {
     1537    echo bp_get_thread_recipients_list();
    15051538}
    15061539    /**
    15071540     * Generate HTML links to the profiles of recipients in the current thread.
    15081541     *
    1509      * @return string
    1510      */
    1511     function bp_get_the_thread_recipients() {
     1542     * @since BuddyPress (2.2.0)
     1543     *
     1544     * @return string
     1545     */
     1546    function bp_get_thread_recipients_list() {
    15121547        global $thread_template;
    15131548
    15141549        $recipient_links = array();
    1515 
    1516         if ( count( $thread_template->thread->recipients ) >= 5 ) {
    1517             return apply_filters( 'bp_get_the_thread_recipients', sprintf( __( '%d Recipients', 'buddypress' ), count( $thread_template->thread->recipients ) ) );
    1518         }
    15191550
    15201551        foreach( (array) $thread_template->thread->recipients as $recipient ) {
     
    15301561        }
    15311562
    1532         return apply_filters( 'bp_get_the_thread_recipients', implode( ', ', $recipient_links ) );
     1563        return apply_filters( 'bp_get_the_thread_recipients_list', implode( ', ', $recipient_links ) );
    15331564    }
    15341565
  • trunk/src/bp-templates/bp-legacy/buddypress/members/single/messages/single.php

    r9089 r9095  
    1010            <span class="highlight">
    1111
    12                 <?php if ( !bp_get_the_thread_recipients() ) : ?>
     12                <?php if ( ! bp_get_thread_recipients_count() ) : ?>
    1313
    1414                    <?php _e( 'You are alone in this conversation.', 'buddypress' ); ?>
    1515
     16                <?php elseif ( 5 <= bp_get_thread_recipients_count() ) : ?>
     17
     18                    <?php printf( __( 'Conversation between %s recipients.', 'buddypress' ), number_format_i18n( bp_get_thread_recipients_count() ) ); ?>
     19
    1620                <?php else : ?>
    1721
    18                     <?php printf( __( 'Conversation between %s and you.', 'buddypress' ), bp_get_the_thread_recipients() ); ?>
     22                    <?php printf( __( 'Conversation between %s and you.', 'buddypress' ), bp_get_thread_recipients_list() ); ?>
    1923
    2024                <?php endif; ?>
Note: See TracChangeset for help on using the changeset viewer.