PluginProbe
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster / trunk
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster vtrunk
2.6.0 trunk 1.1.0 1.1.4 1.2.1 1.2.2 1.2.3 1.2.5 1.2.9 1.3.1 1.3.2 1.5.0 1.5.1 1.5.4 1.5.7 1.5.8 1.5.9 1.6.2 1.6.5 1.6.8 1.7.2 1.7.4 1.7.5 1.7.9 1.8.1 All 42 releases
sellkit / includes / elementor / modules / optin / fields / checkbox.php

checkbox.php in SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster trunk, at includes/elementor/modules/optin/fields/checkbox.php

86 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 defined( 'ABSPATH' ) || die();
4
5 class Sellkit_Elementor_Optin_Field_Checkbox extends Sellkit_Elementor_Optin_Field_Base {
6
7 public static function get_field_type() {
8 return 'checkbox';
9 }
10
11 public function get_input_type() {
12 return 'checkbox';
13 }
14
15 public function render_content() {
16 $field = $this->field;
17 $options = preg_split( "/(\r\n|\n|\r)/", $field['field_options'], -1, PREG_SPLIT_NO_EMPTY );
18
19 if ( empty( $options ) ) {
20 return;
21 }
22
23 ?>
24 <div class="sellkit-field-subgroup <?php echo esc_attr( $field['inline_list'] ); ?>">
25 <?php $this->render_options( $options, $field['required'] ); ?>
26 </div>
27 <?php
28 }
29
30 private function render_options( $options, $required ) {
31 foreach ( $options as $key => $option ) {
32 $id = $this->get_id();
33 $option_id = 'optin-field-' . $id . '-' . $key;
34 $option_label = $option;
35 $option_value = $option;
36 $option_name = "fields[{$id}]";
37 $option_required = $required ? 'required' : '';
38
39 if ( false !== strpos( $option, '|' ) ) {
40 list( $option_label, $option_value ) = explode( '|', $option );
41 }
42
43 ?>
44 <span class="sellkit-field-option sellkit-field-option-checkbox">
45 <input
46 type="checkbox"
47 id="<?php echo esc_attr( $option_id ); ?>"
48 class="sellkit-field"
49 name="<?php echo esc_attr( $option_name ); ?>"
50 value="<?php echo esc_attr( $option_value ); ?>"
51 <?php echo esc_attr( $option_required ); ?>>
52 <label
53 for="<?php echo esc_attr( $option_id ); ?>"
54 class="sellkit-field-label">
55 <?php echo esc_html( $option_label ); ?>
56 </label>
57 </span>
58 <?php
59 }
60 }
61
62 public static function get_additional_controls() {
63 $commons = parent::get_common_controls();
64
65 return [
66 'label' => $commons['label'],
67 'field_options' => [
68 'label' => esc_html__( 'Options', 'sellkit' ),
69 'type' => 'textarea',
70 'default' => '',
71 'conditions' => [ 'terms' => [ parent::get_type_condition() ] ],
72 'description' => esc_html__( 'Enter each option in a separate line. To differentiate between label and value, separate them with a pipe char ("|"). For example: First Name|f_name', 'sellkit' ),
73 ],
74 'inline_list' => [
75 'label' => esc_html__( 'Inline List', 'sellkit' ),
76 'type' => 'switcher',
77 'return_value' => 'sellkit-subgroup-inline',
78 'default' => '',
79 'conditions' => [ 'terms' => [ parent::get_type_condition() ] ],
80 ],
81 'required' => $commons['required'],
82 'width_responsive' => $commons['width_responsive'],
83 ];
84 }
85 }
86