Initial commit.

This commit is contained in:
dcooperdalrymple
2021-02-19 16:43:21 -06:00
commit 22f6c8188e
206 changed files with 33366 additions and 0 deletions

55
inc/priority.php Normal file
View File

@@ -0,0 +1,55 @@
<?php
/**
* @package CleverOgre
* @subpackage OgreAlert
* @since OgreAlert 0.1.7
*/
namespace OgreAlert;
if (!defined('ABSPATH')) exit;
class Priority {
private static $priorities = array(
'high',
'normal',
'low',
);
public static function load() {
add_filter('ogrealert/get_active', array(__CLASS__, 'order'), 10, 1);
}
static function order($alerts) {
if (!is_array($alerts) || empty($alerts)) return $alerts;
$_alerts = array();
foreach ($alerts as $id) {
$_alerts[] = array(
'id' => $id,
'priority' => self::get($id),
);
}
usort($_alerts, function ($a, $b) {
return array_search($a['priority'], self::$priorities) > array_search($b['priority'], self::$priorities);
});
return wp_list_pluck($_alerts, 'id');
}
public static function get($id) {
if (!\OgreAlert\Alert::valid($id)) return false;
$value = get_post_meta($id, '_ogrealert_priority', true);
if (!$value || !in_array($value, self::$priorities)) {
$value = 'normal';
}
return $value;
}
}
\OgreAlert\Priority::load();