Skip to content

Commit 3395977

Browse files
committed
Improved the support for plugins with free and premium versions that can be activated in parallel.
1 parent de76663 commit 3395977

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

includes/class-freemius.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7407,6 +7407,11 @@ function _activate_plugin_event_hook() {
74077407
$this->apply_filters( 'deactivate_on_activation', true )
74087408
) {
74097409
deactivate_plugins( $other_version_basename );
7410+
} else if ( $is_premium_version_activation ) {
7411+
/**
7412+
* To prevent the free version from loading before the premium version when both are active, remove the SDK reference associated with the free version if it's the newest.
7413+
*/
7414+
$this->remove_sdk_reference( $other_version_basename );
74107415
}
74117416
}
74127417

@@ -8201,17 +8206,27 @@ function _deactivate_plugin_hook() {
82018206
* @author Vova Feldman (@svovaf)
82028207
* @since 1.1.6
82038208
*/
8204-
private function remove_sdk_reference() {
8209+
private function remove_sdk_reference( $plugin_basename = null ) {
82058210
global $fs_active_plugins;
82068211

8212+
if ( is_null( $plugin_basename ) ) {
8213+
$plugin_basename = $this->_plugin_basename;
8214+
}
8215+
82078216
foreach ( $fs_active_plugins->plugins as $sdk_path => $data ) {
8208-
if ( $this->_plugin_basename == $data->plugin_path ) {
8217+
if ( $plugin_basename == $data->plugin_path ) {
82098218
unset( $fs_active_plugins->plugins[ $sdk_path ] );
82108219
break;
82118220
}
82128221
}
82138222

8214-
fs_fallback_to_newest_active_sdk();
8223+
if (
8224+
! empty( $fs_active_plugins->newest ) &&
8225+
! empty( $fs_active_plugins->newest->plugin_path ) &&
8226+
$fs_active_plugins->newest->plugin_path === $plugin_basename
8227+
) {
8228+
fs_fallback_to_newest_active_sdk();
8229+
}
82158230
}
82168231

82178232
/**

start.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
* @var string
1717
*/
18-
$this_sdk_version = '2.7.3.5';
18+
$this_sdk_version = '2.7.3.6';
1919

2020
#region SDK Selection Logic --------------------------------------------------------------------
2121

0 commit comments

Comments
 (0)