- Timestamp:
- 07/27/2020 07:33:55 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-members/classes/class-bp-core-members-template.php
r12663 r12692 115 115 * @see BP_User_Query for an in-depth description of parameters. 116 116 * 117 * @param string $type Sort order. 118 * @param int $page_number Page of results. 119 * @param int $per_page Number of results per page. 120 * @param int $max Max number of results to return. 121 * @param int $user_id Limit to friends of a user. 122 * @param string $search_terms Limit to users matching search terms. 123 * @param array $include Limit results by these user IDs. 124 * @param bool $populate_extras Fetch optional extras. 125 * @param array $exclude Exclude these IDs from results. 126 * @param array $meta_key Limit to users with a meta_key. 127 * @param array $meta_value Limit to users with a meta_value (with meta_key). 128 * @param string $page_arg Optional. The string used as a query parameter in pagination links. 129 * Default: 'upage'. 130 * @param array|string $member_type Array or comma-separated string of member types to limit results to. 131 * @param array|string $member_type__in Array or comma-separated string of member types to limit results to. 132 * @param array|string $member_type__not_in Array or comma-separated string of member types to exclude 133 * from results. 134 * @param array $xprofile_query Filter results by xprofile data. Requires the xprofile 135 * component. See {@see BP_XProfile_Query} for details. 136 */ 137 function __construct( $type, $page_number, $per_page, $max, $user_id, $search_terms, $include, $populate_extras, $exclude, $meta_key, $meta_value, $page_arg = 'upage', $member_type = '', $member_type__in = '', $member_type__not_in = '', $xprofile_query = false ) { 138 139 $this->pag_arg = sanitize_key( $page_arg ); 140 $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $page_number ); 141 $this->pag_num = bp_sanitize_pagination_arg( 'num', $per_page ); 142 $this->type = $type; 117 * @param array $args { 118 * Array of arguments. Supports all arguments of BP_User_Query. Additional 119 * arguments, or those with different defaults, are described below. 120 * 121 * @type int $page_number Page of results. Accepted for legacy reasons. Use 'page' instead. 122 * @type int $max Max number of results to return. 123 * @type string $page_arg Optional. The string used as a query parameter in pagination links. 124 * } 125 */ 126 public function __construct( $args ) { 127 // Backward compatibility with old method of passing arguments. 128 if ( ! is_array( $args ) || func_num_args() > 1 ) { 129 _deprecated_argument( __METHOD__, '7.0.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__ ) ); 130 131 $old_args_keys = array( 132 0 => 'type', 133 1 => 'page_number', 134 2 => 'per_page', 135 3 => 'max', 136 4 => 'user_id', 137 5 => 'search_terms', 138 6 => 'include', 139 7 => 'populate_extras', 140 8 => 'exclude', 141 9 => 'meta_key', 142 10 => 'meta_value', 143 11 => 'page_arg', 144 12 => 'member_type', 145 13 => 'member_type__in', 146 14 => 'member_type__not_in' 147 ); 148 149 $args = bp_core_parse_args_array( $old_args_keys, func_get_args() ); 150 } 151 152 // Support both 'page_number' and 'page' for backward compatibility. 153 $args['page_number'] = isset( $args['page_number'] ) ? $args['page_number'] : $args['page']; 154 155 $defaults = array( 156 'type' => 'active', 157 'page_number' => 1, 158 'per_page' => 20, 159 'max' => false, 160 'user_id' => false, 161 'search_terms' => null, 162 'include' => false, 163 'populate_extras' => true, 164 'exclude' => false, 165 'meta_key' => false, 166 'meta_value' => false, 167 'page_arg' => 'upage', 168 'member_type' => '', 169 'member_type__in' => '', 170 'member_type__not_in' => '', 171 'xprofile_query' => false, 172 ); 173 $r = wp_parse_args( $args, $defaults ); 174 175 $this->pag_arg = sanitize_key( $r['page_arg'] ); 176 $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $r['page_number'] ); 177 $this->pag_num = bp_sanitize_pagination_arg( 'num', $r['per_page'] ); 178 $this->type = $r['type']; 143 179 144 180 if ( ! empty( $_REQUEST['letter'] ) ) { 145 $this->members = BP_Core_User::get_users_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page, $ populate_extras, $exclude);181 $this->members = BP_Core_User::get_users_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page, $r['populate_extras'], $r['exclude'] ); 146 182 } else { 147 183 $this->members = bp_core_get_users( … … 150 186 'per_page' => $this->pag_num, 151 187 'page' => $this->pag_page, 152 'user_id' => $ user_id,153 'include' => $ include,154 'search_terms' => $ search_terms,155 'populate_extras' => $ populate_extras,156 'exclude' => $ exclude,157 'meta_key' => $ meta_key,158 'meta_value' => $ meta_value,159 'member_type' => $ member_type,160 'member_type__in' => $ member_type__in,161 'member_type__not_in' => $ member_type__not_in,162 'xprofile_query' => $ xprofile_query,188 'user_id' => $r['user_id'], 189 'include' => $r['include'], 190 'search_terms' => $r['search_terms'], 191 'populate_extras' => $r['populate_extras'], 192 'exclude' => $r['exclude'], 193 'meta_key' => $r['meta_key'], 194 'meta_value' => $r['meta_value'], 195 'member_type' => $r['member_type'], 196 'member_type__in' => $r['member_type__in'], 197 'member_type__not_in' => $r['member_type__not_in'], 198 'xprofile_query' => $r['xprofile_query'], 163 199 ) 164 200 ); 165 201 } 166 202 167 if ( ! $max || $max >= (int) $this->members['total'] )203 if ( ! $r['max'] || $r['max'] >= (int) $this->members['total'] ) { 168 204 $this->total_member_count = (int) $this->members['total']; 169 else 170 $this->total_member_count = (int) $max; 205 } else { 206 $this->total_member_count = (int) $r['max']; 207 } 171 208 172 209 $this->members = $this->members['users']; 173 210 174 if ( $ max) {175 if ( $ max>= count( $this->members ) ) {211 if ( $r['max'] ) { 212 if ( $r['max'] >= count( $this->members ) ) { 176 213 $this->member_count = count( $this->members ); 177 214 } else { 178 $this->member_count = (int) $ max;215 $this->member_count = (int) $r['max']; 179 216 } 180 217 } else { … … 200 237 $add_args = array(); 201 238 202 if ( ! empty( $ search_terms) ) {239 if ( ! empty( $r['search_terms'] ) ) { 203 240 $query_arg = bp_core_get_component_search_query_arg( 'members' ); 204 $add_args[ $query_arg ] = urlencode( $ search_terms);241 $add_args[ $query_arg ] = urlencode( $r['search_terms'] ); 205 242 } 206 243
Note: See TracChangeset
for help on using the changeset viewer.