From 2d76b94be85865931bbce11fd3bbfb7d34b272dd Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 4 Oct 2016 00:39:37 +0000 Subject: [PATCH] Shortcodes: Add a `do_shortcode_tag` filter. The addition of the `pre_do_shortcode_tag` in [38506] allows plugins to short-circuit the shortcode execution process, which is particularly helpful for caching expensive shortcodes. The `do_shortcode_tag` is the corresponding part of that system - when a shortcode hasn't been executed previously, there needs to be a clean method of populating the cache. Props flixos90. Fixes #32790. Built from https://develop.svn.wordpress.org/trunk@38713 git-svn-id: http://core.svn.wordpress.org/trunk@38656 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/shortcodes.php | 22 +++++++++++++++------- wp-includes/version.php | 2 +- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/wp-includes/shortcodes.php b/wp-includes/shortcodes.php index b2aad3dc4d..f0523622cc 100644 --- a/wp-includes/shortcodes.php +++ b/wp-includes/shortcodes.php @@ -339,13 +339,21 @@ function do_shortcode_tag( $m ) { return $return; } - if ( isset( $m[5] ) ) { - // enclosing tag - extra parameter - return $m[1] . call_user_func( $shortcode_tags[$tag], $attr, $m[5], $tag ) . $m[6]; - } else { - // self-closing tag - return $m[1] . call_user_func( $shortcode_tags[$tag], $attr, null, $tag ) . $m[6]; - } + $content = isset( $m[5] ) ? $m[5] : null; + + $output = $m[1] . call_user_func( $shortcode_tags[ $tag ], $attr, $content, $tag ) . $m[6]; + + /** + * Filters the output created by a shortcode callback. + * + * @since 4.7.0 + * + * @param string $output Shortcode output. + * @param string $tag Shortcode name. + * @param array $attr Shortcode attributes array, + * @param array $m Regular expression match array. + */ + return apply_filters( 'do_shortcode_tag', $output, $tag, $attr, $m ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index ba9f691c7d..e6cb70a524 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.7-alpha-38712'; +$wp_version = '4.7-alpha-38713'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.