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/ashe_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', 'ashe' ),
'main' => __( 'Main Menu', 'ashe' ),
'footer' => __( 'Footer Menu', 'ashe' ),
) );
// 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', 'ashe_activation_notice' );
add_action( 'admin_notices', 'ashe_classic_widgets_notice' );
// Add Image Sizes
ashe_add_image_sizes();
}
add_action( 'after_setup_theme', 'ashe_setup' );
/*
** Notice after Theme Activation and Update.
*/
function ashe_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' ) );
if ( ! get_user_meta( $user_id, esc_html( $theme_data->get( 'TextDomain' ) ) . $theme_vers .'_notice_ignore' ) ) {
echo '
';
}
}
function ashe_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, add that to their user meta */
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' ] ) {
add_user_meta( $user_id, esc_html( $theme_data->get( 'TextDomain' ) ) . $theme_vers .'_notice_ignore', 'true', true );
}
}
add_action( 'admin_init', 'ashe_notice_ignore' );
function ashe_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', 'ashe_erase_ignored_notice');
function ashe_admin_scripts() {
// Theme Activation Notice
wp_enqueue_style( 'ashe-admin', get_theme_file_uri( '/assets/css/admin.css' ) );
}
add_action( 'admin_enqueue_scripts', 'ashe_admin_scripts' );
/*
** Notice for Classic Widgets Editor.
*/
function ashe_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", get_bloginfo( 'pingback_url' ) );
}
}
add_action( 'wp_head', 'ashe_pingback_header' );
/*
** Enqueue scripts and styles
*/
function ashe_scripts() {
// Theme Stylesheet
wp_enqueue_style( 'ashe-style', get_stylesheet_uri(), array(), '1.9.7' );
// FontAwesome Icons
wp_enqueue_style( 'fontawesome', get_theme_file_uri( '/assets/css/fontawesome.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
if ( class_exists( 'WooCommerce' ) ) {
wp_enqueue_style( 'ashe-woocommerce', get_theme_file_uri( '/assets/css/woocommerce.css' ) );
}
// Theme Responsive CSS
wp_enqueue_style( 'ashe-responsive', get_theme_file_uri( '/assets/css/responsive.css' ), array(), '1.9.7' );
// Enqueue Custom Scripts
wp_enqueue_script( 'ashe-plugins', get_theme_file_uri( '/assets/js/custom-plugins.js' ), array( 'jquery' ), '1.8.2', true );
wp_enqueue_script( 'ashe-custom-scripts', get_theme_file_uri( '/assets/js/custom-scripts.js' ), array( 'jquery' ), '1.9.7', true );
// Comment reply link
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'ashe_scripts' );
/*
** Enqueue Google Fonts
*/
function ashe_playfair_font_url() {
$font_url = '';
if ( 'off' !== _x( 'on', 'Google font: on or off', 'ashe' ) ) {
$font_url = add_query_arg( 'family', urlencode( 'Playfair Display:400,700' ), "//fonts.googleapis.com/css" );
}
return $font_url;
}
function ashe_opensans_font_url() {
$font_url = '';
if ( 'off' !== _x( 'on', 'Google font: on or off', 'ashe' ) ) {
$font_url = add_query_arg( 'family', urlencode( 'Open Sans:400italic,400,600italic,600,700italic,700' ), "//fonts.googleapis.com/css" );
}
return $font_url;
}
function ashe_kalam_font_url() {
$font_url = '';
if ( 'off' !== _x( 'on', 'Google font: on or off', 'ashe' ) ) {
$font_url = add_query_arg( 'family', urlencode( 'Kalam' ), "//fonts.googleapis.com/css" );
}
return $font_url;
}
function ashe_rokkitt_font_url() {
$font_url = '';
if ( 'off' !== _x( 'on', 'Google font: on or off', 'ashe' ) ) {
$font_url = add_query_arg( 'family', urlencode( 'Rokkitt' ), "//fonts.googleapis.com/css" );
}
return $font_url;
}
function ashe_gfonts_scripts() {
wp_enqueue_style( 'ashe-playfair-font', ashe_playfair_font_url(), array(), '1.0.0' );
wp_enqueue_style( 'ashe-opensans-font', ashe_opensans_font_url(), array(), '1.0.0' );
// Load Kalam if selected
if ( ashe_options( 'typography_logo_family' ) == 'Kalam' || ashe_options( 'typography_nav_family' ) == 'Kalam' ) {
wp_enqueue_style( 'ashe-kalam-font', ashe_kalam_font_url(), array(), '1.0.0' );
}
// Load Rokkitt if selected
if ( ashe_options( 'typography_logo_family' ) == 'Rokkitt' || ashe_options( 'typography_nav_family' ) == 'Rokkitt' ) {
wp_enqueue_style( 'ashe-rokkitt-font', ashe_rokkitt_font_url(), array(), '1.0.0' );
}
}
add_action( 'wp_enqueue_scripts', 'ashe_gfonts_scripts' );
/*
** Register widget areas.
*/
function ashe_widgets_init() {
register_sidebar( array(
'name' => __( 'Right Sidebar', 'ashe' ),
'id' => 'sidebar-right',
'description' => __( 'Add widgets here to appear in your sidebar.', 'ashe' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '
',
'after_title' => ' ',
) );
register_sidebar( array(
'name' => __( 'Left Sidebar', 'ashe' ),
'id' => 'sidebar-left',
'description' => __( 'Add widgets here to appear in your sidebar.', 'ashe' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '
',
'after_title' => ' ',
) );
register_sidebar( array(
'name' => __( 'Sidebar Alt', 'ashe' ),
'id' => 'sidebar-alt',
'description' => __( 'Add widgets here to appear in your alternative/fixed sidebar.', 'ashe' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '
',
'after_title' => ' ',
) );
register_sidebar( array(
'name' => __( 'Footer Widgets', 'ashe' ),
'id' => 'footer-widgets',
'description' => __( 'Add widgets here to appear in your footer.', 'ashe' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '
',
'after_title' => ' ',
) );
}
add_action( 'widgets_init', 'ashe_widgets_init' );
/*
** Custom Image Sizes
*/
if ( ! function_exists( 'ashe_add_image_sizes' ) ) {
function ashe_add_image_sizes() {
add_image_size( 'ashe-slider-full-thumbnail', 1080, 540, true );
add_image_size( 'ashe-full-thumbnail', 1140, 0, true );
add_image_size( 'ashe-list-thumbnail', 300, 300, true );
add_image_size( 'ashe-grid-thumbnail', 500, 330, true );
add_image_size( 'ashe-single-navigation', 75, 75, true );
}
}
/*
** Top Menu Fallback
*/
function ashe_top_menu_fallback() {
if ( current_user_can( 'edit_theme_options' ) ) {
echo '';
}
}
/*
** Main Menu Fallback
*/
function ashe_main_menu_fallback() {
if ( ashe_is_preview() ) {
echo '';
ashe_preview_navigation();
echo ' ';
} else {
if ( current_user_can( 'edit_theme_options' ) ) {
echo '';
}
}
}
/*
** Custom Excerpt Length
*/
function ashe_excerpt_length( $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" ', 'ashe' ), get_the_title( get_the_ID() ) )
);
return 2000;
}
add_filter( 'excerpt_length', 'ashe_excerpt_length', 999 );
function ashe_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" ', 'ashe' ), get_the_title( get_the_ID() ) )
);
return '...';
}
add_filter( 'excerpt_more', 'ashe_new_excerpt' );
if ( ! function_exists( 'ashe_excerpt' ) ) {
function ashe_excerpt( $limit = 50 ) {
echo ''. wp_trim_words(get_the_excerpt(), $limit) .'
';
}
}
/*
** Custom Functions
*/
// HEX to RGBA Converter
function ashe_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;
}
// Retrieves the attachment src from the file URL
function ashe_get_image_src_by_url( $image_url, $image_size ) {
if ( ! isset($image_url) || '' === $image_url ) {
return [ 0 => null ];
} else {
return wp_get_attachment_image_src( attachment_url_to_postid($image_url), $image_size );
}
}
// Social Media
if ( ! function_exists( 'ashe_social_media' ) ) {
function ashe_social_media( $social_class='' ) {
?>
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'
),
)
);
if ( ashe_is_preview() ) {
array_pop($args);
}
$similar_posts = new WP_Query( $args );
if ( $similar_posts->have_posts() ) {
?>
have_posts() ) : $similar_posts->the_post(); ?>
';
$html .= ' ';
$html .= ' ';
$html .= ' ';
$html .= '';
return $html;
}
add_filter( 'get_search_form', 'ashe_custom_search_form' );
/*
** Post Share
*/
function ashe_post_sharing_check() {
if ( ashe_options( 'blog_page_show_facebook' ) || ashe_options( 'blog_page_show_twitter' ) || ashe_options( 'blog_page_show_pinterest' ) || ashe_options( 'blog_page_show_whatsapp' ) || ashe_options( 'blog_page_show_linkedin' ) || ashe_options( 'blog_page_show_tumblr' ) || ashe_options( 'blog_page_show_reddit' ) ) {
return true;
}
return false;
}
if ( ! function_exists( 'ashe_post_sharing' ) ) {
function ashe_post_sharing() {
global $post; ?>
ID)) ).'&description='.get_the_title(); ?>