Home › Forums › Backend Issues (wp-admin) › ReferenceError: acf is not defined › Reply To: ReferenceError: acf is not defined
Hello Elliot
Thx for the quick reply. This however didn’t fix the problem.
If I take a look at the acf_form_wp_head
function I see the following:
function acf_form_wp_head()
{
do_action('acf/input/admin_head');
}
So in fact I already did the do_action part, only from within a function (which I called in my custom code).
I’ve tried some other placements for the do_action in my code but this didn’t work either. I’m not a frequent WordPress user so I’m not sure what to try next.
This is the current situation:
I’ve added a hook to a custom function:
add_action('admin_head', 'cjobs_admin_head');
In that function I’ve put the do_action:
function cjobs_admin_head()
{
do_action('acf/input/admin_head');
}
This is already something different than the code I used in version 3.x. In that version all I had to do was call the acf_form_wp_head
function just before parsing the acf fields.
This is the acf_form_wp_head
function in version 3.x:
function acf_form_wp_head()
{
// global vars
global $post, $acf;
// Style
echo '<link rel="stylesheet" type="text/css" href="'.$acf->dir.'/css/global.css?ver=' . $acf->version . '" />';
echo '<link rel="stylesheet" type="text/css" href="'.$acf->dir.'/css/input.css?ver=' . $acf->version . '" />';
// Javascript
echo '<script type="text/javascript" src="'.$acf->dir.'/js/input-actions.js?ver=' . $acf->version . '" ></script>';
// add user js + css
do_action('acf_head-input');
}
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.