Using WordPress ‘dismissed_updates()’ PHP function

The dismissed_updates() WordPress PHP function is used to display the updates that have been dismissed by the user.

Usage

To use the dismissed_updates() function, simply call it within your WordPress theme or plugin:

dismissed_updates();

This function doesn’t require any parameters or return any value. It directly prints the dismissed updates.

Parameters

This function doesn’t take any parameters.

More information

See WordPress Developer Resources: dismissed_updates()

The dismissed_updates() function was implemented in WordPress version 2.7.0 and, as of the time of writing, it has not been deprecated. You can find its source code in the ‘wp-admin/includes/update.php’ file of your WordPress installation.

Examples

Display Dismissed Updates on a Custom Page

In this example, we will create a custom page in the WordPress dashboard to display the dismissed updates.

// Add a custom page in the admin dashboard
function my_custom_page() {
    add_menu_page(
        'Dismissed Updates', // Page title
        'Dismissed Updates', // Menu title
        'manage_options',    // Capability
        'dismissed-updates', // Menu slug
        'my_custom_page_content' // Function to display the page content
    );
}
add_action('admin_menu', 'my_custom_page');

// Function to display the page content
function my_custom_page_content() {
    echo '<div class="wrap">';
    echo '<h1>Dismissed Updates</h1>';
    dismissed_updates();
    echo '</div>';
}

Display Dismissed Updates in a Meta Box

In this example, we’ll add a meta box to the post editing screen that will display the dismissed updates.

function my_custom_meta_box() {
    add_meta_box(
        'dismissed-updates', // ID of the meta box
        'Dismissed Updates', // Title of the meta box
        'my_meta_box_content', // Function to display the meta box content
        'post' // Post type
    );
}
add_action('add_meta_boxes', 'my_custom_meta_box');

// Function to display the meta box content
function my_meta_box_content() {
    dismissed_updates();
}

Display Dismissed Updates on the Front-end

In this example, we’ll create a shortcode that you can use to display the dismissed updates on the front-end of your site.

function dismissed_updates_shortcode() {
    ob_start();
    dismissed_updates();
    return ob_get_clean();
}
add_shortcode('dismissed-updates', 'dismissed_updates_shortcode');

Hide Dismissed Updates

In this example, we’ll prevent WordPress from displaying the dismissed updates.

remove_action('admin_notices', 'dismissed_updates');

Display Dismissed Updates in a Custom Widget

In this example, we’ll create a custom dashboard widget that displays the dismissed updates.

function my_custom_dashboard_widget() {
    wp_add_dashboard_widget(
        'dismissed-updates', // Widget slug
        'Dismissed Updates', // Title
        'my_widget_content' // Display function
    );
}
add_action('wp_dashboard_setup', 'my_custom_dashboard_widget');

// Function to display the widget content
function my_widget_content() {
    dismissed_updates();
}