Example #1
0
    protected function render_after_field($value, $instance)
    {
        ?>
		</div>
		<?php 
        parent::render_after_field($value, $instance);
    }
    protected function render_after_field($value, $instance)
    {
        $unit_name = $this->get_unit_field_name($this->base_name);
        $unit = !empty($instance[$unit_name]) ? $instance[$unit_name] : '';
        ?>
		<select class="sow-measurement-select-unit"
				name="<?php 
        echo esc_attr($this->for_widget->so_get_field_name($this->base_name . '_unit', $this->parent_container));
        ?>
">
			<?php 
        foreach (siteorigin_widgets_get_measurements_list() as $measurement) {
            ?>
				<option value="<?php 
            echo esc_attr($measurement);
            ?>
" <?php 
            selected($measurement, $unit, true);
            ?>
><?php 
            echo esc_html($measurement);
            ?>
</option>
			<?php 
        }
        ?>
		</select>
		<div class="clear"></div>
		<?php 
        //Still want the default description, if there is one.
        parent::render_after_field($value, $instance);
    }
    protected function render_after_field($value, $instance)
    {
        $value_parts = $this->get_render_values($value);
        $unit = $value_parts['unit'];
        if (is_null($unit)) {
            $unit_name = $this->get_unit_field_name($this->base_name);
            if (!empty($instance[$unit_name])) {
                $unit = $instance[$unit_name];
            } else {
                if (isset($this->default)) {
                    $default_parts = $this->get_render_values($this->default);
                    $unit = $default_parts['unit'];
                }
            }
        }
        ?>
		<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 (siteorigin_widgets_get_measurements_list() as $measurement) {
            ?>
				<option value="<?php 
            echo esc_attr($measurement);
            ?>
" <?php 
            selected($measurement, $unit, true);
            ?>
><?php 
            echo esc_html($measurement);
            ?>
</option>
			<?php 
        }
        ?>
		</select>
		<div class="clear"></div>
		<?php 
        //Still want the default description, if there is one.
        parent::render_after_field($value, $instance);
    }