<!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->user_email, 32 );
</span><del>-                                                if ( get_current_user_id() == $user->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->ID ) ) );
-                                                }
</del><ins>+                                                $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) );
</ins><span class="cx">
</span><span class="cx">                                                 echo "<td $attributes>"; ?>
</span><span class="cx">                                                         <?php echo $avatar; ?><strong><a href="<?php echo $edit_link; ?>" class="edit"><?php echo stripslashes( $user->user_login ); ?></a><?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->ID ) {
-                                $edit_link = 'profile.php';
-                        } else {
-                                $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), "user-edit.php?user_id=$user_object->ID" ) );
-                        }
</del><ins>+                        $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user_object->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">                 <li><?php echo sprintf(        __( '<a href="%s">Choose your privacy setting</a>' ), esc_url( admin_url('options-privacy.php') ) ); ?></li>
</span><span class="cx">                 <li><?php echo sprintf( __( '<a href="%s">Select your tagline and time zone</a>' ), esc_url( admin_url('options-general.php') ) ); ?></li>
</span><span class="cx">                 <li><?php echo sprintf( __( '<a href="%s">Turn comments on or off</a>' ), esc_url( admin_url('options-discussion.php') ) ); ?></li>
</span><del>-                <li><?php echo sprintf( __( '<a href="%s">Fill in your profile</a>' ), esc_url( admin_url('profile.php') ) ); ?></li>
</del><ins>+                <li><?php echo sprintf( __( '<a href="%s">Fill in your profile</a>' ), esc_url( get_edit_profile_url( get_current_user_id() ) ) ); ?></li>
</ins><span class="cx">                 </ul>
</span><span class="cx">         </div>
</span><span class="cx">         <div class="welcome-panel-column">
</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 '<strong>' . __('Notice:') . '</strong> ';
</span><span class="cx">         _e('You&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 '</p><p>';
</span><del>-        printf( '<a href="%s">' . __('Yes, take me to my profile page') . '</a> | ', admin_url('profile.php') . '#password' );
</del><ins>+        printf( '<a href="%s">' . __('Yes, take me to my profile page') . '</a> | ', get_edit_profile_url( get_current_user_id() ) . '#password' );
</ins><span class="cx">         printf( '<a href="%s" id="default-password-nag-no">' . __('No thanks, do not remind me again') . '</a>', '?default_password_nag=0' );
</span><span class="cx">         echo '</p></div>';
</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 ? "profile.php?" : "user-edit.php?user_id=$user_id&"). "updated=true";
</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' => apply_filters( 'comment_form_default_fields', $fields ),
</span><span class="cx">                 'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>',
</span><span class="cx">                 'must_log_in' => '<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>',
</span><del>-                'logged_in_as' => '<p class="logged-in-as">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>',
</del><ins>+                'logged_in_as' => '<p class="logged-in-as">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>' ), get_edit_user_link(), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>',
</ins><span class="cx">                 'comment_notes_before' => '<p class="comment-notes">' . __( 'Your email address will not be published.' ) . ( $req ? $required_text : '' ) . '</p>',
</span><span class="cx">                 'comment_notes_after' => '<p class="form-allowed-tags">' . sprintf( __( 'You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: %s' ), ' <code>' . allowed_tags() . '</code>' ) . '</p>',
</span><span class="cx">                 'id_form' => '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->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->exists() )
+                return '';
+
+        if ( get_current_user_id() == $user->ID )
+                $link = get_edit_profile_url( $user->ID );
+        else
+                $link = add_query_arg( 'user_id', $user->ID, self_admin_url( 'user-edit.php' ) );
+
+        return apply_filters( 'get_edit_user_link', $link, $user->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"> <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
</span><span class="cx"> <?php if ( $user_ID ) : ?>
</span><del>-        <p><?php printf(__('Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out &raquo;</a>'), get_option('siteurl') . '/wp-admin/profile.php', $user_identity, wp_logout_url(get_permalink())); ?></p>
</del><ins>+        <p><?php printf(__('Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out &raquo;</a>'), get_edit_user_link(), $user_identity, wp_logout_url(get_permalink())); ?></p>
</ins><span class="cx"> <?php else : ?>
</span><span class="cx">         <p>
</span><span class="cx">          <input type="text" name="author" id="author" class="textarea" value="<?php echo esc_attr($comment_author); ?>" size="28" tabindex="1" />
</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"> <?php if ( is_user_logged_in() ) : ?>
</span><span class="cx">
</span><del>-<p><?php printf(__('Logged in as <a href="%1$s">%2$s</a>.'), get_option('siteurl') . '/wp-admin/profile.php', $user_identity); ?> <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="<?php esc_attr_e('Log out of this account'); ?>"><?php _e('Log out &raquo;'); ?></a></p>
</del><ins>+<p><?php printf(__('Logged in as <a href="%1$s">%2$s</a>.'), get_edit_user_link(), $user_identity); ?> <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="<?php esc_attr_e('Log out of this account'); ?>"><?php _e('Log out &raquo;'); ?></a></p>
</ins><span class="cx">
</span><span class="cx"> <?php else : ?>
</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() && !$user->has_cap('read') )
</span><span class="cx">                                 $redirect_to = get_dashboard_url( $user->ID );
</span><span class="cx">                         elseif ( !$user->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>