Support Forum
The file field validation does not work, and the filed does not remember its file if it is a customizer setting
$fields[] = [
'title' => __('Favicons', NAME_SPACE),
'id' => PREFIX . 'favicon',
'settings_pages' => [PREFIX . 'favicon'],
// 'option_name' => 'theme_mods_' . NAME_SPACE,
// 'panel' => '',
'fields' => [
[
'id' => PREFIX . 'favicon',
'name' => __('ICO-Favicon', NAME_SPACE),
'type' => 'file',
'force_delete' => true,
'max_file_uploads' => 1,
'upload_dir' => ABSPATH . $symlink,
'unique_filename_callback' => '\ModernFavicon\ModernFavicon::favicon_filename',
'desc' => __('Die .ico Datei sollte PNG-Bilder in den Größen <code>16 x 16, 32 x 32, und 48 x 48</code> bereitstellen.'),
'label_description' => __('Für Safari (Desktop)')
],
[
'id' => PREFIX . 'apple-touch-icon',
'name' => __('Apple-Touch Icon', NAME_SPACE),
'type' => 'file',
'force_delete' => true,
'max_file_uploads' => 1,
'upload_dir' => ABSPATH . $symlink,
'unique_filename_callback' => '\ModernFavicon\ModernFavicon::touchicon_filename',
'desc' => __('Das PNG-Bild sollte <code>180 x 180</code> Pixel groß sein.'),
'label_description' => __('Für iPhones ud iPads')
],
[
'id' => PREFIX . 'manifest_512',
'name' => __('Manifest PNG – 512px', NAME_SPACE),
'type' => 'file',
'force_delete' => true,
'max_file_uploads' => 1,
'upload_dir' => ABSPATH . $symlink,
'unique_filename_callback' => '\ModernFavicon\ModernFavicon::manifest512_filename',
'desc' => __('Das PNG-Bild sollte <code>512 x 512</code> Pixel groß sein.'),
'label_description' => __('Für Android-Geräte')
],
[
'id' => PREFIX . 'manifest_192',
'name' => __('Manifest PNG – 192px', NAME_SPACE),
'type' => 'file',
'force_delete' => true,
'max_file_uploads' => 1,
'upload_dir' => ABSPATH . $symlink,
'unique_filename_callback' => '\ModernFavicon\ModernFavicon::manifest192_filename',
'desc' => __('Das PNG-Bild sollte <code>192 x 192</code> Pixel groß sein.'),
'label_description' => __('Für Android-Geräte')
],
[
'id' => PREFIX . 'svg_icon',
'name' => __('SVG Site-Icon', NAME_SPACE),
'type' => 'file',
'force_delete' => true,
'max_file_uploads' => 1,
'upload_dir' => ABSPATH . $symlink,
'unique_filename_callback' => '\ModernFavicon\ModernFavicon::svgicon_filename',
'desc' => __('Das Seitenverhältnis der SVG-Grafik sollte quadratisch sein.'),
'label_description' => __('Für alle anderen Browser')
],
],
'validation' => [
'rules' => [
PREFIX . 'favicon' => [
'accept' => ['image/vnd.microsoft.icon', 'image/x-icon'],
'extension' => 'ico'
],
PREFIX . 'apple-touch-icon' => [
'accept' => ['image/png'],
'extension' => 'png'
],
PREFIX . 'manifest' => [
'accept' => ['image/png'],
'extension' => 'png'
],
PREFIX . 'svg_icon' => [
'accept' => ['image/svg+xml'],
'extension' => 'svg'
],
],
'messages' => [
PREFIX . 'favicon' => [
'accept' => __('Die Datei hat keinen gültigen ico Mime-Typ.', NAME_SPACE),
'extension' => __('Die Dateiendung muss <code>.ico</code> sein.', NAME_SPACE),
],
PREFIX . 'apple-touch-icon' => [
'accept' => __('Die Datei hat keinen gültigen png Mime-Typ.', NAME_SPACE),
'extension' => __('Die Dateiendung muss <code>.png</code> sein.', NAME_SPACE),
],
PREFIX . 'manifest' => [
'accept' => __('Die Datei hat keinen gültigen png Mime-Typ.', NAME_SPACE),
'extension' => __('Die Dateiendung muss <code>.png</code> sein.', NAME_SPACE),
],
PREFIX . 'svg_icon' => [
'accept' => __('Die Datei hat keinen gültigen svg Mime-Typ.', NAME_SPACE),
'extension' => __('Die Dateiendung muss <code>.svg</code> sein.', NAME_SPACE),
],
],
],
];
the code above works as expected, but not when I modify it to
// 'settings_pages' => [PREFIX . 'favicon'],
'option_name' => 'theme_mods_' . NAME_SPACE,
'panel' => '',
Hello,
I can see the issue on my demo site. I've escalated this issue to the development team to fix it in future updates.