From d3e9a455d71d921caf864abc584e1358af690605 Mon Sep 17 00:00:00 2001 From: Hein van Vlastuin <94352322+hein-obox@users.noreply.github.com> Date: Mon, 19 Jan 2026 14:25:50 +0200 Subject: [PATCH] Internal: Improve Notifications loading in Hello theme (#603) --- modules/admin-home/components/notificator.php | 39 ++++++++++++++++--- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/modules/admin-home/components/notificator.php b/modules/admin-home/components/notificator.php index 539dfae8..a99ffe3e 100644 --- a/modules/admin-home/components/notificator.php +++ b/modules/admin-home/components/notificator.php @@ -5,21 +5,23 @@ exit; // Exit if accessed directly. } -use Elementor\WPNotificationsPackage\V120\Notifications as Notifications_SDK; - class Notificator { - private ?Notifications_SDK $notificator = null; + private ?\Elementor\WPNotificationsPackage\V120\Notifications $notificator = null; public function get_notifications_by_conditions( $force_request = false ) { + if ( null === $this->notificator ) { + return []; + } + return $this->notificator->get_notifications_by_conditions( $force_request ); } public function __construct() { - if ( ! class_exists( 'Elementor\WPNotificationsPackage\V120\Notifications' ) ) { - require_once HELLO_THEME_PATH . '/vendor/autoload.php'; + if ( ! $this->ensure_notifications_class_loaded() ) { + return; } - $this->notificator = new Notifications_SDK( [ + $this->notificator = new \Elementor\WPNotificationsPackage\V120\Notifications( [ 'app_name' => 'hello-elementor', 'app_version' => HELLO_ELEMENTOR_VERSION, 'short_app_name' => 'hello-elementor', @@ -28,4 +30,29 @@ public function __construct() { ], ] ); } + + private function ensure_notifications_class_loaded(): bool { + if ( class_exists( 'Elementor\WPNotificationsPackage\V120\Notifications' ) ) { + return true; + } + + $elementor_autoload = defined( 'ELEMENTOR_PATH' ) + ? ELEMENTOR_PATH . 'vendor/autoload.php' + : WP_PLUGIN_DIR . '/elementor/vendor/autoload.php'; + + if ( file_exists( $elementor_autoload ) ) { + require_once $elementor_autoload; + } + + if ( class_exists( 'Elementor\WPNotificationsPackage\V120\Notifications' ) ) { + return true; + } + + $hello_theme_autoload = HELLO_THEME_PATH . '/vendor/autoload.php'; + if ( file_exists( $hello_theme_autoload ) ) { + require_once $hello_theme_autoload; + } + + return class_exists( 'Elementor\WPNotificationsPackage\V120\Notifications' ); + } }