| 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_Select
*/
class SiteOrigin_Widget_Field_Select extends SiteOrigin_Widget_Field_Base {
/**
* The list of options which may be selected.
*
* @access protected
* @var array
*/
protected $options;
/**
* If present, this string is included as a disabled (not selectable) value at the top of the list of options. If
* there is no default value, it is selected by default. You might even want to leave the label value blank when
* you use this.
*
* @access protected
* @var string
*/
protected $prompt;
/**
* Determines whether this is a single or multiple select field.
*
* @access protected
* @var bool
*/
protected $multiple;
protected function render_field( $value, $instance ) {
?>
<select name="<?php echo esc_attr( $this->element_name ) ?>" id="<?php echo esc_attr( $this->element_id ) ?>"
class="siteorigin-widget-input<?php if ( ! empty( $this->input_css_classes ) ) echo ' ' . implode( ' ', $this->input_css_classes ) ?>"
<?php if( ! empty( $this->multiple ) ) echo 'multiple' ?>>
<?php if ( empty( $this->multiple ) && isset( $this->prompt ) ) : ?>
<option value="default" disabled="disabled" selected="selected"><?php echo esc_html( $this->prompt ) ?></option>
<?php endif; ?>
<?php if( isset( $this->options ) && !empty( $this->options ) ) : ?>
<?php foreach( $this->options as $key => $val ) : ?>
<?php
if( is_array( $value ) ) {
$selected = selected( true, in_array( $key, $value ), false );
}
else {
$selected = selected( $key, $value, false );
} ?>
<option value="<?php echo esc_attr( $key ) ?>" <?php echo $selected ?>><?php echo esc_html( $val ) ?></option>
<?php endforeach; ?>
<?php endif; ?>
</select>
<?php
}
protected function sanitize_field_input( $value, $instance ) {
$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 count( $sanitized_value ) == 1 ? $sanitized_value[0] : $sanitized_value;
}
}