Suggestion: Check if widget exists in dashboard.js or widget display config
-
Currently AntiSpam Bee does not have an option to switch on/off the dashboard widget based on a wp user role/capability.
In a current project it was necessary to remove the widget in “non admin/editor” accounts.
The current solution is a conditional
remove_meta_box('ab_widget', 'dashboard', 'normal');
inadmin_menu
action.Unfortunately this triggers a js-error in Raphael js library when it tries to access/use the non existing
#ab_chart
element indashboard.min.js
when using e.g. an “author” account.Suggestion (simple): Add a check if the element exists before the drawing codeblock in
dashboard.js
, e.g.if (jQuery('#ab_chart').length > 0) {// Draw ..}
Suggestion (complex): Add a configurable user capability to AntiSpam Bee options when to display the widget/include the js.
Thanks for the great plugin!
- The topic ‘Suggestion: Check if widget exists in dashboard.js or widget display config’ is closed to new replies.