PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 3.3.8
Pods – Custom Content Types and Fields v3.3.8
trunk 1.14.8 2.7.31.3 2.8.23.3 2.9.19.3 3.0.10.3 3.1.4.1 3.2.0 3.2.1 3.2.1.1 3.2.2 3.2.4 3.2.5 3.2.6 3.2.7 3.2.7.1 3.2.8 3.2.8.1 3.2.8.2 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9
pods / ui / fields / checkbox.php
pods / ui / fields Last commit date
_comment.php 4 months ago _db.php 4 months ago _hidden.php 4 months ago _label.php 4 months ago _row.php 4 months ago attachment.php 4 months ago checkbox.php 4 months ago cleditor.php 4 months ago codemirror.php 4 months ago color.php 4 months ago currency.php 4 months ago date.php 4 months ago datetime.php 4 months ago email.php 4 months ago link.php 4 months ago number.php 4 months ago oembed.php 4 months ago password.php 4 months ago phone.php 4 months ago radio.php 4 months ago select.php 4 months ago slider.php 4 months ago slug.php 4 months ago text.php 4 months ago textarea.php 4 months ago time.php 4 months ago tinymce.php 4 months ago website.php 4 months ago
checkbox.php
126 lines
1 <?php
2
3 // Don't load directly.
4 if ( ! defined( 'ABSPATH' ) ) {
5 die( '-1' );
6 }
7
8 // phpcs:ignoreFile WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
9
10 $options['data'] = (array) pods_v( 'data', $options, [] );
11
12 $data_count = count( $options['data'] );
13
14 if ( 0 < $data_count ) {
15
16 if ( 1 === (int) pods_v( 'grouped', $options ) ) {
17 ?>
18 <div class="pods-pick-values pods-pick-checkbox">
19 <ul>
20 <?php
21 }
22
23 $counter = 1;
24 $primary_name = $name;
25 $primary_id = 'pods-form-ui-' . PodsForm::clean( $name );
26
27 foreach ( $options['data'] as $val => $label ) {
28 if ( is_array( $label ) ) {
29 if ( isset( $label['label'] ) ) {
30 $label = $label['label'];
31 } else {
32 $label = $val;
33 }
34 }
35
36 $attributes = array();
37
38 $attributes['type'] = 'checkbox';
39 $attributes['tabindex'] = 2;
40
41 if ( ( ! is_array( $value ) && (string) $val === (string) $value ) || ( is_array( $value ) && ( in_array( $val, $value ) || in_array( (string) $val, $value ) ) ) ) {
42 $attributes['checked'] = 'CHECKED';
43 }
44
45 $attributes['value'] = $val;
46
47 if ( 1 < $data_count && false === strpos( (string) $primary_name, '[]' ) ) {
48 $name = (string) $primary_name . '[' . ( $counter - 1 ) . ']';
49 }
50
51 $attributes = PodsForm::merge_attributes( $attributes, $name, $form_field_type, $options );
52
53 $indent_escaped = '';
54
55 $indent_count = substr_count( $label, '&nbsp;&nbsp;&nbsp;' );
56
57 if ( 0 < $indent_count ) {
58 $label = str_replace( '&nbsp;&nbsp;&nbsp;', '', $label );
59
60 $indent_escaped = ' style="margin-left:' . ( 18 * $indent_count ) . 'px;"';
61 }
62
63 if ( 1 < $data_count && false === strpos( (string) $primary_name, '[]' ) ) {
64 $attributes['class'] .= ' pods-dependent-multi';
65 }
66
67 if ( strlen( $label ) < 1 ) {
68 $attributes['class'] .= ' pods-form-ui-no-label';
69 }
70
71 if ( (bool) pods_v( 'readonly', $options, false ) ) {
72 $attributes['readonly'] = 'READONLY';
73 $attributes['disabled'] = 'DISABLED';
74
75 $attributes['class'] .= ' pods-form-ui-read-only';
76 }
77
78 if ( 1 < $data_count ) {
79 $attributes['id'] = $primary_id . $counter;
80 }
81
82 if ( 1 === (int) pods_v( 'grouped', $options ) ) {
83 ?>
84 <li>
85 <?php
86 }
87 ?>
88 <div class="pods-field pods-boolean"<?php echo $indent_escaped; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
89 <input<?php PodsForm::attributes( $attributes, $name, $form_field_type, $options ); ?> />
90 <?php
91 if ( isset( $attributes['readonly'] ) && isset( $attributes['checked'] ) && 'CHECKED' === $attributes['checked'] ) {
92 ?>
93 <input type="hidden" name="<?php echo esc_attr( pods_js_name( $name ) ); ?>" value="<?php echo esc_attr( $attributes['value'] ); ?>" />
94 <?php
95 }
96
97 if ( 0 < strlen( $label ) ) {
98 $help = pods_v( 'help', $options );
99
100 if ( 1 === (int) pods_v( 'grouped', $options ) || empty( $help ) ) {
101 $help = '';
102 }
103
104 PodsForm::output_label( $attributes['id'], $label, $help );
105 }
106 ?>
107 </div>
108 <?php
109
110 if ( 1 === (int) pods_v( 'grouped', $options ) ) {
111 ?>
112 </li>
113 <?php
114 }
115
116 $counter ++;
117 }//end foreach
118
119 if ( 1 === (int) pods_v( 'grouped', $options ) ) {
120 ?>
121 </ul>
122 </div>
123 <?php
124 }
125 }//end if
126