PluginProbe
Texty – SMS Notification for WordPress, WooCommerce, Dokan and more / 2.0.1
Texty – SMS Notification for WordPress, WooCommerce, Dokan and more v2.0.1
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 2.0.1, at texty.php

248 lines 5.6 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.1
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 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.1';
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\Api();
90 new Texty\Dispatcher();
91 new Texty\Compliance();
92
93 /**
94 * Fires after the Texty plugin is fully initialized.
95 *
96 * @param Texty $texty The main plugin instance
97 */
98 do_action( 'texty_loaded', $this );
99 }
100
101 /**
102 * Initialize DataLayerFactory for SmsStat model
103 *
104 * @return void
105 */
106 private function init_datalayer() {
107
108 try {
109 // Initialize the factory with plugin prefix
110 DataLayerFactory::init( 'texty' );
111
112 // Register the SmsStat model and store
113 DataLayerFactory::register_store(
114 Texty\Models\SmsStat::class,
115 Texty\Models\SmsStatStore::class
116 );
117 } catch ( \Exception $e ) {
118 error_log( 'Texty DataLayer Init Error: ' . $e->getMessage() );
119 }
120 }
121
122 /**
123 * Define constants
124 *
125 * @return void
126 */
127 private function define_constants() {
128 define( 'TEXTY_VERSION', $this->version );
129 define( 'TEXTY_DIR', __DIR__ );
130 define( 'TEXTY_FILE', __FILE__ );
131 define( 'TEXTY_URL', plugins_url( '', __FILE__ ) );
132 }
133
134 /**
135 * Run the installer
136 *
137 * @return void
138 */
139 public function activate() {
140 $installer = new Texty\Install();
141 $installer->run();
142 }
143
144 /**
145 * Access to gateway manager
146 *
147 * @return Texty\Gateways
148 */
149 public function gateways() {
150 if ( ! isset( $this->instances['gateway'] ) ) {
151 $this->instances['gateway'] = new \Texty\Gateways();
152 }
153
154 return $this->instances['gateway'];
155 }
156
157 /**
158 * Access to gateway manager
159 *
160 * @return Texty\Settings
161 */
162 public function settings() {
163 if ( ! isset( $this->instances['settings'] ) ) {
164 $this->instances['settings'] = new \Texty\Settings();
165 }
166
167 return $this->instances['settings'];
168 }
169
170 /**
171 * Access to gateway manager
172 *
173 * @return Texty\Notifications
174 */
175 public function notifications() {
176 if ( ! isset( $this->instances['notification'] ) ) {
177 $this->instances['notification'] = new \Texty\Notifications();
178 }
179
180 return $this->instances['notification'];
181 }
182
183 /**
184 * Access to the migrations bootstrap.
185 *
186 * @return Texty\Migrations
187 */
188 public function migrations() {
189 if ( ! isset( $this->instances['migrations'] ) ) {
190 $this->instances['migrations'] = new \Texty\Migrations();
191 }
192
193 return $this->instances['migrations'];
194 }
195
196 /**
197 * Access to the admin-notice bootstrap.
198 *
199 * @return Texty\Notices
200 */
201 public function notices() {
202 if ( ! isset( $this->instances['notices'] ) ) {
203 $this->instances['notices'] = new \Texty\Notices();
204 }
205
206 return $this->instances['notices'];
207 }
208
209 /**
210 * Access to global notification settings.
211 *
212 * @since 2.0.0
213 *
214 * @return Texty\NotificationSettings
215 */
216 public function notification_settings() {
217 if ( ! isset( $this->instances['notification_settings'] ) ) {
218 $this->instances['notification_settings'] = new \Texty\NotificationSettings();
219 }
220
221 return $this->instances['notification_settings'];
222 }
223
224 /**
225 * Initialize the plugin tracker
226 *
227 * @return void
228 */
229 public function appsero_init() {
230 $client = new Texty\Dependencies\Appsero\Client( 'd4c17b0f-8f01-4b95-a8de-42b0641eec9a', 'Texty', __FILE__ );
231
232 // Active insights
233 $client->insights()->init();
234 }
235 }
236
237 /**
238 * Return the instance
239 *
240 * @return \Texty
241 */
242 function texty() { // phpcs:ignore
243 return Texty::instance();
244 }
245
246 // take off
247 texty();
248