PluginProbe
Depicter — Popup & Slider Builder / 1.5.2
Depicter — Popup & Slider Builder v1.5.2
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / app / src / Utility / Sanitize.php

Sanitize.php in Depicter — Popup & Slider Builder 1.5.2, at app/src/Utility/Sanitize.php

59 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Depicter\Utility;
3
4 use \Averta\WordPress\Utility\Sanitize as SanitizeBase;
5
6 class Sanitize extends SanitizeBase {
7
8 public static function html( $input, $allowed_tags = null, $namespace = null, $auto_p = false ){
9 // A fix to allow empty data url for src in image tag
10 if( $namespace === 'depicter/output' ){
11 add_filter( 'wp_kses_uri_attributes', [ __CLASS__, 'skipSrcEscapeTemporary' ], 25 );
12 }
13 $sanitized = parent::html( $input, $allowed_tags, $namespace, $auto_p );
14 if( $namespace === 'depicter/output' ){
15 remove_filter( 'wp_kses_uri_attributes', [ __CLASS__, 'skipSrcEscapeTemporary' ], 25 );
16 }
17
18 return $sanitized;
19 }
20
21 /**
22 * Retrieves default WordPress HTML tags
23 *
24 * @return array
25 */
26 protected static function defaultAllowedTags(){
27 $tags = parent::defaultAllowedTags();
28
29 $tags['style'] = [
30 'type' => true
31 ];
32 $tags['script'] = [
33 'id' => true,
34 'src' => true
35 ];
36 $tags['link'] = [
37 'rel' => true,
38 'id' => true,
39 'href' => true,
40 'media' => true,
41 ];
42 return $tags;
43 }
44
45 /**
46 * Ignore src escaping because `wp_kses` strips `data:` from image placeholder source in PHP 8.0+
47 *
48 * @param array $uriAttributes
49 *
50 * @return array $uriAttributes
51 */
52 public static function skipSrcEscapeTemporary( $uriAttributes ) {
53 if ( ( $key = array_search( 'src', $uriAttributes ) ) !== false) {
54 unset( $uriAttributes[ $key ] );
55 }
56 return $uriAttributes;
57 }
58 }
59