function optimize_slug($slug) { //If no slug exists, start off with the post title if (empty($slug) && isset($_POST['post_title'])) { $slug = $_POST['post_title']; } //Prepare the title and the words for comparison $slug = sustr::tolower(stripslashes($slug)); $words = sustr::tolower(stripslashes($this->get_setting('words_to_remove'))); //Remove the stopwords from the slug $newslug = implode("-", array_diff(explode(" ", $slug), suarr::explode_lines($words))); //Make sure we haven't removed too much! if (empty($newslug)) { return $slug; } else { return $newslug; } }