Skip to:
Content

BuddyPress.org

Changeset 11876


Ignore:
Timestamp:
03/04/2018 01:59:40 PM (9 years ago)
Author:
djpaul
Message:

Nouveau: fix AJAX template loading.

r11821 broke the loading of some AJAX templates in Nouveau. Specifically, the backward compatibility in it was focused only on the group_members special case from bp-legacy, but Nouveau uses the template parameter in more places.

Fixes #7689

Props boonebgorges

Location:
trunk/src/bp-templates/bp-nouveau
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-templates/bp-nouveau/includes/ajax.php

    r11858 r11876  
    8888        }
    8989
    90         // The template part can be overridden by the calling JS function.
    91         if ( ! empty( $_POST['template'] ) && 'groups/single/members' === $_POST['template'] && 'group_members' === $object ) {
    92                 $template_part = 'groups/single/members.php';
    93         } else {
    94                 $template_part = $object . '/' . $object . '-loop.php';
     90        // Get the template path based on the 'template' variable via the AJAX request.
     91        $template = isset( $_POST['template'] ) ? wp_unslash( $_POST['template'] ) : '';
     92
     93        switch ( $template ) {
     94                case 'group_members' :
     95                case 'groups/single/members' :
     96                        $template_part = 'groups/single/members-loop.php';
     97                break;
     98
     99                case 'group_requests' :
     100                        $template_part = 'groups/single/requests-loop.php';
     101                break;
     102
     103                case 'member_notifications' :
     104                        $template_part = 'members/single/notifications/notifications-loop.php';
     105                break;
     106
     107                default :
     108                        $template_part = $object . '/' . $object . '-loop.php';
     109                break;
    95110        }
    96111
  • trunk/src/bp-templates/bp-nouveau/js/buddypress-notifications.js

    r11686 r11876  
    101101                                search_terms        : search_terms,
    102102                                extras              : sort,
    103                                 page                : 1,
    104                                 template            : 'members/single/notifications/notifications-loop'
     103                                page                : 1
    105104                        } );
    106105                },
  • trunk/src/bp-templates/bp-nouveau/js/buddypress-nouveau.js

    r11686 r11876  
    327327                        if ( 'friends' === data.object || 'group_members' === data.object ) {
    328328                                data.object = 'members';
     329                                data.template = data.object;
    329330                        } else if ( 'group_requests' === data.object ) {
    330331                                data.object = 'groups';
     332                                data.template = 'group_requests';
     333                        } else if ( 'notifications' === data.object ) {
     334                                data.object = 'members';
     335                                data.template = 'member_notifications';
    331336                        }
    332337
    … …  
    431436                                        };
    432437
    433                                         if ( 'group_members' === object ) {
    434                                                 $.extend( queryData, { template: 'groups/single/members-loop' } );
    435                                         } else if ( 'group_requests' === object ) {
    436                                                 $.extend( queryData, { template: 'groups/single/requests-loop' } );
    437                                         } else if ( 'notifications' === object ) {
    438                                                 $.extend( queryData, { template: 'members/single/notifications/notifications-loop' } );
    439                                         }
    440 
    441438                                        // Populate the object list
    442439                                        self.objectRequest( queryData );
    … …  
    616613                        if ( $( '#buddypress [data-bp-search="' + object + '"] input[type=search]' ).length ) {
    617614                                search_terms = $( '#buddypress [data-bp-search="' + object + '"] input[type=search]' ).val();
    618                         }
    619 
    620                         // On the Groups Members page, we specify a template
    621                         if ( 'group_members' === object ) {
    622                                 template = 'groups/single/members-loop';
    623                         }
    624 
    625                         // On the Members notifications page, we specify a template
    626                         if ( 'notifications' === object ) {
    627                                 template = 'members/single/notifications/notifications-loop';
    628615                        }
    629616
    … …  
    663650                        if ( $( self.objectNavParent + ' [data-bp-object]' ).length ) {
    664651                                scope = $( self.objectNavParent + ' [data-bp-object="' + object + '"].selected' ).data( 'bp-scope' );
    665                         }
    666 
    667                         if ( 'group_members' === object ) {
    668                                 template = 'groups/single/members-loop';
    669                         }
    670 
    671                         if ( 'notifications' === object ) {
    672                                 template = 'members/single/notifications/notifications-loop';
    673652                        }
    674653
    … …  
    896875                        };
    897876
    898                         if ( 'group_members' === object ) {
    899                                 $.extend( queryData, { template: 'groups/single/members-loop' } );
    900                         } else if ( 'group_requests' === object ) {
    901                                 $.extend( queryData, { template: 'groups/single/requests-loop' } );
    902                         } else if ( 'notifications' === object ) {
    903                                 $.extend( queryData, { template: 'members/single/notifications/notifications-loop' } );
    904                         }
    905 
    906877                        // Request the page
    907878                        self.objectRequest( queryData );
Note: See TracChangeset for help on using the changeset viewer.