Diff: STRATO-apps/wordpress_03/app/wp-content/themes/blocksy/inc/components/single/single-helpers.php

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + <?php
2 +
3 + function blocksy_get_avatar_url($args = []) {
4 + $args = wp_parse_args($args, [
5 + 'size' => 96,
6 +
7 + // User ID | WP_Comment | WP_Post
8 + 'avatar_entity' => '__default__'
9 + ]);
10 +
11 + if ($args['avatar_entity'] === '__default__') {
12 + $args['avatar_entity'] = blocksy_get_author_id();
13 + }
14 +
15 + $user_id = $args['avatar_entity'];
16 + $avatar_id = null;
17 +
18 + // user registration plugin
19 + if (function_exists('ur_replace_gravatar_image')) {
20 +
21 + if ($args['avatar_entity'] instanceof WP_Comment) {
22 + $user_id = $args['avatar_entity']->user_id;
23 + }
24 +
25 + $avatar_id = get_user_meta(
26 + $user_id,
27 + 'user_registration_profile_pic_url',
28 + true
29 + );
30 + }
31 +
32 + if (class_exists('\YITH_WCMAP_Avatar')) {
33 + $yith_custom_avatar = new \YITH_WCMAP_Avatar();
34 + $avatar_id = $yith_custom_avatar->get_user_avatar_id($user_id);
35 + }
36 +
37 + if (class_exists('\FrmRegAvatar')) {
38 + $avatar_id = get_user_meta($user_id, 'frm_avatar_id', true);
39 + }
40 +
41 + if ($avatar_id) {
42 + return wp_get_attachment_url($avatar_id);
43 + }
44 +
45 + return get_avatar_url(
46 + $args['avatar_entity'],
47 + [
48 + 'size' => $args['size']
49 + ]
50 + );
51 + }
52 +
53 + if (! function_exists('blocksy_get_author_id')) {
54 + function blocksy_get_author_id() {
55 + $author_id = get_queried_object_id();
56 +
57 + if (is_singular()) {
58 + $author_id = get_the_author_meta('ID');
59 + }
60 +
61 + if (! $author_id) {
62 + $author = get_user_by('slug', get_query_var('author_name'));
63 +
64 + if ($author) {
65 + $author_id = $author->ID;
66 + }
67 + }
68 +
69 + return $author_id;
70 + }
71 + }
72 +
73 + function blocksy_get_the_author_meta($field, $user_id = false) {
74 + if (! $user_id) {
75 + $user_id = blocksy_get_author_id();
76 + }
77 +
78 + $maybe_meta = apply_filters(
79 + 'blocksy:author:get_the_author_meta',
80 + null,
81 + $field,
82 + $user_id
83 + );
84 +
85 + if ($maybe_meta !== null) {
86 + return $maybe_meta;
87 + }
88 +
89 + return get_the_author_meta($field, $user_id);
90 + }
91 +
92 + function blocksy_get_comment_author_link($args = []) {
93 + $args = wp_parse_args($args, [
94 + 'comment_id' => 0,
95 + 'attr' => []
96 + ]);
97 +
98 + $link = get_comment_author_link($args['comment_id']);
99 +
100 + if (strpos($link, 'href="') !== false) {
101 + $reader = new \WP_HTML_Tag_Processor($link);
102 +
103 + if (
104 + $reader->next_tag([
105 + 'tag_name' => 'a'
106 + ])
107 + ) {
108 + foreach ($args['attr'] as $attr_name => $attr_value) {
109 + $reader->set_attribute($attr_name, $attr_value);
110 + }
111 +
112 + $link = $reader->get_updated_html();
113 + }
114 + }
115 +
116 + return $link;
117 + }
118 +
119 + function blocksy_count_user_posts() {
120 + $author_id = blocksy_get_author_id();
121 +
122 + $maybe_count = apply_filters('blocksy:author:count_user_posts', null, $author_id);
123 +
124 + if ($maybe_count !== null) {
125 + return $maybe_count;
126 + }
127 +
128 + if (! get_userdata($author_id)) {
129 + return 0;
130 + }
131 +
132 + return count_user_posts(
133 + $author_id,
134 + array_merge(
135 + ['post'],
136 + blocksy_manager()->post_types->get_supported_post_types()
137 + )
138 + );
139 + }
140 +
141 + if (! function_exists('blocksy_post_uses_vc')) {
142 + function blocksy_post_uses_vc() {
143 + $post = get_post();
144 + return $post && preg_match('/vc_row/', $post->post_content);
145 + }
146 + }
147 +
148 + if (! function_exists('blocksy_get_content_style_default')) {
149 + function blocksy_get_content_style_default($prefix = null) {
150 + if (! $prefix) {
151 + $prefix = blocksy_manager()->screen->get_prefix();
152 + }
153 +
154 + $default_style = 'wide';
155 +
156 + if (
157 + $prefix === 'bbpress_single'
158 + ||
159 + (
160 + $prefix === 'courses_single'
161 + &&
162 + function_exists('tutor')
163 + )
164 + ) {
165 + $default_style = 'boxed';
166 + }
167 +
168 + return $default_style;
169 + }
170 + }
171 +
172 + /**
173 + * User social channels
174 + *
175 + * @param string $tooltip Should output tooltips.
176 + */
177 + if (! function_exists('blocksy_author_social_channels')) {
178 + function blocksy_author_social_channels($args = []) {
179 + $args = wp_parse_args(
180 + $args,
181 + [
182 + 'new_tab' => true,
183 + 'nofollow' => false
184 + ]
185 + );
186 +
187 + $meta_ids = [
188 + 'facebook',
189 + 'linkedin',
190 + 'dribbble',
191 + 'user_url',
192 + 'twitter',
193 + 'instagram',
194 + 'pinterest',
195 + 'wordpress',
196 + 'github',
197 + 'medium',
198 + 'youtube',
199 + 'vimeo',
200 + 'vkontakte',
201 + 'odnoklassniki',
202 + 'tiktok',
203 + 'mastodon'
204 + ];
205 +
206 + $outputs = [];
207 +
208 + $descriptor = [
209 + 'facebook' => [
210 + 'label' => 'Facebook icon',
211 + 'icon' => '<svg class="ct-icon" width="12" height="12" viewBox="0 0 20 20"><path d="M15.2 7.2h-3.9V4.8c0-.7.5-1.2 1.2-1.2H15V0h-3C9.3 0 7.2 2.2 7.2 4.8v2.4H4.8v3.6h2.4V20h4.3v-9.2h3l.7-3.6z"/></svg>'
212 + ],
213 + 'linkedin' => [
214 + 'label' => 'LinkedIn icon',
215 + 'icon' => '<svg class="ct-icon" width="12" height="12" viewBox="0 0 20 20"><path d="M.1 5.8h4.2V20H.1V5.8zm18.4 1.8c-.8-1-2-1.4-3.5-1.4-1.9 0-3.2 1-4.2 2.4h-.1l-.2-2.8H7.2c.1 1.4 0 14.2 0 14.2h4.3v-8.9c.3-1.1 1.1-1.7 2.2-1.7 1.4 0 2.1 1 2.1 3V20h4.1v-8.1c-.1-1.9-.5-3.3-1.4-4.3zM2.2 0C1 0 0 1 0 2.2c0 1.2 1 2.2 2.2 2.2 1.2 0 2.2-1 2.2-2.2C4.3 1 3.4 0 2.2 0z"/></svg>'
216 + ],
217 + 'dribbble' => [
218 + 'label' => 'Dribbble icon',
219 + 'icon' => '<svg class="ct-icon" width="12" height="12" viewBox="0 0 20 20"><path d="M10 0C4.5 0 0 4.5 0 10s4.5 10 10 10 10-4.5 10-10S15.5 0 10 0m6.1 5.2c1 1.2 1.6 2.8 1.7 4.4-1.1-.2-2.2-.4-3.2-.4-.8 0-1.6.1-2.3.2-.2-.4-.3-.8-.5-1.2 1.6-.6 3.1-1.6 4.3-3m-6.1-3c1.8 0 3.5.6 4.9 1.7-1 1.2-2.4 2.1-3.8 2.7-1-2-2-3.4-2.7-4.3.5 0 1-.1 1.6-.1M6.6 3c.5.6 1.6 2 2.8 4.2-2.4.8-4.8.9-6.2.9h-.7C3 5.9 4.5 4 6.6 3m-4.4 7v-.1h.9c1.6 0 4.3-.1 7.1-1 .2.3.3.7.4 1-1.9.6-3.3 1.6-4.4 2.6-1 .9-1.7 1.9-2.2 2.5-1.1-1.3-1.8-3.1-1.8-5m7.8 7.8c-1.7 0-3.3-.6-4.6-1.5.3-.5.9-1.3 1.8-2.2 1-.9 2.3-1.9 4.1-2.5.6 1.7 1.1 3.6 1.5 5.7-.9.3-1.8.5-2.8.5m4.4-1.4c-.4-1.9-.9-3.7-1.4-5.2.5-.1 1-.1 1.6-.1.9 0 2 .1 3.1.4-.4 2-1.6 3.8-3.3 4.9"/></svg>'
220 + ],
221 + 'user_url' => [
222 + 'label' => 'Website icon',
223 + 'icon' => '<svg class="ct-icon" width="12" height="12" viewBox="0 0 20 20"><path d="M10 0C4.5 0 0 4.5 0 10s4.5 10 10 10 10-4.5 10-10S15.5 0 10 0zm6.9 6H14c-.4-1.8-1.4-3.6-1.4-3.6s2.8.8 4.3 3.6zM10 2s1.2 1.7 1.9 4H8.1C8.8 3.6 10 2 10 2zM2.2 12s-.6-1.8 0-4h3.4c-.3 1.8 0 4 0 4H2.2zm.9 2H6c.6 2.3 1.4 3.6 1.4 3.6C4.3 16.5 3.1 14 3.1 14zM6 6H3.1c1.6-2.8 4.3-3.6 4.3-3.6S6.4 4.2 6 6zm4 12s-1.3-1.9-1.9-4h3.8c-.6 2.1-1.9 4-1.9 4zm2.3-6H7.7s-.3-2 0-4h4.7c.3 1.8-.1 4-.1 4zm.3 5.6s1-1.8 1.4-3.6h2.9c-1.6 2.7-4.3 3.6-4.3 3.6zm1.7-5.6s.3-2.1 0-4h3.4c.6 2.2 0 4 0 4h-3.4z"/></svg>'
224 + ],
225 + 'twitter' => [
226 + 'label' => 'X (Twitter) icon',
227 + 'icon' => '<svg class="ct-icon" width="12" height="12" viewBox="0 0 20 20"><path d="M2.9 0C1.3 0 0 1.3 0 2.9v14.3C0 18.7 1.3 20 2.9 20h14.3c1.6 0 2.9-1.3 2.9-2.9V2.9C20 1.3 18.7 0 17.1 0H2.9zm13.2 3.8L11.5 9l5.5 7.2h-4.3l-3.3-4.4-3.8 4.4H3.4l5-5.7-5.3-6.7h4.4l3 4 3.5-4h2.1zM14.4 15 6.8 5H5.6l7.7 10h1.1z"/></svg>'
228 + ],
229 + 'instagram' => [
230 + 'label' => 'Instagram icon',
231 + 'icon' => '<svg class="ct-icon" width="12" height="12" viewBox="0 0 20 20"><path d="M13.3 10c0 1.8-1.5 3.3-3.3 3.3S6.7 11.8 6.7 10 8.2 6.7 10 6.7s3.3 1.5 3.3 3.3zm6.6-4.2v8.4c0 3.2-2.6 5.8-5.8 5.8H5.8C2.6 20 0 17.4 0 14.1V5.8C0 2.6 2.6 0 5.8 0h8.4c3.2 0 5.8 2.6 5.7 5.8zM15 10c0-2.8-2.2-5-5-5s-5 2.2-5 5 2.2 5 5 5 5-2.2 5-5zm1.6-5.8c0-.4-.4-.8-.8-.8s-.8.4-.8.8.4.8.8.8c.5 0 .8-.4.8-.8z"/></svg>'
232 + ],
233 + 'pinterest' => [
234 + 'label' => 'Pinterest icon',
235 + 'icon' => '<svg class="ct-icon" width="12" height="12" viewBox="0 0 20 20"><path d="M10 0C4.5 0 0 4.5 0 10c0 4.1 2.5 7.6 6 9.2 0-.7 0-1.5.2-2.3s1.3-5.4 1.3-5.4-.3-.6-.3-1.6c0-1.5.9-2.6 1.9-2.6.9 0 1.3.7 1.3 1.5 0 .9-.6 2.3-.9 3.5-.3 1.1.5 1.9 1.6 1.9 1.9 0 3.2-2.4 3.2-5.3 0-2.2-1.5-3.8-4.2-3.8-3 0-4.9 2.3-4.9 4.8 0 .9.3 1.5.7 2 .1.1.2.2.1.5 0 .2-.2.6-.2.8-.1.3-.3.3-.5.3-1.4-.6-2-2.1-2-3.8 0-2.8 2.4-6.2 7.1-6.2 3.8 0 6.3 2.8 6.3 5.7 0 3.9-2.2 6.9-5.4 6.9-1.1 0-2.1-.6-2.4-1.2 0 0-.6 2.3-.7 2.7-.2.8-.6 1.5-1 2.1.9.2 1.8.3 2.8.3 5.5 0 10-4.5 10-10S15.5 0 10 0z"/></svg>'
236 + ],
237 + 'wordpress' => [
238 + 'label' => 'WordPress icon',
239 + 'icon' => '<svg class="ct-icon" width="12" height="12" viewBox="0 0 20 20"><path d="M1.9 4.1C3.7 1.6 6.7 0 10 0c2.4 0 4.6.9 6.3 2.3-.7.2-1.2 1-1.2 1.7 0 .9.5 1.6 1 2.4.5.7.9 1.6.9 2.9 0 .9-.3 2-.8 3.4l-1 3.5-3.8-11.3c.6 0 1.2-.1 1.2-.1.6 0 .5-.8 0-.8 0 0-1.7.1-2.8.1-1 0-2.7-.1-2.7-.1-.6 0-.7.8-.1.8 0 0 .5.1 1.1.1l1.6 4.4-2.3 6.8L3.7 4.9c.6 0 1.2-.1 1.2-.1.5 0 .4-.8-.1-.8 0 0-1.7.1-2.9.1.1 0 .1 0 0 0zM.8 6.2C.3 7.4 0 8.6 0 10c0 3.9 2.2 7.2 5.4 8.9L.8 6.2zm9.4 4.5l-3 8.9c.9.3 1.8.4 2.8.4 1.2 0 2.3-.2 3.4-.6l-3.2-8.7zm9-4.6c0 1-.2 2.2-.8 3.6l-3 8.8c2.8-1.8 4.6-4.9 4.6-8.4 0-1.5-.3-2.8-.8-4z"/></svg>'
240 + ],
241 + 'github' => [
242 + 'label' => 'GitHub icon',
243 + 'icon' => '<svg class="ct-icon" width="12" height="12" viewBox="0 0 20 20"><path d="M8.9.4C4.3.9.6 4.6.1 9.1c-.5 4.7 2.2 8.9 6.3 10.5.3.1.6-.1.6-.5v-1.6s-.4.1-.9.1c-1.4 0-2-1.2-2.1-1.9-.1-.4-.3-.7-.6-1-.3-.1-.4-.1-.4-.2 0-.2.3-.2.4-.2.6 0 1.1.7 1.3 1 .5.8 1.1 1 1.4 1 .4 0 .7-.1.9-.2.1-.7.4-1.4 1-1.8-2.3-.5-4-1.8-4-4 0-1.1.5-2.2 1.2-3-.1-.2-.2-.7-.2-1.4 0-.4 0-1 .3-1.6 0 0 1.4 0 2.8 1.3.5-.2 1.2-.3 1.9-.3s1.4.1 2 .3c1.3-1.3 2.8-1.3 2.8-1.3.2.6.2 1.2.2 1.6 0 .8-.1 1.2-.2 1.4.7.8 1.2 1.8 1.2 3 0 2.2-1.7 3.5-4 4 .6.5 1 1.4 1 2.3v2.6c0 .3.3.6.7.5 3.7-1.5 6.3-5.1 6.3-9.3 0-6-5.1-10.7-11.1-10z"/></svg>'
244 + ],
245 + 'medium' => [
246 + 'label' => 'Medium icon',
247 + 'icon' => '<svg class="ct-icon" width="12" height="12" viewBox="0 0 20 20"><path d="M2.4 5.3c0-.2-.1-.5-.3-.7L.3 2.4v-.3H6l4.5 9.8 3.9-9.8H20v.3l-1.6 1.5c-.1.1-.2.3-.2.4v11.2c0 .2 0 .3.2.4l1.6 1.5v.3h-7.8v-.3l1.6-1.6c.2-.2.2-.2.2-.4V6.5L9.4 17.9h-.6L3.6 6.5v7.6c0 .3.1.6.3.9L6 17.6v.3H0v-.3L2.1 15c.2-.2.3-.6.3-.9V5.3z"/></svg>'
248 + ],
249 + 'youtube' => [
250 + 'label' => 'YouTube icon',
251 + 'icon' => '<svg class="ct-icon" width="12" height="12" viewBox="0 0 20 20"><path d="M18.9 11.9L4.7 19.8c-.2.2-.6.2-1 .2-1 0-2.1-.8-2.1-2.1V2.1C1.6 1 2.4 0 3.7 0c.4 0 .6 0 1 .2l14.2 7.9c1 .6 1.5 1.7.8 2.7-.2.5-.6.9-.8 1.1z"/></svg>'
252 + ],
253 + 'vimeo' => [
254 + 'label' => 'Vimeo icon',
255 + 'icon' => '<svg class="ct-icon" width="12" height="12" viewBox="0 0 20 20"><path d="M20 5.3c-.1 1.9-1.4 4.6-4.1 8-2.7 3.5-5 5.3-6.9 5.3-1.2 0-2.2-1.1-3-3.2-1.5-5.7-2.2-9.1-3.5-9.1-.2 0-.7.3-1.6.9L0 6c2.3-2 4.5-4.3 5.9-4.4 1.6-.2 2.5.9 2.9 3.2 1.3 8.1 1.8 9.3 4.2 5.7.8-1.3 1.3-2.3 1.3-3 .2-2-1.6-1.9-2.8-1.4 1-3.2 2.9-4.8 5.6-4.7 2 0 3 1.3 2.9 3.9z"/></svg>'
256 + ],
257 + 'vkontakte' => [
258 + 'label' => 'Vkontakte icon',
259 + 'icon' => '<svg class="ct-icon" width="12" height="12" viewBox="0 0 20 20"><path d="M19.3 4.7H16c-.3 0-.5.1-.6.4 0 0-1.3 2.4-1.7 3.2-1.1 2.2-1.8 1.5-1.8.5V5.3c0-.6-.5-1.1-1.1-1.1H8.2c-.6 0-1.3.3-1.7.8 0 0 1.2-.2 1.2 1.5v2.6c0 .4-.3.7-.7.7-.2 0-.4-.1-.6-.2-1-1.4-1.8-2.9-2.5-4.5.1-.2-.2-.4-.4-.4H.6c-.4 0-.6.2-.6.5v.2c.9 2.5 4.8 10.2 9.2 10.2H11c.4 0 .7-.3.7-.7v-1.1c0-.4.3-.7.7-.7.2 0 .4.1.5.2l2.2 2.1c.2.2.5.3.7.3h2.9c1.4 0 1.4-1 .6-1.7-.5-.5-2.5-2.6-2.5-2.6-.3-.4-.4-.9-.1-1.3.6-.8 1.7-2.2 2.1-2.8.9-.9 2-2.6.5-2.6z"/></svg>'
260 + ],
261 + 'odnoklassniki' => [
262 + 'label' => 'Odnoklassniki icon',
263 + 'icon' => '<svg class="ct-icon" width="12" height="12" viewBox="0 0 20 20"><path d="M10 10c2.8 0 5-2.2 5-5s-2.2-5-5-5-5 2.2-5 5 2.3 5 5 5zm0-7.5c1.4 0 2.5 1.1 2.5 2.5S11.4 7.5 10 7.5 7.5 6.4 7.5 5 8.6 2.5 10 2.5zM14.5 13c-1.1.7-2.5 1-3.5 1.1l.8.8 2.9 2.9c1.1 1.1-.7 2.9-1.8 1.8L10 16.7l-2.9 2.9c-1.1 1-2.9-.7-1.8-1.8l2.9-2.9.8-.8c-1-.1-2.4-.4-3.5-1.1-1.4-.8-2-1.4-1.4-2.4.3-.6 1.1-1 2.4-.3 0 0 1.4 1.1 3.6 1.1s3.6-1.1 3.6-1.1c1-.8 1.8-.3 2.1.3.5 1 0 1.5-1.3 2.4z"/></svg>'
264 + ],
265 + 'tiktok' => [
266 + 'label' => 'TikTok icon',
267 + 'icon' => '<svg class="ct-icon" width="12" height="12" viewBox="0 0 20 20"><path d="M18.2 4.5c-2.3-.2-4.1-1.9-4.4-4.2V0h-3.4v13.8c0 1.4-1.2 2.6-2.8 2.6-1.4 0-2.6-1.1-2.6-2.6s1.1-2.6 2.6-2.6h.2l.5.1V7.5h-.7c-3.4 0-6.2 2.8-6.2 6.2S4.2 20 7.7 20s6.2-2.8 6.2-6.2v-7c1.1 1.1 2.4 1.6 3.9 1.6h.8V4.6l-.4-.1z"/></svg>'
268 + ],
269 +
270 + 'mastodon' => [
271 + 'label' => 'Mastodon icon',
272 + 'icon' => '<svg class="ct-icon" width="12" height="12" viewBox="0 0 20 20"><path d="M19.3 6.6c0-4.3-2.8-5.6-2.8-5.6C13.7-.3 6.3-.3 3.5 1 3.5 1 .7 2.3.7 6.6c0 5.2-.3 11.6 4.7 12.9 1.8.5 3.4.6 4.6.5 2.3-.1 3.5-.8 3.5-.8l-.1-1.6s-1.6.5-3.4.5c-1.8-.1-3.7-.2-4-2.4v-.6c3.8.9 7.1.4 8 .3 2.5-.3 4.7-1.8 5-3.3.4-2.3.3-5.5.3-5.5zM16 12.2h-2.1V7.1c0-2.2-2.9-2.3-2.9.3v2.8H9V7.4c0-2.6-2.9-2.5-2.9-.3v5.1H4c0-5.4-.2-6.6.8-7.8C6 3.1 8.4 3 9.5 4.6l.5.9.5-.9c1.1-1.6 3.5-1.5 4.7-.3 1 1.3.8 2.4.8 7.9z"/></svg>'
273 + ]
274 + ];
275 +
276 + $additional_descriptors = apply_filters(
277 + 'blocksy:author-profile:custom-social-network',
278 + []
279 + );
280 +
281 + foreach ($additional_descriptors as $field) {
282 + if (
283 + isset($field['id'])
284 + &&
285 + isset($field['name'])
286 + &&
287 + isset($field['icon'])
288 + ) {
289 + $descriptor[$field['id']] = [
290 + 'label' => $field['name'],
291 + 'icon' => $field['icon']
292 + ];
293 +
294 + $meta_ids[] = $field['id'];
295 + }
296 + }
297 +
298 + foreach ($meta_ids as $network_id) {
299 + $meta_value = get_the_author_meta($network_id);
300 +
301 + if (! $meta_value) {
302 + continue;
303 + }
304 +
305 + $attr = [
306 + 'href' => esc_url($meta_value),
307 + 'aria-label' => $descriptor[$network_id]['label']
308 + ];
309 +
310 + if ($args['new_tab']) {
311 + $attr['rel'] = 'noopener noreferrer';
312 + $attr['target'] = '_blank';
313 + }
314 +
315 + if ($args['nofollow']) {
316 + if (! isset($attr['rel'])) {
317 + $attr['rel'] = '';
318 + }
319 +
320 + $attr['rel'] = trim($attr['rel'] . ' nofollow');
321 + }
322 +
323 + $outputs[] = blocksy_html_tag(
324 + 'a',
325 + $attr,
326 + $descriptor[$network_id]['icon']
327 + );
328 + }
329 +
330 + if (empty($outputs)) {
331 + return;
332 + }
333 +
334 + echo blocksy_html_tag(
335 + 'div',
336 + [
337 + 'class' => 'author-box-socials'
338 + ],
339 + blocksy_html_tag(
340 + 'span',
341 + [],
342 + implode(' ', $outputs)
343 + )
344 + );
345 + }
346 + }
347 +
348 + if (! function_exists('blocksy_author_meta_elements')) {
349 + function blocksy_author_meta_elements($args = []) {
350 + if (! is_author()) {
351 + return;
352 + }
353 +
354 + $args = wp_parse_args(
355 + $args,
356 + [
357 + 'value' => [
358 + 'joined' => false,
359 + 'articles_count' => false,
360 + 'comments' => false
361 + ],
362 +
363 + 'attr' => []
364 + ]
365 + );
366 +
367 + if (
368 + ! $args['value']['joined']
369 + &&
370 + ! $args['value']['articles_count']
371 + &&
372 + ! $args['value']['comments']
373 + ) {
374 + return;
375 + }
376 +
377 + $user_data = get_userdata(blocksy_get_author_id());
378 +
379 + $joined_date = '';
380 +
381 + if ($user_data && isset($user_data->user_registered)) {
382 + $joined_date = date_i18n(
383 + get_option('date_format', ''),
384 + strtotime($user_data->user_registered)
385 + );
386 + }
387 +
388 + $comments_count = get_comments([
389 + 'type' => '',
390 + 'user_id' => blocksy_get_author_id(),
391 + 'count' => true,
392 + ]);
393 +
394 + $posts_count = 0;
395 + $posts_count = blocksy_count_user_posts();
396 +
397 + $container_attr = array_merge([
398 + 'class' => 'entry-meta',
399 + 'data-type' => 'simple:slash'
400 + ], $args['attr']);
401 +
402 + ?>
403 +
404 + <ul <?php echo blocksy_attr_to_html($container_attr) ?>>
405 + <?php if ($args['value']['joined'] && ! empty($joined_date)) { ?>
406 + <li class="meta-date"><?php echo esc_html(__( 'Joined', 'blocksy' )); ?>:&nbsp;<?php echo esc_html($joined_date) ?></li>
407 + <?php } ?>
408 +
409 + <?php if ($args['value']['articles_count']) { ?>
410 + <li class="meta-articles"><?php echo esc_html(__( 'Articles', 'blocksy' )); ?>:&nbsp;<?php echo esc_html($posts_count) ?></li>
411 + <?php } ?>
412 +
413 + <?php if ($args['value']['comments'] && intval($comments_count) > 0) { ?>
414 + <li class="meta-comments"><?php echo esc_html(__( 'Comments', 'blocksy' )); ?>:&nbsp;<?php echo esc_html($comments_count) ?></li>
415 + <?php } ?>
416 + </ul>
417 +
418 + <?php
419 + }
420 + }
421 +
422 + /**
423 + * Output author box.
424 + */
425 + if (! function_exists('blocksy_author_box')) {
426 + function blocksy_author_box() {
427 + $prefix = blocksy_manager()->screen->get_prefix();
428 +
429 + $type = blocksy_get_theme_mod($prefix . '_single_author_box_type', 'type-2');
430 +
431 + $wrapper_tag = blocksy_get_theme_mod($prefix . '_single_author_box_name_heading', 'h5');
432 +
433 + $has_author_box_social = blocksy_get_theme_mod(
434 + $prefix . '_single_author_box_social',
435 + 'yes'
436 + ) === 'yes';
437 +
438 + $has_author_box_posts_count = blocksy_get_theme_mod(
439 + $prefix . '_single_author_box_posts_count',
440 + 'yes'
441 + ) === 'yes';
442 +
443 + $class = 'author-box is-width-constrained';
444 +
445 + $class .= ' ' . blocksy_visibility_classes(blocksy_get_theme_mod(
446 + $prefix . '_author_box_visibility',
447 + [
448 + 'desktop' => true,
449 + 'tablet' => true,
450 + 'mobile' => false,
451 + ]
452 + ));
453 +
454 + $deep_link_args = [
455 + 'prefix' => $prefix,
456 + 'suffix' => $prefix . '_has_author_box',
457 + 'shortcut' => 'border'
458 + ];
459 +
460 + $with_link = blocksy_get_theme_mod($prefix . '_single_author_box_archive_link', 'yes') === 'yes';
461 +
462 + ?>
463 +
464 + <div class="<?php echo esc_attr($class); ?>" data-type="<?php echo esc_attr($type); ?>" <?php echo blocksy_generic_get_deep_link($deep_link_args); ?>>
465 + <?php
466 + echo blocksy_simple_image(
467 + apply_filters(
468 + 'blocksy:single:author_box:author-avatar-url',
469 + blocksy_get_avatar_url([
470 + 'avatar_entity' => blocksy_get_author_id(),
471 + 'size' => 120
472 + ])
473 + ),
474 + [
475 + 'tag_name' => $with_link ? 'a' : 'span',
476 + 'inner_content' => $with_link ? '
477 + <svg width="18px" height="13px" viewBox="0 0 20 15">
478 + <polygon points="14.5,2 13.6,2.9 17.6,6.9 0,6.9 0,8.1 17.6,8.1 13.6,12.1 14.5,13 20,7.5 "/>
479 + </svg>
480 + ' : '',
481 + 'html_atts' => array_merge(
482 + $with_link ? [
483 + 'href' => get_author_posts_url(
484 + blocksy_get_author_id(),
485 + blocksy_get_the_author_meta('user_nicename')
486 + ),
487 + ] : [],
488 + []
489 + ),
490 + 'img_atts' => [
491 + 'width' => 60,
492 + 'height' => 60,
493 + 'alt' => blocksy_get_avatar_alt_for(get_the_author_meta('ID'))
494 + ],
495 + ]
496 + );
497 +
498 + ?>
499 +
500 + <section>
501 + <<?php echo $wrapper_tag ?> class="author-box-name">
502 + <?php the_author(); ?>
503 + </<?php echo $wrapper_tag ?>>
504 +
505 + <div class="author-box-bio">
506 + <?php //the_author_meta('description'); ?>
507 +
508 + <?php echo wp_kses_post(wpautop(blocksy_get_the_author_meta('description'))); ?>
509 + </div>
510 +
511 + <?php
512 + if ($has_author_box_social) {
513 + blocksy_author_social_channels([
514 + 'new_tab' => blocksy_get_theme_mod(
515 + $prefix . '_single_author_box_social_link_target',
516 + 'no'
517 + ) === 'yes',
518 +
519 + 'nofollow' => blocksy_get_theme_mod(
520 + $prefix . '_single_author_box_social_link_nofollow',
521 + 'no'
522 + ) === 'yes',
523 + ]);
524 + }
525 + ?>
526 +
527 + <?php if ($has_author_box_posts_count) {
528 + $posts_count = count_user_posts(
529 + blocksy_get_author_id(),
530 + array_merge(
531 + ['post'],
532 + blocksy_manager()->post_types->get_supported_post_types()
533 + )
534 + );
535 +
536 + echo blocksy_html_tag(
537 + $with_link ? 'a' : 'span',
538 + array_merge(
539 + $with_link ? [
540 + 'href' => get_author_posts_url(blocksy_get_author_id()),
541 + ] : [],
542 + [
543 + 'class' => 'ct-author-box-more'
544 + ]
545 + ),
546 + esc_html(__('Articles', 'blocksy')) . ':&nbsp;' . $posts_count
547 + );
548 + } ?>
549 + </section>
550 + </div>
551 +
552 + <?php
553 + }
554 + }
555 +
556 + if (! function_exists('blocksy_get_featured_image_source')) {
557 + function blocksy_get_featured_image_source() {
558 + static $result = null;
559 +
560 + $post_type = blocksy_manager()->post_types->is_supported_post_type();
561 +
562 + if ($post_type) {
563 + return [
564 + 'prefix' => $post_type . '_single',
565 + 'strategy' => 'customizer'
566 + ];
567 + }
568 +
569 + if (blocksy_is_page()) {
570 + return [
571 + 'strategy' => 'customizer',
572 + 'prefix' => 'single_page'
573 + ];
574 + }
575 +
576 + return [
577 + 'strategy' => 'customizer',
578 + 'prefix' => 'single_blog_post'
579 + ];
580 + }
581 + }
582 +
583 + if (! function_exists('blocksy_get_featured_image_output')) {
584 + function blocksy_get_featured_image_output() {
585 + $featured_image_source = blocksy_get_featured_image_source();
586 +
587 + if (blocksy_akg_or_customizer(
588 + 'has_featured_image',
589 + $featured_image_source,
590 + 'no'
591 + ) === 'no') {
592 + return '';
593 + }
594 +
595 + if (blocksy_default_akg(
596 + 'disable_featured_image',
597 + blocksy_get_post_options(),
598 + 'no'
599 + ) === 'yes') {
600 + return '';
601 + }
602 +
603 + if (! has_post_thumbnail()) {
604 + return '';
605 + }
606 +
607 + $prefix = blocksy_manager()->screen->get_prefix();
608 +
609 + $has_video_thumbnail = blocksy_akg_or_customizer(
610 + 'video_thumbnail',
611 + $featured_image_source,
612 + 'no'
613 + );
614 +
615 + $class = 'ct-featured-image';
616 +
617 + $class .= ' ' . blocksy_visibility_classes(
618 + blocksy_akg_or_customizer(
619 + 'featured_image_visibility',
620 + $featured_image_source,
621 + [
622 + 'desktop' => true,
623 + 'tablet' => true,
624 + 'mobile' => true,
625 + ]
626 + )
627 + );
628 +
629 + if (blocksy_sidebar_position() === 'none') {
630 + $image_width = blocksy_akg_or_customizer(
631 + 'featured_image_width',
632 + $featured_image_source,
633 + 'default'
634 + );
635 +
636 + if ($image_width === 'wide') {
637 + $class .= ' alignwide';
638 + }
639 +
640 + if ($image_width === 'full') {
641 + $class .= ' alignfull';
642 + }
643 + }
644 +
645 + $maybe_figcaption = wp_get_attachment_caption(get_post_thumbnail_id());
646 +
647 + if (! empty($maybe_figcaption)) {
648 + $maybe_figcaption = '<figcaption>' . trim($maybe_figcaption) . '</figcaption>';
649 + } else {
650 + $maybe_figcaption = '';
651 + }
652 +
653 + return apply_filters(
654 + 'post_thumbnail_html',
655 + blocksy_html_tag('figure', ['class' => $class], blocksy_media([
656 + 'attachment_id' => get_post_thumbnail_id(),
657 + 'post_id' => get_the_ID(),
658 + 'ratio' => blocksy_akg_or_customizer(
659 + 'featured_image_ratio',
660 + $featured_image_source,
661 + 'original'
662 + ),
663 + 'size' => blocksy_akg_or_customizer(
664 + 'featured_image_size',
665 + $featured_image_source,
666 + 'full'
667 + ),
668 + 'display_video' => $has_video_thumbnail === 'yes',
669 + 'lazyload' => blocksy_get_theme_mod(
670 + 'has_lazy_load_single_featured_image',
671 + 'yes'
672 + ) === 'yes'
673 + ]) . $maybe_figcaption),
674 + get_the_ID(),
675 + get_post_thumbnail_id(),
676 + blocksy_akg_or_customizer(
677 + 'featured_image_size',
678 + $featured_image_source,
679 + 'full'
680 + ),
681 + ''
682 + );
683 + }
684 + }
685 +
686 +