Changeset 7141 for trunk/bp-core/bp-core-classes.php
- Timestamp:
- 06/03/2013 05:12:54 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-classes.php
r7135 r7141 49 49 50 50 /** 51 * Unaltered params as passed to the constructor 52 * 53 * @since BuddyPress (1.8) 54 * @var array 55 */ 56 public $query_vars_raw = array(); 57 58 /** 51 59 * Array of variables to query with 52 60 * … … 120 128 */ 121 129 public function __construct( $query = null ) { 122 if ( ! empty( $query ) ) { 123 $this->query_vars = wp_parse_args( $query, array( 130 131 // Store the raw query vars for later access 132 $this->query_vars_raw = $query; 133 134 // Allow extending classes to register action/filter hooks 135 $this->setup_hooks(); 136 137 if ( ! empty( $this->query_vars_raw ) ) { 138 $this->query_vars = wp_parse_args( $this->query_vars_raw, array( 124 139 'type' => 'newest', 125 140 'per_page' => 0, … … 163 178 164 179 /** 180 * Allow extending classes to set up action/filter hooks 181 * 182 * When extending BP_User_Query, you may need to use some of its 183 * internal hooks to modify the output. It's not convenient to call 184 * add_action() or add_filter() in your class constructor, because 185 * BP_User_Query::__construct() contains a fair amount of logic that 186 * you may not want to override in your class. Define this method in 187 * your own class if you need a place where your extending class can 188 * add its hooks early in the query-building process. See 189 * BP_Group_Member_Query::setup_hooks() for an example. 190 * 191 * @since BuddyPress (1.8) 192 */ 193 public function setup_hooks() {} 194 195 /** 165 196 * Prepare the query for user_ids 166 197 * … … 285 316 286 317 // 'include' - User ids to include in the results 287 if ( false !== $include ) { 288 $include = wp_parse_id_list( $include ); 289 $include_ids = $wpdb->escape( implode( ',', (array) $include ) ); 318 $include = ! empty( $include ) ? wp_parse_id_list( $include ) : array(); 319 $include_ids = $this->get_include_ids( $include ); 320 if ( ! empty( $include_ids ) ) { 321 $include_ids = implode( ',', wp_parse_id_list( $include_ids ) ); 290 322 $sql['where'][] = "u.{$this->uid_name} IN ({$include_ids})"; 291 323 } … … 428 460 } 429 461 } 462 } 463 464 /** 465 * Fetches the ids of users to put in the IN clause of the main query 466 * 467 * By default, returns the value passed to it 468 * ($this->query_vars['include']). Having this abstracted into a 469 * standalone method means that extending classes can override the 470 * logic, parsing together their own user_id limits with the 'include' 471 * ids passed to the class constructor. See BP_Group_Member_Query for 472 * an example. 473 * 474 * @since BuddyPress (1.8) 475 * @param array Sanitized array of user ids, as passed to the 'include' 476 * parameter of the class constructor 477 * @return array The list of users to which the main query should be 478 * limited 479 */ 480 public function get_include_ids( $include = array() ) { 481 return $include; 430 482 } 431 483
Note: See TracChangeset
for help on using the changeset viewer.