_wpMediaViewsL10n not correctly enqueued in wp_enqueue_media()
|Reported by:||Fab1en||Owned by:|
In the wp_enqueue_media function, wp_localize_script( 'media-views', '_wpMediaViewsL10n', $strings ); is called before wp_enqueue_script( 'media-editor' ); (which is dependent on media-views script), so there is a risk that _wpMediaViewsL10n is not taken into account if media-views script has not been enqueued before.
If wp_enqueue_media() is called on the front-end with the admin-bar deactivated, you will have a js error saying Cannot read property 'id' of undefined when trying to read wp.media.view.settings.post.id.
This issue can be solved by placing the wp_localize_script call just after wp_enqueue_script( 'media-editor' ).