video-playlist-for-youtube
Last commit date
includes
1 year ago
index.php
1 year 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
498 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.5 |
| 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="35%"> |
| 172 | <textarea placeholder="Description" cols="40" rows="3" name="TitleDescription[]"> <?php if ($field['TitleDescription'] != '') echo esc_attr($field['TitleDescription']); ?> </textarea> |
| 173 | </td> |
| 174 | |
| 175 | <td width="30%"> |
| 176 | <input type="text" placeholder="Youtube URL" name="YoutubeUr[]" value="<?php if ($field['YoutubeUr'] != '') echo esc_attr($field['YoutubeUr']); ?>" /> |
| 177 | </td> |
| 178 | |
| 179 | <td width="15%"><a class="button remove-row" href="#1">Remove</a><span class="ytubedraggable"> |
| 180 | <svg width="18" height="18" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" role="img" aria-hidden="true" focusable="false"> |
| 181 | <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> |
| 182 | </svg></span></td> |
| 183 | </tr> |
| 184 | <?php wp_nonce_field('gpm_repeatable_meta_box_nonce', 'gpm_repeatable_meta_box_nonce'); |
| 185 | } |
| 186 | else : |
| 187 | // show a blank one |
| 188 | ?> |
| 189 | <tr class="drgble-sect"> |
| 190 | <td> |
| 191 | <input type="text" required="required" placeholder="Title" title="Title" name="TitleItem[]" /> |
| 192 | </td> |
| 193 | <td> |
| 194 | <textarea placeholder="Description" name="TitleDescription[]" cols="40" rows="3"> </textarea> |
| 195 | </td> |
| 196 | |
| 197 | <td> |
| 198 | <input type="text" placeholder="Youtube URL" name="YoutubeUr[]" /> |
| 199 | </td> |
| 200 | |
| 201 | <td><a class="button cmb-remove-row-button button-disabled" href="#">Remove</a><span class="ytubedraggable"> |
| 202 | <svg width="18" height="18" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" role="img" aria-hidden="true" focusable="false"> |
| 203 | <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> |
| 204 | </svg></span></td> |
| 205 | </tr> |
| 206 | <?php wp_nonce_field('gpm_repeatable_meta_box_nonce', 'gpm_repeatable_meta_box_nonce'); |
| 207 | |
| 208 | endif; ?> |
| 209 | |
| 210 | <!-- empty hidden one for jQuery --> |
| 211 | <tr class="empty-row screen-reader-text drgble-sect"> |
| 212 | <td> |
| 213 | <input type="text" placeholder="Title" name="TitleItem[]" /> |
| 214 | </td> |
| 215 | <td> |
| 216 | <textarea placeholder="Description" cols="40" rows="3" name="TitleDescription[]"></textarea> |
| 217 | </td> |
| 218 | <td> |
| 219 | <input type="text" placeholder="Youtube URL" name="YoutubeUr[]" /> |
| 220 | </td> |
| 221 | <td><a class="button remove-row" href="#">Remove</a><span class="ytubedraggable"> |
| 222 | <svg width="18" height="18" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" role="img" aria-hidden="true" focusable="false"> |
| 223 | <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> |
| 224 | </svg></span></td> |
| 225 | </tr> |
| 226 | </tbody> |
| 227 | </table> |
| 228 | <p><a id="add-row" class="button" href="#">Add another</a></p> |
| 229 | <?php |
| 230 | } |
| 231 | add_action('save_post', 'custom_repeatable_meta_box_save'); |
| 232 | function custom_repeatable_meta_box_save($post_id) |
| 233 | { |
| 234 | |
| 235 | //check_admin_referer('gpm_repeatable_meta_box_nonce', 'gpm_repeatable_meta_box_nonce'); |
| 236 | |
| 237 | if ( |
| 238 | ! isset($_POST['gpm_repeatable_meta_box_nonce']) || |
| 239 | ! wp_verify_nonce($_POST['gpm_repeatable_meta_box_nonce'], 'gpm_repeatable_meta_box_nonce') |
| 240 | ) |
| 241 | return; |
| 242 | |
| 243 | if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) |
| 244 | return; |
| 245 | |
| 246 | if (!current_user_can('edit_post', $post_id)) |
| 247 | return; |
| 248 | |
| 249 | $old = get_post_meta($post_id, 'customdata_group', true); |
| 250 | $new = array(); |
| 251 | |
| 252 | |
| 253 | /* Title */ |
| 254 | $invoiceItems = array(); |
| 255 | foreach ($_POST['TitleItem'] as $titlValue) { |
| 256 | $invoiceItems[] = sanitize_text_field($titlValue); |
| 257 | } |
| 258 | /*Description*/ |
| 259 | $prices = array(); |
| 260 | foreach ($_POST['TitleDescription'] as $titlDesValue) { |
| 261 | $prices[] = sanitize_textarea_field($titlDesValue); |
| 262 | } |
| 263 | |
| 264 | /*URL*/ |
| 265 | $YoutubeUr = array(); |
| 266 | foreach ($_POST['YoutubeUr'] as $youtubeUrlValue) { |
| 267 | $YoutubeUr[] = sanitize_text_field($youtubeUrlValue); |
| 268 | } |
| 269 | |
| 270 | $count = count($invoiceItems); |
| 271 | for ($i = 0; $i < $count; $i++) { |
| 272 | if ($invoiceItems[$i] != '') : |
| 273 | $new[$i]['TitleItem'] = stripslashes(wp_strip_all_tags(trim($invoiceItems[$i]))); |
| 274 | $new[$i]['TitleDescription'] = stripslashes(trim($prices[$i])); // and however you want to sanitize |
| 275 | $new[$i]['YoutubeUr'] = filter_var($YoutubeUr[$i], FILTER_SANITIZE_URL); |
| 276 | endif; |
| 277 | } |
| 278 | if (!empty($new) && $new != $old) |
| 279 | update_post_meta($post_id, 'customdata_group', $new); |
| 280 | elseif (empty($new) && $old) |
| 281 | delete_post_meta($post_id, 'customdata_group', $old); |
| 282 | if (isset($_POST['utubeSliderRange'])) { |
| 283 | $new_itm_range = array(); |
| 284 | foreach ($_POST['utubeSliderRange'] as $rangevalue) { |
| 285 | $new_itm_range[] = sanitize_text_field($rangevalue); |
| 286 | } |
| 287 | update_post_meta($post_id, '_utubeSliderRange', $new_itm_range); |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | /*Display playlist*/ |
| 292 | add_shortcode('videoPlaylist', 'vpfy_vplaylist_display_gallery'); |
| 293 | function vpfy_vplaylist_display_gallery($atts) |
| 294 | { |
| 295 | $arry_arg = shortcode_atts(array('id' => ''), $atts); |
| 296 | |
| 297 | $output = ''; |
| 298 | ob_start(); ?> |
| 299 | <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800%7CShadows+Into+Light" rel="stylesheet" type="text/css"> |
| 300 | <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script> |
| 301 | <?php |
| 302 | wp_enqueue_script('vpfy-playlist-min'); |
| 303 | wp_enqueue_script('vpfy-playlist-video'); |
| 304 | wp_enqueue_script('vpfy-unitegallery-video'); |
| 305 | wp_enqueue_style('vpfy-vplay-galcss'); |
| 306 | wp_enqueue_style('vpfy-playlist-ryt-no-thumb'); |
| 307 | wp_enqueue_style('vpfy-playlist-ryt-thumb'); |
| 308 | wp_enqueue_style('vpfy-playlist-ryt-ttl-only'); |
| 309 | wp_enqueue_style('vpfy-unite-gallery'); |
| 310 | |
| 311 | if (!empty($arry_arg['id'])) { |
| 312 | $ytube_custmgrp = get_post_meta($arry_arg['id'], 'customdata_group', true); |
| 313 | |
| 314 | echo ('<div id="gallery' . esc_attr($arry_arg['id']) . '" style="margin:0px auto;display:none;">'); |
| 315 | foreach ($ytube_custmgrp as $ykey => $ytubvalue) { |
| 316 | $ytuburl = parse_url($ytubvalue['YoutubeUr']); |
| 317 | |
| 318 | $existance = 0; |
| 319 | foreach ($ytuburl as $utkey => $utvalue) { |
| 320 | if ('query' == $utkey) { |
| 321 | $existance = 1; |
| 322 | } else { |
| 323 | $existance = 0; |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | if ($existance == 1) { |
| 328 | $ytubid = explode('v=', $ytuburl['query']); |
| 329 | $ytubid = explode('&', $ytubid[1]); |
| 330 | if (strlen($ytubvalue['TitleItem']) > 25) { |
| 331 | $ytvidTitle = substr($ytubvalue['TitleItem'], 0, 25) . "..."; |
| 332 | } else { |
| 333 | $ytvidTitle = $ytubvalue['TitleItem']; |
| 334 | } |
| 335 | ?> |
| 336 | <div data-type="youtube" |
| 337 | data-title="<?php echo esc_attr($ytvidTitle); ?>" |
| 338 | data-description="<?php echo esc_attr(substr($ytubvalue['TitleDescription'], 0, 80)); ?>" |
| 339 | data-thumb="https://i.ytimg.com/vi/<?php echo esc_attr($ytubid[0]); ?>/mqdefault.jpg" |
| 340 | data-image="https://i.ytimg.com/vi/<?php echo esc_attr($ytubid[0]); ?>/sddefault.jpg" |
| 341 | data-videoid="<?php echo esc_attr($ytubid[0]); ?>"></div> |
| 342 | <?php } elseif ($existance == 0) { ?> |
| 343 | <div data-type="youtube" |
| 344 | data-title="<?php echo esc_attr($ytubvalue['TitleItem']); ?>" |
| 345 | data-description="<?php echo esc_attr(substr($ytubvalue['TitleDescription'], 0, 80)); ?>" |
| 346 | data-thumb="https://i.ytimg.com/vi/123/mqdefault.jpg" |
| 347 | data-image="https://i.ytimg.com/vi/123/sddefault.jpg" |
| 348 | data-videoid="123"></div> |
| 349 | <?php } |
| 350 | } |
| 351 | echo ('</div>'); |
| 352 | |
| 353 | if (null !== get_post_meta($arry_arg['id'], '_utubeSliderRange', true)) { |
| 354 | $sliderRange = get_post_meta($arry_arg['id'], '_utubeSliderRange', true); |
| 355 | } |
| 356 | $sliderWidth = !empty($sliderRange) ? $sliderRange[0] : '1100'; |
| 357 | $sliderHeight = !empty($sliderRange) ? $sliderRange[1] : '450'; |
| 358 | if (!empty(get_option('vpfy_vid_autoply')) && get_option('vpfy_vid_autoply') == 1) { |
| 359 | $autoply = 'true'; |
| 360 | } else { |
| 361 | $autoply = 'false'; |
| 362 | } |
| 363 | ?> |
| 364 | <script> |
| 365 | jQuery(document).ready(function() { |
| 366 | jQuery("#gallery<?php echo esc_attr($arry_arg['id']); ?>").unitegallery({ |
| 367 | gallery_theme: "video", |
| 368 | gallery_width: <?php echo esc_attr($sliderWidth); ?>, |
| 369 | gallery_height: <?php echo esc_attr($sliderHeight); ?>, |
| 370 | theme_autoplay: <?php echo esc_attr($autoply); ?>, |
| 371 | }); |
| 372 | }); |
| 373 | </script> |
| 374 | <?php |
| 375 | } |
| 376 | ?> |
| 377 | |
| 378 | <?php $output = ob_get_clean(); |
| 379 | return $output; |
| 380 | } |
| 381 | |
| 382 | |
| 383 | // Add the custom columns to the youtube playlist post type: |
| 384 | add_filter('manage_vid_playlist_ytub_posts_columns', 'set_custom_vpfy_shortcode_columns'); |
| 385 | function set_custom_vpfy_shortcode_columns($columns) |
| 386 | { |
| 387 | $columns['vpfy_col_shortcode'] = __('Shortcode', 'video-playlist-for-youtube'); |
| 388 | return $columns; |
| 389 | } |
| 390 | |
| 391 | // Add the data to the custom columns for the youtube playlist post type: |
| 392 | add_action('manage_vid_playlist_ytub_posts_custom_column', 'vpfy_custom_vidyou_column', 10, 2); |
| 393 | function vpfy_custom_vidyou_column($column, $post_id) |
| 394 | { |
| 395 | switch ($column) { |
| 396 | |
| 397 | case 'vpfy_col_shortcode': |
| 398 | echo esc_attr("[videoPlaylist id=" . $post_id . "]"); |
| 399 | break; |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | |
| 404 | /*Plugin settings */ |
| 405 | function vpfy_vplaylist_slider_settings() |
| 406 | { |
| 407 | if (null !== get_post_meta(get_the_ID(), '_utubeSliderRange', true)) { |
| 408 | $sliderRange = get_post_meta(get_the_ID(), '_utubeSliderRange', true); |
| 409 | } |
| 410 | $sliderWidth = !empty($sliderRange) ? $sliderRange[0] : '1100'; |
| 411 | $sliderHeight = !empty($sliderRange) ? $sliderRange[1] : '450'; |
| 412 | ?> |
| 413 | <div class="ytube-slide-container"> |
| 414 | <!-- slider width --> |
| 415 | <p><strong><?php esc_attr_e('Slider Width: ', 'video-playlist-for-youtube'); ?></strong><span id="ytube_slide_wdth"></span>px</p> |
| 416 | <input type="range" name="utubeSliderRange[]" min="320" max="2200" value="<?php echo esc_attr($sliderWidth); ?>" class="ytube-plyslider" id="vpfu_plyst_width"> |
| 417 | |
| 418 | <!-- slider height --> |
| 419 | <p><strong><?php esc_attr_e('Slider Height: ', 'video-playlist-for-youtube'); ?></strong><span id="ytube_slide_height"></span>px</p> |
| 420 | <input type="range" name="utubeSliderRange[]" min="165" max="900" value="<?php echo esc_attr($sliderHeight); ?>" class="ytube-plyslider" id="vpfu_plyst_height"> |
| 421 | </div> |
| 422 | <?php } |
| 423 | |
| 424 | /*Ajax response for video duration*/ |
| 425 | function vpfytGetYoutubeDuration() |
| 426 | { |
| 427 | |
| 428 | //check_admin_referer('gpm_repeatable_meta_box_nonce', 'gpm_repeatable_meta_box_nonce'); |
| 429 | |
| 430 | if ( |
| 431 | ! isset($_POST['gpm_repeatable_meta_box_nonce']) || |
| 432 | ! wp_verify_nonce($_POST['gpm_repeatable_meta_box_nonce'], 'gpm_repeatable_meta_box_nonce') |
| 433 | ) |
| 434 | return; |
| 435 | |
| 436 | $vid = $_POST['ytvideo_id']; |
| 437 | $get_Gapi_key = get_option('vpfy_reg_ytubapi_key'); |
| 438 | $response = wp_remote_get("https://www.googleapis.com/youtube/v3/videos?id=" . $vid . "&part=contentDetails,statistics&key=" . $get_Gapi_key[0]); |
| 439 | |
| 440 | if (is_array($response) && ! is_wp_error($response)) { |
| 441 | $videoDetails = $response['body']; // use the content |
| 442 | $videoDetails = json_decode($videoDetails, true); |
| 443 | $responsearry = array(); |
| 444 | foreach ($videoDetails['items'] as $vidTime) { |
| 445 | $youtube_time = $vidTime['contentDetails']['duration']; |
| 446 | preg_match_all('!\d+!', $youtube_time, $parts); |
| 447 | if (count($parts[0]) == 3) { |
| 448 | $ythours = $parts[0][0]; |
| 449 | $ytminuts = $parts[0][1]; |
| 450 | $ytsecond = $parts[0][2]; |
| 451 | $responsearry = array('ythours' => $ythours, 'ytminuts' => $ytminuts, 'ytsecond' => $ytsecond); |
| 452 | wp_send_json_success($responsearry); |
| 453 | } |
| 454 | if (count($parts[0]) == 2) { |
| 455 | $ythours = '00'; |
| 456 | $ytminuts = $parts[0][0]; |
| 457 | $ytsecond = $parts[0][1]; |
| 458 | $responsearry = array('ythours' => $ythours, 'ytminuts' => $ytminuts, 'ytsecond' => $ytsecond); |
| 459 | wp_send_json_success($responsearry); |
| 460 | } |
| 461 | if (count($parts[0]) == 1) { |
| 462 | $ythours = '00'; |
| 463 | $ytminuts = '00'; |
| 464 | $ytsecond = $parts[0][0]; |
| 465 | $responsearry = array('ythours' => $ythours, 'ytminuts' => $ytminuts, 'ytsecond' => $ytsecond); |
| 466 | wp_send_json_success($responsearry); |
| 467 | } else { |
| 468 | $ythours = '00'; |
| 469 | $ytminuts = '00'; |
| 470 | $ytsecond = '00'; |
| 471 | $responsearry = array('ythours' => $ythours, 'ytminuts' => $ytminuts, 'ytsecond' => $ytsecond); |
| 472 | wp_send_json_success($responsearry); |
| 473 | } |
| 474 | } |
| 475 | } |
| 476 | } |
| 477 | |
| 478 | /*Create global ajax varialble*/ |
| 479 | add_action("wp_ajax_vpfytGetYoutubeDuration", "vpfytGetYoutubeDuration"); |
| 480 | add_action("wp_ajax_nopriv_vpfytGetYoutubeDuration", "vpfytGetYoutubeDuration"); |
| 481 | |
| 482 | |
| 483 | |
| 484 | /** |
| 485 | * You can use these filters to add custom links to your plugin row in the plugin list. |
| 486 | * @param $links, $file |
| 487 | * @return $links [array] |
| 488 | */ |
| 489 | function vpfy_add_custom_plugin_links($links, $file) { |
| 490 | // Replace 'your-plugin-folder/your-plugin-file.php' with your actual plugin file path |
| 491 | if ($file === 'video-playlist-for-youtube/video-playlist-ytb-plugin.php') { |
| 492 | $links[] = '<a href="https://wp-plugins.galaxyweblinks.com/wp-plugins/video-playlist-for-youtube/demo/" target="_blank">Demo</a>'; |
| 493 | $links[] = '<a href="https://wp-plugins.galaxyweblinks.com/wp-plugins/disable-feeds-wp/doc/" target="_blank">Documentation</a>'; |
| 494 | $links[] = '<a href="https://wp-plugins.galaxyweblinks.com/contact/" target="_blank">Contact Support</a>'; |
| 495 | } |
| 496 | return $links; |
| 497 | } |
| 498 | add_filter( 'plugin_row_meta', 'vpfy_add_custom_plugin_links', 10, 2); |