tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
add_theme_support( 'align-wide' );
add_theme_support( 'post-thumbnails' );
add_image_size( 'blogshop-thubnail-mobile', 350, 250 );
add_image_size( 'blogshop-thubnail-medium', 770, 550 );
add_image_size( 'blogshop-thubnail-large', 1920, 650 );
// This theme uses wp_nav_menu() in one location.
register_nav_menus(
array(
'main-menu' => esc_html__( 'Primary', 'blogshop' ),
'footer-menu' => esc_html__( 'Footer Menu', 'blogshop' ),
)
);
add_theme_support( 'woocommerce' );
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support(
'html5',
array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
)
);
add_theme_support(
'post-formats',
array(
'aside',
'chat',
'gallery',
'image',
'link',
'quote',
'status',
'video',
'audio'
)
);
// Set up the WordPress core custom background feature.
add_theme_support('custom-background', apply_filters(
'blogshop_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 theme support for selective refresh for widgets.
add_theme_support( 'editor-styles' );
add_theme_support( 'wp-block-styles' );
add_editor_style('css/bootstra.css');
/**
* Add support for core custom logo.
*
* @link https://codex.wordpress.org/Theme_Logo
*/
add_theme_support(
'custom-logo',
array(
'height' => 250,
'width' => 250,
'flex-width' => true,
'flex-height' => true,
)
);
}
endif;
add_action( 'after_setup_theme', 'blogshop_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 blogshop_content_width() {
// This variable is intended to be overruled from themes.
// Open WPCS issue: {@link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1043}.
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
$GLOBALS['content_width'] = apply_filters( 'blogshop_content_width', 640 );
}
add_action( 'after_setup_theme', 'blogshop_content_width', 0 );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function blogshop_widgets_init() {
/**
* Main Sidebar
*/
register_sidebar(
array(
'name' => esc_html__( 'Sidebar', 'blogshop' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets here.', 'blogshop' ),
'before_widget' => '',
'before_title' => '
',
)
);
/**
* Sidebar Footer 1
*/
register_sidebar(
array(
'name' => esc_html__( 'Footer 1', 'blogshop' ),
'id' => 'footer-1',
'description' => esc_html__( 'Add widgets here.', 'blogshop' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
)
);
/**
* Sidebar Footer 2
*/
register_sidebar(
array(
'name' => esc_html__( 'Footer 2', 'blogshop' ),
'id' => 'footer-2',
'description' => esc_html__( 'Add widgets here.', 'blogshop' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
)
);
/**
* Sidebar Footer 3
*/
register_sidebar(
array(
'name' => esc_html__( 'Footer 3', 'blogshop' ),
'id' => 'footer-3',
'description' => esc_html__( 'Add widgets here.', 'blogshop' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
)
);
/**
* Sidebar Footer 4
*/
register_sidebar(
array(
'name' => esc_html__( 'Footer 4', 'blogshop' ),
'id' => 'footer-4',
'description' => esc_html__( 'Add widgets here.', 'blogshop' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
)
);
register_sidebar(
array(
'name' => esc_html__( 'Footer Instagram', 'blogshop' ),
'id' => 'instagram',
'description' => esc_html__( 'Add widgets here.', 'blogshop' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
)
);
register_sidebar(
array(
'name' => esc_html__( 'Woocommerce Sidebar', 'blogshop' ),
'id' => 'woocommerce-sidebar',
'description' => esc_html__( 'Add widgets here.', 'blogshop' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
)
);
}
add_action( 'widgets_init', 'blogshop_widgets_init' );
/**
* Enqueue scripts and styles.
*/
function blogshop_scripts() {
wp_enqueue_style( 'blogshop-style', get_stylesheet_uri() );
//Fonts
$body_font = esc_html(get_theme_mod('blogshop_body_fonts', 'Poppins,sans-serif'));
$body_font_size = esc_html(get_theme_mod('blogshop_body_fonts_size', 16));
$body_font_weight = esc_html(get_theme_mod('blogshop_body_fonts_weight', 400));
$body_font_line_height = esc_html(get_theme_mod('blogshop_body_fonts_line_height', 28));
$body_font_pieces = '0';
if ( $body_font ) {
$body_font_pieces = explode(":", $body_font);
}
//Output all the style
$getprimarycolor = get_theme_mod( 'base_color' );
$primarycolor = (!empty($getprimarycolor) ? $getprimarycolor : '#5cca8d');
$menucolor = get_theme_mod( 'menu_color_main', '#000000' );
$menucolorhover = get_theme_mod( 'menu_color_hover', '#5cca8d' );
$data = '
@media only screen and (min-width: 768px) {
#cssmenu>ul>li>a, #cssmenu>ul>li>a:after, #cssmenu>ul>li.current-menu-item>a:after, #cssmenu>ul>li.current_page_item>a:after{
color: '.$menucolor.' !important;
}
#cssmenu>ul>li>a:hover,#cssmenu>ul>li.current_page_item>a, #cssmenu>ul>li>a:hover:after, #cssmenu>ul>li.current-menu-item>a:hover:after, #cssmenu>ul>li.current_page_item>a:hover:after, #cssmenu ul ul li a:hover{
color: '.$menucolorhover.' !important;
}
}
#cssmenu ul li.has-sub:hover > a:after{
background-color: '.$menucolorhover.' !important;
}
.blogshop-credit {
position: absolute !important;
left: 50% !important;
visibility: visible !important;
width: 15px !important;
height: 15px !important;
opacity: 1 !important;
z-index: 1 !important;
top: calc(50% - 9.5px);
}
.blogshop-credit span {
font-size: 0;
}
.blogshop-credit a, .blogshop-credit a:hover {
color: #5cca8d ;
cursor: pointer ;
opacity: 1 ;
}
body.border_and_box_shadow_hide .footer-area.section-padding, body.border_and_box_shadow_hide footer#colophon, body.border_and_box_shadow_hide .widget, body.border_and_box_shadow_hide .blog-post-section article, body.border_and_box_shadow_hide .archive-page-section article, body.border_and_box_shadow_hide .menu-area, body.border_and_box_shadow_hide .site-topbar-area {
border: 0 !important;
box-shadow: none !important;
}
.readmore a,.btn.btn-warning, input[type="submit"], button[type="submit"], span.edit-link a, .comment-form button.btn.btn-primary, .banner-button a, table#wp-calendar #today, ul.pagination li .page-numbers, .woocommerce ul.products li.product .button, .woocommerce div.product .woocommerce-tabs ul.tabs li.active, .woocommerce #respond input#submit.alt, .woocommerce a.button.alt, .woocommerce button.button.alt, .woocommerce input.button.alt, .woocommerce #respond input#submit, .woocommerce a.button, .woocommerce button.button, .woocommerce input.button, .woocommerce nav.woocommerce-pagination ul li a, .woocommerce nav.woocommerce-pagination ul li span, .woocommerce span.onsale, .header-three .social-link-top a, .header-three-search .search-popup>div, .mini-shopping-cart-inner #minicarcount, .active-subfeatured-slider .owl-nav button.owl-next,.active-subfeatured-slider .owl-nav button.owl-prev, .featured-main-slider .owl-nav button.owl-prev, .featured-main-slider .owl-nav button.owl-next, .related-post-sldider .owl-nav button.owl-next, .related-post-sldider .owl-nav button.owl-prev, .sticky:before, .post-gallery .owl-nav button.owl-next, .post-gallery .owl-nav button.owl-prev, .scrooltotop a{
background-color: '.esc_attr( $primarycolor ).';
}
.blog-meta ul li span.fa, .static_icon a, .site-info a, #cssmenu.light ul li a:hover, .social-link-top a:hover, .footer-menu ul li a:hover, #cssmenu.light ul li a:hover:after, a:hover, a:focus, a:active, .post-title a:hover h2, .post-title a:hover h4, #cssmenu.light li.current_page_item a, li.current_page_item a, .author-social-link a, .post-title a:hover h3, .woocommerce ul.products li.product .price, .woocommerce div.product p.price, .woocommerce div.product span.price, .tagcloud a:hover{
color: '.esc_attr( $primarycolor ).';
}
input[type="submit"], button[type="submit"], .title-parent, blockquote{
border-color: '.esc_attr( $primarycolor ).';
}
body, button, input, select, textarea {
font-family: ' . $body_font_pieces[0] .';
font-size: '.$body_font_size.'px;
font-weight: '.$body_font_weight.';
line-height: '.$body_font_line_height.'px;
}
';
$stickyheader = get_theme_mod( 'sticky_header', false );
if (true == $stickyheader) {
$data .= '
.menu-area.sticky-menu {
background: #fff;
position: fixed;
width: 100%;
left: 0;
top: 0;
z-index: 55;
transition: .6s;
}
.site.boxlayout .menu-area.sticky-menu {
width: calc(100% - 200px);
left: 100px;
}
';
}
wp_add_inline_style( 'blogshop-style', $data );
wp_enqueue_script( 'blogshop-active', get_template_directory_uri() . '/js/bundle.js', array( 'jquery' ), '1.0', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'blogshop_scripts' );
/**
* Implement the Custom Header feature.
*/
require get_template_directory() . '/inc/custom-header.php';
/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';
/**
* Functions which enhance the theme by hooking into WordPress.
*/
require get_template_directory() . '/inc/template-functions.php';
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer.php';
/**
* blogshop Comment Template.
*/
require get_template_directory() . '/inc/comment-template.php';
/**
* Sanitize Checkbox for customizer
*/
function blogshop_sanitize_checkbox( $checked ) {
// returns true if checkbox is checked
return ( ( isset( $checked ) && true == $checked ) ? true : false );
}
/**
* Sanitize Radio for customizer
*/
function blogshop_sanitize_radio( $input, $setting ) {
$input = sanitize_key( $input );
$choices = $setting->manager->get_control( $setting->id )->choices;
return ( array_key_exists( $input, $choices ) ? $input : $setting->default );
}
/**
* Sanitize Select for customizer
*/
function blogshop_sanitize_select( $input, $setting ) {
// Ensure input is a slug.
$input = sanitize_key( $input );
// Get list of choices from the control associated with the setting.
$choices = $setting->manager->get_control( $setting->id )->choices;
// If the input is a valid key, return it; otherwise, return the default.
return ( array_key_exists( $input, $choices ) ? $input : $setting->default );
}
/**
* Get Grid Layout
*/
function blogshop_blog_grid() {
if ( 'grid' == get_theme_mod( 'blog_layout' ) ) {
return true;
}
return false;
}
/**
* Get Grid Layout
*/
function blogshop_front_blog_grid() {
if ( 'grid' == get_theme_mod( 'front_post_layout' ) ) {
return true;
}
return false;
}
/**
* Get Categories
*/
function blogshop_get_categories(){
$terms_array = array();
$categories = get_terms(array(
'taxonomy' => 'category',
));
foreach ($categories as $category) {
$terms_array[$category->term_id] = $category->name;
}
return $terms_array;
}
function blogshop_category_sanitize( $input ) {
$valid = blogshop_get_categories();
foreach ( $input as $value ) {
if ( ! array_key_exists( $value, $valid ) ) {
return array();
}
}
return $input;
}
function blogshop_sanitize_number_absint( $number, $setting ) {
// Ensure $number is an absolute integer (whole number, zero or greater).
$number = absint( $number );
// If the input is an absolute integer, return it; otherwise, return the default
return ( $number ? $number : $setting->default );
}
function blogshop_sanitize_image( $image, $setting ) {
/*
* Array of valid image file types.
*
* The array includes image mime types that are included in wp_get_mime_types()
*/
$mimes = array(
'jpg|jpeg|jpe' => 'image/jpeg',
'gif' => 'image/gif',
'png' => 'image/png',
'bmp' => 'image/bmp',
'tif|tiff' => 'image/tiff',
'ico' => 'image/x-icon'
);
// Return an array with file extension and mime_type.
$file = wp_check_filetype( $image, $mimes );
// If $image has a valid mime_type, return it; otherwise, return the default.
return ( $file['ext'] ? $image : $setting->default );
}
//Sanitizes Fonts
function blogshop_sanitize_fonts( $input ) {
$valid = array(
'Source Sans Pro:400,700,400italic,700italic' => 'Source Sans Pro',
'Open Sans:400italic,700italic,400,700' => 'Open Sans',
'Oswald:400,700' => 'Oswald',
'Playfair Display:400,700,400italic' => 'Playfair Display',
'Montserrat:400,700' => 'Montserrat',
'Raleway:400,700' => 'Raleway',
'Droid Sans:400,700' => 'Droid Sans',
'Lato:400,700,400italic,700italic' => 'Lato',
'Arvo:400,700,400italic,700italic' => 'Arvo',
'Lora:400,700,400italic,700italic' => 'Lora',
'Merriweather:400,300italic,300,400italic,700,700italic' => 'Merriweather',
'Oxygen:400,300,700' => 'Oxygen',
'PT Serif:400,700' => 'PT Serif',
'PT Sans:400,700,400italic,700italic' => 'PT Sans',
'PT Sans Narrow:400,700' => 'PT Sans Narrow',
'Cabin:400,700,400italic' => 'Cabin',
'Fjalla One:400' => 'Fjalla One',
'Francois One:400' => 'Francois One',
'Josefin Sans:400,300,600,700' => 'Josefin Sans',
'Libre Baskerville:400,400italic,700' => 'Libre Baskerville',
'Arimo:400,700,400italic,700italic' => 'Arimo',
'Ubuntu:400,700,400italic,700italic' => 'Ubuntu',
'Bitter:400,700,400italic' => 'Bitter',
'Droid Serif:400,700,400italic,700italic' => 'Droid Serif',
'Roboto:400,400italic,700,700italic' => 'Roboto',
'Open Sans Condensed:700,300italic,300' => 'Open Sans Condensed',
'Roboto Condensed:400italic,700italic,400,700' => 'Roboto Condensed',
'Roboto Slab:400,700' => 'Roboto Slab',
'Yanone Kaffeesatz:400,700' => 'Yanone Kaffeesatz',
'Rokkitt:400' => 'Rokkitt',
);
if ( array_key_exists( $input, $valid ) ) {
return $input;
} else {
return '';
}
}
function blogshop_fonts() {
$body_font = esc_html(get_theme_mod('blogshop_body_fonts'));
if( $body_font ) {
wp_enqueue_style( 'blogshop-body-fonts', '//fonts.googleapis.com/css?family='. $body_font );
} else {
wp_enqueue_style( 'blogshop-source-body', '//fonts.googleapis.com/css?family=Poppins:300,400,500,700,800');
}
}
add_action( 'wp_enqueue_scripts', 'blogshop_fonts' );
/**
* Checkout Fields
*/
require get_template_directory() . '/inc/checkout-fields.php';
/**
* Recent Post Widget
*/
require get_template_directory() . '/inc/recent-post.php';
/**
* TGM plugin Activation
*/
require get_template_directory() . '/inc/tgm/required-plugin.php';
/**
* Metabox
*/
if (function_exists('get_field')) {
require get_template_directory() . '/inc/metabox.php';
}
/**
* WooCommerce Page Tittle
*/
add_filter( 'woocommerce_page_title', 'blogshop_woocommerce_shop_title');
function blogshop_woocommerce_shop_title($default){
$page_banner_show = get_theme_mod( 'blog_page_header' );
if ($page_banner_show == 'classic') :
$default = false;
else:
$default = __( 'Shop', 'blogshop' );
endif;
return $default;
}
/**
* WooCommerce MiniCart Count
*/
add_filter( 'woocommerce_add_to_cart_fragments', 'blogshop_refresh_mini_cart_count');
function blogshop_refresh_mini_cart_count($fragments){
ob_start();
?>
cart->get_cart_contents_count(); ?>