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 / radio / radio.php

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

94 lines 3.2 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: radio
5 *
6 * @since 1.0.0
7 * @version 1.0.0
8 *
9 */
10 if ( ! class_exists( 'ESHB_Field_radio' ) ) {
11 class ESHB_Field_radio 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 ) );
23
24 $inline_class = ( $args['inline'] ) ? ' class="csf--inline-list"' : '';
25
26 echo wp_kses_post($this->field_before());
27
28 if ( isset( $this->field['options'] ) ) {
29
30 $options = $this->field['options'];
31 $options = ( is_array( $options ) ) ? $options : array_filter( $this->field_data( $options, false, $args['query_args'] ) );
32
33 if ( is_array( $options ) && ! empty( $options ) ) {
34
35 echo '<ul'. esc_attr($inline_class) .'>';
36
37 foreach ( $options as $option_key => $option_value ) {
38
39 if ( is_array( $option_value ) && ! empty( $option_value ) ) {
40
41 echo '<li>';
42 echo '<ul>';
43 echo '<li><strong>'. esc_attr( $option_key ) .'</strong></li>';
44 foreach ( $option_value as $sub_key => $sub_value ) {
45 $checked = ( $sub_key == $this->value ) ? ' checked' : '';
46 echo '<li>';
47 echo '<label>';
48 echo '<input type="radio" name="'. esc_attr( $this->field_name() ) .'" value="'. esc_attr( $sub_key ) .'"'. esc_attr($this->field_attributes()) . esc_attr( $checked ) .'/>';
49 echo '<span class="csf--text">'. esc_attr( $sub_value ) .'</span>';
50 echo '</label>';
51 echo '</li>';
52 }
53 echo '</ul>';
54 echo '</li>';
55
56 } else {
57
58 $checked = ( $option_key == $this->value ) ? ' checked' : '';
59
60 echo '<li>';
61 echo '<label>';
62 echo '<input type="radio" name="'. esc_attr( $this->field_name() ) .'" value="'. esc_attr( $option_key ) .'"'. esc_attr($this->field_attributes()) . esc_attr( $checked ) .'/>';
63 echo '<span class="csf--text">'. esc_attr( $option_value ) .'</span>';
64 echo '</label>';
65 echo '</li>';
66
67 }
68
69 }
70
71 echo '</ul>';
72
73 } else {
74
75 echo ( ! empty( $this->field['empty_message'] ) ) ? esc_attr( $this->field['empty_message'] ) : esc_html__( 'No data available.', 'easy-hotel' );
76
77 }
78
79 } else {
80
81 $label = ( isset( $this->field['label'] ) ) ? $this->field['label'] : '';
82 echo '<label><input type="radio" name="'. esc_attr( $this->field_name() ) .'" value="1"'. esc_attr($this->field_attributes()) . esc_attr( checked( $this->value, 1, false ) ) .'/>';
83 echo ( ! empty( $this->field['label'] ) ) ? '<span class="csf--text">'. esc_attr( $this->field['label'] ) .'</span>' : '';
84 echo '</label>';
85
86 }
87
88 echo wp_kses_post($this->field_after());
89
90 }
91
92 }
93 }
94