admin管理员组文章数量:1410724
I was just reading through BuddyPress code because I want to develop a custom plugin on top of it. I encountered something very peculiar that I haven't seen before and cannot seem to find any material on.
The following code is from a protected function under a class named BP_Legacy
// Filter BuddyPress template hierarchy and look for page templates.
add_filter( 'bp_get_buddypress_template', array( $this,
'theme_compat_page_templates' ), 10, 1 );
As far as I know, the syntax for add_filter
is something like
add_filter ('hook_name', 'callback_function', $priority, $number_of_arguments)
How is it that an array has been passed instead of the callback function? How exactly would this line of code run?
I was just reading through BuddyPress code because I want to develop a custom plugin on top of it. I encountered something very peculiar that I haven't seen before and cannot seem to find any material on.
The following code is from a protected function under a class named BP_Legacy
// Filter BuddyPress template hierarchy and look for page templates.
add_filter( 'bp_get_buddypress_template', array( $this,
'theme_compat_page_templates' ), 10, 1 );
As far as I know, the syntax for add_filter
is something like
add_filter ('hook_name', 'callback_function', $priority, $number_of_arguments)
How is it that an array has been passed instead of the callback function? How exactly would this line of code run?
Share Improve this question edited Jan 21, 2020 at 22:57 davemackey 3152 silver badges18 bronze badges asked May 19, 2017 at 7:17 Ram IyerRam Iyer 331 silver badge7 bronze badges1 Answer
Reset to default 3You can pass as the callback argument anything which is callable by PHP definition, something that might actually change between PHP versions.
In this specific case the array($o,$m)
type of notation indicates that the filter will call $o->$m
本文标签: plugin developmentaddfilterPassing an array instead of the callback function
版权声明:本文标题:plugin development - add_filter : Passing an array instead of the callback function? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744814758a2626626.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论