- Timestamp:
- 11/13/2021 06:54:07 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-messages/classes/class-bp-messages-box-template.php
r13108 r13148 80 80 81 81 /** 82 * The number of items being requested per page.82 * The number of items (threads) being requested per page. 83 83 * 84 84 * @var int … … 112 112 // Backward compatibility with old method of passing arguments. 113 113 if ( ! is_array( $args ) || count( $function_args ) > 1 ) { 114 _deprecated_argument( __METHOD__, '2.2.0', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) ); 114 _deprecated_argument( 115 __METHOD__, 116 '2.2.0', 117 sprintf( 118 /* translators: 1: the name of the method. 2: the name of the file. */ 119 esc_html__( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), 120 __METHOD__, 121 __FILE__ 122 ) 123 ); 115 124 116 125 $old_args_keys = array( … … 121 130 4 => 'type', 122 131 5 => 'search_terms', 123 6 => 'page_arg' 132 6 => 'page_arg', 124 133 ); 125 134 … … 130 139 $args, 131 140 array( 132 'page' => 1, 133 'per_page' => 10, 134 'page_arg' => 'mpage', 135 'box' => 'inbox', 136 'type' => 'all', 137 'user_id' => bp_loggedin_user_id(), 138 'max' => false, 139 'search_terms' => '', 140 'meta_query' => array(), 141 'page' => 1, 142 'per_page' => 10, 143 'page_arg' => 'mpage', 144 'box' => 'inbox', 145 'type' => 'all', 146 'user_id' => bp_loggedin_user_id(), 147 'max' => false, 148 'search_terms' => '', 149 'meta_query' => array(), 150 'recipients_page' => null, 151 'recipients_per_page' => null, 152 'messages_page' => null, 153 'messages_per_page' => null, 141 154 ) 142 155 ); 143 156 144 157 $this->pag_arg = sanitize_key( $r['page_arg'] ); 145 $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $r['page'] 146 $this->pag_num = bp_sanitize_pagination_arg( 'num', 158 $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $r['page'] ); 159 $this->pag_num = bp_sanitize_pagination_arg( 'num', $r['per_page'] ); 147 160 $this->user_id = $r['user_id']; 148 161 $this->box = $r['box']; … … 151 164 152 165 if ( 'notices' === $this->box ) { 153 $this->threads = BP_Messages_Notice::get_notices( array( 154 'pag_num' => $this->pag_num, 155 'pag_page' => $this->pag_page 156 ) ); 166 $this->threads = BP_Messages_Notice::get_notices( 167 array( 168 'pag_num' => $this->pag_num, 169 'pag_page' => $this->pag_page, 170 ) 171 ); 157 172 } else { 158 $threads = BP_Messages_Thread::get_current_threads_for_user( array( 159 'user_id' => $this->user_id, 160 'box' => $this->box, 161 'type' => $this->type, 162 'limit' => $this->pag_num, 163 'page' => $this->pag_page, 164 'search_terms' => $this->search_terms, 165 'meta_query' => $r['meta_query'], 166 ) ); 173 $threads = BP_Messages_Thread::get_current_threads_for_user( 174 array( 175 'user_id' => $this->user_id, 176 'box' => $this->box, 177 'type' => $this->type, 178 'limit' => $this->pag_num, 179 'page' => $this->pag_page, 180 'search_terms' => $this->search_terms, 181 'meta_query' => $r['meta_query'], 182 'recipients_page' => $r['recipients_page'], 183 'recipients_per_page' => $r['recipients_per_page'], 184 'messages_page' => $r['messages_page'], 185 'messages_per_page' => $r['messages_per_page'], 186 ) 187 ); 167 188 168 189 $this->threads = isset( $threads['threads'] ) ? $threads['threads'] : array(); … … 170 191 } 171 192 172 if ( ! $this->threads ) {193 if ( ! $this->threads ) { 173 194 $this->thread_count = 0; 174 195 $this->total_thread_count = 0; … … 212 233 } 213 234 214 $this->pag_links = paginate_links( array( 215 'base' => add_query_arg( $pag_args, $base ), 216 'format' => '', 217 'total' => ceil( (int) $this->total_thread_count / (int) $this->pag_num ), 218 'current' => $this->pag_page, 219 'prev_text' => _x( '←', 'Message pagination previous text', 'buddypress' ), 220 'next_text' => _x( '→', 'Message pagination next text', 'buddypress' ), 221 'mid_size' => 1, 222 'add_args' => $add_args, 223 ) ); 235 $this->pag_links = paginate_links( 236 array( 237 'base' => add_query_arg( $pag_args, $base ), 238 'format' => '', 239 'total' => ceil( (int) $this->total_thread_count / (int) $this->pag_num ), 240 'current' => $this->pag_page, 241 'prev_text' => _x( '←', 'Message pagination previous text', 'buddypress' ), 242 'next_text' => _x( '→', 'Message pagination next text', 'buddypress' ), 243 'mid_size' => 1, 244 'add_args' => $add_args, 245 ) 246 ); 224 247 } 225 248 } … … 308 331 // Set up the last message data. 309 332 if ( count( $this->thread->messages ) > 1 ) { 310 if ( 'inbox' == $this->box ) {333 if ( 'inbox' === $this->box ) { 311 334 foreach ( (array) $this->thread->messages as $key => $message ) { 312 if ( bp_loggedin_user_id() != $message->sender_id ) {335 if ( bp_loggedin_user_id() !== $message->sender_id ) { 313 336 $last_message_index = $key; 314 337 break; 315 338 } 316 339 } 317 318 } elseif ( 'sentbox' == $this->box ) { 340 } elseif ( 'sentbox' === $this->box ) { 319 341 foreach ( (array) $this->thread->messages as $key => $message ) { 320 if ( bp_loggedin_user_id() == $message->sender_id ) {342 if ( bp_loggedin_user_id() === $message->sender_id ) { 321 343 $last_message_index = $key; 322 344 break;
Note: See TracChangeset
for help on using the changeset viewer.