'essitco_ams_store_widget', 'description' => 'This is an Example Widget', ); parent::__construct( 'essitco_ams_store_widget', 'Featured Stores', $widget_options ); } public function widget( $args, $instance ) { $title = apply_filters( 'widget_title', $instance[ 'title' ] ); echo $args['before_widget'] . $args['before_title'] . $title . $args['after_title']; ?> getFeatureStore($instance[ 'per_page' ]); ?>
'store', 'posts_per_page'=> $per_page, 'post_status' => 'publish', 'orderby' => array( 'meta_value_num' => 'ASC', 'date' =>'DESC' ), 'order' => 'ASC', 'meta_query' => array( 'relation' => 'AND', array( 'key' => 'is_featured', 'value' => 'active', 'compare' => '=' ) ) ); $stores = new WP_Query( $args ); if( $stores->have_posts() ){ echo '
'offer', 'posts_per_page'=> $per_page, 'post_status' => 'publish', 'orderby' => array( 'meta_value_num' => 'ASC', 'date' =>'DESC' ), 'order' => 'ASC', 'meta_query' => array( 'relation' => 'AND', array( 'key' => 'is_featured', 'value' => 'active', 'compare' => '=' ), array( 'key' => 'offer_start_date', 'value' => current_time( 'timestamp' ), 'compare' => '<=' ), array( 'key' => 'offer_expire_date', 'value' => current_time( 'timestamp' ), 'compare' => '>=' ) ) ); $offers = new WP_Query( $args ); if( $offers->have_posts() ){ include(__dir__ .'/../templates/offer-loop.php'); }else{ echo "no featured offer available."; } } } function register_ESSITCO_AMS_Widget() { register_widget( 'ESSITCO_AMS_Store_Widget' ); register_widget( 'ESSITCO_AMS_offer_Widget' ); } add_action( 'widgets_init', 'register_ESSITCO_AMS_Widget' ); ?>