wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
wp_get_block_style_variation_name_from_registered_style › WordPress Function
Seit7.0.0
Veraltetn/v
› wp_get_block_style_variation_name_from_registered_style ( $class_name, $registered_styles = array() )
| Parameter: (2) |
|
| Gibt zurück: |
|
| Definiert in: |
|
| Codex: |
Gets the first style variation name from a className string that matches a registered style.
Quellcode
function wp_get_block_style_variation_name_from_registered_style( string $class_name, array $registered_styles = array() ): ?string {
if ( ! $class_name ) {
return null;
}
$registered_names = array_filter( array_column( $registered_styles, 'name' ) );
$prefix = 'is-style-';
$length = strlen( $prefix );
foreach ( explode( ' ', $class_name ) as $class ) {
if ( str_starts_with( $class, $prefix ) ) {
$variation = substr( $class, $length );
if ( 'default' !== $variation && in_array( $variation, $registered_names, true ) ) {
return $variation;
}
}
}
return null;
}