| 1 |
<?php |
| 2 |
|
| 3 |
defined( 'ABSPATH' ) || die(); |
| 4 |
|
| 5 |
class Sellkit_Elementor_Optin_Field_Acceptance extends Sellkit_Elementor_Optin_Field_Base { |
| 6 |
|
| 7 |
public static function get_field_type() { |
| 8 |
return 'acceptance'; |
| 9 |
} |
| 10 |
|
| 11 |
public function get_input_type() { |
| 12 |
return 'checkbox'; |
| 13 |
} |
| 14 |
|
| 15 |
public function add_field_render_attribute() { |
| 16 |
parent::add_field_render_attribute(); |
| 17 |
|
| 18 |
if ( 'true' === $this->field['checked_by_default'] ) { |
| 19 |
$this->widget->add_render_attribute( 'field-' . $this->get_id(), 'checked' ); |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
public function render_content() { |
| 24 |
?> |
| 25 |
<div class="sellkit-field-subgroup"> |
| 26 |
<span class="sellkit-field-option sellkit-field-option-checkbox"> |
| 27 |
<input <?php echo $this->widget->get_render_attribute_string( 'field-' . esc_attr( $this->get_id() ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Elementor-generated attributes. ?>> |
| 28 |
<label |
| 29 |
for="optin-field-<?php echo esc_attr( $this->get_id() ); ?>" |
| 30 |
class="sellkit-field-label"> |
| 31 |
<?php echo wp_kses_post( $this->field['acceptance_text'] ); ?> |
| 32 |
<?php if ( isset( $this->field['required'] ) && 'true' === $this->field['required'] ) : ?> |
| 33 |
<span class="required-mark-label"></span> |
| 34 |
<?php endif ?> |
| 35 |
</label> |
| 36 |
</span> |
| 37 |
</div> |
| 38 |
<?php |
| 39 |
} |
| 40 |
|
| 41 |
public static function get_additional_controls() { |
| 42 |
$commons = parent::get_common_controls(); |
| 43 |
|
| 44 |
return [ |
| 45 |
'label' => $commons['label'], |
| 46 |
'acceptance_text' => [ |
| 47 |
'label' => esc_html__( 'Acceptance Text', 'sellkit' ), |
| 48 |
'default' => esc_html__( 'I agree to terms.', 'sellkit' ), |
| 49 |
'type' => 'textarea', |
| 50 |
'conditions' => [ 'terms' => [ parent::get_type_condition() ] ], |
| 51 |
], |
| 52 |
'checked_by_default' => [ |
| 53 |
'label' => esc_html__( 'Checked by Default', 'sellkit' ), |
| 54 |
'type' => 'switcher', |
| 55 |
'return_value' => 'true', |
| 56 |
'conditions' => [ 'terms' => [ parent::get_type_condition() ] ], |
| 57 |
], |
| 58 |
'required' => $commons['required'], |
| 59 |
'width_responsive' => $commons['width_responsive'], |
| 60 |
]; |
| 61 |
} |
| 62 |
} |
| 63 |
|