PluginProbe
Hello Plus / 1.7.0
Hello Plus v1.7.0
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.6.0 1.6.1 1.6.2 1.7.0 1.7.1 1.7.2 1.7.3 All 30 releases
hello-plus / modules / forms / fields / acceptance.php

acceptance.php in Hello Plus 1.7.0, at modules/forms/fields/acceptance.php

91 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace HelloPlus\Modules\Forms\Fields;
3
4 use Elementor\Controls_Manager;
5 use HelloPlus\Includes\Utils;
6 use HelloPlus\Plugin;
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly
10 }
11
12 class Acceptance extends Field_Base {
13
14 public function get_type() {
15 return 'ehp-acceptance';
16 }
17
18 public function get_name() {
19 return esc_html__( 'Acceptance', 'hello-plus' );
20 }
21
22 public function update_controls( $widget ) {
23 $elementor = Utils::elementor();
24
25 $control_data = $elementor->controls_manager->get_control_from_stack( $widget->get_unique_name(), 'form_fields' );
26
27 if ( is_wp_error( $control_data ) ) {
28 return;
29 }
30
31 $field_controls = [
32 'acceptance_text' => [
33 'name' => 'acceptance_text',
34 'label' => esc_html__( 'Acceptance Text', 'hello-plus' ),
35 'type' => Controls_Manager::TEXTAREA,
36 'condition' => [
37 'field_type' => $this->get_type(),
38 ],
39 'tab' => 'content',
40 'inner_tab' => 'form_fields_content_tab',
41 'tabs_wrapper' => 'form_fields_tabs',
42 ],
43 'checked_by_default' => [
44 'name' => 'checked_by_default',
45 'label' => esc_html__( 'Checked by Default', 'hello-plus' ),
46 'type' => Controls_Manager::SWITCHER,
47 'condition' => [
48 'field_type' => $this->get_type(),
49 ],
50 'tab' => 'content',
51 'inner_tab' => 'form_fields_content_tab',
52 'tabs_wrapper' => 'form_fields_tabs',
53 ],
54 ];
55
56 $control_data['fields'] = $this->inject_field_controls( $control_data['fields'], $field_controls );
57 $widget->update_control( 'form_fields', $control_data );
58 }
59
60 public function render( $item, $item_index, $form ) {
61 $label = '';
62 $form->add_render_attribute( 'input' . $item_index, 'class', 'elementor-acceptance-field' );
63 $form->add_render_attribute( 'input' . $item_index, 'type', 'checkbox', true );
64
65 if ( ! empty( $item['acceptance_text'] ) ) {
66 $label = '<label for="' . $form->get_attribute_id( $item ) . '">' . $item['acceptance_text'] . '</label>';
67 }
68
69 if ( ! empty( $item['checked_by_default'] ) ) {
70 $form->add_render_attribute( 'input' . $item_index, 'checked', 'checked' );
71 }
72
73 ?>
74 <div class="elementor-field-subgroup">
75 <span class="elementor-field-option">
76 <input <?php $form->print_render_attribute_string( 'input' . $item_index ); ?>>
77 <?php
78 echo wp_kses( $label, [
79 'label' => [
80 'for' => true,
81 'class' => true,
82 'id' => true,
83 'style' => true,
84 ],
85 ] ); ?>
86 </span>
87 </div>
88 <?php
89 }
90 }
91