Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** Custom Reading Time Meta Function */
- function custom_reading_time_meta() {
- if ( \JNews\Single\SinglePost::getInstance()->show_reading_time_meta() ) {
- $output = '';
- if ( vp_metabox( 'jnews_single_post.override_template' ) ) {
- $wpm = (int) vp_metabox( 'jnews_single_post.override.0.post_reading_time_wpm' );
- } else {
- $wpm = (int) get_theme_mod( 'jnews_single_reading_time_wpm', 300 );
- }
- $content = get_post_field( 'post_content', get_the_ID() );
- if ( $content && $wpm ) {
- $content = strip_shortcodes( $content );
- $word_count = str_word_count( $content );
- $word_count = ceil( $word_count / $wpm );
- $reading_time = jnews_return_translation( 'Reading Time: ', 'jnews', 'reading_time' ) . sprintf( _n( jnews_return_translation( '%d min read', 'jnews', 'min_read_s' ), jnews_return_translation( '%d mins read', 'jnews', 'min_read_p', 'jnews' ), $word_count ), $word_count );
- if ( $word_count ) {
- $output =
- "<div class=\"jeg_meta_reading_time\">
- <span>
- " . $reading_time . "
- </span>
- </div>";
- }
- }
- return jnews_sanitize_by_pass( $output );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement