Make WordPress Core

Opened 7 years ago

Last modified 7 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 Owned by:
Priority: normal Milestone: Awaiting Review
Component: General Version:
Severity: normal Keywords:
Cc: Focuses:

Description

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.

​https://github.com/WordPress/WordPress/blob/master/wp-includes/js/wp-emoji.js#L290-L295

Related bugs:

Change History (1)

#1 @swissspidy
7 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.