| @@ -2,9 +2,9 @@ | ||
| 2 | 2 | /** |
| 3 | 3 | * Plugin Name: VdoCipher |
| 4 | 4 | * Plugin URI: https://www.vdocipher.com |
| 5 | 5 | * Description: Secured video hosting for wordpress |
| 6 | - * Version: 1.25 | |
| 6 | + * Version: 1.24 | |
| 7 | 7 | * Author: VdoCipher |
| 8 | 8 | * Author URI: https://www.vdocipher.com |
| 9 | 9 | * License: GPL2 |
| 10 | 10 | */ |
| @@ -15,45 +15,10 @@ | ||
| 15 | 15 | "</head><body>\r\n<h1>Not Found</h1>\r\n<p>The requested URL " . $_SERVER['SCRIPT_NAME'] . " was not found on ". |
| 16 | 16 | "this server.</p>\r\n</body></html>"); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | -if (!defined('VDOCIPHER_PLUGIN_VERSION')) { | |
| 20 | - define('VDOCIPHER_PLUGIN_VERSION', '1.25'); | |
| 21 | -} | |
| 22 | - | |
| 23 | -if (!defined('VDOCIPHER_PLAYER_VERSION')) { | |
| 24 | - define('VDOCIPHER_PLAYER_VERSION', '1.6.10'); | |
| 25 | -} | |
| 26 | - | |
| 27 | -function vdo_plugin_check_version() | |
| 28 | -{ | |
| 29 | -// This applies only for installs 1.24 and below | |
| 30 | - if (!get_option('vdo_plugin_version')) { | |
| 31 | - if (preg_match('/^1\.[0123456]\.[0-9]{1,2}$/', get_option('vdo_embed_version'))) { | |
| 32 | - update_option('vdo_embed_version', VDOCIPHER_PLAYER_VERSION); | |
| 33 | - } | |
| 34 | - if (preg_match('/^1\.[01234]\.[0-9]{1,2}$/', get_option('vdo_embed_version'))) { | |
| 35 | - update_option('vdo_default_height', 'auto'); | |
| 36 | - } | |
| 37 | - update_option('vdo_plugin_version', VDOCIPHER_PLUGIN_VERSION); | |
| 38 | - return ; | |
| 39 | - } | |
| 40 | - // This applies for all new installs after 1.25 | |
| 41 | - if (VDOCIPHER_PLUGIN_VERSION !== get_option('vdo_plugin_version')) { | |
| 42 | - if (preg_match('/^1\.[0-9]{1,2}\.[0-9]{1,2}$/', get_option('vdo_embed_version'))) { | |
| 43 | - update_option('vdo_embed_version', VDOCIPHER_PLAYER_VERSION); | |
| 44 | - } | |
| 45 | - update_option('vdo_plugin_version', VDOCIPHER_PLUGIN_VERSION); | |
| 46 | - return ; | |
| 47 | - } | |
| 48 | - return ; | |
| 49 | -} | |
| 50 | - | |
| 51 | -add_action('plugins_loaded', 'vdo_plugin_check_version'); | |
| 52 | - | |
| 53 | 19 | // Function called to retrieve id for when title given, starts |
| 54 | -function vdo_retrieve_id($title) | |
| 55 | -{ | |
| 20 | +function vdo_retrieve_id($title) { | |
| 56 | 21 | $client_key = get_option('vdo_client_key'); |
| 57 | 22 | if ($client_key == false || $client_key == "") { |
| 58 | 23 | return "Plugin not configured. Please set the API key to embed videos."; |
| 59 | 24 | } |
| @@ -81,10 +46,9 @@ | ||
| 81 | 46 | } |
| 82 | 47 | // Function called to retrieve id for when title given, ends |
| 83 | 48 | |
| 84 | 49 | // Function called to get OTP, starts |
| 85 | -function vdo_otp($video, $otp_post_array = array()) | |
| 86 | -{ | |
| 50 | +function vdo_otp($video, $otp_post_array = array()) { | |
| 87 | 51 | $client_key = get_option('vdo_client_key'); |
| 88 | 52 | if ($client_key == false || $client_key == "") { |
| 89 | 53 | return "Plugin not configured. Please set the API key to embed videos."; |
| 90 | 54 | } |
| @@ -94,16 +58,13 @@ | ||
| 94 | 58 | 'Content-Type'=>'application/json', |
| 95 | 59 | 'Accept'=>'application/json' |
| 96 | 60 | ); |
| 97 | 61 | $otp_post_json = json_encode($otp_post_array); |
| 98 | - $response = wp_remote_post( | |
| 99 | - $url, | |
| 100 | - array( | |
| 101 | - 'method' => 'POST', | |
| 102 | - 'headers' => $headers, | |
| 103 | - 'body' => $otp_post_json | |
| 104 | - ) | |
| 105 | - ); | |
| 62 | + $response = wp_remote_post($url, array( | |
| 63 | + 'method' => 'POST', | |
| 64 | + 'headers' => $headers, | |
| 65 | + 'body' => $otp_post_json | |
| 66 | + )); | |
| 106 | 67 | if (is_wp_error($response)) { |
| 107 | 68 | $error_message = $response->get_error_message(); |
| 108 | 69 | echo "VdoCipher: Something went wrong: $error_message"; |
| 109 | 70 | return ""; |
| @@ -115,50 +76,36 @@ | ||
| 115 | 76 | |
| 116 | 77 | // VdoCipher Shortcode starts |
| 117 | 78 | function vdo_shortcode($atts) |
| 118 | 79 | { |
| 119 | - $vdo_args = shortcode_atts( | |
| 80 | + extract(shortcode_atts( | |
| 120 | 81 | array( |
| 121 | - 'title' => 'TITLE_OF_VIDEO', | |
| 122 | - 'width' => get_option('vdo_default_width'), | |
| 123 | - 'height' => get_option('vdo_default_height'), | |
| 124 | - 'id' => 'id', | |
| 125 | - 'no_annotate'=> false, | |
| 126 | - 'version'=> 0, | |
| 127 | - 'vdo_theme'=> false, | |
| 128 | - 'vdo_version'=> false, | |
| 129 | - 'player_tech'=> '' | |
| 130 | - ), | |
| 82 | + 'title' => 'TITLE_OF_VIDEO', | |
| 83 | + 'width' => get_option('vdo_default_width') . "px", | |
| 84 | + 'height' => get_option('vdo_default_height') . "px", | |
| 85 | + 'id' => 'id', | |
| 86 | + 'no_annotate'=> false, | |
| 87 | + 'version'=> 0, | |
| 88 | + 'vdo_theme'=> false, | |
| 89 | + 'player_tech'=> '' | |
| 90 | + ), | |
| 131 | 91 | $atts |
| 132 | - ); | |
| 133 | - $title = $vdo_args['title']; | |
| 134 | - $width = $vdo_args['width']; | |
| 135 | - $height = $vdo_args['height']; | |
| 136 | - $id = $vdo_args['id']; | |
| 137 | - $no_annotate = $vdo_args['no_annotate']; | |
| 138 | - $version = $vdo_args['version']; | |
| 139 | - $vdo_theme = $vdo_args['vdo_theme']; | |
| 140 | - $vdo_version = $vdo_args['vdo_version']; | |
| 141 | - $player_tech = $vdo_args['player_tech']; | |
| 142 | - | |
| 143 | - if (!preg_match('/.*px$/', $width)) { | |
| 144 | - $width = $width."px"; | |
| 92 | + )); | |
| 93 | + if ((get_option('vdo_default_height')) == 'auto') { | |
| 94 | + $height = 'auto'; | |
| 145 | 95 | } |
| 146 | - if (!preg_match('/.*px$/', $height)) { | |
| 147 | - if ($height != 'auto') { | |
| 148 | - $height = $height."px"; | |
| 149 | - } | |
| 150 | - } | |
| 151 | 96 | if (!$atts['id']) { |
| 152 | 97 | if (!$atts['title']) { |
| 153 | 98 | return "Required argument id for embedded video not found."; |
| 154 | - } else { | |
| 99 | + } | |
| 100 | + else { | |
| 155 | 101 | $video = vdo_retrieve_id($title); |
| 156 | 102 | if ($video == null) { |
| 157 | 103 | return "404. Video not found."; |
| 158 | 104 | } |
| 159 | 105 | } |
| 160 | - } else { | |
| 106 | + } | |
| 107 | + else { | |
| 161 | 108 | $video = $id; |
| 162 | 109 | } |
| 163 | 110 | |
| 164 | 111 | // Initialize $otp_post_array, to be sent as part of OTP request, as for time-to-live 300 |
| @@ -181,10 +128,9 @@ | ||
| 181 | 128 | } |
| 182 | 129 | $vdo_annotate_code = str_replace('{ip}', $_SERVER['REMOTE_ADDR'], $vdo_annotate_code); |
| 183 | 130 | $vdo_annotate_code = preg_replace_callback('/\{date\.([^\}]+)\}/', "eval_date", $vdo_annotate_code); |
| 184 | 131 | $vdo_annotate_code = apply_filters('vdocipher_annotate_postprocess', $vdo_annotate_code); |
| 185 | - // Add annotate code to $otp_post_array, which will be | |
| 186 | - // converted to Json and then sent as POST body to API endpoint | |
| 132 | + // Add annotate code to $otp_post_array, which will be converted to Json and then sent as POST body to API endpoint | |
| 187 | 133 | if (!$no_annotate) { |
| 188 | 134 | $otp_post_array["annotate"] = $vdo_annotate_code; |
| 189 | 135 | } |
| 190 | 136 | } |
| @@ -193,8 +139,9 @@ | ||
| 193 | 139 | $OTP = $OTP_Response->otp; |
| 194 | 140 | $playbackInfo = $OTP_Response->playbackInfo; |
| 195 | 141 | |
| 196 | 142 | if (is_null($OTP)) { |
| 143 | + | |
| 197 | 144 | $output = "<span id='vdo$OTP' style='background:#555555;color:#FFFFFF'><h4>Video not found</h4></span>"; |
| 198 | 145 | return $output; |
| 199 | 146 | } |
| 200 | 147 | |
| @@ -203,25 +150,22 @@ | ||
| 203 | 150 | if (isset($atts['version'])) { |
| 204 | 151 | $version = $atts['version']; |
| 205 | 152 | } |
| 206 | 153 | |
| 207 | - // Video Embed version is retrieved from options table or from shortcode attribute | |
| 154 | + // Video Embed version is updated | |
| 208 | 155 | if ((get_option('vdo_embed_version')) == false) { |
| 209 | - update_option('vdo_embed_version', VDOCIPHER_PLAYER_VERSION); | |
| 156 | + update_option('vdo_embed_version', '1.6.4'); | |
| 210 | 157 | } |
| 211 | - if (!$vdo_version) { | |
| 212 | - $vdo_embed_version_str = get_option('vdo_embed_version'); | |
| 213 | - } else { | |
| 214 | - $vdo_embed_version_str = $vdo_version; | |
| 215 | - } | |
| 158 | + $vdo_embed_version_str = get_option('vdo_embed_version'); | |
| 216 | 159 | |
| 217 | 160 | // Video Player theme, update and as shortcode attribute |
| 218 | 161 | if ((get_option('vdo_player_theme')) == false) { |
| 219 | 162 | update_option('vdo_player_theme', '9ae8bbe8dd964ddc9bdb932cca1cb59a'); |
| 220 | 163 | } |
| 221 | - if (!$vdo_theme) { | |
| 164 | + if(!$vdo_theme){ | |
| 222 | 165 | $vdo_player_theme = get_option('vdo_player_theme'); |
| 223 | - } else { | |
| 166 | + } | |
| 167 | + else { | |
| 224 | 168 | $vdo_player_theme = $vdo_theme; |
| 225 | 169 | } |
| 226 | 170 | |
| 227 | 171 | // tech override custom names |
| @@ -264,9 +208,9 @@ | ||
| 264 | 208 | if (get_option('vdo_watermark_flash_html') === 'flash') { |
| 265 | 209 | $player_tech = "*,-dash"; |
| 266 | 210 | } |
| 267 | 211 | } |
| 268 | - $output = "<div id='vdo$OTP' style='height:$height;width:$width;max-width:100%' ></div>"; | |
| 212 | + $output .= "<div id='vdo$OTP' style='height:$height;width:$width;max-width:100%' ></div>"; | |
| 269 | 213 | $output .= "<script>(function(v,i,d,e,o){v[o]=v[o]||{}; v[o].add = v[o].add || function V(a){". |
| 270 | 214 | "(v[o].d=v[o].d||[]).push(a);};"; |
| 271 | 215 | $output .= "if(!v[o].l) { v[o].l=1*new Date(); a=i.createElement(d), m=i.getElementsByTagName(d)[0];"; |
| 272 | 216 | $output .= "a.async=1; a.src=e; m.parentNode.insertBefore(a,m);}"; |
| @@ -276,18 +220,8 @@ | ||
| 276 | 220 | $output .= "vdo.add({"; |
| 277 | 221 | $output .= "otp: '$OTP',"; |
| 278 | 222 | $output .= "playbackInfo: '$playbackInfo',"; |
| 279 | 223 | $output .= "theme: '$vdo_player_theme',"; |
| 280 | - $output .= "plugins: [{"; | |
| 281 | - $output .= "name: 'keyboard',"; | |
| 282 | - $output .= "options: {"; | |
| 283 | - $output .= "preset: 'default',"; | |
| 284 | - $output .= "bindings: {"; | |
| 285 | - $output .= "'Left' : (player) => player.seek(player.currentTime - 15),"; | |
| 286 | - $output .= "'Right' : (player) => player.seek(player.currentTime + 15),"; | |
| 287 | - $output .= "},"; | |
| 288 | - $output .= "}"; | |
| 289 | - $output .= "}],"; | |
| 290 | 224 | if ($player_tech !== '') { |
| 291 | 225 | $output .= "techoverride: [" ; |
| 292 | 226 | $techarray = explode(',', $player_tech); |
| 293 | 227 | for ($i = 0; $i < sizeof($techarray); $i++) { |
| @@ -325,10 +259,9 @@ | ||
| 325 | 259 | add_action('admin_menu', 'vdo_menu'); |
| 326 | 260 | } else { |
| 327 | 261 | // non-admin enqueues, actions, and filters |
| 328 | 262 | } |
| 329 | -function vdo_menu() | |
| 330 | -{ | |
| 263 | +function vdo_menu() { | |
| 331 | 264 | add_menu_page( |
| 332 | 265 | 'VdoCipher Options', |
| 333 | 266 | 'VdoCipher', |
| 334 | 267 | 'manage_options', |
| @@ -345,10 +278,9 @@ | ||
| 345 | 278 | 'themesvdo' |
| 346 | 279 | ); |
| 347 | 280 | } |
| 348 | 281 | |
| 349 | -function themesvdo() | |
| 350 | -{ | |
| 282 | +function themesvdo() { | |
| 351 | 283 | include('include/player_themes.php'); |
| 352 | 284 | } |
| 353 | 285 | |
| 354 | 286 | function vdo_options() |
| @@ -378,9 +310,8 @@ | ||
| 378 | 310 | register_setting('vdo_option-group', 'vdo_annotate_code'); |
| 379 | 311 | register_setting('vdo_option-group', 'vdo_embed_version'); |
| 380 | 312 | register_setting('vdo_option-group', 'vdo_player_theme'); |
| 381 | 313 | register_setting('vdo_option-group', 'vdo_watermark_flash_html'); |
| 382 | - register_setting('vdo_option-group', 'vdo_plugin_version'); | |
| 383 | 314 | register_setting('vdo_custom_theme', 'vdo_player_theme_options'); |
| 384 | 315 | } |
| 385 | 316 | // add the menu item and register settings (3 functions), ends |
| 386 | 317 | |
| @@ -400,9 +331,9 @@ | ||
| 400 | 331 | update_option('vdo_default_width', '1280'); |
| 401 | 332 | } |
| 402 | 333 | //https://stackoverflow.com/a/2173318/5022684 |
| 403 | 334 | if ((get_option('vdo_embed_version')) == false) { |
| 404 | - update_option('vdo_embed_version', VDOCIPHER_PLAYER_VERSION); | |
| 335 | + update_option('vdo_embed_version', '1.6.4'); | |
| 405 | 336 | } |
| 406 | 337 | if ((get_option('vdo_player_theme')) == false) { |
| 407 | 338 | update_option('vdo_player_theme', '9ae8bbe8dd964ddc9bdb932cca1cb59a'); |
| 408 | 339 | } |
| @@ -408,69 +339,11 @@ | ||
| 408 | 339 | } |
| 409 | 340 | if ((get_option('vdo_watermark_flash_html')) == false) { |
| 410 | 341 | update_option('vdo_watermark_flash_html', 'html5'); |
| 411 | 342 | } |
| 412 | - if ((get_option('vdo_plugin_version')) == false) { | |
| 413 | - update_option('vdo_plugin_version', VDOCIPHER_PLUGIN_VERSION); | |
| 414 | - } | |
| 415 | 343 | } |
| 416 | 344 | register_activation_hook(__FILE__, 'vdo_activate'); |
| 417 | 345 | |
| 418 | -// Registering and specifying Gutenberg block | |
| 419 | -function vdo_register_block() | |
| 420 | -{ | |
| 421 | - if (!function_exists('register_block_type')) { | |
| 422 | - return ; | |
| 423 | - } | |
| 424 | - wp_register_script( | |
| 425 | - 'vdo-block-script', | |
| 426 | - plugins_url('/include/block/dist/blocks.build.js', __FILE__), | |
| 427 | - array('wp-blocks', 'wp-element', 'wp-editor', 'wp-i18n') | |
| 428 | - ); | |
| 429 | - wp_register_style( | |
| 430 | - 'vdo-block-base-style', | |
| 431 | - plugins_url('/include/block/dist/blocks.style.build.css', __FILE__), | |
| 432 | - array('wp-blocks') | |
| 433 | - ); | |
| 434 | - wp_register_style( | |
| 435 | - 'vdo-block-editor-style', | |
| 436 | - plugins_url('/include/block/dist/blocks.editor.build.css', __FILE__), | |
| 437 | - array('wp-edit-blocks') | |
| 438 | - ); | |
| 439 | - register_block_type( | |
| 440 | - 'vdo/block', | |
| 441 | - array( | |
| 442 | - 'editor_script'=>'vdo-block-script', | |
| 443 | - 'editor_style'=>'vdo-block-editor-style', | |
| 444 | - 'style'=>'vdo-block-base-style', | |
| 445 | - 'attributes'=>array( | |
| 446 | - 'id'=>array( | |
| 447 | - 'type'=>'string', | |
| 448 | - ), | |
| 449 | - 'width'=>array( | |
| 450 | - 'type'=>'string', | |
| 451 | - 'default'=>get_option('vdo_default_width') | |
| 452 | - ), | |
| 453 | - 'height'=>array( | |
| 454 | - 'type'=>'string', | |
| 455 | - 'default'=>get_option('vdo_default_height') | |
| 456 | - ), | |
| 457 | - 'vdo_theme'=>array( | |
| 458 | - 'type'=>'string', | |
| 459 | - 'default'=>get_option('vdo_player_theme') | |
| 460 | - ), | |
| 461 | - 'vdo_version'=>array( | |
| 462 | - 'type'=>'string', | |
| 463 | - 'default'=>get_option('vdo_embed_version') | |
| 464 | - ), | |
| 465 | - ), | |
| 466 | - 'render_callback'=>'vdo_shortcode' | |
| 467 | - ) | |
| 468 | - ); | |
| 469 | -} | |
| 470 | - | |
| 471 | -add_action('init', 'vdo_register_block'); | |
| 472 | - | |
| 473 | 346 | // Deactivation Hook starts |
| 474 | 347 | function vdo_deactivate() |
| 475 | 348 | { |
| 476 | 349 | delete_option('vdo_client_key'); |
| @@ -480,9 +353,8 @@ | ||
| 480 | 353 | delete_option('vdo_embed_version'); |
| 481 | 354 | delete_option('vdo_player_theme'); |
| 482 | 355 | delete_option('vdo_watermark_flash_html'); |
| 483 | 356 | delete_option('vdo_player_theme_options'); |
| 484 | - delete_option('vdo_plugin_version'); | |
| 485 | 357 | } |
| 486 | 358 | register_deactivation_hook(__FILE__, 'vdo_deactivate'); |
| 487 | 359 | |
| 488 | 360 | // Admin notice to configure plugin for new installs, starts |