Changeset 13136
- Timestamp:
- 11/01/2021 06:13:15 PM (3 years ago)
- Location:
- trunk/src/bp-templates/bp-nouveau
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-templates/bp-nouveau/includes/ajax.php
r12908 r13136 4 4 * 5 5 * @since 3.0.0 6 * @version 8.0.06 * @version 10.0.0 7 7 */ 8 8 … … 22 22 } 23 23 24 if ( empty( $_POST['object'] ) ) { 25 wp_send_json_error(); 26 } 24 $post_vars = bp_parse_args( 25 $_POST, 26 array( 27 'action' => '', 28 'object' => '', 29 'scope' => '', 30 'filter' => '', 31 'nonce' => '', 32 'template' => '', 33 ) 34 ); 27 35 28 $object = sanitize_title( $ _POST['object'] );36 $object = sanitize_title( $post_vars['object'] ); 29 37 30 38 // Bail if object is not an active component to prevent arbitrary file inclusion. … … 34 42 35 43 // Nonce check! 36 if ( empty( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'bp_nouveau_' . $object ) ) {44 if ( ! $post_vars['nonce'] || ! wp_verify_nonce( $post_vars['nonce'], 'bp_nouveau_' . $object ) ) { 37 45 wp_send_json_error(); 38 46 } … … 42 50 if ( 'activity' === $object ) { 43 51 $scope = ''; 44 if ( ! empty( $_POST['scope'] )) {45 $scope = sanitize_text_field( $ _POST['scope'] );52 if ( $post_vars['scope'] ) { 53 $scope = sanitize_text_field( $post_vars['scope'] ); 46 54 } 47 55 … … 99 107 100 108 // Get the template path based on the 'template' variable via the AJAX request. 101 $template = isset( $_POST['template'] ) ? wp_unslash( $_POST['template'] ) : ''; 109 $template = ''; 110 if ( $post_vars['template'] ) { 111 $template = wp_unslash( $post_vars['template'] ); 112 } 102 113 103 114 switch ( $template ) { … … 141 152 ob_end_clean(); 142 153 154 /** 155 * Add additional info to the Ajax response. 156 * 157 * @since 10.0.0 158 * 159 * @param array $value An associative array with additional information to include in the Ajax response. 160 * @param array $post_vars An associative array containing the Ajax request arguments. 161 */ 162 $additional_info = apply_filters( "bp_nouveau_{$object}_ajax_object_template_response", array(), $post_vars ); 163 if ( $additional_info ) { 164 // Prevents content overrides. 165 if ( isset( $additional_info['contents'] ) ) { 166 unset( $additional_info['contents'] ); 167 } 168 169 $result = array_merge( $result, $additional_info ); 170 } 171 143 172 // Locate the object template. 144 173 wp_send_json_success( $result ); -
trunk/src/bp-templates/bp-nouveau/includes/members/functions.php
r12921 r13136 4 4 * 5 5 * @since 3.0.0 6 * @version 8.0.06 * @version 10.0.0 7 7 */ 8 8 … … 530 530 return $nav->get_primary(); 531 531 } 532 533 /** 534 * Includes additional information about the Members loop Ajax response. 535 * 536 * @since 10.0.0 537 * 538 * @param array $additional_info An associative array with additional information to include in the Ajax response. 539 * @param array $args The Ajax query arguments. 540 * @return array Additional information about the members loop. 541 */ 542 function bp_nouveau_members_loop_additional_info( $additional_info = array(), $args = array() ) { 543 if ( ! isset( $GLOBALS['members_template'] ) || ! $GLOBALS['members_template'] ) { 544 return $additional_info; 545 } 546 547 $members_template = $GLOBALS['members_template']; 548 549 if ( isset( $members_template->member_count ) && 'all' === $args['scope'] ) { 550 $additional_info['totalItems'] = bp_core_number_format( $members_template->member_count ); 551 $additional_info['navLabel'] = esc_html__( 'All Members', 'buddypress' ); 552 553 $nav_labels = array( 554 'active' => esc_html__( 'Active Members', 'buddypress' ), 555 'newest' => esc_html__( 'Newest Members', 'buddypress' ), 556 ); 557 558 if ( isset( $nav_labels[ $args['filter'] ] ) ) { 559 $additional_info['navLabel'] = $nav_labels[ $args['filter'] ]; 560 } 561 } 562 563 return $additional_info; 564 } 565 add_filter( 'bp_nouveau_members_ajax_object_template_response', 'bp_nouveau_members_loop_additional_info', 10, 2 ); -
trunk/src/bp-templates/bp-nouveau/js/buddypress-nouveau.js
r12890 r13136 307 307 } 308 308 309 $( self.objectNavParent + ' [data-bp-scope="' + data.scope + '"]' ).removeClass( 'loading' ); 309 var selectedObjectNavParent = $( self.objectNavParent + ' [data-bp-scope="' + data.scope + '"]' ); 310 311 selectedObjectNavParent.removeClass( 'loading' ); 312 313 if ( response.data && response.data.totalItems && response.data.navLabel ) { 314 selectedObjectNavParent.find( 'a' ).first().html( 315 response.data.navLabel + ' ' 316 ).append( $( '<span></span>' ).addClass( 'count' ).html( response.data.totalItems ) ); 317 } 310 318 311 319 if ( 'reset' !== data.method ) {
Note: See TracChangeset
for help on using the changeset viewer.