Skip to content

Commit 31adb03

Browse files
committed
add no-op function
1 parent fee8401 commit 31adb03

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

plugin.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@
1919

2020
// Freemius SDK: Auto deactivate the free version when activating the paid one.
2121
if ( function_exists( 'sugb_fs' ) ) {
22-
sugb_fs()->set_basename( true, __FILE__ );
23-
return;
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+
}
2429
}
2530

2631
defined( 'STACKABLE_SHOW_PRO_NOTICES' ) || define( 'STACKABLE_SHOW_PRO_NOTICES', true );
@@ -213,6 +218,11 @@ function is_frontend() {
213218
*/
214219
if ( STACKABLE_BUILD !== 'free' ) {
215220
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() {};
216226
}
217227

218228
/**

0 commit comments

Comments
 (0)