WordPress.org

Ready to get started?Download WordPress

Forums

Advanced Automatic Updates
Selective auto-updating of plugins (2 posts)

  1. Wombat
    Member
    Posted 9 months ago #

    Was wondering if this plugin will ever have a feature to selectively update plugins? Almost any site I build has about 95% unmodified plugins and some modded ones which cannot be updated automatically without breaking the machine.

    http://wordpress.org/plugins/automatic-updater/

  2. wiseowl9000
    Member
    Posted 8 months ago #

    1. Copy the code below into a file called plugin_filter.php
    2. Change the $pluginsNotToUpdate adding the plugins you want not to update, by using the plugin folder name and plugin filename
    3. Upload the file to your wp-plugins directory
    <?php
    /**
     * @package Plugin_Filter
     * @version 2.0
     */
    /*
    Plugin Name: Plugin Filter
    Plugin URI: http://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  */);

Reply

You must log in to post.

About this Plugin

About this Topic