PluginProbe ʕ •ᴥ•ʔ
Video Playlist for YouTube / 6.7
Video Playlist for YouTube v6.7
trunk 1.0 2.0 3.0 4.0 6.0 6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.7.1 6.8 6.9
video-playlist-for-youtube / video-playlist-ytb-plugin.php
video-playlist-for-youtube Last commit date
includes 1 year ago index.php 6 years ago readme.txt 1 year ago video-playlist-ytb-plugin.php 1 year ago vpfy-api-playlist-shortcode.php 1 year ago vpfy-settings-pg.php 1 year ago vpfy-vplaylist-functions.php 1 year ago
video-playlist-ytb-plugin.php
515 lines
1 <?php
2 /*
3 * Plugin Name: Video Playlist for YouTube
4 * Plugin URI: https://wordpress.org/plugins/video-playlist-for-youtube
5 * Description: It is a very nifty responsive video playlist for youtube that helps you display youtube channels and videos on your website. By using this plugin you can create unlimited playlist while setting up many options and arrange them in any order using drag n drop features.
6 * Version: 6.7
7 * Author: Galaxy Weblinks
8 * Author URI: https://www.galaxyweblinks.com/
9 * Text Domain: video-playlist-for-youtube
10 * License: GPLv2 or later
11 * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12 */
13
14 if (! defined('ABSPATH')) {
15 exit; // Exit if accessed directly
16 }
17
18 if (!defined('VID_PLYLST_PLUGINURL')) {
19 define('VID_PLYLST_PLUGINURL', plugin_dir_url(__FILE__));
20 }
21 if (!defined('VID_PLYLST_PLUGINPATH')) {
22 define('VID_PLYLST_PLUGINPATH', plugin_dir_path(__FILE__));
23 }
24
25
26 //echo "path ".VID_PLYLST_PLUGINPATH;
27 require_once(VID_PLYLST_PLUGINPATH . 'vpfy-vplaylist-functions.php');
28 require_once(VID_PLYLST_PLUGINPATH . 'vpfy-settings-pg.php');
29 require_once(VID_PLYLST_PLUGINPATH . 'vpfy-api-playlist-shortcode.php');
30 //admin notice when activate plugin
31 register_activation_hook(__FILE__, 'uvfy_vplay_adminnotice');
32 function uvfy_vplay_adminnotice()
33 {
34 update_option('video_plylst_admin_notice', 'enabled');
35 }
36 function uvfy_vplay_admin_notice__success()
37 {
38 if (get_option('video_plylst_admin_notice') == 'enabled') {
39 ?>
40
41 <div class="notice notice-success is-dismissible">
42 <p><?php esc_attr_e('To view setting please ', 'video-playlist-for-youtube'); ?>
43 <a href="<?php echo esc_attr(admin_url('edit.php?post_type=vid_playlist_ytub')); ?>"><?php esc_attr_e('click here', 'video-playlist-for-youtube'); ?></a>
44 </p>
45 </div>
46 <?php
47 delete_option('video_plylst_admin_notice');
48 }
49 }
50 add_action('admin_notices', 'uvfy_vplay_admin_notice__success');
51
52 //Add Menu Page
53 add_action('admin_menu', 'vpfu_vplay_add_menu');
54 function vpfu_vplay_add_menu()
55 {
56 add_menu_page('video playlist', __('Video Playlist', 'video-playlist-for-youtube'), 'manage_options', 'edit.php?post_type=vid_playlist_ytub', NULL);
57 add_submenu_page('edit.php?post_type=vid_playlist_ytub', 'settings', __('Settings', 'video-playlist-for-youtube'), 'manage_options', 'vpfy_settings_menu', 'vpfy_submenu_settings_page');
58 add_action('admin_init', 'vpfyt_settings_api_forytub');
59 }
60 /*Register setting api*/
61 function vpfyt_settings_api_forytub()
62 {
63 register_setting('vpfy_reg_groupname', 'vpfy_reg_ytubapi_key');
64 }
65
66 add_action('init', 'vpfy_vplaylist_custompt', 0);
67 /*
68 * Creating a function to create our CPT
69 */
70
71 function vpfy_vplaylist_custompt()
72 {
73
74 // Set UI labels for Custom Post Type
75 $labels = array(
76 'name' => _x('Playlists', 'Post Type General Name', 'video-playlist-for-youtube'),
77 'singular_name' => _x('Playlist', 'Post Type Singular Name', 'video-playlist-for-youtube'),
78 'menu_name' => __('Playlists', 'video-playlist-for-youtube'),
79 'parent_item_colon' => __('Parent Playlist', 'video-playlist-for-youtube'),
80 'all_items' => __('All Playlists', 'video-playlist-for-youtube'),
81 'view_item' => __('View Playlist', 'video-playlist-for-youtube'),
82 'add_new_item' => __('Add New Playlist', 'video-playlist-for-youtube'),
83 'add_new' => __('Add New', 'video-playlist-for-youtube'),
84 'edit_item' => __('Edit Playlist', 'video-playlist-for-youtube'),
85 'update_item' => __('Update Playlist', 'video-playlist-for-youtube'),
86 'search_items' => __('Search Playlist', 'video-playlist-for-youtube'),
87 'not_found' => __('Not Found', 'video-playlist-for-youtube'),
88 'not_found_in_trash' => __('Not found in Trash', 'video-playlist-for-youtube'),
89 );
90
91 // Set other options for Custom Post Type
92
93 $args = array(
94 'label' => __('Playlists', 'video-playlist-for-youtube'),
95 'description' => __('Playlist for youtube videos', 'video-playlist-for-youtube'),
96 'labels' => $labels,
97 // Features this CPT supports in Post Editor
98 'supports' => array('title'),
99 'hierarchical' => false,
100 'public' => false,
101 'show_ui' => true,
102 'show_in_menu' => 'edit.php?post_type=vid_playlist_ytub',
103 'show_in_nav_menus' => false,
104 'show_in_admin_bar' => true,
105 'menu_position' => null,
106 'can_export' => true,
107 'has_archive' => true,
108 'exclude_from_search' => false,
109 'publicly_queryable' => false,
110 'capability_type' => 'post',
111 'show_in_rest' => true,
112
113 );
114
115 // Registering Custom Post Type
116 register_post_type('vid_playlist_ytub', $args);
117 }
118 /* Add Meta box for shortcode*/
119 add_action('admin_init', 'vpfy_vplaylist_add_meta_boxes_for_shortcode', 2);
120
121 function vpfy_vplaylist_add_meta_boxes_for_shortcode()
122 {
123 add_meta_box('vpfy-vplay-gallery-for-shortcode', __('Shortcode', 'video-playlist-for-youtube'), 'vpfy_vplaylist_for_shortcode_display', 'vid_playlist_ytub', 'side', 'default');
124
125 add_meta_box('vpfy-vplay-videogallery-setings', __('Slider Settings', 'video-playlist-for-youtube'), 'vpfy_vplaylist_slider_settings', 'vid_playlist_ytub', 'side', 'default');
126 }
127
128 function vpfy_vplaylist_for_shortcode_display()
129 {
130 $ytube_current_id = get_the_ID();
131 echo esc_attr("[videoPlaylist id=" . esc_attr($ytube_current_id) . "]");
132 }
133
134 /* Add Meta box*/
135
136 add_action('admin_init', 'vpfysect_vplaylist_add_meta_boxes', 2);
137
138 function vpfysect_vplaylist_add_meta_boxes()
139 {
140 add_meta_box('ytube-vplay-gallery', __('Add YouTube Video URL', 'video-playlist-for-youtube'), 'vpfy_vplaylist_repeatable_meta_box_display', 'vid_playlist_ytub', 'normal', 'default');
141 }
142
143 function vpfy_vplaylist_repeatable_meta_box_display()
144 {
145 global $post;
146 $gpminvoice_group = get_post_meta($post->ID, 'customdata_group', true);
147 wp_nonce_field('gpm_repeatable_meta_box_nonce', 'gpm_repeatable_meta_box_nonce');
148 wp_enqueue_script('vpfyt-vplay-repeatmeta');
149 wp_enqueue_style('vpfy-vplay-adminstyle');
150 wp_enqueue_script('jquery-ui-sortable');
151 ?>
152 <script>
153 jQuery(function() {
154 //jQuery( "tr" ).draggable({ handle: ".ytubedraggable" });
155 jQuery("tbody.ytub-sortble").sortable();
156 jQuery("tbody.ytub-sortble").disableSelection();
157 });
158 </script>
159
160
161 <table id="repeatable-fieldset-one" width="100%">
162 <tbody class="ytub-sortble">
163 <?php
164 if ($gpminvoice_group) :
165 foreach ($gpminvoice_group as $field) {
166 ?>
167 <tr class="drgble-sect">
168 <td width="20%">
169 <input type="text" required="required" placeholder="Title" name="TitleItem[]" value="<?php if ($field['TitleItem'] != '') echo esc_attr($field['TitleItem']); ?>" />
170 </td>
171 <td width="30%">
172 <textarea placeholder="Description" cols="40" rows="3" name="TitleDescription[]"> <?php if ($field['TitleDescription'] != '') echo esc_attr($field['TitleDescription']); ?> </textarea>
173 </td>
174 <td width="10%">
175 <input type="number" placeholder="Description length" name="Descriptionlength[]" value="<?php if ($field['Descriptionlength'] != '') echo esc_attr($field['Descriptionlength']); ?>" />
176 </td>
177 <td width="30%">
178 <input type="text" placeholder="Youtube URL" name="YoutubeUr[]" value="<?php if ($field['YoutubeUr'] != '') echo esc_attr($field['YoutubeUr']); ?>" />
179 </td>
180
181 <td width="10%"><a class="button remove-row" href="#1">Remove</a><span class="ytubedraggable">
182 <svg width="18" height="18" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" role="img" aria-hidden="true" focusable="false">
183 <path d="M13,8c0.6,0,1-0.4,1-1s-0.4-1-1-1s-1,0.4-1,1S12.4,8,13,8z M5,6C4.4,6,4,6.4,4,7s0.4,1,1,1s1-0.4,1-1S5.6,6,5,6z M5,10 c-0.6,0-1,0.4-1,1s0.4,1,1,1s1-0.4,1-1S5.6,10,5,10z M13,10c-0.6,0-1,0.4-1,1s0.4,1,1,1s1-0.4,1-1S13.6,10,13,10z M9,6 C8.4,6,8,6.4,8,7s0.4,1,1,1s1-0.4,1-1S9.6,6,9,6z M9,10c-0.6,0-1,0.4-1,1s0.4,1,1,1s1-0.4,1-1S9.6,10,9,10z"></path>
184 </svg></span></td>
185 </tr>
186 <?php wp_nonce_field('gpm_repeatable_meta_box_nonce', 'gpm_repeatable_meta_box_nonce');
187 }
188 else :
189 // show a blank one
190 ?>
191 <tr class="drgble-sect">
192 <td>
193 <input type="text" required="required" placeholder="Title" title="Title" name="TitleItem[]" />
194 </td>
195 <td>
196 <textarea placeholder="Description" name="TitleDescription[]" cols="40" rows="3"> </textarea>
197 </td>
198 <td>
199 <input type="text" required="required" placeholder="Description length" title="Description lenght" name="Descriptionlength[]" />
200 </td>
201 <td>
202 <input type="text" placeholder="Youtube URL" name="YoutubeUr[]" />
203 </td>
204
205 <td><a class="button cmb-remove-row-button button-disabled" href="#">Remove</a><span class="ytubedraggable">
206 <svg width="18" height="18" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" role="img" aria-hidden="true" focusable="false">
207 <path d="M13,8c0.6,0,1-0.4,1-1s-0.4-1-1-1s-1,0.4-1,1S12.4,8,13,8z M5,6C4.4,6,4,6.4,4,7s0.4,1,1,1s1-0.4,1-1S5.6,6,5,6z M5,10 c-0.6,0-1,0.4-1,1s0.4,1,1,1s1-0.4,1-1S5.6,10,5,10z M13,10c-0.6,0-1,0.4-1,1s0.4,1,1,1s1-0.4,1-1S13.6,10,13,10z M9,6 C8.4,6,8,6.4,8,7s0.4,1,1,1s1-0.4,1-1S9.6,6,9,6z M9,10c-0.6,0-1,0.4-1,1s0.4,1,1,1s1-0.4,1-1S9.6,10,9,10z"></path>
208 </svg></span></td>
209 </tr>
210 <?php wp_nonce_field('gpm_repeatable_meta_box_nonce', 'gpm_repeatable_meta_box_nonce');
211
212 endif; ?>
213
214 <!-- empty hidden one for jQuery -->
215 <tr class="empty-row screen-reader-text drgble-sect">
216 <td>
217 <input type="text" placeholder="Title" name="TitleItem[]" />
218 </td>
219 <td>
220 <textarea placeholder="Description" cols="40" rows="3" name="TitleDescription[]"></textarea>
221 </td>
222 <td>
223 <input type="text" placeholder="Description length" name="Descriptionlength[]" />
224 </td>
225 <td>
226 <input type="text" placeholder="Youtube URL" name="YoutubeUr[]" />
227 </td>
228 <td><a class="button remove-row" href="#">Remove</a><span class="ytubedraggable">
229 <svg width="18" height="18" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" role="img" aria-hidden="true" focusable="false">
230 <path d="M13,8c0.6,0,1-0.4,1-1s-0.4-1-1-1s-1,0.4-1,1S12.4,8,13,8z M5,6C4.4,6,4,6.4,4,7s0.4,1,1,1s1-0.4,1-1S5.6,6,5,6z M5,10 c-0.6,0-1,0.4-1,1s0.4,1,1,1s1-0.4,1-1S5.6,10,5,10z M13,10c-0.6,0-1,0.4-1,1s0.4,1,1,1s1-0.4,1-1S13.6,10,13,10z M9,6 C8.4,6,8,6.4,8,7s0.4,1,1,1s1-0.4,1-1S9.6,6,9,6z M9,10c-0.6,0-1,0.4-1,1s0.4,1,1,1s1-0.4,1-1S9.6,10,9,10z"></path>
231 </svg></span></td>
232 </tr>
233 </tbody>
234 </table>
235 <p><a id="add-row" class="button" href="#">Add another</a></p>
236 <?php
237 }
238 add_action('save_post', 'custom_repeatable_meta_box_save');
239 function custom_repeatable_meta_box_save($post_id)
240 {
241
242 //check_admin_referer('gpm_repeatable_meta_box_nonce', 'gpm_repeatable_meta_box_nonce');
243
244 if (
245 ! isset($_POST['gpm_repeatable_meta_box_nonce']) ||
246 ! wp_verify_nonce($_POST['gpm_repeatable_meta_box_nonce'], 'gpm_repeatable_meta_box_nonce')
247 )
248 return;
249
250 if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
251 return;
252
253 if (!current_user_can('edit_post', $post_id))
254 return;
255
256 $old = get_post_meta($post_id, 'customdata_group', true);
257 $new = array();
258
259
260 /* Title */
261 $invoiceItems = array();
262 foreach ($_POST['TitleItem'] as $titlValue) {
263 $invoiceItems[] = sanitize_text_field($titlValue);
264 }
265 /*Description*/
266 $prices = array();
267 foreach ($_POST['TitleDescription'] as $titlDesValue) {
268 $prices[] = sanitize_textarea_field($titlDesValue);
269 }
270
271 /*Description length*/
272 $deslength = array();
273 foreach ($_POST['Descriptionlength'] as $titlDesLength) {
274 $deslength[] = sanitize_textarea_field($titlDesLength);
275 }
276
277 /*URL*/
278 $YoutubeUr = array();
279 foreach ($_POST['YoutubeUr'] as $youtubeUrlValue) {
280 $YoutubeUr[] = sanitize_text_field($youtubeUrlValue);
281 }
282
283 $count = count($invoiceItems);
284 for ($i = 0; $i < $count; $i++) {
285 if ($invoiceItems[$i] != '') :
286 $new[$i]['TitleItem'] = stripslashes(wp_strip_all_tags(trim($invoiceItems[$i])));
287 $new[$i]['Descriptionlength'] = stripslashes(wp_strip_all_tags(trim($deslength[$i])));
288 $new[$i]['TitleDescription'] = stripslashes(trim($prices[$i])); // and however you want to sanitize
289 $new[$i]['YoutubeUr'] = filter_var($YoutubeUr[$i], FILTER_SANITIZE_URL);
290 endif;
291 }
292 if (!empty($new) && $new != $old)
293 update_post_meta($post_id, 'customdata_group', $new);
294 elseif (empty($new) && $old)
295 delete_post_meta($post_id, 'customdata_group', $old);
296 if (isset($_POST['utubeSliderRange'])) {
297 $new_itm_range = array();
298 foreach ($_POST['utubeSliderRange'] as $rangevalue) {
299 $new_itm_range[] = sanitize_text_field($rangevalue);
300 }
301 update_post_meta($post_id, '_utubeSliderRange', $new_itm_range);
302 }
303 }
304
305 /*Display playlist*/
306 /*Display playlist*/
307 add_shortcode('videoPlaylist', 'vpfy_vplaylist_display_gallery');
308 function vpfy_vplaylist_display_gallery($atts)
309 {
310 $arry_arg = shortcode_atts(array('id' => ''), $atts);
311
312 $output = '';
313 ob_start(); ?>
314 <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800%7CShadows+Into+Light" rel="stylesheet" type="text/css">
315 <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script>
316 <?php
317 wp_enqueue_script('vpfy-playlist-min');
318 wp_enqueue_script('vpfy-playlist-video');
319 wp_enqueue_script('vpfy-unitegallery-video');
320 wp_enqueue_style('vpfy-vplay-galcss');
321 wp_enqueue_style('vpfy-playlist-ryt-no-thumb');
322 wp_enqueue_style('vpfy-playlist-ryt-thumb');
323 wp_enqueue_style('vpfy-playlist-ryt-ttl-only');
324 wp_enqueue_style('vpfy-unite-gallery');
325
326 if (!empty($arry_arg['id'])) {
327 $ytube_custmgrp = get_post_meta($arry_arg['id'], 'customdata_group', true);
328
329 echo ('<div id="gallery' . esc_attr($arry_arg['id']) . '" style="margin:0px auto;display:none;">');
330 foreach ($ytube_custmgrp as $ykey => $ytubvalue) {
331 $ytuburl = parse_url($ytubvalue['YoutubeUr']);
332
333 $existance = 0;
334 foreach ($ytuburl as $utkey => $utvalue) {
335 if ('query' == $utkey) {
336 $existance = 1;
337 } else {
338 $existance = 0;
339 }
340 }
341
342 if ($existance == 1) {
343 $ytubid = explode('v=', $ytuburl['query']);
344 $ytubid = explode('&', $ytubid[1]);
345 if (strlen($ytubvalue['TitleItem']) > 25) {
346 $ytvidTitle = substr($ytubvalue['TitleItem'], 0, 25) . "...";
347 } else {
348 $ytvidTitle = $ytubvalue['TitleItem'];
349 }
350
351 // Set default description length to 80 if not provided
352 $descriptionlength = !empty($ytubvalue['Descriptionlength']) && is_numeric($ytubvalue['Descriptionlength']) ? $ytubvalue['Descriptionlength'] : 80;
353 ?>
354 <div data-type="youtube"
355 data-title="<?php echo esc_attr($ytvidTitle); ?>"
356 data-description="<?php echo esc_attr(substr($ytubvalue['TitleDescription'], 0, $descriptionlength)); ?>"
357 data-thumb="https://i.ytimg.com/vi/<?php echo esc_attr($ytubid[0]); ?>/mqdefault.jpg"
358 data-image="https://i.ytimg.com/vi/<?php echo esc_attr($ytubid[0]); ?>/sddefault.jpg"
359 data-videoid="<?php echo esc_attr($ytubid[0]); ?>"></div>
360 <?php } elseif ($existance == 0) { ?>
361 <div data-type="youtube"
362 data-title="<?php echo esc_attr($ytubvalue['TitleItem']); ?>"
363 data-description="<?php echo esc_attr(substr($ytubvalue['TitleDescription'], 0, $descriptionlength)); ?>"
364 data-thumb="https://i.ytimg.com/vi/123/mqdefault.jpg"
365 data-image="https://i.ytimg.com/vi/123/sddefault.jpg"
366 data-videoid="123"></div>
367 <?php }
368 }
369 echo ('</div>');
370
371 if (null !== get_post_meta($arry_arg['id'], '_utubeSliderRange', true)) {
372 $sliderRange = get_post_meta($arry_arg['id'], '_utubeSliderRange', true);
373 }
374 $sliderWidth = !empty($sliderRange) ? $sliderRange[0] : '1100';
375 $sliderHeight = !empty($sliderRange) ? $sliderRange[1] : '450';
376 if (!empty(get_option('vpfy_vid_autoply')) && get_option('vpfy_vid_autoply') == 1) {
377 $autoply = 'true';
378 } else {
379 $autoply = 'false';
380 }
381 ?>
382 <script>
383 jQuery(document).ready(function() {
384 jQuery("#gallery<?php echo esc_attr($arry_arg['id']); ?>").unitegallery({
385 gallery_theme: "video",
386 gallery_width: <?php echo esc_attr($sliderWidth); ?>,
387 gallery_height: <?php echo esc_attr($sliderHeight); ?>,
388 theme_autoplay: <?php echo esc_attr($autoply); ?>,
389 });
390 });
391 </script>
392 <?php
393 }
394 ?>
395
396 <?php $output = ob_get_clean();
397 return $output;
398 }
399
400 // Add the custom columns to the youtube playlist post type:
401 add_filter('manage_vid_playlist_ytub_posts_columns', 'set_custom_vpfy_shortcode_columns');
402 function set_custom_vpfy_shortcode_columns($columns)
403 {
404 $columns['vpfy_col_shortcode'] = __('Shortcode', 'video-playlist-for-youtube');
405 return $columns;
406 }
407
408 // Add the data to the custom columns for the youtube playlist post type:
409 add_action('manage_vid_playlist_ytub_posts_custom_column', 'vpfy_custom_vidyou_column', 10, 2);
410 function vpfy_custom_vidyou_column($column, $post_id)
411 {
412 switch ($column) {
413
414 case 'vpfy_col_shortcode':
415 echo esc_attr("[videoPlaylist id=" . $post_id . "]");
416 break;
417 }
418 }
419
420
421 /*Plugin settings */
422 function vpfy_vplaylist_slider_settings()
423 {
424 if (null !== get_post_meta(get_the_ID(), '_utubeSliderRange', true)) {
425 $sliderRange = get_post_meta(get_the_ID(), '_utubeSliderRange', true);
426 }
427 $sliderWidth = !empty($sliderRange) ? $sliderRange[0] : '1100';
428 $sliderHeight = !empty($sliderRange) ? $sliderRange[1] : '450';
429 ?>
430 <div class="ytube-slide-container">
431 <!-- slider width -->
432 <p><strong><?php esc_attr_e('Slider Width: ', 'video-playlist-for-youtube'); ?></strong><span id="ytube_slide_wdth"></span>px</p>
433 <input type="range" name="utubeSliderRange[]" min="320" max="2200" value="<?php echo esc_attr($sliderWidth); ?>" class="ytube-plyslider" id="vpfu_plyst_width">
434
435 <!-- slider height -->
436 <p><strong><?php esc_attr_e('Slider Height: ', 'video-playlist-for-youtube'); ?></strong><span id="ytube_slide_height"></span>px</p>
437 <input type="range" name="utubeSliderRange[]" min="165" max="900" value="<?php echo esc_attr($sliderHeight); ?>" class="ytube-plyslider" id="vpfu_plyst_height">
438 </div>
439 <?php }
440
441 /*Ajax response for video duration*/
442 function vpfytGetYoutubeDuration()
443 {
444
445 //check_admin_referer('gpm_repeatable_meta_box_nonce', 'gpm_repeatable_meta_box_nonce');
446
447 if (
448 ! isset($_POST['gpm_repeatable_meta_box_nonce']) ||
449 ! wp_verify_nonce($_POST['gpm_repeatable_meta_box_nonce'], 'gpm_repeatable_meta_box_nonce')
450 )
451 return;
452
453 $vid = $_POST['ytvideo_id'];
454 $get_Gapi_key = get_option('vpfy_reg_ytubapi_key');
455 $response = wp_remote_get("https://www.googleapis.com/youtube/v3/videos?id=" . $vid . "&part=contentDetails,statistics&key=" . $get_Gapi_key[0]);
456
457 if (is_array($response) && ! is_wp_error($response)) {
458 $videoDetails = $response['body']; // use the content
459 $videoDetails = json_decode($videoDetails, true);
460 $responsearry = array();
461 foreach ($videoDetails['items'] as $vidTime) {
462 $youtube_time = $vidTime['contentDetails']['duration'];
463 preg_match_all('!\d+!', $youtube_time, $parts);
464 if (count($parts[0]) == 3) {
465 $ythours = $parts[0][0];
466 $ytminuts = $parts[0][1];
467 $ytsecond = $parts[0][2];
468 $responsearry = array('ythours' => $ythours, 'ytminuts' => $ytminuts, 'ytsecond' => $ytsecond);
469 wp_send_json_success($responsearry);
470 }
471 if (count($parts[0]) == 2) {
472 $ythours = '00';
473 $ytminuts = $parts[0][0];
474 $ytsecond = $parts[0][1];
475 $responsearry = array('ythours' => $ythours, 'ytminuts' => $ytminuts, 'ytsecond' => $ytsecond);
476 wp_send_json_success($responsearry);
477 }
478 if (count($parts[0]) == 1) {
479 $ythours = '00';
480 $ytminuts = '00';
481 $ytsecond = $parts[0][0];
482 $responsearry = array('ythours' => $ythours, 'ytminuts' => $ytminuts, 'ytsecond' => $ytsecond);
483 wp_send_json_success($responsearry);
484 } else {
485 $ythours = '00';
486 $ytminuts = '00';
487 $ytsecond = '00';
488 $responsearry = array('ythours' => $ythours, 'ytminuts' => $ytminuts, 'ytsecond' => $ytsecond);
489 wp_send_json_success($responsearry);
490 }
491 }
492 }
493 }
494
495 /*Create global ajax varialble*/
496 add_action("wp_ajax_vpfytGetYoutubeDuration", "vpfytGetYoutubeDuration");
497 add_action("wp_ajax_nopriv_vpfytGetYoutubeDuration", "vpfytGetYoutubeDuration");
498
499
500
501 /**
502 * You can use these filters to add custom links to your plugin row in the plugin list.
503 * @param $links, $file
504 * @return $links [array]
505 */
506 function vpfy_add_custom_plugin_links($links, $file) {
507 // Replace 'your-plugin-folder/your-plugin-file.php' with your actual plugin file path
508 if ($file === 'video-playlist-for-youtube/video-playlist-ytb-plugin.php') {
509 $links[] = '<a href="https://wp-plugins.galaxyweblinks.com/wp-plugins/video-playlist-for-youtube/demo/" target="_blank">Demo</a>';
510 $links[] = '<a href="https://wp-plugins.galaxyweblinks.com/wp-plugins/disable-feeds-wp/doc/" target="_blank">Documentation</a>';
511 $links[] = '<a href="https://wp-plugins.galaxyweblinks.com/contact/" target="_blank">Contact Support</a>';
512 }
513 return $links;
514 }
515 add_filter( 'plugin_row_meta', 'vpfy_add_custom_plugin_links', 10, 2);