PATH:
home
/
lab2454c
/
caimegroup.com
/
wp-content
/
plugins
/
mailpoet
/
lib
/
API
/
JSON
/
v1
<?php declare(strict_types = 1); 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\Entities\TagEntity; use MailPoet\Tags\TagRepository; class Tags extends APIEndpoint { private $repository; public function __construct( TagRepository $repository ) { $this->repository = $repository; } public function create($data = []) { if (!isset($data['name'])) { return $this->badRequest([ APIError::BAD_REQUEST => __('A tag needs to have a name.', 'mailpoet'), ]); } $data['name'] = sanitize_text_field(wp_unslash($data['name'])); $data['description'] = isset($data['description']) ? sanitize_text_field(wp_unslash($data['description'])) : ''; return $this->successResponse( $this->mapTagEntity($this->repository->createOrUpdate($data)) ); } public function listing() { return $this->successResponse( array_map( [$this, 'mapTagEntity'], $this->repository->findAll() ) ); } private function mapTagEntity(TagEntity $tag): array { return [ 'id' => $tag->getId(), 'name' => $tag->getName(), 'description' => $tag->getDescription(), 'created_at' => $tag->getCreatedAt(), 'updated_at' => $tag->getUpdatedAt(), ]; } }
[-] Segments.php
[edit]
[-] Settings.php
[edit]
[-] Forms.php
[edit]
[-] FeatureFlags.php
[edit]
[-] Setup.php
[edit]
[-] index.php
[edit]
[+]
..
[-] AutomatedLatestContent.php
[edit]
[-] SubscriberStats.php
[edit]
[-] WoocommerceSettings.php
[edit]
[-] NewsletterLinks.php
[edit]
[-] AutomaticEmails.php
[edit]
[-] ImportExport.php
[edit]
[-] Subscribers.php
[edit]
[-] Analytics.php
[edit]
[-] DynamicSegments.php
[edit]
[-] Premium.php
[edit]
[-] UserFlags.php
[edit]
[-] Services.php
[edit]
[-] Newsletters.php
[edit]
[-] CustomFields.php
[edit]
[-] SendingTaskSubscribers.php
[edit]
[-] Coupons.php
[edit]
[-] NewsletterTemplates.php
[edit]
[-] SendingQueue.php
[edit]
[-] Mailer.php
[edit]
[-] Tags.php
[edit]