# firebox/2.1.14/Inc/Core/Helpers/Plugin.php

FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin &amp; Cart Abandonment, version 2.1.14. 163 lines.

- Page: https://pluginprobe.com/plugins/firebox/2.1.14/code/Inc/Core/Helpers/Plugin.php
- Raw: https://pluginprobe.com/plugins/firebox/2.1.14/raw/Inc/Core/Helpers/Plugin.php
- Modified: 2024-05-30T14:06:28+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/firebox/2.1.14/code/Inc/Core/Helpers/Plugin.php#L10-L20`.

```php
<?php
/**
 * @package         FireBox
 * @version         2.1.14
 * 
 * @author          FirePlugins <info@fireplugins.com>
 * @link            https://www.fireplugins.com
 * @copyright       Copyright © 2024 FirePlugins All Rights Reserved
 * @license         GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/

namespace FireBox\Core\Helpers;

if (!defined('ABSPATH'))
{
	exit; // Exit if accessed directly.
}

class Plugin
{
	public static function getLatestVersion()
	{
		$url = FPF_GET_LICENSE_VERSION_URL . 'firebox';

		$response = wp_remote_get($url);

		if (!is_array($response))
		{
			return;
		}

		$response_decoded = null;

		try
		{
			$response_decoded = json_decode($response['body']);
		}
		catch (Exception $ex)
		{
			return;
		}

		if (!isset($response_decoded->version))
		{
			return;
		}

		return $response_decoded->version;
	}
	
	/**
	 * Checks whether the plugin is outdated.
	 * 
	 * @param   int     $days_old
	 * 
	 * @return  bool
	 */
	public static function isOutdated($days_old = 120)
	{
        if (!defined('FBOX_RELEASE_DATE'))
        {
			return false;
		}
		
		if (!$then = strtotime(FBOX_RELEASE_DATE))
		{
			return false;
		}

		$days_old = (int) $days_old;
		$now = time();
		$diff = $now - $then;
		$days_diff = round($diff / (60 * 60 * 24));

		if ($days_diff <= $days_old)
		{
			return false;
		}

		return true;
	}

	/**
	 * Returns the installation date.
	 * 
	 * @return  string
	 */
	public static function getInstallationDate()
	{
		$path = self::getExtensionsDataFilePath();
		
		// If file does not exist, abort
		if (!file_exists($path))
		{
			return;
		}

		// If file exists, retrieve its contents
		$content = file_get_contents($path);

		// Decode it
		if (!$content = json_decode($content, true))
		{
			return;
		}

		// Ensure install date exists
		if (!isset($content['install_date']))
		{
			return;
		}
		
		return $content['install_date'];
	}

	/**
	 * Sets the installation date.
	 * 
	 * @param   string  $install_date
	 * 
	 * @return  bool
	 */
	public static function setInstallationDate($install_date = null)
	{
		$path = self::getExtensionsDataFilePath();

		// If file does not exist, abort
		if (!file_exists($path))
		{
			file_put_contents($path, json_encode(
				[
					'install_date' => $install_date
				]
			));
			return;
		}

		// If file exists, retrieve its contents
		$content = file_get_contents($path);

		// Decode it
		$content = json_decode($content, true);

		if (isset($content['install_date']))
		{
			return false;
		}

		$content['install_date'] = $install_date;

		file_put_contents($path, json_encode($content));
	}

	/**
	 * The file path that stores all extensions data.
	 * 
	 * @return  string
	 */
	public static function getExtensionsDataFilePath()
	{
		return \FPFramework\Helpers\WPHelper::getPluginUploadsDirectory('firebox') . '/data.json';
	}
}
```
