| @@ -43,5 +43,24 @@ | ||
| 43 | 43 | */ |
| 44 | 44 | private function error( $message ) { |
| 45 | 45 | throw new Exception( $message ); |
| 46 | 46 | } |
| 47 | + | |
| 48 | + public function get_sorted_queue( $notices = [], $queue = [] ) { | |
| 49 | + $_sorted_queue = []; | |
| 50 | + | |
| 51 | + if ( ! empty ( $queue ) ) { | |
| 52 | + array_walk( $queue, function ( $value, $key ) use ( &$_sorted_queue, $notices ) { | |
| 53 | + $notice = isset( $notices[ $key ] ) ? $notices[ $key ] : null; | |
| 54 | + if ( ! is_null( $notice ) ) { | |
| 55 | + if ( ! $notice->dismiss->is_dismissed() && ! $notice->is_expired() ) { | |
| 56 | + $_sorted_queue[ $notice->options( 'start' ) ] = $key; | |
| 57 | + } | |
| 58 | + } | |
| 59 | + } ); | |
| 60 | + } | |
| 61 | + | |
| 62 | + ksort( $_sorted_queue ); | |
| 63 | + | |
| 64 | + return $_sorted_queue; | |
| 65 | + } | |
| 47 | 66 | } |