get('book_slug'); } if (empty($book_slug)) { $book_slug = get_post_field('post_name', get_the_ID()); } $book = null; if (class_exists('BDM_Book_Manager') && !empty($book_slug)) { $book = BDM_Book_Manager::get_book_by_slug($book_slug); } if (!$book) { ?>
title); $description = wp_kses_post($book->description); $cover_url = esc_url($book->cover_image); $author_names = []; foreach ($book->authors as $ba) { $author_names[] = esc_html($ba->author_name); } $author_string = !empty($author_names) ? implode(', ', $author_names) : 'B.D. Murphy'; $series = null; if ($book->series_id > 0 && class_exists('BDM_Series')) { $series = BDM_Series::get_series_by_id($book->series_id); } // Get retail links grouped by format and site name $retail_links = []; if (!empty($book->retail_links)) { foreach ($book->retail_links as $link) { $format = $link->format; if (!isset($retail_links[$format])) { $retail_links[$format] = []; } $retail_links[$format][$link->site_name] = $link; } } // Define retailers per format (Google Play and Apple Books don't support paperback/hardcover) $format_retailers = [ 'ebook' => ['Amazon', 'Apple Books', 'Google Play', 'Barnes & Noble', 'Kobo'], 'paperback'=> ['Amazon', 'Barnes & Noble', 'Kobo'], 'hardcover'=> ['Amazon', 'Barnes & Noble', 'Kobo'], 'audio' => ['Amazon', 'Apple Books', 'Barnes & Noble', 'Kobo'], ]; $format_labels = [ 'ebook' => __('eBook', 'bd-bookshelf'), 'paperback' => __('Paperback', 'bd-bookshelf'), 'hardcover' => __('Hardback', 'bd-bookshelf'), 'audio' => __('Audio', 'bd-bookshelf'), ]; // Determine which formats have at least one link $available_formats = []; foreach ($format_retailers as $fmt => $sites) { if (!empty($retail_links[$fmt])) { $available_formats[$fmt] = true; } } // Rating display $rating_html = ''; if ($book->rating_amazon > 0 || $book->rating_goodreads > 0) { $rating_html .= ''; } ?>name)); ?>