PluginProbe
Post Grid Gutenberg Blocks – PostX / 5.1.0
Post Grid Gutenberg Blocks – PostX v5.1.0
5.1.1 5.1.0 5.0.41 5.0.39 5.0.38 5.0.37 5.0.36 5.0.35 5.0.34 5.0.33 5.0.32 5.0.31 5.0.30 5.0.29 5.0.28 5.0.27 5.0.26 5.0.25 5.0.23 5.0.24 5.0.22 5.0.21 5.0.20 5.0.19 5.0.18 All 240 releases
ultimate-post / blocks / template / meta.php

meta.php in Post Grid Gutenberg Blocks – PostX 5.1.0, at blocks/template/meta.php

73 lines 6.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 defined( 'ABSPATH' ) || exit;
3 // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Included inside block render methods; variables are local.
4
5 if ( $attr['metaShow'] ) {
6 $metaCondition;
7 switch ( $block_name ) {
8 case 'post-grid-5':
9 $metaCondition = $attr['layout'] == 'layout3' && $idx == 3 || $idx == 0;
10 break;
11 case 'post-grid-7':
12 $metaCondition = $attr['layout'] == 'layout4' && $idx == 3 || $idx == 0;
13 break;
14 default:
15 $metaCondition = $idx == 0;
16 }
17
18 $attr['metaAuthorPrefix'] = wp_kses( $attr['metaAuthorPrefix'], ultimate_post()->ultp_allowed_html_tags() );
19 $attr['metaSeparator'] = sanitize_html_class( $attr['metaSeparator'] );
20 $attr['metaStyle'] = sanitize_html_class( $attr['metaStyle'] );
21 $attr['className'] = isset( $attr['className'] ) ? sanitize_html_class( $attr['className'] ) : '';
22
23
24 $avatar = get_avatar_url( $user_id );
25 $meta = $metaCondition ? $attr['metaList'] : ( isset( $attr['metaListSmall'] ) ? $attr['metaListSmall'] : $attr['metaList'] );
26 $meta = json_decode( $meta );
27 $meta = is_array( $meta ) ? $meta : array();
28
29 $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>' : '';
30
31 $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>' : '';
32
33 $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>' : '';
34
35 $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>' : '';
36
37 // Author Filter Hook
38 $authorImgOnly = apply_filters( 'postx_loop_author_image_only', $authorImgOnly, $user_id, $post_id, isset( $attr['className'] ) ? $attr['className'] : '' );
39 $authorImg = apply_filters( 'postx_loop_author_image', $authorImg, $user_id, $post_id, isset( $attr['className'] ) ? $attr['className'] : '' );
40 $authorIcon = apply_filters( 'postx_loop_author_icon', $authorIcon, $user_id, $post_id, isset( $attr['className'] ) ? $attr['className'] : '' );
41 $authorBy = apply_filters( 'postx_loop_author_by', $authorBy, $user_id, $post_id, isset( $attr['className'] ) ? $attr['className'] : '' );
42
43 $date = in_array( 'metaDate', $meta ) ? '<span class="ultp-block-date ultp-block-meta-element">' . $time . '</span>' : '';
44 $dateIcon = in_array( 'metaDate', $meta ) ? '<span class="ultp-block-date ultp-block-meta-element">' . ultimate_post()->get_svg_icon( 'calendar' ) . $time . '</span>' : '';
45 $dateModified = in_array( 'metaDateModified', $meta ) ? '<span class="ultp-block-date ultp-block-meta-element">' . $timeModified . '</span>' : '';
46 $dateModifiedIcon = in_array( 'metaDateModified', $meta ) ? '<span class="ultp-block-date ultp-block-meta-element">' . ultimate_post()->get_svg_icon( 'calendar' ) . $timeModified . '</span>' : '';
47 $comments = in_array( 'metaComments', $meta ) ? '<span class="ultp-post-comment ultp-block-meta-element">' . $comment . esc_html__( ' comments', 'ultimate-post' ) . '</span>' : '';
48 $commentsIcon = in_array( 'metaComments', $meta ) ? '<span class="ultp-post-comment ultp-block-meta-element">' . ultimate_post()->get_svg_icon( 'comment' ) . $comment . '</span>' : '';
49 $views = in_array( 'metaView', $meta ) ? '<span class="ultp-post-view ultp-block-meta-element">' . $view . esc_html__( ' views', 'ultimate-post' ) . '</span>' : '';
50 $viewIcon = in_array( 'metaView', $meta ) ? '<span class="ultp-post-view ultp-block-meta-element">' . ultimate_post()->get_svg_icon( 'eye' ) . $view . '</span>' : '';
51 $postTime = in_array( 'metaTime', $meta ) ? '<span class="ultp-post-time ultp-block-meta-element">' . $post_time . esc_html__( ' ago', 'ultimate-post' ) . '</span>' : '';
52 $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>' : '';
53 $reading = in_array( 'metaRead', $meta ) ? '<span class="ultp-post-read ultp-block-meta-element">' . $reading_time . '</span>' : '';
54 $readingIcon = in_array( 'metaRead', $meta ) ? '<span class="ultp-post-read ultp-block-meta-element">' . ultimate_post()->get_svg_icon( 'book' ) . $reading_time . '</span>' : '';
55
56 $post_loop .= '<div class="ultp-block-meta ultp-block-meta-' . $attr['metaSeparator'] . ' ultp-block-meta-' . $attr['metaStyle'] . '">';
57 if ( $attr['metaStyle'] == 'noIcon' ) {
58 $post_loop .= $authorBy . $date . $dateModified . $comments . $views . $reading . $postTime; }
59 if ( $attr['metaStyle'] == 'icon' ) {
60 $post_loop .= $authorIcon . $dateIcon . $dateModifiedIcon . $commentsIcon . $viewIcon . $postTimeIcon . $readingIcon; }
61 if ( $attr['metaStyle'] == 'style2' ) {
62 $post_loop .= $authorBy . $dateIcon . $dateModifiedIcon . $commentsIcon . $viewIcon . $postTimeIcon . $readingIcon; }
63 if ( $attr['metaStyle'] == 'style3' ) {
64 $post_loop .= $authorImg . $dateIcon . $dateModifiedIcon . $commentsIcon . $viewIcon . $postTimeIcon . $readingIcon; }
65 if ( $attr['metaStyle'] == 'style4' ) {
66 $post_loop .= $authorIcon . $dateIcon . $dateModifiedIcon . $commentsIcon . $viewIcon . $postTimeIcon . $readingIcon; }
67 if ( $attr['metaStyle'] == 'style5' ) {
68 $post_loop .= '<div class="ultp-meta-media">' . $authorImgOnly . '</div> <div class="ultp-meta-body">' . $authorBy . $dateIcon . $dateModifiedIcon . $commentsIcon . $viewIcon . $postTimeIcon . $readingIcon . '</div>'; }
69 if ( $attr['metaStyle'] == 'style6' ) {
70 $post_loop .= $authorImgOnly . $authorBy . $dateIcon . $dateModifiedIcon . $commentsIcon . $viewIcon . $postTimeIcon . $readingIcon; }
71 $post_loop .= '</div>';
72 }
73