| 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: 1.1.5 |
| 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 |
/** |
| 20 |
* Texty Class |
| 21 |
*/ |
| 22 |
final class Texty { |
| 23 |
|
| 24 |
/** |
| 25 |
* Plugin version |
| 26 |
* |
| 27 |
* @var string |
| 28 |
*/ |
| 29 |
private $version = '1.1.5'; |
| 30 |
|
| 31 |
/** |
| 32 |
* Instances array |
| 33 |
* |
| 34 |
* @var array |
| 35 |
*/ |
| 36 |
private $instances = []; |
| 37 |
|
| 38 |
/** |
| 39 |
* Initialize |
| 40 |
*/ |
| 41 |
public function __construct() { |
| 42 |
$this->define_constants(); |
| 43 |
$this->appsero_init(); |
| 44 |
|
| 45 |
// run the installer |
| 46 |
register_activation_hook( __FILE__, [ $this, 'activate' ] ); |
| 47 |
|
| 48 |
// load the plugin |
| 49 |
add_action( 'plugins_loaded', [ $this, 'init_plugin' ] ); |
| 50 |
} |
| 51 |
|
| 52 |
/** |
| 53 |
* Initializes the Texty class |
| 54 |
* |
| 55 |
* Checks for an existing Texty instance |
| 56 |
* and if it doesn't find one, creates it. |
| 57 |
*/ |
| 58 |
public static function instance() { |
| 59 |
static $instance = false; |
| 60 |
|
| 61 |
if ( ! $instance ) { |
| 62 |
$instance = new self(); |
| 63 |
} |
| 64 |
|
| 65 |
return $instance; |
| 66 |
} |
| 67 |
|
| 68 |
/** |
| 69 |
* Initialize the plugin |
| 70 |
* |
| 71 |
* @return void |
| 72 |
*/ |
| 73 |
public function init_plugin() { |
| 74 |
if ( is_admin() ) { |
| 75 |
new Texty\Admin(); |
| 76 |
} |
| 77 |
|
| 78 |
new Texty\Api(); |
| 79 |
new Texty\Dispatcher(); |
| 80 |
} |
| 81 |
|
| 82 |
/** |
| 83 |
* Define constants |
| 84 |
* |
| 85 |
* @return void |
| 86 |
*/ |
| 87 |
private function define_constants() { |
| 88 |
define( 'TEXTY_VERSION', $this->version ); |
| 89 |
define( 'TEXTY_DIR', __DIR__ ); |
| 90 |
define( 'TEXTY_FILE', __FILE__ ); |
| 91 |
define( 'TEXTY_URL', plugins_url( '', __FILE__ ) ); |
| 92 |
} |
| 93 |
|
| 94 |
/** |
| 95 |
* Run the installer |
| 96 |
* |
| 97 |
* @return void |
| 98 |
*/ |
| 99 |
public function activate() { |
| 100 |
$installer = new Texty\Install(); |
| 101 |
$installer->run(); |
| 102 |
} |
| 103 |
|
| 104 |
/** |
| 105 |
* Access to gateway manager |
| 106 |
* |
| 107 |
* @return Texty\Gateways |
| 108 |
*/ |
| 109 |
public function gateways() { |
| 110 |
if ( ! isset( $this->instances['gateway'] ) ) { |
| 111 |
$this->instances['gateway'] = new \Texty\Gateways(); |
| 112 |
} |
| 113 |
|
| 114 |
return $this->instances['gateway']; |
| 115 |
} |
| 116 |
|
| 117 |
/** |
| 118 |
* Access to gateway manager |
| 119 |
* |
| 120 |
* @return Texty\Settings |
| 121 |
*/ |
| 122 |
public function settings() { |
| 123 |
if ( ! isset( $this->instances['settings'] ) ) { |
| 124 |
$this->instances['settings'] = new \Texty\Settings(); |
| 125 |
} |
| 126 |
|
| 127 |
return $this->instances['settings']; |
| 128 |
} |
| 129 |
|
| 130 |
/** |
| 131 |
* Access to gateway manager |
| 132 |
* |
| 133 |
* @return Texty\Notifications |
| 134 |
*/ |
| 135 |
public function notifications() { |
| 136 |
if ( ! isset( $this->instances['notification'] ) ) { |
| 137 |
$this->instances['notification'] = new \Texty\Notifications(); |
| 138 |
} |
| 139 |
|
| 140 |
return $this->instances['notification']; |
| 141 |
} |
| 142 |
|
| 143 |
/** |
| 144 |
* Initialize the plugin tracker |
| 145 |
* |
| 146 |
* @return void |
| 147 |
*/ |
| 148 |
public function appsero_init() { |
| 149 |
$client = new Texty\Dependencies\Appsero\Client( 'd4c17b0f-8f01-4b95-a8de-42b0641eec9a', 'Texty', __FILE__ ); |
| 150 |
|
| 151 |
// Active insights |
| 152 |
$client->insights()->init(); |
| 153 |
} |
| 154 |
} |
| 155 |
|
| 156 |
/** |
| 157 |
* Return the instance |
| 158 |
* |
| 159 |
* @return \Texty |
| 160 |
*/ |
| 161 |
function texty() { |
| 162 |
return Texty::instance(); |
| 163 |
} |
| 164 |
|
| 165 |
// take off |
| 166 |
texty(); |
| 167 |
|