[wp-trac] [WordPress Trac] #17657: Shortcode regex doesn't allow for hyphens in shortcode name
WordPress Trac
wp-trac at lists.automattic.com
Sat Jul 21 18:30:34 UTC 2012
#17657: Shortcode regex doesn't allow for hyphens in shortcode name
-------------------------------------+--------------------
Reporter: sivel | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 3.5
Component: Shortcodes | Version: 2.9.2
Severity: normal | Resolution:
Keywords: has-patch needs-testing |
-------------------------------------+--------------------
Comment (by bobbingwide):
Regarding performance, there are two scenarios.
1. When there are no shortcodes in the content
2. Otherwise
I ran a suite of tests where the number of registered shortcodes ranged
from 1 to 200
and the number of shortcodes in the content ranged from 0 to 100
The shortcodes I used were [wpn] and [wp-n], where n ranged from 1 to 100.
All of them were handled by the same function wpsc() { return "wp"; }
There was no appreciable difference between the average time for the fix
and the original code. However, as the number of registered shortcodes
increased so the time taken to handle the content increased.
I added this code into the start of do_shortcode()- right at the front
if ( false === strpos( $content, "[" ) )
return $content;
when there were shortcodes in the content then this only increased the
execution time insignificantly. But when there were no shortcodes in the
content the execution time was constant at .000020 secs per invocation vs
.000080 for 0 shortcodes and .000100 for 100.
4 to 5 times faster!
So, if you're concerned about performance please ADD the above code to
cater for those sites where shortcodes are hardly ever used in the
content.
.php and .csv available on request.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/17657#comment:18>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list