Support

Account

Home Forums Backend Issues (wp-admin) ACF Not Defined – Javascript

Solved

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.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.