mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Bail early from shortcode functions if no delimiter is present.
This is a significant performance improvement for processing content without shortcodes, and only the slightest hit when content contains shortcodes (which must then undergo processing anyway). Performance results on the ticket. props TobiasBg. fixes #23855. git-svn-id: https://develop.svn.wordpress.org/trunk@27394 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -155,6 +155,10 @@ function shortcode_exists( $tag ) {
|
||||
* @return boolean
|
||||
*/
|
||||
function has_shortcode( $content, $tag ) {
|
||||
if ( false === strpos( $content, '[' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( shortcode_exists( $tag ) ) {
|
||||
preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER );
|
||||
if ( empty( $matches ) )
|
||||
@@ -186,6 +190,10 @@ function has_shortcode( $content, $tag ) {
|
||||
function do_shortcode($content) {
|
||||
global $shortcode_tags;
|
||||
|
||||
if ( false === strpos( $content, '[' ) ) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
if (empty($shortcode_tags) || !is_array($shortcode_tags))
|
||||
return $content;
|
||||
|
||||
@@ -375,6 +383,10 @@ function shortcode_atts( $pairs, $atts, $shortcode = '' ) {
|
||||
function strip_shortcodes( $content ) {
|
||||
global $shortcode_tags;
|
||||
|
||||
if ( false === strpos( $content, '[' ) ) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
if (empty($shortcode_tags) || !is_array($shortcode_tags))
|
||||
return $content;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user