Confirm Submission<\/a><\/p> <\/p>
If you received this email by mistake, simply delete it. Your form submission won\'t proceed if you don\'t click the confirmation link above.<\/p>\",\"email_field\":\"\",\"skip_if_logged_in\":\"yes\",\"skip_if_fc_subscribed\":\"no\"}"}]}]',
'[{"id":"8","title":"Subscription Form","status":"published","appearance_settings":null,"form_fields":{"fields":[{"index":1,"element":"container","attributes":[],"settings":{"container_class":"","conditional_logics":{"type":"any","status":false,"conditions":[{"field":"","value":"","operator":""}]}},"columns":[{"fields":[{"index":1,"element":"input_email","attributes":{"type":"email","name":"email","value":"","id":"","class":"","placeholder":"Your Email Address"},"settings":{"container_class":"","label":"","label_placement":"","help_message":"","admin_field_label":"Email","validation_rules":{"required":{"value":true,"message":"This field is required"},"email":{"value":true,"message":"This field must contain a valid email"}},"conditional_logics":[],"is_unique":"no","unique_validation_message":"Email address need to be unique."},"editor_options":{"title":"Email Address","icon_class":"ff-edit-email","template":"inputText"},"uniqElKey":"el_16231279686950.8779857923682932"}]},{"fields":[{"index":15,"element":"custom_submit_button","attributes":{"class":"","type":"submit"},"settings":{"button_style":"","button_size":"md","align":"left","container_class":"","current_state":"normal_styles","background_color":"","color":"","hover_styles":{"backgroundColor":"#ffffff","borderColor":"#1a7efb","color":"#1a7efb","borderRadius":"","minWidth":"100%"},"normal_styles":{"backgroundColor":"#1a7efb","borderColor":"#1a7efb","color":"#ffffff","borderRadius":"","minWidth":"100%"},"button_ui":{"text":"Subscribe","type":"default","img_url":""},"conditional_logics":{"type":"any","status":false,"conditions":[{"field":"","value":"","operator":""}]}},"editor_options":{"title":"Custom Submit Button","icon_class":"dashicons dashicons-arrow-right-alt","template":"customButton"},"uniqElKey":"el_16231279798380.5947400167493171"}]}],"editor_options":{"title":"Two Column Container","icon_class":"ff-edit-column-2"},"uniqElKey":"el_16231279284710.40955091024524304"}],"submitButton":{"uniqElKey":"el_1524065200616","element":"button","attributes":{"type":"submit","class":""},"settings":{"align":"left","button_style":"default","container_class":"","help_message":"","background_color":"#1a7efb","button_size":"md","color":"#ffffff","button_ui":{"type":"default","text":"Subscribe","img_url":""}},"editor_options":{"title":"Submit Button"}}},"has_payment":"0","type":"form","conditions":null,"created_by":"1","created_at":"2021-06-08 04:51:36","updated_at":"2021-06-08 04:54:02","metas":[{"meta_key": "template_name","value": "inline_subscription"},{"meta_key":"formSettings","value":"{\"confirmation\":{\"redirectTo\":\"samePage\",\"messageToShow\":\"Thank you for your message. We will get in touch with you shortly\",\"customPage\":null,\"samePageFormBehavior\":\"hide_form\",\"customUrl\":null},\"restrictions\":{\"limitNumberOfEntries\":{\"enabled\":false,\"numberOfEntries\":null,\"period\":\"total\",\"limitReachedMsg\":\"Maximum number of entries exceeded.\"},\"scheduleForm\":{\"enabled\":false,\"start\":null,\"end\":null,\"pendingMsg\":\"Form submission is not started yet.\",\"expiredMsg\":\"Form submission is now closed.\"},\"requireLogin\":{\"enabled\":false,\"requireLoginMsg\":\"You must be logged in to submit the form.\"},\"denyEmptySubmission\":{\"enabled\":false,\"message\":\"Sorry, you cannot submit an empty form. Let\'s hear what you wanna say.\"}},\"layout\":{\"labelPlacement\":\"top\",\"helpMessagePlacement\":\"with_label\",\"errorMessagePlacement\":\"inline\",\"asteriskPlacement\":\"asterisk-right\"}}"},{"meta_key":"notifications","value":"{\"name\":\"Admin Notification Email\",\"sendTo\":{\"type\":\"email\",\"email\":\"{wp.admin_email}\",\"field\":\"email\",\"routing\":[{\"email\":null,\"field\":null,\"operator\":\"=\",\"value\":null}]},\"fromName\":\"\",\"fromEmail\":\"\",\"replyTo\":\"\",\"bcc\":\"\",\"subject\":\"[{inputs.names}] New Form Submission\",\"message\":\"
{all_data}<\\\/p>\\n
This form submitted at: {embed_post.permalink}<\\\/p>\",\"conditionals\":{\"status\":false,\"type\":\"all\",\"conditions\":[{\"field\":null,\"operator\":\"=\",\"value\":null}]},\"enabled\":false,\"email_template\":\"\"}"},{"meta_key":"step_data_persistency_status","value":"no"},{"meta_key":"_primary_email_field","value":"email"}]}]',
];
foreach ($forms as $index => $formJson) {
$structure = json_decode($formJson, true)[0];
$insertData = [
'title' => $structure['title'],
'type' => $structure['type'],
'status' => 'published',
'created_by' => get_current_user_id(),
'created_at' => current_time('mysql'),
'updated_at' => current_time('mysql'),
'form_fields' => json_encode($structure['form_fields']),
];
$wpdb->insert($formsTable, $insertData, [
'%s',
'%s',
'%s',
'%d',
'%s',
'%s',
'%s',
]);
$formId = $wpdb->insert_id;
foreach ($structure['metas'] as $meta) {
$meta['value'] = trim(preg_replace('/\s+/', ' ', $meta['value']));
$wpdb->insert($wpdb->prefix . 'fluentform_form_meta', [
'form_id' => $formId,
'meta_key' => $meta['meta_key'],
'value' => $meta['value'],
], [
'%d',
'%s',
'%s',
]);
}
}
}
}
public function setCronSchedule()
{
add_filter('cron_schedules', function ($schedules) {
$schedules['ff_every_five_minutes'] = [
'interval' => 300,
'display' => esc_html__('Every 5 Minutes (FluentForm)', 'fluentform'),
];
return $schedules;
}, 10, 1);
$hookName = 'fluentform_do_scheduled_tasks';
if (!wp_next_scheduled($hookName)) {
wp_schedule_event(time(), 'ff_every_five_minutes', $hookName);
}
$emailReportHookName = 'fluentform_do_email_report_scheduled_tasks';
if (!wp_next_scheduled($emailReportHookName)) {
wp_schedule_event(time(), 'daily', $emailReportHookName);
}
}
}