Sindbad~EG File Manager

Current Path : /home/n/i/c/nicedoo/www/wp-content/plugins/flexible-checkout-fields/classes/
Upload File :
Current File : /home/n/i/c/nicedoo/www/wp-content/plugins/flexible-checkout-fields/classes/activation-tracker.php

<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
} // Exit if accessed directly

class Flexible_Checkout_Fields_Activation_Tracker {

	/** @var string */
	private $namespace;

	/**
	 * Flexible_Checkout_Fields_Activation_Tracker constructor.
	 *
	 * @param $namespace string for settings
	 */
	public function __construct( $namespace ) {
		$this->namespace = $namespace;
	}

	/**
	 * Option name for date storage
	 *
	 * @return string
	 */
	private function get_option_name_activation_date() {
		return $this->namespace . '_activation';
	}

	/**
	 * Returns activation date and sets it if were not set before
	 *
	 * @return int unix timestamp for activation datetime
	 */
	public function get_activation_date() {
		$activation_date
			= get_option( $this->get_option_name_activation_date() );
		if ( empty( $activation_date ) ) {
			return $this->touch_activation_date();
		}

		return intval( $activation_date );
	}

	/**
	 * Was activation more than two weeks before today
	 *
	 * @return bool
	 */
	public function is_activated_more_than_two_weeks() {
		$two_weeks = 60 * 60 * 24 * 7 * 2;

		return $this->get_activation_date() + $two_weeks < time();
	}

	/**
	 * Sets activatiion date for today
	 *
	 * @return int unit timestamp for now
	 */
	public function touch_activation_date() {
		$now = time();
		update_option( $this->get_option_name_activation_date(), $now );

		return $now;
	}
}

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists