PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.1.2
JetFormBuilder — Dynamic Blocks Form Builder v3.1.2
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / includes / blocks / render / radio-field-render.php
jetformbuilder / includes / blocks / render Last commit date
action-button-render.php 2 years ago base-select-radio-check.php 2 years ago base.php 2 years ago calculated-field-render.php 2 years ago checkbox-field-render.php 2 years ago date-field-render.php 2 years ago datetime-field-render.php 2 years ago form-builder.php 2 years ago form-hidden-fields.php 2 years ago group-break-field-render.php 2 years ago heading-field-render.php 2 years ago media-field-render.php 2 years ago number-field-render.php 2 years ago radio-field-render.php 2 years ago range-field-render.php 2 years ago repeater-field-render.php 2 years ago select-field-render.php 2 years ago text-field-render.php 2 years ago textarea-field-render.php 2 years ago time-field-render.php 2 years ago wysiwyg-field-render.php 2 years ago
radio-field-render.php
106 lines
1 <?php
2
3 namespace Jet_Form_Builder\Blocks\Render;
4
5 // If this file is called directly, abort.
6 use Jet_Form_Builder\Classes\Builder_Helper;
7
8 if ( ! defined( 'WPINC' ) ) {
9 die;
10 }
11
12 /**
13 * Define text field renderer class
14 */
15 class Radio_Field_Render extends Base_Select_Radio_Check {
16
17 public function __construct( $block_type ) {
18 parent::__construct( $block_type );
19
20 $this->set_options();
21 }
22
23 public function get_name() {
24 return 'radio-field';
25 }
26
27 public function render_without_layout( $template = null, $args = array() ) {
28 parent::render_without_layout( $template, $args );
29
30 return $this->render_options();
31 }
32
33 public function render_options(): string {
34 $required = $this->block_type->get_required_val();
35
36 $this->add_attribute( 'class', 'jet-form-builder__field radio-field checkradio-field' );
37 $this->add_attribute( 'class', $this->args['class_name'] );
38 $this->add_attribute( 'required', $required );
39
40 $html = '<div class="jet-form-builder__fields-group checkradio-wrap" data-jfb-sync>';
41
42 if ( ! empty( $this->args['field_options'] ) ) {
43 foreach ( $this->args['field_options'] as $value => $option ) {
44 $html .= $this->render_option( $value, $option );
45 }
46 }
47
48 $html .= '</div>';
49 $this->reset_attributes();
50
51 return $html;
52 }
53
54 public function render_option( $value, $option ): string {
55 $default = (string) ( $this->args['default'] ?? false );
56
57 if ( is_array( $option ) ) {
58 $val = $option['value'] ?? $value;
59 $label = $option['label'] ?? $val;
60 } else {
61 $val = $value;
62 $label = $option;
63 }
64
65 $html = '<div class="jet-form-builder__field-wrap radio-wrap checkradio-wrap">';
66
67 $item = sprintf(
68 '<label class="jet-form-builder__field-label for-radio">
69 <input %1$s %2$s><span>%3$s</span></label>',
70 Builder_Helper::attrs(
71 array(
72 array( 'type', 'radio' ),
73 array( 'name', esc_attr( $this->block_type->get_field_name() ) ),
74 array( 'value', esc_attr( $val ) ),
75 array( 'data-field-name', esc_attr( $this->args['name'] ) ),
76 array( 'checked', ( (string) $val ) === $default ? 'checked' : '' ),
77 array(
78 'data-calculate',
79 ( is_array( $option ) && isset( $option['calculate'] ) && '' !== $option['calculate'] )
80 ? esc_attr( $option['calculate'] )
81 : '',
82 ),
83 )
84 ),
85 $this->get_attributes_string_save(),
86 wp_kses_post( $label )
87 );
88
89 /**
90 * @since 3.1.0
91 */
92 $html .= apply_filters(
93 'jet-form-builder/render/radio-field/option',
94 $item,
95 $val,
96 $option,
97 $this
98 );
99
100 $html .= '</div>';
101
102 return $html;
103 }
104
105 }
106