get( 'Version' ) );
}
if ( ! defined( 'BLOGLOOM_NAME' ) ) {
define( 'BLOGLOOM_NAME', wp_get_theme()->get( 'Name' ) );
}
if ( ! defined( 'BLOGLOOM_URL_DEMO' ) ) {
define( 'BLOGLOOM_URL_DEMO', wp_get_theme()->get( 'ThemeURI' ) );
}
if ( ! function_exists( 'blogloom_setup' ) ) :
function blogloom_setup() {
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'title-tag' );
add_theme_support( 'wp-block-styles' );
add_theme_support( 'register_block_style' );
add_theme_support( 'register_block_pattern' );
add_theme_support( 'post-thumbnails' );
add_theme_support( 'post-formats', array( 'aside', 'video', 'gallery', 'audio') );
// 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(
'height' => 250,
'width' => 250,
'flex-width' => true,
'flex-height' => true,
)
);
add_theme_support( 'align-wide' );
add_theme_support( 'responsive-embeds' );
add_theme_support( 'html5', array(
'comment-list',
'comment-form',
'search-form',
'gallery',
'caption',
) );
// This theme uses wp_nav_menu() in one location.
register_nav_menus(
array(
'primary' => esc_html__( 'Primary','blogloom' ),
)
);
register_nav_menus(
array(
'footer' => esc_html__( 'Footer','blogloom' ),
)
);
}
endif;
add_action( 'after_setup_theme', 'blogloom_setup' );
add_image_size( 'blogloom-image-small', 300, 9999 );
add_image_size( 'blogloom-image-medium', 600, 9999 );
add_image_size( 'blogloom-image-large', 1200, 9999 );
if ( ! function_exists( 'blogloom_after_active' ) ) :
function blogloom_after_active() {
$theme_active = get_option('stylesheet');
}
endif;
add_action('after_switch_theme', 'blogloom_after_active');
if ( ! function_exists( 'blogloom_header_style' ) ) :
/**
* Styles the header image and text displayed on the blog.
*
* @see blogloom_header_style().
*/
function blogloom_header_style() {
$header_text_color = get_header_textcolor();
/*
* If no custom options for text are set, let's bail.
* get_header_textcolor() options: Any hex value, 'blank' to hide text. Default: add_theme_support( 'custom-header' ).
*/
if ( get_theme_support( 'custom-header', 'default-text-color' ) === $header_text_color ) {
return;
}
// If we get this far, we have custom styles. Let's do this.
?>
$name,
'id' => $id,
'description' => $description,
'before_widget' => $beforeWidget,
'after_widget' => $afterWidget,
'before_title' => $beforeTitle,
'after_title' => $afterTitle,
));
}
function blogloom_widgets_init() {
blogloom_widget_registration(esc_html__('Sidebar Front Page', ''), 'sidebar-1', esc_html__('Add widgets here.', 'blogloom'), '', '
');
blogloom_widget_registration(esc_html__('Sidebar Inner 2', ''), 'sidebar-2', esc_html__('Add widgets here.', 'blogloom'), '', '');
blogloom_widget_registration(esc_html__('Sidebar Inner 3', ''), 'sidebar-3', esc_html__('Add widgets here.', 'blogloom'), '', '');
blogloom_widget_registration(esc_html__('Sidebar Inner 4', ''), 'sidebar-4', esc_html__('Add widgets here.', 'blogloom'), '', '');
blogloom_widget_registration(esc_html__('Sidebar Inner 5', ''), 'sidebar-5', esc_html__('Add widgets here.', 'blogloom'), '', '');
blogloom_widget_registration(esc_html__('Sidebar Inner 6', ''), 'sidebar-6', esc_html__('Add widgets here.', 'blogloom'), '', '');
blogloom_widget_registration(esc_html__('Sidebar E-Commerce', ''), 'sidebar-e-commerce', esc_html__('Add widgets here.', 'blogloom'), '', '');
blogloom_widget_registration(esc_html__('Footer 1', ''), 'footer-1', esc_html__('Add widgets here.', 'blogloom'), '', '');
blogloom_widget_registration(esc_html__('Footer 2', ''), 'footer-2', esc_html__('Add widgets here.', 'blogloom'), '', '');
blogloom_widget_registration(esc_html__('Footer 3', ''), 'footer-3', esc_html__('Add widgets here.', 'blogloom'), '', '');
blogloom_widget_registration(esc_html__('Footer 4', ''), 'footer-4', esc_html__('Add widgets here.', 'blogloom'), '', '');
blogloom_widget_registration(esc_html__('Footer 5', ''), 'footer-5', esc_html__('Add widgets here.', 'blogloom'), '', '');
blogloom_widget_registration(esc_html__('Footer Above', ''), 'footer-above', esc_html__('Add widgets here.', 'blogloom'), '', '');
}
add_action( 'widgets_init', 'blogloom_widgets_init' );
/**
* Count Widget Footer Active
*/
function blogloom_footer_is_widget() {
$widget_active = array();
for($i = 1; $i < 5;$i++) {
if(is_active_sidebar( 'footer-'.$i )) {
$widget_active[$i] = $i;
}
}
return $widget_active;
}
/**
* Enqueue scripts and styles.
*/
function blogloom_scripts() {
wp_enqueue_style( 'blogloom-style', get_stylesheet_uri(), array(), BLOGLOOM_VERSION );
wp_style_add_data( 'blogloom-style', 'rtl', 'replace' );
wp_enqueue_script( 'blogloom-navigation', get_template_directory_uri() . '/assets/js/navigation.js', array(), BLOGLOOM_VERSION, true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'blogloom_scripts' );
/**
* Google Font Default
*/
function blogloom_google_font_default() {
// Using local fonts instead of Google Fonts CDN
return get_template_directory_uri() . '/assets/fonts/google-fonts/inter.css';
}
/**
* Dynamic Front End CSS
*/
function blogloom_dynamic_front_end_css() {
wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/assets/css/bootstrap.min.css', array(), '5.0.2' );
wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/assets/fonts/font-awesome/all.min.css', array(), '6.4.0' );
wp_enqueue_style( 'blogloom-google-fonts', blogloom_google_font_default(), array(), '1.0' );
wp_enqueue_style( 'blogloom-main', get_template_directory_uri() . '/assets/css/main.css', array(), BLOGLOOM_VERSION );
wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/assets/js/bootstrap.min.js', array('jquery'), '5.0.2', true );
wp_enqueue_script( 'blogloom-script', get_template_directory_uri() . '/assets/js/script.js', array('jquery'), BLOGLOOM_VERSION, true );
}
add_action( 'wp_enqueue_scripts', 'blogloom_dynamic_front_end_css' );
/**
* Include necessary files
*/
require get_template_directory() . '/inc/template-tags.php';
require get_template_directory() . '/inc/template-functions.php';
require get_template_directory() . '/inc/widgets/recent-posts-widget.php';
/**
* Set post view count
*/
function blogloom_set_post_view_count($postID) {
$count_key = 'blogloom_post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count == '') {
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
} else {
$count++;
update_post_meta($postID, $count_key, $count);
}
}
/**
* Check if WooCommerce is active
*/
function blogloom_is_woocommerce() {
if ( class_exists( 'woocommerce' ) ) {
return true;
} else {
return false;
}
}
/**
* Custom Heading Archive
*/
add_filter('get_the_archive_title', function ($title) {
if (is_category()) {
$title = single_cat_title('', false);
} elseif (is_tag()) {
$title = single_tag_title('', false);
} elseif (is_author()) {
$title = '' . get_the_author() . '';
} elseif (is_tax()) {
$title = single_term_title('', false);
} elseif (is_post_type_archive()) {
$title = post_type_archive_title('', false);
}
return $title;
});
/**
* Archive layout helper function
*/
function blogloom_archive_layout() {
$sidebar = 'sidebar-1';
$layout = get_theme_mod('blogloom_archive_layout', 'right-sidebar');
$col_one = 'col-lg-8';
$col_two = 'col-lg-4';
if ($layout == 'left-sidebar') {
$col_one = 'col-lg-8 order-lg-2';
$col_two = 'col-lg-4 order-lg-1';
} elseif ($layout == 'no-sidebar') {
$col_one = 'col-lg-12';
$col_two = 'd-none';
}
return array(
'col_one' => $col_one,
'col_two' => $col_two,
'sidebar' => $sidebar,
'layout' => get_theme_mod('blogloom_archive_post_layout', 'grid2')
);
}
/**
* Custom excerpt function
*/
function blogloom_excerpt_custom($limit, $post_id = null) {
$post = $post_id ? get_post($post_id) : get_post();
$excerpt = $post->post_excerpt;
if (empty($excerpt)) {
$excerpt = $post->post_content;
$excerpt = strip_shortcodes($excerpt);
$excerpt = excerpt_remove_blocks($excerpt);
$excerpt = strip_tags($excerpt);
$words = explode(' ', $excerpt, $limit + 1);
if (count($words) > $limit) {
array_pop($words);
$excerpt = implode(' ', $words) . '...';
} else {
$excerpt = implode(' ', $words);
}
}
return $excerpt;
}