The do_dismiss_core_update() WordPress PHP function dismisses a core update for WordPress.
Usage
To use this function, simply call it without any parameters. It will dismiss the current core update notification in your WordPress admin dashboard.
do_dismiss_core_update();
Parameters
This function does not require any parameters.
More Information
See WordPress Developer Resources: do_dismiss_core_update()
It’s important to note that this function was implemented in WordPress version 2.7.0.
Examples
Dismissing a Core Update
When you want to dismiss a core update notification, you can simply call the function in your code.
// Dismiss the current core update. do_dismiss_core_update();
This line of code will dismiss the core update notification in your WordPress admin dashboard.
Using with a Conditional
You can use this function in a conditional statement. Let’s say you have a variable $dismiss_update that you set to true when you want to dismiss the update.
$dismiss_update = true;
if ($dismiss_update) {
// Dismiss the core update.
do_dismiss_core_update();
}
In this example, if $dismiss_update is true, the function will dismiss the core update.
Calling Inside a Function
If you want to dismiss the update in response to a certain action, you might want to wrap do_dismiss_core_update() inside another function. Here, we’ll create a function that dismisses the update when called.
function my_dismiss_update() {
// Dismiss the core update.
do_dismiss_core_update();
}
Now, whenever my_dismiss_update() is called, the core update will be dismissed.
Dismissing Update on a Hook
You can also use this function in combination with a WordPress action hook. In the following example, the core update will be dismissed when the admin_init action is run.
add_action('admin_init', 'do_dismiss_core_update');
This will dismiss the core update every time an admin page is initialized.
Using with a Filter
In this last example, we’ll use a filter to conditionally dismiss the update. We’ll create a filter should_dismiss_update that other parts of our code (or other plugins) can use to decide whether or not to dismiss the update.
if (apply_filters('should_dismiss_update', false)) {
// Dismiss the core update.
do_dismiss_core_update();
}
In this example, if the should_dismiss_update filter returns true, the core update will be dismissed.