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.2 3.5.0 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 3.9.1 3.9.10 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9
tutor / views / metabox / video-metabox.php
tutor / views / metabox Last commit date
course 3 years ago course-add-edd-product-metabox.php 3 years ago course-add-product-metabox.php 3 years ago course-additional-data.php 3 years ago course-contents.php 3 years ago course-level-metabox.php 3 years ago course-topics.php 3 years ago instructors-metabox.php 3 years ago lesson-attachments-metabox.php 3 years ago lesson-metabox.php 3 years ago product-selection.php 3 years ago settings-tabs.php 3 years ago user-profile-fields.php 3 years ago video-metabox.php 3 years ago
video-metabox.php
220 lines
1 <?php
2 /**
3 * Video meta box
4 *
5 * @package Tutor\Views
6 * @subpackage Tutor\MetaBox
7 * @author Themeum <support@themeum.com>
8 * @link https://themeum.com
9 * @since 1.0.0
10 */
11
12 /**
13 * Don't change it, it's supporting modal in other place
14 * if get_the_ID() empty, then it's means we are passing $post variable from another place
15 */
16 if ( get_the_ID() ) {
17 global $post;
18 }
19
20 $video = maybe_unserialize( get_post_meta( $post->ID, '_video', true ) );
21 $videoSource = tutor_utils()->avalue_dot( 'source', $video, 'html5' );
22 $runtimeHours = tutor_utils()->avalue_dot( 'runtime.hours', $video );
23 $runtimeMinutes = tutor_utils()->avalue_dot( 'runtime.minutes', $video );
24 $runtimeSeconds = tutor_utils()->avalue_dot( 'runtime.seconds', $video );
25 $sourceVideoID = tutor_utils()->avalue_dot( 'source_video_id', $video );
26 $poster = tutor_utils()->avalue_dot( 'poster', $video );
27 $videoAttachment = $sourceVideoID ? tutor_utils()->get_attachment_data( $sourceVideoID ) : null;
28
29 $video_sources = tutor_utils()->get_video_sources( false );
30
31 $supported_sources = tutor_utils()->get_option( 'supported_video_sources', array() );
32 ! is_array( $supported_sources ) ? $supported_sources = array( $supported_sources ) : 0;
33 $GLOBALS['supported_sources'] = $supported_sources;
34
35 if ( ! is_array( $supported_sources ) || ! count( $supported_sources ) ) {
36 $notice = __( 'No video source selected from settings!', 'tutor' );
37 ?>
38 <div class='tutor-alert tutor-warning'>
39 <div class='tutor-alert-text'>
40 <span class='tutor-alert-icon tutor-fs-4 tutor-icon-circle-info tutor-mr-12'></span>
41 <span>
42 <?php echo esc_html( $notice ); ?>
43 </span>
44 </div>
45 </div>
46 <?php
47 return;
48 }
49
50 /**
51 * On course create
52 * From video source list first item will be selected, When only one video source selected from settings
53 *
54 * @since 2.0.6
55 */
56 if ( is_array( $supported_sources ) && 1 === count( $supported_sources ) && false === $video ) {
57 $videoSource = $supported_sources[0];
58 }
59
60 /**
61 * Should meta box visible or not
62 *
63 * @param array $videoSource video source.
64 * @param array $source source.
65 * @param boolean $echo should echo.
66 * @return string
67 */
68 function tutor_video_input_state( $videoSource, $source, $echo = true ) {
69 $value = ( $videoSource == $source && in_array( $source, $GLOBALS['supported_sources'] ) ) ? 'block' : 'none';
70 if ( $echo ) {
71 echo esc_attr( 'display: ' . $value );
72 } else {
73 return "display: {$value};";
74 }
75 }
76
77 ?>
78
79 <div class="tutor-mb-32">
80 <label class="tutor-form-label">
81 <?php
82 if ( tutor()->course_post_type === $post->post_type ) {
83 esc_html_e( 'Course Intro Video', 'tutor' );
84 } else {
85 esc_html_e( 'Video Source', 'tutor' );
86 }
87 ?>
88 </label>
89
90 <div class="tutor-input-group tutor-mb-16 tutor-mt-12 tutor-d-block">
91 <div class="tutor-video-upload-wrap">
92 <div class="tutor-dropdown-icon-pack tutor-mt-4" data-video_source="<?php echo esc_attr( empty( $videoSource ) ? '' : $videoSource ); ?>">
93 <i class="tutor-icon-brand-html5-bold" data-for="html5"></i>
94 <i class="tutor-icon-brand-youtube-line" data-for="youtube"></i>
95 <i class="tutor-icon-brand-vimeo-line" data-for="vimeo"></i>
96 <i class="tutor-icon-shortcode" data-for="shortcode"></i>
97 <i class="tutor-icon-link" data-for="external_url"></i>
98 <i class="tutor-icon-coding" data-for="embedded"></i>
99 <?php
100 /**
101 * Hook added to add external video source icon
102 *
103 * @since v2.1.2
104 */
105 do_action( 'tutor_after_video_source_icon' );
106 ?>
107 </div>
108 <select name="video[source]" class="tutor-form-control tutor-select-icon-primary tutor_lesson_video_source no-tutor-dropdown">
109 <option value="-1"><?php esc_html_e( 'Select Video Source', 'tutor' ); ?></option>
110 <?php
111 foreach ( $video_sources as $value => $source ) {
112 if ( in_array( $value, $supported_sources ) ) {
113 ?>
114 <option value="<?php echo esc_attr( $value );?>" <?php selected( $value, $videoSource ); ?>
115 data-icon="<?php echo wp_kses( $source['icon'], tutor_utils()->allowed_icon_tags() ); ?>">
116 <?php echo esc_html( $source['title'] ); ?>
117 </option>
118 <?php
119 }
120 }
121 ?>
122 </select>
123
124 <div class="tutor-mt-16 video-metabox-source-item video_source_wrap_html5 tutor-dashed-uploader <?php echo $sourceVideoID ? 'tutor-has-video' : ''; ?>" style="<?php tutor_video_input_state( $videoSource, 'html5' ); ?>">
125 <div class="video-metabox-source-html5-upload">
126 <p class="video-upload-icon"><i class="tutor-icon-upload-icon-line"></i></p>
127 <p><strong><?php esc_html_e( 'Drag & Drop Your Video', 'tutor' ); ?></strong></p>
128 <p><?php esc_html_e( 'File Format: ', 'tutor' ); ?> <span class="tutor-color-black">.mp4</span></p>
129 <p class="tutor-color-black"><?php esc_html_e( 'or', 'tutor' ); ?></p>
130
131 <div class="video_source_upload_wrap_html5">
132 <button class="video_upload_btn tutor-btn tutor-btn-secondary tutor-btn-md">
133 <?php esc_html_e( 'Browse File', 'tutor' ); ?>
134 </button>
135 <input type="hidden" class="input_source_video_id" name="video[source_video_id]" value="<?php echo esc_attr( $sourceVideoID ); ?>">
136 </div>
137 </div>
138
139 <div class="html5-video-data">
140 <?php
141 // Load Attachment card segment.
142 tutor_load_template_from_custom_path(
143 tutor()->path . '/views/fragments/attachments.php',
144 array(
145 'attachments' => array(
146 $videoAttachment ? $videoAttachment : (object) array(
147 'id' => 0,
148 'url' => '',
149 'title' => '',
150 'size' => '',
151 ),
152 ),
153 'size_below' => true,
154 'no_control' => true,
155 ),
156 false
157 );
158
159 //phpcs:ignore
160 echo '<div class="tutor-fs-6 tutor-fw-medium tutor-color-secondary tutor-mb-12" >' . __( 'Upload Video Poster', 'tutor' ) . '</div>';
161 // Load thumbnail segment.
162 tutor_load_template_from_custom_path(
163 tutor()->path . '/views/fragments/thumbnail-uploader.php',
164 array(
165 'media_id' => tutor_utils()->avalue_dot( 'poster', $video ),
166 'input_name' => 'video[poster]',
167 ),
168 false
169 );
170 ?>
171 </div>
172 </div>
173
174 <div class="tutor-mt-16 video-metabox-source-item video_source_wrap_external_url tutor-dashed-uploader" style="<?php tutor_video_input_state( $videoSource, 'external_url' ); ?>">
175 <input class="tutor-form-control" type="text" name="video[source_external_url]" value="<?php echo esc_attr( tutor_utils()->avalue_dot( 'source_external_url', $video ) ); ?>" placeholder="<?php esc_attr_e( 'Paste External Video URL', 'tutor' ); ?>">
176 </div>
177
178 <div class="tutor-mt-16 video-metabox-source-item video_source_wrap_shortcode tutor-dashed-uploader" style="<?php tutor_video_input_state( $videoSource, 'shortcode' ); ?>">
179 <input class="tutor-form-control" type="text" name="video[source_shortcode]" value="<?php echo esc_attr( tutor_utils()->avalue_dot( 'source_shortcode', $video ) ); ?>" placeholder="<?php esc_attr_e( 'Paste Shortcode', 'tutor' ); ?>">
180 </div>
181
182 <div class="tutor-mt-16 video-metabox-source-item video_source_wrap_youtube tutor-dashed-uploader" style="<?php tutor_video_input_state( $videoSource, 'youtube' ); ?>">
183 <input class="tutor-form-control" type="text" name="video[source_youtube]" value="<?php echo esc_attr( tutor_utils()->avalue_dot( 'source_youtube', $video ) ); ?>" placeholder="<?php esc_attr_e( 'Paste YouTube Video URL', 'tutor' ); ?>" data-youtube_api_key="<?php echo esc_attr( tutor_utils()->get_option( 'lesson_video_duration_youtube_api_key', '' ) ); ?>">
184 </div>
185
186 <div class="tutor-mt-16 video-metabox-source-item video_source_wrap_vimeo tutor-dashed-uploader" style="<?php tutor_video_input_state( $videoSource, 'vimeo' ); ?>">
187 <input class="tutor-form-control" type="text" name="video[source_vimeo]" value="<?php echo esc_attr( tutor_utils()->avalue_dot( 'source_vimeo', $video ) ); ?>" placeholder="<?php esc_attr_e( 'Paste Vimeo Video URL', 'tutor' ); ?>">
188 </div>
189
190 <div class="tutor-mt-16 video-metabox-source-item video_source_wrap_embedded tutor-dashed-uploader" style="<?php tutor_video_input_state( $videoSource, 'embedded' ); ?>">
191 <textarea class="tutor-form-control" name="video[source_embedded]" placeholder="<?php esc_attr_e( 'Place your embedded code here', 'tutor' ); ?>"><?php echo esc_textarea( tutor_utils()->avalue_dot( 'source_embedded', $video ) ); ?></textarea>
192 </div>
193 <?php do_action( 'tutor_after_video_meta_box_item', tutor_video_input_state( $videoSource, 'bunnynet', false ), $post ); ?>
194 </div>
195 </div>
196 </div>
197
198 <!-- For Lesson -->
199 <?php if ( $post->post_type !== tutor()->course_post_type ) : ?>
200 <div class="tutor-mb-20">
201 <label class="tutor-form-label"><?php esc_html_e( 'Video playback time', 'tutor' ); ?></label>
202 <div class="tutor-input-group tutor-option-field-video-duration">
203 <div class="tutor-row">
204 <div class="tutor-col-4">
205 <input class="tutor-form-control" type="number" value="<?php echo esc_attr( $runtimeHours ? $runtimeHours : '00' ); ?>" name="video[runtime][hours]" min="0">
206 <span><?php esc_html_e( 'Hour', 'tutor' ); ?></span>
207 </div>
208 <div class="tutor-col-4">
209 <input class="tutor-form-control" type="number" class="tutor-number-validation" data-min="0" data-max="59" value="<?php echo esc_attr( $runtimeMinutes ? $runtimeMinutes : '00' ); ?>" name="video[runtime][minutes]" min="0">
210 <span><?php esc_html_e( 'Minute', 'tutor' ); ?></span>
211 </div>
212 <div class="tutor-col-4">
213 <input class="tutor-form-control" type="number" class="tutor-number-validation" data-min="0" data-max="59" value="<?php echo esc_attr( $runtimeSeconds ? $runtimeSeconds : '00' ); ?>" name="video[runtime][seconds]" min="0">
214 <span><?php esc_html_e( 'Second', 'tutor' ); ?></span>
215 </div>
216 </div>
217 </div>
218 </div>
219 <?php endif; ?>
220