version; return $theme_version; } /* Fallback menu /* --------------------------------------- */ function businessx_fb_menu() { echo '
'; } /* Count widgets and get their # /* position in sidebar /* ------------------------------------ */ function businessx_get_widget_position( $sidebar_name, $widget_base_ID ) { global $_wp_sidebars_widgets; if ( empty( $_wp_sidebars_widgets ) ) : $_wp_sidebars_widgets = get_option( 'sidebars_widgets', array() ); endif; $sidebars_widgets_count = $_wp_sidebars_widgets; if ( isset( $sidebars_widgets_count[ $sidebar_name ] ) ) : $key = array_search( $widget_base_ID, $sidebars_widgets_count[ $sidebar_name ] ) + 1; return intval( $key ); endif; } /* Output CSS classes based on a filter /* --------------------------------------- */ function businessx_occ( $filter = '', $new_classes = array(), $return = false ) { if( $filter != '' ) { $classes = array(); $classes = apply_filters( $filter, $classes ); $new_classes = apply_filters( $filter . '_new', $new_classes ); $new_classes = array_map( 'esc_attr', array_unique( array_merge( $classes, $new_classes ) ) ); $output = join( ' ', $new_classes ); if( $return ) { return $new_classes; } else { echo esc_attr( $output ); } } else { return ''; } } /* tag classes /* ------------------------------------ */ function businessx_html_tag_classes() { $check_preloader = get_theme_mod( 'preloader_enable', false ); $classes = array(); if( $check_preloader ) { $classes[] = 'js'; } if( has_filter( 'businessx_html_tag_classes___filter' )) { $classes = apply_filters( 'businessx_html_tag_classes___filter', $classes ); } $css_classes = join( ' ', $classes ); if( ! empty( $classes ) ) { echo ' class="' . esc_attr( $css_classes ) . '"'; } } /* Check front page template /* ------------------------------------ */ function businessx_front_pt() { $template = apply_filters( 'businessx_front_pt___filter', 'template-frontpage.php' ); if( is_page_template( $template ) ) { return true; } else { return false; } } /* Get heading template /* ------------------------------------ */ function businessx_get_heading_templ( $area = '', $type = '' ) { $new_area = str_replace( '-', '_', $area ); $filter = (string) 'businessx_heading___' . $new_area; if( $area != '' && $type != '' ) { $part_type = apply_filters( $filter, $type ); get_template_part( 'partials/headings/' . $area . '-heading', $part_type ); } } /* Show/hide sidebars /* ------------------------------------ */ function businessx_hide_sidebar( $sidebar_type = NULL ) { global $post; $sidebar = (string) $sidebar_type; $post_global = get_theme_mod( 'sidebars_post_disable', false ); $page_global = get_theme_mod( 'sidebars_page_disable', false ); if( ! empty( $post ) ) { $pid = $post->ID; $display_sidebar = get_post_meta( $pid, "businessx_{$sidebar}_hide_sidebar", true ); } if( is_single() ) { if( $post_global != true ) { if( isset( $display_sidebar ) ) { return (bool) $display_sidebar; } else { return false; } } else { return true; } } if( is_page() ) { if( $page_global != true ) { if( isset( $display_sidebar ) ) { return (bool) $display_sidebar; } else { return false; } } else { return true; } } } /* Parallax /* ------------------------------------ */ // Output the necessary data to enable the Parallax effect on. // Sections function businessx_section_parallax( $enabled, $bgimg, $return = false ) { $background = get_theme_mod( $bgimg, '' ); $parallax = get_theme_mod( $enabled, false ); $output = ''; if( $bgimg != '' && $parallax ) { $output = ' data-parallax="scroll" data-speed="0.5" data-bleed="50" data-image-src="' . esc_url( $background ) . '" style="background: none !important;"'; } if( $return ) { return $output; } else { echo $output; } } // Custom headers function businessx_ch_parallax( $return = false ) { $ch = get_header_image(); $parallax = get_theme_mod( 'enable_parallax_custom_headers', false ); $output = ''; if( ! empty( $ch ) && $parallax ) { $output = ' data-parallax="scroll" data-speed="0.5" data-image-src="' . esc_url( $ch ) . '" style="background: none !important;"'; } if( $return ) { return $output; } else { echo $output; } } // Single/Pages function businessx_sp_parallax( $return = false ) { global $post; $pid = $post->ID; $size = apply_filters( 'businessx_sp_parallax___thumb_size', 'full' ); $ch = get_header_image(); $parallax = get_theme_mod( 'posts_single_featured_parallax', false ); $output = ''; if ( has_post_thumbnail() && $parallax ) { $large_image = wp_get_attachment_image_src( get_post_thumbnail_id( $pid ), $size ); if ( ! empty( $large_image[0] ) ) { $large_image_url = $large_image[0]; $output = ' data-parallax="scroll" data-speed="0.5" data-image-src="' . esc_url( $large_image_url ) . '" style="background: none !important;"'; } } if( $return ) { return $output; } else { echo $output; } } // Check if it's enbled and add a class; function businessx_parallax_check( $enabled, $return = false ) { $parallax = get_theme_mod( $enabled, false ); if( is_customize_preview() && $parallax ) { if( $return ) { return ' parallaxon'; } else { echo ' parallaxon'; } } } /* Background options /* ------------------------------------ */ // Background repeat function businessx_bg_options_repeat() { $options = apply_filters( 'businessx_bg_options___repeat', $options = array( 'repeat' => esc_html__( 'repeat', 'businessx' ), 'repeat-x' => esc_html__( 'repeat-x', 'businessx' ), 'repeat-y' => esc_html__( 'repeat-y', 'businessx' ), 'no-repeat' => esc_html__( 'no-repeat', 'businessx' ), 'initial' => esc_html__( 'initial', 'businessx' ), ) ); return $options; } // Background position function businessx_bg_options_position() { $options = apply_filters( 'businessx_bg_options___position', $options = array( 'left top' => esc_html__( 'left top', 'businessx' ), 'left center' => esc_html__( 'left center', 'businessx' ), 'left bottom' => esc_html__( 'left bottom', 'businessx' ), 'right top' => esc_html__( 'right top', 'businessx' ), 'right center' => esc_html__( 'right center', 'businessx' ), 'right bottom' => esc_html__( 'right bottom', 'businessx' ), 'center top' => esc_html__( 'center top', 'businessx' ), 'center center' => esc_html__( 'center center', 'businessx' ), 'center bottom' => esc_html__( 'center bottom', 'businessx' ), ) ); return $options; } // Background size function businessx_bg_options_size() { $options = apply_filters( 'businessx_bg_options___size', $options = array( 'auto' => esc_html__( 'auto', 'businessx' ), 'cover' => esc_html__( 'cover', 'businessx' ), 'contain' => esc_html__( 'contain', 'businessx' ), ) ); return array_map( 'esc_attr', array_unique( $options ) ); } /* Opacity options /* ------------------------------------ */ function businessx_opacity_options( $multi = false, $simple = false ) { $options = array(); if( ! $simple ) { if( $multi ) { $options = apply_filters( 'businessx_opacity_options___select_multi', $options = array( array( 'value' => "0", 'title' => esc_html__( 'Transparent', 'businessx' ), 'disabled' => false ), array( 'value' => '0.1', 'title' => esc_html__( '10%', 'businessx' ), 'disabled' => false ), array( 'value' => '0.2', 'title' => esc_html__( '20%', 'businessx' ), 'disabled' => false ), array( 'value' => '0.3', 'title' => esc_html__( '30%', 'businessx' ), 'disabled' => false ), array( 'value' => '0.4', 'title' => esc_html__( '40%', 'businessx' ), 'disabled' => false ), array( 'value' => '0.5', 'title' => esc_html__( '50%', 'businessx' ), 'disabled' => false ), array( 'value' => '0.6', 'title' => esc_html__( '60%', 'businessx' ), 'disabled' => false ), array( 'value' => '0.7', 'title' => esc_html__( '70%', 'businessx' ), 'disabled' => false ), array( 'value' => '0.8', 'title' => esc_html__( '80%', 'businessx' ), 'disabled' => false ), array( 'value' => '0.9', 'title' => esc_html__( '90%', 'businessx' ), 'disabled' => false ), array( 'value' => "1", 'title' => esc_html__( '100%', 'businessx' ), 'disabled' => false ), ) ); } else { $options = apply_filters( 'businessx_opacity_options___select', $options = array( '.0' => esc_html__( 'Transparent', 'businessx' ), '0.1' => esc_html__( '10%', 'businessx' ), '0.2' => esc_html__( '20%', 'businessx' ), '0.3' => esc_html__( '30%', 'businessx' ), '0.4' => esc_html__( '40%', 'businessx' ), '0.5' => esc_html__( '50%', 'businessx' ), '0.6' => esc_html__( '60%', 'businessx' ), '0.7' => esc_html__( '70%', 'businessx' ), '0.8' => esc_html__( '80%', 'businessx' ), '0.9' => esc_html__( '90%', 'businessx' ), '1' => esc_html__( '100%', 'businessx' ), ) ); } } else { $options = apply_filters( 'businessx_opacity_options___select_simple', array( "0", '0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9', "1" ) ); } return $options; } /* Converts hex to rgb vaules /* ------------------------------------ */ function businessx_hex2rgb( $hex, $ret = true ) { $hex = str_replace( "#", "", $hex ); if(strlen($hex) == 3) { $r = hexdec(substr($hex,0,1).substr($hex,0,1)); $g = hexdec(substr($hex,1,1).substr($hex,1,1)); $b = hexdec(substr($hex,2,1).substr($hex,2,1)); } else { $r = hexdec(substr($hex,0,2)); $g = hexdec(substr($hex,2,2)); $b = hexdec(substr($hex,4,2)); } $output = $r . ',' . $g . ','. $b; if( $ret ) { return (string) $output; } else { echo (string) $output; } } /* Converts hex to rgba vaules /* ------------------------------------ */ function businessx_hex2rgba($hex, $alpha = 1, $ret = true) { $hex = str_replace("#", "", $hex); if(strlen($hex) == 3) { $r = hexdec(substr($hex,0,1).substr($hex,0,1)); $g = hexdec(substr($hex,1,1).substr($hex,1,1)); $b = hexdec(substr($hex,2,1).substr($hex,2,1)); } else { $r = hexdec(substr($hex,0,2)); $g = hexdec(substr($hex,2,2)); $b = hexdec(substr($hex,4,2)); } $output = $r . ',' . $g . ','. $b . ',' . $alpha; if( $ret ) { return (string) $output; } else { echo (string) $output; } } /* Display post terms /* ------------------------------------ */ function businessx_terms( $post_id = '', $type = '' ) { $terms = get_the_terms( $post_id, $type ); if ( $terms && ! is_wp_error( $terms ) ) { $term_links = array(); foreach ( $terms as $term ) { $term_links[] = $term->name; } $output = join( ", ", $term_links ); echo esc_html( $output ); } } /* Check if Jetpack/modules are /* enabled /* ------------------------------------ */ function businessx_jetpack_check( $module = '' ) { if ( class_exists( 'Jetpack' ) && in_array( $module, Jetpack::get_active_modules() ) ) { return true; } else { return false; } } /* Sharedaddy options /* ------------------------------------ */ function businessx_sharedaddy_type_check( $type = '' ) { $sharedaddy = get_option( 'sharing-options' ); if( ! empty( $sharedaddy ) ) { $display_on = $sharedaddy[ 'global' ][ 'show' ]; if( in_array( $type, $display_on, true ) ) { return true; } else { return false; } } else { return false; } } /* Px to em /* ------------------------------------ */ function businessx_pxtoem( $target = 18, $base = 18, $echo = false ) { $pattern = '/^(?:\d*\.)?\d+$/'; if( preg_match( $pattern, $base ) && $base > 0 ) { if( preg_match( $pattern, $target ) && $target > 0 ) { $quotient = $target / $base; $result = number_format( $quotient, 4, '.', '' ) . 'em'; if( $echo ) { echo esc_html( $result ); } else { return esc_html( $result ); } } } } /* Post meta /* ------------------------------------ */ function businessx_post_meta( $item_pre = NULL, $item_suf = NULL, $show_more = true, $show_author = false, $show_date = true, $show_category = true, $show_sticky = true, $show_portfolio = true ) { global $post; $item_pre = ! empty( $item_pre ) ? $item_pre : '