AbstractAutomationEmbed.php
5 months ago
Automation.php
2 years ago
AutomationAnalytics.php
2 months ago
AutomationEditor.php
2 months ago
AutomationFlowEmbed.php
5 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
1 week 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
1 week ago
SubscribersExport.php
3 years ago
SubscribersImport.php
2 months ago
Tags.php
2 months ago
Upgrade.php
1 year ago
WelcomeWizard.php
2 months ago
WooCommerceSetup.php
2 months ago
index.php
3 years ago
SubscribersImport.php
57 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\PageRenderer; |
| 9 | use MailPoet\Form\Block; |
| 10 | use MailPoet\Services\Validator; |
| 11 | use MailPoet\Subscribers\ImportExport\ImportExportFactory; |
| 12 | use MailPoet\WP\Functions as WPFunctions; |
| 13 | |
| 14 | class SubscribersImport { |
| 15 | /** @var PageRenderer */ |
| 16 | private $pageRenderer; |
| 17 | |
| 18 | /** @var Block\Date */ |
| 19 | private $dateBlock; |
| 20 | |
| 21 | /** @var WPFunctions */ |
| 22 | private $wp; |
| 23 | |
| 24 | public function __construct( |
| 25 | PageRenderer $pageRenderer, |
| 26 | Block\Date $dateBlock, |
| 27 | WPFunctions $wp |
| 28 | ) { |
| 29 | $this->pageRenderer = $pageRenderer; |
| 30 | $this->dateBlock = $dateBlock; |
| 31 | $this->wp = $wp; |
| 32 | } |
| 33 | |
| 34 | public function render() { |
| 35 | $import = new ImportExportFactory(ImportExportFactory::IMPORT_ACTION); |
| 36 | $data = $import->bootstrap(); |
| 37 | $dateTypes = $this->dateBlock->getDateTypes(); |
| 38 | $data = array_merge($data, [ |
| 39 | 'date_types' => $dateTypes, |
| 40 | 'custom_fields_date_types' => array_map(function ($label, $value) { |
| 41 | return [ |
| 42 | 'label' => $label, |
| 43 | 'value' => $value, |
| 44 | ]; |
| 45 | }, $dateTypes, array_keys($dateTypes)), |
| 46 | 'date_formats' => $this->dateBlock->getDateFormats(), |
| 47 | 'month_names' => $this->dateBlock->getMonthNames(), |
| 48 | 'role_based_emails' => json_encode(Validator::ROLE_EMAILS), |
| 49 | 'custom_fields_api' => [ |
| 50 | 'root' => rtrim($this->wp->escUrlRaw($this->wp->restUrl()), '/'), |
| 51 | 'nonce' => $this->wp->wpCreateNonce('wp_rest'), |
| 52 | ], |
| 53 | ]); |
| 54 | $this->pageRenderer->displayPage('subscribers/importExport/import.html', $data); |
| 55 | } |
| 56 | } |
| 57 |