course
5 years ago
course-add-edd-product-metabox.php
5 years ago
course-add-product-metabox.php
5 years ago
course-additional-data.php
5 years ago
course-contents.php
5 years ago
course-level-metabox.php
5 years ago
course-topics.php
5 years ago
instructors-metabox.php
5 years ago
lesson-attachments-metabox.php
5 years ago
lesson-metabox.php
5 years ago
user-profile-fields.php
5 years ago
video-metabox.php
5 years ago
video-metabox.php
170 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Don't change it, it's supporting modal in other place |
| 4 | * if get_the_ID() empty, then it's means we are passing $post variable from another place |
| 5 | */ |
| 6 | if (get_the_ID()) |
| 7 | global $post; |
| 8 | |
| 9 | $video = maybe_unserialize(get_post_meta($post->ID, '_video', true)); |
| 10 | |
| 11 | $videoSource = tutor_utils()->avalue_dot('source', $video); |
| 12 | $runtimeHours = tutor_utils()->avalue_dot('runtime.hours', $video); |
| 13 | $runtimeMinutes = tutor_utils()->avalue_dot('runtime.minutes', $video); |
| 14 | $runtimeSeconds = tutor_utils()->avalue_dot('runtime.seconds', $video); |
| 15 | $sourceVideoID = tutor_utils()->avalue_dot('source_video_id', $video); |
| 16 | $poster = tutor_utils()->avalue_dot('poster', $video); |
| 17 | |
| 18 | $video_sources = array( |
| 19 | 'html5' => array('title' => __('HTML 5 (mp4)', 'tutor'), 'icon' => 'html5'), |
| 20 | 'external_url' => array('title' => __('External URL', 'tutor'), 'icon' => 'link'), |
| 21 | 'youtube' => array('title' => __('Youtube', 'tutor'), 'icon' => 'youtube'), |
| 22 | 'vimeo' => array('title' => __('Vimeo', 'tutor'), 'icon' => 'vimeo'), |
| 23 | 'embedded' => array('title' => __('Embedded', 'tutor'), 'icon' => 'code') |
| 24 | ); |
| 25 | |
| 26 | $supported_sources = tutor_utils()->get_option('supported_video_sources', $video_sources); |
| 27 | $supported_sources = array_keys($supported_sources); |
| 28 | |
| 29 | $default_source = tutor_utils()->get_option('default_video_source', null); |
| 30 | (!$videoSource && $default_source && in_array($default_source, $supported_sources)) ? $videoSource=$default_source : 0; |
| 31 | |
| 32 | ?> |
| 33 | |
| 34 | <div class="tutor-option-field-row"> |
| 35 | <div class="tutor-option-field-label"> |
| 36 | <label for=""> |
| 37 | <?php |
| 38 | if ($post->post_type === tutor()->course_post_type){ |
| 39 | _e('Course Intro Video', 'tutor'); |
| 40 | }else{ |
| 41 | _e('Video Source', 'tutor'); |
| 42 | } |
| 43 | ?> |
| 44 | </label> |
| 45 | </div> |
| 46 | |
| 47 | <div class="tutor-option-field tutor-video-upload-wrap"> |
| 48 | |
| 49 | <select name="video[source]" class="tutor_lesson_video_source videosource_select2"> |
| 50 | <option value="-1"><?php _e('Select Video Source', 'tutor'); ?></option> |
| 51 | <?php |
| 52 | foreach($video_sources as $value=>$source){ |
| 53 | if(in_array($value, $supported_sources)){ |
| 54 | echo '<option value="'.$value.'" '.selected($value, $videoSource).' data-icon="'.$source['icon'].'" >'.$source['title'].'</option>'; |
| 55 | } |
| 56 | } |
| 57 | ?> |
| 58 | </select> |
| 59 | |
| 60 | <p class="desc"> |
| 61 | <?php _e('Select your preferred video type.', 'tutor'); ?> |
| 62 | </p> |
| 63 | |
| 64 | <div class="video-metabox-source-input-wrap" style="display: <?php echo ! $videoSource ? 'none' : 'block'; ?>;"> |
| 65 | |
| 66 | <div class="video-metabox-source-item video_source_wrap_html5" style="display: <?php echo $videoSource === 'html5' ? 'block' : 'none'; ?>;"> |
| 67 | |
| 68 | <div class="video-metabox-source-html5-upload"> |
| 69 | <p class="video-upload-icon"><i class="tutor-icon-upload"></i></p> |
| 70 | <p><strong><?php _e('Upload Your Video'); ?></strong></p> |
| 71 | <p><?php _e('File Format: '); ?> .mp4</p> |
| 72 | |
| 73 | <div class="video_source_upload_wrap_html5"> |
| 74 | <a href="javascript:;" class="video_upload_btn tutor-button bordered-button"><?php _e('Upload Video', 'tutor'); ?></a> |
| 75 | <input type="hidden" class="input_source_video_id" name="video[source_video_id]" value="<?php echo $sourceVideoID; ?>" > |
| 76 | <p style="display: <?php echo $sourceVideoID ? 'block' : 'none'; ?>;"><?php _e('Media ID', 'tutor'); ?>: <span class="video_media_id"><?php echo $sourceVideoID; ?></span></p> |
| 77 | </div> |
| 78 | |
| 79 | </div> |
| 80 | |
| 81 | <div class="video-metabox-source-html5-poster"> |
| 82 | <div class="tutor-form-field tutor-form-field-course-thumbnail tutor-thumbnail-wrap"> |
| 83 | <div class="tutor-row tutor-align-items-center"> |
| 84 | <div class="tutor-col"> |
| 85 | <div class="builder-course-thumbnail-img-src html5-video-poster"> |
| 86 | <?php |
| 87 | $builder_course_img_src = tutor()->url . 'assets/images/placeholder-course.jpg'; |
| 88 | $poster_url = $builder_course_img_src; |
| 89 | if ( $poster){ |
| 90 | $poster_url = wp_get_attachment_image_url($poster); |
| 91 | } |
| 92 | ?> |
| 93 | <img src="<?php echo $poster_url; ?>" class="thumbnail-img" data-placeholder-src="<?php echo $builder_course_img_src; ?>"> |
| 94 | <a href="javascript:;" class="tutor-course-thumbnail-delete-btn" style="display: <?php echo |
| 95 | $poster ? 'block':'none'; ?>;"><i class="tutor-icon-line-cross"></i></a> |
| 96 | <div class="tutor-builder-course-video-poster-text"> |
| 97 | <h5><?php esc_html_e("Video Poster", 'tutor'); ?></h5> |
| 98 | <span><?php esc_html_e("Thumb Size: 700x430 pixels. File Support: jpg, jpeg, or png", 'tutor'); ?></span> |
| 99 | </div> |
| 100 | </div> |
| 101 | </div> |
| 102 | <div class="tutor-col-auto"> |
| 103 | <div class="builder-course-thumbnail-upload-wrap"> |
| 104 | <input type="hidden" id="tutor_course_thumbnail_id" name="video[poster]" value="<?php echo $poster; ?>"> |
| 105 | <a href="javascript:;" class="tutor-course-thumbnail-upload-btn tutor-button bordered-button |
| 106 | button-transparent"><i class="tutor-icon-photo-add"></i> <?php _e('Upload Image', 'tutor'); ?></a> |
| 107 | </div> |
| 108 | </div> |
| 109 | </div> |
| 110 | |
| 111 | </div> |
| 112 | </div> |
| 113 | </div> |
| 114 | |
| 115 | |
| 116 | <div class="video-metabox-source-item video_source_wrap_external_url" style="display: <?php echo $videoSource === 'external_url' ? 'block' : |
| 117 | 'none'; ?>;"> |
| 118 | <input type="text" name="video[source_external_url]" value="<?php echo tutor_utils()->avalue_dot('source_external_url', $video); |
| 119 | ?>" placeholder="<?php _e('External Video URL', 'tutor'); ?>"> |
| 120 | </div> |
| 121 | |
| 122 | <div class="video-metabox-source-item video_source_wrap_youtube" style="display: <?php echo $videoSource === 'youtube' ? 'block' : |
| 123 | 'none'; ?>;"> |
| 124 | <input type="text" name="video[source_youtube]" value="<?php echo tutor_utils()->avalue_dot('source_youtube', $video); ?>" placeholder="<?php _e('YouTube Video URL', 'tutor'); ?>" data-youtube_api_key="<?php echo tutils()->get_option('lesson_video_duration_youtube_api_key', ''); ?>"> |
| 125 | </div> |
| 126 | <div class="video-metabox-source-item video_source_wrap_vimeo" style="display: <?php echo $videoSource === 'vimeo' ? 'block' : 'none'; ?>;"> |
| 127 | <input type="text" name="video[source_vimeo]" value="<?php echo tutor_utils()->avalue_dot('source_vimeo', $video); ?>" placeholder="<?php _e('Vimeo Video URL', 'tutor'); ?>"> |
| 128 | </div> |
| 129 | <div class="video-metabox-source-item video_source_wrap_embedded" style="display: <?php echo $videoSource === 'embedded' ? 'block' : 'none'; ?>;"> |
| 130 | <textarea name="video[source_embedded]" placeholder="<?php _e('Place your embedded code here', 'tutor'); ?>"><?php echo tutor_utils() |
| 131 | ->avalue_dot |
| 132 | ('source_embedded', $video); |
| 133 | ?></textarea> |
| 134 | </div> |
| 135 | |
| 136 | </div> |
| 137 | |
| 138 | </div> |
| 139 | </div> |
| 140 | <?php |
| 141 | if ( $post->post_type !== tutor()->course_post_type){ |
| 142 | ?> |
| 143 | <div class="tutor-option-field-row tutor-option-field-video-duration"> |
| 144 | <div class="tutor-option-field-label"> |
| 145 | <label for=""><?php _e('Video playback time', 'tutor'); ?></label> |
| 146 | </div> |
| 147 | <div class="tutor-option-field"> |
| 148 | <div class="tutor-option-gorup-fields-wrap"> |
| 149 | <div class="tutor-lesson-video-runtime"> |
| 150 | <div class="tutor-option-group-field"> |
| 151 | <input type="number" value="<?php echo $runtimeHours ? $runtimeHours : '00'; ?>" name="video[runtime][hours]"> |
| 152 | <p class="desc"><?php _e('HH', 'tutor'); ?></p> |
| 153 | </div> |
| 154 | |
| 155 | <div class="tutor-option-group-field"> |
| 156 | <input type="number" class="tutor-number-validation" data-min="0" data-max="59" value="<?php echo $runtimeMinutes ? $runtimeMinutes : '00'; ?>" name="video[runtime][minutes]"> |
| 157 | <p class="desc"><?php _e('MM', 'tutor'); ?></p> |
| 158 | </div> |
| 159 | |
| 160 | <div class="tutor-option-group-field"> |
| 161 | <input type="number" class="tutor-number-validation" data-min="0" data-max="59" value="<?php echo $runtimeSeconds ? $runtimeSeconds : '00'; ?>" name="video[runtime][seconds]"> |
| 162 | <p class="desc"><?php _e('SS', 'tutor'); ?></p> |
| 163 | </div> |
| 164 | </div> |
| 165 | </div> |
| 166 | </div> |
| 167 | </div> |
| 168 | <?php |
| 169 | } |
| 170 | ?> |