Latest TweetsLaunched a new #WordPress #plugin to keep comments open on old posts: perishablepress.com/wordpress-…
Perishable Press

Custom Widget Names with Dashboard Widgets Suite

Quick tutorial for my Dashboard Widgets Suite plugin. This post explains how to customize the DWS widget names on the Dashboard. Normally each DWS widget displays the widget name along with “Widgets Suite” and a little gear icon that links to the plugin settings. Several users have asked if there is a way to change the text, specifically how to remove the extra text and gear icon. So this article explains how to do it as of Dashboard Widgets Suite version 2.3 or better.

Customize All DWS Widget Names

To remove the gear icon and “Widgets Suite” text from all widget names/titles on the Dashboard, add the following code snippet to your theme’s functions.php file (or add via custom plugin):

// Dashboard Widgets Suite - Simplify Widget Names
function dashboard_widgets_suite_simplify_widget_names($widget_name, $widget, $suite, $link) {
	
	return $widget;
	
}
add_filter('dashboard_widgets_suite_name_control_panel', 'dashboard_widgets_suite_simplify_widget_names', 10, 4);
add_filter('dashboard_widgets_suite_name_debug_log',     'dashboard_widgets_suite_simplify_widget_names', 10, 4);
add_filter('dashboard_widgets_suite_name_error_log',     'dashboard_widgets_suite_simplify_widget_names', 10, 4);
add_filter('dashboard_widgets_suite_name_feed_box',      'dashboard_widgets_suite_simplify_widget_names', 10, 4);
add_filter('dashboard_widgets_suite_name_social_box',    'dashboard_widgets_suite_simplify_widget_names', 10, 4);
add_filter('dashboard_widgets_suite_name_list_box',      'dashboard_widgets_suite_simplify_widget_names', 10, 4);
add_filter('dashboard_widgets_suite_name_widget_box',    'dashboard_widgets_suite_simplify_widget_names', 10, 4);
add_filter('dashboard_widgets_suite_name_system_info',   'dashboard_widgets_suite_simplify_widget_names', 10, 4);
add_filter('dashboard_widgets_suite_name_user_notes',    'dashboard_widgets_suite_simplify_widget_names', 10, 4);

So to explain what’s happening here. First we have a function that is hooked into the name of each dashboard widget. You can see below the function where filter hooks are added via the WordPress add_filter function. So basically the simple function applies to every DWS widget on the Dashboard.

Then for the function itself. First notice it is passed four arguments:

$widget_name = Full text/markup for the widget name
$widget      = Text name of the widget, e.g. "Control Panel"
$suite       = Text that says "Widgets Suite"
$link        = Markup for gear-icon settings link

These variables make it easy to customize the name of all widgets quite easily. In this specific example, the function simply returns the name of the widget, $widget. So instead of displaying the default widget names like this:

[ Dashboard Widgets Suite - Default Widget Names ]Dashboard Widgets Suite – Default Widget Names

So when the above code is added, the DWS widgets will be displayed without the “Widgets Suite” text or gear icon, like this:

[ Dashboard Widgets Suite - Custom Widget Names ]Dashboard Widgets Suite – Custom Widget Names

So the first code snippet provided above works great to customize the names of all dashboard widgets provided by the DWS plugin. The passed variables give you much control over how the widget titles/names are displayed on the dashboard. You can mix and match, swap ’em out, or do whatever. And if you still need more control..

Customize Individual Widget Names

While the previous code snippet works great to customize all widget names, it’s also possible to customize widget names individually. Here is an example that shows how to customize the name of the default “Control Panel” widget:

// Dashboard Widgets Suite - Customize Name of Control Panel
function dashboard_widgets_suite_name_control_panel($widget_name, $widget, $suite, $link) {
	
	return 'Widget Control';
	
}
add_filter('dashboard_widgets_suite_name_control_panel', 'dashboard_widgets_suite_name_control_panel', 10, 4);

As-is, this function returns the value “Widget Control” to be used as the name of the “Control Panel” widget. So the “Widgets Suite” and gear icon will not be displayed, only the text that says, “Widget Control”. Of course, you can grab/use any of the same variables as before, as they are passed to the function via the filter hook:

$widget_name = Full text/markup for the widget name
$widget      = Text name of the widget, e.g. "Control Panel"
$suite       = Text that says "Widgets Suite"
$link        = Markup for gear-icon settings link

Literally anything is possible, so you can use the variables and/or your own text/markup to customize widget names exactly as desired.

Jeff Starr
About the Author Jeff Starr = Creative thinker. Passionate about free and open Web.
Archives
One response
  1. I did follow your guide and it works well. I can change the widget name to the one I like. Thanks for sharing

Drop a Comment  ]
RSS