PHP 8.2.31
Preview: AutomaticEmails.php Size: 2.83 KB
/proc/self/root/home/nshryvcy/himaltourism.com/wp-content/plugins/mailpoet/lib/API/JSON/v1/AutomaticEmails.php

<?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);
  }
}

Directory Contents

Dirs: 0 × Files: 25

Name Size Perms Modified Actions
668 B lrw-r--r-- 2023-04-04 05:35:40
Edit Download
3.99 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
2.83 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
2.75 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
10.22 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
1.42 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
11.30 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
5.40 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
0 B lrw-r--r-- 2023-04-04 05:35:40
Edit Download
3.20 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
1.01 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
15.43 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
3.70 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
2.20 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
11.18 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
8.85 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
4.85 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
10.61 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
16.57 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
1014 B lrw-r--r-- 2023-04-04 05:35:40
Edit Download
11.36 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
2.25 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
1.34 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
1.00 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
870 B lrw-r--r-- 2023-04-04 05:35:40
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).