| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Theme: Classic. |
| 5 |
* |
| 6 |
* @link https://plugins360.com |
| 7 |
* @since 1.0.0 |
| 8 |
* |
| 9 |
* @package Automatic_YouTube_Gallery |
| 10 |
*/ |
| 11 |
|
| 12 |
$player_ratio = ! empty( $attributes['player_ratio'] ) ? (float) $attributes['player_ratio'] : '56.25'; |
| 13 |
|
| 14 |
$params = array( |
| 15 |
'uid' => sanitize_text_field( $attributes['uid'] ), |
| 16 |
'autoplay' => (int) $attributes['autoplay'], |
| 17 |
'loop' => (int) $attributes['loop'], |
| 18 |
'muted' => (int) $attributes['muted'], |
| 19 |
'controls' => (int) $attributes['controls'], |
| 20 |
'modestbranding' => (int) $attributes['modestbranding'], |
| 21 |
'cc_load_policy' => (int) $attributes['cc_load_policy'], |
| 22 |
'iv_load_policy' => (int) $attributes['iv_load_policy'], |
| 23 |
'hl' => sanitize_text_field( $attributes['hl'] ), |
| 24 |
'cc_lang_pref' => sanitize_text_field( $attributes['cc_lang_pref'] ) |
| 25 |
); |
| 26 |
|
| 27 |
$featured = $videos[0]; // Featured Video |
| 28 |
?> |
| 29 |
|
| 30 |
<div id="ayg-<?php echo esc_attr( $attributes['uid'] ); ?>" class="ayg ayg-theme-single" data-params='<?php echo wp_json_encode( $params ); ?>'> |
| 31 |
<!-- Player --> |
| 32 |
<div class="ayg-player"> |
| 33 |
<div class="ayg-player-wrapper" style="padding-bottom: <?php echo (float) $player_ratio; ?>%;"> |
| 34 |
<?php |
| 35 |
// Image |
| 36 |
$image_src = 'none'; |
| 37 |
|
| 38 |
if ( isset( $video->thumbnails->default ) ) { |
| 39 |
$image_src = $video->thumbnails->default->url; |
| 40 |
} |
| 41 |
|
| 42 |
if ( 75 == (int) $attributes['player_ratio'] ) { // 4:3 ( default - 120x90, high - 480x360, standard - 640x480 ) |
| 43 |
if ( isset( $video->thumbnails->high ) ) { |
| 44 |
$image_src = $video->thumbnails->high->url; |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
if ( 56.25 == (float) $attributes['player_ratio'] ) { // 16:9 ( medium - 320x180, maxres - 1280x720 ) |
| 49 |
if ( isset( $video->thumbnails->medium ) ) { |
| 50 |
$image_src = $video->thumbnails->medium->url; |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
// Player |
| 55 |
$tag = 'div'; |
| 56 |
if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { |
| 57 |
$tag = 'iframe'; |
| 58 |
} |
| 59 |
|
| 60 |
printf( |
| 61 |
'<%1$s class="ayg-player-iframe" width="100%%" height="100%%" src="%2$s/embed/%3$s" data-id="%3$s" data-image="%4%s" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></%1$s>', |
| 62 |
$tag, |
| 63 |
ayg_get_youtube_domain(), |
| 64 |
esc_attr( $featured->id ), |
| 65 |
esc_attr( $image_src ) |
| 66 |
); |
| 67 |
?> |
| 68 |
</div> |
| 69 |
|
| 70 |
<div class="ayg-player-caption"> |
| 71 |
<?php if ( ! empty( $attributes['player_title'] ) ) : ?> |
| 72 |
<h2 class="ayg-player-title"><?php echo esc_html( $featured->title ); ?></h2> |
| 73 |
<?php endif; ?> |
| 74 |
|
| 75 |
<?php if ( ! empty( $attributes['player_description'] ) && ! empty( $featured->description ) ) : ?> |
| 76 |
<div class="ayg-player-description"><?php echo wp_kses_post( ayg_get_player_description( $featured ) ); ?></div> |
| 77 |
<?php endif; ?> |
| 78 |
</div> |
| 79 |
</div> |
| 80 |
</div> |
| 81 |
|