-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrender-callback.php
More file actions
88 lines (77 loc) · 4.34 KB
/
Copy pathrender-callback.php
File metadata and controls
88 lines (77 loc) · 4.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
if ( ! function_exists( 'register_block_type' ) ) {
return;
}
function render_featured_video_block( $attributes ) {
// Extract attributes
$title = $attributes['title'] ?? 'Featured Video';
$subTitle = $attributes['subTitle'] ?? '';
$mediaURL = $attributes['mediaURL'] ?? '';
$link = $attributes['link'] ?? '';
$linkLabel = $attributes['linkLabel'] ?? '';
$hasLinkNofollow = $attributes['hasLinkNofollow'] ?? false;
$openNewTab = $attributes['openNewTab'] ?? false;
$youtubeEmbed = $attributes['youtubeEmbed'] ?? '';
$rel = $hasLinkNofollow ? 'no follow ' : '';
$rel .= 'noopener noreferrer';
$play_label = $title
? sprintf(__('Play video: %s', 'ufl-block'), $title)
: __('Play video', 'ufl-block');
ob_start();
?>
<section class="featured-video">
<div class="container-fluid single-video-container">
<div class="row align-items-start">
<?php if ( $mediaURL ) : ?>
<a href="https://www.youtube.com/embed/<?php echo esc_attr( $youtubeEmbed ); ?>?autoplay=1&rel=0" class="video-wrapper" role="button" aria-label="<?php echo esc_attr( $play_label ); ?>" data-toggle="lightbox">
<div class="video-play" aria-hidden="true">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 110 109">
<g fill="rgba(0,33,165,0.55)" stroke="#fff" stroke-width="2" data-name="Ellipse 145">
<ellipse cx="55" cy="54.5" stroke="none" rx="55" ry="54.5" />
<ellipse cx="55" cy="54.5" fill="none" rx="54" ry="53.5" />
</g>
<path fill="#fff" d="M75.445 55.49 47 37.99V73Z" data-name="Path 5" />
</svg>
</div>
<img class="img-fluid video-thumb" src="<?php echo esc_url( $mediaURL ); ?>" alt="" aria-hidden="true" />
</a>
<?php else : ?>
<a href="https://www.youtube.com/embed/<?php echo esc_attr( $youtubeEmbed ); ?>?autoplay=1&rel=0" class="video-wrapper" role="button" aria-label="<?php echo esc_attr( $play_label ); ?>" data-toggle="lightbox">
<div class="video-play" aria-hidden="true">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 110 109">
<g fill="rgba(0,33,165,0.55)" stroke="#fff" stroke-width="2" data-name="Ellipse 145">
<ellipse cx="55" cy="54.5" stroke="none" rx="55" ry="54.5" />
<ellipse cx="55" cy="54.5" fill="none" rx="54" ry="53.5" />
</g>
<path fill="#fff" d="M75.445 55.49 47 37.99V73Z" data-name="Path 5" />
</svg>
</div>
<img class="img-fluid video-thumb" src="https://i1.ytimg.com/vi/<?php echo esc_attr( $youtubeEmbed ); ?>/0.jpg" alt="" aria-hidden="true" />
</a>
<?php endif; ?>
</div>
<div class="featured-video-content-wrapper">
<div class="col-12">
<?php if ( ! empty( $title ) ) : ?>
<h2 class="text-white"><?php echo esc_html( $title ); ?></h2>
<?php endif; ?>
<?php if ( ! empty( $subTitle ) ) : ?>
<p class="text-white"><?php echo esc_html( $subTitle ); ?></p>
<?php endif; ?>
</div>
<?php if ( ! empty( $link ) ) : ?>
<a
href="<?php echo esc_url( $link ); ?>"
class="button animated-border-button button-border-orange button-dark-bg"
rel="<?php echo esc_attr( $rel ); ?>"
target="<?php echo $openNewTab ? '_blank' : '_self'; ?>"
>
<?php echo esc_html( $linkLabel ); ?>
</a>
<?php endif; ?>
</div>
</div>
</section>
<?php
return ob_get_clean();
}