Skip to content

Commit f49b565

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

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

includes/class-freemius.php

Lines changed: 24 additions & 4 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

@@ -8198,20 +8203,35 @@ function _deactivate_plugin_hook() {
81988203
}
81998204

82008205
/**
8206+
* @since 1.1.6
8207+
* @since 1.7.4 The $plugin_basename parameter was added by Leo Fajardo (@leorw).
8208+
*
82018209
* @author Vova Feldman (@svovaf)
8202-
* @since 1.1.6
8210+
* @author Leo Fajardo (@leorw)
8211+
*
8212+
* @param string|null $plugin_basename
82038213
*/
8204-
private function remove_sdk_reference() {
8214+
private function remove_sdk_reference( $plugin_basename = null ) {
82058215
global $fs_active_plugins;
82068216

8217+
if ( is_null( $plugin_basename ) ) {
8218+
$plugin_basename = $this->_plugin_basename;
8219+
}
8220+
82078221
foreach ( $fs_active_plugins->plugins as $sdk_path => $data ) {
8208-
if ( $this->_plugin_basename == $data->plugin_path ) {
8222+
if ( $plugin_basename == $data->plugin_path ) {
82098223
unset( $fs_active_plugins->plugins[ $sdk_path ] );
82108224
break;
82118225
}
82128226
}
82138227

8214-
fs_fallback_to_newest_active_sdk();
8228+
if (
8229+
! empty( $fs_active_plugins->newest ) &&
8230+
! empty( $fs_active_plugins->newest->plugin_path ) &&
8231+
$fs_active_plugins->newest->plugin_path === $plugin_basename
8232+
) {
8233+
fs_fallback_to_newest_active_sdk();
8234+
}
82158235
}
82168236

82178237
/**

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)