PluginProbe
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) / 1.2.3
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) v1.2.3
2.1.3 2.1.2 2.1.1 2.1.0 2.0.4 2.0.3 2.0.2 2.0.1 2.0.0 1.5.5 1.5.4 1.5.3 1.5.2 1.5.1 1.5.0 trunk 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 All 57 releases
darkify / admin / ta-framework / fields / radio / radio.php

radio.php in Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) 1.2.3, at admin/ta-framework/fields/radio/radio.php

93 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) {
2 die; } // Cannot access directly.
3 /**
4 *
5 * Field: radio
6 *
7 * @since 1.0.0
8 * @version 1.0.0
9 */
10 if ( ! class_exists( 'DRK_LITE_Field_radio' ) ) {
11 class DRK_LITE_Field_radio extends DRK_LITE_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(
20 $this->field,
21 array(
22 'inline' => false,
23 'query_args' => array(),
24 )
25 );
26
27 $inline_class = ( $args['inline'] ) ? ' class="drk_lite--inline-list"' : '';
28
29 echo wp_kses_post( $this->field_before() );
30
31 if ( isset( $this->field['options'] ) ) {
32
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' . wp_kses_post($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 = ( $sub_key == $this->value ) ? ' checked' : '';
49 echo '<li>';
50 echo '<label>';
51 echo '<input type="radio" name="' . esc_attr( $this->field_name() ) . '" value="' . esc_attr( $sub_key ) . '"' . wp_kses_post( $this->field_attributes() ) . esc_attr( $checked ) . '/>';
52 echo '<span class="drk_lite--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 = ( $option_key == $this->value ) ? ' checked' : '';
62
63 echo '<li>';
64 echo '<label>';
65 echo '<input type="radio" name="' . esc_attr( $this->field_name() ) . '" value="' . esc_attr( $option_key ) . '"' . wp_kses_post( $this->field_attributes() ) . esc_attr( $checked ) . '/>';
66 echo '<span class="drk_lite--text">' . esc_attr( $option_value ) . '</span>';
67 echo '</label>';
68 echo '</li>';
69
70 }
71 }
72
73 echo '</ul>';
74
75 } else {
76
77 echo ( ! empty( $this->field['empty_message'] ) ) ? esc_attr( $this->field['empty_message'] ) : esc_html__( 'No data available.', 'darkify' );
78
79 }
80 } else {
81
82 $label = ( isset( $this->field['label'] ) ) ? $this->field['label'] : '';
83 echo '<label><input type="radio" name="' . esc_attr( $this->field_name() ) . '" value="1"' . wp_kses_post( $this->field_attributes() ) . esc_attr( checked( $this->value, 1, false ) ) . '/>';
84 echo ( ! empty( $this->field['label'] ) ) ? '<span class="drk_lite--text">' . esc_attr( $this->field['label'] ) . '</span>' : '';
85 echo '</label>';
86
87 }
88
89 echo wp_kses_post( $this->field_after() );
90 }
91 }
92 }
93