Skip to content

Commit

Permalink
[api] [connectivity] Improved and fixed an issue with the updating of…
Browse files Browse the repository at this point in the history
… the connectivity info.
  • Loading branch information
fajardoleo authored and vovafeldman committed Feb 12, 2023
1 parent 650a60d commit a27d499
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions includes/class-freemius.php
Original file line number Diff line number Diff line change
Expand Up @@ -4193,6 +4193,20 @@ private function store_connectivity_info( $pong, $is_connected ) {
$this->_is_on = $is_active || ( WP_FS__DEV_MODE && $is_connected && ! WP_FS__SIMULATE_FREEMIUS_OFF );
}

/**
* @author Leo Fajardo (@leorw)
* @since 2.5.4
*
* @param bool $is_connected
*/
private function update_connectivity_info( $is_connected ) {
$this->store_connectivity_info(
// This is true since we update the connection info only after a successful opt-in or license activation which means that Freemius has already been on even before the process.
(object) array( 'is_active' => true ),
$is_connected
);
}

/**
* Force turning Freemius on.
*
Expand Down Expand Up @@ -17407,20 +17421,12 @@ function opt_in(
$is_connected = ( ! FS_Api::is_blocked( $result ) );
}

$this->store_connectivity_info(
// This is true since the user is able to access the opt-in/license activation screen.
(object) array( 'is_active' => true ),
$is_connected
);
$this->update_connectivity_info( $is_connected );

return $result;
}

$this->store_connectivity_info(
// This is true since the user is able to access the opt-in/license activation screen.
(object) array( 'is_active' => true ),
true
);
$this->update_connectivity_info( true );

// Module is being uninstalled, don't handle the returned data.
if ( $is_uninstall ) {
Expand Down Expand Up @@ -17598,6 +17604,9 @@ function setup_network_account(
// Only network level opt-in can have more than one install.
$is_network_level_opt_in = true;
}

$this->update_connectivity_info( true );

// $is_network_level_opt_in = self::is_ajax_action_static( 'network_activate', $this->_module_id );
// If Freemius was OFF before, turn it on.
$this->turn_on();
Expand Down

0 comments on commit a27d499

Please sign in to comment.