show_in_rest = true; register_taxonomy( 'fw-portfolio-category', 'fw-portfolio', (array) $args ); } add_action( 'rest_api_init', 'jevelin_fix_unyson_portfolio_categories_in_block_editor', 11 ); endif; /** * Element Inline Option */ if ( ! function_exists( 'jevelin_element_lazy_option' ) ) : function jevelin_element_lazy_option( $atts ) { if( !isset( $atts['lazy'] ) || ( isset( $atts['lazy'] ) && $atts['lazy'] == 'default' ) ) : $lazy = ( jevelin_option('lazy_loading') == 'enabled' ) ? 1 : 0; else : $lazy = ( isset( $atts['lazy'] ) && $atts['lazy'] == 'enabled' ) ? 1 : 0; endif; return $lazy; } endif; /** * Element Inline Option */ if ( ! function_exists( 'jevelin_element_inline_option' ) ) : function jevelin_element_inline_option() { return array( 'label' => esc_html__('Inline Element', 'jevelin'), 'desc' => esc_html__('Enable for multiple elements to add them in one line Doesnt work in WPbakery page builder front-end mode', 'jevelin'), 'type' => 'radio', 'value' => 'disabled', 'choices' => array( 'disabled' => esc_html__( 'Disabled', 'jevelin' ), 'enabled' => esc_html__( 'Enabled', 'jevelin' ), ) ); } endif; /** * Element Margin Option */ if ( ! function_exists( 'jevelin_element_margin_option' ) ) : function jevelin_element_margin_option() { return array( 'label' => esc_html__( 'Margin', 'jevelin' ), 'desc' => wp_kses( __( 'Enter your custom margin (top right bottom left)', 'jevelin' ), jevelin_allowed_html() ), 'type' => 'text', 'value' => '0px 0px 15px 0px', 'help' => esc_html__( 'Example: 0px 0px 15px 0px', 'jevelin' ), ); } endif; /** * Element Margin Option */ if ( ! function_exists( 'jevelin_wpcf7_form_elements' ) ) : add_filter( 'wpcf7_form_elements', 'jevelin_wpcf7_form_elements' ); function jevelin_wpcf7_form_elements( $form ) { return '
'.$form.'
'; } endif; /** * Check If Gutenberg is being used */ if ( ! function_exists( 'jevelin_is_gutenberg_page' ) ) : function jevelin_is_gutenberg_page() { if ( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) { // The Gutenberg plugin is on. return true; } if( function_exists( 'get_current_screen' ) ) : $current_screen = get_current_screen(); if ( method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() ) : // Gutenberg page on 5+. return true; endif; endif; return false; } endif; /** * If is URL */ function jevelin_is_url( $url = '' ) { if( $url && !is_array( $url ) ) : if( esc_url_raw( $url ) === $url ) : return true; endif; endif; return false; } /** * Load header items */ function jevelin_get_headers() { $header_layout_choices = array( '1' => esc_html__( 'Header 1', 'jevelin' ), '2' => esc_html__( 'Header 2', 'jevelin' ), '3' => esc_html__( 'Header 3', 'jevelin' ), '4' => esc_html__( 'Header 4', 'jevelin' ), '5' => esc_html__( 'Header 5', 'jevelin' ), '6' => esc_html__( 'Header 6 (side navigation)', 'jevelin' ), '7' => esc_html__( 'Header 7 (side navigation)', 'jevelin' ), '8' => esc_html__( 'Header 8', 'jevelin' ), '9' => esc_html__( 'Header 9', 'jevelin' ), '10' => esc_html__( 'Header 10', 'jevelin' ), 'left-1' => esc_html__( 'Left Header 11', 'jevelin' ), 'left-2' => esc_html__( 'Left Header 12', 'jevelin' ), ); global $post; $post2 = $post; $headers = new WP_Query( array( 'post_type' => 'shufflehound_header', 'post_status' => 'publish', 'posts_per_page' => 20 )); if( $headers->have_posts() ) : while( $headers->have_posts() ) : $headers->the_post(); $header_id = 'header-'.get_the_ID(); $header_layout_choices[ $header_id ] = html_entity_decode( get_the_title() ).' (from WPbakery page builder)'; endwhile; endif; wp_reset_postdata(); $post = $post2; return $header_layout_choices; } /** * Load footer items */ function jevelin_get_footers() { $layout_choices = array( 'default' => esc_html__( 'Default (from theme settings)', 'jevelin' ), ); global $post; $post2 = $post; $footers = new WP_Query( array( 'post_type' => 'shufflehound_footer', 'post_status' => 'publish', 'posts_per_page' => 20 )); if( $footers->have_posts() ) : while( $footers->have_posts() ) : $footers->the_post(); $footer_id = get_the_ID(); $layout_choices[ $footer_id ] = get_the_title().' (from WPbakery page builder)'; endwhile; endif; wp_reset_postdata(); $post = $post2; return $layout_choices; } /** * Load page items */ function jevelin_get_pages() { $layout_choices = array( 'disabled' => esc_html__( 'Disabled', 'jevelin' ), ); global $post; $post2 = $post; $footers = new WP_Query( array( 'post_type' => 'page', 'post_status' => 'publish', 'posts_per_page' => -1 )); if( $footers->have_posts() ) : while( $footers->have_posts() ) : $footers->the_post(); $footer_id = get_the_ID(); $layout_choices[ $footer_id ] = get_the_title(); endwhile; endif; wp_reset_postdata(); $post = $post2; return $layout_choices; } /** * Create Custom Random Function */ function jevelin_rand( $length = 10 ) { return substr(str_shuffle(str_repeat($x='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length/strlen($x)) )),1,$length); } /** * Load Instagram Widget template */ add_filter( 'wpiw_template_part', 'jevelin_instagram_class' ); function jevelin_instagram_class( $array ) { return 'inc/templates/instagram-widget.php'; } /* Portfolio Comments Support */ function jevelin_portfolio_comments_support() { add_post_type_support( 'fw-portfolio', array( 'comments' ) ); } add_action( 'init', 'jevelin_portfolio_comments_support' ); /** * Render template */ if ( ! function_exists( 'jevelin_link_it' ) ) : function jevelin_link_it($text) { $text = preg_replace("/(^|[\n ])([\w]*?)([\w]*?:\/\/[\w]+[^ \,\"\n\r\t<]*)/is", "$1$2$3", $text); $text = preg_replace("/(^|[\n ])([\w]*?)((www)\.[^ \,\"\t\n\r<]*)/is", "$1$2$3", $text); $text = preg_replace("/(^|[\n ])([\w]*?)((ftp)\.[^ \,\"\t\n\r<]*)/is", "$1$2$3", $text); $text = preg_replace("/(^|[\n ])([a-z0-9&\-_\.]+?)@([\w\-]+\.([\w\-\.]+)+)/i", "$1$2@$3", $text); return ( $text ); } endif; /** * Render template */ if ( ! function_exists( 'jevelin_render_css' ) ) : function jevelin_render_css() { ob_start(); get_template_part( 'inc/templates/render-css' ); $css = ob_get_clean(); return $css; } endif; /** * Render template - mini */ function jevelin_render_css_mini() { ob_start(); get_template_part( 'inc/templates/render-css-mini' ); return ob_get_clean(); } /** * Get page ID */ if ( ! function_exists( 'jevelin_page_id' ) ) : function jevelin_page_id() { if( function_exists( 'is_shop' ) && is_shop() == true ) { $post_id = get_option( 'woocommerce_shop_page_id' ); } else if( is_search() || is_archive() || is_404() ) { $post_id = false; } else if (in_the_loop()) { $post_id = get_the_ID(); } else { global $wp_query; $post_id = $wp_query->get_queried_object_id(); } return $post_id; } endif; /* Load image ratio - By Post ID */ if ( ! function_exists( 'jevelin_image_ratio' ) ) : function jevelin_image_ratio( $id = '', $size = '', $ratio = '') { $load_ratio = ''; if( $ratio == '') : $load_ratio = ' sh-ratio-container-square'; endif; return '
'; } endif; /* Load image ratio - By Thumbnail ID */ if ( ! function_exists( 'jevelin_image_ratio_by_thumbnail' ) ) : function jevelin_image_ratio_by_thumbnail( $id = '', $size = '', $ratio = '') { $load_ratio = ''; if( $ratio == '') : $load_ratio = ' sh-ratio-container-square'; elseif( $ratio == 'landscape') : $load_ratio = ''; endif; return '
'; } endif; /** * Get post options */ if ( ! function_exists( 'jevelin_post_option' ) ) : function jevelin_post_option( $id = NULL, $name = NULL, $default = NULL) { if( function_exists('fw_get_db_post_option') && $id > 0 && $name ) : return fw_get_db_post_option( $id, $name, $default ); elseif( !empty( $default ) ) : return $default; else : return false; endif; } endif; /** * Get theme options */ if ( ! function_exists( 'jevelin_option' ) ) : if ( is_customize_preview() ) { function jevelin_option( $id = NULL, $default = NULL) { if( function_exists('fw_get_db_settings_option') ) : global $wp_customize; $customizer_option = fw_get_db_customizer_option($id); return fw_get_db_customizer_option($id); elseif( !empty( $default ) ) : return $default; else : return false; endif; } } else { function jevelin_option( $id = NULL, $default = NULL) { if( $id == 'lazy' && function_exists('shufflehound_lazy_loading_enabled_all_sites') ) : return 1; endif; if( function_exists('fw_get_db_settings_option') ) : if( in_array( $id, array( 'accent_color', 'accent_hover_color', 'header_nav_active_color', 'footer_hover_color') ) ) : if( $id == 'accent_color' && jevelin_post_option( jevelin_page_id(), 'accent_color' ) ) : return jevelin_post_option( jevelin_page_id(), 'accent_color' ); elseif( $id == 'accent_hover_color' && jevelin_post_option( jevelin_page_id(), 'accent_hover_color' ) ) : return jevelin_post_option( jevelin_page_id(), 'accent_hover_color' ); elseif( $id == 'header_nav_active_color' && jevelin_post_option( jevelin_page_id(), 'header_nav_active_color' ) ) : return jevelin_post_option( jevelin_page_id(), 'header_nav_active_color' ); elseif( $id == 'footer_hover_color' && jevelin_post_option( jevelin_page_id(), 'footer_hover_color' ) ) : return jevelin_post_option( jevelin_page_id(), 'footer_hover_color' ); else : return fw_get_db_settings_option($id); endif; else : $option = fw_get_db_settings_option( $id ); if( !empty( $option ) || $option === false ) : return $option; elseif( !empty( $default ) || $default === false ) : return $default; else : return false; endif; endif; elseif( !empty( $default ) ) : return $default; else : return false; endif; } } endif; /** * Get theme options value */ if ( ! function_exists( 'jevelin_option_value' ) ) : function jevelin_option_value( $id = NULL, $key = NULL ) { if( $id && $key && function_exists('fw_get_db_settings_option') ) : $val = jevelin_option( $id ); if( isset( $val[$key] ) ) : return esc_attr( $val[$key] ); endif; else : return false; endif; } endif; /** * Get theme options image */ if ( ! function_exists( 'jevelin_option_image' ) ) : function jevelin_option_image( $id = NULL ) { if( function_exists('fw_get_db_settings_option') ) : $url = fw_get_db_settings_option( $id ); if( isset( $url['url'] ) ) : return esc_url( $url['url'] ); endif; else : return false; endif; } endif; /** * Get theme options thumbnail */ if ( ! function_exists( 'jevelin_get_thumb' ) ) : function jevelin_get_thumb( $id, $size = 'large' ) { if( isset( $id ) && $id > 0) : $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($id), $size ); if( isset($thumb['0']) && $thumb['0'] ) : return esc_url( $thumb['0'] ); endif; else : return false; endif; } endif; /** * Get theme options thumbnail */ if ( ! function_exists( 'jevelin_get_small_thumb' ) ) : function jevelin_get_small_thumb( $id, $size = 'post-thumbnail' ) { if( isset( $id ) && $id > 0) : $thumb = wp_get_attachment_image_src( $id, $size ); if( isset($thumb['0']) && $thumb['0'] ) : return esc_url( $thumb['0'] ); endif; else : return false; endif; } endif; /** * Get option image */ if ( ! function_exists( 'jevelin_get_image' ) ) : function jevelin_get_image( $id = NULL ) { if( isset( $id['url'] ) ) : return esc_url( $id['url'] ); elseif( isset( $id[0] ) ) : return esc_url( $id[0] ); else : return false; endif; } endif; /** * Get option image alt */ if ( ! function_exists( 'jevelin_get_image_alt' ) ) : function jevelin_get_image_alt( $id = NULL ) { if( is_object( $id ) || is_array( $id ) ) : if( isset( $id['attachment_id'] ) ) : $post = get_post( $id['attachment_id'] ); if( is_object( $post ) ) : if( $post->post_excerpt ) : return $post->post_excerpt; else : return $post->post_title; endif; endif; else : return false; endif; elseif( $id > 0 ) : $post = get_post( $id ); if( is_object( $post ) ) : if( $post->post_excerpt ) : return $post->post_excerpt; else : return $post->post_title; endif; endif; endif; } endif; /** * Get option image size */ if ( ! function_exists( 'jevelin_get_image_size' ) ) : function jevelin_get_image_size( $id, $size = 'large' ) { if( isset( $id['attachment_id'] ) && $id['attachment_id'] ) : $url = $id['attachment_id']; $thumb = wp_get_attachment_image_src( $url, $size ); if( isset($thumb['0']) && $thumb['0'] ) : return esc_url( $thumb['0'] ); else : return $id['url']; endif; else : return false; endif; } endif; /** * Get picker value */ if ( ! function_exists( 'jevelin_get_picker_value' ) ) : function jevelin_get_picker_value( $atts = NULL, $var = NULL ) { if( !is_null($atts) && isset($atts[key($atts)]) ) : return $atts[key($atts)]; else : return $var; endif; } endif; /** * Get picker */ if ( ! function_exists( 'jevelin_get_picker' ) ) : function jevelin_get_picker( $atts = NULL ) { if( is_array($atts) && $atts != NULL ) : $key = key($atts); if( isset($atts[$atts[$key]]) ) : return $atts[$atts[key($atts)]]; else : return false; endif; endif; } endif; /** * Get font option */ if ( ! function_exists( 'jevelin_font_option' ) ) : function jevelin_font_option( $id ) { $option = jevelin_option( $id ); $o = ''; if( isset($option['family']) && $option['family'] ) : $o.= 'font-family: "'.$option['family'].'"; '; endif; if( isset($option['color']) && $option['color'] ) : $o.= 'color: '.$option['color'].'; '; endif; if( isset($option['letter-spacing']) && $option['letter-spacing'] ) : $o.= 'letter-spacing: '.$option['letter-spacing'].'px; '; endif; if( isset($option['variation']) && $option['variation'] && $option['variation'] != '100' ) : if( $option['variation'] == 'regular' ) : $o.= 'font-weight: 400; '; else : $o.= 'font-weight: '.$option['variation'].'; '; endif; /*elseif( isset($option['weight']) && $option['weight'] ) : $o.= 'font-weight: '.$option['weight'].'; ';*/ endif; if( isset($option['size']) && $option['size'] ) : $o.= 'font-size: '.$option['size'].'px; '; endif; if( isset($option['line-height']) && $option['line-height'] ) : $o.= 'line-height: '.$option['line-height'].'px; '; endif; return $o; } endif; /** * Get font */ if ( ! function_exists( 'jevelin_get_font' ) ) : function jevelin_get_font( $option ) { $o = ''; if( isset($option['family']) && $option['family'] ) : $o.= 'font-family: "'.$option['family'].'"; '; endif; if( isset($option['color']) && $option['color'] ) : $o.= 'color: '.$option['color'].'; '; endif; if( isset($option['letter-spacing']) && $option['letter-spacing'] ) : $o.= 'letter-spacing: '.$option['letter-spacing'].'px; '; endif; if( isset($option['variation']) && $option['variation'] && $option['variation'] != '100' ) : if( $option['variation'] == 'regular' ) : $o.= 'font-weight: 400; '; else : $o.= 'font-weight: '.$option['variation'].'; '; endif; /*elseif( isset($option['weight']) && $option['weight'] ) : $o.= 'font-weight: '.$option['weight'].'; ';*/ endif; if( isset($option['size']) && $option['size'] ) : $o.= 'font-size: '.$option['size'].'px; '; endif; if( isset($option['line-height']) && $option['line-height'] ) : $o.= 'line-height: '.$option['line-height'].'px; '; endif; return $o; } endif; /** * Minify output */ if ( ! function_exists( 'jevelin_is_vc_front' ) ) : function jevelin_is_vc_front(){ return ( isset( $_GET['vc_editable'] ) && $_GET['vc_editable'] == true ) ? true : false; } endif; /** * Minify output */ if ( ! function_exists( 'jevelin_echo_style' ) ) : function jevelin_echo_style( $css ){ if( $css ) : ?> /Uis',"/[[:blank:]]+/"),array('',' '),str_replace(array("\n","\r","\t"),'',$buf)); } endif; /** * Count sidebar items */ if ( ! function_exists( 'jevelin_count_sidebar' ) ) : function jevelin_count_sidebar( $sidebar_id ) { $the_sidebars = wp_get_sidebars_widgets(); if( isset( $the_sidebars [$sidebar_id] ) && count( $the_sidebars[$sidebar_id] ) > 0 ) : return count( $the_sidebars[$sidebar_id] ); endif; } endif; /** * Remove tags */ if ( ! function_exists( 'jevelin_remove_tag' ) ) : function jevelin_remove_tag( $excerpt ) { $o = str_replace( array("

", "

"), "", $excerpt ); echo wp_kses( $o ); } endif; /** * Remove p tags */ if ( ! function_exists( 'jevelin_remove_p' ) ) : function jevelin_remove_p( $text ) { $text = preg_replace('/\<[\/]{0,1}p[^\>]*\>/i', '', $text); return $text; } endif; /** * Replace p with span */ if ( ! function_exists( 'jevelin_replace_p' ) ) : function jevelin_replace_p( $text ) { $text = str_replace( ' 0 ) { echo 'sh-header sh-header-'.$id.' sh-header-'.$id2; } else { echo 'sh-header sh-header-'.$id; } endif; echo $o; } endif; /** * Get footer status */ if ( ! function_exists( 'jevelin_footer_enabled' ) ) : function jevelin_footer_enabled() { if( defined('FW') ) : $footer1 = jevelin_post_option( jevelin_page_id(), 'footer_widgets', 'on' ); $footer2 = jevelin_option( 'footer_widgets', 'on' ); $footer3 = jevelin_count_sidebar('footer_widgets'); return ( $footer3 > 0 ? ( ( isset($footer1) && ( $footer1 == 'on' || $footer1 == 'off' ) && ! is_singular( 'product' ) ) ? $footer1 : ( (isset($footer2) && $footer2 ) ? $footer2 : false) ) : false ); else : return 'off'; endif; } endif; /** * Get footer copyrights status */ if ( ! function_exists( 'jevelin_copyrights_enabled' ) ) : function jevelin_copyrights_enabled() { if( defined('FW') ) : $copyright1 = jevelin_post_option( jevelin_page_id(), 'copyright_bar', 'on' ); $copyright2 = jevelin_option( 'copyright_bar', 'on' ); return ( isset($copyright1) && ( $copyright1 == 'on' || $copyright1 == 'off' )) ? $copyright1 : ( ( isset($copyright2) && $copyright2 ) ? $copyright2 : false ); else : return 'on'; endif; } endif; /** * Set excerpt more */ if ( ! function_exists( 'jevelin_new_excerpt_more' ) ) : function jevelin_new_excerpt_more( $more ) { return '...'; } add_filter( 'excerpt_more', 'jevelin_new_excerpt_more' ); endif; /** * Set excerpt lenght */ if ( ! function_exists( 'jevelin_new_excerpt_word_length' ) ) : function jevelin_new_excerpt_word_length($length) { return jevelin_option( 'post_desc', 45 ); } add_filter('excerpt_length', 'jevelin_new_excerpt_word_length', 9999 ); endif; /** * Show navigation not assigned */ if ( ! function_exists( 'jevelin_asign_menu' ) ) : function jevelin_asign_menu() { if( current_user_can( 'manage_options' ) ) : ?>
max_num_pages; $big = 999999999; // need an unlikely integer if( $total > 1 ) { if( !$current_page = get_query_var('paged') ) $current_page = 1; if( get_option('permalink_structure') ) { $format = 'page/%#%/'; } else { $format = '&paged=%#%'; } if( is_front_page() ) { if( get_query_var('page') ) : $page = get_query_var('page'); else : $page = get_query_var('paged'); endif; } else { $page = get_query_var('paged'); } if( $oldpagination == 1 ) : $base = '%_%'; $page = ( get_query_var('page') ) ? get_query_var('page') : 1; $format = '?page=%#%'; else : $base = str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ); endif; if( $new ) : echo '
'; ob_start(); echo paginate_links(array( 'base' => $base, 'format' => $format, 'current' => max( 1, $page ), 'total' => $total, 'mid_size' => 3, 'type' => 'list', 'prev_text' => $prev_arrow, 'next_text' => $next_arrow, ) ); $pagination = ob_get_contents(); ob_end_clean(); if( $oldpagination == 1 ) : $pagination = str_replace( "class='page-numbers' href=''>1", "class='page-numbers' href='?page=1'>1", $pagination ); endif; echo str_replace( 'page/1/', '', $pagination ); echo '
'; else : wp_link_pages( array() ); endif; } endif; } } /** * Show page links */ if ( !function_exists( 'jevelin_page_links' ) ) : function jevelin_page_links() { echo ''; } endif; /** * Woocommerce - change default pagination */ if( !function_exists('jevelin_woocommerce_pagination') ) : remove_action('woocommerce_pagination', 'jevelin_woocommerce_pagination', 10); function jevelin_woocommerce_pagination() { jevelin_pagination(); } add_action( 'woocommerce_pagination', 'jevelin_woocommerce_pagination', 10); endif; /** * Woocommerce - excerpt */ if( !function_exists('jevelin_woocommerce_product_excerpt') ) { function jevelin_woocommerce_product_excerpt() { if ( is_home() ) { echo ''; the_excerpt(); echo ''; } } add_action( 'woocommerce_after_shop_loop_item_title', 'jevelin_woocommerce_product_excerpt', 35, 2); } /** * Woocommerce - if related page */ if( !function_exists('jevelin_is_realy_woocommerce_page') ) : function jevelin_is_realy_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 ; } } return false; } endif; /** * Woocommerce - shop columns */ if( !function_exists('jevelin_wc_loop_shop_columns') ) : function jevelin_wc_loop_shop_columns() { if( jevelin_option('wc_columns') ) : return jevelin_option('wc_columns'); else : return 4; endif; } endif; /** * Woocommerce - remove related products */ if( !function_exists('jevelin_wc_remove_related_products') ) : function jevelin_wc_remove_related_products( $args ) { return array(); } endif; /** * WooCommerce - add Second Image on Hover * Source: https://github.com/jameskoster/woocommerce-product-image-flipper/blob/master/image-flipper.php */ if( !class_exists('Jevelin_WC_Image_Hover') ) : class Jevelin_WC_Image_Hover { public function __construct() { //add_action( 'wp_enqueue_scripts', array( $this, 'pif_scripts' ) ); // Enqueue the styles add_action( 'woocommerce_before_shop_loop_item_title', array( $this, 'jevelin_woocommerce_template_loop_second_product_thumbnail' ), 11 ); add_filter( 'post_class', array( $this, 'jevelin_product_has_gallery' ) ); } // Add pif-has-gallery class to products that have a gallery function jevelin_product_has_gallery( $classes ) { global $product; $post_type = get_post_type( get_the_ID() ); if ( ! is_admin() ) { if ( $post_type == 'product' ) { $attachment_ids = ( method_exists('WC_Product','get_gallery_attachment_ids') ) ? $product->get_gallery_image_ids() : $product->get_gallery_attachment_ids(); if ( $attachment_ids ) { $classes[] = 'pif-has-gallery'; } } } return $classes; } // Display the second thumbnails function jevelin_woocommerce_template_loop_second_product_thumbnail() { global $product, $woocommerce; $attachment_ids = $product->get_gallery_image_ids(); if ( $attachment_ids ) { $secondary_image_id = $attachment_ids['0']; echo '
'.wp_get_attachment_image( $secondary_image_id, 'shop_catalog', '', $attr = array( 'class' => 'secondary-image attachment-shop-catalog' ) ).'
'; } } } $jevelin_wc_image_hover = new Jevelin_WC_Image_Hover(); endif; /** * WooCommerce - Change paypal icon */ if( !function_exists('jevelin_wc_paypal') ) : function jevelin_wc_paypal($iconUrl) { return get_template_directory_uri() . '/img/paypal_icon.png'; } add_filter('woocommerce_paypal_icon', 'jevelin_wc_paypal'); endif; /** * WooCommerce - Update */ if( !function_exists( 'jevelin_header_wc_header_add_to_cart_fragment' ) ) : add_filter( 'woocommerce_add_to_cart_fragments', 'jevelin_header_wc_header_add_to_cart_fragment' ); function jevelin_header_wc_header_add_to_cart_fragment( $fragments ) { ob_start(); ?>
cart->cart_contents_count; ?>
'.$val.''; endif; } endif; /** * Popover */ if ( ! function_exists( 'jevelin_sticky_post' ) ) : function jevelin_sticky_post() { if( is_sticky() ) : echo ''; endif; } endif; /** * Popover */ if ( ! function_exists( 'jevelin_blog_overlay' ) ) : function jevelin_blog_overlay( $image = '', $link = '1', $lightbox = '1', $lightbox_group = '', $lightbox_name_val = '' ) { $lightbox_name = ( $lightbox_name_val ) ? $lightbox_name_val : 'lightcase'; if( !$image ) : $image = get_permalink(); endif; ?>
'; endif; echo '
'; if( $location == 'portfolio' ) : echo ''; endif; } endif; /** * Page Switch */ if ( ! function_exists( 'jevelin_page_switch' ) ) : function jevelin_page_switch( $prev_post = '', $content = '', $next_post = '' ) { echo '
'; } endif; /** * Export categories */ if ( ! function_exists( 'jevelin_show_categories' ) ) : function jevelin_show_categories() { $i = 0; $o = ''; if( is_single() ) : $limit_categories = 9999999; else : $limit_categories = 6; endif; $categories = get_the_category(); if( $categories ) : foreach( $categories as $category ) : if( $i <= $limit_categories ) : $o.= ''.$category->name.''; $i++; if( $i < count($categories) ) : $o.= ', '; endif; endif; endforeach; endif; if( $i > $limit_categories ) : $o.= '...'; endif; return $o; } endif; /** * Navigation - login */ if ( ! function_exists( 'jevelin_nav_wrap_login' ) ) : function jevelin_nav_wrap_login() { $elements = jevelin_option( 'header_elements' ); if ( class_exists( 'WooCommerce' ) && isset($elements['woo_account']) && $elements['woo_account'] == true ) : if ( !is_user_logged_in() ) : $val = esc_html__( 'Login', 'jevelin' ); else : $val = esc_html__( 'My Account', 'jevelin' ); endif; return ' '; endif; } endif; /** * Navigation - search */ if ( ! function_exists( 'jevelin_nav_wrap_search' ) ) : function jevelin_nav_wrap_search() { $elements = jevelin_option( 'header_elements' ); if( isset($elements['search']) && $elements['search'] == true ) : return ' '; endif; } endif; /** * Navigation - language switcher */ if ( ! function_exists( 'jevelin_nav_wrap_lang' ) ) : function jevelin_nav_wrap_lang() { $lang_option = jevelin_option( 'header_lang' ); $languages = array(); $current = ''; $dropdown = ''; // Polyland plugin if( $lang_option == 'polylang' && function_exists( 'pll_the_languages' ) ) : $languages = pll_the_languages( array( 'raw' => 1 ) ); foreach( $languages as $lang ) : if( $lang['current_lang'] ) : $current = $lang['slug']; endif; endforeach; foreach( $languages as $lang ) : $dropdown.= ''; endforeach; endif; // WPML plugin if( $lang_option == 'wpml' && function_exists( 'icl_get_languages' ) ) : $languages = icl_get_languages('skip_missing=0'); foreach( $languages as $lang ) : if( $lang['active'] ) : $current = $lang['language_code']; endif; endforeach; foreach( $languages as $lang ) : $dropdown.= ''; endforeach; endif; // Output if( count( $languages ) ) : return ' '; endif; } endif; /** * Navigation - social */ if ( ! function_exists( 'jevelin_nav_wrap_social' ) ) : function jevelin_nav_wrap_social() { $elements = jevelin_option( 'header_elements' ); if( isset($elements['social']) && $elements['social'] == true ) : return ' '; endif; } endif; /** * Navigation - cart */ if ( ! function_exists( 'jevelin_nav_wrap_cart' ) ) : function jevelin_nav_wrap_cart( $title = NULL, $show = 0 ) { $elements = jevelin_option( 'header_elements' ); if ( class_exists( 'WooCommerce' ) && ( isset($elements['woo_cart']) && $elements['woo_cart'] == true ) || $show == 1 ) { if( $title == true ) { $title = '
'.esc_html__( 'Cart', 'jevelin' ).'
'; } $cart = ''; if ( jevelin_get_the_widget( 'WC_Widget_Cart', 'title= ' ) ) { $cart = ' '; } return ' '; } } endif; /** * Mobile navigation - menu */ if ( ! function_exists( 'jevelin_nav_wrap_menu_mobile' ) ) : function jevelin_nav_wrap_menu_mobile() { return ' '; } endif; /** * Blog - meta one */ if ( ! function_exists( 'jevelin_meta_one' ) ) : function jevelin_meta_one() { $elements = jevelin_option( 'post_elements' ); ?>
'; endif; if( jevelin_option('social_facebook') ) : $o.= ' '; endif; if( jevelin_option('social_googleplus') ) : $o.= ' '; endif; if( jevelin_option('social_instagram') ) : $o.= ' '; endif; if( jevelin_option('social_youtube') ) : $o.= ' '; endif; if( jevelin_option('social_pinterest') ) : $o.= ' '; endif; if( jevelin_option('social_tumblr') ) : $o.= ' '; endif; if( jevelin_option('social_dribbble') ) : $o.= ' '; endif; if( jevelin_option('social_linkedIn') ) : $o.= ' '; endif; if( jevelin_option('social_skype') ) : $o.= ' '; endif; if( jevelin_option('social_spotify') ) : $o.= ' '; endif; if( jevelin_option('social_soundcloud') ) : $o.= ' '; endif; if( jevelin_option('social_flickr') ) : $o.= ' '; endif; if( jevelin_option('social_wordpress') ) : $o.= ' '; endif; if( is_array( jevelin_option('social_custom') ) ) : foreach( jevelin_option('social_custom') as $social ) : $o.= ' '; endforeach; endif; if( $location != 'footer' ) : $o.= '
'; endif; return $o; } endif; /** * Show search form */ if ( !function_exists( 'jevelin_search_form' ) ) { function jevelin_search_form( $form ) { $form = '
'; return $form; } add_filter( 'get_search_form', 'jevelin_search_form' ); } /** * Get logo height */ if ( !function_exists( 'jevelin_logo_height' ) ) { function jevelin_logo_height( $type = NULL ) { $logo_sizes_val = jevelin_option( 'header_logo_sizes' ); $logo_sizes_atts = jevelin_get_picker( $logo_sizes_val ); if( $type == 'responsive' ) : if( isset($logo_sizes_atts['responsive_height']) && $logo_sizes_atts['responsive_height'] > 0 ) : return intval( $logo_sizes_atts['responsive_height'] ).'px'; else : return 'auto'; endif; elseif( $type == 'sticky' ) : if( isset($logo_sizes_atts['sticky_height']) && $logo_sizes_atts['sticky_height'] > 0 ) : return intval( $logo_sizes_atts['sticky_height'] ).'px'; else : return 'auto'; endif; else : if( isset($logo_sizes_atts['standard_height']) && $logo_sizes_atts['standard_height'] > 0 ) : return intval( $logo_sizes_atts['standard_height'] ).'px'; else : return 'auto'; endif; endif; } } /** * Header Logo */ if( !function_exists('jevelin_header_logo') ) : function jevelin_header_logo() { if( jevelin_option( 'logo_status', true ) ) : $standard_logo = jevelin_option_image('logo'); /* Use Jevelin Logo if Logo is not uploaded */ if( !$standard_logo ) : $standard_logo = get_template_directory_uri().'/img/logo.png'; endif; $sticky_logo = ( jevelin_option_image('logo_sticky') ) ? jevelin_option_image('logo_sticky') : $standard_logo; $light_logo = ( jevelin_option_image('logo_light') ) ? jevelin_option_image('logo_light') : $standard_logo; $title_val = jevelin_option('logo_title'); $title = ( isset( $title_val['logo_title'] ) ) ? esc_attr( $title_val['logo_title'] ) : 'off'; $title_atts = jevelin_get_picker( $title_val ); if( jevelin_logo_height() && jevelin_logo_height() != 'auto' ) : $height = ' height="'.str_replace("px", "", jevelin_logo_height() ).'"'; else : $height = ''; endif; ?> 'post', 'posts_per_page' => -1, 'fields' => 'ids', 'order' => 'ASC' ) ); if( $posts->have_posts() ) : $current_post = $posts->post_count; foreach ( $posts->posts as $id ) : if( $id == get_the_ID() ) : $post_ok = true; elseif( $post_ok == false ) : $post_count++; endif; endforeach; return ''.$post_count.' / '.$posts->post_count.''; endif; } endif; /** * Convert color code to rgb or rgba */ if ( !function_exists( 'jevelin_hex2rgba' ) ) { function jevelin_hex2rgba($color, $opacity = false) { $default = 'rgb(0,0,0)'; //Return default if already rgb if (strpos($color, 'rgba(') !== false) : if( $opacity ) : return str_replace( ',1)', ','.$opacity.')', $color ); else : return $color; endif; endif; //Return default if no color provided if(empty($color)) return $default; //Sanitize $color if "#" is provided if ($color[0] == '#' ) { $color = substr( $color, 1 ); } //Check if color has 6 or 3 characters and get values if (strlen($color) == 6) { $hex = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] ); } elseif ( strlen( $color ) == 3 ) { $hex = array( $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2] ); } else { return $default; } //Convert hexadec to rgb $rgb = array_map('hexdec', $hex); //Check if opacity is set(rgba or rgb) if($opacity){ if(abs($opacity) > 1) $opacity = 1.0; $output = 'rgba('.implode(",",$rgb).','.$opacity.')'; } else { $output = 'rgb('.implode(",",$rgb).')'; } //Return rgb(a) color string return $output; } } /** * Show breadcrumbs tree */ if ( !function_exists( 'jevelin_breadcrumbs' ) ) { function jevelin_breadcrumbs( $args = array() ) { // Do not display on the homepage // Set default arguments $defaults = array( 'separator_icon' => '>', 'breadcrumbs_id' => 'breadcrumbs', 'breadcrumbs_classes' => 'breadcrumb-trail breadcrumbs', 'home_title' => esc_html__( 'Home', 'jevelin' ), ); // Parse any arguments added $args = apply_filters( 'ct_ignite_breadcrumbs_args', wp_parse_args( $args, $defaults ) ); // Set variable for adding separator markup $separator = ' ' . esc_attr( $args['separator_icon'] ) . ' '; // Get global post object global $post; /***** Begin Markup *****/ // Open the breadcrumbs $html = '
'; // Add Homepage link & separator (always present) $html .= '' . esc_attr( $args['home_title'] ) . ''; if ( !is_front_page() ) { $html .= $separator; } // Post if ( is_front_page() ) { //return; } elseif ( is_singular( 'post' ) ) { // Get post category info $category = get_the_category(); // Get category values $category_values = array_values( $category ); // Get last category post is in $last_category = end( $category_values ); // Get parent categories $cat_parents = rtrim( (string)get_category_parents( $last_category->term_id, true, ',' ), ',' ); // Convert into array $cat_parents = explode( ',', $cat_parents ); // Loop through parent categories and add to breadcrumb trail foreach ( $cat_parents as $parent ) { $html .= '' . wp_kses( $parent, wp_kses_allowed_html( 'a' ) ) . ''; $html .= $separator; } // add name of Post $html .= '' . get_the_title() . ''; } // Page elseif ( is_singular( 'page' ) ) { // if page has a parent page if ( $post->post_parent ) { // Get all parents $parents = get_post_ancestors( $post->ID ); // Sort parents into the right order $parents = array_reverse( $parents ); // Add each parent to markup foreach ( $parents as $parent ) { $html .= '' . get_the_title( $parent ) . ''; $html .= $separator; } } // Current page $html .= ' ' . get_the_title() . ''; } // Attachment elseif ( is_singular( 'attachment' ) ) { // Get the parent post ID $parent_id = $post->post_parent; // Get the parent post title $parent_title = get_the_title( $parent_id ); // Get the parent post permalink $parent_permalink = get_permalink( $parent_id ); // Add markup $html .= '' . esc_attr( $parent_title ) . ''; $html .= $separator; // Add name of attachment $html .= ' ' . get_the_title() . ''; } // Custom Post Types elseif ( is_singular() ) { // Get the post type $post_type = get_post_type(); // Get the post object $post_type_object = get_post_type_object( $post_type ); // Get the post type archive $post_type_archive = get_post_type_archive_link( $post_type ); // Add taxonomy link and separator $html .= '' . esc_attr( $post_type_object->labels->name ) . ''; $html .= $separator; // Add name of Post $html .= '' . $post->post_title . ''; } // Category elseif ( is_category() ) { // Get category object $parent = get_queried_object()->category_parent; // If there is a parent category... if ( $parent !== 0 ) { // Get the parent category object $parent_category = get_category( $parent ); // Get the link to the parent category $category_link = get_category_link($parent); // Output the markup for the parent category item $html .= '' . esc_attr( $parent_category->name ) . ''; $html .= $separator; } // Add category markup $html .= '' . single_cat_title( '', false ) . ''; } // Tag elseif ( is_tag() ) { // Add tag markup $html .= '' . single_tag_title( '', false ) . ''; } // Author elseif ( is_author() ) { // Add author markup $html .= '' . get_queried_object()->display_name . ''; } // Day elseif ( is_day() ) { // Add day markup $html .= '' . get_the_date() . ''; } // Month elseif ( is_month() ) { // Add month markup $html .= '' . get_the_date( 'F Y' ) . ''; } // Year elseif ( is_year() ) { // Add year markup $html .= '' . get_the_date( 'Y' ) . ''; } // Custom Taxonomy elseif ( is_archive() ) { // get the name of the taxonomy $custom_tax_name = get_queried_object()->name; // Add markup for taxonomy $html .= '' . esc_attr($custom_tax_name) . ''; } // Search elseif ( is_search() ) { // Add search markup $html .= '' . sprintf(esc_html__('Search Results for "%s"', 'jevelin'), get_search_query()) . ''; } // 404 elseif ( is_404() ) { // Add 404 markup $html .= '' . esc_html__( 'Error 404', 'jevelin' ) . ''; } else { $html .= '' . esc_attr( get_the_title( jevelin_page_id() ) ) . ''; } // Close breadcrumb container $html .= '
'; apply_filters( 'ct_ignite_breadcrumbs_filter', $html ); return wp_kses_post( $html ); } } /* * Search Page Results - Posts Only */ if( is_search() ) : function jevelin_search_results_postsonly( $query ) { if( jevelin_option( 'header_search_results', 'posts' ) == 'onlyposts' && $query->is_search) : $query->set('post_type', 'post'); endif; return $query; } add_filter( 'pre_get_posts', 'jevelin_search_results_postsonly' ); endif; /* * WordPress 5.0 compatibility */ if( is_admin() ) : if( !function_exists('jevelin_disable_block_editor_pt') && isset( $_GET['post'] ) && $_GET['post'] > 0 && isset( $_GET['action'] ) && $_GET['action'] == 'edit' && !isset( $_GET['vcv-gutenberg-editor'] ) ) : function jevelin_disable_block_editor_pt( $use_block_editor, $post_type ) { $use_block_editor = true; if( function_exists( 'is_plugin_active' ) && !is_plugin_active( 'classic-editor/classic-editor.php' ) ) : $id = ( isset( $_GET['post'] ) && $_GET['post'] > 0 ) ? intval( $_GET['post'] ) : 0; if( $id ) : $data = get_post_meta( $id, 'fw:opt:ext:pb:page-builder:json', 1 ); if( $data && $data != '[]' ) : $use_block_editor = false; endif; endif; if( isset( $_GET['classic-editor'] ) ) : $use_block_editor = false; endif; if( $use_block_editor == true ) : $post = get_post( $id ); if( $post && preg_match( '/vc_row/', $post->post_content ) ) : $use_block_editor = false; endif; endif; endif; return $use_block_editor; } add_filter('use_block_editor_for_post_type', 'jevelin_disable_block_editor_pt', 10, 2); endif; if( !function_exists('jevelin_fix_unyson_color_picker_issue') ) : function jevelin_fix_unyson_color_picker_issue() { if( function_exists( 'is_plugin_active' ) && !is_plugin_active( 'classic-editor/classic-editor.php' ) ) : wp_enqueue_script( 'wp-color-picker' ); endif; } endif; add_action( 'admin_enqueue_scripts', 'jevelin_fix_unyson_color_picker_issue' ); endif;