private static function migrate_email_settings_to_action($form_options, $form_id, $post_type, &$imported, $switch) { // No old notifications or autoresponders to carry over if (!isset($form_options['auto_responder']) && !isset($form_options['notification']) && !isset($form_options['email_to'])) { return; } // Initialize notifications array $notifications = array(); // Migrate regular notifications self::migrate_notifications_to_action($form_options, $form_id, $notifications); // Migrate autoresponders self::migrate_autoresponder_to_action($form_options, $form_id, $notifications); if (empty($notifications)) { return; } foreach ($notifications as $new_notification) { $new_notification['post_type'] = $post_type; $new_notification['post_excerpt'] = 'email'; $new_notification['post_title'] = __('Email Notification', 'formidable'); $new_notification['menu_order'] = $form_id; $new_notification['post_status'] = 'publish'; // Switch field IDs and keys, if needed if ($switch) { // Switch field IDs in email conditional logic self::switch_email_contition_field_ids($new_notification['post_content']); // Switch all other field IDs in email $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids($new_notification['post_content']); } $new_notification['post_content'] = FrmAppHelper::prepare_and_encode($new_notification['post_content']); $exists = get_posts(array('name' => $new_notification['post_name'], 'post_type' => $new_notification['post_type'], 'post_status' => $new_notification['post_status'], 'numberposts' => 1)); if (empty($exists)) { FrmAppHelper::save_json_post($new_notification); $imported['imported']['actions']++; } unset($new_notification); } }
/** * Prepare and save settings in styles and actions * * @param array $settings * @param string $group * * @since 2.0.6 */ public static function save_settings($settings, $group) { $settings = (array) $settings; $settings['post_content'] = FrmAppHelper::prepare_and_encode($settings['post_content']); if (empty($settings['ID'])) { unset($settings['ID']); } // delete all caches for this group self::cache_delete_group($group); return self::save_json_post($settings); }