add_shortcode('zency_kort', function($atts) {
$atts = shortcode_atts([
'city' => '',
'height' => '450',
], $atts, 'zency_kort');
$city = sanitize_text_field($atts['city']);
if (empty($city)) {
$behandlingstyper = [
'gravidmassage', 'sportsmassage', 'fysiurgisk-massage',
'dybdegaaende-massage', 'oliemassage', 'wellness-massage',
'bindevaevsmassage', 'thai-massage', 'klassisk-massage',
];
$path = trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/');
$parts = explode('/', $path);
$massageIdx = array_search('massage', $parts);
$bySegments = [];
if ($massageIdx !== false) {
$bySegments = array_slice($parts, $massageIdx + 1);
}
$bySegments = array_filter($bySegments, function($seg) use ($behandlingstyper) {
return !empty($seg) && !in_array($seg, $behandlingstyper);
});
$bySegments = array_values($bySegments);
if (!empty($bySegments)) {
$city = end($bySegments);
}
}
$city = str_replace(
['å','æ','ø','Å','Æ','Ø'],
['aa','ae','oe','aa','ae','oe'],
$city
);
$city = preg_replace('/[^a-z0-9]/', '', strtolower($city));
$kortUrl = content_url('uploads/behandler-kort-v4.html');
if (!empty($city)) {
$kortUrl .= '?city=' . urlencode($city);
}
$height = absint($atts['height']) ?: 450;
$visNavn = ucwords(str_replace('-', ' ', $city)) ?: 'Danmark';
return sprintf(
'',
esc_url($kortUrl),
esc_attr($visNavn),
$height
);
});
404 side - Øv, øv, øv! Du har ramt et "ømt" punkt.
Videre til indhold