PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 2.0.4
Adminify – White Label, Admin Menu Editor, Login Customizer v2.0.4
4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 4.1.17 All 164 releases
adminify / lib / adminify-framework / fields / checkbox / checkbox.php

checkbox.php in Adminify – White Label, Admin Menu Editor, Login Customizer 2.0.4, at lib/adminify-framework/fields/checkbox/checkbox.php

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