PluginProbe
Document Embedder – let visitors read files without downloading / 1.8.6
Document Embedder – let visitors read files without downloading v1.8.6
2.3.1 2.3.0 2.2.1 2.2.0 2.1.2 2.1.1 trunk 1.0 1.1 1.2 1.3 1.7.4 1.7.6 1.7.9 1.8.1 1.8.2 1.8.3 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 2.0.0 2.0.1 2.0.2 All 30 releases
document-emberdder / admin / framework / fields / checkbox / checkbox.php

checkbox.php in Document Embedder – let visitors read files without downloading 1.8.6, at admin/framework/fields/checkbox/checkbox.php

102 lines 3.6 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( 'CSF_Field_checkbox' ) ) {
11 class CSF_Field_checkbox extends CSF_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 'check_all' => false,
23 'check_all_text' => esc_html__( 'Check/Uncheck All' ),
24 ) );
25
26 $inline_class = ( $args['inline'] ) ? ' class="csf--inline-list"' : '';
27
28 echo $this->field_before();
29
30 if ( isset( $this->field['options'] ) ) {
31
32 $value = ( is_array( $this->value ) ) ? $this->value : array_filter( (array) $this->value );
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'. $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 = ( in_array( $sub_key, $value ) ) ? ' checked' : '';
49 echo '<li>';
50 echo '<label>';
51 echo '<input type="checkbox" name="'. esc_attr( $this->field_name( '[]' ) ) .'" value="'. esc_attr( $sub_key ) .'"'. $this->field_attributes() . esc_attr( $checked ) .'/>';
52 echo '<span class="csf--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 = ( in_array( $option_key, $value ) ) ? ' checked' : '';
62
63 echo '<li>';
64 echo '<label>';
65 echo '<input type="checkbox" name="'. esc_attr( $this->field_name( '[]' ) ) .'" value="'. esc_attr( $option_key ) .'"'. $this->field_attributes() . esc_attr( $checked ) .'/>';
66 echo '<span class="csf--text">'. esc_attr( $option_value ) .'</span>';
67 echo '</label>';
68 echo '</li>';
69
70 }
71
72 }
73
74 echo '</ul>';
75
76 if ( $args['check_all'] ) {
77 echo '<div class="csf-checkbox-all">'. esc_html( $args['check_all_text'] ) .'</div>';
78 }
79
80 } else {
81
82 echo ( ! empty( $this->field['empty_message'] ) ) ? esc_attr( $this->field['empty_message'] ) : esc_html__( 'No data available.', 'csf' );
83
84 }
85
86 } else {
87
88 echo '<label class="csf-checkbox">';
89 echo '<input type="hidden" name="'. esc_attr( $this->field_name() ) .'" value="'. $this->value .'" class="csf--input"'. $this->field_attributes() .'/>';
90 echo '<input type="checkbox" name="_pseudo" class="csf--checkbox"'. esc_attr( checked( $this->value, 1, false ) ) . $this->field_attributes() .'/>';
91 echo ( ! empty( $this->field['label'] ) ) ? '<span class="csf--text">'. esc_attr( $this->field['label'] ) .'</span>' : '';
92 echo '</label>';
93
94 }
95
96 echo $this->field_after();
97
98 }
99
100 }
101 }
102