There where reports recently about a change in all in one migrations unlimited extension having an annoying EULA pop up that you have to accept to keep the plugin active.

its all handled by a new all-in-one-wp-migration-unlimited-extension\lib\controller\class-ai1wmue-eula-controller.php
so i reviewed the code contained within this and this uses a constant from within constants.php
// ================
// = EULA Version =
// ================
define( 'AI1WMUE_EULA_VERSION', '1.0' );
PHP
the code in all-in-one-wp-migration-unlimited-extension\lib\controller\class-ai1wmue-eula-controller.php
is a simple comparison that an option within the options table meets the same version in the defined constant
The code in the controller is as follows, it checks that we are an admin and can activate plugins and that the free version is running, and checks the current value of the ai1wmue_eula_accepted_version
option
/**
* Check if EULA needs to be displayed
*
* @return boolean
*/
public static function should_display_eula() {
// Only show on admin pages
if ( ! is_admin() ) {
return false;
}
// Check if user has capability to manage plugins
if ( ! current_user_can( 'activate_plugins' ) ) {
return false;
}
// Additional check: verify the plugin is actually active
if ( ! is_plugin_active( AI1WMUE_PLUGIN_BASENAME ) ) {
return false;
}
// Check if EULA has been accepted for current version
$accepted_version = get_option( 'ai1wmue_eula_accepted_version', '' );
// Show EULA if not accepted or if version has changed
return ( $accepted_version !== AI1WMUE_EULA_VERSION );
}
PHP
The complaint being that this is showing up on client sites and causing issues on upgrades, so what we need to do is add a snippet that handles all future changes to this code
Its immediately obvious we need to set ai1wmue_eula_accepted_version
and we should set it to the value of AI1WMUE_EULA_VERSION
I therefore came to the following code it only runs if the constant AI1WMUE_EULA_VERSION
is present and then updates the ai1wmue_eula_accepted_version
option to meet the current set version
add_action( 'admin_init', function () {
// Only proceed if the constant is defined
if ( defined( 'AI1WMUE_EULA_VERSION' ) ) {
$version = AI1WMUE_EULA_VERSION;
// Only update if needed
if ( get_option( 'ai1wmue_eula_accepted_version' ) !== $version ) {
update_option( 'ai1wmue_eula_accepted_version', $version );
}
}
});
PHP
This now stops this from showing as the value is instantly set on an admin_init
I have distributed this to all my sites in my utility plugin as an activate snippet another way to do this would be to save and execute the snippet via the code snippet extension in MainWP which is perfect for these situations.
Now we have no annoying popup and as long as the code isn’t extensively changed we should also not have issues in future versions as this should always set to the current version.
You can see the accompanying Video here:
Please Note: Although this works I strongly recommend reading and understanding the EULA before you auto accept them.