'',
'label' => esc_html__('-- Choose One --','bigc')
);
$args= array(
'post_type' => 'page',
'posts_per_page' => -1,
);
$query = new WP_Query($args);
if($query->have_posts()): while ($query->have_posts()):$query->the_post();
if (strpos($post->post_content, '[sv_logo') || strpos($post->post_content, '[sv_menu')) {
$page_list[] = array(
'value' => $post->ID,
'label' => $post->post_title
);
}
endwhile;
endif;
wp_reset_postdata();
return $page_list;
}
}
//Get list sidebar
if(!function_exists('sv_get_sidebar_ids'))
{
function sv_get_sidebar_ids($for_optiontree=false)
{
global $wp_registered_sidebars;
$r=array();
$r[]=esc_html__('--Select--','bigc');
if(!empty($wp_registered_sidebars)){
foreach($wp_registered_sidebars as $key=>$value)
{
if($for_optiontree){
$r[]=array(
'value'=>$value['id'],
'label'=>$value['name']
);
}else{
$r[$value['id']]=$value['name'];
}
}
}
return $r;
}
}
//Get order list
if(!function_exists('sv_get_order_list'))
{
function sv_get_order_list($current=false,$extra=array(),$return='array')
{
$default=array(
'none'=>esc_html__('None','bigc'),
'ID'=>esc_html__('Post ID','bigc'),
'author'=>esc_html__('Author','bigc'),
'title'=>esc_html__('Post Title','bigc'),
'name'=>esc_html__('Post Name','bigc'),
'date'=>esc_html__('Post Date','bigc'),
'modified'=>esc_html__('Last Modified Date','bigc'),
'parent'=>esc_html__('Post Parent','bigc'),
'rand'=>esc_html__('Random','bigc'),
'comment_count'=>esc_html__('Comment Count','bigc'),
);
if(!empty($extra) and is_array($extra))
{
$default=array_merge($default,$extra);
}
if($return=="array")
{
return $default;
}elseif($return=='option')
{
$html='';
if(!empty($default)){
foreach($default as $key=>$value){
$selected=selected($key,$current,false);
$html.="";
}
}
return $html;
}
}
}
// Get sidebar
if(!function_exists('sv_get_sidebar'))
{
function sv_get_sidebar()
{
$default=array(
'position'=>'right',
'id' =>'blog-sidebar'
);
return apply_filters('sv_get_sidebar',$default);
}
}
//Favicon
if(!function_exists('sv_load_favicon'))
{
add_action( 'wp_head','sv_load_favicon');
add_action('login_head', 'sv_load_favicon');
add_action('admin_head', 'sv_load_favicon');
function sv_load_favicon()
{
$value = sv_get_option('favicon');
$favicon = (isset($value) && !empty($value))?$value:false;
if($favicon)
echo '' . "\n";
}
}
//Fill css background
if(!function_exists('sv_fill_css_background'))
{
function sv_fill_css_background($data)
{
$string = '';
if(!empty($data['background-color'])) $string .= 'background-color:'.$data['background-color'].';'."\n";
if(!empty($data['background-repeat'])) $string .= 'background-repeat:'.$data['background-repeat'].';'."\n";
if(!empty($data['background-attachment'])) $string .= 'background-attachment:'.$data['background-attachment'].';'."\n";
if(!empty($data['background-position'])) $string .= 'background-position:'.$data['background-position'].';'."\n";
if(!empty($data['background-size'])) $string .= 'background-size:'.$data['background-size'].';'."\n";
if(!empty($data['background-image'])) $string .= 'background-image:url("'.$data['background-image'].'");'."\n";
if(!empty($string)) return SV_Assets::build_css($string);
else return false;
}
}
// Get list menu
if(!function_exists('sv_list_menu_name'))
{
function sv_list_menu_name()
{
$menu_nav = wp_get_nav_menus();
$menu_list = array('Default' => '');
if(is_array($menu_nav) && !empty($menu_nav))
{
foreach($menu_nav as $item)
{
if(is_object($item))
{
$menu_list[$item->name] = $item->slug;
}
}
}
return $menu_list;
}
}
//Display BreadCrumb
if(!function_exists('sv_display_breadcrumb'))
{
function sv_display_breadcrumb()
{
$breadcrumb = sv_get_value_by_id('sv_show_breadrumb','on');
$breadcrumb_style = sv_get_value_by_id('sv_breadrumb_style');
if(empty($breadcrumb)) $breadcrumb = 'on';
if($breadcrumb == 'on'){
$b_class = sv_fill_css_background(sv_get_option('sv_bg_breadcrumb'));
?>
';
echo esc_html__('Home','bigc');
echo ''.' ';
if(is_home() && !is_front_page()){
echo ''.esc_html__('Blog','bigc').'';
}
if (is_category() || is_single()) {
the_category(' ');
if (is_single()) {
echo ' ';
the_title();
echo '';
}
} elseif (is_page()) {
if($post->post_parent){
$anc = get_post_ancestors( get_the_ID() );
$title = get_the_title();
foreach ( $anc as $ancestor ) {
$output = ''.get_the_title($ancestor).' ';
}
echo balanceTags($output);
echo ' '.$title.'';
} else {
echo ' '.get_the_title().'';
}
}
}
elseif (is_tag()) {single_tag_title();}
elseif (is_day()) {echo"".esc_html_e("Archive for ","bigc"); the_time(get_option( 'date_format' )); echo'';}
elseif (is_month()) {echo"".esc_html_e("Archive for ","bigc"); the_time('F, Y'); echo'';}
elseif (is_year()) {echo"".esc_html_e("Archive for ","bigc"); the_time($year); echo'';}
elseif (is_author()) {echo"".esc_html_e("Author Archive ","bigc"); echo'';}
elseif (isset($_GET['paged']) && !empty($_GET['paged'])) {echo "".esc_html_e("Blog Archives","bigc"); echo'';}
elseif (is_search()) {echo"".esc_html_e("Search Results","bigc"); echo'';}
}
}
//Get page value by ID
if(!function_exists('sv_get_value_by_id'))
{
function sv_get_value_by_id($key)
{
if(!empty($key)){
$id = get_the_ID();
if(is_front_page() && is_home()) $id = (int)get_option( 'page_on_front' );
if(!is_front_page() && is_home()) $id = (int)get_option( 'page_for_posts' );
$value = get_post_meta($id,$key,true);
if(empty($value)) $value = sv_get_option($key);
return $value;
}
else return 'Missing a variable of this funtion';
}
}
//Check woocommerce page
if (!function_exists('sv_is_woocommerce_page')) {
function sv_is_woocommerce_page() {
if( function_exists ( "is_woocommerce" ) && is_woocommerce()){
return true;
}
$woocommerce_keys = array ( "woocommerce_shop_page_id" ,
"woocommerce_terms_page_id" ,
"woocommerce_cart_page_id" ,
"woocommerce_checkout_page_id" ,
"woocommerce_pay_page_id" ,
"woocommerce_thanks_page_id" ,
"woocommerce_myaccount_page_id" ,
"woocommerce_edit_address_page_id" ,
"woocommerce_view_order_page_id" ,
"woocommerce_change_password_page_id" ,
"woocommerce_logout_page_id" ,
"woocommerce_lost_password_page_id" ) ;
foreach ( $woocommerce_keys as $wc_page_id ) {
if ( get_the_ID () == get_option ( $wc_page_id , 0 ) ) {
return true ;
}
}
if(function_exists('is_woocommerce')){
if(is_woocommerce()) return true;
}
return false;
}
}
//navigation
if(!function_exists('sv_paging_nav'))
{
function sv_paging_nav()
{
// Don't print empty markup if there's only one page.
if ( $GLOBALS['wp_query']->max_num_pages < 2 ) {
return;
}
$paged = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1;
$pagenum_link = html_entity_decode( get_pagenum_link() );
$query_args = array();
$url_parts = explode( '?', $pagenum_link );
if ( isset( $url_parts[1] ) ) {
wp_parse_str( $url_parts[1], $query_args );
}
$pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link );
$pagenum_link = trailingslashit( $pagenum_link ) . '%_%';
$format = $GLOBALS['wp_rewrite']->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
$format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit( 'page/%#%', 'paged' ) : '?paged=%#%';
// Set up paginated links.
$links = paginate_links( array(
'base' => $pagenum_link,
'format' => $format,
'total' => $GLOBALS['wp_query']->max_num_pages,
'current' => $paged,
'mid_size' => 1,
'add_args' => array_map( 'urlencode', $query_args ),
'prev_text' => esc_html__( '←', 'bigc' ),
'next_text' => esc_html__( '→', 'bigc' ),
) );
if ($links) : ?>
-
|
1) _e('Comments', 'bigc') ;
else _e('0 Comment', 'bigc') ;
?>
' . join('|', $known) .
')[/ ]+(?[0-9.|a-zA-Z.]*)#';
if (!preg_match_all($pattern, $u_agent, $matches)) {
// we have no matching number just continue
}
// see how many we have
$i = count($matches['browser']);
if ($i != 1) {
//we will have two since we are not using 'other' argument yet
//see if version is before or after the name
if (strripos($u_agent,"Version") < strripos($u_agent,$ub)){
$version= $matches['version'][0];
}
else {
$version= $matches['version'][1];
}
}
else {
$version= $matches['version'][0];
}
// check if we have a number
if ($version==null || $version=="") {$version="?";}
return array(
'userAgent' => $u_agent,
'name' => $bname,
'version' => $version,
'platform' => $platform,
'pattern' => $pattern
);
}
}
//Compare URL
if(!function_exists('sv_compare_url')){
function sv_compare_url($ajax = false){
if(!$ajax){
global $yith_woocompare;
$cp_link = $yith_woocompare->obj->add_product_url( get_the_ID());
}
else{
$compare = new YITH_Woocompare_Frontend();
$cp_link = $compare->add_product_url( get_the_ID());
}
$browser = sv_getBrowser();
if(strpos($browser['name'],'Safari')) $safari = false;
else $safari = true;
if(class_exists('YITH_Woocompare_Frontend') && $safari){
$html = '';
return $html;
}
}
}
if(!function_exists('sv_product_box_hover')){
function sv_product_box_hover($echo = false){
global $product;
$button_html = apply_filters( 'woocommerce_loop_add_to_cart_link',
sprintf( '',
esc_url( $product->add_to_cart_url() ),
esc_attr( $product->id ),
esc_attr( $product->get_sku() ),
esc_attr( isset( $quantity ) ? $quantity : 1 ),
$product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button product-add-cart' : '',
esc_attr( $product->product_type )
),
$product );
$html_wl = '';
if(class_exists('YITH_WCWL_Init')) $html_wl = '';
$html = '';
if($echo) echo balanceTags($html);
else return $html;
}
}
//Product meta link filter
if(!function_exists('sv_product_link_filter')){
function sv_product_link_filter($style=''){
global $product;
$html = '';
$button_html = apply_filters( 'woocommerce_loop_add_to_cart_link',
sprintf( '',
esc_url( $product->add_to_cart_url() ),
esc_attr( $product->id ),
esc_attr( $product->get_sku() ),
esc_attr( isset( $quantity ) ? $quantity : 1 ),
$product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button product-add-cart' : '',
esc_attr( $product->product_type )
),
$product );
$html_wl = '';
if(class_exists('YITH_WCWL_Init')) $html_wl = '';
if($style == 'style2'){
$button_html = apply_filters( 'woocommerce_loop_add_to_cart_link',
sprintf( '%s',
esc_url( $product->add_to_cart_url() ),
esc_attr( $product->id ),
esc_attr( $product->get_sku() ),
esc_attr( isset( $quantity ) ? $quantity : 1 ),
$product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button product-add-cart' : '',
esc_attr( $product->product_type ),
esc_html( $product->add_to_cart_text() )
),
$product );
$html .= '
'.sv_compare_url(true).'
'.$button_html.'
'.$html_wl.'
';
}
else{
$html .= '
'.$button_html.'
'.$html_wl.'
'.sv_compare_url(true).'
';
}
return $html;
}
}
// get list taxonomy
if(!function_exists('sv_list_taxonomy'))
{
function sv_list_taxonomy($taxonomy,$show_all = true)
{
if($show_all) $list = array('--Select--' => '');
else $list = array();
if(!isset($taxonomy) || empty($taxonomy)) $taxonomy = 'category';
$tags = get_terms('product_cat');
if(is_array($tags)){
foreach ($tags as $tag) {
if(is_object($tag)) $list[$tag->name] = $tag->slug;
}
}
return $list;
}
}
//search form
if(!function_exists('sv_search_form')){
function sv_search_form(){ ?>
cart->is_empty() ){
$count_item = 0; $html = '';
$html .= '';
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$count_item++;
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
$product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
$product_quantity = woocommerce_quantity_input( array(
'input_name' => "cart[{$cart_item_key}][qty]",
'input_value' => $cart_item['quantity'],
'max_value' => $_product->backorders_allowed() ? '' : $_product->get_stock_quantity(),
'min_value' => '0'
), $_product, false );
$thumb_html = '';
if(has_post_thumbnail($product_id)) $thumb_html = get_the_post_thumbnail($product_id,array(70,70));
$html .= '-
'.$cart_item['quantity'].'
'.apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key ).'
';
}
$html .= '
';
$html .= '
'.WC()->cart->get_cart_total().'
';
}
else $html .= ''.esc_html__("No product in cart","bigc").'
';
if($echo) echo balanceTags($html);
else return $html;
}
}
//get type url
if(!function_exists('sv_get_type_url')){
function sv_get_type_url($type){
$current_url = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
$current_url = str_replace('&type=grid', '', $current_url);
$current_url = str_replace('?type=grid', '', $current_url);
$current_url = str_replace('&type=list', '', $current_url);
$current_url = str_replace('?type=list', '', $current_url);
if(strpos($current_url,'?') > -1 ){
$current_url .= '&type='.$type;
}
else {
$current_url .= '?type='.$type;
}
return $current_url;
}
}
//get type url
if(!function_exists('sv_link_product')){
function sv_link_product($echo = false, $ajax = false){
$html = '';
if(class_exists('YITH_WCWL_Init')) $html_wl = '';
$html.= '';
if($echo) echo balanceTags($html);
else return $html;
}
}
//check sidebar
if(!function_exists('sv_has_sidebar')){
function sv_has_sidebar(){
$check = false;
$sidebar = sv_get_sidebar();
if($sidebar['position'] != 'no') $check = true;
else return $check;
}
}
//custom header append
if(!function_exists('sv_custom_header_append')){
function sv_custom_header_append(){
$show = sv_get_value_by_id('sv_show_header_append');
$list = sv_get_value_by_id('sv_custom_header_append');
$item = sv_get_value_by_id('sv_show_header_item');
if($show == 'on'):
?>
get_gallery_attachment_ids();
$attachment_ids = array_merge($thumb_id,$attachment_ids);
$ul_block = $bx_block = '';$i = 0;
foreach ( $attachment_ids as $attachment_id ) {
$image_link = wp_get_attachment_url( $attachment_id );
if ( ! $image_link )
continue;
$image_title = esc_attr( get_the_title( $attachment_id ) );
$image_caption = esc_attr( get_post_field( 'post_excerpt', $attachment_id ) );
$image = wp_get_attachment_image( $attachment_id, array(454,454), 0, $attr = array(
'title' => $image_title,
'alt' => $image_title
) );
$ul_block .= ''.$image.'';
$bx_block .= ''.$image.'';
$i++;
}
?>
';
return $html;
}
}
//List Post
if(!function_exists('sv_get_list_post')){
function sv_get_list_post(){
$list = array();
$list[] = array(
'value' => '',
'label' => esc_html__('-- Choose One --','bigc')
);
$args= array(
'post_type' => 'post',
'posts_per_page' => -1,
);
$query = new WP_Query($args);
global $post;
if($query->have_posts()): while ($query->have_posts()):$query->the_post();
$list[] = array(
'value' => $post->ID,
'label' => $post->post_title
);
endwhile;
endif;
wp_reset_postdata();
return $list;
}
}
//List Attribute
if(!function_exists('sv_get_list_attribute')){
function sv_get_list_attribute($current){
$html='';
global $wpdb;
$attribute_taxonomies = $wpdb->get_results( "SELECT * FROM " . $wpdb->prefix . "woocommerce_attribute_taxonomies" );
if(!empty($attribute_taxonomies)){
foreach($attribute_taxonomies as $attr){
$selected=selected($attr->attribute_name,$current,false);
$html.="";
}
}
return $html;
}
}
if(!function_exists('sv_get_rating_html')){
function sv_get_rating_html(){
global $product;
$html = '';
$star = $product->get_average_rating();
$width = $star / 5 * 100;
if($star){
$html = '';
}
return $html;
}
}
if(!function_exists('sv_get_meta_product')){
function sv_get_meta_product($check){
global $product,$post;
$html = '';
$date_pro=strtotime($post->post_date);
$date_now=strtotime('now');
$set_timer = sv_get_option( 'sv_set_time_woo', 30);
$uppsell=($date_now-$date_pro-$set_timer*24*60*60);
$from = $product->regular_price;
$to = $product->price;
$percent = '';
if($from != $to && $from > 0){
$percent = round(($from-$to)/$from*100);
}
if($check == 'yes'){
$html .= '';
if($uppsell<0) $html .= ''.esc_html__('new','bigc').'';
if(!empty($percent)) $html .= '-'.$percent.'%';
$html .= '
';
}
return $html;
}
}
//Don't Show popup
session_start();
if(!isset($_SESSION['dont_show_popup'])) $_SESSION['dont_show_popup'] = false;
add_action( 'wp_ajax_set_dont_show', 'sv_set_dont_show' );
add_action( 'wp_ajax_nopriv_set_dont_show', 'sv_set_dont_show' );
if(!function_exists('sv_set_dont_show')){
function sv_set_dont_show() {
$checked = $_POST['checked'];
if($checked){
session_start();
$_SESSION['dont_show_popup'] = $checked;
}
else{
unset($_SESSION['dont_show_popup']);
session_destroy();
}
}
}
if(!function_exists('sv_product_filter_attr')){
function sv_product_filter_attr($cat = true){
$html = '';
$html .= '';
if($cat){
$html .= '
';
$cats = get_terms('product_cat');
foreach ($cats as $cat) {
if(is_object($cat)) $html .= '- '.$cat->name.'
';
}
$html .= '
';
}
global $wpdb;
if ( 0 === sizeof( WC()->query->layered_nav_product_ids ) ) {
$min = floor( $wpdb->get_var( "
SELECT min(meta_value + 0)
FROM {$wpdb->posts} as posts
LEFT JOIN {$wpdb->postmeta} as postmeta ON posts.ID = postmeta.post_id
WHERE meta_key IN ('" . implode( "','", array_map( 'esc_sql', apply_filters( 'woocommerce_price_filter_meta_keys', array( '_price', '_min_variation_price' ) ) ) ) . "')
AND meta_value != ''
" ) );
$max = ceil( $wpdb->get_var( "
SELECT max(meta_value + 0)
FROM {$wpdb->posts} as posts
LEFT JOIN {$wpdb->postmeta} as postmeta ON posts.ID = postmeta.post_id
WHERE meta_key IN ('" . implode( "','", array_map( 'esc_sql', apply_filters( 'woocommerce_price_filter_meta_keys', array( '_price' ) ) ) ) . "')
" ) );
} else {
$min = floor( $wpdb->get_var( "
SELECT min(meta_value + 0)
FROM {$wpdb->posts} as posts
LEFT JOIN {$wpdb->postmeta} as postmeta ON posts.ID = postmeta.post_id
WHERE meta_key IN ('" . implode( "','", array_map( 'esc_sql', apply_filters( 'woocommerce_price_filter_meta_keys', array( '_price', '_min_variation_price' ) ) ) ) . "')
AND meta_value != ''
AND (
posts.ID IN (" . implode( ',', array_map( 'absint', WC()->query->layered_nav_product_ids ) ) . ")
OR (
posts.post_parent IN (" . implode( ',', array_map( 'absint', WC()->query->layered_nav_product_ids ) ) . ")
AND posts.post_parent != 0
)
)
" ) );
$max = ceil( $wpdb->get_var( "
SELECT max(meta_value + 0)
FROM {$wpdb->posts} as posts
LEFT JOIN {$wpdb->postmeta} as postmeta ON posts.ID = postmeta.post_id
WHERE meta_key IN ('" . implode( "','", array_map( 'esc_sql', apply_filters( 'woocommerce_price_filter_meta_keys', array( '_price' ) ) ) ) . "')
AND (
posts.ID IN (" . implode( ',', array_map( 'absint', WC()->query->layered_nav_product_ids ) ) . ")
OR (
posts.post_parent IN (" . implode( ',', array_map( 'absint', WC()->query->layered_nav_product_ids ) ) . ")
AND posts.post_parent != 0
)
)
" ) );
}
$html .= '
';
global $wpdb;
$attribute_taxonomies = $wpdb->get_results( "SELECT * FROM " . $wpdb->prefix . "woocommerce_attribute_taxonomies" );
if(!empty($attribute_taxonomies)){
foreach($attribute_taxonomies as $attr){
$html .= '
';
$terms = get_terms("pa_".$attr->attribute_name);
if(is_array($terms)){
foreach ($terms as $term) {
if($attr->attribute_name == 'color') $attr_label = '';
else $attr_label = $term->name;
$html .= '- '.$attr_label.'
';
}
}
$html .= '
';
}
}
$html .= '
';
return $html;
}
}
// get list taxonomy
if(!function_exists('sv_list_tag_product'))
{
function sv_list_tag_product()
{
$list = array();
$tags = get_terms('product_tag');
if(is_array($tags)){
foreach ($tags as $tag) {
if(is_object($tag)) $list[$tag->name] = $tag->slug;
}
}
return $list;
}
}
if (!function_exists('sv_add_head_style')) {
function sv_add_head_style($style) {
$content ='';
return $content;
}
}
/***************************************END Theme Function***************************************/