• Resolved David Goring

    (@dg12345)


    I’ve noticed that your plugin enqueues its javascript across the whole admin.

    However it requires the acf scripts to run first so on many of the pages it causes an error.

    Instead of enqueueing everywhere could you only enqueue with ACF

    I believe you could achieve this by changing the follow

    classes/main.php line 9 – 10

    
    		add_action( 'admin_footer', [ $this, 'register_assets' ], 1 );
    		add_action( 'admin_footer', [ $this, 'enqueue_assets' ] );
    

    to

    
    		add_action( 'acf/enqueue_scripts', [ $this, 'register_assets' ], 1 );
    		add_action( 'acf/enqueue_scripts', [ $this, 'enqueue_assets' ] );
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • I’m seeing the same issue. It doesn’t appear to be causing the admin to fail, but it would definitely be a good idea to only require this with ACF (as mentioned by Dave above).

    Any movement on this?

    Wanted to follow up on this.

    I tried updating the classes/main.php file with the patch mentioned by @dg12345. This did resolve the admin console error, but when I went to the page edit screen, the preview images didn’t load.

    I added a check to the /assets/js/acf-flexible-content-preview.js file to make sure acf is defined before trying to access it’s methods:

    if ( typeof acf != 'undefined' && typeof acf.getField == 'function' ) {
    ...
    }

    This isn’t the best fix, as the plugin is still enqueueing assets when they’re not needed, but it appears to fix the issue.

    Just wanted to share incase anyone else is looking for a temp fix for this before the plugin core is updated.

    Plugin Author Jameel Moses

    (@jameelmoses)

    This has been fixed in 1.0.5

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Admin Javascript Error’ is closed to new replies.