| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPDM\Elementor\Widgets; |
| 4 |
|
| 5 |
/** |
| 6 |
* Login Form Widget. |
| 7 |
* Displays a user login form. |
| 8 |
*/ |
| 9 |
class LoginFormWidget extends BaseWidget |
| 10 |
{ |
| 11 |
/** |
| 12 |
* Expected settings keys for this widget. |
| 13 |
*/ |
| 14 |
private const SETTINGS_KEYS = ['redirect', 'logo', 'regurl', 'note_before', 'note_after']; |
| 15 |
|
| 16 |
/** |
| 17 |
* Settings sanitization rules. |
| 18 |
*/ |
| 19 |
private const SANITIZERS = [ |
| 20 |
'redirect' => 'url', |
| 21 |
'logo' => 'url', |
| 22 |
'regurl' => 'url', |
| 23 |
'note_before' => 'html', |
| 24 |
'note_after' => 'html', |
| 25 |
]; |
| 26 |
|
| 27 |
public function get_name() |
| 28 |
{ |
| 29 |
return 'wpdmloginform'; |
| 30 |
} |
| 31 |
|
| 32 |
public function get_title() |
| 33 |
{ |
| 34 |
return __('Login Form', WPDM_ELEMENTOR); |
| 35 |
} |
| 36 |
|
| 37 |
public function get_icon() |
| 38 |
{ |
| 39 |
return 'eicon-site-identity'; |
| 40 |
} |
| 41 |
|
| 42 |
protected function register_controls() |
| 43 |
{ |
| 44 |
$this->start_controls_section( |
| 45 |
'content_section', |
| 46 |
[ |
| 47 |
'label' => __('Parameters', WPDM_ELEMENTOR), |
| 48 |
'tab' => \Elementor\Controls_Manager::TAB_CONTENT, |
| 49 |
] |
| 50 |
); |
| 51 |
|
| 52 |
$this->add_control( |
| 53 |
'redirect', |
| 54 |
[ |
| 55 |
'label' => __('Redirect URL', WPDM_ELEMENTOR), |
| 56 |
'type' => \Elementor\Controls_Manager::TEXT, |
| 57 |
'input_type' => 'url', |
| 58 |
'placeholder' => __('Redirect URL', WPDM_ELEMENTOR), |
| 59 |
'description' => __('URL to redirect after login', WPDM_ELEMENTOR) |
| 60 |
] |
| 61 |
); |
| 62 |
|
| 63 |
$this->add_control( |
| 64 |
'logo', |
| 65 |
[ |
| 66 |
'label' => __('Logo URL', WPDM_ELEMENTOR), |
| 67 |
'type' => \Elementor\Controls_Manager::TEXT, |
| 68 |
'input_type' => 'url', |
| 69 |
'placeholder' => __('Logo URL', WPDM_ELEMENTOR), |
| 70 |
'description' => __('Image URL to show on top of the form', WPDM_ELEMENTOR) |
| 71 |
] |
| 72 |
); |
| 73 |
|
| 74 |
$this->add_control( |
| 75 |
'regurl', |
| 76 |
[ |
| 77 |
'label' => __('Registration URL', WPDM_ELEMENTOR), |
| 78 |
'type' => \Elementor\Controls_Manager::TEXT, |
| 79 |
'input_type' => 'url', |
| 80 |
'placeholder' => __('Registration URL', WPDM_ELEMENTOR), |
| 81 |
'description' => __('Custom signup page URL for this login form', WPDM_ELEMENTOR) |
| 82 |
] |
| 83 |
); |
| 84 |
|
| 85 |
$this->add_control( |
| 86 |
'note_before', |
| 87 |
[ |
| 88 |
'label' => __('Note Before', WPDM_ELEMENTOR), |
| 89 |
'type' => \Elementor\Controls_Manager::TEXTAREA, |
| 90 |
'rows' => 3, |
| 91 |
'placeholder' => __('Text to show above the form', WPDM_ELEMENTOR), |
| 92 |
] |
| 93 |
); |
| 94 |
|
| 95 |
$this->add_control( |
| 96 |
'note_after', |
| 97 |
[ |
| 98 |
'label' => __('Note After', WPDM_ELEMENTOR), |
| 99 |
'type' => \Elementor\Controls_Manager::TEXTAREA, |
| 100 |
'rows' => 3, |
| 101 |
'placeholder' => __('Text to show below the form', WPDM_ELEMENTOR), |
| 102 |
] |
| 103 |
); |
| 104 |
|
| 105 |
$this->end_controls_section(); |
| 106 |
} |
| 107 |
|
| 108 |
protected function render() |
| 109 |
{ |
| 110 |
$settings = $this->getCleanSettings(self::SETTINGS_KEYS); |
| 111 |
$settings = $this->sanitizeSettings($settings, self::SANITIZERS); |
| 112 |
|
| 113 |
echo $this->wrapOutput( |
| 114 |
WPDM()->user->login->form($settings), |
| 115 |
'login-form-widget' |
| 116 |
); |
| 117 |
} |
| 118 |
} |
| 119 |
|