Using WordPress ‘paused_plugins_notice()’ PHP function

The paused_plugins_notice() WordPress PHP function renders an admin notice when some plugins have been paused due to errors.

Usage

To use the paused_plugins_notice() function, simply call it inside an action hook. Here’s an example:

add_action('admin_notices', 'paused_plugins_notice');

Parameters

This function has no parameters.

More information

See WordPress Developer Resources: paused_plugins_notice()

This function is available since WordPress version 5.2.0.

Examples

Displaying Paused Plugins Notice

Display the notice about paused plugins when there are any.

// Hook the function to 'admin_notices' action
add_action('admin_notices', 'paused_plugins_notice');

Adding a Custom Paused Plugins Notice

Create a custom function to display a custom notice when plugins are paused.

function custom_paused_plugins_notice() {
    // Check if there are paused plugins
    if (!wp_is_recovery_mode()) {
        return;
    }

    // Display custom notice
    echo '<div class="notice notice-error"><p><strong>Attention!</strong> Some plugins have been paused due to errors.</p></div>';
}

// Hook the custom function to 'admin_notices' action
add_action('admin_notices', 'custom_paused_plugins_notice');

Combining Paused Plugins Notice with Other Notices

Display multiple admin notices including the paused plugins notice.

function multiple_admin_notices() {
    // Call paused_plugins_notice() function
    paused_plugins_notice();

    // Display another custom notice
    echo '<div class="notice notice-info"><p>Your custom notice goes here.</p></div>';
}

// Hook the function to 'admin_notices' action
add_action('admin_notices', 'multiple_admin_notices');

Conditionally Displaying Paused Plugins Notice

Display the paused plugins notice only for administrators.

function admin_only_paused_plugins_notice() {
    // Check if the current user is an administrator
    if (current_user_can('manage_options')) {
        // Display paused plugins notice
        paused_plugins_notice();
    }
}

// Hook the function to 'admin_notices' action
add_action('admin_notices', 'admin_only_paused_plugins_notice');

Adding a Dismissible Paused Plugins Notice

Make the paused plugins notice dismissible by users.

function dismissible_paused_plugins_notice() {
    // Check if there are paused plugins
    if (!wp_is_recovery_mode()) {
        return;
    }

    // Display dismissible notice
    echo '<div class="notice notice-error is-dismissible"><p><strong>Attention!</strong> Some plugins have been paused due to errors.</p></div>';
}

// Hook the custom function to 'admin_notices' action
add_action('admin_notices', 'dismissible_paused_plugins_notice');