fictioneer/partials/_story-header.php

94 lines
2.6 KiB
PHP
Raw Normal View History

2023-01-21 01:31:34 +01:00
<?php
/**
* Partial: Story Header
*
* Rendered in the single-fcn_story.php template right after opening
* the <article> block.
*
* @package WordPress
* @subpackage Fictioneer
* @since 5.0.0
* @since 5.20.0 - Added Elementor support.
2023-01-21 01:31:34 +01:00
* @see single-fcn_story.php
*
2023-08-19 22:22:56 +02:00
* @internal $args['story_data'] Story data from fictioneer_get_story_data().
* @internal $args['story_id'] Current story and post ID.
2024-05-09 22:48:24 +02:00
* @internal $args['context'] Render context. Default null.
2023-01-21 01:31:34 +01:00
*/
// No direct access!
defined( 'ABSPATH' ) OR exit;
// Elementor?
if ( function_exists( 'elementor_theme_do_location' ) && elementor_theme_do_location( 'story_header' ) ) {
return;
}
2023-01-21 01:31:34 +01:00
// Setup
$story = $args['story_data'];
$story_id = $args['story_id'];
2024-05-09 23:42:51 +02:00
$post = get_post( $story_id );
2024-05-09 22:48:24 +02:00
$thumbnail_shown = has_post_thumbnail( $story_id ) &&
! get_post_meta( $story_id, 'fictioneer_story_no_thumbnail', true ) &&
get_theme_mod( 'story_cover_position', 'top-left-overflow' ) === 'top-left-overflow';
$tax_shown = ! get_option( 'fictioneer_hide_taxonomies_on_pages' ) &&
$story['has_taxonomies'] &&
! get_post_meta( $story_id, 'fictioneer_story_no_tags', true );
2023-01-21 01:31:34 +01:00
// Story header classes
$header_classes = ['story__header'];
if ( ! $tax_shown ) {
$header_classes[] = '_no-tax';
}
2023-01-21 01:31:34 +01:00
if ( ! $thumbnail_shown ) {
$header_classes[] = '_no-thumbnail';
$header_classes[] = 'padding-top';
}
2024-05-09 22:48:24 +02:00
if ( ( $args['context'] ?? 0 ) !== 'shortcode' ) {
$header_classes[] = 'padding-left';
$header_classes[] = 'padding-right';
}
// Filter classes
$header_classes = apply_filters( 'fictioneer_filter_story_header_classes', $header_classes, $args );
2023-01-21 01:31:34 +01:00
?>
<header class="<?php echo implode( ' ', $header_classes ); ?>">
2023-01-21 01:31:34 +01:00
<?php if ( $thumbnail_shown ) echo fictioneer_get_story_page_cover( $story ); ?>
<?php if ( $tax_shown ) : ?>
<div class="story__taxonomies tag-group"><?php
echo fictioneer_get_taxonomy_pills(
array(
'fandoms' => $story['fandoms'],
'genres' => $story['genres'],
'characters' => $story['characters']
2023-11-30 20:53:35 +01:00
),
'story_header'
);
2023-01-21 01:31:34 +01:00
?></div>
<div class="story__taxonomies-space"></div>
<?php endif; ?>
<div class="story__identity"><?php
$identity = [];
$identity['title'] = '<h1 class="story__identity-title">' . $story['title'] . '</h1>';
$identity['meta'] = '<div class="story__identity-meta">' . sprintf(
_x( 'by %s', 'Story page: by {Author(s)}', 'fictioneer' ),
fictioneer_get_story_author_nodes( $story_id )
) . '</div>';
$identity = apply_filters( 'fictioneer_filter_story_identity', $identity, $story_id, $story );
echo implode( '', $identity );
?></div>
2023-01-21 01:31:34 +01:00
</header>