', esc_url( get_bloginfo( 'pingback_url' ) ) );
}
}
add_action( 'wp_head', 'buzzpress_pingback_header' );
/**
Add Image Size
**/
function buzzpress_thumbsize() {
add_image_size( 'buzzpress-sidebar-thumbnail', 100, 80, true );
add_image_size( 'buzzpress-search-thumbnail', 150, 150, true );
add_image_size( 'buzzpress-home-thumbnail', 370, 320, true );
add_image_size( 'buzzpress-blog-thumbnail', 1200, 628, true );
}
add_action( 'after_setup_theme', 'buzzpress_thumbsize' );
/**
Custom Excerpt
**/
function buzzpress_get_excerpt( $count ) {
global $post;
$permalink = esc_url(get_permalink($post->ID));
$excerpt = get_the_content();
$excerpt = strip_tags($excerpt);
$excerpt = substr($excerpt, 0, $count);
$excerpt = wp_kses_post(substr($excerpt, 0, strripos($excerpt, " ")));
if(!is_home() || is_front_page()){
$excerpt = '
'.$excerpt.'...
';
return $excerpt;
}
}
/**
Site Logo
**/
function buzzpress_site_logo( $args = array(), $echo = true ) {
$logo = get_custom_logo();
$site_title = get_bloginfo( 'name' );
$contents = '';
$classname = '';
$defaults = array(
'logo' => '%1$s%2$s',
'logo_class' => 'site-logo',
'title' => '%2$s',
'title_class' => 'site-title',
'home_wrap' => '%2$s
',
'single_wrap' => '%2$s
',
'condition' => ( is_front_page() || is_home() ) && ! is_page(),
);
$args = wp_parse_args( $args, $defaults );
/**
* Filters the arguments for `buzzpress_site_logo()`.
*
* @param array $args Parsed arguments.
* @param array $defaults Function's default arguments.
*/
$args = apply_filters( 'buzzpress_site_logo_args', $args, $defaults );
if ( has_custom_logo() ) {
$contents = sprintf( $args['logo'], $logo, esc_html( $site_title ) );
$classname = $args['logo_class'];
} else {
$contents = sprintf( $args['title'], esc_url( get_home_url( null, '/' ) ), esc_html( $site_title ) );
$classname = $args['title_class'];
}
$wrap = $args['condition'] ? 'home_wrap' : 'single_wrap';
$html = sprintf( $args[ $wrap ], $classname, $contents );
/**
* Filters the arguments for `buzzpress_site_logo()`.
*
* @param string $html Compiled html based on our arguments.
* @param array $args Parsed arguments.
* @param string $classname Class name based on current view, home or single.
* @param string $contents HTML for site title or logo.
*/
$html = apply_filters( 'buzzpress_site_logo', $html, $args, $classname, $contents );
if ( ! $echo ) {
return $html;
}
echo $html; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
/**
* Displays the site description.
*
* @param boolean $echo Echo or return the html.
*
* @return string $html The HTML to display.
*/
function buzzpress_site_description( $echo = true ) {
$description = get_bloginfo( 'description' );
if ( ! $description ) {
return;
}
$wrapper = '%s
';
$html = sprintf( $wrapper, esc_html( $description ) );
/**
* Filters the html for the site description.
*
* @since 1.0.0
*
* @param string $html The HTML to display.
* @param string $description Site description via `bloginfo()`.
* @param string $wrapper The format used in case you want to reuse it in a `sprintf()`.
*/
$html = apply_filters( 'buzzpress_site_description', $html, $description, $wrapper );
if ( ! $echo ) {
return $html;
}
echo $html; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function buzzpress_widgets_init() {
register_sidebar(
array(
'name' => esc_html__( 'Sidebar', 'buzzpress' ),
'id' => 'sidebar',
'description' => esc_html__( 'Add widgets here.', 'buzzpress' ),
'before_widget' => '',
'before_title' => '',
) );
register_sidebar(
array(
'name' => esc_html__('Footer Menu Widget Area','buzzpress'),
'id' => 'footer_menu',
'description' => esc_html__('Footer Menu Area','buzzpress'),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
));
register_sidebar(
array(
'name' => esc_html__('© Copyright Widget Area','buzzpress'),
'id' => 'copyright',
'description' => esc_html__('Add Copyright Text','buzzpress'),
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '',
));
}
add_action( 'widgets_init', 'buzzpress_widgets_init' );
/**
Pagination
**/
function buzzpress_the_posts_pagination() {
the_posts_pagination( array(
'mid_size' => 2,
'prev_text' => __( 'Previous', 'buzzpress' ),
'next_text' => __( 'Next', 'buzzpress' ),
) );
}
/**
* Fix skip link focus in IE11.
*
* This does not enqueue the script because it is tiny and because it is only for IE11,
* thus it does not warrant having an entire dedicated blocking script being loaded.
*
* @link https://git.io/vWdr2
*/
function buzzpress_skip_link_focus_fix() {
// The following is minified via `terser --compress --mangle -- assets/js/skip-link-focus-fix.js`.
?>
' . __( 'Skip to the content', 'buzzpress' ) . '';
}
add_action( 'wp_body_open', 'buzzpress_skip_link', 5 );
/**
* Include Kirki
*/
function buzzpress_kirki_configuration() {
return array( 'url_path' => get_stylesheet_directory_uri() . '/inc/kirki/' );
}
add_filter( 'kirki/config', 'buzzpress_kirki_configuration' );
/**
Estimated reading time
**/
function buzzpress_reading_time() {
global $post;
$content = get_post_field( 'post_content', $post->ID );
$word_count = str_word_count( strip_tags( $content ) );
$readingtime = ceil($word_count / 200);
if ($readingtime == 1) {
$timer = " minute read";
} else {
$timer = " minutes read";
}
$totalreadingtime = $readingtime . $timer;
echo '' . $totalreadingtime;
}