course
4 years ago
course-add-edd-product-metabox.php
4 years ago
course-add-product-metabox.php
4 years ago
course-additional-data.php
4 years ago
course-contents.php
4 years ago
course-level-metabox.php
4 years ago
course-topics.php
4 years ago
instructors-metabox.php
4 years ago
lesson-attachments-metabox.php
4 years ago
lesson-metabox.php
4 years ago
product-selection.php
4 years ago
settings-tabs.php
4 years ago
user-profile-fields.php
4 years ago
video-metabox.php
4 years ago
video-metabox.php
157 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Don't change it, it's supporting modal in other place |
| 5 | * if get_the_ID() empty, then it's means we are passing $post variable from another place |
| 6 | */ |
| 7 | if (get_the_ID()) |
| 8 | global $post; |
| 9 | |
| 10 | $video = maybe_unserialize(get_post_meta($post->ID, '_video', true)); |
| 11 | $videoSource = tutor_utils()->avalue_dot('source', $video, 'html5'); |
| 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 | $videoAttachment = $sourceVideoID ? tutor_utils()->get_attachment_data($sourceVideoID) : null; |
| 18 | |
| 19 | $video_sources = tutor_utils()->get_video_sources(false); |
| 20 | |
| 21 | $supported_sources = tutor_utils()->get_option('supported_video_sources', array()); |
| 22 | !is_array($supported_sources) ? $supported_sources = array($supported_sources) : 0; |
| 23 | $GLOBALS['supported_sources'] = $supported_sources; |
| 24 | |
| 25 | if (!is_array($supported_sources) || !count($supported_sources)) { |
| 26 | $notice = __('No video source selected from settings!', 'tutor'); |
| 27 | echo "<div class='tutor-alert tutor-warning'> |
| 28 | <div class='tutor-alert-text'> |
| 29 | <span class='tutor-alert-icon tutor-fs-4 tutor-icon-circle-info tutor-mr-12'></span> |
| 30 | <span>{$notice}</span> |
| 31 | </div> |
| 32 | </div>"; |
| 33 | // _e('No video source selected from settings!', 'tutor'); |
| 34 | return; |
| 35 | } |
| 36 | |
| 37 | |
| 38 | function tutor_video_input_state($videoSource, $source){ |
| 39 | $value = ($videoSource == $source && in_array($source, $GLOBALS['supported_sources'])) ? 'block' : 'none'; |
| 40 | echo 'display:'.$value.';'; |
| 41 | } |
| 42 | ?> |
| 43 | |
| 44 | <div class="tutor-mb-32"> |
| 45 | <label class="tutor-form-label"> |
| 46 | <?php |
| 47 | if ($post->post_type === tutor()->course_post_type) { |
| 48 | _e('Course Intro Video', 'tutor'); |
| 49 | } else { |
| 50 | _e('Video Source', 'tutor'); |
| 51 | } |
| 52 | ?> |
| 53 | </label> |
| 54 | |
| 55 | <div class="tutor-input-group tutor-mb-16 tutor-mt-12 tutor-d-block"> |
| 56 | <div class="tutor-video-upload-wrap"> |
| 57 | <div class="tutor-dropdown-icon-pack tutor-mt-4" data-video_source="<?php echo empty($videoSource) ? '' : $videoSource; ?>"> |
| 58 | <i class="tutor-icon-brand-html5-bold" data-for="html5"></i> |
| 59 | <i class="tutor-icon-brand-youtube-line" data-for="youtube"></i> |
| 60 | <i class="tutor-icon-brand-vimeo-line" data-for="vimeo"></i> |
| 61 | <i class="tutor-icon-shortcode" data-for="shortcode"></i> |
| 62 | <i class="tutor-icon-link" data-for="external_url"></i> |
| 63 | <i class="tutor-icon-coding" data-for="embedded"></i> |
| 64 | </div> |
| 65 | <select name="video[source]" class="tutor-form-control tutor-select-icon-primary tutor_lesson_video_source no-tutor-dropdown"> |
| 66 | <option value="-1"><?php _e('Select Video Source', 'tutor'); ?></option> |
| 67 | <?php |
| 68 | foreach ($video_sources as $value => $source) { |
| 69 | if (in_array($value, $supported_sources)) { |
| 70 | echo '<option value="' . $value . '" ' . selected($value, $videoSource) . ' data-icon="' . $source['icon'] . '"> |
| 71 | ' . $source['title'] . ' |
| 72 | </option>'; |
| 73 | } |
| 74 | } |
| 75 | ?> |
| 76 | </select> |
| 77 | |
| 78 | <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'); ?>"> |
| 79 | <div class="video-metabox-source-html5-upload"> |
| 80 | <p class="video-upload-icon"><i class="tutor-icon-upload-icon-line"></i></p> |
| 81 | <p><strong><?php _e('Drag & Drop Your Video', 'tutor'); ?></strong></p> |
| 82 | <p><?php _e('File Format: ', 'tutor'); ?> <span class="tutor-color-black">.mp4</span></p> |
| 83 | <p class="tutor-color-black"><?php _e('or', 'tutor'); ?></p> |
| 84 | |
| 85 | <div class="video_source_upload_wrap_html5"> |
| 86 | <button class="video_upload_btn tutor-btn tutor-btn-secondary tutor-btn-md"> |
| 87 | <?php _e('Browse File', 'tutor'); ?> |
| 88 | </button> |
| 89 | <input type="hidden" class="input_source_video_id" name="video[source_video_id]" value="<?php echo $sourceVideoID; ?>"> |
| 90 | </div> |
| 91 | </div> |
| 92 | |
| 93 | <div class="html5-video-data"> |
| 94 | <?php |
| 95 | // Load Attachment card segment |
| 96 | tutor_load_template_from_custom_path(tutor()->path . '/views/fragments/attachments.php', array( |
| 97 | 'attachments' => array($videoAttachment ? $videoAttachment : (object)array('id' => 0, 'url' => '', 'title' => '', 'size' => '')), |
| 98 | 'size_below' => true, |
| 99 | 'no_control' => true |
| 100 | ), false); |
| 101 | |
| 102 | echo '<div class="tutor-fs-6 tutor-fw-medium tutor-color-secondary tutor-mb-12" >' . __('Upload Video Poster', 'tutor') . '</div>'; |
| 103 | // Load thumbnail segment |
| 104 | tutor_load_template_from_custom_path(tutor()->path . '/views/fragments/thumbnail-uploader.php', array( |
| 105 | 'media_id' => tutor_utils()->avalue_dot('poster', $video), |
| 106 | 'input_name' => 'video[poster]' |
| 107 | ), false); |
| 108 | ?> |
| 109 | </div> |
| 110 | </div> |
| 111 | |
| 112 | <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'); ?>"> |
| 113 | <input class="tutor-form-control" type="text" name="video[source_external_url]" value="<?php echo tutor_utils()->avalue_dot('source_external_url', $video); ?>" placeholder="<?php _e('Paste External Video URL', 'tutor'); ?>"> |
| 114 | </div> |
| 115 | |
| 116 | <div class="tutor-mt-16 video-metabox-source-item video_source_wrap_shortcode tutor-dashed-uploader" style="<?php tutor_video_input_state($videoSource, 'shortcode'); ?>"> |
| 117 | <input class="tutor-form-control" type="text" name="video[source_shortcode]" value="<?php echo tutor_utils()->avalue_dot('source_shortcode', $video); ?>" placeholder="<?php _e('Paste Shortcode', 'tutor'); ?>"> |
| 118 | </div> |
| 119 | |
| 120 | <div class="tutor-mt-16 video-metabox-source-item video_source_wrap_youtube tutor-dashed-uploader" style="<?php tutor_video_input_state($videoSource, 'youtube'); ?>"> |
| 121 | <input class="tutor-form-control" type="text" name="video[source_youtube]" value="<?php echo tutor_utils()->avalue_dot('source_youtube', $video); ?>" placeholder="<?php _e('Paste YouTube Video URL', 'tutor'); ?>" data-youtube_api_key="<?php echo tutor_utils()->get_option('lesson_video_duration_youtube_api_key', ''); ?>"> |
| 122 | </div> |
| 123 | |
| 124 | <div class="tutor-mt-16 video-metabox-source-item video_source_wrap_vimeo tutor-dashed-uploader" style="<?php tutor_video_input_state($videoSource, 'vimeo'); ?>"> |
| 125 | <input class="tutor-form-control" type="text" name="video[source_vimeo]" value="<?php echo tutor_utils()->avalue_dot('source_vimeo', $video); ?>" placeholder="<?php _e('Paste Vimeo Video URL', 'tutor'); ?>"> |
| 126 | </div> |
| 127 | |
| 128 | <div class="tutor-mt-16 video-metabox-source-item video_source_wrap_embedded tutor-dashed-uploader" style="<?php tutor_video_input_state($videoSource, 'embedded'); ?>"> |
| 129 | <textarea class="tutor-form-control" name="video[source_embedded]" placeholder="<?php _e('Place your embedded code here', 'tutor'); ?>"><?php echo tutor_utils()->avalue_dot('source_embedded', $video); ?></textarea> |
| 130 | </div> |
| 131 | </div> |
| 132 | </div> |
| 133 | </div> |
| 134 | |
| 135 | <!-- For Lesson --> |
| 136 | <?php if ($post->post_type !== tutor()->course_post_type) : ?> |
| 137 | <div class="tutor-mb-20"> |
| 138 | <label class="tutor-form-label"><?php _e('Video playback time', 'tutor'); ?></label> |
| 139 | <div class="tutor-input-group tutor-option-field-video-duration"> |
| 140 | <div class="tutor-row"> |
| 141 | <div class="tutor-col-4"> |
| 142 | <input class="tutor-form-control" type="number" value="<?php echo $runtimeHours ? $runtimeHours : '00'; ?>" name="video[runtime][hours]" min="0"> |
| 143 | <span><?php _e('Hour', 'tutor'); ?></span> |
| 144 | </div> |
| 145 | <div class="tutor-col-4"> |
| 146 | <input class="tutor-form-control" type="number" class="tutor-number-validation" data-min="0" data-max="59" value="<?php echo $runtimeMinutes ? $runtimeMinutes : '00'; ?>" name="video[runtime][minutes]" min="0"> |
| 147 | <span><?php _e('Minute', 'tutor'); ?></span> |
| 148 | </div> |
| 149 | <div class="tutor-col-4"> |
| 150 | <input class="tutor-form-control" type="number" class="tutor-number-validation" data-min="0" data-max="59" value="<?php echo $runtimeSeconds ? $runtimeSeconds : '00'; ?>" name="video[runtime][seconds]" min="0"> |
| 151 | <span><?php _e('Second', 'tutor'); ?></span> |
| 152 | </div> |
| 153 | </div> |
| 154 | </div> |
| 155 | </div> |
| 156 | <?php endif; ?> |
| 157 |