Initial import of the bdmurphy Bookshelf work: the bd-bookshelf theme, bd-bookshelf-plugin, bd-bookshelfhelper and bd-simpleemail plugins, plus the specification documents, mockups and release archives.
129 lines
5.8 KiB
PHP
129 lines
5.8 KiB
PHP
<?php
|
|
/**
|
|
* Template Name: Individual Book
|
|
*/
|
|
|
|
get_header();
|
|
?>
|
|
|
|
<div class="book-page-container">
|
|
<?php
|
|
while (have_posts()) :
|
|
the_post();
|
|
$book_id = get_the_ID();
|
|
$languages = BD_BookShelfHelper::get_supported_languages();
|
|
$current_lang = isset($_GET['lang']) ? sanitize_text_field($_GET['lang']) : 'en';
|
|
$title = BD_BookShelfHelper::get_localized_title($book_id, $current_lang);
|
|
$blurb = BD_BookShelfHelper::get_localized_blurb($book_id, $current_lang);
|
|
$cover_url = BD_BookShelfHelper::get_cover_url($book_id, 'book-page-cover', $current_lang);
|
|
$author = BD_BookShelfHelper::get_pen_name($book_id);
|
|
$series = BD_BookShelfHelper::get_series_info($book_id);
|
|
$ratings = BD_BookShelfHelper::get_ratings($book_id);
|
|
$preview = BD_BookShelfHelper::get_preview_excerpt($book_id, $current_lang);
|
|
$pull_quotes = BD_BookShelfHelper::get_pull_quotes($book_id, $current_lang);
|
|
$reviews = BD_BookShelfHelper::get_reviews($book_id);
|
|
$short_url = bdm_get_short_url($book_id);
|
|
?>
|
|
|
|
<nav class="language-selector">
|
|
<?php foreach ($languages as $code => $name) : ?>
|
|
<a href="?lang=<?php echo esc_attr($code); ?>"
|
|
class="lang-btn <?php echo $current_lang === $code ? 'active' : ''; ?>"
|
|
data-lang="<?php echo esc_attr($code); ?>">
|
|
<?php echo esc_html($name); ?>
|
|
</a>
|
|
<?php endforeach; ?>
|
|
</nav>
|
|
|
|
<div class="book-page-content">
|
|
<div class="book-page-cover">
|
|
<img src="<?php echo esc_url($cover_url); ?>" alt="<?php echo esc_attr($title); ?>">
|
|
</div>
|
|
|
|
<div class="book-page-info">
|
|
<h1 class="book-title"><?php echo esc_html($title); ?></h1>
|
|
<p class="book-pen-name"><?php echo esc_html($author); ?></p>
|
|
|
|
<?php if ($series) : ?>
|
|
<p class="book-series-info">
|
|
<a href="<?php echo esc_url(home_url('/series/' . $series['slug'])); ?>">
|
|
<?php printf(esc_html__('Part of the %s series — Book %d', 'bd-murphy'), esc_html($series['name']), esc_html($series['volume'])); ?>
|
|
</a>
|
|
</p>
|
|
<?php endif; ?>
|
|
|
|
<?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, 'ebook'); ?>
|
|
</div>
|
|
|
|
<div class="book-preview">
|
|
<h3><?php esc_html_e('Read Preview', 'bd-murphy'); ?></h3>
|
|
<p><?php echo esc_html($preview); ?></p>
|
|
</div>
|
|
|
|
<?php if ($pull_quotes) : ?>
|
|
<div class="book-pull-quotes">
|
|
<?php foreach ($pull_quotes as $quote) : ?>
|
|
<blockquote class="pull-quote"><?php echo esc_html($quote); ?></blockquote>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($reviews) : ?>
|
|
<div class="book-reviews">
|
|
<h3><?php esc_html_e('Reviews', 'bd-murphy'); ?></h3>
|
|
<?php foreach ($reviews as $review) : ?>
|
|
<div class="review-card">
|
|
<p class="review-text"><?php echo esc_html($review->comment_text); ?></p>
|
|
<cite class="review-source">
|
|
<?php if ($review->source_url) : ?>
|
|
<a href="<?php echo esc_url($review->source_url); ?>" target="_blank" rel="noopener">
|
|
<?php echo esc_html($review->source_name); ?>
|
|
</a>
|
|
<?php else : ?>
|
|
<?php echo esc_html($review->source_name); ?>
|
|
<?php endif; ?>
|
|
</cite>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="book-blurb">
|
|
<h3><?php esc_html_e('About This Book', 'bd-murphy'); ?></h3>
|
|
<p><?php echo esc_html($blurb); ?></p>
|
|
</div>
|
|
|
|
<button class="share-btn" data-url="<?php echo esc_url($short_url); ?>">
|
|
<?php esc_html_e('Share', 'bd-murphy'); ?>
|
|
</button>
|
|
|
|
<div class="social-share">
|
|
<?php get_template_part('template-parts/social-share'); ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
endwhile;
|
|
?>
|
|
</div>
|
|
|
|
<?php
|
|
get_footer();
|