| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yatra\Core\Shortcodes; |
| 4 |
|
| 5 |
|
| 6 |
defined('ABSPATH') || exit; |
| 7 |
|
| 8 |
/** |
| 9 |
* Shortcode Login class. |
| 10 |
*/ |
| 11 |
class Login |
| 12 |
{ |
| 13 |
|
| 14 |
/** |
| 15 |
* Get the shortcode content. |
| 16 |
* |
| 17 |
* @param array $atts Shortcode attributes. |
| 18 |
* @return string |
| 19 |
*/ |
| 20 |
public static function get($atts) |
| 21 |
{ |
| 22 |
return \Yatra_Shortcodes::shortcode_wrapper(array(__CLASS__, 'output'), $atts); |
| 23 |
} |
| 24 |
|
| 25 |
/** |
| 26 |
* Output the shortcode. |
| 27 |
* |
| 28 |
* @param array $atts Shortcode attributes. |
| 29 |
*/ |
| 30 |
public static function output($atts) |
| 31 |
{ |
| 32 |
$redirect = isset($atts['redirect']) ? sanitize_text_field($atts['redirect']) : ''; |
| 33 |
|
| 34 |
echo '<div class="yatra-row">'; |
| 35 |
|
| 36 |
echo '<div class="yatra-col-md-12 yatra-col-xs-12 yatra-login-wrap">'; |
| 37 |
|
| 38 |
if (is_user_logged_in()) { |
| 39 |
|
| 40 |
$account_page_url = yatra_get_my_account_page(true); |
| 41 |
|
| 42 |
printf(esc_html("%sYou're currently logged in. You can access the My Account page from %shere%s.%s"), '<h2>', '<a href="' . esc_url($account_page_url) . '">', '</a>', '</h2>'); |
| 43 |
|
| 44 |
} else { |
| 45 |
|
| 46 |
yatra_get_template('myaccount/tmpl-form-login.php', array( |
| 47 |
'redirect' => $redirect, |
| 48 |
'title' => __('Login', 'yatra') |
| 49 |
)); |
| 50 |
|
| 51 |
} |
| 52 |
echo '</div>'; |
| 53 |
|
| 54 |
echo '</div>'; |
| 55 |
|
| 56 |
|
| 57 |
} |
| 58 |
|
| 59 |
} |
| 60 |
|