194 lines
9.4 KiB
PHP
194 lines
9.4 KiB
PHP
<?php
|
|
require_once(INCLUDES_PATH . '/Const/recipes.php');
|
|
the_header(
|
|
$context['recipe']->field_title,
|
|
'This is a single recipe page where you can view the details of the recipe, including ingredients, instructions, and more.',
|
|
'recipe',
|
|
[
|
|
|
|
['keywords', 'recipes, cooking, food, cuisine'],
|
|
]
|
|
);
|
|
?>
|
|
|
|
<div id="recipe-id" hidden><?= $context['recipe']->get_id() ?></div>
|
|
<div id="in-usermenu" hidden><?= $context['recipe']->in_usermenu; ?></div>
|
|
|
|
<div class="container">
|
|
<div class="single-recipe">
|
|
<div class="single-recipe-info">
|
|
<div class="single-recipe-info__image">
|
|
<img src="<?= $context['recipe']->get_image_url(); ?>"
|
|
alt="<?php echo $context['recipe']->field_title; ?>">
|
|
</div>
|
|
<div class="single-recipe-info__details">
|
|
<div class="single-recipe-title">
|
|
<h1 class="title"><?php echo $context['recipe']->field_title; ?></h1>
|
|
</div>
|
|
<div class="single-recipe-data">
|
|
<div class="single-recipe-data__item">
|
|
<span class="data-name">Category: </span>
|
|
<span class="data"><?= $context['recipe']->category_name ?></span>
|
|
</div>
|
|
<div class="single-recipe-data__item">
|
|
<span class="data-name">Author: </span>
|
|
<span class="data"><?= $context['author']->field_username ?></span>
|
|
</div>
|
|
<div class="single-recipe-data__item">
|
|
<span class="data-name">Estimated Price: </span>
|
|
<span class="data"><?php echo $context['recipe']->get_price(); ?></span>
|
|
</div>
|
|
<div class="single-recipe-data__item">
|
|
<span class="data-name">Time To Make: </span>
|
|
<span class="data"><?php echo $context['recipe']->get_time(); ?></span>
|
|
</div>
|
|
<div class="single-recipe-data__item">
|
|
<span class="data-name">Ingredients: </span>
|
|
<span class="data"><?= join(", ", $context['ingredients']) ?></span>
|
|
</div>
|
|
<div class="single-recipe-data__item">
|
|
<span class="data-name">Date Created: </span>
|
|
<span class="data"><?php echo $context['recipe']->field_created_at; ?></span>
|
|
</div>
|
|
</div>
|
|
<div class="button-ctrl">
|
|
<select class="hidden" name="daily-meal-select" id="daily-meal-day">
|
|
<?php foreach (DAYS_OF_WEEK as $day): ?>
|
|
<option value="<?= $day ?>"><?= ucfirst($day) ?></option>
|
|
<?php endforeach; ?>
|
|
<option value="remove">Remove From List</option>
|
|
</select>
|
|
<div class="day-select-wrapper">
|
|
<div class="hover-anim">
|
|
<button type="button" href="#" id="day-select" class="btn btn-primary day-select">Add to
|
|
list</button>
|
|
<i class="fa-solid fa-list select-icon"></i>
|
|
</div>
|
|
<div id="custom-select-dropdown" class="custom-select-dropdown hidden">
|
|
<?php foreach (DAYS_OF_WEEK as $day): ?>
|
|
<div class="dropdown-item hover-anim" data-value="<?= $day ?>">
|
|
<?= ucfirst($day) ?>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
<div class="dropdown-item hover-anim" data-value="remove">Remove From List</div>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="small-btns">
|
|
<button id="favorite-btn"
|
|
class="btn btn-secondary btn-small hover-anim <?= $context['recipe']->is_in_favorite ? 'active' : '' ?>"
|
|
title="Add To Favorites">
|
|
<i
|
|
class="<?= $context['recipe']->is_in_favorite ? 'fa-solid' : 'fa-regular' ?> fa-heart"></i>
|
|
</button>
|
|
<a class="btn btn-secondary btn-small hover-anim"
|
|
href="<?php the_permalink('recipes:export-pdf', [$context['recipe']->get_id()]); ?>"
|
|
target="_blank" title="Export As PDF">
|
|
<i class="fa-solid fa-download"></i>
|
|
</a>
|
|
<button class="btn btn-secondary btn-small hover-anim" id="qr-btn" title="Get QR Code">
|
|
<i class="fa-solid fa-qrcode"></i>
|
|
</button>
|
|
</div>
|
|
<div id="overlay" class="hidden"></div>
|
|
<div class="qr-popup hidden">
|
|
<div id="qrcode"></div>
|
|
<a id="downloadLink" class="btn btn-primary hover-anim" href="#" download="recipe-qr.png">
|
|
Download QR Code
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="single-recipe-content">
|
|
<div class="single-instructions">
|
|
<h2 class="title">Instructions</h2>
|
|
|
|
<?= $context['recipe']->get_html_instruction(); ?>
|
|
</div>
|
|
<div class="single-ingredients">
|
|
<h2 class="title">Ingredients</h2>
|
|
<table class="ingredients-table">
|
|
<thead>
|
|
<tr>
|
|
<th>Name</th>
|
|
<th>Count</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
foreach ($context['ingredients'] as $ing) {
|
|
?>
|
|
<tr>
|
|
<td><?= $ing; ?></td>
|
|
<td><?= $ing->get_count(); ?></td>
|
|
</tr>
|
|
<?php } ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="single-recipe-reviews">
|
|
<h2 class="title">Reviews</h2>
|
|
<h3 class="rating">Average Rating: <?= $context['reviews_average'] ?> <i class="fa-regular fa-star"></i></h3>
|
|
<div class="reviews">
|
|
<div class="review-list">
|
|
<h4 class="subtitle">All Reviews</h4>
|
|
<?php if(empty($context['reviews'])): ?>
|
|
<div class="nothing">Nothing to show</div>
|
|
<?php endif; ?>
|
|
|
|
<?php foreach ($context['reviews'] as $review): ?>
|
|
<div class="review">
|
|
<span class="review-title"><?= $review->field_rating ?> <i class="fa-solid fa-star"></i> <?= $review->field_title ?></span>
|
|
<div class="review-body">
|
|
<?= $review->get_html_content() ?>
|
|
</div>
|
|
<div class="single-review-meta">
|
|
<div class="review-meta__user meta">
|
|
<i class="fa-regular fa-user"></i> <?= $review->author_username ?>
|
|
</div>
|
|
<div class="review-meta__date meta"><?= $review->get_date() ?></div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php if($context['display_review_form']): ?>
|
|
<div class="review-form">
|
|
<h4 class="subtitle">Your Review</h4>
|
|
<?php if(isset($context['reviews_error'])) {
|
|
the_alert($context['reviews_error'], 'warning');
|
|
} ?>
|
|
<form id="review-form" class="review-form__form" method="post" action="#">
|
|
<div class="rating-selection">
|
|
<label for="rating-select">Choose rating: </label>
|
|
<select name="rating-select" id="rating select">
|
|
<option>Rating</option>
|
|
<option value="1">1 Star</option>
|
|
<option value="2">2 Star </option>
|
|
<option value="3">3 Star</option>
|
|
<option value="4">4 Star</option>
|
|
<option value="5">5 Star</option>
|
|
</select>
|
|
</div>
|
|
<div class="input">
|
|
<input type="text" name="review-title" id="review-title-input" placeholder="Review Title"
|
|
required>
|
|
</div>
|
|
<textarea name="review-body-input" id="review-body-input" placeholder="Write your review here"></textarea>
|
|
|
|
<button type="submit" class="btn btn-primary hover-anim">Submit</button>
|
|
</form>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<?php the_footer(array(
|
|
ASSETS_PATH . '/js/single.js',
|
|
)); ?>
|