Emails
2 months ago
Integrations
2 months ago
MultichannelMarketing
2 years ago
TransactionalEmails
10 months ago
WooCommerceBookings
1 month ago
WooCommerceSubscriptions
2 months ago
CouponPreProcessor.php
2 months ago
Emails.php
8 months ago
Helper.php
1 month ago
MailPoetTask.php
2 years ago
NonPersistablePreviewData.php
1 month ago
OrderAttributionFields.php
1 month ago
OrderAttributionRevenueReader.php
2 weeks ago
OrderAttributionWriter.php
1 month ago
RandomCouponCodeGenerator.php
2 months ago
Settings.php
1 year ago
SubscriberEngagement.php
3 years ago
Subscription.php
2 months ago
Tracker.php
2 years ago
TransactionalEmailHooks.php
1 year ago
TransactionalEmails.php
1 year ago
WooSystemInfo.php
1 month ago
WooSystemInfoController.php
1 year ago
index.php
3 years ago
MailPoetTask.php
63 lines
| 1 | <?php declare(strict_types = 1); |
| 2 | |
| 3 | namespace MailPoet\WooCommerce; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use Automattic\WooCommerce\Admin\Features\OnboardingTasks\Task; |
| 9 | use MailPoet\Config\Menu; |
| 10 | use MailPoet\DI\ContainerWrapper; |
| 11 | use MailPoet\Settings\SettingsController; |
| 12 | |
| 13 | /** |
| 14 | * MailPoet task that is added to the WooCommerce homepage. |
| 15 | */ |
| 16 | class MailPoetTask extends Task { |
| 17 | public function get_id(): string { // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
| 18 | return 'mailpoet_task'; |
| 19 | } |
| 20 | |
| 21 | public function get_title(): string { // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
| 22 | if ($this->is_complete()) { |
| 23 | return esc_html__('MailPoet is ready to send marketing emails from your store', 'mailpoet'); |
| 24 | } |
| 25 | |
| 26 | return esc_html__('Set up email marketing with MailPoet', 'mailpoet'); |
| 27 | } |
| 28 | |
| 29 | public function get_content(): string { // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
| 30 | return ''; |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * String that is displayed below the title of the task indicating the estimated completion time. |
| 35 | */ |
| 36 | public function get_time(): string { // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
| 37 | return ''; |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Link used when the user clicks on the title of the task. |
| 42 | */ |
| 43 | public function get_action_url(): string { // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
| 44 | if ($this->is_complete()) { |
| 45 | return admin_url('admin.php?page=' . Menu::MAIN_PAGE_SLUG); |
| 46 | } |
| 47 | |
| 48 | return admin_url('admin.php?page=' . Menu::WELCOME_WIZARD_PAGE_SLUG . '&mailpoet_wizard_loaded_via_woocommerce'); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Whether the task is completed. |
| 53 | * If the setting 'version' is not null it means the welcome wizard |
| 54 | * was already completed so we mark this task as completed as well. |
| 55 | */ |
| 56 | public function is_complete(): bool { // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
| 57 | $settings = ContainerWrapper::getInstance()->get(SettingsController::class); |
| 58 | $version = $settings->get('version'); |
| 59 | |
| 60 | return $version !== null; |
| 61 | } |
| 62 | } |
| 63 |