admin管理员组文章数量:1434889
I'm using a WordPress plugin that allows integration actions to integrate it within a theme. Using GeneratePress' Elements feature, I'm adding the action as a hook. Currently the code I'm using is:
<?php do_action(webcomic_integrate_landing_page);
?>
The action itself has some boolean parameters listed at this website. The one I'm most interested in is webcomic_meta.
How can I incorporate the webcomic_meta parameter (set to false) within the PHP tags for running this action?
I'm using a WordPress plugin that allows integration actions to integrate it within a theme. Using GeneratePress' Elements feature, I'm adding the action as a hook. Currently the code I'm using is:
<?php do_action(webcomic_integrate_landing_page);
?>
The action itself has some boolean parameters listed at this website. The one I'm most interested in is webcomic_meta.
How can I incorporate the webcomic_meta parameter (set to false) within the PHP tags for running this action?
Share Improve this question asked Apr 1, 2019 at 17:48 JustenJusten 132 bronze badges1 Answer
Reset to default 1First of all, let's take a look at do_action
docs. As we can read there, this is the function that:
Execute functions hooked on a specific action hook.
And that's the way to use it:
do_action( string $tag, $arg = '' )
So the first param is the tag
(or the hook name). And then you can pass $arg
(or rather $arg
s).
And how to pass that args?
Well... It depends on action. Some of them take no args. Some of them take only one, and some of them take many args. Here's examples:
// this action takes no args
do_action( 'foo' );
// this action takes one arg
do_action( 'bar', $param );
// and this takes few args:
do_action( 'foobar', $param1, $param2, $param3 );
In your case, webcomic_integrate_landing_page
takes only one param, which should be an array (as we can read here):
do_action( 'webcomic_integrate_landing_page', array $args );
So if you want to pass any args in there, here's how:
do_action( 'webcomic_integrate_landing_page', array( 'webcomic_comments' => true, 'webcomic_meta' => false ) );
本文标签: pluginsHow to Use Parameters with a DoAction Function Within PHP Tags
版权声明:本文标题:plugins - How to Use Parameters with a Do_Action Function Within PHP Tags 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745638760a2667724.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论