Support » Plugin: CMP - Coming Soon & Maintenance Plugin by NiteoThemes » Fatal error on niteo-cmp.php

  • Resolved wvega

    (@wvega)


    Hi there,

    I found a website affected by the following error:

    Fatal error: Call to undefined function get_current_screen() in wp-content/plugins/cmp-coming-soon-maintenance/niteo-cmp.php on line 584.

    The error is triggered on a frontend page that receives a POST request.

    It seems to me that the code from cmp_admin_bar() should only be executed on admin pages or more specifically, only if ‘get_current_screen()’ is defined at that point (the documentation says the function won’t be defined on wp-admin/customize.php).

    As a workaround I added the following at the top of the cmp_admin_bar() function.

    if ( ! function_exists( ‘get_current_screen’ ) ) {
    return;
    }

    Please let me know if there is a more appropriate way to avoid this problem.

    • This topic was modified 1 year, 7 months ago by wvega. Reason: Missing connector
    • This topic was modified 1 year, 7 months ago by wvega. Reason: Added missing ! on if condition
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author NiteoThemes

    (@niteo)

    Hi @wvega, nice catch indeed! Your solution is effective solution for the issue.

    Meanwhile I rewrote the plugin code and used a little bit different approach which should mitigate the issue as well. So feel free to update CMP plugin anytime it gets udpated 🙂

    Alex

    Hello Alex,
    I use the latest version 2.8.4 and I also have error messages in the niteo-cmp.php and cmp-settings.php
    What could be the cause here?
    I turned off all plugins.
    My Wordtpress Version 4.9.8 with Avada Theme.

    Warning: array_map() [function.array-map]: Argument #2 should be an array in /home/…/wp-content/plugins/cmp-coming-soon-maintenance/niteo-cmp.php on line 198

    Warning: in_array() expects parameter 2 to be array, null given in /home/…/wp-content/plugins/cmp-coming-soon-maintenance/niteo-cmp.php on line 800 and 789

    Warning: array_map() [function.array-map]: Argument #2 should be an array in /home/…/wp-content/plugins/cmp-coming-soon-maintenance/niteo-cmp.php on line 198 and 208

    Warning: array_search() expects parameter 2 to be array, null given in /home/…/wp-content/plugins/cmp-coming-soon-maintenance/cmp-settings.php on line 540

    Warning: Invalid argument supplied for foreach() in /home/…/wp-content/plugins/cmp-coming-soon-maintenance/cmp-settings.php on line 553

    Best regards
    Dan

    • This reply was modified 1 year, 6 months ago by webboxone.
    Plugin Author NiteoThemes

    (@niteo)

    Hello @webboxone – Dan, those PHP warnings are caused by different behaviour of your PHP version – technically CMP expects to have empty array if no premium themes are installed but null was given in your case.

    I made a small changes and will release update 2.8.5 soon, which should resolve those warnings!

    thanks Alex

    Great, many thanks.
    Best regards Dan

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Fatal error on niteo-cmp.php’ is closed to new replies.