Changeset 7559
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-notifications/bp-notifications-template.php
r7553 r7559 241 241 public function __construct( $args = array() ) { 242 242 243 // Parse arguments 243 244 $r = wp_parse_args( $args, array( 244 245 'user_id' => 0, … … 253 254 ) ); 254 255 256 // Overrides 257 258 // Set which pagination page 259 if ( isset( $_GET[ $r['page_arg'] ] ) ) { 260 $pag_page = intval( $_GET[ $r['page_arg'] ] ); 261 } else { 262 $pag_page = $r['page']; 263 } 264 265 // Set the number to show per page 266 if ( isset( $_GET['num'] ) ) { 267 $pag_num = intval( $_GET['num'] ); 268 } else { 269 $pag_num = intval( $r['per_page'] ); 270 } 271 272 // Sort order direction 273 $orders = array( 'ASC', 'DESC' ); 274 if ( ! empty( $_GET['sort_order'] ) && in_array( $_GET['sort_order'], $orders ) ) { 275 $sort_order = $_GET['sort_order']; 276 } else { 277 $sort_order = in_array( $r['sort_order'], $orders ) ? $r['sort_order'] : 'DESC'; 278 } 279 255 280 // Setup variables 256 $this->pag_page = isset( $_GET[ $r['page_arg'] ] ) ? intval( $_GET[ $r['page_arg'] ] ) : $r['page'];257 $this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : $r['per_page'];281 $this->pag_page = $pag_page; 282 $this->pag_num = $pag_num; 258 283 $this->user_id = $r['user_id']; 259 284 $this->is_new = $r['is_new']; … … 261 286 $this->page_arg = $r['page_arg']; 262 287 $this->order_by = $r['order_by']; 263 $this->sort_order = $ r['sort_order'];288 $this->sort_order = $sort_order; 264 289 265 290 // Get the notifications … … 304 329 'mid_size' => 1, 305 330 ) ); 331 332 // Remove first page from pagination 333 $this->pag_links = str_replace( '?' . $r['page_arg'] . '=1', '', $this->pag_links ); 334 $this->pag_links = str_replace( '&' . $r['page_arg'] . '=1', '', $this->pag_links ); 306 335 } 307 336 } … … 404 433 } 405 434 } 435 436 /** The Loop ******************************************************************/ 406 437 407 438 /** … … 489 520 } 490 521 522 /** Loop Output ***************************************************************/ 523 491 524 /** 492 525 * Output the ID of the notification currently being iterated on. … … 884 917 return apply_filters( 'bp_get_notifications_pagination_links', buddypress()->notifications->query_loop->pag_links ); 885 918 } 919 920 /** Form Helpers **************************************************************/ 921 922 /** 923 * Output the form for changing the sort order of notifications 924 * 925 * @since BuddyPress (1.9.0) 926 */ 927 function bp_notifications_sort_order_form() { 928 929 // Setup local variables 930 $orders = array( 'DESC', 'ASC' ); 931 $selected = 'DESC'; 932 933 // Check for a custom sort_order 934 if ( !empty( $_REQUEST['sort_order'] ) ) { 935 if ( in_array( $_REQUEST['sort_order'], $orders ) ) { 936 $selected = $_REQUEST['sort_order']; 937 } 938 } ?> 939 940 <form action="" method="get" id="notifications-sort-order"> 941 <label for="notifications-friends"><?php esc_html_e( 'Order By:', 'buddypress' ); ?></label> 942 943 <select id="notifications-sort-order-list" name="sort_order" onchange="this.form.submit();"> 944 <option value="DESC" <?php selected( $selected, 'DESC' ); ?>><?php _e( 'Newest First', 'buddypress' ); ?></option> 945 <option value="ASC" <?php selected( $selected, 'ASC' ); ?>><?php _e( 'Oldest First', 'buddypress' ); ?></option> 946 </select> 947 948 <noscript> 949 <input id="submit" type="submit" name="form-submit" class="submit" value="<?php _e( 'Go', 'buddypress' ); ?>" /> 950 </noscript> 951 </form> 952 953 <?php 954 } -
trunk/bp-templates/bp-legacy/buddypress/members/single/notifications.php
r7546 r7559 15 15 16 16 <li id="members-order-select" class="last filter"> 17 18 <label for="members-friends"><?php _e( 'Order By:', 'buddypress' ); ?></label> 19 <select id="members-friends"> 20 <option value="newest"><?php _e( 'Newest First', 'buddypress' ); ?></option> 21 <option value="oldest"><?php _e( 'Oldest First', 'buddypress' ); ?></option> 22 </select> 17 <?php bp_notifications_sort_order_form(); ?> 23 18 </li> 24 19 </ul>
Note: See TracChangeset
for help on using the changeset viewer.