This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
in_theme_update_message-theme_key action
The dynamic portion of the hook name, $theme_key, refers to the theme slug as found in the WordPress.org themes repository.
To use in_theme_update_message-theme_key action, first you have to register it using add_action. You can write this code into functions.php of your activated theme or in a custom WordPress Plugin.
We at WePlugins, always prefer to create a custom WordPress Plugin while using hooks so nothing breaks when you update your WordPress Theme in the future.
In the below live example, we have defined a function execute_on_in_theme_update_message-theme_key_event which takes 2 parameters and we registered using add_action. The first parameter in_theme_update_message-theme_key is the name of the hook, The second parameter execute_on_in_theme_update_message-theme_key_event is the name of the function which needs to be called, the third parameter is the priority of calling the hook if the same hook is used multiple times and the last parameter is the number of arguments (if any) to be passed in the registered function.
Sometimes, you have to remove a registered hook so you can use remove_action to remove in_theme_update_message-theme_key action.
Parameters
- $theme : (WP_Theme) The WP_Theme object.
- $response : (array) An array of metadata about the available theme update.
‘new_version’ (string) New theme version.
‘url’ (string) Theme URL.
‘package’ (string) Theme update package URL.
Below are the 2 parameters required to use this hook.
Live Example 1
This example shows how to use the hook to display a custom message during theme update.
function weplugins_execute_on_in_theme_update_message_theme_key_event($theme, $response){ echo 'A new version of the theme is available!'; } // add the action add_action( "in_theme_update_message-{$theme_key}", "weplugins_execute_on_in_theme_update_message_theme_key_event" , 10, 2);
Live Example 2
This example demonstrates how to log theme update information.
function weplugins_log_theme_update_info($theme, $response) { error_log('Theme: ' . $theme->get('Name') . ' - New Version: ' . $response['new_version']); } // add the action add_action( "in_theme_update_message-{$theme_key}", "weplugins_log_theme_update_info", 20, 2);
Live Example 3
This example modifies the theme update message to include a custom URL.
function weplugins_custom_theme_update_message($theme, $response) { $response['url'] = 'https://custom-url.com'; } // add the action add_action( "in_theme_update_message-{$theme_key}", "weplugins_custom_theme_update_message", 10, 2);
To remove a hook callback, use the example below.
remove_action( "in_theme_update_message-{$theme_key}", "weplugins_execute_on_in_theme_update_message_theme_key_event", 10, 2 );
Please make sure to provide the same callback function name, priority, and number of arguments while removing the hook callback.
Contact Us
If you need any customization or help using this hook, feel free to contact us.
Explore the latest in WordPress
Trying to stay on top of it all? Get the best tools, resources and inspiration sent to your inbox every Wednesday.