Skip to content

Commit

Permalink
Refactor to display links outside of backup_providers.
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenDufresne committed Sep 23, 2024
1 parent 8918127 commit 5a60522
Showing 1 changed file with 37 additions and 34 deletions.
71 changes: 37 additions & 34 deletions class-two-factor-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -804,50 +804,53 @@ public static function login_html( $user, $login_nonce, $redirect_to, $error_msg
<?php $provider->authentication_page( $user ); ?>
</form>

<?php if ( $backup_providers ) :
$backup_link_args = array(
'action' => $action,
'wp-auth-id' => $user->ID,
'wp-auth-nonce' => $login_nonce,
);
if ( $rememberme ) {
$backup_link_args['rememberme'] = $rememberme;
}
if ( $redirect_to ) {
$backup_link_args['redirect_to'] = $redirect_to;
}
if ( $interim_login ) {
$backup_link_args['interim-login'] = 1;
<?php
$links = [];

if ( $backup_providers ) {
$backup_link_args = array(
'action' => $action,
'wp-auth-id' => $user->ID,
'wp-auth-nonce' => $login_nonce,
);
if ( $rememberme ) {
$backup_link_args['rememberme'] = $rememberme;
}
if ( $redirect_to ) {
$backup_link_args['redirect_to'] = $redirect_to;
}
if ( $interim_login ) {
$backup_link_args['interim-login'] = 1;
}

foreach ( $backup_providers as $backup_provider_key => $backup_provider ) {
$backup_link_args['provider'] = $backup_provider_key;
$links[] = sprintf(
'<li><a href="%1$s">%2$s</a></li>',
esc_url( self::login_url( $backup_link_args ) ),
esc_html( $backup_provider->get_alternative_provider_label() )
);
}
}
?>

/*
* Allow plugins to add links to the two-factor login form.
*/
$links = apply_filters( 'two_factor_login_backup_links', $links );
?>

<?php if ( ! empty( $links ) ) : ?>
<div class="backup-methods-wrap">
<p>
<?php esc_html_e( 'Having Problems?', 'two-factor' ); ?>
</p>
<ul>
<?php
$links = [];

foreach ( $backup_providers as $backup_provider_key => $backup_provider ) {
$backup_link_args['provider'] = $backup_provider_key;
$links[] = sprintf(
'<li><a href="$1%s">$2%s</a></li>',
esc_url( self::login_url( $backup_link_args ) ),
esc_html( $backup_provider->get_alternative_provider_label() )
);
}

/*
* Allow plugins to add links to the two-factor login form.
*/
$links = apply_filters( 'two_factor_login_support_links', $links );

// Echo out the filtered links
foreach ( $links as $link ) {
echo wp_kses_post( $link );
echo $link;
}
?>
</ul>
</ul>
</div>
<?php endif; ?>

Expand Down

0 comments on commit 5a60522

Please sign in to comment.