bbp_sanitize_slug( string $slug = '' )
Sanitize permalink slugs when saving the settings page.
Description
Parameters
- $slug
-
(Optional)
Default value: ''
Return
(string)
Source
File: bp-forums/admin/functions.php
function bbp_sanitize_slug( $slug = '' ) {
// Don't allow multiple slashes in a row
$value = preg_replace( '#/+#', '/', str_replace( '#', '', $slug ) );
// Strip out unsafe or unusable chars
$value = esc_url_raw( $value );
// esc_url_raw() adds a scheme via esc_url(), so let's remove it
$value = str_replace( 'http://', '', $value );
// Trim off first and last slashes.
//
// We already prevent double slashing elsewhere, but let's prevent
// accidental poisoning of options values where we can.
$value = ltrim( $value, '/' );
$value = rtrim( $value, '/' );
// Filter the result and return
return apply_filters( 'bbp_sanitize_slug', $value, $slug );
}
Changelog
| Version | Description |
|---|---|
| bbPress (r5364) | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.