-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathnotification-slug-namexx.php
131 lines (118 loc) · 3.04 KB
/
notification-slug-namexx.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
<?php
/**
* Plugin Name: Notification : Nicenamexx
* Description: Extension for Notification plugin
* Plugin URI: https://bracketspace.com
* Author: BracketSpace
* Author URI: https://bracketspace.com
* Version: 1.0.0
* License: GPL3
* Text Domain: notification-slug-namexx
* Domain Path: /resources/languages
* Requires Plugins: notification
*
* @package notification/slug-namexx
*
* phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols
* phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
* phpcs:disable Squiz.Classes.ClassFileName.NoMatch
*/
declare(strict_types=1);
/**
* Things @todo. Replace globally these values:
* - XXNAMESPACEXX
* - Nicenamexx
* - slug_namexx
* - slug-namexx
* - notificationSlugNamexx
*
* You can do this with this simple command replacing the sed parts:
*
* find . -type f \( -iname \*.php -o -iname \*.txt -o -iname \*.json -o -iname \*.js \) -exec \
* sed -i 's/XXNAMESPACEXX/YOURNAMESPACE/g; s/Nicenamexx/Your Nicename/g; \
* s/slug_namexx/your_slug/g; s/slug-namexx/your-slug/g; s/notificationSlugNamexx/yourSlug/g' {} +
*
* Or just execute the rename.sh script
*/
if (! class_exists('NotificationXXNAMESPACEXX')) :
/**
* NotificationXXNAMESPACEXX class
*/
class NotificationXXNAMESPACEXX
{
/**
* Runtime object
*
* @var ?BracketSpace\Notification\XXNAMESPACEXX\Runtime
*/
protected static $runtime;
/**
* Initializes the plugin runtime
*
* @since [Next]
* @param string $pluginFile Main plugin file.
* @return BracketSpace\Notification\XXNAMESPACEXX\Runtime
*/
public static function init($pluginFile)
{
if (self::$runtime === null) {
// Autoloading.
require_once dirname($pluginFile) . '/vendor/autoload.php';
self::$runtime = new BracketSpace\Notification\XXNAMESPACEXX\Runtime($pluginFile);
}
return self::$runtime;
}
/**
* Gets runtime component
*
* @since [Next]
* @return array<class-string,mixed>
*/
public static function components()
{
return self::$runtime !== null ? self::$runtime->components() : [];
}
/**
* Gets runtime component
*
* @since [Next]
* @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 [Next]
* @return ?BracketSpace\Notification\XXNAMESPACEXX\Runtime
*/
public static function runtime()
{
return self::$runtime;
}
/**
* Gets plugin filesystem
*
* @since [Next]
* @throws \Exception When runtime wasn't invoked yet.
* @return \BracketSpace\Notification\XXNAMESPACEXX\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 () {
NotificationXXNAMESPACEXX::init(__FILE__)->init();
},
2
);