$column ) {
$head .= '
' . esc_html( $column ) . ' | ';
}
$body = '';
foreach ( $lines as $line ) {
$cells = array_pad( array_map( 'trim', explode( '|', $line ) ), $n, '' );
if ( '' === $cells[0] ) {
continue;
}
$tone = count( $cells ) === $n + 1 && AIEO_Engine_Blocks::is_tone( $cells[ $n ] ) ? AIEO_Engine_Blocks::tone_classes( $cells[ $n ], true ) : '';
$body .= ( '' !== $tone ? '' : '
' ) . '| ' . esc_html( $cells[0] ) . ' | ';
for ( $c = 1; $c < $n; $c++ ) {
$cell = $cells[ $c ];
$word = $cell;
if ( str_starts_with( $cell, 'text:' ) ) {
$cell = trim( substr( $cell, 5 ) );
$word = null;
}
if ( 'yes' === $word ) {
$html = '' . esc_html__( 'Yes', 'ai-eshop-optimizer' ) . '';
$class = 'is-centred';
} elseif ( in_array( $word, [ 'no', '', '-', '–', '—' ], true ) ) {
$html = '–' . esc_html__( 'No', 'ai-eshop-optimizer' ) . '';
$class = 'is-centred';
} else {
$html = AIEO_Engine_Blocks::inline( $cell );
$class = mb_strlen( AIEO_Engine_Blocks::plain( $cell ) ) <= 16 ? 'is-centred' : '';
}
$body .= '' . $html . ' | ';
}
$body .= '
';
}
$wrapper = AIEO_Engine_Blocks::wrapper( $library,
[
'class' => 'rooster-data-table',
'role' => 'region',
'tabindex' => '0',
'aria-label' => '' !== $label ? $label : __( 'Comparison', 'ai-eshop-optimizer' ),
'data-rooster-ui' => 'rooster-one/table',
]
);
AIEO_Engine_Blocks::out( sprintf( '', $wrapper, $head, $body ) );