name; $stock = get_term_meta( (int) $term->term_id, 'product_count_product_cat', true ); $stock = '' !== (string) $stock ? (int) $stock : (int) $term->count; $image = (int) ( $parts[0] ?? 0 ); $attrs = [ 'class' => 'rooster-category-tiles__image', 'alt' => '', 'sizes' => '(max-width: 63.999rem) 50vw, 25vw', 'loading' => 'lazy', 'decoding' => 'async', 'fetchpriority' => false, ]; if ( $image && class_exists( 'Rooster\\Core\\Images' ) && Rooster\Core\Images::raster( $image ) ) { $set = []; foreach ( Rooster\Core\Images::webp( $image, [ 360, 480, 640, 800, 1000 ] ) as $url => $w ) { $set[] = esc_url( $url ) . ' ' . (int) $w . 'w'; } if ( $set ) { $attrs['srcset'] = implode( ', ', $set ); } } $img = $image && wp_attachment_is_image( $image ) ? (string) wp_get_attachment_image( $image, 'large', false, $attrs ) : ''; if ( '' !== $img && class_exists( 'Rooster\\Core\\Defer', false ) && method_exists( 'Rooster\\Core\\Defer', 'later_image' ) ) { $img = Rooster\Core\Defer::later_image( $img ); $held = true; } $tiles .='
  • ' . '' . '' . $img . '' . '' . '' . esc_html( $name ) . '' . ( $stock > 0 ? '' . esc_html( sprintf( _n( '%s product', '%s products', $stock, 'ai-eshop-optimizer' ), number_format_i18n( $stock ) ) ) . '' : '' ) . '
  • '; } if ( '' === $tiles ) { return; } $wrapper = AIEO_Engine_Blocks::wrapper( $library, [ 'class' => 'rooster-category-tiles rooster-category-tiles--cols-' . max( 2, min( 4, $count ) ) ] ); AIEO_Engine_Blocks::out( sprintf( '', $wrapper, $tiles ), $held ? [ 'data' ] : [] );