PluginProbe
Sharing Image / 3.7
Sharing Image v3.7
3.10 trunk 2.0 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.17 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 3.0 3.1 3.2 3.3 All 29 releases
← All changes | classes/class-templates.php +61 -3 3.03.7 View file →
@@ -228,8 +228,29 @@
228 228 return count( self::get_templates() );
229 229 }
230 230
231 231 /**
232 + * Check if template with given index exists.
233 + *
234 + * @param string $index Template index.
235 + *
236 + * @return bool Whether template exists.
237 + */
238 + public static function has_template( $index ) {
239 + if ( empty( $index ) ) {
240 + return false;
241 + }
242 +
243 + $templates = self::get_templates();
244 +
245 + if ( array_key_exists( $index, $templates ) ) {
246 + return true;
247 + }
248 +
249 + return false;
250 + }
251 +
252 + /**
232 253 * Check unique template index.
233 254 *
234 255 * @param string $index Unique template index to check.
235 256 *
@@ -264,9 +285,9 @@
264 285 }
265 286
266 287 $templates[ $index ] = $editor;
267 288
268 - if ( null === $editor ) {
289 + if ( is_null( $editor ) ) {
269 290 unset( $templates[ $index ] );
270 291 }
271 292
272 293 /**
@@ -436,8 +457,17 @@
436 457 if ( isset( $layer['separator'] ) ) {
437 458 $sanitized['separator'] = preg_replace( '#[^\s,]#', '', $layer['separator'] );
438 459 }
439 460
461 + $sanitized['textconvert'] = 'default';
462 +
463 + // Set only available text convert options.
464 + $converts = array( 'default', 'uppercase', 'lowercase' );
465 +
466 + if ( isset( $layer['textconvert'] ) && in_array( $layer['textconvert'], $converts, true ) ) {
467 + $sanitized['textconvert'] = $layer['textconvert'];
468 + }
469 +
440 470 $sanitized['preset'] = 'none';
441 471
442 472 if ( isset( $layer['preset'] ) ) {
443 473 $preset = array( 'title', 'excerpt', 'categories', 'tags' );
@@ -488,8 +518,18 @@
488 518 if ( ! empty( $layer['fontfile'] ) ) {
489 519 $sanitized['fontfile'] = absint( $layer['fontfile'] );
490 520 }
491 521
522 + $sanitized['opacity'] = 0;
523 +
524 + if ( isset( $layer['opacity'] ) ) {
525 + $opacity = absint( $layer['opacity'] );
526 +
527 + if ( $opacity <= 100 ) {
528 + $sanitized['opacity'] = $opacity;
529 + }
530 + }
531 +
492 532 $sizes = array( 'x', 'y', 'width', 'height' );
493 533
494 534 foreach ( $sizes as $size ) {
495 535 if ( ! isset( $layer[ $size ] ) || '' === $layer[ $size ] ) {
@@ -532,8 +572,18 @@
532 572 if ( ! empty( $layer['attachment'] ) ) {
533 573 $sanitized['attachment'] = absint( $layer['attachment'] );
534 574 }
535 575
576 + $sanitized['opacity'] = 0;
577 +
578 + if ( isset( $layer['opacity'] ) ) {
579 + $opacity = absint( $layer['opacity'] );
580 +
581 + if ( $opacity <= 100 ) {
582 + $sanitized['opacity'] = $opacity;
583 + }
584 + }
585 +
536 586 $sizes = array( 'x', 'y', 'width', 'height' );
537 587
538 588 foreach ( $sizes as $size ) {
539 589 if ( ! isset( $layer[ $size ] ) || '' === $layer[ $size ] ) {
@@ -584,8 +634,12 @@
584 634 if ( ! empty( $layer['collapsed'] ) ) {
585 635 $sanitized['collapsed'] = 1;
586 636 }
587 637
638 + if ( isset( $layer['title'] ) ) {
639 + $sanitized['title'] = sanitize_text_field( $layer['title'] );
640 + }
641 +
588 642 if ( ! empty( $layer['grayscale'] ) ) {
589 643 $sanitized['grayscale'] = 'grayscale';
590 644 }
591 645
@@ -642,8 +696,12 @@
642 696 if ( ! empty( $layer['collapsed'] ) ) {
643 697 $sanitized['collapsed'] = 1;
644 698 }
645 699
700 + if ( isset( $layer['title'] ) ) {
701 + $sanitized['title'] = sanitize_text_field( $layer['title'] );
702 + }
703 +
646 704 if ( ! empty( $layer['outline'] ) ) {
647 705 $sanitized['outline'] = 'outline';
648 706 }
649 707
@@ -655,11 +713,11 @@
655 713
656 714 $sanitized['opacity'] = 0;
657 715
658 716 if ( isset( $layer['opacity'] ) ) {
659 - $opacity = (float) $layer['opacity'];
717 + $opacity = absint( $layer['opacity'] );
660 718
661 - if ( $opacity >= 0 && $opacity <= 100 ) {
719 + if ( $opacity <= 100 ) {
662 720 $sanitized['opacity'] = $opacity;
663 721 }
664 722 }
665 723