450, 'height' => 200, 'flex-width' => true, 'flex-height' => true, ); add_theme_support( 'custom-logo', $custom_logo_defaults ); // Add theme support for Custom Header. $custom_header_defaults = array( 'width' => 1300, 'height' => 500, 'flex-width' => true, 'flex-height' => true, 'default-image' => esc_url( get_template_directory_uri() ) .'/assets/images/header_bg.jpg', 'default-text-color' => '111', ); add_theme_support( 'custom-header', $custom_header_defaults ); // Add theme support for Custom Background. $custom_background_defaults = array( 'default-color' => '', ); add_theme_support( 'custom-background', $custom_background_defaults ); // Set the default content width. $GLOBALS['content_width'] = 960; // This theme uses wp_nav_menu() in two locations register_nav_menus( array( 'top' => __( 'Top Menu', 'bard' ), 'main' => __( 'Main Menu', 'bard' ), 'footer' => __( 'Footer Menu', 'bard' ), ) ); // Switch default core markup for search form, comment form, and comments to output valid HTML5 add_theme_support( 'html5', array( 'comment-form', 'comment-list', 'gallery', 'caption', ) ); // Gutenberg Embeds add_theme_support( 'responsive-embeds' ); // WooCommerce add_theme_support( 'woocommerce' ); add_theme_support( 'wc-product-gallery-zoom' ); add_theme_support( 'wc-product-gallery-lightbox' ); add_theme_support( 'wc-product-gallery-slider' ); // Theme Activation Notice add_action( 'admin_notices', 'bard_activation_notice' ); add_action( 'admin_notices', 'bard_classic_widgets_notice' ); } add_action( 'after_setup_theme', 'bard_setup' ); /* ** Notice after Theme Activation and Update. */ function bard_activation_notice() { if ( isset($_GET['page']) ) { return; } global $pagenow; global $current_user; $user_id = $current_user->ID; $theme_data = wp_get_theme(); $theme_vers = str_replace( '.', '_', $theme_data->get( 'Version' ) ); $nonce = wp_create_nonce( esc_html( $theme_data->get( 'TextDomain' ) ) . $theme_vers . '_notice_ignore_nonce' ); // Add the nonce to the dismiss button URL $dismiss_url = add_query_arg( array( esc_html( $theme_data->get( 'TextDomain' ) ) . $theme_vers . '_notice_ignore' => '0', '_wpnonce' => $nonce ) ); if ( ! get_user_meta( $user_id, esc_html( $theme_data->get( 'TextDomain' ) ) . $theme_vers .'_notice_ignore' ) ) { echo '
'; } } function bard_notice_ignore() { global $current_user; $theme_data = wp_get_theme(); $user_id = $current_user->ID; $theme_vers = str_replace( '.', '_', $theme_data->get( 'Version' ) ); /* If user clicks to ignore the notice, check the nonce before proceeding */ if ( isset( $_GET[ esc_html( $theme_data->get( 'TextDomain' ) ) . $theme_vers . '_notice_ignore' ] ) && '0' == $_GET[ esc_html( $theme_data->get( 'TextDomain' ) ) . $theme_vers . '_notice_ignore' ] && check_admin_referer( esc_html( $theme_data->get( 'TextDomain' ) ) . $theme_vers . '_notice_ignore_nonce' ) ) { add_user_meta( $user_id, esc_html( $theme_data->get( 'TextDomain' ) ) . $theme_vers . '_notice_ignore', 'true', true ); } } add_action( 'admin_init', 'bard_notice_ignore' ); function bard_erase_ignored_notice() { global $current_user; $theme_data = wp_get_theme(); $user_id = $current_user->ID; $theme_vers = str_replace( '.', '_', $theme_data->get( 'Version' ) ); delete_user_meta( $user_id, esc_html( $theme_data->get( 'TextDomain' ) ) . $theme_vers .'_notice_ignore' ); } add_action('after_switch_theme', 'bard_erase_ignored_notice'); function bard_admin_scripts() { // Theme Activation Notice wp_enqueue_style( 'bard-admin', get_theme_file_uri( '/assets/css/admin.css' ) ); } add_action( 'admin_enqueue_scripts', 'bard_admin_scripts' ); /* ** Notice for Classic Widgets Editor. */ function bard_classic_widgets_notice() { $screen = get_current_screen(); if ( ! $screen || 'widgets' !== $screen->base || file_exists(ABSPATH . 'wp-content/plugins/classic-widgets/classic-widgets.php') ) { return; } ?> ' . "\n", esc_url( get_bloginfo( 'pingback_url' ) ) ); } } add_action( 'wp_head', 'bard_pingback_header' ); /* ** Enqueue scripts and styles */ function bard_scripts() { // Theme Stylesheet wp_enqueue_style( 'bard-style', get_stylesheet_uri(), array(), '1.4.9.8' ); // FontAwesome Icons wp_enqueue_style( 'fontawesome', get_theme_file_uri( '/assets/css/fontawesome/all.min.css' ) ); // Fontello Icons wp_enqueue_style( 'fontello', get_theme_file_uri( '/assets/css/fontello.css' ) ); // Slick Slider wp_enqueue_style( 'slick', get_theme_file_uri( '/assets/css/slick.css' ) ); // Scrollbar wp_enqueue_style( 'scrollbar', get_theme_file_uri( '/assets/css/perfect-scrollbar.css' ) ); // WooCommerce wp_enqueue_style( 'bard-woocommerce', get_theme_file_uri( '/assets/css/woocommerce.css' ) ); // Theme Responsive CSS wp_enqueue_style( 'bard-responsive', get_theme_file_uri( '/assets/css/responsive.css' ) ); // Enqueue Custom Scripts wp_enqueue_script( 'bard-plugins', get_theme_file_uri( '/assets/js/custom-plugins.js' ), array( 'jquery' ), false, true ); wp_enqueue_script( 'bard-custom-scripts', get_theme_file_uri( '/assets/js/custom-scripts.js' ), array( 'jquery' ), false, true ); // Comment reply link if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } add_action( 'wp_enqueue_scripts', 'bard_scripts' ); /* ** Google Fonts */ function bard_arizonia_font_url() { $font_url = ''; if ( 'off' !== _x( 'on', 'Google font: on or off', 'bard' ) ) { $font_url = add_query_arg( 'family', urlencode( 'Arizonia:300,300i,400,400i,500,500i,600,600i,700,700i' ), "//fonts.googleapis.com/css" ); } return $font_url; } function bard_montserrat_font_url() { $font_url = ''; if ( 'off' !== _x( 'on', 'Google font: on or off', 'bard' ) ) { $font_url = add_query_arg( 'family', urlencode( 'Montserrat:300,300i,400,400i,500,500i,600,600i,700,700i' ), "//fonts.googleapis.com/css" ); } return $font_url; } function bard_opensans_font_url() { $font_url = ''; if ( 'off' !== _x( 'on', 'Google font: on or off', 'bard' ) ) { $font_url = add_query_arg( 'family', urlencode( 'Open Sans:400,400i,600,600i,700,700i' ), "//fonts.googleapis.com/css" ); } return $font_url; } function bard_kalam_font_url() { $font_url = ''; if ( 'off' !== _x( 'on', 'Google font: on or off', 'bard' ) ) { $font_url = add_query_arg( 'family', urlencode( 'Kalam' ), "//fonts.googleapis.com/css" ); } return $font_url; } function bard_rokkitt_font_url() { $font_url = ''; if ( 'off' !== _x( 'on', 'Google font: on or off', 'bard' ) ) { $font_url = add_query_arg( 'family', urlencode( 'Rokkitt' ), "//fonts.googleapis.com/css" ); } return $font_url; } // Enqueue Fonts function bard_gfonts_scripts() { wp_enqueue_style( 'bard-montserratr-font', bard_montserrat_font_url(), array(), '1.0.0' ); wp_enqueue_style( 'bard-opensans-font', bard_opensans_font_url(), array(), '1.0.0' ); // Load Arizonia if selected if ( bard_options( 'typography_logo_family' ) == 'Arizonia' || bard_options( 'typography_nav_family' ) == 'Arizonia' ) { wp_enqueue_style( 'bard-arizonia-font', bard_arizonia_font_url(), array(), '1.0.0' ); } // Load Kalam if selected if ( bard_options( 'typography_logo_family' ) == 'Kalam' || bard_options( 'typography_nav_family' ) == 'Kalam' ) { wp_enqueue_style( 'bard-kalam-font', bard_kalam_font_url(), array(), '1.0.0' ); } // Load Rokkitt if selected if ( bard_options( 'typography_logo_family' ) == 'Rokkitt' || bard_options( 'typography_nav_family' ) == 'Rokkitt' ) { wp_enqueue_style( 'bard-rokkitt-font', bard_rokkitt_font_url(), array(), '1.0.0' ); } } add_action( 'wp_enqueue_scripts', 'bard_gfonts_scripts' ); /* ** Register widget areas. */ function bard_widgets_init() { register_sidebar( array( 'name' => __( 'Right Sidebar', 'bard' ), 'id' => 'sidebar-right', 'description' => __( 'Add widgets here to appear in your sidebar.', 'bard' ), 'before_widget' => '', 'before_title' => '', ) ); register_sidebar( array( 'name' => __( 'Left Sidebar', 'bard' ), 'id' => 'sidebar-left', 'description' => __( 'Add widgets here to appear in your sidebar.', 'bard' ), 'before_widget' => '', 'before_title' => '', ) ); register_sidebar( array( 'name' => __( 'Sidebar Alt', 'bard' ), 'id' => 'sidebar-alt', 'description' => __( 'Add widgets here to appear in your alternative/fixed sidebar.', 'bard' ), 'before_widget' => '', 'before_title' => '', ) ); register_sidebar( array( 'name' => __( 'Footer Widgets', 'bard' ), 'id' => 'footer-widgets', 'description' => __( 'Add widgets here to appear in your footer.', 'bard' ), 'before_widget' => '', 'before_title' => '', ) ); register_sidebar( array( 'name' => __( 'Instagram Widget', 'bard' ), 'id' => 'instagram-widget', 'description' => __( 'Add widget here to appear in your Footer Instagram Area.', 'bard' ), 'before_widget' => '', 'before_title' => ''. esc_html( wp_trim_words( get_the_excerpt(), $limit ) ) .'
'; } } /* ** Custom Functions */ // HEX to RGBA Converter function bard_hex2rgba( $color, $opacity = 1 ) { // remove '#' from string $color = substr( $color, 1 ); // get values from string $hex = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] ); // convert HEX to RGB $rgb = array_map( 'hexdec', $hex ); // convert HEX to RGBA $output = 'rgba('. implode( ",", $rgb ) .', '. $opacity .')'; return $output; } // Social Media if ( ! function_exists( 'bard_social_media' ) ) { function bard_social_media( $class, $title ) { $social_window = ( bard_options( 'social_media_window' ) === true )?'_blank':'_self'; ?> '; } if ( in_array( $icon, $social_icons_fas ) ) { echo ''; } } } // function_exists( 'bard_social_media' ) // Related Posts if ( ! function_exists( 'bard_related_posts' ) ) { function bard_related_posts( $title, $orderby ) { if ( $orderby === 'none' ) { return; } global $post; $current_categories = get_the_category(); if ( $current_categories ) { $first_category = $current_categories[0]->term_id; // Random if ( $orderby === 'random' ) { $args = array( 'post_type' => 'post', 'post__not_in' => array( $post->ID ), 'orderby' => 'rand', 'posts_per_page' => 3, 'ignore_sticky_posts' => 1, 'meta_query' => array( array( 'key' => '_thumbnail_id', 'compare' => 'EXISTS' ), ) ); // Similar } else { $args = array( 'post_type' => 'post', 'category__in' => array( $first_category ), 'post__not_in' => array( $post->ID ), 'orderby' => 'rand', 'posts_per_page' => 3, 'ignore_sticky_posts' => 1, 'meta_query' => array( array( 'key' => '_thumbnail_id', 'compare' => 'EXISTS' ), ) ); } $similar_posts = new WP_Query( $args ); if ( $similar_posts->have_posts() ) { ?> '; $html .= ''; $html .= ''; $html .= ''; $html .= ''; return $html; return $html; } add_filter( 'get_search_form', 'bard_custom_search_form' ); /* ** Comments Form Section */ if ( ! function_exists( 'bard_comments' ) ) { function bard_comments ( $comment, $args, $depth ) { $_GLOBAL['comment'] = $comment; if (get_comment_type() == 'pingback' || get_comment_type() == 'trackback' ) : ?>