Advertisement
arie_cristianD

add custom link meta on JNews meta

Mar 18th, 2025
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.57 KB | None | 0 0
  1. add_filter( 'jnews_module_post_meta_3', 'override_module_meta_3', 99, 3 );
  2. add_filter( 'jnews_module_post_meta_2', 'override_module_meta_2', 99, 3 );
  3. add_filter( 'jnews_module_post_meta_1', 'override_module_meta_1', 99, 3 );
  4.  
  5.  
  6. add_action( 'jnews_render_after_meta_left', 'print_custom_meta_link' );
  7.  
  8.  
  9. /**
  10.  * Add your custom meta after JNews Left Meta on Single Post page.
  11.  */
  12. function print_custom_meta_link() {
  13.     echo '<div class="jeg_meta_custom"><a href="https://yourlink.com">LINK TEXT</a></div>'; /*  your custom meta here */
  14. }
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21. function override_module_meta_3( $output, $post, $instance ) {
  22.     $output = '';
  23.  
  24.     if ( get_theme_mod( 'jnews_show_block_meta', true ) ) {
  25.         $trending   = ( jnews_get_metabox_value( 'jnews_single_post.trending_post', null, $post->ID ) ) ? '<div class="jeg_meta_trending"><a href="' . get_the_permalink( $post ) . '" aria-label="' . esc_html__( 'View this Trending Post', 'jnews' ) . '"><i class="fa fa-bolt"></i></a></div>' : '';
  26.         $view_count = jnews_meta_views( $post->ID );
  27.  
  28.         if ( jnews_is_review( $post->ID ) ) {
  29.             $rating = jnews_generate_rating( $post->ID, 'jeg_landing_review' );
  30.  
  31.             $output .= '<div class="jeg_post_meta">';
  32.             $output .= $trending;
  33.             $output .= get_theme_mod( 'jnews_show_block_meta_rating', true ) ? $rating : '';
  34.             $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> ' . $instance->format_date( $post ) . '</a></div>' : '';
  35.             $output .= '</div>';
  36.         } else {
  37.  
  38.             // author detail
  39.             $author      = $post->post_author;
  40.             $author_url  = jnews_get_rss_post_id( $author ) ? $post->post_author_url : get_author_posts_url( $author );
  41.             $author_name = jnews_get_rss_post_id( $author ) ? $post->post_author_name : get_the_author_meta( 'display_name', $author );
  42.  
  43.             $output .= '<div class="jeg_post_meta">';
  44.             $output .= $trending;
  45.             $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>" ) : '';
  46.  
  47.             $output .= '<div class="jeg_meta_custom"><a href="https://yourlink.com">LINK TEXT</a></div>'; /*  your custom meta here */
  48.  
  49.             $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> ' . $instance->format_date( $post ) . '</a></div>' : '';
  50.             $output .= get_theme_mod( 'jnews_show_block_meta_views', false ) ? '<div class="jeg_meta_views"><a href="' . get_the_permalink( $post->ID ) . "\" ><i class=\"fa fa-eye\"></i> {$view_count} </a></div>" : '';
  51.             $output .= '</div>';
  52.  
  53.         }
  54.         return $output;
  55.     }
  56. }
  57.  
  58. function override_module_meta_2( $output, $post, $instance ) {
  59.     $output = '';
  60.  
  61.     if ( get_theme_mod( 'jnews_show_block_meta', true ) ) {
  62.         $trending   = ( jnews_get_metabox_value( 'jnews_single_post.trending_post', null, $post->ID ) ) ? '<div class="jeg_meta_trending"><a href="' . get_the_permalink( $post ) . '"  aria-label="' . esc_html__( 'View this Trending Post', 'jnews' ) . '"><i class="fa fa-bolt"></i></a></div>' : '';
  63.         $view_count = jnews_meta_views( $post->ID );
  64.  
  65.         if ( jnews_is_review( $post->ID ) ) {
  66.             $output .= '<div class="jeg_post_meta">';
  67.             $output .= $trending;
  68.             $output .= get_theme_mod( 'jnews_show_block_meta_rating', true ) ? jnews_generate_rating( $post->ID, 'jeg_landing_review' ) : '';
  69.             $output .= '</div>';
  70.         } else {
  71.             $output .= '<div class="jeg_post_meta">';
  72.             $output .= $trending;
  73.  
  74.             $output .= '<div class="jeg_meta_custom"><a href="https://yourlink.com">LINK TEXT</a></div>'; /*  your custom meta here */
  75.  
  76.             $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> ' . $instance->format_date( $post ) . '</a></div>' : '';
  77.             $output .= get_theme_mod( 'jnews_show_block_meta_views', false ) ? '<div class="jeg_meta_views"><a href="' . get_the_permalink( $post->ID ) . "\" ><i class=\"fa fa-eye\"></i> {$view_count} </a></div>" : '';
  78.             $output .= '</div>';
  79.         }
  80.     }
  81.  
  82.     return $output;
  83. }
  84.  
  85.  
  86. function override_module_meta_1( $output, $post, $instance ) {
  87.     $output = '';
  88.     $avatar = false;
  89.     $feed   = false;
  90.     if ( get_theme_mod( 'jnews_show_block_meta', true ) ) {
  91.         $comment    = jnews_get_comments_number( $post->ID );
  92.         $view_count = jnews_meta_views( $post->ID );
  93.  
  94.         // author detail
  95.         $author        = isset( $post->post_author ) ? $post->post_author : 'rss_post';
  96.         $is_rss        = jnews_get_rss_post_id( $author );
  97.         $author_url    = $is_rss ? ( isset( $post->post_author_url ) ? $post->post_author_url : '' ) : get_author_posts_url( $author );
  98.         $author_name   = $is_rss ? $post->post_author_name : get_the_author_meta( 'display_name', $author );
  99.         $author_avatar = ( $is_rss ? false : $avatar ) ?
  100.         '<div class="jeg_author_avatar">
  101.                ' . get_avatar( get_the_author_meta( 'ID', $post->post_author ), 80, null, get_the_author_meta( 'display_name', $post->post_author ) ) . '
  102.            </div>' : '';
  103.  
  104.         $trending = ( jnews_get_metabox_value( 'jnews_single_post.trending_post', null, $post->ID ) ) ? '<div class="jeg_meta_trending"><a href="' . get_the_permalink( $post ) . '" aria-label="' . esc_html__( 'View this Trending Post', 'jnews' ) . '"><i class="fa fa-bolt"></i></a></div>' : '';
  105.  
  106.         if ( jnews_is_review( $post->ID ) ) {
  107.             $rating = jnews_generate_rating( $post->ID, 'jeg_landing_review' );
  108.  
  109.             $output .= '<div class="jeg_post_meta">';
  110.             $output .= $trending;
  111.             $output .= get_theme_mod( 'jnews_show_block_meta_rating', true ) ? $rating : '';
  112.             $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>" ) : '';
  113.             $output .= '</div>';
  114.         } else {
  115.             $output .= '<div class="jeg_post_meta">';
  116.             $output .= $trending;
  117.             $output .= get_theme_mod( 'jnews_show_block_meta_author', true ) && ! empty( $author_name ) ? ( 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>" ) : '';
  118.  
  119.             $output .= '<div class="jeg_meta_custom"><a href="https://yourlink.com">LINK TEXT</a></div>'; /*  your custom meta here */
  120.  
  121.             $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> ' . $instance->format_date( $post ) . '</a></div>' : '';
  122.             $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>" : '';
  123.             $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>" : '';
  124.             $output .= '</div>';
  125.         }
  126.     }
  127.  
  128.     return $output;
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement