| 1 |
<?php |
| 2 |
|
| 3 |
use Give\FormBuilder\EmailPreview\Controllers\SendEmailPreview; |
| 4 |
use Give\FormBuilder\EmailPreview\Controllers\ShowEmailPreview; |
| 5 |
use Give\Framework\Permissions\Facades\UserPermissions; |
| 6 |
|
| 7 |
return [ |
| 8 |
|
| 9 |
/* |
| 10 |
|-------------------------------------------------------------------------- |
| 11 |
| Show the HTML of the email preview |
| 12 |
|-------------------------------------------------------------------------- |
| 13 |
| |
| 14 |
*/ |
| 15 |
|
| 16 |
'show' => [ |
| 17 |
'methods' => WP_REST_Server::CREATABLE, |
| 18 |
'callback' => [give(ShowEmailPreview::class), '__invoke'], |
| 19 |
'permission_callback' => function () { |
| 20 |
return UserPermissions::donationForms()->canEdit(); |
| 21 |
}, |
| 22 |
'args' => [ |
| 23 |
'email_type' => [ |
| 24 |
'required' => true, |
| 25 |
'type' => 'string', |
| 26 |
'sanitize_callback' => 'sanitize_text_field', |
| 27 |
], |
| 28 |
'form_id' => [ |
| 29 |
'required' => true, |
| 30 |
'type' => 'string', |
| 31 |
'sanitize_callback' => 'absint', |
| 32 |
], |
| 33 |
], |
| 34 |
], |
| 35 |
|
| 36 |
/* |
| 37 |
|-------------------------------------------------------------------------- |
| 38 |
| Send the email preview to a specified address |
| 39 |
|-------------------------------------------------------------------------- |
| 40 |
| |
| 41 |
*/ |
| 42 |
|
| 43 |
'send' => [ |
| 44 |
'methods' => WP_REST_Server::CREATABLE, |
| 45 |
'callback' => [give(SendEmailPreview::class), '__invoke'], |
| 46 |
'permission_callback' => function () { |
| 47 |
return UserPermissions::donationForms()->canEdit(); |
| 48 |
}, |
| 49 |
'args' => [ |
| 50 |
'email_type' => [ |
| 51 |
'required' => true, |
| 52 |
'type' => 'string', |
| 53 |
'sanitize_callback' => 'sanitize_text_field', |
| 54 |
], |
| 55 |
'email_address' => [ |
| 56 |
'required' => true, |
| 57 |
'type' => 'string', |
| 58 |
'sanitize_callback' => 'sanitize_email', |
| 59 |
], |
| 60 |
], |
| 61 |
], |
| 62 |
]; |
| 63 |
|