From c85b35e29c8d8079c78e9f2dd088d7e9448c3dba Mon Sep 17 00:00:00 2001 From: "bfintal@gmail.com" <> Date: Mon, 18 Aug 2025 12:14:09 +0800 Subject: [PATCH] fix: when doing a rest api call, a php error stackable_add_welcome_notification is undefined can trigger --- src/pro.php | 6 ++++-- src/welcome/notification-rate.php | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/pro.php b/src/pro.php index 53319db5f9..6fb853e38c 100644 --- a/src/pro.php +++ b/src/pro.php @@ -87,8 +87,10 @@ class Stackable_Go_Premium_Notification { const OLD_TIMER_NOTICE_TIME = 604800; // 7 * 24 * 60 * 60 function __construct() { - add_action( 'admin_menu', array( $this, 'check_pro_notice_date' ), 9 ); - add_action( 'admin_menu', array( $this, 'go_premium_notice_old_raters' ), 9 ); + if ( is_admin() ) { + add_action( 'admin_menu', array( $this, 'check_pro_notice_date' ), 9 ); + add_action( 'admin_menu', array( $this, 'go_premium_notice_old_raters' ), 9 ); + } } /** diff --git a/src/welcome/notification-rate.php b/src/welcome/notification-rate.php index d4314f0e4f..f23dba1d4b 100644 --- a/src/welcome/notification-rate.php +++ b/src/welcome/notification-rate.php @@ -21,7 +21,9 @@ class Stackable_Welcome_Notification_Rate { const RATING_NOTICE_TIME = 432000; // 5 * 24 * 60 * 60 function __construct() { - add_action( 'admin_menu', array( $this, 'check_activation_date' ), 9 ); + if ( is_admin() ) { + add_action( 'admin_menu', array( $this, 'check_activation_date' ), 9 ); + } } /**