Function and usage of dismissed_updates() in wordpress


Answers ( 1 )


    The dismissed_updates() function in WordPress is used to display the updates that have been dismissed by the user. In WordPress, updates can include various elements such as core software updates, plugin updates, theme updates, and translation file updates. These updates are crucial for security, performance, and adding new features.

    When an update is presented in the WordPress admin dashboard, users have the option to dismiss or hide these update notifications for specific plugins, themes, or core updates. Once dismissed, these updates do not appear in the regular updates section. The dismissed_updates() function is used to retrieve and display these dismissed updates.

    Here is a detailed explanation and sample usage of the dismissed_updates() function:

    Function Definition

    • Function Name: dismissed_updates()
    • Purpose: To retrieve and display the list of updates that have been dismissed by the user.
    • Return Value: This function typically returns an array of dismissed updates, including details like the type of update (plugin, theme, core, etc.), the specific item that was updated, and version information.

    Sample Usage

    // Check if the function exists
    if (function_exists('dismissed_updates')) {
        // Get the list of dismissed updates
        $dismissed_updates = dismissed_updates();
        // Check if there are any dismissed updates
        if (!empty($dismissed_updates)) {
            echo '<h2>Dismissed Updates</h2>';
            echo '<ul>';
            // Loop through each dismissed update and display details
            foreach ($dismissed_updates as $update) {
                echo '<li>';
                echo 'Type: ' . esc_html($update->type) . '<br>';
                echo 'Item: ' . esc_html($update->item) . '<br>';
                echo 'Version: ' . esc_html($update->version);
                echo '</li>';
            echo '</ul>';
        } else {
            echo 'No dismissed updates.';
    } else {
        echo 'dismissed_updates function is not available.';

    In this example, the code first checks if the dismissed_updates() function exists. If it does, the function is called to get the list of dismissed updates. It then checks if there are any dismissed updates. If there are, it loops through each update, displaying the type, item, and version. If there are no dismissed updates, it displays a message indicating so.

    Use Case

    This function is particularly useful for developers and administrators who want to review which updates have been dismissed, perhaps for reconsideration or to ensure that important updates are not being ignored.

    Please note, the exact behavior and return value of this function might vary based on the WordPress version and the context in which it is used. It's always a good practice to refer to the official WordPress documentation or the source code for the most accurate and up-to-date information.

Leave an answer