Changeset 9183 for trunk/src/bp-messages/bp-messages-classes.php
- Timestamp:
- 11/26/2014 06:08:23 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-messages/bp-messages-classes.php
r9166 r9183 110 110 * @since BuddyPress (1.0.0) 111 111 * 112 * @param bool|int $thread_id The message thread ID. 113 * @param string $order The order to sort the messages. Either 'ASC' or 'DESC'. 114 */ 115 public function __construct( $thread_id = false, $order = 'ASC' ) { 112 * @see BP_Messages_Thread::populate() for full description of parameters 113 */ 114 public function __construct( $thread_id = false, $order = 'ASC', $args = array() ) { 116 115 if ( $thread_id ) { 117 $this->populate( $thread_id, $order );116 $this->populate( $thread_id, $order, $args ); 118 117 } 119 118 } … … 128 127 * @param int $thread_id The message thread ID. 129 128 * @param string $order The order to sort the messages. Either 'ASC' or 'DESC'. 129 * @param array $args { 130 * Array of arguments. 131 * @type bool $update_meta_cache Whether to pre-fetch metadata for 132 * queried message items. Default: true. 133 * } 130 134 * @return bool False on failure. 131 135 */ 132 public function populate( $thread_id , $order) {136 public function populate( $thread_id = 0, $order = 'ASC', $args = array() ) { 133 137 global $wpdb, $bp; 134 138 135 139 if( 'ASC' != $order && 'DESC' != $order ) { 136 $order= 'ASC'; 137 } 140 $order = 'ASC'; 141 } 142 143 // merge $args with our defaults 144 $r = wp_parse_args( $args, array( 145 'update_meta_cache' => true 146 ) ); 138 147 139 148 $this->messages_order = $order; … … 154 163 if ( isset( $this->recipients[bp_loggedin_user_id()] ) ) { 155 164 $this->unread_count = $this->recipients[bp_loggedin_user_id()]->unread_count; 165 } 166 167 // Grab all message meta 168 if ( true === (bool) $r['update_meta_cache'] ) { 169 bp_messages_update_meta_cache( wp_list_pluck( $this->messages, 'id' ) ); 156 170 } 157 171 … … 326 340 $threads = false; 327 341 foreach ( (array) $sorted_threads as $thread_id => $date_sent ) { 328 $threads[] = new BP_Messages_Thread( $thread_id ); 342 $threads[] = new BP_Messages_Thread( $thread_id, 'ASC', array( 343 'update_meta_cache' => false 344 ) ); 329 345 } 330 346
Note: See TracChangeset
for help on using the changeset viewer.