From 8d3e4a72a4ab2fc32f7132fc197142b9e3f62e16 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Sat, 27 Jun 2020 13:14:44 +0200 Subject: [PATCH] functions.php: add shortcode to set title on distromatic search pages --- functions.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/functions.php b/functions.php index d035609..2aff289 100644 --- a/functions.php +++ b/functions.php @@ -56,6 +56,32 @@ function add_search_box($items, $args) { } add_filter('wp_nav_menu_items','add_search_box', 10, 2); +function set_title($title) { + $urlargspos = strpos($_SERVER[REQUEST_URI], '?'); + if ($urlargspos > 0) { + $urlargs = substr($_SERVER[REQUEST_URI], $urlargspos + 1); + parse_str($urlargs, $args); + $newtitle = $title; + if ($args['arch']) { + $newtitle = $args['arch'] . " - " . $newtitle; + } + if ($args['tag']) { + $newtitle = $args['tag'] . " - " . $newtitle; + } + if ($args['pkg']) { + if ($args['pkg'] == '_index') + $newtitle = 'Index - ' . $newtitle; + else { + $e = explode('.', $args['pkg']); + $newtitle = $e[0] . " - " . $e[1] . " - " . $newtitle; + } + } + return $newtitle; + } + return $title; +} +add_filter('wp_title','set_title'); + // openmamba downloads pages function openmamba_download_link($milestone, $medium, $currarch, $ext, $mlword, $lang) { $latest_file = "/var/ftp/pub/openmamba/media/".$milestone."/".$medium."/".$lang."/latest.inc.php";