• Resolved nikitabasenko

    (@nikitabasenko)


    Hi, everyone.

    So, today accidentally found an error on my WP site.
    I have a few tricks to hide the admin login-page, but before that (i think a few updates of WP) there were no problem. If non-admin user was trying to enter to /wp-admin he got 404 error.

    Today while trying to check if it’s working i got next error:

    Fatal error: Call to undefined function get_current_screen() in /www/wp-content/plugins/wordpress-seo/inc/wpseo-non-ajax-functions.php on line 467

    Didn’t find any solutions on web. I mean, i got a few, but didn’t work.

    So, if anybody has some thoughts – please welcome.

    thx in advance.

Viewing 13 replies - 1 through 13 (of 13 total)
  • Moderator t-p

    (@t-p)

    Your “wordpress-seo” plugin seems to be the error.

    Delete this plugin using FTP , or your web-host’s cPanel or whatever file management application your host provides (no Dashboard access required).

    Hi, @nikitabasenko. The WordPress function get_current_screen is defined in its /wp-admin/includes/screen.php file — so I suggest accessing the files on your server via FTP, and verifying that that particular file does indeed exist there (if not, you’ll want to upload it again).

    Thread Starter nikitabasenko

    (@nikitabasenko)

    Tara

    Your “wordpress-seo” plugin seems to be the error

    I don’t have such plugin ??

    girlieworks –

    and verifying that that particular file does indeed exist there

    The thing is, that there were not error before. It’s maybe after a few last updates of WP during a month. Cause i only added content, not any kind of plugins etc.

    Thread Starter nikitabasenko

    (@nikitabasenko)

    Ok, anyway i found the desicion here – support topic link

    So, the key is.
    On line 466 in file /wp-content/plugins/wordpress-seo/inc/wpseo-non-ajax-functions.php right before

    $screen = get_current_screen();

    i’ve added next line:

    require_once(ABSPATH . ‘wp-admin/includes/screen.php’);

    And the error have gone.

    I think you Problem will get Solved

    Simple add this line in themes functions.php file

    
    add_action( 'init', 'Harimay_init_callback', 10001 );
    function Harimay_init_callback(){
    	if( ! function_exists( get_current_screen ) ){
    		function get_current_screen() {
    			global $current_screen;
    
    			if ( ! isset( $current_screen ) )
    				return null;
    
    			return $current_screen;
    		}
    	}
    }
    
    

    This is not an perfect way but can solved you problem

    Thread Starter nikitabasenko

    (@nikitabasenko)

    @harimay, what do you about my desicion? – is it so bad?

    Moderator t-p

    (@t-p)

    @nikitabasenko,

    Glad to know you got it sorted ??

    You may also want to bring this issue to the attention of the author of /wp-content/plugins/wordpress-seo/ so that they can take appropriate action.

    Where did you download it from?

    Thread Starter nikitabasenko

    (@nikitabasenko)

    Where did you download it from?

    It’s yoast SEO plugin. Got it from WP-plugins (as ussial – admin console installation).

    Sent them a letter.

    I can confirm that adding require_once(ABSPATH . 'wp-admin/includes/screen.php'); does fix the issue.

    @harimay The solution as posted is correct and involves the plugin author. You solution is not correct as it will be overwritten the next time the theme is updated.

    Both are correct because in my code
    I am checking is function exists or not

    If it exists then my code will not going to run

    So there can’t be any clash or fatal error with the WP or any other plugin

    @harimay. Did you read and understand what I wrote about being overwritten?

    Yup
    Sorry I did not ready that propely

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Fatal error get_current_screen’ is closed to new replies.