Widget

Best-in-class sales automation, affiliate network, and education for digital business owners and online marketers. Free Website Tools. AddThis is known for our beautifully simple share buttons. But we also offer a full suite of website tools like list builder, link promotion, and recommended posts, all for free!

What's new in this version. 4.0.4/5 Addresses an issue where forecast in Weather widget may not show recent dates Resolves an issue where widgets may not load data after restart Fixed notification/popup service 4.0.3 Improved Weather widget stability & sources Addresses an issue where widgets do not refresh within its predefined interval after PC wakes Fixed an issue where extensions are not. ‎Widgetsmith lets you personalize your home screen like never before. It starts with a wide collection of highly customizable widgets, which range in function from date, to weather, to astronomy. Each can be adjusted precisely to best fit your desired function and appearance. This set of widge.

Topics

  • Overview
  • Examples
  • Widget Options

Added in WordPress Version 2.7, the Dashboard Widgets API makes it simple to add new widgets to the administration dashboard.

Doing so requires working knowledge of PHP and the WordPress Plugin API, but to plugin or theme authors familiar with hooking actions and filters, it only takes a few minutes and can be a great way to make your plugin even more useful.

Dashboard

Overview Overview

The main function The main function

The main tool needed to add Dashboard Widgets is the wp_add_dashboard_widget() function. You will find a complete description of this function on that link, but a brief overview is given below.

Usage Usage

  • $widget_id: an identifying slug for your widget. This will be used as its CSS class and its key in the array of widgets.
  • $widget_name: this is the name your widget will display in its heading.
  • $callback: The name of a function you will create that will display the actual contents of your widget.
  • $control_callback (Optional): The name of a function you create that will handle submission of widget options forms, and will also display the form elements.
  • $callback_args (Optional): Set of arguments for the callback function.

Action hooks Action hooks

My ebay dashboard widget 2.0 free download2.0

To run the function you will need to hook into the action wp_dashboard_setup via add_action(). For the Network Admin dashboard, use the hook wp_network_dashboard_setup.

Network dashboard:

Ebay

Examples Examples

Basic usage Basic usage

Forcing your widget to the top Forcing your widget to the top

Normally you should just let the users of your plugin put your Dashboard Widget wherever they want by dragging it around. There currently isn’t an easy API way to pre-sort the default widgets, meaning your new widget will always be at the bottom of the list. Until sorting is added to the API its a bit complicated to get around this problem.

Below is an example hooking function that will try to put your widget before the default ones. It does so by manually altering the internal array of metaboxes (of which dashboard widgets are one type) and putting your widget at the top of the list so it shows first.

My Ebay Dashboard Widget 2.0 Free Downloads

Unfortunately this only works for people who have never re-ordered their widgets. Once a user has done so their existing preferences will override this and they will have to move your widget to the top for it to stay there.

Removing default Dashboard Widgets Removing default Dashboard Widgets

In some situations, especially on multi-user blogs, it may be useful to completely remove widgets from the interface. Each individual user can, by default, turn off any given widget using the Screen Options tab at the top, but if you have a lot of non-technical users it might be nicer for them to not see it at all.

To remove dashboard widget, use the remove_meta_box() function. See the example codes below for the required parameters.

These are the names of the default widgets on the dashboard:

My Ebay Dashboard Widget 2.0 Free Download

Here is an example function that removes the QuickPress widget:

The example below removes all Dashboard Widgets:

Adding Widgets in the right side Adding Widgets in the right side

The function doesn’t allow you to choose where you want your widget to go and will automatically add it to the “core” which is the left side. However you are able to get it on the right side very easily.

My Ebay Dashboard Widget 2.0 Free

You can use the add_meta_box() function instead of wp_add_dashboard_widget. Simply specify ‘dashboard’ in place of the $post_type. For example:

Or, after creating the widget:

My Ebay Dashboard Widget 2.0 Free Online

Aggregating RSS feeds in the dashboard Aggregating RSS feeds in the dashboard

If you need to aggregate RSS in your widget you should take a look at the way the existing plugins are set up with caching in /wp-admin/includes/dashboard.php.

Widget Options Widget Options

WordPress does not provide a built-in way to fetch options for a specific widget. By default, you would need to use get_option( 'dashboard_widget_options' ) to fetch all widget options and then filter the returned array manually. This section presents some functions that can easily be added to a theme or plugin to help getting and setting of widget options.

Getting Widget Options Getting Widget Options

This function will fetch all widget options, or only options for a specified widget:

Get a Single Widget Option Get a Single Widget Option

If you want to easily fetch only a single option (for outputting to a theme), the following function will make that easier.

This example should be used with the previous Getting Widget Options example function.

Update Widget Options Update Widget Options

This function can be used to easily update all of a widget’s options. It can also be used to add a widget option non-destructively. Simply set the $add_option argument to true, and this will NOT overwrite any existing options (although it will add any missing ones).

See Also See Also

See Example Dashboard widget for more examples.