Add base route for sending preview email
MAILPOET-6092
This commit is contained in:
committed by
Rostislav Wolný
parent
27d8093f86
commit
87676ccdb6
@@ -10,6 +10,8 @@ namespace MailPoet\EmailEditor\Engine;
|
||||
|
||||
use MailPoet\EmailEditor\Validator\Builder;
|
||||
use WP_Post;
|
||||
use WP_REST_Request;
|
||||
use WP_REST_Response;
|
||||
|
||||
/**
|
||||
* Class for email API controller.
|
||||
@@ -35,6 +37,11 @@ class Email_Api_Controller {
|
||||
// Here comes code saving of Email specific data that will be passed on 'email_data' attribute.
|
||||
}
|
||||
|
||||
public function send_preview_email_data( WP_REST_Request $request ): WP_REST_Response {
|
||||
$data = $request->get_params();
|
||||
return new WP_REST_Response(['success' => true, 'data' => $data], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the schema for email data.
|
||||
*
|
||||
|
@@ -94,6 +94,7 @@ class Email_Editor {
|
||||
$this->extend_email_post_api();
|
||||
$this->settings_controller->init();
|
||||
}
|
||||
add_action( 'rest_api_init', [ $this, 'register_email_editor_api_routes' ] );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -198,6 +199,16 @@ class Email_Editor {
|
||||
);
|
||||
}
|
||||
|
||||
public function register_email_editor_api_routes() {
|
||||
register_rest_route('mailpoet-email-editor/v1', '/send_preview_email', [
|
||||
'methods' => 'POST',
|
||||
'callback' => array( $this->email_api_controller, 'send_preview_email_data' ),
|
||||
'permission_callback' => function() {
|
||||
return current_user_can('edit_posts');
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the schema for email theme data.
|
||||
*
|
||||
|
Reference in New Issue
Block a user