function hocwp_get_current_visitor_location() { $result = array(); $title = __('Unknown location', 'hocwp-theme'); $url = hocwp_get_current_url(); if (is_home()) { $title = __('Viewing index', 'hocwp-theme'); } elseif (is_archive()) { $title = sprintf(__('Viewing %s', 'hocwp-theme'), get_the_archive_title()); } elseif (is_singular()) { $title = sprintf(__('Viewing %s', 'hocwp-theme'), get_the_title()); } elseif (is_search()) { $title = __('Viewing search result', 'hocwp-theme'); } elseif (is_404()) { $title = __('Viewing 404 page not found', 'hocwp-theme'); } $result['object'] = get_queried_object(); $result['url'] = $url; $result['title'] = $title; return $result; }
function hocwp_wc_add_post_type_product_to_search_url() { if (is_search()) { $post_type = hocwp_get_method_value('post_type', 'request'); if ('product' != $post_type) { $url = hocwp_get_current_url(); $url = add_query_arg(array('post_type' => 'product'), $url); wp_redirect($url); exit; } } }