| @@ -2,14 +2,17 @@ | ||
| 2 | 2 | /** |
| 3 | 3 | * Plugin Name: VdoCipher |
| 4 | 4 | * Plugin URI: http://www.vdocipher.com |
| 5 | 5 | * Description: Secured video hosting for wordpress |
| 6 | - * Version: 1.20 | |
| 6 | + * Version: 1.9 | |
| 7 | 7 | * Author: VdoCipher |
| 8 | 8 | * Author URI: http://www.vdocipher.com |
| 9 | 9 | * License: GPL2 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | +error_reporting(E_ALL); | |
| 13 | +ini_set('display_errors', 1); | |
| 14 | + | |
| 12 | 15 | if (__FILE__ == $_SERVER['SCRIPT_FILENAME']) { |
| 13 | 16 | header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); |
| 14 | 17 | exit("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n<html><head>\r\n<title>404 Not Found</title>\r\n". |
| 15 | 18 | "</head><body>\r\n<h1>Not Found</h1>\r\n<p>The requested URL " . $_SERVER['SCRIPT_NAME'] . " was not found on ". |
| @@ -46,15 +49,11 @@ | ||
| 46 | 49 | 'height' => get_option('vdo_default_height') . "px", |
| 47 | 50 | 'id' => 'id', |
| 48 | 51 | 'no_annotate'=> false, |
| 49 | 52 | 'version'=> 0, |
| 50 | - 'player_tech'=> '' | |
| 51 | 53 | ), |
| 52 | 54 | $atts |
| 53 | 55 | )); |
| 54 | - if((get_option('vdo_default_height')) == 'auto') { | |
| 55 | - $height = 'auto'; | |
| 56 | - } | |
| 57 | 56 | if (!$atts['id']) { |
| 58 | 57 | if (!$atts['title']) { |
| 59 | 58 | return "Required argument id for embedded video not found."; |
| 60 | 59 | } |
| @@ -117,85 +116,25 @@ | ||
| 117 | 116 | $version = 0; |
| 118 | 117 | if (isset($atts['version'])) { |
| 119 | 118 | $version = $atts['version']; |
| 120 | 119 | } |
| 121 | - if ((get_option('vdo_embed_version')) == false) { | |
| 122 | - update_option('vdo_embed_version', '1.5.0'); | |
| 120 | + $output = "<div id='vdo$OTP' style='height:$height;width:$width;max-width:100%' ></div>"; | |
| 121 | + $output .= "<script> (function(v,i,d,e,o){v[o]=v[o]||{}; v[o].add = v[o].add || function V(a){". | |
| 122 | + " (v[o].d=v[o].d||[]).push(a);};"; | |
| 123 | + $output .= "if(!v[o].l) { v[o].l=1*new Date(); a=i.createElement(d), m=i.getElementsByTagName(d)[0]; a.async=1; ". | |
| 124 | + "a.src=e; m.parentNode.insertBefore(a,m);}"; | |
| 125 | + $output .= " })(window,document,'script','//de122v0opjemw.cloudfront.net/vdo.js','vdo'); vdo.add({ "; | |
| 126 | + $output .= "o: '$OTP', "; | |
| 127 | + if ($version == 32) { | |
| 128 | + $output .= "version: '$version' "; | |
| 123 | 129 | } |
| 124 | - if ((get_option('vdo_player_theme')) == false) { | |
| 125 | - update_option('vdo_player_theme','9ae8bbe8dd964ddc9bdb932cca1cb59a'); | |
| 126 | - } | |
| 127 | - $vdo_embed_version_str = get_option('vdo_embed_version'); | |
| 128 | - $vdo_player_theme = get_option('vdo_player_theme'); | |
| 129 | - | |
| 130 | - // tech override custom names start | |
| 131 | - switch ($player_tech) { | |
| 132 | - case "flash": | |
| 133 | - $player_tech = "*,-dash"; | |
| 134 | - break; | |
| 135 | - case "nohtml5": | |
| 136 | - $player_tech = "*,-dash"; | |
| 137 | - break; | |
| 138 | - case "noflash": | |
| 139 | - $player_tech = "*,-hss"; | |
| 140 | - break; | |
| 141 | - case "nozen": | |
| 142 | - $player_tech = "*,-zen"; | |
| 143 | - break; | |
| 144 | - case "noios": | |
| 145 | - $player_tech = "*,-hlse"; | |
| 146 | - break; | |
| 147 | - default: | |
| 148 | - break; | |
| 149 | - } | |
| 150 | - // tech override ends | |
| 151 | - | |
| 152 | - // Old Embed Code | |
| 153 | - if($vdo_embed_version_str === '0.5') { | |
| 154 | - $output = "<div id='vdo$OTP' style='height:$height;width:$width;max-width:100%' ></div>"; | |
| 155 | - $output .= "<script> (function(v,i,d,e,o){v[o]=v[o]||{}; v[o].add = v[o].add || function V(a){". | |
| 156 | - " (v[o].d=v[o].d||[]).push(a);};"; | |
| 157 | - $output .= "if(!v[o].l) { v[o].l=1*new Date(); a=i.createElement(d), m=i.getElementsByTagName(d)[0]; a.async=1; ". | |
| 158 | - "a.src=e; m.parentNode.insertBefore(a,m);}"; | |
| 159 | - $output .= " })(window,document,'script','//de122v0opjemw.cloudfront.net/vdo.js','vdo'); vdo.add({ "; | |
| 160 | - $output .= "o: '$OTP', "; | |
| 161 | - if ($version == 32) { | |
| 162 | - $output .= "version: '$version' "; | |
| 163 | - } | |
| 164 | - $output .= "}); </script>"; | |
| 165 | - } | |
| 166 | - //New embed code | |
| 167 | - else { | |
| 168 | - $output .= "<div id='vdo$OTP' style='height:$height;width:$width;max-width:100%' ></div>"; | |
| 169 | - $output .= "<script>(function(v,i,d,e,o){v[o]=v[o]||{}; v[o].add = v[o].add || function V(a){ (v[o].d=v[o].d||[]).push(a);};"; | |
| 170 | - $output .= "if(!v[o].l) { v[o].l=1*new Date(); a=i.createElement(d), m=i.getElementsByTagName(d)[0];"; | |
| 171 | - $output .= "a.async=1; a.src=e; m.parentNode.insertBefore(a,m);}"; | |
| 172 | - $output .= "})(window,document,'script','https://d1z78r8i505acl.cloudfront.net/playerAssets/"; | |
| 173 | - $output .= "$vdo_embed_version_str"; | |
| 174 | - $output .= "/vdo.js','vdo');"; | |
| 175 | - $output .= "vdo.add({"; | |
| 176 | - $output .= "otp: '$OTP',"; | |
| 177 | - $output .= "playbackInfo: btoa(JSON.stringify({"; | |
| 178 | - $output .= "videoId: '$video'})),"; | |
| 179 | - $output .= "theme: '$vdo_player_theme',"; | |
| 180 | - if($player_tech !== ''){ | |
| 181 | - $output .= "techoverride: [" ; | |
| 182 | - $techarray = explode(',', $player_tech); | |
| 183 | - for($i = 0; $i < sizeof($techarray); $i++){ | |
| 184 | - $output .= "'$techarray[$i]'"; | |
| 185 | - if($i !== sizeof($techarray)-1) | |
| 186 | - $output .= ", "; | |
| 187 | - } | |
| 188 | - $output .= "],"; | |
| 189 | - } | |
| 190 | - $output .= "container: document.querySelector('#vdo$OTP'),});"; | |
| 191 | - $output .= "</script>"; | |
| 192 | - } | |
| 130 | + $output .= "}); </script>"; | |
| 193 | 131 | return $output; |
| 194 | 132 | } |
| 195 | 133 | |
| 196 | 134 | add_shortcode('vdo', 'vdo_shortcode'); |
| 197 | 135 | |
| 136 | + | |
| 198 | 137 | /// adding the settings link |
| 199 | 138 | $plugin = plugin_basename(__FILE__); |
| 200 | 139 | add_filter("plugin_action_links_$plugin", 'vdo_settings_link'); |
| 201 | 140 | |
| @@ -200,13 +139,14 @@ | ||
| 200 | 139 | add_filter("plugin_action_links_$plugin", 'vdo_settings_link'); |
| 201 | 140 | |
| 202 | 141 | function vdo_settings_link($links) |
| 203 | 142 | { |
| 204 | - $settings_link = '<a href="options-general.php?page=vdocipher">Settings</a>'; | |
| 143 | + $settings_link = '<a href="options-general.php?page=vdocipher.php">Settings</a>'; | |
| 205 | 144 | array_unshift($links, $settings_link); |
| 206 | 145 | return $links; |
| 207 | 146 | } |
| 208 | 147 | |
| 148 | + | |
| 209 | 149 | /// add the menu item and register settings |
| 210 | 150 | if (is_admin()) { // admin actions |
| 211 | 151 | add_action('admin_menu', 'vdo_menu'); |
| 212 | 152 | add_action('admin_init', 'register_vdo_settings'); |
| @@ -214,17 +154,17 @@ | ||
| 214 | 154 | // non-admin enqueues, actions, and filters |
| 215 | 155 | } |
| 216 | 156 | function vdo_menu() |
| 217 | 157 | { |
| 218 | - add_menu_page('VdoCipher Options', 'VdoCipher', 'manage_options', 'vdocipher', 'vdo_options', plugin_dir_url(__FILE__).'images/logo.png'); | |
| 158 | + add_options_page('VdoCipher Options', 'VdoCipher', 'manage_options', 'vdocipher', 'vdo_options'); | |
| 219 | 159 | } |
| 220 | 160 | function vdo_options() |
| 221 | 161 | { |
| 222 | 162 | if (!get_option('vdo_default_height')) { |
| 223 | - update_option('vdo_default_height', 'auto'); | |
| 163 | + update_option('vdo_default_height', '360'); | |
| 224 | 164 | } |
| 225 | 165 | if (!get_option('vdo_default_width')) { |
| 226 | - update_option('vdo_default_width', '1280'); | |
| 166 | + update_option('vdo_default_width', '640'); | |
| 227 | 167 | } |
| 228 | 168 | $vdo_client_key = get_option('vdo_client_key'); |
| 229 | 169 | if (!$vdo_client_key && strlen($vdo_client_key) != 64) { |
| 230 | 170 | vdo_show_form_client_key(); |
| @@ -241,10 +181,8 @@ | ||
| 241 | 181 | register_setting('vdo_option-group', 'vdo_client_key'); |
| 242 | 182 | register_setting('vdo_option-group', 'vdo_default_height'); |
| 243 | 183 | register_setting('vdo_option-group', 'vdo_default_width'); |
| 244 | 184 | register_setting('vdo_option-group', 'vdo_annotate_code'); |
| 245 | - register_setting('vdo_option-group', 'vdo_embed_version'); | |
| 246 | - register_setting('vdo_option-group', 'vdo_player_theme'); | |
| 247 | 185 | } |
| 248 | 186 | |
| 249 | 187 | /// adding a section for asking for the client key |
| 250 | 188 | function vdo_show_form_client_key() |
| @@ -257,25 +195,16 @@ | ||
| 257 | 195 | delete_option('vdo_client_key'); |
| 258 | 196 | delete_option('vdo_default_width'); |
| 259 | 197 | delete_option('vdo_default_height'); |
| 260 | 198 | delete_option('vdo_annotate_code'); |
| 261 | - delete_option('vdo_embed_version'); | |
| 262 | - delete_option('vdo_player_theme'); | |
| 263 | 199 | } |
| 264 | 200 | function vdo_activate() |
| 265 | 201 | { |
| 266 | - if ((get_option('vdo_default_height')) == false) { | |
| 267 | - update_option('vdo_default_height', 'auto'); | |
| 202 | + if (!get_option('vdo_default_height')) { | |
| 203 | + update_option('vdo_default_height', '400'); | |
| 268 | 204 | } |
| 269 | - if ((get_option('vdo_default_width')) == false) { | |
| 270 | - update_option('vdo_default_width', '1280'); | |
| 271 | - } | |
| 272 | - //https://stackoverflow.com/a/2173318/5022684 | |
| 273 | - if ((get_option('vdo_embed_version')) == false) { | |
| 274 | - update_option('vdo_embed_version', '1.5.0'); | |
| 275 | - } | |
| 276 | - if ((get_option('vdo_player_theme')) == false) { | |
| 277 | - update_option('vdo_player_theme','9ae8bbe8dd964ddc9bdb932cca1cb59a'); | |
| 205 | + if (!get_option('vdo_default_width')) { | |
| 206 | + update_option('vdo_default_width', '640'); | |
| 278 | 207 | } |
| 279 | 208 | } |
| 280 | 209 | register_activation_hook(__FILE__, 'vdo_activate'); |
| 281 | 210 | function vdo_admin_notice() |