array( 'google' => true, 'font-weight' => '400', 'font-family' => 'Roboto', 'subsets' => 'latin-ext' ), 'himara_h_font' => array( 'google' => true, 'font-weight' => '600', 'font-family' => 'Jost', 'subsets' => 'latin-ext' ), 'himara_nav_font' => array( 'font-weight' => '900', 'font-family' => 'Roboto', 'subsets' => 'latin-ext' ), 'primary_color' => array( 'regular' => '#606060', 'hover' => '#606060', 'active' => '#b69854', ), 'menu_color' => array( 'regular' => '#32353c', 'hover' => '', 'active' => '', ), 'sub_menu_color' => array( 'regular' => '#32353c', 'hover' => '', 'active' => '', ), 'footer_language_switcher' => array( 'wpml' => false, 'polylang' => false, ), 'himara_blog_sidebar' => 'right', 'himara_page_sidebar' => 'right', ); $defaults = apply_filters( 'himara_modify_default_options', $defaults ); if ( isset( $defaults[$option] ) ) { return $defaults[$option]; } return false; } } /* -------------------------------------------------------------------------- * Get theme options * @since 1.0.0 * return 'false' if option is not found ---------------------------------------------------------------------------*/ if ( !function_exists( 'himara_get_option' ) ) { function himara_get_option( $option ) { global $himara_settings; if ( empty( $himara_settings ) ) { $himara_settings = get_option( 'himara_settings' ); } if ( empty( $himara_settings[$option] ) ) { $himara_settings[$option] = himara_default_options( $option ); } if ( isset( $himara_settings[$option] ) ) { return is_array( $himara_settings[$option] ) && isset( $himara_settings[$option]['url'] ) ? $himara_settings[$option]['url'] : $himara_settings[$option]; } else { return false; } } } /* -------------------------------------------------------------------------- * Translate options * @since 1.0.0 ---------------------------------------------------------------------------*/ if ( !function_exists( 'himara_get_translate_options' ) ): function himara_get_translate_options() { global $himara_translate; get_template_part( 'core/translate' ); $translate = apply_filters( 'himara_modify_translate_options', $himara_translate ); return $translate; } endif; /* -------------------------------------------------------------------------- * Check if variable is not empty * @since 1.0.0 ---------------------------------------------------------------------------*/ if ( !function_exists( 'himara_get_css_style' ) ) : function himara_get_css_style($property, $variable) { if ( !empty($variable) ) { echo esc_attr( $property.':'.$variable ); } else { return false; } } endif; /* -------------------------------------------------------------------------- * Compress dynamic CSS * @since 1.0.0 ---------------------------------------------------------------------------*/ if ( !function_exists( 'himara_compress_css_code' ) ) : function himara_compress_css_code( $code ) { // Remove Comments $code = preg_replace( '!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $code ); // Remove tabs, spaces, newlines, etc. $code = str_replace( array( "\r\n", "\r", "\n", "\t", ' ', ' ', ' ' ), '', $code ); return $code; } endif; /* -------------------------------------------------------------------------- * Generate dynamic CSS * @since 1.0.0 ---------------------------------------------------------------------------*/ if ( !function_exists( 'himara_generate_dynamic_css' ) ): function himara_generate_dynamic_css() { ob_start(); get_template_part( 'assets/css/dynamic-css' ); // Dynamic CSS (Theme Options) $dynamic_css = ob_get_contents(); ob_end_clean(); // Custom CSS (Additional CSS) $additional_css = himara_get_option( 'additional_css' ); return himara_compress_css_code( $dynamic_css.' '.$additional_css ); } endif; /*----------------------------------------------------------------------------------- * Outputs additional JavaScript code from theme options * @since 1.0.0 -----------------------------------------------------------------------------------*/ add_action( 'wp_enqueue_scripts', 'himara_wp_footer', 89 ); if ( !function_exists( 'himara_wp_footer' ) ): function himara_wp_footer() { //Additional JS $additional_js = trim( preg_replace( '/\s+/', ' ', himara_get_option( 'additional_js' ) ) ); if ( !empty( $additional_js ) ) { echo ''; } } endif; /* -------------------------------------------------------------------------- * Image Sizes * @since 1.0.0 ---------------------------------------------------------------------------*/ if ( !function_exists( 'himara_get_image_sizes' ) ): function himara_get_image_sizes() { $sizes = array( 'himara_image_size_480_480' => array( 'title' => esc_html__('480 x 480', 'himara'), 'w' => 480, 'h' => 480, 'crop' => true), 'himara_image_size_400_800' => array( 'title' => esc_html__('400 x 800', 'himara'), 'w' => 400, 'h' => 800, 'crop' => true), 'himara_image_size_600_400' => array( 'title' => esc_html__('600 x 400', 'himara'), 'w' => 600, 'h' => 400, 'crop' => true), 'himara_image_size_1170_500' => array( 'title' => esc_html__('1170 x 500', 'himara'), 'w' => 1170, 'h' => 500, 'crop' => true), 'himara_image_size_1920_800' => array( 'title' => esc_html__('1920 x 800', 'himara'), 'w' => 1920, 'h' => 800, 'crop' => true), ); $disable_img_sizes = himara_get_option( 'disable_img_sizes' ); if(!empty( $disable_img_sizes )){ $disable_img_sizes = array_keys( array_filter( $disable_img_sizes ) ); } if(!empty($disable_img_sizes) ){ foreach($disable_img_sizes as $size_id ){ unset( $sizes[$size_id]); } } $sizes = apply_filters( 'himara_modify_image_sizes', $sizes ); return $sizes; } endif; /* -------------------------------------------------------------------------- * Get branding * @since 1.0.0 ---------------------------------------------------------------------------*/ if ( !function_exists( 'himara_get_branding' ) ) { function himara_get_branding() { $header_layout = himara_get_option('header_layout'); $first_logo = himara_get_option( 'logo' ); $second_logo = himara_get_option( 'second_logo' ); $logo_height = himara_get_option( 'logo_height' ); $second_logo_height = himara_get_option( 'second_logo_height' ); $trasnparent_page_header = get_post_meta( get_the_ID(), 'himara_mtb_header_transparent', true ); $logo_height_final = $logo_height; $second_logo_height_final = $second_logo_height; // Transparent Header if ( $trasnparent_page_header == true ) { $header_first_logo = $second_logo; $header_second_logo = $first_logo; $logo_height_final = $second_logo_height; $second_logo_height_final = $logo_height; // Normal Header } elseif ( $header_layout === 'horizontal' ) { $header_first_logo = $first_logo; $header_second_logo = $first_logo; // Vertical Header } else { $header_first_logo = $first_logo; $header_second_logo = $second_logo; } if ( empty( $header_first_logo ) ) { $output = ' '.esc_html( get_bloginfo() ).' '; } else { $output = '
' ; } echo wp_kses_post( $output ); } } /* -------------------------------------------------------------------------- * Append menu text to main mobile menu * @since 1.0.0 ---------------------------------------------------------------------------*/ if(!function_exists('himara_append_text_mobile_menu')): add_filter('wp_nav_menu_items','mobile_menu_text', 10, 2); function mobile_menu_text( $nav, $args ) { if ( $args->theme_location == 'himara_main_menu' ) { $newmenuitem = ''; $nav = $newmenuitem.$nav; } return $nav; } endif; /* -------------------------------------------------------------------------- * @ Get blog pages * @ Return Boolean * @ Since 1.0.0 ---------------------------------------------------------------------------*/ if ( !function_exists( 'himara_is_blog' ) ): function himara_is_blog () { return ( is_archive() || is_author() || is_category() || is_home() || is_tag() || is_single() || is_search()); } endif; /* -------------------------------------------------------------------------- * @ Get Header Class * @ Return String (sticky header or/and transparent-header or/and semi-transparent-header) * @ since 1.0.0 ---------------------------------------------------------------------------*/ if ( !function_exists( 'himara_header_class' ) ) { function himara_header_class() { $himara_header_class = himara_get_option('header_layout'); if ( $himara_header_class == '' ) $himara_header_class = 'horizontal'; $himara_header_class = $himara_header_class.'-header '; $himara_mtb_transparent_header = get_post_meta(get_the_ID(), 'himara_mtb_header_transparent', true); $himara_mtb_semi_transparent_header = get_post_meta(get_the_ID(), 'himara_mtb_header_semi_transparent', true); $himara_mtb_fixed_header = get_post_meta(get_the_ID(), 'himara_mtb_header_sticky', true); // EB Fixed Header only for horizontal header if ( is_singular( 'eagle_rooms' ) ) { if ( get_post_meta(get_the_ID(), 'eagle_booking_mtb_room_header_sticky', true) == 1 && himara_get_option('header_layout') === 'horizontal') $himara_header_class .= 'sticky-header '; } // Get The Default Option if (empty($himara_mtb_fixed_header) && $himara_mtb_fixed_header != '0') { $himara_mtb_fixed_header = himara_get_option('header_sticky'); } if ( $himara_mtb_fixed_header == true && himara_get_option('header_layout') === 'horizontal' ) { $himara_header_class .= 'sticky-header '; } if ( $himara_mtb_transparent_header == true ) { $himara_header_class .= 'transparent-header '; } if ( $himara_mtb_semi_transparent_header == true ) { $himara_header_class .= 'semi-transparent-header '; } echo esc_attr( $himara_header_class ); } } /* -------------------------------------------------------------------------- * @ Body Class * @ Since 1.0.0 ---------------------------------------------------------------------------*/ if ( !function_exists( 'himara_body_class' ) ) { function himara_body_class() { // Get MTB $himara_header[] = 'himara-'.himara_get_option('header_layout').'-header'; $himara_header[] = himara_get_option('header_state'); return $himara_header; } } /* -------------------------------------------------------------------------- * @ Get Main Class * @ Return String (padding or no-padding) * @ Since 1.0.0 ---------------------------------------------------------------------------*/ if ( !function_exists( 'himara_main_class' ) ): function himara_main_class() { // Get MTB $himara_mtb_padding = get_post_meta(get_the_ID(), 'himara_mtb_padding', true); // Eagle Booking Plugin if ( is_singular( 'eagle_rooms' ) ) { $himara_mtb_padding = get_post_meta(get_the_ID(), 'eagle_booking_mtb_room_padding', true); } if ( $himara_mtb_padding == '' ) $himara_mtb_padding = true; if ( $himara_mtb_padding == true ) { $himara_main_class = 'padding'; } else { $himara_main_class = 'no-padding'; } echo esc_attr( $himara_main_class ); } endif; /* -------------------------------------------------------------------------- * @ Get Container Class * @ Return String (container or empty) * @ Since 1.0.0 ---------------------------------------------------------------------------*/ if ( !function_exists( 'himara_container_class' ) ): function himara_container_class() { $himara_mtb_container = get_post_meta(get_the_ID(), 'himara_mtb_container', true); // Eagle Booking Plugin if ( is_singular( 'eagle_rooms' ) ) { $himara_mtb_container = get_post_meta(get_the_ID(), 'eagle_booking_mtb_room_container', true); } // Get The Default Option if ( empty( $himara_mtb_container ) && $himara_mtb_container != '0') { $himara_mtb_container = himara_get_option('himara_container'); if ( empty( himara_get_option('himara_container') ) ) $himara_mtb_container = true; } if ( $himara_mtb_container == false ) { $himara_container_class = ''; } else { $himara_container_class = 'container'; } echo esc_attr( $himara_container_class ); } endif; /* -------------------------------------------------------------------------- * @ Get Sidebar * @ Return/Echo String (col-lg-12 or col-lg-9 and col-lg-3 and left or right or none) * @ Parameters column(string), echo(boolean) * @ Since 1.0.0 ---------------------------------------------------------------------------*/ if ( !function_exists( 'himara_sidebar' ) ): function himara_sidebar( $column = '', $echo = true ) { // MTB $himara_mtb_sidebar = get_post_meta( get_the_ID(), 'himara_mtb_sidebar', true ); // MTB of blog pages if (himara_is_blog()) { $himara_mtb_sidebar = get_post_meta(get_queried_object_id(), 'himara_mtb_sidebar', true); } // Eagle Booking (MTB) if ( is_singular( 'eagle_rooms' ) ) { $himara_mtb_sidebar = get_post_meta( get_the_ID(), 'eagle_booking_mtb_room_sidebar', true ); } // Default Options if ( empty( $himara_mtb_sidebar ) || $himara_mtb_sidebar == 'inherit' ) { if (himara_is_blog()) { $himara_mtb_sidebar = himara_get_option('himara_blog_sidebar'); } else { $himara_mtb_sidebar = himara_get_option('himara_page_sidebar'); } } // Initialize $himara_sidebar = ''; // Entry Class if ($column == 'entry') { if ( $himara_mtb_sidebar === 'none' || !is_active_sidebar('himara_default_sidebar') ) { $himara_sidebar .= 'col-lg-12'; } else { $himara_sidebar .= 'col-lg-9'; } // Sidebar Class } elseif ( $column === 'sidebar' ) { if ( $himara_mtb_sidebar !== 'none' ) { $himara_sidebar .= 'col-lg-3'; } // Sidebar Side } else { $himara_sidebar = $himara_mtb_sidebar; } // Return or Echo if($echo == true) { echo esc_attr( $himara_sidebar ); } else { return $himara_sidebar; } } endif; /* -------------------------------------------------------------------------- * @ Get Sidebar Side * @ Return String (left or right or none) * @ Since 1.0.0 ---------------------------------------------------------------------------*/ if ( !function_exists( 'himara_sidebar' ) ): function himara_sidebar() { $himara_mtb_sidebar = get_post_meta( get_the_ID(), 'himara_mtb_sidebar', true ); if ( empty( $himara_mtb_sidebar ) ) { $himara_mtb_sidebar = 'right'; } return $himara_mtb_sidebar; } endif; /* -------------------------------------------------------------------------- * @ Get Page Title * @ since 1.0.0 ---------------------------------------------------------------------------*/ if ( !function_exists( 'himara_page_title' ) ): function himara_page_title() { $page_title = get_post_meta(get_the_ID(), 'himara_mtb_title', true); if (himara_is_blog()) { $blog_post_page = get_option( 'page_for_posts' ); $page_title = get_post_meta($blog_post_page, 'himara_mtb_title', true); } if ( $page_title == true || $page_title == '' ) { return true; } else { return false; } } endif; /* -------------------------------------------------------------------------- * Get font option * @since 1.0.0 ---------------------------------------------------------------------------*/ if ( !function_exists( 'himara_get_font_option' ) ): function himara_get_font_option( $option = false ) { $font = himara_get_option( $option ); // $native_fonts = himara_get_native_fonts(); if ( is_array( $font['font-family'] ) ) { $font['font-family'] = "'".$font['font-family']."'"; } return $font; } endif; /* -------------------------------------------------------------------------- * Generate Google fonts links * @since 1.0.0 ---------------------------------------------------------------------------*/ if ( !function_exists( 'himara_generate_fonts_link' ) ): function himara_generate_fonts_link() { $fonts = array(); $fonts[] = himara_get_option( 'himara_main_font' ); $fonts[] = himara_get_option( 'himara_h_font' ); $fonts[] = himara_get_option( 'himara_nav_font' ); $unique = array(); $native = array(); $protocol = is_ssl() ? 'https://' : 'http://'; $link = array(); foreach ( $fonts as $font ) { if ( !in_array( $font['font-family'], $native ) ) { $temp = array(); if ( isset( $font['font-style'] ) ) { $temp['font-style'] = $font['font-style']; } if ( isset( $font['subsets'] ) ) { $temp['subsets'] = $font['subsets']; } if ( isset( $font['font-weight'] ) ) { $temp['font-weight'] = $font['font-weight']; } $unique[$font['font-family']][] = $temp; } } $subsets = array( 'latin' ); foreach ( $unique as $family => $items ) { $link[$family] = $family; $weight = array( '400' ); foreach ( $items as $item ) { //Check weight and style if ( isset( $item['font-weight'] ) && !empty( $item['font-weight'] ) ) { $temp = $item['font-weight']; if ( isset( $item['font-style'] ) && empty( $item['font-style'] ) ) { $temp .= $item['font-style']; } if ( !in_array( $temp, $weight ) ) { $weight[] = $temp; } } //Check subsets if ( isset( $item['subsets'] ) && !empty( $item['subsets'] ) ) { if ( !in_array( $item['subsets'], $subsets ) ) { $subsets[] = $item['subsets']; } } } $link[$family] .= ':'.implode( ",", $weight ); } if ( !empty( $link ) ) { $query_args = array( 'family' => urlencode( implode( '|', $link ) ), 'subset' => urlencode( implode( ',', $subsets ) ) ); $fonts_url = add_query_arg( $query_args, $protocol.'fonts.googleapis.com/css' ); return esc_url_raw( $fonts_url ); } return ''; } endif; /* -------------------------------------------------------------------------- * WP_Bootstrap_Navwalker * @since 1.0.0 ---------------------------------------------------------------------------*/ if ( ! class_exists( 'WP_Bootstrap_Navwalker' ) ) { class WP_Bootstrap_Navwalker extends Walker_Nav_Menu { public function start_lvl( &$output, $depth = 0, $args = array() ) { $indent = str_repeat( "\t", $depth ); $output .= "\n$indent