Fatal error – undefined get_current_screen() in SettingsPage.php line 64
-
Hello,
YayMail fatals on any front-end page that calls wp_editor().
PHP Fatal error: Uncaught Error: Call to undefined function YayMail\Engine\Backend\get_current_screen() in /wp-content/plugins/yaymail/src/Engine/Backend/SettingsPage.php:64
SettingsPage::register_wp_editor_plugins_script() is hooked into the TinyMCE filter chain applied by _WP_Editors::editor_settings(). That chain runs on every wp_editor() call, including front-end ones. get_current_screen() only exists in wp-admin, so the callback fatals.
On our site this is triggered by Asgaros Forum, which renders a reply editor on the front end. Every forum page returns a 500 for logged-in users and guests. Any plugin calling wp_editor() outside the admin will hit the same problem.
The fix is an is_admin() or function_exists(‘get_current_screen’) guard at the top of the method. The TinyMCE additions are only needed for the email template builder, so returning early on the front end costs nothing.
Environment:
YayMail [FILL IN], WordPress [FILL IN], WooCommerce [FILL IN], PHP [FILL IN], Apache with PHP-FPM.We have a temporary must-use plugin removing your editor hooks on the front end, but would like to drop it once this is patched. Happy to test a fix on staging.
Thanks,
Elliot
You must be logged in to reply to this topic.