From 1fcaf322a06aa6402baa782c4d2252b7882d98df Mon Sep 17 00:00:00 2001 From: Antoine M Date: Thu, 21 May 2026 17:31:54 +0200 Subject: [PATCH] FEATURE Optimize function carhop_get_post_card_link_according_to_post_datas to handle when no pdf attached to analyse --- includes/utilities.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/includes/utilities.php b/includes/utilities.php index 2812abc..9bf8d31 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -492,16 +492,22 @@ function carhop_get_post_card_link_according_to_post_datas($post_id, $card_args case 'analyses-etudes': $type_analyse_etude = get_the_terms($post_id, 'type-analyse-etude')[0] ?? null; + if ($type_analyse_etude->slug === 'analyse') { $link_type = get_field('link_type', $post_id); switch ($link_type) { case 'pdf': $pdf = get_field('pdf', $post_id); + if (is_array($pdf) && ! empty($pdf['url'])) { $link = $pdf['url']; $target = '_blank'; $is_external = true; + } else { + $link = ''; + $target = '_self'; + $is_external = false; } break; case 'link':