| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * Plugin Name: VdoCipher |
| 4 | - * Plugin URI: https://www.vdocipher.com | |
| 4 | + * Plugin URI: http://www.vdocipher.com | |
| 5 | 5 | * Description: Secured video hosting for wordpress |
| 6 | - * Version: 1.25 | |
| 6 | + * Version: 1.13 | |
| 7 | 7 | * Author: VdoCipher |
| 8 | - * Author URI: https://www.vdocipher.com | |
| 8 | + * Author URI: http://www.vdocipher.com | |
| 9 | 9 | * License: GPL2 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | if (__FILE__ == $_SERVER['SCRIPT_FILENAME']) { |
| @@ -15,58 +15,21 @@ | ||
| 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() | |
| 19 | +function vdo_send($action, $params, $posts = array()) | |
| 28 | 20 | { |
| 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 | -// Function called to retrieve id for when title given, starts | |
| 54 | -function vdo_retrieve_id($title) | |
| 55 | -{ | |
| 56 | 21 | $client_key = get_option('vdo_client_key'); |
| 57 | 22 | if ($client_key == false || $client_key == "") { |
| 58 | - return "Plugin not configured. Please set the API key to embed videos."; | |
| 23 | + return "Plugin not configured. Please set the key to embed videos."; | |
| 59 | 24 | } |
| 60 | - $url = "https://dev.vdocipher.com/api/videos?q=$title"; | |
| 61 | - $headers = array( | |
| 62 | - 'Authorization'=>'Apisecret '.$client_key, | |
| 63 | - 'Content-Type'=>'application/json', | |
| 64 | - 'Accept'=>'application/json' | |
| 65 | - ); | |
| 66 | - $response = wp_remote_post($url, array( | |
| 67 | - 'method' => 'GET', | |
| 68 | - 'headers' => $headers | |
| 25 | + | |
| 26 | + $getData = http_build_query($params); | |
| 27 | + $posts["clientSecretKey"] = $client_key; | |
| 28 | + $url = "http://api.vdocipher.com/v2/$action/?$getData"; | |
| 29 | + $response = wp_safe_remote_post($url, array( | |
| 30 | + 'method' => 'POST', | |
| 31 | + 'body' => $posts | |
| 69 | 32 | )); |
| 70 | 33 | if (is_wp_error($response)) { |
| 71 | 34 | $error_message = $response->get_error_message(); |
| 72 | 35 | echo "VdoCipher: Something went wrong: $error_message"; |
| @@ -71,99 +34,52 @@ | ||
| 71 | 34 | $error_message = $response->get_error_message(); |
| 72 | 35 | echo "VdoCipher: Something went wrong: $error_message"; |
| 73 | 36 | return ""; |
| 74 | 37 | } |
| 75 | - $video_json_response = $response['body']; | |
| 76 | - $video_list_object = json_decode($video_json_response); | |
| 77 | - $video_list = $video_list_object->rows; | |
| 78 | - $video_object = $video_list[0]; | |
| 79 | - $video_id = $video_object->id; | |
| 80 | - return $video_id; | |
| 38 | + return $response['body']; | |
| 81 | 39 | } |
| 82 | -// Function called to retrieve id for when title given, ends | |
| 83 | - | |
| 84 | -// Function called to get OTP, starts | |
| 85 | -function vdo_otp($video, $otp_post_array = array()) | |
| 86 | -{ | |
| 87 | - $client_key = get_option('vdo_client_key'); | |
| 88 | - if ($client_key == false || $client_key == "") { | |
| 89 | - return "Plugin not configured. Please set the API key to embed videos."; | |
| 90 | - } | |
| 91 | - $url = "https://dev.vdocipher.com/api/videos/$video/otp"; | |
| 92 | - $headers = array( | |
| 93 | - 'Authorization'=>'Apisecret '.$client_key, | |
| 94 | - 'Content-Type'=>'application/json', | |
| 95 | - 'Accept'=>'application/json' | |
| 96 | - ); | |
| 97 | - $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 | - ); | |
| 106 | - if (is_wp_error($response)) { | |
| 107 | - $error_message = $response->get_error_message(); | |
| 108 | - echo "VdoCipher: Something went wrong: $error_message"; | |
| 109 | - return ""; | |
| 110 | - } | |
| 111 | - $OTP_Response = $response['body']; | |
| 112 | - return json_decode($OTP_Response); | |
| 113 | -} | |
| 114 | -// Function called to get OTP, ends | |
| 115 | - | |
| 116 | -// VdoCipher Shortcode starts | |
| 117 | 40 | function vdo_shortcode($atts) |
| 118 | 41 | { |
| 119 | - $vdo_args = shortcode_atts( | |
| 42 | + extract(shortcode_atts( | |
| 120 | 43 | 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 | - ), | |
| 44 | + 'title' => 'TITLE_OF_VIDEO', | |
| 45 | + 'width' => get_option('vdo_default_width') . "px", | |
| 46 | + 'height' => get_option('vdo_default_height') . "px", | |
| 47 | + 'id' => 'id', | |
| 48 | + 'no_annotate'=> false, | |
| 49 | + 'version'=> 0, | |
| 50 | + ), | |
| 131 | 51 | $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"; | |
| 145 | - } | |
| 146 | - if (!preg_match('/.*px$/', $height)) { | |
| 147 | - if ($height != 'auto') { | |
| 148 | - $height = $height."px"; | |
| 149 | - } | |
| 150 | - } | |
| 52 | + )); | |
| 151 | 53 | if (!$atts['id']) { |
| 152 | 54 | if (!$atts['title']) { |
| 153 | 55 | return "Required argument id for embedded video not found."; |
| 154 | - } else { | |
| 155 | - $video = vdo_retrieve_id($title); | |
| 156 | - if ($video == null) { | |
| 157 | - return "404. Video not found."; | |
| 158 | - } | |
| 159 | 56 | } |
| 57 | + $params = array( | |
| 58 | + 'search'=>array( | |
| 59 | + 'title'=>$title | |
| 60 | + ), | |
| 61 | + 'page'=>1, | |
| 62 | + 'limit'=>30, | |
| 63 | + 'type'=>'json' | |
| 64 | + ); | |
| 65 | + $video = vdo_send("videos", $params); | |
| 66 | + $video = json_decode($video); | |
| 67 | + if ($video == null) { | |
| 68 | + return "404. Video not found."; | |
| 69 | + } | |
| 70 | + $video = $video[0]->id; | |
| 71 | + if ($video == null) { | |
| 72 | + return "No video with given title found."; | |
| 73 | + } | |
| 160 | 74 | } else { |
| 161 | 75 | $video = $id; |
| 162 | 76 | } |
| 163 | 77 | |
| 164 | - // Initialize $otp_post_array, to be sent as part of OTP request, as for time-to-live 300 | |
| 165 | - $otp_post_array = array("ttl" => 300); | |
| 78 | + $params = array( | |
| 79 | + 'video'=>$video | |
| 80 | + ); | |
| 81 | + $anno = false; | |
| 166 | 82 | if (!function_exists("eval_date")) { |
| 167 | 83 | function eval_date($matches) |
| 168 | 84 | { |
| 169 | 85 | return current_time($matches[1]); |
| @@ -181,134 +97,70 @@ | ||
| 181 | 97 | } |
| 182 | 98 | $vdo_annotate_code = str_replace('{ip}', $_SERVER['REMOTE_ADDR'], $vdo_annotate_code); |
| 183 | 99 | $vdo_annotate_code = preg_replace_callback('/\{date\.([^\}]+)\}/', "eval_date", $vdo_annotate_code); |
| 184 | 100 | $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 | |
| 187 | 101 | if (!$no_annotate) { |
| 188 | - $otp_post_array["annotate"] = $vdo_annotate_code; | |
| 102 | + $anno = array("annotate" => $vdo_annotate_code); | |
| 189 | 103 | } |
| 190 | 104 | } |
| 191 | - // OTP is requested via vdo_otp function | |
| 192 | - $OTP_Response = vdo_otp($video, $otp_post_array); | |
| 193 | - $OTP = $OTP_Response->otp; | |
| 194 | - $playbackInfo = $OTP_Response->playbackInfo; | |
| 195 | - | |
| 105 | + $OTP = vdo_send("otp", $params, $anno); | |
| 106 | + $OTP = json_decode($OTP); | |
| 196 | 107 | if (is_null($OTP)) { |
| 197 | 108 | $output = "<span id='vdo$OTP' style='background:#555555;color:#FFFFFF'><h4>Video not found</h4></span>"; |
| 198 | 109 | return $output; |
| 199 | 110 | } |
| 111 | + $OTP = $OTP->otp; | |
| 200 | 112 | |
| 201 | - // Version, legacy, for flash only | |
| 202 | 113 | $version = 0; |
| 203 | 114 | if (isset($atts['version'])) { |
| 204 | 115 | $version = $atts['version']; |
| 205 | 116 | } |
| 206 | - | |
| 207 | - // Video Embed version is retrieved from options table or from shortcode attribute | |
| 208 | - if ((get_option('vdo_embed_version')) == false) { | |
| 209 | - update_option('vdo_embed_version', VDOCIPHER_PLAYER_VERSION); | |
| 117 | + if (empty(get_option('vdo_embed_version'))) { | |
| 118 | + update_option('vdo_embed_version', '0.5'); | |
| 210 | 119 | } |
| 211 | - if (!$vdo_version) { | |
| 212 | - $vdo_embed_version_str = get_option('vdo_embed_version'); | |
| 213 | - } else { | |
| 214 | - $vdo_embed_version_str = $vdo_version; | |
| 120 | + if (empty(get_option('vdo_player_theme'))) { | |
| 121 | + update_option('vdo_player_theme','9ae8bbe8dd964ddc9bdb932cca1cb59a'); | |
| 215 | 122 | } |
| 123 | + $vdo_embed_version_str = get_option('vdo_embed_version'); | |
| 124 | + $vdo_player_theme = get_option('vdo_player_theme'); | |
| 216 | 125 | |
| 217 | - // Video Player theme, update and as shortcode attribute | |
| 218 | - if ((get_option('vdo_player_theme')) == false) { | |
| 219 | - update_option('vdo_player_theme', '9ae8bbe8dd964ddc9bdb932cca1cb59a'); | |
| 220 | - } | |
| 221 | - if (!$vdo_theme) { | |
| 222 | - $vdo_player_theme = get_option('vdo_player_theme'); | |
| 223 | - } else { | |
| 224 | - $vdo_player_theme = $vdo_theme; | |
| 225 | - } | |
| 226 | - | |
| 227 | - // tech override custom names | |
| 228 | - switch ($player_tech) { | |
| 229 | - case "flash": | |
| 230 | - $player_tech = "*,-dash"; | |
| 231 | - break; | |
| 232 | - case "nohtml5": | |
| 233 | - $player_tech = "*,-dash"; | |
| 234 | - break; | |
| 235 | - case "noflash": | |
| 236 | - $player_tech = "*,-hss"; | |
| 237 | - break; | |
| 238 | - case "nozen": | |
| 239 | - $player_tech = "*,-zen"; | |
| 240 | - break; | |
| 241 | - case "noios": | |
| 242 | - $player_tech = "*,-hlse"; | |
| 243 | - break; | |
| 244 | - default: | |
| 245 | - break; | |
| 246 | - } | |
| 247 | - | |
| 248 | 126 | // Old Embed Code |
| 249 | - if ($vdo_embed_version_str === '0.5') { | |
| 250 | - $output = "<div id='vdo$OTP' style='height:$height;width:$width;max-width:100%' ></div>"; | |
| 251 | - $output .= "<script> (function(v,i,d,e,o){v[o]=v[o]||{}; v[o].add = v[o].add || function V(a){". | |
| 252 | - " (v[o].d=v[o].d||[]).push(a);};"; | |
| 253 | - $output .= "if(!v[o].l) { v[o].l=1*new Date();a=i.createElement(d),m=i.getElementsByTagName(d)[0];a.async=1;". | |
| 254 | - "a.src=e; m.parentNode.insertBefore(a,m);}"; | |
| 255 | - $output .= " })(window,document,'script','//de122v0opjemw.cloudfront.net/vdo.js','vdo'); vdo.add({ "; | |
| 256 | - $output .= "o: '$OTP', "; | |
| 257 | - if ($version == 32) { | |
| 258 | - $output .= "version: '$version' "; | |
| 259 | - } | |
| 260 | - $output .= "}); </script>"; | |
| 261 | - } else { | |
| 262 | - //New embed code | |
| 263 | - if ($player_tech === '') { | |
| 264 | - if (get_option('vdo_watermark_flash_html') === 'flash') { | |
| 265 | - $player_tech = "*,-dash"; | |
| 266 | - } | |
| 267 | - } | |
| 268 | - $output = "<div id='vdo$OTP' style='height:$height;width:$width;max-width:100%' ></div>"; | |
| 269 | - $output .= "<script>(function(v,i,d,e,o){v[o]=v[o]||{}; v[o].add = v[o].add || function V(a){". | |
| 270 | - "(v[o].d=v[o].d||[]).push(a);};"; | |
| 271 | - $output .= "if(!v[o].l) { v[o].l=1*new Date(); a=i.createElement(d), m=i.getElementsByTagName(d)[0];"; | |
| 272 | - $output .= "a.async=1; a.src=e; m.parentNode.insertBefore(a,m);}"; | |
| 273 | - $output .= "})(window,document,'script','https://d1z78r8i505acl.cloudfront.net/playerAssets/"; | |
| 274 | - $output .= "$vdo_embed_version_str"; | |
| 275 | - $output .= "/vdo.js','vdo');"; | |
| 276 | - $output .= "vdo.add({"; | |
| 277 | - $output .= "otp: '$OTP',"; | |
| 278 | - $output .= "playbackInfo: '$playbackInfo',"; | |
| 279 | - $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 | - if ($player_tech !== '') { | |
| 291 | - $output .= "techoverride: [" ; | |
| 292 | - $techarray = explode(',', $player_tech); | |
| 293 | - for ($i = 0; $i < sizeof($techarray); $i++) { | |
| 294 | - $techStr = $techarray[$i]; | |
| 295 | - $output .= "'$techStr'"; | |
| 296 | - if ($i !== sizeof($techarray)-1) { | |
| 297 | - $output .= ", "; | |
| 298 | - } | |
| 299 | - } | |
| 300 | - $output .= "],"; | |
| 301 | - } | |
| 302 | - $output .= "container: document.querySelector('#vdo$OTP'),});"; | |
| 303 | - $output .= "</script>"; | |
| 304 | - } | |
| 305 | - return $output; | |
| 127 | + if($vdo_embed_version_str === '0.5') { | |
| 128 | + $output = "<div id='vdo$OTP' style='height:$height;width:$width;max-width:100%' ></div>"; | |
| 129 | + $output .= "<script> (function(v,i,d,e,o){v[o]=v[o]||{}; v[o].add = v[o].add || function V(a){". | |
| 130 | + " (v[o].d=v[o].d||[]).push(a);};"; | |
| 131 | + $output .= "if(!v[o].l) { v[o].l=1*new Date(); a=i.createElement(d), m=i.getElementsByTagName(d)[0]; a.async=1; ". | |
| 132 | + "a.src=e; m.parentNode.insertBefore(a,m);}"; | |
| 133 | + $output .= " })(window,document,'script','//de122v0opjemw.cloudfront.net/vdo.js','vdo'); vdo.add({ "; | |
| 134 | + $output .= "o: '$OTP', "; | |
| 135 | + if ($version == 32) { | |
| 136 | + $output .= "version: '$version' "; | |
| 137 | + } | |
| 138 | + $output .= "}); </script>"; | |
| 139 | + } | |
| 140 | + //New embed code | |
| 141 | + else { | |
| 142 | + $output .= "<div id='vdo$OTP' style='height:$height;width:$width;max-width:100%' ></div>"; | |
| 143 | + $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);};"; | |
| 144 | + $output .= "if(!v[o].l) { v[o].l=1*new Date(); a=i.createElement(d), m=i.getElementsByTagName(d)[0];"; | |
| 145 | + $output .= "a.async=1; a.src=e; m.parentNode.insertBefore(a,m);}"; | |
| 146 | + $output .= "})(window,document,'script','https://d1z78r8i505acl.cloudfront.net/playerAssets/"; | |
| 147 | + $output .= "$vdo_embed_version_str"; | |
| 148 | + $output .= "/vdo.js','vdo');"; | |
| 149 | + $output .= "vdo.add({"; | |
| 150 | + $output .= "otp: '$OTP',"; | |
| 151 | + $output .= "playbackInfo: btoa(JSON.stringify({"; | |
| 152 | + $output .= "videoId: '$video'})),"; | |
| 153 | + $output .= "theme: '$vdo_player_theme',"; | |
| 154 | + $output .= "container: document.querySelector('#vdo$OTP'),});"; | |
| 155 | + $output .= "</script>"; | |
| 156 | + } | |
| 157 | + return $output; | |
| 306 | 158 | } |
| 159 | + | |
| 307 | 160 | add_shortcode('vdo', 'vdo_shortcode'); |
| 308 | -// VdoCipher Shortcode ends | |
| 309 | 161 | |
| 310 | -// adding the Settings link, starts | |
| 162 | +/// adding the settings link | |
| 311 | 163 | $plugin = plugin_basename(__FILE__); |
| 312 | 164 | add_filter("plugin_action_links_$plugin", 'vdo_settings_link'); |
| 313 | 165 | |
| 314 | 166 | function vdo_settings_link($links) |
| @@ -316,49 +168,27 @@ | ||
| 316 | 168 | $settings_link = '<a href="options-general.php?page=vdocipher">Settings</a>'; |
| 317 | 169 | array_unshift($links, $settings_link); |
| 318 | 170 | return $links; |
| 319 | 171 | } |
| 320 | -// adding the Settings link, ends | |
| 321 | 172 | |
| 322 | -// add the menu item and register settings (3 functions), starts | |
| 173 | +/// add the menu item and register settings | |
| 323 | 174 | if (is_admin()) { // admin actions |
| 175 | + add_action('admin_menu', 'vdo_menu'); | |
| 324 | 176 | add_action('admin_init', 'register_vdo_settings'); |
| 325 | - add_action('admin_menu', 'vdo_menu'); | |
| 326 | 177 | } else { |
| 327 | 178 | // non-admin enqueues, actions, and filters |
| 328 | 179 | } |
| 329 | 180 | function vdo_menu() |
| 330 | 181 | { |
| 331 | - add_menu_page( | |
| 332 | - 'VdoCipher Options', | |
| 333 | - 'VdoCipher', | |
| 334 | - 'manage_options', | |
| 335 | - 'vdocipher', | |
| 336 | - 'vdo_options', | |
| 337 | - plugin_dir_url(__FILE__).'images/logo.png' | |
| 338 | - ); | |
| 339 | - add_submenu_page( | |
| 340 | - null, | |
| 341 | - 'Video Player Themes', | |
| 342 | - 'CustomPlayer', | |
| 343 | - 'manage_options', | |
| 344 | - 'themesvdo', | |
| 345 | - 'themesvdo' | |
| 346 | - ); | |
| 182 | + add_menu_page('VdoCipher Options', 'VdoCipher', 'manage_options', 'vdocipher', 'vdo_options'); | |
| 347 | 183 | } |
| 348 | - | |
| 349 | -function themesvdo() | |
| 350 | -{ | |
| 351 | - include('include/player_themes.php'); | |
| 352 | -} | |
| 353 | - | |
| 354 | 184 | function vdo_options() |
| 355 | 185 | { |
| 356 | 186 | if (!get_option('vdo_default_height')) { |
| 357 | - update_option('vdo_default_height', 'auto'); | |
| 187 | + update_option('vdo_default_height', '360'); | |
| 358 | 188 | } |
| 359 | 189 | if (!get_option('vdo_default_width')) { |
| 360 | - update_option('vdo_default_width', '1280'); | |
| 190 | + update_option('vdo_default_width', '640'); | |
| 361 | 191 | } |
| 362 | 192 | $vdo_client_key = get_option('vdo_client_key'); |
| 363 | 193 | if (!$vdo_client_key && strlen($vdo_client_key) != 64) { |
| 364 | 194 | vdo_show_form_client_key(); |
| @@ -377,101 +207,16 @@ | ||
| 377 | 207 | register_setting('vdo_option-group', 'vdo_default_width'); |
| 378 | 208 | register_setting('vdo_option-group', 'vdo_annotate_code'); |
| 379 | 209 | register_setting('vdo_option-group', 'vdo_embed_version'); |
| 380 | 210 | register_setting('vdo_option-group', 'vdo_player_theme'); |
| 381 | - register_setting('vdo_option-group', 'vdo_watermark_flash_html'); | |
| 382 | - register_setting('vdo_option-group', 'vdo_plugin_version'); | |
| 383 | - register_setting('vdo_custom_theme', 'vdo_player_theme_options'); | |
| 384 | 211 | } |
| 385 | -// add the menu item and register settings (3 functions), ends | |
| 386 | 212 | |
| 387 | -// section for client key for new users | |
| 213 | +/// adding a section for asking for the client key | |
| 388 | 214 | function vdo_show_form_client_key() |
| 389 | 215 | { |
| 390 | 216 | include('include/setting_form.php'); |
| 391 | 217 | } |
| 392 | - | |
| 393 | -// Activation Hook starts | |
| 394 | -function vdo_activate() | |
| 395 | -{ | |
| 396 | - if ((get_option('vdo_default_height')) == false) { | |
| 397 | - update_option('vdo_default_height', 'auto'); | |
| 398 | - } | |
| 399 | - if ((get_option('vdo_default_width')) == false) { | |
| 400 | - update_option('vdo_default_width', '1280'); | |
| 401 | - } | |
| 402 | - //https://stackoverflow.com/a/2173318/5022684 | |
| 403 | - if ((get_option('vdo_embed_version')) == false) { | |
| 404 | - update_option('vdo_embed_version', VDOCIPHER_PLAYER_VERSION); | |
| 405 | - } | |
| 406 | - if ((get_option('vdo_player_theme')) == false) { | |
| 407 | - update_option('vdo_player_theme', '9ae8bbe8dd964ddc9bdb932cca1cb59a'); | |
| 408 | - } | |
| 409 | - if ((get_option('vdo_watermark_flash_html')) == false) { | |
| 410 | - update_option('vdo_watermark_flash_html', 'html5'); | |
| 411 | - } | |
| 412 | - if ((get_option('vdo_plugin_version')) == false) { | |
| 413 | - update_option('vdo_plugin_version', VDOCIPHER_PLUGIN_VERSION); | |
| 414 | - } | |
| 415 | -} | |
| 416 | -register_activation_hook(__FILE__, 'vdo_activate'); | |
| 417 | - | |
| 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 | -// Deactivation Hook starts | |
| 218 | +register_deactivation_hook(__FILE__, 'vdo_deactivate'); | |
| 474 | 219 | function vdo_deactivate() |
| 475 | 220 | { |
| 476 | 221 | delete_option('vdo_client_key'); |
| 477 | 222 | delete_option('vdo_default_width'); |
| @@ -478,15 +223,25 @@ | ||
| 478 | 223 | delete_option('vdo_default_height'); |
| 479 | 224 | delete_option('vdo_annotate_code'); |
| 480 | 225 | delete_option('vdo_embed_version'); |
| 481 | 226 | delete_option('vdo_player_theme'); |
| 482 | - delete_option('vdo_watermark_flash_html'); | |
| 483 | - delete_option('vdo_player_theme_options'); | |
| 484 | - delete_option('vdo_plugin_version'); | |
| 485 | 227 | } |
| 486 | -register_deactivation_hook(__FILE__, 'vdo_deactivate'); | |
| 487 | - | |
| 488 | -// Admin notice to configure plugin for new installs, starts | |
| 228 | +function vdo_activate() | |
| 229 | +{ | |
| 230 | + if (!get_option('vdo_default_height')) { | |
| 231 | + update_option('vdo_default_height', '360'); | |
| 232 | + } | |
| 233 | + if (!get_option('vdo_default_width')) { | |
| 234 | + update_option('vdo_default_width', '640'); | |
| 235 | + } | |
| 236 | + if (empty(get_option('vdo_embed_version'))) { | |
| 237 | + update_option('vdo_embed_version', '0.5'); | |
| 238 | + } | |
| 239 | + if (empty(get_option('vdo_player_theme'))) { | |
| 240 | + update_option('vdo_player_theme','9ae8bbe8dd964ddc9bdb932cca1cb59a'); | |
| 241 | + } | |
| 242 | +} | |
| 243 | +register_activation_hook(__FILE__, 'vdo_activate'); | |
| 489 | 244 | function vdo_admin_notice() |
| 490 | 245 | { |
| 491 | 246 | if ((!get_option('vdo_client_key') || strlen(get_option('vdo_client_key')) != 64) |
| 492 | 247 | && basename($_SERVER['PHP_SELF']) == "plugins.php" |