<!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" />
<title>[21364] trunk: Introduce get_edit_user_link().</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { 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 #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#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>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/21364">21364</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2012-07-30 18:30:03 +0000 (Mon, 30 Jul 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Introduce get_edit_user_link(). Props scribu, georgestephanis, johnbillion. fixes <a href="http://core.trac.wordpress.org/ticket/14787">#14787</a> see <a href="http://core.trac.wordpress.org/ticket/20307">#20307</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesclasswpmsuserslisttablephp">trunk/wp-admin/includes/class-wp-ms-users-list-table.php</a></li>
<li><a href="#trunkwpadminincludesclasswpuserslisttablephp">trunk/wp-admin/includes/class-wp-users-list-table.php</a></li>
<li><a href="#trunkwpadminincludesdashboardphp">trunk/wp-admin/includes/dashboard.php</a></li>
<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="#trunkwpincludescommenttemplatephp">trunk/wp-includes/comment-template.php</a></li>
<li><a href="#trunkwpincludeslinktemplatephp">trunk/wp-includes/link-template.php</a></li>
<li><a href="#trunkwpincludesthemecompatcommentspopupphp">trunk/wp-includes/theme-compat/comments-popup.php</a></li>
<li><a href="#trunkwpincludesthemecompatcommentsphp">trunk/wp-includes/theme-compat/comments.php</a></li>
<li><a href="#trunkwploginphp">trunk/wp-login.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesclasswpmsuserslisttablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-ms-users-list-table.php (21363 => 21364)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-ms-users-list-table.php        2012-07-30 16:16:13 UTC (rev 21363)
+++ trunk/wp-admin/includes/class-wp-ms-users-list-table.php        2012-07-30 18:30:03 UTC (rev 21364)
</span><span class="lines">@@ -173,11 +173,7 @@
</span><span class="cx"> 
</span><span class="cx">                                         case 'username':
</span><span class="cx">                                                 $avatar        = get_avatar( $user-&gt;user_email, 32 );
</span><del>-                                                if ( get_current_user_id() == $user-&gt;ID ) {
-                                                        $edit_link = esc_url( network_admin_url( 'profile.php' ) );
-                                                } else {
-                                                        $edit_link = esc_url( network_admin_url( add_query_arg( 'wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), 'user-edit.php?user_id=' . $user-&gt;ID ) ) );
-                                                }
</del><ins>+                                                $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user-&gt;ID ) ) );
</ins><span class="cx"> 
</span><span class="cx">                                                 echo &quot;&lt;td $attributes&gt;&quot;; ?&gt;
</span><span class="cx">                                                         &lt;?php echo $avatar; ?&gt;&lt;strong&gt;&lt;a href=&quot;&lt;?php echo $edit_link; ?&gt;&quot; class=&quot;edit&quot;&gt;&lt;?php echo stripslashes( $user-&gt;user_login ); ?&gt;&lt;/a&gt;&lt;?php
</span></span></pre></div>
<a id="trunkwpadminincludesclasswpuserslisttablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-users-list-table.php (21363 => 21364)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-users-list-table.php        2012-07-30 16:16:13 UTC (rev 21363)
+++ trunk/wp-admin/includes/class-wp-users-list-table.php        2012-07-30 18:30:03 UTC (rev 21364)
</span><span class="lines">@@ -231,12 +231,7 @@
</span><span class="cx">                 // Check if the user for this row is editable
</span><span class="cx">                 if ( current_user_can( 'list_users' ) ) {
</span><span class="cx">                         // Set up the user editing link
</span><del>-                        // TODO: make profile/user-edit determination a separate function
-                        if ( get_current_user_id() == $user_object-&gt;ID ) {
-                                $edit_link = 'profile.php';
-                        } else {
-                                $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), &quot;user-edit.php?user_id=$user_object-&gt;ID&quot; ) );
-                        }
</del><ins>+                        $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user_object-&gt;ID ) ) );
</ins><span class="cx"> 
</span><span class="cx">                         // Set up the hover actions for this user
</span><span class="cx">                         $actions = array();
</span></span></pre></div>
<a id="trunkwpadminincludesdashboardphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/dashboard.php (21363 => 21364)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/dashboard.php        2012-07-30 16:16:13 UTC (rev 21363)
+++ trunk/wp-admin/includes/dashboard.php        2012-07-30 18:30:03 UTC (rev 21364)
</span><span class="lines">@@ -1263,7 +1263,7 @@
</span><span class="cx">                 &lt;li&gt;&lt;?php echo sprintf(        __( '&lt;a href=&quot;%s&quot;&gt;Choose your privacy setting&lt;/a&gt;' ), esc_url( admin_url('options-privacy.php') ) ); ?&gt;&lt;/li&gt;
</span><span class="cx">                 &lt;li&gt;&lt;?php echo sprintf( __( '&lt;a href=&quot;%s&quot;&gt;Select your tagline and time zone&lt;/a&gt;' ), esc_url( admin_url('options-general.php') ) ); ?&gt;&lt;/li&gt;
</span><span class="cx">                 &lt;li&gt;&lt;?php echo sprintf( __( '&lt;a href=&quot;%s&quot;&gt;Turn comments on or off&lt;/a&gt;' ), esc_url( admin_url('options-discussion.php') ) ); ?&gt;&lt;/li&gt;
</span><del>-                &lt;li&gt;&lt;?php echo sprintf( __( '&lt;a href=&quot;%s&quot;&gt;Fill in your profile&lt;/a&gt;' ), esc_url( admin_url('profile.php') ) ); ?&gt;&lt;/li&gt;
</del><ins>+                &lt;li&gt;&lt;?php echo sprintf( __( '&lt;a href=&quot;%s&quot;&gt;Fill in your profile&lt;/a&gt;' ), esc_url( get_edit_profile_url( get_current_user_id() ) ) ); ?&gt;&lt;/li&gt;
</ins><span class="cx">                 &lt;/ul&gt;
</span><span class="cx">         &lt;/div&gt;
</span><span class="cx">         &lt;div class=&quot;welcome-panel-column&quot;&gt;
</span></span></pre></div>
<a id="trunkwpadminincludesuserphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/user.php (21363 => 21364)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/user.php        2012-07-30 16:16:13 UTC (rev 21363)
+++ trunk/wp-admin/includes/user.php        2012-07-30 18:30:03 UTC (rev 21364)
</span><span class="lines">@@ -353,7 +353,7 @@
</span><span class="cx">         echo '&lt;strong&gt;' . __('Notice:') . '&lt;/strong&gt; ';
</span><span class="cx">         _e('You&amp;rsquo;re using the auto-generated password for your account. Would you like to change it to something easier to remember?');
</span><span class="cx">         echo '&lt;/p&gt;&lt;p&gt;';
</span><del>-        printf( '&lt;a href=&quot;%s&quot;&gt;' . __('Yes, take me to my profile page') . '&lt;/a&gt; | ', admin_url('profile.php') . '#password' );
</del><ins>+        printf( '&lt;a href=&quot;%s&quot;&gt;' . __('Yes, take me to my profile page') . '&lt;/a&gt; | ', get_edit_profile_url( get_current_user_id() ) . '#password' );
</ins><span class="cx">         printf( '&lt;a href=&quot;%s&quot; id=&quot;default-password-nag-no&quot;&gt;' . __('No thanks, do not remind me again') . '&lt;/a&gt;', '?default_password_nag=0' );
</span><span class="cx">         echo '&lt;/p&gt;&lt;/div&gt;';
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkwpadminusereditphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/user-edit.php (21363 => 21364)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/user-edit.php        2012-07-30 16:16:13 UTC (rev 21363)
+++ trunk/wp-admin/user-edit.php        2012-07-30 18:30:03 UTC (rev 21364)
</span><span class="lines">@@ -139,7 +139,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> if ( !is_wp_error( $errors ) ) {
</span><del>-        $redirect = (IS_PROFILE_PAGE ? &quot;profile.php?&quot; : &quot;user-edit.php?user_id=$user_id&amp;&quot;). &quot;updated=true&quot;;
</del><ins>+        $redirect = add_query_arg( 'updated', true, get_edit_user_link( $user_id ) );
</ins><span class="cx">         if ( $wp_http_referer )
</span><span class="cx">                 $redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect);
</span><span class="cx">         wp_redirect($redirect);
</span></span></pre></div>
<a id="trunkwpincludescommenttemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/comment-template.php (21363 => 21364)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/comment-template.php        2012-07-30 16:16:13 UTC (rev 21363)
+++ trunk/wp-includes/comment-template.php        2012-07-30 18:30:03 UTC (rev 21364)
</span><span class="lines">@@ -1537,7 +1537,7 @@
</span><span class="cx">                 'fields'               =&gt; apply_filters( 'comment_form_default_fields', $fields ),
</span><span class="cx">                 'comment_field'        =&gt; '&lt;p class=&quot;comment-form-comment&quot;&gt;&lt;label for=&quot;comment&quot;&gt;' . _x( 'Comment', 'noun' ) . '&lt;/label&gt;&lt;textarea id=&quot;comment&quot; name=&quot;comment&quot; cols=&quot;45&quot; rows=&quot;8&quot; aria-required=&quot;true&quot;&gt;&lt;/textarea&gt;&lt;/p&gt;',
</span><span class="cx">                 'must_log_in'          =&gt; '&lt;p class=&quot;must-log-in&quot;&gt;' . sprintf( __( 'You must be &lt;a href=&quot;%s&quot;&gt;logged in&lt;/a&gt; to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '&lt;/p&gt;',
</span><del>-                'logged_in_as'         =&gt; '&lt;p class=&quot;logged-in-as&quot;&gt;' . sprintf( __( 'Logged in as &lt;a href=&quot;%1$s&quot;&gt;%2$s&lt;/a&gt;. &lt;a href=&quot;%3$s&quot; title=&quot;Log out of this account&quot;&gt;Log out?&lt;/a&gt;' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '&lt;/p&gt;',
</del><ins>+                'logged_in_as'         =&gt; '&lt;p class=&quot;logged-in-as&quot;&gt;' . sprintf( __( 'Logged in as &lt;a href=&quot;%1$s&quot;&gt;%2$s&lt;/a&gt;. &lt;a href=&quot;%3$s&quot; title=&quot;Log out of this account&quot;&gt;Log out?&lt;/a&gt;' ), get_edit_user_link(), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '&lt;/p&gt;',
</ins><span class="cx">                 'comment_notes_before' =&gt; '&lt;p class=&quot;comment-notes&quot;&gt;' . __( 'Your email address will not be published.' ) . ( $req ? $required_text : '' ) . '&lt;/p&gt;',
</span><span class="cx">                 'comment_notes_after'  =&gt; '&lt;p class=&quot;form-allowed-tags&quot;&gt;' . sprintf( __( 'You may use these &lt;abbr title=&quot;HyperText Markup Language&quot;&gt;HTML&lt;/abbr&gt; tags and attributes: %s' ), ' &lt;code&gt;' . allowed_tags() . '&lt;/code&gt;' ) . '&lt;/p&gt;',
</span><span class="cx">                 'id_form'              =&gt; 'commentform',
</span></span></pre></div>
<a id="trunkwpincludeslinktemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/link-template.php (21363 => 21364)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/link-template.php        2012-07-30 16:16:13 UTC (rev 21363)
+++ trunk/wp-includes/link-template.php        2012-07-30 18:30:03 UTC (rev 21364)
</span><span class="lines">@@ -1056,6 +1056,34 @@
</span><span class="cx">         echo $before . apply_filters( 'edit_bookmark_link', $link, $bookmark-&gt;link_id ) . $after;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/**
+ * Retrieve edit user link
+ *
+ * @since 3.5.0
+ *
+ * @param int $user_id Optional. User ID. Defaults to the current user.
+ * @return string URL to edit user page or empty string.
+ */
+function get_edit_user_link( $user_id = null ) {
+        if ( ! $user_id )
+                $user_id = get_current_user_id();
+
+        if ( empty( $user_id ) || ! current_user_can( 'edit_user', $user_id ) )
+                return '';
+
+        $user = new WP_User( $user_id );
+
+        if ( ! $user-&gt;exists() )
+                return '';
+
+        if ( get_current_user_id() == $user-&gt;ID )
+                $link = get_edit_profile_url( $user-&gt;ID );
+        else
+                $link = add_query_arg( 'user_id', $user-&gt;ID, self_admin_url( 'user-edit.php' ) );
+
+        return apply_filters( 'get_edit_user_link', $link, $user-&gt;ID );
+}
+
</ins><span class="cx"> // Navigation links
</span><span class="cx"> 
</span><span class="cx"> /**
</span></span></pre></div>
<a id="trunkwpincludesthemecompatcommentspopupphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/theme-compat/comments-popup.php (21363 => 21364)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/theme-compat/comments-popup.php        2012-07-30 16:16:13 UTC (rev 21363)
+++ trunk/wp-includes/theme-compat/comments-popup.php        2012-07-30 18:30:03 UTC (rev 21364)
</span><span class="lines">@@ -68,7 +68,7 @@
</span><span class="cx"> 
</span><span class="cx"> &lt;form action=&quot;&lt;?php echo get_option('siteurl'); ?&gt;/wp-comments-post.php&quot; method=&quot;post&quot; id=&quot;commentform&quot;&gt;
</span><span class="cx"> &lt;?php if ( $user_ID ) : ?&gt;
</span><del>-        &lt;p&gt;&lt;?php printf(__('Logged in as &lt;a href=&quot;%1$s&quot;&gt;%2$s&lt;/a&gt;. &lt;a href=&quot;%3$s&quot; title=&quot;Log out of this account&quot;&gt;Log out &amp;raquo;&lt;/a&gt;'), get_option('siteurl') . '/wp-admin/profile.php', $user_identity, wp_logout_url(get_permalink())); ?&gt;&lt;/p&gt;
</del><ins>+        &lt;p&gt;&lt;?php printf(__('Logged in as &lt;a href=&quot;%1$s&quot;&gt;%2$s&lt;/a&gt;. &lt;a href=&quot;%3$s&quot; title=&quot;Log out of this account&quot;&gt;Log out &amp;raquo;&lt;/a&gt;'), get_edit_user_link(), $user_identity, wp_logout_url(get_permalink())); ?&gt;&lt;/p&gt;
</ins><span class="cx"> &lt;?php else : ?&gt;
</span><span class="cx">         &lt;p&gt;
</span><span class="cx">           &lt;input type=&quot;text&quot; name=&quot;author&quot; id=&quot;author&quot; class=&quot;textarea&quot; value=&quot;&lt;?php echo esc_attr($comment_author); ?&gt;&quot; size=&quot;28&quot; tabindex=&quot;1&quot; /&gt;
</span></span></pre></div>
<a id="trunkwpincludesthemecompatcommentsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/theme-compat/comments.php (21363 => 21364)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/theme-compat/comments.php        2012-07-30 16:16:13 UTC (rev 21363)
+++ trunk/wp-includes/theme-compat/comments.php        2012-07-30 18:30:03 UTC (rev 21364)
</span><span class="lines">@@ -69,7 +69,7 @@
</span><span class="cx"> 
</span><span class="cx"> &lt;?php if ( is_user_logged_in() ) : ?&gt;
</span><span class="cx"> 
</span><del>-&lt;p&gt;&lt;?php printf(__('Logged in as &lt;a href=&quot;%1$s&quot;&gt;%2$s&lt;/a&gt;.'), get_option('siteurl') . '/wp-admin/profile.php', $user_identity); ?&gt; &lt;a href=&quot;&lt;?php echo wp_logout_url(get_permalink()); ?&gt;&quot; title=&quot;&lt;?php esc_attr_e('Log out of this account'); ?&gt;&quot;&gt;&lt;?php _e('Log out &amp;raquo;'); ?&gt;&lt;/a&gt;&lt;/p&gt;
</del><ins>+&lt;p&gt;&lt;?php printf(__('Logged in as &lt;a href=&quot;%1$s&quot;&gt;%2$s&lt;/a&gt;.'), get_edit_user_link(), $user_identity); ?&gt; &lt;a href=&quot;&lt;?php echo wp_logout_url(get_permalink()); ?&gt;&quot; title=&quot;&lt;?php esc_attr_e('Log out of this account'); ?&gt;&quot;&gt;&lt;?php _e('Log out &amp;raquo;'); ?&gt;&lt;/a&gt;&lt;/p&gt;
</ins><span class="cx"> 
</span><span class="cx"> &lt;?php else : ?&gt;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwploginphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-login.php (21363 => 21364)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-login.php        2012-07-30 16:16:13 UTC (rev 21363)
+++ trunk/wp-login.php        2012-07-30 18:30:03 UTC (rev 21364)
</span><span class="lines">@@ -626,7 +626,7 @@
</span><span class="cx">                         elseif ( is_multisite() &amp;&amp; !$user-&gt;has_cap('read') )
</span><span class="cx">                                 $redirect_to = get_dashboard_url( $user-&gt;ID );
</span><span class="cx">                         elseif ( !$user-&gt;has_cap('edit_posts') )
</span><del>-                                $redirect_to = admin_url('profile.php');
</del><ins>+                                $redirect_to = get_edit_user_link();
</ins><span class="cx">                 }
</span><span class="cx">                 wp_safe_redirect($redirect_to);
</span><span class="cx">                 exit();
</span></span></pre>
</div>
</div>

</body>
</html>