File: /home/kashmira/www/razitahir.com/wp-content/themes/upress/template-videos.php
<?php
/**
* Template Name: Videos
* Page Template for displaying videos. You can build the video sections from customizer.
* @package UrduPress
* @since UrduPress 6.0
*/
get_header();
$translation = upress_translation();
?>
<?php if(get_option( 'urdupress_widgets_module_videos', 'on' ) == 'on') { ?>
<div id="primary" class="content-area videos-page">
<?php if ( true == get_theme_mod( 'videos_page_featured_section', 'on' ) ) : ?>
<div class="featured-section">
<div class="featured-video">
<?php
$args = array('post_type' => 'video', 'posts_per_page' => 1, 'tag' => 'featured');
$featured_query = new WP_Query($args);
if($featured_query->have_posts()):
while($featured_query->have_posts()):
$featured_query->the_post();
?>
<div class="embed-container">
<?php rwmb_the_value( 'upress_video_url' ); ?>
</div>
<div class="video-meta">
<h1><?php the_title() ?></h1>
<div><?php get_template_part('template-parts/post', 'meta_md') ?></div>
</div>
<?php
endwhile;
endif;
?>
<?php wp_reset_postdata(); ?>
</div>
<div class="popular-videos">
<h3><img src="<?php echo get_template_directory_uri() ?>/images/fire.png" alt="Flame"> <?php _e($translation['section']['popular_widget_heading'], 'urdupress'); ?></h3>
<div class="widget-body">
<?php get_template_part('template-parts/video/popular', 'videos') ?>
</div>
</div>
</div><!-- Featured Section -->
<?php endif; ?>
<div class="category-blocks">
<?php
// Default values for 'my_repeater_setting' theme mod.
$defaults = [
[
'block_heading' => esc_html__( 'تازہ ترین', 'urdupress' ),
'block_category' => 0,
'block_limit' => '4',
'block_more_link' => true,
],
[
'block_heading' => esc_html__( 'ٹالک شوز', 'urdupress' ),
'block_category' => 0,
'block_limit' => '4',
'block_more_link' => true,
],
];
// Theme_mod settings to check.
$settings = get_theme_mod( 'video_page_block_repeater', $defaults );
?>
<?php
foreach ( $settings as $setting ) :
$limit = (!empty($setting['block_limit']) && $setting['block_limit'] > 0) ? intval($setting['block_limit']) : 4;
$cat_id = (!empty($setting['block_category']) && $setting['block_category'] > 0) ? intval($setting['block_category']) : 0;
?>
<?php //print_r($setting['block_category']); ?>
<div class="category-video-block">
<?php if(!empty($setting['block_heading'])): ?>
<div class="vid-cat-block-header">
<div class="heading-label"><h3><?php echo $setting['block_heading'] ?></h3></div>
<?php if(!empty($cat_id)): ?>
<div class="cat-more-btn">
<a href="<?php echo get_term_link($cat_id, 'video_category') ?>">
<span class="btn-label"><?php esc_html_e('مزید دیکھیں', 'urdupress')?></span>
<span class="btn-icon"><i class="fa fa-chevron-left"></i></span>
</a>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<div class="vid-cat-block-posts">
<?php
$block_args = array(
'post_type' => 'video',
'posts_per_page' => $limit,
'tax_query' => array(
array(
'taxonomy' => 'video_category',
'field' => 'term_id',
'terms' => $cat_id,
),
),
);
$block_query = new WP_Query($block_args);
if($block_query->have_posts()):
while($block_query->have_posts()):
$block_query->the_post(); ?>
<div class="grid-item">
<div class="thumb">
<a href="<?php the_permalink() ?>" aria-label="<?php the_title() ?>">
<?php
if(has_post_thumbnail()):
the_post_thumbnail('video-grid');
else:
echo '<img src="'.get_template_directory_uri().'/images/nothumb-360.jpg" alt="'.get_the_title().'">';
endif;
?>
<span class="overlay-icon"><i class="icon-play-circled2"></i></span>
<span class="video-duration"><?php rwmb_the_value( 'upress_video_duration' ) ?> <i class="icon-clock"></i></span>
</a>
</div>
<div class="meta">
<?php get_template_part('template-parts/video', 'meta_grid') ?>
</div>
</div>
<?php
endwhile;
endif;
wp_reset_postdata();
?>
</div>
</div>
<?php endforeach; ?>
</div><!-- Category Blocks -->
</div><!-- #primary -->
<?php } else { ?>
<div id="primary" class="content-area videos-page">
<h1 class="mt-20 mb-20" style="direction: ltr; text-align: center; font-family: 'Roboto', sans-serif; font-size: 30px; color: #000000;">Videos Module is inactive</h1>
</div>
<?php } ?>
<?php get_footer(); ?>