Skip to:
Content

BuddyPress.org

Changeset 3248


Ignore:
Timestamp:
09/10/2010 11:10:55 PM (14 years ago)
Author:
johnjamesjacoby
Message:

xProfile filter clean-up(1.2 branch). Fixes #2603. Props Paul Gibbs, mariochampion.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.2/bp-xprofile/bp-xprofile-filters.php

    r2576 r3248  
    22
    33/* Apply WordPress defined filters */
    4 add_filter( 'bp_get_the_profile_field_value', 'wp_filter_kses', 1 );
    5 add_filter( 'bp_get_the_profile_field_name', 'wp_filter_kses', 1 );
    64
    7 add_filter( 'bp_get_the_site_member_profile_data', 'wp_filter_kses', 1 );
    8 add_filter( 'xprofile_get_field_data', 'wp_filter_kses', 1 );
    9 add_filter( 'xprofile_field_name_before_save', 'wp_filter_kses', 1 );
     5add_filter( 'bp_get_the_profile_field_value',         'wp_filter_kses', 1 );
     6add_filter( 'bp_get_the_profile_field_name',          'wp_filter_kses', 1 );
     7add_filter( 'bp_get_the_site_member_profile_data',    'wp_filter_kses', 1 );
     8add_filter( 'bp_get_the_profile_field_edit_value',    'wp_filter_kses', 1 );
     9add_filter( 'bp_get_the_profile_field_description',   'wp_filter_kses', 1 );
     10
     11add_filter( 'bp_get_the_profile_field_value',         'wptexturize'        );
     12add_filter( 'bp_get_the_profile_field_value',         'convert_smilies', 2 );
     13add_filter( 'bp_get_the_profile_field_value',         'convert_chars'      );
     14add_filter( 'bp_get_the_profile_field_value',         'wpautop'            );
     15add_filter( 'bp_get_the_profile_field_value',         'make_clickable'     );
     16add_filter( 'bp_get_the_profile_field_value',         'force_balance_tags' );
     17
     18add_filter( 'bp_get_the_profile_field_value',         'stripslashes' );
     19add_filter( 'bp_get_the_profile_field_edit_value',    'stripslashes' );
     20add_filter( 'bp_get_the_profile_field_name',          'stripslashes' );
     21add_filter( 'bp_get_the_profile_field_description',   'stripslashes' );
     22add_filter( 'bp_get_the_site_member_profile_data',    'stripslashes' );
     23
     24add_filter( 'xprofile_get_field_data',                'wp_filter_kses', 1 );
     25add_filter( 'xprofile_field_name_before_save',        'wp_filter_kses', 1 );
    1026add_filter( 'xprofile_field_description_before_save', 'wp_filter_kses', 1 );
     27add_filter( 'xprofile_data_value_before_save',        'wp_filter_kses', 1 );
    1128
    12 add_filter( 'bp_get_the_profile_field_edit_value', 'wp_filter_kses', 1 );
    13 add_filter( 'bp_get_the_profile_field_description', 'wp_filter_kses', 1 );
     29add_filter( 'xprofile_get_field_data',                'force_balance_tags' );
     30add_filter( 'xprofile_field_name_before_save',        'force_balance_tags' );
     31add_filter( 'xprofile_field_description_before_save', 'force_balance_tags' );
     32add_filter( 'xprofile_data_value_before_save',        'force_balance_tags' );
    1433
    15 add_filter( 'xprofile_field_name_before_save', 'force_balance_tags' );
    16 add_filter( 'xprofile_field_description_before_save', 'force_balance_tags' );
    17 
    18 add_filter( 'bp_get_the_profile_field_value', 'wptexturize' );
    19 add_filter( 'bp_get_the_profile_field_value', 'convert_smilies', 2 );
    20 add_filter( 'bp_get_the_profile_field_value', 'convert_chars' );
    21 add_filter( 'bp_get_the_profile_field_value', 'wpautop' );
    22 add_filter( 'bp_get_the_profile_field_value', 'make_clickable' );
    23 add_filter( 'bp_get_the_profile_field_value', 'force_balance_tags' );
    24 
    25 add_filter( 'bp_get_the_site_member_profile_data', 'wptexturize' );
    26 add_filter( 'bp_get_the_site_member_profile_data', 'convert_smilies', 2 );
    27 add_filter( 'bp_get_the_site_member_profile_data', 'convert_chars' );
    28 add_filter( 'bp_get_the_site_member_profile_data', 'make_clickable' );
    29 add_filter( 'bp_get_the_site_member_profile_data', 'force_balance_tags' );
    30 
    31 add_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_format_field_value', 1, 2 );
    32 add_filter( 'bp_get_the_site_member_profile_data', 'xprofile_filter_format_field_value', 1, 2 );
    33 add_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 50, 2 );
    34 
    35 add_filter( 'bp_get_the_profile_field_edit_value', 'stripslashes' );
    36 add_filter( 'bp_get_the_profile_field_value', 'stripslashes' );
    37 add_filter( 'bp_get_the_profile_field_name', 'stripslashes' );
    38 add_filter( 'xprofile_get_field_data', 'stripslashes' );
    39 add_filter( 'bp_get_the_profile_field_description', 'stripslashes' );
    40 add_filter( 'bp_get_the_site_member_profile_data', 'stripslashes' );
     34add_filter( 'xprofile_get_field_data',                'stripslashes' );
    4135
    4236/* Custom BuddyPress filters */
    4337
     38add_filter( 'bp_get_the_profile_field_value',         'xprofile_filter_format_field_value', 1, 2 );
     39add_filter( 'bp_get_the_site_member_profile_data',    'xprofile_filter_format_field_value', 1, 2 );
     40add_filter( 'bp_get_the_profile_field_value',         'xprofile_filter_link_profile_data', 50, 2 );
     41
    4442function xprofile_filter_format_field_value( $field_value, $field_type = '' ) {
    45     if ( !isset($field_value) || empty( $field_value ) )
     43    if ( !isset( $field_value ) || empty( $field_value ) )
    4644        return false;
    4745
    48     if ( 'datebox' == $field_type ) {
     46    if ( 'datebox' == $field_type )
    4947        $field_value = bp_format_time( $field_value, true );
    50     } else {
     48    else
    5149        $field_value = str_replace(']]>', ']]>', $field_value );
    52     }
    5350
    54     return stripslashes( stripslashes( $field_value ) );
     51    return stripslashes( $field_value );
    5552}
    5653
     
    6865            $value = trim( $value );
    6966
    70             /* If the value is a URL, skip it and just make it clickable. */
     67            // If the value is a URL, skip it and just make it clickable.
    7168            if ( preg_match( '@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', $value ) ) {
    7269                $new_values[] = make_clickable( $value );
    7370            } else {
    74                 if ( count( explode( ' ', $value ) ) > 5 )
     71                if ( count( explode( ' ', $value ) ) > 5 ) {
    7572                    $new_values[] = $value;
    76                 else
     73                } else {
    7774                    $new_values[] = '<a href="' . site_url( BP_MEMBERS_SLUG ) . '/?s=' . strip_tags( $value ) . '">' . $value . '</a>';
     75                }
    7876            }
    7977        }
     
    8785function xprofile_filter_comments( $comments, $post_id ) {
    8886    foreach( (array)$comments as $comment ) {
    89         if ( $comment->user_id )
     87        if ( $comment->user_id ) {
    9088            $user_ids[] = $comment->user_id;
     89        }
    9190    }
    9291
     
    102101    foreach( (array)$comments as $i => $comment ) {
    103102        if ( !empty( $comment->user_id ) ) {
    104             if ( !empty( $users[$comment->user_id] ) )
     103            if ( !empty( $users[$comment->user_id] ) ) {
    105104                $comments[$i]->comment_author = $users[$comment->user_id];
     105            }
    106106        }
    107107    }
Note: See TracChangeset for help on using the changeset viewer.