| @@ -7,9 +7,9 @@ | ||
| 7 | 7 | |
| 8 | 8 | namespace Smackcoders\SMUSERS; |
| 9 | 9 | |
| 10 | 10 | if ( ! defined( 'ABSPATH' ) ) |
| 11 | -exit; // Exit if accessed directly | |
| 11 | + exit; // Exit if accessed directly | |
| 12 | 12 | |
| 13 | 13 | class ImportHelpers { |
| 14 | 14 | private static $helpers_instance = null; |
| 15 | 15 | |
| @@ -148,21 +148,21 @@ | ||
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | $math = 'MATH('; |
| 152 | - if (strpos($csv_element, $math) !== false) { | |
| 153 | - $equation = str_replace('MATH(', '', $csv_element); | |
| 154 | - $equation = str_replace(')', '', $equation); | |
| 155 | - $csv_element = $this->evalmath($equation); | |
| 156 | - } | |
| 152 | + if (strpos($csv_element, $math) !== false) { | |
| 153 | + $equation = str_replace('MATH(', '', $csv_element); | |
| 154 | + $equation = str_replace(')', '', $equation); | |
| 155 | + $csv_element = $this->evalmath($equation); | |
| 156 | + } | |
| 157 | 157 | |
| 158 | - $wp_element= trim($key); | |
| 159 | - if(!empty($csv_element) && !empty($wp_element)){ | |
| 160 | - $post_values[$wp_element] = $csv_element; | |
| 161 | - } | |
| 162 | - //} | |
| 158 | + $wp_element= trim($key); | |
| 159 | + if(!empty($csv_element) && !empty($wp_element)){ | |
| 160 | + $post_values[$wp_element] = $csv_element; | |
| 161 | + } | |
| 162 | + //} | |
| 163 | 163 | } |
| 164 | - | |
| 164 | + | |
| 165 | 165 | elseif(!in_array($csv_value , $header_array)){ |
| 166 | 166 | $wp_element= trim($key); |
| 167 | 167 | $post_values[$wp_element] = $csv_value; |
| 168 | 168 | } |
| @@ -191,9 +191,8 @@ | ||
| 191 | 191 | |
| 192 | 192 | // convert percentages to decimal |
| 193 | 193 | $equation = preg_replace("/([+-])([0-9]{1})(%)/","*(1\$1.0\$2)",$equation); |
| 194 | 194 | $equation = preg_replace("/([+-])([0-9]+)(%)/","*(1\$1.\$2)",$equation); |
| 195 | - //$equation = preg_replace("/([0-9]+)(%)/",".\$1",$equation); | |
| 196 | 195 | |
| 197 | 196 | if ( $equation != "" ) |
| 198 | 197 | { |
| 199 | 198 | $result = @eval("return " . $equation . ";" ); |
| @@ -216,17 +215,17 @@ | ||
| 216 | 215 | global $wpdb; |
| 217 | 216 | $importlog_table_name = $wpdb->prefix ."import_log_detail"; |
| 218 | 217 | |
| 219 | 218 | $wpdb->insert($importlog_table_name, array( |
| 220 | - 'hash_key' => $hash_key, | |
| 221 | - 'message' => "{$message}", | |
| 222 | - 'status' => "{$status}", | |
| 223 | - 'verify' => "{$verify}", | |
| 224 | - 'post_id' => $post_id, | |
| 219 | + 'hash_key' => $hash_key, | |
| 220 | + 'message' => "{$message}", | |
| 221 | + 'status' => "{$status}", | |
| 222 | + 'verify' => "{$verify}", | |
| 223 | + 'post_id' => $post_id, | |
| 225 | 224 | |
| 226 | - ), | |
| 227 | - array('%s', '%s', '%s', '%s', '%d') | |
| 228 | - ); | |
| 225 | + ), | |
| 226 | + array('%s', '%s', '%s', '%s', '%d') | |
| 227 | + ); | |
| 229 | 228 | } |
| 230 | 229 | |
| 231 | 230 | public function update_error_log($message , $hash_key , $post_id){ |
| 232 | 231 | global $wpdb; |
| @@ -232,42 +231,42 @@ | ||
| 232 | 231 | global $wpdb; |
| 233 | 232 | $importlog_table_name = $wpdb->prefix ."import_log_detail"; |
| 234 | 233 | |
| 235 | 234 | $wpdb->insert($importlog_table_name, array( |
| 236 | - 'hash_key' => $hash_key, | |
| 237 | - 'message' => "{$message}", | |
| 238 | - 'post_id' => $post_id | |
| 235 | + 'hash_key' => $hash_key, | |
| 236 | + 'message' => "{$message}", | |
| 237 | + 'post_id' => $post_id | |
| 239 | 238 | |
| 240 | - ), | |
| 241 | - array('%s', '%s', '%d') | |
| 242 | - ); | |
| 239 | + ), | |
| 240 | + array('%s', '%s', '%d') | |
| 241 | + ); | |
| 243 | 242 | } |
| 244 | 243 | |
| 245 | 244 | public function update_category_log($category , $post_id){ |
| 246 | 245 | global $wpdb; |
| 247 | 246 | $wpdb->update($wpdb->prefix.'import_log_detail', array( |
| 248 | - 'categories' => "{$category}" | |
| 249 | - ), | |
| 250 | - array('post_id' => $post_id) | |
| 251 | - ); | |
| 247 | + 'categories' => "{$category}" | |
| 248 | + ), | |
| 249 | + array('post_id' => $post_id) | |
| 250 | + ); | |
| 252 | 251 | } |
| 253 | 252 | |
| 254 | 253 | public function update_tag_log($tag , $post_id){ |
| 255 | 254 | global $wpdb; |
| 256 | 255 | $wpdb->update($wpdb->prefix.'import_log_detail', array( |
| 257 | - 'tags' => "{$tag}" | |
| 258 | - ), | |
| 259 | - array('post_id' => $post_id) | |
| 260 | - ); | |
| 256 | + 'tags' => "{$tag}" | |
| 257 | + ), | |
| 258 | + array('post_id' => $post_id) | |
| 259 | + ); | |
| 261 | 260 | } |
| 262 | 261 | public function update_status_log($status , $verify , $post_id){ |
| 263 | 262 | global $wpdb; |
| 264 | 263 | $wpdb->update($wpdb->prefix.'import_log_detail', array( |
| 265 | - 'status' => "{$status}", | |
| 266 | - 'verify' => "{$verify}" | |
| 267 | - ), | |
| 268 | - array('post_id' => $post_id) | |
| 269 | - ); | |
| 264 | + 'status' => "{$status}", | |
| 265 | + 'verify' => "{$verify}" | |
| 266 | + ), | |
| 267 | + array('post_id' => $post_id) | |
| 268 | + ); | |
| 270 | 269 | } |
| 271 | 270 | |
| 272 | 271 | public function formatSizeUnits($bytes) |
| 273 | 272 | { |