<?php
/**
 * Video past broadcast
 *
 * @package wpstream-theme
 */

$wpstream_get_post_type = $post->post_type;
$author_id              = wpstream_get_author_id( $post->ID );
$use_transient          = wpstream_theme_return_use_transient();
$transient_key          = 'wpstream_product_broadcaster_vod_query_' . $author_id;
$post_types_array       = apply_filters( 'wpstream_video_past_broadcast_post_type', array( 'post' ) );

$broadcaster_video_query_args = array(
	'post_status'    => 'publish',
	'post_type'      => $post_types_array,
	'posts_per_page' => 4,
	'orderby'        => 'date',
	'order'          => 'DESC',
	//phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
	'meta_query'     => array(
		array(
			'key'     => 'wpstream_theme_attach_to_channel',
			'value'   => $post->ID,
			'compare' => '=',
			'type'    => 'numeric',
		),

	),
);

$query = wpstream_theme_custom_query( $broadcaster_video_query_args, $transient_key, $use_transient );

if ( $query->found_posts > 0 ) { ?>

	<section class="wpstream_section wpstream_broadcaster_section ">

		<div class="<?php echo esc_attr( wpstream_theme_container_class() ); ?>">

			<div class="wpstream_section-line mb-3"></div>

			<div class="wpstream-grid-main ">
				<h2 class="title-more">

					<?php
					echo esc_html( $wpstream_section_title ?? '' );
					?>

					<a href="<?php echo esc_url( wpstream_get_single_post_author_link( $post->ID ) ); ?>">
						<?php esc_html_e( 'See more', 'hello-wpstream' ); ?>
						<?php echo wpstream_theme_get_svg_icon( 'right-arrow.svg' );//phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
					</a>
				</h2>
				<div class="row">

					<?php
					include get_template_directory() . '/template-parts/single/video-loop-content.php';
					?>

				</div>
			</div>
		</div>
	</section>
	
	<?php
}
?>