After update from WP 5.0.2 to 5.0.3 I had issues in wp-admin. I couldn't edit post data. There was JS error "Uncaught SyntaxError: missing ) after argument list", undefined "_" (lodash) etc.
3 Answers
The issue for me was the clean_script_tag()
function from Soil.
Removing add_filter('script_loader_tag', 'clean_script_tag');
solved the bug for me.
-
1Or wrap it in
if (!is_admin())
to still benefit from it on the front-end. Commented Oct 1, 2019 at 2:51
I found that:
<script type='text/javascript'>( 'fetch' in window ) || document.write( '<script src="http://website.com/wp-includes/js/dist/vendor/wp-polyfill-fetch.min.js?ver=3.0.0' defer "></scr' + 'ipt>' ); ...</script>
Note: wp-polyfill-fetch.min.js?ver=3.0.0 ' defer " >
The problem was in the PHP hook added defer to script, like here: How to add defer="defer" tag in plugin javascripts?
Reason: Confusion/conflict with quotes (' & ") witch break down JS.
The solve: Delete/disable the adding 'defer' PHP-hook or add some conditions for don't touch Gutenberg scripts.
More detals here: https://github.com/WordPress/gutenberg/issues/13029
-
I don't see an answer anywhere in this post. Yes, the problem is traceable to incorrect quotes, but how do you fix it? Commented Feb 4, 2019 at 23:44
-
@IvanDurst Just disable this adding 'defer' PHP code (the easy way) or add conditions by Guttenberg file names or to add 'defer' for not all <script>. More info you can get by links in the answer. Note: you can easily delete 'defer'-code because it's just optimization stuff. Commented Feb 5, 2019 at 10:12
-
thanks for updating, that makes sense, I'll give it a try! Commented Feb 5, 2019 at 22:27
The problem is due to WordPress Gutenberg’s some js which doesn’t support defer. I had the same problem, I have added a WordPress hook to defer js. I have added a condition now that the hook will not call on admin pages and it fixed my issue.
Just go to the Function.php of your theme and find the below code and replace it with a new one.
OLD code:
add_filter( ‘clean_url’, ‘defer_parsing_of_js’, 11, 1 );
New code:
if ( !is_admin() ) {
add_filter( ‘clean_url’, ‘defer_parsing_of_js’, 11, 1 );
}
after this code, it is not adding defer to admin side scripts and yes it will work 200%.