You’ve passed those $upgrader_object
and $options
parameters to prefix_plugin_upgrade
function. But you’re not actually using those parameters inside the function. So you can merge those functions like below-
/**
* Update plugin settings on activate
* Update plugin settings on upgrade
*/
function prefix_plugin_activate() {
$new_option = array( 'new_setting' => 'on' );
$existing_settings = get_option( 'existing_settings' );
$new_settings = array_merge( $new_option, $existing_settings );
update_option( 'existing_settings', $new_settings );
}
// register_activation_hook( __FILE__, 'prefix_plugin_activate' );
register_activation_hook( PREFIX_PLUGIN_PATH . 'main-plugin-file.php', 'prefix_plugin_activate' );
add_action( 'upgrader_process_complete', 'prefix_plugin_activate', 10, 2);
Hope this is gonna help.