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); } }
public function wcva_register_shop_scripts() { if (is_shop() || is_product_category() || is_product_tag()) { wp_enqueue_script('wcva-shop-frontend', '' . wcva_PLUGIN_URL . 'js/shop-frontend.js', array('jquery')); wp_enqueue_style('wcva-shop-frontend', '' . wcva_PLUGIN_URL . 'css/shop-frontend.css'); } }
function tesseract_woocommerce_wrapper_start() { $layout_loop = get_theme_mod('tesseract_woocommerce_loop_layout'); $layout_product = get_theme_mod('tesseract_woocommerce_product_layout'); if (is_shop() || is_product_category() || is_product_tag()) { if ($layout_loop == 'sidebar-left' || $layout_loop == 'sidebar-right') { $primclass = 'with-sidebar'; $primclass .= $layout_loop == 'sidebar-left' ? ' sidebar-left' : ' sidebar-right'; } else { if ($layout_loop == 'fullwidth' || !$layout_loop) { $primclass = 'no-sidebar'; } } } else { if (is_product()) { if ($layout_product == 'sidebar-left' || $layout_product == 'sidebar-right') { $primclass = 'with-sidebar'; $primclass .= $layout_product == 'sidebar-left' ? ' sidebar-left' : ' sidebar-right'; } else { if ($layout_product == 'fullwidth' || !$layout_product) { $primclass = 'no-sidebar'; } } } else { $primclass = 'sidebar-default'; } } echo '<div id="primary" class="content-area ' . $primclass . '">'; }
function siw_remove_unnecessary_scripts() { //variatie als radiobuttons if (!is_product()) { wp_dequeue_script('kt-wc-add-to-cart-variation-radio'); } //woocommerce ajax filter if (!is_shop() && !is_product_category() && !is_product_tag()) { wp_dequeue_script('yith-wcan-script'); wp_dequeue_style('yith-wcan-frontend'); } //woocommerce wp_dequeue_script('woocommerce'); //wp-embed wp_deregister_script('wp-embed'); //search&filter wp_dequeue_style('search-filter-chosen-styles'); wp_dequeue_style('search-filter-plugin-styles'); wp_deregister_script('search-filter-chosen-script'); wp_deregister_script('jquery-ui-datepicker'); wp_deregister_script('search-filter-plugin-build'); wp_register_script('search-filter-plugin-build', plugins_url('search-filter-pro/public/assets/js/search-filter-build.min.js'), array('jquery'), '', TRUE); //kadence slider wordt alleen gebruikt op de homepage. if (!is_front_page()) { wp_dequeue_script('kadence_slider_js'); wp_dequeue_style('kadence_slider_css'); } //ncf font wp_dequeue_style('ncf_lato_font'); //styling van mailpoet widget wp_deregister_style('validate-engine-css'); }
/** * Get theme option value * @param string $option * @return mix|boolean */ function ts_get_opt($option) { global $ts_theme_options; $local = false; //get local from main shop page if (class_exists('WooCommerce') && (is_shop() || is_product_category() || is_product_tag())) { $shop_page = woocommerce_get_page_id('shop'); if (!empty($shop_page)) { $value = ts_get_post_opt($option . '-local', (int) $shop_page); $local = true; } //get local from metaboxes for the post value and override if not empty } else { if (is_singular()) { $value = ts_get_post_opt($option . '-local'); $local = true; } } //return local value if exists if ($local === true) { //if $value is an array we need to check if first element is not empty before we return $value $first_element = null; if (is_array($value)) { $first_element = reset($value); } if (is_string($value) && (strlen($value) > 0 || !empty($value)) || is_array($value) && !empty($first_element)) { return $value; } } if (isset($ts_theme_options[$option])) { return $ts_theme_options[$option]; } return false; }
function flatsome_admin_bar_helper() { global $wp_admin_bar; $optionUrl = get_admin_url() . 'themes.php?page=optionsframework'; $adminUrl = get_admin_url(); if (is_category() || is_home()) { $wp_admin_bar->add_menu(array('parent' => false, 'id' => 'admin_bar_helper', 'title' => 'Blog Layout', 'href' => $optionUrl . '&tab=of-option-blog')); } if (ux_is_woocommerce_active()) { if (is_checkout() || is_cart()) { $wp_admin_bar->add_menu(array('parent' => false, 'id' => 'admin_bar_helper', 'title' => 'Checkout Settings', 'href' => $adminUrl . 'admin.php?page=wc-settings&tab=checkout')); } if (is_product()) { $wp_admin_bar->add_menu(array('parent' => false, 'id' => 'admin_bar_helper', 'title' => 'Product Page Layout', 'href' => $optionUrl . '&tab=of-option-productpage')); } if (is_account_page()) { $wp_admin_bar->add_menu(array('parent' => false, 'id' => 'admin_bar_helper', 'title' => 'My Account Page', 'href' => $adminUrl . 'admin.php?page=wc-settings&tab=account')); } if (is_shop() || is_product_category()) { $wp_admin_bar->add_menu(array('parent' => false, 'id' => 'admin_bar_helper', 'title' => 'Shop Settings')); $wp_admin_bar->add_menu(array('parent' => 'admin_bar_helper', 'id' => 'admin_bar_helper_flatsome', 'title' => 'Category Page Layout', 'href' => $optionUrl . '&tab=of-option-categorypage')); $wp_admin_bar->add_menu(array('parent' => 'admin_bar_helper', 'id' => 'admin_bar_helper_woocommerce', 'title' => 'Shop Page Display', 'href' => $adminUrl . 'admin.php?page=wc-settings&tab=products§ion=display')); } } }
/** * Init theme config for shop. * */ function dt_woocommerce_init_template_config($name = '') { dt_woocommerce_add_config_actions(); if ('shop' != $name) { return; } $config = presscore_get_config(); $post_id = null; if (is_shop()) { $post_id = woocommerce_get_page_id('shop'); } else { if (is_cart()) { $post_id = woocommerce_get_page_id('cart'); } else { if (is_checkout()) { $post_id = woocommerce_get_page_id('checkout'); } } } presscore_config_base_init($post_id); if (is_product_category() || is_product_tag()) { $post_id = woocommerce_get_page_id('shop'); if ($post_id) { $config->set('post_id', $post_id); presscore_config_populate_sidebar_and_footer_options(); $config->set('post_id', null); } } if (!is_product()) { add_filter('presscore_get_page_title', 'dt_woocommerce_get_page_title', 20); } // replace theme breadcrumbs add_filter('presscore_get_breadcrumbs-html', 'dt_woocommerce_replace_theme_breadcrumbs', 20, 2); }
function woothemes_add_javascript() { global $woo_options; wp_register_script('prettyPhoto', get_template_directory_uri() . '/includes/js/jquery.prettyPhoto.js', array('jquery')); wp_register_script('enable-lightbox', get_template_directory_uri() . '/includes/js/enable-lightbox.js', array('jquery', 'prettyPhoto')); wp_register_script('google-maps', 'http://maps.google.com/maps/api/js?sensor=false'); wp_register_script('google-maps-markers', get_template_directory_uri() . '/includes/js/markers.js'); wp_register_script('flexslider', get_template_directory_uri() . '/includes/js/jquery.flexslider-min.js', array('jquery')); wp_register_script('featured-slider', get_template_directory_uri() . '/includes/js/featured-slider.js', array('jquery', 'flexslider')); wp_register_script('infinite-scroll', get_template_directory_uri() . '/includes/js/jquery.infinitescroll.min.js', array('jquery')); wp_register_script('masonry', get_template_directory_uri() . '/includes/js/jquery.masonry.min.js', array('jquery')); wp_enqueue_script('third party', get_template_directory_uri() . '/includes/js/third-party.js', array('jquery')); wp_enqueue_script('tiptip', get_template_directory_uri() . '/includes/js/jquery.tiptip.min.js', array('jquery')); wp_enqueue_script('general', get_template_directory_uri() . '/includes/js/general.js', array('jquery')); // Load Google Script on Contact Form Page Template if (is_page_template('template-contact.php')) { wp_enqueue_script('google-maps'); wp_enqueue_script('google-maps-markers'); } // End If Statement // Load infinite scroll on shop page / product cats if (is_woocommerce_activated()) { if ($woo_options['woocommerce_archives_infinite_scroll'] == 'true' && (is_shop() || is_product_category())) { wp_enqueue_script('infinite-scroll'); } } // Load Masonry on the blog grid layout if (is_page_template('template-blog-grid.php')) { wp_enqueue_script('masonry'); add_action('wp_head', 'woo_fire_masonry'); } do_action('woothemes_add_javascript'); }
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')); } }
/** * WooCommerce conditionals * * 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) **/ function is_woocommerce() { if (is_shop() || is_product_category() || is_product_tag() || is_product()) { return true; } else { return false; } }
function kadence_sidebar_id() { if (is_front_page()) { global $virtue; if (!empty($virtue['home_sidebar'])) { $sidebar = $virtue['home_sidebar']; } else { $sidebar = 'sidebar-primary'; } } else { if (class_exists('woocommerce') and is_shop() || is_product_category() || is_product_tag()) { global $virtue; if (!empty($virtue['shop_sidebar'])) { $sidebar = $virtue['shop_sidebar']; } else { $sidebar = 'sidebar-primary'; } } elseif (class_exists('woocommerce') and is_account_page()) { get_template_part('templates/account', 'sidebar'); $sidebar = ""; } elseif (is_page_template('page-blog.php') || is_page_template('page-sidebar.php') || is_page_template('page-feature-sidebar.php') || get_post_type() == 'post') { global $post; $sidebar_name = get_post_meta($post->ID, '_kad_sidebar_choice', true); if (!empty($sidebar_name)) { $sidebar = $sidebar_name; } else { $sidebar = 'sidebar-primary'; } } else { if (is_archive()) { $sidebar = 'sidebar-primary'; } else { if (is_category()) { $sidebar = 'sidebar-primary'; } elseif (is_tag()) { $sidebar = 'sidebar-primary'; } elseif (is_post_type_archive()) { $sidebar = 'sidebar-primary'; } elseif (is_day()) { $sidebar = 'sidebar-primary'; } elseif (is_month()) { $sidebar = 'sidebar-primary'; } elseif (is_year()) { $sidebar = 'sidebar-primary'; } elseif (is_author()) { $sidebar = 'sidebar-primary'; } elseif (is_search()) { $sidebar = 'sidebar-primary'; } else { $sidebar = 'sidebar-primary'; } } } } return apply_filters('kadence_sidebar_id', $sidebar); }
function woocs_subcats_from_parentcat() { if (is_product_category()) { global $wp_query; $woocs_cat = $wp_query->get_queried_object(); $args = array('hierarchical' => 1, 'show_option_none' => '', 'hide_empty' => 0, 'parent' => $woocs_cat->term_id, 'taxonomy' => 'product_cat'); $woocs_subcats = get_categories($args); } return $woocs_subcats; }
function IsExtensionPage() { RWLogger::LogEnterence('WooCommerce_IsExtensionPage'); if (RWLogger::IsOn()) { RWLogger::Log('WooCommerce_IsExtensionPage', 'is_product() = ' . json_encode(is_product())); RWLogger::Log('WooCommerce_IsExtensionPage', 'is_product_category() = ' . json_encode(is_product_category())); RWLogger::Log('WooCommerce_IsExtensionPage', 'is_shop() = ' . json_encode(is_shop())); } return $this->IsWooCommerce() && (is_product() || is_product_category() || is_shop()); }
public static function get_categories() { global $wp_query; $defaults = array('before' => '', 'after' => '', 'force_display' => false); $args = array(); $args = wp_parse_args($args, $defaults); extract($args); $term = get_queried_object(); $parent_id = empty($term->term_id) ? 0 : $term->term_id; if (is_product_category()) { $display_type = get_woocommerce_term_meta($term->term_id, 'display_type', true); switch ($display_type) { case 'products': return; break; case '': if (get_option('woocommerce_category_archive_display') == '') { return; } break; } } $product_categories = get_categories(apply_filters('woocommerce_product_subcategories_args', array('parent' => $parent_id, 'menu_order' => 'ASC', 'hide_empty' => 0, 'hierarchical' => 1, 'taxonomy' => 'product_cat', 'pad_counts' => 1))); if (!apply_filters('woocommerce_product_subcategories_hide_empty', false)) { $product_categories = wp_list_filter($product_categories, array('count' => 0), 'NOT'); } if ($product_categories) { echo $before; foreach ($product_categories as $category) { wc_get_template('content-product_cat.php', array('category' => $category)); } if (is_product_category()) { $display_type = get_woocommerce_term_meta($term->term_id, 'display_type', true); switch ($display_type) { case 'subcategories': $wp_query->post_count = 0; $wp_query->max_num_pages = 0; break; case '': if (get_option('woocommerce_category_archive_display') == 'subcategories') { $wp_query->post_count = 0; $wp_query->max_num_pages = 0; } break; } } if (is_shop() && get_option('woocommerce_shop_page_display') == 'subcategories') { $wp_query->post_count = 0; $wp_query->max_num_pages = 0; } echo $after; return true; } }
function nimber_show_per_row() { if (is_shop()) { $woo_layout = ot_get_option('woo_layout'); } elseif (is_product_category() || is_product_tag()) { $woo_layout = ot_get_option('woo_archive_layout'); } else { $woo_layout = 4; } return $woo_layout; }
function amt_is_woocommerce_product_group() { // Check if woocommerce product group page and return true; // WooCommerce (http://docs.woothemes.com/document/conditional-tags/) // Also validates with is_tax(). if (function_exists('is_product_category') || function_exists('is_product_tag')) { if (is_product_category() || is_product_tag()) { return true; } } }
/** * Get current page URL for layered nav items. * * @return string */ protected function get_page_base_url() { if (defined('SHOP_IS_ON_FRONT')) { $link = home_url(); } elseif (is_post_type_archive('product') || is_page(wc_get_page_id('shop'))) { $link = get_post_type_archive_link('product'); } elseif (is_product_category()) { $link = get_term_link(get_query_var('product_cat'), 'product_cat'); } elseif (is_product_tag()) { $link = get_term_link(get_query_var('product_tag'), 'product_tag'); } else { $queried_object = get_queried_object(); $link = get_term_link($queried_object->slug, $queried_object->taxonomy); } // Min/Max if (isset($_GET['min_price'])) { $link = add_query_arg('min_price', wc_clean($_GET['min_price']), $link); } if (isset($_GET['max_price'])) { $link = add_query_arg('max_price', wc_clean($_GET['max_price']), $link); } // Orderby if (isset($_GET['orderby'])) { $link = add_query_arg('orderby', wc_clean($_GET['orderby']), $link); } /** * Search Arg. * To support quote characters, first they are decoded from " entities, then URL encoded. */ if (get_search_query()) { $link = add_query_arg('s', rawurlencode(htmlspecialchars_decode(get_search_query())), $link); } // Post Type Arg if (isset($_GET['post_type'])) { $link = add_query_arg('post_type', wc_clean($_GET['post_type']), $link); } // Min Rating Arg if (isset($_GET['min_rating'])) { $link = add_query_arg('min_rating', wc_clean($_GET['min_rating']), $link); } // All current filters if ($_chosen_attributes = WC_Query::get_layered_nav_chosen_attributes()) { foreach ($_chosen_attributes as $name => $data) { $filter_name = sanitize_title(str_replace('pa_', '', $name)); if (!empty($data['terms'])) { $link = add_query_arg('filter_' . $filter_name, implode(',', $data['terms']), $link); } if ('or' == $data['query_type']) { $link = add_query_arg('query_type_' . $filter_name, 'or', $link); } } } return $link; }
function woocs_load_scripts() { if (is_product_category()) { //$woocs_type = get_option('woocs_type'); wp_enqueue_script('woocs-slider-js', plugins_url('js/jquery.bxslider.min.js', __FILE__), array('jquery')); wp_enqueue_script('jquery-effects-core'); wp_enqueue_script('woocs-main-js', plugins_url('js/main.js', __FILE__)); wp_enqueue_style('woocs-slider-css', plugins_url('styles/jquery.bxslider.css', __FILE__)); wp_enqueue_style('woocs-main-css', plugins_url('styles/main.css', __FILE__)); } }
function woocommerce_category_image() { if (is_product_category()) { global $wp_query; $cat = $wp_query->get_queried_object(); $thumbnail_id = get_woocommerce_term_meta($cat->term_id, 'thumbnail_id', true); $image = wp_get_attachment_url($thumbnail_id); if ($image) { echo '<img src="' . $image . '" alt="" class="img-responsive" />'; } } }
function forbid_credits_page() { global $post; $terms = wp_get_post_terms($post->ID, 'product_cat'); $categories = array(); foreach ($terms as $term) { $categories[] = $term->slug; } if (is_product_category('credit') || is_product() && has_term('credit', 'product_cat')) { header('Location: ' . get_permalink(woocommerce_get_page_id('shop')) . ''); } }
function special_nav_class($classes, $item){ if( in_array('current-menu-item', $classes) ){ $classes[] = 'active '; } if( in_array('current_page_parent', $classes) ){ $classes[] = 'current-menu-item active'; } if( $item->url == get_permalink(woocommerce_get_page_id( 'shop' ) ) && ( is_shop() || is_product_category() || is_cart() || is_checkout() ) ){ $classes[] = 'current-menu-item active'; } return $classes; }
function greek_woocommerce_category_image() { if (is_product_category()) { global $wp_query; $cat = $wp_query->get_queried_object(); $thumbnail_id = get_woocommerce_term_meta($cat->term_id, 'thumbnail_id', true); $image = wp_get_attachment_url($thumbnail_id); if ($image) { echo '<p class="category-image-desc"><img src="' . esc_url($image) . '" alt="" /></p>'; } } }
function kadence_sidebar_on_shop_page() { global $virtue; if (isset($virtue['shop_layout']) && $virtue['shop_layout'] == 'sidebar') { if (is_shop() || is_product_category() || is_product_tag()) { return false; } } else { if (is_shop() || is_product_category() || is_product_tag()) { return true; } } }
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')); } }
/** * Get sidebar settings based on the page type * * @return array */ public function sidebar_options() { if (is_home()) { $sidebars = array('global' => '1', 'sidebar_1' => Avada()->settings->get('blog_archive_sidebar'), 'sidebar_2' => Avada()->settings->get('blog_archive_sidebar_2'), 'position' => Avada()->settings->get('blog_sidebar_position')); } elseif (function_exists('is_bbpress') && is_bbpress()) { $sidebars = array('global' => Avada()->settings->get('bbpress_global_sidebar'), 'sidebar_1' => Avada()->settings->get('ppbress_sidebar'), 'sidebar_2' => Avada()->settings->get('ppbress_sidebar_2'), 'position' => Avada()->settings->get('bbpress_sidebar_position')); if (bbp_is_forum_archive() || bbp_is_topic_archive() || bbp_is_user_home() || bbp_is_search()) { $sidebars = array('global' => '1', 'sidebar_1' => Avada()->settings->get('ppbress_sidebar'), 'sidebar_2' => Avada()->settings->get('ppbress_sidebar_2'), 'position' => Avada()->settings->get('bbpress_sidebar_position')); } } elseif (function_exists('is_buddypress') && is_buddypress()) { $sidebars = array('global' => Avada()->settings->get('bbpress_global_sidebar'), 'sidebar_1' => Avada()->settings->get('ppbress_sidebar'), 'sidebar_2' => Avada()->settings->get('ppbress_sidebar_2'), 'position' => Avada()->settings->get('bbpress_sidebar_position')); } elseif (class_exists('WooCommerce') && (is_product() || is_shop())) { $sidebars = array('global' => Avada()->settings->get('woo_global_sidebar'), 'sidebar_1' => Avada()->settings->get('woo_sidebar'), 'sidebar_2' => Avada()->settings->get('woo_sidebar_2'), 'position' => Avada()->settings->get('woo_sidebar_position')); } elseif (class_exists('WooCommerce') && (is_product_category() || is_product_tag())) { $sidebars = array('global' => '1', 'sidebar_1' => Avada()->settings->get('woocommerce_archive_sidebar'), 'sidebar_2' => Avada()->settings->get('woocommerce_archive_sidebar_2'), 'position' => Avada()->settings->get('woo_sidebar_position')); } elseif (is_page()) { $sidebars = array('global' => Avada()->settings->get('pages_global_sidebar'), 'sidebar_1' => Avada()->settings->get('pages_sidebar'), 'sidebar_2' => Avada()->settings->get('pages_sidebar_2'), 'position' => Avada()->settings->get('default_sidebar_pos')); } elseif (is_single()) { $sidebars = array('global' => Avada()->settings->get('posts_global_sidebar'), 'sidebar_1' => Avada()->settings->get('posts_sidebar'), 'sidebar_2' => Avada()->settings->get('posts_sidebar_2'), 'position' => Avada()->settings->get('blog_sidebar_position')); if (is_singular('avada_portfolio')) { $sidebars = array('global' => Avada()->settings->get('portfolio_global_sidebar'), 'sidebar_1' => Avada()->settings->get('portfolio_sidebar'), 'sidebar_2' => Avada()->settings->get('portfolio_sidebar_2'), 'position' => Avada()->settings->get('portfolio_sidebar_position')); } else { if (is_singular('tribe_events') || is_singular('tribe_organizer') || is_singular('tribe_venue')) { $sidebars = array('global' => Avada()->settings->get('ec_global_sidebar'), 'sidebar_1' => Avada()->settings->get('ec_sidebar'), 'sidebar_2' => Avada()->settings->get('ec_sidebar_2'), 'position' => Avada()->settings->get('ec_sidebar_pos')); } } if (is_singular('tribe_organizer') || is_singular('tribe_venue')) { $sidebars['global'] = 1; } } elseif (is_archive()) { $sidebars = array('global' => '1', 'sidebar_1' => Avada()->settings->get('blog_archive_sidebar'), 'sidebar_2' => Avada()->settings->get('blog_archive_sidebar_2'), 'position' => Avada()->settings->get('blog_sidebar_position')); if (is_post_type_archive('avada_portfolio') || is_tax('portfolio_category') || is_tax('portfolio_skills') || is_tax('portfolio_tags')) { $sidebars = array('global' => '1', 'sidebar_1' => Avada()->settings->get('portfolio_archive_sidebar'), 'sidebar_2' => Avada()->settings->get('portfolio_archive_sidebar_2'), 'position' => Avada()->settings->get('portfolio_sidebar_position')); } } elseif (is_search()) { $sidebars = array('global' => '1', 'sidebar_1' => Avada()->settings->get('search_sidebar'), 'sidebar_2' => Avada()->settings->get('search_sidebar_2'), 'position' => Avada()->settings->get('search_sidebar_position')); } else { $sidebars = array('global' => Avada()->settings->get('pages_global_sidebar'), 'sidebar_1' => Avada()->settings->get('pages_sidebar'), 'sidebar_2' => Avada()->settings->get('pages_sidebar_2'), 'position' => Avada()->settings->get('default_sidebar_pos')); } if (class_exists('Tribe__Events__Main') && is_events_archive()) { $sidebars = array('global' => '1', 'sidebar_1' => Avada()->settings->get('ec_sidebar'), 'sidebar_2' => Avada()->settings->get('ec_sidebar_2'), 'position' => Avada()->settings->get('ec_sidebar_pos')); } // Remove sidebars from the certain woocommerce pages if (class_exists('WooCommerce')) { if (is_cart() || is_checkout() || is_account_page() || get_option('woocommerce_thanks_page_id') && is_page(get_option('woocommerce_thanks_page_id'))) { $sidebars = array(); } } return $sidebars; }
/** * This function configure sidebar and footer as for the 'shop' woocommerce page. * * @param string $name */ function dt_woocommerce_configure_archive_templates($name = '') { if ('shop' !== $name) { return; } if (is_product_category() || is_product_tag()) { $post_id = woocommerce_get_page_id('shop'); if ($post_id) { presscore_get_config()->set('post_id', $post_id); presscore_config_populate_sidebar_and_footer_options(); presscore_get_config()->set('post_id', null); } } }
function cs_wc_loop_add_to_cart_scripts() { if (is_shop() || is_product_category() || is_product_tag() || is_product()) { ?> <script> jQuery( document ).ready( function( $ ) { $( document ).on( 'change', '.quantity .qty', function() { $( this ).parent( '.quantity' ).next( '.add_to_cart_button' ).attr( 'data-quantity', $( this ).val() ); }); }); </script> <?php } }
function getPost() { $data = new stdClass(); global $post, $wp_query; $categoryId = (int) get_query_var('cat'); if (function_exists('is_woocommerce') && is_woocommerce()) { $data->post = get_post(get_option('woocommerce_shop_page_id')); if (is_product()) { $data->post = $post; } elseif (is_product_category() || is_product_tag()) { $data->post->post_title = ThemeHelper::esc_html($wp_query->queried_object->name); } elseif (is_search()) { $data->post->post_title = sprintf(__('Search products for phrase <i>%s</i>', THEME_DOMAIN), esc_html(get_query_var('s'))); } setup_postdata($data->post); } else { if (is_tag()) { $data->post = get_post(ThemeOption::getOption('blog_search_post_id')); $tagQuery = get_query_var('tag'); $tagData = get_tags(array('slug' => $tagQuery)); $data->post->post_title = esc_html($tagData[0]->name); } elseif (is_author()) { $author = get_userdata(get_query_var('author')); $data->post = get_post(ThemeOption::getOption('blog_author_post_id')); $data->post->post_title = sprintf(__('All posts from %s', THEME_DOMAIN), get_the_author_meta('display_name', $author->data->ID)); } elseif (is_category($categoryId)) { $category = get_category($categoryId); $data->post = get_post(ThemeOption::getOption('blog_category_post_id')); $data->post->post_title = ThemeHelper::esc_html($category->name); } elseif (is_day()) { $data->post = get_post(ThemeOption::getOption('blog_archive_post_id')); $data->post->post_title = get_the_date(); } elseif (is_archive()) { $data->post = get_post(ThemeOption::getOption('blog_archive_post_id')); $data->post->post_title = single_month_title(' ', false); } elseif (is_search()) { $data->post = get_post(ThemeOption::getOption('blog_search_post_id')); $data->post->post_title = sprintf(__('Kết quả tìm kiếm: <i>%s</i>', THEME_DOMAIN), esc_html(get_query_var('s'))); } elseif (is_404()) { $data->post = get_post(ThemeOption::getOption('page_404_page_id')); $data->post->post_title = $data->post->post_title; } else { return false; } } return $data; }
function simple_breadcrumb() { global $post; $separator = ' <img src="' . get_stylesheet_directory_uri() . '/images/arrow.jpg" /> '; // Simply change the separator to what ever you need e.g. / or > echo '<div class="breadcrumb">'; if (!is_front_page()) { echo '<a href="'; echo get_option('home'); echo '">'; //bloginfo('name') ; echo 'Home'; echo "</a> " . $separator; if (is_category() || is_single()) { the_category(', '); if (is_single()) { echo $separator; the_title(); } } elseif (is_page() && $post->post_parent) { $home = get_page(get_option('page_on_front')); for ($i = count($post->ancestors) - 1; $i >= 0; $i--) { if ($home->ID != $post->ancestors[$i]) { echo '<a href="'; echo get_permalink($post->ancestors[$i]); echo '">'; echo get_the_title($post->ancestors[$i]); echo "</a>" . $separator; } } echo the_title(); } elseif (is_page()) { echo the_title(); } elseif (is_404()) { echo "404"; } elseif (is_product_category()) { print_r($category); exit; } } else { //bloginfo('name'); echo 'Home'; } echo '</div>'; }
/** * Set meta description based on template. */ function seo_description() { if (get_post_type(array('post', 'page', 'product'))) { $description = get_post_meta(get_the_ID(), '_fathom_seo_description', true); if ($description == '') { $description = get_excerpt_by_id(get_the_ID()); } } elseif (is_product_category()) { global $wp_query; $cat_id = $wp_query->get_queried_object_id(); $description = single_term_title() . ' - ' . strip_tags(term_description($cat_id, 'product_cat')); } // fallback if (!isset($description) || $description == '') { $description = get_bloginfo('description'); } return esc_attr($description); }