function setup_gridlist()
 {
     if (is_shop() || is_product_category() || is_product_tag() || is_product_taxonomy()) {
         add_action('wp_enqueue_scripts', array($this, 'setup_scripts_script'), 20);
         add_action('woocommerce_before_shop_loop', array($this, 'gridlist_toggle_button'), 10);
     }
 }
 /**
  * Get the post id to use to display a header
  * For example, if a header is set for the blog, we will use it for the archive and search page
  *
  * @return int $id
  */
 function wolf_get_header_post_id()
 {
     if (is_404() || is_page_template('page-templates/home.php')) {
         return;
     }
     $post_id = null;
     $shop_page_id = wolf_get_woocommerce_shop_page_id();
     $is_shop_page = function_exists('is_shop') ? is_shop() : false;
     $is_product_taxonomy = function_exists('is_product_taxonomy') ? is_product_taxonomy() : false;
     $is_single_product = function_exists('is_product') ? is_product() : false;
     // is blog
     if (get_option('page_for_posts') && wolf_is_blog() && false == $is_shop_page && false == $is_product_taxonomy) {
         $post_id = get_option('page_for_posts');
         // if woocommerce
     } elseif ($is_shop_page || $is_product_taxonomy) {
         $post_id = $shop_page_id;
         // is single product
     } elseif ($is_single_product) {
         if (get_post_meta(get_the_ID(), '_header_bg_img', true) || get_post_meta(get_the_ID(), '_header_bg_color', true)) {
             $post_id = get_the_ID();
         } else {
             $post_id = $shop_page_id;
         }
     } else {
         $post_id = get_the_ID();
     }
     return $post_id;
 }
 /**
  * Load a template.
  *
  * Handles template usage so that we can use our own templates instead of the themes.
  *
  * Templates are in the 'templates' folder. woocommerce looks for theme
  * overrides in /theme/woocommerce/ by default
  *
  * For beginners, it also looks for a woocommerce.php template first. If the user adds
  * this to the theme (containing a woocommerce() inside) this will be used for all
  * woocommerce templates.
  *
  * @param mixed $template
  * @return string
  */
 public static function template_loader($template)
 {
     $find = array('woocommerce.php');
     $file = '';
     if (is_single() && get_post_type() == 'product') {
         $file = 'single-product.php';
         $find[] = $file;
         $find[] = WC()->template_path() . $file;
     } elseif (is_product_taxonomy()) {
         $term = get_queried_object();
         if (is_tax('product_cat') || is_tax('product_tag')) {
             $file = 'taxonomy-' . $term->taxonomy . '.php';
         } else {
             $file = 'archive-product.php';
         }
         $find[] = 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
         $find[] = WC()->template_path() . 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
         $find[] = 'taxonomy-' . $term->taxonomy . '.php';
         $find[] = WC()->template_path() . 'taxonomy-' . $term->taxonomy . '.php';
         $find[] = $file;
         $find[] = WC()->template_path() . $file;
     } elseif (is_post_type_archive('product') || is_page(wc_get_page_id('shop'))) {
         $file = 'archive-product.php';
         $find[] = $file;
         $find[] = WC()->template_path() . $file;
     }
     if ($file) {
         $template = locate_template(array_unique($find));
         $status_options = get_option('woocommerce_status_options', array());
         if (!$template || !empty($status_options['template_debug_mode']) && current_user_can('manage_options')) {
             $template = WC()->plugin_path() . '/templates/' . $file;
         }
     }
     return $template;
 }
 /**
  * Echo the widget content.
  *
  * Subclasses should over-ride this function to generate their widget code.
  *
  * @param array $args     Display arguments including before_title, after_title,
  *                        before_widget, and after_widget.
  * @param array $instance The settings for the particular instance of the widget.
  *
  * @author Andrea Grillo <*****@*****.**>
  */
 public function widget($args, $instance)
 {
     $hide = !empty($instance['hide_on_vendor_page']) && is_product_taxonomy(YITH_Vendors()->get_taxonomy_name());
     if (!$hide) {
         yith_wcpv_get_template('vendors-list', $instance, 'widgets');
     }
 }
Example #5
0
 function setup_scripts_script()
 {
     if (is_shop() || is_product_category() || is_product_tag() || is_product_taxonomy()) {
         wp_enqueue_script('cookie', plugins_url('/assets/js/jquery.cookie.min.js', __FILE__), array('jquery'));
         wp_enqueue_script('grid-list-scripts', plugins_url('/assets/js/jquery.gridlistview.min.js', __FILE__), array('jquery'));
         add_action('wp_footer', array(&$this, 'gridlist_set_default_view'));
     }
 }
Example #6
0
/**
 * Add classes to <body>
 *
 * @param array $classes
 *
 * @return array
 */
function constructent_body_class($classes)
{
    // Layout class
    $classes[] = constructent_layout();
    // Class for layout style
    $classes[] = constructent_option('layout_style');
    // Color scheme
    $custom_color_scheme = constructent_option('custom_color_scheme');
    if (!$custom_color_scheme) {
        $classes[] = constructent_option('color_scheme');
    } else {
        $classes[] = 'custom-color-scheme';
    }
    // Class for custom header color
    if (constructent_option('header_custom') && constructent_option('header_background')) {
        $classes[] = 'header-custom';
    }
    // Class for woocommerce columns
    if (function_exists('is_shop') && (is_shop() || is_product_taxonomy())) {
        global $woocommerce_loop;
        if (empty($woocommerce_loop['columns'])) {
            $columns = 'full-content' == constructent_layout() ? 4 : 3;
        } else {
            $columns = $woocommerce_loop['columns'];
        }
        $classes[] = 'columns-' . esc_attr($columns);
    }
    // Class for solid header
    $header_type = constructent_option('header_type');
    $header_type = $header_type ? esc_attr($header_type) : 'static';
    if ($header_type == 'absolute' && !is_page_template('tpl/homepage.php')) {
        $classes[] = 'header-static';
    } else {
        $classes[] = 'header-' . $header_type;
    }
    // Transparent header
    if ('absolute' == $header_type && is_page_template('tpl/homepage.php') && constructent_option('header_transparent')) {
        $classes[] = 'header-transparent';
    }
    // Class for menu hover
    if ($hover = constructent_option('menu_hover')) {
        $classes[] = 'menu-hover-' . $hover;
    }
    // If no featured title area
    if (!constructent_show_featured_title()) {
        $classes[] = 'no-title-area';
    }
    // Class for portfolio layout
    if (is_page_template('tpl/portfolio.php')) {
        $classes[] = 'portfolio-' . constructent_meta('style_portfolio');
    }
    // Class for portfolio category layout
    if (is_tax('portfolio_category')) {
        $classes[] = 'portfolio-' . constructent_option('portfolio_view');
    }
    $classes = array_unique(array_filter($classes));
    return $classes;
}
 function setup_gridlist()
 {
     if (is_shop() || is_product_category() || is_product_tag() || is_product_taxonomy()) {
         add_action('wp_enqueue_scripts', array($this, 'setup_scripts_styles'), 20);
         add_action('wp_enqueue_scripts', array($this, 'setup_scripts_script'), 20);
         add_action('woocommerce_before_shop_loop', array($this, 'gridlist_toggle_button'), 30);
         add_action('woocommerce_after_shop_loop_item', array($this, 'gridlist_buttonwrap_open'), 9);
         add_action('woocommerce_after_shop_loop_item', array($this, 'gridlist_buttonwrap_close'), 11);
         add_action('woocommerce_after_shop_loop_item', array($this, 'gridlist_hr'), 30);
         add_action('woocommerce_after_shop_loop_item', 'woocommerce_template_single_excerpt', 5);
         add_action('woocommerce_after_subcategory', array($this, 'gridlist_cat_desc'));
     }
 }
 public function init()
 {
     wp_localize_script('etp-script', 'sfpSettings', array('shopLayout' => false, 'mobStore' => false, 'infiniteScroll' => false));
     if (!is_woocommerce_activated()) {
         $this->css .= '.wc-18-tags-active #site-navigation > div { width: 100%; }';
         return;
     }
     add_filter('eighteen_tags_loop_columns', array($this, 'columns'), 999);
     //Header cart display
     $header_cart = $this->get('header-wc-cart');
     add_action('wc_18_tags_in' . $header_cart . '_nav', 'eighteen_tags_header_cart');
     if (!empty($header_cart)) {
         add_action('wc_18_tags_in_nav', 'eighteen_tags_header_cart');
         WooCommerce_18_Tags_Public::$desktop_css .= '#site-navigation.main-navigation .site-header-cart { display: none !important; }';
         $this->css .= '.wc-18-tags-active #site-navigation > div { width: 100%; }';
     }
     //Header cart color
     $this->css .= '.wc-18-tags-active .site-header-cart .cart-contents { color: ' . $this->get('header-wc-cart-color', '#000000') . '; }';
     $is_product_archive = is_shop() || is_product_taxonomy();
     $is_checkout_process = is_cart() || is_checkout();
     $this->set_styles($is_product_archive, $is_checkout_process);
 }
<?php

/**
 *	Template for displaying shop results bar/button
 */
if (!defined('ABSPATH')) {
    exit;
}
// Is search query set and not empty?
$is_search = !empty($_REQUEST['s']) ? true : false;
if ($is_search || is_product_taxonomy()) {
    // Is this a product category?
    $is_category = $is_search ? false : is_product_category();
    // Results bar class
    $results_bar_class = $is_category ? ' is-category' : '';
    // Get shop page URL
    $shop_page_url = get_permalink(wc_get_page_id('shop'));
    ?>

    <div class="nm-shop-results-bar btn<?php 
    echo esc_attr($results_bar_class);
    ?>
">
        <a href="#" data-shop-url="<?php 
    echo esc_url($shop_page_url);
    ?>
" id="nm-shop-results-reset">
            <i class="nm-font nm-font-close2"></i>
            <?php 
    if ($is_search) {
        printf(esc_html__('Search results for %s', 'nm-framework'), '<span>"' . $_REQUEST['s'] . '"</span>');
Example #10
0
switch ($headline) {
    case 'mixed':
        $headline = is_single() ? 'navigation' : 'breadcrumbs';
        break;
    case 'navigation':
        if (!is_single()) {
            $headline = 'none';
        }
        break;
}
if ($headline != 'none') {
    get_template_part('parts/' . $headline);
}
?>
			<h1><?php 
if (Everything::isPluginActive('woocommerce') && (is_shop() || is_product_taxonomy()) && !is_product()) {
    woocommerce_page_title();
} else {
    if (is_home()) {
        is_front_page() ? _e('Blog', 'everything') : single_post_title();
    } else {
        if (is_day()) {
            echo get_the_date();
        } else {
            if (is_month()) {
                echo get_the_date('F Y');
            } else {
                if (is_year()) {
                    echo get_the_date('Y');
                } else {
                    if (is_category() || is_tax('portfolio-category')) {
Example #11
0
				<?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 -->
 /**
  * Check if we will be showing products or not (and not subcats only)
  *
  * @access public
  * @subpackage	Loop
  * @return bool
  */
 function woocommerce_products_will_display()
 {
     if (is_shop()) {
         return get_option('woocommerce_shop_page_display') != 'subcategories';
     }
     if (!is_product_taxonomy()) {
         return false;
     }
     if (is_search() || is_filtered() || is_paged()) {
         return true;
     }
     $term = get_queried_object();
     if (is_product_category()) {
         switch (get_woocommerce_term_meta($term->term_id, 'display_type', true)) {
             case 'products':
             case 'both':
                 return true;
                 break;
             case '':
                 if (get_option('woocommerce_category_archive_display') != 'subcategories') {
                     return true;
                 }
                 break;
         }
     }
     global $wpdb;
     $parent_id = empty($term->term_id) ? 0 : $term->term_id;
     $taxonomy = empty($term->taxonomy) ? '' : $term->taxonomy;
     $products_will_display = false;
     if (!$parent_id && !$taxonomy) {
         return true;
     }
     if (false === ($products_will_display = get_transient('wc_products_will_display_' . $parent_id))) {
         $has_children = $wpdb->get_col($wpdb->prepare("SELECT term_id FROM {$wpdb->term_taxonomy} WHERE parent = %d AND taxonomy = %s", $parent_id, $taxonomy));
         if ($has_children) {
             // Check terms have products inside - parents first
             if (sizeof(get_objects_in_term($has_children, $taxonomy)) > 0) {
                 $products_will_display = true;
             } else {
                 // If we get here, the parents were empty so we're forced to check children
                 foreach ($has_children as $term) {
                     $children = get_term_children($term, $taxonomy);
                     if (sizeof(get_objects_in_term($children, $taxonomy)) > 0) {
                         $products_will_display = true;
                         break;
                     }
                 }
             }
         } else {
             $products_will_display = true;
         }
     }
     set_transient('wc_products_will_display_' . $parent_id, $products_will_display);
     return $products_will_display;
 }
Example #13
0
 function redirect_double_taxonomy($redirect, $request)
 {
     if (self::$settings['permalink_structure'] !== '' && (is_shop() || is_product_taxonomy()) !== false && strpos($request, 'product_cat=') > 0) {
         return $request;
     }
     return $redirect;
 }
Example #14
0
do_action('prdctfltr_filter_form_after', $curr_options, $pf_activated);
?>
		<div class="prdctfltr_add_inputs">
		<?php 
if (!in_array('search', $curr_elements) && isset($pf_activated['s'])) {
    echo '<input type="hidden" name="s" value="' . $pf_activated['s'] . '" />';
}
if (isset($_GET['page_id'])) {
    echo '<input type="hidden" name="page_id" value="' . $_GET['page_id'] . '" />';
}
if (isset($_GET['lang'])) {
    echo '<input type="hidden" name="lang" value="' . $_GET['lang'] . '" />';
}
$curr_posttype = get_option('wc_settings_prdctfltr_force_product', 'no');
if ($curr_posttype == 'no') {
    if (!isset($pf_activated['s']) && $pf_structure == '' && (is_shop() || is_product_taxonomy())) {
        echo '<input type="hidden" name="post_type" value="product" />';
    }
} else {
    echo '<input type="hidden" name="post_type" value="product" />';
}
if (isset($pf_activated['orderby']) && !in_array('sort', $curr_elements)) {
    echo '<input type="hidden" name="orderby" value="' . $pf_activated['orderby'] . '" />';
}
if (!isset($prdctfltr_global['sc_init']) && !empty($prdctfltr_global['active_permalinks'])) {
    foreach ($prdctfltr_global['active_permalinks'] as $pf_k => $pf_v) {
        /*if ( !in_array( $pf_k, $active_filters ) ) {*/
        echo '<input type="hidden" name="' . $pf_k . '" value="' . $prdctfltr_global['permalinks_data'][$pf_k . '_string'] . '" />';
        /*}*/
        $prdctfltr_global['filter_js'][$prdctfltr_id]['adds'][$pf_k] = $prdctfltr_global['permalinks_data'][$pf_k . '_string'];
    }
 /**
  * Check if we will be showing products or not (and not subcats only)
  *
  * @access public
  * @subpackage	Loop
  * @return void
  */
 function woocommerce_products_will_display()
 {
     global $woocommerce, $wpdb;
     if (!is_product_category() && !is_product_tag() && !is_shop() && !is_product_taxonomy()) {
         return false;
     }
     if (is_search() || is_filtered() || is_paged()) {
         return true;
     }
     if (is_shop() && get_option('woocommerce_shop_page_display') != 'subcategories') {
         return true;
     }
     $term = get_queried_object();
     if (is_product_category()) {
         switch (get_woocommerce_term_meta($term->term_id, 'display_type', true)) {
             case 'products':
             case 'both':
                 return true;
                 break;
             case '':
                 if (get_option('woocommerce_category_archive_display') != 'subcategories') {
                     return true;
                 }
                 break;
         }
     }
     $parent_id = empty($term->term_id) ? 0 : $term->term_id;
     $has_children = $wpdb->get_col($wpdb->prepare("SELECT term_id FROM {$wpdb->term_taxonomy} WHERE parent = %d", $parent_id));
     if ($has_children) {
         // Check terms have products inside
         $children = array();
         foreach ($has_children as $term) {
             $children = array_merge($children, get_term_children($term, 'product_cat'));
             $children[] = $term;
         }
         $objects = get_objects_in_term($children, 'product_cat');
         if (sizeof($objects) > 0) {
             return false;
         } else {
             return true;
         }
     } else {
         return true;
     }
 }
Example #16
0
<?php

/**
 * @package    WordPress
 * @subpackage Everything
 * @since      1.0
 */
// Separator
$separator = '&rsaquo;';
// is_rtl() ? '&lsaquo;' : '&rsaquo;'
// bbPress
if (Everything::isPluginActive('bbpress') && Everything::to('bbpress/breadcrumbs') && is_bbpress()) {
    $breadcrumbs_html = bbp_get_breadcrumb(array('before' => '', 'after' => '', 'sep' => $separator, 'sep_before' => '', 'sep_after' => '', 'current_before' => '', 'current_after' => ''));
} else {
    if (Everything::isPluginActive('woocommerce') && Everything::to('woocommerce/breadcrumbs') && (is_shop() || is_product_taxonomy() || is_product())) {
        //  || is_cart() || is_checkout() || is_order_received_page() || is_account_page()
        $breadcrumbs_html = \Drone\Func::functionGetOutputBuffer('woocommerce_breadcrumb', array('delimiter' => $separator, 'wrap_before' => '', 'wrap_after' => ''));
    } else {
        if (Everything::isPluginActive('breadcrumb-navxt')) {
            $options = get_option('bcn_options');
            $separator = $options['hseparator'];
            $breadcrumbs_html = bcn_display(true);
        } else {
            if (Everything::isPluginActive('breadcrumb-trail')) {
                $breadcrumbs_html = breadcrumb_trail(array('separator' => $separator, 'show_browse' => false, 'echo' => false));
            } else {
                if (Everything::isPluginActive('wordpress-seo')) {
                    $options = get_option('wpseo_internallinks');
                    $separator = $options['breadcrumbs-sep'] ? $options['breadcrumbs-sep'] : '&raquo;';
                    $breadcrumbs_html = yoast_breadcrumb('', '', false);
                } else {
 /**
  * Generates Product structured data.
  *
  * Hooked into `woocommerce_single_product_summary` action hook.
  * Hooked into `woocommerce_shop_loop` action hook.
  *
  * @param WC_Product $product Product data (default: null).
  */
 public function generate_product_data($product = null)
 {
     if (!is_object($product)) {
         global $product;
     }
     $markup = array();
     $markup['@type'] = 'Product';
     $markup['@id'] = get_permalink($product->get_id());
     $markup['url'] = $markup['@id'];
     $markup['name'] = $product->get_title();
     if (apply_filters('woocommerce_structured_data_product_limit', is_product_taxonomy() || is_shop())) {
         $this->set_data(apply_filters('woocommerce_structured_data_product_limited', $markup, $product));
         return;
     }
     $products = array();
     if ($is_variable = $product->is_type('variable')) {
         $variations = $product->get_available_variations();
         foreach ($variations as $variation) {
             $products[] = wc_get_product($variation['variation_id']);
         }
     } else {
         $products[] = $product;
     }
     $markup_offers = array();
     foreach ($products as $_product) {
         $markup_offers[] = array('@type' => 'Offer', 'priceCurrency' => get_woocommerce_currency(), 'price' => $_product->get_price(), 'availability' => 'http://schema.org/' . ($stock = $_product->is_in_stock() ? 'InStock' : 'OutOfStock'), 'sku' => $_product->get_sku(), 'image' => wp_get_attachment_url($_product->get_image_id()), 'description' => $is_variable ? $_product->get_variation_description() : '', 'seller' => array('@type' => 'Organization', 'name' => get_bloginfo('name'), 'url' => get_bloginfo('url')));
     }
     $markup['description'] = get_the_excerpt($product->get_id());
     $markup['offers'] = $markup_offers;
     if ($product->get_rating_count()) {
         $markup['aggregateRating'] = array('@type' => 'AggregateRating', 'ratingValue' => $product->get_average_rating(), 'ratingCount' => $product->get_rating_count(), 'reviewCount' => $product->get_review_count());
     }
     $this->set_data(apply_filters('woocommerce_structured_data_product', $markup, $product));
 }
Example #18
0
 public static function woocommerce_before_shop_loop()
 {
     if (!defined('DOING_AJAX')) {
         if (is_product_taxonomy() or is_shop()) {
             if (class_exists('MetaDataFilter') and MetaDataFilter::is_page_mdf_data()) {
                 $_REQUEST['mdf_do_not_render_shortcode_tpl'] = true;
                 $_REQUEST['mdf_get_query_args_only'] = true;
                 do_shortcode('[meta_data_filter_results]');
                 $args = $_REQUEST['meta_data_filter_args'];
                 global $wp_query;
                 $wp_query = new WP_Query($args);
                 $_REQUEST['meta_data_filter_found_posts'] = $wp_query->found_posts;
             }
         }
     }
 }
 /**
  * Get specific layouts from options for shop-related pages
  *
  * @since  1.0.0
  * @param  string $layout layout type.
  * @return string
  */
 public function shop_page_layouts($layout)
 {
     if (is_shop()) {
         $layout = cherry_wc_options()->get_option('shop-loop-layout', 'no-sidebar');
     } elseif (is_product_taxonomy()) {
         $layout = cherry_wc_options()->get_option('shop-category-layout', 'no-sidebar');
     } elseif (is_singular('product')) {
         $layout = cherry_wc_options()->get_option('shop-single-layout', 'no-sidebar');
     }
     return $layout;
 }
 function template_loader($template)
 {
     if (is_product_taxonomy()) {
         global $sitepress, $woocommerce_wpml;
         $current_language = $sitepress->get_current_language();
         $default_language = $sitepress->get_default_language();
         if ($current_language != $default_language) {
             $templates = array('woocommerce.php');
             $term = get_queried_object();
             if (is_tax('product_cat') || is_tax('product_tag')) {
                 $file = 'taxonomy-' . $term->taxonomy . '.php';
             } else {
                 $file = 'archive-product.php';
             }
             // check templates
             $term = get_queried_object();
             $taxonomy = $term->taxonomy;
             $prefix = 'taxonomy-' . $taxonomy;
             $original_term_id = icl_object_id($term->term_id, $taxonomy, true, $default_language);
             $original_term = $woocommerce_wpml->products->wcml_get_term_by_id($original_term_id, $taxonomy);
             $terms_to_check = array($term->term_id => $term->slug);
             if ($original_term) {
                 $terms_to_check[$original_term_id] = $original_term->slug;
             }
             $paths = array('', WC()->template_path());
             foreach ($paths as $path) {
                 foreach ($terms_to_check as $term_id => $term_slug) {
                     $templates[] = $path . "{$prefix}-{$current_language}-{$term_slug}.php";
                     $templates[] = $path . "{$prefix}-{$current_language}-{$term_id}.php";
                     $templates[] = $path . "{$prefix}-{$term_slug}.php";
                     $templates[] = $path . "{$prefix}-{$term_id}.php";
                 }
                 $templates[] = $path . "{$prefix}-{$current_language}.php";
                 $templates[] = $path . "{$prefix}.php";
                 $templates[] = $path . $file;
             }
             $template = locate_template(array_unique($templates));
             if (!$template || WC_TEMPLATE_DEBUG_MODE) {
                 $template = WC()->plugin_path() . '/templates/' . $file;
             }
         }
     }
     return $template;
 }
 /**
  * Check if we will be showing products or not (and not subcats only)
  *
  * @access public
  * @subpackage	Loop
  * @return bool
  */
 function woocommerce_products_will_display()
 {
     if (is_shop()) {
         return get_option('woocommerce_shop_page_display') != 'subcategories';
     }
     if (!is_product_taxonomy()) {
         return false;
     }
     if (is_search() || is_filtered() || is_paged()) {
         return true;
     }
     $term = get_queried_object();
     if (is_product_category()) {
         switch (get_woocommerce_term_meta($term->term_id, 'display_type', true)) {
             case 'subcategories':
                 // Nothing - we want to continue to see if there are products/subcats
                 break;
             case 'products':
             case 'both':
                 return true;
                 break;
             default:
                 // Default - no setting
                 if (get_option('woocommerce_category_archive_display') != 'subcategories') {
                     return true;
                 }
                 break;
         }
     }
     // Begin subcategory logic
     global $wpdb;
     $parent_id = empty($term->term_id) ? 0 : $term->term_id;
     $taxonomy = empty($term->taxonomy) ? '' : $term->taxonomy;
     $products_will_display = true;
     if (!$parent_id && !$taxonomy) {
         return true;
     }
     $transient_name = 'wc_products_will_display_' . $parent_id . WC_Cache_Helper::get_transient_version('product_query');
     if (false === ($products_will_display = get_transient($transient_name))) {
         $has_children = $wpdb->get_col($wpdb->prepare("SELECT term_id FROM {$wpdb->term_taxonomy} WHERE parent = %d AND taxonomy = %s", $parent_id, $taxonomy));
         if ($has_children) {
             // Check terms have products inside - parents first. If products are found inside, subcats will be shown instead of products so we can return false.
             if (sizeof(get_objects_in_term($has_children, $taxonomy)) > 0) {
                 $products_will_display = false;
             } else {
                 // If we get here, the parents were empty so we're forced to check children
                 foreach ($has_children as $term) {
                     $children = get_term_children($term, $taxonomy);
                     if (sizeof(get_objects_in_term($children, $taxonomy)) > 0) {
                         $products_will_display = false;
                         break;
                     }
                 }
             }
         } else {
             $products_will_display = true;
         }
     }
     set_transient($transient_name, $products_will_display, YEAR_IN_SECONDS);
     return $products_will_display;
 }
Example #22
0
function dh_get_main_class($body = false)
{
    $class = dh_get_main_col_class('', $body);
    if (is_home() || is_front_page()) {
        $layout = dh_get_theme_option('blog-layout', 'right-sidebar');
        $class = dh_get_main_col_class($layout, $body);
    } elseif (is_post_type_archive('portfolio') || is_tax('portfolio_category')) {
        $layout = dh_get_theme_option('portfolio-main-layout', 'full-width');
        $class = dh_get_main_col_class($layout, $body);
    } elseif (is_archive() || is_search()) {
        $layout = dh_get_theme_option('archive-layout', 'full-width');
        $class = dh_get_main_col_class($layout, $body);
    } elseif (is_singular('portfolio')) {
        $layout = dh_get_theme_option('portfolio-single-layout', 'full-width');
        $class = dh_get_main_col_class($layout, $body);
    } elseif (is_single()) {
        $layout = dh_get_theme_option('single-layout', 'right-sidebar');
        $class = dh_get_main_col_class($layout, $body);
    } else {
        $layout = dh_get_theme_option('main-layout', 'right-sidebar');
        $class = dh_get_main_col_class($layout, $body);
    }
    if (defined('WOOCOMMERCE_VERSION')) {
        if (is_shop()) {
            remove_action('dh_left_sidebar', 'dh_get_sidebar');
            remove_action('dh_left_sidebar_extra', 'dh_get_extra_sidebar');
            remove_action('dh_right_sidebar', 'dh_get_sidebar');
            remove_action('dh_right_sidebar_extra', 'dh_get_extra_sidebar');
            $layout = dh_get_theme_option('woo-shop-layout', 'full-width');
            $class = dh_get_main_col_class($layout, $body, 11);
        } elseif (is_product_category() || is_product_tag() || is_product_taxonomy()) {
            remove_action('dh_left_sidebar', 'dh_get_sidebar');
            remove_action('dh_left_sidebar_extra', 'dh_get_extra_sidebar');
            remove_action('dh_right_sidebar', 'dh_get_sidebar');
            remove_action('dh_right_sidebar_extra', 'dh_get_extra_sidebar');
            $layout = dh_get_theme_option('woo-category-layout', 'right-sidebar');
            $class = dh_get_main_col_class($layout, $body, 11);
        } elseif (is_product()) {
            remove_action('dh_left_sidebar', 'dh_get_sidebar');
            remove_action('dh_left_sidebar_extra', 'dh_get_extra_sidebar');
            remove_action('dh_right_sidebar', 'dh_get_sidebar');
            remove_action('dh_right_sidebar_extra', 'dh_get_extra_sidebar');
            $layout = dh_get_theme_option('woo-product-layout', 'full-width');
            $class = dh_get_main_col_class($layout, $body, 11);
        }
    }
    if ($body) {
        return $class;
    }
    $class .= ' main-wrap';
    $class = apply_filters('dh_get_main_class', $class);
    return esc_attr($class);
}
Example #23
0
 function setup_gridlist()
 {
     if (is_shop() || is_product_category() || is_product_tag() || is_product_taxonomy()) {
         add_action('woocommerce_after_shop_loop_item', 'woocommerce_template_single_excerpt', 5);
     }
 }
/**
 * is_woocommerce - Returns true if on a page which uses WooCommerce templates (cart and checkout are standard pages with shortcodes and thus are not included)
 *
 * @access public
 * @return bool
 */
function is_woocommerce()
{
    return apply_filters('is_woocommerce', is_shop() || is_product_taxonomy() || is_product() ? true : false);
}
 /**
  * Get an array of filenames to search for a given template.
  *
  * @since  2.7.0
  * @param  string $file The default file name.
  * @return string[]
  */
 private static function get_template_loader_files($default_file)
 {
     $search_files = apply_filters('woocommerce_template_loader_files', array(), $default_file);
     $search_files[] = 'woocommerce.php';
     if (is_product_taxonomy()) {
         $term = get_queried_object();
         $find[] = 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
         $find[] = WC()->template_path() . 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
         $find[] = 'taxonomy-' . $term->taxonomy . '.php';
         $find[] = WC()->template_path() . 'taxonomy-' . $term->taxonomy . '.php';
     }
     $search_files[] = $default_file;
     $search_files[] = WC()->template_path() . $default_file;
     return array_unique($search_files);
 }
function mb_is_woocommerce_page()
{
    $is_woocommerce = false;
    if (class_exists('Woocommerce')) {
        if (is_woocommerce() || is_shop() || is_product_category() || is_product_taxonomy() || is_product_tag() || is_product() || is_cart() || is_checkout() || is_order_received_page() || is_account_page() || is_ajax()) {
            $is_woocommerce = true;
        }
    }
    return $is_woocommerce;
}
Example #27
0
    }
}
// CSS animations preload class
$nm_body_class .= ' nm-preload';
// Top bar
$top_bar = isset($_GET['top_bar']) ? true : $nm_theme_options['top_bar'];
$top_bar_column_left_size = intval($nm_theme_options['top_bar_left_column_size']);
$top_bar_column_right_size = 12 - $top_bar_column_left_size;
// Fixed header body class
$nm_body_class .= $nm_theme_options['header_fixed'] ? ' header-fixed' : '';
if (is_front_page()) {
    // Header border class - Home-page
    $nm_body_class .= isset($_GET['header_border']) ? ' header-border-1' : ' header-border-' . $nm_theme_options['home_header_border'];
    // Header transparency class - Home-page
    $nm_body_class .= isset($_GET['transparent_header']) ? ' header-transparent-1' : ' header-transparent-' . $nm_theme_options['home_header_transparent'];
} elseif (nm_woocommerce_activated() && (is_shop() || is_product_taxonomy())) {
    // Header border class - Shop archive/listing
    $nm_body_class .= ' header-border-' . $nm_theme_options['shop_header_border'];
} else {
    // Header border class
    $nm_body_class .= ' header-border-' . $nm_theme_options['header_border'];
}
// Sticky footer class
$sticky_footer_class = ' footer-sticky-' . $nm_theme_options['footer_sticky'];
?>
<!DOCTYPE html>

<html <?php 
language_attributes();
?>
 class="<?php 
 /**
  * Helper method to fall back to WooCommerce core archive front end rendering or Views archive
  * If Layouts plugin is activated but no Layouts has been assigned to an archive
  * Since 2.4.1
  * @access public
  * @return void
  */
 public function wc_views_check_if_anyproductarchive_has_layout()
 {
     if (defined('WPDDL_VERSION')) {
         //Layouts is activated on this site
         global $wpddlayout, $woocommerce;
         if (is_object($wpddlayout) & is_object($woocommerce)) {
             //Rule below applies only to WooCommerce product archives
             if (is_shop() || is_product_category() || is_product_tag() || is_product_taxonomy()) {
                 if (class_exists('WPDD_Layouts_RenderManager')) {
                     $layouts_render_manager_instance = WPDD_Layouts_RenderManager::getInstance();
                     if (method_exists($layouts_render_manager_instance, 'get_layout_id_for_render')) {
                         $layouts_id_to_render = $layouts_render_manager_instance->get_layout_id_for_render(false, $args = null);
                         $layouts_id = intval($layouts_id_to_render);
                         if ($layouts_id > 0) {
                             //This constant defined only once
                             define('WC_VIEWS_ARCHIVES_LAYOUTS', true);
                         }
                     }
                 }
             }
         }
     }
 }
 /**
  * Set the product columns
  *
  * @return void
  */
 function wc_pac_columns()
 {
     // Product columns.
     if (is_shop() || is_product_taxonomy() || is_product_category() || is_product_tag()) {
         add_filter('body_class', array($this, 'woocommerce_pac_columns'));
         add_filter('loop_shop_columns', array($this, 'woocommerce_pac_products_row'));
     }
 }
Example #30
-1
 /**
  * Load a template.
  *
  * Handles template usage so that we can use our own templates instead of the themes.
  *
  * Templates are in the 'templates' folder. woocommerce looks for theme
  * overrides in /theme/woocommerce/ by default
  *
  * For beginners, it also looks for a woocommerce.php template first. If the user adds
  * this to the theme (containing a woocommerce() inside) this will be used for all
  * woocommerce templates.
  *
  * @param mixed $template
  * @return string
  */
 public static function template_loader($template)
 {
     $find = array('woocommerce.php');
     $file = '';
     if (is_single() && get_post_type() == 'product') {
         $file = 'single-product.php';
         $find[] = $file;
         $find[] = WC()->template_path() . $file;
     } elseif (is_product_taxonomy()) {
         $term = get_queried_object();
         if (is_tax('product_cat') || is_tax('product_tag')) {
             $file = 'taxonomy-' . $term->taxonomy . '.php';
         } else {
             $file = 'archive-product.php';
         }
         $find[] = 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
         $find[] = WC()->template_path() . 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
         $find[] = 'taxonomy-' . $term->taxonomy . '.php';
         $find[] = WC()->template_path() . 'taxonomy-' . $term->taxonomy . '.php';
         $find[] = $file;
         $find[] = WC()->template_path() . $file;
     } elseif (is_post_type_archive('product') || is_page(wc_get_page_id('shop'))) {
         $file = 'archive-product.php';
         $find[] = $file;
         $find[] = WC()->template_path() . $file;
     }
     if ($file) {
         $template = locate_template(array_unique($find));
         if (!$template || WC_TEMPLATE_DEBUG_MODE) {
             $template = WC()->plugin_path() . '/templates/' . $file;
         }
     }
     return $template;
 }