Make WordPress Core

Opened 5 years ago

Last modified 5 years ago

#47419 new defect (bug)

If emojis or embeds JavaScript is not loaded, variable wp is undefined in the front-end.

Reported by: shelob9's profile Shelob9 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:


In my plugin I am using wp.createElement in the front-end and using wp_enqueue_scripts( 'wp-element' ) to load it. If emojis are disabled, the error "uncaught reference error, variable wp not defined" happens when trying to access wp.createElement.

I could be wrong, but I think the problem is that if emojis are disabled, this line, which sets up the wp variable does not run.

Related bugs:

Change History (1)

#1 @swissspidy
5 years ago

One should always use window.wp = window.wp || {}; when working with global variables like that in a plugin. Not sure if we can add this in core by default as an inline script or something.

Note: See TracTickets for help on using tickets.