| 1 |
<?php |
| 2 |
namespace FormLayer; |
| 3 |
|
| 4 |
if(!defined('ABSPATH')){ |
| 5 |
exit; |
| 6 |
} |
| 7 |
|
| 8 |
class Templates{ |
| 9 |
|
| 10 |
static function get_all(){ |
| 11 |
$templates = [ |
| 12 |
[ 'id' => 'scratch', 'title' => __('Start from Scratch', 'formlayer'), 'desc' => __('A clean slate for your custom form vision.', 'formlayer'), 'icon' => 'dashicons-plus', 'cat' => 'all' ], |
| 13 |
[ 'id' => 'contact', 'title' => __('Direct Contact Hub', 'formlayer'), 'desc' => __('Professional name, email, and message for inquiries.', 'formlayer'), 'icon' => 'dashicons-email', 'cat' => 'general', 'fields' => [ |
| 14 |
[ 'id' => 'f1', 'type' => 'name', 'label' => 'Full Identity', 'placeholder' => 'Your complete name', 'required' => true ], |
| 15 |
[ 'id' => 'f2', 'type' => 'email', 'label' => 'Contact Mail', 'placeholder' => 'best@email.com', 'required' => true ], |
| 16 |
[ 'id' => 'f3', 'type' => 'text', 'label' => 'Subject', 'placeholder' => 'How can we help?', 'required' => true ], |
| 17 |
[ 'id' => 'f4', 'type' => 'textarea', 'label' => 'Message Body', 'placeholder' => 'Tell us how we can help...', 'required' => true ], |
| 18 |
[ 'id' => 'f5', 'type' => 'gdpr', 'label' => 'I agree to the privacy policy', 'required' => true ], |
| 19 |
[ 'id' => 'f6', 'type' => 'submit', 'label' => 'Send Message' ] |
| 20 |
]], |
| 21 |
[ 'id' => 'lead_gen', 'title' => __('Growth Lead Capturer', 'formlayer'), 'desc' => __('Optimized for high-conversion B2B marketing.', 'formlayer'), 'icon' => 'dashicons-megaphone', 'cat' => 'marketing', 'fields' => [ |
| 22 |
[ 'id' => 'f1', 'type' => 'name', 'label' => 'Prospect Name', 'required' => true ], |
| 23 |
[ 'id' => 'f2', 'type' => 'email', 'label' => 'Professional Business Email', 'required' => true ], |
| 24 |
[ 'id' => 'f3', 'type' => 'text', 'label' => 'Company Name', 'required' => true ], |
| 25 |
[ 'id' => 'f4', 'type' => 'dropdown', 'label' => 'Industry Sector', 'options' => ['Tech', 'Health', 'Finance', 'Education'], 'required' => true ], |
| 26 |
[ 'id' => 'f5', 'type' => 'url', 'label' => 'Company Website', 'required' => false ], |
| 27 |
[ 'id' => 'f6', 'type' => 'submit', 'label' => 'Get Started' ] |
| 28 |
]], |
| 29 |
[ 'id' => 'service', 'title' => __('Service Request Desk', 'formlayer'), 'desc' => __('Efficient ticket generation for technical issues.', 'formlayer'), 'icon' => 'dashicons-sos', 'cat' => 'crm', 'fields' => [ |
| 30 |
[ 'id' => 'f1', 'type' => 'email', 'label' => 'Requester Email', 'required' => true ], |
| 31 |
[ 'id' => 'f2', 'type' => 'dropdown', 'label' => 'Issue Category', 'options' => ['Hardware', 'Software', 'Network', 'Account'], 'required' => true ], |
| 32 |
[ 'id' => 'f3', 'type' => 'radio', 'label' => 'Issue Priority', 'options' => ['P1 - Critical', 'P2 - High', 'P3 - Normal'], 'required' => true ], |
| 33 |
[ 'id' => 'f4', 'type' => 'text', 'label' => 'Summary Subject', 'required' => true ], |
| 34 |
[ 'id' => 'f5', 'type' => 'textarea', 'label' => 'Detailed Problem Description', 'placeholder' => 'Describe the technical issue...', 'required' => true ], |
| 35 |
[ 'id' => 'f6', 'type' => 'submit', 'label' => 'Open Support Ticket' ] |
| 36 |
]], |
| 37 |
[ 'id' => 'feedback', 'title' => __('Product Insight Survey', 'formlayer'), 'desc' => __('Listen to your users with quantitative ratings.', 'formlayer'), 'icon' => 'dashicons-awards', 'cat' => 'feedback', 'fields' => [ |
| 38 |
[ 'id' => 'f1', 'type' => 'name', 'label' => 'Reviewer Name', 'required' => false ], |
| 39 |
[ 'id' => 'f2', 'type' => 'rating', 'label' => 'Overall Satisfaction Score', 'required' => true ], |
| 40 |
[ 'id' => 'f3', 'type' => 'textarea', 'label' => 'What is our best feature?', 'required' => false ], |
| 41 |
[ 'id' => 'f4', 'type' => 'textarea', 'label' => 'Areas for Improvement', 'required' => false ], |
| 42 |
[ 'id' => 'f5', 'type' => 'checkbox', 'label' => 'Would you recommend us?', 'options' => ['Yes', 'Maybe', 'No'], 'required' => true ], |
| 43 |
[ 'id' => 'f6', 'type' => 'submit', 'label' => 'Send Feedback' ] |
| 44 |
]], |
| 45 |
// Pro Teaser Templates |
| 46 |
[ 'id' => 'course_reg', 'title' => __('Course Enrollment (Pro)', 'formlayer'), 'desc' => __('Secure student details and course selections.', 'formlayer'), 'icon' => 'dashicons-welcome-learn-more', 'cat' => 'education', 'is_pro' => true ], |
| 47 |
[ 'id' => 'it_asset', 'title' => __('IT Asset Request (Pro)', 'formlayer'), 'desc' => __('Workflow for internal hardware and software requests.', 'formlayer'), 'icon' => 'dashicons-laptop', 'cat' => 'it', 'is_pro' => true ], |
| 48 |
[ 'id' => 'expense_claim', 'title' => __('Expense Reimbursement (Pro)', 'formlayer'), 'desc' => __('Processing finance claims for team mileage and costs.', 'formlayer'), 'icon' => 'dashicons-money-alt', 'cat' => 'finance', 'is_pro' => true ], |
| 49 |
[ 'id' => 'onboarding', 'title' => __('Member Onboarding (Pro)', 'formlayer'), 'desc' => __('User registration for your digital community.', 'formlayer'), 'icon' => 'dashicons-admin-users', 'cat' => 'crm', 'is_pro' => true ], |
| 50 |
[ 'id' => 'talent', 'title' => __('Talent Discovery Portal (Pro)', 'formlayer'), 'desc' => __('Modern job application flow with portfolio support.', 'formlayer'), 'icon' => 'dashicons-id', 'cat' => 'hr', 'is_pro' => true ], |
| 51 |
[ 'id' => 'marketing_survey', 'title' => __('Market Trends Survey (Pro)', 'formlayer'), 'desc' => __('Analyze industry shifts with comprehensive data.', 'formlayer'), 'icon' => 'dashicons-chart-area', 'cat' => 'marketing', 'is_pro' => true ] |
| 52 |
]; |
| 53 |
|
| 54 |
return apply_filters('formlayer_templates', $templates); |
| 55 |
} |
| 56 |
|
| 57 |
static function js_templates(){ |
| 58 |
return [ |
| 59 |
|
| 60 |
'empty_state' => ' |
| 61 |
<div class="formlayer-empty-dropzone"> |
| 62 |
<div class="formlayer-empty-icon"> |
| 63 |
<span class="dashicons dashicons-plus"></span> |
| 64 |
</div> |
| 65 |
<p>' . esc_html__('Click on sidebar elements to add them to your form.', 'formlayer' ) . '</p> |
| 66 |
</div>', |
| 67 |
|
| 68 |
'field_instance' => ' |
| 69 |
<div class="formlayer-field-instance {{active_class}} label-{{label_placement}} {{container_class}}" data-id="{{id}}"> |
| 70 |
{{label_html}} |
| 71 |
<div class="formlayer-field-input" {{input_style}}> |
| 72 |
{{input_html}} |
| 73 |
</div> |
| 74 |
{{help_html}} |
| 75 |
{{actions_html}} |
| 76 |
</div>', |
| 77 |
|
| 78 |
'field_label' => ' |
| 79 |
<div class="formlayer-field-label"> |
| 80 |
<label {{label_style}}>{{label}} {{required_mark}}</label> |
| 81 |
</div>', |
| 82 |
|
| 83 |
'field_actions' => ' |
| 84 |
<div class="formlayer-field-actions"> |
| 85 |
<button class="formlayer-field-move-up" title="' . esc_attr__( 'Move Up', 'formlayer' ) . '" {{move_up_disabled}}> |
| 86 |
<span class="dashicons dashicons-arrow-up-alt2"></span> |
| 87 |
</button> |
| 88 |
<button class="formlayer-field-move-down" title="' . esc_attr__( 'Move Down', 'formlayer' ) . '" {{move_down_disabled}}> |
| 89 |
<span class="dashicons dashicons-arrow-down-alt2"></span> |
| 90 |
</button> |
| 91 |
<button class="formlayer-field-clone" title="' . esc_attr__( 'Clone', 'formlayer' ) . '"> |
| 92 |
<span class="dashicons dashicons-admin-page"></span> |
| 93 |
</button> |
| 94 |
<button class="formlayer-field-delete" title="' . esc_attr__( 'Delete', 'formlayer' ) . '"> |
| 95 |
<span class="dashicons dashicons-trash"></span> |
| 96 |
</button> |
| 97 |
</div>', |
| 98 |
|
| 99 |
'hidden_field_preview' => ' |
| 100 |
<div class="formlayer-field-hidden-preview"> |
| 101 |
<span class="dashicons dashicons-visibility-faint"></span> |
| 102 |
' . esc_html__( 'Hidden:', 'formlayer' ) . ' {{value}} |
| 103 |
</div>', |
| 104 |
|
| 105 |
'captcha_preview' => ' |
| 106 |
<div class="formlayer-captcha-preview fl-style-box"> |
| 107 |
<span class="dashicons dashicons-shield fl-icon"></span> |
| 108 |
<div class="fl-title">{{provider}}</div> |
| 109 |
<p class="fl-desc">' . esc_html__( '(Using global credentials from settings)', 'formlayer' ) . '</p> |
| 110 |
</div>', |
| 111 |
|
| 112 |
'richtext_preview' => ' |
| 113 |
<div class="formlayer-richtext-preview fl-style-box"> |
| 114 |
<div class="fl-toolbar"> |
| 115 |
<span class="dashicons dashicons-editor-bold"></span> |
| 116 |
<span class="dashicons dashicons-editor-italic"></span> |
| 117 |
<span class="dashicons dashicons-editor-ul"></span> |
| 118 |
<span class="dashicons dashicons-editor-ol"></span> |
| 119 |
</div> |
| 120 |
<div class="fl-placeholder">' . esc_html__( 'Rich Text Editor Placeholder', 'formlayer' ) . '</div> |
| 121 |
</div>', |
| 122 |
|
| 123 |
'template_card' => ' |
| 124 |
<div class="formlayer-template-card {{locked_class}}" data-id="{{id}}"> |
| 125 |
{{badge_html}} |
| 126 |
<div class="template-icon"> |
| 127 |
<span class="dashicons {{icon}}"></span> |
| 128 |
</div> |
| 129 |
<div class="template-info"> |
| 130 |
<h4>{{title}}</h4> |
| 131 |
<p>{{desc}}</p> |
| 132 |
</div> |
| 133 |
<div class="template-footer"> |
| 134 |
{{button_html}} |
| 135 |
</div> |
| 136 |
</div>', |
| 137 |
|
| 138 |
'no_templates_found' => ' |
| 139 |
<div class="formlayer-empty-search"> |
| 140 |
<span class="dashicons dashicons-search"></span> |
| 141 |
<h3>' . esc_html__( 'No templates found', 'formlayer' ) . '</h3> |
| 142 |
<p>' . esc_html__( 'Try a different search term or category.', 'formlayer' ) . '</p> |
| 143 |
</div>', |
| 144 |
|
| 145 |
'file_upload_box' => ' |
| 146 |
<div class="formlayer-file-upload-box"> |
| 147 |
<div class="formlayer-file-fake-btn" {{btn_style}}>{{btn_text}}</div> |
| 148 |
<span class="formlayer-file-chosen-name">{{chosen_text}}</span> |
| 149 |
</div>', |
| 150 |
|
| 151 |
'name_fields_preview' => ' |
| 152 |
<div class="formlayer-name-preview-container"> |
| 153 |
{{sub_fields}} |
| 154 |
</div>', |
| 155 |
|
| 156 |
'address_grid_preview' => ' |
| 157 |
<div class="formlayer-grid formlayer-address-grid"> |
| 158 |
{{sub_fields}} |
| 159 |
</div>', |
| 160 |
|
| 161 |
'sub_field_preview' => ' |
| 162 |
<div class="formlayer-sub-field {{full_width_class}}"> |
| 163 |
<input type="{{type}}" placeholder="{{placeholder}}" disabled> |
| 164 |
<div class="formlayer-sub-label">{{label}}</div> |
| 165 |
</div>', |
| 166 |
|
| 167 |
'sidebar_category' => ' |
| 168 |
<div class="formlayer-category {{open_class}}" data-cat="{{id}}"> |
| 169 |
<div class="formlayer-category-header"> |
| 170 |
<span> |
| 171 |
<span class="dashicons dashicons-admin-generic"></span> {{label}} |
| 172 |
</span> |
| 173 |
<span class="dashicons dashicons-arrow-down-alt2"></span> |
| 174 |
</div> |
| 175 |
<div class="formlayer-category-content"> |
| 176 |
{{fields_html}} |
| 177 |
</div> |
| 178 |
</div>', |
| 179 |
|
| 180 |
'palette_field' => ' |
| 181 |
<div class="formlayer-palette-field" data-type="{{type}}"> |
| 182 |
<span class="dashicons {{icon}}"></span> |
| 183 |
<span>{{label}}</span> |
| 184 |
</div>', |
| 185 |
|
| 186 |
'sidebar_accordion' => ' |
| 187 |
<div class="formlayer-accordion {{open_class}}" data-accordion="{{id}}"> |
| 188 |
<div class="formlayer-accordion-header"> |
| 189 |
<h4>{{title}}</h4> |
| 190 |
<span class="dashicons dashicons-arrow-down-alt2"></span> |
| 191 |
</div> |
| 192 |
<div class="formlayer-accordion-content"> |
| 193 |
{{content_html}} |
| 194 |
</div> |
| 195 |
</div>', |
| 196 |
|
| 197 |
'control_group' => ' |
| 198 |
<div class="formlayer-control-group"> |
| 199 |
<label class="formlayer-control-label">{{label}} {{info_html}}</label> |
| 200 |
{{input_html}} |
| 201 |
</div>', |
| 202 |
|
| 203 |
'info_icon' => ' |
| 204 |
<span class="formlayer-info-icon" title="{{title}}">i</span>', |
| 205 |
|
| 206 |
'option_edit_row' => ' |
| 207 |
<div class="formlayer-option-edit-row" data-index="{{index}}"> |
| 208 |
<input type="checkbox" class="formlayer-option-default" {{default_checked}} title="' . esc_attr__( 'Default selected', 'formlayer' ) . '"> |
| 209 |
<input type="text" class="formlayer-option-label" value="{{label}}" placeholder="' . esc_attr__( 'Label', 'formlayer' ) . '"> |
| 210 |
<input type="text" class="formlayer-option-value" value="{{value}}" placeholder="' . esc_attr__( 'Value', 'formlayer' ) . '"> |
| 211 |
<button class="formlayer-btn-remove-option" title="' . esc_attr__( 'Remove', 'formlayer' ) . '"> |
| 212 |
<span class="dashicons dashicons-no-alt"></span> |
| 213 |
</button> |
| 214 |
</div>' |
| 215 |
|
| 216 |
]; |
| 217 |
} |
| 218 |
} |
| 219 |
|