Skip to content

Commit d9436ed

Browse files
committed
Wrap do_shortcode in try/finally so the temp hook is always removed, regardless of error state
1 parent 7fcf7fa commit d9436ed

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

includes/functions.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
function bbpress_allowed_shortcodes_do_shortcode( string $content, bool $ignore_html = false ): string {
1717
add_filter( 'pre_do_shortcode_tag', 'bbpress_allowed_shortcodes_pre_do_shortcode_tag', 1, 4 );
1818

19-
$content = do_shortcode( $content, $ignore_html );
20-
21-
remove_filter( 'pre_do_shortcode_tag', 'bbpress_allowed_shortcodes_pre_do_shortcode_tag', 1 );
22-
23-
return $content;
19+
try {
20+
return do_shortcode( $content, $ignore_html );
21+
} finally {
22+
remove_filter( 'pre_do_shortcode_tag', 'bbpress_allowed_shortcodes_pre_do_shortcode_tag', 1 );
23+
}
2424
}
2525

2626
/**

0 commit comments

Comments
 (0)