diff options
author | yehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664> | 2019-11-25 09:25:43 +0000 |
---|---|---|
committer | yehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664> | 2019-11-25 09:25:43 +0000 |
commit | b5fd728e37aa2a9c7a5f37e8dead0a95117d541b (patch) | |
tree | a7158edc5e4e576e0377f078dabc87c699315c62 /Postman/Extensions/License/PostmanLicenseManager.php | |
parent | c61784411988d36d9bbd93cd3a97e773990af342 (diff) | |
download | Post-SMTP-b5fd728e37aa2a9c7a5f37e8dead0a95117d541b.zip |
phpmailer delivery improvments
bug fixes
add option to disable notifications
fix Invalid “Reply-To” e-mail address
Diffstat (limited to 'Postman/Extensions/License/PostmanLicenseManager.php')
-rw-r--r-- | Postman/Extensions/License/PostmanLicenseManager.php | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/Postman/Extensions/License/PostmanLicenseManager.php b/Postman/Extensions/License/PostmanLicenseManager.php new file mode 100644 index 0000000..280b564 --- /dev/null +++ b/Postman/Extensions/License/PostmanLicenseManager.php @@ -0,0 +1,102 @@ +<?php +if ( ! defined( 'ABSPATH' ) ) exit; + +class PostmanLicenseManager { + + const ENDPOINT = 'https://postmansmtp.com'; + + const CORE_EXTENSIONS = [ 'gmail_api', 'sendgrid_api', 'mandrill_api', 'mailgun_api' ]; + + private $extensions; + + private $rand_cache_interval = 12; + + private static $instance; + + public static function get_instance() { + if ( ! self::$instance ) { + self::$instance = new static(); + } + + return self::$instance; + } + + /** + * PostmanLicenseManager constructor. + */ + private function __construct() + { + $this->includes(); + $this->rand_cache_interval = rand( 1, 24 ); + + add_filter( 'extra_plugin_headers', [ $this, 'add_extension_headers' ] ); + } + + public function includes() { + include_once 'PostmanLicenseHandler.php'; + + include_once ABSPATH . '/wp-admin/includes/plugin.php'; + + } + + + function add_extension_headers($headers) { + $headers[] = 'Class'; + $headers[] = 'Slug'; + + return $headers; + } + + /** + * Init + */ + public function init() { + + $plugins = get_plugins(); + foreach ( $plugins as $plugin_dir_and_filename => $plugin_data ) { + + if ( ! is_plugin_active( $plugin_dir_and_filename ) ) { + continue; + } + + if ( false !== strpos( $plugin_dir_and_filename, 'post-smtp-extension' ) ) { + $slug = $plugin_dir_and_filename; + $class = $plugin_data['Class']; + $plugin_path = WP_CONTENT_DIR . '/plugins/' . $plugin_dir_and_filename; + + $this->extensions[$slug]['plugin_data'] = $plugin_data; + $this->extensions[$slug]['plugin_dir_and_filename'] = $plugin_dir_and_filename; + $this->extensions[$slug]['license_manager'] = new PostmanLicenseHandler( + $plugin_path, $plugin_data['Name'], + $plugin_data['Version'], $plugin_data['Author'] + ); + if ( $this->extensions[$slug]['license_manager']->is_licensed() ) { + include_once $plugin_path; + + $this->extensions[$slug]['instance'] = new $class; + } + } + } + + if ( ! empty( $this->extensions ) ) { + new PostmanAdmin(); + } + } + + public function add_extension($slug) { + $plugin_path = WP_CONTENT_DIR . '/plugins/' . $this->extensions[$slug]['plugin_dir_and_filename']; + $class = $this->extensions[$slug]['plugin_data']['Class']; + + include_once $plugin_path; + $this->extensions[$slug]['instance'] = new $class; + } + + public function remove_extension($slug) { + $this->extensions[$slug]['instance'] = null; + unset($this->extensions[$slug]['instance']); + } + + public function get_extensions() { + return $this->extensions; + } +}
\ No newline at end of file |