Files
piratepoet/lib/API/JSON/v1/Setup.php
wxa 7788aebe83 Fix minor PR remarks [MAILPOET-2015]
Reuse updateCaptcha() function
Inject Captcha class using DI
Add no-cache headers to captcha image
Fix an error when accessing the captcha page directly
Edit the line in settings regarding missing dependencies
2019-07-23 08:37:46 -04:00

41 lines
1.0 KiB
PHP

<?php
namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\WP\Functions as WPFunctions;
use MailPoet\Config\AccessControl;
use MailPoet\Config\Activator;
use MailPoet\Config\Populator;
use MailPoet\Settings\SettingsController;
use MailPoet\Subscription\Captcha;
if (!defined('ABSPATH')) exit;
class Setup extends APIEndpoint {
private $wp;
public $permissions = [
'global' => AccessControl::PERMISSION_MANAGE_SETTINGS,
];
function __construct(WPFunctions $wp) {
$this->wp = $wp;
}
function reset() {
try {
$settings = new SettingsController();
$captcha = new Captcha();
$activator = new Activator($settings, new Populator($settings, $this->wp, $captcha));
$activator->deactivate();
$activator->activate();
$this->wp->doAction('mailpoet_setup_reset');
return $this->successResponse();
} catch (\Exception $e) {
return $this->errorResponse([
$e->getCode() => $e->getMessage(),
]);
}
}
}