Мне нужно добавить некоторую проверку ошибок в эту функцию, чтобы убедиться, что функции imagegif() и imagecolorset() успешны. Обычной причиной сбоя является проблема с разрешениями, при которой файл spot2.gif недоступен для записи.Помогите добавить проверку ошибок на эту функцию
Однако, когда я изменяю spot2.gif только для чтения, условие, которое должно вызывать условия «else», предупреждение echo'd javascript не срабатывает.
function set_theme_color_spot2($hex)
{
$info = hexToRGB($hex);
$token = "../wp-content/themes/".get_option('template')."/styles/".get_option('myTheme')."/spot2.gif";
$token2 = "../wp-content/themes/".get_option('template')."/styles/".get_option('myTheme')."/spot2-template.gif";
if (file_exists($token2) && is_writable($token))
{
$img = imagecreatefromgif("../wp-content/themes/".get_option('template')."/styles/".get_option('myTheme')."/spot2-template.gif");
$color = imagecolorallocate($img, $info["red"], $info["green"], $info["blue"]);
imagecolorset($img, 0, $info["red"], $info["green"], $info["blue"]);
imagegif($img, $token);
$themecolor = get_option('myTheme').'_color4';
update_option($themecolor, $hex);
}
else
{
echo "<script type='text/javascript'>alert('The template colors could not be changed because your current file permissions are too restrictive. Make sure the files in the styles directory are set to 644');</script>";
}
}
Это имеет смысл для меня. Я обновил свой вопрос и добавил проверку is_writable в условном блоке. Тем не менее, его все еще выполняется, даже когда spot2.gif настроено вручную только для чтения ... Любые идеи? –