I've a theme which supports multiple templates, each with a header background image whose color can be set by the site owner via a colorpicker widget in my theme's options panel. This has the effect of opening the background image, recoloring it and resaving it back to the server.
I've had zero issues with this routine until recently when a customer installed the theme on a web host whose default read/write permissions are apparently much more restrictive than the norm. In this case, the user was unabl开发者_运维技巧e to alter the colors of the template images because of the permissions settings.
I'm looking for a bit of understanding on what the permissions would need to be (assuming I purposefully set them via script) to allow the logged in wordpress user to write to files under my theme's styles directory.
The code I'm using to write to the image file is below...
$img = imagecreatefromgif("../wp-content/themes/mytheme/styles/".get_option('my_theme')."/image.gif");
$color = imagecolorallocate($img, $info["red"], $info["green"], $info["blue"]);
imagecolorset($img, 0, $info["red"], $info["green"], $info["blue"]);
imagegif($img, $path);
What I have done in the past (and what I have seen people instruct other to do for autoupdate / wordpress file management) was to chown apache-user.apache-user folder/
This way you give the apache user (that is running apache for instance) access to the wordpress files, keep them at whatever permissions you want (read/write/exec).
Give that a try.
(of course replace apache-user
with the proper user, ex: www-data
)
精彩评论