Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught TypeError: Cannot read property 'secret' of null wp-embed.min.js

Tags:

wordpress

There is an error at my console showing Uncaught TypeError: Cannot read property 'secret' of null at a.wp.receiveEmbedMessage (wp-embed.min.js?x59911:1)

Is there a way to fix this?

like image 311
iamsushi_j12n Avatar asked Aug 17 '18 10:08

iamsushi_j12n


2 Answers

Issue is with Wordpress wp-embed.js . Change following following code/

if ( ! ( data.secret || data.message || data.value ) ) {

to

if ( ! data || ! ( data.secret || data.message || data.value ) ) {

On line 32. It should solve the issue. Refrence : https://core.trac.wordpress.org/ticket/44832

like image 115
webmatrix Avatar answered Sep 18 '22 18:09

webmatrix


The issue ticket (also linked by Webmatrix) suggests the following code for wp-embed.js (starting line 31).

if ( data && ! ( data.secret || data.message || data.value ) ) {
    return;
}

But changing that won't matter, since the wp-embed.min.js file is the one actually used. - And since it's all on one line, it's a little harder to find the right place.

Search for the string d.secret|| to find the right part and then replace that condition check with if(d && !(d.secret||d.message||d.value)).

I had the same issue and doing this fixed it for me, while webmatrix's code (minified) if ( !d||!(d.secret||d.message||d.value) ) didn't work for my problem.

This suggests that in my case data is in fact being passed, it just doesn't have the value that I want. Maybe there's also a problem of sometimes no data being passed at all in which case you should still add his !data || at the very beginning of my conditional, like so: if(!d||d && !(d.secret||d.message||d.value)).


Note

However, note you shouldn't be editing core files usually - because it could vanish on the next update - in this situation though, the next update is very likely to contain the same or a better fix, so if it's overwritten it shouldn't matter.

like image 30
Julix Avatar answered Sep 20 '22 18:09

Julix