File: //home/parhudrw/www/wp-content/plugins/around-elementor/modules/login/widgets/login.php
<?php
namespace AroundElementor\Modules\Login\Widgets;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
use AroundElementor\Base\Base_Widget;
use Elementor\Controls_Manager;
use Elementor\Core\Schemes;
use Elementor\Group_Control_Typography;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Plugin;
use AroundElementor\Modules\Login\Skins;
use Elementor\Repeater;
/**
* around Elementor login widget.
*
* around Elementor widget that displays a login with the ability to control every
* aspect of the login design.
*
* @since 1.0.0
*/
class Login extends Base_Widget {
protected function register_skins() {
$this->add_skin( new Skins\Skin_Style_1( $this ) );
$this->add_skin( new Skins\Skin_Style_2( $this ) );
}
public function get_name() {
return 'ar-login';
}
public function get_title() {
return esc_html__( 'User Account Forms', 'around-elementor' );
}
public function get_icon() {
return 'eicon-lock-user';
}
public function get_keywords() {
return [ 'login', 'user', 'form', 'signin', 'signup', 'register' ];
}
protected function register_controls() {
$can_register = get_option( 'users_can_register' );
$this->start_controls_section( 'section_general', [
'label' => esc_html__( 'General', 'around-elementor' ),
] );
$this->add_control( 'display', [
'label' => esc_html__( 'Display', 'around-elementor' ),
'description' => esc_html__( 'Choose which forms you want to display. Please note that the register form is available only if registration is enabled from Settings > General > Membership.', 'around-elementor' ),
'type' => Controls_Manager::SELECT,
'options' => [
'all' => esc_html__( 'All', 'around-elementor' ),
'login' => esc_html__( 'Login', 'around-elementor' ),
'register' => esc_html__( 'Register', 'around-elementor' ),
'forgot' => esc_html__( 'Password Reset', 'around-elementor' )
],
'default' => 'all'
] );
$this->add_control(
'show_background_image',
[
'label' => esc_html__( 'Show Background Image', 'around-elementor' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Show', 'around-elementor' ),
'label_off' => esc_html__( 'Hide', 'around-elementor' ),
'default' => 'yes',
'separator' => 'before',
'condition' => [
'_skin!' => ''
],
]
);
$this->add_control(
'bg_image',
[
'label' => __( 'Background Image', 'around-elementor' ),
'type' => Controls_Manager::MEDIA,
'condition' => [
'show_background_image' => 'yes',
'_skin!' => ''
],
]
);
$this->end_controls_section();
$this->add_form_option_controls();
$this->add_login_form_controls();
$this->add_register_form_controls();
$this->add_password_reset_form_controls();
$this->add_additional_options_controls();
$this->start_controls_section( 'section_heading_style', [
'label' => esc_html__( 'Form', 'around-elementor' ),
'tab' => Controls_Manager::TAB_STYLE,
] );
$this->add_control( 'form_title_heading', [
'label' => __( 'Form Title', 'around-elementor' ),
'type' => Controls_Manager::HEADING,
'condition' => [ 'show_form_title' => 'yes'],
] );
$this->add_control( 'form_title_color', [
'label' => esc_html__( 'Color', 'around-elementor' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .form-header__title' => 'color: {{VALUE}};'
],
'condition' => [ 'show_form_title' => 'yes'],
] );
$this->add_group_control( Group_Control_Typography::get_type(), [
'name' => 'form_title_typography',
'selector' => '{{WRAPPER}} .form-header__title',
'condition' => [ 'show_form_title' => 'yes'],
] );
$this->add_control( 'form_title_alignment', [
'label' => esc_html__( 'Alignment', 'around-elementor' ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => esc_html__( 'Left', 'around-elementor' ),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => esc_html__( 'Center', 'around-elementor' ),
'icon' => 'eicon-text-align-center',
],
'right' => [
'title' => esc_html__( 'Right', 'around-elementor' ),
'icon' => 'eicon-text-align-right',
],
],
'selectors' => [
'{{WRAPPER}} .form-header__title' => 'text-align: {{VALUE}}',
],
'default' => 'left',
'condition' => [ 'show_form_title' => 'yes' ],
] );
$this->add_control( 'title_css', [
'label' => esc_html__( 'CSS Classes', 'around-elementor' ),
'type' => Controls_Manager::TEXT,
'title' => esc_html__( 'Add your custom class for text without the dot. e.g: my-class', 'around-elementor' ),
'default' => 'h2',
'condition' => [ 'show_form_title' => 'yes'],
] );
$this->add_control( 'form_description_heading', [
'label' => __( 'Form Description', 'around-elementor' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
'condition' => [ 'show_form_description' => 'yes' ],
] );
$this->add_control( 'form_description_color', [
'label' => esc_html__( 'Color', 'around-elementor' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .form-header__desc' => 'color: {{VALUE}};',
],
'condition' => [ 'show_form_description' => 'yes' ],
] );
$this->add_group_control( Group_Control_Typography::get_type(), [
'name' => 'form_description_typography',
'selector' => '{{WRAPPER}} .form-header__desc',
'condition' => [ 'show_form_description' => 'yes' ],
] );
$this->add_control(
'description_alignment',
[
'label' => esc_html__( 'Description Alignment', 'around-elementor' ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => esc_html__( 'Left', 'around-elementor' ),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => esc_html__( 'Center', 'around-elementor' ),
'icon' => 'eicon-text-align-center',
],
'right' => [
'title' => esc_html__( 'Right', 'around-elementor' ),
'icon' => 'eicon-text-align-right',
],
],
'selectors' => [
'{{WRAPPER}} .form-header__desc' => 'text-align: {{VALUE}}',
],
'default' => 'left',
'condition' => [ 'show_form_description' => 'yes' ],
]
);
$this->add_control(
'description_css', [
'label' => esc_html__( 'CSS Classes', 'around-elementor' ),
'type' => Controls_Manager::TEXT,
'title' => esc_html__( 'Add your custom class for text without the dot. e.g: my-class', 'around-elementor' ),
'default' => 'font-size-sm mb-4',
'condition' => [
'show_form_description' => 'yes',
],
]
);
$this->add_control( 'form_footer_alignment', [
'label' => esc_html__( 'Form Footer Alignment', 'around-elementor' ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => esc_html__( 'Left', 'around-elementor' ),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => esc_html__( 'Center', 'around-elementor' ),
'icon' => 'eicon-text-align-center',
],
'right' => [
'title' => esc_html__( 'Right', 'around-elementor' ),
'icon' => 'eicon-text-align-right',
],
],
'separator' => 'before',
'default' => 'left',
'selectors' => [
'{{WRAPPER}} .form__footer' => 'text-align: {{VALUE}}',
],
] );
$this->end_controls_section();
}
private function add_form_option_controls() {
$can_register = get_option( 'users_can_register' );
$this->start_controls_section( 'section_form_controls', [
'label' => esc_html__( 'Form Controls', 'around-elementor' ),
] );
$this->add_control( 'show_form_title', [
'label' => esc_html__( 'Title', 'around-elementor' ),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
'label_off' => esc_html__( 'Hide', 'around-elementor' ),
'label_on' => esc_html__( 'Show', 'around-elementor' ),
] );
$this->add_control( 'title_tag', [
'label' => esc_html__( 'Title HTML Tag', 'around-elementor' ),
'type' => Controls_Manager::SELECT,
'options' => [
'h1' => 'H1',
'h2' => 'H2',
'h3' => 'H3',
'h4' => 'H4',
'h5' => 'H5',
'h6' => 'H6',
'div' => 'div',
'span' => 'span',
'p' => 'p',
],
'default' => 'h1',
'condition' => [
'show_form_title' => 'yes',
],
] );
$this->add_control( 'show_form_description', [
'label' => esc_html__( 'Description', 'around-elementor' ),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
'label_off' => esc_html__( 'Hide', 'around-elementor' ),
'label_on' => esc_html__( 'Show', 'around-elementor' ),
] );
$this->add_control( 'show_labels', [
'label' => esc_html__( 'Login Form Labels', 'around-elementor' ),
'type' => Controls_Manager::SWITCHER,
'default' => 'no',
'label_off' => esc_html__( 'Hide', 'around-elementor' ),
'label_on' => esc_html__( 'Show', 'around-elementor' ),
] );
if ( $can_register ) :
$this->add_control( 'show_register_labels', [
'label' => esc_html__( 'Register Form Labels', 'around-elementor' ),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
'label_off' => esc_html__( 'Hide', 'around-elementor' ),
'label_on' => esc_html__( 'Show', 'around-elementor' ),
] );
endif;
$this->add_control( 'button_heading', [
'label' => esc_html__( 'Submit Button', 'around-elementor' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
] );
$this->add_control( 'button_type', [
'label' => esc_html__( 'Type', 'around-elementor' ),
'type' => Controls_Manager::SELECT,
'default' => 'primary',
'options' => [
'primary' => esc_html__( 'Primary', 'around-elementor' ),
'secondary' => esc_html__( 'Secondary', 'around-elementor' ),
'success' => esc_html__( 'Success', 'around-elementor' ),
'danger' => esc_html__( 'Danger', 'around-elementor' ),
'warning' => esc_html__( 'Warning', 'around-elementor' ),
'info' => esc_html__( 'Info', 'around-elementor' ),
'dark' => esc_html__( 'Dark', 'around-elementor' ),
'link' => esc_html__( 'Link', 'around-elementor' ),
'gradient' => esc_html__( 'Gradient', 'around-elementor' ),
],
] );
$this->add_control( 'button_size', [
'label' => esc_html__( 'Size', 'around-elementor' ),
'type' => Controls_Manager::SELECT,
'options' => [
'sm' => esc_html__( 'Small', 'around-elementor' ),
'' => esc_html__( 'Base', 'around-elementor' ),
'lg' => esc_html__( 'Large', 'around-elementor' ),
'block' => esc_html__( 'Block', 'around-elementor' ),
],
'style_transfer' => true,
'default' => '',
] );
$this->add_control( 'button_css_id', [
'label' => esc_html__( 'Button ID', 'around-elementor' ),
'type' => Controls_Manager::TEXT,
'dynamic' => [
'active' => true,
],
'default' => '',
'title' => esc_html__( 'Add your custom id WITHOUT the Pound key. e.g: my-id', 'around-elementor' ),
'description' => esc_html__( 'Please make sure the ID is unique and not used elsewhere on the page this form is displayed. This field allows <code>A-z 0-9</code> & underscore chars without spaces.', 'around-elementor' ),
'separator' => 'before',
] );
$this->end_controls_section();
}
private function form_fields_render_attributes() {
$settings = $this->get_settings();
$unique_id = uniqid();
$can_register = get_option( 'users_can_register' );
$this->add_render_attribute( 'button_text', 'class', [
'elementor-login__button',
'btn',
'btn-block',
'btn-primary'
] );
$this->add_render_attribute( 'register_button_text', 'class', [
'ar-register__button',
'btn',
'btn-block',
'btn-primary',
'w-50'
] );
$this->add_render_attribute( 'lost_button_text', 'class', [
'ar-lost__button',
'btn',
'btn-primary'
] );
if ( ! empty( $settings['button_type'] ) ) {
$this->add_render_attribute( 'button_text', 'class', 'btn-' . $settings['button_type'] );
}
if ( ! empty( $settings['button_radius'] ) ) {
if ( $settings['button_radius'] == 'rounded-0' ) {
$this->add_render_attribute( 'button_text', 'class', $settings['button_radius'] );
} else if ( $settings['button_radius'] == 'card-btn' ) {
$this->add_render_attribute( 'button_text', 'class', $settings['button_radius'] );
} else {
$this->add_render_attribute( 'button_text', 'class', 'btn-' . $settings['button_radius'] );
}
}
if ( ! empty( $settings['button_size'] ) ) {
$this->add_render_attribute( 'button_text', 'class', 'btn-' . $settings['button_size'] );
}
if ( ! empty( $settings[ 'button_classes' ] ) ) {
$this->add_render_attribute( 'button_text', 'class', $settings['button_classes'] );
}
$this->add_render_attribute(
[
'wrapper' => [
'class' => [
'ar-form-fields-wrapper',
],
],
'field-group' => [
'class' => [
'elementor-field-type-text',
'elementor-field-group',
'elementor-col-100',
'input-group-overlay',
'form-group',
],
],
'password-field-group' => [
'class' => [
'elementor-field-type-text',
'elementor-field-group',
'elementor-col-100',
'input-group-overlay',
'cs-password-toggle',
'form-group',
],
],
'button' => [
'class' => [
'ar-button',
],
'name' => 'login',
],
'user_label' => [
'for' => 'user-' . $unique_id,
],
'user_input' => [
'type' => 'text',
'name' => 'username',
'id' => 'user-' . $unique_id,
'placeholder' => $settings['user_placeholder'],
'class' => [
'form-control prepended-form-control',
],
'value' => (! empty( $_POST['username'] ) ) ? esc_attr( wp_unslash( $_POST['username'] ) ) : ''
],
'password_label' => [
'for' => 'password-' . $unique_id,
],
'password_input' => [
'type' => 'password',
'name' => 'password',
'id' => 'password-' . $unique_id,
'placeholder' => $settings['password_placeholder'],
'class' => [
'form-control prepended-form-control',
],
],
'user_forget_password_label' => [
'for' => 'recoverSrEmail-' . $unique_id,
],
'user_forget_password_input' => [
'type' => 'text',
'name' => 'user_login',
'id' => 'recoverSrEmail-' . $unique_id,
'placeholder' => $settings['user_placeholder'],
'class' => [
'form-control',
],
],
'user_register_label' => [
'for' => 'reg_username-' . $unique_id,
],
'user_register_input' => [
'type' => 'text',
'name' => 'username',
'id' => 'reg_username-' . $unique_id,
'placeholder' => $settings['register_email_placeholder'],
'class' => [
'form-control prepended-form-control',
],
],
'register_password_label' => [
'for' => 'signupSrPassword-' . $unique_id,
],
'register_password_input' => [
'type' => 'password',
'name' => 'password',
'id' => 'signupSrPassword-' . $unique_id,
'placeholder' => $settings['register_password_placeholder'],
'class' => [
'form-control',
],
],
'email_register_label' => [
'for' => 'reg_email-' . $unique_id,
],
'email_register_input' => [
'type' => 'email',
'name' => 'email',
'id' => 'reg_email-' . $unique_id,
'placeholder' => $settings['register_email_placeholder'],
'class' => [
'form-control',
],
],
'register_confirm_password_label' => [
'for' => 'signupSrConfirmPassword-' . $unique_id,
],
'register_confirm_password_input' => [
'type' => 'password',
'name' => 'confirmPassword',
'id' => 'signupSrConfirmPassword-' . $unique_id,
'placeholder' => $settings['register_confirm_password_placeholder'],
'class' => [
'form-control',
],
],
//TODO: add unique ID
'label_user' => [
'for' => 'user',
'class' => 'elementor-field-label',
],
'label_password' => [
'for' => 'password',
'class' => 'elementor-field-label',
],
]
);
if ( ! $settings['show_labels'] ) {
$this->add_render_attribute( 'label', 'class', 'elementor-screen-only' );
}
if ( ! $settings['show_register_labels'] ) {
$this->add_render_attribute( 'label', 'class', 'elementor-screen-only' );
}
$this->add_render_attribute( 'field-group', 'class', 'elementor-field-required' )
->add_render_attribute( 'input', 'required', true )
->add_render_attribute( 'input', 'aria-required', 'true' );
}
private function add_login_form_controls() {
$can_register = get_option( 'users_can_register' );
$this->start_controls_section( 'section_login', [
'label' => esc_html__( 'Login Form', 'around-elementor' ),
'condition' => [
'display' => [ 'all', 'login' ]
]
] );
$this->add_control(
'login_title', [
'label' => esc_html__( 'Form Title', 'around-elementor' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
'default' => esc_html__( 'Sign in', 'around-elementor' ),
'placeholder' => esc_html__( 'Title', 'around-elementor' ),
'condition' => [
'show_form_title' => 'yes',
],
]
);
$this->add_control(
'login_description', [
'label' => esc_html__( 'Form Description', 'around-elementor' ),
'type' => Controls_Manager::TEXTAREA,
'default' => esc_html__( 'Sign in to your account using email and password provided during registration.', 'around-elementor' ),
'placeholder' => esc_html__( 'Description', 'around-elementor' ),
'condition' => [
'show_form_description' => 'yes',
],
]
);
$this->add_control( 'user_label', [
'label' => esc_html__( 'Username Label', 'around-elementor' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
'separator' => 'before',
'default' => esc_html__( 'Email Address', 'around-elementor' ),
'condition' => [
'show_labels' => 'yes',
],
] );
$this->add_control( 'user_placeholder', [
'label' => esc_html__( 'Username Placeholder', 'around-elementor' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
'default' => esc_html__( 'Email', 'around-elementor' ),
] );
$this->add_control( 'password_label', [
'label' => esc_html__( 'Password Label', 'around-elementor' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
'separator' => 'before',
'default' => esc_html__( 'Password', 'around-elementor' ),
'condition' => [
'show_labels' => 'yes',
],
] );
$this->add_control( 'password_placeholder', [
'label' => esc_html__( 'Password Placeholder', 'around-elementor' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
'default' => esc_html__( 'Password', 'around-elementor' ),
] );
$this->add_control( 'show_lost_password', [
'label' => esc_html__( 'Password Reset Link', 'around-elementor' ),
'separator' => 'before',
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
'label_off' => esc_html__( 'Hide', 'around-elementor' ),
'label_on' => esc_html__( 'Show', 'around-elementor' ),
] );
$this->add_control( 'password_reset_text', [
'label' => esc_html__( 'Password Reset Text', 'around-elementor' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
'default' => esc_html__( 'Forgot password?', 'around-elementor' ),
'label_off' => esc_html__( 'Hide', 'around-elementor' ),
'label_on' => esc_html__( 'Show', 'around-elementor' ),
'condition' => [ 'show_lost_password' => 'yes' ]
] );
$this->add_control( 'password_reset_link', [
'label' => esc_html__( 'Password Reset Page', 'around-elementor' ),
'type' => Controls_Manager::URL,
'default' => [ 'url' => '#' ],
'dynamic' => [ 'active' => true ],
'condition' => [ 'display!' => 'all', 'show_lost_password' => 'yes' ],
] );
$this->add_control( 'show_remember_me', [
'label' => esc_html__( 'Remember Me', 'around-elementor' ),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
'separator' => 'before',
'label_off' => esc_html__( 'Hide', 'around-elementor' ),
'label_on' => esc_html__( 'Show', 'around-elementor' ),
] );
$this->add_control( 'button_text', [
'label' => esc_html__( 'Login Button Text', 'around-elementor' ),
'label_block' => true,
'separator' => 'before',
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'Sign in', 'around-elementor' ),
] );
if ( $can_register ) :
$this->add_control( 'show_register', [
'label' => esc_html__( 'Registration Link', 'around-elementor' ),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
'separator' => 'before',
'label_off' => esc_html__( 'Hide', 'around-elementor' ),
'label_on' => esc_html__( 'Show', 'around-elementor' ),
] );
$this->add_control( 'register_link_intro', [
'label' => esc_html__( 'Registration Page Intro', 'around-elementor' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'Don\'t have an account?', 'around-elementor' ),
'condition' => [ 'show_register' => 'yes' ],
] );
$this->add_control( 'register_link_text', [
'label' => esc_html__( 'Registration Link Text', 'around-elementor' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'Sign up', 'around-elementor' ),
'condition' => [ 'show_register' => 'yes' ],
] );
$this->add_control( 'register_link', [
'label' => esc_html__( 'Registration Page Link', 'around-elementor' ),
'type' => Controls_Manager::URL,
'default' => [ 'url' => '#' ],
'dynamic' => [ 'active' => true ],
'condition' => [ 'display!' => 'all', 'show_register' => 'yes' ],
] );
endif;
$this->end_controls_section();
}
private function add_register_form_controls() {
$can_register = get_option( 'users_can_register' );
if ( $can_register ) :
$this->start_controls_section( 'section_register', [
'label' => esc_html__( 'Register Form', 'around-elementor' ),
'condition' => [ 'display' => [ 'all', 'register' ] ]
] );
$this->add_control( 'register_title', [
'label' => esc_html__( 'Form Title', 'around-elementor' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
'default' => esc_html__( 'Sign up', 'around-elementor' ),
'placeholder' => esc_html__( 'Title', 'around-elementor' ),
'condition' => [ 'show_form_title' => 'yes' ],
] );
$this->add_control( 'register_description', [
'label' => esc_html__( 'Form Description', 'around-elementor' ),
'type' => Controls_Manager::TEXTAREA,
'default' => esc_html__( 'Registration takes less than a minute but gives you full control over your orders.
', 'around-elementor' ),
'placeholder' => esc_html__( 'Description', 'around-elementor' ),
'condition' => [ 'show_form_description' => 'yes' ],
'separator' => 'after',
] );
$this->add_control( 'register_email_label', [
'label' => esc_html__( 'Email Label', 'around-elementor' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'Email Address', 'around-elementor' ),
'condition' => [ 'show_register_labels' => 'yes' ]
] );
$this->add_control( 'register_email_placeholder', [
'label' => esc_html__( 'Email Placeholder', 'around-elementor' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'Email', 'around-elementor' ),
'separator' => 'after',
] );
$this->add_control( 'register_password_label', [
'label' => esc_html__( 'Pasword Label', 'around-elementor' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'Password', 'around-elementor' ),
'condition' => [ 'show_register_labels' => 'yes' ]
] );
$this->add_control( 'register_password_placeholder', [
'label' => esc_html__( 'Password Placeholder', 'around-elementor' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'Password', 'around-elementor' ),
] );
$this->add_control( 'register_confirm_password_placeholder', [
'label' => esc_html__( 'Confirm Password Label', 'around-elementor' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'Confirm Password', 'around-elementor' ),
'separator' => 'after',
] );
$this->add_control( 'register_button_text', [
'label' => esc_html__( 'Register Button Text', 'around-elementor' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
'default' => esc_html__( 'Sign up', 'around-elementor' ),
] );
$this->add_control( 'show_login', [
'label' => esc_html__( 'Login Link', 'around-elementor' ),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
'separator' => 'before',
'label_off' => esc_html__( 'Hide', 'around-elementor' ),
'label_on' => esc_html__( 'Show', 'around-elementor' ),
] );
$this->add_control( 'login_link_intro', [
'label' => esc_html__( 'Login Page Intro', 'around-elementor' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'Already have an account?', 'around-elementor' ),
'condition' => [ 'show_login' => 'yes' ],
] );
$this->add_control( 'login_link_text', [
'label' => esc_html__( 'Login Link Text', 'around-elementor' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'Sign in', 'around-elementor' ),
'condition' => [ 'show_login' => 'yes' ],
] );
$this->add_control( 'login_link', [
'label' => esc_html__( 'Login Page Link', 'around-elementor' ),
'type' => Controls_Manager::URL,
'default' => [ 'url' => '#' ],
'dynamic' => [ 'active' => true ],
'condition' => [ 'display!' => 'all', 'show_login' => 'yes' ],
] );
$this->end_controls_section();
endif;
}
private function add_password_reset_form_controls() {
$this->start_controls_section( 'section_password_reset', [
'label' => esc_html__( 'Password Reset Form', 'around-elementor' ),
'condition' => [ 'display' => [ 'all', 'forgot' ] ]
] );
$this->add_control( 'password_title', [
'label' => esc_html__( 'Form Title', 'around-elementor' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'Forgot your password?', 'around-elementor' ),
'placeholder' => esc_html__( 'Title', 'around-elementor' ),
'condition' => [ 'show_form_title' => 'yes' ],
] );
$this->add_control( 'password_description', [
'label' => esc_html__( 'Form Description', 'around-elementor' ),
'label_block' => true,
'type' => Controls_Manager::TEXTAREA,
'default' => esc_html__( 'Change your password in three easy steps. This helps to keep your new password secure.', 'around-elementor' ),
'placeholder' => esc_html__( 'Description', 'around-elementor' ),
'condition' => [ 'show_form_description' => 'yes' ],
] );
$this->add_control( 'show_change_password_steps', [
'label' => esc_html__( 'Show Change Passwords Steps', 'around-elementor' ),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
'separator' => 'before',
'label_off' => esc_html__( 'Hide', 'around-elementor' ),
'label_on' => esc_html__( 'Show', 'around-elementor' ),
] );
$repeater = new Repeater();
$repeater->add_control(
'item_text',
[
'label' => esc_html__( 'List Text', 'around-elementor' ),
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'List Item', 'around-elementor' ),
]
);
$this->add_control(
'steps',
[
'type' => Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'default' => [
[
'item_text' => esc_html__( 'Fill in your email address below.', 'around-elementor' ),
],
[
'item_text' => esc_html__( "We'll email you a temporary code.", 'around-elementor' ),
],
[
'item_text' => esc_html__( 'Use the code to change your password on our secure website.', 'around-elementor' ),
],
],
'condition' => [ 'show_change_password_steps' => 'yes' ],
'title_field' => '{{{ item_text }}}',
]
);
$this->add_control( 'reset_pasword_button_text', [
'label' => esc_html__( 'Button Text', 'around-elementor' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'Get new password', 'around-elementor' ),
] );
$this->add_control( 'rp_show_login', [
'label' => esc_html__( 'Login Link', 'around-elementor' ),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
'separator' => 'before',
'label_off' => esc_html__( 'Hide', 'around-elementor' ),
'label_on' => esc_html__( 'Show', 'around-elementor' ),
] );
$this->add_control( 'rp_login_link_intro', [
'label' => esc_html__( 'Login Page Intro', 'around-elementor' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'Remember your password?', 'around-elementor' ),
'condition' => [ 'rp_show_login' => 'yes' ],
] );
$this->add_control( 'rp_login_link_text', [
'label' => esc_html__( 'Login Link Text', 'around-elementor' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'Log in', 'around-elementor' ),
'condition' => [ 'rp_show_login' => 'yes' ],
] );
$this->add_control( 'rp_login_link', [
'label' => esc_html__( 'Login Page Link', 'around-elementor' ),
'type' => Controls_Manager::URL,
'default' => [ 'url' => '#' ],
'dynamic' => [ 'active' => true ],
'condition' => [ 'display!' => 'all', 'rp_show_login' => 'yes' ],
] );
$this->end_controls_section();
}
private function add_additional_options_controls() {
$this->start_controls_section( 'section_login_content', [
'label' => esc_html__( 'Additional Options', 'around-elementor' ),
] );
$this->add_control( 'redirect_after_login', [
'label' => esc_html__( 'Redirect After Login', 'around-elementor' ),
'type' => Controls_Manager::SWITCHER,
'default' => '',
'label_off' => esc_html__( 'Off', 'around-elementor' ),
'label_on' => esc_html__( 'On', 'around-elementor' ),
] );
$this->add_control( 'redirect_url', [
'type' => Controls_Manager::URL,
'show_label' => false,
'options' => false,
'separator' => false,
'placeholder' => esc_html__( 'https://your-link.com', 'around-elementor' ),
'description' => esc_html__( 'Note: Because of security reasons, you can ONLY use your current domain here.', 'around-elementor' ),
'condition' => [ 'redirect_after_login' => 'yes' ],
'default' => [ 'url' => '#' ],
] );
$this->add_control( 'redirect_after_logout', [
'label' => esc_html__( 'Redirect After Logout', 'around-elementor' ),
'type' => Controls_Manager::SWITCHER,
'default' => '',
'label_off' => esc_html__( 'Off', 'around-elementor' ),
'label_on' => esc_html__( 'On', 'around-elementor' ),
] );
$this->add_control( 'redirect_logout_url', [
'type' => Controls_Manager::URL,
'show_label' => false,
'options' => false,
'separator' => false,
'placeholder' => esc_html__( 'https://your-link.com', 'around-elementor' ),
'description' => esc_html__( 'Note: Because of security reasons, you can ONLY use your current domain here.', 'around-elementor' ),
'condition' => [ 'redirect_after_logout' => 'yes' ],
] );
$this->end_controls_section();
}
protected function render() {
$settings = $this->get_settings();
$current_url = remove_query_arg( 'fake_arg' );
$logout_redirect = $current_url;
$show_title = $settings['show_form_title'];
$show_description = $settings['show_form_description'];
$title_tag = $settings['title_tag'];
$display = $settings['display'];
$unique_id = uniqid();
$login_form_id = 'signin-view' . $unique_id;
$register_form_id = 'signup-view-' . $unique_id;
$lost_pwd_form_id = 'lost-password-' . $unique_id;
/**
* Add Form IDs to settings data
*/
$settings['login_form_id'] = $login_form_id;
$settings['register_form_id'] = $register_form_id;
$settings['lost_pwd_form_id'] = $lost_pwd_form_id;
if ( 'yes' === $settings['redirect_after_logout'] && ! empty( $settings['redirect_logout_url']['url'] ) ) {
$logout_redirect = $settings['redirect_logout_url']['url'];
}
if ( is_user_logged_in() && ! Plugin::$instance->editor->is_edit_mode() ) {
$current_user = wp_get_current_user();
echo '<div class="elementor-login elementor-login__logged-in-message sigin-container py-5 py-md-7" style="flex: 1 0 auto;">' .
sprintf( __( 'You are Logged in as %1$s (<a href="%2$s">Logout</a>)', 'around-elementor' ), $current_user->display_name, wp_logout_url( $logout_redirect ) ) .
'</div>';
return;
}
$this->form_fields_render_attributes();
if ( 'register' === $display ) {
$this->render_register_form( $settings );
return;
} elseif ( 'login' === $display ) {
$this->render_login_form( $settings );
return;
} elseif ( 'forgot' === $display ) {
$this->render_password_reset_form( $settings );
return;
}
$show = ( get_option( 'users_can_register' ) && 'yes' === $settings['show_register'] );
$column_classes='';
if ( ! $show ) {
$column_classes=' mx-auto';
}
?>
<div class="container py-5 py-md-7">
<div class="row align-items-center pt-2">
<div class="col-md-6 col-lg-5 mb-5 mb-md-0<?php echo esc_attr( $column_classes ); ?>">
<div class="cs-view show" id="<?php echo esc_attr( $login_form_id ); ?>">
<div class="bg-secondary px-4 py-5 p-sm-5 rounded-lg">
<?php $this->render_login_form( $settings ); ?>
</div>
</div>
<div class="cs-view" id="<?php echo esc_attr( $lost_pwd_form_id ); ?>">
<?php $this->render_password_reset_form( $settings ); ?>
</div>
</div>
<?php if ( get_option( 'users_can_register' ) ): ?>
<div class="col-md-6 offset-lg-1 style-3">
<?php $this->render_register_form( $settings ); ?>
</div>
<?php endif; ?>
</div>
</div><?php
}
private function render_form_header( $title, $desc, $settings ) {
$show_title = ( 'yes' === $settings['show_form_title'] );
$show_desc = ( 'yes' === $settings['show_form_description'] );
$title_tag = $settings['title_tag'];
$this->add_render_attribute( 'form_title', 'class', 'form-header__title' );
if ( ! empty( $settings['title_css'] ) ) {
$this->add_render_attribute( 'form_title', 'class', $settings['title_css'] );
}
$this->add_render_attribute( 'form_desc', 'class', 'form-header__desc' );
if ( ! empty( $settings['description_css'] ) ) {
$this->add_render_attribute( 'form_desc', 'class', $settings['description_css'] );
}
?><?php if ( $show_title && ! empty( $title ) ): ?>
<<?php echo $title_tag . ' ' . $this->get_render_attribute_string( 'form_title' ); ?>><?php echo esc_html( $title ); ?></<?php echo $title_tag; ?>>
<?php endif; ?>
<?php if ( $show_desc && ! empty( $desc ) ): ?>
<p <?php echo $this->get_render_attribute_string( 'form_desc' ); ?>><?php echo esc_html( $desc ); ?></p>
<?php endif;
}
private function render_label( $render_key, $settings, $label_key = '' ) {
$show_label = ( 'yes' === $settings['show_labels'] );
if ( ! $show_label ) {
$this->add_render_attribute( $render_key, 'class', 'sr-only' );
}
if ( empty( $label_key ) ) {
$label_key = $render_key;
}
?><label <?php echo $this->get_render_attribute_string( $render_key );?>>
<?php print( $settings[ $label_key ] ); ?>
</label><?php
}
private function render_register_label( $render_key, $settings, $label_key = '' ) {
$show_label = ( 'yes' === $settings['show_register_labels'] );
if ( ! $show_label ) {
$this->add_render_attribute( $render_key, 'class', 'sr-only' );
}
if ( empty( $label_key ) ) {
$label_key = $render_key;
}
?><label <?php echo $this->get_render_attribute_string( $render_key );?>>
<?php print( $settings[ $label_key ] ); ?>
</label><?php
}
private function render_lost_password_form_link( $settings ) {
$show = ( 'yes' === $settings['show_lost_password'] );
$form_id = $settings['lost_pwd_form_id'];
$link_text = $settings['password_reset_text'];
if ( ! $show ) {
return;
}
$this->add_render_attribute( 'lost_password_form_link', [
'id' => 'forgot-password-tab',
'class' => [ 'elementor-lost-password', 'nav-link-style font-size-ms' ]
] );
if ( 'all' === $settings['display'] ) {
$this->add_render_attribute( 'lost_password_form_link', 'data-view', '#' . $form_id );
$this->add_render_attribute( 'lost_password_form_link', 'href', '#' );
$this->add_render_attribute( 'lost_password_form_link', 'class', 'login-signup-view-switcher' );
} else {
$this->add_link_attributes( 'lost_password_form_link', $settings['password_reset_link'] );
}
printf( '<a %1$s>%2$s</a>', $this->get_render_attribute_string( 'lost_password_form_link' ), $link_text );
}
private function render_register_form_link( $settings ) {
$show = ( get_option( 'users_can_register' ) && 'yes' === $settings['show_register'] );
$form_id = $settings['register_form_id'];
$link_intro = $settings['register_link_intro'];
$link_text = $settings['register_link_text'];
if ( ! $show ) {
return;
}
$this->add_render_attribute( 'register_form_link', [
'class' => [ 'd-inline-block', 'login' ]
] );
if ( 'all' === $settings['display'] ) {
$this->add_render_attribute( 'register_form_link', 'data-view', '#' . $form_id );
$this->add_render_attribute( 'register_form_link', 'href', '#' );
$this->add_render_attribute( 'register_form_link', 'class', 'font-weight-medium' );
} else {
$this->add_link_attributes( 'register_form_link', $settings['register_link'] );
}
$link_html = sprintf( '<a %1$s>%2$s</a>', $this->get_render_attribute_string( 'register_form_link' ), $link_text );
?><p class="font-size-sm pt-3 mb-0 form__footer">
<?php printf( '%s %s', $link_intro, $link_html ); ?>
</p><?php
}
private function render_login_form_link( $settings ) {
$show = ( 'yes' === $settings['show_login'] );
$form_id = $settings['login_form_id'];
$link_intro = $settings['login_link_intro'];
$link_text = $settings['login_link_text'];
if ( ! $show ) {
return;
}
$this->add_render_attribute( 'login_form_link', [
'class' => [ 'login' ]
] );
if ( 'all' === $settings['display'] ) {
$this->add_render_attribute( 'login_form_link', 'data-view', '#' . $form_id );
$this->add_render_attribute( 'login_form_link', 'href', '#' );
$this->add_render_attribute( 'login_form_link', 'class', 'font-weight-medium' );
} else {
$this->add_link_attributes( 'login_form_link', $settings['login_link'] );
}
$link_html = sprintf( '<a %1$s>%2$s</a>', $this->get_render_attribute_string( 'login_form_link' ), $link_text );
?><p class="font-size-sm pt-3 mb-0 form__footer">
<?php printf( '%s %s', $link_intro, $link_html ); ?>
</p><?php
}
private function render_rp_login_form_link( $settings ) {
$show = ( 'yes' === $settings['rp_show_login'] );
$form_id = $settings['login_form_id'];
$link_intro = $settings['rp_login_link_intro'];
$link_text = $settings['rp_login_link_text'];
if ( ! $show ) {
return;
}
$this->add_render_attribute( 'rp_login_form_link', [
'class' => [ 'login' ],
'id' => 'signin-view'
] );
if ( 'all' === $settings['display'] ) {
$this->add_render_attribute( 'rp_login_form_link', 'data-view', '#' . $form_id );
$this->add_render_attribute( 'rp_login_form_link', 'href', '#' );
$this->add_render_attribute( 'rp_login_form_link', 'class', 'login-signup-view-switcher' );
} else {
$this->add_link_attributes( 'rp_login_form_link', $settings['rp_login_link'] );
}
$link_html = sprintf( '<a %1$s>%2$s</a>', $this->get_render_attribute_string( 'rp_login_form_link' ), $link_text );
?><p class="font-size-sm pt-3 mb-0 form__footer">
<?php printf( '%s %s.', $link_intro, $link_html ); ?>
</p><?php
}
private function render_login_form( $settings ) {
$current_url = remove_query_arg( 'fake_arg' );
if ( 'yes' === $settings['redirect_after_login'] && ! empty( $settings['redirect_url']['url'] ) ) {
$redirect_url = $settings['redirect_url']['url'];
} else {
$redirect_url = $current_url;
}
$this->render_form_header( $settings['login_title'], $settings['login_description'], $settings );
?>
<form class="elementor-form ar-login-form login" method="post">
<?php
if ( isset( $_POST['login'] ) ) {
// show any error messages after form submission
?><div class="mb-3"><?php around_show_error_messages(); ?></div><?php
}
?>
<input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_url ); ?>">
<div <?php echo $this->get_render_attribute_string( 'wrapper' ); ?>>
<div <?php echo $this->get_render_attribute_string( 'field-group' ); ?>>
<?php $this->render_label( 'user_label', $settings ); ?>
<div class="input-group">
<div class="input-group-prepend-overlay">
<span class="input-group-text"><i class="fe-mail"></i></span>
</div>
<input <?php echo $this->get_render_attribute_string( 'user_input' );?>>
</div>
</div>
<div <?php echo $this->get_render_attribute_string( 'password-field-group' ); ?>>
<?php $this->render_label( 'password_label', $settings ); ?>
<div class="input-group">
<div class="input-group-prepend-overlay">
<span class="input-group-text"><i class="fe-lock"></i></span>
</div>
<input <?php echo $this->get_render_attribute_string( 'password_input' ); ?>>
<label class="cs-password-toggle-btn">
<input class="custom-control-input" type="checkbox"><i class="fe-eye cs-password-toggle-indicator"></i><span class="sr-only"><?php echo esc_html__('Show password', 'around-elementor');?></span>
</label>
</div>
</div>
<div class="d-flex justify-content-between align-items-center form-group">
<?php if ( 'yes' === $settings['show_remember_me'] ) : ?>
<div class="custom-control custom-checkbox elementor-field-type-checkbox elementor-field-group elementor-col-100 elementor-remember-me">
<input class="custom-control-input" type="checkbox" id="keep-signed-2">
<label class="custom-control-label p-0" for="keep-signed-2"><?php echo esc_html__( 'Keep me signed in', 'around-elementor' ); ?></label>
</div>
<?php endif; ?>
<?php $this->render_lost_password_form_link( $settings ); ?>
</div>
<?php if ( ! empty( $settings['button_text'] ) ) : ?>
<input type="hidden" name="around_login_nonce" value="<?php echo wp_create_nonce('around-login-nonce'); ?>"/>
<input type="hidden" name="around_login_check" value="1"/>
<button type="submit" name="login" <?php echo $this->get_render_attribute_string( 'button_text' ); ?>><?php echo $settings['button_text']; ?></button>
<?php endif; ?>
</div>
</form><?php
}
private function render_register_form( $settings ) {
$can_register = get_option( 'users_can_register' );
if ( ! $can_register ) {
return;
}
$this->render_form_header( $settings['register_title'], $settings['register_description'], $settings );
?>
<form class="ar-register elementor-form register" method="post">
<?php
if ( isset( $_POST['register'] ) ) {
?><div class="mb-3"><?php around_show_error_messages(); ?></div><?php
}
?>
<div <?php echo $this->get_render_attribute_string( 'wrapper' ); ?>>
<div <?php echo $this->get_render_attribute_string( 'field-group' ); ?>>
<?php $this->render_register_label( 'email_register_label', $settings, 'register_email_label' ); ?>
<input <?php echo $this->get_render_attribute_string( 'email_register_input' );?>>
</div>
<?php if ( apply_filters( 'around_register_password_enabled', true ) ) : ?>
<div <?php echo $this->get_render_attribute_string( 'password-field-group' ); ?>>
<?php $this->render_register_label( 'register_password_label', $settings, 'register_password_label' ); ?>
<div class="cs-password-toggle">
<input <?php echo $this->get_render_attribute_string( 'register_password_input' ); ?>>
<label class="cs-password-toggle-btn">
<input class="custom-control-input" type="checkbox"><i class="fe-eye cs-password-toggle-indicator"></i><span class="sr-only"><?php echo esc_html__('Show password', 'around-elementor');?></span>
</label>
</div>
</div>
<div <?php echo $this->get_render_attribute_string( 'password-field-group' ); ?>>
<?php $this->render_register_label( 'register_password_label', $settings, 'register_password_label' ); ?>
<div class="cs-password-toggle">
<input <?php echo $this->get_render_attribute_string( 'register_confirm_password_input' ); ?>>
<label class="cs-password-toggle-btn">
<input class="custom-control-input" type="checkbox"><i class="fe-eye cs-password-toggle-indicator"></i><span class="sr-only"><?php echo esc_html__('Show password', 'around-elementor');?></span>
</label>
</div>
</div>
<?php else : ?>
<p><?php echo esc_html__( 'A password will be sent to your email address.', 'around-elementor' ); ?></p>
<?php endif; ?>
<?php if ( ! empty( $settings['button_text'] ) ) : ?>
<input type="hidden" name="around_register_nonce" value="<?php echo wp_create_nonce('around-register-nonce'); ?>"/>
<input type="hidden" name="around_register_check" value="1"/>
<button type="submit" <?php echo $this->get_render_attribute_string( 'register_button_text' ); ?> name="register"><?php echo $settings['register_button_text']; ?></button>
<?php endif; ?>
</div>
</form><?php
}
private function render_change_password_steps( $settings ) { ?>
<?php if ( ! empty( $settings['steps'] ) && 'yes' === $settings['show_change_password_steps'] ) : ?>
<ul class="list-unstyled font-size-sm pb-1 mb-4">
<?php foreach ( $settings['steps'] as $index => $item ) :
$counter = $index+1;
$repeater_setting_key = $this->get_repeater_setting_key( 'item_text', 'steps', $index );
$this->add_render_attribute( $repeater_setting_key, 'class', [
'around-elementor-steps', ''
] );
$this->add_inline_editing_attributes( $repeater_setting_key );
?>
<li class="ar-steps elementor-repeater-item-<?php echo $item['_id']; ?> d-flex">
<?php if ( ! empty( $item['item_text'] ) ) : ?>
<span class="text-primary font-weight-semibold mr-1"><?php echo esc_attr( $counter ); ?>.</span>
<span <?php echo $this->get_render_attribute_string( $repeater_setting_key ); ?>><?php echo $item['item_text']; ?></span>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif;
}
private function render_password_reset_form( $settings ) {
$this->render_form_header( $settings['password_title'], $settings['password_description'], $settings );
$this->render_change_password_steps( $settings ); ?>
<div class="bg-secondary rounded-lg px-3 py-4 p-sm-4">
<form class="ar-forget-password elementor-form forget-password p-2" name="lostpasswordform" method="post">
<?php if ( isset( $_POST['recoverPassword'] ) ) { ?>
<div class="mb-3">
<?php around_show_error_messages(); ?>
<?php around_show_success_messages(); ?>
</div>
<?php } ?>
<div <?php echo $this->get_render_attribute_string( 'wrapper' ); ?>>
<div <?php echo $this->get_render_attribute_string( 'field-group' ); ?>>
<?php $this->render_label( 'user_forget_password_label', $settings, 'user_label' ); ?>
<input <?php echo $this->get_render_attribute_string( 'user_forget_password_input' );?>>
</div>
<?php if ( ! empty( $settings['button_text'] ) ) : ?>
<input type="hidden" name="around_lost_password_nonce" value="<?php echo wp_create_nonce('around-lost-password-nonce'); ?>"/>
<input type="hidden" name="around_lost_password_check" value="1"/>
<?php wp_nonce_field( 'ajax-lost-password-nonce', 'lost-password-security' ); ?>
<button type="submit" name="recoverPassword" <?php echo $this->get_render_attribute_string( 'lost_button_text' ); ?>><?php echo $settings['reset_pasword_button_text']; ?></button>
<?php endif; ?>
</div>
<?php $this->render_rp_login_form_link( $settings ); ?>
</form></div><?php
}
public function render_plain_content() {}
}