zZzzZ.
home2
/
zrzvbdry
/
couponetive.com
/
wp-content
/
themes
/
savings-pro-main
/
inc
/
widgets
New Folder
Editing: trending.php
Save
Cancel
<?php /** * Add Trending Coupons widget. */ class WPCoupon_trending_widget extends WP_Widget { /** * Register widget with WordPress. */ function __construct() { parent::__construct( 'st_tr_coupons', // Base ID esc_html__( 'Savings Pro Trending Deals', 'savings-pro' ), // Name array( 'description' => esc_html__( 'Display Trending Coupons', 'savings-pro' ), 'classname' => 'st-tr-coupons' ), // 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 ) { ?> <div class="content-widgets frontpage-before-main trending-deals top-offer"> <?php echo $args['before_widget']; $instance = wp_parse_args( $instance, array( 'title' => '', 'posts_per_page' => '', 'num_words' => 10, 'num_words_no_thumb' => 16, 'layout' => 'less', 'enable_coupon_btn' => '', 'content_des_color' => '#fff7f3', ) ); if ( ! empty( $instance['title'] ) ) { echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ). $args['after_title']; } global $wp_query, $post, $paged, $wp_rewrite; $paged = wpcoupon_get_paged(); $get_args = array(); $number = apply_filters( 'st_coupons_number' , get_option( 'posts_per_page' ) ); if( $instance['posts_per_page'] ) { $number = $instance['posts_per_page']; } else { } $get_args[ 'posts_per_page' ] = $number; $posts = wpcoupon_get_coupons( $get_args, $paged , $_max_page ); $current_link = get_permalink(); $tpl_name = null; if ( ! $instance['layout'] || $instance['layout'] == 'less' ) { $tpl_name = 'cat'; } if ( isset( $instance['num_words'] ) ) { $GLOBALS['coupon_num_words'] = $instance['num_words'] ; $GLOBALS['coupon_num_words_no_thumb'] = $instance['num_words_no_thumb'] ; } $id = uniqid('coupons-'); ?> <div class="coupons-tab-contents"> <?php // Popular coupons $coupons = wpcoupon_get_popular_coupons($number); $_max_page = $wp_query->max_num_pages; ?> <div class="ajax-coupons coupon-tab-content popular-tab <?php echo ( $num_tab > 1 ) ? 'hide' : '' ?>"> <div class="store-listings st-list-coupons"> <?php if ($coupons) { foreach ($coupons as $post) { wpcoupon_setup_coupon($post, $current_link); $has_thumb = wpcoupon_maybe_show_coupon_thumb(); $has_expired = wpcoupon_coupon()->has_expired(); ?> <div data-id="<?php echo wpcoupon_coupon()->ID; ?>" class="coupon-item <?php echo $has_thumb ? 'has-thumb' : 'no-thumb'; ?> store-listing-item tending-coupon-listing-item shadow-box <?php echo ( $has_expired ) ? 'coupon-expired' : 'coupon-live'; ?> coupon-listing-item"> <?php if ( $has_thumb ) { $myimage = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full');?> <?php $background_colors = array('#ffffff'); $count = count($background_colors) - 1; $i = rand(0, $count); $rand_background = $background_colors[$i]; if( $myimage ){?> <div class="store-thumb-link" style="background: url(<?php echo $myimage[0]; ?>);" > <?php }else{ $bg_color = array('#a30000', '#0058a3', '#00a37d', '#a37800'); $count_1 = count($bg_color) - 1; $i_1 = rand(0, $count_1); $rand_background_1 = $bg_color[$i_1]; ?> <div class="store-thumb-link" style="background:<?php echo $rand_background_1; ?>;" > <?php } ?> <div class="store-thumb"> <?php if ( ! is_tax( 'coupon_store' ) ) { ?> <a class="thumb-padding" href="<?php echo esc_attr( wpcoupon_coupon()->get_store_url() ); ?>" style="background-color: <?php echo $rand_background; ?>;"> <?php echo wpcoupon_coupon()->get_store_thumb( 'wpcoupon_medium-thumb' ); ?> </a> <?php } else { ?> <span class="thumb-padding store-th" > <?php echo wpcoupon_coupon()->get_store_thumb( 'wpcoupon_medium-thumb' ); ?> </span> <?php } ?> <span class="thumb-padding"> <?php $text = get_post_meta( wpcoupon_coupon()->ID, '_wpc_coupon_save', true ); $is_free_shipping = get_post_meta( wpcoupon_coupon()->ID, '_wpc_free_shipping', true ); $a = explode( '|', $text ); if ( count( $a ) > 1 ) { $text = $a[0]; if ( $is_free_shipping ) { esc_html_e( 'Free Shipping', 'savings-pro' ); } elseif ( $text ) { echo wp_kses_post( $text ); } if ( $a[1] ) { echo '<span>' . esc_html( $a[1] ) . '</span>'; } } else { if ( $is_free_shipping ) { esc_html_e( 'Free Shipping', 'savings-pro' ); } elseif ( $text ) { echo wp_kses_post( $text ); } } ?> </span> </div> </div> <?php } ?> <div class="coupon-des" style="background:<?php echo $instance['content_des_color'];?>"> <div class="coupon-store"> <span><?php echo esc_html_e(wpcoupon_coupon()->store->name ); ?></span> </div> <a title="<?php echo esc_attr( get_the_title( wpcoupon_coupon()->ID ) ) ?>" <?php if ( ! wpcoupon_is_single_enable() ) { ?> rel="nofollow" <?php } ?> class="coupon-link" data-type="<?php echo wpcoupon_coupon()->get_type(); ?>" data-coupon-id="<?php echo wpcoupon_coupon()->ID; ?>" data-aff-url="<?php echo esc_attr( wpcoupon_coupon()->get_go_out_url() ); ?>" data-code="<?php echo esc_attr( wpcoupon_coupon()->get_code() ); ?>" href="<?php echo esc_attr( wpcoupon_coupon()->get_href() ); ?>"> <div class="coupon-title"> <?php edit_post_link('<i class="edit icon"></i>', '', '', wpcoupon_coupon()->ID ); ?> <a title="<?php echo esc_attr( get_the_title( wpcoupon_coupon()->ID ) ) ?>" <?php if ( ! wpcoupon_is_single_enable() ) { ?> rel="nofollow" <?php } ?> class="coupon-link" data-type="<?php echo wpcoupon_coupon()->get_type(); ?>" data-coupon-id="<?php echo wpcoupon_coupon()->ID; ?>" data-aff-url="<?php echo esc_attr( wpcoupon_coupon()->get_go_out_url() ); ?>" data-code="<?php echo esc_attr( wpcoupon_coupon()->get_code() ); ?>" href="<?php echo esc_attr( wpcoupon_coupon()->get_href() ); ?>"> <?php echo substr(get_the_title( wpcoupon_coupon()->ID ),0,150) . '';?> </a> </div> </a> <?php //get_template_part('loop/coupon-footer-meta'); ?> <div class="coupon-footer coupon-listing-footer"> <div class="footer-coupon-listing"> <ul class="use-coupon fleft"> <li> <?php esc_html_e( 'Used ', 'savings-pro' ); ?> <?php echo wpcoupon_coupon()->get_total_used();?> <?php esc_html_e( ' times', 'savings-pro' ); ?> </li> </ul> <ul class="fright"> <li> <a data-reveal="reveal-comments" href="#"> <?php esc_attr_e( 'See Details', 'savings-pro' ); ?> </a> </li> </ul> </div> <div data-coupon-id="<?php echo wpcoupon_coupon()->ID; ?>" class="reveal-content reveal-comments reveal-footer-meta"> <span class="close"></span> <!-- Tab area--> <form class="tabset"> <!-- Tab 1 --> <input type="radio" name="tabset" id="<?php echo wpcoupon_coupon()->ID; ?>-tab1" aria-controls="<?php echo wpcoupon_coupon()->ID; ?>-tab1" checked="checked"> <div class="tab-panels"> <section id="<?php echo wpcoupon_coupon()->ID; ?>-tab1" class="tab-panel"> <div class="coupon-dess"> <?php if ( wpcoupon_get_option( 'coupon_more_desc', true ) ) { ?> <div class="coupon-des-ellip"> <div><strong><?php echo esc_html__( 'Deal Stats: ', 'savings-pro' );?></strong></div> <div> <?php if ( ! wpcoupon_coupon()->has_expired() ) { ?> <strong><?php echo esc_html__( 'Experies: ', 'savings-pro' );?></strong><span class="exp"><?php echo wpcoupon_coupon()->get_expires(); ?></span> <?php } else { ?> <span class="exp has-expired"><?php echo wpcoupon_coupon()->get_expires() ; ?></span> <?php } ?> </div> <div class="last-validate"> <strong><?php echo esc_html__( 'Last Validated: ', 'savings-pro' );?></strong><span><?php echo wpcoupon_coupon()->get_v_date(); ?></span> </div> <div class="coupon-description-title"> <strong><?php esc_html_e( 'Description:', 'savings-pro' ); ?></strong> </div> <div class="coupon-description"> <?php echo wpcoupon_coupon()->get_excerpt( false, '<span class="c-actions-span">...<a class="more" href="#">'.esc_html__( 'More', 'savings-pro' ).'</a></span>' ); ?> </div> </div> <?php if ( wpcoupon_coupon()->has_more_content ) { ?> <div class="coupon-des-full"> <div><strong><?php echo esc_html__( 'Deal Stats: ', 'savings-pro' );?></strong></div> <div> <?php if ( ! wpcoupon_coupon()->has_expired() ) { ?> <strong><?php echo esc_html__( 'Experies: ', 'savings-pro' );?></strong><span class="exp"><?php echo wpcoupon_coupon()->get_expires(); ?></span> <?php } else { ?> <span class="exp has-expired"><?php echo wpcoupon_coupon()->get_expires() ; ?></span> <?php } ?> </div> <div> <strong><?php echo esc_html__( 'Last Validated: ', 'savings-pro' );?></strong><span><?php echo wpcoupon_coupon()->get_v_date(); ?></span> </div> <div class="coupon-description-title"> <strong><?php esc_html_e( 'Description:', 'savings-pro' ); ?></strong> </div> <?php echo str_replace( ']]>', ']]>', apply_filters( 'the_content', wpcoupon_coupon()->post_content.' <a class="more less" href="#">'. esc_html__( 'Less', 'savings-pro') .'</a>' ) ); ?> </div> <?php } ?> <?php } else { ?> <?php echo apply_filters( 'the_content', wpcoupon_coupon()->post_content ); ?> <?php } ?> </div> </section> </div> </form> <!-- Tab Area--> </div> <?php $enable_coupon_btn = $instance['enable_coupon_btn']; ?> <?php if ($enable_coupon_btn== 1) {?> <?php switch ( wpcoupon_coupon()->get_type() ) { case 'sale': ?> <a rel="nofollow" data-type="<?php echo wpcoupon_coupon()->get_type(); ?>" data-coupon-id="<?php echo wpcoupon_coupon()->ID; ?>" data-aff-url="<?php echo esc_attr( wpcoupon_coupon()->get_go_out_url() ); ?>" class="coupon-deal trnd-get-code-btn" href="<?php echo esc_attr( wpcoupon_coupon()->get_href() ); ?>"><?php echo esc_attr( wpcoupon_get_option( 'get_deal_btn_txt' ), 'savings-pro' ); ?></a> <?php break; case 'print': ?> <a rel="nofollow" data-type="<?php echo wpcoupon_coupon()->get_type(); ?>" data-coupon-id="<?php echo wpcoupon_coupon()->ID; ?>" data-aff-url="<?php echo esc_attr( wpcoupon_coupon()->get_go_out_url() ); ?>" class="coupon-print trnd-get-code-btn" href="<?php echo esc_attr( wpcoupon_coupon()->get_href() ); ?>"><?php echo esc_attr( wpcoupon_get_option( 'print_coupon_btn_txt' ), 'savings-pro' ); ?></a> <?php break; default: ?> <a rel="nofollow" data-type="<?php echo wpcoupon_coupon()->get_type(); ?>" data-coupon-id="<?php echo wpcoupon_coupon()->ID; ?>" href="<?php echo esc_attr( wpcoupon_coupon()->get_href() ); ?>" class="coupon-button trnd-get-code-btn" data-tooltip="<?php echo esc_attr_e( 'Click to copy & open site', 'savings-pro' ); ?>" data-position="top center" data-inverted="" data-code="<?php echo esc_attr( wpcoupon_coupon()->get_code() ); ?>" data-aff-url="<?php echo esc_attr( wpcoupon_coupon()->get_go_out_url() ); ?>"> <span class="get-code"><?php echo esc_attr( wpcoupon_get_option( 'get_code_btn_txt' ), 'savings-pro' ); ?></span> </a> <?php }} ?> </div> </div> <?php get_template_part('loop/coupon-modal'); ?> </div> <?php } } else { ?> <div class="ui warning message"> <i class="close icon"></i> <div class="header"> <?php esc_html_e('Oops! No coupons found', 'savings-pro'); ?> </div> <p><?php esc_html_e('There is no coupons! Please comeback later.', 'savings-pro'); ?></p> </div> <?php } ?> </div> <?php wp_reset_postdata(); ?> </div> <?php ?> </div> <?php echo $args['after_widget']; ?> </div> <?php } /** * 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' => '', 'posts_per_page' => '', 'num_words' => 10, 'num_words_no_thumb' => 16, 'layout' => 'less', 'enable_coupon_btn' => '', 'content_des_color' => '#fff7f3', ) ); $title = ! empty( $instance['title'] ) ? $instance['title'] : esc_html__( 'Trending Coupons, Discounts & Promotions', 'savings-pro' ); $content_des_color = ! empty( $instance['content_des_color'] ) ? $instance['content_des_color'] : esc_html__( '#07525d', 'savings-pro' ); ?> <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( $title ); ?>"> </p> <p> <label for="<?php echo $this->get_field_id( 'posts_per_page' ); ?>"><?php esc_html_e( 'Number coupons to show:', 'savings-pro' ); ?></label> <input class="" id="<?php echo $this->get_field_id( 'posts_per_page' ); ?>" name="<?php echo $this->get_field_name( 'posts_per_page' ); ?>" type="text" value="<?php echo empty($instance['posts_per_page'])?'12':esc_attr( $instance['posts_per_page'] ); ?>"> </p> <p> <label style="float:left;width:165px;" for="<?php echo $this->get_field_id( 'content_des_color' ); ?>"><?php esc_html_e( 'Content Description Color:', 'savings-pro' ); ?></label> <input class="widefat content_des_color" id="<?php echo $this->get_field_id( 'content_des_color' ); ?>" name="<?php echo $this->get_field_name( 'content_des_color' ); ?>" type="color" value="<?php echo esc_attr( $content_des_color ); ?>" style="padding: 0px 2px;height: 25px;width: 38px;position: relative;top: 4px;left: 4px;"> </p> <p> <input class="widefat" id="<?php echo $this->get_field_id( 'enable_coupon_btn' ); ?>" name="<?php echo $this->get_field_name( 'enable_coupon_btn' ); ?>" <?php checked( $instance['enable_coupon_btn'], 1 ); ?> type="checkbox" value="1"> <label for="<?php echo $this->get_field_id( 'Show coupon button' ); ?>"><?php esc_html_e( 'Show coupon button:', 'savings-pro' ); ?></label> </p> <?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_trending_widget() { register_widget( 'WPCoupon_trending_widget' ); } add_action( 'widgets_init', 'wpcoupon_register_trending_widget' );