$parts[0], 'icon' => sanitize_key( (string) ( $parts[1] ?? '' ) ), 'rows' => [] ]; continue; } if ( ! $groups ) { continue; } $parts = array_map( 'trim', explode( '|', $line, 2 ) ); $groups[ count( $groups ) - 1 ]['rows'][] = [ $parts[0], (string) ( $parts[1] ?? '' ) ]; } $groups = array_values( array_filter( $groups, static fn ( array $g ): bool => '' !== $g['name'] ) ); if ( ! $groups ) { return; } $unit = array_map( 'trim', explode( '|', (string) ( $attributes['unit'] ?? '' ), 2 ) ); $singular = (string) ( $unit[0] ?? '' ); $plural = (string) ( $unit[1] ?? $singular ); $inner = ''; foreach ( $groups as $i => $group ) { $n = count( $group['rows'] ); $glyph = '' !== $group['icon'] && function_exists( 'rooster_icon' ) ? rooster_icon( $group['icon'], [ 'width' => 20, 'height' => 20, 'class' => 'rooster-detail-cards__glyph' ] ) : ''; $count = '' !== $singular ? $n . ' ' . ( 1 === $n ? $singular : $plural ) : (string) $n; $inner .= '
' . '' . $glyph . ' ' . '' . esc_html( $group['name'] ) . ' ' . '' . esc_html( $count ) . ' ' . ''; if ( $group['rows'] ) { $inner .= ''; } $inner .= '
'; } $wrapper = AIEO_Engine_Blocks::wrapper( $library, [ 'class' => 'rooster-detail-cards', 'data-rooster-ui' => 'rooster-one/card' ] ); AIEO_Engine_Blocks::out( sprintf( '
%2$s
', $wrapper, $inner ) );