Created
October 23, 2025 18:25
-
-
Save yahyaahrika/afc22f1540d393e0230f9d2a75e90789 to your computer and use it in GitHub Desktop.
Add this to your WordPress menu to fix the mobile menu button not opening. Install the Code Snippets plugin, paste the PHP code, then save and activate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action('wp_enqueue_scripts', function () { | |
| // Ensure elementor-frontend is enqueued before our inline JS. | |
| // Priority 20 places this after Elementor's own scripts in most setups. | |
| wp_add_inline_script( | |
| 'elementor-frontend', | |
| // BEGIN inline JS | |
| '(function(){ | |
| // --- softDeprecated shim --- | |
| window.elementorCommon = window.elementorCommon || {}; | |
| window.elementorCommon.helpers = window.elementorCommon.helpers || {}; | |
| if (typeof window.elementorCommon.helpers.softDeprecated !== "function") { | |
| window.elementorCommon.helpers.softDeprecated = function(){ /* noop to prevent crashes */ }; | |
| } | |
| // --- NestedTabs shim --- | |
| // Some Elementor Pro versions expect elementorModules.frontend.handlers.NestedTabs. | |
| // If core doesn\'t provide it, define a minimal class so inheritance doesn\'t fail. | |
| window.elementorModules = window.elementorModules || {}; | |
| window.elementorModules.frontend = window.elementorModules.frontend || {}; | |
| window.elementorModules.frontend.handlers = window.elementorModules.frontend.handlers || {}; | |
| if (!window.elementorModules.frontend.handlers.NestedTabs) { | |
| // Use Base if available; otherwise use a bare function to avoid TypeError on "extends". | |
| var BaseCtor = (window.elementorModules.frontend.handlers.Base) || function(){}; | |
| try { | |
| // Define a tiny class that won\'t do anything harmful. | |
| var DummyNestedTabs = (function(_Base){ | |
| function C(){ _Base.apply(this, arguments); } | |
| if (_Base && _Base.prototype) { | |
| C.prototype = Object.create(_Base.prototype); | |
| C.prototype.constructor = C; | |
| } | |
| C.prototype.onInit = C.prototype.onInit || function(){}; | |
| return C; | |
| })(BaseCtor); | |
| window.elementorModules.frontend.handlers.NestedTabs = DummyNestedTabs; | |
| } catch(e) { | |
| // If anything goes wrong, at least define a no-op so Pro doesn\'t crash. | |
| window.elementorModules.frontend.handlers.NestedTabs = function(){}; | |
| } | |
| } | |
| })();' | |
| // END inline JS | |
| ); | |
| }, 20); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Here are a few clean, corrected options—pick the style you like: | |
| **Concise sentence** | |
| * “Add this to your WordPress menu to fix the mobile menu button not opening. Install the Code Snippets plugin, paste the PHP code, then save and activate.” | |
| **Step-by-step** | |
| 1. Install the **Code Snippets** plugin. | |
| 2. Add the provided **PHP** snippet. | |
| 3. **Save** the snippet and **Activate** it. | |
| 4. This will fix the **mobile menu button** not opening in your WordPress menu. | |
| **Even shorter** | |
| * “Install Code Snippets → add the PHP code → Save & Activate to fix the mobile menu button on WordPress.” |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment