WordPress.org

Make WordPress Core

Changeset 21364


Ignore:
Timestamp:
07/30/2012 06:30:03 PM (9 years ago)
Author:
ryan
Message:

Introduce get_edit_user_link(). Props scribu, georgestephanis, johnbillion. fixes #14787 see #20307

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-ms-users-list-table.php

    r21323 r21364  
    174174                    case 'username':
    175175                        $avatar = get_avatar( $user->user_email, 32 );
    176                         if ( get_current_user_id() == $user->ID ) {
    177                             $edit_link = esc_url( network_admin_url( 'profile.php' ) );
    178                         } else {
    179                             $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 ) ) );
    180                         }
     176                        $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) );
    181177
    182178                        echo "<td $attributes>"; ?>
  • trunk/wp-admin/includes/class-wp-users-list-table.php

    r21323 r21364  
    232232        if ( current_user_can( 'list_users' ) ) {
    233233            // Set up the user editing link
    234             // TODO: make profile/user-edit determination a separate function
    235             if ( get_current_user_id() == $user_object->ID ) {
    236                 $edit_link = 'profile.php';
    237             } else {
    238                 $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), "user-edit.php?user_id=$user_object->ID" ) );
    239             }
     234            $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user_object->ID ) ) );
    240235
    241236            // Set up the hover actions for this user
  • trunk/wp-admin/includes/dashboard.php

    r21311 r21364  
    12641264        <li><?php echo sprintf( __( '<a href="%s">Select your tagline and time zone</a>' ), esc_url( admin_url('options-general.php') ) ); ?></li>
    12651265        <li><?php echo sprintf( __( '<a href="%s">Turn comments on or off</a>' ), esc_url( admin_url('options-discussion.php') ) ); ?></li>
    1266         <li><?php echo sprintf( __( '<a href="%s">Fill in your profile</a>' ), esc_url( admin_url('profile.php') ) ); ?></li>
     1266        <li><?php echo sprintf( __( '<a href="%s">Fill in your profile</a>' ), esc_url( get_edit_profile_url( get_current_user_id() ) ) ); ?></li>
    12671267        </ul>
    12681268    </div>
  • trunk/wp-admin/includes/user.php

    r21170 r21364  
    354354    _e('You&rsquo;re using the auto-generated password for your account. Would you like to change it to something easier to remember?');
    355355    echo '</p><p>';
    356     printf( '<a href="%s">' . __('Yes, take me to my profile page') . '</a> | ', admin_url('profile.php') . '#password' );
     356    printf( '<a href="%s">' . __('Yes, take me to my profile page') . '</a> | ', get_edit_profile_url( get_current_user_id() ) . '#password' );
    357357    printf( '<a href="%s" id="default-password-nag-no">' . __('No thanks, do not remind me again') . '</a>', '?default_password_nag=0' );
    358358    echo '</p></div>';
  • trunk/wp-admin/user-edit.php

    r21204 r21364  
    140140
    141141if ( !is_wp_error( $errors ) ) {
    142     $redirect = (IS_PROFILE_PAGE ? "profile.php?" : "user-edit.php?user_id=$user_id&"). "updated=true";
     142    $redirect = add_query_arg( 'updated', true, get_edit_user_link( $user_id ) );
    143143    if ( $wp_http_referer )
    144144        $redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect);
  • trunk/wp-includes/comment-template.php

    r21330 r21364  
    15381538        '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>',
    15391539        '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>',
    1540         '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>',
     1540        '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>',
    15411541        'comment_notes_before' => '<p class="comment-notes">' . __( 'Your email address will not be published.' ) . ( $req ? $required_text : '' ) . '</p>',
    15421542        '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>',
  • trunk/wp-includes/link-template.php

    r21174 r21364  
    10571057}
    10581058
     1059/**
     1060 * Retrieve edit user link
     1061 *
     1062 * @since 3.5.0
     1063 *
     1064 * @param int $user_id Optional. User ID. Defaults to the current user.
     1065 * @return string URL to edit user page or empty string.
     1066 */
     1067function get_edit_user_link( $user_id = null ) {
     1068    if ( ! $user_id )
     1069        $user_id = get_current_user_id();
     1070
     1071    if ( empty( $user_id ) || ! current_user_can( 'edit_user', $user_id ) )
     1072        return '';
     1073
     1074    $user = new WP_User( $user_id );
     1075
     1076    if ( ! $user->exists() )
     1077        return '';
     1078
     1079    if ( get_current_user_id() == $user->ID )
     1080        $link = get_edit_profile_url( $user->ID );
     1081    else
     1082        $link = add_query_arg( 'user_id', $user->ID, self_admin_url( 'user-edit.php' ) );
     1083
     1084    return apply_filters( 'get_edit_user_link', $link, $user->ID );
     1085}
     1086
    10591087// Navigation links
    10601088
  • trunk/wp-includes/theme-compat/comments-popup.php

    r19028 r21364  
    6969<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
    7070<?php if ( $user_ID ) : ?>
    71     <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>
     71    <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>
    7272<?php else : ?>
    7373    <p>
  • trunk/wp-includes/theme-compat/comments.php

    r19684 r21364  
    7070<?php if ( is_user_logged_in() ) : ?>
    7171
    72 <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>
     72<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>
    7373
    7474<?php else : ?>
  • trunk/wp-login.php

    r21311 r21364  
    627627                $redirect_to = get_dashboard_url( $user->ID );
    628628            elseif ( !$user->has_cap('edit_posts') )
    629                 $redirect_to = admin_url('profile.php');
     629                $redirect_to = get_edit_user_link();
    630630        }
    631631        wp_safe_redirect($redirect_to);
Note: See TracChangeset for help on using the changeset viewer.