Opened 6 years ago
Last modified 6 years ago
#47419 new defect (bug)
If emojis or embeds JavaScript is not loaded, variable wp is undefined in the front-end.
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | General | Keywords: | |
Focuses: | Cc: |
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:
Note: See
TracTickets for help on using
tickets.
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.