2
0
Fork 0
mirror of https://github.com/elementor/hello-theme.git synced 2026-03-03 12:56:14 +08:00
hello-theme/modules/admin-home/components/notificator.php
Hein van Vlastuin d54df7cb8a
Some checks are pending
Build / Build theme (push) Waiting to run
Lint / ESLint (push) Waiting to run
Lint / PHPCS (push) Waiting to run
PHPUnit / File Diff (push) Waiting to run
PHPUnit / PHPUnit - WordPress 6.5 - PHP version 7.4 (push) Blocked by required conditions
PHPUnit / PHPUnit - WordPress 6.6 - PHP version 7.4 (push) Blocked by required conditions
PHPUnit / PHPUnit - WordPress latest - PHP version 7.4 (push) Blocked by required conditions
PHPUnit / PHPUnit - WordPress nightly - PHP version 7.4 (push) Blocked by required conditions
PHPUnit / PHPUnit - WordPress 6.5 - PHP version 8.0 (push) Blocked by required conditions
PHPUnit / PHPUnit - WordPress 6.6 - PHP version 8.0 (push) Blocked by required conditions
PHPUnit / PHPUnit - WordPress latest - PHP version 8.0 (push) Blocked by required conditions
PHPUnit / PHPUnit - WordPress nightly - PHP version 8.0 (push) Blocked by required conditions
PHPUnit / PHPUnit - WordPress 6.5 - PHP version 8.1 (push) Blocked by required conditions
PHPUnit / PHPUnit - WordPress 6.6 - PHP version 8.1 (push) Blocked by required conditions
PHPUnit / PHPUnit - WordPress latest - PHP version 8.1 (push) Blocked by required conditions
PHPUnit / PHPUnit - WordPress nightly - PHP version 8.1 (push) Blocked by required conditions
PHPUnit / PHPUnit - WordPress 6.5 - PHP version 8.2 (push) Blocked by required conditions
PHPUnit / PHPUnit - WordPress 6.6 - PHP version 8.2 (push) Blocked by required conditions
PHPUnit / PHPUnit - WordPress latest - PHP version 8.2 (push) Blocked by required conditions
PHPUnit / PHPUnit - WordPress nightly - PHP version 8.2 (push) Blocked by required conditions
PHPUnit / PHPUnit - WordPress 6.5 - PHP version 8.3 (push) Blocked by required conditions
PHPUnit / PHPUnit - WordPress 6.6 - PHP version 8.3 (push) Blocked by required conditions
PHPUnit / PHPUnit - WordPress latest - PHP version 8.3 (push) Blocked by required conditions
PHPUnit / PHPUnit - WordPress nightly - PHP version 8.3 (push) Blocked by required conditions
PHPUnit / PHPUnit - Test Results (push) Blocked by required conditions
Internal: Improve Notifications loading in Hello theme (#603)
2026-01-19 14:25:50 +02:00

58 lines
1.6 KiB
PHP

<?php
namespace HelloTheme\Modules\AdminHome\Components;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
class Notificator {
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 ( ! $this->ensure_notifications_class_loaded() ) {
return;
}
$this->notificator = new \Elementor\WPNotificationsPackage\V120\Notifications( [
'app_name' => 'hello-elementor',
'app_version' => HELLO_ELEMENTOR_VERSION,
'short_app_name' => 'hello-elementor',
'app_data' => [
'theme_name' => 'hello-elementor',
],
] );
}
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' );
}
}