| 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 |
$attr['metaAuthorPrefix'] = wp_kses( $attr['metaAuthorPrefix'], ultimate_post()->ultp_allowed_html_tags() ); |
| 18 |
$attr['metaSeparator'] = sanitize_html_class( $attr['metaSeparator'] ); |
| 19 |
$attr['metaStyle'] = sanitize_html_class( $attr['metaStyle'] ); |
| 20 |
$attr['className'] = isset( $attr['className'] ) ? sanitize_html_class( $attr['className'] ) : ''; |
| 21 |
|
| 22 |
|
| 23 |
$avatar = get_avatar_url( $user_id ); |
| 24 |
$meta = $metaCondition ? $attr['metaList'] : ( isset( $attr['metaListSmall'] ) ? $attr['metaListSmall'] : $attr['metaList'] ); |
| 25 |
$meta = json_decode( $meta ); |
| 26 |
$meta = is_array( $meta ) ? $meta : array(); |
| 27 |
|
| 28 |
$authorImgOnly = in_array( 'metaAuthor', $meta ) ? '<span class="ultp-block-author ultp-block-meta-element"><img loading="lazy" class="ultp-meta-author-img" src="' . $avatar . '" alt="' . __( 'By', 'ultimate-post' ) . '" /></span>' : ''; |
| 29 |
|
| 30 |
$authorImg = in_array( 'metaAuthor', $meta ) ? '<span class="ultp-block-author ultp-block-meta-element"><img loading="lazy" class="ultp-meta-author-img" src="' . $avatar . '" alt="' . __( 'By', 'ultimate-post' ) . '" />' . $attr['metaAuthorPrefix'] . '<a class="' . ( empty( $author_link ) ? 'ultp-meta-author-no-link' : '' ) . '" href="' . ( $attr['authorLink'] ? $author_link : 'javascript:void(0)' ) . '">' . $display_name . '</a></span>' : ''; |
| 31 |
|
| 32 |
$authorIcon = in_array( 'metaAuthor', $meta ) ? '<span class="ultp-block-author ultp-block-meta-element">' . ultimate_post()->get_svg_icon( 'user' ) . '<a class="' . ( empty( $author_link ) ? 'ultp-meta-author-no-link' : '' ) . '" href="' . ( $attr['authorLink'] ? $author_link : 'javascript:void(0)' ) . '">' . $display_name . '</a></span>' : ''; |
| 33 |
|
| 34 |
$authorBy = in_array( 'metaAuthor', $meta ) ? '<span class="ultp-block-author ultp-block-meta-element">' . $attr['metaAuthorPrefix'] . '<a class="' . ( empty( $author_link ) ? 'ultp-meta-author-no-link' : '' ) . '" href="' . ( $attr['authorLink'] ? $author_link : 'javascript:void(0)' ) . '">' . $display_name . '</a></span>' : ''; |
| 35 |
|
| 36 |
// Author Filter Hook |
| 37 |
$authorImgOnly = apply_filters( 'postx_loop_author_image_only', $authorImgOnly, $user_id, $post_id, isset( $attr['className'] ) ? $attr['className'] : '' ); |
| 38 |
$authorImg = apply_filters( 'postx_loop_author_image', $authorImg, $user_id, $post_id, isset( $attr['className'] ) ? $attr['className'] : '' ); |
| 39 |
$authorIcon = apply_filters( 'postx_loop_author_icon', $authorIcon, $user_id, $post_id, isset( $attr['className'] ) ? $attr['className'] : '' ); |
| 40 |
$authorBy = apply_filters( 'postx_loop_author_by', $authorBy, $user_id, $post_id, isset( $attr['className'] ) ? $attr['className'] : '' ); |
| 41 |
|
| 42 |
$date = in_array( 'metaDate', $meta ) ? '<span class="ultp-block-date ultp-block-meta-element">' . $time . '</span>' : ''; |
| 43 |
$dateIcon = in_array( 'metaDate', $meta ) ? '<span class="ultp-block-date ultp-block-meta-element">' . ultimate_post()->get_svg_icon( 'calendar' ) . $time . '</span>' : ''; |
| 44 |
$dateModified = in_array( 'metaDateModified', $meta ) ? '<span class="ultp-block-date ultp-block-meta-element">' . $timeModified . '</span>' : ''; |
| 45 |
$dateModifiedIcon = in_array( 'metaDateModified', $meta ) ? '<span class="ultp-block-date ultp-block-meta-element">' . ultimate_post()->get_svg_icon( 'calendar' ) . $timeModified . '</span>' : ''; |
| 46 |
$comments = in_array( 'metaComments', $meta ) ? '<span class="ultp-post-comment ultp-block-meta-element">' . $comment . esc_html__( ' comments', 'ultimate-post' ) . '</span>' : ''; |
| 47 |
$commentsIcon = in_array( 'metaComments', $meta ) ? '<span class="ultp-post-comment ultp-block-meta-element">' . ultimate_post()->get_svg_icon( 'comment' ) . $comment . '</span>' : ''; |
| 48 |
$views = in_array( 'metaView', $meta ) ? '<span class="ultp-post-view ultp-block-meta-element">' . $view . esc_html__( ' views', 'ultimate-post' ) . '</span>' : ''; |
| 49 |
$viewIcon = in_array( 'metaView', $meta ) ? '<span class="ultp-post-view ultp-block-meta-element">' . ultimate_post()->get_svg_icon( 'eye' ) . $view . '</span>' : ''; |
| 50 |
$postTime = in_array( 'metaTime', $meta ) ? '<span class="ultp-post-time ultp-block-meta-element">' . $post_time . esc_html__( ' ago', 'ultimate-post' ) . '</span>' : ''; |
| 51 |
$postTimeIcon = in_array( 'metaTime', $meta ) ? '<span class="ultp-post-time ultp-block-meta-element">' . ultimate_post()->get_svg_icon( 'clock' ) . $post_time . esc_html__( ' ago', 'ultimate-post' ) . '</span>' : ''; |
| 52 |
$reading = in_array( 'metaRead', $meta ) ? '<span class="ultp-post-read ultp-block-meta-element">' . $reading_time . '</span>' : ''; |
| 53 |
$readingIcon = in_array( 'metaRead', $meta ) ? '<span class="ultp-post-read ultp-block-meta-element">' . ultimate_post()->get_svg_icon( 'book' ) . $reading_time . '</span>' : ''; |
| 54 |
|
| 55 |
$post_loop .= '<div class="ultp-block-meta ultp-block-meta-' . $attr['metaSeparator'] . ' ultp-block-meta-' . $attr['metaStyle'] . '">'; |
| 56 |
if ( $attr['metaStyle'] == 'noIcon' ) { |
| 57 |
$post_loop .= $authorBy . $date . $dateModified . $comments . $views . $reading . $postTime; } |
| 58 |
if ( $attr['metaStyle'] == 'icon' ) { |
| 59 |
$post_loop .= $authorIcon . $dateIcon . $dateModifiedIcon . $commentsIcon . $viewIcon . $postTimeIcon . $readingIcon; } |
| 60 |
if ( $attr['metaStyle'] == 'style2' ) { |
| 61 |
$post_loop .= $authorBy . $dateIcon . $dateModifiedIcon . $commentsIcon . $viewIcon . $postTimeIcon . $readingIcon; } |
| 62 |
if ( $attr['metaStyle'] == 'style3' ) { |
| 63 |
$post_loop .= $authorImg . $dateIcon . $dateModifiedIcon . $commentsIcon . $viewIcon . $postTimeIcon . $readingIcon; } |
| 64 |
if ( $attr['metaStyle'] == 'style4' ) { |
| 65 |
$post_loop .= $authorIcon . $dateIcon . $dateModifiedIcon . $commentsIcon . $viewIcon . $postTimeIcon . $readingIcon; } |
| 66 |
if ( $attr['metaStyle'] == 'style5' ) { |
| 67 |
$post_loop .= '<div class="ultp-meta-media">' . $authorImgOnly . '</div> <div class="ultp-meta-body">' . $authorBy . $dateIcon . $dateModifiedIcon . $commentsIcon . $viewIcon . $postTimeIcon . $readingIcon . '</div>'; } |
| 68 |
if ( $attr['metaStyle'] == 'style6' ) { |
| 69 |
$post_loop .= $authorImgOnly . $authorBy . $dateIcon . $dateModifiedIcon . $commentsIcon . $viewIcon . $postTimeIcon . $readingIcon; } |
| 70 |
$post_loop .= '</div>'; |
| 71 |
} |
| 72 |
|