From 4bf5306d046db603d06d001b6f5be80e51154415 Mon Sep 17 00:00:00 2001 From: vendidero Date: Fri, 22 Dec 2023 13:12:50 +0100 Subject: [PATCH] Version check + update. --- src/Install.php | 4 ++-- src/Package.php | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Install.php b/src/Install.php index 1aae1b7..2ed978d 100644 --- a/src/Install.php +++ b/src/Install.php @@ -21,9 +21,9 @@ public static function install() { wp_die( wp_kses_post( $notice ) ); } - - self::add_options(); } + + self::add_options(); } private static function add_options() { diff --git a/src/Package.php b/src/Package.php index a29408b..5372053 100644 --- a/src/Package.php +++ b/src/Package.php @@ -41,6 +41,7 @@ public static function init() { protected static function init_hooks() { add_action( 'init', array( __CLASS__, 'load_plugin_textdomain' ) ); + add_action( 'init', array( __CLASS__, 'check_version' ), 10 ); /** * Listen to action scheduler hooks for report generation @@ -768,6 +769,14 @@ public static function install() { Install::install(); } + public static function check_version() { + if ( self::has_dependencies() && ! defined( 'IFRAME_REQUEST' ) && ( get_option( 'one_stop_shop_woocommerce' ) !== self::get_version() ) ) { + Install::install(); + + do_action( 'oss_woocommerce_updated' ); + } + } + public static function deactivate() { if ( self::has_dependencies() && Admin::supports_wc_admin() ) { foreach ( Admin::get_notes() as $oss_note ) {