Support » Plugin: Pods - Custom Content Types and Fields » Problem with get_current_screen()

  • Resolved therealgilles

    (@chamois_blanc)



    Hello,

    I think there is an issue with the code when doing ajax requests. I got a PHP error saying get_current_screen() was undefined.

    [19-May-2018 19:54:50 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function get_current_screen() in .../public_html/wp-content/plugins/pods/classes/PodsInit.php:347
    Stack trace: 
    #0 .../public_html/wp-includes/class-wp-hook.php(286): PodsInit->register_assets('')
    #1 .../public_html/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)
    #2 .../public_html/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
    #3 .../public_html/wp-login.php(103): do_action('login_enqueue_s...')
    #4 .../public_html/wp-login.php(1011): login_header('Log In', '', Object(WP_Error))
    #5 .../public_html/wp-content/plugins/login-with-ajax/login-with-ajax.php(234): include_once('/home/89942.clo...')
    #6 .../public_html/wp-content/plugins/login-with-ajax/login-with in .../public_html/wp-content/plugins/pods/classes/PodsInit.php on line 347

    I am thinking it has to do with this code:

        if ( is_admin() ) {
          $screen = get_current_screen();

    which appears twice in plugins/pods/classes/PodsInit.php. Maybe it should be replaced with:

        if ( is_admin() && !wp_doing_ajax() ) {
          $screen = get_current_screen();
Viewing 3 replies - 1 through 3 (of 3 total)
  • therealgilles

    (@chamois_blanc)

    Or this code would probably be better:

    if ( is_admin() && function_exists('get_current_screen') ) {
          $screen = get_current_screen();
    therealgilles

    (@chamois_blanc)

    Plugin Author Jim True

    (@jimtrue)

    @therealgilles Can you add your additional information above (not just the fix, but where and how you’re getting the error, to that bug report? I’m closing this forum post because this really should be in our GitHub Bug Report and not in the Support Forums as we don’t work bugs to resolution here.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.