video-playlist-for-youtube
Last commit date
includes
2 years ago
index.php
2 years ago
readme.txt
2 years ago
video-playlist-ytb-plugin.php
2 years ago
vpfy-api-playlist-shortcode.php
2 years ago
vpfy-settings-pg.php
2 years ago
vpfy-vplaylist-functions.php
2 years ago
vpfy-settings-pg.php
146 lines
| 1 | <?php |
| 2 | if (!defined('ABSPATH')) exit; // Exit if accessed directly |
| 3 | |
| 4 | function vpfy_submenu_settings_page() { ?> |
| 5 | <div class="wrap"> |
| 6 | <h2><?php _e('Video Playlist for YouTube Settings', 'video-playlist-for-youtube'); ?></h2> |
| 7 | <?php |
| 8 | wp_enqueue_style('vpfy-vplay-settings'); |
| 9 | wp_enqueue_script('vpfyt-vplay-settngpg'); |
| 10 | ?> |
| 11 | <?php $tab = isset($_GET['tab']) ? $_GET['tab'] : 'dashboard'; ?> |
| 12 | |
| 13 | <h2 class="nav-tab-wrapper"> |
| 14 | <a href="<?php echo admin_url('edit.php?post_type=vid_playlist_ytub&page=vpfy_settings_menu&tab=dashboard'); ?>" class="nav-tab <?php echo $tab == 'dashboard' ? 'nav-tab-active' : ''; ?>"><?php _e('Dashboard', 'video-playlist-for-youtube'); ?></a> |
| 15 | <a href="<?php echo admin_url('edit.php?post_type=vid_playlist_ytub&page=vpfy_settings_menu&tab=settings'); ?>" class="nav-tab <?php echo $tab == 'settings' ? 'nav-tab-active' : ''; ?>"><?php _e('General Settings', 'video-playlist-for-youtube'); ?></a> |
| 16 | <a href="<?php echo admin_url('edit.php?post_type=vid_playlist_ytub&page=vpfy_settings_menu&tab=api'); ?>" class="nav-tab <?php echo $tab == 'api' ? 'nav-tab-active' : ''; ?>"><?php _e('YouTube API', 'video-playlist-for-youtube'); ?></a> |
| 17 | <a href="<?php echo admin_url('edit.php?post_type=vid_playlist_ytub&page=vpfy_settings_menu&tab=help'); ?>" class="nav-tab <?php echo $tab == 'help' ? 'nav-tab-active' : ''; ?>"><?php _e('Help/Usage', 'video-playlist-for-youtube'); ?></a> |
| 18 | </h2> |
| 19 | |
| 20 | <?php if ((string) $tab === 'dashboard') { ?> |
| 21 | <?php |
| 22 | if (isset($_POST['generate_shortcd'])) { |
| 23 | $vpfy_channelid = sanitize_text_field($_POST['vpfy_channelid']); |
| 24 | $vpfy_maxvideos = (int) sanitize_text_field($_POST['vpfy_maxvideos']); |
| 25 | $vpfysliderwid = (int) sanitize_text_field($_POST['vpfysliderwid']); |
| 26 | $vpfysliderhei = (int) sanitize_text_field($_POST['vpfysliderhei']); |
| 27 | ?> |
| 28 | |
| 29 | <div class="genratshort updated notice is-dismissible"> |
| 30 | <h4>Display a video playlist for youtube on any post or page via a simple shortcode</h4> |
| 31 | <p><code>[channel4Youtube channelid=<?php echo $vpfy_channelid; ?> maxresults=<?php echo $vpfy_maxvideos; ?> width=<?php echo $vpfysliderwid; ?> height=<?php echo $vpfysliderhei; ?>]</code></p> |
| 32 | </div> |
| 33 | |
| 34 | <?php |
| 35 | } |
| 36 | ?> |
| 37 | <div id="poststuff"> |
| 38 | <h3><?php _e('About Video Playlist', 'video-playlist-for-youtube'); ?></h3> |
| 39 | <p><?php _e('Display video playlist for YouTube on any post, page or custom post type via a simple shortcode. The plugin supports a manual YouTube playlist (Add title, description and external youtube link) and a dynamic one using the YouTube Data API v3.', 'video-playlist-for-youtube'); ?></p> |
| 40 | |
| 41 | <p><?php _e('Embedded players must have a viewport that is at least 320px by 165px. If the player displays controls, it must be large enough to fully display the controls without shrinking the viewport below the minimum size. ', 'video-playlist-for-youtube'); ?></p> |
| 42 | <p><?php _e('By embedding YouTube videos on your site, you are agreeing to <a href="https://developers.google.com/youtube/terms/api-services-terms-of-service" rel="external" target="_blank">YouTube API Terms of Service</a>.', 'video-playlist-for-youtube'); ?></p> |
| 43 | <hr> |
| 44 | <h3><?php _e('Generate Dynamic Shortcode', 'video-playlist-for-youtube'); ?></h3> |
| 45 | <p><?php _e('By embedding YouTube videos on your site, paste your channel Id here <a href="https://www.youtube.com/account_advanced" target="_blank" alt="youtube channel id">https://www.youtube.com/account_advanced</a>', 'video-playlist-for-youtube'); ?></p> |
| 46 | |
| 47 | <form method="post" action=""> |
| 48 | |
| 49 | <p class="vpfydssh"><label for="vpfy_channelid"><?php _e('Channel ID', 'video-playlist-for-youtube'); ?></label> |
| 50 | <input type="text" name="vpfy_channelid" class="regular-text" id="vpfy_channelid" placeholder="Channel ID" value="" required="required"> |
| 51 | </p> |
| 52 | <p class="vpfydssh"><label for="vpfy_maxres"><?php _e('Show Videos', 'video-playlist-for-youtube'); ?></label> |
| 53 | <input type="number" name="vpfy_maxvideos" class="regular-text" id="vpfy_maxvideos" placeholder="Show Maximum Videos" min="2" value="" required="required"> |
| 54 | </p> |
| 55 | <div class="vpfy-wihi"> |
| 56 | <!-- slider width --> |
| 57 | <p class="vpfydssh"><label for="vpfy_slidwidh"><?php _e('Slider Width: ', 'video-playlist-for-youtube');?><span id="ytube_slidesetting_wdth"></span>px</label> |
| 58 | <input type="range" name="vpfysliderwid" min="320" max="2200" value="" class="regular-text ytube-plyslider" id="vpfu_plyst_wid"></p> |
| 59 | |
| 60 | <!-- slider height --> |
| 61 | <p class="vpfydssh"><label for="vpfy_slidheight"><?php _e('Slider Height: ', 'video-playlist-for-youtube');?><span id="ytube_slidesetting_height"></span>px</label> |
| 62 | <input type="range" name="vpfysliderhei" min="165" max="900" value="" class="regular-text ytube-plyslider" id="vpfu_plyst_hei"></p> |
| 63 | </div> |
| 64 | |
| 65 | |
| 66 | <p><input type="submit" name="generate_shortcd" class="button button-primary" value="<?php _e('Generate Shortcode', 'video-playlist-for-youtube'); ?>"></p> |
| 67 | |
| 68 | </form> |
| 69 | |
| 70 | </div> |
| 71 | <?php |
| 72 | } else if ((string) $tab === 'settings') { |
| 73 | if (isset($_POST['info_update1']) && current_user_can('manage_options')) { |
| 74 | if (isset($_POST['vpfy_vid_autoply'])) { |
| 75 | update_option('vpfy_vid_autoply', (int) sanitize_text_field($_POST['vpfy_vid_autoply'])); |
| 76 | } else { |
| 77 | update_option('vpfy_vid_autoply', 0); |
| 78 | } |
| 79 | if (isset($_POST['vpfy_vid_length'])) { |
| 80 | update_option('vpfy_vid_length', (int) sanitize_text_field($_POST['vpfy_vid_length'])); |
| 81 | } else { |
| 82 | update_option('vpfy_vid_length', 0); |
| 83 | } |
| 84 | if (isset($_POST['ytpp_controls'])) { |
| 85 | update_option('ytpp_controls', (int) sanitize_text_field($_POST['ytpp_controls'])); |
| 86 | } else { |
| 87 | update_option('ytpp_controls', 0); |
| 88 | } |
| 89 | |
| 90 | |
| 91 | echo '<div class="updated notice is-dismissible"><p>Settings updated!</p></div>'; |
| 92 | } |
| 93 | ?> |
| 94 | <form method="post" action=""> |
| 95 | <h3><?php _e('Player Settings', 'video-playlist-for-youtube'); ?></h3> |
| 96 | |
| 97 | <p> |
| 98 | <input type="checkbox" name="vpfy_vid_autoply" id="vpfy_vid_autoply" value="1" <?php if (get_option('vpfy_vid_autoply') == 1) echo 'checked'; ?>> <label for="vpfy_vid_autoply">AutoPlay</label> |
| 99 | </p> |
| 100 | <p> |
| 101 | <input type="checkbox" name="vpfy_vid_length" id="vpfy_vid_length" value="1" <?php if (get_option('vpfy_vid_length') == 1) echo 'checked'; ?>> <label for="vpfy_vid_length">Show video length/duration </label> |
| 102 | </p> |
| 103 | |
| 104 | <p><input type="submit" name="info_update1" class="button button-primary" value="<?php _e('Save Changes', 'video-playlist-for-youtube'); ?>"></p> |
| 105 | </form> |
| 106 | <?php |
| 107 | } else if ((string) $tab === 'api') { |
| 108 | if( isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true'): |
| 109 | echo '<div class="updated notice is-dismissible"><p>Settings updated!</p></div>'; |
| 110 | endif; |
| 111 | ?> |
| 112 | <h2><?php _e( 'YouTube API V3', 'video-playlist-for-youtube' ); ?></h2> |
| 113 | <h4><?php _e( 'For getting video duration and show youtube channel, do not forget to create your API key at ', 'video-playlist-for-youtube' ); ?><a href="https://console.developers.google.com/project" target="_blank"><?php _e( 'https://console.developers.google.com/project', 'video-playlist-for-youtube' ); ?></a> |
| 114 | </h4> |
| 115 | <div class="googlepai"> |
| 116 | <form method="post" action="options.php"> |
| 117 | <?php |
| 118 | $get_Gapi = get_option('vpfy_reg_ytubapi_key'); |
| 119 | do_settings_sections('vpfy_reg_groupname'); |
| 120 | settings_fields( 'vpfy_reg_groupname' ); |
| 121 | ?> |
| 122 | <p><input type="text" name="vpfy_reg_ytubapi_key[]" value="<?php if(!empty($get_Gapi)){echo esc_html($get_Gapi[0]);} ?>" class="regular-text" placeholder="YouTube API"> |
| 123 | </p> |
| 124 | <?php submit_button(); ?> |
| 125 | </form> |
| 126 | </div> |
| 127 | <?php |
| 128 | } else if ((string) $tab === 'help') { ?> |
| 129 | <div id="poststuff"> |
| 130 | <?php _e('<h3>Help & Usage Details</h3> |
| 131 | <h4>To create an YouTube API key follow these steps</h4> |
| 132 | <p>1] Login your Google account.</p> |
| 133 | <p>2] Prefer the link - <a href ="https://console.developers.google.com/project" target="_blank"><strong>https://console.developers.google.com/project</strong></a></p> |
| 134 | <p>3] On the top bar click on the "CREATE PROJECT" button to create a new project.</p> |
| 135 | <p>4] Once create, select that project and go to the "API & Services"</p> |
| 136 | <p>5] Click on the "ENABLE APIS AND SERVICES" and enable "YouTube Data API v3" Service.</p> |
| 137 | <p>6] Once enable service go to the "credentials" Menu and create an API Key.</p> |
| 138 | <p>7] Copy that key and put in the plugin settings YouTube API tab.</p>', 'video-playlist-for-youtube'); ?> |
| 139 | </div> |
| 140 | <?php |
| 141 | } |
| 142 | ?> |
| 143 | </div> |
| 144 | <?php |
| 145 | } |
| 146 |