Home › Forums › Backend Issues (wp-admin) › ACF Not Defined – Javascript
Hello,
I’ve followed the instructions for Including ACF in my Custom Plugin but every ACF page I keep running into the same JS issue:
Uncaught ReferenceError: acf is not defined
The URL to the file is right. The paths appear right. I don’t have any PHP errors in my debug.logs. I’m not running any Javascript in the admin panel. My integration file is pretty straight forward:
Class PREFIX_ACF_Integration {
/**
* Call any necessary methods
*
* @return void
*/
public static function register() {
$class = new self();
$class->filter_hooks();
$class->include_acf();
}
/**
* Add any necessary filters
*
* @return void
*/
private function filter_hooks() {
add_filter( 'acf/settings/path', array( $this, 'acf_settings_path' ), 1 );
add_filter( 'acf/settings/dir', array( $this, 'acf_settings_dir' ), 1 );
add_filter( 'acf/settings/url', array( $this, 'acf_settings_url' ), 1 );
add_filter( 'acf/settings/load_json', array( $this, 'acf_setting_json_load' ), 1 );
}
/**
* Change Advanced Custom Fields Setting Path
*
* @return String
*/
public function acf_settings_path() {
return plugin_dir_path( __FILE__ ) . 'advanced-custom-fields/';
}
/**
* Change Advanced Custom Fields Setting Directory
*
* @return String
*/
public function acf_settings_dir() {
return plugins_url( 'advanced-custom-fields/', __FILE__ );
}
/**
* Change Advanced Custom Fields Setting URL
*
* @return String
*/
public function acf_settings_url() {
return plugins_url( 'advanced-custom-fields/', __FILE__ );
}
/**
* Change Advanced Custom Fields JSON 'Load From' Locations
*
* @return String
*/
public function acf_setting_json_load( $paths ) {
unset( $paths[0] );
$paths[] = plugin_dir_path( __FILE__ ) . 'fields/';
return $paths;
}
/**
* Include Advanced Custom Fields
*
* @return void
*/
private function include_acf() {
require_once( plugin_dir_path( __FILE__ ) . 'advanced-custom-fields/acf.php' );
}
} // END PREFIX_ACF_Integration
PREFIX_ACF_Integration::register();
Am I missing something in the plugin integration section? Why would every ACF page ( even the tools and settings pages ) be missing acf
javascript reference? How do I go about debugging this kind of issue?
Anddddddd as it turns out I forgot that I had ACF already installed and active before integrating it into my custom plugin. The two were conflicting. Once I uninstalled active plugin the issue was solved.
You must be logged in to reply to this topic.
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.