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