| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | if (__FILE__ == $_SERVER['SCRIPT_FILENAME']) { |
| 3 | 3 | header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); |
| 4 | - exit("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n<html lang='en'><head>\r\n<title>404 Not Found</title>\r\n". | |
| 4 | + exit("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n<html><head>\r\n<title>404 Not Found</title>\r\n". | |
| 5 | 5 | "</head><body>\r\n<h1>Not Found</h1>\r\n<p>The requested URL " . $_SERVER['SCRIPT_NAME'] . " was not found on ". |
| 6 | 6 | "this server.</p>\r\n</body></html>"); |
| 7 | 7 | } |
| 8 | 8 | ?> |
| @@ -14,179 +14,135 @@ | ||
| 14 | 14 | <?php |
| 15 | 15 | settings_fields('vdo_option-group'); |
| 16 | 16 | do_settings_sections('vdo_option-group'); |
| 17 | 17 | ?> |
| 18 | - <?php | |
| 19 | - $existingKey = get_option('vdo_client_key'); | |
| 20 | - $keyIsValid = $existingKey && strlen($existingKey) == 64; | |
| 21 | - $keyDescriptionDisplay = $keyIsValid ? 'none' : 'block'; | |
| 22 | - $restElementDisplay = $keyIsValid ? 'table-row-group' : 'none'; | |
| 23 | - ?> | |
| 18 | + <div class="updated"> | |
| 19 | + <p><strong>Status : </strong> Ready to use. You can now embed your videos inside posts and pages.</p> | |
| 20 | + </div> | |
| 24 | 21 | <table class="form-table"> |
| 25 | - <tbody> | |
| 26 | 22 | <tr valign="top"> |
| 27 | - <th scope="row"><label for="vdo_client_key">API Secret Key</label></th> | |
| 28 | - <td> | |
| 29 | - <div style="display: inline-flex;"> | |
| 30 | - <input id="vdo_client_key" name="vdo_client_key" style="width: 640px" | |
| 31 | - type="password" required minlength="64" maxlength="64" | |
| 32 | - value="<?php echo esc_attr(get_option('vdo_client_key')); ?>"/> | |
| 33 | - <button id="toggle_API_visibility" data-protected="On" class="button" type="button">Show API Secret Key</button> | |
| 34 | - </div> | |
| 35 | - <p class="description" style="display: <?= $keyDescriptionDisplay ?>"> | |
| 36 | - API Key is a shared secret between your website servers and vdocipher dashboard. To generate this, | |
| 37 | - login to vdocipher dashboard, go to "Config" > "API Keys". Generate a new key and copy-paste it here. | |
| 38 | - </p> | |
| 39 | - </td> | |
| 23 | + <th scope="row">Client Secret Key</th> | |
| 24 | + <td><input type="text" name="vdo_client_key" | |
| 25 | + value="<?php echo esc_attr(get_option('vdo_client_key')); ?>" | |
| 26 | + max-length="64" style="width: 640px" id="vdo_client_key" /></td> | |
| 40 | 27 | </tr> |
| 41 | - </tbody> | |
| 42 | 28 | |
| 43 | - <tbody style="display: <?= $restElementDisplay ?>"> | |
| 44 | 29 | <tr valign="top"> |
| 45 | - <th scope="row"><label for="vdo_default_width">Default Width</label></th> | |
| 46 | - <td> | |
| 47 | - <input id="vdo_default_width" name="vdo_default_width" | |
| 48 | - type="number" required | |
| 49 | - value="<?php echo esc_attr(get_option('vdo_default_width')); ?>" | |
| 30 | + <th scope="row">Default Width</th> | |
| 31 | + <td><input type="text" id="vdo_default_width" name="vdo_default_width" | |
| 32 | + value="<?php echo esc_attr(get_option('vdo_default_width')); ?>" | |
| 50 | 33 | /></td> |
| 51 | 34 | </tr> |
| 52 | 35 | |
| 53 | 36 | <tr valign="top"> |
| 54 | - <th scope="row"><label for="vdo_default_height">Default Height</label></th> | |
| 55 | - <td> | |
| 56 | - <input type="text" id="vdo_default_height" name="vdo_default_height" | |
| 57 | - required pattern="^auto|\d+$" | |
| 58 | - value="<?php echo esc_attr(get_option('vdo_default_height')); ?>"/> | |
| 59 | - <p class="description">Can be either "auto" or a number. Set to "auto" height and max width for responsive layout.</p> | |
| 60 | - </td> | |
| 37 | + <th scope="row">Default Height</th> | |
| 38 | + <td><input type="text" id="vdo_default_height" name="vdo_default_height" | |
| 39 | + value="<?php echo esc_attr(get_option('vdo_default_height')); ?>" | |
| 40 | + /></td> | |
| 61 | 41 | </tr> |
| 62 | 42 | |
| 63 | - <tr> | |
| 64 | - <th scope="row"><label for="vdo_player_speed">Playback speed</label></th> | |
| 65 | - <td> | |
| 66 | - <input type="text" id="vdo_player_speed" name="vdo_player_speed" | |
| 67 | - pattern="^\d.\d{1,2}(,\d.\d{1,2})+$" | |
| 68 | - value="<?php echo esc_attr(get_option('vdo_player_speed')); ?>" | |
| 69 | - /> | |
| 70 | - <p class="description">Speed can be defined as comma separated decimal values e.g. 0.75,1.0,1.25,1.5,1.75,2.0</p> | |
| 71 | - <p class="description">With player v2, there is an option to set this as part of custom player configuration. This setting will override any options set as part of custom player.</p> | |
| 72 | - </td> | |
| 73 | - </tr> | |
| 74 | - | |
| 75 | 43 | <!-- Version Number --> |
| 76 | 44 | <?php |
| 77 | - $existingVersion = get_option('vdo_embed_version'); | |
| 78 | - $embedVersionDisplay = 'none'; | |
| 79 | - if ($existingVersion !== false && $existingVersion !== VDOCIPHER_PLAYER_VERSION) { | |
| 80 | - $embedVersionDisplay = 'table-row'; | |
| 81 | - } ?> | |
| 45 | + if ((get_option('vdo_embed_version')) == false) { | |
| 46 | + update_option('vdo_embed_version', '1.6.4'); | |
| 47 | + } | |
| 48 | + ?> | |
| 82 | 49 | <tr valign="top"> |
| 83 | - <?php | |
| 84 | - function vdo_selected($match) { | |
| 85 | - $existingEmbedVersion = get_option('vdo_embed_version'); | |
| 86 | - // global $existingEmbedVersion; | |
| 87 | - // return $GLOBALS['existingEmbedVersion'] ; | |
| 88 | - return $existingEmbedVersion === $match ? 'selected="selected"' : ''; | |
| 89 | - } | |
| 90 | - ?> | |
| 91 | - <th scope="row"><label for="vdo_embed_version">Player Version</label></th> | |
| 92 | - <td> | |
| 93 | - <div style="display: inline-flex"> | |
| 94 | - <select name="vdo_embed_version" id="vdo_embed_version" onchange="" autocomplete="off"> | |
| 95 | - <option value="1.6.10" <?= vdo_selected('1.6.10') ?>>v1</option> | |
| 96 | - <option value="v2" <?= vdo_selected('v2') ?>>v2 (Recommended)</option> | |
| 97 | - </select> | |
| 98 | - </div> | |
| 99 | - <?php include( 'player-versions-doc.php' ) ?> | |
| 100 | - </td> | |
| 50 | + <th scope="row">Player Version</th> | |
| 51 | + <td> | |
| 52 | + <div style="display: inline-flex"> | |
| 53 | + <select id="vdo_embed_version"> | |
| 54 | + <?php | |
| 55 | + $vdo_embed_version_vars = array( | |
| 56 | + '0.5', '1.0.0', '1.1.0', '1.1.3', '1.2.7', '1.3.3', '1.4.5','1.5.0','1.6.4' | |
| 57 | + ); | |
| 58 | + $vdo_embed_version_str = get_option('vdo_embed_version'); | |
| 59 | + foreach ($vdo_embed_version_vars as $vdo_embed_version_var) { | |
| 60 | + if ($vdo_embed_version_str == $vdo_embed_version_var) { | |
| 61 | + $selected = 'selected'; | |
| 62 | + } else { | |
| 63 | + $selected = ''; | |
| 64 | + } | |
| 65 | + switch ($vdo_embed_version_var) { | |
| 66 | + case '0.5': | |
| 67 | + $version_old_new = ' (old player)'; | |
| 68 | + break; | |
| 69 | + case '1.6.4': | |
| 70 | + $version_old_new = ' (newest player)' ; | |
| 71 | + break; | |
| 72 | + default: | |
| 73 | + $version_old_new = ' (new player)'; | |
| 74 | + break; | |
| 75 | + } | |
| 76 | + ?> | |
| 77 | + <option value="<?php echo $vdo_embed_version_var; ?>" <?php echo $selected; ?> > | |
| 78 | + <?php echo $vdo_embed_version_var . $version_old_new ; ?> | |
| 79 | + </option> | |
| 80 | + <?php } ?> | |
| 81 | + <option value="Custom Version"> | |
| 82 | + <?php echo 'Custom Version' ?> | |
| 83 | + </option> | |
| 84 | + </select> | |
| 85 | + <input type="text" name="vdo_embed_version" | |
| 86 | + id="vdo_custom_version" | |
| 87 | + style="margin-left:20px; position: relative; width:120px;" /> | |
| 88 | + </div> | |
| 89 | + <p class="description">It is recommended that you use the latest player version for best video playback.</p> | |
| 90 | + </td> | |
| 101 | 91 | </tr> |
| 102 | 92 | |
| 103 | 93 | <!-- Player Theme Options --> |
| 104 | 94 | <?php |
| 105 | - /** | |
| 106 | - * if the player is v1 and non-standard theme, then only allow disabling non-standard themes | |
| 107 | - * if the player is v1 and standard theme, do not show anything | |
| 108 | - * if the player is v2, allow adding player IDs. But validate the length of id | |
| 109 | - * | |
| 110 | - * This can be implemented in both PHP and JS. But if the JS is essential, then we can skip | |
| 111 | - * writing in PHP and run the JS function after page load. | |
| 112 | - */ | |
| 113 | - $existingTheme = get_option('vdo_player_theme'); | |
| 95 | + if ((get_option('vdo_player_theme')) == false) { | |
| 96 | + update_option('vdo_player_theme', '9ae8bbe8dd964ddc9bdb932cca1cb59a'); | |
| 97 | + } | |
| 114 | 98 | ?> |
| 115 | - <tr valign="top" id="vdo_theme_editing_row" > | |
| 116 | - <th scope="row"><label for="vdo_player_theme">Player ID</label></th> | |
| 99 | + <tr valign="top"> | |
| 100 | + <th scope="row">Player Theme</th> | |
| 117 | 101 | <td> |
| 118 | - <div style="display:inline-flex; margin-bottom:10px;"> | |
| 119 | - <input | |
| 120 | - type="text" | |
| 121 | - name="vdo_player_theme" | |
| 122 | - id="vdo_player_theme" | |
| 123 | - value="<?php echo $existingTheme; ?>" | |
| 124 | - maxlength="32" | |
| 125 | - style="width: 320px" | |
| 126 | - /> | |
| 127 | - <p class="vdo_saveChangeMessage" style="display: none; font-style: italic">Click on "save changes" below to confirm</p> | |
| 128 | - <button id="vdo_setDefaultThemeBtn" style="display: none" class="button" type="button">Revert to default theme</button><br/> | |
| 129 | - <script> | |
| 130 | - (function () { | |
| 131 | - const themeInputRow = document.querySelector('#vdo_theme_editing_row'); | |
| 132 | - const themeInputField = themeInputRow.querySelector('input'); | |
| 133 | - const playerVersionField = document.querySelector('[name=vdo_embed_version]'); | |
| 134 | - const setDefaultButton = document.querySelector('#vdo_setDefaultThemeBtn'); | |
| 135 | - playerVersionField.addEventListener('change', updateThemeInput); | |
| 136 | - const defaultV1Theme = '9ae8bbe8dd964ddc9bdb932cca1cb59a'; | |
| 137 | - const originalTheme = "<?= get_option('vdo_player_theme') ?>"; | |
| 138 | - let resetV2Theme, resetV1Theme; | |
| 139 | - function updateThemeInput() { | |
| 140 | - if (playerVersionField.value === 'v2') { | |
| 141 | - themeInputRow.style.display = ''; | |
| 142 | - if (themeInputField.value.match(/^\w{32}$/)) resetV1Theme = themeInputField.value; | |
| 143 | - if (resetV2Theme) themeInputField.value = resetV2Theme; | |
| 144 | - // if the input is not valid for v2, clear the field | |
| 145 | - if (!themeInputField.value.match(/^\w{16}$/)) themeInputField.value = ''; | |
| 146 | - // set the max and min length for v2 players | |
| 147 | - themeInputField.setAttribute('maxlength', '16'); | |
| 148 | - themeInputField.setAttribute('minlength', '16'); | |
| 149 | - setDefaultButton.style.display = 'none'; | |
| 150 | - } else { | |
| 151 | - // if input valid for v2, save in reset variable | |
| 152 | - if (themeInputField.value.match(/^\w{16}$/)) resetV2Theme = themeInputField.value; | |
| 153 | - if (resetV1Theme) themeInputField.value = resetV1Theme; | |
| 154 | - // if input is not valid for v1, reset to default theme | |
| 155 | - if (!themeInputField.value.match(/^\w{32}$/)) themeInputField.value = defaultV1Theme; | |
| 156 | - themeInputField.setAttribute('maxlength', '32'); | |
| 157 | - themeInputField.setAttribute('minlength', '32'); | |
| 158 | - // if original theme was some custom v1 theme, hide the entire row | |
| 159 | - // else, show reset button | |
| 160 | - if (originalTheme.length !== 32 || originalTheme === defaultV1Theme) { | |
| 161 | - themeInputRow.style.display = 'none'; | |
| 162 | - } else { | |
| 163 | - setDefaultButton.style.display = ''; | |
| 164 | - setDefaultButton.addEventListener('click', (e) => { | |
| 165 | - e.preventDefault(); | |
| 166 | - themeInputField.value = '9ae8bbe8dd964ddc9bdb932cca1cb59a' | |
| 167 | - e.target.style.display = 'none'; | |
| 168 | - e.target.parentElement.querySelector('.vdo_saveChangeMessage').style.display = ''; | |
| 169 | - }); | |
| 170 | - } | |
| 171 | - } | |
| 172 | - } | |
| 173 | - setTimeout(() => { | |
| 174 | - updateThemeInput(); | |
| 175 | - }, 0); | |
| 176 | - })() | |
| 177 | - </script> | |
| 178 | - </div> | |
| 179 | - <?php include('player-id-doc.html'); ?> | |
| 102 | + <input type="text" name="vdo_player_theme" | |
| 103 | + value="<?php echo esc_attr(get_option('vdo_player_theme')); ?>" max-length = "32" style="width: 320px" | |
| 104 | + /> | |
| 105 | + <p class="description"> | |
| 106 | + Player theme is not available for old player version(0.5). The default theme will be applied for old player. | |
| 107 | + </p> | |
| 180 | 108 | </td> |
| 181 | 109 | </tr> |
| 182 | 110 | <!-- Player Theme Options end--> |
| 183 | 111 | |
| 112 | + <!-- Player Watermark option - Flash/ HTML5 starts --> | |
| 113 | + <tr id="vdo_watermark_html_flash" valign="top"> | |
| 114 | + <th scope="row"> Choice of Watermark </th> | |
| 115 | + <td> | |
| 116 | + <?php | |
| 117 | + if ((get_option(vdo_watermark_flash_html) == 'html5')) { | |
| 118 | + $vdocheckedhtml5 = 'checked'; | |
| 119 | + $vdocheckedflash = ''; | |
| 120 | + } elseif ((get_option(vdo_watermark_flash_html) == 'flash')) { | |
| 121 | + $vdocheckedhtml5 = ''; | |
| 122 | + $vdocheckedflash = 'checked'; | |
| 123 | + } | |
| 124 | + ?> | |
| 125 | + <input type="radio" class="vdo-htmlflash" | |
| 126 | + value="html5" name="vdo_watermark_flash_html" | |
| 127 | + id="vdo_html5" <?php echo $vdocheckedhtml5; ?> > | |
| 128 | + <label for="vdo_html5">HTML5 (Overlay)</label> | |
| 129 | + | |
| 130 | + <input type="radio" class="vdo-htmlflash" | |
| 131 | + value="flash" name="vdo_watermark_flash_html" | |
| 132 | + id="vdo_flash" <?php echo $vdocheckedflash; ?> > | |
| 133 | + <label for="vdo_flash">Flash (Hard-Coded)</label> | |
| 134 | + </td> | |
| 135 | + </tr> | |
| 136 | + <!-- Player Watermark option - Flash/ HTML5 ends --> | |
| 137 | + | |
| 138 | + | |
| 184 | 139 | <tr valign="top"> |
| 185 | - <th scope="row"><label for="vdo_watermarkjson">Annotation Statement</label></th> | |
| 140 | + <th scope="row">Annotation Statement</th> | |
| 186 | 141 | <td> |
| 187 | 142 | <div style="display: inline-flex;"> |
| 188 | - <textarea name="vdo_annotate_code" id="vdo_watermarkjson" rows="6" cols="55" style="font-family: monospace" | |
| 143 | + <textarea name="vdo_annotate_code" id="vdo_watermarkjson" | |
| 144 | + type="textarea" rows="6" cols="55" style="display: float-left" | |
| 189 | 145 | ><?php |
| 190 | 146 | if (get_option('vdo_annotate_code') != "") { |
| 191 | 147 | echo get_option('vdo_annotate_code'); |
| 192 | 148 | $vdo_annotation_code = get_option('vdo_annotate_code'); |
| @@ -208,50 +164,19 @@ | ||
| 208 | 164 | </a> |
| 209 | 165 | </p> |
| 210 | 166 | </td> |
| 211 | 167 | </tr> |
| 212 | - | |
| 213 | - <!-- Advanced Options --> | |
| 214 | - | |
| 215 | - <tr valign="top"> | |
| 216 | - <th scope="row"></th> | |
| 217 | - <td> | |
| 218 | - <details> | |
| 219 | - <summary style="cursor: pointer">Advanced Options</summary> | |
| 220 | - <div style="margin: 20px 0"> | |
| 221 | - <div style="display: inline-flex;"> | |
| 222 | - <div style="width: 300px;"> | |
| 223 | - <label for="vdo_show_plugin_in_sidebar"><strong>Show VdoCipher in sidebar</strong></label> | |
| 224 | - </div> | |
| 225 | - <div> | |
| 226 | - <input type="checkbox" name="vdo_show_plugin_in_sidebar" id="vdo_show_plugin_in_sidebar" | |
| 227 | - value="true" <?php echo esc_attr(get_option('vdo_show_plugin_in_sidebar')) == 'true' ? 'checked' : ''; ?>/> | |
| 228 | - </div> | |
| 229 | - </div> | |
| 230 | - <p class="description"> | |
| 231 | - Not recommended to be changed. Mark this option unchecked if you like to hide the VdoCipher settings page from the sidebar.<br/> | |
| 232 | - Once changed, you will need to access this page from inside the Wordpress Settings / Plugins page. | |
| 233 | - </p> | |
| 234 | - </div> | |
| 235 | - </details> | |
| 236 | - | |
| 237 | - </td> | |
| 238 | - </tr> | |
| 239 | - | |
| 240 | - <!-- Footer --> | |
| 241 | - <tr style="display:none;"> | |
| 242 | - <td>Plugin version no.: </td> | |
| 243 | - <td><input | |
| 244 | - id="vdo_plugin_version" name="vdo_plugin_version" type="hidden" | |
| 245 | - value="<?php echo esc_attr(get_option('vdo_plugin_version')); ?>" readonly> | |
| 246 | - </td> | |
| 247 | - </tr> | |
| 248 | - | |
| 249 | - </tbody> | |
| 250 | 168 | </table> |
| 251 | 169 | <?php |
| 252 | 170 | wp_enqueue_script('vdo_validate_watermark', plugin_dir_url(__FILE__).'js/validatewatermark.js'); |
| 253 | - wp_enqueue_script('vdo_hide_key', plugin_dir_url(__FILE__).'js/showkey.js'); | |
| 171 | + wp_localize_script('vdo_validate_watermark', 'vdoValidateWatermark', array( | |
| 172 | + 'vdoWatermark' => $vdo_annotation_code | |
| 173 | + )); | |
| 174 | + wp_enqueue_script('vdo_html_flash_choice', plugin_dir_url(__FILE__).'js/flashhtml5choice.js'); | |
| 175 | + wp_localize_script('vdo_html_flash_choice', 'vdoVD', array( | |
| 176 | + 'vdoAV' => $vdo_embed_version_vars, | |
| 177 | + 'vdoSV' => $vdo_embed_version_str | |
| 178 | + )); | |
| 254 | 179 | ?> |
| 255 | 180 | <?php submit_button(); ?> |
| 256 | 181 | </form> |
| 257 | 182 | </div> |