| @@ -1,39 +1,47 @@ | ||
| 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 | - foreach( $details['options'] as $option ){ | |
| 11 | - $found = false; | |
| 12 | - | |
| 13 | - $values = explode( ', ', $value ); | |
| 14 | - if( strpos( $option, '%' ) === false ){ | |
| 15 | - $label = $option; | |
| 16 | - $value_attr = $option; | |
| 17 | - if ( in_array( $option, $values ) ) | |
| 18 | - $found = true; | |
| 19 | - } | |
| 20 | - else{ | |
| 21 | - $option_parts = explode( '%', $option ); | |
| 22 | - if( !empty( $option_parts ) ){ | |
| 23 | - if( empty( $option_parts[0] ) && count( $option_parts ) == 3 ){ | |
| 24 | - $label = $option_parts[1]; | |
| 25 | - $value_attr = $option_parts[2]; | |
| 26 | - if ( in_array( $option_parts[2], $values ) ) | |
| 27 | - $found = true; | |
| 28 | - } | |
| 29 | - } | |
| 30 | - } | |
| 31 | - | |
| 32 | - $element .= '<div><label><input type="radio" name="'. esc_attr( Wordpress_Creation_Kit_PB::wck_generate_slug( $details['title'], $details ) ) .'" id="'; | |
| 33 | - if( !empty( $frontend_prefix ) ) | |
| 34 | - $element .= $frontend_prefix; | |
| 35 | - $element .= esc_attr( Wordpress_Creation_Kit_PB::wck_generate_slug( $details['title'] . '_' . $value_attr ) ) .'" value="'. esc_attr( $value_attr ) .'" '. checked( $found, true, false ) .'class="mb-radio mb-field" />'. esc_html( $label ) .'</label></div>'; | |
| 36 | - } | |
| 37 | - $element .= '</div>'; | |
| 38 | -} | |
| 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 | +} | |
| 39 | 47 | ?> |