fictioneer/footer.php

105 lines
3.2 KiB
PHP
Raw Normal View History

2023-01-21 01:31:34 +01:00
<?php
/**
* Template Part: Footer
*
* Closes the site container and includes the breadcrumbs, footer menu, cookie
* consent banner, TTS interface, application wide icons, and HTML footer.
*
* @package WordPress
* @subpackage Fictioneer
* @since 3.0
* @see fictioneer_get_breadcrumbs()
* @see fictioneer_get_footer_copyright_note()
* @see partials/_tts-interface.php
* @see partials/_consent-banner.php
* @see wp_footer()
*
2023-08-20 01:04:49 +02:00
* @internal $args['post_id'] Optional. Current post ID.
* @internal $args['post_type'] Optional. Current post type.
* @internal $args['breadcrumbs'] Array of breadcrumb tuples with label (0) and link (1).
2023-01-21 01:31:34 +01:00
*/
2023-08-03 20:29:19 +02:00
// Setup
2023-08-04 00:54:41 +02:00
$page_id = get_queried_object_id();
$extra_classes = [];
2023-08-04 00:54:41 +02:00
2024-05-16 14:27:37 +02:00
// Catch calls without arguments
$args['post_id'] = $args['post_id'] ?? $page_id;
$args['post_type'] = $args['post_type'] ?? 'none';
$args['breadcrumbs'] = $args['breadcrumbs'] ?? [];
// Fix wrong post ID
2023-08-04 00:54:41 +02:00
if ( $page_id != $args['post_id'] ) {
$args['post_id'] = $page_id;
}
2023-08-03 20:29:19 +02:00
// Null post ID for generated pages
if ( is_archive() || is_search() || is_404() ) {
$args['post_id'] = null;
}
// Extra classes
if ( get_theme_mod( 'footer_style' ) === 'isolated' ) {
$extra_classes[] = '_footer-isolated';
}
2023-08-03 20:29:19 +02:00
// Hook after #main closes
do_action( 'fictioneer_after_main', $args );
?>
2023-01-21 01:31:34 +01:00
2024-06-11 21:34:36 +02:00
<?php if ( ! ( $args['blank'] ?? 0 ) ) :
if ( ! function_exists( 'elementor_theme_do_location' ) || ! elementor_theme_do_location( 'footer' ) ) :
?>
<footer class="footer layout-links <?php echo implode( ' ', $extra_classes ); ?>">
<div class="footer__wrapper">
<?php do_action( 'fictioneer_site_footer', $args ); ?>
</div>
</footer>
<?php endif; endif; ?>
2023-08-03 20:29:19 +02:00
</div> <!-- #site -->
2023-01-21 01:31:34 +01:00
<?php
// Render TTS interface if required
if (
! empty( $args['post_id'] ) &&
$args['post_type'] == 'fcn_chapter' &&
2023-01-21 01:31:34 +01:00
! post_password_required()
) {
2024-05-19 14:30:44 +02:00
fictioneer_get_cached_partial( 'partials/_tts-interface' );
2023-01-21 01:31:34 +01:00
}
// Render cookie banner HTML if required
if ( get_option( 'fictioneer_cookie_banner' ) ) {
2024-05-19 14:30:44 +02:00
fictioneer_get_cached_partial( 'partials/_consent-banner' );
}
2023-01-21 01:31:34 +01:00
?>
<?php /* Adding the AJAX nonce this way allows caching plugins to update it dynamically. */ ?>
<input id="general-fictioneer-nonce" name="fictioneer_nonce" type="hidden" value="<?php echo wp_create_nonce( 'fictioneer_nonce' ); ?>">
2023-01-21 01:31:34 +01:00
<?php
// Lightbox container
if ( get_option( 'fictioneer_enable_lightbox' ) ) {
2023-09-18 10:02:51 +02:00
echo '<div id="fictioneer-lightbox" class="lightbox"><button type="button" class="lightbox__close" aria-label="' . esc_attr__( 'Close lightbox', 'fictioneer' ) . '">' . fictioneer_get_icon( 'fa-xmark' ) . '</button><i class="fa-solid fa-spinner fa-spin loader" style="--fa-animation-duration: .8s;"></i><div class="lightbox__content"></div></div>';
2023-01-21 01:31:34 +01:00
}
// Fictioneer footer hook
do_action( 'fictioneer_footer', $args );
// WordPress footer hook (includes modals)
2023-01-21 01:31:34 +01:00
wp_footer();
?>
</body>
</html>
<?php
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
global $fictioneer_render_start_time;
echo '<!-- Render Time: ' . number_format( microtime( true ) - $fictioneer_render_start_time, 4 ) . ' seconds. -->';
}
?>