PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 3.8.9
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v3.8.9
4.9.2 4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 All 200 releases
betterdocs / vendor / priyomukul / wp-notice / src / Utils / Helper.php

Helper.php in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 3.8.9, at vendor/priyomukul/wp-notice/src/Utils/Helper.php

66 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace PriyoMukul\WPNotice\Utils;
4
5 use Exception;
6
7 trait Helper {
8
9 public function is_installed( $plugin ) {
10 if ( ! function_exists( 'get_plugins' ) ) {
11 require_once ABSPATH . 'wp-admin/includes/plugin.php';
12 }
13 $plugins = get_plugins();
14
15 return isset( $plugins[ $plugin ] ) ? $plugins[ $plugin ] : false;
16 }
17
18 /**
19 * Get current timestamp
20 * @return integer
21 */
22 public function time() {
23 return intval( current_time( 'timestamp' ) );
24 }
25
26 /**
27 * Make timestamp for a number
28 *
29 * @param string $time
30 *
31 * @return int
32 */
33 public function strtotime( $time = '+7 day' ) {
34 return intval( strtotime( date( 'r', $this->time() ) . " $time" ) );
35 }
36
37 public function date( $time ) {
38 return date( 'd-m-Y h:i:s', $time );
39 }
40
41 /**
42 * @throws Exception
43 */
44 private function error( $message ) {
45 throw new Exception( $message );
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 }
66 }