← All changes
|
backend/src/Services/Template/ProductFeedbackFormTemplate.php
+17
-8
0.9
→
1.5
View file →
| @@ -3,13 +3,8 @@ | ||
| 3 | 3 | declare(strict_types=1); |
| 4 | 4 | |
| 5 | 5 | namespace IvyForms\Services\Template; |
| 6 | 6 | |
| 7 | -// phpcs:disable PSR1.Files.SideEffects | |
| 8 | -if (!defined('ABSPATH')) { | |
| 9 | - exit; // Exit if accessed directly | |
| 10 | -} | |
| 11 | - | |
| 12 | 7 | use IvyForms\Services\Translations\BackendStrings; |
| 13 | 8 | |
| 14 | 9 | /** |
| 15 | 10 | * Product Feedback Form Template |
| @@ -18,13 +13,13 @@ | ||
| 18 | 13 | */ |
| 19 | 14 | class ProductFeedbackFormTemplate |
| 20 | 15 | { |
| 21 | 16 | /** |
| 22 | - * Get the Product Feedback Form template | |
| 17 | + * Get template metadata (without form_data) | |
| 23 | 18 | * |
| 24 | 19 | * @return array<string, mixed> |
| 25 | 20 | */ |
| 26 | - public static function getTemplate(): array | |
| 21 | + public static function getTemplateMeta(): array | |
| 27 | 22 | { |
| 28 | 23 | return [ |
| 29 | 24 | 'id' => 'product_feedback_form', |
| 30 | 25 | 'name' => BackendStrings::getTemplateStrings()['product_feedback_form'], |
| @@ -32,8 +27,21 @@ | ||
| 32 | 27 | 'category' => 'feedback-forms', |
| 33 | 28 | 'subcategory' => 'customer-feedback-forms', |
| 34 | 29 | 'is_pro' => false, |
| 35 | 30 | 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'product-feedback-form.svg', |
| 31 | + ]; | |
| 32 | + } | |
| 33 | + | |
| 34 | + /** | |
| 35 | + * Get the full template including form data | |
| 36 | + * | |
| 37 | + * @return array<string, mixed> | |
| 38 | + */ | |
| 39 | + public static function getTemplate(): array | |
| 40 | + { | |
| 41 | + return array_merge( | |
| 42 | + self::getTemplateMeta(), | |
| 43 | + [ | |
| 36 | 44 | 'form_data' => [ |
| 37 | 45 | 'name' => BackendStrings::getTemplateStrings()['product_feedback_form'], |
| 38 | 46 | 'published' => 1, |
| 39 | 47 | 'showTitle' => 1, |
| @@ -48,9 +56,10 @@ | ||
| 48 | 56 | self::getWhatCanBeImprovedTextareaField() |
| 49 | 57 | ), |
| 50 | 58 | 'settings' => [] |
| 51 | 59 | ] |
| 52 | - ]; | |
| 60 | + ] | |
| 61 | + ); | |
| 53 | 62 | } |
| 54 | 63 | |
| 55 | 64 | /** |
| 56 | 65 | * Product name dropdown (required) |