array( 'class' => array() ), 'br' => array() ); $mess = wp_kses(__('Your cart is currently empty.Before proceed to checkout you must add some products to shopping cart.
You will find a lot of interesting products on our "Shop" page.
', 'elessi-theme'), $allowed_html); return $mess; } endif; /** * Link account */ if (!function_exists('elessi_link_account')) { function elessi_link_account() { $links = false; /* Active woocommerce */ if (NASA_WOO_ACTIVED) { $myaccount_page_id = get_option('woocommerce_myaccount_page_id'); if ($myaccount_page_id) { $links = get_permalink($myaccount_page_id); } } else { $links = !NASA_CORE_USER_LOGGED ? wp_login_url() : admin_url('profile.php'); } return $links ? $links : home_url('/'); } } /** * Tiny account */ if (!function_exists('elessi_tiny_account')) { function elessi_tiny_account($icon = false) { global $nasa_opt; if (isset($nasa_opt['hide_tini_menu_acc']) && $nasa_opt['hide_tini_menu_acc']) { return ''; } if (isset($nasa_opt['header-type']) && $nasa_opt['header-type'] == '8') { return ''; } $links = elessi_link_account(); $result = ''; return apply_filters('nasa_tiny_account_ajax', $result); } } /** * Submenu Account */ if (!function_exists('elessi_sub_account')) : function elessi_sub_account() { if (!NASA_CORE_USER_LOGGED) { return ''; } $submenu = ''; return $submenu; } endif; /** * icon cart */ if (!function_exists('elessi_mini_cart_icon')) : function elessi_mini_cart_icon() { global $nasa_opt; $icon_number = isset($nasa_opt['mini-cart-icon']) ? $nasa_opt['mini-cart-icon'] : '1'; switch ($icon_number) { case '2': $icon = ''; break; case '3': $icon = ''; break; case '4': $icon = ''; break; case '5': $icon = ''; break; case '6': $icon = ''; break; case '7': $icon = ''; break; case '1': default: $icon = ''; break; } return apply_filters('nasa_mini_icon_cart', $icon); } endif; /** * Mini cart icon * * @global type $nasa_opt * @global type $nasa_mini_cart * @param type $recount * @return type */ if (!function_exists('elessi_mini_cart')) { function elessi_mini_cart($recount = false) { global $nasa_opt, $nasa_mini_cart; if (!NASA_WOO_ACTIVED || (isset($nasa_opt['disable-cart']) && $nasa_opt['disable-cart'])) { return ''; } if (!$nasa_mini_cart) { $count = $recount ? WC()->cart->get_cart_contents_count() : 0; $class = $count ? '' : ' hidden-tag nasa-product-empty'; if ($count && (!isset($nasa_opt['compact_number']) || $nasa_opt['compact_number'])) { $count = $count > 9 ? '9+' : $count; } $icon_class = elessi_mini_cart_icon(); $nasa_mini_cart = '' . '' . $icon_class . '' . apply_filters('nasa_mini_cart_total_items', $count) . '' . '' . '' . esc_html__('Cart', 'elessi-theme') . '' . ''; $nasa_mini_cart = apply_filters('nasa_mini_cart', $nasa_mini_cart); $GLOBALS['nasa_mini_cart'] = $nasa_mini_cart; } return $nasa_mini_cart; } } /** * Add to cart dropdown - Refresh mini cart content. */ add_filter('woocommerce_add_to_cart_fragments', 'elessi_add_to_cart_refresh'); if (!function_exists('elessi_add_to_cart_refresh')) : function elessi_add_to_cart_refresh($fragments) { $fragments['.cart-inner'] = elessi_mini_cart(true); if (isset($_REQUEST['product_id'])) { $svg = ''; $fragments['.woocommerce-message'] = sprintf( '', $svg . esc_html__('Product added to cart successfully!', 'elessi-theme') ); } return $fragments; } endif; /** * Open Cart Sidebar - With disable AJAX Add To Cart - Quickview | Single Product Page */ add_action('wp_head', 'elessi_added_cart_event_sidebar'); if (!function_exists('elessi_added_cart_event_sidebar')) : function elessi_added_cart_event_sidebar() { global $nasa_opt; if (!isset($nasa_opt['enable_ajax_addtocart']) || $nasa_opt['enable_ajax_addtocart'] == '1' || (isset($nasa_opt['event-after-add-to-cart']) && $nasa_opt['event-after-add-to-cart'] !== 'sidebar')) { return; } if (isset($_POST['add-to-cart']) && $_POST['add-to-cart']) { wc_clear_notices(); add_filter('nasa_cart_sidebar_show', function() { return true; }); } } endif; /** * Mini wishlist sidebar */ if (!function_exists('elessi_mini_wishlist_sidebar')) { function elessi_mini_wishlist_sidebar($return = false) { if (!NASA_WOO_ACTIVED){ return ''; } global $nasa_opt; if (!NASA_WISHLIST_ENABLE && isset($nasa_opt['enable_nasa_wishlist']) && !$nasa_opt['enable_nasa_wishlist']) : return ''; endif; if ($return) : ob_start(); endif; $file = ELESSI_CHILD_PATH . '/includes/nasa-sidebar-wishlist.php'; include is_file($file) ? $file : ELESSI_THEME_PATH . '/includes/nasa-sidebar-wishlist.php'; if ($return) : $content = ob_get_clean(); return $content; endif; } } if (!function_exists('nasa_gen_categories_map_child')) { function nasa_gen_categories_map_child($cats) { if (!NASA_WOO_ACTIVED){ return ''; } $content_child = ''; $args = array( 'taxonomy' => 'product_cat', 'hierarchical' => true, 'parent' => $cats->term_taxonomy_id ); $childrens = get_terms(apply_filters('woocommerce_product_attribute_terms', $args)); if (count($childrens) > 0) { $content_child = ''; } return $content_child; } } if (!function_exists('nasa_get_categories_map')) { function nasa_get_categories_map() { global $nasa_opt; if (!NASA_WOO_ACTIVED){ return ''; } $args = array( 'taxonomy' => 'product_cat', 'hierarchical' => true, 'hide_empty' => false, 'parent' => 0 ); $cats = get_terms(apply_filters('woocommerce_product_attribute_terms', $args)); $columns_number = isset($nasa_opt['where_you_are_cls']) && $nasa_opt['where_you_are_cls'] ? $nasa_opt['where_you_are_cls'] : '4'; $columns_number_small = isset($nasa_opt['where_you_are_cls_s']) && $nasa_opt['where_you_are_cls_s'] ? $nasa_opt['where_you_are_cls_s'] : '1'; $columns_number_tablet = isset($nasa_opt['where_you_are_cls_m']) && $nasa_opt['where_you_are_cls_m'] ? $nasa_opt['where_you_are_cls_m'] : '3'; $column_class = 'large-block-grid-' . $columns_number . ' small-block-grid-' . $columns_number_small . ' medium-block-grid-' . $columns_number_tablet ; $content = ''; return $content; } } if (!function_exists('nasa_get_menu_map')) { function nasa_get_menu_map() { global $nasa_opt; $arr_menu = array_filter(get_nav_menu_locations()); $menu = wp_get_nav_menu_object($arr_menu['primary']); $menu_items = wp_get_nav_menu_items($menu->term_id, array('update_post_term_cache' => false)); $menu_pa = array(); foreach ($menu_items as $menu_item) { if ($menu_item->menu_item_parent === '0') { $menu_pa[] = $menu_item; } } $columns_number = isset($nasa_opt['where_you_are_cls']) && $nasa_opt['where_you_are_cls'] ? $nasa_opt['where_you_are_cls'] : '4'; $columns_number_small = isset($nasa_opt['where_you_are_cls_s']) && $nasa_opt['where_you_are_cls_s'] ? $nasa_opt['where_you_are_cls_s'] : '1'; $columns_number_tablet = isset($nasa_opt['where_you_are_cls_m']) && $nasa_opt['where_you_are_cls_m'] ? $nasa_opt['where_you_are_cls_m'] : '3'; $column_class = 'large-block-grid-' . $columns_number . ' small-block-grid-' . $columns_number_small . ' medium-block-grid-' . $columns_number_tablet ; $content = ''; return $content; } } if (!function_exists('nasa_gen_menu_map_child')) { function nasa_gen_menu_map_child($menu_splice,$menu_items) { $content_child =''; $menu_children = array(); foreach ($menu_items as $menu_item) { if ($menu_item->menu_item_parent == $menu_splice->ID) { $menu_children[] = $menu_item; } } if (count($menu_children) > 0) { $content_child = ''; } return $content_child; } } /** * Add to cart button from wishlist */ if (!function_exists('elessi_add_to_cart_in_wishlist')) : function elessi_add_to_cart_in_wishlist() { global $product, $nasa_opt; if (isset($nasa_opt['disable-cart']) && $nasa_opt['disable-cart']) { return ''; } if (!$product->is_in_stock() || !$product->is_purchasable()) { return ''; } $enable_button_ajax = false; $product_type = $product->get_type(); $product_id = $product->get_id(); $url = esc_url($product->add_to_cart_url()); if ($product_type == 'simple' || ($product_type == NASA_COMBO_TYPE && 'instock' === $product->get_bundled_items_stock_status())) { $enable_button_ajax = 'yes' === get_option('woocommerce_enable_ajax_add_to_cart') ? true : false; $url = $enable_button_ajax ? 'javascript:void(0);' : $url; } /** * Bundle product */ if ($product_type == 'woosb') { $url = '?add-to-cart=' . $product_id; if (get_option('yith_wcwl_remove_after_add_to_cart') == 'yes') { $url .= '&remove_from_wishlist_after_add_to_cart=' . $product_id; } } $class_btn = 'button-in-wishlist small btn-from-wishlist add-to-cart-grid wishlist-fragment product_type_' . esc_attr($product_type); $class_btn .= $enable_button_ajax ? ' nasa_add_to_cart_from_wishlist' : ''; $args = array( 'quantity' => 1, 'class' => $class_btn, 'attributes' => array( 'data-product_id' => $product_id, 'data-product_sku' => $product->get_sku(), 'data-type' => $product_type, 'aria-label' => $product->add_to_cart_description(), 'rel' => 'nofollow', ), ); if (isset($args['attributes']['aria-label'])) { $args['attributes']['aria-label'] = wp_strip_all_tags($args['attributes']['aria-label']); } $add_to_cart = apply_filters( 'woocommerce_loop_add_to_cart_link', // WPCS: XSS ok. sprintf( '%s', $url, esc_attr(isset($args['quantity']) ? $args['quantity'] : 1), esc_attr(isset($args['class']) ? $args['class'] : 'button'), isset($args['attributes']) ? wc_implode_html_attributes($args['attributes']) : '', esc_html($product->add_to_cart_text()) ), $product, $args ); if ($product_type === 'variable') { $add_to_cart .= sprintf('%s', $product_id, esc_html__('Quick View', 'elessi-theme')); } return $add_to_cart; } endif; /** * ARGS add to cart loop */ if (!function_exists('elessi_loop_add_to_cart_args')): function elessi_loop_add_to_cart_args($args, $product) { global $nasa_opt; /** * Custom Attributes */ if (!isset($args['attributes'])) { $args['attributes'] = array(); } $args['attributes']['title'] = $product->add_to_cart_text(); /** * Custom Class */ if (!isset($args['class'])) { $args['class'] = ''; } $args['class'] .= ' add-to-cart-grid btn-link nasa-tip'; $ajax_sp = 'yes' === get_option('woocommerce_enable_ajax_add_to_cart') ? true : false; if (!$ajax_sp) { $args['class'] .= ' nasa-disable-ajax'; } if ($product->is_purchasable() && $product->is_in_stock()) { $product_type = $product->get_type(); /** * Variation product */ if ($product_type == 'variation') { $args['attributes']['data-variation_id'] = $product->get_id(); $args['attributes']['data-variation'] = json_encode($product->get_variation_attributes()); } /** * Yith Bundle product */ if ($product_type == NASA_COMBO_TYPE) { $args['class'] .= $ajax_sp ? ' nasa_bundle_add_to_cart' : ''; $args['attributes']['data-type'] = $product_type; } } /** * Custom Icon */ $icon_cart = ''; $icon_number = isset($nasa_opt['cart-icon-grid']) ? $nasa_opt['cart-icon-grid'] : '1'; switch ($icon_number) { case '2': $icon_cart .= ''; break; case '3': $icon_cart .= ''; break; case '4': $icon_cart .= ''; break; case '5': $icon_cart .= ''; break; case '6': $icon_cart .= ''; break; case '7': $icon_cart .= ''; break; case '8': $icon_cart .= ''; break; case '9': $icon_cart = ' '; break; case '1': default: $icon_cart .= ''; break; } $args['icon_cart'] = apply_filters('nasa_filter_add_to_cart_icon', $icon_cart); $args['class'] = apply_filters('nasa_filter_add_to_cart_class', $args['class']); return $args; } endif; /** * Product group buttons */ if (!function_exists('elessi_product_group_button')): function elessi_product_group_button() { ob_start(); $file = ELESSI_CHILD_PATH . '/includes/nasa-product-buttons.php'; include is_file($file) ? $file : ELESSI_THEME_PATH . '/includes/nasa-product-buttons.php'; return ob_get_clean(); } endif; /** * Wishlist link */ if (!function_exists('elessi_tini_wishlist')): function elessi_tini_wishlist($icon = false) { if (!NASA_WOO_ACTIVED || !NASA_WISHLIST_ENABLE) { return; } $tini_wishlist = ''; $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); $span = $icon ? '' : ''; $tini_wishlist .= '' . $span . esc_html__('Wishlist', 'elessi-theme') . ''; return $tini_wishlist; } endif; /** * Wishlist icons */ if (!function_exists('elessi_icon_wishlist')): function elessi_icon_wishlist() { if (!NASA_WOO_ACTIVED) { return ''; } $svg_wishlist = ''; global $nasa_icon_wishlist; if (!isset($nasa_icon_wishlist)) { $show = defined('NASA_PLG_CACHE_ACTIVE') && NASA_PLG_CACHE_ACTIVE ? false : true; $count = elessi_get_count_wishlist($show); /** * Yith WooCommerce Wishlist */ if (NASA_WISHLIST_ENABLE) { $class = 'wishlist-link nasa-flex ns-mini-yith-wcwl'; $class .= ' wishlist-link-premium'; $wishlist_page_id = get_option('yith_wcwl_wishlist_page_id'); if (function_exists('icl_object_id') && $wishlist_page_id) { $wishlist_page_id = icl_object_id($wishlist_page_id, 'page', true); } $href = $wishlist_page_id ? get_permalink($wishlist_page_id) : home_url('/'); $icon = apply_filters('nasa_mini_icon_wishlist', $svg_wishlist); $nasa_icon_wishlist = '' . '' . $icon . $count . '' . '' . esc_html__('Wishlist', 'elessi-theme') . '' . ''; } /** * NasaTheme Wishlist */ else { global $nasa_opt; if (isset($nasa_opt['enable_nasa_wishlist']) && !$nasa_opt['enable_nasa_wishlist']) { return; } $class = 'wishlist-link nasa-wishlist-link nasa-flex'; $icon = apply_filters('nasa_mini_icon_wishlist', $svg_wishlist); $nasa_icon_wishlist = '' . '' . $icon . $count . '' . '' . esc_html__('Wishlist', 'elessi-theme') . '' . ''; } $GLOBALS['nasa_icon_wishlist'] = $nasa_icon_wishlist; } return isset($nasa_icon_wishlist) && $nasa_icon_wishlist ? apply_filters('nasa_mini_wishlist', $nasa_icon_wishlist) : ''; } endif; /** * Count mini wishlist icon */ if (!function_exists('elessi_get_count_wishlist')) : function elessi_get_count_wishlist($show = true, $init_count = true) { if (!NASA_WOO_ACTIVED) { return ''; } global $nasa_opt; $count = 0; if (NASA_WISHLIST_ENABLE) { $count = $init_count ? yith_wcwl_count_products() : 0; } else { $show = true; } $hasEmpty = (int) $count == 0 ? ' nasa-product-empty' : ''; $sl = $show ? '' : ' hidden-tag'; $class_wrap = 'nasa-wishlist-count nasa-mini-number wishlist-number' . $sl . $hasEmpty; if (!isset($nasa_opt['compact_number']) || $nasa_opt['compact_number']) { $count = $count > 9 ? '9+' : (int) $count; } return '' . apply_filters('nasa_mini_wishlist_total_items', $count) . ''; } endif; add_filter('yith_wcwl_fragment_output', function($frg) { $frg['.nasa-wishlist-count'] = elessi_get_count_wishlist(); return $frg; }); /** * Compare link */ if (!function_exists('elessi_icon_compare')): function elessi_icon_compare() { if (!NASA_WOO_ACTIVED || !defined('YITH_WOOCOMPARE')) { return; } global $nasa_icon_compare, $nasa_opt; if (!$nasa_icon_compare) { global $yith_woocompare; if (!isset($nasa_opt['nasa-product-compare']) || $nasa_opt['nasa-product-compare']) { $view_href = isset($nasa_opt['nasa-page-view-compage']) && (int) $nasa_opt['nasa-page-view-compage'] ? get_permalink((int) $nasa_opt['nasa-page-view-compage']) : home_url('/'); $class = 'nasa-show-compare nasa-flex'; $wrap = false; } else { $view_href = add_query_arg(array('iframe' => 'true'), $yith_woocompare->obj->view_table_url()); $class = 'compare'; $wrap = true; } $svg_compare = ''; $icon = apply_filters('nasa_mini_icon_compare', $svg_compare); $GLOBALS['nasa_icon_compare'] = ($wrap ? '' : '') . '' . '' . $icon . '0' . '' . '' . esc_html__('Compare', 'elessi-theme') . '' . '' . ($wrap ? '' : ''); } return $nasa_icon_compare ? apply_filters('nasa_mini_compare', $nasa_icon_compare) : ''; } endif; /** * Count mini Compare icon */ if (!function_exists('elessi_get_count_compare')): function elessi_get_count_compare($show = true) { if (!NASA_WOO_ACTIVED || !defined('YITH_WOOCOMPARE')) { return ''; } global $nasa_opt, $yith_woocompare; $count = count($yith_woocompare->obj->products_list); $hasEmpty = (int) $count == 0 ? ' nasa-product-empty' : ''; $sl = $show ? '' : ' hidden-tag'; $class_wrap = 'nasa-compare-count nasa-mini-number compare-number' . $sl . $hasEmpty; if (!isset($nasa_opt['compact_number']) || $nasa_opt['compact_number']) { $count = $count > 9 ? '9+' : (int) $count; } return '' . apply_filters('nasa_mini_compare_total_items', $count) . ''; } endif; /** * Nasa root categories in Shop Top bar */ if (!function_exists('elessi_get_root_categories')): function elessi_get_root_categories() { global $nasa_opt; $content = ''; if (isset($nasa_opt['top_filter_rootcat']) && !$nasa_opt['top_filter_rootcat']) { echo ($content); return; } if (!is_post_type_archive('product') && !is_tax(get_object_taxonomies('product'))) { echo ($content); return; } if (NASA_WOO_ACTIVED){ $nasa_terms = get_terms(apply_filters('woocommerce_product_attribute_terms', array( 'taxonomy' => 'product_cat', 'parent' => 0, 'hide_empty' => false, 'orderby' => 'name' ))); if ($nasa_terms) { $slug = get_query_var('product_cat'); $nasa_catActive = $slug ? $slug : ''; $content .= '
'; $content .= '
'; } } $icon = $content != '' ? '
' . esc_html__('BROWSE', 'elessi-theme') . '
' : ''; $content = $icon . $content; echo $content; } endif; /** * Categories thumbnail */ if (!function_exists('elessi_category_thumbnail')) : function elessi_category_thumbnail($category = null, $type = 'thumbnail') { if (!$category) { return ''; } $img_str = ''; $small_thumbnail_size = apply_filters('single_product_small_thumbnail_size', $type); $thumbnail_id = function_exists('get_term_meta') ? get_term_meta($category->term_id, 'thumbnail_id', true) : get_woocommerce_term_meta($category->term_id, 'thumbnail_id', true); $image_src = ''; if ($thumbnail_id) { $image = wp_get_attachment_image_src($thumbnail_id, $small_thumbnail_size); $image_src = $image[0]; $image_width = $image[1]; $image_height = $image[2]; } else { $image_src = wc_placeholder_img_src(); $image_width = 100; $image_height = 100; } if ($image_src) { $image_src = str_replace(' ', '%20', $image_src); $img_str = '' . esc_attr($category->name) . ''; } return $img_str; } endif; /** * Login Or Register Form */ add_action('nasa_login_register_form', 'elessi_login_register_form', 10, 1); if (!function_exists('elessi_login_register_form')) : function elessi_login_register_form($prefix = false) { global $nasa_opt; if (!NASA_WOO_ACTIVED) { return; } if ($prefix) { remove_action('woocommerce_before_customer_login_form', 'woocommerce_output_all_notices', 10); } $file = ELESSI_CHILD_PATH . '/includes/nasa-login-register-form.php'; include is_file($file) ? $file : ELESSI_THEME_PATH . '/includes/nasa-login-register-form.php'; } endif; /** * Number post_per_page shop/archive_product */ add_filter('loop_shop_per_page', 'elessi_loop_shop_per_page', 20); if (!function_exists('elessi_loop_shop_per_page')) : function elessi_loop_shop_per_page($post_per_page) { global $nasa_opt; return (isset($nasa_opt['products_pr_page']) && (int) $nasa_opt['products_pr_page']) ? (int) $nasa_opt['products_pr_page'] : get_option('posts_per_page'); } endif; /** * Number relate products */ add_filter('woocommerce_output_related_products_args', 'elessi_output_related_products_args'); if (!function_exists('elessi_output_related_products_args')) : function elessi_output_related_products_args($args) { global $nasa_opt; $args['posts_per_page'] = (isset($nasa_opt['relate_product_number']) && (int) $nasa_opt['relate_product_number']) ? (int) $nasa_opt['relate_product_number'] : 12; return $args; } endif; /** * Compare list in bot site */ add_action('nasa_show_mini_compare', 'elessi_show_mini_compare'); if (!function_exists('elessi_show_mini_compare')) : function elessi_show_mini_compare() { global $nasa_opt, $yith_woocompare; if (!class_exists('YITH_Woocompare_Frontend') || (isset($nasa_opt['nasa-product-compare']) && !$nasa_opt['nasa-product-compare'])) { return; } $nasa_compare = isset($yith_woocompare->obj) ? $yith_woocompare->obj : $yith_woocompare; if (!$nasa_compare || !($nasa_compare instanceof YITH_Woocompare_Frontend)) { return; } if (!isset($nasa_opt['nasa-page-view-compage']) || !(int) $nasa_opt['nasa-page-view-compage']) { $pages = get_pages(array( 'meta_key' => '_wp_page_template', 'meta_value' => 'page-view-compare.php' )); if ($pages) { foreach ($pages as $page) { $nasa_opt['nasa-page-view-compage'] = (int) $page->ID; break; } } } $page_compare = isset($nasa_opt['nasa-page-view-compage']) && (int) $nasa_opt['nasa-page-view-compage'] ? (int) $nasa_opt['nasa-page-view-compage'] : 0; if (function_exists('icl_object_id') && $page_compare) { $page_langID = icl_object_id($page_compare, 'page', true); if ($page_langID && $page_langID != $page_compare) { $page_compare = (int) $page_langID; } } $view_href = $page_compare ? get_permalink($page_compare) : home_url('/'); $nasa_compare_list = $nasa_compare->get_products_list(); $file = ELESSI_CHILD_PATH . '/includes/nasa-mini-compare.php'; include is_file($file) ? $file : ELESSI_THEME_PATH . '/includes/nasa-mini-compare.php'; } endif; /** * Empty Compare */ add_action('nasa_empty_mini_compare', 'elessi_empty_mini_compare'); if (!function_exists('elessi_empty_mini_compare')) : function elessi_empty_mini_compare() { global $nasa_opt, $yith_woocompare; if (!class_exists('YITH_Woocompare_Frontend') || (isset($nasa_opt['nasa-product-compare']) && !$nasa_opt['nasa-product-compare'])) { return; } $nasa_compare = isset($yith_woocompare->obj) ? $yith_woocompare->obj : $yith_woocompare; if (!$nasa_compare || !($nasa_compare instanceof YITH_Woocompare_Frontend)) { return; } if (!isset($nasa_opt['nasa-page-view-compage']) || !(int) $nasa_opt['nasa-page-view-compage']) { $pages = get_pages(array( 'meta_key' => '_wp_page_template', 'meta_value' => 'page-view-compare.php' )); if ($pages) { foreach ($pages as $page) { $nasa_opt['nasa-page-view-compage'] = (int) $page->ID; break; } } } $page_compare = isset($nasa_opt['nasa-page-view-compage']) && (int) $nasa_opt['nasa-page-view-compage'] ? (int) $nasa_opt['nasa-page-view-compage'] : 0; if (function_exists('icl_object_id') && $page_compare) { $page_langID = icl_object_id($page_compare, 'page', true); if ($page_langID && $page_langID != $page_compare) { $page_compare = (int) $page_langID; } } $view_href = $page_compare ? get_permalink($page_compare) : home_url('/'); // $nasa_compare_list = array(); $file = ELESSI_CHILD_PATH . '/includes/nasa-mini-compare.php'; include is_file($file) ? $file : ELESSI_THEME_PATH . '/includes/nasa-mini-compare.php'; } endif; /** * Default page compare */ if (!function_exists('elessi_products_compare_content')) : function elessi_products_compare_content($echo = false) { global $nasa_opt, $yith_woocompare; if (!class_exists('YITH_Woocompare_Frontend') || (isset($nasa_opt['nasa-product-compare']) && !$nasa_opt['nasa-product-compare'])) { return ''; } $nasa_compare = isset($yith_woocompare->obj) ? $yith_woocompare->obj : $yith_woocompare; if (!$nasa_compare || !($nasa_compare instanceof YITH_Woocompare_Frontend)) { return ''; } $file = ELESSI_CHILD_PATH . '/includes/nasa-view-compare.php'; if (!$echo) { ob_start(); include is_file($file) ? $file : ELESSI_THEME_PATH . '/includes/nasa-view-compare.php'; return ob_get_clean(); } else { include is_file($file) ? $file : ELESSI_THEME_PATH . '/includes/nasa-view-compare.php'; } } endif; /** * NEXT NAV ON SINGLE PRODUCT */ add_action('next_prev_product', 'elessi_next_product'); if (!function_exists('elessi_next_product')) : function elessi_next_product() { $next_post = get_next_post(true, '', 'product_cat'); if (is_a($next_post, 'WP_Post')) { global $nasa_opt; $in_mobile = isset($nasa_opt['nasa_in_mobile']) && $nasa_opt['nasa_in_mobile'] ? true : false; $next_product = wc_get_product($next_post->ID); $title = $next_product->get_name(); $link = $next_product->get_permalink(); $class_ajax = defined('NASA_AJAX_PRODUCT') && NASA_AJAX_PRODUCT ? ' nasa-ajax-call' : ''; ?>
get_image('thumbnail'); ?>

get_price_html(); ?>
ID); $title = $prev_product->get_name(); $link = $prev_product->get_permalink(); $class_ajax = defined('NASA_AJAX_PRODUCT') && NASA_AJAX_PRODUCT ? ' nasa-ajax-call' : ''; ?>
get_image('thumbnail'); ?>

get_price_html(); ?>
'; } } /** * ADD VIDEO PLAY BUTTON ON PRODUCT DETAIL PAGE */ add_action('nasa_single_buttons', 'elessi_product_video_btn', 9); if (!function_exists('elessi_product_video_btn')) { function elessi_product_video_btn() { global $product; if (!$product) { return; } $id = $product->get_id(); $video_link = elessi_get_product_meta_value($id, '_product_video_link'); if ($video_link) { $video_link = str_replace('youtube.com/shorts/', 'youtube.com/watch?v=', $video_link); ?> '; echo '.has-product-video .mfp-iframe-holder .mfp-content {max-width: ' . $width . 'px; height: ' . $height . 'px;}'; // echo '.has-product-video .mfp-iframe-scaler{padding-top: ' . $iframe_scale . ';}'; echo ''; // wp_add_inline_style('product_detail_css_custom', $style); } } } } /** * Wishlist Button ext Yith Wishlist */ if (!function_exists('elessi_add_wishlist_button')) : function elessi_add_wishlist_button($tip = 'left') { if (NASA_WISHLIST_ENABLE) { global $product; if (!shortcode_exists('yith_wcwl_add_to_wishlist')) { return; } $premium = defined('YITH_WCWL_PREMIUM') && YITH_WCWL_PREMIUM ? true : false; $variation = false; $productId = $product->get_id(); $productType = $product->get_type(); if ($productType == 'variation') { $variation_product = $product; $productId = wp_get_post_parent_id($productId); $parentProduct = wc_get_product($productId); $productType = $parentProduct->get_type(); $GLOBALS['product'] = $parentProduct; $variation = true; } $class_btn = 'btn-wishlist btn-link wishlist-icon nasa-tip ns-yith-wcwl'; $class_btn .= $tip !== 'label' ? ' nasa-tip-' . $tip : ''; $exists = function_exists('yith_wcwl_wishlists') ? yith_wcwl_wishlists()->is_product_in_wishlist($productId) : false; $class_btn .= $exists ? ' nasa-added' : ''; $class_yith = 'add-to-link ns-yith-add-to-wishlist-wrap hidden-tag'; if ($premium) { $class_yith .= ' yith-premium'; $class_btn .= ' has-yith-premium'; } /** * Apply Filters Icon */ $icon = apply_filters('nasa_icon_wishlist', ' '); ?> get_availability(); if ($availability['availability']) { echo apply_filters('woocommerce_get_stock_html', '

' . wp_kses(__('Availability: ', 'elessi-theme'), array('span' => array())) . esc_html($availability['availability']) . '

', $availability['availability']); } } endif; /** * Toggle coupon */ if (!function_exists('elessi_wrap_coupon_toggle')) : function elessi_wrap_coupon_toggle($content) { return '
' . $content . '
'; } endif; /** * Tab Combo Yith Bundle product */ if (!function_exists('elessi_combo_tab')) : function elessi_combo_tab($nasa_viewmore = true) { global $woocommerce, $nasa_opt, $product; if (!$woocommerce || !$product || $product->get_type() != NASA_COMBO_TYPE || !$combo = $product->get_bundled_items()) { return false; } $file = ELESSI_CHILD_PATH . '/includes/nasa-combo-products-in-detail.php'; $file = is_file($file) ? $file : ELESSI_THEME_PATH . '/includes/nasa-combo-products-in-detail.php'; ob_start(); include $file; return ob_get_clean(); } endif; /** * Get All categories product filter in top */ if (!function_exists('elessi_get_all_categories')) : function elessi_get_all_categories($show_children_only = false, $main = false, $hierarchical = true) { if (!NASA_WOO_ACTIVED) { return; } global $nasa_opt, $wp_query, $post; $hide_empty = (isset($nasa_opt['hide_empty_cat_top']) && $nasa_opt['hide_empty_cat_top']) ? true : false; $list_args = array( 'taxonomy' => 'product_cat', 'show_count' => 0, 'hierarchical' => $hierarchical, 'hide_empty' => apply_filters('nasa_top_filter_cats_hide_empty', $hide_empty) ); /** * Max depth = 0 ~ all */ $depth_top = !isset($nasa_opt['depth_cat_top']) ? 0 : (int) $nasa_opt['depth_cat_top']; $max_depth = apply_filters('nasa_max_depth_top_filter_cats', $depth_top); $order = isset($nasa_opt['order_cat_top']) ? $nasa_opt['order_cat_top'] : 'name'; $list_args['menu_order'] = false; if (apply_filters('nasa_top_filter_categories_orderby', $order) == 'order') { $list_args['orderby'] = 'meta_value_num'; $list_args['meta_key'] = 'order'; } else { $list_args['orderby'] = 'title'; } $current_cat = false; $cat_ancestors = array(); $root_id = 0; /** * post type page */ if ( isset($nasa_opt['disable_top_level_cat']) && $nasa_opt['disable_top_level_cat'] && isset($post->ID) && $post->post_type == 'page' ) { $current_slug = get_post_meta($post->ID, '_nasa_root_category', true); if ($current_slug) { $current_cat = get_term_by('slug', $current_slug, 'product_cat'); if ($current_cat && isset($current_cat->term_id)) { $cat_ancestors = get_ancestors($current_cat->term_id, 'product_cat'); } } } /** * Archive product category */ elseif (is_tax('product_cat')) { $current_cat = $wp_query->queried_object; $cat_ancestors = get_ancestors($current_cat->term_id, 'product_cat'); } /** * Single product page */ elseif (is_singular('product')) { $terms = wc_get_product_terms( $post->ID, 'product_cat', apply_filters( 'woocommerce_product_categories_widget_product_terms_args', array( 'orderby' => 'parent', 'order' => 'DESC', ) ) ); if ($terms) { $main_term = apply_filters('woocommerce_product_categories_widget_main_term', $terms[0], $terms); $current_cat = $main_term; $cat_ancestors = get_ancestors($main_term->term_id, 'product_cat'); } } /** * Only Show Children */ if ($show_children_only && $current_cat) { if ($hierarchical) { $include = array_merge( $cat_ancestors, array($current_cat->term_id), get_terms( 'product_cat', array( 'fields' => 'ids', 'parent' => 0, 'hierarchical' => true, 'hide_empty' => false, ) ), get_terms( 'product_cat', array( 'fields' => 'ids', 'parent' => $current_cat->term_id, 'hierarchical' => true, 'hide_empty' => false, ) ) ); // Gather siblings of ancestors. if ($cat_ancestors) { foreach ($cat_ancestors as $ancestor) { $include = array_merge( $include, get_terms( 'product_cat', array( 'fields' => 'ids', 'parent' => $ancestor, 'hierarchical' => false, 'hide_empty' => false, ) ) ); } } } else { // Direct children. $include = get_terms( 'product_cat', array( 'fields' => 'ids', 'parent' => $current_cat->term_id, 'hierarchical' => true, 'hide_empty' => false, ) ); } $list_args['include'] = implode(',', $include); if (empty($include)) { return; } } elseif ((isset($nasa_opt['disable_top_level_cat']) && $nasa_opt['disable_top_level_cat'])) { $root_id = $cat_ancestors ? end($cat_ancestors) : ($current_cat ? $current_cat->term_id : $root_id); $list_args['child_of'] = apply_filters('nasa_root_id_top_filter_cats', $root_id); } elseif ($show_children_only) { $list_args['child_of'] = 0; $list_args['depth'] = 1; $list_args['hierarchical'] = 1; } $list_args['walker'] = new Elessi_Product_Cat_List_Walker($max_depth); $list_args['title_li'] = ''; $list_args['pad_counts'] = 1; $list_args['show_option_none'] = esc_html__('No product categories exist.', 'elessi-theme'); $list_args['current_category'] = $current_cat ? $current_cat->term_id : ''; $list_args['current_category_ancestors'] = $cat_ancestors; $list_args['max_depth'] = ''; $list_args['echo'] = false; if (!isset($nasa_opt['show_uncategorized']) || !$nasa_opt['show_uncategorized']) { $uncategorized = get_option('default_product_cat'); if ($uncategorized) { $list_args['exclude'] = $uncategorized; } } $nasa_top_filter = ''; $tmpl = isset($nasa_opt['tmpl_html']) && $nasa_opt['tmpl_html'] ? true : false; $result = $main ? '
' : '
'; $result .= $tmpl ? '' : ''; $result .= '
'; return $result; } endif; /** * nasa_archive_get_sub_categories */ add_action('nasa_archive_get_sub_categories', 'elessi_archive_get_sub_categories'); if (!function_exists('elessi_archive_get_sub_categories')) : function elessi_archive_get_sub_categories() { $GLOBALS['nasa_cat_loop_delay'] = 0; echo '
'; woocommerce_product_subcategories(array( 'before' => '

' . esc_html__('Subcategories: ', 'elessi-theme') . '

', 'after' => '

' )); echo '
'; } endif; /** * Filter Paginate Links * * Since 4.6.3 */ add_filter('paginate_links', 'elessi_paginate_links'); if (!function_exists('elessi_paginate_links')) : function elessi_paginate_links($link) { if (!defined('NASA_AJAX_SHOP') || !NASA_AJAX_SHOP) { return $link; } if ('/page/1' === substr($link, strlen($link)-7, 7)) { return str_replace('/page/1', '', $link); } return str_replace('/page/1/', '/', $link); } endif; add_filter('paginate_links_output', 'elessi_modify_paginate_links_output', 10, 2); if (!function_exists('elessi_modify_paginate_links_output')) : function elessi_modify_paginate_links_output($r, $args) { global $nasa_opt; if (isset($nasa_opt['single_review_ajax']) && $nasa_opt['single_review_ajax'] && NASA_WOO_ACTIVED && is_product()) { // $comment_order = get_option('comment_order'); $current = (int) $args['current']; $total = (int) $args['total']; $link = str_replace('%_%', $args['format'], $args['base']); $link = str_replace('%#%', $current + 1, $link); $elclass = $current + 1 > $total ? 'hidden-tag' : ''; $r = '
' . '' . '' . esc_html__('Load more', 'elessi-theme') . '' . '' . '
'; } return $r; } endif; add_filter('comment_text', 'elessi_custom_comment_text', 30, 3); if (!function_exists('elessi_custom_comment_text')) : function elessi_custom_comment_text($comment_text, $comment, $args) { if (NASA_WOO_ACTIVED && is_product()) { $comment_text .= '' . apply_filters('ns_comment_text_read_more', '[...]') . ''; } return $comment_text; } endif; add_action('pre_get_comments', 'elessi_filter_reviews_product'); if (!function_exists('elessi_filter_reviews_product')) : function elessi_filter_reviews_product($query) { if (!NASA_WOO_ACTIVED) { return; } $sort_type = isset($_GET['review_sort']) && $_GET['review_sort'] != '' ? $_GET['review_sort'] : 'date_DESC'; update_option('default_comments_page', 'oldest'); update_option('comment_order', 'asc'); if (is_product()) { switch ($sort_type) { case 'rating_ASC': $query->query_vars['orderby'] = 'meta_value_num'; $query->query_vars['meta_key'] = 'rating'; $query->query_vars['order'] = 'ASC'; break; case 'rating_DESC': $query->query_vars['orderby'] = 'meta_value_num'; $query->query_vars['meta_key'] = 'rating'; $query->query_vars['order'] = 'DESC'; break; case 'media_DESC': $meta_query = array( array( 'key' => 'nasa_review_images', 'compare' => 'EXISTS', ), ); $query->query_vars['meta_query'] = $meta_query; $query->query_vars['orderby'] = 'comment_date'; $query->query_vars['order'] = 'DESC'; break; case 'date_ASC': $query->query_vars['orderby'] = 'comment_date'; $query->query_vars['order'] = 'ASC'; break; case 'date_DESC': $query->query_vars['orderby'] = 'comment_date'; $query->query_vars['order'] = 'DESC'; break; default: break; } } } endif; /** * Filter Pagination args * * Since 4.6.3 */ add_filter('woocommerce_pagination_args', 'elessi_pagination_args'); if (!function_exists('elessi_pagination_args')) : function elessi_pagination_args($args) { if (empty($args)) { $args = array(); } $args['prev_text'] = ''; $args['next_text'] = ''; $args['type'] = 'list'; $args['end_size'] = 1; $args['mid_size'] = 1; return $args; } endif; /** * No paging url */ if (!function_exists('elessi_nopaging_url')) : function elessi_nopaging_url() { global $wp; if (!$wp->request) { return false; } $current_url = home_url($wp->request); $pattern = '/page(\/)*([0-9\/])*/i'; $nopaging_url = preg_replace($pattern, '', $current_url); return trailingslashit($nopaging_url); } endif; /** * Compatible WooCommerce_Advanced_Free_Shipping * Only with one Rule "subtotal >= Rule" */ add_action('nasa_subtotal_free_shipping', 'elessi_subtotal_free_shipping'); add_action('woocommerce_widget_shopping_cart_total', 'elessi_subtotal_free_shipping', 20); if (!function_exists('elessi_subtotal_free_shipping')) : function elessi_subtotal_free_shipping($return = false) { global $nasa_opt; $value = 0; $content = ''; /** * Check active plug-in WooCommerce || WooCommerce_Advanced_Free_Shipping */ if ( (isset($nasa_opt['free_shipbar']) && !$nasa_opt['free_shipbar']) || !NASA_WOO_ACTIVED || !class_exists('WooCommerce_Advanced_Free_Shipping') || !function_exists('WAFS') ) { return $content; } /** * Check setting plug-in */ $wafs = WAFS(); if (!isset($wafs->was_method)) { $wafs->wafs_free_shipping(); } $wafs_method = isset($wafs->was_method) ? $wafs->was_method : null; if (!$wafs_method || $wafs_method->enabled === 'no') { return $content; } /** * Check has */ $wafs_posts = get_posts(array( // 'posts_per_page' => 2, 'post_status' => 'publish', 'post_type' => 'wafs' )); if (!$wafs_posts || count($wafs_posts) < 1) { return $content; } require_once ELESSI_THEME_PATH . '/cores/nasa-advanced-free-shipping.php'; $out_nsafs = false; /** * Check and Rules */ foreach ($wafs_posts as $wafs_post) { $condition_groups = get_post_meta($wafs_post->ID, '_wafs_shipping_method_conditions', true); if (!$condition_groups || count($condition_groups) < 1) { continue; } $condition_group = reset($condition_groups); if (!$condition_group || count($condition_group) < 1) { continue; } $nsafs = new Nasa_Advanced_Free_Shipping($condition_group); if (!$nsafs->render) { continue; } if ($out_nsafs && $out_nsafs->value > $nsafs->value) { $out_nsafs = $nsafs; } if (!$out_nsafs && $nsafs->render) { $out_nsafs = $nsafs; } } if ($out_nsafs) { $content = $out_nsafs->output_html(); } if (!$return) { echo $content; return; } return $content; } endif; /** * Add Free_Shipping to Cart page */ add_action('woocommerce_cart_contents', 'elessi_subtotal_free_shipping_in_cart'); if (!function_exists('elessi_subtotal_free_shipping_in_cart')) : function elessi_subtotal_free_shipping_in_cart() { $content = elessi_subtotal_free_shipping(true); if ($content !== '') { echo '' . $content . ''; } } endif; /** * Before account Navigation */ add_action('woocommerce_before_account_navigation', 'elessi_before_account_nav'); if (!function_exists('elessi_before_account_nav')) : function elessi_before_account_nav() { if (!NASA_WOO_ACTIVED || !NASA_CORE_USER_LOGGED) { return; } $current_user = wp_get_current_user(); ?>
'; } endif; /** * Account Dashboard Square */ add_action('woocommerce_account_dashboard', 'elessi_account_dashboard_nav'); if (!function_exists('elessi_account_dashboard_nav')) : function elessi_account_dashboard_nav() { if (!NASA_WOO_ACTIVED || !NASA_CORE_USER_LOGGED) { return; } $extra_class = 'nasa-MyAccount-navigation'; $file = ELESSI_CHILD_PATH . '/includes/nasa-acc-nav.php'; include is_file($file) ? $file : ELESSI_THEME_PATH . '/includes/nasa-acc-nav.php'; } endif; /** * Custom class Single product Price */ add_filter('woocommerce_product_price_class', 'elessi_product_price_class'); if (!function_exists('elessi_product_price_class')) : function elessi_product_price_class($class) { $class .= ' nasa-single-product-price'; return $class; } endif; /** * Custom class Single product tabs */ add_filter('nasa_single_product_tabs_style', 'elessi_single_product_tabs_class'); if (!function_exists('elessi_single_product_tabs_class')) : function elessi_single_product_tabs_class($class) { global $nasa_opt; $classes = isset($nasa_opt['tab_style_info']) ? $nasa_opt['tab_style_info'] : $class; return $classes; } endif; /** * Override woocommerce_catalog_orderby */ add_filter('woocommerce_catalog_orderby', 'elessi_wc_catalog_orderby'); if (!function_exists('elessi_wc_catalog_orderby')) : function elessi_wc_catalog_orderby($catalogs) { return array( 'menu_order' => __('Default sorting', 'elessi-theme'), 'popularity' => __('Popularity', 'elessi-theme'), 'rating' => __('Average rating', 'elessi-theme'), 'date' => __('Latest', 'elessi-theme'), 'price' => __('Price: Ascending', 'elessi-theme'), 'price-desc' => __('Price: Descending', 'elessi-theme'), ); } endif; /** * Get Root term_id */ if (!function_exists('elessi_get_root_term_id')) : function elessi_get_root_term_id() { return function_exists('nasa_root_term_id') ? nasa_root_term_id() : false; } endif; /** * Hook Before render shop */ add_action('nasa_before_render_shop', 'elessi_override_options_shop'); if (!function_exists('elessi_override_options_shop')) : function elessi_override_options_shop() { global $nasa_opt; $mobile_app = (isset($nasa_opt['nasa_in_mobile']) && $nasa_opt['nasa_in_mobile'] && isset($nasa_opt['mobile_layout']) && $nasa_opt['mobile_layout'] == 'app') ? true : false; /** * Override for Root Category */ $root_cat_id = !$mobile_app ? elessi_get_root_term_id() : false; if ($root_cat_id) { /* Override cat side-bar layout */ $cat_sidebar_style = get_term_meta($root_cat_id, 'cat_sidebar_layout', true); if ($cat_sidebar_style != '') { $nasa_opt['category_sidebar'] = $cat_sidebar_style; } /** * Product Type view */ $cat_type_view = get_term_meta($root_cat_id, 'cat_type_view', true); if ($cat_type_view != '') { $nasa_opt['products_type_view'] = $cat_type_view; } /** * Change Shop Layout Mode */ $cat_change_shop_layout = get_term_meta($root_cat_id, 'cat_change_shop_layout', true); if ($cat_change_shop_layout != '') { $nasa_opt['option_change_shop_layout'] = $cat_change_shop_layout; } /** * Product Column Icon Style */ $cat_change_layout_type = get_term_meta($root_cat_id, 'cat_change_layout_type', true); if ($cat_change_layout_type != '') { $nasa_opt['nasa_change_layout_view'] = $cat_change_layout_type; } /** * Product Change View mode */ $cat_change_view = get_term_meta($root_cat_id, 'cat_change_view', true); if ($cat_change_view != '') { $nasa_opt['enable_change_view'] = $cat_change_view == -1 ? false : '1'; } /** * Product Option Column Select To Display */ $cat_multicheck_options_cols_display = get_term_meta($root_cat_id, 'cat_multicheck_options_cols_display', true); if (!empty($cat_multicheck_options_cols_display)) { $nasa_opt['multicheck_options_cols_display'] = $cat_multicheck_options_cols_display; } /** * Product Per row */ $cat_per_row = get_term_meta($root_cat_id, 'cat_per_row', true); if ($cat_per_row != '') { $nasa_opt['products_per_row'] = $cat_per_row; } /** * Product Per row Medium */ $cat_per_row_medium = get_term_meta($root_cat_id, 'cat_per_row_medium', true); if ($cat_per_row_medium != '') { $nasa_opt['products_per_row_tablet'] = $cat_per_row_medium; } /** * Product Per row Small */ $cat_per_row_small = get_term_meta($root_cat_id, 'cat_per_row_small', true); if ($cat_per_row_small != '') { $nasa_opt['products_per_row_small'] = $cat_per_row_small; } /** * Products layout_style */ $cat_layout_style = get_term_meta($root_cat_id, 'cat_layout_style', true); if ($cat_layout_style != '') { $nasa_opt['products_layout_style'] = $cat_layout_style; } /** * Products masonry_mode */ $cat_masonry_mode = get_term_meta($root_cat_id, 'cat_masonry_mode', true); if ($cat_masonry_mode != '') { $nasa_opt['products_masonry_mode'] = $cat_masonry_mode; } /** * Products Recommended Columns */ $cat_recommend_columns = get_term_meta($root_cat_id, 'cat_recommend_columns', true); if ($cat_recommend_columns != '') { $nasa_opt['recommend_columns_desk'] = $cat_recommend_columns; } /** * Products Recommend Columns Medium */ $cat_recommend_columns_medium = get_term_meta($root_cat_id, 'cat_recommend_columns_medium', true); if ($cat_recommend_columns_medium != '') { $nasa_opt['recommend_columns_tablet'] = $cat_recommend_columns_medium; } /** * Products Recommended Columns Small */ $cat_recommend_columns_small = get_term_meta($root_cat_id, 'cat_recommend_columns_small', true); if ($cat_recommend_columns_small != '') { $nasa_opt['recommend_columns_small'] = $cat_recommend_columns_small; } } if ($mobile_app) { $nasa_opt['category_sidebar'] = 'top'; } $GLOBALS['nasa_opt'] = $nasa_opt; } endif; /** * Hook Before render shop */ add_action('nasa_before_render_single_product', 'elessi_override_options_single_product'); if (!function_exists('elessi_override_options_single_product')) : function elessi_override_options_single_product() { global $nasa_opt; /** * Override for Root Category */ $root_cat_id = elessi_get_root_term_id(); if ($root_cat_id) { /** * Products Relate Columns */ $cat_relate_columns = get_term_meta($root_cat_id, 'cat_relate_columns', true); if ($cat_relate_columns != '') { $nasa_opt['relate_columns_desk'] = $cat_relate_columns; } /** * Products Relate Columns Medium */ $cat_relate_columns_medium = get_term_meta($root_cat_id, 'cat_relate_columns_medium', true); if ($cat_relate_columns_medium != '') { $nasa_opt['relate_columns_tablet'] = $cat_relate_columns_medium; } /** * Products Relate Columns Small */ $cat_relate_columns_small = get_term_meta($root_cat_id, 'cat_relate_columns_small', true); if ($cat_relate_columns_small != '') { $nasa_opt['relate_columns_small'] = $cat_relate_columns_small; } } $GLOBALS['nasa_opt'] = $nasa_opt; } endif; /** * Add sku to product search */ add_action('pre_get_posts', 'elessi_pre_get_posts_sku'); if (!function_exists('elessi_pre_get_posts_sku')) : function elessi_pre_get_posts_sku($query) { global $nasa_opt; // conditions - change the post type clause if you're not searching woocommerce or 'product' post type if ( NASA_CORE_IN_ADMIN || !isset($nasa_opt['sp_search_sku']) || !$nasa_opt['sp_search_sku'] || !$query->is_main_query() || !$query->is_search() || 'product' != get_query_var('post_type') ){ return; } add_filter('posts_join', 'elessi_sku_search_join'); add_filter('posts_where', 'elessi_sku_search_where'); add_filter('posts_groupby', 'elessi_sku_search_groupby'); } endif; /** * Filter JOIN with _sku */ if (!function_exists('elessi_sku_search_join')) : function elessi_sku_search_join($join) { global $wpdb; // change to your meta key if not woo $join .= ' LEFT JOIN ' . $wpdb->postmeta . ' nspm ON (' . $wpdb->posts . '.ID = nspm.post_id AND nspm.meta_key="_sku")'; return $join; } endif; /** * Filter WHERE with _sku */ if (!function_exists('elessi_sku_search_where')) : function elessi_sku_search_where($where) { global $wpdb; return preg_replace( "/\(\s*{$wpdb->posts}.post_title\s+LIKE\s*(\'[^\']+\')\s*\)/", '(' . $wpdb->posts . '.post_title LIKE $1) OR (nspm.meta_value LIKE $1)', $where ); } endif; /** * Filter GROUP BY id with _sku */ if (!function_exists('elessi_sku_search_groupby')) : function elessi_sku_search_groupby($groupby) { global $wpdb; $nsgroupby = $wpdb->posts . '.ID'; if (preg_match("/$nsgroupby/", $groupby)) { // grouping we need is already there return $groupby; } if (!strlen(trim($groupby))) { // groupby was empty, use ours return $nsgroupby; } // wasn't empty, append ours return $groupby . ', ' . $nsgroupby; } endif; /** * Cart Total Coupons - Label */ add_filter('woocommerce_cart_totals_coupon_label', 'elessi_cart_totals_coupon_label'); if (!function_exists('elessi_cart_totals_coupon_label')) : function elessi_cart_totals_coupon_label($label) { return esc_html__('Coupon', 'elessi-theme'); } endif; /** * Cart Total Coupons - HTML */ add_filter('woocommerce_cart_totals_coupon_html', 'elessi_cart_totals_coupon_html', 10, 3); if (!function_exists('elessi_cart_totals_coupon_html')) : function elessi_cart_totals_coupon_html($coupon_html, $coupon, $discount_amount_html) { $code = $coupon->get_code(); $href = add_query_arg('remove_coupon', rawurlencode($code), defined('WOOCOMMERCE_CHECKOUT') ? wc_get_checkout_url() : wc_get_cart_url()); $coupon_html = '' . '' . '' . $code . '' . $discount_amount_html . ''; return $coupon_html; } endif; /** * get List Coupons - Publish */ if (!function_exists('elessi_wc_publish_coupons')) : function elessi_wc_publish_coupons() { global $nasa_opt; $coupons = array(); if (isset($nasa_opt['mini_cart_p_coupon']) && $nasa_opt['mini_cart_p_coupon']) { $coupons_fetch = explode("\n", $nasa_opt['mini_cart_p_coupon']); if (!empty($coupons_fetch)) { foreach ($coupons_fetch as $coupon) { $code = trim($coupon); $coupon_obj = new WC_Coupon($code); if ($coupon_obj instanceof WC_Coupon && $coupon_obj->get_id()) { $coupons[] = $coupon_obj; } } } } return $coupons; } endif; /** * Comment media img Template */ add_filter('woocommerce_product_review_comment_form_args', 'elessi_comment_media_upload', 9999); if (!function_exists('elessi_comment_media_upload')) : function elessi_comment_media_upload($comment_form) { global $nasa_opt; if (!isset($nasa_opt['comment_media']) || !$nasa_opt['comment_media'] || !isset($comment_form['comment_field'])) { return $comment_form; } $svg_alert = ''; $cam_img = ''; $plus_svg = ''; $max_size = isset($nasa_opt['maxsize_comment_media']) && (int) $nasa_opt['maxsize_comment_media'] ? (int) $nasa_opt['maxsize_comment_media'] : 1024; $max_files = isset($nasa_opt['maxfiles_comment_media']) && (int) $nasa_opt['maxfiles_comment_media'] ? (int) $nasa_opt['maxfiles_comment_media'] : 3; $label = sprintf(esc_html__('Maximum file size is %s kB, max %s files', 'elessi-theme'), $max_size, $max_files); $label2 = '' . $cam_img . '' . '' . esc_html__('Upload photos', 'elessi-theme') . ' (0/' . $max_files .')' . '' . $svg_alert . $label . ''; $media_html = '

' . '' . '' . ' ' . '

'; if (!NASA_CORE_USER_LOGGED) { $comment_form['fields']['nasa-comment-media-video'] = $media_html; } else { $comment_form['comment_field'] .= $media_html; } return $comment_form; } endif; /** * Comment media video Template */ add_filter('woocommerce_product_review_comment_form_args', 'elessi_comment_media_upload_video', 9999); if (!function_exists('elessi_comment_media_upload_video')) : function elessi_comment_media_upload_video($comment_form) { global $nasa_opt; if (!isset($nasa_opt['comment_media_video']) || !$nasa_opt['comment_media_video'] || !isset($comment_form['comment_field'])) { return $comment_form; } $svg_alert = ''; $cam_img = ''; $plus_svg = ''; $max_size = isset($nasa_opt['maxsize_comment_media_video']) && (int) $nasa_opt['maxsize_comment_media_video'] ? (int) $nasa_opt['maxsize_comment_media_video'] : 1024; $max_files = isset($nasa_opt['maxfiles_comment_media_video']) && (int) $nasa_opt['maxfiles_comment_media_video'] ? (int) $nasa_opt['maxfiles_comment_media_video'] : 1; $label = sprintf(_n('Maximum file size is %s kB, max %s file', 'Maximum file size is %s kB, max %s files', $max_files, 'elessi-theme'), $max_size,$max_files); $label2 = '' . $cam_img . '' . '' . sprintf(_n('Upload video', 'Upload videos', $max_files, 'elessi-theme')) . ' (0/' . $max_files . ')' . '' . $svg_alert . $label . ''; // video input $media_html = '

' . '' . '' . '' . '

'; if (!NASA_CORE_USER_LOGGED) { $comment_form['fields']['nasa-comment-media'] = $media_html; } else { $comment_form['comment_field'] .= $media_html; } return $comment_form; } endif; /** * Process comment media */ add_filter('preprocess_comment', 'elessi_preprocess_review_media', 10); if (!function_exists('elessi_preprocess_review_media')) : function elessi_preprocess_review_media($commentdata) { global $nasa_opt; $files_img = isset($_FILES['ns_image_upload']) && !empty($_FILES['ns_image_upload']) ? $_FILES['ns_image_upload'] : array(); $files_video = isset($_FILES['ns_video_upload']) && !empty($_FILES['ns_video_upload']) ? $_FILES['ns_video_upload'] : array(); if (empty($files_img) && empty($files_video)) { return $commentdata; } if (isset($nasa_opt['comment_media']) && $nasa_opt['comment_media'] && !empty($files_img)) { $max_size = isset($nasa_opt['maxsize_comment_media']) && (int) $nasa_opt['maxsize_comment_media'] ? (int) $nasa_opt['maxsize_comment_media'] : 1024; $max_files = isset($nasa_opt['maxfiles_comment_media']) && (int) $nasa_opt['maxfiles_comment_media'] ? (int) $nasa_opt['maxfiles_comment_media'] : 3; /** * Allow maxfiles upload */ if (isset($files_img['name']) && count($files_img['name']) > $max_files) { $mess = '' . esc_html__('Error: ', 'elessi-theme') . '' . sprintf(esc_html__('Maximum number of image files allowed is: %s file(s)', 'elessi-theme'), $max_files); wp_die($mess); } /** * Allow maxsize upload */ if (isset($files_img['size']) && !empty($files_img['size'])) { foreach ($files_img['size'] as $k => $size) { if (!$size) { if (isset($files_img['name'][$k])) { unset($files_img['name'][$k]); } if (isset($files_img['type'][$k])) { unset($files_img['type'][$k]); } if (isset($files_img['size'][$k])) { unset($files_img['size'][$k]); } continue; } if ($size > ($max_size * 1024)) { $mess = '' . esc_html__('Error: ', 'elessi-theme') . '' . sprintf(esc_html__('Max image size allowed: %s kB', 'elessi-theme'), $max_size); wp_die($mess); } } } /** * Allow Types upload */ if (isset($files_img['type']) && !empty($files_img['type'])) { foreach ($files_img['type'] as $type) { $type_file = strtolower($type); if (!in_array($type_file, array("image/jpg", "image/jpeg", "image/bmp", "image/png", "image/gif" ))) { wp_die(esc_html__('Only format image accepted: JPG, JPEG, BMP, PNG, GIF', 'elessi-theme')); } } } } if (isset($nasa_opt['comment_media_video']) && $nasa_opt['comment_media_video'] && !empty($files_video)) { $max_size = isset($nasa_opt['maxsize_comment_media_video']) && (int) $nasa_opt['maxsize_comment_media_video'] ? (int) $nasa_opt['maxsize_comment_media_video'] : 1024; $max_files = isset($nasa_opt['maxfiles_comment_media_video']) && (int) $nasa_opt['maxfiles_comment_media_video'] ? (int) $nasa_opt['maxfiles_comment_media_video'] : 1; /** * Allow maxfiles upload */ if (isset($files_video['name']) && count($files_video['name']) > $max_files) { $mess = '' . esc_html__('Error: ', 'elessi-theme') . '' . sprintf(esc_html__('Maximum number of video files allowed is: %s file(s)', 'elessi-theme'), $max_files); wp_die($mess); } /** * Allow maxsize upload */ if (isset($files_video['size']) && !empty($files_video['size'])) { foreach ($files_video['size'] as $k => $size) { if (!$size) { if (isset($files_video['name'][$k])) { unset($files_video['name'][$k]); } if (isset($files_video['type'][$k])) { unset($files_video['type'][$k]); } if (isset($files_video['size'][$k])) { unset($files_video['size'][$k]); } continue; } if ($size > ($max_size * 1024)) { $mess = '' . esc_html__('Error: ', 'elessi-theme') . '' . sprintf(esc_html__('Max video size allowed: %s kB', 'elessi-theme'), $max_size); wp_die($mess); } } } /** * Allow Types upload */ if (isset($files_video['type']) && !empty($files_video['type'])) { foreach ($files_video['type'] as $type) { $type_file = strtolower($type); if (!in_array($type_file, array("video/mp4", "video/avi", "video/mpeg", "video/mov" ))) { wp_die(esc_html__('Only format video accepted: MP4, AVI, MPEG, MOV', 'elessi-theme')); } } } } /** * Allow upload images */ add_action('comment_post', 'elessi_add_review_media', 10, 1); return $commentdata; } endif; /** * Add Review images */ if (!function_exists('elessi_add_review_media')) : function elessi_add_review_media($comment_id) { $comment = get_comment($comment_id); $post_id = isset($comment->comment_post_ID) ? $comment->comment_post_ID : null; $files_img = $_FILES["ns_image_upload"]; $files_video = $_FILES["ns_video_upload"]; $files = array(); if (!empty($files_img) && !empty($files_video)) { foreach ($files_img as $key => $value) { $files[$key] = array_merge($files_img[$key], $files_video[$key]); } } else { $files = !empty($files_img) ? $files_img : $files_video; } $media_id = array(); if (!empty($files['name'])) { require_once ABSPATH . 'wp-admin/includes/image.php'; require_once ABSPATH . 'wp-admin/includes/file.php'; require_once ABSPATH . 'wp-admin/includes/media.php'; add_filter('intermediate_image_sizes_advanced', 'elessi_comment_img_sizes'); add_filter('big_image_size_threshold', '__return_false'); foreach ($files['name'] as $key => $value) { if ($files['size'][$key]) { $file = array( 'name' => apply_filters('nasa_photo_reviews_image_file_name', $value, $comment_id, $post_id), 'type' => $files['type'][$key], 'tmp_name' => $files['tmp_name'][$key], 'error' => $files['error'][$key], 'size' => $files['size'][$key] ); $_FILES["upload_file"] = $file; $attachment_id = media_handle_upload("upload_file", $post_id); if (is_wp_error($attachment_id)) { wp_die($attachment_id->get_error_message()); } else { $media_id[] = $attachment_id; } } } remove_filter('intermediate_image_sizes_advanced', 'elessi_comment_img_sizes'); } if (!empty($media_id)) { update_comment_meta($comment_id, 'nasa_review_images', $media_id); } } endif; if (!function_exists('get_latest_reviews_attachment_ids_with_images')) : function get_latest_reviews_attachment_ids_with_images($product_id, $limit = 5) { $attachment_ids= []; $k = 0; $args = array( 'post_id' => $product_id, // 'number' => $limit, 'status' => 'approve', 'meta_query' => array( array( 'key' => 'nasa_review_images', 'compare' => 'EXISTS' ), ), 'orderby' => 'comment_date', 'order' => 'DESC', ); $comments = get_comments($args); if (!empty($comments)) { foreach ($comments as $comment) { $review_images = get_comment_meta($comment->comment_ID, 'nasa_review_images', true); if (!empty($review_images) && is_array($review_images)) { foreach ($review_images as $attachment_id) { $k++; if (count($attachment_ids) < 5) { $attachment_ids[] = $attachment_id; } } } } } return ['attachment_ids' => $attachment_ids, 'count' => $k]; } endif; /** * Image size upload for Images review product */ if (!function_exists('elessi_comment_img_sizes')) : function elessi_comment_img_sizes($sizes) { if (isset($sizes['thumbnail'])) { return array('thumbnail' => $sizes['thumbnail']); } return $sizes; } endif; /** * Show Review images */ add_action('woocommerce_review_before', 'elessi_review_images', 10, 1); if (!function_exists('elessi_review_images')) : function elessi_review_images($comment) { global $nasa_opt; if (!isset($nasa_opt['comment_media']) || !$nasa_opt['comment_media']) { return; } $file = ELESSI_CHILD_PATH . '/includes/nasa-review-images.php'; include is_file($file) ? $file : ELESSI_THEME_PATH . '/includes/nasa-review-images.php'; } endif; // add_action('woocommerce_review_after_comment_text', 'elessi_review_helpful', 10, 1); add_action('woocommerce_review_before', 'elessi_review_helpful', 10, 1); if (!function_exists('elessi_review_helpful')) : function elessi_review_helpful($comment) { global $nasa_opt; if (!isset($nasa_opt['ns_comment_helpful']) || !$nasa_opt['ns_comment_helpful']) { return; } $file = ELESSI_CHILD_PATH . '/includes/nasa-review-helpful.php'; include is_file($file) ? $file : ELESSI_THEME_PATH . '/includes/nasa-review-helpful.php'; } endif; /** * Add Svg Account Dashboard Square */ if (!function_exists('elessi_add_svg_images')) : function elessi_add_svg_images($endpoint) { $svg = ''; switch ($endpoint) { case 'orders': $svg = ''; break; case 'downloads': $svg = ' '; break; case 'edit-address': $svg = ' '; break; case 'edit-account': $svg = ' '; break; case 'customer-logout': $svg = ' '; break; case '1': default: $svg = ' '; break; } return $svg; } endif; /** * Add Svg into post mesg */ add_filter('wp_kses_allowed_html', 'elessi_wp_kses_allowed_html_svg', 10, 2); if (!function_exists('elessi_wp_kses_allowed_html_svg')) : function elessi_wp_kses_allowed_html_svg($allowedposttags, $context) { if ($context === 'post') { $allowedposttags['svg'] = array( 'xmlns' => true, 'viewbox' => true, 'width' => true, 'height' => true, ); $allowedposttags['path'] = array( 'd' => true, 'fill' => true, ); } return $allowedposttags; } endif; /** * Ajax return json for Submit Review */ add_filter('comment_post_redirect', 'elessi_comment_post_redirect', 10, 2); if (!function_exists('elessi_comment_post_redirect')) : function elessi_comment_post_redirect($location, $comment) { /** * No change with Customer Reviews for WooCommerce plugin */ if (function_exists('cusrev_init') || $comment->comment_type !== 'review') { return $location; } $location = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : preg_replace('/comment-page-\d+.*$/', '', $location); $parsed_url = parse_url($location); $query_params = array(); parse_str($parsed_url['query'] ?? '', $query_params); $query_params['review_sort'] = 'date_DESC'; $parsed_url['query'] = http_build_query($query_params); $location = $parsed_url['scheme'] . '://' . $parsed_url['host'] . $parsed_url['path'] . '?' . $parsed_url['query']; $html = file_get_contents($location); $response = array( 'code' => 'success', 'html' => $html, 'comment_id' => '#li-comment-' . $comment->comment_ID, 'message' => esc_html__('Your review has been submitted', 'elessi-theme'), ); header('Content-Type: application/json'); echo json_encode($response); exit; } endif; add_filter('comment_class', 'elessi_add_custom_class_to_review', 10, 5); if (!function_exists('elessi_add_custom_class_to_review')) : function elessi_add_custom_class_to_review($classes, $css_class, $comment_ID, $comment, $post) { if (get_post_type($post) == 'product') { $classes[] = 'ns-product-review'; } return $classes; } endif; add_action('woocommerce_review_before', 'elessi_review_confetti', 10, 1); if (!function_exists('elessi_review_confetti')) : function elessi_review_confetti() { global $nasa_opt; $theme_version = isset($nasa_opt['js_theme_version']) && $nasa_opt['js_theme_version'] ? apply_filters('nasa_version_assets', NASA_VERSION) : null; wp_enqueue_script('jquery-confetti', ELESSI_THEME_URI . '/assets/js/min/jquery.confetti.min.js', array('jquery'), $theme_version, true); } endif;