本文整理汇总了PHP中admin_tools::SlugSlashes方法的典型用法代码示例。如果您正苦于以下问题:PHP admin_tools::SlugSlashes方法的具体用法?PHP admin_tools::SlugSlashes怎么用?PHP admin_tools::SlugSlashes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类admin_tools
的用法示例。
在下文中一共展示了admin_tools::SlugSlashes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PostedSlug
/**
* 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);
}