Skip to content

Commit

Permalink
fix redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath committed Mar 17, 2021
1 parent d96e231 commit f4d2090
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions packages/block-library/src/loginout/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,21 @@
function render_block_core_loginout( $attributes ) {

// Build the redirect URL.
$redirect_url = isset( $attributes['redirectToCurrent'] ) && $attributes['redirectToCurrent']
? get_permalink( get_the_ID() )
: '';
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

$classes = is_user_logged_in() ? 'logged-in' : 'logged-out';
$contents = wp_loginout( $redirect_url, false );
$contents = wp_loginout(
isset( $attributes['redirectToCurrent'] ) && $attributes['redirectToCurrent'] ? $current_url : '',
false
);

// If logged-out and displayLoginAsForm is true, show the login form.
if ( ! is_user_logged_in() && ! empty( $attributes['displayLoginAsForm'] ) ) {
// Add a class.
$classes .= ' has-login-form';

// Get the form.
$contents = wp_login_form(
array(
'echo' => false,
'redirect' => $redirect_url,
)
);
$contents = wp_login_form( array( 'echo' => false ) );
}

$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
Expand Down

0 comments on commit f4d2090

Please sign in to comment.