Make WordPress Core

Ticket #47984: pre_do_shortcodes.diff

File pre_do_shortcodes.diff, 1.0 KB (added by miyarakira, 5 years ago)

Draft version of proposed patch

  • src/wp-includes/shortcodes.php

     
    177177function do_shortcode( $content, $ignore_html = false ) {
    178178        global $shortcode_tags;
    179179
     180        /**
     181         * Filters whether to continue with do_shortcode.
     182         *
     183         * Passing a truthy value to the filter will effectively short-circuit the
     184         * shortcode search & replace process, returning that value instead.
     185         *
     186         * @since
     187         *
     188         * @param bool|string $return Short-circuit return value. Either false or the value to replace the content with.
     189         * @param string $content Content to search for shortcodes.
     190         * @param bool $ignore_html When true, shortcodes inside HTML elements will be skipped.
     191         */
     192        $return = apply_filters( 'pre_do_shortcode', false, $content, $ignore_html );
     193        if ( false !== $return ) {
     194                return $return;
     195        }
     196
    180197        if ( false === strpos( $content, '[' ) ) {
    181198                return $content;
    182199        }