<?php
/**
 * Video trending content
 *
 * @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_latest_video_trending';

$trending_video_query_args = array(
	'post_status'    => 'publish',
	'post_type'      => $wpstream_get_post_type,
	'posts_per_page' => 4,
	//phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key
	'meta_key'       => 'post_view_count',
	'orderby'        => 'meta_value_num',
	'order'          => 'DESC',
);

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

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

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

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

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

				</h2>
				<div class="row">

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

				</div>
			</div>
		</div>
	</section>

	<?php
}