PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 3.1.9
Adminify – White Label, Admin Menu Editor, Login Customizer v3.1.9
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 / Libs / adminify-framework / fields / checkbox / checkbox.php

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

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