'', 'title' => (string) ( $parts[0] ?? '' ), 'text' => (string) ( $parts[1] ?? '' ), 'tone' => $tone, 'mark' => $mark, 'anchor' => $anchor, 'link' => $link ]
: [ 'icon' => sanitize_key( (string) ( $parts[0] ?? '' ) ), 'title' => (string) ( $parts[1] ?? '' ), 'text' => (string) ( $parts[2] ?? '' ), 'tone' => $tone, 'mark' => '', 'anchor' => $anchor, 'link' => $link ];
if ( '' !== $card['title'] || '' !== $card['text'] ) {
$cards[] = $card;
}
}
if ( ! $cards ) {
return;
}
$columns = $steps ? max( 2, min( 4, count( $cards ) ) ) : ( in_array( (int) ( $attributes['columns'] ?? 3 ), [ 2, 4 ], true ) ? (int) $attributes['columns'] : 3 );
$tag = $steps ? 'ol' : 'div';
$item = $steps ? 'li' : 'div';
$rule = 'side' === (string) ( $attributes['rule'] ?? '' ) ? ' rooster-card-grid--rule-side' : '';
$border = in_array( (string) ( $attributes['border'] ?? '' ), [ 'strong', 'accent' ], true ) ? ' rooster-card-grid--border-' . $attributes['border'] : '';
$wrapper = AIEO_Engine_Blocks::wrapper( $library,
[
'class' => 'rooster-card-grid rooster-card-grid--' . $layout . ' rooster-card-grid--cols-' . $columns . $rule . $border,
'data-rooster-ui' => 'rooster-one/card',
]
);
$inner = '';
foreach ( $cards as $n => $card ) {
if ( $steps && '' !== $card['mark'] && function_exists( 'rooster_icon' ) && '' !== ( $glyph = rooster_icon( $card['mark'], [ 'width' => 18, 'height' => 18, 'class' => 'rooster-card-grid__mark' ] ) ) ) {
$lead = '' . $glyph . '' . (int) ( $n + 1 ) . '';
} elseif ( $steps ) {
$lead = '' . (int) ( $n + 1 ) . '';
} elseif ( 'none' === $card['icon'] ) {
$lead = '';
} else {
$glyph = '' !== $card['icon'] && function_exists( 'rooster_icon' ) ? rooster_icon( $card['icon'], [ 'width' => 20, 'height' => 20, 'class' => 'rooster-card-grid__glyph' ] ) : '';
$lead = '' . $glyph . '';
}
$toned = AIEO_Engine_Blocks::tone_classes( $card['tone'], true );
$inner .= '<' . $item . ' class="rooster-card-grid__card' . ( '' !== $toned ? ' ' . esc_attr( $toned ) : '' ) . ( '' === $lead ? ' has-no-icon' : '' ) . '"'
. ( '' !== $card['anchor'] ? ' id="' . esc_attr( $card['anchor'] ) . '"' : '' ) . '>' . $lead
. ( '' !== $card['title'] ? sprintf( '
' . AIEO_Engine_Blocks::inline( $card['text'] ) . '
' : '' ) . ( '' !== $card['link'] ? '' . AIEO_Engine_Blocks::inline( $card['link'] ) . '
' : '' ) . '' . $item . '>'; } AIEO_Engine_Blocks::out( sprintf( '<%1$s %2$s>%3$s%1$s>', $tag, $wrapper, $inner ) );