Shortcodes: Add the `pre_do_shortcode_tag` filter.

This filter allows the shortcode generation process to be short-circuited, so expensive short codes can be cached and returned immediately.

Props ideag.
Fixes #37906.


Built from https://develop.svn.wordpress.org/trunk@38506


git-svn-id: http://core.svn.wordpress.org/trunk@38447 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Gary Pendergast 2016-09-02 00:10:28 +00:00
parent 8682603166
commit 75c1875587
2 changed files with 19 additions and 1 deletions

View File

@ -321,6 +321,24 @@ function do_shortcode_tag( $m ) {
return $m[0];
}
/**
* Filters whether to call a shortcode callback.
*
* Passing a truthy value to the filter will effectively short-circuit the
* shortcode generation process, returning that value instead.
*
* @since 4.7.0
*
* @param bool|string $return Short-circuit return value. Either false or the value to replace the shortcode with.
* @param string $tag Shortcode name.
* @param array $attr Shortcode attributes array,
* @param array $m Regular expression match array.
*/
$return = apply_filters( 'pre_do_shortcode_tag', false, $tag, $attr, $m );
if ( false !== $return ) {
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];

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.7-alpha-38505';
$wp_version = '4.7-alpha-38506';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.