PluginProbe ʕ •ᴥ•ʔ
Author Website Templates – Create Writer, Author & Publisher Websites Easily / 1.1.9
Author Website Templates – Create Writer, Author & Publisher Websites Easily v1.1.9
trunk 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9
author-website-templates / build / blocks / author-pro / book-hero / render.php
author-website-templates / build / blocks / author-pro / book-hero Last commit date
block.json 1 month ago index.asset.php 1 month ago index.js 1 month ago render.php 1 month ago style-index-rtl.css 1 month ago style-index.css 1 month ago
render.php
447 lines
1 <?php
2 /**
3 * Render Book Hero [Author Pro] Block
4 */
5
6 $block_id = isset($attributes['blockId']) ? $attributes['blockId'] : '';
7 if (empty($block_id)) {
8 $block_id = 'awt-book-hero-' . uniqid();
9 }
10
11 // Data Handling to support Editor vs Frontend
12 $book_id = get_the_ID();
13 $is_editor = defined('REST_REQUEST') && REST_REQUEST === true;
14
15 // If in editor and not on a book post, try to find the latest book for preview
16 if ($is_editor && get_post_type($book_id) !== 'book') {
17 $min_query = new WP_Query([
18 'post_type' => 'book',
19 'posts_per_page' => 1,
20 'post_status' => 'publish'
21 ]);
22 if ($min_query->have_posts()) {
23 $min_query->the_post();
24 $book_id = get_the_ID();
25 wp_reset_postdata();
26 }
27 }
28
29 // 1. Fetch Data
30 // Basic
31 $title = get_the_title($book_id);
32 $permalink = get_permalink($book_id);
33 $cover_url = get_the_post_thumbnail_url($book_id, 'full');
34 $description = get_post_meta($book_id, '_rsbs_short_description', true);
35
36 if (empty($description)) {
37 // fallback to excerpt or content trimmed
38 $post_obj = get_post($book_id);
39 $description = $post_obj->post_excerpt ? $post_obj->post_excerpt : wp_trim_words($post_obj->post_content, 30);
40 }
41
42 // Stats
43 $pages = get_post_meta($book_id, '_rsbs_book_pages', true);
44 $year = get_post_meta($book_id, '_rsbs_book_publish_year', true);
45 $language = get_post_meta($book_id, '_rsbs_book_language', true);
46
47 // Pricing
48 $regular_price = get_post_meta($book_id, '_rsbs_book_price', true);
49 $sale_price = get_post_meta($book_id, '_rsbs_book_sale_price', true);
50
51 // Format Prices
52 $regular_price_clean = floatval(preg_replace('/[^0-9.]/', '', $regular_price));
53 $sale_price_clean = floatval(preg_replace('/[^0-9.]/', '', $sale_price));
54 $has_sale = $sale_price_clean > 0 && $sale_price_clean < $regular_price_clean;
55
56 $savings_pct = 0;
57 if ($has_sale && $regular_price_clean > 0) {
58 $savings_pct = round((($regular_price_clean - $sale_price_clean) / $regular_price_clean) * 100);
59 }
60
61 // Buttons
62 $buy_btn_text = get_post_meta($book_id, '_rsbs_buy_btn_text', true);
63 $buy_btn_link = get_post_meta($book_id, '_rsbs_buy_btn_link', true);
64 if (empty($buy_btn_text)) $buy_btn_text = 'Buy on Amazon';
65
66 // Secondary Buttons/Stores
67 $stores_list = get_post_meta($book_id, 'rswpbs_also_available_website_list', true);
68
69
70 // Formats
71 $formats_data = get_post_meta($book_id, 'rswpbs_book_formats', true);
72 $formats_string = '';
73 if (!empty($formats_data) && is_array($formats_data)) {
74 $format_names = [];
75 foreach ($formats_data as $cat) {
76 if (!empty($cat['name'])) {
77 $format_names[] = $cat['name'];
78 }
79 }
80 if (!empty($format_names)) {
81 $formats_string = implode(', ', $format_names);
82 }
83 }
84
85
86 // Reviews Calculation
87 $review_args = [
88 'post_type' => 'book_reviews',
89 'posts_per_page' => -1,
90 'meta_query' => [
91 [
92 'key' => '_rswpbs_reviewed_book',
93 'value' => $book_id,
94 'compare' => '='
95 ]
96 ]
97 ];
98 $reviews_query = new WP_Query($review_args);
99 $total_reviews = $reviews_query->found_posts;
100 $sum_rating = 0;
101
102 if ($reviews_query->have_posts()) {
103 while ($reviews_query->have_posts()) {
104 $reviews_query->the_post();
105 $r_val = get_post_meta(get_the_ID(), '_rswpbs_rating', true);
106 $sum_rating += floatval($r_val);
107 }
108 wp_reset_postdata();
109 }
110
111 $avg_rating = ($total_reviews > 0) ? round($sum_rating / $total_reviews, 1) : 0;
112
113
114 // 2. Attributes
115 $show_breadcrumbs = isset($attributes['showBreadcrumbs']) ? $attributes['showBreadcrumbs'] : true;
116 $show_stats = isset($attributes['showStats']) ? $attributes['showStats'] : true;
117 $show_badge = isset($attributes['showBadge']) ? $attributes['showBadge'] : true;
118 $show_review_count = isset($attributes['showReviewCount']) ? $attributes['showReviewCount'] : true;
119
120 $badge_text = !empty($attributes['badgeText']) ? $attributes['badgeText'] : '#1 New York Times Bestseller';
121 $sub_title = !empty($attributes['subTitle']) ? $attributes['subTitle'] : '';
122 if (empty($sub_title)) {
123 $sub_title = get_post_meta($book_id, '_rsbs_book_reading_age', true);
124 if($sub_title) $sub_title = esc_html($reading_age_label) . ": " . $sub_title;
125 }
126
127 $formats_title = !empty($attributes['formatsTitle']) ? $attributes['formatsTitle'] : 'Available Formats';
128
129 $pages_label = !empty($attributes['pagesLabel']) ? $attributes['pagesLabel'] : 'Pages';
130 $year_label = !empty($attributes['yearLabel']) ? $attributes['yearLabel'] : 'Year';
131 $language_label = !empty($attributes['languageLabel']) ? $attributes['languageLabel'] : 'Language';
132 $reading_age_label = !empty($attributes['readingAgeLabel']) ? $attributes['readingAgeLabel'] : 'Reading Age';
133 $review_link_text = !empty($attributes['reviewLinkText']) ? $attributes['reviewLinkText'] : 'Read %s Reviews';
134
135 // Colors
136 $section_bg = isset($attributes['sectionBg']) ? $attributes['sectionBg'] : '';
137 $primary_color = isset($attributes['primaryColor']) ? $attributes['primaryColor'] : (isset($attributes['titleColor']) ? $attributes['titleColor'] : '');
138 $secondary_color = isset($attributes['secondaryColor']) ? $attributes['secondaryColor'] : (isset($attributes['textColor']) ? $attributes['textColor'] : '');
139 $accent_color = isset($attributes['accentColor']) ? $attributes['accentColor'] : '';
140
141 $btn_bg = isset($attributes['btnBg']) ? $attributes['btnBg'] : ($accent_color ? $accent_color : '');
142 $btn_text = isset($attributes['btnText']) ? $attributes['btnText'] : '#ffffff';
143 $btn_hover_bg = isset($attributes['btnHoverBg']) ? $attributes['btnHoverBg'] : '';
144 $btn_hover_text = isset($attributes['btnHoverText']) ? $attributes['btnHoverText'] : '';
145
146
147 // 3. Dynamic CSS
148 $anchor = isset($attributes['anchor']) ? $attributes['anchor'] : '';
149 $element_id = !empty($anchor) ? $anchor : $block_id;
150 $css_id = '#' . $element_id;
151 $custom_css = "";
152
153 if ($section_bg) $custom_css .= "$css_id .awt-section-bg { background-color: $section_bg !important; }";
154 if ($primary_color) {
155 $custom_css .= "$css_id .text-primary { color: $primary_color !important; }";
156 $custom_css .= "$css_id .border-primary { border-color: $primary_color !important; }";
157 $custom_css .= "$css_id .bg-primary { background-color: $primary_color !important; }";
158 $custom_css .= "$css_id .hover\:text-primary:hover { color: $primary_color !important; }";
159 }
160 if ($secondary_color) {
161 $custom_css .= "$css_id .text-secondary { color: $secondary_color !important; }";
162 $custom_css .= "$css_id .prose-slate { color: $secondary_color !important; }";
163 }
164 if ($accent_color) {
165 $custom_css .= "$css_id .text-accent { color: $accent_color !important; }";
166 $custom_css .= "$css_id .bg-accent { background-color: $accent_color !important; }";
167 $custom_css .= "$css_id .border-accent { border-color: $accent_color !important; }";
168 $custom_css .= "$css_id .hover\:text-accent:hover { color: $accent_color !important; }";
169 $custom_css .= "$css_id .hover\:bg-accent:hover { background-color: $accent_color !important; }";
170 $custom_css .= "$css_id .hover\:border-accent:hover { border-color: $accent_color !important; }";
171
172 // SVG Fills
173 $custom_css .= "$css_id .awt-svg-accent { color: $accent_color !important; }";
174 $custom_css .= "$css_id .awt-blur-accent { background-color: " . rswpthemes_awt_hex2rgba($accent_color, 0.05) . " !important; }";
175 }
176
177 // Button Overrides
178 if ($btn_bg) $custom_css .= "$css_id .awt-btn-primary { background-color: $btn_bg !important; }";
179 if ($btn_text) $custom_css .= "$css_id .awt-btn-primary { color: $btn_text !important; }";
180 if ($btn_hover_bg) $custom_css .= "$css_id .awt-btn-primary:hover { background-color: $btn_hover_bg !important; }";
181 if ($btn_hover_text) $custom_css .= "$css_id .awt-btn-primary:hover { color: $btn_hover_text !important; }";
182
183
184 // Wrapper Attributes
185 $wrapper_attributes = get_block_wrapper_attributes([
186 'class' => 'awt-book-hero',
187 'id' => $element_id,
188 ]);
189
190 // Helper
191 if (!function_exists('rswpthemes_awt_hex2rgba')) {
192 function rswpthemes_awt_hex2rgba($color, $opacity = false) {
193 $default = 'rgb(0,0,0)';
194 if(empty($color)) return $default;
195 if ($color[0] == '#' ) {
196 $color = substr( $color, 1 );
197 }
198 if (strlen($color) == 6) {
199 $hex = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] );
200 } elseif ( strlen( $color ) == 3 ) {
201 $hex = array( $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2] );
202 } else {
203 return $default;
204 }
205 $rgb = array_map('hexdec', $hex);
206 if($opacity){
207 if(abs($opacity) > 1) $opacity = 1.0;
208 $output = 'rgba('.implode(",",$rgb).','.$opacity.')';
209 } else {
210 $output = 'rgb('.implode(",",$rgb).')';
211 }
212 return $output;
213 }
214 }
215 ?>
216
217 <?php if (!empty($custom_css)) : ?>
218 <style><?php echo $custom_css; ?></style>
219 <?php endif; ?>
220
221 <div <?php echo $wrapper_attributes; ?>>
222 <?php if ($show_breadcrumbs) : ?>
223 <div class="pt-4 pb-4 bg-paper border-b border-gray-100 awt-breadcrumb-section">
224 <div class="awt-container">
225 <nav class="flex text-xs font-medium text-gray-400" aria-label="Breadcrumb">
226 <ol class="flex list-none items-center space-x-2">
227 <li><a href="<?php echo home_url(); ?>" class="hover:text-primary text-gray-400 transition">Home</a></li>
228 <li>
229 <!-- Chevron Right -->
230 <svg class="w-2.5 h-2.5" fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><path d="M471.1 297.4C483.6 309.9 483.6 330.2 471.1 342.7L279.1 534.7C266.6 547.2 246.3 547.2 233.8 534.7C221.3 522.2 221.3 501.9 233.8 489.4L403.2 320L233.9 150.6C221.4 138.1 221.4 117.8 233.9 105.3C246.4 92.8 266.7 92.8 279.2 105.3L471.2 297.3z"/></svg>
231 </li>
232 <li><a href="<?php echo get_post_type_archive_link('book'); ?>" class="hover:text-primary text-gray-400 transition">Books</a></li>
233 <li>
234 <!-- Chevron Right -->
235 <svg class="w-2.5 h-2.5" fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><path d="M471.1 297.4C483.6 309.9 483.6 330.2 471.1 342.7L279.1 534.7C266.6 547.2 246.3 547.2 233.8 534.7C221.3 522.2 221.3 501.9 233.8 489.4L403.2 320L233.9 150.6C221.4 138.1 221.4 117.8 233.9 105.3C246.4 92.8 266.7 92.8 279.2 105.3L471.2 297.3z"/></svg>
236 </li>
237 <li class="text-accent font-bold"><?php echo esc_html($title); ?></li>
238 </ol>
239 </nav>
240 </div>
241 </div>
242 <?php endif; ?>
243
244 <section class="py-12 lg:py-20 bg-white awt-section-bg">
245 <div class="awt-container">
246 <div class="grid grid-cols-1 lg:grid-cols-12 gap-12 lg:gap-20">
247
248 <div class="lg:col-span-5 flex flex-col items-center">
249 <div class="relative w-full max-w-md mx-auto group">
250 <div
251 class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[120%] h-[120%] bg-accent/5 rounded-full blur-3xl -z-10 awt-blur-accent"
252 <?php if ($cover_url) echo 'style="background-image: url(' . esc_url($cover_url) . '); background-size: cover; opacity: 0.15;"'; ?>
253 >
254 </div>
255
256 <div
257 class="relative rounded-lg shadow-2xl overflow-hidden transform transition duration-500 hover:scale-[1.02]">
258 <?php if ($cover_url) : ?>
259 <img src="<?php echo esc_url($cover_url); ?>"
260 alt="<?php echo esc_attr($title); ?>" class="w-full h-auto object-cover">
261 <?php else : ?>
262 <div class="w-full h-96 bg-gray-200 flex items-center justify-center text-gray-400">No Image</div>
263 <?php endif; ?>
264
265 <a href="#"
266 class="absolute bottom-6 right-6 w-12 h-12 bg-white rounded-full shadow-lg flex items-center justify-center text-accent hover:bg-accent hover:text-white transition group-hover:scale-110 awt-svg-accent">
267 <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 16 16"> <path d="M16 8s-3-5.5-8-5.5S0 8 0 8s3 5.5 8 5.5S16 8 16 8zM1.173 8a13.133 13.133 0 0 1 1.66-2.043C4.12 4.668 5.88 3.5 8 3.5c2.12 0 3.879 1.168 5.168 2.457A13.133 13.133 0 0 1 14.828 8c-.058.087-.122.183-.195.288-.335.48-.83 1.12-1.465 1.755C11.879 11.332 10.119 12.5 8 12.5c-2.12 0-3.879-1.168-5.168-2.457A13.134 13.134 0 0 1 1.172 8z"/> <path d="M8 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5z"/> </svg>
268 </a>
269 </div>
270 </div>
271
272 <?php if ($show_stats) : ?>
273 <div class="grid grid-cols-3 gap-4 w-full max-w-md mt-8 border-t border-b border-gray-100 py-6">
274 <div class="text-center border-r border-gray-100">
275 <span class="block text-xl font-bold text-primary font-serif"><?php echo esc_html($pages); ?></span>
276 <span class="text-xs text-gray-400 uppercase tracking-wider"><?php echo esc_html($pages_label); ?></span>
277 </div>
278 <div class="text-center border-r border-gray-100">
279 <span class="block text-xl font-bold text-primary font-serif"><?php echo esc_html($year); ?></span>
280 <span class="text-xs text-gray-400 uppercase tracking-wider"><?php echo esc_html($year_label); ?></span>
281 </div>
282 <div class="text-center">
283 <span class="block text-xl font-bold text-primary font-serif"><?php echo esc_html($language); ?></span>
284 <span class="text-xs text-gray-400 uppercase tracking-wider"><?php echo esc_html($language_label); ?></span>
285 </div>
286 </div>
287 <?php endif; ?>
288 </div>
289
290 <div class="lg:col-span-7 flex flex-col justify-center">
291 <div class="mb-6">
292 <?php if ($show_badge && !empty($badge_text)) : ?>
293 <div
294 class="inline-flex items-center gap-2 px-3 py-1 bg-yellow-50 text-yellow-700 rounded-full text-xs font-bold uppercase tracking-wider mb-4 awt-badge-container">
295 <!-- Trophy Icon -->
296 <svg class="w-3 h-3 mr-1" fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><path d="M208.3 64L432.3 64C458.8 64 480.4 85.8 479.4 112.2C479.2 117.5 479 122.8 478.7 128L528.3 128C554.4 128 577.4 149.6 575.4 177.8C567.9 281.5 514.9 338.5 457.4 368.3C441.6 376.5 425.5 382.6 410.2 387.1C390 415.7 369 430.8 352.3 438.9L352.3 512L416.3 512C434 512 448.3 526.3 448.3 544C448.3 561.7 434 576 416.3 576L224.3 576C206.6 576 192.3 561.7 192.3 544C192.3 526.3 206.6 512 224.3 512L288.3 512L288.3 438.9C272.3 431.2 252.4 416.9 233 390.6C214.6 385.8 194.6 378.5 175.1 367.5C121 337.2 72.2 280.1 65.2 177.6C63.3 149.5 86.2 127.9 112.3 127.9L161.9 127.9C161.6 122.7 161.4 117.5 161.2 112.1C160.2 85.6 181.8 63.9 208.3 63.9zM165.5 176L113.1 176C119.3 260.7 158.2 303.1 198.3 325.6C183.9 288.3 172 239.6 165.5 176zM444 320.8C484.5 297 521.1 254.7 527.3 176L475 176C468.8 236.9 457.6 284.2 444 320.8z"/></svg>
297 <?php echo esc_html($badge_text); ?>
298 </div>
299 <?php endif; ?>
300 <h1 class="text-4xl lg:text-5xl font-serif font-bold text-primary mb-2"><?php echo esc_html($title); ?></h1>
301 <?php if ($sub_title) : ?>
302 <p class="text-lg text-secondary font-medium"><?php echo esc_html($sub_title); ?></p>
303 <?php endif; ?>
304 </div>
305
306 <?php if ($show_review_count) : ?>
307 <div class="flex items-center gap-4 mb-8">
308 <div class="flex text-yellow-500 text-sm stars awt-svg-accent">
309 <?php
310 $stars = ($avg_rating > 0) ? round($avg_rating) : 0;
311 for($i=0; $i<5; $i++) {
312 if ($i < $stars) {
313 echo '<svg class="w-3 h-3" fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><path d="M341.5 45.1C337.4 37.1 329.1 32 320.1 32C311.1 32 302.8 37.1 298.7 45.1L225.1 189.3L65.2 214.7C56.3 216.1 48.9 222.4 46.1 231C43.3 239.6 45.6 249 51.9 255.4L166.3 369.9L141.1 529.8C139.7 538.7 143.4 547.7 150.7 553C158 558.3 167.6 559.1 175.7 555L320.1 481.6L464.4 555C472.4 559.1 482.1 558.3 489.4 553C496.7 547.7 500.4 538.8 499 529.8L473.7 369.9L588.1 255.4C594.5 249 596.7 239.6 593.9 231C591.1 222.4 583.8 216.1 574.8 214.7L415 189.3L341.5 45.1z"/></svg>';
314 } else {
315 echo '<svg class="w-3 h-3 text-gray-300" fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><path d="M341.5 45.1C337.4 37.1 329.1 32 320.1 32C311.1 32 302.8 37.1 298.7 45.1L225.1 189.3L65.2 214.7C56.3 216.1 48.9 222.4 46.1 231C43.3 239.6 45.6 249 51.9 255.4L166.3 369.9L141.1 529.8C139.7 538.7 143.4 547.7 150.7 553C158 558.3 167.6 559.1 175.7 555L320.1 481.6L464.4 555C472.4 559.1 482.1 558.3 489.4 553C496.7 547.7 500.4 538.8 499 529.8L473.7 369.9L588.1 255.4C594.5 249 596.7 239.6 593.9 231C591.1 222.4 583.8 216.1 574.8 214.7L415 189.3L341.5 45.1z"/></svg>';
316 }
317 }
318 ?>
319 </div>
320 <a href="#reviews"
321 class="text-sm text-gray-500 font-medium hover:text-accent cursor-pointer underline decoration-dotted transition">
322 <?php printf(esc_html($review_link_text), number_format($total_reviews)); ?>
323 </a>
324 </div>
325 <?php endif; ?>
326
327 <div class="prose prose-slate text-secondary mb-8 leading-relaxed">
328 <?php echo wp_kses_post($description); ?>
329 </div>
330
331 <div class="bg-paper p-6 rounded-xl border border-gray-100 mb-8 awt-pricing-box">
332 <?php
333
334 $regular_price_clean = '';
335 $sale_price_clean = '';
336 $has_sale = false;
337 $savings_pct = 0;
338
339
340 if ( function_exists('rswpbs_get_linked_product') ) {
341 $linked_product = rswpbs_get_linked_product();
342
343 if ( $linked_product ) {
344 $regular_price = $linked_product->get_regular_price();
345 $sale_price = $linked_product->get_sale_price();
346
347
348 if ( '' !== $regular_price && null !== $regular_price ) {
349 $has_sale = $sale_price && $sale_price < $regular_price;
350
351
352 $regular_price_clean = number_format( (float) $regular_price, 2 );
353 $sale_price_clean = $sale_price ? number_format( (float) $sale_price, 2 ) : '';
354
355 if ( $has_sale ) {
356 $savings_pct = round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
357 }
358 }
359 }
360 }
361
362
363 if ( ! empty( $regular_price_clean ) ) : ?>
364 <div class="flex flex-wrap items-end gap-3 mb-6">
365 <?php if ( $has_sale ) : ?>
366 <span class="text-3xl font-serif font-bold text-accent"><?php echo esc_html( $sale_price_clean ); ?></span>
367 <span class="text-lg text-gray-400 line-through decoration-red-500 decoration-2 mb-1"><?php echo esc_html( $regular_price_clean ); ?></span>
368 <span class="text-xs font-bold text-green-600 bg-green-100 px-2 py-1 rounded ml-2 mb-1">Save <?php echo $savings_pct; ?>%</span>
369 <?php else: ?>
370 <span class="text-3xl font-serif font-bold text-accent"><?php echo esc_html( $regular_price_clean ); ?></span>
371 <?php endif; ?>
372 </div>
373 <?php endif; ?>
374
375 <div class="flex flex-wrap flex-col sm:flex-row gap-4 mb-4">
376
377 <?php
378 echo shortcode_exists('rswpbs_book_cart') ? do_shortcode( "[rswpbs_book_cart/]" ) : '' ;
379
380 if ($buy_btn_link) : ?>
381 <a target="_blank" href="<?php echo esc_url($buy_btn_link); ?>"
382 class="w-full sm:w-auto self-start bg-accent awt-btn-primary text-white font-bold py-3.5 px-6 rounded text-center hover:bg-orange-700 transition shadow-lg shadow-orange-100 flex items-center justify-center gap-2">
383 <?php echo esc_html($buy_btn_text); ?>
384 </a>
385 <?php endif; ?>
386
387 <?php
388 if (!empty($stores_list) && is_array($stores_list)) {
389 foreach ($stores_list as $store) {
390 $store_name = isset($store['website_name']) ? $store['website_name'] : 'Store';
391 $store_url = isset($store['book_url']) ? $store['book_url'] : '#';
392
393 echo '<a target="_blank" href="'.esc_url($store_url).'" class="w-full sm:w-auto self-start bg-white border border-gray-300 text-primary font-bold py-3.5 px-6 rounded text-center hover:border-accent hover:text-accent transition flex items-center justify-center gap-2">';
394 echo esc_html($store_name);
395 echo '</a>';
396 }
397 }
398 ?>
399 </div>
400
401 <?php if ($formats_string) : ?>
402 <p class="text-xs text-center text-gray-400 flex items-center justify-center">
403 <svg class="w-3 h-3 mr-2 text-green-500" fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><path d="M530.8 134.1C545.1 144.5 548.3 164.5 537.9 178.8L281.9 530.8C276.4 538.4 267.9 543.1 258.5 543.9C249.1 544.7 240 541.2 233.4 534.6L105.4 406.6C92.9 394.1 92.9 373.8 105.4 361.3C117.9 348.8 138.2 348.8 150.7 361.3L252.2 462.8L486.2 141.1C496.6 126.8 516.6 123.6 530.9 134z"/></svg>
404 Available in <?php echo esc_html($formats_string); ?>
405 </p>
406 <?php endif; ?>
407 </div>
408
409 <div>
410 <h3 class="text-sm font-bold text-primary uppercase tracking-widest mb-4"><?php echo esc_html($formats_title); ?></h3>
411
412 <?php if (!empty($formats_data) && is_array($formats_data)) : ?>
413 <ul class="border border-gray-100 rounded-xl list-none pl-0 bg-paper overflow-hidden">
414 <?php foreach ($formats_data as $format) :
415 $f_name = !empty($format['name']) ? $format['name'] : '';
416 $f_price = !empty($format['price']) ? $format['price'] : '';
417 $f_link = !empty($format['link']) ? $format['link'] : '';
418 ?>
419 <li class="group border-b border-gray-100 last:border-0 transition hover:bg-white">
420 <a target="_blank" href="<?php echo esc_url($f_link ? $f_link : '#'); ?>" class="flex items-center justify-between p-4 no-underline <?php echo empty($f_link) ? 'pointer-events-none' : ''; ?>">
421 <div class="flex items-center gap-3">
422 <svg class="w-4 h-4 awt-svg-accent text-accent" fill="currentColor" viewBox="0 0 512 512">
423 <path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM369 209L241 337c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L335 175c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z"/>
424 </svg>
425 <span class="text-sm font-bold text-primary"><?php echo esc_html($f_name); ?></span>
426 </div>
427 <div class="flex items-center gap-2">
428 <span class="text-sm font-bold text-accent"><?php echo esc_html($f_price); ?></span>
429 <?php if ($f_link) : ?>
430 <svg class="w-3 h-3 text-gray-400 group-hover:text-accent transition" fill="currentColor" viewBox="0 0 320 512">
431 <path d="M310.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L242.7 256 73.4 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z"/>
432 </svg>
433 <?php endif; ?>
434 </div>
435 </a>
436 </li>
437 <?php endforeach; ?>
438 </ul>
439 <?php endif; ?>
440 </div>
441
442 </div>
443 </div>
444 </div>
445 </section>
446 </div>
447