Fatal error with get_current_screen() call
-
Using WordPress 4.9.5, WooCommerce 3.2.4 and Gift Cards for WooCommerce 2.6.1.
I am getting the following fatal error when not logged in:
[22-Apr-2018 11:48:43 UTC] PHP Fatal error: Uncaught Error: Call to undefined function get_current_screen() in /wp-content/plugins/gift-cards-for-woocommerce/includes/post-type.php:219
Stack trace:
#0 /wp-includes/class-wp-hook.php(288): cf_search_where(‘ AND wp_posts.I…’)
#1 /wp-includes/plugin.php(244): WP_Hook->apply_filters(‘ AND wp_posts.I…’, Array)
#2 /wp-includes/class-wp-query.php(2376): apply_filters_ref_array(‘posts_where’, Array)
#3 /wp-includes/class-wp-query.php(3230): WP_Query->get_posts()
#4 /wp-includes/class-wp.php(599): WP_Query->query(Array)
#5 /wp-includes/class-wp.php(715): WP->query_posts()
#6 /wp-includes/functions.php(960): WP->main(”)
#7 /wp-blog-header.php(16): wp()
#8 /index.php(17): require(‘/….’)
#9 in /wp-content/plugins/gift-cards-for-woocommerce/includes/post-type.php on line 219For the ‘enter_title_here’ filter you use the same login (get_current_screen and check screen->post_type).
For that function I found a method that does not use get_current_screen():
https://wordpress.stackexchange.com/a/13004/57684I went through each function that calls get_current_screen() and changed the code to no longer use that function but use get_post_type() instead. Here is a patch:
https://pastebin.com/jQkYWcv2I no longer get the fatal error but I have not done much testing.
- The topic ‘Fatal error with get_current_screen() call’ is closed to new replies.