File: /var/www/clients/client125/web350/web/wp-content/themes/basel/inc/functions.php
<?php use XTS\Config;
if ( ! defined('BASEL_THEME_DIR')) exit('No direct script access allowed');
if ( ! function_exists( 'basel_get_post_by_query_autocomplete' ) ) {
/**
* Autocomplete by post.
*
* @since 1.0.0
*/
function basel_get_post_by_query_autocomplete() {
$output = array();
$args = array(
'post_type' => $_POST['value'], // phpcs:ignore
's' => isset( $_POST['params']['term'] ) ? $_POST['params']['term'] : '', // phpcs:ignore
'post_status' => 'publish',
'numberposts' => apply_filters( 'basel_get_numberposts_by_query_autocomplete', 20 ),
'exclude' => isset( $_POST['selected'] ) ? $_POST['selected'] : array(), // phpcs:ignore
);
$posts = get_posts( $args );
if ( count( $posts ) > 0 ) { // phpcs:ignore
foreach ( $posts as $value ) {
$output[] = array(
'id' => $value->ID,
'text' => $value->post_title . ' ID:(' . $value->ID . ')',
);
}
}
echo wp_json_encode( $output );
die();
}
add_action( 'wp_ajax_basel_get_post_by_query_autocomplete', 'basel_get_post_by_query_autocomplete' );
add_action( 'wp_ajax_nopriv_basel_get_post_by_query_autocomplete', 'basel_get_post_by_query_autocomplete' );
}
if ( ! function_exists( 'basel_get_post_by_ids_autocomplete' ) ) {
/**
* Autocomplete by post ids.
*
* @since 1.0.0
*
* @param array $ids Posts ids.
*
* @return array
*/
function basel_get_post_by_ids_autocomplete( $ids ) {
$output = array();
if ( ! $ids ) {
return $output;
}
if ( ! is_array( $ids ) ) {
$ids = array( $ids );
}
foreach ( $ids as $id ) {
$post = get_post( $id );
if ( $post ) {
$output[ $post->ID ] = array(
'name' => $post->post_title . ' ID:(' . $post->ID . ')',
'value' => $post->ID,
);
}
}
return $output;
}
}
if ( ! function_exists( 'basel_gutenberg_show_widgets' ) ) {
/**
* Gutenberg show widgets.
*
* @return array
*/
function basel_gutenberg_show_widgets() {
return array();
}
add_action( 'widget_types_to_hide_from_legacy_widget_block', 'basel_gutenberg_show_widgets', 100 );
}
if ( ! function_exists( 'basel_page_css_files_disable' ) ) {
/**
* Page css files disable.
*
* @param string $description Term description.
* @return string
* @since 1.0.0
*/
function basel_page_css_files_disable( $description ) {
$GLOBALS['basel_page_css_ignore'] = true;
return $description;
}
}
if ( ! function_exists( 'basel_page_css_files_enable' ) ) {
/**
* Page css files enable.
*
* @param string $description Term description.
* @return string
* @since 1.0.0
*/
function basel_page_css_files_enable( $description ) {
unset( $GLOBALS['basel_page_css_ignore'] );
return $description;
}
}
if ( ! function_exists( 'basel_gutenberg_disable_svg' ) ) {
/**
* Gutenberg disable svg.
*/
function basel_gutenberg_disable_svg() {
if ( basel_get_opt( 'disable_gutenberg_css' ) ) {
remove_action( 'wp_enqueue_scripts', 'wp_enqueue_global_styles' );
remove_action( 'wp_body_open', 'wp_global_styles_render_svg_filters' );
}
}
add_action( 'init', 'basel_gutenberg_disable_svg' );
}
if ( ! function_exists( 'basel_remove_jquery_migrate' ) ) {
/**
* Remove JQuery migrate.
*
* @param WP_Scripts $scripts wp script object.
*/
function basel_remove_jquery_migrate( $scripts ) {
if ( ! is_admin() && isset( $scripts->registered['jquery'] ) && basel_get_opt( 'remove_jquery_migrate', false ) ) {
$script = $scripts->registered['jquery'];
if ( $script->deps ) {
$script->deps = array_diff( $script->deps, array( 'jquery-migrate' ) );
}
}
}
add_action( 'wp_default_scripts', 'basel_remove_jquery_migrate' );
}
if ( ! function_exists( 'basel_get_theme_settings_css_files_name_array' ) ) {
/**
* Get css files array.
*
* @return array
*/
function basel_get_theme_settings_css_files_name_array() {
return basel_get_theme_settings_css_files_array( 'name' );
}
}
if ( ! function_exists( 'basel_get_theme_settings_css_files_array' ) ) {
/**
* Get css files array.
*
* @param string $name_format Result name format.
*
* @return array
*/
function basel_get_theme_settings_css_files_array( $name_format = 'title' ) {
$config_styles = basel_get_config( 'css-files' );
$styles_options = array();
foreach ( $config_styles as $key => $styles ) {
foreach ( $styles as $style ) {
if ( isset( $styles_options[ $style['name'] ] ) ) {
continue;
}
$styles_options[ $key ] = array(
'name' => $style['title'],
'value' => $key,
);
if ( 'name' === $name_format ) {
$styles_options[ $key ]['name'] = 'wd-' . $style['name'] . '-css';
}
}
}
asort( $styles_options );
return $styles_options;
}
}
if ( ! function_exists( 'basel_cookie_secure_param' ) ) {
/**
* Cookie secure param.
*
* @since 1.0.0
*/
function basel_cookie_secure_param() {
return apply_filters( 'basel_cookie_secure_param', is_ssl() );
}
}
if ( ! function_exists( 'basel_get_document_title' ) ) {
/**
* Returns document title for the current page.
*
* @since 1.0.0
*
* @return string
*/
function basel_get_document_title() {
$title = wp_get_document_title();
$post_meta = get_post_meta( basel_get_the_ID(), '_yoast_wpseo_title', true );
if ( property_exists( get_queried_object(), 'term_id' ) && function_exists( 'YoastSEO' ) ) {
$taxonomy_helper = YoastSEO()->helpers->taxonomy;
$meta = $taxonomy_helper->get_term_meta( get_queried_object() );
if ( isset( $meta['wpseo_title'] ) && $meta['wpseo_title'] ) {
$title = wpseo_replace_vars( $meta['wpseo_title'], get_queried_object() );
}
} elseif ( $post_meta && function_exists( 'wpseo_replace_vars' ) ) {
$title = wpseo_replace_vars( $post_meta, get_post( basel_get_the_ID() ) );
}
return $title;
}
}
if ( ! function_exists( 'basel_get_taxonomies_by_ids_autocomplete' ) ) {
/**
* Autocomplete by taxonomies ids.
*
* @since 1.0.0
*
* @param array $ids Posts ids.
*
* @return array
*/
function basel_get_taxonomies_by_ids_autocomplete( $ids ) {
$output = array();
if ( ! $ids ) {
return $output;
}
if ( ! is_array( $ids ) ) {
$ids = array( $ids );
}
foreach ( $ids as $id ) {
$term = get_term( $id );
if ( $term ) {
$output[ $term->term_id ] = array(
'name' => $term->name,
'value' => $term->term_id,
);
}
}
return $output;
}
}
if ( ! function_exists( 'basel_get_taxonomies_by_query_autocomplete' ) ) {
/**
* Autocomplete by taxonomies.
*
* @since 1.0.0
*/
function basel_get_taxonomies_by_query_autocomplete() {
$output = array();
$args = array(
'number' => 5,
'taxonomy' => $_POST['value'], // phpcs:ignore
'search' => $_POST['params']['term'], // phpcs:ignore
);
$terms = get_terms( $args );
if ( count( $terms ) > 0 ) { // phpcs:ignore
foreach ( $terms as $term ) {
$output[] = array(
'id' => $term->term_id,
'text' => $term->name,
);
}
}
echo wp_json_encode( $output );
die();
}
add_action( 'wp_ajax_basel_get_taxonomies_by_query_autocomplete', 'basel_get_taxonomies_by_query_autocomplete' );
add_action( 'wp_ajax_nopriv_basel_get_taxonomies_by_query_autocomplete', 'basel_get_taxonomies_by_query_autocomplete' );
}
// **********************************************************************//
// ! Body classes
// **********************************************************************//
if( ! function_exists( 'basel_body_class' ) ) {
function basel_body_class( $classes ) {
$page_id = basel_page_ID();
$site_width = basel_get_opt( 'site_width' );
$cart_design = basel_get_opt( 'shopping_cart' );
$wishlist = basel_get_opt( 'header_wishlist' );
$header = basel_get_opt( 'header' );
$header_overlap_opt = basel_get_opt( 'header-overlap' );
$product_design = basel_product_design();
$top_bar = basel_get_opt( 'top-bar' );
$ajax_shop = basel_get_opt( 'ajax_shop' );
$header_search = basel_get_opt( 'header_search' );
$ajax_search = basel_get_opt( 'search_ajax' );
$catalog_mode = basel_get_opt( 'catalog_mode' );
$categories_toggle = basel_get_opt( 'categories_toggle' );
$header = basel_get_opt( 'header' );
$sticky_footer = basel_get_opt( 'sticky_footer' );
$dark = basel_get_opt( 'dark_version' );
$mobile_menu_position = basel_get_opt( 'mobile_menu_position' );
$hide_sidebar_mobile = basel_get_opt( 'shop_hide_sidebar_mobile' );
$hide_sidebar_tablet = basel_get_opt( 'shop_hide_sidebar_tablet' );
$hide_sidebar_desktop = basel_get_opt( 'shop_hide_sidebar_desktop' );
$main_sidebar_mobile = basel_get_opt( 'hide_main_sidebar_mobile' );
$single_post_design = basel_get_opt( 'single_post_design' );
$header_overlap = $header_sticky = $disable_sticky = false;
$disable = get_post_meta( $page_id, '_basel_title_off', true );
$classes[] = 'wrapper-' . $site_width;
$classes[] = 'global-cart-design-' . $cart_design;
$classes[] = 'global-search-' . $header_search;
$classes[] = 'global-header-' . $header;
$classes[] = 'mobile-nav-from-' . $mobile_menu_position;
if ( $single_post_design == 'large_image' && is_single() ) {
$classes[] = 'single-post-large-image';
}
if( is_singular( 'product') )
$classes[] = 'basel-product-design-' . $product_design;
if ( basel_woocommerce_installed() && ( is_shop() || is_product_category() ) && ( $hide_sidebar_desktop && $sticky_footer ) ) {
$classes[] = 'no-sticky-footer';
}elseif( $sticky_footer ){
$classes[] = 'sticky-footer-on';
}
$classes[] = ( $dark ) ? 'basel-dark' : 'basel-light';
if( $catalog_mode ) {
$classes[] = 'catalog-mode-on';
} else {
$classes[] = 'catalog-mode-off';
}
if( $categories_toggle ) {
$classes[] = 'categories-accordion-on';
} else {
$classes[] = 'categories-accordion-off';
}
if( $wishlist ) {
$classes[] = 'global-wishlist-enable';
} else {
$classes[] = 'global-wishlist-disable';
}
if( $top_bar ) {
$classes[] = 'basel-top-bar-on';
} else {
$classes[] = 'basel-top-bar-off';
}
if( $ajax_shop ) {
$classes[] = 'basel-ajax-shop-on';
} else {
$classes[] = 'basel-ajax-shop-off';
}
if( $ajax_search ) {
$classes[] = 'basel-ajax-search-on';
} else {
$classes[] = 'basel-ajax-search-off';
}
//Header banner
if ( !basel_get_opt( 'header_close_btn' ) && basel_get_opt( 'header_banner' ) && ! basel_maintenance_page() ) {
$classes[] = 'header-banner-display';
}
if ( basel_get_opt( 'header_banner' ) && ! basel_maintenance_page() ) {
$classes[] = 'header-banner-enabled';
}
// Sticky header settings
if( basel_get_opt('sticky_header') ) {
$classes[] = 'enable-sticky-header';
$header_sticky = true;
} else {
$disable_sticky = true;
$classes[] = 'disable-sticky-header';
}
// Force header full width class
if( is_singular( 'product') && basel_get_opt('force_header_full_width') && basel_product_design() == 'sticky' ) {
$classes[] = 'header-full-width';
}
if( basel_get_opt('header_full_width') ) {
$classes[] = 'header-full-width';
}
if( in_array( $header, array('menu-top') ) ) {
$header_sticky = 'real';
$classes[] = 'sticky-navigation-only';
} else if( in_array( $header, array('base', 'simple', 'logo-center', 'categories') ) ) {
$header_sticky = 'clone';
}
// Header overlaps content in the following cases:
// 1. Header type is overlap
// 2. Not on the single product page
// 3. Not shop page and not disabled page title
/*if( $header == 'overlap'
&& ! is_singular( 'product' )
&& ! ( basel_woocommerce_installed()
&& ( is_shop() || is_product_category() || is_product_tag() || is_singular( "product" ) )
&& $disable
)
) {
$header_overlap = true;
$header_sticky = 'real';
} */
// If header type is SHOP and overlap option is enabled
if( $header == 'shop' || $header == 'split' ) {
$header_sticky = 'real';
if( $header_overlap_opt ) {
$header_overlap = true;
}
}
if( $header == 'simple' && $header_overlap_opt ) {
$header_overlap = true;
$header_sticky = 'real';
}
/*if( $header == 'simple' && $header_sticky == 'real' && ! $header_overlap ) {
$classes[] = 'basel-header-smooth';
}*/
if( $header_overlap ) {
$classes[] = 'basel-header-overlap';
}
if( $header_sticky == 'clone' && ! $disable_sticky ) {
$classes[] = 'sticky-header-clone';
} elseif( $header_sticky && ! $disable_sticky ) {
$classes[] = 'sticky-header-real';
}
//Off canvas sidebar
if( ( $hide_sidebar_mobile && ( basel_woocommerce_installed() && ( is_shop() || is_product_category() || is_product_tag() || basel_is_product_attribute_archieve() ) ) ) || ( $main_sidebar_mobile && ( ! basel_woocommerce_installed() || ( ! is_shop() && ! is_product_category() && ! is_product_tag() && ! basel_is_product_attribute_archieve() ) ) ) ) {
$classes[] = 'offcanvas-sidebar-mobile';
}
if( $hide_sidebar_tablet ) {
$classes[] = 'offcanvas-sidebar-tablet';
}
if( $hide_sidebar_desktop ) {
$classes[] = 'offcanvas-sidebar-desktop';
}
if ( ! is_user_logged_in() && basel_get_opt( 'login_prices' ) ) {
$classes[] = 'login-see-prices';
}
if ( basel_get_opt( 'sticky_toolbar' ) ) {
$classes[] = 'sticky-toolbar-on';
}
if ( basel_get_opt( 'hide_larger_price' ) ) {
$classes[] = 'hide-larger-price';
}
if ( basel_get_opt( 'rev_slider_inherit_theme_font' ) ) {
$classes[] = 'inherit-theme-font';
}
return $classes;
}
add_filter('body_class', 'basel_body_class');
}
/**
* ------------------------------------------------------------------------------------------------
* Filter wp_title
* ------------------------------------------------------------------------------------------------
*/
if( ! function_exists( 'basel_wp_title' ) ) {
function basel_wp_title( $title, $sep ) {
global $paged, $page;
if ( is_feed() )
return $title;
// Add the site name.
$title .= get_bloginfo( 'name' );
// Add the site description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
$title = "$title $sep $site_description";
// Add a page number if necessary.
if ( $paged >= 2 || $page >= 2 )
$title = "$title $sep " . sprintf( esc_html__( 'Page %s', 'basel' ), max( $paged, $page ) );
return $title;
}
add_filter( 'wp_title', 'basel_wp_title', 10, 2 );
}
/**
* ------------------------------------------------------------------------------------------------
* Get predefined footer configuration by index
* ------------------------------------------------------------------------------------------------
*/
if( ! function_exists( 'basel_get_footer_config' ) ) {
function basel_get_footer_config( $index ) {
if( $index > 20 || $index < 1) {
$index = 1;
}
$configs = apply_filters( 'basel_footer_configs_array', array(
1 => array(
'cols' => array(
'col-sm-12'
),
),
2 => array(
'cols' => array(
'col-sm-6',
'col-sm-6',
),
),
3 => array(
'cols' => array(
'col-sm-4',
'col-sm-4',
'col-sm-4',
),
),
4 => array(
'cols' => array(
'col-md-3 col-sm-6',
'col-md-3 col-sm-6',
'col-md-3 col-sm-6',
'col-md-3 col-sm-6',
),
'clears' => array(
2 => 'sm'
)
),
5 => array(
'cols' => array(
'col-md-2 col-sm-4',
'col-md-2 col-sm-4',
'col-md-2 col-sm-4',
'col-md-2 col-sm-4',
'col-md-2 col-sm-4',
'col-md-2 col-sm-4',
),
'clears' => array(
3 => 'sm'
)
),
6 => array(
'cols' => array(
'col-md-3 col-sm-4',
'col-md-6 col-sm-4',
'col-md-3 col-sm-4',
),
),
7 => array(
'cols' => array(
'col-md-6 col-sm-4',
'col-md-3 col-sm-4',
'col-md-3 col-sm-4',
),
),
8 => array(
'cols' => array(
'col-md-3 col-sm-4',
'col-md-3 col-sm-4',
'col-md-6 col-sm-4',
),
),
9 => array(
'cols' => array(
'col-md-12 col-sm-12',
'col-md-3 col-sm-6',
'col-md-3 col-sm-6',
'col-md-3 col-sm-6',
'col-md-3 col-sm-6',
),
'clears' => array(
1 => 'md',
1 => 'lg',
3 => 'sm',
),
),
10 => array(
'cols' => array(
'col-md-6 col-sm-12',
'col-md-6 col-sm-12',
'col-md-3 col-sm-6',
'col-md-3 col-sm-6',
'col-md-3 col-sm-6',
'col-md-3 col-sm-6',
),
'clears' => array(
2 => 'md',
2 => 'lg',
4 => 'sm',
),
),
11 => array(
'cols' => array(
'col-md-6 col-sm-12',
'col-md-6 col-sm-12',
'col-md-2 col-sm-6',
'col-md-2 col-sm-6',
'col-md-2 col-sm-6',
'col-md-2 col-sm-6',
'col-md-4 col-sm-12',
),
'clears' => array(
2 => 'md',
2 => 'lg',
4 => 'sm',
),
),
12 => array(
'cols' => array(
'col-md-12 col-sm-12',
'col-md-2 col-sm-6',
'col-md-2 col-sm-6',
'col-md-2 col-sm-6',
'col-md-2 col-sm-6',
'col-md-4 col-sm-12',
),
'clears' => array(
1 => 'md',
1 => 'lg',
3 => 'sm',
),
),
) );
return (isset( $configs[$index] )) ? $configs[$index] : array();
}
}
// **********************************************************************//
// ! Theme 3d plugins
// **********************************************************************//
if(!defined('YITH_REFER_ID')) {
define('YITH_REFER_ID', '1040314');
}
if( ! function_exists( 'basel_3d_plugins' )) {
function basel_3d_plugins() {
if( function_exists( 'set_revslider_as_theme' ) ){
set_revslider_as_theme();
}
}
add_action( 'init', 'basel_3d_plugins' );
}
if( ! function_exists( 'basel_vcSetAsTheme' ) ) {
function basel_vcSetAsTheme() {
if( function_exists( 'vc_set_as_theme' ) ){
vc_set_as_theme();
}
}
add_action( 'vc_before_init', 'basel_vcSetAsTheme' );
}
// **********************************************************************//
// ! Function to get taxonomy meta data
// **********************************************************************//
if( ! function_exists( 'basel_tax_data' ) ) {
function basel_tax_data($taxonomy, $term_id, $meta_key) {
return get_term_meta( $term_id, $meta_key, true);
}
}
// **********************************************************************//
// ! Obtain real page ID (shop page, blog, portfolio or simple page)
// **********************************************************************//
/**
* This function is called once when initializing BASEL_Layout object
* then you can use function basel_page_ID to get current page id
*/
if( ! function_exists( 'basel_get_the_ID' ) ) {
function basel_get_the_ID( $settings = array() ) {
global $post;
$page_id = 0;
$page_for_posts = get_option( 'page_for_posts' );
$page_for_shop = get_option( 'woocommerce_shop_page_id' );
$page_for_projects = basel_tpl2id( 'portfolio.php' );
$custom_404_id = basel_get_opt( 'custom_404_page' );
if ( isset( $post->ID ) ) $page_id = $post->ID;
if ( isset( $post->ID ) && ( is_singular( 'page' ) || is_singular( 'post' ) ) ) {
$page_id = $post->ID;
} else if ( is_home() || is_singular( 'post' ) || is_search() || is_tag() || is_category() || is_date() || is_author() ) {
$page_id = $page_for_posts;
} else if ( is_archive('portfolio') && get_post_type() == 'portfolio' ) {
$page_id = $page_for_projects;
}
if ( basel_woocommerce_installed() && function_exists( 'is_shop' ) ) {
if ( isset( $settings['singulars'] ) && in_array( 'product', $settings['singulars']) && is_singular( 'product' ) ) {
// keep post id
} else if ( is_shop() || is_product_category() || is_product_tag() || is_singular( 'product' ) || basel_is_product_attribute_archieve() ) {
$page_id = $page_for_shop;
}
}
if ( is_404() && ( $custom_404_id != 'default' || ! empty( $custom_404_id ) ) ) $page_id = $custom_404_id;
return $page_id;
}
}
// **********************************************************************//
// ! Function to get HTML block content
// **********************************************************************//
if( ! function_exists( 'basel_get_html_block' ) ) {
function basel_get_html_block($id) {
$post = get_post( $id );
if ( ! $post || $post->post_type != 'cms_block' ) return;
$content = do_shortcode( $post->post_content );
$shortcodes_custom_css = get_post_meta( $id, '_wpb_shortcodes_custom_css', true );
$basel_shortcodes_custom_css = get_post_meta( $id, 'basel_shortcodes_custom_css', true );
$content .= '<style data-type="vc_shortcodes-custom-css">';
if ( ! empty( $basel_shortcodes_custom_css ) ) {
$content .= $basel_shortcodes_custom_css;
}
if ( ! empty( $shortcodes_custom_css ) ) {
$content .= $shortcodes_custom_css;
}
$content .= '</style>';
return $content;
}
}
if( ! function_exists( 'basel_get_static_blocks_array' ) ) {
function basel_get_static_blocks_array( $new = false ) {
$args = array( 'posts_per_page' => 500, 'post_type' => 'cms_block' );
$blocks_posts = get_posts( $args );
$array = array();
foreach ( $blocks_posts as $post ) :
setup_postdata( $post );
if ( $new ) {
$array[ $post->ID ] = array(
'name' => $post->post_title . ' (ID:' . $post->ID . ')',
'value' => $post->ID,
);
} else {
$array[ $post->post_title . ' (ID:' . $post->ID . ')' ] = $post->ID;
}
endforeach;
wp_reset_postdata();
return $array;
}
}
// **********************************************************************//
// ! Support shortcodes in text widget
// **********************************************************************//
add_filter('widget_text', 'do_shortcode');
// **********************************************************************//
// ! Set excerpt length and more btn
// **********************************************************************//
add_filter( 'excerpt_length', 'basel_excerpt_length', 999 );
if( ! function_exists( 'basel_excerpt_length' ) ) {
function basel_excerpt_length( $length ) {
return 20;
}
}
add_filter('excerpt_more', 'basel_new_excerpt_more');
if( ! function_exists( 'basel_new_excerpt_more' ) ) {
function basel_new_excerpt_more( $more ) {
return '';
}
}
// **********************************************************************//
// ! Add scroll to top buttom
// **********************************************************************//
add_action( 'wp_footer', 'basel_scroll_top_btn' );
if( ! function_exists( 'basel_scroll_top_btn' ) ) {
function basel_scroll_top_btn( $more ) {
if( !basel_get_opt( 'scroll_top_btn' ) ) return;
basel_enqueue_inline_style( 'opt-scrolltotop' );
?>
<a href="#" rel="nofollow" class="scrollToTop basel-tooltip"><?php esc_attr_e( 'Scroll To Top', 'basel' ); ?></a>
<?php
}
}
// **********************************************************************//
// ! Return related posts args array
// **********************************************************************//
if( ! function_exists( 'basel_get_related_posts_args' ) ) {
function basel_get_related_posts_args( $post_id ) {
$taxs = wp_get_post_tags( $post_id );
$args = array();
if ( $taxs ) {
$tax_ids = array();
foreach( $taxs as $individual_tax ) $tax_ids[] = $individual_tax->term_id;
$args = array(
'tag__in' => $tax_ids,
'post__not_in' => array( $post_id ),
'posts_per_page' => 12,
'ignore_sticky_posts' => 1
);
}
return $args;
}
}
// **********************************************************************//
// ! Navigation walker
// **********************************************************************//
if( ! class_exists( 'BASEL_Mega_Menu_Walker' )) {
class BASEL_Mega_Menu_Walker extends Walker_Nav_Menu {
private $color_scheme = 'dark';
/**
* Starts the list before the elements are added.
*
* @see Walker::start_lvl()
*
* @since 3.0.0
*
* @param string $output Passed by reference. Used to append additional content.
* @param int $depth Depth of menu item. Used for padding.
* @param array $args An array of arguments. @see wp_nav_menu()
*/
public function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t", $depth);
if( $depth == 0) {
$output .= "\n$indent<div class=\"sub-menu-dropdown color-scheme-" . $this->color_scheme . "\">\n";
$output .= "\n$indent<div class=\"container\">\n";
}
if( $depth < 1 ) {
$sub_menu_class = "sub-menu";
} else {
$sub_menu_class = "sub-sub-menu";
}
$output .= "\n$indent<ul class=\"$sub_menu_class color-scheme-" . $this->color_scheme . "\">\n";
if( $this->color_scheme == 'light') $this->color_scheme = 'dark';
}
/**
* Ends the list of after the elements are added.
*
* @see Walker::end_lvl()
*
* @since 3.0.0
*
* @param string $output Passed by reference. Used to append additional content.
* @param int $depth Depth of menu item. Used for padding.
* @param array $args An array of arguments. @see wp_nav_menu()
*/
public function end_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t", $depth);
$output .= "$indent</ul>\n";
if( $depth == 0) {
$output .= "$indent</div>\n";
$output .= "$indent</div>\n";
}
}
/**
* Start the element output.
*
* @see Walker::start_el()
*
* @since 3.0.0
*
* @param string $output Passed by reference. Used to append additional content.
* @param object $item Menu item data object.
* @param int $depth Depth of menu item. Used for padding.
* @param array $args An array of arguments. @see wp_nav_menu()
* @param int $id Current item ID.
*/
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
$classes[] = 'menu-item-' . $item->ID;
$design = $width = $height = $icon = $label = $label_out = '';
$design = get_post_meta( $item->ID, '_menu_item_design', true );
$width = get_post_meta( $item->ID, '_menu_item_width', true );
$height = get_post_meta( $item->ID, '_menu_item_height', true );
$icon = get_post_meta( $item->ID, '_menu_item_icon', true );
$event = get_post_meta( $item->ID, '_menu_item_event', true );
$label = get_post_meta( $item->ID, '_menu_item_label', true );
$opanchor = get_post_meta( $item->ID, '_menu_item_opanchor', true );
$callbtn = get_post_meta( $item->ID, '_menu_item_callbtn', true );
$color_scheme = get_post_meta( $item->ID, '_menu_item_colorscheme', true );
if( $color_scheme == 'light' ) $this->color_scheme = 'light';
if( empty($design) ) $design = 'default';
$classes[] = 'menu-item-design-' . $design;
$event = (empty($event)) ? 'hover' : $event;
$classes[] = 'item-event-' . $event;
if( $opanchor == 'enable' ) {
$classes[] = 'onepage-link';
if(($key = array_search('current-menu-item', $classes)) !== false) {
unset($classes[$key]);
}
}
if( $callbtn == 'enable' ) {
$classes[] = 'callto-btn';
}
if( !empty( $label ) ) {
$classes[] = 'item-with-label';
$classes[] = 'item-label-' . $label;
$label_text = '';
switch ( $label ) {
case 'hot':
$label_text = esc_html__('Hot', 'basel');
break;
case 'sale':
$label_text = esc_html__('Sale', 'basel');
break;
case 'new':
$label_text = esc_html__('New', 'basel');
break;
}
$label_out = '<span class="menu-label menu-label-' . $label . '">' . esc_attr( $label_text ) . '</span>';
}
if( ! empty( $item->description ) ) {
$classes[] = 'menu-item-has-children';
}
/**
* Filter the CSS class(es) applied to a menu item's list item element.
*
* @since 3.0.0
* @since 4.1.0 The `$depth` parameter was added.
*
* @param array $classes The CSS classes that are applied to the menu item's `<li>` element.
* @param object $item The current menu item.
* @param array $args An array of {@see wp_nav_menu()} arguments.
* @param int $depth Depth of menu item. Used for padding.
*/
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args, $depth ) );
$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
/**
* Filter the ID applied to a menu item's list item element.
*
* @since 3.0.1
* @since 4.1.0 The `$depth` parameter was added.
*
* @param string $menu_id The ID that is applied to the menu item's `<li>` element.
* @param object $item The current menu item.
* @param array $args An array of {@see wp_nav_menu()} arguments.
* @param int $depth Depth of menu item. Used for padding.
*/
$id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args, $depth );
$id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
$output .= $indent . '<li' . $id . $class_names .'>';
$atts = array();
$atts['title'] = ! empty( $item->attr_title ) ? $item->attr_title : '';
$atts['target'] = ! empty( $item->target ) ? $item->target : '';
$atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : '';
$atts['href'] = ! empty( $item->url ) ? $item->url : '';
/**
* Filter the HTML attributes applied to a menu item's anchor element.
*
* @since 3.6.0
* @since 4.1.0 The `$depth` parameter was added.
*
* @param array $atts {
* The HTML attributes applied to the menu item's `<a>` element, empty strings are ignored.
*
* @type string $title Title attribute.
* @type string $target Target attribute.
* @type string $rel The rel attribute.
* @type string $href The href attribute.
* }
* @param object $item The current menu item.
* @param array $args An array of {@see wp_nav_menu()} arguments.
* @param int $depth Depth of menu item. Used for padding.
*/
$atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth );
$attributes = '';
foreach ( $atts as $attr => $value ) {
if ( ! empty( $value ) ) {
$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
$attributes .= ' ' . $attr . '="' . $value . '"';
}
}
$item_output = $args->before;
$item_output .= '<a'. $attributes .'>';
if($icon != '') {
$item_output .= '<i class="fa fa-' . $icon . '"></i>';
}
/** This filter is documented in wp-includes/post-template.php */
$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
$item_output .= $label_out;
$item_output .= '</a>';
$item_output .= $args->after;
$styles = '';
if( $depth == 0) {
/**
* Add background image to dropdown
**/
if( has_post_thumbnail( $item->ID ) ) {
$post_thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $item->ID ), 'full' );
//ar($post_thumbnail);
$styles .= '.menu-item-' . $item->ID . ' > .sub-menu-dropdown {';
$styles .= 'background-image: url(' . $post_thumbnail[0] .'); ';
$styles .= '}';
}
if( ! empty( $item->description ) && !in_array("menu-item-has-children", $item->classes) ) {
$item_output .= "\n$indent<div class=\"sub-menu-dropdown color-scheme-" . $this->color_scheme . "\">\n";
$item_output .= "\n$indent<div class=\"container\">\n";
$item_output .= do_shortcode( $item->description );
$item_output .= "\n$indent</div>\n";
$item_output .= "\n$indent</div>\n";
if( $this->color_scheme == 'light') $this->color_scheme = 'dark';
}
}
if($design == 'sized' && !empty($height) && !empty($width)) {
$styles .= '.menu-item-' . $item->ID . ' > .sub-menu-dropdown {';
$styles .= 'min-height: ' . $height .'px; ';
$styles .= 'width: ' . $width .'px; ';
$styles .= '}';
}
if( $styles != '' ) {
$item_output .= '<style>';
$item_output .= $styles;
$item_output .= '</style>';
}
/**
* Filter a menu item's starting output.
*
* The menu item's starting output only includes `$args->before`, the opening `<a>`,
* the menu item's title, the closing `</a>`, and `$args->after`. Currently, there is
* no filter for modifying the opening and closing `<li>` for a menu item.
*
* @since 3.0.0
*
* @param string $item_output The menu item's starting HTML output.
* @param object $item Menu item data object.
* @param int $depth Depth of menu item. Used for padding.
* @param array $args An array of {@see wp_nav_menu()} arguments.
*/
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
}
}
}
// **********************************************************************//
// ! // Deletes first gallery shortcode and returns content (http://stackoverflow.com/questions/17224100/wordpress-remove-shortcode-and-save-for-use-elsewhere)
// **********************************************************************//
if( ! function_exists( 'basel_strip_shortcode_gallery' ) ) {
function basel_strip_shortcode_gallery( $content ) {
preg_match_all( '/'. get_shortcode_regex() .'/s', $content, $matches, PREG_SET_ORDER );
if ( ! empty( $matches ) ) {
foreach ( $matches as $shortcode ) {
if ( 'gallery' === $shortcode[2] ) {
$pos = strpos( $content, $shortcode[0] );
if ($pos !== false)
return substr_replace( $content, '', $pos, strlen($shortcode[0]) );
}
}
}
return $content;
}
}
// **********************************************************************//
// ! Get exceprt from post content
// **********************************************************************//
if( ! function_exists( 'basel_excerpt_from_content' ) ) {
function basel_excerpt_from_content($post_content, $limit, $shortcodes = '') {
// Strip shortcodes and HTML tags
if ( empty( $shortcodes )) {
$post_content = preg_replace("/\[caption(.*)\[\/caption\]/i", '', $post_content);
$post_content = preg_replace('`\[[^\]]*\]`','',$post_content);
}
$post_content = stripslashes(wp_filter_nohtml_kses($post_content));
$excerpt = explode(' ', $post_content, $limit);
if ( count( $excerpt) >= $limit ) {
array_pop( $excerpt );
$excerpt = implode( " ", $excerpt ) . '...';
} else {
$excerpt = implode( " ", $excerpt );
}
$excerpt = strip_tags( $excerpt );
if (trim($excerpt) == '...') {
return '';
}
return $excerpt;
}
}
// **********************************************************************//
// ! Get portfolio taxonomies dropdown
// **********************************************************************//
if( ! function_exists( 'basel_get_projects_cats_array') ) {
function basel_get_projects_cats_array() {
$return = array('All' => '');
if( ! post_type_exists( 'portfolio' ) ) return array();
$cats = get_terms( 'project-cat' );
foreach ($cats as $key => $cat) {
$return[$cat->name] = $cat->term_id;
}
return $return;
}
}
// **********************************************************************//
// ! Get menus dropdown
// **********************************************************************//
if( ! function_exists( 'basel_get_menus_array') ) {
function basel_get_menus_array($new = false) {
$basel_menus = wp_get_nav_menus();
$basel_menu_dropdown = array();
foreach ( $basel_menus as $menu ) {
if ( $new ) {
$basel_menu_dropdown[$menu->term_id] = array(
'name' => $menu->name,
'value' => $menu->term_id,
);
} else {
$basel_menu_dropdown[$menu->term_id] = $menu->name;
}
}
return $basel_menu_dropdown;
}
}
// **********************************************************************//
// ! Get registered sidebars dropdown
// **********************************************************************//
if(!function_exists('basel_get_sidebars_array')) {
function basel_get_sidebars_array( $new = false ) {
global $wp_registered_sidebars;
$sidebars = array();
if ( $new ) {
$sidebars['none'] = array(
'name' => 'none',
'value' => 'none'
);
} else {
$sidebars['none'] = 'none';
}
foreach( $wp_registered_sidebars as $id=>$sidebar ) {
if ( $new ) {
$sidebars[$id] = array(
'name' => $sidebar[ 'name' ],
'value' => $id
);
} else {
$sidebars[ $id ] = $sidebar[ 'name' ];
}
}
return $sidebars;
}
}
// **********************************************************************//
// ! If page needs header
// **********************************************************************//
if( ! function_exists( 'basel_needs_header' ) ) {
function basel_needs_header() {
return ( ! basel_maintenance_page() );
}
}
// **********************************************************************//
// ! If page needs footer
// **********************************************************************//
if( ! function_exists( 'basel_needs_footer' ) ) {
function basel_needs_footer() {
return ( ! basel_maintenance_page() );
}
}
// **********************************************************************//
// ! Is maintenance page
// **********************************************************************//
if( ! function_exists( 'basel_maintenance_page' ) ) {
function basel_maintenance_page() {
$pages_ids = basel_pages_ids_from_template( 'maintenance' );
if( ! empty( $pages_ids ) && is_page( $pages_ids ) ) {
return true;
}
return false;
}
}
// **********************************************************************//
// ! Get page id by template name
// **********************************************************************//
if( ! function_exists( 'basel_pages_ids_from_template' ) ) {
function basel_pages_ids_from_template( $name ) {
$pages = get_pages(array(
'meta_key' => '_wp_page_template',
'meta_value' => $name . '.php'
));
$return = array();
foreach($pages as $page){
$return[] = $page->ID;
}
return $return;
}
}
// **********************************************************************//
// ! Get content of the SVG icon located in images/svg folder
// **********************************************************************//
if( ! function_exists( 'basel_get_svg_content' ) ) {
function basel_get_svg_content($name) {
$folder = BASEL_THEMEROOT . '/images/svg';
$file = $folder . '/' . $name . '.svg';
return (file_exists( $file )) ? basel_get_any_svg( $file ) : false;
}
}
if( ! function_exists( 'basel_get_any_svg' ) ) {
function basel_get_any_svg( $file, $id = false ) {
$content = basel_get_svg( $file );
$start_tag = '<svg';
if( $id ) {
$pattern = "/id=\"(\w)+\"/";
if( preg_match($pattern, $content) ) {
$content = preg_replace($pattern, "id=\"" . $id . "\"", $content, 1);
} else {
$content = preg_replace( "/<svg/", "<svg id=\"" . $id . "\"", $content);
}
}
// Strip doctype
$position = strpos($content, $start_tag);
$content = substr($content, $position);
return $content;
}
}
// **********************************************************************//
// ! Get config file
// **********************************************************************//
if( ! function_exists( 'basel_get_config' ) ) {
function basel_get_config( $name ) {
return Config::get_instance()->get_config( $name );
}
}
// **********************************************************************//
// ! Text to one-line string
// **********************************************************************//
if( ! function_exists( 'basel_text2line')) {
function basel_text2line( $str ) {
return trim(preg_replace("/('|\"|\r?\n)/", '', $str));
}
}
// **********************************************************************//
// ! Get page ID by it's template name
// **********************************************************************//
if( ! function_exists( 'basel_tpl2id' ) ) {
function basel_tpl2id( $tpl = '' ) {
$pages = get_pages(array(
'meta_key' => '_wp_page_template',
'meta_value' => $tpl
));
foreach($pages as $page){
return $page->ID;
}
}
}
// **********************************************************************//
// ! Function print array within a pre tags
// **********************************************************************//
if( ! function_exists( 'ar' ) ) {
function ar($array) {
echo '<pre>';
print_r($array);
echo '</pre>';
}
}
// **********************************************************************//
// ! Get protocol (http or https)
// **********************************************************************//
if( ! function_exists( 'basel_http' )) {
function basel_http() {
if( ! is_ssl() ) {
return 'http';
} else {
return 'https';
}
}
}
// **********************************************************************//
// Function return vc_row with gradient.
// **********************************************************************//
if( ! function_exists( 'basel_get_gradient_attr' ) ) {
function basel_get_gradient_attr( $output, $obj, $attr ) {
if ( ! empty( $attr['basel_gradient_switch'] ) ) {
$gradient_css = basel_get_gradient_css( $attr['basel_color_gradient'] );
$output = preg_replace_callback('/basel-row-gradient-enable.*?>/',
function ( $matches ) use( $gradient_css ) {
return strtolower( $matches[0] . '<div class="basel-row-gradient" style="' . $gradient_css . '";></div>' );
}, $output );
}
return $output;
}
}
add_filter( 'vc_shortcode_output', 'basel_get_gradient_attr', 10, 3 );
// **********************************************************************//
// Function return gradient css.
// **********************************************************************//
if( ! function_exists( 'basel_get_gradient_css' ) ) {
function basel_get_gradient_css( $gradient_attr ) {
$gradient_css = explode( '|', $gradient_attr );
$css = $gradient_css[1];
$webkit_css = $gradient_css[1];
$css = str_replace( array( 'left', 'top', 'right', 'bottom' ), array( 'to side1', 'to side2', 'to side3', 'to side4' ), $css );
$css = str_replace( array( 'side1', 'side2', 'side3', 'side4' ), array( 'right', 'bottom', 'left', 'top' ), $css );
$result = 'background-image:-webkit-' . $webkit_css . ';';
$result .= 'background-image:' . $css . ';';
return $result;
}
}
// **********************************************************************//
// ! Append :hover to CSS selectors array
// **********************************************************************//
if( ! function_exists( 'basel_append_hover_state' ) ) {
function basel_append_hover_state( $selectors ) {
// if( ! is_array( $selectors ) ) {
$selectors = explode(',', $selectors[0]);
// }
$return = array();
foreach ($selectors as $selector) {
$return[] = $selector . ':hover';
}
return implode(',', $return);
}
}
// **********************************************************************//
// Get gradient field
// **********************************************************************//
if( ! function_exists( 'basel_get_gradient_field' ) ) {
function basel_get_gradient_field( $param_name, $value, $is_VC = false ) {
$classes = $param_name;
$classes .= ( $is_VC ) ? ' wpb_vc_param_value' : '';
$uniqid = uniqid();
$output = '<div class="basel-grad-wrap">';
$output .= '<div class="basel-grad-line" id="basel-grad-line' . $uniqid . '"></div>';
$output .= '<div class="basel-grad-preview" id="basel-grad-preview' . $uniqid . '"></div>';
$output .= '<input id="basel-grad-val' . $uniqid . '" class="' . $classes . '" name="' . $param_name . '" style="display:none" value="'.$value.'"/>';
$output .= '</div>';
$gradient_data = explode( '|', $value );
$gradient_points_data = $gradient_data[0];
$gradient_type_data = ( isset( $gradient_data[2] ) ) ? $gradient_data[2] : '';
$gradient_direction_data = ( isset( $gradient_data[3] ) ) ? $gradient_data[3] : '';
//Point result
$result_point_value = '';
if ( ! empty( $gradient_points_data ) ) {
$points_value = explode( '/', $gradient_points_data );
array_pop( $points_value );
foreach ( $points_value as $key => $points_values ) {
$points_values = explode( '-', $points_values );
$result_point_value .= '{color:"' . $points_values[0] . '",position:' . $points_values[1] . '},';
}
}else{
$result_point_value = '{color:"rgb(60, 27, 59)",position:0},{color:"rgb(90, 55, 105)",position: 33},{color:"rgb(46, 76, 130)",position:66},{color:"rgb(29, 28, 44)",position:100}';
}
//Type result
$result_type_value = ( ! empty( $gradient_type_data ) ) ? $gradient_type_data : 'linear' ;
//Direction result
$result_direction_value = ( ! empty( $gradient_direction_data ) ) ? $gradient_direction_data : 'left' ;
$output .= "<script>
jQuery( document ).ready( function() {
var gradient_line = '#basel-grad-line" . $uniqid . "',
gradient_preview = '#basel-grad-preview" . $uniqid . "',
grad_val = '#basel-grad-val" . $uniqid . "';
gradX(gradient_line, {
targets: [gradient_preview],
change: function( points, styles, type, direction ) {
for( i = 0; i < styles.length; ++i ) {
jQuery( gradient_preview ).css( 'background-image', styles[i] );
var points_value = '';
jQuery( points ).each( function( index , value ){
points_value += value[0] + '-' + value[1] + '/';
})
jQuery( grad_val ).attr( 'value', points_value + '|' + styles[i] + '|' + type + '|' + direction );
}
},
type: \"" . $result_type_value . "\",
direction: \"" . $result_direction_value . "\",
sliders: [" . $result_point_value . "]
});
})
</script>";
return $output;
}
}
// **********************************************************************//
// Basel get theme info
// **********************************************************************//
if( ! function_exists( 'basel_get_theme_info' ) ) {
function basel_get_theme_info( $parameter ) {
$theme_info = wp_get_theme();
if ( is_child_theme() ){
$theme_info = wp_get_theme( $theme_info->parent()->template );
}
return $theme_info->get( $parameter );
}
}
// **********************************************************************//
// Basel page CSS
// **********************************************************************//
if ( !function_exists('basel_settings_css') ) {
function basel_settings_css() {
$logo_container_width = basel_get_opt( 'logo_width' );
$logo_img_width = basel_get_opt( 'logo_img_width' );
$right_column_width = basel_get_opt( 'right_column_width' );
$header = basel_get_opt( 'header' );
$header_height = basel_get_opt( 'header_height' );
$sticky_header_height = basel_get_opt( 'sticky_header_height' );
$mobile_header_height = basel_get_opt( 'mobile_header_height' );
$right_column_width_percents = $menu_width = (int) (100 - $logo_container_width) / 2;
$widgets_scroll = basel_get_opt( 'widgets_scroll' );
$widgets_height = basel_get_opt( 'widget_heights' );
//Topbar
$topbar_height = basel_get_opt( 'top_bar_height' );
$topbar_height_mobile = basel_get_opt( 'top_bar_mobile_height' );
//Header banner
$header_banner_height = basel_get_opt( 'header_banner_height' );
$header_banner_height_mobile = basel_get_opt( 'header_banner_mobile_height' );
//Shop popup
$shop_popup_width = basel_get_opt( 'popup_width' );
$custom_product_background = get_post_meta( get_the_ID(), '_basel_product-background', true );
$text_font = basel_get_opt('text-font');
$primary_font = basel_get_opt('primary-font');
ob_start();
?>
/* Shop popup */
.basel-promo-popup {
max-width: <?php echo esc_html( $shop_popup_width ); ?>px;
}
.site-logo {
width: <?php echo esc_html( $logo_container_width ); ?>%;
}
.site-logo img {
max-width: <?php echo esc_html( $logo_img_width ); ?>px;
max-height: <?php echo esc_html( $header_height ); ?>px;
}
<?php if( $header == 'shop' ): ?>
.widgetarea-head,
.main-nav {
width: <?php echo esc_html( $menu_width ); ?>%;
}
.right-column {
width: <?php echo esc_html( $right_column_width_percents ); ?>%;
}
<?php elseif( $header == 'logo-center' ): ?>
.widgetarea-head {
width: <?php echo esc_html( $menu_width ); ?>%;
}
.right-column {
width: <?php echo esc_html( $right_column_width_percents ); ?>%;
}
.sticky-header .right-column {
width: <?php echo esc_html( $right_column_width ); ?>px;
}
<?php elseif( $header == 'split' ): ?>
.left-column,
.right-column {
width: <?php echo esc_html( $right_column_width ); ?>px;
}
<?php else: ?>
.right-column {
width: <?php echo esc_html( $right_column_width ); ?>px;
}
<?php endif; ?>
<?php if( $widgets_scroll ): ?>
.basel-woocommerce-layered-nav .basel-scroll-content {
max-height: <?php echo esc_html($widgets_height); ?>px;
}
<?php endif; ?>
/* header Banner */
body .header-banner {
height: <?php echo esc_html( $header_banner_height ); ?>px;
}
body.header-banner-display .website-wrapper {
margin-top:<?php echo esc_html( $header_banner_height ); ?>px;
}
/* Topbar height configs */
.topbar-menu ul > li {
line-height: <?php echo esc_html( $topbar_height ); ?>px;
}
.topbar-wrapp,
.topbar-content:before {
height: <?php echo esc_html( $topbar_height ); ?>px;
}
.sticky-header-prepared.basel-top-bar-on .header-shop,
.sticky-header-prepared.basel-top-bar-on .header-split,
.enable-sticky-header.basel-header-overlap.basel-top-bar-on .main-header {
top: <?php echo esc_html( $topbar_height ); ?>px;
}
/* Header height configs */
/* Limit logo image height for according to header height */
.site-logo img {
max-height: <?php echo esc_html( $header_height ); ?>px;
}
/* And for sticky header logo also */
.act-scroll .site-logo img,
.header-clone .site-logo img {
max-height: <?php echo esc_html( $sticky_header_height ); ?>px;
}
/* Set sticky headers height for cloned headers based on menu links line height */
.header-clone .main-nav .menu > li > a {
height: <?php echo esc_html( $sticky_header_height ); ?>px;
line-height: <?php echo esc_html( $sticky_header_height ); ?>px;
}
/* Height for switch logos */
.sticky-header-real:not(.global-header-menu-top) .switch-logo-enable .basel-logo {
height: <?php echo esc_html( $header_height ); ?>px;
}
.sticky-header-real:not(.global-header-menu-top) .act-scroll .switch-logo-enable .basel-logo {
height: <?php echo esc_html( $sticky_header_height ); ?>px;
}
.sticky-header-real:not(.global-header-menu-top) .act-scroll .switch-logo-enable {
transform: translateY(-<?php echo esc_html( $sticky_header_height ); ?>px);
}
<?php if( $header == 'base' || $header == 'logo-center' || $header == 'split' ): ?>
/* Header height for layouts that don't have line height for menu links */
.wrapp-header {
min-height: <?php echo esc_html( $header_height ); ?>px;
}
<?php elseif( $header != 'vertical' ): ?>
/* Header height for these layouts based on it's menu links line height */
.main-nav .menu > li > a {
height: <?php echo esc_html( $header_height ); ?>px;
line-height: <?php echo esc_html( $header_height ); ?>px;
}
/* The same for sticky header */
.act-scroll .main-nav .menu > li > a {
height: <?php echo esc_html( $sticky_header_height ); ?>px;
line-height: <?php echo esc_html( $sticky_header_height ); ?>px;
}
<?php endif; ?>
<?php if( $header == 'split' ): ?>
/* Sticky header height for split header layout */
.act-scroll .wrapp-header {
min-height: <?php echo esc_html( $sticky_header_height ); ?>px;
}
<?php endif; ?>
<?php if( $header == 'shop' ): ?>
/* Set line height for header links for shop header layout. Based in the header height option */
.header-shop .right-column .header-links {
height: <?php echo esc_html( $header_height ); ?>px;
line-height: <?php echo esc_html( $header_height ); ?>px;
}
/* The same for sticky header */
.header-shop.act-scroll .right-column .header-links {
height: <?php echo esc_html( $sticky_header_height ); ?>px;
line-height: <?php echo esc_html( $sticky_header_height ); ?>px;
}
<?php endif; ?>
<?php if ( !empty( $custom_product_background ) ): ?>
.single-product .site-content{
background-color: <?php echo esc_html( $custom_product_background ); ?> !important;
}
<?php endif ?>
/* Page headings settings for heading overlap. Calculate on the header height base */
.basel-header-overlap .title-size-default,
.basel-header-overlap .title-size-small,
.basel-header-overlap .title-shop.without-title.title-size-default,
.basel-header-overlap .title-shop.without-title.title-size-small {
padding-top: <?php echo esc_html($header_height + 40); ?>px;
}
.basel-header-overlap .title-shop.without-title.title-size-large,
.basel-header-overlap .title-size-large {
padding-top: <?php echo esc_html($header_height + 120); ?>px;
}
@media (max-width: 991px) {
/* header Banner */
body .header-banner {
height: <?php echo esc_html( $header_banner_height_mobile ); ?>px;
}
body.header-banner-display .website-wrapper {
margin-top:<?php echo esc_html( $header_banner_height_mobile ); ?>px;
}
/* Topbar height configs */
.topbar-menu ul > li {
line-height: <?php echo esc_html( $topbar_height_mobile ); ?>px;
}
.topbar-wrapp,
.topbar-content:before {
height: <?php echo esc_html( $topbar_height_mobile ); ?>px;
}
.sticky-header-prepared.basel-top-bar-on .header-shop,
.sticky-header-prepared.basel-top-bar-on .header-split,
.enable-sticky-header.basel-header-overlap.basel-top-bar-on .main-header {
top: <?php echo esc_html( $topbar_height_mobile ); ?>px;
}
/* Set header height for mobile devices */
.main-header .wrapp-header {
min-height: <?php echo esc_html( $mobile_header_height ); ?>px;
}
/* Limit logo image height for mobile according to mobile header height */
.site-logo img {
max-height: <?php echo esc_html( $mobile_header_height ); ?>px;
}
/* Limit logo on sticky header. Both header real and header cloned */
.act-scroll .site-logo img,
.header-clone .site-logo img {
max-height: <?php echo esc_html( $mobile_header_height ); ?>px;
}
/* Height for switch logos */
.main-header .switch-logo-enable .basel-logo {
height: <?php echo esc_html( $mobile_header_height ); ?>px;
}
.sticky-header-real:not(.global-header-menu-top) .act-scroll .switch-logo-enable .basel-logo {
height: <?php echo esc_html( $mobile_header_height ); ?>px;
}
.sticky-header-real:not(.global-header-menu-top) .act-scroll .switch-logo-enable {
transform: translateY(-<?php echo esc_html( $mobile_header_height ); ?>px);
}
/* Page headings settings for heading overlap. Calculate on the MOBILE header height base */
.basel-header-overlap .title-size-default,
.basel-header-overlap .title-size-small,
.basel-header-overlap .title-shop.without-title.title-size-default,
.basel-header-overlap .title-shop.without-title.title-size-small {
padding-top: <?php echo esc_html($mobile_header_height + 20); ?>px;
}
.basel-header-overlap .title-shop.without-title.title-size-large,
.basel-header-overlap .title-size-large {
padding-top: <?php echo esc_html($mobile_header_height + 60); ?>px;
}
}
<?php if ( basel_get_opt( 'rev_slider_inherit_theme_font' ) ): ?>
<?php if ( isset( $text_font[0] ) && isset( $text_font[0]['font-family'] ) ): ?>
.wpb_revslider_element [data-type=text],
.wpb_revslider_element [data-type=button] {
font-family: <?php echo esc_html( $text_font[0]['font-family'] ); ?> !important;
}
<?php endif; ?>
<?php if ( isset( $primary_font[0] ) && isset( $primary_font[0]['font-family'] ) ): ?>
.wpb_revslider_element h1[data-type=text],
.wpb_revslider_element h2[data-type=text],
.wpb_revslider_element h3[data-type=text],
.wpb_revslider_element h4[data-type=text],
.wpb_revslider_element h5[data-type=text],
.wpb_revslider_element h6[data-type=text] {
font-family: <?php echo esc_html( $primary_font[0]['font-family'] ); ?> !important;
}
<?php endif; ?>
<?php endif; ?>
<?php
if ( basel_get_opt( 'more_cat_button' ) && basel_get_opt( 'more_cat_button_count' ) ) {
$count = basel_get_opt( 'more_cat_button_count' ) + 1;
echo '.basel-more-cat:not(.basel-show-cat) .menu > .menu-item:nth-child(n+' . $count . '):not(:last-child) {
display: none;
}.basel-more-cat .menu > .menu-item:nth-child(n+' . $count . ') {
animation: fade-in .3s ease both;
}
.basel-show-cat .menu .basel-more-cat-btn {
display: none;
}';
}
return ob_get_clean();
}
}
// **********************************************************************//
// Function return vc_video with image mask.
// **********************************************************************//
if( ! function_exists( 'basel_add_video_poster' ) ) {
function basel_add_video_poster( $output, $obj, $attr ) {
if ( ! empty( $attr['image_poster_switch'] ) ) {
$image_id = $attr['poster_image'];
$image_size = 'full';
if ( isset( $attr['img_size'] ) ) $image_size = $attr['img_size'];
$image = basel_get_image_src( $image_id, $image_size );
$output = preg_replace_callback('/wpb_video_wrapper.*?>/',
function ( $matches ) use( $image ) {
return $matches[0] . '<div class="basel-video-poster-wrapper"><div class="basel-video-poster" style="background-image:url(' . $image . ')";></div><div class="button-play"></div></div>';
}, $output );
}
return $output;
}
add_filter( 'vc_shortcode_output', 'basel_add_video_poster', 10, 3 );
}
// **********************************************************************//
// Function return all images sizes
// **********************************************************************//
if( ! function_exists( 'basel_get_all_image_sizes' ) ) {
function basel_get_all_image_sizes() {
global $_wp_additional_image_sizes;
$default_image_sizes = array( 'thumbnail', 'medium', 'large', 'full' );
foreach ( $default_image_sizes as $size ) {
$image_sizes[ $size ][ 'width' ] = intval( get_option( "{$size}_size_w" ) );
$image_sizes[ $size ][ 'height' ] = intval( get_option( "{$size}_size_h" ) );
$image_sizes[ $size ][ 'crop' ] = get_option( "{$size}_crop" ) ? get_option( "{$size}_crop" ) : false;
}
if ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) ) {
$image_sizes = array_merge( $image_sizes, $_wp_additional_image_sizes );
}
return $image_sizes;
}
}
if( ! function_exists( 'basel_get_image_size' ) ) {
function basel_get_image_size( $thumb_size ) {
if ( is_string( $thumb_size ) && in_array( $thumb_size, array( 'thumbnail', 'thumb', 'medium', 'large', 'full' ) ) ) {
$images_sizes = basel_get_all_image_sizes();
$image_size = $images_sizes[$thumb_size];
if ( $thumb_size == 'full') {
$image_size['width'] = 999999;
$image_size['height'] = 999999;
}
return array( $image_size['width'], $image_size['height'] );
}elseif ( is_string( $thumb_size ) ) {
preg_match_all( '/\d+/', $thumb_size, $thumb_matches );
if ( isset( $thumb_matches[0] ) ) {
$thumb_size = array();
if ( count( $thumb_matches[0] ) > 1 ) {
$thumb_size[] = $thumb_matches[0][0]; // width
$thumb_size[] = $thumb_matches[0][1]; // height
} elseif ( count( $thumb_matches[0] ) > 0 && count( $thumb_matches[0] ) < 2 ) {
$thumb_size[] = $thumb_matches[0][0]; // width
$thumb_size[] = $thumb_matches[0][0]; // height
} else {
$thumb_size = false;
}
}
return $thumb_size;
}
}
}
if( ! function_exists( 'basel_get_image_src' ) ) {
function basel_get_image_src( $thumb_id, $thumb_size ) {
$thumb_size = basel_get_image_size( $thumb_size );
$thumbnail = wpb_resize( $thumb_id, null, $thumb_size[0], $thumb_size[1], true );
return $thumbnail['url'];
}
}
// **********************************************************************//
// Check is theme is activated with a purchase code
// **********************************************************************//
if ( ! function_exists( 'basel_is_license_activated' ) ) {
function basel_is_license_activated() {
return get_option( 'basel_is_activated', false );
}
}
// **********************************************************************//
// ! Function to get all pages
// **********************************************************************//
if( ! function_exists( 'basel_get_pages' ) ) {
function basel_get_pages( $new = false ) {
if( $new ) {
$pages = array();
} else {
$pages = array( 'default' => esc_html__( 'Default', 'basel' ) );
}
foreach( get_pages() as $page ){
if( $new ) {
$pages[ $page->ID ] = array(
'name' => $page->post_title,
'value' => $page->ID,
);
} else {
$pages[$page->ID] = $page->post_title;
}
}
return $pages;
}
}
// **********************************************************************//
// ! Function to set custom 404 page
// **********************************************************************//
if( ! function_exists( 'basel_custom_404_page' ) ) {
function basel_custom_404_page( $template ) {
global $wp_query;
$custom_404 = basel_get_opt( 'custom_404_page' );
if ( $custom_404 == 'default' || empty( $custom_404 ) ) return $template;
$wp_query->query( 'page_id=' . $custom_404 );
$wp_query->the_post();
$template = get_page_template();
rewind_posts();
return $template;
}
add_filter( '404_template', 'basel_custom_404_page', 999 );
}
// **********************************************************************//
// Get current breadcrumbs
// **********************************************************************//
if ( ! function_exists( 'basel_current_breadcrumbs' ) ) {
function basel_current_breadcrumbs( $type, $return = false ) {
if ( $return ) {
ob_start();
}
$function = ( $type == 'shop' ) ? 'woocommerce_breadcrumb' : 'basel_breadcrumbs';
if ( basel_get_opt( 'yoast_' . $type . '_breadcrumbs' ) && function_exists( 'yoast_breadcrumb' ) ) {
if ( is_singular( 'product' ) && $type == 'shop' ) {
echo basel_back_btn();
}
echo '<div class="yoast-breadcrumb">';
echo yoast_breadcrumb();
echo '</div>';
} else {
$function();
}
if ( $return ) {
return ob_get_clean();
}
}
}
/*==============================================
= Lazy loading functions =
==============================================*/
// **********************************************************************//
// Filters HTML <img> tag and adds lazy loading attributes. Used for avatar images.
// **********************************************************************//
if ( ! function_exists( 'basel_lazy_avatar_image' ) ) {
function basel_lazy_avatar_image( $html ) {
if ( preg_match( "/src=['\"]data:image/is", $html ) ) return $html;
$uploaded = basel_get_opt( 'lazy_custom_placeholder' );
if ( $uploaded['url'] ) {
$lazy_image = $uploaded['url'];
} else {
$lazy_image = basel_lazy_get_default_preview();
}
return basel_lazy_replace_image( $html, $lazy_image );
}
}
// **********************************************************************//
// Filters HTML <img> tag and adds lazy loading attributes. Used for product categories images for example.
// **********************************************************************//
if( ! function_exists( 'basel_lazy_attachment_replace' ) ) {
function basel_lazy_attachment_replace( $imgHTML, $attach_id, $size ) {
if ( preg_match( "/src=['\"]data:image/is", $imgHTML ) ) return $imgHTML;
if( $attach_id ) {
$lazy_image = basel_get_attachment_placeholder( $attach_id, $size );
} else {
$lazy_image = basel_lazy_get_default_preview();
}
return basel_lazy_replace_image( $imgHTML, $lazy_image );
}
}
// **********************************************************************//
// Filters HTML <img> tag and adds lazy loading attributes. Used for instagram images.
// **********************************************************************//
if( ! function_exists( 'basel_lazy_image_standard' ) ) {
function basel_lazy_image_standard( $html ) {
if ( preg_match( "/src=['\"]data:image/is", $html ) ) return $html;
$lazy_image = basel_lazy_get_default_preview();
return basel_lazy_replace_image( $html, $lazy_image );
}
}
// **********************************************************************//
// Get default preview image.
// **********************************************************************//
if( ! function_exists( 'basel_lazy_get_default_preview' ) ) {
function basel_lazy_get_default_preview() {
return BASEL_IMAGES . '/lazy.png';
}
}
// **********************************************************************//
// Filters WPBakery generated image. Needs an HTML, its ID, and params with image size.
// **********************************************************************//
if( ! function_exists( 'basel_lazy_image' ) ) {
function basel_lazy_image( $img, $attach_id, $params ) {
$thumb_size = basel_get_image_size( $params['thumb_size'] );
$imgHTML = $img['thumbnail'];
if ( preg_match( "/src=['\"]data:image|basel-lazy-load/is", $imgHTML ) ) return $img;
$lazy_image = basel_get_attachment_placeholder( $attach_id, $thumb_size );
$img['thumbnail'] = basel_lazy_replace_image( $imgHTML, $lazy_image );
return $img;
}
}
// **********************************************************************//
// Filters <img> tag passed as an argument.
// **********************************************************************//
if( ! function_exists( 'basel_lazy_replace_image' ) ) {
function basel_lazy_replace_image( $html, $src ) {
$class = basel_lazy_css_class();
$new = '';
$new = preg_replace( '/<img(.*?)src=/is', '<img$1src="'.$src.'" data-basel-src=', $html );
$new = preg_replace( '/<img(.*?)srcset=/is', '<img$1srcset="" data-srcset=', $new );
if ( preg_match( '/class=["\']/i', $new ) ) {
$new = preg_replace( '/class=(["\'])(.*?)["\']/is', 'class=$1' . $class . ' $2$1', $new );
} else {
$new = preg_replace( '/<img/is', '<img class="' . $class . '"', $new );
}
return $new;
}
}
// **********************************************************************//
// Filters default WordPress images ATTRIBUTES array called by core API functions.
// **********************************************************************//
if( ! function_exists( 'basel_lazy_attributes' ) ) {
function basel_lazy_attributes($attr, $attachment, $size) {
$attr['data-basel-src'] = $attr['src'];
if( isset( $attr['srcset'] ) ) $attr['data-srcset'] = $attr['srcset'];
$attr['src'] = basel_get_attachment_placeholder( $attachment->ID, $size );
$attr['srcset'] = '';
$attr['class'] = $attr['class'] . ' ' . basel_lazy_css_class();
return $attr;
}
}
// **********************************************************************//
// Get lazy loading image CSS class
// **********************************************************************//
if( ! function_exists( 'basel_lazy_css_class' ) ) {
function basel_lazy_css_class() {
$class = 'basel-lazy-load';
$class .= ' basel-lazy-' . basel_get_opt( 'lazy_effect' );
return $class;
}
}
// **********************************************************************//
// Get placeholder image. Needs ID to genereate a blurred preview and size.
// **********************************************************************//
if( ! function_exists( 'basel_get_attachment_placeholder' ) ) {
function basel_get_attachment_placeholder( $id, $size ) {
// Get size from array
if( is_array( $size) ) {
$width = $size[0];
$height = $size[1];
} else {
// Take it from the original image
$image = wp_get_attachment_image_src($id, $size);
$width = $image[1];
$height = $image[2];
}
$placeholder_size = basel_get_placeholder_size( $width, $height );
$uploaded = basel_get_opt('lazy_custom_placeholder');
$img = basel_lazy_get_default_preview();
if( basel_get_opt( 'lazy_generate_previews' ) && function_exists( 'vc_get_image_by_size' ) ) {
$img = vc_get_image_by_size( $id, $placeholder_size );
} else if( ! empty( $uploaded ) && is_array( $uploaded ) && ! empty( $uploaded['url'] ) && ! empty( $uploaded['id'] ) ) {
$img = $uploaded['url'];
if( basel_get_opt( 'lazy_proprtion_size' ) && function_exists( 'vc_get_image_by_size' ) ) {
$img = vc_get_image_by_size( $uploaded['id'], $width . 'x' . $height );
}
} else {
return basel_lazy_get_default_preview();
}
if( basel_get_opt( 'lazy_base_64' ) ) $img = basel_encode_image($id, $img);
return $img;
}
}
// **********************************************************************//
// Encode small preview image to BASE 64
// **********************************************************************//
if( ! function_exists( 'basel_encode_image' ) ) {
function basel_encode_image( $id, $url ) {
if( ! wp_attachment_is_image( $id ) || preg_match('/^data\:image/', $url ) ) return $url;
$meta_key = '_base64_image.' . md5($url);
$img_url = get_post_meta( $id, $meta_key, true );
if( $img_url ) return $img_url;
$image_path = preg_replace('/^.*?wp-content\/uploads\//i', '', $url);
if( ( $uploads = wp_get_upload_dir() ) && ( false === $uploads['error'] ) && ( 0 !== strpos( $image_path, $uploads['basedir'] ) ) ) {
if( false !== strpos( $image_path, 'wp-content/uploads' ) )
$image_path = trailingslashit( $uploads['basedir'] . '/' . _wp_get_attachment_relative_path( $image_path ) ) . basename( $image_path );
else
$image_path = $uploads['basedir'] . '/' . $image_path;
}
$max_size = 150 * 1024; // MB
//echo '[['.$max_size.' vs '.filesize($image_path).']]';
if( file_exists( $image_path ) && ( ! $max_size || ( filesize( $image_path ) <= $max_size ) ) ) {
$filetype = wp_check_filetype( $image_path );
// Read image path, convert to base64 encoding
if ( function_exists( 'basel_compress' ) && function_exists( 'basel_get_file' ) ) {
$imageData = basel_compress( basel_get_file( $image_path ) );
} else {
$imageData = '';
}
// Format the image SRC: data:{mime};base64,{data};
$img_url = 'data:image/' . $filetype['ext'] . ';base64,' . $imageData;
update_post_meta( $id, $meta_key, $img_url );
return $img_url;
}
return $url;
}
}
// **********************************************************************//
// Generate placeholder preview small size.
// **********************************************************************//
if( ! function_exists( 'basel_get_placeholder_size' ) ) {
function basel_get_placeholder_size( $x0, $y0 ) {
$x = $y = 10;
if( $x0 < $y0) {
$y = ($x * $y0) / $x0;
}
if( $x0 > $y0) {
$x = ($y * $x0) / $y0;
}
$x = ceil( $x );
$y = ceil( $y );
return (int) $x . 'x' . (int) $y;
}
}
/*===== End of Lazy loading functions ======*/
// **********************************************************************//
// Is blog archive page
// **********************************************************************//
if ( ! function_exists( 'basel_is_blog_archive' ) ) {
function basel_is_blog_archive() {
return ( is_home() || is_search() || is_tag() || is_category() || is_date() || is_author() );
}
}
if ( ! function_exists( 'basel_is_portfolio_archive' ) ) {
function basel_is_portfolio_archive() {
return ( is_post_type_archive( 'portfolio' ) || is_tax( 'project-cat' ) );
}
}
/**
* ------------------------------------------------------------------------------------------------
* Is shop on front page
* ------------------------------------------------------------------------------------------------
*/
if ( ! function_exists( 'basel_is_shop_on_front' ) ) {
function basel_is_shop_on_front() {
return function_exists( 'wc_get_page_id' ) && 'page' === get_option( 'show_on_front' ) && wc_get_page_id( 'shop' ) == get_option( 'page_on_front' );
}
}
if ( ! function_exists( 'basel_get_allowed_html' ) ) {
/**
* Return allowed html tags
*
* @since 1.0.0
*
* @return array
*/
function basel_get_allowed_html() {
return array(
'br' => array(),
'i' => array(),
'b' => array(),
'u' => array(),
'em' => array(),
'a' => array(
'href' => true,
'class' => true,
'title' => true,
'rel' => true,
),
'strong' => array(),
'span' => array(
'style' => true,
'class' => true,
),
);
}
}
if ( ! function_exists( 'basel_dokan_lazy_load_fix' ) ) {
function basel_dokan_lazy_load_fix(){
return array(
'img' => array(
'alt' => array(),
'class' => array(),
'height' => array(),
'src' => array(),
'width' => array(),
'data-basel-src' => array(),
'data-srcset' => array(),
),
);
}
add_filter( 'dokan_product_image_attributes', 'basel_dokan_lazy_load_fix', 10 );
}
if ( ! function_exists( 'basel_clean' ) ) {
/**
* Clean variables using sanitize_text_field. Arrays are cleaned recursively.
* Non-scalar values are ignored.
*
* @param string|array $var Data to sanitize.
* @return string|array
*/
function basel_clean( $var ) {
if ( is_array( $var ) ) {
return array_map( 'basel_clean', $var );
} else {
return is_scalar( $var ) ? sanitize_text_field( $var ) : $var;
}
}
}
if ( ! function_exists( 'xts_get_default_value' ) ) {
/**
* Get default theme settings value
*
* @since 1.0.0
*
* @param string $key Value key.
*
* @return string
*/
function xts_get_default_value( $key ) {
// $default_values = xts_get_config( 'framework-defaults' );
// $theme_values = xts_get_config( 'theme-defaults' );
// if ( $theme_values ) {
// $default_values = wp_parse_args( $theme_values, $default_values );
// }
return '';
return isset( $default_values[ $key ] ) ? $default_values[ $key ] : '';
}
}
if ( ! function_exists( 'basel_product_attributes_array' ) ) {
function basel_product_attributes_array() {
if ( ! function_exists( 'wc_get_attribute_taxonomies' ) ) {
return;
}
$attributes = array();
foreach ( wc_get_attribute_taxonomies() as $attribute ) {
$attributes[ 'pa_' . $attribute->attribute_name ] = array(
'name' => $attribute->attribute_label, 'value' => 'pa_' . $attribute->attribute_name,
);
}
return $attributes;
}
}
if ( ! function_exists( 'basel_get_pages_array' ) ) {
/**
* Get all pages array
*
* @since 1.0.0
*
* @return array
*/
function basel_get_pages_array() {
$pages = array();
foreach ( get_pages() as $page ) {
$pages[ $page->ID ] = array(
'name' => $page->post_title,
'value' => $page->ID,
);
}
return $pages;
}
}
// **********************************************************************//
// Is share button enable
// **********************************************************************//
if ( ! function_exists( 'basel_is_social_link_enable' ) ) {
function basel_is_social_link_enable( $type ) {
$result = false;
if ( $type == 'share' && ( basel_get_opt('share_fb') || basel_get_opt('share_twitter') || basel_get_opt('share_linkedin') || basel_get_opt('share_pinterest') || basel_get_opt('share_ok') || basel_get_opt('share_whatsapp') || basel_get_opt('share_email') || basel_get_opt('share_vk') || basel_get_opt('share_tg') || basel_get_opt('share_tiktok') ) ) {
$result = true;
}
if ( $type == 'follow' && ( basel_get_opt('fb_link') || basel_get_opt('twitter_link') || basel_get_opt('google_link') || basel_get_opt('isntagram_link') || basel_get_opt('pinterest_link') || basel_get_opt('youtube_link') || basel_get_opt('tumblr_link') || basel_get_opt('linkedin_link') || basel_get_opt('vimeo_link') || basel_get_opt('flickr_link') || basel_get_opt('github_link') || basel_get_opt('dribbble_link') || basel_get_opt('behance_link') || basel_get_opt('soundcloud_link') || basel_get_opt('spotify_link') || basel_get_opt('ok_link') || basel_get_opt('whatsapp_link') || basel_get_opt('vk_link') || basel_get_opt('snapchat_link') || basel_get_opt('tg_link') || basel_get_opt('tiktok_link') || basel_get_opt( 'social_email' ) ) ) {
$result = true;
}
return $result;
}
}
if ( ! function_exists( 'basel_android_browser_bar_color' ) ) {
/**
* Display cart widget side
*
* @since 1.0.0
*/
function basel_android_browser_bar_color() {
$color = basel_get_opt( 'android_browser_bar_color' );
if ( isset( $color['idle'] ) ) {
echo '<meta name="theme-color" content="'. $color['idle'] .'">';
}
}
add_filter( 'wp_head', 'basel_android_browser_bar_color' );
}
if( ! function_exists( 'basel_remove_https' ) ) {
function basel_remove_https($link) {
return preg_replace('#^https?:#', '', $link);
}
}
if ( ! function_exists( 'basel_nav_menu_portfolio_item_classes' ) ) {
/**
* Fix active class in nav for portfolio page.
*
* @param array $menu_items Menu items.
*
* @return array
*/
function basel_nav_menu_portfolio_item_classes( $menu_items ) {
$portfolio_page = intval( basel_tpl2id( 'portfolio.php' ) );
if ( ! empty( $menu_items ) && is_array( $menu_items ) ) {
foreach ( $menu_items as $key => $menu_item ) {
$classes = $menu_item->classes;
$menu_id = intval( $menu_item->object_id );
if ( is_post_type_archive( 'portfolio' ) && $portfolio_page === $menu_id && 'page' === $menu_item->object ) {
$menu_items[ $key ]->current = true;
$classes[] = 'current-menu-item';
$classes[] = 'current_page_item';
} elseif ( is_singular( 'portfolio' ) && $portfolio_page === $menu_id ) {
$classes[] = 'current_page_parent';
}
$menu_items[ $key ]->classes = array_unique( $classes );
}
}
return $menu_items;
}
add_filter( 'wp_nav_menu_objects', 'basel_nav_menu_portfolio_item_classes', 20 );
}