From 0c866cfa79cc2ee55b9b2a7174b2b66585424188 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Fri, 19 Jun 2015 21:33:25 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@32867 git-svn-id: http://core.svn.wordpress.org/trunk@32838 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/shortcodes.php | 10 +++++++--- wp-includes/version.php | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/wp-includes/shortcodes.php b/wp-includes/shortcodes.php index 1299f74843..c399bb0065 100644 --- a/wp-includes/shortcodes.php +++ b/wp-includes/shortcodes.php @@ -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]; diff --git a/wp-includes/version.php b/wp-includes/version.php index 4d7da56819..b69b8435b0 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.3-alpha-32866'; +$wp_version = '4.3-alpha-32867'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.