/** * Clean a slug posted by the user * @param string $slug The slug provided by the user * @return string * @since 2.4b5 */ static function PostedSlug($string, $from_label = false) { includeFile('tool/strings.php'); // Remove control characters $string = preg_replace('#[[:cntrl:]]#u', '', $string); // [\x00-\x1F\x7F] //illegal characters $string = str_replace(array('?', '*', ':', '|'), array('', '', '', ''), $string); //change known entities to their character equivalent $string = gp_strings::entity_unescape($string); //if it's from a label, remove any html if ($from_label) { $string = admin_tools::LabelHtml($string); $string = strip_tags($string); //after removing tags, unescape special characters $string = str_replace(array('<', '>', '"', ''', '&'), array('<', '>', '"', "'", '&'), $string); } // # character after unescape for entities and unescape of special chacters when $from_label is true $string = str_replace('#', '', $string); //slashes $string = admin_tools::SlugSlashes($string); return str_replace(' ', '_', $string); }