diff --git a/src/classes/entities/class-tainacan-item.php b/src/classes/entities/class-tainacan-item.php index e2811e78e..5ce5eb694 100644 --- a/src/classes/entities/class-tainacan-item.php +++ b/src/classes/entities/class-tainacan-item.php @@ -771,8 +771,8 @@ class Item extends Entity { } } - - return apply_filters("tainacan-item-get-document-as-html", wp_kses_post($output), $img_size, $this); + $allowed_html = wp_kses_allowed_html('tainacan_post'); + return apply_filters("tainacan-item-get-document-as-html", wp_kses($output, $allowed_html), $img_size, $this); } @@ -806,8 +806,8 @@ class Item extends Entity { $output .= $embed; } } - - return wp_kses_post($output); + $allowed_html = wp_kses_allowed_html('tainacan_post'); + return wp_kses($output, $allowed_html); } diff --git a/src/classes/theme-helper/template-tags.php b/src/classes/theme-helper/template-tags.php index 7956af9be..d096681aa 100644 --- a/src/classes/theme-helper/template-tags.php +++ b/src/classes/theme-helper/template-tags.php @@ -3,6 +3,13 @@ use \Tainacan\Entities; use \Tainacan\Repositories; +function tainacan_get_default_allowed_styles ( $styles ) { + $styles[] = 'display'; + $styles[] = 'position'; + $styles[] = 'visibility'; + return $styles; +} + /** * To be used inside The Loop * @@ -332,7 +339,9 @@ function tainacan_get_the_media_component( $args['media_main_id'] = $media_id . '-main'; $args['media_thumbs_id'] = $media_id . '-thumbs'; $args['media_id'] = $media_id; - + $allowed_html = wp_kses_allowed_html('tainacan_post'); + add_filter( 'safe_style_css', 'tainacan_get_default_allowed_styles'); + if ( $args['has_media_main'] || $args['has_media_thumbs'] ) : // Modal lightbox layer for rendering photoswipe add_action('wp_footer', 'tainacan_get_the_media_modal_layer'); @@ -363,7 +372,9 @@ function tainacan_get_the_media_component( @@ -394,7 +405,7 @@ function tainacan_get_the_media_component( @@ -420,8 +431,10 @@ function tainacan_get_the_media_component( - - + '' ), $args); - $allowed_html = wp_kses_allowed_html('post'); - $allowed_html['iframe'] = array( - 'src' => true, - 'height' => true, - 'width' => true, - 'frameborder' => true, - 'allowfullscreen' => true, - ); + $allowed_html = wp_kses_allowed_html('tainacan_post'); ob_start(); ?> diff --git a/src/tainacan.php b/src/tainacan.php index 2552c3831..18d7389a9 100644 --- a/src/tainacan.php +++ b/src/tainacan.php @@ -122,4 +122,22 @@ function tainacan_add_admin_bar_items ( WP_Admin_Bar $admin_bar ) { } } } -add_action( 'admin_bar_menu', 'tainacan_add_admin_bar_items', 500 ); \ No newline at end of file +add_action( 'admin_bar_menu', 'tainacan_add_admin_bar_items', 500 ); + + +add_filter('wp_kses_allowed_html', function($allowedposttags, $context) { + if($context == 'tainacan_post') { + $post_allowed_html = wp_kses_allowed_html('post'); + return array_merge( + $post_allowed_html, + ['iframe' => array( + 'src' => true, + 'height' => true, + 'width' => true, + 'frameborder' => true, + 'allowfullscreen' => true, + )] + ); + } + return $allowedposttags; +}, 10, 2); \ No newline at end of file