PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 3.3.1
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v3.3.1
3.3.1 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 All 138 releases
← All changes | includes/Core/Util/WpFileHandler.php +24 -19 2.03.3.1 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,11 +16,11 @@
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) {
19 - require_once ABSPATH . 'wp-load.php';
20 - $_upload_dir = $this->_bitformsUploadBaseDir . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . $this->_formID . DIRECTORY_SEPARATOR . $entryID;
20 + public function uploadFeatureImg($file, $entryID, $postID)
21 + {
22 + $_upload_dir = FileHandler::getEntriesFileUploadDir($this->_formID, $entryID);
21 23 $files = is_string($file) ? json_decode($file) : $file;
22 24 $IMGFileName = $files[0];
23 25 $IMGFilePath = $_upload_dir . DIRECTORY_SEPARATOR . $IMGFileName;
24 26 if (file_exists($IMGFilePath)) {
@@ -45,11 +47,11 @@
45 47 set_post_thumbnail($postID, $attachmentId);
46 48 }
47 49 }
48 50
49 - public function singleFileMoveWpMedia($entryID, $fileValues, $post_id) {
50 - $_upload_dir = $this->_bitformsUploadBaseDir . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . $this->_formID . DIRECTORY_SEPARATOR . $entryID;
51 - require_once ABSPATH . 'wp-load.php';
51 + public function singleFileMoveWpMedia($entryID, $fileValues, $post_id)
52 + {
53 + $_upload_dir = FileHandler::getEntriesFileUploadDir($this->_formID, $entryID);
52 54 $files = is_string($fileValues) ? json_decode($fileValues) : $fileValues;
53 55
54 56 $IMGFileName = $files[0];
55 57 $IMGFilePath = $_upload_dir . DIRECTORY_SEPARATOR . $IMGFileName;
@@ -77,11 +79,11 @@
77 79 return $attachmentId;
78 80 }
79 81 }
80 82
81 - public function multiFileMoveWpMedia($entryID, $fileValues, $post_id) {
82 - $_upload_dir = $this->_bitformsUploadBaseDir . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . $this->_formID . DIRECTORY_SEPARATOR . $entryID;
83 - require_once ABSPATH . 'wp-load.php';
83 + public function multiFileMoveWpMedia($entryID, $fileValues, $post_id)
84 + {
85 + $_upload_dir = FileHandler::getEntriesFileUploadDir($this->_formID, $entryID);
84 86 $attachMentId = [];
85 87 $files = is_string($fileValues) ? json_decode($fileValues) : $fileValues;
86 88 foreach ($files as $file) {
87 89 $IMGFileName = $file;
@@ -115,15 +117,18 @@
115 117 }
116 118 return $attachMentId;
117 119 }
118 120
119 - public function taxonomyData($formFields, $fieldValues) {
121 + public function taxonomyData($formFields, $fieldValues)
122 + {
120 123 $taxanomyData = [];
121 124 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) {
125 + $customType = isset($field['customType']) ? $field['customType'] : null;
126 + $customType = (!isset($customType) && 'select' === $field->type && isset($field->customTypeList)) ? $field->customTypeList[0] : $customType;
127 + if (isset($customType)) {
128 + if (isset($customType->isTaxonomy) && !empty($fieldValues[$field['key']]) && isset($customType->isHierarchical)) {
129 + if (true === $customType->isTaxonomy) {
130 + if (true === $customType->isHierarchical) {
126 131 $taxanomyData[$fieldKey]['value'] = $fieldValues[$field['key']];
127 132 } else {
128 133 $slug = '';
129 134
@@ -129,9 +134,9 @@
129 134
130 135 if (is_array($fieldValues[$field['key']])) {
131 136 $allSlug = [];
132 137 foreach ($fieldValues[$field['key']] as $key => $value) {
133 - $exists = get_term_by('term_id', $value, $field['customType']->filter->taxanomy);
138 + $exists = get_term_by('term_id', $value, $customType->filter->taxanomy);
134 139 if ($exists) {
135 140 $allSlug[$key] = $exists->slug;
136 141 }
137 142 }
@@ -136,9 +141,9 @@
136 141 }
137 142 }
138 143 $slug = implode(',', $allSlug);
139 144 } else {
140 - $exists = get_term_by('term_id', $fieldValues[$field['key']], $field['customType']->filter->taxanomy);
145 + $exists = get_term_by('term_id', $fieldValues[$field['key']], $customType->filter->taxanomy);
141 146 if ($exists) {
142 147 $slug = $exists->slug;
143 148 }
144 149 }
@@ -144,9 +149,9 @@
144 149 }
145 150
146 151 $taxanomyData[$fieldKey]['value'] = $slug;
147 152 }
148 - $taxanomyData[$fieldKey]['term'] = $field['customType']->filter->taxanomy;
153 + $taxanomyData[$fieldKey]['term'] = $customType->filter->taxanomy;
149 154 }
150 155 }
151 156 }
152 157 }