Advertisement
fauzanjeg

Custom Meta for JNews - Module 3 || Add Category

Oct 17th, 2021
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.76 KB | None | 0 0
  1. /* Custom Meta for JNews - Module 3 || Add Category */
  2. function custom_post_meta_1_module_3(  $output, $post, $instance ) {
  3.     if ( get_class( $instance ) === 'JNews\Module\Block\Block_3_View' ) {
  4.         $output = '';
  5.         $block_3_class = JNews\Module\Block\Block_3_View::getInstance();
  6.         if ( get_theme_mod( 'jnews_show_block_meta', true ) ) {
  7.             $comment    = jnews_get_comments_number( $post->ID );
  8.             $view_count = jnews_meta_views( $post->ID );
  9.  
  10.             // author detail
  11.             $author        = isset( $post->post_author ) ? $post->post_author : 'rss_post';
  12.             $is_rss        = jnews_get_rss_post_id( $author );
  13.             $author_url    = $is_rss ? ( isset( $post->post_author_url ) ? $post->post_author_url : '' ) : get_author_posts_url( $author );
  14.             $author_name   = $is_rss ? $post->post_author_name : get_the_author_meta( 'display_name', $author );
  15.             $author_avatar = ( $is_rss ? false : $avatar) ?
  16.                 '<div class="jeg_author_avatar">
  17.                    ' . get_avatar( get_the_author_meta( 'ID', $post->post_author ), 80, null, get_the_author_meta( 'display_name', $post->post_author ) ) . '
  18.                </div>' : '';
  19.  
  20.             $trending = ( vp_metabox( 'jnews_single_post.trending_post', null, $post->ID ) ) ? "<div class=\"jeg_meta_trending\"><a href=\"" . get_the_permalink( $post ) . "\"><i class=\"fa fa-bolt\"></i></a></div>" : "";
  21.  
  22.             if ( jnews_is_review( $post->ID ) ) {
  23.                 $rating = jnews_generate_rating( $post->ID, 'jeg_landing_review' );
  24.  
  25.                 $output .= "<div class=\"jeg_post_meta\">";
  26.                 $output .= $trending;
  27.                 $output .= get_theme_mod( 'jnews_show_block_meta_rating', true ) ? $rating : "";
  28.                 $output .= get_theme_mod( 'jnews_show_block_meta_author', true ) ? ( jnews_check_coauthor_plus() ? "<div class=\"jeg_meta_author coauthor\">" . jnews_get_author_coauthor( $post->ID, false, 'by', 1 ) . "</div>" : "<div class=\"jeg_meta_author\"><span class=\"by\">" . jnews_return_translation( 'by', 'jnews', 'by' ) . "</span> <a href=\"{$author_url}\">{$author_name}</a></div>" ) : "";
  29.                 /* Start Custom */
  30.                 $output .= "<div class=\"jeg_post_category\">";
  31.                 $output .= "<span> In " . $block_3_class->get_primary_category ($post->ID ) . "</span>";
  32.                 $output .= "</div>";
  33.                 /* End Custom */
  34.                 $output .= "</div>";
  35.             } else {
  36.                 $output .= "<div class=\"jeg_post_meta\">";
  37.                 $output .= $trending;
  38.                 $output .= get_theme_mod( 'jnews_show_block_meta_author', true ) ? ( jnews_check_coauthor_plus() ? "<div class=\"jeg_meta_author coauthor\">" . jnews_get_author_coauthor( $post->ID, $avatar, 'by', 1 ) . "</div>" : "<div class=\"jeg_meta_author\">" . $author_avatar . "<span class=\"by\">" . jnews_return_translation( 'by', 'jnews', 'by' ) . "</span> <a href=\"{$author_url}\">{$author_name}</a></div>" ) : "";
  39.                 $output .= get_theme_mod( 'jnews_show_block_meta_date', true ) ? "<div class=\"jeg_meta_date\"><a href=\"" . get_the_permalink( $post ) . "\"><i class=\"fa fa-clock-o\"></i> " . $block_3_class->format_date( $post ) . "</a></div>" : "";
  40.                 $output .= get_theme_mod( 'jnews_show_block_meta_comment', true ) && ! $feed ? "<div class=\"jeg_meta_comment\"><a href=\"" . jnews_get_respond_link( $post->ID ) . "\" ><i class=\"fa fa-comment-o\"></i> {$comment} </a></div>" : "";
  41.                 $output .= get_theme_mod( 'jnews_show_block_meta_views', false ) && ! $feed ? "<div class=\"jeg_meta_views\"><a href=\"" . get_the_permalink( $post->ID ) . "\" ><i class=\"fa fa-eye\"></i> {$view_count} </a></div>" : "";
  42.                 /* Start Custom */
  43.                 $output .= "<div class=\"jeg_post_category\">";
  44.                 $output .= "<span> In " . $block_3_class->get_primary_category ($post->ID ) . "</span>";
  45.                 $output .= "</div>";
  46.                 /* End Custom */
  47.                 $output .= "</div>";
  48.             }
  49.         }
  50.         return $output;
  51.     }
  52.     return $output;
  53. }
  54. add_filter( 'jnews_module_post_meta_1', 'custom_post_meta_1_module_3', null, 3 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement