WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
класс не описан

ActionScheduler_Versions() WC 1.0

Class ActionScheduler_Versions

Хуков нет.

Возвращает

Null. Ничего.

Использование

$ActionScheduler_Versions = new ActionScheduler_Versions();
// use class methods

Методы

  1. get_versions()
  2. initialize_latest_version()
  3. instance()
  4. latest_version()
  5. latest_version_callback()
  6. register( $version_string, $initialization_callback )

Код ActionScheduler Versions: woocommerce/packages/action-scheduler/classes/ActionScheduler_Versions.php WC 4.3.1

<?php
class ActionScheduler_Versions {
	/**
	 * @var ActionScheduler_Versions
	 */
	private static $instance = NULL;

	private $versions = array();

	public function register( $version_string, $initialization_callback ) {
		if ( isset($this->versions[$version_string]) ) {
			return FALSE;
		}
		$this->versions[$version_string] = $initialization_callback;
		return TRUE;
	}

	public function get_versions() {
		return $this->versions;
	}

	public function latest_version() {
		$keys = array_keys($this->versions);
		if ( empty($keys) ) {
			return false;
		}
		uasort( $keys, 'version_compare' );
		return end($keys);
	}

	public function latest_version_callback() {
		$latest = $this->latest_version();
		if ( empty($latest) || !isset($this->versions[$latest]) ) {
			return '__return_null';
		}
		return $this->versions[$latest];
	}

	/**
	 * @return ActionScheduler_Versions
	 * @codeCoverageIgnore
	 */
	public static function instance() {
		if ( empty(self::$instance) ) {
			self::$instance = new self();
		}
		return self::$instance;
	}

	/**
	 * @codeCoverageIgnore
	 */
	public static function initialize_latest_version() {
		$self = self::instance();
		call_user_func($self->latest_version_callback());
	}
}