File: /home/imensosw/www/imenso.co/webofai/wp-content/themes/webofai_theme-old/single-tool.php
<?php
get_header();
global $post;
$post_id = get_the_ID();
$tool_icon = \Theme\Helpers::display_attachment(get_field('tool_icon', $post_id));
$tool_image_id = get_field('tool_image', $post_id);
$tool_image = \Theme\Helpers::get_image($tool_image_id, 'large');
$post_title = get_the_title($post_id);
$post_date = get_the_date('j F Y', $post_id);
$short_description = get_field('short_description', $post_id);
$website_url = get_field('website_url', $post_id);
$tool_gallery = get_field('tool_gallery', $post_id);
$tool_features = get_field('tool_features', $post_id);
//$tool_pricing = get_the_terms($post_id, 'tool-pricing');
$tool_archive = get_field('tool_archive', 'options');
$tool_category = wp_get_post_terms($post_id, 'tool-category');
$link_text = \Theme\Helpers::get_key_from_array('link_text', $tool_archive);
$page_archive = \Theme\Helpers::get_key_from_array('page_archive', $tool_archive);
// favorites
$favorites = intval(get_post_meta($post_id, 'favorites', true));
$favorites_users = get_post_meta($post_id, 'favorites_users', true);
$favorites_users = json_decode($favorites_users, true);
// current user
$user_id = get_current_user_id();
$tool_description = get_field('tool_description', $post_id);
$args = array(
'post_type' => 'tool',
'posts_per_page' => 3,
'order' => 'DESC',
'orderby' => 'ID',
'post__not_in' => array($post->ID),
);
$relatedPosts = new WP_Query($args);
$button = get_field('button', $post_id);
$tool_pricing = wp_get_post_terms(get_the_ID(), 'tool-pricing');
if (!empty($tool_pricing) && !is_wp_error($tool_pricing)) {
$first_term = $tool_pricing[0];
// Do something with the first term here
}
?>
<?php if (have_posts()): the_post(); ?>
<div class="single-post-wrapper">
<div class="container">
<!-- single tool hero block-->
<section class="single_tool_hero_block"
data-section-class="single_tool_hero_block">
<div class="content-wrapper">
<div class="tool-wrapper iv-st-from-bottom">
<div class="left-content">
<?php if ($tool_icon || $tool_image) { ?>
<a href="<?= $website_url ?>"
class="left-section ">
<picture class="aspect-ratio">
<?= $tool_icon ?: $tool_image ?>
</picture>
</a>
<?php } ?>
<div class="tool-group">
<div class="title-and-tool-pricing ">
<?php if ($post_title) { ?>
<h1 class="headline-3 tool-title "><?= $post_title ?></h1>
<?php } ?>
<?php if (!empty($tool_pricing) && !is_wp_error($tool_pricing)) {
$first_term = $tool_pricing[0];
$term_id = $first_term?->term_id;
$term_link = get_term_link($term_id);
?>
<a class="wp-post-term"
href="<?php echo esc_html($term_link); ?>">
<div class="inner-term paragraph">
<?= esc_html($first_term->name); ?>
</div>
</a>
<?php
} ?>
</div>
<?php if ($short_description) { ?>
<div
class="paragraph short-description"><?= $short_description ?></div>
<?php } ?>
</div>
</div>
<div class="right-content">
<button
class="single-tool-favourite favorite-button <?= isset($favorites_users[$user_id]) ? 'favorite' : '' ?>"
aria-label="Add to favourite" data-post-id="<?= $post_id ?>"
data-user-id="<?= $user_id ?>">
<svg viewBox="0 0 20 18">
<path
d="M19,5.7c0,3.4-3.1,6.2-7.7,10.4L10,17.3,8.7,16.1C4.1,11.9,1,9.1,1,5.7a5,5,0,0,1,5-5,5.3,5.3,0,0,1,4,1.9A5.3,5.3,0,0,1,14,.7,5,5,0,0,1,19,5.7Z"
fill="#FFFFFF" stroke="#a1a1aa" stroke-miterlimit="10"
stroke-width="1.5"/>
</svg>
</button>
<?php if ($website_url) { ?>
<a class="cta-button active"
href="<?= $website_url ?>"><?= __('Visit Site', 'webofai') ?>
</a>
<?php } ?>
</div>
</div>
<?php if ($tool_gallery || $tool_image) {
if (empty($tool_gallery)) {
$tool_gallery[] = $tool_image_id;
}
?>
<div class="image-tool-wrapper iv-st-from-bottom">
<div class='swiper mySwiper'>
<div class='swiper-wrapper'>
<?php foreach ($tool_gallery as $tool_image):
?>
<div class='swiper-slide'>
<picture class="image-wrapper">
<?= \Theme\Helpers::get_image($tool_image, 'large') ?>
</picture>
</div>
<?php endforeach; ?>
</div>
<div class='swiper-scrollbar'></div>
<div class='swiper-button-next'>
<svg width='24' height='24' viewBox='0 0 24 24' fill='none'
xmlns='http://www.w3.org/2000/svg'>
<path d='M9 18L15 12L9 6' stroke='white' stroke-width='1.5'
stroke-linecap='round' stroke-linejoin='round'/>
</svg>
</div>
<div class='swiper-button-prev'>
<svg width='24' height='24' viewBox='0 0 24 24' fill='none'
xmlns='http://www.w3.org/2000/svg'>
<path d='M9 18L15 12L9 6' stroke='white' stroke-width='1.5'
stroke-linecap='round' stroke-linejoin='round'/>
</svg>
</div>
</div>
</div>
<?php } ?>
</div>
</section>
<!-- About Tool block -->
<section class="about_tool_block"
data-section-class="about_tool_block" id="about-section">
<div class="container">
<div class="tool-box iv-st-from-bottom">
<ul class="tabs-group ">
<li><a href="#about-section"
class="tab-btn active"><?= __('About', 'webofai_theme') ?></a>
</li>
<?php if (have_rows('features', $post_id)): ?>
<li><a href="#feature-section"
class="tab-btn"><?= __('Features', 'webofai_theme') ?></a>
</li>
<?php endif; ?>
<?php if (have_rows('pricing', $post_id)) { ?>
<li><a href="#pricing-section"
class="tab-btn"><?= __('Pricing Plans', 'webofai_theme') ?></a>
</li>
<?php } ?>
<li><a href="#reviews-section"
class="tab-btn"><?= __('Reviews', 'webofai_theme') ?></a>
</li>
<?php if (have_rows('faqs')) { ?>
<li><a href="#faqs"
class="tab-btn"><?= __('FAQs', 'webofai_theme') ?></a>
</li>
<?php } ?>
<?php if ($relatedPosts->have_posts()): ?>
<li><a href="#blog-section"
class="tab-btn"><?= __('Blogs', 'webofai_theme') ?></a>
</li>
<?php endif; ?>
</ul>
<div class="about-tool-card card" itemscope
itemprop="mainEntity"
itemtype="https://schema.org/Question">
<div class="content-svg accordion-head">
<h3
class="feature-title"><?= __('About', 'webofai_theme') ?></h3>
<svg class="toggle-open minus-plus" width="24"
height="24" viewBox="0 0 24 24" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path d="M18 15L12 9L6 15" stroke="#2E2E2E"
stroke-width="1.5" stroke-linecap="round"
stroke-linejoin="round"/>
</svg>
</div>
<div class="accordion-body about-tool-description" itemscope
itemprop="acceptedAnswer"
itemtype="https://schema.org/Answer">
<div aria-hidden="true" style="height: 2.6rem"></div>
<?php if ($tool_description): ?>
<div class="tool-description max-line">
<?= $tool_description ?>
</div>
<?php endif; ?>
<?php if ($tool_description): ?>
<a href="#"
class="read-more"><?= __('Read more', 'webofai_theme') ?></a>
<?php endif; ?>
<?php if ($post_date): ?>
<div class="date-of-post sub-title">
<span>
<?= __('Release Date:', 'webofai_theme') ?>
</span>
<?= $post_date ?>
</div>
<?php endif; ?>
<div style="display:none" class="developer-text sub-title">
<span>
<?= __('Developers:', 'webofai_theme') ?>
</span>
<?= __('OpenAI', 'webofai_theme') ?>
</div>
<div class="category-group">
<?php if ($tool_category && !is_wp_error($tool_category)) {
?>
<div
class="category-text sub-title"><?= __('Category:', 'webofai_theme') ?></div>
<div class="cat-buttons">
<?php foreach ($tool_category as $tool_cat) {
$term_link = get_term_link($tool_cat);
?>
<a href="<?= $term_link ?>"
class="cta-button cat-btn"><?= $tool_cat->name ?></a>
<?php } ?>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- feature block -->
<?php if (have_rows('features', $post_id)): ?>
<section class="feature_block"
data-section-class="feature_block" id="feature-section">
<div class="container">
<div class="feature-cards iv-st-from-bottom">
<div class="feature-card card tool-box " itemscope
itemprop="mainEntity"
itemtype="https://schema.org/Question">
<div class="content-svg accordion-head">
<h3
class="feature-title"><?= __('Features', 'webofai_theme') ?></h3>
<svg class="toggle-open minus-plus" width="24"
height="24" viewBox="0 0 24 24" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path d="M18 15L12 9L6 15" stroke="#2E2E2E"
stroke-width="1.5" stroke-linecap="round"
stroke-linejoin="round"/>
</svg>
</div>
<div class="accordion-body" itemscope
itemprop="acceptedAnswer"
itemtype="https://schema.org/Answer">
<div aria-hidden="true" style="height: 2.6rem"></div>
<ul class="feature-description">
<?php while (have_rows('features', $post_id)):
the_row();
$feature_name = get_sub_field('feature_name');
$description = get_sub_field('description');
?>
<li class="feature-excerpt ">
<span><?= $feature_name ?></span><?= $description ?>
</li>
<?php endwhile; ?>
</ul>
</div>
</div>
</div>
</div>
</section>
<?php endif; ?>
<!--pricing block -->
<?php if (have_rows('pricing', $post_id)) { ?>
<section class="pricing_block" data-section-class="pricing_block"
id="pricing-section">
<div class="main-wrapper tool-box iv-st-from-bottom"
itemscope
itemprop="mainEntity"
itemtype="https://schema.org/Question">
<div class="upper accordion-head">
<h2><?= __('Pricing', 'webofai') ?></h2>
<svg class="toggle-open minus-plus" width="24"
height="24" viewBox="0 0 24 24" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path d="M18 15L12 9L6 15" stroke="#2E2E2E"
stroke-width="1.5" stroke-linecap="round"
stroke-linejoin="round"/>
</svg>
</div>
<div class="lower accordion-body" itemscope
itemprop="acceptedAnswer"
itemtype="https://schema.org/Answer">
<div aria-hidden="true" style="height: 2.6rem"></div>
<div class="pricing">
<?php while (have_rows('pricing', $post_id)) {
the_row();
$plan = get_sub_field('plan');
$plan_price = get_sub_field('plan_price');
$subscription_fee = get_sub_field('subscription_fee');
?>
<div class="card">
<?php if ($plan) { ?>
<div class="plan-name"><?= $plan ?></div>
<?php } ?>
<?php if ($plan_price) { ?>
<div class="plan-price"><?= $plan_price ?></div>
<?php } ?>
<?php if ($subscription_fee) { ?>
<div class="plan-period"><?= $subscription_fee ?></div>
<?php } ?>
</div>
<?php } ?>
</div>
<?php if (\Theme\Helpers::get_key_from_array('title', $button)) { ?>
<button class="cta-button secondary-btn button" href="<?= $button['url'] ?>" target="<?= $button['target'] ?>"> <?= $button['title'] ?> </button>
<?php } ?>
</div>
</div>
</section>
<?php } ?>
<!-- site reviews block -->
<section data-section-class='site_reviews_block'
class='site_reviews_block ' id='reviews-section'>
<div class='reviews-card iv-st-from-bottom'>
<div class='review-card card' itemscope
itemprop='mainEntity'
itemtype='https://schema.org/Question'>
<div class='content-svg accordion-head reviews-title-wrapper'>
<h3
class='reviews-title'><?= __('Reviews', 'webofai_theme') ?>
<?php echo do_shortcode("[site_reviews_summary assigned_posts='$post_id']"); ?>
</h3>
<svg class="toggle-open minus-plus" width="24"
height="24" viewBox="0 0 24 24" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path d="M18 15L12 9L6 15" stroke="#2E2E2E"
stroke-width="1.5" stroke-linecap="round"
stroke-linejoin="round"/>
</svg>
</div>
<div class="accordion-body comments-body" itemscope
itemprop="acceptedAnswer"
itemtype="https://schema.org/Answer">
<div aria-hidden="true" style="height: 1.6rem"></div>
<?php if (!is_user_logged_in()) { ?>
<div class="warning-wrapper">
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'>
<!--! Font Awesome Pro 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. -->
<path
d="M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"/>
</svg>
<p
class='warning'><?= __('Please LoggIn To Write A Review') ?></p>
</div>
<?php } else { ?>
<div
class='reviews-ctabtn'> <?php echo do_shortcode("[site_reviews_summary assigned_posts='$post_id']"); ?>
<a
class="cta-button"><?php echo __('Write a Review', 'webofai') ?></a>
</div>
<?php } ?>
<?php
echo do_shortcode("[site_reviews assigned_posts='$post_id']"); ?>
<a
class="cta-button all-reviews"><?php echo __('View all reviews', 'webofai') ?></a>
<?php echo do_shortcode("[site_reviews_form assigned_posts='$post_id']");
// endif;
?>
</div>
</div>
</div>
</section>
<!-- faq block -->
<?php if (have_rows('faqs')) { ?>
<section data-section-class="faq_block" class="faq_block" id="faqs">
<div class="faq-wrapper iv-st-from-bottom">
<div class="block-wrapper tool-box" itemscope
itemprop="mainEntity"
itemtype="https://schema.org/Question">
<div class="faq-main-title accordion-head">
<h3
class="headline-2 "><?= __('Frequently Asked Questions', 'webofai') ?></h3>
<svg class="toggle-open minus-plus" width="24"
height="24" viewBox="0 0 24 24" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path d="M18 15L12 9L6 15" stroke="#2E2E2E"
stroke-width="1.5" stroke-linecap="round"
stroke-linejoin="round"/>
</svg>
</div>
<div class="faq-block accordion-body" itemscope
itemprop="acceptedAnswer"
itemtype="https://schema.org/Answer">
<div aria-hidden="true" style="height: 2.4rem"></div>
<?php while (have_rows('faqs')) {
the_row();
$question = get_sub_field('question');
$answer = get_sub_field('answer');
?>
<div class="faq-section" itemscope
itemprop="mainEntity"
itemtype="https://schema.org/Question">
<?php if ($question) { ?>
<div class="title-svg accordion-head">
<div
class="paragraph faqs-title "><?= $question ?></div>
<svg width="24" height="24" viewBox="0 0 24 24"
fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 5V19M5 12H19" stroke="#2E2E2E"
stroke-width="1.5" stroke-linecap="round"
stroke-linejoin="round"/>
</svg>
</div>
<?php } ?>
<?php if ($answer) { ?>
<div class="paragraph accordion-body faqs-description"
itemscope
itemprop="acceptedAnswer"
itemtype="https://schema.org/Answer"><?= $answer ?></div>
<?php } ?>
</div>
<?php } ?>
</div>
</div>
</div>
</section>
<?php } ?>
<!-- related posts -->
<?php if ($relatedPosts->have_posts()): ?>
<section class="related_categories_block second-version"
data-section-class="related_categories_block"
id="blog-section">
<h3
class="block-title headline-2 iv-st-from-bottom"><?= __('Tools you might like', 'webofai') ?></h3>
<div class="cards-wrapper grid-cards ">
<?php while ($relatedPosts->have_posts()) {
$relatedPosts->the_post();
get_template_part("partials/tool-card", '', array('post_id' => get_the_ID()));
?>
<?php } ?>
</div>
<?php
wp_reset_postdata(); ?>
</section>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<?php
get_footer();