Add wp_registration_url() and register_url filter.

props scribu, JustinSainton, SergeyBiryukov.
fixes #17950.



git-svn-id: http://core.svn.wordpress.org/trunk@24053 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2013-04-22 20:21:22 +00:00
parent 00b7fa589a
commit a9712e0183
2 changed files with 26 additions and 11 deletions

View File

@ -219,12 +219,12 @@ function wp_loginout($redirect = '', $echo = true) {
/**
* Returns the Log Out URL.
*
* Returns the URL that allows the user to log out of the site
* Returns the URL that allows the user to log out of the site.
*
* @since 2.7.0
* @uses wp_nonce_url() To protect against CSRF
* @uses site_url() To generate the log in URL
* @uses apply_filters() calls 'logout_url' hook on final logout url
* @uses wp_nonce_url() To protect against CSRF.
* @uses site_url() To generate the log out URL.
* @uses apply_filters() calls 'logout_url' hook on final logout URL.
*
* @param string $redirect Path to redirect to on logout.
* @return string A log out URL.
@ -244,11 +244,11 @@ function wp_logout_url($redirect = '') {
/**
* Returns the Log In URL.
*
* Returns the URL that allows the user to log in to the site
* Returns the URL that allows the user to log in to the site.
*
* @since 2.7.0
* @uses site_url() To generate the log in URL
* @uses apply_filters() calls 'login_url' hook on final login url
* @uses site_url() To generate the log in URL.
* @uses apply_filters() calls 'login_url' hook on final login URL.
*
* @param string $redirect Path to redirect to on login.
* @param bool $force_reauth Whether to force reauthorization, even if a cookie is present. Default is false.
@ -266,6 +266,21 @@ function wp_login_url($redirect = '', $force_reauth = false) {
return apply_filters('login_url', $login_url, $redirect);
}
/**
* Returns the user registration URL.
*
* Returns the URL that allows the user to register on the site.
*
* @since 3.6.0
* @uses site_url() To generate the registration URL.
* @uses apply_filters() calls 'register_url' hook on final URL.
*
* @return string
*/
function wp_registration_url() {
return apply_filters( 'register_url', site_url( 'wp-login.php?action=register', 'login' ) );
}
/**
* Provides a simple login form for use anywhere within WordPress. By default, it echoes
* the HTML immediately. Pass array('echo'=>false) to return the string instead.
@ -359,7 +374,7 @@ function wp_register( $before = '<li>', $after = '</li>', $echo = true ) {
if ( ! is_user_logged_in() ) {
if ( get_option('users_can_register') )
$link = $before . '<a href="' . site_url('wp-login.php?action=register', 'login') . '">' . __('Register') . '</a>' . $after;
$link = $before . '<a href="' . esc_url( wp_registration_url() ) . '">' . __('Register') . '</a>' . $after;
else
$link = '';
} else {

View File

@ -466,7 +466,7 @@ case 'retrievepassword' :
<p id="nav">
<a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e('Log in') ?></a>
<?php if ( get_option( 'users_can_register' ) ) : ?>
| <?php echo apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( site_url( 'wp-login.php?action=register', 'login' ) ), __( 'Register' ) ) ); ?>
| <?php echo apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ) ); ?>
<?php endif; ?>
</p>
@ -525,7 +525,7 @@ case 'rp' :
<p id="nav">
<a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a>
<?php if ( get_option( 'users_can_register' ) ) : ?>
| <?php echo apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( site_url( 'wp-login.php?action=register', 'login' ) ), __( 'Register' ) ) ); ?>
| <?php echo apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ) ); ?>
<?php endif; ?>
</p>
@ -732,7 +732,7 @@ default:
<p id="nav">
<?php if ( ! isset( $_GET['checkemail'] ) || ! in_array( $_GET['checkemail'], array( 'confirm', 'newpass' ) ) ) : ?>
<?php if ( get_option( 'users_can_register' ) ) : ?>
<?php echo apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( site_url( 'wp-login.php?action=register', 'login' ) ), __( 'Register' ) ) ); ?> |
<?php echo apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ) ); ?> |
<?php endif; ?>
<a href="<?php echo esc_url( wp_lostpassword_url() ); ?>" title="<?php esc_attr_e( 'Password Lost and Found' ); ?>"><?php _e( 'Lost your password?' ); ?></a>
<?php endif; ?>