| Server IP : 213.186.33.4 / Your IP : 216.73.216.146 Web Server : Apache System : Linux webm005.cluster103.gra.hosting.ovh.net 6.18.39-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Tue Jul 21 12:03:15 CEST 2026 x86_64 User : karinebmkh ( 644538) PHP Version : 8.4.22 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/karinebmkh/www2/wp-content/plugins/so-widgets-bundle/base/inc/fields/ |
Upload File : |
<?php
/**
* Class SiteOrigin_Widget_Field_Checkbox
*/
class SiteOrigin_Widget_Field_Checkboxes extends SiteOrigin_Widget_Field_Base {
protected $options;
protected function render_field( $value, $instance ) {
if( empty($value) ) {
$value = array();
}
if( !is_array( $value ) ) {
$value = array( $value );
}
$i = 0;
foreach( $this->options as $id => $label ) {
?>
<label for="<?php echo esc_attr( $this->element_id ) ?>-<?php echo esc_attr( $id ) ?>" class="so-checkbox-label">
<input
type="checkbox"
class="siteorigin-widget-input"
name="<?php echo esc_attr( $this->element_name ) ?>[<?php echo esc_attr( $i++ ) ?>]"
value="<?php echo esc_attr( $id ) ?>"
id="<?php echo esc_attr( $this->element_id ) ?>-<?php echo esc_attr( $id ) ?>"
<?php checked( in_array( $id, $value ) ) ?>
/>
<?php echo( $label ) ?>
</label>
<?php
}
}
protected function sanitize_field_input( $value, $instance ) {
if( empty( $value ) ) {
$value = array();
}
$values = is_array( $value ) ? $value : array( $value );
$keys = array_keys( $this->options );
$sanitized_value = array();
foreach( $values as $value ) {
if ( !in_array( $value, $keys ) ) {
$sanitized_value[] = isset( $this->default ) ? $this->default : false;
}
else {
$sanitized_value[] = $value;
}
}
return $sanitized_value;
}
}