- Timestamp:
- 01/08/2023 11:03:12 PM (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-messages/classes/class-bp-messages-thread.php
r13395 r13401 27 27 28 28 /** 29 * The current messages .29 * The current messages in the message thread. 30 30 * 31 31 * @since 1.0.0 … … 33 33 */ 34 34 public $messages; 35 36 /** 37 * The current messages count in the message thread. 38 * 39 * @since 12.0.0 40 * @var int 41 */ 42 public $messages_total_count; 35 43 36 44 /** … … 189 197 return false; 190 198 } 199 200 // Messages total count. 201 $this->messages_total_count = self::get_total_thread_message_count( $this->thread_id ); 191 202 192 203 $last_message_index = count( $this->messages ) - 1; … … 941 952 942 953 /** 954 * Returns the total number of messages in a thread. 955 * 956 * @since 12.0.0 957 * 958 * @global wpdb $wpdb WordPress database object. 959 * 960 * @param integer $thread_id The message thread ID. 961 * @return integer Total thread message count 962 */ 963 public static function get_total_thread_message_count( $thread_id ) { 964 global $wpdb; 965 966 $cache_key = "{$thread_id}_bp_messages_thread_total_count"; 967 $total_count = wp_cache_get( $cache_key, 'bp_messages_threads' ); 968 969 if ( false === $total_count ) { 970 $bp = buddypress(); 971 972 $total_count = (int) $wpdb->get_var( 973 $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->messages->table_name_messages} WHERE thread_id = %d", $thread_id ) 974 ); 975 976 wp_cache_set( $cache_key, $total_count, 'bp_messages_threads' ); 977 } 978 979 /** 980 * Thread messages count. 981 * 982 * @since 12.0.0 983 * 984 * @param integer $total_count Total thread messages count. 985 * @param integer $thread_id ID of the thread. 986 */ 987 return (int) apply_filters( 'messages_thread_get_total_message_count', $total_count, (int) $thread_id ); 988 } 989 990 /** 943 991 * Determine if the logged-in user is a sender of any message in a thread. 944 992 *
Note: See TracChangeset
for help on using the changeset viewer.