<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[BuddyPress] [3248] branches/1.2/bp-xprofile/bp-xprofile-filters.php:
  xProfile filter clean-up(1.2 branch).</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd>3248</dd>
<dt>Author</dt> <dd>johnjamesjacoby</dd>
<dt>Date</dt> <dd>2010-09-10 23:10:55 +0000 (Fri, 10 Sep 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>xProfile filter clean-up(1.2 branch). Fixes #2603. Props Paul Gibbs, mariochampion.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branches12bpxprofilebpxprofilefiltersphp">branches/1.2/bp-xprofile/bp-xprofile-filters.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branches12bpxprofilebpxprofilefiltersphp"></a>
<div class="modfile"><h4>Modified: branches/1.2/bp-xprofile/bp-xprofile-filters.php (3247 => 3248)</h4>
<pre class="diff"><span>
<span class="info">--- branches/1.2/bp-xprofile/bp-xprofile-filters.php        2010-09-10 21:49:11 UTC (rev 3247)
+++ branches/1.2/bp-xprofile/bp-xprofile-filters.php        2010-09-10 23:10:55 UTC (rev 3248)
</span><span class="lines">@@ -1,57 +1,54 @@
</span><span class="cx"> &lt;?php
</span><span class="cx"> 
</span><span class="cx"> /* Apply WordPress defined filters */
</span><del>-add_filter( 'bp_get_the_profile_field_value', 'wp_filter_kses', 1 );
-add_filter( 'bp_get_the_profile_field_name', 'wp_filter_kses', 1 );
</del><span class="cx"> 
</span><del>-add_filter( 'bp_get_the_site_member_profile_data', 'wp_filter_kses', 1 );
-add_filter( 'xprofile_get_field_data', 'wp_filter_kses', 1 );
-add_filter( 'xprofile_field_name_before_save', 'wp_filter_kses', 1 );
-add_filter( 'xprofile_field_description_before_save', 'wp_filter_kses', 1 );
</del><ins>+add_filter( 'bp_get_the_profile_field_value',         'wp_filter_kses', 1 );
+add_filter( 'bp_get_the_profile_field_name',          'wp_filter_kses', 1 );
+add_filter( 'bp_get_the_site_member_profile_data',    'wp_filter_kses', 1 );
+add_filter( 'bp_get_the_profile_field_edit_value',    'wp_filter_kses', 1 );
+add_filter( 'bp_get_the_profile_field_description',   'wp_filter_kses', 1 );
</ins><span class="cx"> 
</span><del>-add_filter( 'bp_get_the_profile_field_edit_value', 'wp_filter_kses', 1 );
-add_filter( 'bp_get_the_profile_field_description', 'wp_filter_kses', 1 );
</del><ins>+add_filter( 'bp_get_the_profile_field_value',         'wptexturize'        );
+add_filter( 'bp_get_the_profile_field_value',         'convert_smilies', 2 );
+add_filter( 'bp_get_the_profile_field_value',         'convert_chars'      );
+add_filter( 'bp_get_the_profile_field_value',         'wpautop'            );
+add_filter( 'bp_get_the_profile_field_value',         'make_clickable'     );
+add_filter( 'bp_get_the_profile_field_value',         'force_balance_tags' );
</ins><span class="cx"> 
</span><del>-add_filter( 'xprofile_field_name_before_save', 'force_balance_tags' );
-add_filter( 'xprofile_field_description_before_save', 'force_balance_tags' );
</del><ins>+add_filter( 'bp_get_the_profile_field_value',         'stripslashes' );
+add_filter( 'bp_get_the_profile_field_edit_value',    'stripslashes' );
+add_filter( 'bp_get_the_profile_field_name',          'stripslashes' );
+add_filter( 'bp_get_the_profile_field_description',   'stripslashes' );
+add_filter( 'bp_get_the_site_member_profile_data',    'stripslashes' );
</ins><span class="cx"> 
</span><del>-add_filter( 'bp_get_the_profile_field_value', 'wptexturize' );
-add_filter( 'bp_get_the_profile_field_value', 'convert_smilies', 2 );
-add_filter( 'bp_get_the_profile_field_value', 'convert_chars' );
-add_filter( 'bp_get_the_profile_field_value', 'wpautop' );
-add_filter( 'bp_get_the_profile_field_value', 'make_clickable' );
-add_filter( 'bp_get_the_profile_field_value', 'force_balance_tags' );
</del><ins>+add_filter( 'xprofile_get_field_data',                'wp_filter_kses', 1 );
+add_filter( 'xprofile_field_name_before_save',        'wp_filter_kses', 1 );
+add_filter( 'xprofile_field_description_before_save', 'wp_filter_kses', 1 );
+add_filter( 'xprofile_data_value_before_save',        'wp_filter_kses', 1 );
</ins><span class="cx"> 
</span><del>-add_filter( 'bp_get_the_site_member_profile_data', 'wptexturize' );
-add_filter( 'bp_get_the_site_member_profile_data', 'convert_smilies', 2 );
-add_filter( 'bp_get_the_site_member_profile_data', 'convert_chars' );
-add_filter( 'bp_get_the_site_member_profile_data', 'make_clickable' );
-add_filter( 'bp_get_the_site_member_profile_data', 'force_balance_tags' );
</del><ins>+add_filter( 'xprofile_get_field_data',                'force_balance_tags' );
+add_filter( 'xprofile_field_name_before_save',        'force_balance_tags' );
+add_filter( 'xprofile_field_description_before_save', 'force_balance_tags' );
+add_filter( 'xprofile_data_value_before_save',        'force_balance_tags' );
</ins><span class="cx"> 
</span><del>-add_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_format_field_value', 1, 2 );
-add_filter( 'bp_get_the_site_member_profile_data', 'xprofile_filter_format_field_value', 1, 2 );
-add_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 50, 2 );
</del><ins>+add_filter( 'xprofile_get_field_data',                'stripslashes' );
</ins><span class="cx"> 
</span><del>-add_filter( 'bp_get_the_profile_field_edit_value', 'stripslashes' );
-add_filter( 'bp_get_the_profile_field_value', 'stripslashes' );
-add_filter( 'bp_get_the_profile_field_name', 'stripslashes' );
-add_filter( 'xprofile_get_field_data', 'stripslashes' );
-add_filter( 'bp_get_the_profile_field_description', 'stripslashes' );
-add_filter( 'bp_get_the_site_member_profile_data', 'stripslashes' );
-
</del><span class="cx"> /* Custom BuddyPress filters */
</span><span class="cx"> 
</span><ins>+add_filter( 'bp_get_the_profile_field_value',         'xprofile_filter_format_field_value', 1, 2 );
+add_filter( 'bp_get_the_site_member_profile_data',    'xprofile_filter_format_field_value', 1, 2 );
+add_filter( 'bp_get_the_profile_field_value',         'xprofile_filter_link_profile_data', 50, 2 );
+
</ins><span class="cx"> function xprofile_filter_format_field_value( $field_value, $field_type = '' ) {
</span><del>-        if ( !isset($field_value) || empty( $field_value ) )
</del><ins>+        if ( !isset( $field_value ) || empty( $field_value ) )
</ins><span class="cx">                 return false;
</span><span class="cx"> 
</span><del>-        if ( 'datebox' == $field_type ) {
</del><ins>+        if ( 'datebox' == $field_type )
</ins><span class="cx">                 $field_value = bp_format_time( $field_value, true );
</span><del>-        } else {
</del><ins>+        else
</ins><span class="cx">                 $field_value = str_replace(']]&gt;', ']]&amp;gt;', $field_value );
</span><del>-        }
</del><span class="cx"> 
</span><del>-        return stripslashes( stripslashes( $field_value ) );
</del><ins>+        return stripslashes( $field_value );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function xprofile_filter_link_profile_data( $field_value, $field_type = 'textbox' ) {
</span><span class="lines">@@ -67,14 +64,15 @@
</span><span class="cx">                 foreach ( (array)$values as $value ) {
</span><span class="cx">                         $value = trim( $value );
</span><span class="cx"> 
</span><del>-                        /* If the value is a URL, skip it and just make it clickable. */
</del><ins>+                        // If the value is a URL, skip it and just make it clickable.
</ins><span class="cx">                         if ( preg_match( '@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', $value ) ) {
</span><span class="cx">                                 $new_values[] = make_clickable( $value );
</span><span class="cx">                         } else {
</span><del>-                                if ( count( explode( ' ', $value ) ) &gt; 5 )
</del><ins>+                                if ( count( explode( ' ', $value ) ) &gt; 5 ) {
</ins><span class="cx">                                         $new_values[] = $value;
</span><del>-                                else
</del><ins>+                                } else {
</ins><span class="cx">                                         $new_values[] = '&lt;a href=&quot;' . site_url( BP_MEMBERS_SLUG ) . '/?s=' . strip_tags( $value ) . '&quot;&gt;' . $value . '&lt;/a&gt;';
</span><ins>+                                }
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="lines">@@ -86,8 +84,9 @@
</span><span class="cx"> 
</span><span class="cx"> function xprofile_filter_comments( $comments, $post_id ) {
</span><span class="cx">         foreach( (array)$comments as $comment ) {
</span><del>-                if ( $comment-&gt;user_id )
</del><ins>+                if ( $comment-&gt;user_id ) {
</ins><span class="cx">                         $user_ids[] = $comment-&gt;user_id;
</span><ins>+                }
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if ( empty( $user_ids ) )
</span><span class="lines">@@ -101,8 +100,9 @@
</span><span class="cx"> 
</span><span class="cx">         foreach( (array)$comments as $i =&gt; $comment ) {
</span><span class="cx">                 if ( !empty( $comment-&gt;user_id ) ) {
</span><del>-                        if ( !empty( $users[$comment-&gt;user_id] ) )
</del><ins>+                        if ( !empty( $users[$comment-&gt;user_id] ) ) {
</ins><span class="cx">                                 $comments[$i]-&gt;comment_author = $users[$comment-&gt;user_id];
</span><ins>+                        }
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -110,4 +110,4 @@
</span><span class="cx"> }
</span><span class="cx"> add_filter( 'comments_array', 'xprofile_filter_comments', 10, 2 );
</span><span class="cx"> 
</span><del>-?&gt;
</del><span class="cx">\ No newline at end of file
</span><ins>+?&gt;
</ins></span></pre>
</div>
</div>

</body>
</html>