Bug report: JS throws error in the profitmag_tabs function
-
Good day guys,
I had a discussion with the plugin author of loco translate. And he recommend to contact you guys. Here’s the outcome:
The JavaScript file inc/admin-panel/js/custom.js throws an error on line 21 in the profitmag_tabs function when the variable active_tab does not contain a hash of its own (like #options-group-7) When it contains something else like a URL you will get a jQuery error that will not be caught.
This navigation tabs code runs on all admin pages (not just its own pages) and assumes that any HTML element with the class nav-tab-wrapper belongs to itself (which it won’t when it runs on all pages as it’s a WordPress style)
So what happens is that if you visit a any other page with navigation tabs (like my plugin, or some other WordPress pages) Profitmag’s code will save an invalid active tab string to local storage (in this case a full URL rather than a hash). Any time that is then used to construct a jQuery object you will get an error.
Alternative solutions for the theme author:
1. Use a better way to identify your own HTML elements. A WordPress class name is not a good choice
2. Only run your JavaScript on your own pages that actually need it.
3. Sanity check data before using it and before saving it to local storageAny of these solutions will fix the problem, but I’d recommend option 2 as general good practice.
*************************************
Would be great if you could give feedback on the above
Cheers,
Michael
- The topic ‘Bug report: JS throws error in the profitmag_tabs function’ is closed to new replies.