PluginProbe
Texty – SMS Notification for WordPress, WooCommerce, Dokan and more / trunk
Texty – SMS Notification for WordPress, WooCommerce, Dokan and more vtrunk
2.0.2 trunk 0.2 1.0 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 2.0.0 2.0.1
texty / texty.php

texty.php in Texty – SMS Notification for WordPress, WooCommerce, Dokan and more trunk, at texty.php

259 lines 6.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Texty
4 * Description: SMS Notification for WordPress
5 * Plugin URI: https://wordpress.org/plugins/texty/
6 * Author: weDevs
7 * Author URI: https://wptexty.com/
8 * Version: 2.0.2
9 * License: GPL2 or later
10 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
11 * Text Domain: texty
12 * Requires at least: 6.8
13 * Requires PHP: 7.4
14 */
15 defined( 'ABSPATH' ) || exit;
16
17 require __DIR__ . '/vendor/autoload.php';
18
19 use Texty\Dependencies\WeDevs\WPKit\DataLayer\DataLayerFactory;
20
21 /**
22 * Texty Class
23 */
24 final class Texty {
25
26 /**
27 * Plugin version
28 *
29 * @var string
30 */
31 private $version = '2.0.2';
32
33 /**
34 * Instances array
35 *
36 * @var array
37 */
38 private $instances = [];
39
40 /**
41 * Initialize
42 */
43 public function __construct() {
44 $this->define_constants();
45 $this->appsero_init();
46
47 // run the installer
48 register_activation_hook( __FILE__, [ $this, 'activate' ] );
49
50 // load the plugin
51 add_action( 'plugins_loaded', [ $this, 'init_plugin' ] );
52 }
53
54 /**
55 * Initializes the Texty class
56 *
57 * Checks for an existing Texty instance
58 * and if it doesn't find one, creates it.
59 */
60 public static function instance() {
61 static $instance = false;
62
63 if ( ! $instance ) {
64 $instance = new self();
65 }
66
67 return $instance;
68 }
69
70 /**
71 * Initialize the plugin
72 *
73 * @return void
74 */
75 public function init_plugin() {
76 // Initialize DataLayerFactory for SmsStat model
77 $this->init_datalayer();
78
79 // Instantiate the notices + migrations bootstraps so their
80 // rest_api_init hooks are wired before WP fires them. Notices first,
81 // because Migrations registers its NoticeProvider into Notices.
82 $this->notices();
83 $this->migrations();
84
85 if ( is_admin() ) {
86 new Texty\Admin();
87 }
88
89 new Texty\Assets();
90 new Texty\Api();
91 new Texty\Dispatcher();
92 new Texty\Compliance();
93
94 /**
95 * Fires after the Texty plugin is fully initialized.
96 *
97 * @param Texty $texty The main plugin instance
98 */
99 do_action( 'texty_loaded', $this );
100 }
101
102 /**
103 * Initialize DataLayerFactory for SmsStat model
104 *
105 * @return void
106 */
107 private function init_datalayer() {
108
109 try {
110 // Initialize the factory with plugin prefix
111 DataLayerFactory::init( 'texty' );
112
113 // Register the SmsStat model and store
114 DataLayerFactory::register_store(
115 Texty\Models\SmsStat::class,
116 Texty\Models\SmsStatStore::class
117 );
118
119 /**
120 * Fires after the DataLayerFactory is initialized and Texty's own
121 * stores are registered. Add-ons should register their DataLayer
122 * models/stores here (via DataLayerFactory::register_store) so the
123 * factory is guaranteed ready and prefixed. Runs before texty_loaded.
124 *
125 * @param Texty $texty The main plugin instance.
126 */
127 do_action( 'texty_datalayer_init', $this );
128 } catch ( \Exception $e ) {
129 error_log( 'Texty DataLayer Init Error: ' . $e->getMessage() );
130 }
131 }
132
133 /**
134 * Define constants
135 *
136 * @return void
137 */
138 private function define_constants() {
139 define( 'TEXTY_VERSION', $this->version );
140 define( 'TEXTY_DIR', __DIR__ );
141 define( 'TEXTY_FILE', __FILE__ );
142 define( 'TEXTY_URL', plugins_url( '', __FILE__ ) );
143 }
144
145 /**
146 * Run the installer
147 *
148 * @return void
149 */
150 public function activate() {
151 $installer = new Texty\Install();
152 $installer->run();
153 }
154
155 /**
156 * Access to gateway manager
157 *
158 * @return Texty\Gateways
159 */
160 public function gateways() {
161 if ( ! isset( $this->instances['gateway'] ) ) {
162 $this->instances['gateway'] = new \Texty\Gateways();
163 }
164
165 return $this->instances['gateway'];
166 }
167
168 /**
169 * Access to gateway manager
170 *
171 * @return Texty\Settings
172 */
173 public function settings() {
174 if ( ! isset( $this->instances['settings'] ) ) {
175 $this->instances['settings'] = new \Texty\Settings();
176 }
177
178 return $this->instances['settings'];
179 }
180
181 /**
182 * Access to gateway manager
183 *
184 * @return Texty\Notifications
185 */
186 public function notifications() {
187 if ( ! isset( $this->instances['notification'] ) ) {
188 $this->instances['notification'] = new \Texty\Notifications();
189 }
190
191 return $this->instances['notification'];
192 }
193
194 /**
195 * Access to the migrations bootstrap.
196 *
197 * @return Texty\Migrations
198 */
199 public function migrations() {
200 if ( ! isset( $this->instances['migrations'] ) ) {
201 $this->instances['migrations'] = new \Texty\Migrations();
202 }
203
204 return $this->instances['migrations'];
205 }
206
207 /**
208 * Access to the admin-notice bootstrap.
209 *
210 * @return Texty\Notices
211 */
212 public function notices() {
213 if ( ! isset( $this->instances['notices'] ) ) {
214 $this->instances['notices'] = new \Texty\Notices();
215 }
216
217 return $this->instances['notices'];
218 }
219
220 /**
221 * Access to global notification settings.
222 *
223 * @since 2.0.0
224 *
225 * @return Texty\NotificationSettings
226 */
227 public function notification_settings() {
228 if ( ! isset( $this->instances['notification_settings'] ) ) {
229 $this->instances['notification_settings'] = new \Texty\NotificationSettings();
230 }
231
232 return $this->instances['notification_settings'];
233 }
234
235 /**
236 * Initialize the plugin tracker
237 *
238 * @return void
239 */
240 public function appsero_init() {
241 $client = new Texty\Dependencies\Appsero\Client( 'd4c17b0f-8f01-4b95-a8de-42b0641eec9a', 'Texty', __FILE__ );
242
243 // Active insights
244 $client->insights()->init();
245 }
246 }
247
248 /**
249 * Return the instance
250 *
251 * @return \Texty
252 */
253 function texty() { // phpcs:ignore
254 return Texty::instance();
255 }
256
257 // take off
258 texty();
259