function __construct() { $classname = 'yith-woocommerce-ajax-product-filter yith-woo-ajax-navigation woocommerce widget_layered_nav'; $classname .= 'checkboxes' == yith_wcan_get_option('yith_wcan_ajax_shop_filter_style', 'standard') ? ' with-checkbox' : ''; $widget_ops = array('classname' => $classname, 'description' => __('Filter the product list without reloading the page', 'yith-woocommerce-ajax-navigation')); $control_ops = array('width' => 400, 'height' => 350); add_action('wp_ajax_yith_wcan_select_type', array($this, 'ajax_print_terms')); parent::__construct('yith-woo-ajax-navigation', _x('YITH WooCommerce Ajax Product Filter', 'Admin: Widget Title', 'yith-woocommerce-ajax-navigation'), $widget_ops, $control_ops); }
/** * Enqueue frontend styles and scripts * * @access public * @return void * @since 1.0.0 */ public function enqueue_styles_scripts() { if (yith_wcan_can_be_displayed()) { $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; wp_enqueue_style('yith-wcan-frontend', YITH_WCAN_URL . 'assets/css/frontend.css', false, $this->version); wp_enqueue_script('yith-wcan-script', YITH_WCAN_URL . 'assets/js/yith-wcan-frontend' . $suffix . '.js', array('jquery'), $this->version, true); $custom_style = yith_wcan_get_option('yith_wcan_custom_style', ''); !empty($custom_style) && wp_add_inline_style('yith-wcan-frontend', sanitize_text_field($custom_style)); $args = apply_filters('yith_wcan_ajax_frontend_classes', array('container' => yith_wcan_get_option('yith_wcan_ajax_shop_container', '.products'), 'pagination' => yith_wcan_get_option('yith_wcan_ajax_shop_pagination', 'nav.woocommerce-pagination'), 'result_count' => yith_wcan_get_option('yith_wcan_ajax_shop_result_container', '.woocommerce-result-count'))); wp_localize_script('yith-wcan-script', 'yith_wcan', apply_filters('yith-wcan-frontend-args', $args)); } }
/** * Get is the current uri are filtered * * @return bool true if the url are filtered, false otherwise * * @since 2.8.6 * @author Andrea Grillo <*****@*****.**> */ function yit_is_filtered_uri() { global $_chosen_attributes; $brands = yit_get_brands_taxonomy(); $show_all_categories_link_enabled = 'yes' == yith_wcan_get_option('yith_wcan_enable_see_all_categories_link', 'no'); //check if current page is filtered $is_filtered_uri = isset($_GET['product_cat']) || count($_chosen_attributes) > 0 || isset($_GET['min_price']) || isset($_GET['max_price']) || isset($_GET['orderby']) || isset($_GET['instock_filter']) || isset($_GET['onsale_filter']) || isset($_GET['product_tag']) || isset($_GET[$brands]); return apply_filters('yit_wcan_is_filtered_uri', $is_filtered_uri); }
/** * Get the array of objects terms * * @param $type A type of term to display * * @return $terms mixed|array * * @since 1.3.1 */ function yit_get_terms($case, $taxonomy, $instance = false) { $exclude = apply_filters('yith_wcan_exclude_terms', array(), $instance); $include = apply_filters('yith_wcan_include_terms', array(), $instance); $reordered = false; switch ($case) { case 'all': $terms = get_terms($taxonomy, array('hide_empty' => true, 'exclude' => $exclude)); break; case 'hierarchical': $terms = get_terms($taxonomy, array('hide_empty' => true, 'exclude' => $exclude)); if (!in_array($instance['type'], apply_filters('yith_wcan_display_type_list', array('list')))) { $terms = yit_reorder_terms_by_parent($terms); $reordered = true; } break; case 'parent': $terms = get_terms($taxonomy, array('hide_empty' => true, 'parent' => false, 'exclude' => $exclude)); break; default: $args = array('hide_empty' => true, 'exclude' => $exclude, 'include' => $include); if ('parent' == $instance['display']) { $args['parent'] = false; } $terms = get_terms($taxonomy, $args); if ('hierarchical' == $instance['display']) { if (!in_array($instance['type'], apply_filters('yith_wcan_display_type_list', array('list')))) { $terms = yit_reorder_terms_by_parent($terms); $reordered = true; } } break; } if ('product' == yith_wcan_get_option('yith_wcan_ajax_shop_terms_order', 'alphabetical') && 'hierarchical' != $instance['display'] && !is_wp_error($terms) && !$reordered) { usort($terms, 'yit_terms_sort'); } return apply_filters('yith_wcan_get_terms_list', $terms, $taxonomy, $instance); }