Skip to:
Content

BuddyPress.org

Changeset 13096


Ignore:
Timestamp:
08/26/2021 12:53:27 AM (5 years ago)
Author:
espellcaste
Message:

Making PHPDoc Improvements to the BP Messages (component) files.

Also, adding several minor PHP changes.

See #8553

Location:
trunk/src/bp-messages
Files:
33 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-messages/actions/bulk-delete.php

    r11925 r13096  
    11<?php
    22/**
    3  * Messages: Bulk-delete action handler
     3 * Messages: Bulk-delete action handler.
    44 *
    55 * @package BuddyPress
     
    2121        $thread_ids = $_POST['thread_ids'];
    2222
    23         if ( !$thread_ids || !messages_check_thread_access( $thread_ids ) ) {
     23        if ( ! $thread_ids || ! messages_check_thread_access( $thread_ids ) ) {
    2424                bp_core_redirect( trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() ) );
    2525        } else {
    26                 if ( !check_admin_referer( 'messages_delete_thread' ) ) {
     26                if ( ! check_admin_referer( 'messages_delete_thread' ) ) {
    2727                        return false;
    2828                }
    2929
    30                 if ( !messages_delete_thread( $thread_ids ) ) {
    31                         bp_core_add_message( __('There was an error deleting messages.', 'buddypress'), 'error' );
     30                if ( ! messages_delete_thread( $thread_ids ) ) {
     31                        bp_core_add_message( __( 'There was an error deleting messages.', 'buddypress' ), 'error' );
    3232                } else {
    33                         bp_core_add_message( __('Messages deleted.', 'buddypress') );
     33                        bp_core_add_message( __( 'Messages deleted.', 'buddypress' ) );
    3434                }
    3535
  • trunk/src/bp-messages/actions/bulk-manage-star.php

    r12592 r13096  
    11<?php
    22/**
    3  * Messages: Bulk-manage star action handler
     3 * Messages: Bulk-manage star action handler.
    44 *
    55 * @package BuddyPress
  • trunk/src/bp-messages/actions/bulk-manage.php

    r11925 r13096  
    11<?php
    22/**
    3  * Messages: Bulk-manage action handler
     3 * Messages: Bulk-manage action handler.
    44 *
    55 * @package BuddyPress
     
    2525        $nonce    = ! empty( $_POST['messages_bulk_nonce'] ) ? $_POST['messages_bulk_nonce'] : '';
    2626        $messages = ! empty( $_POST['message_ids'] ) ? $_POST['message_ids'] : '';
    27 
    2827        $messages = wp_parse_id_list( $messages );
    2928
    3029        // Bail if no action or no IDs.
    31         if ( ( ! in_array( $action, array( 'delete', 'read', 'unread' ) ) ) || empty( $messages ) || empty( $nonce ) ) {
     30        if ( ( ! in_array( $action, array( 'delete', 'read', 'unread' ), true ) ) || empty( $messages ) || empty( $nonce ) ) {
    3231                bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/' );
    3332        }
     
    4847        // Delete, mark as read or unread depending on the user 'action'.
    4948        switch ( $action ) {
    50                 case 'delete' :
     49                case 'delete':
    5150                        foreach ( $messages as $message ) {
    5251                                messages_delete_thread( $message );
    5352                        }
    5453                        bp_core_add_message( __( 'Messages deleted.', 'buddypress' ) );
    55                 break;
     54                        break;
    5655
    57                 case 'read' :
     56                case 'read':
    5857                        foreach ( $messages as $message ) {
    5958                                messages_mark_thread_read( $message );
    6059                        }
    6160                        bp_core_add_message( __( 'Messages marked as read', 'buddypress' ) );
    62                 break;
     61                        break;
    6362
    64                 case 'unread' :
     63                case 'unread':
    6564                        foreach ( $messages as $message ) {
    6665                                messages_mark_thread_unread( $message );
    6766                        }
    6867                        bp_core_add_message( __( 'Messages marked as unread.', 'buddypress' ) );
    69                 break;
     68                        break;
    7069        }
    7170
  • trunk/src/bp-messages/actions/compose.php

    r11925 r13096  
    11<?php
    22/**
    3  * Messages: Compose action handler
     3 * Messages: Compose action handler.
    44 *
    55 * @package BuddyPress
     
    1313 * @since 2.4.0 This function was split from messages_screen_compose(). See #6505.
    1414 *
    15  * @return boolean
     15 * @return bool
    1616 */
    1717function bp_messages_action_create_message() {
     
    6565
    6666                        // Filter recipients into the format we need - array( 'username/userid', 'username/userid' ).
    67                         $autocomplete_recipients = (array) explode( ',', $_POST['send-to-input']     );
     67                        $autocomplete_recipients = (array) explode( ',', $_POST['send-to-input'] );
    6868                        $typed_recipients        = (array) explode( ' ', $_POST['send_to_usernames'] );
    6969                        $recipients              = array_merge( $autocomplete_recipients, $typed_recipients );
     
    8383                                'subject'    => $_POST['subject'],
    8484                                'content'    => $_POST['content'],
    85                                 'error_type' => 'wp_error'
     85                                'error_type' => 'wp_error',
    8686                        ) );
    8787
  • trunk/src/bp-messages/actions/delete.php

    r11925 r13096  
    11<?php
    22/**
    3  * Messages: Delete action handler
     3 * Messages: Delete action handler.
    44 *
    55 * @package BuddyPress
     
    2121        $thread_id = bp_action_variable( 1 );
    2222
    23         if ( !$thread_id || !is_numeric( $thread_id ) || !messages_check_thread_access( $thread_id ) ) {
     23        if ( ! $thread_id || ! is_numeric( $thread_id ) || ! messages_check_thread_access( $thread_id ) ) {
    2424                bp_core_redirect( trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() ) );
    2525        } else {
     
    2929
    3030                // Delete message.
    31                 if ( !messages_delete_thread( $thread_id ) ) {
     31                if ( ! messages_delete_thread( $thread_id ) ) {
    3232                        bp_core_add_message( __('There was an error deleting that message.', 'buddypress'), 'error' );
    3333                } else {
  • trunk/src/bp-messages/actions/notices.php

    r12990 r13096  
    11<?php
    22/**
    3  * Messages: Edit notice action handler
     3 * Messages: Edit notice action handler.
    44 *
    55 * @package BuddyPress
     
    1313 * @since 2.4.0 This function was split from messages_screen_notices(). See #6505.
    1414 *
    15  * @return boolean
     15 * @return bool
    1616 */
    1717function bp_messages_action_edit_notice() {
  • trunk/src/bp-messages/actions/read.php

    r11925 r13096  
    11<?php
    22/**
    3  * Messages: Read action handler
     3 * Messages: Read action handler.
    44 *
    55 * @package BuddyPress
     
    1313 * @since 2.2.0
    1414 *
    15  * @return false|null Returns false on failure. Otherwise redirects back to the
    16  *                   message box URL.
     15 * @return bool Returns false on failure. Otherwise redirects back to the
     16 *              message box URL.
    1717 */
    1818function bp_messages_action_mark_read() {
  • trunk/src/bp-messages/actions/star.php

    r11925 r13096  
    11<?php
    22/**
    3  * Messages: Star action handler
     3 * Messages: Star action handler.
    44 *
    55 * @package BuddyPress
  • trunk/src/bp-messages/actions/unread.php

    r11925 r13096  
    11<?php
    22/**
    3  * Messages: Unread action handler
     3 * Messages: Unread action handler.
    44 *
    55 * @package BuddyPress
     
    1313 * @since 2.2.0
    1414 *
    15  * @return false|null Returns false on failure. Otherwise redirects back to the
    16  *                   message box URL.
     15 * @return bool Returns false on failure. Otherwise redirects back to the
     16 *              message box URL.
    1717 */
    1818function bp_messages_action_mark_unread() {
  • trunk/src/bp-messages/actions/view.php

    r11925 r13096  
    11<?php
    22/**
    3  * Messages: View action handler
     3 * Messages: View action handler.
    44 *
    55 * @package BuddyPress
     
    1010/**
    1111 * Process a request to view a single message thread.
     12 *
     13 * @return bool False if not a single conversation.
    1214 */
    1315function messages_action_conversation() {
  • trunk/src/bp-messages/bp-messages-admin.php

    r11868 r13096  
    44 *
    55 * @package BuddyPress
    6  * @subpackage Messages
     6 * @subpackage MessagesAdmin
    77 * @since 3.0.0
    88 */
     
    1111defined( 'ABSPATH' ) || exit;
    1212
    13 // Load the Sitewide Notices Admin
     13// Load the Sitewide Notices Admin.
    1414add_action( bp_core_admin_hook(), array( 'BP_Messages_Notices_Admin', 'register_notices_admin' ), 9 );
  • trunk/src/bp-messages/bp-messages-blocks.php

    r13005 r13096  
    99
    1010// Exit if accessed directly.
    11 if ( ! defined( 'ABSPATH' ) ) {
    12         exit;
    13 }
     11defined( 'ABSPATH' ) || exit;
    1412
    1513/**
     
    1917 *
    2018 * @param array $attributes The block attributes.
    21  * @return string           HTML output.
     19 * @return string HTML output.
    2220 */
    2321function bp_messages_render_sitewide_notices_block( $attributes = array() ) {
  • trunk/src/bp-messages/bp-messages-cache.php

    r11578 r13096  
    5454 * @param BP_Messages_Message $message Message being saved.
    5555 */
    56 function bp_messages_clear_cache_on_message_save( BP_Messages_Message $message ) {
     56function bp_messages_clear_cache_on_message_save( $message ) {
    5757        // Delete thread cache.
    5858        wp_cache_delete( $message->thread_id, 'bp_messages_threads' );
     
    7979function bp_messages_clear_cache_on_message_delete( $thread_ids, $user_id ) {
    8080        // Delete thread and thread recipient cache.
    81         foreach( (array) $thread_ids as $thread_id ) {
     81        foreach ( (array) $thread_ids as $thread_id ) {
    8282                wp_cache_delete( $thread_id, 'bp_messages_threads' );
    8383                wp_cache_delete( "thread_recipients_{$thread_id}", 'bp_messages' );
     
    9595 *
    9696 * @since 2.0.0
    97  *
    98  * @param BP_Messages_Notice $notice Notice that was saved.
    9997 */
    100 function bp_notices_clear_cache( $notice ) {
     98function bp_notices_clear_cache() {
    10199        wp_cache_delete( 'active_notice', 'bp_messages' );
    102100}
    103 add_action( 'messages_notice_after_save',    'bp_notices_clear_cache' );
     101add_action( 'messages_notice_after_save', 'bp_notices_clear_cache' );
    104102add_action( 'messages_notice_before_delete', 'bp_notices_clear_cache' );
  • trunk/src/bp-messages/bp-messages-functions.php

    r12989 r13096  
    212212 */
    213213function messages_send_notice( $subject, $message ) {
    214         if ( !bp_current_user_can( 'bp_moderate' ) || empty( $subject ) || empty( $message ) ) {
     214
     215        if ( ! bp_current_user_can( 'bp_moderate' ) || empty( $subject ) || empty( $message ) ) {
    215216                return false;
    216 
    217         // Has access to send notices, lets do it.
    218         } else {
    219                 $notice            = new BP_Messages_Notice;
    220                 $notice->subject   = $subject;
    221                 $notice->message   = $message;
    222                 $notice->date_sent = bp_core_current_time();
    223                 $notice->is_active = 1;
    224                 $notice->save(); // Send it.
    225 
    226                 /**
    227                  * Fires after a notice has been successfully sent.
    228                  *
    229                  * @since 1.0.0
    230                  *
    231                  * @param string $subject Subject of the notice.
    232                  * @param string $message Content of the notice.
    233                  */
    234                 do_action_ref_array( 'messages_send_notice', array( $subject, $message ) );
    235 
    236                 return true;
    237         }
     217        }
     218
     219        $notice            = new BP_Messages_Notice;
     220        $notice->subject   = $subject;
     221        $notice->message   = $message;
     222        $notice->date_sent = bp_core_current_time();
     223        $notice->is_active = 1;
     224        $notice->save(); // Send it.
     225
     226        /**
     227         * Fires after a notice has been successfully sent.
     228         *
     229         * @since 1.0.0
     230         *
     231         * @param string             $subject Subject of the notice.
     232         * @param string             $message Content of the notice.
     233         * @param BP_Messages_Notice $notice  Notice object sent.
     234         */
     235        do_action_ref_array( 'messages_send_notice', array( $subject, $message, $notice ) );
     236
     237        return true;
    238238}
    239239
     
    276276                $error = 0;
    277277                for ( $i = 0, $count = count( $thread_ids ); $i < $count; ++$i ) {
    278                         if ( ! BP_Messages_Thread::delete( $thread_ids[$i], $user_id ) ) {
     278                        if ( ! BP_Messages_Thread::delete( $thread_ids[ $i ], $user_id ) ) {
    279279                                $error = 1;
    280280                        }
     
    427427 * @since 2.3.0
    428428 *
     429 * @global BuddyPress $bp The one true BuddyPress instance.
     430 * @global wpdb $wpdb WordPress database object.
     431 *
    429432 * @param  int $message_id ID of the message.
    430433 * @return int The ID of the thread if found, otherwise 0.
     
    446449 *
    447450 * @since 2.2.0
     451 *
     452 * @global wpdb $wpdb WordPress database object.
    448453 *
    449454 * @see delete_metadata() for full documentation excluding $meta_type variable.
     
    579584
    580585        // These should be extracted below.
    581         $recipients    = array();
    582         $email_subject = $email_content = '';
    583         $sender_id     = 0;
     586        $recipients = array();
     587        $sender_id  = 0;
    584588
    585589        // Barf.
     
    666670                );
    667671        }
    668 
    669         $user_data_to_export = array();
    670672
    671673        $user_threads = BP_Messages_Thread::get_current_threads_for_user( array(
     
    717719                                ),
    718720                                array(
    719                                         'name' => __( 'Recipients', 'buddypress' ),
     721                                        'name'  => __( 'Recipients', 'buddypress' ),
    720722                                        'value' => $recipients,
    721723                                ),
  • trunk/src/bp-messages/bp-messages-notifications.php

    r13035 r13096  
    120120                );
    121121
    122         // Custom notification action for the Messages component
     122        // Custom notification action for the Messages component.
    123123        } else {
    124124                if ( 'string' === $format ) {
     
    127127                        $retval = array(
    128128                                'text' => $text,
    129                                 'link' => $link
     129                                'link' => $link,
    130130                        );
    131131                }
     
    216216 *
    217217 * @since 1.9.0
     218 *
     219 * @global BP_Messages_Thread_Template $thread_template
    218220 */
    219221function bp_messages_screen_conversation_mark_notifications() {
     
    309311                        <tr>
    310312                                <th class="icon"></th>
    311                                 <th class="title"><?php _e( 'Messages', 'buddypress' ) ?></th>
    312                                 <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
    313                                 <th class="no"><?php _e( 'No', 'buddypress' )?></th>
     313                                <th class="title"><?php esc_html_e( 'Messages', 'buddypress' ); ?></th>
     314                                <th class="yes"><?php esc_html_e( 'Yes', 'buddypress' ); ?></th>
     315                                <th class="no"><?php esc_html_e( 'No', 'buddypress' ); ?></th>
    314316                        </tr>
    315317                </thead>
     
    318320                        <tr id="messages-notification-settings-new-message">
    319321                                <td></td>
    320                                 <td><?php _e( 'A member sends you a new message', 'buddypress' ) ?></td>
     322                                <td><?php esc_html_e( 'A member sends you a new message', 'buddypress' ); ?></td>
    321323                                <td class="yes"><input type="radio" name="notifications[notification_messages_new_message]" id="notification-messages-new-messages-yes" value="yes" <?php checked( $new_messages, 'yes', true ) ?>/><label for="notification-messages-new-messages-yes" class="bp-screen-reader-text"><?php
    322324                                        /* translators: accessibility text */
    323                                         _e( 'Yes, send email', 'buddypress' );
     325                                        esc_html_e( 'Yes, send email', 'buddypress' );
    324326                                ?></label></td>
    325327                                <td class="no"><input type="radio" name="notifications[notification_messages_new_message]" id="notification-messages-new-messages-no" value="no" <?php checked( $new_messages, 'no', true ) ?>/><label for="notification-messages-new-messages-no" class="bp-screen-reader-text"><?php
    326328                                        /* translators: accessibility text */
    327                                         _e( 'No, do not send email', 'buddypress' );
     329                                        esc_html_e( 'No, do not send email', 'buddypress' );
    328330                                ?></label></td>
    329331                        </tr>
  • trunk/src/bp-messages/bp-messages-star.php

    r12055 r13096  
    1111defined( 'ABSPATH' ) || exit;
    1212
    13 /** UTILITY **************************************************************/
     13/** UTILITY ****************************************************************/
    1414
    1515/**
     
    2121 */
    2222function bp_get_messages_starred_slug() {
     23
    2324        /**
    2425         * Filters the starred message slug.
     
    5152        $starred = array_flip( (array) bp_messages_get_meta( $mid, 'starred_by_user', false ) );
    5253
    53         if ( isset( $starred[$user_id] ) ) {
    54                 return true;
    55         } else {
    56                 return false;
    57         }
     54        return isset( $starred[ $user_id ] );
    5855}
    5956
     
    256253                'message_id' => 0,
    257254                'user_id'    => bp_displayed_user_id(),
    258                 'bulk'       => false
     255                'bulk'       => false,
    259256        ) );
    260257
  • trunk/src/bp-messages/bp-messages-template.php

    r12990 r13096  
    9494 * Check whether there are more threads to iterate over.
    9595 *
     96 * @global BP_Messages_Box_Template $messages_template
     97 *
    9698 * @return bool
    9799 */
     
    104106 * Set up the current thread inside the loop.
    105107 *
    106  * @return object
     108 * @global BP_Messages_Box_Template $messages_template
     109 *
     110 * @return BP_Messages_Thread
    107111 */
    108112function bp_message_thread() {
     
    120124         * Get the ID of the current thread in the loop.
    121125         *
     126         * @global BP_Messages_Box_Template $messages_template
     127         *
    122128         * @return int
    123129         */
     
    132138                 * @param int $thread_id ID of the current thread in the loop.
    133139                 */
    134                 return apply_filters( 'bp_get_message_thread_id', $messages_template->thread->thread_id );
     140                return apply_filters( 'bp_get_message_thread_id', (int) $messages_template->thread->thread_id );
    135141        }
    136142
     
    144150         * Get the subject of the current thread in the loop.
    145151         *
     152         * @global BP_Messages_Box_Template $messages_template
     153         *
    146154         * @return string
    147155         */
     
    168176         * Generate an excerpt from the current message in the loop.
    169177         *
     178         * @global BP_Messages_Box_Template $messages_template
     179         *
    170180         * @return string
    171181         */
     
    208218         * @since 2.0.0
    209219         *
     220         * @global BP_Messages_Box_Template $messages_template
     221         *
    210222         * @return string The raw content of the last message in the thread.
    211223         */
     
    232244         * Get a link to the page of the current thread's last author.
    233245         *
     246         * @global BP_Messages_Box_Template $messages_template
     247         *
    234248         * @return string
    235249         */
     
    256270         * Generate HTML links to the pages of the current thread's recipients.
    257271         *
     272         * @global BP_Messages_Box_Template $messages_template
     273         *
    258274         * @return string
    259275         */
     
    268284                 * @param string $value HTML links to the pages of the current thread's recipients.
    269285                 */
    270                 return apply_filters( 'bp_message_thread_to', BP_Messages_Thread::get_recipient_links($messages_template->thread->recipients ) );
     286                return apply_filters( 'bp_message_thread_to', BP_Messages_Thread::get_recipient_links( $messages_template->thread->recipients ) );
    271287        }
    272288
     
    288304         *
    289305         * @since 2.9.0 Introduced `$user_id` parameter.
     306         *
     307         * @global BP_Messages_Box_Template $messages_template
    290308         *
    291309         * @param int $thread_id Optional. ID of the thread. Default: current
     
    304322                }
    305323
    306                 if ( null === $user_id ) {
     324                if ( empty( $user_id ) ) {
    307325                        $user_id = bp_loggedin_user_id();
    308326                }
     
    329347 * @since 2.9.0 Introduced `$user_id` parameter.
    330348 *
    331  * @param int $user_id Optional. ID of the user relative to whom the link
    332  *                     should be generated. Default: ID of logged-in user.
     349 * @param int|null $user_id Optional. ID of the user relative to whom the link
     350 *                          should be generated. Default: ID of logged-in user.
    333351 */
    334352function bp_message_thread_delete_link( $user_id = null ) {
     
    340358         * @since 2.9.0 Introduced `$user_id` parameter.
    341359         *
    342          * @param int $user_id Optional. ID of the user relative to whom the link
    343          *                     should be generated. Default: ID of logged-in user.
     360         * @global BP_Messages_Box_Template $messages_template
     361         *
     362         * @param int|null $user_id Optional. ID of the user relative to whom the link
     363         *                          should be generated. Default: ID of logged-in user.
    344364         * @return string
    345365         */
     
    347367                global $messages_template;
    348368
    349                 if ( null === $user_id ) {
     369                if ( empty( $user_id ) ) {
    350370                        $user_id = bp_loggedin_user_id();
    351371                }
     
    372392 * @since 2.9.0 Introduced `$user_id` parameter.
    373393 *
    374  * @param int $user_id Optional. ID of the user relative to whom the link
    375  *                     should be generated. Default: ID of logged-in user.
     394 * @param int|null $user_id Optional. ID of the user relative to whom the link
     395 *                          should be generated. Default: ID of logged-in user.
    376396 */
    377397function bp_the_message_thread_mark_unread_url( $user_id = null ) {
     
    384404         * @since 2.9.0 Introduced `$user_id` parameter.
    385405         *
    386          * @param int $user_id Optional. ID of the user relative to whom the link
    387          *                     should be generated. Default: ID of logged-in user.
     406         * @param int|null $user_id Optional. ID of the user relative to whom the link
     407         *                          should be generated. Default: ID of logged-in user.
    388408         * @return string
    389409         */
     
    396416                $args = array(
    397417                        'action'     => 'unread',
    398                         'message_id' => $id
     418                        'message_id' => $id,
    399419                );
    400420
    401                 if ( null === $user_id ) {
     421                if ( empty( $user_id ) ) {
    402422                        $user_id = bp_loggedin_user_id();
    403423                }
     
    434454 * @since 2.9.0 Introduced `$user_id` parameter.
    435455 *
    436  * @param int $user_id Optional. ID of the user relative to whom the link
    437  *                     should be generated. Default: ID of logged-in user.
     456 * @param int|null $user_id Optional. ID of the user relative to whom the link
     457 *                          should be generated. Default: ID of logged-in user.
    438458 */
    439459function bp_the_message_thread_mark_read_url( $user_id = null ) {
     
    446466         * @since 2.9.0 Introduced `$user_id` parameter.
    447467         *
    448          * @param int $user_id Optional. ID of the user relative to whom the link
    449          *                     should be generated. Default: ID of logged-in user.
     468         * @param int|null $user_id Optional. ID of the user relative to whom the link
     469         *                          should be generated. Default: ID of logged-in user.
    450470         * @return string
    451471         */
     
    458478                $args = array(
    459479                        'action'     => 'read',
    460                         'message_id' => $id
     480                        'message_id' => $id,
    461481                );
    462482
    463                 if ( null === $user_id ) {
     483                if ( empty( $user_id ) ) {
    464484                        $user_id = bp_loggedin_user_id();
    465485                }
     
    484504                 * @param int    $user_id ID of the user relative to whom the link should be generated.
    485505                 */
    486                 return apply_filters( 'bp_get_the_message_thread_mark_read_url', $url );
     506                return apply_filters( 'bp_get_the_message_thread_mark_read_url', $url, $user_id );
    487507        }
    488508
     
    496516         * Generate the CSS class for the current thread.
    497517         *
     518         * @global BP_Messages_Box_Template $messages_template
     519         *
    498520         * @return string
    499521         */
     
    503525                $class = false;
    504526
    505                 if ( $messages_template->current_thread % 2 == 1 ) {
     527                if ( $messages_template->current_thread % 2 === 1 ) {
    506528                        $class .= 'alt';
    507529                }
     
    520542 * Check whether the current thread has unread items.
    521543 *
     544 * @global BP_Messages_Box_Template $messages_template
     545 *
    522546 * @return bool True if there are unread items, otherwise false.
    523547 */
     
    525549        global $messages_template;
    526550
    527         $retval = ! empty( $messages_template->thread->unread_count )
    528                 ? true
    529                 : false;
     551        $retval = ! empty( $messages_template->thread->unread_count );
    530552
    531553        /**
     
    547569        /**
    548570         * Get the current thread's unread count.
     571         *
     572         * @global BP_Messages_Box_Template $messages_template
    549573         *
    550574         * @return int
     
    564588                 * @param int $count Current thread unread count.
    565589                 */
    566                 return apply_filters( 'bp_get_message_thread_unread_count', $count );
     590                return apply_filters( 'bp_get_message_thread_unread_count', (int) $count );
    567591        }
    568592
     
    654678         * Get the unformatted date of the last post in the current thread.
    655679         *
     680         * @global BP_Messages_Box_Template $messages_template
     681         *
    656682         * @return string
    657683         */
     
    707733         * @see bp_core_fetch_avatar() For a description of arguments and
    708734         *      return values.
     735         *
     736         * @global BP_Messages_Box_Template $messages_template
    709737         *
    710738         * @param array|string $args {
     
    759787 * Output the unread messages count for the current inbox.
    760788 *
    761  * @since 2.6.x Added $user_id argument.
     789 * @since 2.6.x Added the `$user_id` paremeter.
    762790 *
    763791 * @param int $user_id The user ID.
    764  *
    765  * @return int $unread_count Total inbox unread count for user.
    766792 */
    767793function bp_total_unread_messages_count( $user_id = 0 ) {
     
    771797         * Get the unread messages count for the current inbox.
    772798         *
    773          * @since 2.6.x Added $user_id argument.
     799         * @since 2.6.x Added the `$user_id` paremeter.
    774800         *
    775801         * @param int $user_id The user ID.
     
    784810                 * @since 1.0.0
    785811                 *
    786                  * @param int $value Unread messages count for the current inbox.
    787                  */
    788                 return apply_filters( 'bp_get_total_unread_messages_count', BP_Messages_Thread::get_inbox_count( $user_id ) );
     812                 * @param int $value   Unread messages count for the current inbox.
     813                 * @param int $user_id ID of the user the messages are from.
     814                 */
     815                return apply_filters( 'bp_get_total_unread_messages_count', BP_Messages_Thread::get_inbox_count( $user_id ), $user_id );
    789816        }
    790817
     
    798825         * Get the pagination HTML for the current thread loop.
    799826         *
     827         * @global BP_Messages_Box_Template $messages_template
     828         *
    800829         * @return string
    801830         */
     
    815844/**
    816845 * Generate the "Viewing message x to y (of z messages)" string for a loop.
     846 *
     847 * @global BP_Messages_Box_Template $messages_template
    817848 */
    818849function bp_messages_pagination_count() {
     
    10581089 * @since 1.6.0
    10591090 *
     1091 * @global BP_Messages_Box_Template $messages_template
     1092 *
    10601093 * @return bool
    10611094 */
     
    10841117 * @since 1.0.0
    10851118 * @deprecated 1.6.0
    1086  * @return bool
    10871119 */
    10881120function bp_message_is_active_notice() {
     
    11121144 */
    11131145function bp_message_notice_id() {
    1114         echo (int) bp_get_message_notice_id();
     1146        echo bp_get_message_notice_id();
    11151147}
    11161148        /**
    11171149         * Get the ID of the current notice in the loop.
     1150         *
     1151         * @global BP_Messages_Box_Template $messages_template
    11181152         *
    11191153         * @return int
     
    11291163                 * @param int $id ID of the current notice in the loop.
    11301164                 */
    1131                 return apply_filters( 'bp_get_message_notice_id', $messages_template->thread->id );
     1165                return apply_filters( 'bp_get_message_notice_id', (int) $messages_template->thread->id );
    11321166        }
    11331167
     
    11411175         * Get the post date of the current notice in the loop.
    11421176         *
     1177         * @global BP_Messages_Box_Template $messages_template
     1178         *
    11431179         * @return string
    11441180         */
     
    11711207         * @since 5.0.0 The $notice parameter has been added.
    11721208         *
    1173          * @param BP_Messages_Notice $notice The notice object.
     1209         * @global BP_Messages_Box_Template $messages_template
     1210         *
     1211         * @param BP_Messages_Notice|null $notice The notice object.
    11741212         * @return string
    11751213         */
     
    12061244         * @since 5.0.0 The $notice parameter has been added.
    12071245         *
    1208          * @param BP_Messages_Notice $notice The notice object.
     1246         * @global BP_Messages_Box_Template $messages_template
     1247         *
     1248         * @param BP_Messages_Notice|null $notice The notice object.
    12091249         * @return string
    12101250         */
     
    12351275         * Get the URL for deleting the current notice.
    12361276         *
     1277         * @global BP_Messages_Box_Template $messages_template
     1278         *
    12371279         * @return string Delete URL.
    12381280         */
     
    12591301        /**
    12601302         * Get the URL for deactivating the current notice.
     1303         *
     1304         * @global BP_Messages_Box_Template $messages_template
    12611305         *
    12621306         * @return string
     
    12901334         * Generate the text ('Deactivate' or 'Activate') for the notice action link.
    12911335         *
     1336         * @global BP_Messages_Box_Template $messages_template
     1337         *
    12921338         * @return string
    12931339         */
     
    13151361 *
    13161362 * @since 9.0.0
    1317  * @return string URL for dismissing the current notice for the current user.
    13181363 */
    13191364function bp_message_notice_dismiss_link() {
     
    13851430
    13861431        if ( is_array( $closed_notices ) ) {
    1387                 if ( !in_array( $notice->id, $closed_notices ) && $notice->id ) {
     1432                if ( ! in_array( $notice->id, $closed_notices, true ) && $notice->id ) {
    13881433                        ?>
    13891434                        <div id="message" class="info notice" rel="n-<?php echo esc_attr( $notice->id ); ?>">
     
    15771622 * Initialize the messages template loop for a specific thread.
    15781623 *
     1624 * @global BP_Messages_Thread_Template $thread_template
     1625 *
    15791626 * @param array|string $args {
    15801627 *     Array of arguments. All are optional.
     
    16191666         * Get the 'ASC' or 'DESC' messages order string for this loop.
    16201667         *
     1668         * @global BP_Messages_Thread_Template $thread_template
     1669         *
    16211670         * @return string
    16221671         */
    16231672        function bp_get_thread_messages_order() {
    16241673                global $thread_template;
     1674
    16251675                return $thread_template->thread->messages_order;
    16261676        }
     
    16281678/**
    16291679 * Check whether there are more messages to iterate over.
     1680 *
     1681 * @global BP_Messages_Thread_Template $thread_template
    16301682 *
    16311683 * @return bool
     
    16401692 * Set up the current thread inside the loop.
    16411693 *
    1642  * @return object
     1694 * @global BP_Messages_Thread_Template $thread_template
     1695 *
     1696 * @return BP_Messages_Message
    16431697 */
    16441698function bp_thread_the_message() {
     
    16571711         * Get the ID of the thread that the current loop belongs to.
    16581712         *
     1713         * @global BP_Messages_Thread_Template $thread_template
     1714         *
    16591715         * @return int
    16601716         */
     
    16801736        /**
    16811737         * Get the subject of the thread currently being iterated over.
     1738         *
     1739         * @global BP_Messages_Thread_Template $thread_template
    16821740         *
    16831741         * @return string
     
    17131771        }
    17141772
     1773        /**
     1774         * Filters the thread recipients.
     1775         *
     1776         * @since 10.0.0
     1777         *
     1778         * @param string $recipients List of thread recipients.
     1779         */
    17151780        return apply_filters( 'bp_get_the_thread_recipients', $recipients );
    17161781}
     
    17201785 *
    17211786 * @since 2.2.0
     1787 *
     1788 * @global BP_Messages_Thread_Template $thread_template
    17221789 *
    17231790 * @return int
     
    17251792function bp_get_thread_recipients_count() {
    17261793        global $thread_template;
     1794
    17271795        /**
    17281796         * Filters the total number of recipients in a thread.
     
    17651833         *
    17661834         * @since 2.2.0
     1835         *
     1836         * @global BP_Messages_Thread_Template $thread_template
    17671837         *
    17681838         * @return string
     
    18061876 */
    18071877function bp_the_thread_message_id() {
    1808         echo (int) bp_get_the_thread_message_id();
     1878        echo bp_get_the_thread_message_id();
    18091879}
    18101880        /**
     
    18121882         *
    18131883         * @since 1.9.0
     1884         *
     1885         * @global BP_Messages_Thread_Template $thread_template
    18141886         *
    18151887         * @return int
     
    18201892                $thread_message_id = isset( $thread_template->message->id )
    18211893                        ? (int) $thread_template->message->id
    1822                         : null;
     1894                        : 0;
    18231895
    18241896                /**
     
    18291901                 * @param int $thread_message_id ID of the current message in the thread.
    18301902                 */
    1831                 return apply_filters( 'bp_get_the_thread_message_id', $thread_message_id );
     1903                return (int) apply_filters( 'bp_get_the_thread_message_id', (int) $thread_message_id );
    18321904        }
    18331905
     
    18451917         * @since 2.1.0
    18461918         *
     1919         * @global BP_Messages_Thread_Template $thread_template
     1920         *
    18471921         * @return string
    18481922         */
     
    18591933
    18601934                // Whether the sender is the same as the logged-in user.
    1861                 if ( bp_loggedin_user_id() == $thread_template->message->sender_id ) {
     1935                if ( bp_loggedin_user_id() === $thread_template->message->sender_id ) {
    18621936                        $classes[] = 'sent-by-me';
    18631937                }
     
    18841958         * Get the CSS class used for message zebra striping.
    18851959         *
     1960         * @global BP_Messages_Thread_Template $thread_template
     1961         *
    18861962         * @return string
    18871963         */
     
    18891965                global $thread_template;
    18901966
    1891                 if ( $thread_template->current_message % 2 == 1 ) {
     1967                $class = 'odd';
     1968                if ( 1 === $thread_template->current_message % 2 ) {
    18921969                        $class = 'even alt';
    1893                 } else {
    1894                         $class = 'odd';
    18951970                }
    18961971
     
    19111986 */
    19121987function bp_the_thread_message_sender_id() {
    1913         echo (int) bp_get_the_thread_message_sender_id();
     1988        echo bp_get_the_thread_message_sender_id();
    19141989}
    19151990        /**
     
    19171992         *
    19181993         * @since 2.1.0
     1994         *
     1995         * @global BP_Messages_Thread_Template $thread_template
    19191996         *
    19201997         * @return int
     
    19482025        /**
    19492026         * Get the avatar for the current message sender.
     2027         *
     2028         * @global BP_Messages_Thread_Template $thread_template
    19502029         *
    19512030         * @param array|string $args {
     
    19982077         * @since 1.1.0
    19992078         *
     2079         * @global BP_Messages_Thread_Template $thread_template
     2080         *
    20002081         * @return string
    20012082         */
     
    20252106         *
    20262107         * @since 1.1.0
     2108         *
     2109         * @global BP_Messages_Thread_Template $thread_template
    20272110         *
    20282111         * @return string
     
    21222205         * @since 2.1.0
    21232206         *
     2207         * @global BP_Messages_Thread_Template $thread_template
    21242208         *
    21252209         * @return int
     
    21502234         *
    21512235         * @since 1.1.0
     2236         *
     2237         * @global BP_Messages_Thread_Template $thread_template
    21522238         *
    21532239         * @return string
     
    21832269 */
    21842270function bp_messages_embed() {
    2185         add_filter( 'embed_post_id',         'bp_get_the_thread_message_id' );
    2186         add_filter( 'bp_embed_get_cache',    'bp_embed_message_cache',      10, 3 );
     2271        add_filter( 'embed_post_id', 'bp_get_the_thread_message_id' );
     2272        add_filter( 'bp_embed_get_cache', 'bp_embed_message_cache', 10, 3 );
    21872273        add_action( 'bp_embed_update_cache', 'bp_embed_message_save_cache', 10, 3 );
    21882274}
  • trunk/src/bp-messages/bp-messages-widgets.php

    r11366 r13096  
    44 *
    55 * @package BuddyPress
    6  * @subpackage Messages
     6 * @subpackage MessagesWidgets
    77 * @since 1.9.0
    88 */
     
    1717 */
    1818function bp_messages_register_widgets() {
    19         add_action( 'widgets_init', function() { register_widget( 'BP_Messages_Sitewide_Notices_Widget' ); } );
     19        add_action(
     20                'widgets_init',
     21                function() {
     22                        register_widget( 'BP_Messages_Sitewide_Notices_Widget' );
     23                }
     24        );
    2025}
    2126add_action( 'bp_register_widgets', 'bp_messages_register_widgets' );
  • trunk/src/bp-messages/classes/class-bp-messages-box-template.php

    r12602 r13096  
    44 *
    55 * @package BuddyPress
    6  * @subpackage MessagesTemplate
     6 * @subpackage MessagesClasses
    77 * @since 1.5.0
    88 */
     
    4747         * The thread object currently being iterated on.
    4848         *
    49          * @var object
     49         * @var BP_Messages_Thread|bool
    5050         */
    5151        public $thread = false;
     
    105105         * @param array $args {
    106106         *     Array of arguments. See bp_has_message_threads() for full description.
    107          * }
     107         * }.
    108108         */
    109109        public function __construct( $args = array() ) {
     
    230230         */
    231231        public function has_threads() {
    232                 if ( $this->thread_count ) {
    233                         return true;
    234                 }
    235 
    236                 return false;
     232                return ( $this->thread_count );
    237233        }
    238234
     
    240236         * Set up the next member and iterate index.
    241237         *
    242          * @return object The next member to iterate over.
     238         * @return BP_Messages_Thread The next member to iterate over.
    243239         */
    244240        public function next_thread() {
    245241                $this->current_thread++;
    246                 $this->thread = $this->threads[$this->current_thread];
     242                $this->thread = $this->threads[ $this->current_thread ];
    247243
    248244                return $this->thread;
     
    270266         * @return bool True if there are more threads to show, otherwise false.
    271267         */
    272         function message_threads() {
     268        public function message_threads() {
    273269                if ( $this->current_thread + 1 < $this->thread_count ) {
    274270                        return true;
    275                 } elseif ( $this->current_thread + 1 == $this->thread_count ) {
     271                } elseif ( $this->current_thread + 1 === $this->thread_count ) {
    276272
    277273                        /**
     
    308304
    309305                        // Set up the last message data.
    310                         if ( count($this->thread->messages) > 1 ) {
     306                        if ( count( $this->thread->messages ) > 1 ) {
    311307                                if ( 'inbox' == $this->box ) {
    312308                                        foreach ( (array) $this->thread->messages as $key => $message ) {
     
    335331
    336332                // Loop has just started.
    337                 if ( 0 == $this->current_thread ) {
     333                if ( 0 === $this->current_thread ) {
    338334
    339335                        /**
  • trunk/src/bp-messages/classes/class-bp-messages-component.php

    r13093 r13096  
    66 *
    77 * @package BuddyPress
    8  * @subpackage MessagesLoader
     8 * @subpackage MessagesClasses
    99 * @since 1.5.0
    1010 */
  • trunk/src/bp-messages/classes/class-bp-messages-message.php

    r11307 r13096  
    1515 */
    1616class BP_Messages_Message {
     17
    1718        /**
    1819         * ID of the message.
     
    8081        /**
    8182         * Set up data related to a specific message object.
     83         *
     84         * @global BuddyPress $bp The one true BuddyPress instance.
     85         * @global wpdb $wpdb WordPress database object.
    8286         *
    8387         * @param int $id ID of the message.
     
    101105         * Send a message.
    102106         *
     107         * @global BuddyPress $bp The one true BuddyPress instance.
     108         * @global wpdb $wpdb WordPress database object.
     109         *
    103110         * @return int|bool ID of the newly created message on success, false on failure.
    104111         */
     
    180187         * Get a list of recipients for a message.
    181188         *
     189         * @global BuddyPress $bp The one true BuddyPress instance.
     190         * @global wpdb $wpdb WordPress database object.
     191         *
    182192         * @return object $value List of recipients for a message.
    183193         */
     
    221231                 * @since 2.8.0
    222232                 *
    223                  * @param array $recipient_ids Array of recipients IDs that were retrieved based on submitted usernames.
     233                 * @param array $recipient_ids       Array of recipients IDs that were retrieved based on submitted usernames.
    224234                 * @param array $recipient_usernames Array of recipients usernames that were submitted by a user.
    225235                 */
     
    230240         * Get the ID of the message last sent by the logged-in user for a given thread.
    231241         *
     242         * @global BuddyPress $bp The one true BuddyPress instance.
     243         * @global wpdb $wpdb WordPress database object.
     244         *
    232245         * @param int $thread_id ID of the thread.
    233246         *
     
    246259        /**
    247260         * Check whether a user is the sender of a message.
     261         *
     262         * @global BuddyPress $bp The one true BuddyPress instance.
     263         * @global wpdb $wpdb WordPress database object.
    248264         *
    249265         * @param int $user_id ID of the user.
     
    266282         * Get the ID of the sender of a message.
    267283         *
     284         * @global BuddyPress $bp The one true BuddyPress instance.
     285         * @global wpdb $wpdb WordPress database object.
     286         *
    268287         * @param int $message_id ID of the message.
    269288         *
  • trunk/src/bp-messages/classes/class-bp-messages-notice.php

    r11293 r13096  
    1919 */
    2020class BP_Messages_Notice {
     21
    2122        /**
    2223         * The notice ID.
    2324         *
     25         * @var int|null
     26         */
     27        public $id = null;
     28
     29        /**
     30         * The subject line for the notice.
     31         *
     32         * @var string
     33         */
     34        public $subject;
     35
     36        /**
     37         * The content of the notice.
     38         *
     39         * @var string
     40         */
     41        public $message;
     42
     43        /**
     44         * The date the notice was created.
     45         *
     46         * @var string
     47         */
     48        public $date_sent;
     49
     50        /**
     51         * Whether the notice is active or not.
     52         *
    2453         * @var int
    2554         */
    26         public $id = null;
    27 
    28         /**
    29          * The subject line for the notice.
    30          *
    31          * @var string
    32          */
    33         public $subject;
    34 
    35         /**
    36          * The content of the notice.
    37          *
    38          * @var string
    39          */
    40         public $message;
    41 
    42         /**
    43          * The date the notice was created.
    44          *
    45          * @var string
    46          */
    47         public $date_sent;
    48 
    49         /**
    50          * Whether the notice is active or not.
    51          *
    52          * @var int
    53          */
    5455        public $is_active;
    5556
     
    6263         */
    6364        public function __construct( $id = null ) {
    64                 if ( $id ) {
     65                if ( ! empty( $id ) ) {
    6566                        $this->id = (int) $id;
    6667                        $this->populate();
     
    7273         *
    7374         * Runs during constructor.
     75         *
     76         * @global BuddyPress $bp The one true BuddyPress instance.
     77         * @global wpdb $wpdb WordPress database object.
    7478         *
    7579         * @since 1.0.0
     
    9397         * Saves a notice.
    9498         *
     99         * @global BuddyPress $bp The one true BuddyPress instance.
     100         * @global wpdb $wpdb WordPress database object.
     101         *
    95102         * @since 1.0.0
    96103         *
     
    174181         * Deletes a notice.
    175182         *
     183         * @global BuddyPress $bp The one true BuddyPress instance.
     184         * @global wpdb $wpdb WordPress database object.
     185         *
    176186         * @since 1.0.0
    177187         *
     
    215225         *
    216226         * To get all notices, pass a value of -1 to pag_num.
     227         *
     228         * @global BuddyPress $bp The one true BuddyPress instance.
     229         * @global wpdb $wpdb WordPress database object.
    217230         *
    218231         * @since 1.0.0
     
    223236         *     @type int $pag_page The page number.  Defaults to 1.
    224237         * }
    225          * @return object List of notices to display.
     238         * @return array List of notices to display.
    226239         */
    227240        public static function get_notices( $args = array() ) {
     
    253266                 * @since 2.8.0
    254267                 *
    255                  * @param array $r Array of parameters.
     268                 * @param array $notices List of notices sorted by date and paginated.
     269                 * @param array $r       Array of parameters.
    256270                 */
    257271                return apply_filters( 'messages_notice_get_notices', $notices, $r );
     
    261275         * Returns the total number of recorded notices.
    262276         *
     277         * @global BuddyPress $bp The one true BuddyPress instance.
     278         * @global wpdb $wpdb WordPress database object.
     279         *
    263280         * @since 1.0.0
    264281         *
     
    276293                 *
    277294                 * @since 2.8.0
    278                  */
    279                 return (int) apply_filters( 'messages_notice_get_total_notice_count', $notice_count );
     295                 *
     296                 * @param int $notice_count Total number of recorded notices.
     297                 */
     298                return apply_filters( 'messages_notice_get_total_notice_count', (int) $notice_count );
    280299        }
    281300
     
    283302         * Returns the active notice that should be displayed on the front end.
    284303         *
    285          * @since 1.0.0
    286          *
    287          * @return object The BP_Messages_Notice object.
     304         * @global BuddyPress $bp The one true BuddyPress instance.
     305         * @global wpdb $wpdb WordPress database object.
     306         *
     307         * @since 1.0.0
     308         *
     309         * @return BP_Messages_Notice
    288310         */
    289311        public static function get_active() {
     
    305327                 *
    306328                 * @since 2.8.0
     329                 *
     330                 * @param BP_Messages_Notice $notice The notice object.
    307331                 */
    308332                return apply_filters( 'messages_notice_get_active', $notice );
  • trunk/src/bp-messages/classes/class-bp-messages-notices-admin.php

    r12724 r13096  
    33 * BuddyPress messages component Site-wide Notices admin screen.
    44 *
    5  *
    65 * @package BuddyPress
    7  * @subpackage Messages
     6 * @subpackage MessagesClasses
    87 * @since 3.0.0
    98 */
     
    1211defined( 'ABSPATH' ) || exit;
    1312
     13/**
     14 * BuddyPress Notices Admin class.
     15 */
    1416class BP_Messages_Notices_Admin {
    1517
     
    3436         *
    3537         * @since 3.0.0
    36          * @var object
     38         * @var BP_Messages_Notices_List_Table|string
    3739         */
    3840        public $list_table = '';
    3941
    40 
    41         /**
    42      * Create a new instance or access the current instance of this class.
    43      *
    44      * @since 3.0.0
    45      */
     42        /**
     43         * Create a new instance or access the current instance of this class.
     44         *
     45         * @global BuddyPress $bp The one true BuddyPress instance.
     46         *
     47         * @since 3.0.0
     48         *
     49         * @return BP_Messages_Notices_Admin
     50         */
    4651        public static function register_notices_admin() {
    4752
     
    6065
    6166        /**
    62          * Constructor method.
     67         * Constructor.
    6368         *
    6469         * @since 3.0.0
  • trunk/src/bp-messages/classes/class-bp-messages-notices-list-table.php

    r12592 r13096  
    44 *
    55 * @package BuddyPress
    6  * @subpackage Messages
     6 * @subpackage MessagesClasses
    77 * @since 3.0.0
    88 */
     
    1616}
    1717
     18/**
     19 * BuddyPress Notices List Table class.
     20 */
    1821class BP_Messages_Notices_List_Table extends WP_List_Table {
    1922
     
    2225         *
    2326         * @since 3.0.0
     27         *
     28         * @param array $args Arguments passed to the WP_List_Table::constructor.
    2429         */
    2530        public function __construct( $args = array() ) {
  • trunk/src/bp-messages/classes/class-bp-messages-sitewide-notices-widget.php

    r12976 r13096  
    44 *
    55 * @package BuddyPress
    6  * @subpackage Messages
     6 * @subpackage MessagesClasses
    77 * @since 1.9.0
    88 */
     
    2424         * @since 9.0.0 Adds the `show_instance_in_rest` property to Widget options.
    2525         */
    26         function __construct() {
     26        public function __construct() {
    2727                parent::__construct(
    2828                        'bp_messages_sitewide_notices_widget',
     
    107107         *
    108108         * @param array $instance See {@WP_Widget::form()}.
    109          *
    110          * @return string|null Widget form output.
    111109         */
    112110        public function form( $instance ) {
  • trunk/src/bp-messages/classes/class-bp-messages-thread-template.php

    r10522 r13096  
    44 *
    55 * @package BuddyPress
    6  * @subpackage MessagesTemplate
     6 * @subpackage MessagesClasses
    77 * @since 1.5.0
    88 */
     
    101101         */
    102102        public function has_messages() {
    103                 if ( ! empty( $this->message_count ) ) {
    104                         return true;
    105                 }
    106 
    107                 return false;
     103                return ( ! empty( $this->message_count ) );
    108104        }
    109105
    110106        /**
    111          * Set up the next member and iterate index.
     107         * Set up the next message and iterate index.
    112108         *
    113          * @return object The next member to iterate over.
     109         * @return BP_Messages_Message The next message to iterate over.
    114110         */
    115111        public function next_message() {
  • trunk/src/bp-messages/classes/class-bp-messages-thread.php

    r13086 r13096  
    213213         */
    214214        public function mark_read() {
    215                 BP_Messages_Thread::mark_as_read( $this->thread_id );
     215                self::mark_as_read( $this->thread_id );
    216216        }
    217217
     
    224224         */
    225225        public function mark_unread() {
    226                 BP_Messages_Thread::mark_as_unread( $this->thread_id );
     226                self::mark_as_unread( $this->thread_id );
    227227        }
    228228
     
    232232         * @since 1.0.0
    233233         * @since 2.3.0 Added $thread_id as a parameter.
     234         *
     235         * @global BuddyPress $bp The one true BuddyPress instance.
     236         * @global wpdb $wpdb WordPress database object.
    234237         *
    235238         * @param int $thread_id The thread ID.
     
    283286         * @since 2.3.0
    284287         *
     288         * @global BuddyPress $bp The one true BuddyPress instance.
     289         * @global wpdb $wpdb WordPress database object.
     290         *
    285291         * @param int $thread_id The message thread ID.
    286292         *
    287          * @return object List of messages associated with a thread.
     293         * @return array List of messages associated with a thread.
    288294         */
    289295        public static function get_messages( $thread_id = 0 ) {
     
    334340         * @since 2.7.0 The $user_id parameter was added. Previously the current user
    335341         *              was always assumed.
     342         *
     343         * @global BuddyPress $bp The one true BuddyPress instance.
     344         * @global wpdb $wpdb WordPress database object.
    336345         *
    337346         * @param int $thread_id The message thread ID.
     
    428437         *
    429438         * @since 1.0.0
     439         *
     440         * @global BuddyPress $bp The one true BuddyPress instance.
     441         * @global wpdb $wpdb WordPress database object.
    430442         *
    431443         * @param array $args {
     
    593605         * @since 2.2.0
    594606         *
     607         * @global wpdb $wpdb WordPress database object.
     608         *
    595609         * @param array $meta_query An array of meta_query filters. See the
    596610         *                          documentation for WP_Meta_Query for details.
     
    624638         * @since 9.0.0 Added the `user_id` parameter.
    625639         *
     640         * @global BuddyPress $bp The one true BuddyPress instance.
     641         * @global wpdb $wpdb WordPress database object.
     642         *
    626643         * @param int $thread_id The message thread ID.
    627644         * @param int $user_id   The user the thread will be marked as read.
    628645         *
    629          * @return false|int Number of threads marked as read or false on error.
     646         * @return bool|int Number of threads marked as read or false on error.
    630647         */
    631648        public static function mark_as_read( $thread_id = 0, $user_id = 0 ) {
     
    665682         * @since 9.0.0 Added the `user_id` parameter.
    666683         *
     684         * @global BuddyPress $bp The one true BuddyPress instance.
     685         * @global wpdb $wpdb WordPress database object.
     686         *
    667687         * @param int $thread_id The message thread ID.
    668688         * @param int $user_id   The user the thread will be marked as unread.
    669689         *
    670          * @return false|int Number of threads marked as unread or false on error.
     690         * @return bool|int Number of threads marked as unread or false on error.
    671691         */
    672692        public static function mark_as_unread( $thread_id = 0, $user_id = 0 ) {
     
    690710                 *
    691711                 * @since 2.8.0
    692                  * @since 9.0.0 Added the `user_id` parameter.
    693                  *
    694                  * @param int $thread_id The message thread ID.
    695                  * @param int $user_id   The user the thread will be marked as unread.
     712                 * @since 9.0.0  Added the `$user_id` parameter.
     713                 * @since 10.0.0 Added the `$retval` parameter.
     714                 *
     715                 * @param int      $thread_id The message thread ID.
     716                 * @param int      $user_id   The user the thread will be marked as unread.
     717                 * @param bool|int $retval     =Number of threads marked as unread or false on error.
    696718                 */
    697                 do_action( 'messages_thread_mark_as_unread', $thread_id, $user_id );
     719                do_action( 'messages_thread_mark_as_unread', $thread_id, $user_id, $retval );
    698720
    699721                return $retval;
     
    710732         * @param string $type    The type of messages to get. Either 'all' or 'unread'.
    711733         *                        or 'read'. Defaults to 'all'.
    712          * @return int $value Total thread count for the provided user.
     734         * @return int Total thread count for the provided user.
    713735         */
    714736        public static function get_total_threads_for_user( $user_id, $box = 'inbox', $type = 'all' ) {
     
    736758         * @since 1.0.0
    737759         *
     760         * @global BuddyPress $bp The one true BuddyPress instance.
     761         * @global wpdb $wpdb WordPress database object.
     762         *
    738763         * @param int $thread_id The message thread ID.
    739764         * @return bool
     
    750775                }
    751776
    752                 return in_array( bp_loggedin_user_id(), $sender_ids );
     777                return in_array( bp_loggedin_user_id(), $sender_ids, true );
    753778        }
    754779
     
    757782         *
    758783         * @since 1.0.0
     784         *
     785         * @global BuddyPress $bp The one true BuddyPress instance.
     786         * @global wpdb $wpdb WordPress database object.
    759787         *
    760788         * @param int $thread_id The message thread ID.
     
    778806         * @since 1.0.0
    779807         *
     808         * @global BuddyPress $bp The one true BuddyPress instance.
     809         * @global wpdb $wpdb WordPress database object.
     810         *
    780811         * @param int $user_id The user ID.
    781          * @return int $unread_count Total inbox unread count for user.
     812         * @return int Total inbox unread count for user.
    782813         */
    783814        public static function get_inbox_count( $user_id = 0 ) {
     
    839870         *
    840871         * @param int $thread_id The message thread ID.
    841          * @return false|int|null The message thread ID on success, null on failure.
     872         * @return bool|int|null The message thread ID on success, null on failure.
    842873         */
    843874        public static function is_valid( $thread_id = 0 ) {
     
    868899         *
    869900         * @param array $recipients Array containing the message recipients (array of objects).
    870          * @return string $value String of message recipent userlinks.
     901         * @return string String of message recipent userlinks.
    871902         */
    872903        public static function get_recipient_links( $recipients ) {
     
    895926         * Upgrade method for the older BP message thread DB table.
    896927         *
     928         * @todo We should remove this. No one is going to upgrade from v1.1, right?
     929         *
    897930         * @since 1.2.0
    898931         *
    899          * @todo We should remove this.  No one is going to upgrade from v1.1, right?
     932         * @global BuddyPress $bp The one true BuddyPress instance.
     933         * @global wpdb $wpdb WordPress database object.
     934         *
    900935         * @return bool
    901936         */
  • trunk/src/bp-messages/screens/compose.php

    r11925 r13096  
    11<?php
    22/**
    3  * Messages: User's "Messages > Compose" screen handler
     3 * Messages: User's "Messages > Compose" screen handler.
    44 *
    55 * @package BuddyPress
  • trunk/src/bp-messages/screens/inbox.php

    r11925 r13096  
    11<?php
    22/**
    3  * Messages: User's "Messages" screen handler
     3 * Messages: User's "Messages" screen handler.
    44 *
    55 * @package BuddyPress
  • trunk/src/bp-messages/screens/notices.php

    r11925 r13096  
    11<?php
    22/**
    3  * Messages: User's "Messages > Notices" screen handler
     3 * Messages: User's "Messages > Notices" screen handler.
    44 *
    55 * @package BuddyPress
     
    1212 *
    1313 * @since 1.0.0
    14  *
    15  * @return false|null False on failure.
    1614 */
    1715function messages_screen_notices() {
  • trunk/src/bp-messages/screens/sentbox.php

    r11925 r13096  
    11<?php
    22/**
    3  * Messages: User's "Messages > Sent" screen handler
     3 * Messages: User's "Messages > Sent" screen handler.
    44 *
    55 * @package BuddyPress
  • trunk/src/bp-messages/screens/starred.php

    r12055 r13096  
    11<?php
    22/**
    3  * Messages: User's "Messages > Starred" screen handler
     3 * Messages: User's "Messages > Starred" screen handler.
    44 *
    55 * @package BuddyPress
  • trunk/src/bp-messages/screens/view.php

    r12592 r13096  
    11<?php
    22/**
    3  * Messages: Conversation thread screen handler
     3 * Messages: Conversation thread screen handler.
    44 *
    55 * @package BuddyPress
     
    1313 * @since 1.0.0
    1414 *
    15  * @return false|null False on failure.
     15 * @global BuddyPress $bp The one true BuddyPress instance.
     16 *
     17 * @return bool False on failure.
    1618 */
    1719function messages_screen_conversation() {
     
    5052
    5153        // Decrease the unread count in the nav before it's rendered.
    52         $count    = bp_get_total_unread_messages_count();
    53         $class    = ( 0 === $count ) ? 'no-count' : 'count';
     54        $count = bp_get_total_unread_messages_count();
     55        $class = ( 0 === $count ) ? 'no-count' : 'count';
    5456
    5557        /* translators: 1: class name. 2: number of messages */
Note: See TracChangeset for help on using the changeset viewer.