{"id":13392848,"date":"2020-09-11T12:43:09","date_gmt":"2020-09-11T12:43:09","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/admin-javascript-error-2\/"},"modified":"2020-09-11T12:43:09","modified_gmt":"2020-09-11T12:43:09","slug":"admin-javascript-error-2","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/admin-javascript-error-2\/","title":{"rendered":"Admin Javascript Error"},"content":{"rendered":"<p>I&#8217;ve noticed that your plugin enqueues its javascript across the whole admin.<\/p>\n<p>However it requires the acf scripts to run first so on many of the pages it causes an error.<\/p>\n<p>Instead of enqueueing everywhere could you only enqueue with ACF<\/p>\n<p>I believe you could achieve this by changing the follow <\/p>\n<p>classes\/main.php line 9 &#8211; 10<\/p>\n<pre><code>\n\t\tadd_action( &#039;admin_footer&#039;, [ $this, &#039;register_assets&#039; ], 1 );\n\t\tadd_action( &#039;admin_footer&#039;, [ $this, &#039;enqueue_assets&#039; ] );\n<\/code><\/pre>\n<p>to<\/p>\n<pre><code>\n\t\tadd_action( &#039;acf\/enqueue_scripts&#039;, [ $this, &#039;register_assets&#039; ], 1 );\n\t\tadd_action( &#039;acf\/enqueue_scripts&#039;, [ $this, &#039;enqueue_assets&#039; ] );\n<\/code><\/pre>\n","protected":false},"template":"","class_list":["post-13392848","topic","type-topic","status-publish","hentry","topic-tag-script-error"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/13392848","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/13392848\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=13392848"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}