admin管理员组文章数量:1201032
I have below code.
add_action( 'admin_init', [$this, 'settings_page_registration'] );
I would like to use enqueue_assets
function name inside add_action()
.
Should I use like below ?
add_action( 'admin_init', [$this, 'settings_page_registration', 'enqueue_assets'] );
I have below code.
add_action( 'admin_init', [$this, 'settings_page_registration'] );
I would like to use enqueue_assets
function name inside add_action()
.
Should I use like below ?
add_action( 'admin_init', [$this, 'settings_page_registration', 'enqueue_assets'] );
Share
Improve this question
asked May 10, 2022 at 3:37
FoysalFoysal
4451 gold badge5 silver badges16 bronze badges
2
|
1 Answer
Reset to default 2If you need to call enqueue_assets
at admin_init
, then add a new add_action()
:
add_action( 'admin_init', [$this, 'settings_page_registration'] );
add_action( 'admin_init', [$this, 'enqueue_assets'] );
- https://developer.wordpress.org/reference/functions/add_action/
That said, if your assets are JS scripts or CSS, you should consider wp_enqueue_script()
& wp_enqueue_scripts
- https://developer.wordpress.org/reference/functions/wp_enqueue_script
- https://developer.wordpress.org/reference/hooks/wp_enqueue_scripts/
本文标签: adminHow to pass multiple parameter in addaction()
版权声明:本文标题:admin - How to pass multiple parameter in add_action() 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738595581a2101768.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
admin_init
. Thanks. – Foysal Commented May 10, 2022 at 3:53