Since nobody posted a complete answer, I used the method s_ha_dum described and written a function that returns a shortcode
=> attributes
array/map.
function attribute_map($str, $att = null) {
$res = array();
$reg = get_shortcode_regex();
preg_match_all('~'.$reg.'~',$str, $matches);
foreach($matches[2] as $key => $name) {
$parsed = shortcode_parse_atts($matches[3][$key]);
$parsed = is_array($parsed) ? $parsed : array();
if(array_key_exists($name, $res)) {
$arr = array();
if(is_array($res[$name])) {
$arr = $res[$name];
} else {
$arr[] = $res[$name];
}
$arr[] = array_key_exists($att, $parsed) ? $parsed[$att] : $parsed;
$res[$name] = $arr;
} else {
$res[$name][] = array_key_exists($att, $parsed) ? $parsed[$att] : $parsed;
}
}
return $res;
}
Example usage:
Content of the page:
[outer_shortcode]
[inner_code url="#" title="Hello"]
[/outer_shortcode]
Shortcode implementations:
add_shortcode('outer_shortcode',function($atts,$content) {
return attribute_map($content);
});
add_shortcode('inner_shortcode',function($atts,$content) {
return '';
});
This will render to:
Array
(
[inner_shortcode] => Array
(
[url] => #
Get attributes of nested shortcodes => Hello
)
)