-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignature-notification.php
114 lines (102 loc) · 2.47 KB
/
signature-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
<?php
/**
* Plugin Name: Notification : Signature
* Description: Add your own Signature to Notification Emails
* Plugin URI: https://bracketspace.com
* Author: BracketSpace
* Author URI: https://bracketspace.com
* Version: 4.0.0
* License: GPL3
* Text Domain: notification-signature
* Domain Path: /languages
* Requires Plugins: notification
*
* @package notification/signature
*
* phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols
* phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
* phpcs:disable Squiz.Classes.ClassFileName.NoMatch
*/
declare(strict_types=1);
if (! class_exists('NotificationSignature')) :
/**
* NotificationSignature class
*/
class NotificationSignature
{
/**
* Runtime object
*
* @var ?BracketSpace\Notification\Signature\Runtime
*/
protected static $runtime;
/**
* Initializes the plugin runtime
*
* @since 2.2.0
* @param string $pluginFile Main plugin file.
* @return BracketSpace\Notification\Signature\Runtime
*/
public static function init($pluginFile)
{
if (self::$runtime === null) {
// Autoloading.
require_once dirname($pluginFile) . '/vendor/autoload.php';
self::$runtime = new BracketSpace\Notification\Signature\Runtime($pluginFile);
}
return self::$runtime;
}
/**
* Gets runtime component
*
* @since 2.2.0
* @return array<class-string,mixed>
*/
public static function components()
{
return self::$runtime !== null ? self::$runtime->components() : [];
}
/**
* Gets runtime component
*
* @since 2.2.0
* @param string $componentName Component name.
* @return mixed
*/
public static function component($componentName)
{
return self::$runtime !== null ? self::$runtime->component($componentName) : null;
}
/**
* Gets runtime object
*
* @since 2.2.0
* @return ?BracketSpace\Notification\Signature\Runtime
*/
public static function runtime()
{
return self::$runtime;
}
/**
* Gets plugin filesystem
*
* @since 4.0.0
* @throws \Exception When runtime wasn't invoked yet.
* @return \BracketSpace\Notification\Signature\Dependencies\Micropackage\Filesystem\Filesystem
*/
public static function fs()
{
if (self::$runtime === null) {
throw new \Exception('Runtime has not been invoked yet.');
}
return self::$runtime->getFilesystem();
}
}
endif;
add_action(
'notification/init',
static function () {
NotificationSignature::init(__FILE__)->init();
},
2
);