mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@38506 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user