<?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing namespace MailPoet\Subscription; if (!defined('ABSPATH')) exit; use MailPoet\API\JSON\API; use MailPoet\API\JSON\Endpoint; use MailPoet\API\JSON\Response as APIResponse; use MailPoet\Util\Url as UrlHelper; class Form { /** @var API */ private $api; /** @var UrlHelper */ private $urlHelper; public function __construct( API $api, UrlHelper $urlHelper ) { $this->api = $api; $this->urlHelper = $urlHelper; } public function onSubmit($requestData = false) { $requestData = ($requestData) ? $requestData : $_REQUEST; $this->api->setRequestData($requestData, Endpoint::TYPE_POST); $formId = (!empty($requestData['data']['form_id'])) ? (int)$requestData['data']['form_id'] : false; $response = $this->api->processRoute(); if ($response->status !== APIResponse::STATUS_OK) { return (isset($response->meta['redirect_url'])) ? $this->urlHelper->redirectTo($response->meta['redirect_url']) : $this->urlHelper->redirectBack( [ 'mailpoet_error' => ($formId) ? $formId : true, 'mailpoet_success' => null, ] ); } else { return (isset($response->meta['redirect_url'])) ? $this->urlHelper->redirectTo($response->meta['redirect_url']) : $this->urlHelper->redirectBack( [ 'mailpoet_success' => $formId, 'mailpoet_error' => null, ] ); } } }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
Blacklist.php | File | 1.69 KB | 0644 |
|
Comment.php | File | 3.33 KB | 0644 |
|
Form.php | File | 1.51 KB | 0644 |
|
Manage.php | File | 7.88 KB | 0644 |
|
ManageSubscriptionFormRenderer.php | File | 8.48 KB | 0644 |
|
Pages.php | File | 17.59 KB | 0644 |
|
Registration.php | File | 3.23 KB | 0644 |
|
SubscriptionUrlFactory.php | File | 4.04 KB | 0644 |
|
Throttling.php | File | 3.29 KB | 0644 |
|
index.php | File | 6 B | 0644 |
|