use new title-setting method for civicm-wordpress 4.6+
authorChristian Wach <needle@haystack.co.uk>
Tue, 11 Nov 2014 11:57:48 +0000 (11:57 +0000)
committerChristian Wach <needle@haystack.co.uk>
Tue, 11 Nov 2014 11:57:48 +0000 (11:57 +0000)
CRM/Utils/System/WordPress.php

index a69eff6b7f8b53903255ca95386936914cd00b92..7c59cdcef45bc683c25b829cabf6112330450a9d 100644 (file)
@@ -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);
+      
     }
   }