{"id":19004503,"date":"2026-08-27T12:02:56","date_gmt":"2026-08-27T12:02:56","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/fatal-error-undefined-get_current_screen-in-settingspage-php-line-64\/"},"modified":"2026-08-27T12:02:56","modified_gmt":"2026-08-27T12:02:56","slug":"fatal-error-undefined-get_current_screen-in-settingspage-php-line-64","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/fatal-error-undefined-get_current_screen-in-settingspage-php-line-64\/","title":{"rendered":"Fatal error &#8211; undefined get_current_screen() in SettingsPage.php line 64"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Hello,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">YayMail fatals on any front-end page that calls wp_editor().<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The fix is an is_admin() or function_exists(&#8216;get_current_screen&#8217;) 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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Environment:<br \/>YayMail [FILL IN], WordPress [FILL IN], WooCommerce [FILL IN], PHP [FILL IN], Apache with PHP-FPM.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thanks,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Elliot<\/p>\n","protected":false},"template":"","class_list":["post-19004503","topic","type-topic","status-publish","hentry","topic-tag-fatal-error"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/19004503","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/19004503\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=19004503"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}