diff --git a/omnisend/class-omnisend-core-bootstrap.php b/omnisend/class-omnisend-core-bootstrap.php
index 953d120..3461a1c 100644
--- a/omnisend/class-omnisend-core-bootstrap.php
+++ b/omnisend/class-omnisend-core-bootstrap.php
@@ -33,13 +33,13 @@
// Omnisend for Woo plugin.
const OMNISEND_CORE_WOOCOMMERCE_PLUGIN_API_KEY_OPTION = 'omnisend_api_key';
+spl_autoload_register( array( 'Omnisend_Core_Bootstrap', 'autoloader' ) );
+register_uninstall_hook( __FILE__, 'Omnisend_Core_Bootstrap::uninstall' );
add_action( 'plugins_loaded', 'Omnisend_Core_Bootstrap::load' );
class Omnisend_Core_Bootstrap {
- public static function load() {
- spl_autoload_register( array( 'Omnisend_Core_Bootstrap', 'autoloader' ) );
-
+ public static function load(): void {
add_action( 'admin_notices', 'Omnisend_Core_Bootstrap::admin_notices' );
add_action( 'admin_menu', 'Omnisend_Core_Bootstrap::add_admin_menu' );
add_action( 'admin_enqueue_scripts', 'Omnisend_Core_Bootstrap::load_omnisend_admin_styles' );
@@ -63,7 +63,7 @@ public static function add_admin_menu() {
add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $omnisend_icon, $position );
}
- public static function load_omnisend_admin_styles() {
+ public static function load_omnisend_admin_styles(): void {
// phpcs:disable WordPress.Security.NonceVerification
if ( isset( $_GET['page'] ) ) {
if ( in_array( $_GET['page'], array( 'omnisend' ), true ) ) {
@@ -83,7 +83,7 @@ public static function load_omnisend_admin_styles() {
}
}
- public static function admin_notices() {
+ public static function admin_notices(): void {
if ( Options::is_connected() && self::is_omnisend_woocommerce_plugin_active() && ! get_option( OMNISEND_CORE_WOOCOMMERCE_PLUGIN_API_KEY_OPTION ) ) {
echo '
If you want to use Omnisend for Woo plugin please contact customer support.
';
}
@@ -120,4 +120,8 @@ public static function autoloader( $class_name ): void {
require_once $path;
}
}
+
+ public static function uninstall(): void {
+ Options::delete_all();
+ }
}
diff --git a/omnisend/includes/Internal/class-connection.php b/omnisend/includes/Internal/class-connection.php
index 738d282..ff20016 100644
--- a/omnisend/includes/Internal/class-connection.php
+++ b/omnisend/includes/Internal/class-connection.php
@@ -7,8 +7,6 @@
namespace Omnisend\Internal;
-use Omnisend\Public\Client\V1\Client;
-use Omnisend\Public\Client\V1\Contact;
use Omnisend_Core_Bootstrap;
defined( 'ABSPATH' ) || die( 'no direct access' );
diff --git a/omnisend/includes/Internal/class-options.php b/omnisend/includes/Internal/class-options.php
index 95b62eb..f27f1fa 100644
--- a/omnisend/includes/Internal/class-options.php
+++ b/omnisend/includes/Internal/class-options.php
@@ -10,10 +10,10 @@
defined( 'ABSPATH' ) || die( 'no direct access' );
class Options {
-
- private const OPTION_API_KEY = 'omnisend_core_api_key';
- private const OPTION_BRAND_ID = 'omnisend_core_brand_id';
- private const OPTION_STORE_CONNECTED = 'omnisend_core_store_connected';
+ // omni_send instead of omnisend used to distinct and not interfere with Omnisend for Woo plugin.
+ private const OPTION_API_KEY = 'omni_send_core_api_key';
+ private const OPTION_BRAND_ID = 'omni_send_core_brand_id';
+ private const OPTION_STORE_CONNECTED = 'omni_send_core_store_connected';
public static function get_api_key(): string {
$api_key = get_option( self::OPTION_API_KEY );
@@ -55,9 +55,13 @@ public static function is_connected(): bool {
return self::is_store_connected() && self::get_api_key();
}
- public static function disconnect() {
+ public static function disconnect(): void {
delete_option( self::OPTION_API_KEY );
delete_option( self::OPTION_BRAND_ID );
delete_option( self::OPTION_STORE_CONNECTED );
}
+
+ public static function delete_all(): void {
+ self::disconnect();
+ }
}
diff --git a/omnisend/includes/Internal/class-snippet.php b/omnisend/includes/Internal/class-snippet.php
index 5ec7c0b..3dd21ae 100644
--- a/omnisend/includes/Internal/class-snippet.php
+++ b/omnisend/includes/Internal/class-snippet.php
@@ -12,9 +12,9 @@
class Snippet {
public static function add() {
- $brand_id = Omnisend_Core_Options::get_brand_id();
+ $brand_id = Options::get_brand_id();
if ( $brand_id ) {
- require_once 'view/snippet.html';
+ require_once __DIR__ . '/../../view/snippet.html';
}
}
}