I’m writing to report a critical bug that is preventing the Class Manager feature from working within the Oxygen Builder environment. I believe I have identified the root causes and have implemented a temporary fix.
1. The Primary Issue: Missing JavaScript Dependency
-
Problem: When attempting to use the Class Manager in Oxygen, the feature fails to load. The browser’s developer console shows a JavaScript error:
Uncaught ReferenceError: Mousetrap is not defined. -
Cause: The plugin’s JavaScript (
class-manager.jsandclass-manager-iframe.js) calls theMousetrap.jslibrary for keyboard shortcuts. However, this library is not being loaded. I checked the plugin files and couldn’t find themousetrap.jsfile bundled with the plugin. -
Hypothesis: It appears Swiss Knife was relying on Oxygen Builder to provide this script as a dependency. A recent update to Oxygen has likely removed
Mousetrap.js, which has, in turn, broken your plugin’s functionality.
2. The Secondary Issue: Incorrect CSS Positioning
-
Problem: Once the JavaScript issue is resolved, the lock icon’s container (
.swk-locked-div) is incorrectly positioned, appearing too high up and obscuring other UI elements. -
Cause: The CSS for this element is missing a correct
topvalue to position it properly within the Oxygen UI.
My Temporary Solution
To get the feature working again, I created a single PHP snippet to address both issues. I am sharing it in case it helps you debug.
This snippet does two things:
-
It enqueues the
Mousetrap.jslibrary from a public CDN. -
It injects the necessary CSS to fix the positioning of the
.swk-locked-div.
<?php
/**
* Temporary Fix for Swiss Knife Class Manager in Oxygen
* 1. Loads the missing Mousetrap.js dependency.
* 2. Corrects the CSS for the .swk-locked-div element.
*/
// 1. Enqueue the missing Mousetrap.js script from a CDN
add_action( 'init', function() {
wp_enqueue_script(
'swiss-knife-mousetrap-fix',
'[https://cdnjs.cloudflare.com/ajax/libs/mousetrap/1.6.5/mousetrap.min.js](https://cdnjs.cloudflare.com/ajax/libs/mousetrap/1.6.5/mousetrap.min.js)',
['jquery'],
'1.6.5',
false
);
});
// 2. Inject the CSS fix into the page head
add_action( 'wp_head', function() {
?>
<style id="swiss-knife-css-fix">
.swk-locked-div {
top: 155px !important;
}
</style>
<?php
});
Suggested Permanent Fix
To prevent this from happening in the future, I would strongly recommend:
-
Bundling your dependencies: Please include the
mousetrap.min.jsfile within your plugin and enqueue it yourselves. This will ensure your features work reliably and are not dependent on other plugins’ codebases. -
Updating the core stylesheet: Please add the
top: 155px;rule (or a more robust positioning solution) to your plugin’s CSS for the.swk-locked-divselector.
If you get error Uncaught ReferenceError: Mousetrap is not defined
Please enable feature:
Utilities > Keyboard Shortcuts
Then moustrap will be loaded. Will release update to it’s loaded when import feature is enabled as well.
Will fix that in the next release so its loaded on both features
Released