Highlight premium plugins in the auto-update column
Add a label “Premium Plugin” to the auto-update column for premium plugins based on an array of premium plugin files.
add_filter('plugin_auto_update_setting_html', 'highlight_premium_plugins', 10, 3);
function highlight_premium_plugins($html, $plugin_file, $plugin_data) {
$premium_plugins = array(
'premium-plugin-1/premium-plugin-1.php',
'premium-plugin-2/premium-plugin-2.php',
);
if (in_array($plugin_file, $premium_plugins)) {
$html .= '<div class="premium-plugin-label">Premium Plugin</div>';
}
return $html;
}
Change auto-update column content for inactive plugins
Replace the auto-update column content with a custom message for inactive plugins.
add_filter('plugin_auto_update_setting_html', 'change_content_for_inactive_plugins', 10, 3);
function change_content_for_inactive_plugins($html, $plugin_file, $plugin_data) {
if (!is_plugin_active($plugin_file)) {
$html = '<span class="inactive-plugin">This plugin is inactive. Activate the plugin to manage auto-updates.</span>';
}
return $html;
}
Add custom icons to auto-update links
Add custom icons to the enable and disable auto-update links.
add_filter('plugin_auto_update_setting_html', 'add_custom_icons_to_auto_update_links', 10, 3);
function add_custom_icons_to_auto_update_links($html, $plugin_file, $plugin_data) {
$enable_icon = '<i class="custom-icon-enable"></i>';
$disable_icon = '<i class="custom-icon-disable"></i>';
$html = str_replace('Enable auto-updates', $enable_icon . ' Enable auto-updates', $html);
$html = str_replace('Disable auto-updates', $disable_icon . ' Disable auto-updates', $html);
return $html;
}
Add a custom action to the auto-update column
Add a custom action link to the auto-update column for each plugin.
add_filter('plugin_auto_update_setting_html', 'add_custom_action_to_auto_update_column', 10, 3);
function add_custom_action_to_auto_update_column($html, $plugin_file, $plugin_data) {
$custom_action = '<a href="#" class="custom-action">Custom Action</a>';
$html .= $custom_action;
return $html;
}
10. Remove auto-update links for specific user roles
Remove auto-update links for users with a specific user role, such as “editor”.
add_filter('plugin_auto_update_setting_html', 'remove_auto_update_links_for_specific_user_role', 10, 3);
function remove_auto_update_links_for_specific_user_role($html, $plugin_file, $plugin_data) {
$current_user = wp_get_current_user();
if (in_array('editor', $current_user->roles)) {
$html = preg_replace('/<a href=".*?" class="toggle-auto-update.*?<\/a>/', '', $html);
}
return $html;
}