| 1 |
<?php |
| 2 |
/** |
| 3 |
* Login Form Shortcode. |
| 4 |
* |
| 5 |
* @author ThimPress |
| 6 |
* @category Shortcodes |
| 7 |
* @package Learnpress/Shortcodes |
| 8 |
* @version 3.0.0 |
| 9 |
* @extends LP_Abstract_Shortcode |
| 10 |
*/ |
| 11 |
|
| 12 |
defined( 'ABSPATH' ) || exit(); |
| 13 |
|
| 14 |
if ( ! class_exists( 'LP_Shortcode_Login_Form' ) ) { |
| 15 |
/** |
| 16 |
* Class LP_Shortcode_Login_Form |
| 17 |
*/ |
| 18 |
class LP_Shortcode_Login_Form extends LP_Abstract_Shortcode { |
| 19 |
/** |
| 20 |
* LP_Shortcode_Login_Form constructor. |
| 21 |
* |
| 22 |
* @param mixed $atts |
| 23 |
*/ |
| 24 |
public function __construct( $atts = '' ) { |
| 25 |
parent::__construct( $atts ); |
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* Shortcode content. |
| 30 |
* |
| 31 |
* @return string |
| 32 |
*/ |
| 33 |
public function output() { |
| 34 |
if ( is_user_logged_in() ) { |
| 35 |
$user = learn_press_get_current_user(); |
| 36 |
$output = sprintf( __( 'Your are logged in as %1$s. <a href="%2$s">Log out</a>?', 'learnpress' ), $user->get_display_name(), wp_logout_url() ); |
| 37 |
} else { |
| 38 |
ob_start(); |
| 39 |
learn_press_show_message(); |
| 40 |
learn_press_get_template( 'global/form-login.php' ); |
| 41 |
$output = ob_get_clean(); |
| 42 |
} |
| 43 |
|
| 44 |
return $output; |
| 45 |
} |
| 46 |
|
| 47 |
} |
| 48 |
} |
| 49 |
|