Add shortcode_atts_$shortcode filter for when the name of the shortcode is passed to shortcode_atts(). props coffee2code. fixes #15155.
git-svn-id: http://core.svn.wordpress.org/trunk@23626 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3fcf3e1134
commit
c3a174becd
|
@ -644,7 +644,7 @@ function img_caption_shortcode($attr, $content = null) {
|
||||||
'align' => 'alignnone',
|
'align' => 'alignnone',
|
||||||
'width' => '',
|
'width' => '',
|
||||||
'caption' => ''
|
'caption' => ''
|
||||||
), $attr));
|
), $attr, 'caption'));
|
||||||
|
|
||||||
if ( 1 > (int) $width || empty($caption) )
|
if ( 1 > (int) $width || empty($caption) )
|
||||||
return $content;
|
return $content;
|
||||||
|
@ -704,7 +704,7 @@ function gallery_shortcode($attr) {
|
||||||
'size' => 'thumbnail',
|
'size' => 'thumbnail',
|
||||||
'include' => '',
|
'include' => '',
|
||||||
'exclude' => ''
|
'exclude' => ''
|
||||||
), $attr));
|
), $attr, 'gallery'));
|
||||||
|
|
||||||
$id = intval($id);
|
$id = intval($id);
|
||||||
if ( 'RAND' == $order )
|
if ( 'RAND' == $order )
|
||||||
|
|
|
@ -289,9 +289,10 @@ function shortcode_parse_atts($text) {
|
||||||
*
|
*
|
||||||
* @param array $pairs Entire list of supported attributes and their defaults.
|
* @param array $pairs Entire list of supported attributes and their defaults.
|
||||||
* @param array $atts User defined attributes in shortcode tag.
|
* @param array $atts User defined attributes in shortcode tag.
|
||||||
|
* @param string $shortcode Optional. The name of the shortcode, provided for context to enable filtering
|
||||||
* @return array Combined and filtered attribute list.
|
* @return array Combined and filtered attribute list.
|
||||||
*/
|
*/
|
||||||
function shortcode_atts($pairs, $atts) {
|
function shortcode_atts( $pairs, $atts, $shortcode = '' ) {
|
||||||
$atts = (array)$atts;
|
$atts = (array)$atts;
|
||||||
$out = array();
|
$out = array();
|
||||||
foreach($pairs as $name => $default) {
|
foreach($pairs as $name => $default) {
|
||||||
|
@ -300,6 +301,10 @@ function shortcode_atts($pairs, $atts) {
|
||||||
else
|
else
|
||||||
$out[$name] = $default;
|
$out[$name] = $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( $shortcode )
|
||||||
|
$out = apply_filters( "shortcode_atts_{$shortcode}", $out, $pairs, $atts );
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue