• Resolved Pramod Jodhani

    (@promz)


    Hi,

    I’m facing this problem:

    Fatal error: Call to undefined function get_current_screen() in /public_html/wp-content/plugins/acf-enhanced-message-field/acf-enhanced-message-v5.php on line 100

    THis is the code I wrote:

    add_action(“wp_head” , “pramod_single_php_logic”);

    function pramod_single_php_logic() {

    if(is_single()) {

    global $post;

    $routing_rules = get_field(“routing_rules” , $post->ID);

    }

    }

    routing_rules is a repeater type parent field.

    https://wordpress.org/plugins/acf-enhanced-message-field/

Viewing 4 replies - 1 through 4 (of 4 total)
  • I too was getting this error then dug into the get_current_screen(); function. See the Usage Restrictions of the Codex:

    Usage Restrictions
    This function is defined on most admin pages, but not all. Thus there are cases where is_admin() will return true, but attempting to call get_current_screen() will result in a fatal error because it is not defined. One known example is wp-admin/customize.php.

    It appears as if the plugin is attempting to run on the front-end of the site when in fact a proper check of is_admin(); should be run. Wrapping the code found in acf-enhanced-message-v5.php with:
    if ( is_admin() ) {}

    Seems to fix this issue. @drebbitsweb should confirm.

    Thread Starter Pramod Jodhani

    (@promz)

    Thanks Pence. I will try your suggestion and let you know if it works.

    Plugin Author Dreb Bitanghol

    (@drebbitsweb)

    Hey Guys,

    I’ve pushed a fix on this. Kindly update your copy of the plugin and let me know how it goes 😉

    Best,
    Dreb

    My apologies for not responding sooner on this – your update fixed this issue! Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Fatal error: Call to undefined function get_current_screen()’ is closed to new replies.