| 1 |
<?php |
| 2 |
namespace HelloPlus\Modules\Forms\Fields; |
| 3 |
|
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; // Exit if accessed directly |
| 6 |
} |
| 7 |
|
| 8 |
class Acceptance extends Field_Base { |
| 9 |
|
| 10 |
public function get_type() { |
| 11 |
return 'ehp-acceptance'; |
| 12 |
} |
| 13 |
|
| 14 |
public function get_name() { |
| 15 |
return esc_html__( 'Acceptance', 'hello-plus' ); |
| 16 |
} |
| 17 |
|
| 18 |
public function render( $item, $item_index, $form ) { |
| 19 |
$label = ''; |
| 20 |
$form->add_render_attribute( 'input' . $item_index, 'class', 'elementor-acceptance-field' ); |
| 21 |
$form->add_render_attribute( 'input' . $item_index, 'type', 'checkbox', true ); |
| 22 |
|
| 23 |
if ( ! empty( $item['acceptance_text'] ) ) { |
| 24 |
$label = '<label for="' . $form->get_attribute_id( $item ) . '">' . $item['acceptance_text'] . '</label>'; |
| 25 |
} |
| 26 |
|
| 27 |
if ( ! empty( $item['checked_by_default'] ) ) { |
| 28 |
$form->add_render_attribute( 'input' . $item_index, 'checked', 'checked' ); |
| 29 |
} |
| 30 |
|
| 31 |
?> |
| 32 |
<div class="elementor-field-subgroup"> |
| 33 |
<span class="elementor-field-option"> |
| 34 |
<input <?php $form->print_render_attribute_string( 'input' . $item_index ); ?>> |
| 35 |
<?php |
| 36 |
echo wp_kses( $label, [ |
| 37 |
'label' => [ |
| 38 |
'for' => true, |
| 39 |
'class' => true, |
| 40 |
'id' => true, |
| 41 |
'style' => true, |
| 42 |
], |
| 43 |
] ); ?> |
| 44 |
</span> |
| 45 |
</div> |
| 46 |
<?php |
| 47 |
} |
| 48 |
} |
| 49 |
|