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' ),
) );
// 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',
) );
// 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
global $pagenow;
if ( is_admin() && ('themes.php' == $pagenow) && isset( $_GET['activated'] ) ) {
add_action( 'admin_notices', 'bard_activation_notice' );
}
}
add_action( 'after_setup_theme', 'bard_setup' );
// Notice after Theme Activation
function bard_activation_notice() {
echo '
';
}
/**
* Add a pingback url auto-discovery header for singularly identifiable articles.
*/
function bard_pingback_header() {
if ( is_singular() && pings_open() ) {
printf( '' . "\n", 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() );
// 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_playfair_font_url() {
$font_url = '';
if ( 'off' !== _x( 'on', 'Google font: on or off', 'bard' ) ) {
$font_url = add_query_arg( 'family', urlencode( 'Playfair Display:400,700' ), "//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:400italic,400,600italic,600,700italic,700' ), "//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-playfair-font', bard_playfair_font_url(), array(), '1.0.0' );
wp_enqueue_style( 'bard-opensans-font', bard_opensans_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' => __( 'Sidebar Right', 'bard' ),
'id' => 'sidebar-right',
'description' => __( 'Add widgets here to appear in your sidebar.', 'bard' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Sidebar Left', 'bard' ),
'id' => 'sidebar-left',
'description' => __( 'Add widgets here to appear in your sidebar.', 'bard' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_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' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Footer Widgets', 'bard' ),
'id' => 'footer-widgets',
'description' => __( 'Add widgets here to appear in your footer.', 'bard' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_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' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
) );
}
add_action( 'widgets_init', 'bard_widgets_init' );
/*
** Custom Image Sizes
*/
add_image_size( 'bard-slider-full-thumbnail', 1080, 540, true );
add_image_size( 'bard-full-thumbnail', 1140, 0, true );
add_image_size( 'bard-grid-thumbnail', 500, 380, true );
add_image_size( 'bard-list-thumbnail', 300, 300, true );
add_image_size( 'bard-single-navigation', 75, 75, true );
/*
** Main Menu Fallback
*/
function bard_main_menu_fallback() {
if ( current_user_can( 'edit_theme_options' ) ) {
echo '';
}
}
/*
** Random Post Button
*/
if ( ! function_exists( 'bard_random_post_button' ) ) {
function bard_random_post_button() {
$args = array(
'post_type' => 'post',
'orderby' => 'rand',
'posts_per_page' => 1
);
$random_post = new WP_Query( $args );
while ( $random_post->have_posts() ) : $random_post->the_post(); ?>
%2$s',
esc_url( get_permalink( get_the_ID() ) ),
/* translators: %s: Name of current post */
sprintf( __( 'Continue reading "%s"', 'bard' ), get_the_title( get_the_ID() ) )
);
return 2000;
}
add_filter( 'excerpt_length', 'bard_excerpt_length', 999 );
function bard_new_excerpt( $link ) {
if ( is_admin() ) {
return $link;
}
$link = sprintf( '%2$s
',
esc_url( get_permalink( get_the_ID() ) ),
/* translators: %s: Name of current post */
sprintf( __( 'Continue reading "%s"', 'bard' ), get_the_title( get_the_ID() ) )
);
return '...';
}
add_filter( 'excerpt_more', 'bard_new_excerpt' );
if ( ! function_exists( 'bard_excerpt' ) ) {
function bard_excerpt( $limit = 50 ) {
echo ''. 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( $social_class, $title ) {
$social_window = ( bard_options( 'social_media_window' ) === true )?'_blank':'_self';
?>
term_id;
$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() ) {
?>
have_posts() ) : $similar_posts->the_post(); ?>
';
$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' ) : ?>