[Under Review] Prevent updating when this is not allowed

I would like MainWP to implement the file_mod_allowed filter to stop installing themes, plugins and core.

The items should still show as updates-available, just not installable like the behavior in WordPress.

The reason we want this are;

  • It is bad practice to update production sites without first verifying the updates on a test environment. We want to enforce this within our MainWP installation
  • All our plugins and themes are managed in git and installed using composer. We automatically deploy staging sites with updates and deploy to production sites once approved.

This behavior was first partly available in MainWP but after #90 this is changed. But I don’t agree on this change. The correct solution to something like that I think would be something like:

add_filter('file_mod_allowed',  function($allowed, $context) {
   if($context == 'mainwp') return true;
   return $allowed;
});

And MainWP implementing the file_mod_allowed filter.

You can see similar functionality in the WordPress automatic updater where you would add a similar code to allow auto-updates when DISALLOW_FILE_MODS is set to true.

    public function allow_updater_file_mod( $allowed, $context ){
        if( $context == 'automatic_updater' ) return true;
        return $allowed;
    }

This issue was first posted on #109 albeit, less detailed.