Uncaught ReferenceError: wp is not defined in admin/static/js/script.js and featured-image.js on admin screens without wp-* scripts
Title: Uncaught ReferenceError: wp is not defined in admin/static/js/script.js and featured-image.js on admin screens without wp-* scripts
- Version: 2.8.23 (WP 7.0.4)
-
Brizy_Admin_Main::action_register_static()enqueuesadmin/static/js/script.jsandadmin/static/js/featured-image.json every admin screen with onlyjqueryandunderscoreas dependencies. Both access the globalwpwithout checking it exists:
script.js → BrizyGutenberg.init(): if (typeof wp.data != 'undefined')featured-image.js: if (wp.hooks && wp.hooks.addFilter)- On admin screens that load no
wp-*script,wpis undefined, so both throw. BecauseBrizyGutenberg.init()throws first,BrizyClassicEditor,BrizyFeedbackDialog,BrizyMaintenanceandDemoImportnever initialise on those screens. - Suggested fix:
typeof wp !== 'undefined' && ... (also wp.autosave in script.js).Enqueue
featured-image.js only through enqueue_block_editor_assets, with deps wp-hooks, wp-element, wp-data.
0
-
Hello Shelomo,
Thank you for sharing the error details. To help us better understand and investigate the issue, could you please provide a little more context about when and where the error occurs?
- The URL of the webpage where you are seeing the error.
- Do you see the error on the website frontend, or in Chrome DevTools?
- What steps should we follow to reproduce the error?
This information will help us reproduce the issue on our side, identify the underlying cause, and determine the best way to resolve it.
0
Please sign in to leave a comment.
Comments
1 comment