Support

Account

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?