File: /var/www/html/wpprotonperinggit/wp-content/themes/voiture/inc/widgets/listing-list.php
<?php
class Voiture_Widget_Listing_List extends WP_Widget {
public function __construct() {
parent::__construct(
'apus_widget_listing_list',
esc_html__('Apus Simple Listings List', 'voiture'),
array( 'description' => esc_html__( 'Show list of listing', 'voiture' ), )
);
$this->widgetName = 'listing_list';
}
public function widget( $args, $instance ) {
get_template_part('widgets/listing-list', '', array('args' => $args, 'instance' => $instance));
}
public function form( $instance ) {
$defaults = array(
'title' => 'Latest Listings',
'number_post' => '4',
'orderby' => '',
'order' => '',
'get_listings_by' => 'recent',
'style' => 'carousel',
);
$instance = wp_parse_args((array) $instance, $defaults);
// Widget admin form
$orderbys = array(
'' => esc_html__('Default', 'voiture'),
'date' => esc_html__('Date', 'voiture'),
'ID' => esc_html__('ID', 'voiture'),
'author' => esc_html__('Author', 'voiture'),
'title' => esc_html__('Title', 'voiture'),
'modified' => esc_html__('Modified', 'voiture'),
'rand' => esc_html__('Random', 'voiture'),
'comment_count' => esc_html__('Comment count', 'voiture'),
'menu_order' => esc_html__('Menu order', 'voiture'),
);
$orders = array(
'' => esc_html__('Default', 'voiture'),
'ASC' => esc_html__('Ascending', 'voiture'),
'DESC' => esc_html__('Descending', 'voiture'),
);
$get_listings_bys = array(
'featured' => esc_html__('Featured Listings', 'voiture'),
'urgent' => esc_html__('Urgent Listings', 'voiture'),
'recent' => esc_html__('Recent Listings', 'voiture'),
);
$style = array(
'carousel' => esc_html__('Carousel', 'voiture'),
'list' => esc_html__('List', 'voiture'),
);
?>
<p>
<label for="<?php echo esc_attr($this->get_field_id( 'title' )); ?>"><?php esc_html_e( 'Title:', 'voiture' ); ?></label>
<input class="widefat" id="<?php echo esc_attr($this->get_field_id( 'title' )); ?>" name="<?php echo esc_attr($this->get_field_name( 'title' )); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr($this->get_field_id('orderby')); ?>">
<?php echo esc_html__('Order By:', 'voiture' ); ?>
</label>
<br>
<select id="<?php echo esc_attr($this->get_field_id('orderby')); ?>" name="<?php echo esc_attr($this->get_field_name('orderby')); ?>">
<?php foreach ($orderbys as $key => $title) { ?>
<option value="<?php echo esc_attr( $key ); ?>" <?php selected($instance['orderby'], $key); ?> ><?php echo esc_html( $title ); ?></option>
<?php } ?>
</select>
</p>
<p>
<label for="<?php echo esc_attr($this->get_field_id('order')); ?>">
<?php echo esc_html__('Order:', 'voiture' ); ?>
</label>
<br>
<select id="<?php echo esc_attr($this->get_field_id('order')); ?>" name="<?php echo esc_attr($this->get_field_name('order')); ?>">
<?php foreach ($orders as $key => $title) { ?>
<option value="<?php echo esc_attr( $key ); ?>" <?php selected($instance['order'], $key); ?> ><?php echo esc_html( $title ); ?></option>
<?php } ?>
</select>
</p>
<p>
<label for="<?php echo esc_attr($this->get_field_id('get_listings_by')); ?>">
<?php echo esc_html__('Get listings by:', 'voiture' ); ?>
</label>
<br>
<select id="<?php echo esc_attr($this->get_field_id('get_listings_by')); ?>" name="<?php echo esc_attr($this->get_field_name('get_listings_by')); ?>">
<?php foreach ($get_listings_bys as $key => $title) { ?>
<option value="<?php echo esc_attr( $key ); ?>" <?php selected($instance['get_listings_by'], $key); ?> ><?php echo esc_html( $title ); ?></option>
<?php } ?>
</select>
</p>
<p>
<label for="<?php echo esc_attr($this->get_field_id('style')); ?>">
<?php echo esc_html__('Style:', 'voiture' ); ?>
</label>
<br>
<select id="<?php echo esc_attr($this->get_field_id('style')); ?>" name="<?php echo esc_attr($this->get_field_name('style')); ?>">
<?php foreach ($style as $key => $title) { ?>
<option value="<?php echo esc_attr( $key ); ?>" <?php selected($instance['style'], $key); ?> ><?php echo esc_html( $title ); ?></option>
<?php } ?>
</select>
</p>
<p>
<label for="<?php echo esc_attr($this->get_field_id( 'number_post' )); ?>"><?php esc_html_e( 'Num Posts:', 'voiture' ); ?></label>
<input class="widefat" id="<?php echo esc_attr($this->get_field_id( 'number_post' )); ?>" name="<?php echo esc_attr($this->get_field_name( 'number_post' )); ?>" type="text" value="<?php echo esc_attr($instance['number_post']); ?>" />
</p>
<?php
}
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
$instance['number_post'] = ( ! empty( $new_instance['number_post'] ) ) ? strip_tags( $new_instance['number_post'] ) : '';
$instance['orderby'] = ( ! empty( $new_instance['orderby'] ) ) ? strip_tags( $new_instance['orderby'] ) : '';
$instance['order'] = ( ! empty( $new_instance['order'] ) ) ? strip_tags( $new_instance['order'] ) : '';
$instance['get_listings_by'] = ( ! empty( $new_instance['get_listings_by'] ) ) ? strip_tags( $new_instance['get_listings_by'] ) : '';
$instance['style'] = ( ! empty( $new_instance['style'] ) ) ? strip_tags( $new_instance['style'] ) : '';
return $instance;
}
}
call_user_func( implode('_', array('register', 'widget') ), 'Voiture_Widget_Listing_List' );