Server IP : 104.21.14.103 / Your IP : 3.16.218.216 Web Server : LiteSpeed System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : giankuin ( 1871) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/proc/thread-self/root/proc/thread-self/root/home/giankuin/thietke365.net/wp-content/plugins/mailpoet/lib/API/JSON/v1/ |
Upload File : |
<?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing namespace MailPoet\API\JSON\v1; if (!defined('ABSPATH')) exit; use MailPoet\API\JSON\Endpoint as APIEndpoint; use MailPoet\API\JSON\Error as APIError; use MailPoet\AutomaticEmails\AutomaticEmails as AutomaticEmailsController; use MailPoet\Config\AccessControl; use MailPoet\WP\Functions as WPFunctions; class AutomaticEmails extends APIEndpoint { public $permissions = [ 'global' => AccessControl::PERMISSION_MANAGE_SEGMENTS, ]; /** @var AutomaticEmailsController */ private $automaticEmails; /** @var WPFunctions */ private $wp; public function __construct( AutomaticEmailsController $automaticEmails, WPFunctions $wp ) { $this->automaticEmails = $automaticEmails; $this->wp = $wp; } public function getEventOptions($data) { $query = (!empty($data['query'])) ? $data['query'] : null; $filter = (!empty($data['filter'])) ? $data['filter'] : null; $emailSlug = (!empty($data['email_slug'])) ? $data['email_slug'] : null; $eventSlug = (!empty($data['event_slug'])) ? $data['event_slug'] : null; if (!$query || !$filter || !$emailSlug || !$eventSlug) { return $this->errorResponse( [ APIError::BAD_REQUEST => __('Improperly formatted request.', 'mailpoet'), ] ); } $event = $this->automaticEmails->getAutomaticEmailEventBySlug($emailSlug, $eventSlug); $eventFilter = (!empty($event['options']['remoteQueryFilter'])) ? $event['options']['remoteQueryFilter'] : null; return ($eventFilter === $filter && WPFunctions::get()->hasFilter($eventFilter)) ? $this->successResponse($this->wp->applyFilters($eventFilter, $query)) : $this->errorResponse( [ APIError::BAD_REQUEST => __('Automatic email event filter does not exist.', 'mailpoet'), ] ); } public function getEventShortcodes($data) { $emailSlug = (!empty($data['email_slug'])) ? $data['email_slug'] : null; $eventSlug = (!empty($data['event_slug'])) ? $data['event_slug'] : null; if (!$emailSlug || !$eventSlug) { return $this->errorResponse( [ APIError::BAD_REQUEST => __('Improperly formatted request.', 'mailpoet'), ] ); } $automaticEmail = $this->automaticEmails->getAutomaticEmailBySlug($emailSlug); $event = $this->automaticEmails->getAutomaticEmailEventBySlug($emailSlug, $eventSlug); if (!$event) { return $this->errorResponse( [ APIError::BAD_REQUEST => __('Automatic email event does not exist.', 'mailpoet'), ] ); } $eventShortcodes = (!empty($event['shortcodes']) && is_array($event['shortcodes'])) ? [ $automaticEmail['title'] => $event['shortcodes'], ] : null; return $this->successResponse($eventShortcodes); } }