Title: Call to undefined function called get_current_screen
Last modified: September 16, 2020

---

# Call to undefined function called get_current_screen

 *  [e4jvikwp](https://wordpress.org/support/users/e4jvikwp/)
 * (@e4jvikwp)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/call-to-undefined-function-called-get_current_screen/)
 * Hi Staff,
 * I’m a developer of VikWP company and I’m reaching you to report an issue that
   occurs with almost all our plugins.
 * Sometimes our plugins need to instantiate an editor within the “init” hook, where
   the `get_current_screen` function is not yet available. Here’s the code that’s
   causing the issue:
 *     ```
       // @file class-editor.php
       public function is_post_editor_page() {
           if ( ! is_admin() ) {
               return false;
           }
   
           $screen = get_current_screen();
   
           return $screen->parent_base === 'edit';
       }
       ```
   
 * Since the `get_current_screen` function doesn’t exist yet, we strongly suggest
   you to check that before using it. The example below should be able to fix the
   reported issue:
 *     ```
       public function is_post_editor_page() {
           if ( ! is_admin() ) {
               return false;
           }
       ​
           /**
            * Check whether the get_current_screen function exists
            * because it is loaded only after 'admin_init' hook.
            */
           if ( ! function_exists( 'get_current_screen' ) ) {
               return false;
           }
       ​
           $screen = get_current_screen();
       ​
           /**
            * Since the screen might not have been set, we should check
            * whether it returned NULL, in order to avoid displaying
            * a 'Trying to get property of non-object' notice.
            */
           return $screen !== null && $screen->parent_base === 'edit';
       }
       ```
   
 * We would appreciate if you could enhance the way you check whether the user is
   currently located on the post editor page, so that our plugins won’t face that
   issue anymore.
    -  This topic was modified 5 years, 8 months ago by [e4jvikwp](https://wordpress.org/support/users/e4jvikwp/).
    -  This topic was modified 5 years, 8 months ago by [e4jvikwp](https://wordpress.org/support/users/e4jvikwp/).

Viewing 1 replies (of 1 total)

 *  Plugin Support [Ethan Choi](https://wordpress.org/support/users/ethanchoi/)
 * (@ethanchoi)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/call-to-undefined-function-called-get_current_screen/#post-13423591)
 * Hey [@e4jvikwp](https://wordpress.org/support/users/e4jvikwp/),
 * Thanks for reaching out!
 * Our development team has reviewed your suggestion, and this fix will be included
   in the next plugin release.
 * Thank you 🙂
    -  This reply was modified 5 years, 8 months ago by [Ethan Choi](https://wordpress.org/support/users/ethanchoi/).

Viewing 1 replies (of 1 total)

The topic ‘Call to undefined function called get_current_screen’ is closed to new
replies.

 * ![](https://ps.w.org/wpforms-lite/assets/icon.svg?rev=3254748)
 * [WPForms - Easy Form Builder for WordPress - Contact Forms, Payment Forms, Surveys, & More](https://wordpress.org/plugins/wpforms-lite/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wpforms-lite/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wpforms-lite/)
 * [Active Topics](https://wordpress.org/support/plugin/wpforms-lite/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wpforms-lite/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wpforms-lite/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Ethan Choi](https://wordpress.org/support/users/ethanchoi/)
 * Last activity: [5 years, 8 months ago](https://wordpress.org/support/topic/call-to-undefined-function-called-get_current_screen/#post-13423591)
 * Status: not a support question