开发者 |
Michael Uno
miunosoft |
---|---|
更新时间 | 2016年12月21日 22:56 |
捐献地址: | 去捐款 |
PHP版本: | 3.4 及以上 |
WordPress版本: | 4.7.0 |
版权: | GPLv2 or later |
版权网址: | 版权信息 |
[my_shortcode foo[1]="one" foo[2]="two"]
However, commentcode can handle it.
`
The attributes are interpreted as
array(
'foo' => array(
1 => 'one',
2 => 'two',
)
)
`
Preserved Letter Cases
The shortcode does not allow capitalized attribute names.
[my_shortcode CapitalName="I need it to be capitalized"]
The attribute is interpreted as
array( 'capitalname' => 'I need it to be capitalized', )
This is not useful when you need to perform remote API requests which require argument names with capital letters.
However, the commentcode API preserves those argument names.
`
will be
array(
'CapitalName' => 'Please keep capitalization!',
)
`
commentcode-api.php
and other files compressed in the zip folder to the /wp-content/plugins/
directory.add_commentcode()
function. It accepts two parameters.
function get_my_commentcode( $text, $arguments, $tag ) { return "<pre>" . htmlspecialchars( print_r( $arguments, true ) ) . "</pre>"; } add_commentcode( 'my_commentcode', 'get_my_commentcode' );
For a test, while running the above code, try inserting <!---my_commentcode Foo="bar" numbers[ 1 ]="one" numbers[ 2 ]="two"--->
in a post.