diff --git a/inc/alert.php b/inc/alert.php index e01bd80..abafc50 100644 --- a/inc/alert.php +++ b/inc/alert.php @@ -140,6 +140,9 @@ class Alert { return apply_filters('ogrealert/get_active', $alerts); } + public static function has_active() { + return apply_filters('ogrealert/has_active', !empty(self::get_active())); + } public static function get_random() { $alerts = self::get_active(); diff --git a/inc/display.php b/inc/display.php index 780a9ac..afbe537 100644 --- a/inc/display.php +++ b/inc/display.php @@ -18,7 +18,7 @@ class Display { } static function init() { - if (empty(\OgreAlert\Alert::get_active())) return; + if (!\OgreAlert\Alert::has_active()) return; add_action('wp_enqueue_scripts', array(__CLASS__, 'enqueue_scripts')); @@ -47,11 +47,10 @@ class Display { } static function display_alerts() { - $ids = \OgreAlert\Alert::get_active(); - if (empty($ids)) return; + if (!\OgreAlert\Alert::has_active()) return; self::load_template('loop-start'); - foreach ($ids as $id) { + foreach (\OgreAlert\Alert::get_active() as $id) { self::load_template('alert', \OgreAlert\Priority::get($id), true, array('id' => $id)); } self::load_template('loop-end');