Ticket #6789: 6789.05.patch
| File 6789.05.patch, 22.6 KB (added by , 9 years ago) |
|---|
-
src/bp-xprofile/bp-xprofile-filters.php
diff --git a/src/bp-xprofile/bp-xprofile-filters.php b/src/bp-xprofile/bp-xprofile-filters.php index a0c9481..0d65ee2 100644
a b function xprofile_filter_kses( $content, $data_obj = null ) { 154 154 * Safely runs profile field data through kses and force_balance_tags. 155 155 * 156 156 * @since 1.2.6 157 * @since 2.9.0 The `$field_value` parameter accepts an array. 157 158 * 158 * @param string $field_value Field value being santized.159 * @param int $field_id FieldID being sanitized.160 * @param bool $reserialize Whether to reserialize arrays before returning. Defaults to true.161 * @param object|null $data_obj The BP_XProfile_ProfileData object.162 * @return string 159 * @param string|array $field_value Field value being santized. 160 * @param int $data_id Data ID being sanitized. 161 * @param bool $reserialize Whether to reserialize arrays before returning. Defaults to true. 162 * @param object|null $data_obj The BP_XProfile_ProfileData object. 163 * @return string|array 163 164 */ 164 function xprofile_sanitize_data_value_before_save( $field_value, $field_id = 0, $reserialize = true, $data_obj = null ) { 165 166 // Return if empty. 167 if ( empty( $field_value ) ) { 168 return $field_value; 169 } 165 function xprofile_sanitize_data_value_before_save( $field_value, $data_id = 0, $reserialize = true, $data_obj = null ) { 170 166 171 167 // Value might be serialized. 172 168 $field_value = maybe_unserialize( $field_value ); 173 169 170 // Return if empty. Special-case support for integer 0 for the number field type. 171 if ( empty( $field_value ) && ! is_integer( $field_value ) && $field_value !== '0' ) { 172 return $field_value; 173 } 174 174 175 // Filter single value. 175 if ( ! is_array( $field_value) ) {176 if ( ! $data_obj || ! bp_xprofile_field_supports_multiple_values( $data_obj->field_id ) ) { 176 177 $kses_field_value = xprofile_filter_kses( $field_value, $data_obj ); 177 178 $filtered_field_value = wp_rel_nofollow( force_balance_tags( $kses_field_value ) ); 178 179 … … function xprofile_sanitize_data_value_before_save( $field_value, $field_id = 0, 180 181 * Filters the kses-filtered data before saving to database. 181 182 * 182 183 * @since 1.5.0 184 * @since 2.9.0 The `$filtered_field_value` accepts an array. 183 185 * 184 * @param string $filtered_field_value The filtered value.186 * @param string|array $filtered_field_value The filtered value. 185 187 * @param string $field_value The original value before filtering. 186 188 * @param BP_XProfile_ProfileData $data_obj The BP_XProfile_ProfileData object. 187 189 */ 188 190 $filtered_field_value = apply_filters( 'xprofile_filtered_data_value_before_save', $filtered_field_value, $field_value, $data_obj ); 189 191 192 if ( ! empty( $reserialize ) ) { 193 $filtered_field_value = maybe_serialize( $filtered_field_value ); 194 } 195 190 196 // Filter each array item independently. 191 197 } else { 192 198 $filtered_values = array(); 193 199 foreach ( (array) $field_value as $value ) { 194 $kses_field_value = xprofile_filter_kses( $value, $data_obj ); 200 $unserialized_value = maybe_unserialize( $value ); 201 $kses_field_value = xprofile_filter_kses( $unserialized_value, $data_obj ); 195 202 $filtered_value = wp_rel_nofollow( force_balance_tags( $kses_field_value ) ); 196 203 197 204 /** This filter is documented in bp-xprofile/bp-xprofile-filters.php */ 198 205 $filtered_values[] = apply_filters( 'xprofile_filtered_data_value_before_save', $filtered_value, $value, $data_obj ); 199 200 206 } 201 207 202 if ( ! empty( $reserialize ) ) {203 $filtered_field_value = serialize($filtered_values );208 if ( ! empty( $reserialize ) ) { 209 $filtered_field_value = array_map( 'maybe_serialize', $filtered_values ); 204 210 } else { 205 211 $filtered_field_value = $filtered_values; 206 212 } -
src/bp-xprofile/bp-xprofile-functions.php
diff --git a/src/bp-xprofile/bp-xprofile-functions.php b/src/bp-xprofile/bp-xprofile-functions.php index 21ffe7b..d909d1c 100644
a b function xprofile_get_field_data( $field, $user_id = 0, $multi_format = 'array' 361 361 362 362 $values = maybe_unserialize( BP_XProfile_ProfileData::get_value_byid( $field_id, $user_id ) ); 363 363 364 if ( is_array( $values ) ) { 364 // Consider multiple values 365 if ( bp_xprofile_field_supports_multiple_values( $field_id ) ) { 366 $values = array_map( 'maybe_unserialize', $values ); 365 367 $data = array(); 366 368 foreach( (array) $values as $value ) { 367 369 … … function xprofile_set_field_data( $field, $user_id, $value, $is_required = false 461 463 return false; 462 464 } 463 465 464 $field = new BP_XProfile_ProfileData(); 465 $field->field_id = $field_id; 466 $field->user_id = $user_id; 467 $field->value = maybe_serialize( $value ); 466 $data = new BP_XProfile_ProfileData(); 467 $data->field_id = $field_id; 468 $data->user_id = $user_id; 468 469 469 return $field->save(); 470 // Consider multiple values 471 if ( bp_xprofile_field_supports_multiple_values( $field_id ) ) { 472 $data->value = array_map( 'maybe_serialize', $value ); 473 } else { 474 $data->value = maybe_serialize( $value ); 475 } 476 477 return $data->save(); 470 478 } 471 479 472 480 /** … … function xprofile_get_random_profile_data( $user_id, $exclude_fullname = true ) 638 646 * Formats a profile field according to its type. [ TODO: Should really be moved to filters ] 639 647 * 640 648 * @since 1.0.0 649 * @since 2.9.0 The `$field_value` parameter can be an array. 641 650 * 642 * @param string $field_type The type of field: datebox, selectbox, textbox etc.643 * @param string $field_value The actual value.651 * @param string $field_type The type of field: datebox, selectbox, textbox etc. 652 * @param string|array $field_value The actual value. 644 653 * @return string|bool The formatted value, or false if value is empty. 645 654 */ 646 655 function xprofile_format_profile_field( $field_type, $field_value ) { … … function bp_xprofile_is_richtext_enabled_for_field( $field_id = null ) { 1130 1139 } 1131 1140 1132 1141 /** 1142 * Does this profile field support multiple values? 1143 * 1144 * @since 2.9.0 1145 * 1146 * @param int|null $field_id Optional. Default current field ID. 1147 * @return bool Whether the field supports multiple values 1148 */ 1149 function bp_xprofile_field_supports_multiple_values( $field_id = null ) { 1150 if ( ! $field_id ) { 1151 $field_id = bp_get_the_profile_field_id(); 1152 } 1153 1154 $field = xprofile_get_field( $field_id, null, false ); 1155 1156 $supports = false; 1157 if ( $field instanceof BP_XProfile_Field ) { 1158 $supports = (bool) $field->type_obj->supports_multiple_values; 1159 } 1160 1161 /** 1162 * Filters whether the given field supports multiple values. 1163 * 1164 * @since 2.9.0 1165 * 1166 * @param bool $supports True if the field supports multiple values, otherwise false. 1167 * @param int $field_id ID of the field. 1168 */ 1169 return (bool) apply_filters( 'bp_xprofile_field_supports_multiple_values', $supports, $field_id ); 1170 } 1171 1172 /** 1133 1173 * Get visibility levels out of the $bp global. 1134 1174 * 1135 1175 * @since 1.6.0 -
src/bp-xprofile/bp-xprofile-template.php
diff --git a/src/bp-xprofile/bp-xprofile-template.php b/src/bp-xprofile/bp-xprofile-template.php index 63723da..ec7c791 100644
a b function bp_the_profile_field_visibility_level_label() { 907 907 * Return unserialized profile field data. 908 908 * 909 909 * @since 1.0.0 910 * @since 2.9.0 The `$value` parameter can be an array. 910 911 * 911 * @param string $value Content to maybe unserialize.912 * @param string|array $value Content to maybe unserialize. 912 913 * @return string 913 914 */ 914 915 function bp_unserialize_profile_field( $value ) { 915 if ( is_serialized( $value) ) {916 $field_value = maybe_unserialize( $value);916 if ( is_serialized( $value ) || is_array( $value ) ) { 917 $field_value = maybe_unserialize( $value ); 917 918 $field_value = implode( ', ', $field_value ); 918 919 return $field_value; 919 920 } -
src/bp-xprofile/classes/class-bp-xprofile-field-type-checkbox.php
diff --git a/src/bp-xprofile/classes/class-bp-xprofile-field-type-checkbox.php b/src/bp-xprofile/classes/class-bp-xprofile-field-type-checkbox.php index 7267ad9..a4a2167 100644
a b class BP_XProfile_Field_Type_Checkbox extends BP_XProfile_Field_Type { 28 28 $this->category = _x( 'Multi Fields', 'xprofile field type category', 'buddypress' ); 29 29 $this->name = _x( 'Checkboxes', 'xprofile field type', 'buddypress' ); 30 30 31 $this->supports_multiple_values = true; 31 32 $this->supports_multiple_defaults = true; 32 33 $this->accepts_null_value = true; 33 34 $this->supports_options = true; -
src/bp-xprofile/classes/class-bp-xprofile-field-type-multiselectbox.php
diff --git a/src/bp-xprofile/classes/class-bp-xprofile-field-type-multiselectbox.php b/src/bp-xprofile/classes/class-bp-xprofile-field-type-multiselectbox.php index 5ecaa10..af92d00 100644
a b class BP_XProfile_Field_Type_Multiselectbox extends BP_XProfile_Field_Type { 28 28 $this->category = _x( 'Multi Fields', 'xprofile field type category', 'buddypress' ); 29 29 $this->name = _x( 'Multi Select Box', 'xprofile field type', 'buddypress' ); 30 30 31 $this->supports_multiple_values = true; 31 32 $this->supports_multiple_defaults = true; 32 33 $this->accepts_null_value = true; 33 34 $this->supports_options = true; -
src/bp-xprofile/classes/class-bp-xprofile-field-type.php
diff --git a/src/bp-xprofile/classes/class-bp-xprofile-field-type.php b/src/bp-xprofile/classes/class-bp-xprofile-field-type.php index f282a82..75035dd 100644
a b abstract class BP_XProfile_Field_Type { 66 66 public $supports_options = false; 67 67 68 68 /** 69 * If allowed to store multiple values. 70 * 71 * @since 2.9.0 72 * @var bool Does this field support multiple values? e.g. multiselectbox, checkbox. 73 */ 74 public $supports_multiple_values = false; 75 76 /** 69 77 * If allowed to support multiple options as default. 70 78 * 71 79 * @since 2.0.0 -
src/bp-xprofile/classes/class-bp-xprofile-profiledata.php
diff --git a/src/bp-xprofile/classes/class-bp-xprofile-profiledata.php b/src/bp-xprofile/classes/class-bp-xprofile-profiledata.php index 62603e7..b6763c9 100644
a b class BP_XProfile_ProfileData { 89 89 $bp = buddypress(); 90 90 91 91 $sql = $wpdb->prepare( "SELECT * FROM {$bp->profile->table_name_data} WHERE field_id = %d AND user_id = %d", $field_id, $user_id ); 92 $profiledata = $wpdb->get_r ow( $sql );92 $profiledata = $wpdb->get_results( $sql ); 93 93 94 94 if ( $profiledata ) { 95 96 // Parse multiple values for the first field 97 if ( bp_xprofile_field_supports_multiple_values( $profiledata[0]->field_id ) ) { 98 $profiledata[0]->value = wp_list_pluck( $profiledata, 'value' ); 99 100 // Parse empty list 101 if ( array() === maybe_unserialize( $profiledata[0]->value ) ) { 102 $profiledata[0]->value = array(); 103 } 104 } 105 106 // Get the first row 107 $profiledata = $profiledata[0]; 95 108 wp_cache_set( $cache_key, $profiledata, 'bp_xprofile_data' ); 96 109 } 97 110 } … … class BP_XProfile_ProfileData { 100 113 $this->id = (int) $profiledata->id; 101 114 $this->user_id = (int) $profiledata->user_id; 102 115 $this->field_id = (int) $profiledata->field_id; 103 $this->value = stripslashes( $profiledata->value );116 $this->value = is_array( $profiledata->value ) ? array_map( 'stripslashes', $profiledata->value ) : stripslashes( $profiledata->value ); 104 117 $this->last_updated = $profiledata->last_updated; 105 118 106 119 } else { … … class BP_XProfile_ProfileData { 184 197 185 198 $bp = buddypress(); 186 199 187 $this->user_id = apply_filters( 'xprofile_data_user_id_before_save', $this->user_id, $this->id ); 188 $this->field_id = apply_filters( 'xprofile_data_field_id_before_save', $this->field_id, $this->id ); 189 $this->value = apply_filters( 'xprofile_data_value_before_save', $this->value, $this->id, true, $this ); 200 /** 201 * Filters the data's user ID before saving to the database. 202 * 203 * @since 1.0.0 204 * 205 * @param int $user_id The user ID. 206 * @param int $data_id The field data ID. 207 */ 208 $this->user_id = apply_filters( 'xprofile_data_user_id_before_save', $this->user_id, $this->id ); 209 210 /** 211 * Filters the data's field ID before saving to the database. 212 * 213 * @since 1.0.0 214 * 215 * @param int $field_id The field ID. 216 * @param int $data_id The field data ID. 217 */ 218 $this->field_id = apply_filters( 'xprofile_data_field_id_before_save', $this->field_id, $this->id ); 219 220 /** 221 * Filters the data's value before saving to the database. 222 * 223 * @since 1.0.0 224 * @since 2.1.0 Added `$reserialize` and `$this` parameters. 225 * 226 * @param string $field_value The field value. 227 * @param int $data_id The field data ID. 228 * @param bool $reserialize Whether to reserialize arrays before returning. Defaults to true. 229 * @param BP_XProfile_ProfileData $this Current instance of the profile data being saved. 230 */ 231 $this->value = apply_filters( 'xprofile_data_value_before_save', $this->value, $this->id, true, $this ); 232 233 /** 234 * Filters the data's last updated timestamp before saving to the database. 235 * 236 * @since 1.0.0 237 * 238 * @param int $last_updated The last updated timestamp. 239 * @param int $data_id The field data ID. 240 */ 190 241 $this->last_updated = apply_filters( 'xprofile_data_last_updated_before_save', bp_core_current_time(), $this->id ); 191 242 192 243 /** … … class BP_XProfile_ProfileData { 201 252 do_action_ref_array( 'xprofile_data_before_save', array( $this ) ); 202 253 203 254 if ( $this->is_valid_field() ) { 204 if ( $this->exists() && strlen( trim( $this->value ) ) ) { 255 256 // Special-case support for integer 0 for the number field type 257 $value_is_empty = empty( $this->value ) && ! is_integer( $this->value ) && '0' !== $this->value; 258 259 // Store as multiple values 260 if ( $this->exists() && bp_xprofile_field_supports_multiple_values( $this->field_id ) ) { 261 262 // Delete previous rows. 263 $this->delete(); 264 265 // Store empty list as serialized array 266 if ( empty( $this->value ) ) { 267 $this->value = array( serialize( array() ) ); 268 } 269 270 // Store each value in a separate row 271 foreach ( array_values( (array) $this->value ) as $k => $value ) { 272 $result = $wpdb->query( $wpdb->prepare("INSERT INTO {$bp->profile->table_name_data} (user_id, field_id, value, last_updated) VALUES (%d, %d, %s, %s)", $this->user_id, $this->field_id, $value, $this->last_updated ) ); 273 274 // Use the first inserted id as the new data identifier 275 if ( 0 === $k ) { 276 $this->id = $wpdb->insert_id; 277 } 278 } 279 280 // Store as single value 281 } elseif ( $this->exists() && ! $value_is_empty ) { 205 282 $result = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->profile->table_name_data} SET value = %s, last_updated = %s WHERE user_id = %d AND field_id = %d", $this->value, $this->last_updated, $this->user_id, $this->field_id ) ); 206 283 207 } elseif ( $this->exists() && empty( $this->value ) ) {208 // Data removed, delete the entry.284 // Data removed, delete the entry. 285 } elseif ( $this->exists() && $value_is_empty ) { 209 286 $result = $this->delete(); 210 287 211 } else {288 } elseif ( ! $value_is_empty ) { 212 289 $result = $wpdb->query( $wpdb->prepare("INSERT INTO {$bp->profile->table_name_data} (user_id, field_id, value, last_updated) VALUES (%d, %d, %s, %s)", $this->user_id, $this->field_id, $this->value, $this->last_updated ) ); 213 290 $this->id = $wpdb->insert_id; 214 291 } … … class BP_XProfile_ProfileData { 299 376 // Rekey. 300 377 $queried_data = array(); 301 378 foreach ( $uncached_data as $ud ) { 302 $d = new stdClass; 303 $d->id = $ud->id; 304 $d->user_id = $ud->user_id; 305 $d->field_id = $ud->field_id; 306 $d->value = $ud->value; 307 $d->last_updated = $ud->last_updated; 308 309 $queried_data[ $ud->field_id ] = $d; 379 380 // Set initial field data 381 if ( ! isset( $queried_data[ $ud->field_id ] ) ) { 382 $d = new stdClass; 383 $d->id = $ud->id; 384 $d->user_id = $ud->user_id; 385 $d->field_id = $ud->field_id; 386 $d->last_updated = $ud->last_updated; 387 388 // Collect multiple values in array 389 // TODO: no stripslashing here? See ::populate() 390 if ( bp_xprofile_field_supports_multiple_values( $ud->field_id ) ) { 391 $d->value = ( array() === maybe_unserialize( $ud->value ) ) ? array() : array( $ud->value ); 392 } else { 393 $d->value = $ud->value; 394 } 395 396 $queried_data[ $ud->field_id ] = $d; 397 398 // Collect multiple values per field 399 } elseif ( bp_xprofile_field_supports_multiple_values( $ud->field_id ) ) { 400 // TODO: no stripslashing here? See ::populate() 401 $queried_data[ $ud->field_id ]->value[] = $ud->value; 402 } 310 403 } 311 404 312 405 // Set caches. … … class BP_XProfile_ProfileData { 325 418 $d->id = ''; 326 419 $d->user_id = $user_id; 327 420 $d->field_id = $field_id; 328 $d->value = '';421 $d->value = bp_xprofile_field_supports_multiple_values( $field_id ) ? array() : ''; 329 422 $d->last_updated = ''; 330 423 331 424 wp_cache_set( $cache_key, $d, 'bp_xprofile_data' ); … … class BP_XProfile_ProfileData { 405 498 * Get the user's field data id by the id of the xprofile field. 406 499 * 407 500 * @since 1.6.0 501 * @since 2.9.0 Returns the first/main data id in case of multiple values. 408 502 * 409 503 * @param int $field_id Field ID being queried for. 410 504 * @param int $user_id User ID associated with field. … … class BP_XProfile_ProfileData { 471 565 $bp = buddypress(); 472 566 $uncached_ids_sql = implode( ',', $uncached_ids ); 473 567 $queried_data = $wpdb->get_results( $wpdb->prepare( "SELECT id, user_id, field_id, value, last_updated FROM {$bp->profile->table_name_data} WHERE field_id = %d AND user_id IN ({$uncached_ids_sql})", $field_id ) ); 568 $multiple = bp_xprofile_field_supports_multiple_values( $field_id ); 474 569 475 570 // Rekey. 476 571 $qd = array(); 477 572 foreach ( $queried_data as $data ) { 478 $qd[ $data->user_id ] = $data; 573 574 // Set initial user data 575 if ( ! isset( $qd[ $data->user_id ] ) ) { 576 577 // Collect multiple values in array 578 if ( $multiple ) { 579 // TODO: no stripslashing here? See ::populate(). 580 $data->value = ( array() === maybe_unserialize( $data->value ) ) ? array() : array( $data->value ); 581 } 582 583 $qd[ $data->user_id ] = $data; 584 585 // Collect multiple values per field 586 } elseif ( $multiple ) { 587 // TODO: no stripslashing here? See ::populate(). 588 $qd[ $data->user_id ]->value[] = $data->value; 589 } 479 590 } 480 591 481 592 foreach ( $uncached_ids as $id ) { … … class BP_XProfile_ProfileData { 490 601 $d->id = ''; 491 602 $d->user_id = $id; 492 603 $d->field_id = $field_id; 493 $d->value = '';604 $d->value = $multiple ? array() : ''; 494 605 $d->last_updated = ''; 495 606 } 496 607 … … class BP_XProfile_ProfileData { 566 677 $field_sql .= $wpdb->prepare( "AND f.name = %s", $fields ); 567 678 } 568 679 569 $sql = $wpdb->prepare( "SELECT d.value, f.name FROM {$bp->profile->table_name_data} d, {$bp->profile->table_name_fields} f WHERE d.field_id = f.id AND d.user_id = %d AND f.parent_id = 0 $field_sql", $user_id );680 $sql = $wpdb->prepare( "SELECT d.value, f.name, f.id FROM {$bp->profile->table_name_data} d, {$bp->profile->table_name_fields} f WHERE d.field_id = f.id AND d.user_id = %d AND f.parent_id = 0 $field_sql", $user_id ); 570 681 $values = $wpdb->get_results( $sql ); 571 682 683 // TODO: checking for empty result/WP_Error, but not in other methods? 572 684 if ( empty( $values ) || is_wp_error( $values ) ) { 573 685 return false; 574 686 } … … class BP_XProfile_ProfileData { 579 691 for ( $i = 0, $count = count( $values ); $i < $count; ++$i ) { 580 692 for ( $j = 0; $j < count( $fields ); $j++ ) { 581 693 if ( $values[$i]->name == $fields[$j] ) { 582 $new_values[$fields[$j]] = $values[$i]->value; 694 $multiple = bp_xprofile_field_supports_multiple_values( $values[$i]->id ); 695 696 // TODO: no stripslashing here? See ::populate() 697 if ( ! isset( $new_values[ $fields[$j] ] ) ) { 698 if ( $multiple ) { 699 $new_values[$fields[$j]] = ( array() === $values[$i]->value ) ? array() : array( $values[$i]->value ); 700 } else { 701 $new_values[$fields[$j]] = $values[$i]->value; 702 } 703 } elseif ( $multiple ) { 704 $new_values[$fields[$j]][] = $values[$i]->value; 705 } 583 706 } elseif ( !array_key_exists( $fields[$j], $new_values ) ) { 584 707 $new_values[$fields[$j]] = NULL; 585 708 } 586 709 } 587 710 } 588 711 } else { 589 $new_values = $values[0]->value; 712 713 // Collect multiple values in array 714 // TODO: no stripslashing here? See ::populate() 715 if ( bp_xprofile_field_supports_multiple_values( $values[0]->id ) ) { 716 $new_values = wp_list_pluck( $values, 'value' ); 717 718 // Parse empty list 719 if ( array() === maybe_unserialize( $new_values[0] ) ) { 720 $new_values = array(); 721 } 722 } else { 723 $new_values = $values[0]->value; 724 } 590 725 } 591 726 592 727 return $new_values; … … class BP_XProfile_ProfileData { 651 786 * 652 787 * @since 1.0.0 653 788 * 654 * @param int $user_id User ID to query for.655 * @param string $exclude_fullname SQL portion used to exclude by field ID.789 * @param int $user_id User ID to query for. 790 * @param bool $exclude_fullname Optional. Whether to exclude the fullname field. Defaults to false. 656 791 * @return array|null|object 657 792 */ 658 public static function get_random( $user_id, $exclude_fullname ) {793 public static function get_random( $user_id, $exclude_fullname = false ) { 659 794 global $wpdb; 660 795 661 796 $exclude_sql = ! empty( $exclude_fullname ) ? ' AND pf.id != 1' : ''; 662 797 663 798 $bp = buddypress(); 664 799 665 return $wpdb->get_results( $wpdb->prepare( "SELECT pf.type, pf.name, pd.value FROM {$bp->profile->table_name_data} pd INNER JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id AND pd.user_id = %d {$exclude_sql} ORDER BY RAND() LIMIT 1", $user_id ) ); 800 $rand_sql = "SELECT id FROM {$bp->profile->table_name_fields} ORDER BY RAND() LIMIT 1"; 801 $result = $wpdb->get_results( $wpdb->prepare( "SELECT pf.type, pf.name, pd.value, pf.id FROM {$bp->profile->table_name_data} pd INNER JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id AND pd.user_id = %d {$exclude_sql} WHERE pf.id IN ($rand_sql)", $user_id ) ); 802 803 // Collect multiple values in array 804 if ( bp_xprofile_field_supports_multiple_values( $result[0]->id ) ) { 805 // TODO: no stripslashing here? See ::populate() 806 $result[0]->value = wp_list_pluck( $result, 'value' ); 807 808 // Parse empty list 809 if ( array() === maybe_unserialize( $result[0]->value ) ) { 810 $result[0]->value = array(); 811 } 812 813 $result = array( $result[0] ); 814 } 815 816 return $result; 666 817 } 667 818 668 819 /**
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)