PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 3.9.8
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v3.9.8
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 / checkbox.php

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

54 lines 2.0 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-checkboxes">';
10 foreach( $details['options'] as $option ){
11 $found = false;
12
13 if( !is_array( $value ) )
14 $values = explode( ', ', $value );
15 else
16 $values = $value;
17
18 if( strpos( $option, '%' ) === false ){
19 $label = $option;
20 $value_attr = $option;
21 if ( in_array( $option, $values ) )
22 $found = true;
23 }
24 else{
25 $option_parts = explode( '%', $option );
26 if( !empty( $option_parts ) ){
27 if( empty( $option_parts[0] ) && count( $option_parts ) == 3 ){
28 $label = $option_parts[1];
29 $value_attr = $option_parts[2];
30 if ( in_array( $option_parts[2], $values ) )
31 $found = true;
32 }
33 }
34 }
35
36 $element .= '<div><label><input type="checkbox" name="'. $single_prefix . esc_attr( Wordpress_Creation_Kit_PB::wck_generate_slug( $details['title'], $details ) );
37 if( $this->args['single'] && $this->args['context'] != 'option' ) {
38 $element .= '[]';
39 }
40 $element .= '" id="';
41
42 if( !empty( $frontend_prefix ) )
43 $element .= $frontend_prefix;
44
45 /* 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 */
46 if( !empty( $details['slug'] ) )
47 $slug_from = $details['slug'];
48 else
49 $slug_from = $details['title'];
50 $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-checkbox mb-field" />'. esc_html( $label ) .'</label></div>' ;
51 }
52 $element .= '</div>';
53 }
54 ?>