forked from BracketSpace/Notification
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotification.php
130 lines (106 loc) · 2.92 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
<?php
/*
Plugin Name: Notification
Description: Send email notifications about various events in WordPress. You can also create your custom triggers for any action.
Plugin URI: https://notification.underdev.it
Author: underDEV
Author URI: https://underdev.it
Version: 3.1.1
License: GPL3
Text Domain: notification
Domain Path: /languages
*/
if ( ! defined( 'NOTIFICATION_URL' ) ) {
define( 'NOTIFICATION_URL', plugin_dir_url( __FILE__ ) );
}
if ( ! defined( 'NOTIFICATION_DIR' ) ) {
define( 'NOTIFICATION_DIR', plugin_dir_path( __FILE__ ) );
}
/**
* Composer autoload
*/
require_once( 'vendor/autoload.php' );
/**
* Check minimum requirements of the plugin
* @param string $php_ver The minimum PHP version.
* @param string $wp_ver The minimum WP version.
* @param string $name The name of the theme/plugin to check.
* @param array $plugins Required plugins format plugin_path/plugin_name.
*/
$requirements = new Minimum_Requirements( '5.3', '3.6', __( 'Notification', 'notification' ), array() );
/**
* Check compatibility on activation
*/
register_activation_hook( __FILE__, array( $requirements, 'check_compatibility_on_install' ) );
/**
* If it is already installed and activated check if example new version is compatible,
* if is not don't load plugin code and print admin_notice
*/
if ( ! $requirements->is_compatible_version() ) {
add_action( 'admin_notices', array( $requirements, 'load_plugin_admin_notices' ) );
return;
}
/**
* Setup plugin
* @return void
*/
function notification_plugin_setup() {
load_plugin_textdomain( 'notification', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}
add_action( 'plugins_loaded', 'notification_plugin_setup' );
/**
* Initialize plugin
* @return void
*/
function notification_initialize() {
/**
* Notifications instance
*/
underDEV\Notification\Notifications::get();
/**
* Settings instance
*/
underDEV\Notification\Settings::get();
}
add_action( 'init', 'notification_initialize', 5 );
/**
* Initialize default triggers and recipients
* @return void
*/
function notification_default_triggers_recipients_initialization() {
/**
* Load some default triggers
*/
require_once( NOTIFICATION_DIR . trailingslashit( 'triggers' ) . 'triggers.php' );
/**
* Load default recipients
*/
require_once( NOTIFICATION_DIR . trailingslashit( 'recipients' ) . 'recipients.php' );
}
add_action( 'init', 'notification_default_triggers_recipients_initialization', 9 );
/**
* Initialize plugin on admin side
* @return void
*/
function notification_admin_initialize() {
/**
* Admin instance
*/
underDEV\Notification\Admin::get();
/**
* Extensions
*/
underDEV\Notification\Extensions::get();
}
add_action( 'init', 'notification_admin_initialize', 5 );
/**
* Initialize Upgrader
* @return void
*/
function notification_upgrade() {
/**
* Upgrade instance
*/
underDEV\Notification\Upgrade::get();
}
add_action( 'admin_init', 'notification_upgrade', 5 );