Aucune description

Installation.php 903B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace MailPoet\Util;
  3. if (!defined('ABSPATH')) exit;
  4. use MailPoet\Settings\SettingsController;
  5. use MailPoet\WP\Functions as WPFunctions;
  6. use MailPoetVendor\Carbon\Carbon;
  7. class Installation {
  8. const NEW_INSTALLATION_DAYS_LIMIT = 30;
  9. /** @var SettingsController */
  10. private $settings;
  11. /** @var WPFunctions */
  12. private $wp;
  13. public function __construct(
  14. SettingsController $settings,
  15. WPFunctions $wp
  16. ) {
  17. $this->settings = $settings;
  18. $this->wp = $wp;
  19. }
  20. public function isNewInstallation() {
  21. $installedAt = $this->settings->get('installed_at');
  22. if (is_null($installedAt)) {
  23. return true;
  24. }
  25. $installedAt = Carbon::createFromTimestamp(strtotime($installedAt));
  26. $currentTime = Carbon::createFromTimestamp($this->wp->currentTime('timestamp'));
  27. return $currentTime->diffInDays($installedAt) <= self::NEW_INSTALLATION_DAYS_LIMIT;
  28. }
  29. }