- Copy the code below into a file called plugin_filter.php
- Change the $pluginsNotToUpdate adding the plugins you want not to update, by using the plugin folder name and plugin filename
- Upload the file to your wp-plugins directory
<?php
/**
* @package Plugin_Filter
* @version 2.0
*/
/*
Plugin Name: Plugin Filter
Plugin URI: https://www.brideonline.com.au/
Description: Removes certain plugins from being updated.
Author: Ben Wise
Version: 2.0
Author URI: https://github.com/WiseOwl9000
*/
/**
* @param $update bool Ignore this it just is set to whether the plugin should be updated
* @param $plugin string Indicates which plugin will be upgraded. Contains the directory name of the plugin followed by / followed by the filename containing the "Plugin Name:" parameters.
*/
function filter_plugins_bol($update, $plugin)
{
/*
// debugging
error_log(print_r($plugin,true));
ob_start();
var_dump(func_get_args());
$econ = ob_get_contents();
debug_print_backtrace();
ob_end_clean();
error_log($econ);
*/
$pluginsNotToUpdate[] = "plugin-folder-name/plugin-file-name.php";
// add more plugins to exclude by repeating the line above with new plugin folder / plugin file
// Allow all plugins except the ones listed above to be updated
if (!in_array(trim($plugin),$pluginsNotToUpdate))
{
// error_log("plugin is not in list allowing");
return true; // return true to allow update to go ahead
}
// error_log("plugin is in list trying to abort");
return false;
}
// Now set that function up to execute when the admin_notices action is called
// Important priority should be higher to ensure our plugin gets the final say on whether the plugin can be updated or not.
// Priority 1 didn't work
add_filter( 'auto_update_plugin', 'filter_plugins_bol' ,20 /* priority */,2 /* argument count passed to filter function */);