esc_html__( 'Primary Menu', 'blogbd' ),
)
);
add_theme_support(
'html5',
array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
)
);
add_theme_support(
'custom-background',
apply_filters(
'blogbd_custom_background_args',
array(
'default-color' => 'dddddd',
'default-image' => '',
)
)
);
add_theme_support( 'customize-selective-refresh-widgets' );
// Support for default block styles
add_theme_support( 'wp-block-styles' );
// Support for responsive embeds
add_theme_support( 'responsive-embeds' );
// Support for custom logo
add_theme_support(
'custom-logo',
array(
'height' => 100,
'width' => 400,
'flex-height' => true,
'flex-width' => true,
)
);
// Support for custom header
add_theme_support(
'custom-header',
array(
'default-image' => '',
'default-text-color' => 'dddddd',
'width' => 1000,
'height' => 250,
'flex-width' => true,
'flex-height' => true,
'header-text' => true,
)
);
// Support for wide alignment
add_theme_support( 'align-wide' );
}
endif;
add_action( 'after_setup_theme', 'blogbd_setup' );
/**
* Define content width
*/
function blogbd_content_width() {
$GLOBALS['content_width'] = apply_filters( 'blogbd_content_width', 640 );
}
add_action( 'after_setup_theme', 'blogbd_content_width', 0 );
/**
* Register Sidebar and Initialize Widgets
*/
function blogbd_widgets_init() {
register_sidebar(
array(
'name' => esc_html__( 'Sidebar', 'blogbd' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets here.', 'blogbd' ),
'before_widget' => '',
'before_title' => '
',
)
);
}
add_action( 'widgets_init', 'blogbd_widgets_init' );
/**
* Enqueue css and js files
*/
function blogbd_scripts() {
// Enqueue Default Theme Style
wp_enqueue_style( 'blogbd-style', get_stylesheet_uri() );
// Enqueue Font Awesome
wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/assets/css/font-awesome.css', array(), '1.0', 'all' );
// Enqueue jQuery
wp_enqueue_script( 'jquery' );
// Enqueue Custom Navigation
wp_enqueue_script( 'blogbd-navigation', get_template_directory_uri() . '/assets/js/menu.js', array( 'jquery' ), '1.0', true );
// Enqueue Submenu Keyboard Navigation
wp_enqueue_script( 'blogbd-keyboard-navigation', get_template_directory_uri() . '/assets/js/blogbd-keyboard-navigation.js', array( 'jquery' ), null, true );
}
add_action( 'wp_enqueue_scripts', 'blogbd_scripts' );
/**
* Set default thumbnail size
*/
set_post_thumbnail_size( 1200, 9999 ); // Unlimited height, soft crop
/**
* Define custom thumbnail sizes
*/
add_image_size( 'blogbd-featured', 800, 400, true ); // 800 pixels wide by 400 pixels tall, hard crop mode
/**
* Required files
*/
require get_template_directory() . '/inc/customizer.php';
require get_template_directory() . '/inc/template-tags.php';
require get_template_directory() . '/inc/sanitize.php';
/**
* Register custom block styles
*/
function blogbd_register_block_styles() {
register_block_style(
'core/quote',
array(
'name' => 'fancy-quote',
'label' => __( 'Fancy Quote', 'blogbd' ),
)
);
}
add_action( 'init', 'blogbd_register_block_styles' );
/**
* Add editor styles
*/
function blogbd_add_editor_styles() {
add_editor_style( 'assets/css/editor-style.css' );
}
add_action( 'admin_init', 'blogbd_add_editor_styles' );
/**
* Enqueue the comment-reply script
*/
function blogbd_enqueue_comment_reply_script() {
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'blogbd_enqueue_comment_reply_script' );
function blogbd_custom_excerpt_length( $length ) {
$custom_excerpt_length = get_theme_mod( 'excerpt_length', 20 );
return $custom_excerpt_length;
}
add_filter( 'excerpt_length', 'blogbd_custom_excerpt_length', 999 );
function blogbd_excerpt_more( $more ) {
$read_more_text = get_theme_mod( 'read_more_text', __( 'Read more', 'blogbd' ) );
return '... ' . esc_html( $read_more_text ) . ' ';
}
add_filter( 'excerpt_more', 'blogbd_excerpt_more' );
/* Since v1.2 */
// Hook to admin_notices to display the messages
add_action( 'admin_notices', 'blogbd_recommended_plugins' );
function blogbd_recommended_plugins() {
// Include necessary plugin functions
include_once ABSPATH . 'wp-admin/includes/plugin.php';
$plugin_file = 'daisy-links/daisy-links.php';
// Check if the plugin is installed
$is_installed = file_exists( WP_PLUGIN_DIR . '/' . $plugin_file );
// Check if the plugin is active
$is_active = is_plugin_active( $plugin_file );
// Display "Install Now" notice if the plugin is not installed
if ( ! $is_installed ) {
$plugin_slug = 'daisy-links';
$install_url = wp_nonce_url(
self_admin_url( 'update.php?action=install-plugin&plugin=' . $plugin_slug ),
'install-plugin_' . $plugin_slug
);
?>
array( 'label' => __( 'About', 'blogbd' ) ),
'archive' => array( 'label' => __( 'Archive', 'blogbd' ) ),
'banners' => array( 'label' => __( 'Banners', 'blogbd' ) ),
'call-to-action' => array( 'label' => __( 'Call to Action', 'blogbd' ) ),
'footers' => array( 'label' => __( 'Footers', 'blogbd' ) ),
'gallery' => array( 'label' => __( 'Gallery', 'blogbd' ) ),
'headers' => array( 'label' => __( 'Headers', 'blogbd' ) ),
'posts' => array( 'label' => __( 'Posts', 'blogbd' ) ),
'text' => array( 'label' => __( 'Text', 'blogbd' ) ),
);
foreach ( $categories as $slug => $args ) {
if ( class_exists( 'WP_Block_Pattern_Categories_Registry' ) &&
! WP_Block_Pattern_Categories_Registry::get_instance()->is_registered( $slug ) ) {
register_block_pattern_category( $slug, $args );
}
}
}
/**
* Register all block patterns
*/
function blogbd_register_patterns_content() {
// Header Patterns
blogbd_register_hero_pattern();
blogbd_register_header_with_navigation();
blogbd_register_minimal_header();
// Banner Patterns
blogbd_register_featured_banner();
blogbd_register_news_banner();
// About Patterns
blogbd_register_about_pattern();
blogbd_register_team_section();
blogbd_register_mission_section();
// Call to Action Patterns
blogbd_register_cta_pattern();
blogbd_register_newsletter_cta();
blogbd_register_download_cta();
// Footer Patterns
blogbd_register_footer_simple();
blogbd_register_footer_columns();
blogbd_register_footer_with_menu();
// Gallery Patterns
blogbd_register_gallery_grid();
blogbd_register_masonry_gallery();
blogbd_register_carousel_gallery();
// Text Patterns
blogbd_register_text_highlight();
blogbd_register_quote_section();
blogbd_register_featured_text();
// Post Patterns
blogbd_register_featured_posts();
blogbd_register_post_grid();
blogbd_register_recent_posts();
// Archive Patterns
blogbd_register_archive_header();
blogbd_register_category_grid();
}
// ==================== HEADER PATTERNS ====================
function blogbd_register_hero_pattern() {
register_block_pattern(
'blogbd/hero-section',
array(
'title' => __( 'Hero Section', 'blogbd' ),
'description' => __( 'A full-width hero banner with background image and heading.', 'blogbd' ),
'categories' => array( 'headers', 'banners' ),
'content' =>
'
' . esc_html__( 'Welcome to BlogBD', 'blogbd' ) . '
' . esc_html__( 'Share your stories with the world.', 'blogbd' ) . '
',
)
);
}
function blogbd_register_header_with_navigation() {
register_block_pattern(
'blogbd/header-with-navigation',
array(
'title' => __( 'Header with Navigation', 'blogbd' ),
'description' => __( 'A complete header with logo, navigation menu, and search.', 'blogbd' ),
'categories' => array( 'headers' ),
'content' =>
'
',
)
);
}
function blogbd_register_minimal_header() {
register_block_pattern(
'blogbd/minimal-header',
array(
'title' => __( 'Minimal Header', 'blogbd' ),
'description' => __( 'A clean, minimal header with centered logo and simple navigation.', 'blogbd' ),
'categories' => array( 'headers' ),
'content' =>
'
',
)
);
}
// ==================== BANNER PATTERNS ====================
function blogbd_register_featured_banner() {
register_block_pattern(
'blogbd/featured-banner',
array(
'title' => __( 'Featured Post Banner', 'blogbd' ),
'description' => __( 'A prominent banner showcasing featured content with category badge.', 'blogbd' ),
'categories' => array( 'banners' ),
'content' =>
'
' . esc_html__( 'Featured Story', 'blogbd' ) . '
',
)
);
}
function blogbd_register_news_banner() {
register_block_pattern(
'blogbd/news-banner',
array(
'title' => __( 'Breaking News Banner', 'blogbd' ),
'description' => __( 'An attention-grabbing banner for breaking news or announcements.', 'blogbd' ),
'categories' => array( 'banners' ),
'content' =>
'
' . esc_html__( 'Breaking News:', 'blogbd' ) . ' ' . esc_html__( 'Important announcement or latest update goes here.', 'blogbd' ) . '
',
)
);
}
// ==================== ABOUT PATTERNS ====================
function blogbd_register_about_pattern() {
register_block_pattern(
'blogbd/about-section',
array(
'title' => __( 'About Section', 'blogbd' ),
'description' => __( 'An about section with image and text columns.', 'blogbd' ),
'categories' => array( 'about' ),
'content' =>
'
' . esc_html__( 'About Us', 'blogbd' ) . '
' . esc_html__( 'We\'re passionate about sharing stories, tips, and tutorials that inspire creativity and growth.', 'blogbd' ) . '
',
)
);
}
function blogbd_register_team_section() {
register_block_pattern(
'blogbd/team-section',
array(
'title' => __( 'Team Section', 'blogbd' ),
'description' => __( 'Display your team members with photos and descriptions.', 'blogbd' ),
'categories' => array( 'about' ),
'content' =>
'
' . esc_html__( 'Meet Our Team', 'blogbd' ) . '
' . esc_html__( 'John Doe', 'blogbd' ) . '
' . esc_html__( 'Founder & Editor', 'blogbd' ) . '
' . esc_html__( 'Jane Smith', 'blogbd' ) . '
' . esc_html__( 'Content Manager', 'blogbd' ) . '
',
)
);
}
function blogbd_register_mission_section() {
register_block_pattern(
'blogbd/mission-section',
array(
'title' => __( 'Mission & Values', 'blogbd' ),
'description' => __( 'A section highlighting company mission and core values.', 'blogbd' ),
'categories' => array( 'about' ),
'content' =>
'
' . esc_html__( 'Our Mission & Values', 'blogbd' ) . '
' . esc_html__( 'We believe in creating meaningful content that makes a difference.', 'blogbd' ) . '
' . esc_html__( 'Quality', 'blogbd' ) . '
' . esc_html__( 'We deliver high-quality, well-researched content that our readers can trust.', 'blogbd' ) . '
' . esc_html__( 'Community', 'blogbd' ) . '
' . esc_html__( 'Building a supportive community where ideas and stories can flourish.', 'blogbd' ) . '
' . esc_html__( 'Innovation', 'blogbd' ) . '
' . esc_html__( 'Always exploring new ways to tell stories and engage with our audience.', 'blogbd' ) . '
',
)
);
}
// ==================== CALL TO ACTION PATTERNS ====================
function blogbd_register_cta_pattern() {
register_block_pattern(
'blogbd/cta-section',
array(
'title' => __( 'Call to Action', 'blogbd' ),
'description' => __( 'A centered call-to-action with button.', 'blogbd' ),
'categories' => array( 'call-to-action' ),
'content' =>
'
' . esc_html__( 'Join Our Community', 'blogbd' ) . '
',
)
);
}
function blogbd_register_newsletter_cta() {
register_block_pattern(
'blogbd/newsletter-cta',
array(
'title' => __( 'Newsletter Signup', 'blogbd' ),
'description' => __( 'A newsletter subscription call to action with email input.', 'blogbd' ),
'categories' => array( 'call-to-action' ),
'content' =>
'
' . esc_html__( 'Stay Updated', 'blogbd' ) . '
' . esc_html__( 'Subscribe to our newsletter and never miss our latest news and updates.', 'blogbd' ) . '
',
)
);
}
function blogbd_register_download_cta() {
register_block_pattern(
'blogbd/download-cta',
array(
'title' => __( 'Download CTA', 'blogbd' ),
'description' => __( 'A call to action for downloading resources or content.', 'blogbd' ),
'categories' => array( 'call-to-action' ),
'content' =>
'
' . esc_html__( 'Free E-book Download', 'blogbd' ) . '
' . esc_html__( 'Get our free guide to starting your own successful blog. Packed with tips and strategies.', 'blogbd' ) . '
',
)
);
}
// ==================== FOOTER PATTERNS ====================
function blogbd_register_footer_simple() {
register_block_pattern(
'blogbd/footer-simple',
array(
'title' => __( 'Simple Footer', 'blogbd' ),
'description' => __( 'A simple footer with text and social links.', 'blogbd' ),
'categories' => array( 'footers' ),
'content' =>
'
© ' . esc_html( date( 'Y' ) ) . ' ' . esc_html__( 'BlogBD. All rights reserved.', 'blogbd' ) . '
',
)
);
}
function blogbd_register_footer_columns() {
register_block_pattern(
'blogbd/footer-columns',
array(
'title' => __( 'Footer with Columns', 'blogbd' ),
'description' => __( 'A multi-column footer with navigation and contact information.', 'blogbd' ),
'categories' => array( 'footers' ),
'content' =>
'
' . esc_html__( 'BlogBD', 'blogbd' ) . '
' . esc_html__( 'Sharing stories that matter. Join our community of readers and writers.', 'blogbd' ) . '
' . esc_html__( 'Quick Links', 'blogbd' ) . '
' . esc_html__( 'Contact', 'blogbd' ) . '
email@blogbd.com +1 234 567 890
',
)
);
}
function blogbd_register_footer_with_menu() {
register_block_pattern(
'blogbd/footer-with-menu',
array(
'title' => __( 'Footer with Menu', 'blogbd' ),
'description' => __( 'A comprehensive footer with menu links and copyright.', 'blogbd' ),
'categories' => array( 'footers' ),
'content' =>
'
© ' . esc_html( date( 'Y' ) ) . ' ' . esc_html__( 'BlogBD Theme. Built with WordPress.', 'blogbd' ) . '
',
)
);
}
// ==================== GALLERY PATTERNS ====================
function blogbd_register_gallery_grid() {
register_block_pattern(
'blogbd/gallery-grid',
array(
'title' => __( 'Gallery Grid', 'blogbd' ),
'description' => __( 'A responsive image gallery grid.', 'blogbd' ),
'categories' => array( 'gallery' ),
'content' =>
'
',
)
);
}
function blogbd_register_masonry_gallery() {
register_block_pattern(
'blogbd/masonry-gallery',
array(
'title' => __( 'Masonry Gallery', 'blogbd' ),
'description' => __( 'A Pinterest-style masonry layout gallery.', 'blogbd' ),
'categories' => array( 'gallery' ),
'content' =>
'
',
)
);
}
function blogbd_register_carousel_gallery() {
register_block_pattern(
'blogbd/carousel-gallery',
array(
'title' => __( 'Image Carousel', 'blogbd' ),
'description' => __( 'A horizontal scrolling image carousel.', 'blogbd' ),
'categories' => array( 'gallery' ),
'content' =>
'
',
)
);
}
// ==================== TEXT PATTERNS ====================
function blogbd_register_text_highlight() {
register_block_pattern(
'blogbd/text-highlight',
array(
'title' => __( 'Highlighted Text Section', 'blogbd' ),
'description' => __( 'A centered text section with large typography.', 'blogbd' ),
'categories' => array( 'text' ),
'content' =>
'
' . esc_html__( 'Writing that inspires readers to think differently.', 'blogbd' ) . '
',
)
);
}
function blogbd_register_quote_section() {
register_block_pattern(
'blogbd/quote-section',
array(
'title' => __( 'Quote Section', 'blogbd' ),
'description' => __( 'A prominent quote or testimonial section.', 'blogbd' ),
'categories' => array( 'text' ),
'content' =>
'
' . esc_html__( 'The best stories are those that connect us to our shared humanity and inspire positive change in the world.', 'blogbd' ) . '
' . esc_html__( 'BlogBD Community', 'blogbd' ) . '
',
)
);
}
function blogbd_register_featured_text() {
register_block_pattern(
'blogbd/featured-text',
array(
'title' => __( 'Featured Text with Background', 'blogbd' ),
'description' => __( 'Text content with colored background for emphasis.', 'blogbd' ),
'categories' => array( 'text' ),
'content' =>
'
' . esc_html__( 'Why Stories Matter', 'blogbd' ) . '
' . esc_html__( 'Stories have the power to transform perspectives, build connections, and create lasting impact. Through shared experiences, we learn, grow, and understand our world better.', 'blogbd' ) . '
',
)
);
}
// ==================== POST PATTERNS ====================
function blogbd_register_featured_posts() {
register_block_pattern(
'blogbd/featured-posts',
array(
'title' => __( 'Featured Posts Grid', 'blogbd' ),
'description' => __( 'A grid layout showcasing featured blog posts.', 'blogbd' ),
'categories' => array( 'posts' ),
'content' =>
'
' . esc_html__( 'Featured Posts', 'blogbd' ) . '
',
)
);
}
function blogbd_register_post_grid() {
register_block_pattern(
'blogbd/post-grid',
array(
'title' => __( 'Post Grid Layout', 'blogbd' ),
'description' => __( 'A clean grid layout for displaying blog posts.', 'blogbd' ),
'categories' => array( 'posts' ),
'content' =>
'
',
)
);
}
function blogbd_register_recent_posts() {
register_block_pattern(
'blogbd/recent-posts',
array(
'title' => __( 'Recent Posts List', 'blogbd' ),
'description' => __( 'A simple list of recent blog posts.', 'blogbd' ),
'categories' => array( 'posts' ),
'content' =>
'
' . esc_html__( 'Recent Posts', 'blogbd' ) . '
',
)
);
}
// ==================== ARCHIVE PATTERNS ====================
function blogbd_register_archive_header() {
register_block_pattern(
'blogbd/archive-header',
array(
'title' => __( 'Archive Page Header', 'blogbd' ),
'description' => __( 'A header section for archive pages with title and description.', 'blogbd' ),
'categories' => array( 'archive' ),
'content' =>
'
',
)
);
}
function blogbd_register_category_grid() {
register_block_pattern(
'blogbd/category-grid',
array(
'title' => __( 'Category Grid', 'blogbd' ),
'description' => __( 'A grid layout for displaying post categories.', 'blogbd' ),
'categories' => array( 'archive' ),
'content' =>
'
' . esc_html__( 'Browse by Category', 'blogbd' ) . '
',
)
);
}
// Initialize the block patterns
add_action( 'init', 'blogbd_register_block_patterns' );