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
148 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Render template for Author Pro Author Taxonomy Info block |
| 4 | * |
| 5 | * @package Author_Website_Templates |
| 6 | */ |
| 7 | |
| 8 | if (!defined('ABSPATH')) { |
| 9 | exit; |
| 10 | } |
| 11 | |
| 12 | // Attributes |
| 13 | $accentColor = isset($attributes['accentColor']) ? $attributes['accentColor'] : '#ea580c'; |
| 14 | |
| 15 | // Helper to hex to rgb |
| 16 | function hex2rgb($hex) { |
| 17 | $hex = str_replace("#", "", $hex); |
| 18 | if(strlen($hex) == 3) { |
| 19 | $r = hexdec(substr($hex,0,1).substr($hex,0,1)); |
| 20 | $g = hexdec(substr($hex,1,1).substr($hex,1,1)); |
| 21 | $b = hexdec(substr($hex,2,1).substr($hex,2,1)); |
| 22 | } else { |
| 23 | $r = hexdec(substr($hex,0,2)); |
| 24 | $g = hexdec(substr($hex,2,2)); |
| 25 | $b = hexdec(substr($hex,4,2)); |
| 26 | } |
| 27 | return array($r, $g, $b); |
| 28 | } |
| 29 | |
| 30 | // Get Accent Color RGBA for opacity |
| 31 | $rgb = hex2rgb($accentColor); |
| 32 | $accent_bg_light = "rgba({$rgb[0]}, {$rgb[1]}, {$rgb[2]}, 0.1)"; |
| 33 | |
| 34 | // Get Current Term |
| 35 | $term = get_queried_object(); |
| 36 | $author_name = 'Author Name'; |
| 37 | $author_description = 'Author biography description will appear here on the frontend.'; |
| 38 | $author_image_url = 'https://images.unsplash.com/photo-1556157382-97eda2d62296?auto=format&fit=crop&q=80&w=800'; // Default placeholder |
| 39 | $social_profiles = []; |
| 40 | $total_books = 0; |
| 41 | |
| 42 | // If in editor or not a term, use mock data? |
| 43 | // Or try to get a sample term? |
| 44 | // For now, if $term is valid, use it. |
| 45 | if ($term instanceof WP_Term && $term->taxonomy === 'book-author') { |
| 46 | $author_name = $term->name; |
| 47 | $author_description = term_description($term->term_id); |
| 48 | if (empty($author_description)) { |
| 49 | // Fallback to meta description if term description is empty |
| 50 | $author_description = get_term_meta($term->term_id, 'rswpbs_book_author_description', true); |
| 51 | } |
| 52 | |
| 53 | $author_image_url_meta = get_term_meta($term->term_id, 'rswpbs_book_author_picture', true); |
| 54 | if (!empty($author_image_url_meta)) { |
| 55 | $author_image_url = $author_image_url_meta; |
| 56 | } |
| 57 | |
| 58 | $social_profiles = get_term_meta($term->term_id, 'rswpbs_book_author_social_profiles', true); |
| 59 | $total_books = $term->count; |
| 60 | } else { |
| 61 | // Possibly in editor logic where get_queried_object might not return what we expect always. |
| 62 | // If inside Render block in editor, $term might be null or page. |
| 63 | // We can show placeholder data in editor. |
| 64 | } |
| 65 | |
| 66 | if (!is_tax('book-author')) { |
| 67 | return; |
| 68 | } |
| 69 | |
| 70 | ?> |
| 71 | |
| 72 | <section class="py-24 bg-paper <?php echo isset($attributes['className']) ? esc_attr($attributes['className']) : ''; ?>"> |
| 73 | <div class="awt-container px-10 mx-auto"> |
| 74 | <div class="grid grid-cols-1 lg:grid-cols-12 gap-12 lg:gap-20 items-start"> |
| 75 | |
| 76 | <div class="lg:col-span-5 relative"> |
| 77 | <div class="relative group"> |
| 78 | <div class="absolute top-4 -left-4 w-full h-full border-2 rounded-2xl z-0 transition-transform duration-500 group-hover:translate-x-2 group-hover:translate-y-2" style="border-color: <?php echo esc_attr($accentColor); ?>;"></div> |
| 79 | <div class="absolute -bottom-4 -right-4 w-full h-full bg-slate-50 rounded-2xl -z-10"></div> |
| 80 | |
| 81 | <img src="<?php echo esc_url($author_image_url); ?>" |
| 82 | alt="<?php echo esc_attr($author_name); ?>" |
| 83 | class="relative z-10 w-full aspect-[3/4] object-cover rounded-2xl shadow-xl grayscale group-hover:grayscale-0 transition duration-700"> |
| 84 | |
| 85 | <div class="absolute -bottom-6 -right-6 z-20 bg-white p-5 rounded-xl shadow-[0_8px_30px_rgb(0,0,0,0.12)] border-l-4" style="border-color: <?php echo esc_attr($accentColor); ?>;"> |
| 86 | <div class="flex items-center gap-3"> |
| 87 | <div class="p-2 rounded-full" style="color: <?php echo esc_attr($accentColor); ?>; background-color: <?php echo esc_attr($accent_bg_light); ?>;"> |
| 88 | <i class="fas fa-pen-nib"></i> |
| 89 | </div> |
| 90 | <div> |
| 91 | <p class="text-sm font-bold text-gray-400 uppercase tracking-widest text-[10px]">Total Books</p> |
| 92 | <p class="text-xl font-serif font-bold text-primary"><?php echo esc_html($total_books); ?>+ Published</p> |
| 93 | </div> |
| 94 | </div> |
| 95 | </div> |
| 96 | </div> |
| 97 | </div> |
| 98 | |
| 99 | <div class="lg:col-span-7 pt-4"> |
| 100 | <span class="font-bold text-xs uppercase tracking-widest mb-3 block" style="color: <?php echo esc_attr($accentColor); ?>;">Biography</span> |
| 101 | |
| 102 | <h2 class="text-4xl lg:text-5xl font-serif font-bold text-primary mb-6"><?php echo esc_html($author_name); ?></h2> |
| 103 | |
| 104 | <div class="prose prose-lg prose-slate text-secondary mb-10 leading-relaxed text-justify"> |
| 105 | <?php echo wp_kses_post($author_description); ?> |
| 106 | </div> |
| 107 | <?php if (!empty($social_profiles) && is_array($social_profiles)): ?> |
| 108 | <div class="border-t border-gray-100 pt-8"> |
| 109 | <h4 class="text-sm font-bold text-primary mb-4 uppercase tracking-widest">Connect with Author</h4> |
| 110 | <div class="flex flex-wrap gap-3"> |
| 111 | <?php foreach ($social_profiles as $profile): ?> |
| 112 | <?php |
| 113 | $link = isset($profile['profile_link']) ? $profile['profile_link'] : '#'; |
| 114 | $icon = isset($profile['website_icon']) ? $profile['website_icon'] : 'fas fa-link'; |
| 115 | $name = isset($profile['special_title']) ? $profile['special_title'] : 'Social'; // Assuming a title field or we can derive from icon/link |
| 116 | // If no title, we can guess or just show icon. |
| 117 | // Based on reference, we need a name. |
| 118 | // If the array structure is unknown, I'll assume standard from the other blocks? |
| 119 | // User said: "Key rswpbs_book_author_social_profiles (Returns serialized array with website_icon class and profile_link)." |
| 120 | // I'll guess name or just use 'Social'. |
| 121 | if (empty($name) || $name === 'Social') { |
| 122 | if (strpos($link, 'facebook') !== false) $name = 'Facebook'; |
| 123 | elseif (strpos($link, 'twitter') !== false) $name = 'Twitter'; |
| 124 | elseif (strpos($link, 'linkedin') !== false) $name = 'LinkedIn'; |
| 125 | elseif (strpos($link, 'instagram') !== false) $name = 'Instagram'; |
| 126 | else $name = 'Website'; |
| 127 | } |
| 128 | ?> |
| 129 | <a href="<?php echo esc_url($link); ?>" target="_blank" class="group flex items-center gap-3 px-5 py-3 bg-slate-50 border border-gray-100 rounded-lg hover:bg-white hover:shadow-md transition duration-300 hover:border-[<?php echo esc_attr($accentColor); ?>]" |
| 130 | onmouseover="this.style.borderColor='<?php echo esc_attr($accentColor); ?>'" |
| 131 | onmouseout="this.style.borderColor=''" |
| 132 | > |
| 133 | <i class="<?php echo esc_attr($icon); ?> text-lg text-gray-400 transition" |
| 134 | style="transition: color 0.3s;" |
| 135 | onmouseover="this.style.color='<?php echo esc_attr($accentColor); ?>'" |
| 136 | onmouseout="this.style.color=''" |
| 137 | ></i> |
| 138 | <span class="text-sm font-bold text-secondary group-hover:text-primary"><?php echo esc_html($name); ?></span> |
| 139 | </a> |
| 140 | <?php endforeach; ?> |
| 141 | </div> |
| 142 | </div> |
| 143 | <?php endif; ?> |
| 144 | </div> |
| 145 | </div> |
| 146 | </div> |
| 147 | </section> |
| 148 |