function document_title($title = '', $sep = '-', $seplocation = 'right') { // Remove default seperator and add spacing if (trim($sep) === '' || $sep === '»' || $sep === '»') { $sep = '-'; } $sep = ' ' . $sep . ' '; // Determine page number, if any $page_num = ''; if (is_paged()) { global $page, $paged; if ($paged >= 2 || $page >= 2) { $page_num = $sep . sprintf(esc_html__('Page %d', 'ubik'), max($paged, $page)); } } // Generate the title using our all-purpose title function $title = apply_filters('ubik_seo_document_title_raw', ubik_title()); $name = get_bloginfo('name'); $desc = get_bloginfo('description'); // Handle three scenarios: home/front page, archive feeds, and everything else if (is_front_page() || is_home()) { $title = $name; if (!empty($desc) && !is_paged()) { $title .= $sep . $desc; } } elseif (is_feed() && is_archive()) { $title = $sep . $title; // Adding the separator alters the default archive feed title output } else { $title = $title . $sep . $name; } // Sanitize and add page number as needed $title = esc_html(strip_tags(stripslashes(preg_replace('/\\s+/', ' ', trim($title . $page_num))))); return apply_filters('ubik_seo_document_title_final', $title); }
function ubik_seo_yoast_title_cleaner($title) { if (is_singular() && function_exists('ubik_title')) { $title = ubik_title(); } return $title; }