# ablocks/2.13.0/includes/ajax/email-template.php

aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder &amp; Animation Builder, version 2.13.0. 114 lines.

- Page: https://pluginprobe.com/plugins/ablocks/2.13.0/code/includes/ajax/email-template.php
- Raw: https://pluginprobe.com/plugins/ablocks/2.13.0/raw/includes/ajax/email-template.php
- Modified: 2026-09-08T12:29:06+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/ablocks/2.13.0/code/includes/ajax/email-template.php#L10-L20`.

```php
<?php

namespace ABlocks\Ajax;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

use ABlocks\Classes\AbstractAjaxHandler;
use ABlocks\Helper;
use ABlocks\Classes\{ Sanitizer, EmailTemplate as EmailTemplateModel };
use Exception;
class EmailTemplate extends AbstractAjaxHandler {
	public function __construct() {
		$this->actions = [
			'get_templates'      => [
				'callback' => [ $this, 'get_templates' ],
				'capability' => 'ablocks_manage_forms',
				'fields' => [
					'email_template_id' => 'string',
					'isSubscription' => 'boolean',
				]
			],
			'update_template'      => [
				'callback' => [ $this, 'update_template' ],
				'capability' => 'ablocks_manage_forms',
				'fields' => [
					'from' => 'string',
					'email_template_id' => 'string',
					'slug'     => 'string',
					'from_name' => 'string',
					'to' => 'string',
					'subject' => 'string',
					'body' => 'post',
					'reply_to' => 'string',
					'cc' => 'string',
					'bcc' => 'string',
					'format' => 'string',
					'status' => 'boolean',
				]
			],
			'delete_template'      => [
				'callback' => [ $this, 'delete_template' ],
				'capability' => 'ablocks_manage_forms',
				'fields' => [
					'email_template_id' => 'string',
					'slug'     => 'string',
				]
			],
			'remove_templates'      => [
				'callback' => [ $this, 'remove_templates' ],
				'capability' => 'ablocks_manage_forms',
				'fields' => [
					'email_template_id' => 'string',
				]
			],
		];
	}

	public function get_templates( array $payload ) : void {
		$email_template_id = $payload['email_template_id'] ?? '';
		$isSubscription = boolval( $payload['isSubscription'] ?? false );
		try {
			wp_send_json_success(
				EmailTemplateModel::ins( $email_template_id )
					->get_templates( $isSubscription )
			);
		} catch ( Exception $e ) {
			wp_send_json_error(
				$e->getMessage()
			);
		}
	}

	public function update_template( array $payload ) : void {
		$email_template_id = $payload['email_template_id'] ?? '';
		$slug     = $payload['slug'] ?? '';
		unset( $payload['email_template_id'], $payload['slug'] );
		try {
			wp_send_json_success(
				EmailTemplateModel::ins( $email_template_id )
					->update_template( $slug, $payload )
			);
		} catch ( Exception $e ) {
			wp_send_json_error(
				$e->getMessage()
			);
		}
	}

	public function delete_template( array $payload ) : void {
		$email_template_id = $payload['email_template_id'] ?? '';
		$slug     = $payload['slug'] ?? '';
		try {
			wp_send_json_success(
				EmailTemplateModel::ins( $email_template_id )
					->delete_template( $slug )
			);
		} catch ( Exception $e ) {
			wp_send_json_error(
				$e->getMessage()
			);
		}
	}

	public function remove_templates( array $payload ) : void {
		$email_template_id = $payload['email_template_id'] ?? '';
		delete_option( $email_template_id );
		wp_send_json_success( [
			'message' => __( 'Templates deleted.', 'ablocks' )
		] );
	}
}

```
