From 0734e0e877717608d4ee601729fc444d99c623f4 Mon Sep 17 00:00:00 2001 From: Christian Wach Date: Tue, 11 Nov 2014 11:57:48 +0000 Subject: [PATCH] use new title-setting method for civicm-wordpress 4.6+ --- CRM/Utils/System/WordPress.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/CRM/Utils/System/WordPress.php b/CRM/Utils/System/WordPress.php index a69eff6b7f..7c59cdcef4 100644 --- a/CRM/Utils/System/WordPress.php +++ b/CRM/Utils/System/WordPress.php @@ -66,11 +66,33 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { if (!$pageTitle) { $pageTitle = $title; } - if (civicrm_wp_in_civicrm()) { + + // get civi-wordpress instance + $civi = civi_wp(); + + // do we have functionality provided by plugin version 4.6+ present? + if (method_exists($civi, 'civicrm_context_get')) { + + global $civicrm_wp_title; + $civicrm_wp_title = $pageTitle; + + // yes, set page title, depending on context + $context = civi_wp()->civicrm_context_get(); + switch ( $context ) { + case 'admin': + case 'shortcode': + $template = CRM_Core_Smarty::singleton(); + $template->assign('pageTitle', $pageTitle); + } + + } elseif (civicrm_wp_in_civicrm()) { + + // legacy pre-4.6 behaviour global $civicrm_wp_title; $civicrm_wp_title = $pageTitle; $template = CRM_Core_Smarty::singleton(); $template->assign('pageTitle', $pageTitle); + } } -- 2.25.1