PluginProbe ʕ •ᴥ•ʔ
Author Website Templates – Create Writer, Author & Publisher Websites Easily / 1.1.5
Author Website Templates – Create Writer, Author & Publisher Websites Easily v1.1.5
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 / footer / render.php
author-website-templates / build / blocks / author-pro / footer Last commit date
block.json 5 months ago index.asset.php 5 months ago index.js 5 months ago render.php 5 months ago
render.php
223 lines
1 <?php
2 /**
3 * Author Pro Footer Block Template.
4 *
5 * @param array $attributes - Block attributes.
6 * @param string $content - Block content.
7 * @param WP_Block $block - Block object.
8 */
9
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit;
12 }
13
14 // Attributes
15 $block_id = isset( $attributes['blockId'] ) ? $attributes['blockId'] : 'footer-' . uniqid();
16 $anchor = isset( $attributes['anchor'] ) ? $attributes['anchor'] : '';
17 $element_id = ! empty( $anchor ) ? $anchor : $block_id;
18
19 $logo_type = isset( $attributes['logoType'] ) ? $attributes['logoType'] : 'custom';
20 $logo_text = isset( $attributes['logoText'] ) ? $attributes['logoText'] : 'AuthorPro.';
21 $logo_image_url = isset( $attributes['logoImageUrl'] ) ? $attributes['logoImageUrl'] : '';
22 $description = isset( $attributes['description'] ) ? $attributes['description'] : '';
23 // Safe array handling
24 $social_links = ( isset( $attributes['socialLinks'] ) && is_array( $attributes['socialLinks'] ) ) ? $attributes['socialLinks'] : array();
25
26 $col2_title = isset( $attributes['col2Title'] ) ? $attributes['col2Title'] : 'Quick Links';
27 $menu2_slug = isset( $attributes['menu2Slug'] ) ? $attributes['menu2Slug'] : '';
28
29 $col3_title = isset( $attributes['col3Title'] ) ? $attributes['col3Title'] : 'Resources';
30 $menu3_slug = isset( $attributes['menu3Slug'] ) ? $attributes['menu3Slug'] : '';
31
32 $col4_title = isset( $attributes['col4Title'] ) ? $attributes['col4Title'] : 'Contact Info';
33 // Safe array handling
34 $contact_details = ( isset( $attributes['contactDetails'] ) && is_array( $attributes['contactDetails'] ) ) ? $attributes['contactDetails'] : array();
35
36 $copyright_text = isset( $attributes['copyrightText'] ) ? $attributes['copyrightText'] : '';
37 $bottom_menu_slug = isset( $attributes['bottomMenuSlug'] ) ? $attributes['bottomMenuSlug'] : '';
38
39 // Colors
40 $bg_color = isset( $attributes['footerBgColor'] ) ? $attributes['footerBgColor'] : '#0f172a';
41 $text_color = isset( $attributes['textColor'] ) ? $attributes['textColor'] : '#94a3b8';
42 $heading_color = isset( $attributes['headingColor'] ) ? $attributes['headingColor'] : '#ffffff';
43 $accent_color = isset( $attributes['accentColor'] ) ? $attributes['accentColor'] : '#ea580c';
44 $border_color = isset( $attributes['borderColor'] ) ? $attributes['borderColor'] : '#1e293b';
45
46 // Helper to get menu links safely
47 $get_menu_links = function( $slug ) {
48 if ( ! $slug ) {
49 return array();
50 }
51 $items = wp_get_nav_menu_items( $slug );
52 return ( $items && is_array( $items ) ) ? $items : array();
53 };
54
55 $menu2_items = $get_menu_links( $menu2_slug );
56 $menu3_items = $get_menu_links( $menu3_slug );
57 $bottom_items = $get_menu_links( $bottom_menu_slug );
58
59 // CSS Variables
60 $style_vars = "
61 --awt-footer-bg: {$bg_color};
62 --awt-text-color: {$text_color};
63 --awt-heading-color: {$heading_color};
64 --awt-accent-color: {$accent_color};
65 --awt-border-color: {$border_color};
66 ";
67
68 // Wrapper parameters
69 $wrapper_attr = get_block_wrapper_attributes( array(
70 'class' => "bg-primary text-slate-400 pt-20 pb-10 border-t border-slate-800 awt-footer block-{$block_id}",
71 'id' => $element_id,
72 'style' => $style_vars,
73 ) );
74 ?>
75
76 <style>
77 .block-<?php echo esc_attr( $block_id ); ?>.awt-footer {
78 background-color: var(--awt-footer-bg);
79 color: var(--awt-text-color);
80 border-color: var(--awt-border-color);
81 }
82 .block-<?php echo esc_attr( $block_id ); ?>.awt-footer h4,
83 .block-<?php echo esc_attr( $block_id ); ?>.awt-footer .logo-text {
84 color: var(--awt-heading-color);
85 }
86 .block-<?php echo esc_attr( $block_id ); ?>.awt-footer a:hover,
87 .block-<?php echo esc_attr( $block_id ); ?>.awt-footer .social-icon:hover {
88 color: var(--awt-accent-color);
89 }
90 .block-<?php echo esc_attr( $block_id ); ?>.awt-footer .social-icon:hover {
91 background-color: var(--awt-accent-color);
92 color: #fff !important;
93 }
94 .block-<?php echo esc_attr( $block_id ); ?>.awt-footer .contact-icon {
95 color: var(--awt-accent-color);
96 }
97 /* Logo Box default */
98 .block-<?php echo esc_attr( $block_id ); ?>.awt-footer .logo-box {
99 background-color: #fff;
100 color: var(--awt-footer-bg); /* Primary */
101 }
102 .block-<?php echo esc_attr( $block_id ); ?>.awt-footer .awt-custom-icon {
103 object-fit: contain;
104 }
105 /* SVG Styling in Links/Icons */
106 .block-<?php echo esc_attr( $block_id ); ?>.awt-footer svg {
107 width: 1rem; /* w-4 */
108 height: 1rem; /* h-4 */
109 fill: currentColor;
110 }
111 </style>
112
113 <footer <?php echo $wrapper_attr; ?>>
114 <div class="awt-container">
115 <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-12 mb-16">
116 <!-- Col 1: Logo & Bio -->
117 <div>
118 <a href="<?php echo esc_url( home_url( '/' ) ); ?>" class="flex items-center gap-2 mb-6">
119 <?php if ( 'image' === $logo_type && $logo_image_url ) : ?>
120 <img src="<?php echo esc_url( $logo_image_url ); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name' ) ); ?>" class="max-h-12 w-auto" />
121 <?php elseif ( 'site_title' === $logo_type ) : ?>
122 <span class="text-xl font-serif font-bold text-white logo-text">
123 <?php echo esc_html( get_bloginfo( 'name' ) ); ?>
124 </span>
125 <?php else : ?>
126 <span class="w-8 h-8 bg-white text-primary rounded flex items-center justify-center font-bold font-serif logo-box">
127 <?php echo esc_html( substr( $logo_text, 0, 1 ) ); ?>
128 </span>
129 <span class="text-xl font-serif font-bold text-white logo-text">
130 <?php echo esc_html( $logo_text ); ?>
131 </span>
132 <?php endif; ?>
133 </a>
134 <p class="text-sm leading-relaxed mb-6">
135 <?php echo wp_kses_post( $description ); ?>
136 </p>
137 <div class="flex gap-4">
138 <?php if ( ! empty( $social_links ) && is_array( $social_links ) ) : ?>
139 <?php foreach ( $social_links as $link ) : ?>
140 <?php
141 $icon_url = isset( $link['iconUrl'] ) ? $link['iconUrl'] : '';
142 $svg_content = isset( $link['svgContent'] ) ? $link['svgContent'] : '';
143 $url = isset( $link['url'] ) ? $link['url'] : '#';
144 ?>
145 <a href="<?php echo esc_url( $url ); ?>" class="w-8 h-8 bg-slate-800 rounded flex items-center justify-center text-slate-400 hover:bg-accent hover:text-white transition">
146 <?php if ( $icon_url ) : ?>
147 <img src="<?php echo esc_url( $icon_url ); ?>" alt="Social" class="awt-custom-icon w-4 h-4" />
148 <?php elseif ( ! empty( $svg_content ) ) : ?>
149 <span class="w-4 h-4 flex items-center justify-center"><?php echo $svg_content; ?></span>
150 <?php endif; ?>
151 </a>
152 <?php endforeach; ?>
153 <?php endif; ?>
154 </div>
155 </div>
156
157 <!-- Col 2: Quick Links -->
158 <div>
159 <h4 class="text-white font-bold text-sm uppercase tracking-widest mb-6"><?php echo esc_html( $col2_title ); ?></h4>
160 <ul class="space-y-3 text-sm list-none pl-0">
161 <?php if ( ! empty( $menu2_items ) && is_array( $menu2_items ) ) : ?>
162 <?php foreach ( $menu2_items as $item ) : ?>
163 <li><a href="<?php echo esc_url( $item->url ); ?>" class="hover:text-accent text-slate-400 transition"><?php echo esc_html( $item->title ); ?></a></li>
164 <?php endforeach; ?>
165 <?php else : ?>
166 <li class="italic opacity-50">Select a menu in block settings.</li>
167 <?php endif; ?>
168 </ul>
169 </div>
170
171 <!-- Col 3: Resources -->
172 <div>
173 <h4 class="text-white font-bold text-sm uppercase tracking-widest mb-6"><?php echo esc_html( $col3_title ); ?></h4>
174 <ul class="space-y-3 text-sm list-none pl-0">
175 <?php if ( ! empty( $menu3_items ) && is_array( $menu3_items ) ) : ?>
176 <?php foreach ( $menu3_items as $item ) : ?>
177 <li><a href="<?php echo esc_url( $item->url ); ?>" class="hover:text-accent text-slate-400 transition"><?php echo esc_html( $item->title ); ?></a></li>
178 <?php endforeach; ?>
179 <?php else : ?>
180 <li class="italic opacity-50">Select a menu in block settings.</li>
181 <?php endif; ?>
182 </ul>
183 </div>
184
185 <!-- Col 4: Contact Info -->
186 <div>
187 <h4 class="text-white font-bold text-sm uppercase tracking-widest mb-6"><?php echo esc_html( $col4_title ); ?></h4>
188 <ul class="space-y-4 text-sm list-none pl-0">
189 <?php if ( ! empty( $contact_details ) && is_array( $contact_details ) ) : ?>
190 <?php foreach ( $contact_details as $detail ) : ?>
191 <?php
192 $icon_url = isset( $detail['iconUrl'] ) ? $detail['iconUrl'] : '';
193 $svg_content = isset( $detail['svgContent'] ) ? $detail['svgContent'] : '';
194 $text = isset( $detail['text'] ) ? $detail['text'] : '';
195 ?>
196 <li class="flex items-start gap-3">
197 <?php if ( $icon_url ) : ?>
198 <img src="<?php echo esc_url( $icon_url ); ?>" alt="Icon" class="awt-custom-icon w-4 h-4 mt-1" />
199 <?php elseif ( ! empty( $svg_content ) ) : ?>
200 <span class="contact-icon mt-1 text-accent flex items-center justify-center w-4 h-4"><?php echo $svg_content; ?></span>
201 <?php endif; ?>
202 <span><?php echo wp_kses_post( $text ); ?></span>
203 </li>
204 <?php endforeach; ?>
205 <?php endif; ?>
206 </ul>
207 </div>
208 </div>
209
210 <!-- Bottom Area -->
211 <div class="border-t border-slate-800 pt-8 flex flex-col md:flex-row justify-between items-center text-xs text-slate-500">
212 <p><?php echo wp_kses_post( $copyright_text ); ?></p>
213 <div class="flex gap-6 mt-4 md:mt-0 flex-wrap">
214 <?php if ( ! empty( $bottom_items ) && is_array( $bottom_items ) ) : ?>
215 <?php foreach ( $bottom_items as $item ) : ?>
216 <a href="<?php echo esc_url( $item->url ); ?>" class="hover:text-white text-slate-400 transition"><?php echo esc_html( $item->title ); ?></a>
217 <?php endforeach; ?>
218 <?php endif; ?>
219 </div>
220 </div>
221 </div>
222 </footer>
223