80, 'width' => 200, 'flex-height' => true, 'flex-width' => true, 'header-text' => array( 'site-title', 'site-description' ), ) ) ); /* Add image sizes */ $image_sizes = Bahotel_L_Settings::$image_sizes; if ( !empty( $image_sizes ) ) { foreach ( $image_sizes as $id => $size ) { add_image_size( $id, $size['width'], $size['height'], $size['crop'] ); } } // Register navigation menus. register_nav_menus( array( 'primary' => __( 'Primary Menu', 'ba-hotel-light' ) ) ); return; } ////////////////////////////////////// add_action( 'wp_enqueue_scripts', 'bahotel_l_enqueue_scripts', 30, 1 ); /** * Loads required styles and scripts. * */ function bahotel_l_enqueue_scripts(){ // Output Google fonts if set. $google_fonts = Bahotel_L_Settings::google_font_styles(); if ( $google_fonts ) { wp_enqueue_style( 'bahotel-l-gfonts', esc_url( $google_fonts ), false ); } wp_enqueue_style( 'dashicons' ); wp_enqueue_style( 'bahotel-l-linearicons' , BAHOTEL_L_URI . '/fonts/linearicons-free/web_font/style.css', false, '1.0.0' ); wp_enqueue_style( 'bahotel-l-elegantfont' , BAHOTEL_L_URI . '/fonts/elegant-font/css/style.min.css', false, '1.0.0' ); if (BAHOTEL_L_DEV){ //included into theme style.min.css $styles = array( 'normalize' => 'normalize.css', 'bootstrap' => 'bootstrap.min.css', ); foreach ( $styles as $id => $style ) { wp_enqueue_style( 'bahotel-l-' . $id, BAHOTEL_L_URI . '/css/' . $style, false, BAHOTEL_L_VERSION ); } wp_enqueue_style( 'bahotel-l-main' , BAHOTEL_L_URI . '/style.css', false, BAHOTEL_L_VERSION ); } else { //// main styles file wp_enqueue_style( 'bahotel-l-main' , BAHOTEL_L_URI . '/style.min.css', false, BAHOTEL_L_VERSION ); } //// custom styles wp_add_inline_style( 'bahotel-l-main', Bahotel_L_Settings::inline_styles() ); wp_enqueue_style( 'bahotel-l-slick' , BAHOTEL_L_URI . '/js/slick/slick.css', false, BAHOTEL_L_VERSION ); wp_enqueue_style( 'bahotel-l-slick-theme' , BAHOTEL_L_URI . '/js/slick/slick-theme.css', false, BAHOTEL_L_VERSION ); //Load comment reply js if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } $scripts = array( 'html5' => 'html5.js', 'skip-link-focus-fix' => 'skip-link-focus-fix.js', 'popper' => 'popper.min.js', 'bootstrap' => 'bootstrap.min.js', 'slick' => 'slick/slick.min.js', 'theme' => 'theme'.(BAHOTEL_L_DEV ? '' : '.min').'.js' ); foreach ( $scripts as $id => $script ) { wp_enqueue_script( 'bahotel-l-'.$id, BAHOTEL_L_URI .'/js/'. $script, array( 'jquery' ), BAHOTEL_L_VERSION, true ); } wp_script_add_data( 'bahotel-l-html5', 'conditional', 'lt IE 9' ); } /////////////////////////////// add_filter( 'style_loader_src', 'bahotel_l_remove_ver_css', 9999, 2 ); /** * Clear version arg in google font css url * */ function bahotel_l_remove_ver_css($src, $handle) { if ($handle == 'bahotel-l-gfonts' && strpos($src, 'ver=') !== false) { $src = remove_query_arg('ver', $src); } return $src; } /////////////////////////////// //add_filter('script_loader_tag', 'bahotel_l_async_defer_scripts', 10, 3); /** * Loads scripts as async or defer to improve site perfomance. * */ function bahotel_l_async_defer_scripts($tag, $handle, $src) { $scripts = array( 'bahotel-l-html5' => 1, 'bahotel-l-skip-link-focus-fix' => 1, 'bahotel-l-photoswipe' => 1, 'bahotel-l-photoswipe-ui' => 1, ); if (isset($scripts[$handle])) { return str_replace(' src', ' defer="defer" src', $tag); } return $tag; } ////////////////////////////////// add_action( 'widgets_init', 'bahotel_l_widgets_init', 10 ); function bahotel_l_widgets_init(){ foreach (Bahotel_L_Settings::$sidebars as $id => $sidebar){ $h_tag = $id == 'left' || $id == 'right' ? 'h3' : 'h2'; register_sidebar( array( 'id' => $id, 'name' => esc_html( $sidebar['name'] ), 'description' => (isset($sidebar['desc']) ? esc_html($sidebar['desc']) : ''), 'before_widget' => '', 'before_title' => '<'.$h_tag.' class="widget-title">', 'after_title' => ''.$h_tag.'>
' ) ); } return; } //////////////////// if ( ! isset( $content_width ) ) $content_width = 900; ////////////////////////////////////////////////// add_filter( 'wp_get_attachment_image_attributes', 'bahotel_l_post_thumbnail_sizes_attr', 10, 3 ); /** * Add custom sizes attribute to responsive image functionality for post thumbnails. * * @param array $attr Attributes for the image markup. * @param WP_Post $attachment Image attachment post. * @param string|array $size Requested size. Image size or array of width and height values * (in that order). Default 'thumbnail'. * * @return string Value for use in post thumbnail 'sizes' attribute. */ function bahotel_l_post_thumbnail_sizes_attr( $attr, $attachment, $size ) { if ( is_admin() ) { return $attr; } if ($size == 'bahotel_thumbnail_sm'){ $attr['sizes'] = '(max-width: 420px) 420px, (max-width: 870px) 870px, 100vw'; } elseif ( ! is_singular() ) { $attr['sizes'] = '100vw'; } return $attr; } ///////////////////////////// if ( ! function_exists( 'wp_body_open' ) ) { /** * Shim for wp_body_open, ensuring backwards compatibility with versions of WordPress older than 5.2. */ function wp_body_open() { do_action( 'wp_body_open' ); } } ////////////////////////////////////////////////// include_once BAHOTEL_L_DIR . '/includes/class-settings.php'; include_once BAHOTEL_L_DIR . '/includes/class-page-options.php'; include_once BAHOTEL_L_DIR . '/includes/class-nav-menu.php'; /** * Recommended plugins. */ include_once BAHOTEL_L_DIR . '/includes/functions-plugins.php'; /** * Theme administration. */ if ( is_admin() ) { include_once BAHOTEL_L_DIR . '/includes/class-redux.php'; include_once BAHOTEL_L_DIR . '/includes/class-cmb2-admin.php'; include_once BAHOTEL_L_DIR . '/includes/customizer.php'; } //////////////////////////////////////////////////////////// //// Functions section. //////////////////////////////////////////////////////////// include_once BAHOTEL_L_DIR . '/includes/template-functions.php';