240, 'width' => 320, 'flex-height' => true, 'flex-width' => true, 'header-text' => array('blog-title', 'blog-description'), )); // Make the theme translation ready load_theme_textdomain('bsblog', get_template_directory() . '/languages'); } add_action('after_setup_theme', 'bstheme_setup'); endif; /* --------------------------------------------------------------------------------------------- ENQUEUE JAVASCRIPT --------------------------------------------------------------------------------------------- */ if (!function_exists('bsblog_load_javascript_files')): function bsblog_load_javascript_files() { $theme_version = wp_get_theme('bsblog')->get('Version'); wp_register_script('bsblog_flexslider', get_template_directory_uri() . '/assets/js/flexslider.js', '2.4.0', true); wp_register_script('bsblog_doubletap', get_template_directory_uri() . '/assets/js/doubletaptogo.js', $theme_version, true); wp_enqueue_script('bsblog_global', get_template_directory_uri() . '/assets/js/global.js', array('jquery', 'bsblog_flexslider', 'bsblog_doubletap'), $theme_version, true); if (is_singular()) { wp_enqueue_script('comment-reply'); } } add_action('wp_enqueue_scripts', 'bsblog_load_javascript_files'); endif; /* --------------------------------------------------------------------------------------------- ENQUEUE STYLES --------------------------------------------------------------------------------------------- */ if (!function_exists('bsblog_load_style')): function bsblog_load_style() { if (is_admin()) { return; } $theme_version = wp_get_theme('bsblog')->get('Version'); $dependencies = array(); /** * Translators: If there are characters in your language that are not * supported by the theme fonts, translate this to 'off'. Do not translate * into your own language. */ if ('off' !== _x('on', 'Google Fonts: on or off', 'bsblog')) { // Register Google Fonts wp_register_style('bsblog_google_fonts', '//fonts.googleapis.com/css?family=Lato:400,700,900,400italic,700italic|Merriweather:700,900,400italic'); $dependencies[] = 'bsblog_google_fonts'; } wp_register_style('bsblog_fontawesome', get_template_directory_uri() . '/assets/css/font-awesome.min.css', array(), '5.13.0'); $dependencies[] = 'bsblog_fontawesome'; wp_enqueue_style('bsblog_style', get_stylesheet_uri(), $dependencies, $theme_version); } add_action('wp_print_styles', 'bsblog_load_style'); endif; /* --------------------------------------------------------------------------------------------- ADD EDITOR STYLES --------------------------------------------------------------------------------------------- */ if (!function_exists('bsblog_add_editor_styles')): function bsblog_add_editor_styles() { add_editor_style('assets/css/bsblog-classic-editor-styles.css'); /** * Translators: If there are characters in your language that are not * supported by the theme fonts, translate this to 'off'. Do not translate * into your own language. */ if ('off' !== _x('on', 'Google Fonts: on or off', 'bsblog')) { $font_url = '//fonts.googleapis.com/css?family=Lato:400,700,900|Playfair+Display:400,700,400italic'; add_editor_style(str_replace(', ', '%2C', $font_url)); } } add_action('init', 'bsblog_add_editor_styles'); endif; /* --------------------------------------------------------------------------------------------- ADD WIDGET AREAS --------------------------------------------------------------------------------------------- */ if (!function_exists('bsblog_sidebar_registration')): function bsblog_sidebar_registration() { register_sidebar(array( 'name' => __('Sidebar', 'bsblog'), 'id' => 'sidebar', 'description' => __('Widgets in this area will be shown in the sidebar.', 'bsblog'), 'before_title' => '

', 'after_title' => '

', 'before_widget' => '
', 'after_widget' => '
', )); } add_action('widgets_init', 'bsblog_sidebar_registration'); endif; /* --------------------------------------------------------------------------------------------- INCLUDE REQUIRED FILES --------------------------------------------------------------------------------------------- */ // Theme Customizer options. require get_template_directory() . '/inc/classes/class-bsblog-customizer.php'; // Recent Comments widget require get_template_directory() . '/inc/widgets/recent-comments.php'; // Recent Posts widget require get_template_directory() . '/inc/widgets/recent-posts.php'; /* --------------------------------------------------------------------------------------------- MODIFY WIDGETS --------------------------------------------------------------------------------------------- */ if (!function_exists('bsblog_unregister_default_widgets')): function bsblog_unregister_default_widgets() { // Register custom widgets register_widget('Rowling_Recent_Comments'); register_widget('Rowling_Recent_Posts'); // Unregister replaced widgets unregister_widget('WP_Widget_Recent_Comments'); unregister_widget('WP_Widget_Recent_Posts'); } add_action('widgets_init', 'bsblog_unregister_default_widgets', 11); endif; /* --------------------------------------------------------------------------------------------- CHECK FOR JAVASCRIPT --------------------------------------------------------------------------------------------- */ if (!function_exists('bsblog_html_js_class')) { function bsblog_html_js_class() { echo '' . "\n"; } add_action('wp_head', 'bsblog_html_js_class', 1); } /* --------------------------------------------------------------------------------------------- RELATED POSTS FUNCTION --------------------------------------------------------------------------------------------- */ if (!function_exists('bsblog_related_posts')): function bsblog_related_posts($number_of_posts = 3) { ?>

→

true, 'meta_key' => '_thumbnail_id', 'posts_per_page' => $number_of_posts, 'post_status' => 'publish', 'post__not_in' => array($post->ID), ); // Create a query for posts in the same category as the ones for the current post $cat_ids = array(); $categories = get_the_category(); foreach ($categories as $category) { $cat_ids[] = $category->cat_ID; } $term_posts_args = array_merge($base_args, array('category__in' => $cat_ids)); $related_posts = get_posts($term_posts_args); // No results for the categories? Get random posts instead if (!$related_posts): $random_posts_args = array_merge($base_args, array('orderby' => 'rand')); $related_posts = get_posts($random_posts_args); endif; // If either the category query or random query hit pay dirt, output the posts if ($related_posts): foreach ($related_posts as $related_post): ?> ID)): ?> ID, 'post-image-thumb') ?>

ID); echo $category[0]->cat_name; ?>

ID); ?>

' . __('Read More', 'bsblog') . '

'; } add_filter('the_content_more_link', 'bsblog_modify_read_more_link'); endif; /* --------------------------------------------------------------------------------------------- BODY CLASSES --------------------------------------------------------------------------------------------- */ if (!function_exists('bsblog_body_classes')): function bsblog_body_classes($classes) { // If has post thumbnail if (is_single() && has_post_thumbnail()) { $classes[] = 'has-featured-image'; } return $classes; } add_filter('body_class', 'bsblog_body_classes'); endif; /* --------------------------------------------------------------------------------------------- GET COMMENT EXCERPT LENGTH --------------------------------------------------------------------------------------------- */ if (!function_exists('bsblog_get_comment_excerpt')): function bsblog_get_comment_excerpt($comment_ID = 0, $num_words = 20) { $comment = get_comment($comment_ID); $comment_text = strip_tags($comment->comment_content); $blah = explode(' ', $comment_text); if (count($blah) > $num_words) { $k = $num_words; $use_dotdotdot = 1; } else { $k = count($blah); $use_dotdotdot = 0; } $excerpt = ''; for ($i = 0; $i < $k; $i++) { $excerpt .= $blah[$i] . ' '; } $excerpt .= ($use_dotdotdot) ? '...' : ''; return apply_filters('get_comment_excerpt', $excerpt); } endif; /* --------------------------------------------------------------------------------------------- FLEXSLIDER FUNCTION --------------------------------------------------------------------------------------------- */ if (!function_exists('bsblog_flexslider')): function bsblog_flexslider($size) { $attachment_parent = is_page() ? $post->ID : get_the_ID(); $images = get_posts(array( 'numberposts' => -1, 'orderby' => 'menu_order', 'order' => 'ASC', 'post_mime_type' => 'image', 'post_parent' => $attachment_parent, 'post_status' => null, 'post_type' => 'attachment', )); if (!$images) { return; } ?>
    ID, $size); if (!$attimg) { continue; } ?>
  • post_excerpt) && is_single()): ?>

    post_excerpt; ?>

' : '
'; } endif; /* --------------------------------------------------------------------------------------------- COMMENT FUNCTION --------------------------------------------------------------------------------------------- */ if (!function_exists('bsblog_comment')): function bsblog_comment($comment, $args, $depth) { switch ($comment->comment_type): case 'pingback': case 'trackback': ?>
  • id="comment-"> ', '');?>
  • id="li-comment-">
    user_id === $post->post_author): ?>

    ', '');?>
    comment_approved): ?>
    __('Reply', 'bsblog'), 'depth' => $depth, 'max_depth' => $args['max_depth'], 'before' => '
    ', 'after' => '
    ', )); endif;?>
    _x('Accent', 'Name of the accent color in the Block Editor palette', 'bsblog'), 'slug' => 'accent', 'color' => $accent_color, ), array( 'name' => _x('Black', 'Name of the black color in the Block Editor palette', 'bsblog'), 'slug' => 'black', 'color' => '#111', ), array( 'name' => _x('Dark Gray', 'Name of the dark gray color in the Block Editor palette', 'bsblog'), 'slug' => 'dark-gray', 'color' => '#333', ), array( 'name' => _x('Medium Gray', 'Name of the medium gray color in the Block Editor palette', 'bsblog'), 'slug' => 'medium-gray', 'color' => '#555', ), array( 'name' => _x('Light Gray', 'Name of the light gray color in the Block Editor palette', 'bsblog'), 'slug' => 'light-gray', 'color' => '#777', ), array( 'name' => _x('White', 'Name of the white color in the Block Editor palette', 'bsblog'), 'slug' => 'white', 'color' => '#fff', ), )); /* Block Editor Font Sizes ----------- */ add_theme_support('editor-font-sizes', array( array( 'name' => _x('Small', 'Name of the small font size in Block Editor', 'bsblog'), 'shortName' => _x('S', 'Short name of the small font size in the Block Editor.', 'bsblog'), 'size' => 15, 'slug' => 'small', ), array( 'name' => _x('Normal', 'Name of the normal font size in Block Editor', 'bsblog'), 'shortName' => _x('N', 'Short name of the normal font size in the Block Editor.', 'bsblog'), 'size' => 17, 'slug' => 'normal', ), array( 'name' => _x('Large', 'Name of the large font size in Block Editor', 'bsblog'), 'shortName' => _x('L', 'Short name of the large font size in the Block Editor.', 'bsblog'), 'size' => 24, 'slug' => 'large', ), array( 'name' => _x('Larger', 'Name of the larger font size in Block Editor', 'bsblog'), 'shortName' => _x('XL', 'Short name of the larger font size in the Block Editor.', 'bsblog'), 'size' => 28, 'slug' => 'larger', ), )); } add_action('after_setup_theme', 'bsblog_add_block_editor_features'); endif; /* --------------------------------------------------------------------------------------------- BLOCK EDITOR EDITOR STYLES --------------------------------------------------------------------------------------------- */ if (!function_exists('bsblog_block_editor_styles')): function bsblog_block_editor_styles() { $theme_version = wp_get_theme('bsblog')->get('Version'); $dependencies = array(); /** * Translators: If there are characters in your language that are not * supported by the theme fonts, translate this to 'off'. Do not translate * into your own language. */ if ('off' !== _x('on', 'Google Fonts: on or off', 'bsblog')) { wp_register_style('bsblog-block-editor-styles-font', '//fonts.googleapis.com/css?family=Lato:400,700,900,400italic,700italic|Merriweather:700,900,400italic', false, 1.0, 'all'); $dependencies[] = 'bsblog-block-editor-styles-font'; } // Enqueue the editor styles wp_enqueue_style('bsblog-block-editor-styles', get_theme_file_uri('/assets/css/bsblog-block-editor-styles.css'), $dependencies, $theme_version, 'all'); } add_action('enqueue_block_editor_assets', 'bsblog_block_editor_styles', 1); endif; /* --------------------------------------------------------------------------------------------- BLOCK EDITOR EDITOR STYLES --------------------------------------------------------------------------------------------- */ if (!function_exists('bsblog_substr')): function bsblog_substr($str = "", $length = 150, $after = "") { $tempStr = $str; $tempStr = ((strlen($tempStr) > $length)) ? mb_substr($tempStr, 0, $length) : $tempStr; $tempStr = !empty($after) ? $tempStr . $after : $tempStr; echo $tempStr; } endif;