|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 |
|
| 20 | +if ( ! function_exists( 'stackable_multiple_plugins_check' ) ) { |
| 21 | + // Prevent multiple Stackable plugin versions from being active simultaneously. |
| 22 | + function stackable_multiple_plugins_check() { |
| 23 | + if ( is_plugin_active( $GLOBALS['OTHER_STACKABLE_FILE'] ) ) { |
| 24 | + deactivate_plugins( $GLOBALS['OTHER_STACKABLE_FILE'] ); |
| 25 | + } |
| 26 | + } |
| 27 | +} |
| 28 | + |
| 29 | +if ( defined('STACKABLE_FILE') && STACKABLE_FILE !== __FILE__ && ! isset( $GLOBALS['OTHER_STACKABLE_FILE'] ) ) { |
| 30 | + // Get relative file path of the other Stackable version. |
| 31 | + preg_match( "#([^\/]*?\/plugin.php)$#", STACKABLE_FILE, $matches ); |
| 32 | + $GLOBALS['OTHER_STACKABLE_FILE'] = $matches[1]; |
| 33 | + |
| 34 | + register_activation_hook( __FILE__, 'stackable_multiple_plugins_check' ); |
| 35 | +} |
| 36 | + |
20 | 37 | // Freemius SDK: Auto deactivate the free version when activating the paid one. |
21 | 38 | if ( function_exists( 'sugb_fs' ) ) { |
22 | | - // Prevent PHP errors by checking sugb_fs return value. |
23 | | - // In the free version, sugb_fs() is a no-op function that returns null. |
24 | | - // Only proceed if sugb_fs() returns an object (i.e., the Freemius SDK is loaded). |
25 | | - if ( is_object( sugb_fs() ) ) { |
26 | | - sugb_fs()->set_basename( false, __FILE__ ); |
27 | | - return; |
28 | | - } |
| 39 | + sugb_fs()->set_basename( true, __FILE__ ); |
| 40 | + return; |
29 | 41 | } |
30 | 42 |
|
31 | 43 | defined( 'STACKABLE_SHOW_PRO_NOTICES' ) || define( 'STACKABLE_SHOW_PRO_NOTICES', true ); |
@@ -218,11 +230,6 @@ function is_frontend() { |
218 | 230 | */ |
219 | 231 | if ( STACKABLE_BUILD !== 'free' ) { |
220 | 232 | require_once( plugin_dir_path( __FILE__ ) . 'freemius.php' ); |
221 | | -} else if ( ! function_exists( 'sugb_fs' ) ) { |
222 | | - // Provide a no-op sugb_fs() stub for compatibility when Freemius SDK is not loaded. |
223 | | - // This allows themes and plugins to safely check for Stackable's presence. |
224 | | - // The function returns null and performs no actions. |
225 | | - function sugb_fs() {}; |
226 | 233 | } |
227 | 234 |
|
228 | 235 | /** |
|
0 commit comments