From 3a761adbd734635b4c27c7a5eba3a8ba14f4b08f Mon Sep 17 00:00:00 2001 From: Aaron Campbell Date: Sun, 23 Oct 2016 14:25:31 +0000 Subject: [PATCH] Shortcodes: Add new `strip_shortcodes_tagnames` filter. With the new `strip_shortcodes_tagnames` filter you can specify which shortcodes are stripped by `strip_shortcodes()`. The default is all registered shortcodes. Props DylanAuty, orvils, swissspidy. Fixes #37767. Built from https://develop.svn.wordpress.org/trunk@38877 git-svn-id: http://core.svn.wordpress.org/trunk@38820 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/shortcodes.php | 15 ++++++++++++++- wp-includes/version.php | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/wp-includes/shortcodes.php b/wp-includes/shortcodes.php index f0523622cc..3af0e10f58 100644 --- a/wp-includes/shortcodes.php +++ b/wp-includes/shortcodes.php @@ -605,7 +605,20 @@ function strip_shortcodes( $content ) { // Find all registered tag names in $content. preg_match_all( '@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches ); - $tagnames = array_intersect( array_keys( $shortcode_tags ), $matches[1] ); + + $tags_to_remove = array_keys( $shortcode_tags ); + + /** + * Filters the list of shortcode tags to remove from the content. + * + * @since 4.7.0 + * + * @param array $tag_array Array of shortcode tags to remove. + * @param string $content Content shortcodes are being removed from. + */ + $tags_to_remove = apply_filters( 'strip_shortcodes_tagnames', $tags_to_remove, $content ); + + $tagnames = array_intersect( $tags_to_remove, $matches[1] ); if ( empty( $tagnames ) ) { return $content; diff --git a/wp-includes/version.php b/wp-includes/version.php index 5a8c9b1bec..970f06bfb1 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.7-alpha-38876'; +$wp_version = '4.7-alpha-38877'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.