canAccess()) { // do not display widget in case the user is not authorized return false; } $args = array(); // set widget ID as first argument $args[] = $widget->getID(); // set widget name as second argument $args[] = $widget->getName(); // set callback to display the widget contents $args[] = array($widget, 'getHtml'); // check if the widget supports a configuration if ($widget->getForm()) { // set callback to display the configuration form $args[] = array($widget, 'config'); // set configuration settings as last argument $args[] = $widget->getConfig(); } // call function to register the widget call_user_func_array('wp_add_dashboard_widget', $args); } }