Changeset 2710735
- Timestamp:
- 04/17/2022 12:44:06 PM (4 years ago)
- Location:
- typed/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (2 diffs)
-
typed.php (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
-
typed/trunk/readme.txt
r2694968 r2710735 4 4 Requires at least: 3.0 5 5 Tested up to: 5.9.2 6 Stable tag: 5.9.26 Stable tag: 1.2 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 60 60 * Add support to wordpress version 4.9.4 61 61 62 = 1. 1.4=62 = 1.2 = 63 63 * Add support to wordpress version 5.9.2 64 64 * Add support to PHP 8 -
typed/trunk/typed.php
r2694968 r2710735 3 3 Plugin Name: Typed 4 4 Description: Typed Plugin created based on "typed.js" a jQuery plugin that types. Enter in any string, and watch it type at the speed you've set, backspace what it's typed, and begin a new sentence for however many strings you've set. 5 Version: 1. 1.55 Version: 1.2 6 6 Author: zonnix 7 7 Author URI: http://zonnix.net … … 85 85 $strings .= $string . ';#$#;'; 86 86 } 87 $strings = trim($strings, ';#$#;');88 $font_size = get_post_meta($post_id, 'font_size', true);89 $font_type = get_post_meta($post_id, 'font_type', true);90 $color = get_post_meta($post_id, 'font_color', true);91 $font_weight = get_post_meta($post_id, 'font_weight', true);92 $anchor_color = get_post_meta($post_id, 'anchor_color', true);93 $cursor_color = get_post_meta($post_id, 'cursor_color', true);87 $strings = esc_html(trim($strings, ';#$#;')); 88 $font_size = esc_html(get_post_meta($post_id, 'font_size', true)); 89 $font_type = esc_html(get_post_meta($post_id, 'font_type', true)); 90 $color = esc_html(get_post_meta($post_id, 'font_color', true)); 91 $font_weight = esc_html(get_post_meta($post_id, 'font_weight', true)); 92 $anchor_color = esc_html(get_post_meta($post_id, 'anchor_color', true)); 93 $cursor_color = esc_html(get_post_meta($post_id, 'cursor_color', true)); 94 94 ?> 95 95 <style> 96 96 97 97 <?php if (get_post_meta($post_id, 'blinking_cursor', true) == 'yes'): ?> 98 .typed-div-<?php echo $post_id; ?> .typed-cursor{99 opacity: 1;100 -webkit-animation: blink 0.7s infinite;101 -moz-animation: blink 0.7s infinite;102 animation: blink 0.7s infinite;103 }104 @keyframes blink{105 0% { opacity:1; }106 50% { opacity:0; }107 100% { opacity:1; }108 }109 @-webkit-keyframes blink{110 0% { opacity:1; }111 50% { opacity:0; }112 100% { opacity:1; }113 }114 @-moz-keyframes blink{115 0% { opacity:1; }116 50% { opacity:0; }117 100% { opacity:1; }118 }98 .typed-div-<?php echo $post_id; ?> .typed-cursor{ 99 opacity: 1; 100 -webkit-animation: blink 0.7s infinite; 101 -moz-animation: blink 0.7s infinite; 102 animation: blink 0.7s infinite; 103 } 104 @keyframes blink{ 105 0% { opacity:1; } 106 50% { opacity:0; } 107 100% { opacity:1; } 108 } 109 @-webkit-keyframes blink{ 110 0% { opacity:1; } 111 50% { opacity:0; } 112 100% { opacity:1; } 113 } 114 @-moz-keyframes blink{ 115 0% { opacity:1; } 116 50% { opacity:0; } 117 100% { opacity:1; } 118 } 119 119 <?php endif; ?> 120 120 .typed-div-<?php echo $post_id; ?> { … … 123 123 endif; 124 124 ?> 125 <?php if ($font_type): ?>font-family: <?php126 echo $font_type . ';';127 endif;128 ?>125 <?php if ($font_type): ?>font-family: <?php 126 echo $font_type . ';'; 127 endif; 128 ?> 129 129 <?php if ($color): ?>color: <?php 130 130 echo $color . ';'; … … 152 152 </style> 153 153 <div class="typed-div-<?php echo $post_id; ?>"> 154 <span style="white-space:pre;word-wrap: break-word;line-height: 1;" class="typed_perview_div" data-cursor-char="<?php echo get_post_meta($post_id, 'cursor_char', true); ?>" data-cursor="<?php echo get_post_meta($post_id, 'show_cursor', true); ?>" data-strings="<?php echo $strings; ?>" data-speed="<?php echo get_post_meta($post_id, 'type_speed', true); ?>" data-delay="<?php echo get_post_meta($post_id, 'start_delay', true); ?>" data-back-delay="<?php echo get_post_meta($post_id, 'back_delay', true); ?>" data-back-speed="<?php echo get_post_meta($post_id, 'back_speed', true); ?>" data-loop="<?php echo get_post_meta($post_id, 'typed_loop', true); ?>"></span>154 <span style="white-space:pre;word-wrap: break-word;line-height: 1;" class="typed_perview_div" data-cursor-char="<?php echo esc_attr(get_post_meta($post_id, 'cursor_char', true)); ?>" data-cursor="<?php echo esc_attr(get_post_meta($post_id, 'show_cursor', true)); ?>" data-strings="<?php echo esc_attr($strings); ?>" data-speed="<?php echo esc_attr(get_post_meta($post_id, 'type_speed', true)); ?>" data-delay="<?php echo esc_attr(get_post_meta($post_id, 'start_delay', true)); ?>" data-back-delay="<?php echo esc_attr(get_post_meta($post_id, 'back_delay', true)); ?>" data-back-speed="<?php echo esc_attr(get_post_meta($post_id, 'back_speed', true)); ?>" data-loop="<?php echo esc_attr(get_post_meta($post_id, 'typed_loop', true)); ?>"></span> 155 155 </div> 156 156 <br><pre class="update-nag shorCode">Generated Shortcode: [typed id='<?php echo $post_id; ?>']</pre> … … 177 177 foreach ($typed_strings as $string): 178 178 ?> 179 <p><input type="text" name="typed_strings[]" value="<?php echo str_replace('"', "'", $string); ?>"/> <a href="javascript:void(0)" class="add_typed_string button-secondary">+</a> <?php if ($index > 0): ?><a href="javascript:void(0)" class="remove_typed_string button-secondary">-</a><?php endif; ?></p>179 <p><input type="text" name="typed_strings[]" value="<?php echo esc_attr(str_replace('"', "'", $string)); ?>"/> <a href="javascript:void(0)" class="add_typed_string button-secondary">+</a> <?php if ($index > 0): ?><a href="javascript:void(0)" class="remove_typed_string button-secondary">-</a><?php endif; ?></p> 180 180 <?php 181 181 $index++; … … 192 192 <td>Type Speed</td> 193 193 <td> 194 <input type="text" value="<?php echo get_post_meta($post_id, 'type_speed', true) ? get_post_meta($post_id, 'type_speed', true) : 0; ?>" name="type_speed"/>194 <input type="text" value="<?php echo esc_attr(get_post_meta($post_id, 'type_speed', true)) ? esc_attr(get_post_meta($post_id, 'type_speed', true)) : 0; ?>" name="type_speed"/> 195 195 <br><span class="description">type speed in milliseconds </span> 196 196 </td> … … 199 199 <td>Start Delay</td> 200 200 <td> 201 <input type="text" value="<?php echo get_post_meta($post_id, 'start_delay', true) ? get_post_meta($post_id, 'start_delay', true) : 0; ?>" name="start_delay"/>201 <input type="text" value="<?php echo esc_attr(get_post_meta($post_id, 'start_delay', true)) ? esc_attr(get_post_meta($post_id, 'start_delay', true)) : 0; ?>" name="start_delay"/> 202 202 <br><span class="description">time before typing starts in milliseconds </span> 203 203 </td> … … 206 206 <td>Back Speed</td> 207 207 <td> 208 <input type="text" value="<?php echo get_post_meta($post_id, 'back_speed', true) ? get_post_meta($post_id, 'back_speed', true) : 0; ?>" name="back_speed"/>208 <input type="text" value="<?php echo esc_attr(get_post_meta($post_id, 'back_speed', true)) ? esc_attr(get_post_meta($post_id, 'back_speed', true)) : 0; ?>" name="back_speed"/> 209 209 <br><span class="description">backspacing speed in milliseconds </span> 210 210 </td> … … 213 213 <td>Back Delay</td> 214 214 <td> 215 <input type="text" value="<?php echo get_post_meta($post_id, 'back_delay', true) ? get_post_meta($post_id, 'back_delay', true) : 500; ?>" name="back_delay"/>215 <input type="text" value="<?php echo esc_attr(get_post_meta($post_id, 'back_delay', true)) ? esc_attr(get_post_meta($post_id, 'back_delay', true)) : 500; ?>" name="back_delay"/> 216 216 <br><span class="description">time before backspacing in milliseconds </span> 217 217 </td> … … 234 234 <td>Cursor Char</td> 235 235 <td> 236 <input type="text" value="<?php echo get_post_meta($post_id, 'cursor_char', true) ? get_post_meta($post_id, 'cursor_char', true) : '|'; ?>" name="cursor_char"/>236 <input type="text" value="<?php echo esc_attr(get_post_meta($post_id, 'cursor_char', true)) ? esc_attr(get_post_meta($post_id, 'cursor_char', true)) : '|'; ?>" name="cursor_char"/> 237 237 <br><span class="description">character for cursor</span> 238 238 </td> … … 258 258 <td style="width: 15%;">Font Size</td> 259 259 <td> 260 <input type="text" placeholder="eg. 24" value="<?php echo get_post_meta($post_id, 'font_size', true); ?>" name="font_size"/>260 <input type="text" placeholder="eg. 24" value="<?php echo esc_attr(get_post_meta($post_id, 'font_size', true)); ?>" name="font_size"/> 261 261 </td> 262 262 </tr> … … 264 264 <td style="width: 15%;">Font Family</td> 265 265 <td> 266 <input type="text" placeholder='Helvetica,Arial,sans-serif' value="<?php echo get_post_meta($post_id, 'font_type', true); ?>" name="font_type"/>266 <input type="text" placeholder='Helvetica,Arial,sans-serif' value="<?php echo esc_attr(get_post_meta($post_id, 'font_type', true)); ?>" name="font_type"/> 267 267 </td> 268 268 </tr> … … 270 270 <td style="width: 15%;">Font Weight</td> 271 271 <td> 272 <input type="text" placeholder="eg. 300" value="<?php echo get_post_meta($post_id, 'font_weight', true); ?>" name="font_weight"/>272 <input type="text" placeholder="eg. 300" value="<?php echo esc_attr(get_post_meta($post_id, 'font_weight', true)); ?>" name="font_weight"/> 273 273 </td> 274 274 </tr> … … 276 276 <td>Color</td> 277 277 <td> 278 <input class="typed-color-field" type="text" value="<?php echo get_post_meta($post_id, 'font_color', true); ?>" name="font_color"/>278 <input class="typed-color-field" type="text" value="<?php echo esc_attr(get_post_meta($post_id, 'font_color', true)); ?>" name="font_color"/> 279 279 </td> 280 280 </tr> … … 282 282 <td>Anchor Color</td> 283 283 <td> 284 <input class="typed-color-field" type="text" value="<?php echo get_post_meta($post_id, 'anchor_color', true); ?>" name="anchor_color"/>284 <input class="typed-color-field" type="text" value="<?php echo esc_attr(get_post_meta($post_id, 'anchor_color', true)); ?>" name="anchor_color"/> 285 285 </td> 286 286 </tr> … … 288 288 <td>Cursor Color</td> 289 289 <td> 290 <input class="typed-color-field" type="text" value="<?php echo get_post_meta($post_id, 'cursor_color', true); ?>" name="cursor_color"/>290 <input class="typed-color-field" type="text" value="<?php echo esc_attr(get_post_meta($post_id, 'cursor_color', true)); ?>" name="cursor_color"/> 291 291 </td> 292 292 </tr> … … 319 319 if (isset($_POST['post_type']) && 'typed' == $_POST['post_type']) { 320 320 if (isset($_POST['font_size'])) 321 update_post_meta($post_id, 'font_size', $_POST['font_size']);321 update_post_meta($post_id, 'font_size', sanitize_text_field($_POST['font_size'])); 322 322 323 323 if (isset($_POST['font_type'])) 324 update_post_meta($post_id, 'font_type', $_POST['font_type']);324 update_post_meta($post_id, 'font_type', sanitize_text_field($_POST['font_type'])); 325 325 326 326 if (isset($_POST['font_color'])) 327 update_post_meta($post_id, 'font_color', $_POST['font_color']);327 update_post_meta($post_id, 'font_color', sanitize_text_field($_POST['font_color'])); 328 328 329 329 if (isset($_POST['anchor_color'])) 330 update_post_meta($post_id, 'anchor_color', $_POST['anchor_color']);330 update_post_meta($post_id, 'anchor_color', sanitize_text_field($_POST['anchor_color'])); 331 331 332 332 if (isset($_POST['cursor_color'])) 333 update_post_meta($post_id, 'cursor_color', $_POST['cursor_color']);333 update_post_meta($post_id, 'cursor_color', sanitize_text_field($_POST['cursor_color'])); 334 334 335 335 if (isset($_POST['font_weight'])) 336 update_post_meta($post_id, 'font_weight', $_POST['font_weight']);337 338 if (isset($_POST['typed_strings'])) {339 $_POST['typed_strings'] = array_map( 'esc_attr', $_POST['typed_strings'] );336 update_post_meta($post_id, 'font_weight', sanitize_text_field($_POST['font_weight'])); 337 338 if (isset($_POST['typed_strings'])) { 339 $_POST['typed_strings'] = array_map('esc_attr', $_POST['typed_strings']); 340 340 update_post_meta($post_id, 'typed_strings', $_POST['typed_strings']); 341 341 } 342 342 343 343 if (isset($_POST['type_speed'])) 344 update_post_meta($post_id, 'type_speed', $_POST['type_speed']);344 update_post_meta($post_id, 'type_speed', sanitize_text_field($_POST['type_speed'])); 345 345 346 346 if (isset($_POST['start_delay'])) 347 update_post_meta($post_id, 'start_delay', $_POST['start_delay']);347 update_post_meta($post_id, 'start_delay', sanitize_text_field($_POST['start_delay'])); 348 348 349 349 if (isset($_POST['back_speed'])) 350 update_post_meta($post_id, 'back_speed', $_POST['back_speed']);350 update_post_meta($post_id, 'back_speed', sanitize_text_field($_POST['back_speed'])); 351 351 352 352 if (isset($_POST['back_delay'])) 353 update_post_meta($post_id, 'back_delay', $_POST['back_delay']);353 update_post_meta($post_id, 'back_delay', sanitize_text_field($_POST['back_delay'])); 354 354 355 355 if (isset($_POST['typed_loop'])) 356 update_post_meta($post_id, 'typed_loop', $_POST['typed_loop']);356 update_post_meta($post_id, 'typed_loop', sanitize_text_field($_POST['typed_loop'])); 357 357 else 358 358 update_post_meta($post_id, 'typed_loop', 'no'); 359 359 360 360 if (isset($_POST['show_cursor'])) 361 update_post_meta($post_id, 'show_cursor', $_POST['show_cursor']);361 update_post_meta($post_id, 'show_cursor', sanitize_text_field($_POST['show_cursor'])); 362 362 else 363 363 update_post_meta($post_id, 'show_cursor', 'no'); 364 364 365 365 if (isset($_POST['blinking_cursor'])) 366 update_post_meta($post_id, 'blinking_cursor', $_POST['blinking_cursor']);366 update_post_meta($post_id, 'blinking_cursor', sanitize_text_field($_POST['blinking_cursor'])); 367 367 else 368 368 update_post_meta($post_id, 'blinking_cursor', 'no'); 369 369 370 370 if (isset($_POST['cursor_char'])) 371 update_post_meta($post_id, 'cursor_char', $_POST['cursor_char']);371 update_post_meta($post_id, 'cursor_char', sanitize_text_field($_POST['cursor_char'])); 372 372 } 373 373 } … … 391 391 $typed = get_post($post_id); 392 392 if ($typed) : 393 $font_size = get_post_meta($post_id, 'font_size', true);394 $font_type = get_post_meta($post_id, 'font_type', true);395 $color = get_post_meta($post_id, 'font_color', true);396 $font_weight = get_post_meta($post_id, 'font_weight', true);397 $anchor_color = get_post_meta($post_id, 'anchor_color', true);398 $cursor_color = get_post_meta($post_id, 'cursor_color', true);393 $font_size = esc_html(get_post_meta($post_id, 'font_size', true)); 394 $font_type = esc_html(get_post_meta($post_id, 'font_type', true)); 395 $color = esc_html(get_post_meta($post_id, 'font_color', true)); 396 $font_weight = esc_html(get_post_meta($post_id, 'font_weight', true)); 397 $anchor_color = esc_html(get_post_meta($post_id, 'anchor_color', true)); 398 $cursor_color = esc_html(get_post_meta($post_id, 'cursor_color', true)); 399 399 $typed_strings = get_post_meta($post_id, 'typed_strings', true); 400 400 if (!$typed_strings) … … 405 405 $strings .= $string . ';#$#;'; 406 406 } 407 $strings = trim($strings, ';#$#;');407 $strings = esc_html(trim($strings, ';#$#;')); 408 408 ?> 409 409 <style> … … 413 413 endif; 414 414 ?> 415 <?php if ($font_type): ?>font-family: <?php416 echo $font_type . ';';417 endif;418 ?>415 <?php if ($font_type): ?>font-family: <?php 416 echo $font_type . ';'; 417 endif; 418 ?> 419 419 <?php if ($color): ?>color: <?php 420 420 echo $color . ';'; … … 440 440 ?> 441 441 } 442 442 443 443 <?php if (get_post_meta($post_id, 'blinking_cursor', true) == 'yes'): ?> 444 444 .typed-div-<?php echo $post_id; ?> .typed-cursor{ … … 466 466 </style> 467 467 <div class="typed-div-<?php echo $post_id; ?>"> 468 <span style="white-space:pre;" class="typed_perview_div" data-cursor-char="<?php echo get_post_meta($post_id, 'cursor_char', true); ?>" data-cursor="<?php echo get_post_meta($post_id, 'show_cursor', true); ?>" data-strings="<?php echo $strings; ?>" data-speed="<?php echo get_post_meta($post_id, 'type_speed', true); ?>" data-delay="<?php echo get_post_meta($post_id, 'start_delay', true); ?>" data-back-delay="<?php echo get_post_meta($post_id, 'back_delay', true); ?>" data-back-speed="<?php echo get_post_meta($post_id, 'back_speed', true); ?>" data-loop="<?php echo get_post_meta($post_id, 'typed_loop', true); ?>"></span>468 <span style="white-space:pre;" class="typed_perview_div" data-cursor-char="<?php echo esc_attr(get_post_meta($post_id, 'cursor_char', true)); ?>" data-cursor="<?php echo esc_attr(get_post_meta($post_id, 'show_cursor', true)); ?>" data-strings="<?php echo esc_attr($strings); ?>" data-speed="<?php echo esc_attr(get_post_meta($post_id, 'type_speed', true)); ?>" data-delay="<?php echo esc_attr(get_post_meta($post_id, 'start_delay', true)); ?>" data-back-delay="<?php echo esc_attr(get_post_meta($post_id, 'back_delay', true)); ?>" data-back-speed="<?php echo esc_attr(get_post_meta($post_id, 'back_speed', true)); ?>" data-loop="<?php echo esc_attr(get_post_meta($post_id, 'typed_loop', true)); ?>"></span> 469 469 </div> 470 470 <?php
Note: See TracChangeset
for help on using the changeset viewer.