Added support for class in each widget fields
This commit is contained in:
parent
eeafb202aa
commit
532c1f9474
|
@ -5,7 +5,7 @@
|
|||
* @author WooThemes
|
||||
* @category Widgets
|
||||
* @package WooCommerce/Abstracts
|
||||
* @version 2.3.0
|
||||
* @version 2.5.0
|
||||
* @extends WP_Widget
|
||||
*/
|
||||
abstract class WC_Widget extends WP_Widget {
|
||||
|
@ -128,9 +128,9 @@ abstract class WC_Widget extends WP_Widget {
|
|||
/**
|
||||
* update function.
|
||||
*
|
||||
* @see WP_Widget->update
|
||||
* @param array $new_instance
|
||||
* @param array $old_instance
|
||||
* @see WP_Widget->update
|
||||
* @param array $new_instance
|
||||
* @param array $old_instance
|
||||
* @return array
|
||||
*/
|
||||
public function update( $new_instance, $old_instance ) {
|
||||
|
@ -158,7 +158,7 @@ abstract class WC_Widget extends WP_Widget {
|
|||
/**
|
||||
* form function.
|
||||
*
|
||||
* @see WP_Widget->form
|
||||
* @see WP_Widget->form
|
||||
* @param array $instance
|
||||
*/
|
||||
public function form( $instance ) {
|
||||
|
@ -169,6 +169,7 @@ abstract class WC_Widget extends WP_Widget {
|
|||
|
||||
foreach ( $this->settings as $key => $setting ) {
|
||||
|
||||
$class = isset( $setting['class'] ) ? $setting['class'] : $key;
|
||||
$value = isset( $instance[ $key ] ) ? $instance[ $key ] : $setting['std'];
|
||||
|
||||
switch ( $setting['type'] ) {
|
||||
|
@ -177,7 +178,7 @@ abstract class WC_Widget extends WP_Widget {
|
|||
?>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id( $key ); ?>"><?php echo $setting['label']; ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>" name="<?php echo $this->get_field_name( $key ); ?>" type="text" value="<?php echo esc_attr( $value ); ?>" />
|
||||
<input class="widefat <?php echo esc_attr( $class ); ?>" id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>" name="<?php echo $this->get_field_name( $key ); ?>" type="text" value="<?php echo esc_attr( $value ); ?>" />
|
||||
</p>
|
||||
<?php
|
||||
break;
|
||||
|
@ -186,7 +187,7 @@ abstract class WC_Widget extends WP_Widget {
|
|||
?>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id( $key ); ?>"><?php echo $setting['label']; ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>" name="<?php echo $this->get_field_name( $key ); ?>" type="number" step="<?php echo esc_attr( $setting['step'] ); ?>" min="<?php echo esc_attr( $setting['min'] ); ?>" max="<?php echo esc_attr( $setting['max'] ); ?>" value="<?php echo esc_attr( $value ); ?>" />
|
||||
<input class="widefat <?php echo esc_attr( $class ); ?>" id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>" name="<?php echo $this->get_field_name( $key ); ?>" type="number" step="<?php echo esc_attr( $setting['step'] ); ?>" min="<?php echo esc_attr( $setting['min'] ); ?>" max="<?php echo esc_attr( $setting['max'] ); ?>" value="<?php echo esc_attr( $value ); ?>" />
|
||||
</p>
|
||||
<?php
|
||||
break;
|
||||
|
@ -195,7 +196,7 @@ abstract class WC_Widget extends WP_Widget {
|
|||
?>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id( $key ); ?>"><?php echo $setting['label']; ?></label>
|
||||
<select class="widefat" id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>" name="<?php echo $this->get_field_name( $key ); ?>">
|
||||
<select class="widefat <?php echo esc_attr( $class ); ?>" id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>" name="<?php echo $this->get_field_name( $key ); ?>">
|
||||
<?php foreach ( $setting['options'] as $option_key => $option_value ) : ?>
|
||||
<option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $option_key, $value ); ?>><?php echo esc_html( $option_value ); ?></option>
|
||||
<?php endforeach; ?>
|
||||
|
@ -207,7 +208,7 @@ abstract class WC_Widget extends WP_Widget {
|
|||
case 'checkbox' :
|
||||
?>
|
||||
<p>
|
||||
<input id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $key ) ); ?>" type="checkbox" value="1" <?php checked( $value, 1 ); ?> />
|
||||
<input class="<?php echo esc_attr( $class ); ?>" id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $key ) ); ?>" type="checkbox" value="1" <?php checked( $value, 1 ); ?> />
|
||||
<label for="<?php echo $this->get_field_id( $key ); ?>"><?php echo $setting['label']; ?></label>
|
||||
</p>
|
||||
<?php
|
||||
|
|
Loading…
Reference in New Issue