| 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="'. esc_attr( Wordpress_Creation_Kit_PB::wck_generate_slug( $details['title'], $details ) ) .'" id="'; |
| 37 |
if( !empty( $frontend_prefix ) ) |
| 38 |
$element .= $frontend_prefix; |
| 39 |
$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-checkbox mb-field" />'. esc_html( $label ) .'</label></div>' ; |
| 40 |
} |
| 41 |
$element .= '</div>'; |
| 42 |
} |
| 43 |
?> |