2023-01-21 01:31:34 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Template Part: Header
|
|
|
|
*
|
|
|
|
* Starts the document. The HTML root <html> is used to store default settings and
|
|
|
|
* configuration classes since it is the only node available at the beginning.
|
|
|
|
* This is necessary for the light/dark switch and site settings to work without
|
|
|
|
* causing color flickering or layout shifts.
|
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Fictioneer
|
|
|
|
* @since 3.0
|
|
|
|
* @see wp_head()
|
|
|
|
* @see wp_body_open()
|
|
|
|
* @see fictioneer_output_head_meta()
|
|
|
|
* @see fictioneer_output_head_critical_scripts()
|
|
|
|
*
|
2023-08-20 01:04:49 +02:00
|
|
|
* @internal $args Array of arguments passed to the template.
|
2023-01-21 01:31:34 +01:00
|
|
|
*/
|
|
|
|
|
2023-08-03 17:02:46 +02:00
|
|
|
|
2023-08-27 22:03:18 +02:00
|
|
|
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
|
|
|
|
global $fictioneer_render_start_time;
|
|
|
|
$fictioneer_render_start_time = microtime( true );
|
|
|
|
}
|
|
|
|
|
2024-05-17 10:42:44 +02:00
|
|
|
// IDs
|
2023-08-03 17:02:46 +02:00
|
|
|
global $post;
|
|
|
|
|
2023-08-04 00:54:41 +02:00
|
|
|
$page_id = get_queried_object_id();
|
2023-08-03 19:55:33 +02:00
|
|
|
$post_id = $post ? $post->ID : null;
|
2023-08-03 17:02:46 +02:00
|
|
|
|
2023-08-04 00:54:41 +02:00
|
|
|
if ( $page_id != $post_id ) {
|
|
|
|
$post_id = $page_id;
|
|
|
|
}
|
|
|
|
|
2024-05-16 20:35:05 +02:00
|
|
|
if ( is_archive() || is_search() || is_404() || FICTIONEER_MU_REGISTRATION ) {
|
2023-08-03 19:55:33 +02:00
|
|
|
$post_id = null;
|
2023-08-03 17:02:46 +02:00
|
|
|
}
|
|
|
|
|
2024-05-17 10:32:48 +02:00
|
|
|
// Prevent indexing if required
|
|
|
|
if ( ( $args['no_index'] ?? 0 ) || FICTIONEER_MU_REGISTRATION ) {
|
|
|
|
add_filter( 'wp_robots', 'wp_robots_no_robots' );
|
|
|
|
}
|
|
|
|
|
2023-08-03 17:02:46 +02:00
|
|
|
?>
|
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
<!doctype html>
|
|
|
|
|
|
|
|
<html <?php language_attributes(); ?> <?php fictioneer_root_attributes(); ?>>
|
|
|
|
|
2024-05-17 10:42:44 +02:00
|
|
|
<head><?php wp_head(); ?></head>
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2023-11-24 00:44:08 +01:00
|
|
|
<body <?php body_class( 'site-bg scrolled-to-top' ); ?> data-post-id="<?php echo $post_id ?: -1; ?>">
|
2023-01-21 01:31:34 +01:00
|
|
|
<?php wp_body_open(); ?>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
// Setup
|
|
|
|
$story_id = null;
|
|
|
|
$header_image_url = get_header_image();
|
|
|
|
|
|
|
|
// If this is a content page...
|
2023-08-03 19:55:33 +02:00
|
|
|
if ( ! empty( $post_id ) ) {
|
2023-01-21 01:31:34 +01:00
|
|
|
// Type?
|
|
|
|
switch ( $post->post_type ) {
|
|
|
|
case 'fcn_story':
|
|
|
|
$story_id = $post_id;
|
|
|
|
break;
|
|
|
|
case 'fcn_chapter':
|
2023-11-30 16:03:53 +01:00
|
|
|
$story_id = get_post_meta( get_the_ID(), 'fictioneer_chapter_story', true );
|
2023-01-21 01:31:34 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Custom header image?
|
2023-11-30 16:03:53 +01:00
|
|
|
if ( get_post_meta( $post_id, 'fictioneer_custom_header_image', true ) ) {
|
|
|
|
$header_image_url = get_post_meta( $post_id, 'fictioneer_custom_header_image', true );
|
2023-01-21 01:31:34 +01:00
|
|
|
$header_image_url = wp_get_attachment_image_url( $header_image_url, 'full' );
|
2023-11-30 16:03:53 +01:00
|
|
|
} elseif ( ! empty( $story_id ) && get_post_meta( $story_id, 'fictioneer_custom_header_image', true ) ) {
|
|
|
|
$header_image_url = get_post_meta( $story_id, 'fictioneer_custom_header_image', true );
|
2023-01-21 01:31:34 +01:00
|
|
|
$header_image_url = wp_get_attachment_image_url( $header_image_url, 'full' );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Filter header image
|
2023-08-03 19:55:33 +02:00
|
|
|
if ( ! empty( $post_id ) && $header_image_url ) {
|
2023-01-21 01:31:34 +01:00
|
|
|
$header_image_url = apply_filters( 'fictioneer_filter_header_image', $header_image_url, $post_id );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Action arguments
|
|
|
|
$action_args = array(
|
|
|
|
'post_id' => $post_id,
|
|
|
|
'story_id' => $story_id,
|
|
|
|
'header_image_url' => $header_image_url,
|
2024-05-16 19:37:12 +02:00
|
|
|
'header_args' => $args ?? []
|
2023-01-21 01:31:34 +01:00
|
|
|
);
|
|
|
|
|
2023-06-08 21:30:25 +02:00
|
|
|
// Includes mobile menu
|
2023-01-21 01:31:34 +01:00
|
|
|
do_action( 'fictioneer_body', $action_args );
|
|
|
|
|
|
|
|
// Inline storage tuples
|
|
|
|
$inline_storage = array(
|
|
|
|
'permalink' => ['data-permalink', esc_url( get_permalink() )],
|
|
|
|
'homelink' => ['data-homelink', esc_url( home_url() )],
|
|
|
|
'post_id' => ['data-post-id', $post_id],
|
|
|
|
'story_id' => ['data-story-id', $story_id]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Filter inline storage
|
|
|
|
$inline_storage = apply_filters( 'fictioneer_filter_inline_storage', $inline_storage );
|
|
|
|
|
|
|
|
// Prepare inline storage attributes
|
|
|
|
$inline_storage = array_map(
|
|
|
|
function ( $node ) {
|
|
|
|
return $node[0] . '="' . $node[1] . '"';
|
|
|
|
},
|
|
|
|
$inline_storage
|
|
|
|
);
|
|
|
|
?>
|
|
|
|
|
|
|
|
<div id="inline-storage" <?php echo implode( ' ', $inline_storage ); ?> hidden></div>
|
|
|
|
|
|
|
|
<div id="notifications" class="notifications"></div>
|
|
|
|
|
|
|
|
<div id="site" class="site background-texture">
|
|
|
|
|
|
|
|
<?php
|
|
|
|
// Includes header background, navigation bar, and site header (with title, logo, etc.)
|
|
|
|
do_action( 'fictioneer_site', $action_args );
|
|
|
|
?>
|