答案 0 :(得分:5)
这就是CF7如何注册文本字段的短标签:
add_action( 'wpcf7_init', 'wpcf7_add_shortcode_text' );
function wpcf7_add_shortcode_text() {
wpcf7_add_shortcode(
array( 'text', 'text*', 'email', 'email*', 'url', 'url*', 'tel', 'tel*' ),
'wpcf7_text_shortcode_handler', true );
}
请注意函数wpcf7_init
的钩子是wpcf7_add_shortcode()
,所以,如果我们自己做一个例子:
add_action( 'wpcf7_init', 'custom_add_shortcode_hello' );
function custom_add_shortcode_hello() {
wpcf7_add_shortcode( 'helloworld', 'custom_hello_shortcode_handler' ); // "helloworld" is the type of the form-tag
}
然后是回调处理程序
function custom_hello_shortcode_handler( $tag ) {
return 'hello world ! ';
}
现在,如果你将在表格中添加
CF7 say : [helloworld]
你应该看到
CF7 say : hello world !
如果您想使用普通表单标签,请注意可用的默认类型是:
text, text*, email, email*, tel, tel*, url, url*, textarea ,textarea* , number, number*, range and range* , date , date*,checkbox, checkbox*, radio, select and select* , file , file*, captchac ,captchar, quiz , acceptance, submit;
现在,我写了所有这些,因为据我所知(我可能错了),对于wpcf7_tg_pane_text_and_relatives()
modules/text.php
中wpcf7_remove_shortcode( $tag );
中定义的现有标记,HTML表单没有过滤器。 1}}
,但你可以做的是使用{
...
"reviews" : [
{
"aspects" : [
{
"rating" : 3,
"type" : "quality"
}
],
"author_name" : "Simon Bengtsson",
"author_url" : "https://plus.google.com/104675092887960962573",
"language" : "en",
"rating" : 5,
"text" : "Just went inside to have a look at Google. Amazing.",
"time" : 1338440552869
}
]
...
}
删除默认标记(例如文本),然后通过创建一个新标记(例如文本)添加自己的上述示例以适应您的需要
话虽这么说,我还不确定你想要什么以及为什么这个(你真的没有解释目标,只是顺便说一下)因为恕我直言,经过我写的很多CF7自定义插件后,我真的做到了不明白为什么不只是创建一个更容易和更多构造的新标签。
但话说回来,我可能错了。