| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPDM\Elementor\Widgets; |
| 4 |
|
| 5 |
/** |
| 6 |
* Registration Form Widget. |
| 7 |
* Displays a user registration form. |
| 8 |
*/ |
| 9 |
class RegFormWidget extends BaseWidget |
| 10 |
{ |
| 11 |
/** |
| 12 |
* Expected settings keys for this widget. |
| 13 |
*/ |
| 14 |
private const SETTINGS_KEYS = ['captcha', 'verifyemail', 'autologin', 'logo']; |
| 15 |
|
| 16 |
/** |
| 17 |
* Settings sanitization rules. |
| 18 |
*/ |
| 19 |
private const SANITIZERS = [ |
| 20 |
'captcha' => 'bool', |
| 21 |
'verifyemail' => 'bool', |
| 22 |
'autologin' => 'bool', |
| 23 |
'logo' => 'url', |
| 24 |
]; |
| 25 |
|
| 26 |
public function get_name() |
| 27 |
{ |
| 28 |
return 'wpdmregform'; |
| 29 |
} |
| 30 |
|
| 31 |
public function get_title() |
| 32 |
{ |
| 33 |
return __('Registration Form', WPDM_ELEMENTOR); |
| 34 |
} |
| 35 |
|
| 36 |
public function get_icon() |
| 37 |
{ |
| 38 |
return 'eicon-person'; |
| 39 |
} |
| 40 |
|
| 41 |
protected function register_controls() |
| 42 |
{ |
| 43 |
$this->start_controls_section( |
| 44 |
'content_section', |
| 45 |
[ |
| 46 |
'label' => __('Parameters', WPDM_ELEMENTOR), |
| 47 |
'tab' => \Elementor\Controls_Manager::TAB_CONTENT, |
| 48 |
] |
| 49 |
); |
| 50 |
|
| 51 |
$this->add_control( |
| 52 |
'captcha', |
| 53 |
[ |
| 54 |
'label' => __('Show Captcha', WPDM_ELEMENTOR), |
| 55 |
'type' => \Elementor\Controls_Manager::CHOOSE, |
| 56 |
'options' => [ |
| 57 |
'0' => ['title' => __('No', WPDM_ELEMENTOR), 'icon' => 'eicon-close'], |
| 58 |
'1' => ['title' => __('Yes', WPDM_ELEMENTOR), 'icon' => 'eicon-check'] |
| 59 |
], |
| 60 |
'default' => '1' |
| 61 |
] |
| 62 |
); |
| 63 |
|
| 64 |
$this->add_control( |
| 65 |
'verifyemail', |
| 66 |
[ |
| 67 |
'label' => __('Verify Email', WPDM_ELEMENTOR), |
| 68 |
'type' => \Elementor\Controls_Manager::CHOOSE, |
| 69 |
'options' => [ |
| 70 |
'0' => ['title' => __('No', WPDM_ELEMENTOR), 'icon' => 'eicon-close'], |
| 71 |
'1' => ['title' => __('Yes', WPDM_ELEMENTOR), 'icon' => 'eicon-check'] |
| 72 |
], |
| 73 |
'default' => '1', |
| 74 |
'description' => __('Send password via email when enabled', WPDM_ELEMENTOR) |
| 75 |
] |
| 76 |
); |
| 77 |
|
| 78 |
$this->add_control( |
| 79 |
'autologin', |
| 80 |
[ |
| 81 |
'label' => __('Auto Login', WPDM_ELEMENTOR), |
| 82 |
'type' => \Elementor\Controls_Manager::CHOOSE, |
| 83 |
'options' => [ |
| 84 |
'0' => ['title' => __('No', WPDM_ELEMENTOR), 'icon' => 'eicon-close'], |
| 85 |
'1' => ['title' => __('Yes', WPDM_ELEMENTOR), 'icon' => 'eicon-check'] |
| 86 |
], |
| 87 |
'default' => '0', |
| 88 |
'description' => __('Automatically log in user after registration', WPDM_ELEMENTOR) |
| 89 |
] |
| 90 |
); |
| 91 |
|
| 92 |
$this->add_control( |
| 93 |
'logo', |
| 94 |
[ |
| 95 |
'label' => __('Logo URL', WPDM_ELEMENTOR), |
| 96 |
'type' => \Elementor\Controls_Manager::TEXT, |
| 97 |
'input_type' => 'url', |
| 98 |
'placeholder' => __('Logo URL', WPDM_ELEMENTOR), |
| 99 |
'description' => __('Image URL to show on top of the form', WPDM_ELEMENTOR) |
| 100 |
] |
| 101 |
); |
| 102 |
|
| 103 |
$this->end_controls_section(); |
| 104 |
} |
| 105 |
|
| 106 |
protected function render() |
| 107 |
{ |
| 108 |
$settings = $this->getCleanSettings(self::SETTINGS_KEYS); |
| 109 |
$settings = $this->sanitizeSettings($settings, self::SANITIZERS); |
| 110 |
|
| 111 |
echo $this->wrapOutput( |
| 112 |
WPDM()->user->register->form($settings), |
| 113 |
'registration-form-widget' |
| 114 |
); |
| 115 |
} |
| 116 |
} |
| 117 |
|