No Description

Beacon.php 3.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace MailPoet\Helpscout;
  3. if (!defined('ABSPATH')) exit;
  4. use MailPoet\Cron\CronHelper;
  5. use MailPoet\DI\ContainerWrapper;
  6. use MailPoet\Router\Endpoints\CronDaemon;
  7. use MailPoet\Services\Bridge;
  8. use MailPoet\Settings\SettingsController;
  9. use MailPoet\Util\License\Features\Subscribers as SubscribersFeature;
  10. use MailPoet\WP\Functions as WPFunctions;
  11. class Beacon {
  12. /** @var SettingsController */
  13. private $settings;
  14. /** @var WPFunctions */
  15. private $wp;
  16. /** @var SubscribersFeature */
  17. private $subscribersFeature;
  18. public function __construct(
  19. SettingsController $settings,
  20. WPFunctions $wp,
  21. SubscribersFeature $subscribersFeature
  22. ) {
  23. $this->settings = $settings;
  24. $this->wp = $wp;
  25. $this->subscribersFeature = $subscribersFeature;
  26. }
  27. public function getData() {
  28. global $wpdb;
  29. $dbVersion = $wpdb->get_var('SELECT @@VERSION');
  30. $mta = $this->settings->get('mta');
  31. $currentTheme = WPFunctions::get()->wpGetTheme();
  32. $currentUser = WPFunctions::get()->wpGetCurrentUser();
  33. $sender = $this->settings->get('sender', ['address' => null]);
  34. $premiumKey = $this->settings->get(Bridge::PREMIUM_KEY_SETTING_NAME) ?: $this->settings->get(Bridge::API_KEY_SETTING_NAME);
  35. $cronHelper = ContainerWrapper::getInstance()->get(CronHelper::class);
  36. $cronPingUrl = $cronHelper->getCronUrl(
  37. CronDaemon::ACTION_PING
  38. );
  39. return [
  40. 'name' => $currentUser->display_name, // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
  41. 'email' => $sender['address'],
  42. 'PHP version' => PHP_VERSION,
  43. 'MailPoet Free version' => MAILPOET_VERSION,
  44. 'MailPoet Premium version' => (defined('MAILPOET_PREMIUM_VERSION')) ? MAILPOET_PREMIUM_VERSION : 'N/A',
  45. 'MailPoet Premium/MSS key' => $premiumKey,
  46. 'WordPress version' => $this->wp->getBloginfo('version'),
  47. 'Database version' => $dbVersion,
  48. 'Web server' => (!empty($_SERVER["SERVER_SOFTWARE"])) ? $_SERVER["SERVER_SOFTWARE"] : 'N/A',
  49. 'Server OS' => (function_exists('php_uname')) ? utf8_encode(php_uname()) : 'N/A',
  50. 'WP_MEMORY_LIMIT' => WP_MEMORY_LIMIT,
  51. 'WP_MAX_MEMORY_LIMIT' => WP_MAX_MEMORY_LIMIT,
  52. 'WP_DEBUG' => WP_DEBUG,
  53. 'PHP max_execution_time' => ini_get('max_execution_time'),
  54. 'PHP memory_limit' => ini_get('memory_limit'),
  55. 'PHP upload_max_filesize' => ini_get('upload_max_filesize'),
  56. 'PHP post_max_size' => ini_get('post_max_size'),
  57. 'WordPress language' => $this->wp->getLocale(),
  58. 'Multisite environment?' => (is_multisite() ? 'Yes' : 'No'),
  59. 'Current Theme' => $currentTheme->get('Name') .
  60. ' (version ' . $currentTheme->get('Version') . ')',
  61. 'Active Plugin names' => join(", ", $this->wp->getOption('active_plugins')),
  62. 'Sending Method' => $mta['method'],
  63. 'Sending Frequency' => sprintf('%d emails every %d minutes',
  64. $mta['frequency']['emails'],
  65. $mta['frequency']['interval']
  66. ),
  67. 'Task Scheduler method' => $this->settings->get('cron_trigger.method'),
  68. 'Cron ping URL' => $cronPingUrl,
  69. 'Default FROM address' => $this->settings->get('sender.address'),
  70. 'Default Reply-To address' => $this->settings->get('reply_to.address'),
  71. 'Bounce Email Address' => $this->settings->get('bounce.address'),
  72. 'Total number of subscribers' => $this->subscribersFeature->getSubscribersCount(),
  73. 'Plugin installed at' => $this->settings->get('installed_at'),
  74. ];
  75. }
  76. }