add_shortcode(‘gestione_foto_matrimonio’, function() {
$upload_dir = WP_CONTENT_DIR . ‘/uploads/Foto Matrimonio/’;
$upload_url = content_url(‘uploads/Foto Matrimonio’);
// Eliminazione file
if (!empty($_GET[‘delete’])) {
$file = basename($_GET[‘delete’]);
$path = $upload_dir . $file;
if (file_exists($path)) {
unlink($path);
echo “
Foto eliminata.
“;
}
}
if (!is_dir($upload_dir)) {
return “
Nessuna foto trovata.
“;
}
$files = array_diff(scandir($upload_dir), array(‘.’, ‘..’));
if (empty($files)) {
return “
Nessuna foto caricata.
“;
}
// AGGIUNTA IMPORTANTE: classe galleria-foto
$html = ‘
‘;
return $html;
});