<?php } } } wp_reset_query(); } } ?> </h1> <?php if (of_get_option('g_breadcrumbs_id') == 'yes') { ?> <!-- BEGIN BREADCRUMBS--> <?php /* Begin shop */ if (function_exists('is_shop') && is_shop() || function_exists('is_product') && is_product() || function_exists('is_product_taxonomy') && is_product_taxonomy() || function_exists('is_product_list') && is_product_list()) { if (class_exists('Woocommerce')) { woocommerce_breadcrumb(array('delimiter' => ' / ', 'wrap_before' => '<ul class="breadcrumb breadcrumb__t">', 'wrap_after' => '</ul>')); } elseif (function_exists('jigoshop_init')) { jigoshop_breadcrumb('/ ', '<ul class="breadcrumb breadcrumb__t">', '</ul>'); } /* End shop */ } elseif (function_exists('breadcrumbs')) { breadcrumbs(); } ?> <!-- END BREADCRUMBS --> <?php } ?> </section><!-- .title-section -->
/** * Widget * Display the widget in the sidebar * * @param array sidebar arguments * @param array instance */ public function widget($args, $instance) { // TODO: Optimize this code // Extract the widget arguments extract($args); global $_chosen_attributes, $jigoshop_all_post_ids_in_view; // Hide widget if not product related if (!is_product_list()) { return false; } // Set the widget title $title = apply_filters('widget_title', $instance['title'] ? $instance['title'] : __('Filter by Attributes', 'jigoshop'), $instance, $this->id_base); // Check if taxonomy exists $taxonomy = 'pa_' . sanitize_title($instance['attribute']); if (!taxonomy_exists($taxonomy)) { return false; } // Get all the terms that aren't empty $args = array('hide_empty' => true); $terms = get_terms($taxonomy, $args); $has_terms = (bool) $terms; // If has terms print layered navigation if ($has_terms) { $found = false; ob_start(); // Print the widget wrapper & title echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } //Remove param link $remove_link = remove_query_arg('filter_' . sanitize_title($instance['attribute'])); echo "<a class=\"layerd_nav_clear\" href=\"{$remove_link}\">Clear</a>"; // Open the list echo "<ul>"; foreach ($terms as $term) { $_products_in_term = get_objects_in_term($term->term_id, $taxonomy); // Get product count & set flag $count = sizeof(array_intersect($_products_in_term, $jigoshop_all_post_ids_in_view)); $has_products = (bool) $count; if ($has_products) { $found = true; } $class = ''; $arg = 'filter_' . sanitize_title($instance['attribute']); if (isset($_GET[$arg])) { $current_filter = explode(',', $_GET[$arg]); } else { $current_filter = array(); } if (!is_array($current_filter)) { $current_filter = array(); } if (!in_array($term->term_id, $current_filter)) { $current_filter[] = $term->term_id; } // Base Link decided by current page if (defined('SHOP_IS_ON_FRONT')) { $link = ''; } elseif (is_shop()) { $link = get_post_type_archive_link('product'); } else { $link = get_term_link(get_query_var('term'), get_query_var('taxonomy')); } // All current filters if ($_chosen_attributes) { foreach ($_chosen_attributes as $name => $value) { if ($name !== $taxonomy) { $link = add_query_arg(sanitize_title(str_replace('pa_', 'filter_', $name)), implode(',', $value), $link); } } } // Min/Max if (isset($_GET['min_price'])) { $link = add_query_arg('min_price', $_GET['min_price'], $link); } if (isset($_GET['max_price'])) { $link = add_query_arg('max_price', $_GET['max_price'], $link); } // Current Filter = this widget if (isset($_chosen_attributes[$taxonomy]) && is_array($_chosen_attributes[$taxonomy]) && in_array($term->term_id, $_chosen_attributes[$taxonomy])) { $class = 'class="chosen"'; } else { $link = add_query_arg($arg, implode(',', $current_filter), $link); } // Search Arg if (get_search_query()) { $link = add_query_arg('s', get_search_query(), $link); } // Post Type Arg if (isset($_GET['post_type'])) { $link = add_query_arg('post_type', $_GET['post_type'], $link); } echo '<li ' . $class . '>'; if ($has_products) { echo '<a href="' . esc_url($link) . '">'; } else { echo '<span>'; } echo $term->name; if ($has_products) { echo '</a>'; } else { echo '</span>'; } echo ' <small class="count">' . $count . '</small></li>'; } echo "</ul>"; // Close the list // Print closing widget wrapper echo $after_widget; if (!$found) { ob_clean(); // clear the buffer return false; // display nothing } else { echo ob_get_clean(); // output the buffer } } }
function is_in_jigoshop_page() { return is_shop() || is_product_list() || is_product_category() || is_product_tag() || is_product() || is_cart() || is_checkout() || is_account() ? true : false; }
/** * Evaluates to true only on the Shop, Category, Tag and Single Product Pages * * @return bool * @since 0.9.9.1 */ function is_content_wrapped() { $is_wrapped = false; $is_wrapped |= is_product_list(); $is_wrapped |= is_product(); return $is_wrapped; }