Make WordPress Core

Ticket #37767: 37767.patch

File 37767.patch, 1.2 KB (added by DylanAuty, 8 years ago)

Add's additional param to the strip_shortcode function which can be used to override the array of tags being processed. If it is set, the global variable is ignored. Meaning it will only allow the shortcodes passed in optionally

  • src/wp-includes/shortcodes.php

     
    565565 * @global array $shortcode_tags
    566566 *
    567567 * @param string $content Content to remove shortcode tags.
     568 * @param array $tag_array (Optional) Array of tags to be stripped - will ignore global
    568569 * @return string Content without shortcode tags.
    569570 */
    570 function strip_shortcodes( $content ) {
     571function strip_shortcodes( $content , $tag_array = false) {
    571572        global $shortcode_tags;
    572573
    573574        if ( false === strpos( $content, '[' ) ) {
     
    577578        if (empty($shortcode_tags) || !is_array($shortcode_tags))
    578579                return $content;
    579580
    580         // Find all registered tag names in $content.
     581        // Find all registered tag names in $content. -- if Tag array is set, then use this instead of global
    581582        preg_match_all( '@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches );
    582         $tagnames = array_intersect( array_keys( $shortcode_tags ), $matches[1] );
     583        $tagnames = array_intersect( array_keys( ( $tag_array !== false && is_array($tag_array) ? $tag_array : $shortcode_tags ) , $matches[1] );
    583584
    584585        if ( empty( $tagnames ) ) {
    585586                return $content;