PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 4.0.3
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v4.0.3
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
profile-builder / assets / lib / wck-api / fields / radio.php

radio.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 4.0.3, at assets/lib/wck-api/fields/radio.php

47 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /* @param string $meta Meta name.
3 * @param array $details Contains the details for the field.
4 * @param string $value Contains input value;
5 * @param string $context Context where the function is used. Depending on it some actions are preformed.;
6 * @return string $element input element html string. */
7
8 if( !empty( $details['options'] ) ){
9 $element .= '<div class="wck-radiobuttons">';
10 $element .= '<div class="cozmoslabs-radio-inputs-row">';
11 foreach( $details['options'] as $option ){
12 $found = false;
13
14 $values = explode( ', ', $value );
15 if( strpos( $option, '%' ) === false ){
16 $label = $option;
17 $value_attr = $option;
18 if ( in_array( $option, $values ) )
19 $found = true;
20 }
21 else{
22 $option_parts = explode( '%', $option );
23 if( !empty( $option_parts ) ){
24 if( empty( $option_parts[0] ) && count( $option_parts ) == 3 ){
25 $label = $option_parts[1];
26 $value_attr = $option_parts[2];
27 if ( in_array( $option_parts[2], $values ) )
28 $found = true;
29 }
30 }
31 }
32
33 $element .= '<label><input type="radio" name="'. $single_prefix . esc_attr( Wordpress_Creation_Kit_PB::wck_generate_slug( $details['title'], $details ) ) .'" id="';
34 if( !empty( $frontend_prefix ) )
35 $element .= $frontend_prefix;
36
37 /* since the slug below is generated from the value as well we need to determine here if we have a slug or not and not let the wck_generate_slug() function do that */
38 if( !empty( $details['slug'] ) )
39 $slug_from = $details['slug'];
40 else
41 $slug_from = $details['title'];
42 $element .= esc_attr( Wordpress_Creation_Kit_PB::wck_generate_slug( $slug_from . '_' . $value_attr ) ) .'" value="'. esc_attr( $value_attr ) .'" '. checked( $found, true, false ) .'class="mb-radio mb-field" />'. esc_html( $label ) .'</label>';
43 }
44 $element .= '</div>';
45 $element .= '</div>';
46 }
47 ?>