WordPress Automatic Install and Upgrade Errors

My friend and colleague Karlene Petitt is just about to undertake a short ‘WordPress Introduction’ course. She had a list of requirements from her tutor with essential criteria being that the user should be able to apply themes, plugins and core upgrades using the built in WordPress upgrade functionality.

I’ve just installed two default WordPress installations for Karlene and – given that I haven’t used the built in upgrade features extensively before – came across a few errors.

The first issue to trouble me was the fact Karlene isn’t overly tech savvy (sorry, Mrs. P) … and I didn’t want to trouble here with the need to enter FTP host, username and password details every single time she wanted to install any kind of feature. The solution? Hardcode those 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/');

Now, every time Karlene wants to install anything, she can do so via the admin control panel without any FTP entanglements.

The second issue that troubled me were the following errors:

Unable to Locate WordPress Plugin Directory

Warning: 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

The problem code

The problem code

I search the WordPress Codex for a solution and found this code that you would copy into the bottom of your wp-config.php file (although it’s code we won’t use: see below).

if(is_admin()) {
	add_filter('filesystem_method', create_function('$a', 'return "direct";' ));
	define( 'FS_CHMOD_DIR', 0751 );
}

This will tell WordPress to use the “direct write” method; with create_function as a quick hack (that should be expanded upon). 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-content folder should be given appropriate permissions (maybe 0777 if all else fails)
  • If the system fails to create an ‘upgrade‘ directory in wp-content, create it manually (as you would with your uploads directory)
First Name:
Your Email Address:
 


If you liked this article, you may also like:

  1. Form Checking & Displaying Errors
  2. Create a WordPress Gallery from all Images in a Directory (Using TimThumb)
  3. Disabling and Deleting WordPress Post Revisions
  4. Better WordPress Custom Coding – custom functions/css file
  5. Add the WordPress Header and Footer, and Utilise the Features of WP on a non-WordPress Page
About Marty

is a passionate web developer from Sydney, Australia. He owns about 600 websites and makes a healthy living from working the web. As a day job, he works as a pilot for an international airline. Follow Marty on Twitter or Google+.

Please leave a comment or question!

*