Skip to content

Commit a441b57

Browse files
fajardoleoswashata
authored andcommitted
[opt-in] Fixed an issue with the opt-in moderation and API connectivity test logic.
1 parent c23bd6b commit a441b57

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

includes/class-freemius.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4174,13 +4174,17 @@ function has_api_connectivity( $flush_if_no_connectivity = false ) {
41744174
! empty( $this->_storage->connectivity_test ) &&
41754175
isset( $this->_storage->connectivity_test['is_active'] )
41764176
) {
4177-
$is_active = $this->_storage->connectivity_test['is_active'];
4177+
$is_connected = isset( $this->_storage->connectivity_test['is_connected'] ) ?
4178+
$this->_storage->connectivity_test['is_connected'] :
4179+
null;
4180+
$is_active = ( $this->_storage->connectivity_test['is_active'] || is_object( $this->_site ) );
41784181
} else {
4179-
$is_active = $this->should_turn_fs_on( $this->apply_filters( 'is_plugin_update', $this->is_plugin_update() ) );
4180-
4181-
$this->store_connectivity_info( (object) array( 'is_active' => $is_active ), null );
4182+
$is_connected = null;
4183+
$is_active = $this->should_turn_fs_on( $this->apply_filters( 'is_plugin_update', $this->is_plugin_update() ) );
41824184
}
41834185

4186+
$this->store_connectivity_info( (object) array( 'is_active' => $is_active ), $is_connected );
4187+
41844188
if ( $is_active ) {
41854189
$this->_is_on = true;
41864190
}
@@ -5484,7 +5488,12 @@ private function parse_settings( &$plugin_info ) {
54845488
'affiliate_moderation' => $this->get_option( $plugin_info, 'has_affiliation' ),
54855489
'bundle_id' => $this->get_option( $plugin_info, 'bundle_id', null ),
54865490
'bundle_public_key' => $this->get_option( $plugin_info, 'bundle_public_key', null ),
5487-
'opt_in_moderation' => $this->get_option( $plugin_info, 'opt_in', null ),
5491+
'opt_in_moderation' => $this->get_option(
5492+
$plugin_info,
5493+
'opt_in',
5494+
// For backward compatibility, we support both parameter names: opt_in and opt_in_moderation.
5495+
$this->get_option( $plugin_info, 'opt_in_moderation', null )
5496+
),
54885497
) );
54895498

54905499
if ( $plugin->is_updated() ) {

0 commit comments

Comments
 (0)