Check `is_callable()` in `do_shortcode_tag()`, not `add_shortcode()`.

Add a `_doing_it_wrong()` in `do_shortcode_tag()` when `is_callable()` is `false`.

Props aaroncampbell.
See #32445.


git-svn-id: https://develop.svn.wordpress.org/trunk@32867 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2015-06-19 21:32:31 +00:00
parent 9123db3dcb
commit ee4e5c4b35
1 changed files with 7 additions and 3 deletions

View File

@ -88,9 +88,7 @@ $shortcode_tags = array();
*/
function add_shortcode($tag, $func) {
global $shortcode_tags;
if ( is_callable($func) )
$shortcode_tags[$tag] = $func;
$shortcode_tags[ $tag ] = $func;
}
/**
@ -282,6 +280,12 @@ function do_shortcode_tag( $m ) {
$tag = $m[2];
$attr = shortcode_parse_atts( $m[3] );
if ( ! is_callable( $shortcode_tags[ $tag ] ) ) {
$message = sprintf( __( 'Attempting to parse a shortcode without a valid callback: %s' ), $tag );
_doing_it_wrong( __FUNCTION__, $message, '4.3.0' );
return $m[0];
}
if ( isset( $m[5] ) ) {
// enclosing tag - extra parameter
return $m[1] . call_user_func( $shortcode_tags[$tag], $attr, $m[5], $tag ) . $m[6];