Ticket #1793: move_theme_content_cookies_to_ajax.patch
| File move_theme_content_cookies_to_ajax.patch, 13.6 KB (added by , 16 years ago) |
|---|
-
bp-blogs/bp-blogs-templatetags.php
# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: \\UBU\www\sandbox2\public_html\wp-content\plugins\buddypress # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process.
109 109 function bp_has_blogs( $args = '' ) { 110 110 global $bp, $blogs_template; 111 111 112 /***113 * Set the defaults based on the current page. Any of these will be overridden114 * if arguments are directly passed into the loop. Custom plugins should always115 * pass their parameters directly to the loop.116 */117 $type = 'active';118 $user_id = false;119 $page = 1;120 121 /* User filtering */122 if ( !empty( $bp->displayed_user->id ) || 'personal' == $_COOKIE['bp-blogs-scope'] )123 $user_id = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->id : $bp->loggedin_user->id;124 125 /* Action filtering */126 if ( !empty( $_COOKIE['bp-blogs-filter'] ) && '-1' != $_COOKIE['bp-blogs-filter'] )127 $type = $_COOKIE['bp-blogs-filter'];128 129 if ( !empty( $_COOKIE['bp-blogs-page'] ) && '-1' != $_COOKIE['bp-blogs-page'] )130 $page = $_COOKIE['bp-blogs-page'];131 132 112 $defaults = array( 133 'type' => $type,134 'page' => $page,113 'type' => 'active', 114 'page' => 1, 135 115 'per_page' => 20, 136 116 'max' => false, 137 117 138 'user_id' => $user_id, // Pass a user_id to limit to only blogs this user has higher than subscriber access to139 No newline at end of file 118 'user_id' => false, // Pass a user_id to limit to only blogs this user has higher than subscriber access to 119 No newline at end of file 140 120 'search_terms' => false // Pass search terms to filter on the blog title or description. 141 121 ); -
bp-core/bp-core-templatetags.php
117 117 function bp_has_members( $args = '' ) { 118 118 global $bp, $members_template; 119 119 120 /***121 * Set the defaults based on the current page. Any of these will be overridden122 * if arguments are directly passed into the loop. Custom plugins should always123 * pass their parameters directly to the loop.124 */125 $type = 'active';126 $user_id = false;127 $page = 1;128 129 /* User filtering */130 if ( !empty( $bp->displayed_user->id ) || 'personal' == $_COOKIE['bp-members-scope'] )131 $user_id = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->id : $bp->loggedin_user->id;132 133 /* Action filtering */134 if ( !empty( $_COOKIE['bp-members-filter'] ) && '-1' != $_COOKIE['bp-members-filter'] )135 $type = $_COOKIE['bp-members-filter'];136 137 if ( !empty( $_COOKIE['bp-members-page'] ) && '-1' != $_COOKIE['bp-members-page'] )138 $page = $_COOKIE['bp-members-page'];139 140 120 // type: active ( default ) | random | newest | popular | online | alphabetical 141 121 $defaults = array( 142 'type' => $type,143 'page' => $page,122 'type' => 'active', 123 'page' => 1, 144 124 'per_page' => 20, 145 125 'max' => false, 146 126 147 127 'include' => false, // Pass a user_id or comma separated list of user_ids to only show these users 148 128 149 'user_id' => $user_id, // Pass a user_id to only show friends of this user129 'user_id' => false, // Pass a user_id to only show friends of this user 150 130 'search_terms' => false, // Pass search_terms to filter users by their profile data 151 131 152 132 'populate_extras' => true // Fetch usermeta? Friend count, last active etc. … … 1399 1379 return apply_filters( 'bp_ajax_querystring', $bp->ajax_querystring ); 1400 1380 } 1401 1381 1382 function bp_set_ajax_querystring( $string ) { 1383 global $bp; 1384 1385 $bp->ajax_querystring = apply_filters( 'bp_set_ajax_querystring', $string ); 1386 } 1387 1388 No newline at end of file 1402 1389 /* Template is_() functions to determine the current page */ 1403 1390 1404 1391 function bp_is_active( $component ) { -
bp-forums/bp-forums-templatetags.php
155 155 function bp_has_forum_topics( $args = '' ) { 156 156 global $forum_template, $bp; 157 157 158 /***159 * Set the defaults based on the current page. Any of these will be overridden160 * if arguments are directly passed into the loop. Custom plugins should always161 * pass their parameters directly to the loop.162 */163 $type = 'newest';164 $user_id = false;165 $page = 1;166 167 /* User filtering */168 if ( !empty( $bp->displayed_user->id ) || 'personal' == $_COOKIE['bp-forums-scope'] )169 $user_id = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->id : $bp->loggedin_user->id;170 171 /* Action filtering */172 if ( !empty( $_COOKIE['bp-forums-filter'] ) && '-1' != $_COOKIE['bp-forums-filter'] )173 $type = $_COOKIE['bp-forums-filter'];174 175 if ( !empty( $_COOKIE['bp-forums-page'] ) && '-1' != $_COOKIE['bp-forums-page'] )176 $page = $_COOKIE['bp-forums-page'];177 178 158 $defaults = array( 179 'type' => $type,159 'type' => 'newest', 180 160 'forum_id' => false, 181 'user_id' => $user_id,182 'page' => $page,183 No newline at end of file 161 'user_id' => false, 162 'page' => 1, 163 No newline at end of file 184 164 'per_page' => 20, 185 165 'max' => false, -
bp-groups/bp-groups-templatetags.php
'no_stickies' => false,
170 170 function bp_has_groups( $args = '' ) { 171 171 global $groups_template, $bp; 172 172 173 /***174 * Set the defaults based on the current page. Any of these will be overridden175 * if arguments are directly passed into the loop. Custom plugins should always176 * pass their parameters directly to the loop.177 */178 $type = 'active';179 $user_id = false;180 $page = 1;181 182 /* User filtering */183 if ( !empty( $bp->displayed_user->id ) || 'personal' == $_COOKIE['bp-groups-scope'] )184 $user_id = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->id : $bp->loggedin_user->id;185 186 /* Action filtering */187 if ( !empty( $_COOKIE['bp-groups-filter'] ) && '-1' != $_COOKIE['bp-groups-filter'] )188 $type = $_COOKIE['bp-groups-filter'];189 190 if ( !empty( $_COOKIE['bp-groups-page'] ) && '-1' != $_COOKIE['bp-groups-page'] )191 $page = $_COOKIE['bp-groups-page'];192 193 173 $defaults = array( 194 'type' => $type,195 'page' => $page,174 'type' => 'active', 175 'page' => 1, 196 176 'per_page' => 20, 197 177 'max' => false, 198 178 199 'user_id' => $user_id, // Pass a user ID to limit to groups this user has joined200 No newline at end of file 179 'user_id' => false, // Pass a user ID to limit to groups this user has joined 180 No newline at end of file 201 181 'slug' => false, // Pass a group slug to only return that group 202 182 'search_terms' => false // Pass search terms to return only matching groups -
bp-themes/bp-default/_inc/ajax.php
);
9 9 * your own _inc/ajax.php file and add/remove AJAX functionality as you see fit. 10 10 */ 11 11 12 function bp_dtheme_ajax_querystring( $object = null ) { 13 global $bp; 14 15 /* Backwards and forwards compatibility */ 16 if ( empty( $object ) ) { 17 // no object? just return it 18 return apply_filters( 'bp_dtheme_ajax_querystring', bp_ajax_querystring() ); 19 } elseif ( 'activity' == $object ) { 20 // activity filtering not completed yet, but here is what the filter will be 21 $pre_filtered_querystring = apply_filters( 'bp_dtheme_ajax_querystring_activity_filter', bp_ajax_querystring() ); 22 return apply_filters( 'bp_dtheme_ajax_querystring', $pre_filtered_querystring ); 23 } 24 25 /* Handle content filtering for the THEME */ 26 $c_scope = 'bp-' . $object . '-scope'; 27 $c_filter = 'bp-' . $object . '-filter'; 28 29 $scope = ( !empty( $_COOKIE[$c_scope] ) ) ? $_COOKIE[$c_scope] : null; 30 $filter = ( !empty( $_COOKIE[$c_filter] ) && '-1' != $_COOKIE[$c_filter] ) ? $_COOKIE[$c_filter] : null; 31 32 $defaults = array( 33 'object' => $object, 34 'scope' => $scope, 35 'type' => $filter 36 ); 37 38 // Do pre-filtering 39 $r = wp_parse_args( bp_ajax_querystring(), $defaults ); 40 $pre_filtered_querystring = apply_filters( 'bp_dtheme_ajax_querystring_' . $object . '_filter', http_build_query($r) ); 41 42 // Return after global filter applied 43 return apply_filters( 'bp_dtheme_ajax_querystring', $pre_filtered_querystring ); 44 } 45 46 /* Personal filtering */ 47 function bp_dtheme_ajax_querystring_filter_personal( $query_string ) { 48 global $bp; 49 50 $r = wp_parse_args( $query_string ); 51 extract($r); 52 53 if ( !empty( $bp->displayed_user->id ) || 'personal' == $scope ) { 54 $r['user_id'] = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->id : $bp->loggedin_user->id; 55 return http_build_query($r); 56 } else { 57 return $query_string; 58 } 59 } 60 add_filter( 'bp_dtheme_ajax_querystring_groups_filter', 'bp_dtheme_ajax_querystring_filter_personal', 1 ); 61 add_filter( 'bp_dtheme_ajax_querystring_forums_filter', 'bp_dtheme_ajax_querystring_filter_personal', 1 ); 62 add_filter( 'bp_dtheme_ajax_querystring_members_filter', 'bp_dtheme_ajax_querystring_filter_personal', 1 ); 63 add_filter( 'bp_dtheme_ajax_querystring_blogs_filter', 'bp_dtheme_ajax_querystring_filter_personal', 1 ); 64 12 65 function bp_dtheme_object_filter() { 13 66 global $bp; 14 67 … … 30 83 $search_terms = false; 31 84 32 85 /* Build the querystring */ 33 if ( empty( $filter ) ) 34 $filter = 'active'; 86 $querystring_args = 87 array( 88 'object' => $object, 89 'scope' => $scope, 90 'filter' => empty( $filter ) ? 'active' : $filter, 91 'page' => empty( $page ) ? 1 : $page, 92 ); 35 93 36 $bp->ajax_querystring = 'type=' . $filter . '&page=' . $page;37 38 94 if ( !empty( $search_terms ) ) 39 $ bp->ajax_querystring .= '&search_terms=' .$search_terms;95 $querystring_args['search_terms'] = $search_terms; 40 96 41 if ( $scope == 'personal' || $bp->displayed_user->id ) { 42 $user_id = ( $bp->displayed_user->id ) ? $bp->displayed_user->id : $bp->loggedin_user->id; 43 $bp->ajax_querystring .= '&user_id=' . $user_id; 44 } 97 bp_set_ajax_querystring( apply_filters( 'bp_dtheme_ajax_querystring_content_filter', http_build_query($querystring_args), $extras ) ); 45 98 46 $bp->ajax_querystring = apply_filters( 'bp_dtheme_ajax_querystring_content_filter', $bp->ajax_querystring, $extras );47 48 99 locate_template( array( "$object/$object-loop.php" ), true ); 49 100 } 50 101 add_action( 'wp_ajax_members_filter', 'bp_dtheme_object_filter' ); … … 251 302 } 252 303 $query_string = implode( '&', $new_args ) . '&page=' . $page; 253 304 254 $bp->ajax_querystring = apply_filters( 'bp_dtheme_ajax_querystring_activity_filter', $query_string, $scope);255 $result['query_string'] = $bp->ajax_querystring;256 No newline at end of file 305 bp_set_ajax_querystring( apply_filters( 'bp_dtheme_ajax_querystring_activity_filter', $query_string, $scope ) ); 306 $result['query_string'] = bp_ajax_querystring(); 307 No newline at end of file 257 308 $result['feed_url'] = apply_filters( 'bp_dtheme_ajax_feed_url', $feed_url ); 258 309 -
bp-themes/bp-default/activity/activity-loop.php
/* Buffer the loop in the template to a var for JS to spit out. */
2 2 3 3 <?php do_action( 'bp_before_activity_loop' ) ?> 4 4 5 <?php if ( bp_has_activities( bp_ ajax_querystring() ) ) : ?>6 No newline at end of file 5 <?php if ( bp_has_activities( bp_dtheme_ajax_querystring( 'activity' ) ) ) : ?> 6 No newline at end of file 7 7 8 8 <?php /* Show pagination if JS is not enabled, since the "Load More" link will do nothing */ ?> -
bp-themes/bp-default/blogs/blogs-loop.php
<noscript>
2 2 3 3 <?php do_action( 'bp_before_blogs_loop' ) ?> 4 4 5 <?php if ( bp_has_blogs( bp_ ajax_querystring() ) ) : ?>5 <?php if ( bp_has_blogs( bp_dtheme_ajax_querystring( 'blogs' ) ) ) : ?> 6 6 7 7 <div class="pagination"> 8 8 -
bp-themes/bp-default/forums/forums-loop.php
1 <?php if ( bp_has_forum_topics( bp_ ajax_querystring() ) ) : ?>2 No newline at end of file 1 <?php if ( bp_has_forum_topics( bp_dtheme_ajax_querystring( 'forums' ) ) ) : ?> 2 No newline at end of file 3 3 4 4 <div class="pagination"> -
bp-themes/bp-default/groups/groups-loop.php
2 2 3 3 <?php do_action( 'bp_before_groups_loop' ) ?> 4 4 5 <?php if ( bp_has_groups( bp_ ajax_querystring() ) ) : ?>6 No newline at end of file 5 <?php if ( bp_has_groups( bp_dtheme_ajax_querystring( 'groups' ) ) ) : ?> 6 No newline at end of file 7 7 8 8 <div class="pagination"> -
bp-themes/bp-default/members/members-loop.php
2 2 3 3 <?php do_action( 'bp_before_members_loop' ) ?> 4 4 5 <?php if ( bp_has_members( bp_ ajax_querystring() ) ) : ?>6 No newline at end of file 5 <?php if ( bp_has_members( bp_dtheme_ajax_querystring( 'members' ) ) ) : ?> 6 No newline at end of file 7 7 8 8 <div class="pagination">