80, 'width' => 200, 'flex-height' => true, 'flex-width' => true, )); add_theme_support('html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', 'style', 'script', )); add_theme_support( 'custom-header', array( 'width' => 2000, 'height' => 1200, ) ); add_theme_support('custom-background'); add_theme_support('editor-styles'); add_editor_style('style.css'); register_nav_menus(array( 'primary' => __('Primary Menu', 'bloggerly'), )); register_block_pattern( 'bloggerly/hero', array( 'title' => __('Hero Section', 'bloggerly'), 'content' => '

Hero Title

', ) ); } add_action('after_setup_theme', 'bloggerly_theme_setup'); /** * Enqueue scripts and styles */ function bloggerly_enqueue_scripts() { wp_enqueue_style( 'bloggerly-style', get_stylesheet_uri(), array(), wp_get_theme()->get('Version') ); wp_enqueue_script( 'bloggerly-theme-js', get_template_directory_uri() . '/assets/js/theme.js', array(), wp_get_theme()->get('Version'), true ); } add_action('wp_enqueue_scripts', 'bloggerly_enqueue_scripts'); /** * Custom image sizes */ function bloggerly_image_sizes() { add_image_size('bloggerly-featured-large', 1200, 800, true); } add_action('after_setup_theme', 'bloggerly_image_sizes'); /** * Register widget areas */ function bloggerly_widgets_init() { register_sidebar( array( 'name' => esc_html__('Sidebar', 'bloggerly'), 'id' => 'sidebar-1', 'description' => esc_html__('Main Sidebar', 'bloggerly'), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); } add_action('widgets_init', 'bloggerly_widgets_init'); /** * Set content width */ function bloggerly_content_width() { $GLOBALS['bloggerly_content_width'] = apply_filters('bloggerly_content_width', 800); } add_action('after_setup_theme', 'bloggerly_content_width', 0); /** * Customizer Settings */ function bloggerly_customize_register($wp_customize) { $wp_customize->add_setting('bloggerly_primary_color', array( 'default' => '#6c5ce7', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'refresh', )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'bloggerly_primary_color', array( 'label' => __('Primary Color', 'bloggerly'), 'section' => 'colors', ))); $wp_customize->add_setting('bloggerly_font_family', array( 'default' => 'sans', 'sanitize_callback' => 'sanitize_key', 'transport' => 'refresh', )); $wp_customize->add_control('bloggerly_font_family', array( 'label' => __('Body Font Family', 'bloggerly'), 'section' => 'colors', 'type' => 'select', 'choices' => array( 'sans' => 'System Sans-Serif', 'serif' => 'Georgia / Serif', 'mono' => 'Monospace', ), )); } add_action('customize_register', 'bloggerly_customize_register'); /** * Output Customizer CSS */ function bloggerly_customizer_css() { $primary = get_theme_mod('bloggerly_primary_color', '#6c5ce7'); $font_choice = get_theme_mod('bloggerly_font_family', 'sans'); $font_css = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif'; if ('serif' === $font_choice) { $font_css = '"Georgia", "Times New Roman", Times, serif'; } elseif ('mono' === $font_choice) { $font_css = '"Courier New", Courier, monospace'; } if ($primary !== '#6c5ce7' || $font_choice !== 'sans') { ?> is_main_query() && $query->is_home()) { $query->set('posts_per_page', 9); } } add_action('pre_get_posts', 'bloggerly_query_adjustments'); /** * Inline SVG Logo Logic */ function bloggerly_inline_svg_logo($html) { if (strpos($html, '.svg') !== false) { $logo_id = get_theme_mod('custom_logo'); $file_path = get_attached_file($logo_id); if ($file_path && file_exists($file_path)) { $svg = file_get_contents($file_path); if ($svg) { return $svg; } } } return $html; } add_filter('get_custom_logo', 'bloggerly_inline_svg_logo'); /** * Register custom block styles. */ function bloggerly_register_block_styles() { register_block_style( 'core/paragraph', array( 'name' => 'highlight-paragraph', 'label' => __('Highlight Paragraph', 'bloggerly'), ) ); } add_action('init', 'bloggerly_register_block_styles'); /** * Output custom font CSS safely (NO phpcs:ignore) */ function bloggerly_output_font_css($font_css) { $allowed_fonts = array( 'Arial', 'Helvetica', 'Georgia', 'Times New Roman', ); if (in_array($font_css, $allowed_fonts, true)) { echo esc_attr($font_css); } }