本文整理匯總了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);
}