What Does this Code Snippet Do?

I got this error message when I was installing a plugin: “Unable to locate WordPress Content directory (wp-content)”.

I found a solution here: http://wordpress.org/support/topic/cannot-find-content-directory-wp-content

Read More

They suggested adding the following code to the wp-config.php file:

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

This solution worked for me. My questions are:

a) What does this code do?

b) If I run into the same error on the production server is it safe to use this code?

Thank you.

-Laxmidi

Related posts

Leave a Reply

2 comments

  1. The first part (add_filter()) tells WordPress to use the direct-write method. The second part (define()) tells WordPress to apply 0751 permissions to any directory it creates. More information here.

    I would not consider using the Direct Write method to be safe to use in a live, public, shared-hosting environment.

    Also, it might not – and in fact probably won’t – work in a shared-hosting environment.

  2. I agree this is a bad idea.Though the permission itself might not be an issue the method is.

    751 is a file system permissions (chmod), it means:

    User: read/write/execute
    Group: read/execute
    All: execute