Automattic\WooCommerce\Blueprint

Util::is_valid_wp_plugin_slugpublic staticWC 1.0

Check to see if given string is a valid WordPress plugin slug.

Method of the class: Util{}

No Hooks.

Returns

true|false.

Usage

$result = Util::is_valid_wp_plugin_slug( $slug );
$slug(string) (required)
The slug to be validated.

Util::is_valid_wp_plugin_slug() code WC 9.9.5

public static function is_valid_wp_plugin_slug( $slug ) {
	// Check if the slug only contains allowed characters.
	if ( preg_match( '/^[a-z0-9-]+$/', $slug ) ) {
		return true;
	}

	return false;
}