20, 'height' => 20, 'class' => 'rooster-action-panel__glyph' ] ) : ''; $chip = '' !== $chip ? '' . $chip . '' : ''; $glyphs = static function ( string $slug, int $size ): array { $slug = sanitize_key( $slug ); if ( 'arrow-right' === $slug ) { return [ '', '' ]; } return [ '' !== $slug && 'none' !== $slug && function_exists( 'rooster_icon' ) ? rooster_icon( $slug, [ 'width' => $size, 'height' => $size, 'class' => 'rooster-action-panel__icon' ] ) : '', '' ]; }; if ( 'wash' === $layout || 'ink' === $layout ) { $body = $chip; if ( '' !== $eyebrow ) { $body .= '

' . esc_html( $eyebrow ) . '

'; } if ( '' !== $heading ) { $body .= sprintf( '%2$s', $level, esc_html( $heading ) ); } foreach ( preg_split( '/\n\s*\n/', $text ) ?: [] as $para ) { if ( '' !== trim( $para ) ) { $body .= '

' . AIEO_Engine_Blocks::inline( trim( $para ) ) . '

'; } } $lines = (string) ( $attributes['buttons'] ?? '' ); if ( 'ink' === $layout ) { $body .= '' !== trim( $lines ) ? (string) render_block( [ 'blockName' => 'rooster/action', 'attrs' => [ 'variant' => 'buttons', 'buttons' => $lines, 'tone' => (string) ( $attributes['tone'] ?? '' ) ], 'innerBlocks' => [], 'innerHTML' => '', 'innerContent' => [] ] ) : ''; } else { $links = ''; foreach ( AIEO_Engine_Blocks::lines( $lines ) as $line ) { $parts = array_map( 'trim', explode( '|', $line ) ); if ( '' !== (string) ( $parts[0] ?? '' ) && '' !== (string) ( $parts[1] ?? '' ) ) { $other = (string) wp_parse_url( (string) $parts[1], PHP_URL_HOST ); $away = '' !== $other && $other !== $host; [ $before, $after ] = $glyphs( (string) ( $parts[3] ?? '' ), 16 ); $links .= '' . $before . esc_html( (string) $parts[0] ) . ( $away ? ' ' . esc_html__( '(opens in a new tab)', 'ai-eshop-optimizer' ) . '' : '' ) . $after . ''; } } $body .= '' !== $links ? '
' . $links . '
' : ''; } $note = trim( (string) ( $attributes['note'] ?? '' ) ); if ( '' !== $note ) { $body .= '

' . AIEO_Engine_Blocks::inline( $note ) . '

'; } $wrapper = AIEO_Engine_Blocks::wrapper( $library, [ 'class' => 'rooster-action-panel rooster-action-panel--' . $layout, 'data-rooster-ui' => 'rooster-one/action' ] ); AIEO_Engine_Blocks::out( sprintf( '
%2$s
', $wrapper, $body ) ); return; } $body = $chip; if ( '' !== $eyebrow && 'band' === $layout ) { $body .= '

' . esc_html( $eyebrow ) . '

'; } if ( '' !== $heading ) { $body .= sprintf( '%2$s', $level, esc_html( $heading ) ); } if ( '' !== $text ) { $body .= '

' . AIEO_Engine_Blocks::inline( $text ) . '

'; } $items = 'band' === $layout ? AIEO_Engine_Blocks::lines( (string) ( $attributes['items'] ?? '' ) ) : []; if ( $items ) { $body .= ''; } $buttons = ''; foreach ( AIEO_Engine_Blocks::lines( (string) ( $attributes['buttons'] ?? '' ) ) as $i => $line ) { $parts = array_map( 'trim', explode( '|', $line ) ); $label = (string) ( $parts[0] ?? '' ); $href = (string) ( $parts[1] ?? '' ); if ( '' === $label || '' === $href ) { continue; } $said = strtolower( (string) ( $parts[2] ?? '' ) ); $kind = 'secondary' === $said || ( '' === $said && $i > 0 ) ? 'secondary' : 'primary'; $other = (string) wp_parse_url( $href, PHP_URL_HOST ); $external = '' !== $other && $other !== $host; $slug = sanitize_key( (string) ( $parts[3] ?? '' ) ); [ $before ] = $external && 'external-link' === $slug ? [ '' ] : $glyphs( $slug, 18 ); $buttons .= '' . $before . esc_html( $label ) . ( $external ? ' ' . esc_html__( '(opens in a new tab)', 'ai-eshop-optimizer' ) . '' : '' ) . ''; } if ( '' !== $buttons ) { $body .= '
' . $buttons . '
'; } $wrapper = AIEO_Engine_Blocks::wrapper( $library, [ 'class' => 'rooster-action-panel rooster-action-panel--' . $layout, 'data-rooster-ui' => 'rooster-one/action' ] ); AIEO_Engine_Blocks::out( sprintf( '
%2$s
', $wrapper, $body ) );