我想您正在寻找PHP函数extract()
function your_shortcode_callback( $atts ) {
// compare incoming $atts against defaults and extract out
extract( shortcode_atts( array(
\'width\' => \'12\',
\'height\' => \'4\',
\'file\' => \'\'
), $atts ) );
if( ! $file )
return \'\';
// do something with the $width, $height, and $file variables
}