一些HTML元素接受无价值的属性,例如<input disabled />
或<video autoplay />
如果我想在默认情况下禁用自动播放(=完全忽略属性),但可以选择启用它,那么如何处理这种情况。
可能的情况:
// [video]
<video>
// [video autoplay]
<video autoplay="autoplay"> // using XML syntax
// [video autoplay="autoplay"]
<video autoplay="autoplay">
// [video autoplay="false"]
<video autoplay="false"> // value doesn\'t matter - video will still auto play
这样做的标准方式对我没有帮助I don\'t want to have a default value:// http://codex.wordpress.org/Shortcode_API#Attributes
function my_shortcode_handler( $atts, $content = null ) {
extract( shortcode_atts( array(
\'attr_1\' => \'attribute 1 default\',
\'attr_2\' => \'attribute 2 default\',
// ...etc
), $atts ) );
}
我肯定能找到我自己解决这个问题的方法,但如果有一个很好的方法可以做到这一点,我很感兴趣。