From 332a0f3ac3a02441d5f055a406ef89c72a5bace9 Mon Sep 17 00:00:00 2001 From: arttu Date: Thu, 23 May 2019 14:08:14 +0300 Subject: [PATCH] fix og:title translation --- content/themes/custom/models/search.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/content/themes/custom/models/search.php b/content/themes/custom/models/search.php index 357db66..62749f8 100644 --- a/content/themes/custom/models/search.php +++ b/content/themes/custom/models/search.php @@ -20,17 +20,19 @@ class Search extends \DustPress\Model { * Modify page title according to backend translation */ public function ModifyTitle() { + add_filter( 'wp_title', [ __CLASS__, 'PageTitle' ], 100 ); + add_filter( 'wpseo_opengraph_title', [ __CLASS__, 'PageTitle' ], 100 ); + } - /** - * Change the title - * - * @param string $title Existing title. - * @return string Modified $title. - */ - add_filter( 'wp_title', function( string $title ) : string { - $title = parse_path( 'haku.advanced_search', \DustPress\ApiTranslation::get_translations() ) ?? $title; - return $title; - }, 30); + /** + * Change the title + * + * @param string $title Existing title. + * @return string Modified $title. + */ + public static function PageTitle( string $title ) : string { + $title = parse_path( 'haku.advanced_search', \DustPress\ApiTranslation::get_translations() ) ?? $title; + return $title; } public function SearchBase() {