-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbomb.php
More file actions
164 lines (147 loc) · 3.92 KB
/
bomb.php
File metadata and controls
164 lines (147 loc) · 3.92 KB
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?php
/*
* Plugin Name: Bomb - SMS Notifier
* Plugin URI: https://redq.io
* Description: WooCommerce order notification plugin.
* Version: 1.0.0
* Author: RedQ, Inc
* Author URI: https://redq.io
* Requires at least: 4.7
* Tested up to: 5.5.1
*
* Text Domain: sms-notifier
* Domain Path: /languages/
*
* Copyright: © 2012-2020 RedQ,Inc.
* License: GNU General Public License v3.0
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*
*/
/**
* Class SmsNotifier
*/
class SmsNotifier
{
/**
* @var null
*/
protected static $_instance = null;
/**
* @create instance on self
*/
public static function instance()
{
if (is_null(self::$_instance)) {
self::$_instance = new self();
}
return self::$_instance;
}
public function __construct()
{
if (!defined('SMS_NOTIFIER_REQUIRED_PHP_VERSION')) {
define('SMS_NOTIFIER_REQUIRED_PHP_VERSION', 5.6);
}
if (!defined('SMS_NOTIFIER_REQUIRED_WP_VERSION')) {
define('SMS_NOTIFIER_REQUIRED_WP_VERSION', 4.5);
}
add_action('admin_init', array($this, 'check_version'));
if (!self::compatible_version()) {
return;
}
$this->sms_notifier_load_all_classes();
$this->sms_notifier_app_bootstrap();
add_action('plugins_loaded', array($this, 'sms_notifier_language_textdomain'), 1);
}
public function sms_notifier_load_all_classes()
{
include_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
}
/**
* App Bootstrap
* Fire all class
*/
public function sms_notifier_app_bootstrap()
{
/**
* Define plugin constant
*/
define('SMS_NOTIFIER_DIR', untrailingslashit(plugin_dir_path(__FILE__)));
define('SMS_NOTIFIER_URL', untrailingslashit(plugins_url(basename(plugin_dir_path(__FILE__)), basename(__FILE__))));
define('SMS_NOTIFIER_FILE', __FILE__);
define('SMS_NOTIFIER_CSS', SMS_NOTIFIER_URL . '/assets/css/');
define('SMS_NOTIFIER_JS', SMS_NOTIFIER_URL . '/assets/js/');
new SmsNotifier\Admin\Settings();
new SmsNotifier\Admin\SmsGatewayInit();
new SmsNotifier\Admin\AsyncHandler();
}
/**
* Get the template path.
*
* @return string
* @since 1.0.0
*/
public function template_path()
{
return apply_filters('sms_notifier_template_path', 'sms-notifier/');
}
/**
* Get the plugin path.
*
* @return string
* @since 1.0.0
*/
public function plugin_path()
{
return untrailingslashit(plugin_dir_path(__FILE__));
}
/**
* Get the plugin textdomain for multilingual.
* @return null
*/
public function sms_notifier_language_textdomain()
{
load_plugin_textdomain('sms-notifier', false, dirname(plugin_basename(__FILE__)) . '/languages/');
}
static function compatible_version()
{
if (phpversion() < SMS_NOTIFIER_REQUIRED_PHP_VERSION || $GLOBALS['wp_version'] < SMS_NOTIFIER_REQUIRED_WP_VERSION) return false;
return true;
}
// The backup sanity check, in case the plugin is activated in a weird way,
// or the versions change after activation.
public function check_version()
{
if (!self::compatible_version()) {
if (is_plugin_active(plugin_basename(__FILE__))) {
deactivate_plugins(plugin_basename(__FILE__));
add_action('admin_notices', array($this, 'disabled_notice'));
if (isset($_GET['activate'])) {
unset($_GET['activate']);
}
}
}
}
public function disabled_notice()
{
if (phpversion() < SMS_NOTIFIER_REQUIRED_PHP_VERSION) { ?>
<div class="notice notice-error is-dismissible">
<p><?php esc_html_e('SMS Notifier requires PHP ' . SMS_NOTIFIER_REQUIRED_PHP_VERSION . ' or higher!', 'sms-notifier'); ?></p>
</div>
<?php
}
if ($GLOBALS['wp_version'] < SMS_NOTIFIER_REQUIRED_WP_VERSION) { ?>
<div class="notice notice-error is-dismissible">
<p><?php esc_html_e('SMS Notifier requires Wordpress ' . SMS_NOTIFIER_REQUIRED_WP_VERSION . ' or higher!', 'sms-notifier'); ?></p>
</div>
<?php
}
}
}
/**
* @return null|SmsNotifier
*/
function SmsNotifier()
{
return SmsNotifier::instance();
}
$GLOBALS['sms_notifier'] = SmsNotifier();