render.php
113 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Render template for Child Author Page Title block |
| 4 | * |
| 5 | * @package Author_Website_Templates |
| 6 | */ |
| 7 | |
| 8 | // If direct access, exit |
| 9 | if (!defined('ABSPATH')) { |
| 10 | exit; |
| 11 | } |
| 12 | |
| 13 | // Attributes with defaults |
| 14 | $titleStyle = isset($attributes['titleStyle']) ? $attributes['titleStyle'] : 'fun'; |
| 15 | $badgeText = isset($attributes['badgeText']) ? $attributes['badgeText'] : 'Biography'; |
| 16 | $heading = isset($attributes['heading']) ? $attributes['heading'] : 'So Nice to Meet You!'; |
| 17 | $subHeading = isset($attributes['subHeading']) ? $attributes['subHeading'] : 'I\'m Danielle Steel, a writer of silly stories and a lover of big adventures.'; |
| 18 | $sectionBgColor = isset($attributes['sectionBgColor']) ? $attributes['sectionBgColor'] : ''; |
| 19 | $curveColor = isset($attributes['curveColor']) ? $attributes['curveColor'] : '#FFFDF5'; |
| 20 | $headingColor = isset($attributes['headingColor']) ? $attributes['headingColor'] : ''; |
| 21 | $textColor = isset($attributes['textColor']) ? $attributes['textColor'] : ''; |
| 22 | $blockId = isset($attributes['blockId']) ? $attributes['blockId'] : ''; |
| 23 | |
| 24 | // Render Dynamic Content based on context |
| 25 | if (is_archive()) { |
| 26 | $heading = get_the_archive_title(); |
| 27 | $subHeading = get_the_archive_description(); |
| 28 | } elseif (is_search()) { |
| 29 | $heading = sprintf('Search Results for: %s', get_search_query()); |
| 30 | $subHeading = ''; |
| 31 | } elseif (is_404()) { |
| 32 | $heading = __('Page Not Found', 'author-website-templates'); |
| 33 | $subHeading = __('It looks like nothing was found at this location.', 'author-website-templates'); |
| 34 | } elseif (is_home() && !is_front_page()) { |
| 35 | $heading = single_post_title('', false); |
| 36 | $subHeading = ''; |
| 37 | } |
| 38 | |
| 39 | // Set default background color based on style if not explicitly set |
| 40 | if (empty($sectionBgColor)) { |
| 41 | $sectionBgColor = ($titleStyle === 'elegant') ? '#f8fafc' : 'rgba(0, 198, 255, 0.1)'; |
| 42 | } |
| 43 | |
| 44 | // Classes |
| 45 | $container_class = 'alignfull relative overflow-hidden pt-20 pb-28'; |
| 46 | if (!empty($blockId)) { |
| 47 | $container_class .= ' block-' . esc_attr($blockId); |
| 48 | } |
| 49 | |
| 50 | // Heading Classes |
| 51 | if ($titleStyle === 'elegant') { |
| 52 | $heading_class = 'text-5xl md:text-7xl font-serif font-bold mb-6'; |
| 53 | if (empty($headingColor)) { |
| 54 | $heading_class .= ' text-brand-dark'; |
| 55 | } |
| 56 | } else { |
| 57 | // Fun (default) |
| 58 | $heading_class = 'text-5xl md:text-7xl font-black mb-4'; |
| 59 | if (empty($headingColor)) { |
| 60 | $heading_class .= ' text-navy'; |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | // Subheading Classes |
| 65 | if ($titleStyle === 'elegant') { |
| 66 | $sub_heading_class = 'text-xl max-w-2xl mx-auto font-light leading-relaxed'; |
| 67 | if (empty($textColor)) { |
| 68 | $sub_heading_class .= ' text-brand-gray'; |
| 69 | } |
| 70 | } else { |
| 71 | // Fun (default) |
| 72 | $sub_heading_class = 'text-xl max-w-lg mx-auto'; |
| 73 | if (empty($textColor)) { |
| 74 | $sub_heading_class .= ' text-navy/80'; |
| 75 | } |
| 76 | } |
| 77 | ?> |
| 78 | |
| 79 | <section class="<?php echo esc_attr($container_class); ?>" |
| 80 | style="background-color: <?php echo esc_attr($sectionBgColor); ?>;"> |
| 81 | |
| 82 | <!-- Bottom SVG Wave - Only for Fun Style --> |
| 83 | <?php if ($titleStyle !== 'elegant'): ?> |
| 84 | <div class="absolute bottom-0 left-0 w-full"> |
| 85 | <svg viewBox="0 0 1440 100" fill="none" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" |
| 86 | class="w-full h-auto"> |
| 87 | <path d="M0 100H1440V0C1192.5 49.497 919.5 74.497 720 74.497C520.5 74.497 247.5 49.497 0 0V100Z" |
| 88 | fill="<?php echo esc_attr($curveColor); ?>" /> |
| 89 | </svg> |
| 90 | </div> |
| 91 | <?php endif; ?> |
| 92 | |
| 93 | <div class="awt-container mx-auto px-6 relative z-10 text-center"> |
| 94 | <!-- Badge - Only for Elegant Style --> |
| 95 | <?php if ($titleStyle === 'elegant' && !empty($badgeText)): ?> |
| 96 | <span class="font-bold text-gray-500 uppercase tracking-widest text-xs mb-4 block"> |
| 97 | <?php echo esc_html($badgeText); ?> |
| 98 | </span> |
| 99 | <?php endif; ?> |
| 100 | |
| 101 | <?php if (!empty($heading)): ?> |
| 102 | <h1 class="<?php echo esc_attr($heading_class); ?>" <?php echo !empty($headingColor) ? 'style="color: ' . esc_attr($headingColor) . ';"' : ''; ?>> |
| 103 | <?php echo wp_kses_post($heading); ?> |
| 104 | </h1> |
| 105 | <?php endif; ?> |
| 106 | |
| 107 | <?php if (!empty($subHeading)): ?> |
| 108 | <p class="<?php echo esc_attr($sub_heading_class); ?>" <?php echo !empty($textColor) ? 'style="color: ' . esc_attr($textColor) . ';"' : ''; ?>> |
| 109 | <?php echo wp_kses_post($subHeading); ?> |
| 110 | </p> |
| 111 | <?php endif; ?> |
| 112 | </div> |
| 113 | </section> |