PHP: Dynamic slug function with SEO improvements