admin管理员组文章数量:1336304
I have one question as for Nav Menu Items custom fields in the Appearance > Customizer screen.
Since 5.4. there are 2 new hooks:
wp_nav_menu_item_custom_fields
- it works for Appearance > Menus properly and I have added 2 custom fields.wp_nav_menu_item_custom_fields_customize_template
- it works for Appearance > Customizer and adds HTML properly.
But I need to use {{data}}
attribute for getting menu item attributes (my custom e.g. {{{data.visibility}}}
). I want to put the same 2 custom fields to WP Customizer > Menus > Item section via this hook wp_nav_menu_item_custom_fields_customize_template
and use in JS extended {{{data}}}
object.
There is default {{data}}
variable in JS template, it looks like this object
I have added 2 custom fields with custom data for each menu item via this hook wp_nav_menu_item_custom_fields
and it works properly.
Is there a way how I can add custom properties for every menu item to {data}
via PHP (add_filter
) or JS hooks (wp.hooks.addFilter
). I don't want to localize script and create another variable and use it in the JS template in wp_nav_menu_item_custom_fields_customize_template
hook's callback.
Let me know, Thanks!
本文标签: customizationHow to extend navmenuitemcontrol data in Appearance gt Customize
版权声明:本文标题:customization - How to extend nav-menu-item-control data in Appearance > Customize? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742390154a2465827.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论