array( 'name' => esc_html__( 'Login', 'mega' ), 'description' => esc_html__( 'Login block', 'mega' )),
'universal' => true
);
parent::__construct( __CLASS__, $args );
}
public function settings( $form )
{
$form->add_control( 'Mega_Control_Text', array( 'label' => esc_html__( 'Title', 'mega' ), 'value' => esc_html__( 'Login', 'mega' ), 'name' => 'title' ));
$form->add_control( 'Mega_Control_WP_Editor', array( 'label' => esc_html__( 'Text', 'mega' ), 'desc' => wp_kses( __( '[lost_password] is the lost password URL.', 'mega' ), array( 'strong' => true )), 'value' => wp_kses( __( 'If you have an account with us, you can safely login below. Forgot your password?', 'mega' ), array( 'a' => array( 'href' => true ))), 'name' => 'text' ));
$form->add_control( 'Mega_Control_WP_Editor', array( 'label' => esc_html__( 'Text Alt', 'mega' ), 'desc' => wp_kses( __( '[logout] is the logout URL.', 'mega' ), array( 'strong' => true )), 'value' => wp_kses( __( 'You are already logged in. Log out?', 'mega' ), array( 'a' => array( 'href' => true ))), 'name' => 'text_alt' ));
}
public function block()
{
extract( $this->mega['settings'] );
if ( is_user_logged_in() )
{
echo wpautop( preg_replace( '/\[?logout\]?/', esc_url( wp_logout_url( home_url() )), $text_alt ));
}
else
{
echo wpautop( preg_replace( '/\[?lost_password\]?/', esc_url( wp_lostpassword_url( home_url() )), $text ));
wp_login_form();
}
}
}