| @@ -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><head>\r\n<title>404 Not Found</title>\r\n". | |
| 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". | |
| 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,153 +14,179 @@ | ||
| 14 | 14 | <?php |
| 15 | 15 | settings_fields('vdo_option-group'); |
| 16 | 16 | do_settings_sections('vdo_option-group'); |
| 17 | 17 | ?> |
| 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> | |
| 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 | + ?> | |
| 21 | 24 | <table class="form-table"> |
| 25 | + <tbody> | |
| 22 | 26 | <tr valign="top"> |
| 23 | - <th scope="row">API Secret Key</th> | |
| 27 | + <th scope="row"><label for="vdo_client_key">API Secret Key</label></th> | |
| 24 | 28 | <td> |
| 25 | 29 | <div style="display: inline-flex;"> |
| 26 | - <input type="password" name="vdo_client_key" | |
| 27 | - value="<?php echo esc_attr(get_option('vdo_client_key')); ?>" | |
| 28 | - max-length="64" style="width: 640px" id="vdo_client_key" /> | |
| 29 | - <p style="margin-left:20px; position: relative"> | |
| 30 | - <span id="toggle_span"> | |
| 31 | - <button id="toggle_API_visibility" href="#" data-protected="On">Show API Secret Key</button> | |
| 32 | - </span> | |
| 33 | - </p> | |
| 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 | 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> | |
| 35 | 39 | </td> |
| 36 | 40 | </tr> |
| 41 | + </tbody> | |
| 37 | 42 | |
| 43 | + <tbody style="display: <?= $restElementDisplay ?>"> | |
| 38 | 44 | <tr valign="top"> |
| 39 | - <th scope="row">Default Width</th> | |
| 40 | - <td><input type="text" id="vdo_default_width" name="vdo_default_width" | |
| 41 | - value="<?php echo esc_attr(get_option('vdo_default_width')); ?>" | |
| 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')); ?>" | |
| 42 | 50 | /></td> |
| 43 | 51 | </tr> |
| 44 | 52 | |
| 45 | 53 | <tr valign="top"> |
| 46 | - <th scope="row">Default Height</th> | |
| 47 | - <td><input type="text" id="vdo_default_height" name="vdo_default_height" | |
| 48 | - value="<?php echo esc_attr(get_option('vdo_default_height')); ?>" | |
| 49 | - /></td> | |
| 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> | |
| 50 | 61 | </tr> |
| 51 | 62 | |
| 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 | + | |
| 52 | 75 | <!-- Version Number --> |
| 53 | 76 | <?php |
| 54 | - if ((get_option('vdo_embed_version')) == false) { | |
| 55 | - update_option('vdo_embed_version', VDOCIPHER_PLAYER_VERSION); | |
| 56 | - } | |
| 57 | - ?> | |
| 77 | + $existingVersion = get_option('vdo_embed_version'); | |
| 78 | + $embedVersionDisplay = 'none'; | |
| 79 | + if ($existingVersion !== false && $existingVersion !== VDOCIPHER_PLAYER_VERSION) { | |
| 80 | + $embedVersionDisplay = 'table-row'; | |
| 81 | + } ?> | |
| 58 | 82 | <tr valign="top"> |
| 59 | - <th scope="row">Player Version</th> | |
| 60 | - <td> | |
| 61 | - <div style="display: inline-flex"> | |
| 62 | - <select id="vdo_embed_version"> | |
| 63 | - <?php | |
| 64 | - $vdo_embed_version_vars = array( | |
| 65 | - '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','1.6.10' | |
| 66 | - ); | |
| 67 | - $vdo_embed_version_string = get_option('vdo_embed_version'); | |
| 68 | - foreach ($vdo_embed_version_vars as $vdo_embed_version_var) { | |
| 69 | - if ($vdo_embed_version_string == $vdo_embed_version_var) { | |
| 70 | - $selected = 'selected'; | |
| 71 | - } else { | |
| 72 | - $selected = ''; | |
| 73 | - } | |
| 74 | - switch ($vdo_embed_version_var) { | |
| 75 | - case '0.5': | |
| 76 | - $version_old_new = ' (old player)'; | |
| 77 | - break; | |
| 78 | - case VDOCIPHER_PLAYER_VERSION: | |
| 79 | - $version_old_new = ' (newest player)' ; | |
| 80 | - break; | |
| 81 | - default: | |
| 82 | - $version_old_new = ' (new player)'; | |
| 83 | - break; | |
| 84 | - } | |
| 85 | - ?> | |
| 86 | - <option value="<?php echo $vdo_embed_version_var; ?>" <?php echo $selected; ?> > | |
| 87 | - <?php echo $vdo_embed_version_var . $version_old_new ; ?> | |
| 88 | - </option> | |
| 89 | - <?php } ?> | |
| 90 | - <option value="Custom Version"> | |
| 91 | - <?php echo 'Custom Version' ?> | |
| 92 | - </option> | |
| 93 | - </select> | |
| 94 | - <input type="text" name="vdo_embed_version" | |
| 95 | - id="vdo_custom_version" | |
| 96 | - style="margin-left:20px; position: relative; width:120px;" /> | |
| 97 | - </div> | |
| 98 | - <p class="description">It is recommended that you use the latest player version for best video playback.</p> | |
| 99 | - </td> | |
| 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> | |
| 100 | 101 | </tr> |
| 101 | 102 | |
| 102 | 103 | <!-- Player Theme Options --> |
| 103 | 104 | <?php |
| 104 | - if (!(get_option('vdo_player_theme'))) { | |
| 105 | - update_option('vdo_player_theme', '9ae8bbe8dd964ddc9bdb932cca1cb59a'); | |
| 106 | - } | |
| 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'); | |
| 107 | 114 | ?> |
| 108 | - <tr valign="top"> | |
| 109 | - <th scope="row">Player Theme</th> | |
| 115 | + <tr valign="top" id="vdo_theme_editing_row" > | |
| 116 | + <th scope="row"><label for="vdo_player_theme">Player ID</label></th> | |
| 110 | 117 | <td> |
| 111 | - <div style="display:inline-flex; margin-bottom:10px;"> | |
| 112 | - <input | |
| 113 | - type="text" | |
| 114 | - name="vdo_player_theme" | |
| 115 | - value="<?php echo esc_attr(get_option('vdo_player_theme')); ?>" | |
| 116 | - max-length = "32" | |
| 117 | - style="width: 320px" | |
| 118 | - readonly | |
| 119 | - /> | |
| 120 | - <p style="margin-left:20px; position: relative"> | |
| 121 | - <span><a href="<?php menu_page_url('themesvdo', 1); ?> " >Select Custom Player Theme</a><br/> | |
| 122 | - </p> | |
| 123 | - </div> | |
| 124 | - <p class="description"> | |
| 125 | - Player theme is not available for old player version(0.5). The default theme will be applied for old player. | |
| 126 | - </p> | |
| 127 | - | |
| 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'); ?> | |
| 128 | 180 | </td> |
| 129 | 181 | </tr> |
| 130 | 182 | <!-- Player Theme Options end--> |
| 131 | 183 | |
| 132 | - <!-- Player Watermark option - Flash/ HTML5 starts --> | |
| 133 | - <tr id="vdo_watermark_html_flash" valign="top"> | |
| 134 | - <th scope="row"> Choice of Watermark </th> | |
| 135 | - <td> | |
| 136 | - <?php | |
| 137 | - if ((get_option('vdo_watermark_flash_html') == 'html5')) { | |
| 138 | - $vdocheckedhtml5 = 'checked'; | |
| 139 | - $vdocheckedflash = ''; | |
| 140 | - } elseif ((get_option('vdo_watermark_flash_html') == 'flash')) { | |
| 141 | - $vdocheckedhtml5 = ''; | |
| 142 | - $vdocheckedflash = 'checked'; | |
| 143 | - } | |
| 144 | - ?> | |
| 145 | - <input type="radio" class="vdo-htmlflash" | |
| 146 | - value="html5" name="vdo_watermark_flash_html" | |
| 147 | - id="vdo_html5" <?php echo $vdocheckedhtml5; ?> > | |
| 148 | - <label for="vdo_html5">HTML5 (Overlay)</label> | |
| 149 | - | |
| 150 | - <input type="radio" class="vdo-htmlflash" | |
| 151 | - value="flash" name="vdo_watermark_flash_html" | |
| 152 | - id="vdo_flash" <?php echo $vdocheckedflash; ?> > | |
| 153 | - <label for="vdo_flash">Flash (Hard-Coded)</label> | |
| 154 | - </td> | |
| 155 | - </tr> | |
| 156 | - <!-- Player Watermark option - Flash/ HTML5 ends --> | |
| 157 | 184 | <tr valign="top"> |
| 158 | - <th scope="row">Annotation Statement</th> | |
| 185 | + <th scope="row"><label for="vdo_watermarkjson">Annotation Statement</label></th> | |
| 159 | 186 | <td> |
| 160 | 187 | <div style="display: inline-flex;"> |
| 161 | - <textarea name="vdo_annotate_code" id="vdo_watermarkjson" | |
| 162 | - type="textarea" rows="6" cols="55" style="display: float-left" | |
| 188 | + <textarea name="vdo_annotate_code" id="vdo_watermarkjson" rows="6" cols="55" style="font-family: monospace" | |
| 163 | 189 | ><?php |
| 164 | 190 | if (get_option('vdo_annotate_code') != "") { |
| 165 | 191 | echo get_option('vdo_annotate_code'); |
| 166 | 192 | $vdo_annotation_code = get_option('vdo_annotate_code'); |
| @@ -182,27 +208,50 @@ | ||
| 182 | 208 | </a> |
| 183 | 209 | </p> |
| 184 | 210 | </td> |
| 185 | 211 | </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 --> | |
| 186 | 241 | <tr style="display:none;"> |
| 187 | 242 | <td>Plugin version no.: </td> |
| 188 | 243 | <td><input |
| 189 | - id="vdo_plugin_version" name="vdo_plugin_version" | |
| 244 | + id="vdo_plugin_version" name="vdo_plugin_version" type="hidden" | |
| 190 | 245 | value="<?php echo esc_attr(get_option('vdo_plugin_version')); ?>" readonly> |
| 191 | 246 | </td> |
| 192 | 247 | </tr> |
| 248 | + | |
| 249 | + </tbody> | |
| 193 | 250 | </table> |
| 194 | 251 | <?php |
| 195 | 252 | wp_enqueue_script('vdo_validate_watermark', plugin_dir_url(__FILE__).'js/validatewatermark.js'); |
| 196 | - wp_localize_script('vdo_validate_watermark', 'vdoValidateWatermark', array( | |
| 197 | - 'vdoWatermark' => $vdo_annotation_code | |
| 198 | - )); | |
| 199 | - wp_enqueue_script('vdo_html_flash_choice', plugin_dir_url(__FILE__).'js/flashhtml5choice.js'); | |
| 200 | 253 | wp_enqueue_script('vdo_hide_key', plugin_dir_url(__FILE__).'js/showkey.js'); |
| 201 | - wp_localize_script('vdo_html_flash_choice', 'vdoVD', array( | |
| 202 | - 'vdoAV' => $vdo_embed_version_vars, | |
| 203 | - 'vdoSV' => $vdo_embed_version_string | |
| 204 | - )); | |
| 205 | 254 | ?> |
| 206 | 255 | <?php submit_button(); ?> |
| 207 | 256 | </form> |
| 208 | 257 | </div> |