WP_Plugin_Dependencies::sanitize_dependency_slugs()
Sanitizes slugs.
Метод класса: WP_Plugin_Dependencies{}
Хуки из метода
Возвращает
Массив
. An array of sanitized plugin dependency slugs.
Использование
$result = WP_Plugin_Dependencies::sanitize_dependency_slugs( $slugs );
- $slugs(строка) (обязательный)
- A comma-separated string of plugin dependency slugs.
Список изменений
С версии 6.5.0 | Введена. |
Код WP_Plugin_Dependencies::sanitize_dependency_slugs() WP Plugin Dependencies::sanitize dependency slugs WP 6.6.2
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; }