WordPress.org

Make WordPress Core

Ticket #23855: 23855-shortcodes.patch

File 23855-shortcodes.patch, 1.1 KB (added by TobiasBg, 5 years ago)

Leave Shortcode functions early if there can not be a Shortcode in the content

  • wp-includes/shortcodes.php

    function shortcode_exists( $tag ) { 
    151151 * @return boolean
    152152 */
    153153function has_shortcode( $content, $tag ) {
     154        if ( false === strpos( $content, '[' ) )
     155                return false;
     156
    154157        if ( shortcode_exists( $tag ) ) {
    155158                $matches = array();
    156159                preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER );
    function has_shortcode( $content, $tag ) { 
    182185function do_shortcode($content) {
    183186        global $shortcode_tags;
    184187
     188        if ( false === strpos( $content, '[' ) )
     189                return $content;
     190
    185191        if (empty($shortcode_tags) || !is_array($shortcode_tags))
    186192                return $content;
    187193
    function shortcode_atts( $pairs, $atts, $shortcode = '' ) { 
    358364function strip_shortcodes( $content ) {
    359365        global $shortcode_tags;
    360366
     367        if ( false === strpos( $content, '[' ) )
     368                return $content;
     369
    361370        if (empty($shortcode_tags) || !is_array($shortcode_tags))
    362371                return $content;
    363372