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 / footer / render.php
author-website-templates / build / blocks / author-pro / footer Last commit date
block.json 1 month ago index.asset.php 1 month ago index.js 1 month ago render.php 1 month ago
render.php
248 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'] : '';
41 $text_color = isset( $attributes['textColor'] ) ? $attributes['textColor'] : '';
42 $heading_color = isset( $attributes['headingColor'] ) ? $attributes['headingColor'] : '';
43 $accent_color = isset( $attributes['accentColor'] ) ? $attributes['accentColor'] : '';
44 $border_color = isset( $attributes['borderColor'] ) ? $attributes['borderColor'] : '';
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 if ( ! empty( $bg_color ) ) {
62 $style_vars .= "--awt-footer-bg: {$bg_color};";
63 }
64 if ( ! empty( $text_color ) ) {
65 $style_vars .= "--awt-text-color: {$text_color};";
66 }
67 if ( ! empty( $heading_color ) ) {
68 $style_vars .= "--awt-heading-color: {$heading_color};";
69 }
70 if ( ! empty( $accent_color ) ) {
71 $style_vars .= "--awt-accent-color: {$accent_color};";
72 }
73 if ( ! empty( $border_color ) ) {
74 $style_vars .= "--awt-border-color: {$border_color};";
75 }
76
77 // Wrapper parameters
78 $wrapper_attr = get_block_wrapper_attributes( array(
79 'class' => "bg-primary text-slate-400 pt-20 pb-10 border-t border-slate-800 awt-footer block-{$block_id}",
80 'id' => $element_id,
81 'style' => $style_vars,
82 ) );
83 ?>
84
85 <style>
86 .block-<?php echo esc_attr( $block_id ); ?>.awt-footer {
87 <?php if ( ! empty( $bg_color ) ) : ?>
88 background-color: var(--awt-footer-bg);
89 <?php endif; ?>
90 <?php if ( ! empty( $text_color ) ) : ?>
91 color: var(--awt-text-color);
92 <?php endif; ?>
93 <?php if ( ! empty( $border_color ) ) : ?>
94 border-color: var(--awt-border-color);
95 <?php endif; ?>
96 }
97 .block-<?php echo esc_attr( $block_id ); ?>.awt-footer h4,
98 .block-<?php echo esc_attr( $block_id ); ?>.awt-footer .logo-text {
99 <?php if ( ! empty( $heading_color ) ) : ?>
100 color: var(--awt-heading-color);
101 <?php endif; ?>
102 }
103 .block-<?php echo esc_attr( $block_id ); ?>.awt-footer a:hover,
104 .block-<?php echo esc_attr( $block_id ); ?>.awt-footer .social-icon:hover {
105 <?php if ( ! empty( $accent_color ) ) : ?>
106 color: var(--awt-accent-color);
107 <?php endif; ?>
108 }
109 .block-<?php echo esc_attr( $block_id ); ?>.awt-footer .social-icon:hover {
110 <?php if ( ! empty( $accent_color ) ) : ?>
111 background-color: var(--awt-accent-color);
112 color: #fff !important;
113 <?php endif; ?>
114 }
115 .block-<?php echo esc_attr( $block_id ); ?>.awt-footer .contact-icon {
116 <?php if ( ! empty( $accent_color ) ) : ?>
117 color: var(--awt-accent-color);
118 <?php endif; ?>
119 }
120 /* Logo Box default */
121 .block-<?php echo esc_attr( $block_id ); ?>.awt-footer .logo-box {
122 background-color: #fff;
123 <?php if ( ! empty( $bg_color ) ) : ?>
124 color: var(--awt-footer-bg); /* Primary */
125 <?php endif; ?>
126 }
127 .block-<?php echo esc_attr( $block_id ); ?>.awt-footer .awt-custom-icon {
128 object-fit: contain;
129 }
130 /* SVG Styling in Links/Icons */
131 .block-<?php echo esc_attr( $block_id ); ?>.awt-footer svg {
132 width: 1rem; /* w-4 */
133 height: 1rem; /* h-4 */
134 fill: currentColor;
135 }
136 </style>
137
138 <footer <?php echo $wrapper_attr; ?>>
139 <div class="awt-container">
140 <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-12 mb-16">
141 <!-- Col 1: Logo & Bio -->
142 <div>
143 <a href="<?php echo esc_url( home_url( '/' ) ); ?>" class="flex items-center gap-2 mb-6">
144 <?php if ( 'image' === $logo_type && $logo_image_url ) : ?>
145 <img src="<?php echo esc_url( $logo_image_url ); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name' ) ); ?>" class="max-h-12 w-auto" />
146 <?php elseif ( 'site_title' === $logo_type ) : ?>
147 <span class="text-xl font-serif font-bold text-white logo-text">
148 <?php echo esc_html( get_bloginfo( 'name' ) ); ?>
149 </span>
150 <?php else : ?>
151 <span class="w-8 h-8 bg-white text-primary rounded flex items-center justify-center font-bold font-serif logo-box">
152 <?php echo esc_html( substr( $logo_text, 0, 1 ) ); ?>
153 </span>
154 <span class="text-xl font-serif font-bold text-white logo-text">
155 <?php echo esc_html( $logo_text ); ?>
156 </span>
157 <?php endif; ?>
158 </a>
159 <p class="text-sm leading-relaxed mb-6">
160 <?php echo wp_kses_post( $description ); ?>
161 </p>
162 <div class="flex gap-4">
163 <?php if ( ! empty( $social_links ) && is_array( $social_links ) ) : ?>
164 <?php foreach ( $social_links as $link ) : ?>
165 <?php
166 $icon_url = isset( $link['iconUrl'] ) ? $link['iconUrl'] : '';
167 $svg_content = isset( $link['svgContent'] ) ? $link['svgContent'] : '';
168 $url = isset( $link['url'] ) ? $link['url'] : '#';
169 ?>
170 <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">
171 <?php if ( $icon_url ) : ?>
172 <img src="<?php echo esc_url( $icon_url ); ?>" alt="Social" class="awt-custom-icon w-4 h-4" />
173 <?php elseif ( ! empty( $svg_content ) ) : ?>
174 <span class="w-4 h-4 flex items-center justify-center"><?php echo $svg_content; ?></span>
175 <?php endif; ?>
176 </a>
177 <?php endforeach; ?>
178 <?php endif; ?>
179 </div>
180 </div>
181
182 <!-- Col 2: Quick Links -->
183 <div>
184 <h4 class="text-white font-bold text-sm uppercase tracking-widest mb-6"><?php echo esc_html( $col2_title ); ?></h4>
185 <ul class="space-y-3 text-sm list-none pl-0">
186 <?php if ( ! empty( $menu2_items ) && is_array( $menu2_items ) ) : ?>
187 <?php foreach ( $menu2_items as $item ) : ?>
188 <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>
189 <?php endforeach; ?>
190 <?php else : ?>
191 <li class="italic opacity-50">Select a menu in block settings.</li>
192 <?php endif; ?>
193 </ul>
194 </div>
195
196 <!-- Col 3: Resources -->
197 <div>
198 <h4 class="text-white font-bold text-sm uppercase tracking-widest mb-6"><?php echo esc_html( $col3_title ); ?></h4>
199 <ul class="space-y-3 text-sm list-none pl-0">
200 <?php if ( ! empty( $menu3_items ) && is_array( $menu3_items ) ) : ?>
201 <?php foreach ( $menu3_items as $item ) : ?>
202 <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>
203 <?php endforeach; ?>
204 <?php else : ?>
205 <li class="italic opacity-50">Select a menu in block settings.</li>
206 <?php endif; ?>
207 </ul>
208 </div>
209
210 <!-- Col 4: Contact Info -->
211 <div>
212 <h4 class="text-white font-bold text-sm uppercase tracking-widest mb-6"><?php echo esc_html( $col4_title ); ?></h4>
213 <ul class="space-y-4 text-sm list-none pl-0">
214 <?php if ( ! empty( $contact_details ) && is_array( $contact_details ) ) : ?>
215 <?php foreach ( $contact_details as $detail ) : ?>
216 <?php
217 $icon_url = isset( $detail['iconUrl'] ) ? $detail['iconUrl'] : '';
218 $svg_content = isset( $detail['svgContent'] ) ? $detail['svgContent'] : '';
219 $text = isset( $detail['text'] ) ? $detail['text'] : '';
220 ?>
221 <li class="flex items-start gap-3">
222 <?php if ( $icon_url ) : ?>
223 <img src="<?php echo esc_url( $icon_url ); ?>" alt="Icon" class="awt-custom-icon w-4 h-4 mt-1" />
224 <?php elseif ( ! empty( $svg_content ) ) : ?>
225 <span class="contact-icon mt-1 text-accent flex items-center justify-center w-4 h-4"><?php echo $svg_content; ?></span>
226 <?php endif; ?>
227 <span><?php echo wp_kses_post( $text ); ?></span>
228 </li>
229 <?php endforeach; ?>
230 <?php endif; ?>
231 </ul>
232 </div>
233 </div>
234
235 <!-- Bottom Area -->
236 <div class="border-t border-slate-800 pt-8 flex flex-col md:flex-row justify-between items-center text-xs text-slate-500">
237 <p><?php echo wp_kses_post( $copyright_text ); ?></p>
238 <div class="flex gap-6 mt-4 md:mt-0 flex-wrap">
239 <?php if ( ! empty( $bottom_items ) && is_array( $bottom_items ) ) : ?>
240 <?php foreach ( $bottom_items as $item ) : ?>
241 <a href="<?php echo esc_url( $item->url ); ?>" class="hover:text-white text-slate-400 transition"><?php echo esc_html( $item->title ); ?></a>
242 <?php endforeach; ?>
243 <?php endif; ?>
244 </div>
245 </div>
246 </div>
247 </footer>
248