PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 3.1.2
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v3.1.2
V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 2.10.2 All 137 releases
bit-form / includes / Core / Util / PostHelpers.php

PostHelpers.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 3.1.2, at includes/Core/Util/PostHelpers.php

52 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BitCode\BitForm\Core\Util;
4
5 trait PostHelpers
6 {
7 protected function postFieldMapping($postMap, $fieldValues, $postID, $entryID)
8 {
9 $postData = [];
10
11 $uploadFeatureImg = new WpFileHandler($this->_formID);
12
13 foreach ($postMap as $fieldPair) {
14 if (!empty($fieldPair->postField) && !empty($fieldPair->formField)) {
15 $formField = $fieldPair->formField;
16
17 $postField = $fieldPair->postField;
18
19 if ('_thumbnail_id' === $fieldPair->postField && !empty($fieldValues[$formField])) {
20 $uploadFeatureImg->uploadFeatureImg($fieldValues[$formField], $entryID, $postID);
21 } else {
22 if ('custom' === $fieldPair->formField && isset($fieldPair->customValue)) {
23 $postData[$postField] = $fieldPair->customValue;
24 } else {
25 $postData[$postField] = $fieldValues[$formField];
26 }
27 }
28 }
29 }
30 return $postData;
31 }
32
33 protected function setPostData($integrationDetails)
34 {
35 $postData = [];
36
37 $postData['comment_status'] = isset($integrationDetails->comment_status) ? $integrationDetails->comment_status : '';
38
39 $postData['post_status'] = isset($integrationDetails->post_status) ? $integrationDetails->post_status : '';
40
41 $postData['post_type'] = isset($integrationDetails->post_type) ? $integrationDetails->post_type : '';
42
43 if (isset($integrationDetails->post_author) && 'logged_in_user' !== $integrationDetails->post_author) {
44 $postData['post_author'] = $integrationDetails->post_author;
45 } else {
46 $postData['post_author'] = get_current_user_id();
47 }
48
49 return $postData;
50 }
51 }
52