mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-03 04:04:35 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@38877 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user