wordpress – plesk error Call to undefined function is_admin()

In the Plesk under the subscription we are seeing the following error and we can not apply the Plesk security settings. 

Error: PHP Fatal error: Call to undefined function is_admin() in /usr/share/plesk-wp-cli/php/wp-cli.php(18) : eval()’d code on line 87

Parallels identifies this in a KB article:

 http://kb.sp.parallels.com/en/123569

They say:

Cause:

Modified wp-config.php file inside a WordPress installation document root. Function is_admin() could be handled properly while it evaluated from CLI.

Resolution

Either remove his function from the wp-config.php or modify it, as it shown on example below:

if(function_exists(‘is_admin’))

We compared the config against another new installation and removed the following lines from it.

============================================================

if(is_admin()) {

    add_filter(‘filesystem_method’, create_function(‘$a’, ‘return “direct”;’ ));

    define( ‘FS_CHMOD_DIR’, 0751 );

}

if(is_admin()) {

    add_filter(‘filesystem_method’, create_function(‘$a’, ‘return “ftpext”;’ ));

    define( ‘FS_CHMOD_DIR’, 0755 );

}

============================================================

Then in the subscriptions control panel we clicked the Plesk to refresh button for WordPress security scan and all appears to be fine now.

Posted in centos, plesk, wordpress.