Analytics.php
3 years ago
AutomatedLatestContent.php
1 month ago
AutomaticEmails.php
3 years ago
Captcha.php
1 year ago
Coupons.php
2 years ago
CustomFields.php
2 months ago
DynamicProducts.php
1 year ago
DynamicSegments.php
1 month ago
FeatureFlags.php
3 years ago
Forms.php
1 month ago
Help.php
1 year ago
ImportExport.php
2 months ago
Mailer.php
1 year ago
NewsletterLinks.php
2 months ago
NewsletterTemplates.php
2 months ago
Newsletters.php
1 month ago
Premium.php
10 months ago
RedirectResponse.php
1 year ago
Segments.php
1 month ago
SendingQueue.php
2 months ago
Services.php
6 months ago
Settings.php
2 months ago
Setup.php
1 year ago
StatisticsExport.php
2 months ago
SubscriberStats.php
1 month ago
Subscribers.php
1 month ago
Tags.php
3 years ago
UserFlags.php
2 years ago
WoocommerceProductVariations.php
2 months ago
WoocommerceSettings.php
3 years ago
index.php
3 years ago
Setup.php
52 lines
| 1 | <?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing |
| 2 | |
| 3 | namespace MailPoet\API\JSON\v1; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\API\JSON\Endpoint as APIEndpoint; |
| 9 | use MailPoet\Config\AccessControl; |
| 10 | use MailPoet\Config\Activator; |
| 11 | use MailPoet\Settings\SettingsController; |
| 12 | use MailPoet\WP\Functions as WPFunctions; |
| 13 | |
| 14 | class Setup extends APIEndpoint { |
| 15 | public $permissions = [ |
| 16 | 'global' => AccessControl::PERMISSION_MANAGE_SETTINGS, |
| 17 | ]; |
| 18 | |
| 19 | /** @var WPFunctions */ |
| 20 | private $wp; |
| 21 | |
| 22 | /** @var Activator */ |
| 23 | private $activator; |
| 24 | |
| 25 | /** @var SettingsController */ |
| 26 | private $settings; |
| 27 | |
| 28 | public function __construct( |
| 29 | WPFunctions $wp, |
| 30 | Activator $activator, |
| 31 | SettingsController $settings |
| 32 | ) { |
| 33 | $this->wp = $wp; |
| 34 | $this->activator = $activator; |
| 35 | $this->settings = $settings; |
| 36 | } |
| 37 | |
| 38 | public function reset() { |
| 39 | try { |
| 40 | $this->activator->deactivate(); |
| 41 | $this->settings->resetCache(); |
| 42 | $this->activator->activate(); |
| 43 | $this->wp->doAction('mailpoet_setup_reset'); |
| 44 | return $this->successResponse(); |
| 45 | } catch (\Exception $e) { |
| 46 | return $this->errorResponse([ |
| 47 | $e->getCode() => $e->getMessage(), |
| 48 | ]); |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 |