From a441b571f03be70ecfa969f10523c39194fc75fb Mon Sep 17 00:00:00 2001 From: Leo Fajardo Date: Wed, 22 May 2024 17:40:30 +0800 Subject: [PATCH] [opt-in] Fixed an issue with the opt-in moderation and API connectivity test logic. --- includes/class-freemius.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/includes/class-freemius.php b/includes/class-freemius.php index 20b178be..347bc44d 100755 --- a/includes/class-freemius.php +++ b/includes/class-freemius.php @@ -4174,13 +4174,17 @@ function has_api_connectivity( $flush_if_no_connectivity = false ) { ! empty( $this->_storage->connectivity_test ) && isset( $this->_storage->connectivity_test['is_active'] ) ) { - $is_active = $this->_storage->connectivity_test['is_active']; + $is_connected = isset( $this->_storage->connectivity_test['is_connected'] ) ? + $this->_storage->connectivity_test['is_connected'] : + null; + $is_active = ( $this->_storage->connectivity_test['is_active'] || is_object( $this->_site ) ); } else { - $is_active = $this->should_turn_fs_on( $this->apply_filters( 'is_plugin_update', $this->is_plugin_update() ) ); - - $this->store_connectivity_info( (object) array( 'is_active' => $is_active ), null ); + $is_connected = null; + $is_active = $this->should_turn_fs_on( $this->apply_filters( 'is_plugin_update', $this->is_plugin_update() ) ); } + $this->store_connectivity_info( (object) array( 'is_active' => $is_active ), $is_connected ); + if ( $is_active ) { $this->_is_on = true; } @@ -5484,7 +5488,12 @@ private function parse_settings( &$plugin_info ) { 'affiliate_moderation' => $this->get_option( $plugin_info, 'has_affiliation' ), 'bundle_id' => $this->get_option( $plugin_info, 'bundle_id', null ), 'bundle_public_key' => $this->get_option( $plugin_info, 'bundle_public_key', null ), - 'opt_in_moderation' => $this->get_option( $plugin_info, 'opt_in', null ), + 'opt_in_moderation' => $this->get_option( + $plugin_info, + 'opt_in', + // For backward compatibility, we support both parameter names: opt_in and opt_in_moderation. + $this->get_option( $plugin_info, 'opt_in_moderation', null ) + ), ) ); if ( $plugin->is_updated() ) {