bbp_sanitize_slug( string $slug = '' )

Sanitize permalink slugs when saving the settings page.


Description Description


Parameters Parameters

$slug

(Optional)

Default value: ''


Top ↑

Return Return

(string)


Top ↑

Source Source

File: includes/admin/common.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 & return
	return apply_filters( 'bbp_sanitize_slug', $value, $slug );
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.6.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.