From 62c20d1eb87fbd5bb9a42e4d237c7192bd81e856 Mon Sep 17 00:00:00 2001
From: Coleman Watts <coleman@civicrm.org>
Date: Fri, 26 Apr 2019 08:56:46 -0400
Subject: [PATCH] Alter menubar breakpoint to match WP admin theme

---
 CRM/Utils/System.php           |  1 +
 CRM/Utils/System/Base.php      |  8 ++++++++
 CRM/Utils/System/WordPress.php | 10 ++++++++++
 Civi/Core/Container.php        |  1 +
 4 files changed, 20 insertions(+)

diff --git a/CRM/Utils/System.php b/CRM/Utils/System.php
index 6733d57f7e2..4706b2672cf 100644
--- a/CRM/Utils/System.php
+++ b/CRM/Utils/System.php
@@ -52,6 +52,7 @@
  * @method static setHttpHeader(string $name, string $value) Set http header.
  * @method static array synchronizeUsers() Create CRM contacts for all existing CMS users.
  * @method static appendCoreResources(\Civi\Core\Event\GenericHookEvent $e) Callback for hook_civicrm_coreResourceList.
+ * @method static alterAssetUrl(\Civi\Core\Event\GenericHookEvent $e) Callback for hook_civicrm_getAssetUrl.
  */
 class CRM_Utils_System {
 
diff --git a/CRM/Utils/System/Base.php b/CRM/Utils/System/Base.php
index 0ad46528d41..8bb09e260fc 100644
--- a/CRM/Utils/System/Base.php
+++ b/CRM/Utils/System/Base.php
@@ -919,6 +919,14 @@ abstract class CRM_Utils_System_Base {
   public function appendCoreResources(\Civi\Core\Event\GenericHookEvent $e) {
   }
 
+  /**
+   * Modify dynamic assets.
+   *
+   * @param \Civi\Core\Event\GenericHookEvent $e
+   */
+  public function alterAssetUrl(\Civi\Core\Event\GenericHookEvent $e) {
+  }
+
   /**
    * @param string $name
    * @param string $value
diff --git a/CRM/Utils/System/WordPress.php b/CRM/Utils/System/WordPress.php
index 5beecc51ea0..0f67b9be385 100644
--- a/CRM/Utils/System/WordPress.php
+++ b/CRM/Utils/System/WordPress.php
@@ -807,6 +807,16 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base {
     $e->list[] = 'js/crm.wordpress.js';
   }
 
+  /**
+   * @inheritDoc
+   */
+  public function alterAssetUrl(\Civi\Core\Event\GenericHookEvent $e) {
+    // Set menubar breakpoint to match WP admin theme
+    if ($e->asset == 'crm-menubar.css') {
+      $e->params['breakpoint'] = 783;
+    }
+  }
+
   /**
    * @inheritDoc
    */
diff --git a/Civi/Core/Container.php b/Civi/Core/Container.php
index 579ee3083ee..9ce531d1bb7 100644
--- a/Civi/Core/Container.php
+++ b/Civi/Core/Container.php
@@ -322,6 +322,7 @@ class Container {
     $dispatcher->addListener('hook_civicrm_buildAsset', ['\CRM_Utils_VisualBundle', 'buildAssetCss']);
     $dispatcher->addListener('hook_civicrm_buildAsset', ['\CRM_Core_Resources', 'renderMenubarStylesheet']);
     $dispatcher->addListener('hook_civicrm_coreResourceList', ['\CRM_Utils_System', 'appendCoreResources']);
+    $dispatcher->addListener('hook_civicrm_getAssetUrl', ['\CRM_Utils_System', 'alterAssetUrl']);
     $dispatcher->addListener('civi.dao.postInsert', ['\CRM_Core_BAO_RecurringEntity', 'triggerInsert']);
     $dispatcher->addListener('civi.dao.postUpdate', ['\CRM_Core_BAO_RecurringEntity', 'triggerUpdate']);
     $dispatcher->addListener('civi.dao.postDelete', ['\CRM_Core_BAO_RecurringEntity', 'triggerDelete']);
-- 
GitLab