PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.16.2
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.16.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
← All changes | includes/Core/Util/WpFileHandler.php +26 -17 2.02.16.2 View file →
@@ -1,15 +1,17 @@
1 1 <?php
2 2
3 3 namespace BitCode\BitForm\Core\Util;
4 4
5 -class WpFileHandler {
5 +class WpFileHandler
6 +{
6 7 private $_formID;
7 8 private $_uploadDirInfo;
8 9 private $_wpUploadbaseDir;
9 10 private $_bitformsUploadBaseDir;
10 11
11 - public function __construct($fromID) {
12 + public function __construct($fromID)
13 + {
12 14 $this->_formID = $fromID;
13 15 $this->_uploadDirInfo = wp_upload_dir();
14 16 $this->_wpUploadbaseDir = $this->_uploadDirInfo['basedir'];
15 17 $this->_bitformsUploadBaseDir = $this->_wpUploadbaseDir . DIRECTORY_SEPARATOR . 'bitforms';
@@ -14,9 +16,10 @@
14 16 $this->_wpUploadbaseDir = $this->_uploadDirInfo['basedir'];
15 17 $this->_bitformsUploadBaseDir = $this->_wpUploadbaseDir . DIRECTORY_SEPARATOR . 'bitforms';
16 18 }
17 19
18 - public function uploadFeatureImg($file, $entryID, $postID) {
20 + public function uploadFeatureImg($file, $entryID, $postID)
21 + {
19 22 require_once ABSPATH . 'wp-load.php';
20 23 $_upload_dir = $this->_bitformsUploadBaseDir . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . $this->_formID . DIRECTORY_SEPARATOR . $entryID;
21 24 $files = is_string($file) ? json_decode($file) : $file;
22 25 $IMGFileName = $files[0];
@@ -45,9 +48,10 @@
45 48 set_post_thumbnail($postID, $attachmentId);
46 49 }
47 50 }
48 51
49 - public function singleFileMoveWpMedia($entryID, $fileValues, $post_id) {
52 + public function singleFileMoveWpMedia($entryID, $fileValues, $post_id)
53 + {
50 54 $_upload_dir = $this->_bitformsUploadBaseDir . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . $this->_formID . DIRECTORY_SEPARATOR . $entryID;
51 55 require_once ABSPATH . 'wp-load.php';
52 56 $files = is_string($fileValues) ? json_decode($fileValues) : $fileValues;
53 57
@@ -77,9 +81,10 @@
77 81 return $attachmentId;
78 82 }
79 83 }
80 84
81 - public function multiFileMoveWpMedia($entryID, $fileValues, $post_id) {
85 + public function multiFileMoveWpMedia($entryID, $fileValues, $post_id)
86 + {
82 87 $_upload_dir = $this->_bitformsUploadBaseDir . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . $this->_formID . DIRECTORY_SEPARATOR . $entryID;
83 88 require_once ABSPATH . 'wp-load.php';
84 89 $attachMentId = [];
85 90 $files = is_string($fileValues) ? json_decode($fileValues) : $fileValues;
@@ -115,16 +120,20 @@
115 120 }
116 121 return $attachMentId;
117 122 }
118 123
119 - public function taxonomyData($formFields, $fieldValues) {
120 - $taxanomyData = [];
124 + public function getTaxonomies($formFields, $fieldValues)
125 + {
126 + $taxonomies = [];
121 127 foreach ($formFields as $fieldKey => $field) {
122 - if (isset($field['customType'])) {
123 - if (isset($field['customType']->isTaxonomy) && !empty($fieldValues[$field['key']]) && isset($field['customType']->isHierarchical)) {
124 - if (true === $field['customType']->isTaxonomy) {
125 - if (true === $field['customType']->isHierarchical) {
126 - $taxanomyData[$fieldKey]['value'] = $fieldValues[$field['key']];
128 + $field = 'object' === gettype($field) ? (array) $field : $field;
129 + $customType = isset($field['customType']) ? $field['customType'] : null;
130 + $customType = (!isset($customType) && 'select' === $field['type'] && isset($field['customTypeList'])) ? $field['customTypeList'][0] : $customType;
131 + if (isset($customType)) {
132 + if (isset($customType->isTaxonomy) && !empty($fieldValues[$field['key']]) && isset($customType->isHierarchical)) {
133 + if (true === $customType->isTaxonomy) {
134 + if (true === $customType->isHierarchical) {
135 + $taxonomies[$fieldKey]['value'] = $fieldValues[$field['key']];
127 136 } else {
128 137 $slug = '';
129 138
130 139 if (is_array($fieldValues[$field['key']])) {
@@ -129,9 +138,9 @@
129 138
130 139 if (is_array($fieldValues[$field['key']])) {
131 140 $allSlug = [];
132 141 foreach ($fieldValues[$field['key']] as $key => $value) {
133 - $exists = get_term_by('term_id', $value, $field['customType']->filter->taxanomy);
142 + $exists = get_term_by('term_id', $value, $customType->filter->taxanomy);
134 143 if ($exists) {
135 144 $allSlug[$key] = $exists->slug;
136 145 }
137 146 }
@@ -136,20 +145,20 @@
136 145 }
137 146 }
138 147 $slug = implode(',', $allSlug);
139 148 } else {
140 - $exists = get_term_by('term_id', $fieldValues[$field['key']], $field['customType']->filter->taxanomy);
149 + $exists = get_term_by('term_id', $fieldValues[$field['key']], $customType->filter->taxanomy);
141 150 if ($exists) {
142 151 $slug = $exists->slug;
143 152 }
144 153 }
145 154
146 - $taxanomyData[$fieldKey]['value'] = $slug;
155 + $taxonomies[$fieldKey]['value'] = $slug;
147 156 }
148 - $taxanomyData[$fieldKey]['term'] = $field['customType']->filter->taxanomy;
157 + $taxonomies[$fieldKey]['term'] = $customType->filter->taxanomy;
149 158 }
150 159 }
151 160 }
152 161 }
153 - return $taxanomyData;
162 + return $taxonomies;
154 163 }
155 164 }