' . $read_time . $time_unit . $time_postfix . ''; } break; default: $output_str = apply_filters( 'bevro_meta_case_' . $meta_value, $output_str, $loop_count, $separator ); } $loop_count ++; } return $output_str; } } if ( ! function_exists( 'bevro_calculate_reading_time' ) ){ /** * Calculate reading time. * * @since 1.0 * * @param int $post_id Post content. * @return int read time. */ function bevro_calculate_reading_time( $post_id ){ $post_content = get_post_field( 'post_content', $post_id ); $stripped_content = strip_shortcodes( $post_content ); $strip_tags_content = strip_tags( $stripped_content ); $word_count = str_word_count( $strip_tags_content ); $reading_time = ceil( $word_count / 220 ); return $reading_time; } } if ( ! function_exists( 'bevro_post_date' ) ){ /** * Function to get Date of Post * * @return html Markup. */ function bevro_post_date(){ $output = ''; $format = apply_filters( 'bevro_post_date_format', '' ); $time_string = esc_html( get_the_date( $format ) ); $modified_date = esc_html( get_the_modified_date( $format ) ); $posted_on = sprintf( esc_html( '%s' ), $time_string ); $modified_on = sprintf( esc_html( '%s' ), $modified_date ); $output .= ''; $output .= ''; //$output .= ' ' . $modified_on . ''; $output .= ''; return apply_filters( 'bevro_post_date', $output ); } } if ( ! function_exists( 'bevro_post_author' ) ){ /** * Function to get Author of Post * * @param string $output_filter Filter string. * @return html Markup. */ function bevro_post_author( $output_filter = '' ){ $output = ''; $byline = sprintf( esc_html( '%s' ), '' ); $output .= ''; return apply_filters( 'bevro_post_author', $output, $output_filter ); } } /** * Read more text. * * @param string $text default read more text. * @return string read more text */ function bevro_read_more_text( $text ){ $read_more = get_theme_mod( 'bevro_blog_read_more_txt' ); if ( '' != $read_more ){ $text = $read_more; } return $text; } add_filter( 'bevro_post_read_more', 'bevro_read_more_text'); /** * Function to get Read More Link of Post * * @since 1.0.0 * @return html */ if ( ! function_exists( 'bevro_post_link' ) ){ /** * Function to get Read More Link of Post * * @param string $output_filter Filter string. * @return html Markup. */ function bevro_post_link( $output_filter = '' ){ $enabled = apply_filters( 'bevro_post_link_enabled', '__return_true' ); if ( ( is_admin() && ! wp_doing_ajax() ) || ! $enabled ){ return $output_filter; } $bevro_read_more_text = apply_filters( 'bevro_post_read_more', __( 'Read More »', 'bevro' ) ); $read_more_classes = apply_filters( 'bevro_post_read_more_class', array() ); $post_link = sprintf( esc_html( '%s' ), ' ' . the_title( '', '', false ) . $bevro_read_more_text . '' ); $output = ' …

' . $post_link . '

'; return apply_filters( 'bevro_post_link', $output, $output_filter ); } } add_filter( 'excerpt_more', 'bevro_post_link', 1 ); /** * Function to get Number of Comments of Post * * @since 1.0.0 * @return html */ if ( ! function_exists( 'bevro_post_comments' ) ) { /** * Function to get Number of Comments of Post * * @param string $output_filter Output filter. * @return html Markup. */ function bevro_post_comments( $output_filter = '' ) { $output = ''; ob_start(); if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) { ?> ' . $tags_list . ''; } return apply_filters( 'bevro_post_tags', $output, $output_filter ); } } /** * Function to get Categories of Post * * @since 1.0.0 * @return html */ if ( ! function_exists( 'bevro_post_categories' ) ) { /** * Function to get Categories applied of Post * * @param string $output_filter Output filter. * @return html Markup. */ function bevro_post_categories( $output_filter = '' ){ $output = ''; /* translators: used between list items, there is a space after the comma */ $categories_list = get_the_category_list( __( ', ', 'bevro' ) ); if ( $categories_list ) { $output .= '' . $categories_list . ''; } return apply_filters( 'bevro_post_categories', $output, $output_filter ); } } /** * Prints HTML with meta information for the current post-date/time and author. */ if ( ! function_exists( 'bevro_blog_get_post_meta' ) ){ /** * Prints HTML with meta information for the current post-date/time and author. * * @since 1.0 * @return mixed Markup. */ function bevro_blog_get_post_meta() { $enable_meta = apply_filters( 'bevro_blog_post_meta_enabled', '__return_true' ); $post_meta = bevro_get_option( 'bevro-blog-meta' ); $post_meta_seprator = get_theme_mod( 'bevro_blog_meta_seprator','/' ); if ( 'post' == get_post_type() && is_array( $post_meta ) && $enable_meta ) { $output_str = bevro_get_post_meta( $post_meta, $post_meta_seprator); if ( ! empty( $output_str ) ) { echo apply_filters( 'bevro_blog_post_meta', '
' . $output_str . '
', $output_str ); // WPCS: XSS OK. } } } } /** * Excerpt count. * * @param int $length default count of words. * @return int count of words */ function bevro_excerpt_length( $length ){ $excerpt_length = (string) get_theme_mod( 'bevro_blog_expt_length' ); if ( '' != $excerpt_length ) { $length = $excerpt_length; } return $length; } add_filter( 'excerpt_length','bevro_excerpt_length', 999 ); /** * Read more class. * * @param array $class default classes. * @return array classes */ function bevro_read_more_class( $class ) { $read_more_button = get_theme_mod( 'bevro_main_read_more_btn' ); if ( $read_more_button ) { $class[] = 'brv-button'; } return $class; } add_filter( 'bevro_post_read_more_class','bevro_read_more_class', 999 ); /** * Display Blog Post Excerpt */ if ( ! function_exists( 'bevro_the_excerpt' ) ){ /** * Display Blog Post Excerpt * * @since 1.0.0 */ function bevro_the_excerpt(){?>
%2$s %3$s %4$s'; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ){ $time_string = ''; } $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date( 'M' ) ), esc_html( get_the_date( 'j' ) ), esc_html( get_the_date( 'Y' ) ), esc_attr( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_date() ) ); ob_start(); if ((function_exists('has_post_thumbnail')) && (has_post_thumbnail())){?>
', '' ); ?>
post_content ) ); $embeds = apply_filters( 'bevro_get_post_audio', get_media_embedded_in_content( $content ) ); if ( empty( $embeds ) ) { return ''; } // check what is the first embed containg video tag, youtube or vimeo. foreach ( $embeds as $embed ) { if ( strpos( $embed, 'audio' ) ) { return '' . $embed . ''; } } } } /** * Get first image from post content */ if ( ! function_exists( 'bevro_get_video_from_post' ) ) { /** * Get first image from post content * * @since 1.0 * @param number $post_id Post id. * @return mixed */ function bevro_get_video_from_post( $post_id ) { $post = get_post( $post_id ); $content = do_shortcode( apply_filters( 'the_content', $post->post_content ) ); $embeds = apply_filters( 'bevro_get_post_audio', get_media_embedded_in_content( $content ) ); if ( empty( $embeds ) ) { return ''; } // check what is the first embed containg video tag, youtube or vimeo. foreach ( $embeds as $embed ) { if ( strpos( $embed, 'video' ) || strpos( $embed, 'youtube' ) || strpos( $embed, 'vimeo' ) ) { return $embed; } } } } /**************************************/ //Blog Post Formate /**************************************/ if ( ! function_exists( 'bevro_blog_post_get_featured_item' ) ) { /** * To featured image / gallery / audio / video etc. As per the post format. * * @since 1.0 * @return mixed */ function bevro_blog_post_get_featured_item(){ $post_featured_data = ''; $post_format = get_post_format(); switch ( $post_format ){ case 'video': $video = bevro_get_video_from_post( get_the_ID() ); $post_featured_data = "
{$video}
"; break; case 'gallery': $post_featured_data = get_post_gallery( get_the_ID(), false ); break; case 'audio': $post_featured_data = do_shortcode( bevro_get_audios_from_post( get_the_ID() ) ); break; case 'quote': // Check is post has quote format if (has_post_format('quote', get_the_ID())){ $the_content = get_the_content(); // find blockquotes $regex = '/([\s\S]*?)/i'; $blockquotes = preg_match_all($regex, $the_content, $matches); // rebuild blockqoutes $my_blockquotes = ''; foreach ($matches[1] as $blockquote){ $my_blockquotes .= "{$blockquote}"; } // rebuild content $post_featured_data = ''; if (!empty($my_blockquotes)){ $post_featured_data = "
{$my_blockquotes}
\n"; } } break; } echo $post_featured_data; } } add_action( 'bevro_blog_post_featured_format', 'bevro_blog_post_get_featured_item' ); function bevro_get_post_gallery( $gallery, $post ){ // Already found a gallery so lets quit. // Check the post exists. $post = get_post( $post ); if ( ! $post ) { return $gallery; } if ( ! has_blocks( $post->post_content ) ){ return false; } /** * Search for gallery blocks and then, if found, return the html from the * first gallery block. * */ $pattern = "/([\s\S]*?)/i"; preg_match_all( $pattern, $post->post_content, $the_galleries ); // Check a gallery was found and if so change the gallery html. if ( ! empty( $the_galleries[1] ) ) { $gallery = reset( $the_galleries[1] ); } return $gallery; } add_filter( 'get_post_gallery', 'bevro_get_post_gallery', 10, 2 );