110 lines
4.2 KiB
PHP
110 lines
4.2 KiB
PHP
<?php
|
|
/**
|
|
* БИТ.WMS Child Theme — single-webinar.php
|
|
*
|
|
* Single (detail) template for the 'webinar' custom post type.
|
|
*
|
|
* Two display modes depending on webinar_date vs today:
|
|
* Upcoming — webinar_date, webinar_speaker, webinar_program (wysiwyg), registration link.
|
|
* Past — webinar_video_embed (wysiwyg/oEmbed), webinar_presentation (file url), webinar_program.
|
|
*
|
|
* ACF fields used:
|
|
* webinar_date — date picker (YYYY-MM-DD)
|
|
* webinar_speaker — text
|
|
* webinar_program — wysiwyg
|
|
* webinar_register_url — url
|
|
* webinar_video_embed — wysiwyg (oembed or raw iframe)
|
|
* webinar_presentation — file (array with 'url' and 'filename')
|
|
*
|
|
* @package bitwms-child
|
|
*/
|
|
|
|
defined( 'ABSPATH' ) || exit;
|
|
|
|
get_header();
|
|
the_post();
|
|
|
|
$webinar_date = get_field( 'webinar_date' ); // e.g. '2026-05-10'
|
|
$speaker = get_field( 'webinar_speaker' );
|
|
$program = get_field( 'webinar_program' );
|
|
$register_url = get_field( 'webinar_register_url' );
|
|
$video_embed = get_field( 'webinar_video_embed' );
|
|
$presentation = get_field( 'webinar_presentation' );
|
|
|
|
$is_upcoming = $webinar_date && strtotime( $webinar_date ) > time();
|
|
?>
|
|
<main class="single-webinar">
|
|
<div class="container">
|
|
<article>
|
|
<h1><?php the_title(); ?></h1>
|
|
|
|
<div class="single-webinar__meta">
|
|
<?php if ( $webinar_date ) : ?>
|
|
<span class="single-webinar__date">
|
|
<strong><?php esc_html_e( 'Дата:', 'bitwms-child' ); ?></strong>
|
|
<?php echo esc_html( date_i18n( 'd.m.Y', strtotime( $webinar_date ) ) ); ?>
|
|
</span>
|
|
<?php endif; ?>
|
|
<?php if ( $speaker ) : ?>
|
|
<span class="single-webinar__speaker">
|
|
<strong><?php esc_html_e( 'Спикер:', 'bitwms-child' ); ?></strong>
|
|
<?php echo esc_html( $speaker ); ?>
|
|
</span>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<?php if ( ! $is_upcoming && $video_embed ) : ?>
|
|
<div class="single-webinar__video">
|
|
<?php echo wp_kses_post( $video_embed ); ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ( $program ) : ?>
|
|
<div class="single-webinar__section">
|
|
<h2><?php esc_html_e( 'Программа', 'bitwms-child' ); ?></h2>
|
|
<?php echo wp_kses_post( $program ); ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ( $is_upcoming && $register_url ) : ?>
|
|
<div class="single-webinar__cta">
|
|
<a href="<?php echo esc_url( $register_url ); ?>" class="btn btn-primary" target="_blank" rel="noopener">
|
|
<?php esc_html_e( 'Зарегистрироваться', 'bitwms-child' ); ?>
|
|
</a>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ( ! $is_upcoming && $presentation ) : ?>
|
|
<div class="single-webinar__presentation">
|
|
<a href="<?php echo esc_url( $presentation['url'] ); ?>" class="btn btn-secondary" download>
|
|
<?php esc_html_e( 'Скачать презентацию', 'bitwms-child' ); ?>
|
|
</a>
|
|
</div>
|
|
<?php endif; ?>
|
|
</article>
|
|
|
|
<?php
|
|
$related = new WP_Query( array(
|
|
'post_type' => 'webinar',
|
|
'posts_per_page' => 3,
|
|
'orderby' => 'rand',
|
|
'post__not_in' => array( get_the_ID() ),
|
|
) );
|
|
if ( $related->have_posts() ) :
|
|
?>
|
|
<section class="related-posts">
|
|
<h2><?php esc_html_e( 'Другие вебинары', 'bitwms-child' ); ?></h2>
|
|
<div class="content-grid">
|
|
<?php while ( $related->have_posts() ) : $related->the_post(); ?>
|
|
<?php get_template_part( 'templates/content-card' ); ?>
|
|
<?php endwhile; ?>
|
|
</div>
|
|
</section>
|
|
<?php
|
|
wp_reset_postdata();
|
|
endif;
|
|
?>
|
|
</div>
|
|
</main>
|
|
<?php get_footer();
|