The install_theme_overwrite_actions WordPress PHP Filter allows you to modify the list of action links displayed after a single theme installation failure when overwriting is allowed.
Usage
add_filter('install_theme_overwrite_actions', 'your_custom_function', 10, 3); function your_custom_function($install_actions, $api, $new_theme_data) { // your custom code here return $install_actions; }
Parameters
- $install_actions (string[]): Array of theme action links.
- $api (object): Object containing WordPress.org API theme data.
- $new_theme_data (array): Array with uploaded theme data.
More information
See WordPress Developer Resources: install_theme_overwrite_actions
Examples
Add a custom link to the action list
Add a custom link to the list of theme action links after a failed installation.
add_filter('install_theme_overwrite_actions', 'add_custom_link', 10, 3); function add_custom_link($install_actions, $api, $new_theme_data) { $install_actions['custom_link'] = '<a href="https://example.com">Custom Link</a>'; return $install_actions; }
Remove a specific link from the action list
Remove the “Activate” link from the list of theme action links after a failed installation.
add_filter('install_theme_overwrite_actions', 'remove_activate_link', 10, 3); function remove_activate_link($install_actions, $api, $new_theme_data) { unset($install_actions['activate']); return $install_actions; }
Change the text of a link in the action list
Change the text of the “Preview” link to “Try it out!” after a failed installation.
add_filter('install_theme_overwrite_actions', 'change_preview_text', 10, 3); function change_preview_text($install_actions, $api, $new_theme_data) { $install_actions['preview'] = str_replace('Preview', 'Try it out!', $install_actions['preview']); return $install_actions; }
Add a conditional link to the action list
Add a link to the theme’s support page if the theme has one.
add_filter('install_theme_overwrite_actions', 'add_support_link', 10, 3); function add_support_link($install_actions, $api, $new_theme_data) { if (!empty($api->sections['support'])) { $install_actions['support'] = '<a href="' . esc_url($api->sections['support']) . '">Theme Support</a>'; } return $install_actions; }
Rearrange the order of links in the action list
Move the “Preview” link to the beginning of the list of theme action links.
add_filter('install_theme_overwrite_actions', 'reorder_preview_link', 10, 3); function reorder_preview_link($install_actions, $api, $new_theme_data) { $preview_link = $install_actions['preview']; unset($install_actions['preview']); $install_actions = array('preview' => $preview_link) + $install_actions; return $install_actions; }