Make WordPress Core


Ignore:
Timestamp:
03/06/2013 08:07:40 PM (12 years ago)
Author:
nacin
Message:

Add shortcode_atts_$shortcode filter for when the name of the shortcode is passed to shortcode_atts(). props coffee2code. fixes #15155.

File:
1 edited

Legend:

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

    r22401 r23626  
    290290 * @param array $pairs Entire list of supported attributes and their defaults.
    291291 * @param array $atts User defined attributes in shortcode tag.
     292 * @param string $shortcode Optional. The name of the shortcode, provided for context to enable filtering
    292293 * @return array Combined and filtered attribute list.
    293294 */
    294 function shortcode_atts($pairs, $atts) {
     295function shortcode_atts( $pairs, $atts, $shortcode = '' ) {
    295296    $atts = (array)$atts;
    296297    $out = array();
     
    301302            $out[$name] = $default;
    302303    }
     304
     305    if ( $shortcode )
     306        $out = apply_filters( "shortcode_atts_{$shortcode}", $out, $pairs, $atts );
     307
    303308    return $out;
    304309}
Note: See TracChangeset for help on using the changeset viewer.