| 1 |
<?php |
| 2 |
|
| 3 |
// Exit if accessed directly |
| 4 |
if ( ! defined( 'ABSPATH' ) ) exit; |
| 5 |
|
| 6 |
require_once "class-pb-widget-base.php"; |
| 7 |
|
| 8 |
/** |
| 9 |
* Elementor widget for our wppb-recover-password shortcode |
| 10 |
*/ |
| 11 |
class PB_Elementor_Recover_Password_Widget extends PB_Elementor_Widget { |
| 12 |
|
| 13 |
/** |
| 14 |
* Get widget name. |
| 15 |
* |
| 16 |
*/ |
| 17 |
public function get_name() { |
| 18 |
return 'wppb-recover-password'; |
| 19 |
} |
| 20 |
|
| 21 |
/** |
| 22 |
* Get widget title. |
| 23 |
* |
| 24 |
*/ |
| 25 |
public function get_title() { |
| 26 |
return __( 'Recover Password', 'profile-builder' ); |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Get widget icon. |
| 31 |
* |
| 32 |
*/ |
| 33 |
public function get_icon() { |
| 34 |
return 'eicon-shortcode'; |
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* Register widget controls. |
| 39 |
* |
| 40 |
*/ |
| 41 |
protected function register_controls() { |
| 42 |
|
| 43 |
$this->start_controls_section( |
| 44 |
'pb_content_section', |
| 45 |
array( |
| 46 |
'label' => __( 'Form Settings', 'profile-builder' ), |
| 47 |
'tab' => \Elementor\Controls_Manager::TAB_CONTENT, |
| 48 |
) |
| 49 |
); |
| 50 |
|
| 51 |
if( defined( 'WPPB_PAID_PLUGIN_DIR' ) ) { |
| 52 |
$this->add_control( |
| 53 |
'pb_ajax', |
| 54 |
array( |
| 55 |
'label' => __( 'AJAX Validation', 'profile-builder' ), |
| 56 |
'type' => \Elementor\Controls_Manager::SWITCHER, |
| 57 |
'label_on' => __( 'Yes', 'profile-builder' ), |
| 58 |
'label_off' => __( 'No', 'profile-builder' ), |
| 59 |
'return_value' => 'true', |
| 60 |
'default' => 'false', |
| 61 |
) |
| 62 |
); |
| 63 |
} |
| 64 |
else { |
| 65 |
$this->add_control( |
| 66 |
'pb_recovery_no_controls_text', |
| 67 |
array( |
| 68 |
'type' => \Elementor\Controls_Manager::RAW_HTML, |
| 69 |
'raw' => __( 'There are no available controls for the Password Recovery form', 'profile-builder' ), |
| 70 |
) |
| 71 |
); |
| 72 |
} |
| 73 |
|
| 74 |
$this->end_controls_section(); |
| 75 |
|
| 76 |
// Instructions Paragraph tab |
| 77 |
$this->add_styling_control_group( |
| 78 |
'Instructions Paragraph', |
| 79 |
'', |
| 80 |
'pb_recover_password_instructions', |
| 81 |
[ |
| 82 |
'paragraph' => [ |
| 83 |
'selector' => '#wppb-recover-password p', |
| 84 |
'section_name' => 'Paragraph', |
| 85 |
] |
| 86 |
] |
| 87 |
); |
| 88 |
|
| 89 |
// User Login Style tab |
| 90 |
if( !$this->is_placeholder_labels_active() ) { |
| 91 |
$sections['label'] = [ |
| 92 |
'selector' => '#wppb-recover-password .wppb-username-email label', |
| 93 |
'section_name' => 'Label', |
| 94 |
]; |
| 95 |
} |
| 96 |
$sections['input'] = [ |
| 97 |
'selector' => '#wppb-recover-password .wppb-username-email input', |
| 98 |
'section_name' => 'Input', |
| 99 |
]; |
| 100 |
$this->add_styling_control_group( |
| 101 |
'User Login', |
| 102 |
'', |
| 103 |
'pb_recover_password_username', |
| 104 |
$sections |
| 105 |
); |
| 106 |
unset($sections); |
| 107 |
|
| 108 |
// reCAPTCHA Style tab |
| 109 |
if( !$this->is_placeholder_labels_active() ) { |
| 110 |
include_once(WPPB_PLUGIN_DIR . '/front-end/default-fields/recaptcha/recaptcha.php'); |
| 111 |
include_once(WPPB_PLUGIN_DIR . '/front-end/default-fields/turnstile/turnstile.php'); |
| 112 |
$field = wppb_get_recaptcha_field(); |
| 113 |
if (!empty($field) && isset($field['captcha-pb-forms']) && (strpos($field['captcha-pb-forms'], 'pb_recover_password') !== false)) { |
| 114 |
$this->add_styling_control_group( |
| 115 |
'reCAPTCHA', |
| 116 |
'', |
| 117 |
'pb_recover_password_recaptcha', |
| 118 |
[ |
| 119 |
'label' => [ |
| 120 |
'selector' => '#wppb-recover-password .wppb-form-field.wppb-recaptcha label', |
| 121 |
'section_name' => 'Label', |
| 122 |
] |
| 123 |
] |
| 124 |
); |
| 125 |
} |
| 126 |
} |
| 127 |
|
| 128 |
// Submit Button Style tab |
| 129 |
$this->add_styling_control_group( |
| 130 |
'Submit Button', |
| 131 |
'', |
| 132 |
'pb_recover_password_button', |
| 133 |
[ |
| 134 |
'input' => [ |
| 135 |
'selector' => '#wppb-recover-password .form-submit input#wppb-recover-password-button', |
| 136 |
'section_name' => 'Input', |
| 137 |
] |
| 138 |
] |
| 139 |
); |
| 140 |
} |
| 141 |
|
| 142 |
/** |
| 143 |
* Render widget output in the front-end. |
| 144 |
* |
| 145 |
*/ |
| 146 |
protected function render() { |
| 147 |
echo $this->render_widget( 'rp' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 148 |
} |
| 149 |
|
| 150 |
} |
| 151 |
|