PluginProbe
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) / 1.2.4
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) v1.2.4
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 / checkbox / checkbox.php

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

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