tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support( 'post-thumbnails' );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary' => esc_html__( 'Primary', 'blossom-fashion' ),
) );
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', array(
'search-form',
'comment-list',
'gallery',
'caption',
) );
// Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'blossom_fashion_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
) ) );
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
/**
* Add support for core custom logo.
*
* @link https://codex.wordpress.org/Theme_Logo
*/
add_theme_support( 'custom-logo', array( 'header-text' => array( 'site-title', 'site-description' ) ) );
add_theme_support( 'custom-header', apply_filters( 'blossom_fashion_custom_header_args', array(
'default-image' => '',
'video' => true,
'width' => 1920,
'height' => 760,
'header-text' => false
) ) );
/** Images sizes */
add_image_size( 'blossom-fashion-slider', 1920, 760, true );
add_image_size( 'blossom-fashion-featured', 400, 230, true );
add_image_size( 'blossom-fashion-with-sidebar', 925, 540, true );
add_image_size( 'blossom-fashion-fullwidth', 1320, 540, true );
add_image_size( 'blossom-fashion-blog-home', 435, 332, true );
add_image_size( 'blossom-fashion-blog-archive', 260, 200, true );
add_image_size( 'blossom-fashion-related', 300, 232, true );
add_image_size( 'blossom-fashion-popular', 280, 215, true );
add_image_size( 'blossom-fashion-schema', 600, 60 );
add_image_size( 'blossom-fashion-shop', 293, 400, true );
// Add theme support for Responsive Videos.
add_theme_support( 'jetpack-responsive-videos' );
}
endif;
add_action( 'after_setup_theme', 'blossom_fashion_setup' );
/**
* Set the content width in pixels, based on the theme's design and stylesheet.
*
* Priority 0 to make it available to lower priority callbacks.
*
* @global int $content_width
*/
function blossom_fashion_content_width() {
$GLOBALS['content_width'] = apply_filters( 'blossom_fashion_content_width', 925 );
}
add_action( 'after_setup_theme', 'blossom_fashion_content_width', 0 );
if( ! function_exists( 'blossom_fashion_template_redirect_content_width' ) ) :
/**
* Adjust content_width value according to template.
*
* @return void
*/
function blossom_fashion_template_redirect_content_width(){
// Full Width in the absence of sidebar.
if( is_singular() ){
$sidebar_layout = blossom_fashion_sidebar_layout();
if( ( $sidebar_layout == 'full-width' ) || ! is_active_sidebar( 'sidebar' ) ) $GLOBALS['content_width'] = 1320;
}elseif( ! is_active_sidebar( 'sidebar' ) ){
$GLOBALS['content_width'] = 1320;
}
}
endif;
add_action( 'template_redirect', 'blossom_fashion_template_redirect_content_width' );
/**
* Enqueue scripts and styles.
*/
function blossom_fashion_scripts() {
// Use minified libraries if SCRIPT_DEBUG is false
$build = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '/build' : '';
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
if( blossom_fashion_is_woocommerce_activated() )
wp_enqueue_style( 'blossom-fashion-woocommerce', get_template_directory_uri(). '/css' . $build . '/woocommerce' . $suffix . '.css', array(), BLOSSOM_FASHION_THEME_VERSION );
wp_enqueue_style( 'font-awesome', get_template_directory_uri(). '/css' . $build . '/font-awesome' . $suffix . '.css', array(), '4.7' );
wp_enqueue_style( 'owl-carousel', get_template_directory_uri(). '/css' . $build . '/owl.carousel' . $suffix . '.css', array(), '2.2.1' );
wp_enqueue_style( 'animate', get_template_directory_uri(). '/css' . $build . '/animate' . $suffix . '.css', array(), '3.5.2' );
wp_enqueue_style( 'blossom-fashion-google-fonts', blossom_fashion_fonts_url(), array(), null );
wp_enqueue_style( 'blossom-fashion-style', get_stylesheet_uri(), array(), BLOSSOM_FASHION_THEME_VERSION );
wp_enqueue_script( 'owl-carousel', get_template_directory_uri() . '/js' . $build . '/owl.carousel' . $suffix . '.js', array( 'jquery' ), '2.2.1', true );
wp_enqueue_script( 'blossom-fashion-custom', get_template_directory_uri() . '/js' . $build . '/custom' . $suffix . '.js', array( 'jquery' ), BLOSSOM_FASHION_THEME_VERSION, true );
$array = array(
'rtl' => is_rtl(),
'animation' => get_theme_mod( 'slider_animation' ),
'ajax_url' => admin_url( 'admin-ajax.php' ),
);
wp_localize_script( 'blossom-fashion-custom', 'blossom_fashion_data', $array );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'blossom_fashion_scripts' );
/**
* Adds custom classes to the array of body classes.
*
* @param array $classes Classes for the body element.
* @return array
*/
function blossom_fashion_body_classes( $classes ) {
// Adds a class of hfeed to non-singular pages.
if ( ! is_singular() ) {
$classes[] = 'hfeed';
}
// Adds a class of custom-background-image to sites with a custom background image.
if ( get_background_image() ) {
$classes[] = 'custom-background-image custom-background';
}
// Adds a class of custom-background-color to sites with a custom background color.
if ( get_background_color() != 'ffffff' ) {
$classes[] = 'custom-background-color custom-background';
}
$classes[] = blossom_fashion_sidebar_layout();
return $classes;
}
add_filter( 'body_class', 'blossom_fashion_body_classes' );
if( ! function_exists( 'blossom_fashion_post_classes' ) ) :
/**
* Add custom classes to the array of post classes.
*/
function blossom_fashion_post_classes( $classes ){
global $wp_query;
if( is_front_page() && is_home() && $wp_query->current_post == 0 ){
$classes[] = 'first-post';
}
if( is_search() ){
$classes[] = 'search-post';
}
return $classes;
}
endif;
add_filter( 'post_class', 'blossom_fashion_post_classes' );
/**
* Add a pingback url auto-discovery header for singularly identifiable articles.
*/
function blossom_fashion_pingback_header() {
if ( is_singular() && pings_open() ) {
echo '';
}
}
add_action( 'wp_head', 'blossom_fashion_pingback_header' );
if( ! function_exists( 'blossom_fashion_get_archive_title' ) ) :
/**
* Archive Title Filter
*/
function blossom_fashion_get_archive_title( $title ){
$ed_prefix = get_theme_mod( 'ed_prefix_archive', false );
if( is_category() ){
if( $ed_prefix ){
$title = '
' . single_cat_title( '', false ) . '
';
}else{
/* translators: Category archive title. 1: Category name */
$title = sprintf( __( '%1$sCategory%2$s %3$s', 'blossom-fashion' ), '', '', '' . single_cat_title( '', false ) . '
' );
}
}elseif( is_tag() ){
if( $ed_prefix ){
$title = '' . single_tag_title( '', false ) . '
';
}else{
/* translators: Tag archive title. 1: Tag name */
$title = sprintf( __( '%1$sTag%2$s %3$s', 'blossom-fashion' ), '', '', '' . single_tag_title( '', false ) . '
' );
}
}elseif( is_year() ){
if( $ed_prefix ){
$title = '' . get_the_date( _x( 'Y', 'yearly archives date format', 'blossom-fashion' ) ) . '
';
}else{
/* translators: Yearly archive title. 1: Year */
$title = sprintf( __( '%1$sYear%2$s %3$s', 'blossom-fashion' ), '', '', '' . get_the_date( _x( 'Y', 'yearly archives date format', 'blossom-fashion' ) ) . '
' );
}
}elseif( is_month() ){
if( $ed_prefix ){
$title = '' . get_the_date( _x( 'F Y', 'monthly archives date format', 'blossom-fashion' ) ) . '
';
}else{
/* translators: Monthly archive title. 1: Month name and year */
$title = sprintf( __( '%1$sMonth%2$s %3$s', 'blossom-fashion' ), '', '', '' . get_the_date( _x( 'F Y', 'monthly archives date format', 'blossom-fashion' ) ) . '
' );
}
}elseif( is_day() ){
if( $ed_prefix ){
$title = '' . get_the_date( _x( 'F j, Y', 'daily archives date format', 'blossom-fashion' ) ) . '
';
}else{
/* translators: Daily archive title. 1: Date */
$title = sprintf( __( '%1$sDay%2$s %3$s', 'blossom-fashion' ), '', '', '' . get_the_date( _x( 'F j, Y', 'daily archives date format', 'blossom-fashion' ) ) . '
' );
}
}elseif( is_post_type_archive() && ! is_post_type_archive( 'product' ) ) {
if( $ed_prefix ){
$title = '' . post_type_archive_title( '', false ) . '
';
}else{
/* translators: Post type archive title. 1: Post type name */
$title = sprintf( __( '%1$sArchives%2$s %3$s', 'blossom-fashion' ), '', '', '' . post_type_archive_title( '', false ) . '
' );
}
}elseif( is_tax() ) {
$tax = get_taxonomy( get_queried_object()->taxonomy );
if( $ed_prefix ){
$title = '' . single_term_title( '', false ) . '
';
}else{
/* translators: Taxonomy term archive title. 1: Taxonomy singular name, 2: Current taxonomy term */
$title = sprintf( __( '%1$s: %2$s', 'blossom-fashion' ), '' . $tax->labels->singular_name . '', '' . single_term_title( '', false ) . '
' );
}
}else {
$title = sprintf( __( '%1$sArchives%2$s', 'blossom-fashion' ), '', '
' );
}
return $title;
}
endif;
add_filter( 'get_the_archive_title', 'blossom_fashion_get_archive_title' );
if( ! function_exists( 'blossom_fashion_change_comment_form_default_fields' ) ) :
/**
* Change Comment form default fields i.e. author, email & url.
* https://blog.josemcastaneda.com/2016/08/08/copy-paste-hurting-theme/
*/
function blossom_fashion_change_comment_form_default_fields( $fields ){
// get the current commenter if available
$commenter = wp_get_current_commenter();
// core functionality
$req = get_option( 'require_name_email' );
$aria_req = ( $req ? " aria-required='true'" : '' );
// Change just the author field
$fields['author'] = '';
$fields['email'] = '';
$fields['url'] = '';
return $fields;
}
endif;
add_filter( 'comment_form_default_fields', 'blossom_fashion_change_comment_form_default_fields' );
if( ! function_exists( 'blossom_fashion_change_comment_form_defaults' ) ) :
/**
* Change Comment Form defaults
* https://blog.josemcastaneda.com/2016/08/08/copy-paste-hurting-theme/
*/
function blossom_fashion_change_comment_form_defaults( $defaults ){
$defaults['comment_field'] = '';
return $defaults;
}
endif;
add_filter( 'comment_form_defaults', 'blossom_fashion_change_comment_form_defaults' );
if ( ! function_exists( 'blossom_fashion_excerpt_more' ) ) :
/**
* Replaces "[...]" (appended to automatically generated excerpts) with ... *
*/
function blossom_fashion_excerpt_more( $more ) {
return is_admin() ? $more : ' … ';
}
endif;
add_filter( 'excerpt_more', 'blossom_fashion_excerpt_more' );
if ( ! function_exists( 'blossom_fashion_excerpt_length' ) ) :
/**
* Changes the default 55 character in excerpt
*/
function blossom_fashion_excerpt_length( $length ) {
$excerpt_length = get_theme_mod( 'excerpt_length', 55 );
return is_admin() ? $length : absint( $excerpt_length );
}
endif;
add_filter( 'excerpt_length', 'blossom_fashion_excerpt_length', 999 );
if( ! function_exists( 'blossom_fashion_exclude_cat' ) ) :
/**
* Exclude post with Category from blog and archive page.
*/
function blossom_fashion_exclude_cat( $query ){
$ed_banner = get_theme_mod( 'ed_banner_section', 'slider_banner' );
$slider_type = get_theme_mod( 'slider_type', 'latest_posts' );
$slider_cat = get_theme_mod( 'slider_cat' );
$posts_per_page = get_theme_mod( 'no_of_slides', 3 );
if( ! is_admin() && $query->is_main_query() && $query->is_home() && $ed_banner == 'slider_banner' ){
if( $slider_type === 'cat' && $slider_cat ){
$query->set( 'category__not_in', array( $slider_cat ) );
}elseif( $slider_type == 'latest_posts' ){
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => $posts_per_page,
'ignore_sticky_posts' => true
);
$latest = get_posts( $args );
$excludes = array();
foreach( $latest as $l ){
array_push( $excludes, $l->ID );
}
$query->set( 'post__not_in', $excludes );
}
}
}
endif;
add_filter( 'pre_get_posts', 'blossom_fashion_exclude_cat' );
if( ! function_exists( 'blossom_fashion_single_post_schema' ) ) :
/**
* Single Post Schema
*
* @return string
*/
function blossom_fashion_single_post_schema() {
if ( is_singular( 'post' ) ) {
global $post;
$custom_logo_id = get_theme_mod( 'custom_logo' );
$site_logo = wp_get_attachment_image_src( $custom_logo_id , 'blossom-fashion-schema' );
$images = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
$excerpt = blossom_fashion_escape_text_tags( $post->post_excerpt );
$content = $excerpt === "" ? mb_substr( blossom_fashion_escape_text_tags( $post->post_content ), 0, 110 ) : $excerpt;
$schema_type = ! empty( $custom_logo_id ) && has_post_thumbnail( $post->ID ) ? "BlogPosting" : "Blog";
$args = array(
"@context" => "http://schema.org",
"@type" => $schema_type,
"mainEntityOfPage" => array(
"@type" => "WebPage",
"@id" => get_permalink( $post->ID )
),
"headline" => get_the_title( $post->ID ),
"image" => array(
"@type" => "ImageObject",
"url" => $images[0],
"width" => $images[1],
"height" => $images[2]
),
"datePublished" => get_the_time( DATE_ISO8601, $post->ID ),
"dateModified" => get_post_modified_time( DATE_ISO8601, __return_false(), $post->ID ),
"author" => array(
"@type" => "Person",
"name" => blossom_fashion_escape_text_tags( get_the_author_meta( 'display_name', $post->post_author ) )
),
"publisher" => array(
"@type" => "Organization",
"name" => get_bloginfo( 'name' ),
"description" => get_bloginfo( 'description' ),
"logo" => array(
"@type" => "ImageObject",
"url" => $site_logo[0],
"width" => $site_logo[1],
"height" => $site_logo[2]
)
),
"description" => ( class_exists('WPSEO_Meta') ? WPSEO_Meta::get_value( 'metadesc' ) : $content )
);
if ( has_post_thumbnail( $post->ID ) ) :
$args['image'] = array(
"@type" => "ImageObject",
"url" => $images[0],
"width" => $images[1],
"height" => $images[2]
);
endif;
if ( ! empty( $custom_logo_id ) ) :
$args['publisher'] = array(
"@type" => "Organization",
"name" => get_bloginfo( 'name' ),
"description" => get_bloginfo( 'description' ),
"logo" => array(
"@type" => "ImageObject",
"url" => $site_logo[0],
"width" => $site_logo[1],
"height" => $site_logo[2]
)
);
endif;
echo '' , PHP_EOL;
}
}
endif;
add_action( 'wp_head', 'blossom_fashion_single_post_schema' );
if( ! function_exists( 'blossom_fashion_get_comment_author_link' ) ) :
/**
* Filter to modify comment author link
* @link https://developer.wordpress.org/reference/functions/get_comment_author_link/
*/
function blossom_fashion_get_comment_author_link( $return, $author, $comment_ID ){
$comment = get_comment( $comment_ID );
$url = get_comment_author_url( $comment );
$author = get_comment_author( $comment );
if ( empty( $url ) || 'http://' == $url )
$return = ''. esc_html( $author ) .'';
else
$return = '' . esc_html( $author ) . '';
return $return;
}
endif;
add_filter( 'get_comment_author_link', 'blossom_fashion_get_comment_author_link', 10, 3 );