Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'jnews_render_after_meta_left', 'render_custom_meta' );
- /**
- * Render custom meta structure
- *
- * @return void
- */
- function render_custom_meta() {
- $single = JNews\Single\SinglePost::getInstance();
- $post = get_post();
- $author = $post->post_author;
- ?>
- <div class="jeg_meta_author">
- <div class="left-meta-image">
- <?php echo get_avatar( get_the_author_meta( 'ID', $author ), 80, null, get_the_author_meta( 'display_name', $author ) ); ?>
- </div>
- <div class="left-meta-text">
- <div class="the-author-meta">
- <span class="meta_text"><?php jnews_print_translation( 'by', 'jnews', 'by' ); ?></span>
- <?php jnews_the_author_link( $author ); ?>
- </div>
- <div class="the-other-meta">
- <div class="jeg_meta_date">
- <a href="<?php the_permalink(); ?>"><?php echo esc_html( $single->post_date_format( $post ) ); ?></a>
- </div>
- <?php custom_reading_time_meta(); ?>
- </div>
- </div>
- </div>
- <?php
- }
- /**
- * Render custom reading time meta
- *
- * @return void
- */
- function custom_reading_time_meta() {
- $output = '';
- if ( jnews_get_metabox_value( 'jnews_single_post.override_template' ) ) {
- $wpm = (int) jnews_get_metabox_value( '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' === get_theme_mod( 'jnews_calculate_word_method', 'str_word_count' ) ) ? str_word_count( $content ) : substr_count( $content, ' ' ) + 5; /* see p3HUlGhX */
- $word_count = ceil( $word_count / $wpm );
- $reading_time = jnews_return_translation( 'Reading Time: ', 'jnews', 'reading_time' );
- if ( defined( 'JNEWS_FRONT_TRANSLATION' ) ) {
- $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 );
- } else {
- $reading_time .= sprintf( _n( '%d min read', '%d mins read', $word_count, 'jnews' ), $word_count );
- }
- if ( $word_count ) {
- $output =
- '<div class="jeg_meta_reading_time">
- <span>
- ' . $reading_time . '
- </span>
- </div>';
- }
- }
- echo jnews_sanitize_by_pass( $output );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement