WordPress.org

Make WordPress Core

Changeset 10931


Ignore:
Timestamp:
04/14/09 18:31:49 (5 years ago)
Author:
ryan
Message:

Updates to wp_login_url() and wp_logout_url(). Use them in more places. Props wnorris. fixes #9536

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/themes/classic/comments.php

    r10767 r10931  
    4343 
    4444<?php if ( get_option('comment_registration') && !$user_ID ) : ?> 
    45 <p><?php printf(__('You must be <a href="%s">logged in</a> to post a comment.'), get_option('siteurl')."/wp-login.php?redirect_to=".urlencode(get_permalink()));?></p> 
     45<p><?php printf(__('You must be <a href="%s">logged in</a> to post a comment.'), wp_login_url( get_permalink() ) );?></p> 
    4646<?php else : ?> 
    4747 
  • trunk/wp-content/themes/default/comments.php

    r10177 r10931  
    5858 
    5959<?php if ( get_option('comment_registration') && !$user_ID ) : ?> 
    60 <p>You must be <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php echo urlencode(get_permalink()); ?>">logged in</a> to post a comment.</p> 
     60<p>You must be <a href="<?php echo wp_login_url( get_permalink() ); ?>">logged in</a> to post a comment.</p> 
    6161<?php else : ?> 
    6262 
  • trunk/wp-includes/comment-template.php

    r10875 r10931  
    985985 
    986986    if ( get_option('comment_registration') && !$user_ID ) 
    987         $link = '<a rel="nofollow" href="' . site_url('wp-login.php?redirect_to=' . get_permalink()) . '">' . $login_text . '</a>'; 
     987        $link = '<a rel="nofollow" href="' . wp_login_url( get_permalink() ) . '">' . $login_text . '</a>'; 
    988988    else 
    989989        $link = "<a rel='nofollow' class='comment-reply-link' href='" . wp_specialchars( add_query_arg( 'replytocom', $comment->comment_ID ) ) . "#" . $respond_id . "' onclick='return addComment.moveForm(\"$add_below-$comment->comment_ID\", \"$comment->comment_ID\", \"$respond_id\", \"$post->ID\")'>$reply_text</a>"; 
     
    10361036 
    10371037    if ( get_option('comment_registration') && !$user_ID ) { 
    1038         $link = '<a rel="nofollow" href="' . site_url('wp-login.php?redirect_to=' . get_permalink()) . '">' . $login_text . '</a>'; 
     1038        $link = '<a rel="nofollow" href="' . wp_login_url( get_permalink() ) . '">' . $login_text . '</a>'; 
    10391039    } else { 
    10401040        $link = "<a rel='nofollow' class='comment-reply-link' href='" . get_permalink($post->ID) . "#$respond_id' onclick='return addComment.moveForm(\"$add_below-$post->ID\", \"0\", \"$respond_id\", \"$post->ID\")'>$reply_text</a>"; 
  • trunk/wp-includes/functions.php

    r10897 r10931  
    23182318        $html .= "</p><p><a href='" . remove_query_arg( 'updated', clean_url( wp_get_referer() ) ) . "'>" . __( 'Please try again.' ) . "</a>"; 
    23192319    elseif ( 'log-out' == $action ) 
    2320         $html .= "</p><p>" . sprintf( __( "Do you really want to <a href='%s'>log out</a>?"), wp_nonce_url( site_url('wp-login.php?action=logout', 'login'), 'log-out' ) ); 
     2320        $html .= "</p><p>" . sprintf( __( "Do you really want to <a href='%s'>log out</a>?"), wp_logout_url() ); 
    23212321 
    23222322    wp_die( $html, $title); 
  • trunk/wp-includes/general-template.php

    r10810 r10931  
    155155 * @uses wp_nonce_url() To protect against CSRF 
    156156 * @uses site_url() To generate the log in URL 
     157 * @uses apply_filters() calls 'logout_url' hook on final logout url 
    157158 * 
    158159 * @param string $redirect Path to redirect to on logout. 
    159160 */ 
    160161function wp_logout_url($redirect = '') { 
    161     if ( strlen($redirect) ) 
    162         $redirect = "&redirect_to=$redirect"; 
    163  
    164     return wp_nonce_url( site_url("wp-login.php?action=logout$redirect", 'login'), 'log-out' ); 
     162    $args = array( 'action' => 'logout' ); 
     163    if ( !empty($redirect) ) { 
     164        $args['redirect_to'] = $redirect; 
     165    } 
     166 
     167    $logout_url = add_query_arg($args, site_url('wp-login.php', 'login')); 
     168    $logout_url = wp_nonce_url( $logout_url, 'log-out' ); 
     169 
     170    return apply_filters('logout_url', $logout_url, $redirect); 
    165171} 
    166172 
     
    172178 * @since 2.7 
    173179 * @uses site_url() To generate the log in URL 
     180 * @uses apply_filters() calls 'login_url' hook on final login url 
    174181 * 
    175182 * @param string $redirect Path to redirect to on login. 
    176183 */ 
    177184function wp_login_url($redirect = '') { 
    178     if ( strlen($redirect) ) 
    179         $redirect = "?redirect_to=$redirect"; 
    180  
    181     return site_url("wp-login.php$redirect", 'login'); 
     185    $login_url = site_url('wp-login.php', 'login'); 
     186 
     187    if ( !empty($redirect) ) { 
     188        $login_url = add_query_arg('redirect_to', $redirect, $login_url); 
     189    } 
     190 
     191    return apply_filters('login_url', $login_url, $redirect); 
    182192} 
    183193 
  • trunk/wp-includes/pluggable.php

    r10838 r10931  
    751751    $redirect = ( strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer() ) ? wp_get_referer() : $proto . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; 
    752752 
    753     $login_url = site_url( 'wp-login.php?redirect_to=' . urlencode( $redirect ), 'login' ); 
     753    $login_url = wp_login_url($redirect); 
    754754 
    755755    wp_redirect($login_url); 
     
    11031103    $message  = sprintf(__('Username: %s'), $user_login) . "\r\n"; 
    11041104    $message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n"; 
    1105     $message .= site_url("wp-login.php", 'login') . "\r\n"; 
     1105    $message .= wp_login_url() . "\r\n"; 
    11061106 
    11071107    wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_option('blogname')), $message); 
Note: See TracChangeset for help on using the changeset viewer.