WordPress 3.8 – update plugins prompting for FTP Login

The Problem

After upgrading to WordPress 3.8, trying to update plugins fails with the prompt for FTP login credentials.

The error message reads:

“To perform the requested action, WordPress needs to access to your web server. Please enter your FTP credentials to proceed.?

The solution

After reading many pages about the issue everyone says it is down to security on the file system or the user who owns files on the file system not matching the user running the WordPress site.

So I attempted to edit an existing plugin by changing a version number from 1.3.0 to 1.3.1 and saving the plugin. This saved and the plugin UI updated with the new version number so this proved that security was not the issue.

In my wp-config.php file I have the following defined:

define ('FS_METHOD', 'direct');

This tells WordPress that I wish to force the “direct” method of plugin updates.

The problem is found in .\wp-admin\includes\file.php

The method in question that is causing all the problems is “get_filesystem_method”

I debugged through this method and it gets all the way to the bottom and $method = ‘direct’

The final line of this method is:

return apply_filters('filesystem_method', $method, $args);

I changed this to:

//return apply_filters('filesystem_method', $method, $args);
echo($method . '<br/>');
$method = apply_filters('filesystem_method', $method, $args);
echo($method . '<br/>');
return $method;

When you try to update a plugin you will see the “echo” statements printed out on-screen and it shows that $method is being changed from ‘direct’ to ‘ftpext’, by the apply filters method.

To fix the problem change the return statement of ‘get_filesystem_method’ as follows:

//return apply_filters('filesystem_method', $method, $args);
return $method;

Now you are forcing ‘get_filesystem_method’ to return ‘direct’, and when I attempt an update a plugin it works.