WordPress.org

Make WordPress Core

Ticket #15155: 15155.2.diff

File 15155.2.diff, 1.4 KB (added by coffee2code, 7 years ago)

Changes as suggested by @nacin (see associated comment for details)

  • wp-includes/shortcodes.php

     
    259259 *
    260260 * @param array $pairs Entire list of supported attributes and their defaults.
    261261 * @param array $atts User defined attributes in shortcode tag.
     262 * @param string $shortcode Optional. The name of the shortcode, provided for context to enable filtering
    262263 * @return array Combined and filtered attribute list.
    263264 */
    264 function shortcode_atts($pairs, $atts) {
     265function shortcode_atts( $pairs, $atts, $shortcode = '' ) {
    265266        $atts = (array)$atts;
    266267        $out = array();
    267268        foreach($pairs as $name => $default) {
     
    270271                else
    271272                        $out[$name] = $default;
    272273        }
     274
     275        if ( ! empty( $shortcode ) )
     276                $out = apply_filters( 'shortcode_atts_' . $shortcode, $out, $pairs, $atts );
     277
    273278        return $out;
    274279}
    275280
  • wp-includes/media.php

     
    731731                'align' => 'alignnone',
    732732                'width' => '',
    733733                'caption' => ''
    734         ), $attr));
     734        ), $attr, 'caption'));
    735735
    736736        if ( 1 > (int) $width || empty($caption) )
    737737                return $content;
     
    784784                'size'       => 'thumbnail',
    785785                'include'    => '',
    786786                'exclude'    => ''
    787         ), $attr));
     787        ), $attr, 'gallery'));
    788788
    789789        $id = intval($id);
    790790        if ( 'RAND' == $order )