Wordpress post editor crashes with Polyfill typo

When trying to edit a wordpress post (page) the editor loads indefinitely, console shows JS error with post.phppolyfi

When trying to edit a wordpress post (page) the editor loads indefinitely, console shows JS error with post.php / polyfill, see code below. To me it seems to be a typo and I have no idea where the line is injected so I could change it manually.

Disabling all plugins did not change anything, neither did disabling Gutenberg. I am not much of a coder, nevertheless it seems to me there should not be a double quotation mark after the last 'defer"... in the line of code.

I am running WP 5.0.2 on Apache (Domainfactory) in a managed server environment, Theme is Enfold by Kriesi. Re-installing Wordpress and the theme (copied from working installations) changed nothing so far.

The reported error in the console is "Uncaught SyntaxError: missing ) after argument list" in https://.../wp-admin/post.php?post=23&action=edit&lang=de&classic-editor=1:238

There it says

( 'fetch' in window ) || document.write( '<script src=".min.js?ver=3.0.0' defer='defer"></scr' + 'ipt>' );( document.contains ) || document.write( '<script src=".min.js?ver=3.26.0-0' defer='defer"></scr' + 'ipt>' );( window.FormData && window.FormData.prototype.keys ) || document.write( '<script src=".min.js?ver=3.0.12' defer='defer"></scr' + 'ipt>' );( Element.prototype.matches && Element.prototype.closest ) || document.write( '<script src=".min.js?ver=2.0.2' defer='defer"></scr' + 'ipt>' );

Any idea would be much appreciated.

When trying to edit a wordpress post (page) the editor loads indefinitely, console shows JS error with post.php / polyfill, see code below. To me it seems to be a typo and I have no idea where the line is injected so I could change it manually.

Disabling all plugins did not change anything, neither did disabling Gutenberg. I am not much of a coder, nevertheless it seems to me there should not be a double quotation mark after the last 'defer"... in the line of code.

I am running WP 5.0.2 on Apache (Domainfactory) in a managed server environment, Theme is Enfold by Kriesi. Re-installing Wordpress and the theme (copied from working installations) changed nothing so far.

The reported error in the console is "Uncaught SyntaxError: missing ) after argument list" in https://.../wp-admin/post.php?post=23&action=edit&lang=de&classic-editor=1:238

There it says

( 'fetch' in window ) || document.write( '<script src="https://12345678-123.ch/wp-includes/js/dist/vendor/wp-polyfill-fetch.min.js?ver=3.0.0' defer='defer"></scr' + 'ipt>' );( document.contains ) || document.write( '<script src="https://12345678-123.ch/wp-includes/js/dist/vendor/wp-polyfill-node-contains.min.js?ver=3.26.0-0' defer='defer"></scr' + 'ipt>' );( window.FormData && window.FormData.prototype.keys ) || document.write( '<script src="https://12345678-123.ch/wp-includes/js/dist/vendor/wp-polyfill-formdata.min.js?ver=3.0.12' defer='defer"></scr' + 'ipt>' );( Element.prototype.matches && Element.prototype.closest ) || document.write( '<script src="https://12345678-123.ch/wp-includes/js/dist/vendor/wp-polyfill-element-closest.min.js?ver=2.0.2' defer='defer"></scr' + 'ipt>' );

Any idea would be much appreciated.

Share Improve this question edited Jan 5, 2019 at 8:27 fuxia 107k39 gold badges255 silver badges459 bronze badges asked Jan 4, 2019 at 15:01 AmanahumpaAmanahumpa 231 silver badge6 bronze badges 7
  • ask at: s.tk/wp – T.Todua Commented Jan 4, 2019 at 15:12
  • I am sorry. What does that mean? – Amanahumpa Commented Jan 4, 2019 at 15:14
  • Thank you for editing and prividing a real resource. Your link sends me to the WP Core bug tracker and there it says it has to be a WP core bug, which is unsure. Moreover I can not wait for the next wordpress update to edit the existing pages I hope to get direction and inspiration here. To file a ticket is another step in the process. Please allow me to get help here. – Amanahumpa Commented Jan 4, 2019 at 15:34
  • Did you try changing themes? Not just disabling plugins but also changing the theme? If that solves the issue, then you know it's the theme. – disinfor Commented Jan 4, 2019 at 15:37
  • Yes, I did. When using a standard theme and standard editor it works but is of no use since it depends on the integrated page builder ('advanced layout editor'). Dev of the theme has no reports on that so far. I am using the exact same combo of WP / theme / Hoster on other projects. No probs there... :-/ My hope is a workaround until the dev teams can react to that. – Amanahumpa Commented Jan 4, 2019 at 15:46
 |  Show 2 more comments

3 Answers 3

Reset to default 1

Here is an answer: WordPress v5.0.3 Gutenberg & JS error "Uncaught SyntaxError: missing ) after argument list"

The simplest way: Find & delete PHP Hook which added 'defer' to script (in the function.php file). Or if you have skills you can edit the code of the hook. Reason: Confusion/conflict with quotes (' & ") witch break down JS.

About 'defer' you can read here: https://www.w3schools/tags/att_script_defer.asp This is probably due to speed optimization on your website.

OK, so I struggled to find an answer myself to this - but this worked for me. I was stripping out the type='text/javascript' on script tags because it's not required for valid HTML5 - but WordPress insists on including it when you enqueue_script. I had a function in my theme like below to deal with this - so I just stopped it running in admin and it removed the error - your mileage may vary but maybe check your theme or plugins for something similar ;)

/**
 *
 * WordPress insists on inserting invalid javascript script tag definitions when enqueuing
 * This removes this cruft - to check in the future - will WordPress get patched to support this?
 *
 */
add_filter( 'script_loader_tag', 'mywfx_html5_clean_js_tags' );
function mywfx_html5_clean_js_tags( $input ) {

 if ( !is_admin() ) {

    $input = str_replace( "type='text/javascript' ", '', $input );
    return str_replace( "'", '"', $input );

 } else {

    return $input;

 }

}

Maybe the lesson to be learnt from injected code is: Check all potencial sources of code injection.

It turned out there was code put in the child themes' functions.php. At the time the question was asked it was as "unnessessary" to look for the problem there as it was dumb not to do that.

I am sorry and grateful for the help provided. Thank you.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745641765a4637734.html

相关推荐

  • Wordpress post editor crashes with Polyfill typo

    When trying to edit a wordpress post (page) the editor loads indefinitely, console shows JS error with post.phppolyfi

    6小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信