PluginProbe
Import Users & Customers with Meta | WP Ultimate CSV Importer Add-on / trunk
Import Users & Customers with Meta | WP Ultimate CSV Importer Add-on vtrunk
2.0 1.7.1 1.2.9 1.3 1.4 1.4.1 1.4.2 1.4.3 1.5 1.6 1.7 trunk 1.0 1.1 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8
← All changes | importExtensions/MediaHandling.php +82 -13 1.7trunk View file →
@@ -79,20 +79,49 @@
79 79 }
80 80 return $attach_id;
81 81 }
82 82 else{
83 - $attachment_id = $wpdb->get_results("SELECT ID FROM {$wpdb->prefix}posts WHERE post_type = 'attachment' AND guid LIKE '%$image_title%'", ARRAY_A);
83 + $attachment_id = $wpdb->get_results(
84 + $wpdb->prepare(
85 + "SELECT ID FROM {$wpdb->prefix}posts WHERE post_type = 'attachment' AND guid LIKE %s",
86 + '%' . $wpdb->esc_like( $image_title ) . '%'
87 + ),
88 + ARRAY_A
89 + );
84 90
85 91 }
86 92 if(is_array($attachment_id) && !empty($attachment_id[0]['ID']) && $image_type != 'Featured'){
87 93 $table_name = $wpdb->prefix . 'smackcsv_file_events';
88 - $post_title = $wpdb->get_var("SELECT post_title FROM {$wpdb->prefix}posts WHERE ID = '{$post_id}' AND post_status != 'trash'");
89 - $file_name = $wpdb->get_var("SELECT file_name FROM $table_name WHERE hash_key = '$hash_key'");
94 + $post_title = $wpdb->get_var(
95 + $wpdb->prepare(
96 + "SELECT post_title FROM {$wpdb->prefix}posts WHERE ID = %d AND post_status != 'trash'",
97 + absint( $post_id )
98 + )
99 + );
100 + $file_name = $wpdb->get_var(
101 + $wpdb->prepare(
102 + "SELECT file_name FROM $table_name WHERE hash_key = %s",
103 + $hash_key
104 + )
105 + );
90 106 $shortcode_table = $wpdb->prefix . "ultimate_csv_importer_shortcode_manager";
91 107 $attach_id = $attachment_id[0]['ID'];
92 - $check_id = $wpdb->get_results("SELECT ID FROM {$wpdb->prefix}posts WHERE ID ='{$attach_id}' AND post_title ='image-failed' AND post_type = 'attachment' AND guid LIKE '%$image_title%'", ARRAY_A);
108 + $check_id = $wpdb->get_results(
109 + $wpdb->prepare(
110 + "SELECT ID FROM {$wpdb->prefix}posts WHERE ID = %d AND post_title ='image-failed' AND post_type = 'attachment' AND guid LIKE %s",
111 + absint( $attach_id ),
112 + '%' . $wpdb->esc_like( $image_title ) . '%'
113 + ),
114 + ARRAY_A
115 + );
93 116 if(!empty($check_id)){
94 - $failed_ids = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}ultimate_csv_importer_shortcode_manager WHERE post_id='{$post_id}' AND media_id = '{$attach_id}'");
117 + $failed_ids = $wpdb->get_results(
118 + $wpdb->prepare(
119 + "SELECT * FROM {$wpdb->prefix}ultimate_csv_importer_shortcode_manager WHERE post_id = %d AND media_id = %d",
120 + absint( $post_id ),
121 + absint( $attach_id )
122 + )
123 + );
95 124 if(!empty($failed_ids) && $failed_ids[0]->post_id != $post_id){
96 125 $attach_id = $check_id[0]['ID'];;
97 126 $insert_status = $wpdb->insert($shortcode_table,
98 127 array(
@@ -229,10 +258,14 @@
229 258 $fimg_name = @basename($f_img);
230 259 $fimg_name = str_replace(' ', '-', trim($fimg_name));
231 260 $fimg_name = preg_replace('/[^a-zA-Z0-9._\-\s]/', '', $fimg_name);
232 261 }
233 - $attachment_id = $wpdb->get_var("SELECT ID FROM ".$wpdb->prefix."posts WHERE post_type = 'attachment' AND guid LIKE '%$fimg_name'");
234 -
262 + $attachment_id = $wpdb->get_var(
263 + $wpdb->prepare(
264 + "SELECT ID FROM ".$wpdb->prefix."posts WHERE post_type = 'attachment' AND guid LIKE %s",
265 + '%' . $wpdb->esc_like( $fimg_name )
266 + )
267 + );
235 268 if($attachment_id){
236 269 if(!empty($data_array['featured_image'])){
237 270 set_post_thumbnail( $post_id, $attachment_id );
238 271 return $attachment_id;
@@ -397,11 +430,27 @@
397 430 }
398 431 public function image_meta_table_entry($line_number ,$post_values, $post_id ,$acf_wpname_element, $acf_csv_name, $hash_key, $plugin,$get_import_type,$templatekey = null,$gmode = null,$header_array = null, $value_array = null,$imgformat = null,$typecct = null,$indexs=null){
399 432 global $wpdb;
400 433 $table_name = $wpdb->prefix . 'smackcsv_file_events';
401 - $file_name = $wpdb->get_var("SELECT file_name FROM $table_name WHERE hash_key = '$hash_key'");
402 - $post_title = $wpdb->get_var("SELECT post_title FROM {$wpdb->prefix}posts WHERE ID = '{$post_id}' AND post_status != 'trash'");
403 - $failed_ids = $wpdb->get_results("SELECT post_title,post_id,image_shortcode,media_id,original_image FROM {$wpdb->prefix}ultimate_csv_importer_shortcode_manager WHERE image_shortcode ='Featured_image_' AND post_id = '{$post_id}' AND original_image = '{$acf_csv_name}' ");
434 + $file_name = $wpdb->get_var(
435 + $wpdb->prepare(
436 + "SELECT file_name FROM $table_name WHERE hash_key = %s",
437 + $hash_key
438 + )
439 + );
440 + $post_title = $wpdb->get_var(
441 + $wpdb->prepare(
442 + "SELECT post_title FROM {$wpdb->prefix}posts WHERE ID = %d AND post_status != 'trash'",
443 + absint( $post_id )
444 + )
445 + );
446 + $failed_ids = $wpdb->get_results(
447 + $wpdb->prepare(
448 + "SELECT post_title,post_id,image_shortcode,media_id,original_image FROM {$wpdb->prefix}ultimate_csv_importer_shortcode_manager WHERE image_shortcode ='Featured_image_' AND post_id = %d AND original_image = %s",
449 + absint( $post_id ),
450 + $acf_csv_name
451 + )
452 + );
404 453 //$core_instance = CoreFieldsImport::getInstance();
405 454 //$core_instance = new WooCommerceCoreImport;
406 455 $shortcode_table = $wpdb->prefix . "ultimate_csv_importer_shortcode_manager";
407 456
@@ -423,9 +472,16 @@
423 472 $acf_image_meta =json_encode($image_meta_value);
424 473 }
425 474 $acf_image_meta = isset($acf_image_meta) ? $acf_image_meta : null;
426 475 $attach_id = $this->media_handling($acf_csv_name, $post_id, $post_values,$get_import_type,$plugin,$hash_key,'',$header_array,$value_array,$indexs,$acf_wpname_element,$acf_image_meta);
427 - $failed_id = $wpdb->get_results("SELECT post_title,post_id,image_shortcode,media_id,original_image FROM {$wpdb->prefix}ultimate_csv_importer_shortcode_manager WHERE post_id = '{$post_id}' AND original_image = '{$acf_csv_name}' AND image_shortcode = '" . esc_sql($plugin.'_image__'.$acf_wpname_element) . "' ");
476 + $failed_id = $wpdb->get_results(
477 + $wpdb->prepare(
478 + "SELECT post_title,post_id,image_shortcode,media_id,original_image FROM {$wpdb->prefix}ultimate_csv_importer_shortcode_manager WHERE post_id = %d AND original_image = %s AND image_shortcode = %s",
479 + absint( $post_id ),
480 + $acf_csv_name,
481 + $plugin . '_image__' . $acf_wpname_element
482 + )
483 + );
428 484 if(!empty($attach_id)){
429 485 $this->store_image_ids($attach_id ); //store the image id
430 486 return $attach_id;
431 487 }
@@ -485,14 +541,27 @@
485 541 }
486 542 }
487 543 else{
488 544 $media_id = $failed_id[0]->media_id;
489 - $attachment_id = $wpdb->get_results("SELECT ID FROM {$wpdb->prefix}posts WHERE ID = $media_id AND post_title ='image-failed' AND post_type = 'attachment' AND guid LIKE '%$fimg_name%'", ARRAY_A);
545 + $attachment_id = $wpdb->get_results(
546 + $wpdb->prepare(
547 + "SELECT ID FROM {$wpdb->prefix}posts WHERE ID = %d AND post_title ='image-failed' AND post_type = 'attachment' AND guid LIKE %s",
548 + absint( $media_id ),
549 + '%' . $wpdb->esc_like( $fimg_name ) . '%'
550 + ),
551 + ARRAY_A
552 + );
490 553 $attach_id= $attachment_id[0]['ID'];
491 554 }
492 555 return isset($attach_id) ? $attach_id : '';
493 556 }else{
494 - $attachment_id = $wpdb->get_results("SELECT ID FROM {$wpdb->prefix}posts WHERE post_title ='image-failed' AND post_type = 'attachment' AND guid LIKE '%$fimg_name%'", ARRAY_A);
557 + $attachment_id = $wpdb->get_results(
558 + $wpdb->prepare(
559 + "SELECT ID FROM {$wpdb->prefix}posts WHERE post_title ='image-failed' AND post_type = 'attachment' AND guid LIKE %s",
560 + '%' . $wpdb->esc_like( $fimg_name ) . '%'
561 + ),
562 + ARRAY_A
563 + );
495 564 }
496 565 return $attach_id;
497 566 }
498 567 }