-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathwpforms-field-godam-record-entry-view.php
More file actions
72 lines (64 loc) · 3.29 KB
/
wpforms-field-godam-record-entry-view.php
File metadata and controls
72 lines (64 loc) · 3.29 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
<?php
/**
* Template/View which is render on the WPForms View Entry page for the GoDAM Video Recorder field.
*
* @package GoDAM
*
* @since 1.3.0
*/
use RTGODAM\Inc\WPForms\WPForms_Integration_Helper;
$godam_form_id = absint( $form_data['id'] );
$godam_entry_id = isset( $_GET['entry_id'] ) ? absint( $_GET['entry_id'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$godam_field_id = absint( $field['id'] );
$godam_attachment_url = $value; // URL of the saved file, which is under /uploads/godam/wpforms.
$godam_attachment_name = basename( $value );
$godam_transcoded_url = WPForms_Integration_Helper::get_transcoded_url( $godam_form_id, $godam_entry_id, $godam_field_id );
$godam_hls_transcoded_url = WPForms_Integration_Helper::get_hls_transcoded_url( $godam_form_id, $godam_entry_id, $godam_field_id );
$godam_transcoded_status = WPForms_Integration_Helper::get_transcoded_status( $godam_form_id, $godam_entry_id, $godam_field_id );
// Detect if this is an audio file.
$file_type = wp_check_filetype( $godam_attachment_url );
$mime_type = ! empty( $file_type['type'] ) ? $file_type['type'] : '';
$is_audio = ! empty( $mime_type ) && strpos( $mime_type, 'audio' ) !== false;
// Handle .webm audio files.
if ( 'webm' === $file_type['ext'] && godam_is_audio_file_by_name( $godam_attachment_url ) ) {
$is_audio = true;
}
?>
<div class="godam-video-preview">
<div class="godam-video-link-wrapper">
<span><?php esc_html_e( 'URL: ', 'godam' ); ?></span>
<a
href="<?php echo esc_url( $godam_attachment_url ); ?>"
target="_blank"
class="godam-video-link <?php echo ( empty( $value ) ? 'hidden' : '' ); ?>"
>
<div class="godam-video-name"><?php echo esc_html( $godam_attachment_name ); ?></div>
</a>
</div>
<div class="godam-transcoded-url-info">
<?php if ( 'not_started' === $godam_transcoded_status ) : ?>
<span class='dashicons dashicons-controls-play'></span><strong><?php esc_html_e( 'Video transcoding process has not started.', 'godam' ); ?></strong>
<?php elseif ( 'transcoded' === $godam_transcoded_status ) : ?>
<span class='dashicons dashicons-yes-alt'></span><strong><?php esc_html_e( 'Video saved and transcoded successfully on GoDAM', 'godam' ); ?></strong>
<?php else : ?>
<span class='dashicons dashicons-hourglass'></span><strong><?php esc_html_e( 'Video transcoding process is in-progress.', 'godam' ); ?></strong>
<?php endif; ?>
</div>
<?php if ( $is_audio ) : ?>
<audio controls>
<?php if ( $godam_transcoded_url ) : ?>
<source src="<?php echo esc_url( $godam_transcoded_url ); ?>" type="audio/mpeg">
<?php endif; ?>
<source src="<?php echo esc_url( $godam_attachment_url ); ?>" type="<?php echo esc_attr( $mime_type ); ?>">
<?php esc_html_e( 'Your browser does not support the audio element.', 'godam' ); ?>
</audio>
<?php else : ?>
<?php
$godam_thumbnail_url = ''; // Default empty thumbnail.
// No need to escape here, the entire template will be returned as strings,
// which will be later on escaped using wp_kses_post() by WPForms before rendering the field.
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo force_balance_tags( do_shortcode( "[godam_video poster='{$godam_thumbnail_url}' src='{$godam_attachment_url}' transcoded_url='{$godam_transcoded_url}']" ) );
?>
<?php endif; ?>
</div>