Home › Forums › General Issues › Access ACF functions from plugin › Reply To: Access ACF functions from plugin
OK, I answered my own question and I guess I was missing something really simple: just call get_field() from within my plugin code.
What I was missing was that because the get_field function is defined in a file that was “include”d by the ACF class initialize method, that function is added to the global namespace. It just never occurred to me that get_field might be a global function.
But I’m really confused about *why* the ACF coders would dump functions like “get_field” into the global namespace. If I ever attempt to load another plugin or theme that does the same thing – declares a ‘get_field’ function into the global namespace – it will trigger a fatal error.
Isn’t this what namespaces and classes are for?
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
Accordions are a great way to group related information while allowing users to interactively show and hide content. In this video, Damon Cook goes in-depth on how to create an accessible accordion block using ACF PRO’s Repeater field.https://t.co/RXT0g25akN— Advanced Custom Fields (@wp_acf) March 2, 2023
© 2023 Advanced Custom Fields.