| 1 |
<?php |
| 2 |
defined('ABSPATH') || exit; |
| 3 |
|
| 4 |
if ($attr['metaShow']) { |
| 5 |
$metaCondition; |
| 6 |
switch ($block_name) { |
| 7 |
case 'post-grid-5': |
| 8 |
$metaCondition = $attr['layout'] == 'layout3' && $idx == 3 || $idx == 0; |
| 9 |
break; |
| 10 |
case 'post-grid-7': |
| 11 |
$metaCondition = $attr['layout'] == 'layout4' && $idx == 3 || $idx == 0; |
| 12 |
break; |
| 13 |
default: |
| 14 |
$metaCondition = $idx == 0; |
| 15 |
} |
| 16 |
|
| 17 |
$avatar = get_avatar_url($user_id); |
| 18 |
$meta = $metaCondition ? $attr['metaList'] : ( isset($attr['metaListSmall']) ? $attr['metaListSmall'] : $attr['metaList'] ); |
| 19 |
$meta = json_decode($meta); |
| 20 |
$meta = is_array($meta) ? $meta : []; |
| 21 |
|
| 22 |
$authorImgOnly = in_array('metaAuthor', $meta) ? '<span class="ultp-block-author"><img loading="lazy" class="ultp-meta-author-img" src="'.$avatar.'" alt="'.__("By","ultimate-post").'" /></span>' : ''; |
| 23 |
$authorImg = in_array('metaAuthor', $meta) ? '<span class="ultp-block-author"><img loading="lazy" class="ultp-meta-author-img" src="'.$avatar.'" alt="'.__("By","ultimate-post").'" />'.$attr['metaAuthorPrefix'].'<a href="'.($attr['authorLink']?$author_link:'javascript:void(0)').'">'.$display_name .'</a></span>' : ''; |
| 24 |
$authorIcon = in_array('metaAuthor', $meta) ? '<span class="ultp-block-author">'.ultimate_post()->svg_icon('user').'<a href="'.($attr['authorLink']?$author_link:'javascript:void(0)').'">'.$display_name.'</a></span>' : ''; |
| 25 |
$authorBy = in_array('metaAuthor', $meta) ? '<span class="ultp-block-author">'.$attr['metaAuthorPrefix'].'<a href="'.($attr['authorLink']?$author_link:'javascript:void(0)').'">'.$display_name.'</a></span>' : ''; |
| 26 |
|
| 27 |
// Author Filter Hook |
| 28 |
$authorImgOnly = apply_filters( 'postx_loop_author_image_only', $authorImgOnly, $user_id, $post_id, isset($attr["className"]) ? $attr["className"] : ''); |
| 29 |
$authorImg = apply_filters( 'postx_loop_author_image', $authorImg, $user_id, $post_id, isset($attr["className"]) ? $attr["className"] : ''); |
| 30 |
$authorIcon = apply_filters( 'postx_loop_author_icon', $authorIcon, $user_id, $post_id, isset($attr["className"]) ? $attr["className"] : ''); |
| 31 |
$authorBy = apply_filters( 'postx_loop_author_by', $authorBy, $user_id, $post_id, isset($attr["className"]) ? $attr["className"] : ''); |
| 32 |
|
| 33 |
$date = in_array('metaDate', $meta) ? '<span class="ultp-block-date">'.$time.'</span>' : ''; |
| 34 |
$dateIcon = in_array('metaDate', $meta) ? '<span class="ultp-block-date">'.ultimate_post()->svg_icon('calendar').$time.'</span>' : ''; |
| 35 |
$dateModified = in_array('metaDateModified', $meta) ? '<span class="ultp-block-date">'.$timeModified.'</span>' : ''; |
| 36 |
$dateModifiedIcon = in_array('metaDateModified', $meta) ? '<span class="ultp-block-date">'.ultimate_post()->svg_icon('calendar').$timeModified.'</span>' : ''; |
| 37 |
$comments = in_array('metaComments', $meta) ? '<span class="ultp-post-comment">'.$comment.esc_html__(" comments", "ultimate-post").'</span>' : ''; |
| 38 |
$commentsIcon = in_array('metaComments', $meta) ? '<span class="ultp-post-comment">'.ultimate_post()->svg_icon('comment').$comment.'</span>' : ''; |
| 39 |
$views = in_array('metaView', $meta) ? '<span class="ultp-post-view">'.$view.esc_html__(" views", "ultimate-post").'</span>' : ''; |
| 40 |
$viewIcon = in_array('metaView', $meta) ? '<span class="ultp-post-view">'.ultimate_post()->svg_icon('eye').$view.'</span>' : ''; |
| 41 |
$postTime = in_array('metaTime', $meta) ? '<span class="ultp-post-time">'.$post_time.esc_html__(" ago", "ultimate-post").'</span>' : ''; |
| 42 |
$postTimeIcon = in_array('metaTime', $meta) ? '<span class="ultp-post-time">'.ultimate_post()->svg_icon('clock').$post_time.esc_html__(" ago", "ultimate-post").'</span>' : ''; |
| 43 |
$reading = in_array('metaRead', $meta) ? '<span class="ultp-post-read">'.$reading_time.'</span>' : ''; |
| 44 |
$readingIcon = in_array('metaRead', $meta) ? '<span class="ultp-post-read">'.ultimate_post()->svg_icon('book').$reading_time.'</span>' : ''; |
| 45 |
|
| 46 |
$post_loop .= '<div class="ultp-block-meta ultp-block-meta-'.$attr['metaSeparator'].' ultp-block-meta-'.$attr['metaStyle'].'">'; |
| 47 |
if ($attr['metaStyle'] == 'noIcon') { $post_loop .= $authorBy.$date.$dateModified.$comments.$views.$reading.$postTime; } |
| 48 |
if ($attr['metaStyle'] == 'icon') { $post_loop .= $authorIcon.$dateIcon.$dateModifiedIcon.$commentsIcon.$viewIcon.$postTimeIcon.$readingIcon; } |
| 49 |
if ($attr['metaStyle'] == 'style2') { $post_loop .= $authorBy.$dateIcon.$dateModifiedIcon.$commentsIcon.$viewIcon.$postTimeIcon.$readingIcon; } |
| 50 |
if ($attr['metaStyle'] == 'style3') { $post_loop .= $authorImg.$dateIcon.$dateModifiedIcon.$commentsIcon.$viewIcon.$postTimeIcon.$readingIcon; } |
| 51 |
if ($attr['metaStyle'] == 'style4') { $post_loop .= $authorIcon.$dateIcon.$dateModifiedIcon.$commentsIcon.$viewIcon.$postTimeIcon.$readingIcon; } |
| 52 |
if ($attr['metaStyle'] == 'style5') { $post_loop .= '<div class="ultp-meta-media">'.$authorImgOnly.'</div> <div class="ultp-meta-body">'.$authorBy.$dateIcon.$dateModifiedIcon.$commentsIcon.$viewIcon.$postTimeIcon.$readingIcon.'</div>'; } |
| 53 |
if ($attr['metaStyle'] == 'style6') { $post_loop .= $authorImgOnly.$authorBy.$dateIcon.$dateModifiedIcon.$commentsIcon.$viewIcon.$postTimeIcon.$readingIcon; } |
| 54 |
$post_loop .= '</div>'; |
| 55 |
} |