zZzzZ.
home2
/
zrzvbdry
/
airuzu.com
/
wp-content
/
themes
/
savings-pro-main
/
inc
/
widgets
New Folder
Editing: carousel.php
Save
Cancel
<?php /** * Add Taxonomy widget. */ class WPCoupon_Carousel_Widget extends WP_Widget { /** * Register widget with WordPress. */ function __construct() { parent::__construct( 'st_carousel', // Base ID esc_html__( 'WPCoupon Store Carousel', 'savings-pro' ), // Name array( 'description' => esc_html__( 'Display store width Carousel', 'savings-pro' ), 'classname' => 'widget_carousel widget_wpc_carousel' ), // Args array( 'width' => 530 ) ); } /** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget( $args, $instance ) { $instance = wp_parse_args( $instance, array( 'title' => '', 'query' => array(), 'controls' => array(), 'featured_only' => '', ) ); $query = wp_parse_args( $instance['query'], array( 'include' => '', 'exclude' => '', 'order' => 'ASC', 'orderby' => '', 'number' => 6, ) ); if ( $query['include'] != '' ){ $query['include'] = array_map( 'intval', explode(',', $query['include'] ) ); } else { unset( $query['include'] ); } if ( $query['exclude'] != '' ){ $query['exclude'] = array_map( 'intval', explode(',', $query['exclude'] ) ); } else { unset( $query['exclude'] ); } if ( $instance['featured_only'] == 1 ) { $query['meta_key'] = '_wpc_is_featured'; $query['meta_value'] = 'on'; $query['meta_query'] = array( array( 'key' => '_wpc_is_featured', 'value' => 'on', 'compare' => '=', ), ); } $is_rtl = is_rtl() ? true : false; $url = get_template_directory_uri().'/inc/widgets/'; //wp_enqueue_script( 'owl.carousel', $url.'assets/js/owl.carousel.js', array(), false, true ); //wp_enqueue_script( 'st-carousel', $url.'assets/js/carousel.js', array(), false, true ); $terms = get_terms( 'coupon_store', $query ); echo $args['before_widget']; ?> <section class="favorite-deals-section"> <div class="container"> <?php if ( ! empty( $instance['title'] ) ) {?> <div class="section-header"> <h3 class="section-title"><?php echo $instance['title']?></h3> <p class="section-sub-title"><?php echo $instance['sub-title']?></p> </div> <?php }?> <div class="section-body"> <div class="left-section"> <img alt="" class="lazy loaded" width="589" height="517" src="https://node2.sdccdn.com/images/savings/logo/5021835.jpeg"> </div> <div class="right-section"> <div class="store-list"> <?php if ( $terms ) { ?> <?php foreach ( $terms as $term ) { wpcoupon_setup_store( $term ); ?> <div class="list-item"> <div class="item-left"> <div class="store-thum-img"> <div class="item-logo"> <?php echo wpcoupon_store()->get_thumbnail( 'wpcoupon_small_thumb' ); ?> </div> </div> <div class="item-txt"> <?php $store_name = wpcoupon_store()->get_display_name(); $term_url = wpcoupon_store()->get_url(); $st_content = wpcoupon_store()->get_content(); if ( $store_name && $term_url != $store_name ) { $data = parse_url( $store_name ); if (is_array($data)) { $url = isset($data['host']) ? $data['host'] : ''; if (!$url) { $url = isset($data['path']) ? $data['path'] : ''; } } else { $url = wpcoupon_store()->get_display_name(); } } else { $url = $url = wpcoupon_store()->get_display_name(); } ?> <h4><?php echo esc_html( $store_name ); ?></h4> <?php echo substr($st_content, 0, 98); ?> </div> </div> <a class="details-btn" href="<?php echo esc_url( $term_url ) ; ?>">View Coupons</a> </div> <?php } } ?> </div> </div> </div> </div> </section> <?php wp_reset_postdata(); echo $args['after_widget']; } /** * Back-end widget form. * * @see WP_Widget::form() * * @param array $instance Previously saved values from database. */ public function form( $instance ) { $instance = wp_parse_args( $instance, array( 'title' => '', 'sub-title' => '', 'query' => array(), 'controls' => array(), 'featured_only' => '', ) ); $query = wp_parse_args( $instance['query'], array( 'include' => '', 'exclude' => '', 'order' => 'ASC', 'orderby' => 'DESC', 'number' => 6, ) ); ?> <p> <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'savings-pro' ); ?></label> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>"> </p> <p> <label for="<?php echo $this->get_field_id( 'sub-title' ); ?>"><?php esc_html_e( 'Sub Title:', 'savings-pro' ); ?></label> <textarea class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'sub-title' ); ?>" type="text" value="<?php echo esc_attr( $instance['sub-title'] ); ?>"></textarea> </p> <p> <input class="widefat" id="<?php echo $this->get_field_id( 'featured_only' ); ?>" name="<?php echo $this->get_field_name( 'featured_only' ); ?>" <?php checked( $instance['featured_only'], 1 ); ?> type="checkbox" value="1"> <label for="<?php echo $this->get_field_id( 'featured_only' ); ?>"><?php esc_html_e( 'Featured stores only.', 'savings-pro' ); ?></label> </p> <p> <label for="<?php echo $this->get_field_id( 'include' ); ?>"><?php esc_html_e( 'Include:', 'savings-pro' ); ?></label> <input class="widefat" id="<?php echo $this->get_field_id( 'include' ); ?>" name="<?php echo $this->get_field_name( 'query' ).'[include]'; ?>" type="text" value="<?php echo esc_attr( $query['include'] ); ?>"> </p> <p> <label for="<?php echo $this->get_field_id( 'exclude' ); ?>"><?php esc_html_e( 'Exclude:', 'savings-pro' ); ?></label> <input class="widefat" id="<?php echo $this->get_field_id( 'exclude' ); ?>" name="<?php echo $this->get_field_name( 'query' ).'[exclude]'; ?>" type="text" value="<?php echo esc_attr( $query['exclude'] ); ?>"> </p> <p> <label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php esc_html_e( 'How many stores to display ?', 'savings-pro' ); ?></label> <input class="" id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'query' ).'[number]'; ?>" type="text" value="<?php echo esc_attr( $query['number'] ); ?>"> </p> <p> <label for="<?php echo $this->get_field_id( 'orderby' ); ?>"><?php esc_html_e( 'Order by:', 'savings-pro' ); ?></label> <select name="<?php echo $this->get_field_name( 'query' ).'[orderby]'; ?>"> <?php $a = array( 'none' => esc_html__( 'Default', 'savings-pro' ), 'count' => esc_html__( 'Number coupons', 'savings-pro' ), 'name' => esc_html__( 'Title', 'savings-pro' ), 'id' => esc_html__( 'Preserve Store ID order given in the inlcude IDs', 'savings-pro' ), ) ; foreach ( $a as $k => $v ) { echo '<option value="'.$k.'" '.selected( $query['orderby'], $k, false ).' >'.$v.'</option>'; } ?> </select> </p> <p> <label for="<?php echo $this->get_field_id( 'order' ); ?>"><?php esc_html_e( 'Order:', 'savings-pro' ); ?></label> <select name="<?php echo $this->get_field_name( 'query' ).'[order]'; ?>"> <?php $a = array( 'desc' => esc_html__( 'Desc', 'savings-pro' ), 'asc' => esc_html__( 'Asc', 'savings-pro' ), ); foreach ( $a as $k => $v ) { echo '<option value="'.$k.'" '.selected( $query['order'], $k, false ).' >'.$v.'</option>'; } ?> </select> </p> <hr> <?php } /** * Sanitize widget form values as they are saved. * * @see WP_Widget::update() * * @param array $new_instance Values just sent to be saved. * @param array $old_instance Previously saved values from database. * * @return array Updated safe values to be saved. */ public function update( $new_instance, $old_instance ) { //$instance = array(); $new_instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : ''; return $new_instance; // return $instance; } } // class Popular_Store // register Foo_Widget widget function wpcoupon_register_carousel_widget() { register_widget( 'WPCoupon_Carousel_Widget' ); } add_action( 'widgets_init', 'wpcoupon_register_carousel_widget' );