本文整理匯總了PHP中BP_Groups_Group::check_slug方法的典型用法代碼示例。如果您正苦於以下問題:PHP BP_Groups_Group::check_slug方法的具體用法?PHP BP_Groups_Group::check_slug怎麽用?PHP BP_Groups_Group::check_slug使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類BP_Groups_Group
的用法示例。
在下文中一共展示了BP_Groups_Group::check_slug方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: groups_check_slug
/**
* Provide a unique, sanitized version of a group slug.
*
* @param string $slug Group slug to check.
*
* @return string $slug A unique and sanitized slug.
*/
function groups_check_slug($slug)
{
$bp = buddypress();
if ('wp' == substr($slug, 0, 2)) {
$slug = substr($slug, 2, strlen($slug) - 2);
}
if (in_array($slug, (array) $bp->groups->forbidden_names)) {
$slug = $slug . '-' . rand();
}
if (BP_Groups_Group::check_slug($slug)) {
do {
$slug = $slug . '-' . rand();
} while (BP_Groups_Group::check_slug($slug));
}
return $slug;
}
示例2: check_slug
function check_slug($id, $slug)
{
global $bp;
/* Allow save if no change */
if ($slug == $bp->groups->current_group->slug) {
return true;
}
/* Group slugs cannot start with wp */
if ('wp' == substr($slug, 0, 2)) {
$slug = substr($slug, 2, strlen($slug) - 2);
}
/* Don't allow forbidden names */
if (in_array($slug, (array) $bp->groups->forbidden_names)) {
return false;
}
/* Run it through the BP core slug checker */
if (BP_Groups_Group::check_slug($slug)) {
if ($slug != BP_Groups_Group::get_slug($id)) {
return false;
}
}
/* Slug is good, return true */
return true;
}