Skip to content

Commit 72f12de

Browse files
committed
remove scripts later in the queue
1 parent 9b64285 commit 72f12de

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

includes/class-shortcodes.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,6 @@ public static function content( $atts, $content, $tag ) {
197197

198198
$content = \get_post_field( 'post_content', $post );
199199

200-
// replace script and style elements
201-
$content = \preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $content );
202-
203200
if ( 'yes' === $atts['apply_filters'] ) {
204201
$content = \apply_filters( 'the_content', $content );
205202
} else {
@@ -208,6 +205,9 @@ public static function content( $atts, $content, $tag ) {
208205
$content = wp_filter_content_tags( $content );
209206
}
210207

208+
// replace script and style elements
209+
$content = \preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $content );
210+
211211
$content = \trim( \preg_replace( '/[\n\r\t]/', '', $content ) );
212212

213213
return $content;

tests/test-class-activitypub-shortcodes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public function test_content() {
1010
$post->post_date = current_time( 'mysql' );
1111
$post->post_date_gmt = current_time( 'mysql', 1 );
1212
$post->post_title = 'Some title or other';
13-
$post->post_content = '<script>test</script>hallo';
13+
$post->post_content = '<script>test</script>hallo<script type="javascript">{"asdf": "qwerty"}</script><style></style>';
1414
$post->post_status = 'publish';
1515
$post->comment_status = 'closed';
1616
$post->ping_status = 'closed';

0 commit comments

Comments
 (0)