Make WordPress Core

Changeset 23626


Ignore:
Timestamp:
03/06/2013 08:07:40 PM (14 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.

Location:
trunk/wp-includes
Files:
2 edited

Legend:

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

    r23439 r23626  
    645645                'width' => '',
    646646                'caption' => ''
    647         ), $attr));
     647        ), $attr, 'caption'));
    648648
    649649        if ( 1 > (int) $width || empty($caption) )
    … …  
    705705                'include'    => '',
    706706                'exclude'    => ''
    707         ), $attr));
     707        ), $attr, 'gallery'));
    708708
    709709        $id = intval($id);
  • 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.