/** * Top Rated Products Widget. * Gets and displays top rated products in an unordered list. * * @package WooCommerce\Widgets * @version 3.3.0 */ defined( 'ABSPATH' ) || exit; /** * Widget top rated products class. */ class WC_Widget_Top_Rated_Products extends WC_Widget { /** * Constructor. */ public function __construct() { $this->widget_cssclass = 'woocommerce widget_top_rated_products'; $this->widget_description = __( "A list of your store's top-rated products.", 'woocommerce' ); $this->widget_id = 'woocommerce_top_rated_products'; $this->widget_name = __( 'Products by Rating list', 'woocommerce' ); $this->settings = array( 'title' => array( 'type' => 'text', 'std' => __( 'Top rated products', 'woocommerce' ), 'label' => __( 'Title', 'woocommerce' ), ), 'number' => array( 'type' => 'number', 'step' => 1, 'min' => 1, 'max' => '', 'std' => 5, 'label' => __( 'Number of products to show', 'woocommerce' ), ), ); parent::__construct(); } /** * Output widget. * * @see WP_Widget * @param array $args Arguments. * @param array $instance Widget instance. */ public function widget( $args, $instance ) { if ( $this->get_cached_widget( $args ) ) { return; } ob_start(); $number = ! empty( $instance['number'] ) ? absint( $instance['number'] ) : $this->settings['number']['std']; $query_args = apply_filters( 'woocommerce_top_rated_products_widget_args', array( 'posts_per_page' => $number, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'meta_key' => '_wc_average_rating', 'orderby' => 'meta_value_num', 'order' => 'DESC', 'meta_query' => WC()->query->get_meta_query(), 'tax_query' => WC()->query->get_tax_query(), ) ); // WPCS: slow query ok. $r = new WP_Query( $query_args ); if ( $r->have_posts() ) { $this->widget_start( $args, $instance ); echo wp_kses_post( apply_filters( 'woocommerce_before_widget_product_list', '' ) ); $this->widget_end( $args ); } wp_reset_postdata(); $content = ob_get_clean(); echo $content; // WPCS: XSS ok. $this->cache_widget( $args, $content ); } } function ux_navigation($atts) { extract(shortcode_atts(array( 'class' => '', 'visibility' => '', 'parent' => '', 'align' => 'left', 'style' => 'line', 'type' => 'vertical', // horizontal / vertical 'size' => '', 'case' => 'uppercase', //'bg_color' => '', //'height' => '', //'sticky' => '', ), $atts)); ob_start(); global $post; $current = get_the_ID($post->ID); $classes = array('nav'); if($class) $classes[] = $class; if($visibility) $classes[] = $visibility; if($case) $classes[] = 'nav-'.$case; if($type) $classes[] = 'nav-'.$type; if($size) $classes[] = 'nav-size-'.$size; if($style) $classes[] = 'nav-'.$style; if($align) $classes[] = 'text-'.$align.' nav-'.$align; echo ''; $content = ob_get_contents(); ob_end_clean(); return $content; } add_shortcode("ux_nav", "ux_navigation"); // Move Cross sell product to under cart remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' ); add_action( 'woocommerce_after_cart_table', 'woocommerce_cross_sell_display' ); // Add Content after Cart if(!function_exists('flatsome_html_cart_footer')) { function flatsome_html_cart_footer(){ $content = get_theme_mod('html_cart_footer'); echo ''; } add_action( 'woocommerce_after_cart', 'flatsome_html_cart_footer', 99); } // Add Content in cart sidebar if(!function_exists('flatsome_html_cart_sidebar')) { function flatsome_html_cart_sidebar(){ $content = get_theme_mod('html_cart_sidebar'); $icons = get_theme_mod('payment_icons_placement'); echo '
'.do_shortcode($content).'
'; if(is_array($icons) && in_array('cart', $icons)) echo do_shortcode('[ux_payment_icons]'); } add_action( 'flatsome_cart_sidebar', 'flatsome_html_cart_sidebar', 10); } // Continue Shopping button if(!function_exists('flatsome_continue_shopping')) { function flatsome_continue_shopping(){ wc_get_template_part('cart/continue-shopping'); } } add_action('woocommerce_cart_actions', 'flatsome_continue_shopping', 10); // Move Privacy policy to bottom function flatsome_fix_policy_text(){ if(function_exists('wc_checkout_privacy_policy_text')) { remove_action( 'woocommerce_checkout_terms_and_conditions', 'wc_checkout_privacy_policy_text', 20 ); add_action( 'woocommerce_checkout_after_order_review', 'wc_checkout_privacy_policy_text', 1 ); } } add_action( 'init', 'flatsome_fix_policy_text', 10);