Sanitizes slugs.
Parameters
$slugs
stringrequired- A comma-separated string of plugin dependency slugs.
Source
protected static function sanitize_dependency_slugs( $slugs ) {
$sanitized_slugs = array();
$slugs = explode( ',', $slugs );
foreach ( $slugs as $slug ) {
$slug = trim( $slug );
/**
* Filters a plugin dependency's slug before matching to
* the WordPress.org slug format.
*
* Can be used to switch between free and premium plugin slugs, for example.
*
* @since 6.5.0
*
* @param string $slug The slug.
*/
$slug = apply_filters( 'wp_plugin_dependencies_slug', $slug );
// Match to WordPress.org slug format.
if ( preg_match( '/^[a-z0-9]+(-[a-z0-9]+)*$/mu', $slug ) ) {
$sanitized_slugs[] = $slug;
}
}
$sanitized_slugs = array_unique( $sanitized_slugs );
sort( $sanitized_slugs );
return $sanitized_slugs;
}
Hooks
- apply_filters( ‘wp_plugin_dependencies_slug’,
string $slug ) Filters a plugin dependency’s slug before matching to the WordPress.org slug format.
Changelog
Version | Description |
---|---|
6.5.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.