<!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, #msg p { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul { 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>[11784] trunk:
  Make it much easier to filter contact methods from user profiles adding and removing at will
 .</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/11784">11784</a></dd>
<dt>Author</dt> <dd>westi</dd>
<dt>Date</dt> <dd>2009-08-06 21:59:52 +0000 (Thu, 06 Aug 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>Make it much easier to filter contact methods from user profiles adding and removing at will. Fixes <a href="http://trac.wordpress.org/ticket/10240">#10240</a> props joostdevalk.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesuserphp">trunk/wp-admin/includes/user.php</a></li>
<li><a href="#trunkwpadminusereditphp">trunk/wp-admin/user-edit.php</a></li>
<li><a href="#trunkwpincludesregistrationphp">trunk/wp-includes/registration.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesuserphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/user.php (11783 => 11784)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/user.php        2009-08-06 20:48:59 UTC (rev 11783)
+++ trunk/wp-admin/includes/user.php        2009-08-06 21:59:52 UTC (rev 11784)
</span><span class="lines">@@ -105,12 +105,11 @@
</span><span class="cx">                 $user-&gt;display_name = esc_html( trim( $_POST['display_name'] ));
</span><span class="cx">         if ( isset( $_POST['description'] ))
</span><span class="cx">                 $user-&gt;description = trim( $_POST['description'] );
</span><del>-        if ( isset( $_POST['jabber'] ))
-                $user-&gt;jabber = esc_html( trim( $_POST['jabber'] ));
-        if ( isset( $_POST['aim'] ))
-                $user-&gt;aim = esc_html( trim( $_POST['aim'] ));
-        if ( isset( $_POST['yim'] ))
-                $user-&gt;yim = esc_html( trim( $_POST['yim'] ));
</del><ins>+        $user_contactmethods = _wp_get_user_contactmethods();
+        foreach ($user_contactmethods as $method =&gt; $name) {
+                if ( isset( $_POST[$method] ))
+                        $user-&gt;$method = esc_html( trim( $_POST[$method] ) );
+        }
</ins><span class="cx">         if ( !$update )
</span><span class="cx">                 $user-&gt;rich_editing = 'true';  // Default to true for new users.
</span><span class="cx">         else if ( isset( $_POST['rich_editing'] ) )
</span><span class="lines">@@ -378,9 +377,12 @@
</span><span class="cx">         $user-&gt;last_name    = esc_attr($user-&gt;last_name);
</span><span class="cx">         $user-&gt;display_name = esc_attr($user-&gt;display_name);
</span><span class="cx">         $user-&gt;nickname     = esc_attr($user-&gt;nickname);
</span><del>-        $user-&gt;aim          = isset( $user-&gt;aim ) &amp;&amp; !empty( $user-&gt;aim ) ? esc_attr($user-&gt;aim) : '';
-        $user-&gt;yim          = isset( $user-&gt;yim ) &amp;&amp; !empty( $user-&gt;yim ) ? esc_attr($user-&gt;yim) : '';
-        $user-&gt;jabber       = isset( $user-&gt;jabber ) &amp;&amp; !empty( $user-&gt;jabber ) ? esc_attr($user-&gt;jabber) : '';
</del><ins>+
+        $user_contactmethods = _wp_get_user_contactmethods();
+        foreach ($user_contactmethods as $method =&gt; $name) {
+                $user-&gt;{$method} = isset( $user-&gt;{$method} ) &amp;&amp; !empty( $user-&gt;{$method} ) ? esc_attr($user-&gt;{$method}) : '';
+        }
+        
</ins><span class="cx">         $user-&gt;description  = isset( $user-&gt;description ) &amp;&amp; !empty( $user-&gt;description ) ? esc_html($user-&gt;description) : '';
</span><span class="cx"> 
</span><span class="cx">         return $user;
</span><span class="lines">@@ -835,4 +837,21 @@
</span><span class="cx">         echo '&lt;/p&gt;&lt;/div&gt;';
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/**
+ * Setup the default contact methods
+ *
+ * @access private
+ * @since 
+ *
+ * @return array $user_contactmethods Array of contact methods and their labels.
+ */
+function _wp_get_user_contactmethods() {
+        $user_contactmethods = array(
+                'aim' =&gt; __('AIM'),
+                'yim' =&gt; __('Yahoo IM'),
+                'jabber' =&gt; __('Jabber / Google Talk')
+        );
+        return apply_filters('user_contactmethods',$user_contactmethods);
+}
+
</ins><span class="cx"> ?&gt;
</span></span></pre></div>
<a id="trunkwpadminusereditphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/user-edit.php (11783 => 11784)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/user-edit.php        2009-08-06 20:48:59 UTC (rev 11783)
+++ trunk/wp-admin/user-edit.php        2009-08-06 21:59:52 UTC (rev 11784)
</span><span class="lines">@@ -267,20 +267,16 @@
</span><span class="cx">         &lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;url&quot; id=&quot;url&quot; value=&quot;&lt;?php echo esc_attr($profileuser-&gt;user_url) ?&gt;&quot; class=&quot;regular-text code&quot; /&gt;&lt;/td&gt;
</span><span class="cx"> &lt;/tr&gt;
</span><span class="cx"> 
</span><ins>+&lt;?php
+        foreach (_wp_get_user_contactmethods() as $name =&gt; $desc) {
+?&gt;
</ins><span class="cx"> &lt;tr&gt;
</span><del>-        &lt;th&gt;&lt;label for=&quot;aim&quot;&gt;&lt;?php echo apply_filters('user_aim_label', __('AIM')); ?&gt;&lt;/label&gt;&lt;/th&gt;
-        &lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;aim&quot; id=&quot;aim&quot; value=&quot;&lt;?php echo esc_attr($profileuser-&gt;aim) ?&gt;&quot; class=&quot;regular-text&quot; /&gt;&lt;/td&gt;
-&lt;/tr&gt;
-
-&lt;tr&gt;
-        &lt;th&gt;&lt;label for=&quot;yim&quot;&gt;&lt;?php echo apply_filters('user_yim_label', __('Yahoo IM')); ?&gt;&lt;/label&gt;&lt;/th&gt;
-        &lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;yim&quot; id=&quot;yim&quot; value=&quot;&lt;?php echo esc_attr($profileuser-&gt;yim) ?&gt;&quot; class=&quot;regular-text&quot; /&gt;&lt;/td&gt;
-&lt;/tr&gt;
-
-&lt;tr&gt;
-        &lt;th&gt;&lt;label for=&quot;jabber&quot;&gt;&lt;?php echo apply_filters('user_jabber_label', __('Jabber / Google Talk')); ?&gt;&lt;/label&gt;&lt;/th&gt;
-        &lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;jabber&quot; id=&quot;jabber&quot; value=&quot;&lt;?php echo esc_attr($profileuser-&gt;jabber) ?&gt;&quot; class=&quot;regular-text&quot; /&gt;&lt;/td&gt;
-&lt;/tr&gt;
</del><ins>+        &lt;th&gt;&lt;label for=&quot;&lt;?php echo $name; ?&gt;&quot;&gt;&lt;?php echo apply_filters('user_'.$name.'_label', $desc); ?&gt;&lt;/label&gt;&lt;/th&gt;
+        &lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;&lt;?php echo $name; ?&gt;&quot; id=&quot;&lt;?php echo $name; ?&gt;&quot; value=&quot;&lt;?php echo esc_attr($profileuser-&gt;$name) ?&gt;&quot; class=&quot;regular-text&quot; /&gt;&lt;/td&gt;
+&lt;/tr&gt;        
+&lt;?php
+        }
+?&gt;
</ins><span class="cx"> &lt;/table&gt;
</span><span class="cx"> 
</span><span class="cx"> &lt;h3&gt;&lt;?php IS_PROFILE_PAGE ? _e('About Yourself') : _e('About the user'); ?&gt;&lt;/h3&gt;
</span></span></pre></div>
<a id="trunkwpincludesregistrationphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/registration.php (11783 => 11784)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/registration.php        2009-08-06 20:48:59 UTC (rev 11783)
+++ trunk/wp-includes/registration.php        2009-08-06 21:59:52 UTC (rev 11784)
</span><span class="lines">@@ -164,15 +164,6 @@
</span><span class="cx">         if ( empty($use_ssl) )
</span><span class="cx">                 $use_ssl = 0;
</span><span class="cx"> 
</span><del>-        if ( empty($jabber) )
-                $jabber = '';
-
-        if ( empty($aim) )
-                $aim = '';
-
-        if ( empty($yim) )
-                $yim = '';
-
</del><span class="cx">         if ( empty($user_registered) )
</span><span class="cx">                 $user_registered = gmdate('Y-m-d H:i:s');
</span><span class="cx"> 
</span><span class="lines">@@ -203,13 +194,16 @@
</span><span class="cx">         update_usermeta( $user_id, 'last_name', $last_name);
</span><span class="cx">         update_usermeta( $user_id, 'nickname', $nickname );
</span><span class="cx">         update_usermeta( $user_id, 'description', $description );
</span><del>-        update_usermeta( $user_id, 'jabber', $jabber );
-        update_usermeta( $user_id, 'aim', $aim );
-        update_usermeta( $user_id, 'yim', $yim );
</del><span class="cx">         update_usermeta( $user_id, 'rich_editing', $rich_editing);
</span><span class="cx">         update_usermeta( $user_id, 'comment_shortcuts', $comment_shortcuts);
</span><span class="cx">         update_usermeta( $user_id, 'admin_color', $admin_color);
</span><span class="cx">         update_usermeta( $user_id, 'use_ssl', $use_ssl);
</span><ins>+        foreach (_wp_get_user_contactmethods() as $method =&gt; $name) {
+                if ( empty($$method) )
+                        $$method = '';
+                
+                update_usermeta( $user_id, $method, $$method );
+        }
</ins><span class="cx"> 
</span><span class="cx">         if ( isset($role) ) {
</span><span class="cx">                 $user = new WP_User($user_id);
</span></span></pre>
</div>
</div>

</body>
</html>