Files
Bookshelf/Old/bd-murphy-author/archive-book.php
2026-10-18 19:01:01 -07:00

87 lines
3.8 KiB
PHP

<?php
// Copyright 2026 Umbra Tools (umbratools.com)
// SPDX-License-Identifier: Apache-2.0
/**
* Template Name: All Books
*/
get_header();
?>
<div class="books-container">
<header class="page-header">
<h1 class="page-title"><?php esc_html_e('Books', 'bd-murphy'); ?></h1>
<?php
if (class_exists('BD_BookShelfHelper') && BD_BookShelfHelper::series_count() > 0) {
echo '<a href="' . home_url('/series/') . '" class="browse-series-link">' . __('Browse by Series', 'bd-murphy') . '</a>';
}
?>
</header>
<div class="books-list">
<?php
if (have_posts()) :
while (have_posts()) :
the_post();
setup_postdata($post);
$book_id = get_the_ID();
$cover_url = BD_BookShelfHelper::get_cover_url($book_id, 'book-cover');
$title = get_the_title();
$author = BD_BookShelfHelper::get_pen_name($book_id);
$ratings = BD_BookShelfHelper::get_ratings($book_id);
$blurb = BD_BookShelfHelper::get_blurb_excerpt($book_id);
$series = BD_BookShelfHelper::get_series_info($book_id);
?>
<article class="book-entry">
<div class="book-entry-cover">
<img src="<?php echo esc_url($cover_url); ?>" alt="<?php echo esc_attr($title); ?>">
</div>
<div class="book-entry-details">
<?php if ($series) : ?>
<span class="book-series-label">
<a href="<?php echo esc_url(home_url('/series/' . $series['slug'])); ?>">
<?php printf(esc_html__('Part of %s', 'bd-murphy'), esc_html($series['name'])); ?>
</a>
</span>
<?php endif; ?>
<h2 class="book-title"><?php echo esc_html($title); ?></h2>
<p class="book-author"><?php echo esc_html($author); ?></p>
<?php if ($ratings) : ?>
<div class="book-ratings">
<?php if (!empty($ratings['amazon'])) : ?>
<span class="rating amazon">Amazon: <?php echo esc_html($ratings['amazon']); ?></span>
<?php endif; ?>
<?php if (!empty($ratings['goodreads'])) : ?>
<span class="rating goodreads">Goodreads: <?php echo esc_html($ratings['goodreads']); ?></span>
<?php endif; ?>
</div>
<?php endif; ?>
<div class="book-format-toggle">
<button class="format-btn active" data-format="ebook"><?php esc_html_e('Ebook', 'bd-murphy'); ?></button>
<button class="format-btn" data-format="paperback"><?php esc_html_e('Paperback', 'bd-murphy'); ?></button>
<button class="format-btn" data-format="hardback"><?php esc_html_e('Hardback', 'bd-murphy'); ?></button>
</div>
<div class="book-retailer-links">
<?php BD_BookShelfHelper::display_retailer_links($book_id); ?>
</div>
<p class="book-blurb"><?php echo esc_html($blurb); ?></p>
</div>
</article>
<?php
endwhile;
wp_reset_postdata();
else :
?>
<p class="no-books"><?php esc_html_e('No books available yet.', 'bd-murphy'); ?></p>
<?php endif; ?>
</div>
</div>
<?php
get_footer();