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

152 lines 3.0 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://github.com/weDevsOfficial/texty
6 * Author: weDevs
7 * Author URI: https://tareq.co
8 * Version: 0.2
9 * License: GPL2 or later
10 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
11 * Text Domain: texty
12 */
13 defined( 'ABSPATH' ) || exit;
14
15 require __DIR__ . '/vendor/autoload.php';
16
17 /**
18 * Texty Class
19 */
20 final class Texty {
21
22 /**
23 * Plugin version
24 *
25 * @var string
26 */
27 private $version = '0.2';
28
29 /**
30 * Instances array
31 *
32 * @var array
33 */
34 private $instances = [];
35
36 /**
37 * Initialize
38 */
39 public function __construct() {
40 $this->define_constants();
41
42 // run the installer
43 register_activation_hook( __FILE__, [ $this, 'activate' ] );
44
45 // load the plugin
46 add_action( 'plugins_loaded', [ $this, 'init_plugin' ] );
47 }
48
49 /**
50 * Initializes the Texty class
51 *
52 * Checks for an existing Texty instance
53 * and if it doesn't find one, creates it.
54 */
55 public static function instance() {
56 static $instance = false;
57
58 if ( ! $instance ) {
59 $instance = new self();
60 }
61
62 return $instance;
63 }
64
65 /**
66 * Initialize the plugin
67 *
68 * @return void
69 */
70 public function init_plugin() {
71 if ( is_admin() ) {
72 new Texty\Admin();
73 }
74
75 new Texty\Api();
76 new Texty\Dispatcher();
77 }
78
79 /**
80 * Define constants
81 *
82 * @return void
83 */
84 private function define_constants() {
85 define( 'TEXTY_VERSION', $this->version );
86 define( 'TEXTY_DIR', __DIR__ );
87 define( 'TEXTY_FILE', __FILE__ );
88 define( 'TEXTY_URL', plugins_url( '', __FILE__ ) );
89 }
90
91 /**
92 * Run the installer
93 *
94 * @return void
95 */
96 public function activate() {
97 $installer = new Texty\Install();
98 $installer->run();
99 }
100
101 /**
102 * Access to gateway manager
103 *
104 * @return Texty\Gateways
105 */
106 public function gateways() {
107 if ( ! isset( $this->instances['gateway'] ) ) {
108 $this->instances['gateway'] = new \Texty\Gateways();
109 }
110
111 return $this->instances['gateway'];
112 }
113
114 /**
115 * Access to gateway manager
116 *
117 * @return Texty\Settings
118 */
119 public function settings() {
120 if ( ! isset( $this->instances['settings'] ) ) {
121 $this->instances['settings'] = new \Texty\Settings();
122 }
123
124 return $this->instances['settings'];
125 }
126
127 /**
128 * Access to gateway manager
129 *
130 * @return Texty\Notifications
131 */
132 public function notifications() {
133 if ( ! isset( $this->instances['notification'] ) ) {
134 $this->instances['notification'] = new \Texty\Notifications();
135 }
136
137 return $this->instances['notification'];
138 }
139 }
140
141 /**
142 * Return the instance
143 *
144 * @return \Texty
145 */
146 function texty() {
147 return Texty::instance();
148 }
149
150 // take off
151 texty();
152