How can I make wordpress call this function when a post is saved?
$folder = "/temp/files/"; //path of the folder to be removed
function delFolder($folder)
{
foreach(glob($folder . '/*') as $file) //takes the content of the given folder
{
if(is_dir($file)) //check if it is another folder then recursively call itself on it
delFolder($file);
else
unlink($file); //check if it is file then deletes it
}
rmdir($folder); //removes the folder
}