video-playlist-for-youtube
Last commit date
includes
3 weeks ago
index.php
3 weeks ago
readme.txt
3 weeks ago
video-playlist-ytb-plugin.php
3 weeks ago
vpfy-api-playlist-shortcode.php
3 weeks ago
vpfy-settings-pg.php
3 weeks ago
vpfy-vplaylist-functions.php
3 weeks ago
vpfy-settings-pg.php
188 lines
| 1 | <?php |
| 2 | if (!defined('ABSPATH')) exit; // Exit if accessed directly |
| 3 | |
| 4 | function vpfy_submenu_settings_page() { ?> |
| 5 | <div class="wrap"> |
| 6 | |
| 7 | <h2><?php esc_attr_e('Video Playlist for YouTube Settings', 'video-playlist-for-youtube'); ?></h2> |
| 8 | |
| 9 | <div class="notice vpfy--notice"> |
| 10 | <div> |
| 11 | <h3><?php esc_attr_e('Video Playlist for YouTube', 'video-playlist-for-youtube'); ?></h3> |
| 12 | <p>Here's a link to the demo and documentation for the plugin. This will help you learn more about its features and how to use it.</p> |
| 13 | <div class="e-notice__actions"> |
| 14 | <a href="https://wp-plugins.galaxyweblinks.com/wp-plugins/video-playlist-for-youtube/demo" class="e-button--cta" target="_blank"><span>Demo</span></a> |
| 15 | <a href="https://wp-plugins.galaxyweblinks.com/wp-plugins/video-playlist-for-youtube/doc" class="e-button--cta cta-secondary" target="_blank"><span>Documentation</span></a> |
| 16 | </div> |
| 17 | <p class="e-note">For any feedback or queries regarding this plugin, please contact our <a href="https://wp-plugins.galaxyweblinks.com/contact/" target="_blank">Support team</a>.</p> |
| 18 | </div> |
| 19 | </div> |
| 20 | |
| 21 | <?php |
| 22 | wp_enqueue_style('vpfy-vplay-settings'); |
| 23 | wp_enqueue_script('vpfyt-vplay-settngpg'); |
| 24 | ?> |
| 25 | <?php |
| 26 | |
| 27 | $dashboard = esc_url(admin_url('edit.php?post_type=vid_playlist_ytub&page=vpfy_settings_menu&tab=dashboard')); |
| 28 | $settings = esc_url(admin_url('edit.php?post_type=vid_playlist_ytub&page=vpfy_settings_menu&tab=settings')); |
| 29 | $api = esc_url(admin_url('edit.php?post_type=vid_playlist_ytub&page=vpfy_settings_menu&tab=api')); |
| 30 | $help = esc_url(admin_url('edit.php?post_type=vid_playlist_ytub&page=vpfy_settings_menu&tab=help')); |
| 31 | ?> |
| 32 | |
| 33 | <h2 class="nav-tab-wrapper"> |
| 34 | <a href="<?php echo esc_attr($dashboard); ?>" class="nav-tab <?php echo (!isset($_GET['tab']) || $_GET['tab'] == 'dashboard' ) ? 'nav-tab-active' : ''; ?>"><?php esc_attr_e('Dashboard', 'video-playlist-for-youtube'); ?></a> |
| 35 | <a href="<?php echo esc_attr($settings); ?>" class="nav-tab <?php echo (isset($_GET['tab']) && $_GET['tab'] == 'settings' ) ? 'nav-tab-active' : ''; ?>"><?php esc_attr_e('General Settings', 'video-playlist-for-youtube'); ?></a> |
| 36 | <a href="<?php echo esc_attr($api); ?>" class="nav-tab <?php echo (isset($_GET['tab']) && $_GET['tab'] == 'api' ) ? 'nav-tab-active' : ''; ?>"><?php esc_attr_e('YouTube API', 'video-playlist-for-youtube'); ?></a> |
| 37 | <a href="<?php echo esc_attr($help); ?>" class="nav-tab <?php echo (isset($_GET['tab']) && $_GET['tab'] == 'help' ) ? 'nav-tab-active' : ''; ?>"><?php esc_attr_e('Help/Usage', 'video-playlist-for-youtube'); ?></a> |
| 38 | </h2> |
| 39 | |
| 40 | <?php if ( empty($_GET['tab']) || !isset($_GET['tab']) || $_GET['tab'] === 'dashboard') { ?> |
| 41 | <?php |
| 42 | |
| 43 | |
| 44 | if (isset($_POST['generate_shortcd'])) { |
| 45 | |
| 46 | //check_admin_referer('gpm_repeatable_meta_box_nonce', 'gpm_repeatable_meta_box_nonce'); |
| 47 | |
| 48 | if ( ! isset( $_POST['gpm_repeatable_meta_box_nonce'] ) || |
| 49 | ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['gpm_repeatable_meta_box_nonce'] ) ), 'gpm_repeatable_meta_box_nonce' ) ) |
| 50 | return; |
| 51 | |
| 52 | $vpfy_channelid = isset($_POST['vpfy_channelid']) ? sanitize_text_field(wp_unslash($_POST['vpfy_channelid'])) : ''; |
| 53 | $vpfy_maxvideos = isset($_POST['vpfy_maxvideos']) ? (int) sanitize_text_field(wp_unslash($_POST['vpfy_maxvideos'])) : 0; |
| 54 | $vpfysliderwid = isset($_POST['vpfysliderwid']) ? (int) sanitize_text_field(wp_unslash($_POST['vpfysliderwid'])) : 0; |
| 55 | $vpfysliderhei = isset($_POST['vpfysliderhei']) ? (int) sanitize_text_field(wp_unslash($_POST['vpfysliderhei'])) : 0; |
| 56 | ?> |
| 57 | |
| 58 | <div class="genratshort updated notice is-dismissible"> |
| 59 | <h4>Display a video playlist for youtube on any post or page via a simple shortcode</h4> |
| 60 | <p><code>[channel4Youtube channelid=<?php if(!empty($vpfy_channelid)) { echo esc_attr($vpfy_channelid); } ?> maxresults=<?php if(!empty($vpfy_maxvideos)) { echo esc_attr($vpfy_maxvideos); } ?> width=<?php if(!empty($vpfy_channelid)) { echo esc_attr($vpfysliderwid); } ?> height=<?php if(!empty($vpfy_channelid)) { echo esc_attr($vpfysliderhei); } ?>]</code></p> |
| 61 | </div> |
| 62 | |
| 63 | <?php |
| 64 | } |
| 65 | ?> |
| 66 | <div id="poststuff"> |
| 67 | <h3><?php esc_attr_e('About Video Playlist', 'video-playlist-for-youtube'); ?></h3> |
| 68 | <p><?php esc_attr_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> |
| 69 | |
| 70 | <p><?php esc_attr_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> |
| 71 | <p><?php esc_attr_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> |
| 72 | <hr> |
| 73 | <h3><?php esc_attr_e('Generate Dynamic Shortcode', 'video-playlist-for-youtube'); ?></h3> |
| 74 | <p><?php esc_attr_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> |
| 75 | |
| 76 | <form method="post" action=""> |
| 77 | |
| 78 | <p class="vpfydssh"><label for="vpfy_channelid"><?php esc_attr_e('Channel ID', 'video-playlist-for-youtube'); ?></label> |
| 79 | <input type="text" name="vpfy_channelid" class="regular-text" id="vpfy_channelid" placeholder="Channel ID" value="" required="required"> |
| 80 | </p> |
| 81 | <p class="vpfydssh"><label for="vpfy_maxres"><?php esc_attr_e('Show Videos', 'video-playlist-for-youtube'); ?></label> |
| 82 | <input type="number" name="vpfy_maxvideos" class="regular-text" id="vpfy_maxvideos" placeholder="Show Maximum Videos" min="2" value="" required="required"> |
| 83 | </p> |
| 84 | <div class="vpfy-wihi"> |
| 85 | <!-- slider width --> |
| 86 | <p class="vpfydssh"><label for="vpfy_slidwidh"><?php esc_attr_e('Slider Width: ', 'video-playlist-for-youtube');?><span id="ytube_slidesetting_wdth"></span>px</label> |
| 87 | <input type="range" name="vpfysliderwid" min="320" max="2200" value="" class="regular-text ytube-plyslider" id="vpfu_plyst_wid"></p> |
| 88 | |
| 89 | <!-- slider height --> |
| 90 | <p class="vpfydssh"><label for="vpfy_slidheight"><?php esc_attr_e('Slider Height: ', 'video-playlist-for-youtube');?><span id="ytube_slidesetting_height"></span>px</label> |
| 91 | <input type="range" name="vpfysliderhei" min="165" max="900" value="" class="regular-text ytube-plyslider" id="vpfu_plyst_hei"></p> |
| 92 | </div> |
| 93 | |
| 94 | |
| 95 | <p><input type="submit" name="generate_shortcd" class="button button-primary" value="<?php esc_attr_e('Generate Shortcode', 'video-playlist-for-youtube'); ?>"></p> |
| 96 | |
| 97 | <?php wp_nonce_field( 'gpm_repeatable_meta_box_nonce', 'gpm_repeatable_meta_box_nonce' ); ?> |
| 98 | |
| 99 | </form> |
| 100 | |
| 101 | </div> |
| 102 | <?php |
| 103 | } else if (!empty($_GET['tab']) && isset($_GET['tab']) && $_GET['tab'] === 'settings') { |
| 104 | if (isset($_POST['info_update1']) && current_user_can('manage_options')) { |
| 105 | |
| 106 | //check_admin_referer('gpm_repeatable_meta_box_nonce', 'gpm_repeatable_meta_box_nonce'); |
| 107 | |
| 108 | if ( ! isset( $_POST['gpm_repeatable_meta_box_nonce'] ) || |
| 109 | ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['gpm_repeatable_meta_box_nonce'] ) ), 'gpm_repeatable_meta_box_nonce' ) ) |
| 110 | return; |
| 111 | |
| 112 | |
| 113 | if (isset($_POST['vpfy_vid_autoply'])) { |
| 114 | update_option('vpfy_vid_autoply', (int) sanitize_text_field(wp_unslash($_POST['vpfy_vid_autoply']))); |
| 115 | } else { |
| 116 | update_option('vpfy_vid_autoply', 0); |
| 117 | } |
| 118 | if (isset($_POST['vpfy_vid_length'])) { |
| 119 | update_option('vpfy_vid_length', (int) sanitize_text_field(wp_unslash($_POST['vpfy_vid_length']))); |
| 120 | } else { |
| 121 | update_option('vpfy_vid_length', 0); |
| 122 | } |
| 123 | if (isset($_POST['ytpp_controls'])) { |
| 124 | update_option('ytpp_controls', (int) sanitize_text_field(wp_unslash($_POST['ytpp_controls']))); |
| 125 | } else { |
| 126 | update_option('ytpp_controls', 0); |
| 127 | } |
| 128 | |
| 129 | |
| 130 | echo ('<div class="updated notice is-dismissible"><p>Settings updated!</p></div>'); |
| 131 | } |
| 132 | ?> |
| 133 | <form method="post" action=""> |
| 134 | <h3><?php esc_attr_e('Player Settings', 'video-playlist-for-youtube'); ?></h3> |
| 135 | |
| 136 | <p> |
| 137 | <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> |
| 138 | </p> |
| 139 | <p> |
| 140 | <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> |
| 141 | </p> |
| 142 | |
| 143 | <p><input type="submit" name="info_update1" class="button button-primary" value="<?php esc_attr_e('Save Changes', 'video-playlist-for-youtube'); ?>"></p> |
| 144 | <?php wp_nonce_field( 'gpm_repeatable_meta_box_nonce', 'gpm_repeatable_meta_box_nonce' ); ?> |
| 145 | </form> |
| 146 | <?php |
| 147 | } else if (!empty($_GET['tab']) && isset($_GET['tab']) && $_GET['tab'] === 'api') { |
| 148 | if( isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true'): |
| 149 | |
| 150 | echo ('<div class="updated notice is-dismissible"><p>Settings updated!</p></div>'); |
| 151 | endif; |
| 152 | ?> |
| 153 | <h2><?php esc_attr_e( 'YouTube API V3', 'video-playlist-for-youtube' ); ?></h2> |
| 154 | <h4><?php esc_attr_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 esc_attr_e( 'https://console.developers.google.com/project', 'video-playlist-for-youtube' ); ?></a> |
| 155 | </h4> |
| 156 | <div class="googlepai"> |
| 157 | <form method="post" action="options.php"> |
| 158 | <?php |
| 159 | $get_Gapi = get_option('vpfy_reg_ytubapi_key'); |
| 160 | do_settings_sections('vpfy_reg_groupname'); |
| 161 | settings_fields( 'vpfy_reg_groupname' ); |
| 162 | ?> |
| 163 | <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" required> |
| 164 | </p> |
| 165 | <?php wp_nonce_field( 'gpm_repeatable_meta_box_nonce', 'gpm_repeatable_meta_box_nonce' ); ?> |
| 166 | <?php submit_button(); ?> |
| 167 | </form> |
| 168 | </div> |
| 169 | <?php |
| 170 | } else if (!empty($_GET['tab']) && isset($_GET['tab']) && $_GET['tab'] === 'help') { ?> |
| 171 | <div id="poststuff"> |
| 172 | <?php echo '<h3>Help & Usage Details</h3> |
| 173 | <h4>To create an YouTube API key follow these steps</h4> |
| 174 | <p>1] Login your Google account.</p> |
| 175 | <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> |
| 176 | <p>3] On the top bar click on the "CREATE PROJECT" button to create a new project.</p> |
| 177 | <p>4] Once create, select that project and go to the "API & Services"</p> |
| 178 | <p>5] Click on the "ENABLE APIS AND SERVICES" and enable "YouTube Data API v3" Service.</p> |
| 179 | <p>6] Once enable service go to the "credentials" Menu and create an API Key.</p> |
| 180 | <p>7] Copy that key and put in the plugin settings YouTube API tab.</p>'; ?> |
| 181 | </div> |
| 182 | <?php |
| 183 | } |
| 184 | ?> |
| 185 | </div> |
| 186 | <?php |
| 187 | } |
| 188 |