[wp-trac] [WordPress Trac] #23855: Leave Shortcode functions early, if there's no Shortcode delimiter

WordPress Trac noreply at wordpress.org
Sun Mar 24 15:15:03 UTC 2013


#23855: Leave Shortcode functions early, if there's no Shortcode delimiter
-----------------------------+-------------------------
 Reporter:  TobiasBg         |       Type:  enhancement
   Status:  new              |   Priority:  normal
Milestone:  Awaiting Review  |  Component:  Shortcodes
  Version:                   |   Severity:  normal
 Keywords:  has-patch        |
-----------------------------+-------------------------
 The main Shortcode processing functions (like {{{do_shortcode()}}}) all
 make several function calls to build the Shortcode RegEx, with a lot of
 array handling and string concatenation, before finally using a comparably
 expensive {{{preg_replace()}}} - and that's for every post that is shown
 on a page, even if there's no Shortcode in the post.

 With a quick check for the opening bracket {{{[}}}, that is required for
 every Shortcode, we can skip that extra work and leave those functions
 early to save some processing time.

 The attached patch adds that to {{{do_shortcode()}}},
 {{{strip_shortcodes()}}}, and {{{has_shortcode()}}}.

 (Hat tip to bobbingwhite, who suggested this in
 [http://core.trac.wordpress.org/ticket/17657#comment:18 this comment]
 before, but it didn't gain traction as the ticket dealt with a different
 aspect of Shortcodes.)

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/23855>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list