Filter hook 'wp_dashboard_widgets'

in WP Core File wp-admin/includes/dashboard.php at line 144

View Source

wp_dashboard_widgets

Filter Hook
Description
Filters the list of widgets to load for the admin dashboard.

Hook Information

File Location wp-admin/includes/dashboard.php View on GitHub
Hook Type Filter
Line Number 144

Hook Parameters

Type Name Description
string[] $dashboard_widgets An array of dashboard widget IDs.

Usage Examples

Basic Usage
<?php
// Hook into wp_dashboard_widgets
add_filter('wp_dashboard_widgets', 'my_custom_filter', 10, 1);

function my_custom_filter($dashboard_widgets) {
    // Your custom filtering logic here
    return $dashboard_widgets;
}

Source Code Context

wp-admin/includes/dashboard.php:144 - How this hook is used in WordPress core
<?php
 139  		 *
 140  		 * @since 2.5.0
 141  		 *
 142  		 * @param string[] $dashboard_widgets An array of dashboard widget IDs.
 143  		 */
 144  		$dashboard_widgets = apply_filters( 'wp_dashboard_widgets', array() );
 145  	}
 146  
 147  	foreach ( $dashboard_widgets as $widget_id ) {
 148  		$name = empty( $wp_registered_widgets[ $widget_id ]['all_link'] ) ? $wp_registered_widgets[ $widget_id ]['name'] : $wp_registered_widgets[ $widget_id ]['name'] . " <a href='{$wp_registered_widgets[$widget_id]['all_link']}' class='edit-box open-box'>" . __( 'View all' ) . '</a>';
 149  		wp_add_dashboard_widget( $widget_id, $name, $wp_registered_widgets[ $widget_id ]['callback'], $wp_registered_widget_controls[ $widget_id ]['callback'] );

PHP Documentation

<?php
/**
		 * Filters the list of widgets to load for the admin dashboard.
		 *
		 * @since 2.5.0
		 *
		 * @param string[] $dashboard_widgets An array of dashboard widget IDs.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-admin/includes/dashboard.php
Related Hooks

Related hooks will be displayed here in future updates.