PluginProbe
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites / trunk
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites vtrunk
4.1.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.1.2 2.5.0 2.5.3 2.6.1 All 38 releases
blockspare / inc / block-posts-config / latest-post-tile-common.php

latest-post-tile-common.php in BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites trunk, at inc/block-posts-config/latest-post-tile-common.php

172 lines 7.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!function_exists('blockspare_post_tile_img')) {
3 function blockspare_post_tile_img($post_id, $category_class, $attributes, $post_thumb_id, $post_thumb_size)
4 { ?>
5 <figure class="blockspare-posts-block-post-img">
6 <a href="<?php echo esc_url(get_permalink($post_id)); ?>" aria-label="<?php echo esc_attr(get_the_title($post_id)); ?>">
7 <?php
8 if (has_post_thumbnail($post_id)) {
9 echo wp_kses_post(wp_get_attachment_image($post_thumb_id, $post_thumb_size, '', ["class" => 'hover-child']));
10 } else { ?>
11 <div class="bs-no-thumbnail-img"> </div><?php
12 } ?>
13 </a>
14 <?php if ($attributes['displayPostCategory'] == 'true' && ($attributes['contentOrder'] == 'content-order-2')) { ?>
15 <div class="<?php echo esc_attr($category_class); ?>">
16 <?php $categories_list = get_the_category_list(' ', '', $post_id);
17 if ($categories_list) {
18 printf(esc_html__('%1$s', "blockspare"), $categories_list); // WPCS: XSS OK.
19 }
20 if ($attributes['postType'] != 'post') {
21 $terms = get_the_terms($post_id, $attributes['taxType']);
22 if ($terms) {
23 foreach ($terms as $trem) { ?>
24 <a herf=><?php echo $trem->name; ?></a><?php
25 }
26 }
27 } ?>
28 </div><?php
29 } ?>
30 </figure>
31 <?php }
32 }
33
34 if (!function_exists('blockspare_post_tile_content')) {
35 function blockspare_post_tile_content($attributes, $post_id, $category_class, $className = '')
36 { ?>
37 <div class="blockspare-posts-block-post-content <?php echo esc_attr($className); ?> <?php echo esc_attr($attributes['contentOrder']); ?> <?php echo esc_attr($attributes['titleOnHover']) ?>">
38 <div class="blockspare-posts-block-bg-overlay"></div>
39 <header class="blockspare-posts-block-post-grid-header">
40 <?php
41 if ($attributes['displayPostCategory'] == 'true' && ($attributes['contentOrder'] != 'content-order-2')) { ?>
42 <div class="<?php echo esc_attr($category_class); ?>">
43 <?php
44 $categories_list = get_the_category_list(' ', '', $post_id);
45 if ($categories_list) {
46 printf(esc_html__('%1$s', "blockspare"), $categories_list); // WPCS: XSS OK.
47 }
48 if ($attributes['postType'] != 'post') {
49 $terms = get_the_terms($post_id, $attributes['taxType']);
50 if ($terms) {
51 foreach ($terms as $trem) { ?>
52 <a herf=><?php echo $trem->name; ?></a>
53 <?php }
54 }
55 }
56 ?>
57 </div><?php
58 }
59
60 $title = get_the_title($post_id);
61 if (isset($attributes['displayPostTitle']) && $attributes['displayPostTitle'] == 'true') { ?>
62 <h2 class="blockspare-posts-block-post-grid-title">
63 <a href="<?php echo esc_url(get_permalink($post_id)); ?>" class="blockspare-posts-block-title-link"
64 rel="bookmark">
65 <span><?php echo get_the_title(); ?></span>
66 </a>
67 </h2>
68 <?php
69 }
70 if (isset($attributes['postType']) && (isset($attributes['displayPostAuthor']) || isset($attributes['displayPostDate']))) { ?>
71 <div class="blockspare-posts-block-post-grid-byline">
72 <?php
73 if (isset($attributes['displayPostAuthor']) && $attributes['displayPostAuthor'] == 'true') { ?>
74 <div class="blockspare-posts-block-post-grid-author">
75 <!-- <a class="blockspare-posts-block-text-link"
76 href="<?php echo esc_url(get_author_posts_url(get_the_author_meta('ID'))); ?>"
77 itemprop="url" rel="author">
78 <span itemprop="name"><i
79 class="<?php echo esc_attr($attributes['authorIcon']); ?>"></i><?php echo esc_html(get_the_author_meta('display_name', get_the_author_meta('ID'))); ?></span>
80 </a> -->
81 <?php
82 $author_id = get_post_field('post_author', $post_id);
83 $blockspare_get_multiauthor = new BlocksapreMultiAuthorForFrontend();
84 $blockspare_get_multiauthor->blockspare_front_by_author($post_id, $attributes['authorIcon'], $author_id); ?>
85 </div>
86 <?php
87 }
88
89 if (isset($attributes['displayPostDate']) && $attributes['displayPostDate'] == 'true') { ?>
90 <time datetime="<?php echo esc_attr(get_the_date('c', $post_id)); ?>" class="blockspare-posts-block-post-grid-date" itemprop="datePublished"><i class="<?php echo esc_attr($attributes['dateIcon']); ?>" aria-hidden="true"></i><?php echo esc_html(get_the_date('', $post_id)); ?></time>
91 <?php
92 }
93 if ($attributes['enableComment'] == 'true') { ?>
94 <span class="comment_count"><i class='<?php echo esc_attr($attributes['commentIcon']); ?>' aria-hidden="true"></i><?php echo esc_html(get_comments_number($post_id)); ?></span>
95 <?php
96 } ?>
97 </div>
98
99 <?php } ?>
100
101 </header>
102
103 <?php
104 /* Get the excerpt */
105 $excerpt = blockspare_post_excerpt($attributes, $post_id);
106 if ($attributes['displayPostExcerpt'] == 'true' && $excerpt != null) { ?>
107 <div class="blockspare-posts-block-post-grid-excerpt">
108 <?php
109 if (isset($attributes['displayPostExcerpt']) && $attributes['displayPostExcerpt'] == 'true') { ?>
110 <div class="blockspare-posts-block-post-grid-excerpt-content"><?php echo wp_kses_post($excerpt); ?></div>
111 <?php
112 } ?>
113
114
115 <?php if (isset($attributes['displayPostLink']) && $attributes['displayPostLink'] == 'true') { ?>
116 <p>
117 <a
118 class="blockspare-posts-block-post-grid-more-link blockspare-posts-block-text-link"
119 href="<?php echo esc_url(get_permalink($post_id)); ?>"
120 aria-label="<?php echo sprintf(esc_attr__('Read more about %s', 'blockspare'), esc_html(get_the_title($post_id))); ?>">
121 <span aria-hidden="true"><?php echo esc_html($attributes['readMoreText']); ?></span>
122 </a>
123
124 </p>
125 <?php
126 } ?>
127 </div>
128 <?php } ?>
129
130 </div>
131 </div>
132 <?php
133 }
134 }
135
136
137 if (!function_exists('blockspare_post_excerpt')) {
138 function blockspare_post_excerpt($attributes, $post_id)
139 {
140 /* Get the excerpt */
141 $excerpt = get_post_field(
142 'post_excerpt',
143 $post_id,
144 'display'
145 );
146
147 if (empty($excerpt)) {
148 $excerpt = preg_replace(
149 array(
150 '/\<figcaption>.*\<\/figcaption>/',
151 '/\[caption.*\[\/caption\]/',
152 ),
153 '',
154 get_the_content()
155 );
156 }
157
158 // Trim the excerpt if necessary.
159 if (isset($attributes['excerptLength'])) {
160 $excerpt = wp_trim_words(
161 $excerpt,
162 $attributes['excerptLength']
163 );
164 }
165
166 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- This is a WP core filter.
167 $excerpt = apply_filters('the_excerpt', $excerpt);
168
169 return $excerpt;
170 }
171 }
172