Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add availability checks to widget related code (#15983)
This commit adds availability checks for the function get_current_screen and for the globals wp_widget_factory, wp_registered_widgets. The function get_current_screen should only be called in admin pages, but according to the docs, we may have admin pages without the function so I think a check should be added. For example, I guess it may be possible to have an admin page with admin_footer but without the function defined. Regarding the globals wp_widget_factory, wp_registered_widgets used in gutenberg_get_legacy_widget_settings function, the function is called as part of the filter block_editor_settings, I guess the filter may be executed in a situation where the widget globals are not initialized e.g: in a custom plugin page with a custom block editor. I think it is better to check the availability of the globals. If the globals are not available we will not pass available legacy widgets to the front end.
- Loading branch information