[ 'grid', __( 'Grid', 'ai-eshop-optimizer' ) ], 'list' => [ 'list', __( 'List', 'ai-eshop-optimizer' ) ], ]; $rooster_links = ''; foreach ( $rooster_views as $rooster_view => [ $rooster_icon, $rooster_label ] ) { $rooster_links .= sprintf( '%5$s%4$s', esc_url( WooCommerce::view_url( $rooster_view ) ), esc_attr( $rooster_view ), $rooster_view === $rooster_current ? ' aria-current="true"' : '', esc_attr( $rooster_label ), rooster_icon( $rooster_icon, [ 'width' => 20, 'height' => 20 ] ) ); } $rooster_columns = array_values( array_unique( array_intersect( array_map( 'intval', (array) ( $attributes['columns'] ?? [] ) ), [ 3, 4 ] ) ) ); $rooster_phone = class_exists( Rooster\Core\DeviceClass::class ) && Rooster\Core\DeviceClass::enabled() && 'mobile' === rooster_device_class(); $rooster_cols = ''; if ( count( $rooster_columns ) > 1 && ! $rooster_phone && method_exists( WooCommerce::class, 'columns_switch' ) ) { sort( $rooster_columns ); foreach ( $rooster_columns as $rooster_count ) { $rooster_name = sprintf( _n( '%d product a row', '%d products a row', $rooster_count, 'ai-eshop-optimizer' ), $rooster_count ); $rooster_cols .= sprintf( '', $rooster_count, (string) $rooster_count === WooCommerce::shop_columns() ? 'true' : 'false', esc_attr( $rooster_name ), 'list' === $rooster_current ? ' disabled' : '' ); } $rooster_cols = sprintf( '
%2$s
', esc_attr__( 'Products a row', 'ai-eshop-optimizer' ), $rooster_cols ); WooCommerce::columns_switch(); } $rooster_back = ''; if ( ! $rooster_phone && method_exists( WooCommerce::class, 'filters_place' ) ) { $rooster_side = 'end' === WooCommerce::filters_place() ? 'end' : 'start'; $rooster_back = sprintf( '
', esc_attr( $rooster_side ), esc_attr__( 'Put the filters back beside the products', 'ai-eshop-optimizer' ), rooster_icon( 'end' === $rooster_side ? 'panel-right' : 'panel-left', [ 'width' => 20, 'height' => 20 ] ) ); } Rooster\Core\Blocks::expect( 'rooster-shop-toolbar-end' ); AIEO_Engine_Blocks::out( sprintf( '
%2$s%3$s
%5$s
', get_block_wrapper_attributes( [ 'class' => 'rooster-view-switch' ] ), $rooster_back, $rooster_cols, esc_attr__( 'View', 'ai-eshop-optimizer' ), $rooster_links ) );