The problem and solution described came about after a friend had issues with her WP installation. To cut a long story short, I had to hard-code FTP details into the wp-config.php file using WordPress Upgrade Constants
.
define('FTP_USER', 'username');
define('FTP_PASS', 'password');
define('FTP_HOST', 'ftp.example.org');
define('FTP_BASE', '/path/to/wordpress/');
define('FTP_CONTENT_DIR', '/path/to/wordpress/wp-content/');
define('FTP_PLUGIN_DIR ', '/path/to/wordpress/wp-content/plugins/');
The second issue that troubled me were the following errors:
Unable to Locate WordPress Plugin DirectoryWarning: array_keys() [function.array-keys]: The first argument should be an array in /home/www/wp-admin/includes/class-wp-upgrader.php on line 189
I search the WordPress Codex for a solution and found this snippet (you should copy to your wp-config.php file (although it's code we won't use: see below).
This will tell WordPress to use the "direct write" method; with create_function as a quick hack. You would then tell WordPress (via defined constants) what permissions to apply to the files and folders it creates.
define( 'FS_CHMOD_DIR', 0777 );
define( 'FS_CHMOD_FILE', 0777 );
However, a quick search of the WordPress Codex found constants that negate the need for any of the above. So, open up config.php and copy the following somewhere near the top of the file.
define( 'FS_METHOD', 'direct' );
define( 'FS_CHMOD_DIR', 0777 );
define( 'FS_CHMOD_FILE', 0777 );
Defining FS_METHOD as"direct" forces WordPress to use Direct File I/O requests from within PHP. The manual sensibly states that this is fraught with opening up security issues on poorly configured hosts. Use with caution.
Common Errors
- Remember, your
wp-contentfolder should be given appropriate permissions. - If the system fails to create an '
upgrade' directory inwp-content, create it manually (as you would with youruploadsdirectory).
