AbstractAutomationEmbed.php
5 months ago
Automation.php
2 years ago
AutomationAnalytics.php
2 months ago
AutomationEditor.php
2 months ago
AutomationFlowEmbed.php
6 months ago
AutomationPreviewEmbed.php
2 months ago
AutomationTemplates.php
2 years ago
CustomFields.php
2 months ago
DynamicSegments.php
2 months ago
ExperimentalFeatures.php
3 years ago
FormEditor.php
2 weeks ago
Forms.php
2 months ago
Help.php
2 months ago
Homepage.php
2 years ago
Landingpage.php
2 years ago
Logs.php
1 month ago
NewsletterEditor.php
2 months ago
Newsletters.php
2 months ago
Settings.php
5 months ago
StaticSegments.php
2 months ago
Subscribers.php
2 weeks ago
SubscribersExport.php
3 years ago
SubscribersImport.php
2 months ago
Tags.php
3 months ago
Upgrade.php
1 year ago
WelcomeWizard.php
2 months ago
WooCommerceSetup.php
2 months ago
index.php
3 years ago
Logs.php
61 lines
| 1 | <?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing |
| 2 | |
| 3 | namespace MailPoet\AdminPages\Pages; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\AdminPages\AssetsController; |
| 9 | use MailPoet\AdminPages\PageRenderer; |
| 10 | use MailPoet\Logging\LogRepository; |
| 11 | use MailPoet\Logging\LogsDownload; |
| 12 | use MailPoet\WP\Functions as WPFunctions; |
| 13 | use MailPoetVendor\Carbon\Carbon; |
| 14 | |
| 15 | class Logs { |
| 16 | /** @var AssetsController */ |
| 17 | private $assetsController; |
| 18 | |
| 19 | /** @var PageRenderer */ |
| 20 | private $pageRenderer; |
| 21 | |
| 22 | /** @var WPFunctions */ |
| 23 | private $wp; |
| 24 | |
| 25 | /** @var LogRepository */ |
| 26 | private $logRepository; |
| 27 | |
| 28 | public function __construct( |
| 29 | AssetsController $assetsController, |
| 30 | PageRenderer $pageRenderer, |
| 31 | WPFunctions $wp, |
| 32 | LogRepository $logRepository |
| 33 | ) { |
| 34 | $this->assetsController = $assetsController; |
| 35 | $this->pageRenderer = $pageRenderer; |
| 36 | $this->wp = $wp; |
| 37 | $this->logRepository = $logRepository; |
| 38 | } |
| 39 | |
| 40 | public function render() { |
| 41 | $this->assetsController->setupDataViewsDependencies(); |
| 42 | |
| 43 | $dateFrom = (new Carbon())->subDays(7); |
| 44 | $data = [ |
| 45 | 'logs_default_from' => $dateFrom->format('Y-m-d'), |
| 46 | 'logs_filter_options' => [ |
| 47 | 'names' => $this->logRepository->getDistinctNames(), |
| 48 | ], |
| 49 | 'api' => [ |
| 50 | 'root' => rtrim($this->wp->escUrlRaw($this->wp->restUrl()), '/'), |
| 51 | 'nonce' => $this->wp->wpCreateNonce('wp_rest'), |
| 52 | ], |
| 53 | 'download' => [ |
| 54 | 'action_url' => $this->wp->adminUrl('admin-post.php'), |
| 55 | 'nonce' => LogsDownload::createNonce($this->wp), |
| 56 | ], |
| 57 | ]; |
| 58 | $this->pageRenderer->displayPage('logs.html', $data); |
| 59 | } |
| 60 | } |
| 61 |