-
Notifications
You must be signed in to change notification settings - Fork 30
/
notification.php
136 lines (118 loc) · 2.97 KB
/
notification.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
/**
* Plugin Name: Notification
* Description: Customisable email and webhook notifications with powerful developer friendly API for custom triggers and notifications. Send alerts easily.
* Author: BracketSpace
* Author URI: https://bracketspace.com
* Version: 9.0.3
* Requires PHP: 7.4
* Requires at least: 5.8
* License: GPL3
* Text Domain: notification
* Domain Path: /languages
*
* @package notification
*/
if ( ! class_exists( 'Notification' ) ) :
/**
* Notification class
*/
class Notification {
/**
* Runtime object
*
* @var BracketSpace\Notification\Runtime
*/
protected static $runtime;
/**
* Initializes the plugin runtime
*
* @since 7.0.0
* @param string $pluginFile Main plugin file.
* @return BracketSpace\Notification\Runtime
*/
public static function init( $pluginFile ) {
if ( ! isset( self::$runtime ) ) {
// Autoloading.
require_once dirname( $pluginFile ) . '/vendor/autoload.php';
self::$runtime = new BracketSpace\Notification\Runtime( $pluginFile );
}
return self::$runtime;
}
/**
* Gets runtime component
*
* @since 7.0.0
* @return array
*/
public static function components() {
return isset( self::$runtime ) ? self::$runtime->components() : [];
}
/**
* Gets runtime component
*
* @since 7.0.0
* @param class-string $componentName Component name.
* @return mixed
*/
public static function component( $componentName ) {
return isset( self::$runtime ) ? self::$runtime->component( $componentName ) : null;
}
/**
* Gets runtime object
*
* @since 7.0.0
* @return BracketSpace\Notification\Runtime
*/
public static function runtime() {
return self::$runtime;
}
/**
* Gets plugin version
*
* @since 7.0.0
* @return string
*/
public static function version() {
return self::$runtime::VERSION;
}
/**
* Gets plugin filesystem
*
* @since 8.0.0
* @throws \Exception When settings class wasn't invoked yet.
* @return BracketSpace\Notification\Core\Settings
*/
public static function settings() {
$settings = self::component('BracketSpace\Notification\Core\Settings');
if (! $settings instanceof BracketSpace\Notification\Core\Settings) {
throw new Exception( 'Notification runtime has not been invoked yet.' );
}
return $settings;
}
/**
* Gets plugin settings instance
*
* @since 9.0.0
* @throws \Exception When runtime wasn't invoked yet.
* @return \BracketSpace\Notification\Dependencies\Micropackage\Filesystem\Filesystem
*/
public static function fs() {
if ( ! isset( self::$runtime ) ) {
throw new Exception( 'Notification runtime has not been invoked yet.' );
}
return self::$runtime->getFilesystem();
}
}
endif;
add_action( 'init', function() {
Notification::init( __FILE__ )->init();
}, 5 );
/**
* Overwrites the Filesystem method
*
* @since 7.0.4
*/
add_filter( 'filesystem_method', function() {
return 'direct';
}, 1000000 );