Нет описания

mailpoet-cron.php 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. ini_set("display_errors", "1");
  3. error_reporting(E_ALL);
  4. if (!isset($argv[1]) || !$argv[1]) {
  5. echo 'You need to pass a WordPress root as an argument.';
  6. exit(1);
  7. }
  8. $wpLoadFile = $argv[1] . '/wp-load.php';
  9. if (!file_exists($wpLoadFile)) {
  10. echo 'WordPress root argument is not valid.';
  11. exit(1);
  12. }
  13. if (!defined('ABSPATH')) {
  14. /** Set up WordPress environment */
  15. require_once($wpLoadFile);
  16. }
  17. if (!is_plugin_active('mailpoet/mailpoet.php')) {
  18. echo 'MailPoet plugin is not active';
  19. exit(1);
  20. }
  21. // Check for minimum supported PHP version
  22. if (version_compare(phpversion(), '7.1.0', '<')) {
  23. echo 'MailPoet requires PHP version 7.1 or newer (version 7.4 recommended).';
  24. exit(1);
  25. }
  26. if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
  27. set_time_limit(0);
  28. }
  29. $container = \MailPoet\DI\ContainerWrapper::getInstance(WP_DEBUG);
  30. // Check if Linux Cron method is set in plugin settings
  31. $settings = $container->get(\MailPoet\Settings\SettingsController::class);
  32. if ($settings->get('cron_trigger.method') !== \MailPoet\Cron\CronTrigger::METHOD_LINUX_CRON) {
  33. echo 'MailPoet is not configured to run with Linux Cron.';
  34. exit(1);
  35. }
  36. // Run Cron Daemon
  37. $cronHelper = $container->get(\MailPoet\Cron\CronHelper::class);
  38. $data = $cronHelper->createDaemon(null);
  39. $trigger = $container->get(\MailPoet\Cron\Daemon::class);
  40. $trigger->run($data);