根据属性值注册新的短代码处理程序:
function wrapper_shortcode_handler ( $atts, $content ) {
if ( "apple" === $atts["snack"] )
add_shortcode( "flavor", "healthy_callback" );
if ( "donut" === $atts["snack"] )
add_shortcode( "flavor", "fatty_callback" );
return do_shortcode( $content );
}
另请参见
Execute shortcode only in another shortcode