HEX
Server: Apache/2.4.65 (Ubuntu)
System: Linux ielts-store-v2 6.8.0-1036-gcp #38~22.04.1-Ubuntu SMP Thu Aug 14 01:19:18 UTC 2025 x86_64
User: root (0)
PHP: 7.2.34-54+ubuntu20.04.1+deb.sury.org+1
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: /var/www/html/ielts-store/wp-content/plugins/automatewoo/includes/abstracts/addon.php
<?php
// phpcs:ignoreFile

namespace AutomateWoo;

/**
 * Addon class.
 *
 * This class must remain named as 'includes/abstracts/addon.php' because it's what AW add-ons expect.
 */
abstract class Addon {

	/** @var Addon - must declare in child */
	protected static $_instance;

	/** @var string */
	public $id;

	/** @var string */
	public $name;

	/** @var string */
	public $version;

	/** @var string */
	public $plugin_basename;

	/** @var string */
	public $plugin_path;

	/** @var string */
	public $file;

	/** @var string */
	public $min_php_version;

	/** @var string */
	public $min_automatewoo_version;

	/** @var string */
	public $min_woocommerce_version;

	/** @var array */
	public $db_updates = [];



	/**
	 * Method to init the add on
	 */
	abstract function init();

	/**
	 * Required method to return options class
	 * @return Options_API
	 */
	abstract function options();

	/**
	 * Optional installer method
	 */
	function install() {}


	/**
	 * Constructor for add-on
	 * @param Plugin_Data|object $plugin_data
	 */
	function __construct( $plugin_data ) {

		$this->id = $plugin_data->id;
		$this->name = $plugin_data->name;
		$this->version = $plugin_data->version;
		$this->file = $plugin_data->file;
		$this->min_automatewoo_version = $plugin_data->min_automatewoo_version;

		$this->plugin_basename = plugin_basename( $plugin_data->file );
		$this->plugin_path = dirname( $plugin_data->file );

		add_action( 'automatewoo_init_addons', [ $this, 'register' ] );
		add_action( 'automatewoo_init_addons', [ $this, 'init' ] );
	}


	/**
	 * @param string $end
	 * @return string
	 */
	function url( $end = '' ) {
		return untrailingslashit( plugin_dir_url( $this->plugin_basename ) ) . $end;
	}


	/**
	 * @param string $end
	 * @return string
	 */
	function path( $end = '' ) {
		return untrailingslashit( $this->plugin_path ) . $end;
	}


	/**
	 * Check the version stored in the database and determine if an upgrade needs to occur
	 */
	function check_version() {

		if ( version_compare( $this->version, $this->options()->version, '=' ) )
			return;

		$this->install();

		if ( $this->is_database_upgrade_available() ) {
			add_action( 'admin_notices', [ $this, 'data_upgrade_prompt' ] );
		}
		else {
			$this->update_database_version();
		}
	}


	/**
	 * @return bool
	 */
	function is_database_upgrade_available() {

		if ( version_compare( $this->version, $this->options()->version, '=' ) || empty( $this->db_updates ) ) {
			return false;
		}

		return $this->options()->version && version_compare( $this->options()->version, max( $this->db_updates ), '<' );
	}


	/**
	 * Handle updates
	 */
	function do_database_update() {

		@ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) );

		foreach ( $this->db_updates as $update ) {
			if ( version_compare( $this->options()->version, $update, '<' ) ) {
				include $this->path( "/includes/updates/$update.php" );
			}
		}

		$this->update_database_version();
	}


	/**
	 * Update version to current
	 */
	function update_database_version() {
		update_option( $this->options()->prefix . 'version', $this->version, true );
		do_action( 'automatewoo_addon_updated' );
	}


	/**
	 * Renders prompt notice for user to update
	 */
	function data_upgrade_prompt() {
		AW()->admin->get_view( 'data-upgrade-prompt', [
			'plugin_name' => $this->name,
			'plugin_slug' => $this->id
		]);
	}


	/**
	 * Registers the add-on.
	 *
	 * @since 4.6.0
	 */
	public function register() {
		Addons::register( $this );
	}


	/**
	 * Runs when the add-on plugin is activated.
	 */
	function activate() {
		flush_rewrite_rules();
		AdminNotices::add_notice( 'addon_welcome_' . $this->id );
	}


	/**
	 * @return string
	 */
	function get_getting_started_url() {
		return '';
	}


	/**
	 * @param Plugin_Data|mixed $data
	 * @return Addon|mixed
	 */
	static function instance( $data ) {
		if ( is_null( static::$_instance ) ) {
			static::$_instance = new static( $data );
		}
		return static::$_instance;
	}

}


/**
 * @class Plugin_Data
 */
class Plugin_Data {
	public $id;
	public $name;
	public $version;
	public $file;
	public $min_php_version;
	public $min_automatewoo_version;
	public $min_woocommerce_version;
}