Make WordPress Core


Ignore:
Timestamp:
10/23/2016 02:24:26 PM (8 years ago)
Author:
aaroncampbell
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/shortcodes.php

    r38713 r38877  
    606606    // Find all registered tag names in $content.
    607607    preg_match_all( '@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches );
    608     $tagnames = array_intersect( array_keys( $shortcode_tags ), $matches[1] );
     608
     609    $tags_to_remove = array_keys( $shortcode_tags );
     610
     611    /**
     612     * Filters the list of shortcode tags to remove from the content.
     613     *
     614     * @since 4.7.0
     615     *
     616     * @param array  $tag_array Array of shortcode tags to remove.
     617     * @param string $content   Content shortcodes are being removed from.
     618     */
     619    $tags_to_remove = apply_filters( 'strip_shortcodes_tagnames', $tags_to_remove, $content );
     620
     621    $tagnames = array_intersect( $tags_to_remove, $matches[1] );
    609622
    610623    if ( empty( $tagnames ) ) {
Note: See TracChangeset for help on using the changeset viewer.