_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
radio.php
106 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 | if ( 1 === (int) pods_v( 'grouped', $options, 0 ) ) { |
| 13 | ?> |
| 14 | <div class="pods-pick-values pods-pick-radio"> |
| 15 | <ul> |
| 16 | <?php |
| 17 | } |
| 18 | |
| 19 | $counter = 1; |
| 20 | $primary_name = $name; |
| 21 | $primary_id = 'pods-form-ui-' . PodsForm::clean( $name ); |
| 22 | $selection_made = false; |
| 23 | |
| 24 | foreach ( $options['data'] as $val => $label ) { |
| 25 | if ( is_array( $label ) ) { |
| 26 | if ( isset( $label['label'] ) ) { |
| 27 | $label = $label['label']; |
| 28 | } else { |
| 29 | $label = $val; |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | $attributes = array(); |
| 34 | |
| 35 | $attributes['type'] = 'radio'; |
| 36 | |
| 37 | $attributes['checked'] = null; |
| 38 | $attributes['tabindex'] = 2; |
| 39 | |
| 40 | if ( ! $selection_made && ( $val == $value || ( is_array( $value ) && in_array( $val, $value ) ) ) ) { |
| 41 | $attributes['checked'] = 'CHECKED'; |
| 42 | $selection_made = true; |
| 43 | } |
| 44 | |
| 45 | $attributes['value'] = $val; |
| 46 | |
| 47 | $attributes = PodsForm::merge_attributes( $attributes, $name, $form_field_type, $options ); |
| 48 | |
| 49 | $indent_escaped = ''; |
| 50 | |
| 51 | $indent_count = substr_count( $label, ' ' ); |
| 52 | |
| 53 | if ( 0 < $indent_count ) { |
| 54 | $label = str_replace( ' ', '', $label ); |
| 55 | |
| 56 | $indent_escaped = ' style="margin-left:' . ( 18 * $indent_count ) . 'px;"'; |
| 57 | } |
| 58 | |
| 59 | if ( (bool) pods_v( 'readonly', $options, false ) ) { |
| 60 | $attributes['readonly'] = 'READONLY'; |
| 61 | |
| 62 | $attributes['class'] .= ' pods-form-ui-read-only'; |
| 63 | } |
| 64 | |
| 65 | if ( 1 < count( $options['data'] ) ) { |
| 66 | $attributes['id'] = $primary_id . $counter; |
| 67 | } |
| 68 | |
| 69 | if ( 1 === (int) pods_v( 'grouped', $options, 0 ) ) { |
| 70 | ?> |
| 71 | <li> |
| 72 | <?php |
| 73 | } |
| 74 | ?> |
| 75 | <div class="pods-field pods-boolean"<?php echo $indent_escaped; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>> |
| 76 | <input<?php PodsForm::attributes( $attributes, $name, $form_field_type, $options ); ?> /> |
| 77 | <?php |
| 78 | if ( 0 < strlen( $label ) ) { |
| 79 | $help = pods_v( 'help', $options ); |
| 80 | |
| 81 | if ( 1 === (int) pods_v( 'grouped', $options, 0 ) || empty( $help ) ) { |
| 82 | $help = ''; |
| 83 | } |
| 84 | |
| 85 | PodsForm::output_label( $attributes['id'], $label, $help ); |
| 86 | } |
| 87 | ?> |
| 88 | </div> |
| 89 | <?php |
| 90 | |
| 91 | if ( 1 === (int) pods_v( 'grouped', $options, 0 ) ) { |
| 92 | ?> |
| 93 | </li> |
| 94 | <?php |
| 95 | } |
| 96 | |
| 97 | $counter ++; |
| 98 | }//end foreach |
| 99 | |
| 100 | if ( 1 === (int) pods_v( 'grouped', $options, 0 ) ) { |
| 101 | ?> |
| 102 | </ul> |
| 103 | </div> |
| 104 | <?php |
| 105 | } |
| 106 |