feat(theme): About, Contact, FAQ, blog list and post pages from new front
- Route pages by address to theme templates (about-us, contact-us, faq, blogs, posts) - Scoped design CSS (pages.css) + Astra/WordPress fixes (pages-wp.css), page JS - Contact form emails the new Settings -> Viator Collector -> Contact email (fallback: admin email), Reply-To the visitor, honeypot spam trap - Blog list shows real posts with search, sort and paging; posts use the article design with comments as reviews and related articles - Design images converted to WebP (~15MB PNG -> ~1MB) - Theme 1.0.10, plugin 1.9.1 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
197
astra-child-hoponhopoff/templates/post.php
Normal file
197
astra-child-hoponhopoff/templates/post.php
Normal file
@@ -0,0 +1,197 @@
|
||||
<?php
|
||||
/**
|
||||
* Single blog post — "new front/blog-post.html" with the post's own title,
|
||||
* image and content. "Review's" are the post's WordPress comments.
|
||||
*/
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
get_header();
|
||||
|
||||
the_post();
|
||||
$hoho_post_id = get_the_ID();
|
||||
$hoho_cats = get_the_category();
|
||||
$hoho_reviews = get_comments(
|
||||
array(
|
||||
'post_id' => $hoho_post_id,
|
||||
'status' => 'approve',
|
||||
'parent' => 0,
|
||||
'order' => 'ASC',
|
||||
)
|
||||
);
|
||||
$hoho_related = get_posts(
|
||||
array(
|
||||
'post_type' => 'post',
|
||||
'posts_per_page' => 4,
|
||||
'post__not_in' => array( $hoho_post_id ),
|
||||
'category__in' => wp_list_pluck( $hoho_cats, 'term_id' ),
|
||||
'ignore_sticky_posts' => true,
|
||||
)
|
||||
);
|
||||
if ( count( $hoho_related ) < 4 ) {
|
||||
$hoho_related = array_merge(
|
||||
$hoho_related,
|
||||
get_posts(
|
||||
array(
|
||||
'post_type' => 'post',
|
||||
'posts_per_page' => 4 - count( $hoho_related ),
|
||||
'post__not_in' => array_merge( array( $hoho_post_id ), wp_list_pluck( $hoho_related, 'ID' ) ),
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
$hoho_blog_url = get_option( 'page_for_posts' ) ? get_permalink( get_option( 'page_for_posts' ) ) : home_url( '/blogs/' );
|
||||
|
||||
/**
|
||||
* One review card in the design's markup.
|
||||
*/
|
||||
$hoho_review = function ( $comment, $classes ) use ( $hoho_post_id ) {
|
||||
$by_author = (int) $comment->user_id && (int) $comment->user_id === (int) get_post_field( 'post_author', $hoho_post_id );
|
||||
?>
|
||||
<article class="rcard <?php echo esc_attr( $classes ); ?>" id="comment-<?php echo (int) $comment->comment_ID; ?>">
|
||||
<header class="rcard__head">
|
||||
<?php echo get_avatar( $comment, 48, '', '', array( 'class' => 'rcard__avatar' ) ); ?>
|
||||
<div class="rcard__who">
|
||||
<b><?php echo esc_html( get_comment_author( $comment ) ); ?></b>
|
||||
<span><?php echo esc_html( $by_author ? __( 'Admin', 'hoponhopoff' ) : get_comment_date( 'Y/m/d', $comment ) ); ?></span>
|
||||
</div>
|
||||
</header>
|
||||
<div class="rcard__text"><?php echo wp_kses_post( wpautop( get_comment_text( $comment ) ) ); ?></div>
|
||||
</article>
|
||||
<?php
|
||||
};
|
||||
?>
|
||||
<main id="main" class="hoho-page">
|
||||
<section class="hero hero--post">
|
||||
<div class="hero__media">
|
||||
<img class="hero__img" src="<?php echo esc_url( hoho_post_image_url( $hoho_post_id, 'full' ) ); ?>" alt="" fetchpriority="high" />
|
||||
</div>
|
||||
<?php
|
||||
if ( function_exists( 'vc_ring_badge' ) ) {
|
||||
echo vc_ring_badge( 'SCROLL DOWN · SCROLL DOWN · ', '#post', 'scroll' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
?>
|
||||
</section>
|
||||
|
||||
<article class="section post" id="post">
|
||||
<div class="container">
|
||||
<div class="post__inner">
|
||||
<header class="tour-head post__head">
|
||||
<h1 class="post__title"><?php the_title(); ?></h1>
|
||||
<div class="tmeta">
|
||||
<?php if ( $hoho_cats ) : ?>
|
||||
<span class="tmeta__item"><?php echo hoho_icon( 'location', 'tmeta__icon' ); // phpcs:ignore ?><?php echo esc_html( $hoho_cats[0]->name ); ?></span>
|
||||
<span class="tmeta__rule" aria-hidden="true"></span>
|
||||
<?php endif; ?>
|
||||
<span class="tmeta__item"><?php echo hoho_icon( 'calendar', 'tmeta__icon' ); // phpcs:ignore ?><?php echo esc_html( get_the_date() ); ?></span>
|
||||
<span class="tmeta__rule" aria-hidden="true"></span>
|
||||
<span class="tmeta__item"><?php echo hoho_icon( 'person', 'tmeta__icon' ); // phpcs:ignore ?><?php
|
||||
/* translators: %s: author name. */
|
||||
echo esc_html( sprintf( __( 'from %s', 'hoponhopoff' ), get_the_author() ) );
|
||||
?></span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="post__body">
|
||||
<div class="hoho-prose">
|
||||
<?php the_content(); ?>
|
||||
</div>
|
||||
<hr class="post__rule" />
|
||||
|
||||
<div class="share">
|
||||
<h2 class="share__title"><?php echo esc_html__( 'Share with your friends!', 'hoponhopoff' ); ?></h2>
|
||||
<div class="share__btns">
|
||||
<a class="share__btn" data-share="telegram" href="https://t.me/share/url" target="_blank" rel="noopener" aria-label="<?php echo esc_attr__( 'Share on Telegram', 'hoponhopoff' ); ?>"><?php echo hoho_icon( 'telegram', 'icon--20' ); // phpcs:ignore ?></a>
|
||||
<a class="share__btn" data-share="facebook" href="https://www.facebook.com/sharer/sharer.php" target="_blank" rel="noopener" aria-label="<?php echo esc_attr__( 'Share on Facebook', 'hoponhopoff' ); ?>"><?php echo hoho_icon( 'facebook', 'icon--20' ); // phpcs:ignore ?></a>
|
||||
<a class="share__btn" href="<?php echo esc_url( hoho_socials()['instagram'] ); ?>" target="_blank" rel="noopener" aria-label="Instagram"><?php echo hoho_icon( 'instagram', 'icon--20' ); // phpcs:ignore ?></a>
|
||||
<a class="share__btn" data-share="whatsapp" href="https://wa.me/" target="_blank" rel="noopener" aria-label="<?php echo esc_attr__( 'Share on WhatsApp', 'hoponhopoff' ); ?>"><?php echo hoho_icon( 'whatsapp', 'icon--20' ); // phpcs:ignore ?></a>
|
||||
<button class="share__btn share__btn--copy" type="button" data-copy-link><?php echo esc_html__( 'Copy page link', 'hoponhopoff' ); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ( comments_open() || $hoho_reviews ) : ?>
|
||||
<section class="reviews" id="reviews" aria-labelledby="reviewsTitle">
|
||||
<h2 class="post__h2" id="reviewsTitle"><?php echo esc_html__( 'Review’s', 'hoponhopoff' ); ?></h2>
|
||||
|
||||
<?php if ( comments_open() ) : ?>
|
||||
<form class="rform" id="reviewForm" method="post" action="<?php echo esc_url( site_url( '/wp-comments-post.php' ) ); ?>">
|
||||
<p class="rform__title"><?php echo hoho_icon( 'chat' ); // phpcs:ignore ?><?php echo esc_html__( 'Submit review', 'hoponhopoff' ); ?></p>
|
||||
<?php if ( ! is_user_logged_in() ) : ?>
|
||||
<div class="rform__row">
|
||||
<div class="field">
|
||||
<span class="field__label"><?php echo hoho_icon( 'person' ); // phpcs:ignore ?><label for="r-name"><?php echo esc_html__( 'Full Name', 'hoponhopoff' ); ?></label></span>
|
||||
<input class="rinput" id="r-name" name="author" type="text" placeholder="<?php echo esc_attr__( 'Enter full name', 'hoponhopoff' ); ?>" autocomplete="name" required />
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="field__label"><?php echo hoho_icon( 'mail' ); // phpcs:ignore ?><label for="r-email"><?php echo esc_html__( 'Email', 'hoponhopoff' ); ?></label></span>
|
||||
<input class="rinput" id="r-email" name="email" type="email" placeholder="<?php echo esc_attr__( 'Enter email', 'hoponhopoff' ); ?>" autocomplete="email" required />
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="field">
|
||||
<span class="field__label"><?php echo hoho_icon( 'chat' ); // phpcs:ignore ?><label for="r-text"><?php echo esc_html__( 'Your Review', 'hoponhopoff' ); ?></label></span>
|
||||
<textarea class="rinput rinput--area" id="r-text" name="comment" rows="4" placeholder="<?php echo esc_attr__( 'Type your review here ...', 'hoponhopoff' ); ?>" required></textarea>
|
||||
</div>
|
||||
<?php comment_id_fields( $hoho_post_id ); ?>
|
||||
<?php do_action( 'comment_form', $hoho_post_id ); ?>
|
||||
<p class="rform__status" role="status"><?php echo isset( $_GET['unapproved'] ) ? esc_html__( 'Thanks! Your review has been submitted for approval.', 'hoponhopoff' ) : ''; // phpcs:ignore WordPress.Security.NonceVerification ?></p>
|
||||
<button class="btn btn--dark rform__submit" type="submit"><?php echo esc_html__( 'Submit', 'hoponhopoff' ); ?></button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( $hoho_reviews ) : ?>
|
||||
<div class="reviews__list<?php echo count( $hoho_reviews ) > 3 ? ' is-collapsed' : ''; ?>" id="reviewList">
|
||||
<?php
|
||||
foreach ( $hoho_reviews as $hoho_comment ) {
|
||||
$hoho_review( $hoho_comment, 'rcard--tint' );
|
||||
$hoho_replies = get_comments(
|
||||
array(
|
||||
'post_id' => $hoho_post_id,
|
||||
'status' => 'approve',
|
||||
'parent' => $hoho_comment->comment_ID,
|
||||
'order' => 'ASC',
|
||||
)
|
||||
);
|
||||
if ( $hoho_replies ) {
|
||||
echo '<div class="replies"><span class="replies__k">' . esc_html__( 'Replies', 'hoponhopoff' ) . '</span>';
|
||||
foreach ( $hoho_replies as $i => $hoho_reply ) {
|
||||
$hoho_review( $hoho_reply, $i % 2 ? 'rcard--tint rcard--reply' : 'rcard--reply' );
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php if ( count( $hoho_reviews ) > 3 ) : ?>
|
||||
<button class="reviews__more" type="button" id="reviewMore" aria-expanded="false" aria-controls="reviewList">
|
||||
<span><?php echo esc_html__( 'Show all reviews', 'hoponhopoff' ); ?></span>
|
||||
<?php echo hoho_icon( 'chevron' ); // phpcs:ignore ?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( $hoho_related ) : ?>
|
||||
<section class="related" aria-labelledby="relatedTitle">
|
||||
<div class="related__head">
|
||||
<h2 class="post__h2" id="relatedTitle"><?php echo esc_html__( 'Related Articles', 'hoponhopoff' ); ?></h2>
|
||||
<a class="btn btn--ghost btn--wide related__all" href="<?php echo esc_url( $hoho_blog_url ); ?>">
|
||||
<span><?php echo esc_html__( 'See all', 'hoponhopoff' ); ?></span>
|
||||
<?php echo hoho_icon( 'arrow-ne' ); // phpcs:ignore ?>
|
||||
</a>
|
||||
</div>
|
||||
<ul class="tgrid tgrid--related">
|
||||
<?php
|
||||
foreach ( $hoho_related as $hoho_rel ) {
|
||||
echo hoho_article_card( $hoho_rel, 'related' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</main>
|
||||
<?php
|
||||
get_footer();
|
||||
Reference in New Issue
Block a user