The core_update_footer() WordPress PHP function returns a message in the admin footer regarding the core update status of the WordPress installation.
Usage
Below is an example of using the core_update_footer() function:
add_filter('update_footer', 'custom_update_footer', 9999); function custom_update_footer($msg = '') { // Code implementation here }
In this example, the ‘update_footer’ action hook is being used to modify the default WordPress admin footer message. The custom_update_footer
function, which is tied to the action hook, receives an optional parameter $msg
, a string containing the current admin footer message.
Parameters
- $msg (string) – This is an optional parameter that represents the current admin footer message.
More information
See WordPress Developer Resources: core_update_footer
This function has been available since WordPress version 2.3.
Examples
Basic usage of core_update_footer
add_filter('update_footer', 'custom_update_footer', 9999); function custom_update_footer($msg = '') { return 'Custom footer message'; }
This example simply changes the default admin footer message to ‘Custom footer message’.
Displaying the current WordPress version
add_filter('update_footer', 'version_footer', 9999); function version_footer($msg = '') { return 'Version ' . get_bloginfo('version', 'display'); }
This example changes the admin footer message to display the current version of WordPress.
Displaying a different message for non-admin users
add_filter('update_footer', 'user_specific_footer', 9999); function user_specific_footer($msg = '') { if (!current_user_can('update_core')) { return 'You are not allowed to update WordPress.'; } else { return 'Version ' . get_bloginfo('version', 'display'); } }
This example changes the footer message based on the user’s capabilities. Non-admin users see a different message.
Displaying update status
add_filter('update_footer', 'update_status_footer', 9999); function update_status_footer($msg = '') { $update_data = get_preferred_from_update_core(); if ($update_data->response == 'upgrade') { return 'New WordPress version available!'; } else { return 'Your WordPress is up to date.'; } }
This example checks if there is a new WordPress version available and changes the footer message accordingly.
Providing a link to updates page
add_filter('update_footer', 'update_link_footer', 9999); function update_link_footer($msg = '') { $update_data = get_preferred_from_update_core(); if ($update_data->response == 'upgrade') { return '<a href="' . network_admin_url('update-core.php') . '">Update to new WordPress version now!</a>'; } else { return 'Your WordPress is up to date.'; } }
In this example, if a new WordPress version is available, a link to the updates page is displayed in the footer.