Skip to content

Commit

Permalink
Better handling of the redirect URL, #95
Browse files Browse the repository at this point in the history
  • Loading branch information
Zane committed May 7, 2015
1 parent 3520bf7 commit fa878b9
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,29 @@ function zm_ajax_login_register_enqueue_scripts(){


function zm_ajax_login_register_localized_js(){


$redirect_url = get_option('ajax_login_register_redirect');
$redirect_url = empty( $redirect_url ) ? network_site_url($_SERVER['REQUEST_URI']) : $redirect_url;
$redirect_url = apply_filters( 'zm_ajax_login_redirect', $redirect_url );

// Just use the current page
if ( empty( $redirect_url ) ){
global $wp;
$formatted_url = trailingslashit( add_query_arg( '', '', network_site_url( $wp->request ) ) );
}

// This is just a slug, and doesn't have http(s), so lets add it
elseif ( strpos( $redirect_url, 'http' ) === false ) {
$formatted_url = network_site_url( $redirect_url );
}

// Just use what ever they entered
else {

$formatted_url = esc_url( $redirect_url );
}

$redirect_url = apply_filters( 'zm_ajax_login_redirect', $formatted_url );

$width = array(
'default' => 265,
'wide' => 440,
Expand Down

0 comments on commit fa878b9

Please sign in to comment.