| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Plugin Name: EmailKit |
| 5 |
* Plugin URI: https://wpmet.com/plugin/emailkit/ |
| 6 |
* Description: EmailKit is the most-complete drag-and-drop Email template builder. |
| 7 |
* Author: wpmet |
| 8 |
* Author URI: https://wpmet.com |
| 9 |
* Version: 1.6.9 |
| 10 |
* Text Domain: emailkit |
| 11 |
* License: GPLv3 |
| 12 |
* License URI: https://www.gnu.org/licenses/gpl-3.0.txt |
| 13 |
*/ |
| 14 |
if (!defined('ABSPATH')) { |
| 15 |
exit; |
| 16 |
} |
| 17 |
|
| 18 |
require_once __DIR__ . '/vendor/autoload.php'; |
| 19 |
require_once __DIR__ . '/traits/singleton.php'; |
| 20 |
|
| 21 |
/** |
| 22 |
* The main plugin class |
| 23 |
*/ |
| 24 |
final class EmailKit |
| 25 |
{ |
| 26 |
|
| 27 |
/** |
| 28 |
* Plugin version |
| 29 |
* |
| 30 |
* @var string |
| 31 |
*/ |
| 32 |
|
| 33 |
/** |
| 34 |
* Class constructor |
| 35 |
*/ |
| 36 |
private function __construct() |
| 37 |
{ |
| 38 |
$this->define_constants(); |
| 39 |
register_activation_hook(__FILE__, [$this, 'activate']); |
| 40 |
register_deactivation_hook(__FILE__, [$this,'deactivate_emailkit']); |
| 41 |
|
| 42 |
add_action('plugins_loaded', [$this, 'init_plugin'], 112); |
| 43 |
add_action('init', [$this, 'load_textdomain'], 0); |
| 44 |
add_action('init', [$this, 'init_promotional'], 10); |
| 45 |
add_action( 'admin_enqueue_scripts',[$this, 'emailkit_global_assets'] ); |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* Initializes a singleton instance |
| 50 |
* |
| 51 |
* @return \EmailKit |
| 52 |
*/ |
| 53 |
public static function init() |
| 54 |
{ |
| 55 |
|
| 56 |
static $instance = false; |
| 57 |
|
| 58 |
if (!$instance) { |
| 59 |
$instance = new self(); |
| 60 |
} |
| 61 |
|
| 62 |
return $instance; |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
/** |
| 67 |
* Define the required plugin constants |
| 68 |
* |
| 69 |
* @return void |
| 70 |
*/ |
| 71 |
public function define_constants() |
| 72 |
{ |
| 73 |
define('EMAILKIT_VERSION', '1.6.9'); |
| 74 |
define('EMAILKIT_TEXTDOMAIN', 'emailkit'); |
| 75 |
define('EMAILKIT_FILE', __FILE__); |
| 76 |
define('EMAILKIT_PATH', __DIR__); |
| 77 |
define('EMAILKIT_URL', trailingslashit(plugin_dir_url(EMAILKIT_FILE))); |
| 78 |
define('EMAILKIT_DIR', trailingslashit(plugin_dir_path(__FILE__))); |
| 79 |
define('EMAILKIT_INC', EMAILKIT_URL . 'includes/'); |
| 80 |
define('EMAILKIT_ADMIN', EMAILKIT_INC . 'Admin/'); |
| 81 |
define('EMAILKIT_ASSETS', EMAILKIT_URL . 'assets'); |
| 82 |
define('EMAILKIT_CONFIG', []); |
| 83 |
} |
| 84 |
|
| 85 |
|
| 86 |
/** |
| 87 |
* Initialize the plugin |
| 88 |
* |
| 89 |
* @return void |
| 90 |
*/ |
| 91 |
public function init_plugin() |
| 92 |
{ |
| 93 |
do_action('emailkit/before_loaded'); |
| 94 |
|
| 95 |
new EmailKit\Admin(); |
| 96 |
|
| 97 |
do_action('emailkit/after_loaded'); |
| 98 |
} |
| 99 |
|
| 100 |
/** |
| 101 |
* Load the plugin translations |
| 102 |
* |
| 103 |
* @return void |
| 104 |
*/ |
| 105 |
public function load_textdomain() |
| 106 |
{ |
| 107 |
load_plugin_textdomain('emailkit', false, dirname(plugin_basename(EMAILKIT_FILE)) . '/languages'); |
| 108 |
} |
| 109 |
|
| 110 |
/** |
| 111 |
* Initialize the promotional classes |
| 112 |
* |
| 113 |
* Runs on `init` because these classes translate strings while booting, |
| 114 |
* and translations must not be loaded before `init`. |
| 115 |
* |
| 116 |
* @return void |
| 117 |
*/ |
| 118 |
public function init_promotional() |
| 119 |
{ |
| 120 |
(new EmailKit\Promotional\Promotional())->init(); |
| 121 |
} |
| 122 |
|
| 123 |
public function emailkit_global_assets() |
| 124 |
{ |
| 125 |
wp_enqueue_style('emailkit-admin-style', EMAILKIT_URL . 'assets/admin/css/emailkit-global.css', [], EMAILKIT_VERSION); |
| 126 |
} |
| 127 |
|
| 128 |
/** |
| 129 |
* Do stuff upon plugin activation |
| 130 |
*/ |
| 131 |
public function activate() |
| 132 |
{ |
| 133 |
/** |
| 134 |
* Save plugin installation time. |
| 135 |
*/ |
| 136 |
|
| 137 |
$installed = get_option('emailkit_installed'); |
| 138 |
if (!$installed) { |
| 139 |
update_option('emailkit_installed', time()); |
| 140 |
} |
| 141 |
|
| 142 |
/** |
| 143 |
* Update plugin version. |
| 144 |
* |
| 145 |
* @param string $option |
| 146 |
*/ |
| 147 |
update_option('emailkit_version', EMAILKIT_VERSION); |
| 148 |
|
| 149 |
// After Active Plugin CPT menu for EmailKit |
| 150 |
$cpt = new EmailKit\Admin\CPT(); |
| 151 |
$cpt->postType(); |
| 152 |
$cpt->add_role(); |
| 153 |
|
| 154 |
flush_rewrite_rules(); |
| 155 |
|
| 156 |
} |
| 157 |
|
| 158 |
// Deactivate plugin |
| 159 |
function deactivate_emailkit() { |
| 160 |
} |
| 161 |
|
| 162 |
|
| 163 |
} |
| 164 |
/**. |
| 165 |
* Initializes the main plugin |
| 166 |
* |
| 167 |
* @return \EmailKit |
| 168 |
*/ |
| 169 |
|
| 170 |
EmailKit::init(); |
| 171 |
|