'Login', // Default text for the login link
'redirect' => '', // Default redirect URL after login
'class' => 'btn-login', // Custom CSS class for login link
'logged_in_text' => 'You are already logged in!', // Text to display when logged in
'logged_in_redirect' => '', // Redirect URL for logged-in users
'logged_in_class' => 'btn-logged-in', // Custom CSS class for logged-in users
'logged_in_link_text' => 'Go to Dashboard' // Text for the dashboard link when logged in
), $atts);
// If the user is logged in
if (is_user_logged_in()) {
// Check if a redirect URL for logged-in users is set
$redirect_logged_in = !empty($atts['logged_in_redirect']) ? esc_url($atts['logged_in_redirect']) : home_url();
// Create the message for logged-in users with the logged-in class
$logged_in_message = '' . esc_html($atts['logged_in_text']) . '';
// Provide the link to redirect logged-in users (optional)
return $logged_in_message . ' ' . esc_html($atts['logged_in_link_text']) . '';
}
// If the user is not logged in
// Set the redirect URL
$redirect_url = !empty($atts['redirect']) ? esc_url($atts['redirect']) : home_url();
// Generate the login URL
$login_url = wp_login_url($redirect_url);
// Create the login link with the login class
return '' . esc_html($atts['text']) . '';
}
add_shortcode("aio_login", "aiosc_shortcode_login");