<?php global $smof_data; if (!isset($smof_data['ts_enable_quickshop']) || isset($smof_data['ts_enable_quickshop']) && (int) $smof_data['ts_enable_quickshop'] == 1) { if (ts_has_woocommerce() && !class_exists('TS_Quickshop')) { class TS_Quickshop { public $id; function __construct() { $this->add_hook(); } function add_quickshop_button() { global $product; $href = admin_url('admin-ajax.php', is_ssl() ? 'https' : 'http') . '?ajax=true&action=load_quickshop_content&product_id=' . $product->id; echo '<div class="button-in quickshop">'; echo '<a class="quickshop" href="' . esc_url($href) . '"><i class="fa fa-search"></i><span class="ts-tooltip button-tooltip">' . esc_html__('Quick view', 'gon') . '</span></a>'; echo '</div>'; } function add_hook() { global $smof_data; add_action('woocommerce_after_shop_loop_item_title', array($this, 'add_quickshop_button'), 10004); /** Product content hook **/ add_action('ts_quickshop_single_product_title', array($this, 'product_title'), 10); add_action('ts_quickshop_single_product_summary', 'woocommerce_template_single_rating', 10); add_action('ts_quickshop_single_product_summary', 'ts_template_single_sku', 20); add_action('ts_quickshop_single_product_summary', 'ts_template_single_availability', 30); add_action('ts_quickshop_single_product_summary', 'woocommerce_template_single_excerpt', 40); add_action('ts_quickshop_single_product_summary', 'woocommerce_template_single_price', 50);
?> "> <div class="search-table"> <div class="search-field search-content"> <input type="text" value="<?php echo get_search_query(); ?> " name="s" id="s<?php echo esc_attr($rand_id); ?> " placeholder="<?php echo esc_attr($placeholder_text); ?> " autocomplete="off" /> <?php if (ts_has_woocommerce()) { ?> <input type="hidden" name="post_type" value="product" /> <?php } ?> </div> <div class="search-button"> <input type="submit" id="searchsubmit<?php echo esc_attr($rand_id); ?> " value="<?php esc_html_e('Search', 'gon'); ?> " /> </div>
<?php if (!class_exists('TS_Grid_List') && ts_has_woocommerce()) { class TS_Grid_List { function __construct() { /* Hooks */ if (get_option('ts_enable_glt', 'yes') == 'yes') { add_action('wp', array($this, 'setup_gridlist'), 20); } /* Init settings */ $this->settings = array(array('name' => esc_html__('Default catalog view', 'gon'), 'type' => 'title', 'id' => 'ts_glt_options'), array('name' => esc_html__('Catalog view', 'gon'), 'desc_tip' => '', 'id' => 'ts_enable_glt', 'type' => 'checkbox', 'desc' => esc_html__('Display option to show product in grid or list view', 'gon'), 'default' => 'yes'), array('name' => esc_html__('Default catalog view', 'gon'), 'desc_tip' => esc_html__('Display products in grid or list view by default', 'gon'), 'id' => 'ts_glt_default', 'type' => 'select', 'options' => array('grid' => esc_html__('Grid', 'gon'), 'list' => esc_html__('List', 'gon'))), array('type' => 'sectionend', 'id' => 'ts_glt_options')); /* Default options */ add_option('ts_glt_default', 'grid'); /* Admin */ add_action('woocommerce_settings_image_options_after', array($this, 'admin_settings'), 20); add_action('woocommerce_update_options_catalog', array($this, 'save_admin_settings')); add_action('woocommerce_update_options_products', array($this, 'save_admin_settings')); } function admin_settings() { woocommerce_admin_fields($this->settings); } function save_admin_settings() { woocommerce_update_options($this->settings); } function setup_gridlist() { if (is_shop() || is_product_category() || is_product_tag() || is_product_taxonomy()) {
function get_list_categories($cat_parent_id) { if (!ts_has_woocommerce()) { return array(); } $args = array('taxonomy' => 'product_cat', 'hierarchical' => 1, 'parent' => $cat_parent_id, 'title_li' => '', 'child_of' => 0); $cats = get_categories($args); return $cats; }
/** Tini wishlist **/ function ts_tini_wishlist() { if (!(ts_has_woocommerce() && class_exists('YITH_WCWL'))) { return; } ob_start(); $wishlist_page_id = get_option('yith_wcwl_wishlist_page_id'); if (function_exists('icl_object_id')) { $wishlist_page_id = icl_object_id($wishlist_page_id, 'page', true); } $wishlist_page = get_permalink($wishlist_page_id); $count = yith_wcwl_count_products(); ?> <a title="<?php esc_html_e('Wishlist', 'gon'); ?> " href="<?php echo esc_url($wishlist_page); ?> " class="tini-wishlist"> <?php esc_html_e('Wishlist', 'gon'); ?> <?php echo '(' . ($count > 0 ? zeroise($count, 2) : '0') . ')'; ?> </a> <?php $tini_wishlist = ob_get_clean(); return $tini_wishlist; }
function widget($args, $instance) { extract($args); if (!(ts_has_woocommerce() || is_tax('product_cat') || is_tax('product_tag') || is_post_type_archive('product'))) { return; } if (sizeof(WC()->query->unfiltered_product_ids) == 0) { return; // None shown - return } global $_chosen_attributes, $wp; $title = apply_filters('widget_title', $instance['title']); $fields = ''; if (get_search_query()) { $fields .= '<input type="hidden" name="s" value="' . get_search_query() . '" />'; } if (!empty($_GET['post_type'])) { $fields .= '<input type="hidden" name="post_type" value="' . esc_attr($_GET['post_type']) . '" />'; } if (!empty($_GET['product_cat'])) { $fields .= '<input type="hidden" name="product_cat" value="' . esc_attr($_GET['product_cat']) . '" />'; } if (!empty($_GET['product_tag'])) { $fields .= '<input type="hidden" name="product_tag" value="' . esc_attr($_GET['product_tag']) . '" />'; } if (!empty($_GET['orderby'])) { $fields .= '<input type="hidden" name="orderby" value="' . esc_attr($_GET['orderby']) . '" />'; } if (!empty($_GET['min_price'])) { $fields .= '<input type="hidden" name="min_price" value="' . esc_attr($_GET['min_price']) . '" />'; } if (!empty($_GET['max_price'])) { $fields .= '<input type="hidden" name="max_price" value="' . esc_attr($_GET['max_price']) . '" />'; } if ($_chosen_attributes) { foreach ($_chosen_attributes as $attribute => $data) { $taxonomy_filter = 'filter_' . str_replace('pa_', '', $attribute); $fields .= '<input type="hidden" name="' . esc_attr($taxonomy_filter) . '" value="' . esc_attr(implode(',', $data['terms'])) . '" />'; if ('or' == $data['query_type']) { $fields .= '<input type="hidden" name="' . esc_attr(str_replace('pa_', 'query_type_', $attribute)) . '" value="or" />'; } } } if ('' == get_option('permalink_structure')) { $form_action = remove_query_arg(array('page', 'paged'), add_query_arg($wp->query_string, '', home_url($wp->request))); } else { $form_action = preg_replace('%\\/page/[0-9]+%', '', home_url(trailingslashit($wp->request))); } echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } ?> <div class="product-filter-by-availability-wrapper"> <ul> <li> <input type="checkbox" id="ts-instock-checkbox" value="instock" <?php checked('instock', !empty($_GET['stock']) ? $_GET['stock'] : '', true); ?> /> <label for="ts-instock-checkbox"><?php esc_html_e('In stock', 'gon'); ?> </label> </li> <li> <input type="checkbox" id="ts-outofstock-checkbox" value="outofstock" <?php checked('outofstock', !empty($_GET['stock']) ? $_GET['stock'] : '', true); ?> /> <label for="ts-outofstock-checkbox"><?php esc_html_e('Out of stock', 'gon'); ?> </label> </li> </ul> <form method="get" action="<?php echo esc_url($form_action); ?> "> <input type="hidden" name="stock" value="" /> <?php echo $fields; ?> </form> </div> <?php echo $after_widget; }
function widget($args, $instance) { extract($args); if (!(ts_has_woocommerce() || is_tax('product_cat') || is_tax('product_tag') || is_post_type_archive('product'))) { return; } $title = apply_filters('widget_title', $instance['title']); $query_type = $instance['query_type']; global $_chosen_attributes, $_attributes_array; $current_term = $_attributes_array && is_tax($_attributes_array) ? get_queried_object()->term_id : ''; $current_tax = $_attributes_array && is_tax($_attributes_array) ? get_queried_object()->taxonomy : ''; $attr_slug = 'color'; $taxonomy = wc_attribute_taxonomy_name($attr_slug); if (!taxonomy_exists($taxonomy)) { return; } $terms = get_terms($taxonomy, array('hide_empty' => 1)); if (count($terms) > 0) { ob_start(); $found = false; echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } /* Force found when option is selected - do not force found on taxonomy attributes */ if (!$_attributes_array || !is_tax($_attributes_array)) { if (is_array($_chosen_attributes) && array_key_exists($taxonomy, $_chosen_attributes)) { $found = true; } } /* List display */ echo "<ul>"; foreach ($terms as $term) { /* Get count based on current view - uses transients */ $transient_name = 'wc_ln_count_' . md5(sanitize_key($taxonomy) . sanitize_key($term->term_taxonomy_id)); if (false === ($_products_in_term = get_transient($transient_name))) { $_products_in_term = get_objects_in_term($term->term_id, $taxonomy); set_transient($transient_name, $_products_in_term); } $option_is_set = isset($_chosen_attributes[$taxonomy]) && in_array($term->term_id, $_chosen_attributes[$taxonomy]['terms']); /* If this is an AND query, only show options with count > 0 */ if ($query_type == 'and') { $count = sizeof(array_intersect($_products_in_term, WC()->query->filtered_product_ids)); /* skip the term for the current archive */ if ($current_term == $term->term_id) { continue; } if ($count > 0 && $current_term !== $term->term_id) { $found = true; } if ($count == 0 && !$option_is_set) { continue; } /* If this is an OR query, show all options so search can be expanded */ } else { /* skip the term for the current archive */ if ($current_term == $term->term_id) { continue; } $count = sizeof(array_intersect($_products_in_term, WC()->query->unfiltered_product_ids)); if ($count > 0) { $found = true; } } $arg = 'filter_' . sanitize_title($attr_slug); $current_filter = isset($_GET[$arg]) ? explode(',', $_GET[$arg]) : array(); if (!is_array($current_filter)) { $current_filter = array(); } $current_filter = array_map('esc_attr', $current_filter); 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 = home_url('/'); } elseif (is_post_type_archive('product') || is_page(wc_get_page_id('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 => $data) { if ($name !== $taxonomy) { /* exclude query arg for current term archive term */ while (in_array($current_term, $data['terms'])) { $key = array_search($current_term, $data); unset($data['terms'][$key]); } if (!empty($data['terms'])) { $link = add_query_arg(sanitize_title(str_replace('pa_', 'filter_', $name)), implode(',', $data['terms']), $link); } if ($data['query_type'] == 'or') { $link = add_query_arg(sanitize_title(str_replace('pa_', 'query_type_', $name)), 'or', $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]['terms']) && in_array($term->term_id, $_chosen_attributes[$taxonomy]['terms'])) { $class = 'class="chosen"'; /* Remove this term is $current_filter has more than 1 term filtered */ if (sizeof($current_filter) > 1) { $current_filter_without_this = array_diff($current_filter, array($term->term_id)); $link = add_query_arg($arg, implode(',', $current_filter_without_this), $link); } } else { $class = ''; $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); } /* Query type Arg */ if ($query_type == 'or' && !(sizeof($current_filter) == 1 && isset($_chosen_attributes[$taxonomy]['terms']) && is_array($_chosen_attributes[$taxonomy]['terms']) && in_array($term->term_id, $_chosen_attributes[$taxonomy]['terms']))) { $link = add_query_arg('query_type_' . sanitize_title($attr_slug), 'or', $link); } $datas = get_metadata('woocommerce_term', $term->term_id, "ts_product_color_config", true); if (strlen($datas) > 0) { $datas = unserialize($datas); } else { $datas = array('ts_color_color' => "#ffffff", 'ts_color_image' => 0); } echo '<li ' . $class . '>'; echo $count > 0 || $option_is_set ? '<a title="' . $term->name . '" href="' . esc_url($link) . '">' : '<span>'; if (absint($datas['ts_color_image']) > 0) { echo wp_get_attachment_image(absint($datas['ts_color_image']), 'ts_prod_color_thumb', true, array('title' => $term->name, 'alt' => $term->name)); } else { echo "<span style='background-color:{$datas['ts_color_color']}'>{$term->name}</span>"; } echo $count > 0 || $option_is_set ? '</a>' : '</span>'; echo ' <small class="count">' . $count . '</small>'; echo '</li>'; } echo "</ul>"; echo $after_widget; if ($found) { echo ob_get_clean(); } else { ob_end_clean(); } } }
function ts_template_redirect() { global $wp_query, $post, $ts_page_datas, $smof_data; /* Get Page Options */ if (is_page() || is_tax('product_cat') || is_tax('product_tag') || is_post_type_archive('product')) { if (is_page()) { $page_id = $post->ID; } if (is_tax('product_cat') || is_tax('product_tag') || is_post_type_archive('product')) { $page_id = get_option('woocommerce_shop_page_id', 0); } $post_custom = get_post_custom($page_id); foreach ($post_custom as $key => $value) { if (isset($value[0])) { $ts_page_datas[$key] = $value[0]; } } $page_option_default = array('ts_layout_style' => 'default', 'ts_page_layout' => '0-1-0', 'ts_left_sidebar' => '', 'ts_right_sidebar' => '', 'ts_full_page' => 0, 'ts_header_layout' => 'default', 'ts_header_transparent' => 0, 'ts_header_text_color' => 'default', 'ts_menu_id' => 0, 'ts_breadcrumb_layout' => 'default', 'ts_breadcrumb_bg_parallax' => 'default', 'ts_bg_breadcrumbs' => '', 'ts_logo' => '', 'ts_logo_sticky' => '', 'ts_show_breadcrumb' => 1, 'ts_show_page_title' => 1, 'ts_page_slider' => 0, 'ts_page_slider_position' => 'before_main_content', 'ts_rev_slider' => 0); $ts_page_datas = ts_array_atts($page_option_default, $ts_page_datas); if ($ts_page_datas['ts_layout_style'] != 'default') { $smof_data['ts_layout_style'] = $ts_page_datas['ts_layout_style']; } if ($ts_page_datas['ts_header_layout'] != 'default') { $smof_data['ts_header_layout'] = $ts_page_datas['ts_header_layout']; } if ($ts_page_datas['ts_breadcrumb_layout'] != 'default') { $smof_data['ts_breadcrumb_layout'] = $ts_page_datas['ts_breadcrumb_layout']; } if ($ts_page_datas['ts_breadcrumb_bg_parallax'] != 'default') { $smof_data['ts_breadcrumb_bg_parallax'] = $ts_page_datas['ts_breadcrumb_bg_parallax']; } if (trim($ts_page_datas['ts_bg_breadcrumbs']) != '') { $smof_data['ts_bg_breadcrumbs'] = $ts_page_datas['ts_bg_breadcrumbs']; } if (trim($ts_page_datas['ts_logo']) != '') { $smof_data['ts_logo'] = $ts_page_datas['ts_logo']; } if (trim($ts_page_datas['ts_logo_sticky']) != '') { $smof_data['ts_logo_sticky'] = $ts_page_datas['ts_logo_sticky']; } if ($ts_page_datas['ts_menu_id']) { add_filter('wp_nav_menu_args', 'ts_filter_wp_nav_menu_args'); } if ($ts_page_datas['ts_full_page']) { add_filter('body_class', create_function('$classes', '$classes[] = "full-page"; return $classes;')); } } /* Archive - Category product */ if (is_tax('product_cat') || is_tax('product_tag') || is_post_type_archive('product')) { ts_set_header_breadcrumb_layout_woocommerce_page('shop'); add_action('wp_enqueue_scripts', 'ts_grid_list_desc_style', 1000); ts_remove_hooks_from_shop_loop(); /* Update product category layout */ if (is_tax('product_cat')) { $term = $wp_query->queried_object; if (!empty($term->term_id)) { $bg_breadcrumbs_id = get_woocommerce_term_meta($term->term_id, 'bg_breadcrumbs_id', true); $layout = get_woocommerce_term_meta($term->term_id, 'layout', true); $left_sidebar = get_woocommerce_term_meta($term->term_id, 'left_sidebar', true); $right_sidebar = get_woocommerce_term_meta($term->term_id, 'right_sidebar', true); if ($bg_breadcrumbs_id != '') { $bg_breadcrumbs_src = wp_get_attachment_url($bg_breadcrumbs_id); if ($bg_breadcrumbs_src !== false) { $smof_data['ts_bg_breadcrumbs'] = $bg_breadcrumbs_src; } } if ($layout != '') { $smof_data['ts_prod_cat_layout'] = $layout; } if ($left_sidebar != '') { $smof_data['ts_prod_cat_left_sidebar'] = $left_sidebar; } if ($right_sidebar != '') { $smof_data['ts_prod_cat_right_sidebar'] = $right_sidebar; } } } } /* single post */ if (is_singular('post')) { $post_data = array(); $post_custom = get_post_custom(); foreach ($post_custom as $key => $value) { if (isset($value[0])) { $post_data[$key] = $value[0]; } } $smof_data['ts_blog_details_layout'] = isset($post_data['ts_post_layout']) && $post_data['ts_post_layout'] != '0' ? $post_data['ts_post_layout'] : $smof_data['ts_blog_details_layout']; $smof_data['ts_blog_details_left_sidebar'] = isset($post_data['ts_post_left_sidebar']) && $post_data['ts_post_left_sidebar'] != '0' ? $post_data['ts_post_left_sidebar'] : $smof_data['ts_blog_details_left_sidebar']; $smof_data['ts_blog_details_right_sidebar'] = isset($post_data['ts_post_right_sidebar']) && $post_data['ts_post_right_sidebar'] != '0' ? $post_data['ts_post_right_sidebar'] : $smof_data['ts_blog_details_right_sidebar']; /* Update Post Views Count */ $views_count = get_post_meta($post->ID, '_ts_post_views_count', true); if ($views_count) { $views_count++; update_post_meta($post->ID, '_ts_post_views_count', $views_count); } else { update_post_meta($post->ID, '_ts_post_views_count', 1); } /* Breadcrumb */ $bg_breadcrumbs = get_post_meta($post->ID, 'ts_bg_breadcrumbs', true); if (!empty($bg_breadcrumbs)) { $smof_data['ts_bg_breadcrumbs'] = $bg_breadcrumbs; } } /* Single product */ if (is_singular('product')) { /* Add vertical thumbnail class */ $vertical_thumbnail = isset($smof_data['ts_prod_thumbnails_style']) && $smof_data['ts_prod_thumbnails_style'] == 'vertical'; if ($vertical_thumbnail) { add_filter('post_class', create_function('$classes', '$classes[] = "vertical-thumbnail"; return $classes;')); } /* Remove hooks on Related and Up-Sell products */ ts_remove_hooks_from_shop_loop(); if (!$smof_data['ts_prod_cat_grid_desc']) { remove_action('woocommerce_after_shop_loop_item', 'ts_template_loop_short_description', 40); } $prod_data = array(); $post_custom = get_post_custom(); foreach ($post_custom as $key => $value) { if (isset($value[0])) { $prod_data[$key] = $value[0]; } } $smof_data['ts_prod_layout'] = isset($prod_data['ts_prod_layout']) && $prod_data['ts_prod_layout'] != '0' ? $prod_data['ts_prod_layout'] : $smof_data['ts_prod_layout']; $smof_data['ts_prod_left_sidebar'] = isset($prod_data['ts_prod_left_sidebar']) && $prod_data['ts_prod_left_sidebar'] != '0' ? $prod_data['ts_prod_left_sidebar'] : $smof_data['ts_prod_left_sidebar']; $smof_data['ts_prod_right_sidebar'] = isset($prod_data['ts_prod_right_sidebar']) && $prod_data['ts_prod_right_sidebar'] != '0' ? $prod_data['ts_prod_right_sidebar'] : $smof_data['ts_prod_right_sidebar']; if (!$smof_data['ts_prod_thumbnail']) { remove_action('woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20); } if (!$smof_data['ts_prod_label']) { remove_action('ts_before_product_image', 'ts_template_loop_product_label', 10); } if (!$smof_data['ts_prod_rating']) { remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_rating', 5); } if (!$smof_data['ts_prod_sku']) { remove_action('woocommerce_single_product_summary', 'ts_template_single_sku', 6); } if (!$smof_data['ts_prod_availability']) { remove_action('woocommerce_single_product_summary', 'ts_template_single_availability', 3); } if (!$smof_data['ts_prod_excerpt']) { remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20); } if (!$smof_data['ts_prod_count_down']) { remove_action('woocommerce_single_product_summary', 'ts_template_loop_time_deals', 20); } if (!$smof_data['ts_prod_price']) { remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_price', 2); remove_action('woocommerce_single_variation', 'woocommerce_single_variation', 10); } if (!$smof_data['ts_prod_add_to_cart'] || $smof_data['ts_enable_catalog_mode']) { $terms = get_the_terms($post->ID, 'product_type'); $product_type = !empty($terms) ? sanitize_title(current($terms)->name) : 'simple'; if ($product_type != 'variable') { remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30); } else { remove_action('woocommerce_single_variation', 'woocommerce_single_variation_add_to_cart_button', 20); } } if (!$smof_data['ts_prod_sharing']) { remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 70); } if (!$smof_data['ts_prod_upsells']) { remove_action('woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15); } if (!$smof_data['ts_prod_related']) { remove_action('woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20); } if (isset($smof_data['ts_prod_tabs_position']) && $smof_data['ts_prod_tabs_position'] == 'inside_summary') { remove_action('woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10); add_action('woocommerce_single_product_summary', 'woocommerce_output_product_data_tabs', 50); } /* Breadcrumb */ $bg_breadcrumbs = get_post_meta($post->ID, 'ts_bg_breadcrumbs', true); if (!empty($bg_breadcrumbs)) { $smof_data['ts_bg_breadcrumbs'] = $bg_breadcrumbs; } /* Fix cloudzoom for WP 4.4 */ add_filter('wp_get_attachment_image_attributes', function ($attr) { if (isset($attr['sizes'])) { unset($attr['sizes']); } if (isset($attr['srcset'])) { unset($attr['srcset']); } return $attr; }, 9999); add_filter('wp_calculate_image_sizes', '__return_false', 9999); add_filter('wp_calculate_image_srcset', '__return_false', 9999); remove_filter('the_content', 'wp_make_content_images_responsive'); } /* Single Portfolio */ if (is_singular('ts_portfolio')) { $portfolio_data = array(); $post_custom = get_post_custom(); foreach ($post_custom as $key => $value) { if (isset($value[0])) { $portfolio_data[$key] = $value[0]; } } if (isset($portfolio_data['ts_portfolio_custom_field']) && $portfolio_data['ts_portfolio_custom_field'] == 1) { $smof_data['ts_portfolio_custom_field_title'] = isset($portfolio_data['ts_portfolio_custom_field_title']) ? $portfolio_data['ts_portfolio_custom_field_title'] : $smof_data['ts_portfolio_custom_field_title']; $smof_data['ts_portfolio_custom_field_content'] = isset($portfolio_data['ts_portfolio_custom_field_content']) ? $portfolio_data['ts_portfolio_custom_field_content'] : $smof_data['ts_portfolio_custom_field_content']; } } /* WooCommerce - Other pages */ if (ts_has_woocommerce()) { if (is_cart()) { ts_set_header_breadcrumb_layout_woocommerce_page('cart'); ts_remove_hooks_from_shop_loop(); if (!$smof_data['ts_prod_cat_grid_desc']) { remove_action('woocommerce_after_shop_loop_item', 'ts_template_loop_short_description', 40); } } if (is_checkout()) { ts_set_header_breadcrumb_layout_woocommerce_page('checkout'); } if (is_account_page()) { ts_set_header_breadcrumb_layout_woocommerce_page('myaccount'); } } /* Right to left */ if (is_rtl()) { $smof_data['ts_enable_rtl'] = 1; } /* Remove bbpress style if not in any bbpress page */ if (function_exists('is_bbpress') && !is_bbpress()) { add_filter('bbp_default_styles', create_function('', 'return array();')); add_filter('bbp_default_scripts', create_function('', 'return array();')); } /* Remove background image if not necessary */ $load_bg = true; if (is_page_template('page-templates/fullwidth-template.php')) { $load_bg = false; } if (is_page() && isset($ts_page_datas['ts_layout_style']) && $load_bg) { if ($ts_page_datas['ts_layout_style'] == 'wide' || $ts_page_datas['ts_layout_style'] == 'default' && $smof_data['ts_layout_style'] == 'wide') { $load_bg = false; } } if (!$load_bg) { add_filter('theme_mod_background_image', create_function('', 'return "";')); } }
function ts_ajax_search() { global $wpdb, $post, $smof_data; $search_for_product = ts_has_woocommerce(); if ($search_for_product) { $taxonomy = 'product_cat'; $post_type = 'product'; } else { $taxonomy = 'category'; $post_type = 'post'; } $num_result = isset($smof_data['ts_ajax_search_number_result']) ? (int) $smof_data['ts_ajax_search_number_result'] : 10; $search_string = $_POST['search_string']; $category = isset($_POST['category']) ? $_POST['category'] : ''; $args = array('post_type' => $post_type, 'post_status' => 'publish', 's' => $search_string, 'posts_per_page' => $num_result); if ($search_for_product) { $args['meta_query'] = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')); } if ($category != '') { $args['tax_query'] = array(array('taxonomy' => $taxonomy, 'terms' => $category, 'field' => 'slug')); } $results = new WP_Query($args); if ($results->have_posts()) { $html = '<ul>'; while ($results->have_posts()) { $results->the_post(); $link = get_permalink($post->ID); $html .= '<li><a href="' . $link . '">' . ts_search_highlight_string($post->post_title, $search_string) . '</a></li>'; } wp_reset_postdata(); $html .= '</ul>'; $return = array(); $return['html'] = $html; $return['search_string'] = $search_string; die(json_encode($return)); } die(''); }