Skip to content

Commit

Permalink
[auto-deactivation] [bug-fix] The auto deactivation of the free/premi…
Browse files Browse the repository at this point in the history
…um version upon an activation of the other version was only working for opted-in users.
  • Loading branch information
vovafeldman committed Jun 27, 2017
1 parent 5deb1b5 commit 9584d33
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions includes/class-freemius.php
Original file line number Diff line number Diff line change
Expand Up @@ -4119,19 +4119,10 @@ function _activate_plugin_event_hook() {
// Clear API cache on activation.
FS_Api::clear_cache();

if ( $this->is_registered() ) {
$is_premium_version_activation = ( current_filter() !== ( 'activate_' . $this->_free_plugin_basename ) );

if ( $is_premium_version_activation ) {
$this->reconnect_locally();
}

$this->_logger->info( 'Activating ' . ( $is_premium_version_activation ? 'premium' : 'free' ) . ' plugin version.' );

// Schedule re-activation event and sync.
// $this->sync_install( array(), true );
$this->schedule_install_sync();

// 1. If running in the activation of the FREE module, get the basename of the PREMIUM.
// 2. If running in the activation of the PREMIUM module, get the basename of the FREE.
$other_version_basename = $is_premium_version_activation ?
Expand All @@ -4148,6 +4139,15 @@ function _activate_plugin_event_hook() {
deactivate_plugins( $other_version_basename );
}

if ( $this->is_registered() ) {
if ( $is_premium_version_activation ) {
$this->reconnect_locally();
}

// Schedule re-activation event and sync.
// $this->sync_install( array(), true );
$this->schedule_install_sync();

// If activating the premium module version, add an admin notice to congratulate for an upgrade completion.
if ( $is_premium_version_activation ) {
$this->_admin_notices->add(
Expand Down

0 comments on commit 9584d33

Please sign in to comment.