-
Notifications
You must be signed in to change notification settings - Fork 0
/
notification-buddypress.php
114 lines (102 loc) · 2.56 KB
/
notification-buddypress.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 : BuddyPress
* Description: BuddyPress integration with Notification plugin. Add Triggers for all BuddyPress actions.
* Plugin URI: http://wordpress.org/plugins/notification-buddypress/
* Author: BracketSpace
* Author URI: https://bracketspace.com
* Version: 3.0.0
* License: GPL3
* Text Domain: notification-buddypress
* Domain Path: /languages
* Requires Plugins: notification, buddypress
*
* @package notification/buddypress
*
* 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('NotificationBuddyPress')) :
/**
* NotificationBuddyPress class
*/
class NotificationBuddyPress
{
/**
* Runtime object
*
* @var ?BracketSpace\Notification\BuddyPress\Runtime
*/
protected static $runtime;
/**
* Initializes the plugin runtime
*
* @since 2.0.0
* @param string $pluginFile Main plugin file.
* @return BracketSpace\Notification\BuddyPress\Runtime
*/
public static function init($pluginFile)
{
if (self::$runtime === null) {
// Autoloading.
require_once dirname($pluginFile) . '/vendor/autoload.php';
self::$runtime = new BracketSpace\Notification\BuddyPress\Runtime($pluginFile);
}
return self::$runtime;
}
/**
* Gets runtime component
*
* @since 2.0.0
* @return array<class-string,mixed>
*/
public static function components()
{
return self::$runtime !== null ? self::$runtime->components() : [];
}
/**
* Gets runtime component
*
* @since 2.0.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.0.0
* @return ?BracketSpace\Notification\BuddyPress\Runtime
*/
public static function runtime()
{
return self::$runtime;
}
/**
* Gets plugin filesystem
*
* @since 2.0.0
* @throws \Exception When runtime wasn't invoked yet.
* @return \BracketSpace\Notification\BuddyPress\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 () {
NotificationBuddyPress::init(__FILE__)->init();
},
2
);