Skip to:
Content

BuddyPress.org

Ticket #5742: 5742.02.patch

File 5742.02.patch, 4.0 KB (added by needle, 12 years ago)
  • bp-xprofile/bp-xprofile-classes.php

     
    10971097
    10981098                $this->user_id      = apply_filters( 'xprofile_data_user_id_before_save',      $this->user_id,         $this->id );
    10991099                $this->field_id     = apply_filters( 'xprofile_data_field_id_before_save',     $this->field_id,        $this->id );
    1100                 $this->value        = apply_filters( 'xprofile_data_value_before_save',        $this->value,           $this->id );
     1100                $this->value        = apply_filters( 'xprofile_data_value_before_save',        $this->value,           $this->id, true, $this );
    11011101                $this->last_updated = apply_filters( 'xprofile_data_last_updated_before_save', bp_core_current_time(), $this->id );
    11021102
    11031103                do_action_ref_array( 'xprofile_data_before_save', array( $this ) );
  • bp-xprofile/bp-xprofile-filters.php

     
    5151add_filter( 'xprofile_get_field_data',                  'stripslashes' );
    5252add_filter( 'xprofile_get_field_data',                  'xprofile_filter_format_field_value_by_field_id', 5, 2 );
    5353
    54 add_filter( 'xprofile_data_value_before_save',          'xprofile_sanitize_data_value_before_save', 1, 2 );
     54add_filter( 'xprofile_data_value_before_save',          'xprofile_sanitize_data_value_before_save', 1, 4 );
    5555add_filter( 'xprofile_filtered_data_value_before_save', 'trim', 2 );
    5656
    5757/**
     
    6060 * Run profile field values through kses with filterable allowed tags.
    6161 *
    6262 * @param string $content
     63 * @param object $data_obj The BP_XProfile_ProfileData object
    6364 * @return string $content
    6465 */
    65 function xprofile_filter_kses( $content ) {
     66function xprofile_filter_kses( $content, $data_obj = null ) {
    6667        global $allowedtags;
    6768
    6869        $xprofile_allowedtags             = $allowedtags;
    6970        $xprofile_allowedtags['a']['rel'] = array();
    7071
    71         $xprofile_allowedtags = apply_filters( 'xprofile_allowed_tags', $xprofile_allowedtags );
     72        $xprofile_allowedtags = apply_filters( 'xprofile_allowed_tags', $xprofile_allowedtags, $data_obj );
    7273        return wp_kses( $content, $xprofile_allowedtags );
    7374}
    7475
     
    7879 * @param string $field_value
    7980 * @param int $field_id
    8081 * @param bool $reserialize Whether to reserialize arrays before returning. Defaults to true
     82 * @param object $data_obj The BP_XProfile_ProfileData object
    8183 * @return string
    8284 */
    83 function xprofile_sanitize_data_value_before_save( $field_value, $field_id = 0, $reserialize = true ) {
     85function xprofile_sanitize_data_value_before_save( $field_value, $field_id = 0, $reserialize = true, $data_obj = null ) {
    8486
    8587        // Return if empty
    8688        if ( empty( $field_value ) ) {
     
    9294
    9395        // Filter single value
    9496        if ( !is_array( $field_value ) ) {
    95                 $kses_field_value     = xprofile_filter_kses( $field_value );
     97                $kses_field_value     = xprofile_filter_kses( $field_value, $data_obj );
    9698                $filtered_field_value = wp_rel_nofollow( force_balance_tags( $kses_field_value ) );
    97                 $filtered_field_value = apply_filters( 'xprofile_filtered_data_value_before_save', $filtered_field_value, $field_value );
     99                $filtered_field_value = apply_filters( 'xprofile_filtered_data_value_before_save', $filtered_field_value, $field_value, $data_obj );
    98100
    99101        // Filter each array item independently
    100102        } else {
    101103                $filtered_values = array();
    102104                foreach ( (array) $field_value as $value ) {
    103                         $kses_field_value       = xprofile_filter_kses( $value );
     105                        $kses_field_value       = xprofile_filter_kses( $value, $data_obj );
    104106                        $filtered_value         = wp_rel_nofollow( force_balance_tags( $kses_field_value ) );
    105                         $filtered_values[] = apply_filters( 'xprofile_filtered_data_value_before_save', $filtered_value, $value );
     107                        $filtered_values[] = apply_filters( 'xprofile_filtered_data_value_before_save', $filtered_value, $value, $data_obj );
    106108
    107109                }
    108110