function bv_tv_date($value) { if (!$value || !is_scalar($value)) return ''; $value = (string) $value; if (preg_match('/^\d{8}$/', $value)) { $dt = DateTime::createFromFormat('!Ymd', $value); return $dt ? $dt->format('d.m.Y.') : $value; } if (preg_match('/^\d{4}-\d{2}-\d{2}$/', $value)) { $dt = DateTime::createFromFormat('!Y-m-d', $value); return $dt ? $dt->format('d.m.Y.') : $value; } return $value; } function bv_tv_info($label, $value) { if ($value === '' || $value === null || is_array($value)) return; echo '
Memorijal nije pronađen. Proverite slug ili URL u shortcode-u.
'; $view = isset($_GET['bv_view']) ? sanitize_key(wp_unslash($_GET['bv_view'])) : 'basic'; if (!in_array($view, ['basic','timeline','biography'], true)) $view = 'basic'; $title = get_the_title($id); $image = bv_tv_img(bv_tv_field($id, 'bv_memorial_image_1')); $birth = bv_tv_date(bv_tv_field($id, 'bv_birth_date')); $death = bv_tv_date(bv_tv_field($id, 'bv_death_date')); $q = get_post_meta($id, '_bv_memorial_questionnaire_v2', true); if (!is_array($q)) $q = []; $left_note = !empty($q['bv_v2_left_memorial_note']) ? $q['bv_v2_left_memorial_note'] : ''; $message = !empty($q['bv_v2_top_main_message']) ? $q['bv_v2_top_main_message'] : bv_tv_field($id, 'bv_tagline'); $bio = bv_tv_field($id, 'bv_biography_text'); if (!$bio) $bio = $q['bv_v2_biography_text'] ?? ''; $footer = !empty($q['bv_v2_bottom_memorial_text']) ? $q['bv_v2_bottom_memorial_text'] : ''; $base = get_permalink($id); // Kada je shortcode na test stranici, parametar se dodaje trenutnoj stranici, ne listingu. $here = get_permalink(get_queried_object_id()); if (!$here) $here = $base; $urls = [ 'basic' => remove_query_arg('bv_view', $here), 'timeline' => add_query_arg('bv_view', 'timeline', $here), 'biography' => add_query_arg('bv_view', 'biography', $here), ]; ob_start(); ?>