-
Notifications
You must be signed in to change notification settings - Fork 11
/
texty.php
164 lines (140 loc) · 3.29 KB
/
texty.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
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: Texty
* Description: SMS Notification for WordPress
* Plugin URI: https://wordpress.org/plugins/texty/
* Author: weDevs
* Author URI: https://wptexty.com/
* Version: 1.1.4
* License: GPL2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: texty
*/
defined( 'ABSPATH' ) || exit;
require __DIR__ . '/vendor/autoload.php';
/**
* Texty Class
*/
final class Texty {
/**
* Plugin version
*
* @var string
*/
private $version = '1.1.4';
/**
* Instances array
*
* @var array
*/
private $instances = [];
/**
* Initialize
*/
public function __construct() {
$this->define_constants();
$this->appsero_init();
// run the installer
register_activation_hook( __FILE__, [ $this, 'activate' ] );
// load the plugin
add_action( 'plugins_loaded', [ $this, 'init_plugin' ] );
}
/**
* Initializes the Texty class
*
* Checks for an existing Texty instance
* and if it doesn't find one, creates it.
*/
public static function instance() {
static $instance = false;
if ( ! $instance ) {
$instance = new self();
}
return $instance;
}
/**
* Initialize the plugin
*
* @return void
*/
public function init_plugin() {
if ( is_admin() ) {
new Texty\Admin();
}
new Texty\Api();
new Texty\Dispatcher();
}
/**
* Define constants
*
* @return void
*/
private function define_constants() {
define( 'TEXTY_VERSION', $this->version );
define( 'TEXTY_DIR', __DIR__ );
define( 'TEXTY_FILE', __FILE__ );
define( 'TEXTY_URL', plugins_url( '', __FILE__ ) );
}
/**
* Run the installer
*
* @return void
*/
public function activate() {
$installer = new Texty\Install();
$installer->run();
}
/**
* Access to gateway manager
*
* @return Texty\Gateways
*/
public function gateways() {
if ( ! isset( $this->instances['gateway'] ) ) {
$this->instances['gateway'] = new \Texty\Gateways();
}
return $this->instances['gateway'];
}
/**
* Access to gateway manager
*
* @return Texty\Settings
*/
public function settings() {
if ( ! isset( $this->instances['settings'] ) ) {
$this->instances['settings'] = new \Texty\Settings();
}
return $this->instances['settings'];
}
/**
* Access to gateway manager
*
* @return Texty\Notifications
*/
public function notifications() {
if ( ! isset( $this->instances['notification'] ) ) {
$this->instances['notification'] = new \Texty\Notifications();
}
return $this->instances['notification'];
}
/**
* Initialize the plugin tracker
*
* @return void
*/
public function appsero_init() {
$client = new Appsero\Client( 'd4c17b0f-8f01-4b95-a8de-42b0641eec9a', 'Texty', __FILE__ );
// Active insights
$client->insights()->init();
}
}
/**
* Return the instance
*
* @return \Texty
*/
function texty() {
return Texty::instance();
}
// take off
texty();