array(), ); /** * Hook in tabs. */ public static function init() { add_action( 'init', array( __CLASS__, 'check_version' ), 5 ); } /** * Check WooCommerce version and run the updater is required. * * This check is done on all requests and runs if he versions do not match. */ public static function check_version() { if ( get_option( 'appmaker_wc_version' ) !== WC()->version ) { self::install(); do_action( 'appmaker_wc_updated' ); } } /** * Install WC. */ public static function install() { if ( ! defined( 'APPMAKER_WC_INSTALLING' ) ) { define( 'APPMAKER_WC_INSTALLING', true ); } self::update(); self::update_version(); // Trigger action. do_action( 'appmaker_wc_installed' ); } /** * Execute all update functions */ private static function update() { $current_db_version = get_option( 'appmaker_wc_version' ); foreach ( self::$updates as $version => $update_callbacks ) { if ( version_compare( $current_db_version, $version, '<' ) ) { foreach ( $update_callbacks as $update_callback ) { call_user_func( $update_callback ); } } } } /** * Update WC version to current. */ private static function update_version() { delete_option( 'appmaker_wc_version' ); add_option( 'appmaker_wc_version', APPMAKER_WC::$version ); } } APPMAKER_WC_Install::init();