PluginProbe
Easy Hotel – Powerful Hotel Booking / trunk
Easy Hotel – Powerful Hotel Booking vtrunk
2.0.8 2.0.7 2.0.6 2.0.5 2.0.4 2.0.3 2.0.2 2.0.1 2.0.0 1.9.9 1.9.8 1.9.7 1.9.6 1.9.5 1.9.4 1.9.3 1.9.2 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 All 110 releases
easy-hotel / admin / includes / framework / fields / checkbox / checkbox.php

checkbox.php in Easy Hotel – Powerful Hotel Booking trunk, at admin/includes/framework/fields/checkbox/checkbox.php

102 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
2 /**
3 *
4 * Field: checkbox
5 *
6 * @since 1.0.0
7 * @version 1.0.0
8 *
9 */
10 if ( ! class_exists( 'ESHB_Field_checkbox' ) ) {
11 class ESHB_Field_checkbox extends ESHB_Fields {
12
13 public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
14 parent::__construct( $field, $value, $unique, $where, $parent );
15 }
16
17 public function render() {
18
19 $args = wp_parse_args( $this->field, array(
20 'inline' => false,
21 'query_args' => array(),
22 'check_all' => false,
23 'check_all_text' => 'Check/Uncheck All',
24 ) );
25
26 $inline_class = ( $args['inline'] ) ? ' class="csf--inline-list"' : '';
27
28 echo wp_kses_post($this->field_before());
29
30 if ( isset( $this->field['options'] ) ) {
31
32 $value = ( is_array( $this->value ) ) ? $this->value : array_filter( (array) $this->value );
33 $options = $this->field['options'];
34 $options = ( is_array( $options ) ) ? $options : array_filter( $this->field_data( $options, false, $args['query_args'] ) );
35
36 if ( is_array( $options ) && ! empty( $options ) ) {
37
38 echo '<ul'. esc_attr($inline_class) .'>';
39
40 foreach ( $options as $option_key => $option_value ) {
41
42 if ( is_array( $option_value ) && ! empty( $option_value ) ) {
43
44 echo '<li>';
45 echo '<ul>';
46 echo '<li><strong>'. esc_attr( $option_key ) .'</strong></li>';
47 foreach ( $option_value as $sub_key => $sub_value ) {
48 $checked = ( in_array( $sub_key, $value ) ) ? ' checked' : '';
49 echo '<li>';
50 echo '<label>';
51 echo '<input type="checkbox" name="'. esc_attr( $this->field_name( '[]' ) ) .'" value="'. esc_attr( $sub_key ) .'"'. esc_attr(esc_attr($this->field_attributes())) . esc_attr( $checked ) .'/>';
52 echo '<span class="csf--text">'. esc_attr( $sub_value ) .'</span>';
53 echo '</label>';
54 echo '</li>';
55 }
56 echo '</ul>';
57 echo '</li>';
58
59 } else {
60
61 $checked = ( in_array( $option_key, $value ) ) ? ' checked' : '';
62
63 echo '<li>';
64 echo '<label>';
65 echo '<input type="checkbox" name="'. esc_attr( $this->field_name( '[]' ) ) .'" value="'. esc_attr( $option_key ) .'"'. esc_attr($this->field_attributes()) . esc_attr( $checked ) .'/>';
66 echo '<span class="csf--text">'. esc_attr( $option_value ) .'</span>';
67 echo '</label>';
68 echo '</li>';
69
70 }
71
72 }
73
74 echo '</ul>';
75
76 if ( $args['check_all'] ) {
77 echo '<div class="csf-checkbox-all">'. esc_html( $args['check_all_text'] ) .'</div>';
78 }
79
80 } else {
81
82 echo ( ! empty( $this->field['empty_message'] ) ) ? esc_attr( $this->field['empty_message'] ) : esc_html__( 'No data available.', 'easy-hotel' );
83
84 }
85
86 } else {
87
88 echo '<label class="csf-checkbox">';
89 echo '<input type="hidden" name="'. esc_attr( $this->field_name() ) .'" value="'. esc_attr($this->value) .'" class="csf--input"'. esc_attr($this->field_attributes()) .'/>';
90 echo '<input type="checkbox" name="_pseudo" class="csf--checkbox"'. esc_attr( checked( $this->value, 1, false ) ) . esc_attr($this->field_attributes()) .'/>';
91 echo ( ! empty( $this->field['label'] ) ) ? '<span class="csf--text">'. esc_attr( $this->field['label'] ) .'</span>' : '';
92 echo '</label>';
93
94 }
95
96 echo wp_kses_post($this->field_after());
97
98 }
99
100 }
101 }
102