$name, 'price' => self::format( $raw ), 'amount' => ctype_digit( preg_replace( '/\s/', '', $raw ) ) && '' !== $raw ? (int) preg_replace( '/\s/', '', $raw ) : null, ); } if ( '' === $title || ! $items ) { continue; } $service = sanitize_title( (string) ( $group['service'] ?? '' ) ); $result[] = array( 'title' => $title, 'service' => $service, 'url' => $urls[ $service ] ?? '', 'items' => $items, ); } return $result; } private static function plain( string $value ): string { return trim( html_entity_decode( wp_strip_all_tags( $value ), ENT_QUOTES | ENT_HTML5, 'UTF-8' ) ); } public static function format( string $price ): string { $price = self::plain( $price ); $digits = preg_replace( '/[^\d]/', '', $price ); if ( '' === $price || $digits !== preg_replace( '/\s/', '', $price ) ) { return $price; } return sprintf( __( 'от %s zł', 'smilia-core' ), number_format_i18n( (int) $digits ) ); } }