Make WordPress Core


Ignore:
Timestamp:
06/19/2015 09:32:31 PM (9 years ago)
Author:
wonderboymusic
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/shortcodes.php

    r32624 r32867  
    8989function add_shortcode($tag, $func) {
    9090    global $shortcode_tags;
    91 
    92     if ( is_callable($func) )
    93         $shortcode_tags[$tag] = $func;
     91    $shortcode_tags[ $tag ] = $func;
    9492}
    9593
     
    283281    $attr = shortcode_parse_atts( $m[3] );
    284282
     283    if ( ! is_callable( $shortcode_tags[ $tag ] ) ) {
     284        $message = sprintf( __( 'Attempting to parse a shortcode without a valid callback: %s' ), $tag );
     285        _doing_it_wrong( __FUNCTION__, $message, '4.3.0' );
     286        return $m[0];
     287    }
     288
    285289    if ( isset( $m[5] ) ) {
    286290        // enclosing tag - extra parameter
Note: See TracChangeset for help on using the changeset viewer.