Ultimate CSV Importer - Version 3.9.4

Version Description

Download this release

Release Info

Developer smackcoders
Plugin Icon 128x128 Ultimate CSV Importer
Version 3.9.4
Comparing to
See all releases

Code changes from version 3.9.3 to 3.9.4

Readme.txt CHANGED
@@ -1,11 +1,11 @@
1
- === CSV Import for Wordpress ===
2
  Contributors: smackcoders
3
  Donate link: http://www.smackcoders.com/donate.html
4
  Tags: csv importer, import csv, import woocommerce, import marketpress, import seo by yoast, import all in one seo, scheduled import, import remote file, export woocommerce, import types fields, import acf fields, import inline images
5
  Requires at least: 4.0
6
  Tested up to: 4.5
7
- Stable tag: 3.9.3
8
- Version: 3.9.3
9
  Author: smackcoders
10
  Author URI: http://profiles.wordpress.org/smackcoders/
11
  License: GPLv2 or later
@@ -63,7 +63,7 @@ Ultimate CSV Importer PRO has all the features of WP Ultimate CSV Importer and i
63
 
64
  You can try the [live demo](http://demo.smackcoders.com/wordpressdemofour/wp-admin/admin.php?page=wp-ultimate-csv-importer-pro%2Findex.php&__module=dashboard) or request for free trial in [WordPress Ultimate CSV Importer](https://www.smackcoders.com/wp-ultimate-csv-importer-pro.html) page to generate your own WordPress test environment.
65
 
66
- Read our [blog](https://www.smackcoders.com/blog/category/wordpress-products) to know more about the new [features]() of our WordPress plugins.
67
 
68
  [Troubleshooting tips](https://wordpress.org/support/topic/tips-to-trouble-shoot-wp-ultimate-csv-importer-issues-1)
69
 
@@ -89,6 +89,8 @@ php_value auto_prepend_file none<br />
89
  php_value auto_append_file none<br />
90
  This will solve your issue or get support from hosting if you didn’t have sufficient permission.
91
  == Changelog ==
 
 
92
  = 3.9.3 =
93
  * Added: Compatibility for WordPress 4.5
94
  * Fixed: Environment issue with custom port id in MAMP.
@@ -354,6 +356,8 @@ This will solve your issue or get support from hosting if you didn’t have suff
354
  * Initial release version. Tested and found works well without any issues.
355
 
356
  == Upgrade Notice ==
 
 
357
  = 3.9.3 =
358
  * Upgrade now to get support for custom port id in MAMP environment and WordPress 4.5 compatibility.
359
  = 3.9.2 =
1
+ === CSV Import for WordPress ===
2
  Contributors: smackcoders
3
  Donate link: http://www.smackcoders.com/donate.html
4
  Tags: csv importer, import csv, import woocommerce, import marketpress, import seo by yoast, import all in one seo, scheduled import, import remote file, export woocommerce, import types fields, import acf fields, import inline images
5
  Requires at least: 4.0
6
  Tested up to: 4.5
7
+ Stable tag: 3.9.4
8
+ Version: 3.9.4
9
  Author: smackcoders
10
  Author URI: http://profiles.wordpress.org/smackcoders/
11
  License: GPLv2 or later
63
 
64
  You can try the [live demo](http://demo.smackcoders.com/wordpressdemofour/wp-admin/admin.php?page=wp-ultimate-csv-importer-pro%2Findex.php&__module=dashboard) or request for free trial in [WordPress Ultimate CSV Importer](https://www.smackcoders.com/wp-ultimate-csv-importer-pro.html) page to generate your own WordPress test environment.
65
 
66
+ Read our [blog](https://www.smackcoders.com/blog/category/wordpress-products) to know more about the new [features](https://www.smackcoders.com/wp-ultimate-csv-importer-pro/features.html) of our WordPress plugins.
67
 
68
  [Troubleshooting tips](https://wordpress.org/support/topic/tips-to-trouble-shoot-wp-ultimate-csv-importer-issues-1)
69
 
89
  php_value auto_append_file none<br />
90
  This will solve your issue or get support from hosting if you didn’t have sufficient permission.
91
  == Changelog ==
92
+ = 3.9.4 =
93
+ * Improvements: Duplicate image handling. Option to skip or rename image as imagename-number if image name is same as existing media image name.
94
  = 3.9.3 =
95
  * Added: Compatibility for WordPress 4.5
96
  * Fixed: Environment issue with custom port id in MAMP.
356
  * Initial release version. Tested and found works well without any issues.
357
 
358
  == Upgrade Notice ==
359
+ = 3.9.4 =
360
+ * Upgrade now for duplicate image handling feature.
361
  = 3.9.3 =
362
  * Upgrade now to get support for custom port id in MAMP environment and WordPress 4.5 compatibility.
363
  = 3.9.2 =
includes/WPImporter_includes_helper.php CHANGED
@@ -435,9 +435,18 @@ class WPImporter_includes_helper {
435
  /**
436
  * function to map the csv file and process it
437
  *
 
 
 
 
 
 
 
 
 
438
  * @return boolean
439
  */
440
- function processDataInWP($data_rows, $ret_array, $session_arr, $currentLimit, $extractedimagelocation, $importinlineimageoption, $sample_inlineimage_url = null) {
441
  global $wpdb;
442
  $post_id = '';
443
  $new_post = array();
@@ -558,9 +567,9 @@ class WPImporter_includes_helper {
558
 
559
  $f_img = $new_post [$ckey];
560
  $fimg_path = $full_path;
561
- $fimg_name = @basename($f_img);
562
 
563
- $fimg_name = str_replace(' ', '-', $fimg_name);
 
564
  $fimg_name = preg_replace('/[^a-zA-Z0-9._\-\s]/', '', $fimg_name);
565
  $fimg_name = urlencode($fimg_name);
566
  $parseURL = parse_url($f_img);
@@ -569,16 +578,17 @@ class WPImporter_includes_helper {
569
  $fimg_name = $fimg_name . '.jpg';
570
  }
571
  $f_img_slug = '';
572
- $featured_image = $path_parts['filename'];
573
- $f_img_slug = strtolower(str_replace('', '-', $f_img_slug));
 
574
  $f_img_slug = preg_replace('/[^a-zA-Z0-9._\-\s]/', '', $f_img_slug);
575
  $post_slug_value = strtolower($f_img_slug);
576
- if (array_key_exists('extension', $path_parts)) {
577
- //$fimg_name = wp_unique_filename($fimg_path, $fimg_name, $path_parts['extension']);
 
578
  }
579
  $this->get_fimg_from_URL($f_img, $fimg_path, $fimg_name, $post_slug_value, $currentLimit, $this);
580
  $filepath = $fimg_path . "/" . $fimg_name;
581
-
582
  if (@getimagesize($filepath)) {
583
  $img = wp_get_image_editor($filepath);
584
  $file ['guid'] = $baseurl . "/" . $fimg_name;
@@ -827,7 +837,7 @@ class WPImporter_includes_helper {
827
  if ($this->MultiImages == 'true') { // Inline image import feature by fredrick marks
828
  $inlineImagesObj = new WPImporter_inlineImages();
829
  $postid = wp_insert_post($data_array);
830
- $post_id = $inlineImagesObj->importwithInlineImages($postid, $currentLimit, $data_array, $this, $importinlineimageoption, $extractedimagelocation, $sample_inlineimage_url);
831
  } else {
832
  /* Check post parent is exist or not */
833
  if(isset($data_array['post_parent']) && isset($data_array['post_type']) && $data_array['post_type'] == 'page'){
@@ -945,7 +955,7 @@ class WPImporter_includes_helper {
945
  if (!empty ($file)) {
946
  //$wp_filetype = wp_check_filetype(@basename($file ['guid']), null);
947
  $wp_upload_dir = wp_upload_dir();
948
- $attachment = array('guid' => $file ['guid'], 'post_mime_type' => 'image/jpeg', 'post_title' => preg_replace('/[^a-zA-Z0-9._\s]/', '', @basename($file ['post_title'])), 'post_content' => '', 'post_status' => 'inherit');
949
  if ($get_media_settings == 1) {
950
  $generate_attachment = $dirname . '/' . $fimg_name;
951
  } else {
@@ -955,22 +965,28 @@ class WPImporter_includes_helper {
955
  /*$attach_id = wp_insert_attachment($attachment, $generate_attachment, $post_id);
956
  $attach_data = wp_generate_attachment_metadata($attach_id, $uploadedImage);
957
  wp_update_attachment_metadata($attach_id, $attach_data);*/
958
- $existing_attachment = array();
959
- $query = $wpdb->get_results($wpdb->prepare("select post_title from $wpdb->posts where post_type = %s and post_mime_type = %s",'attachment','image/jpeg'));
960
- if(!empty($query)) {
961
- foreach ( $query as $key ) {
962
- $existing_attachment[] = $key->post_title;
 
 
963
  }
964
- }
965
- if (!in_array($attachment['post_title'], $existing_attachment)) {
966
- $attach_id = wp_insert_attachment($attachment, $generate_attachment, $post_id);
967
- $attach_data = wp_generate_attachment_metadata($attach_id, $uploadedImage);
968
- wp_update_attachment_metadata($attach_id, $attach_data);
969
- } else {
970
- $query2 = $wpdb->get_results($wpdb->prepare("select ID from $wpdb->posts where post_title = %s and post_type = %s",$attachment['post_title'],'attachment'));
971
- foreach ($query2 as $key2) {
972
- $attach_id = $key2->ID;
973
  }
 
 
 
 
974
  }
975
  set_post_thumbnail($post_id, $attach_id);
976
  }
@@ -1214,7 +1230,7 @@ class WPImporter_includes_helper {
1214
  return $smack_csv_import_method;
1215
  }
1216
 
1217
- function helpnotes() {
1218
  $smackhelpnotes = '<span style="position:absolute;margin-top:6px;margin-left:15px;">
1219
  <a href="#" class="tooltip">
1220
  <img src="' . esc_url(WP_CONST_ULTIMATE_CSV_IMP_DIR . "images/help.png").'" />
@@ -1225,6 +1241,19 @@ class WPImporter_includes_helper {
1225
  </span>
1226
  </a>
1227
  </span>';
 
 
 
 
 
 
 
 
 
 
 
 
 
1228
  return $smackhelpnotes;
1229
  }
1230
 
435
  /**
436
  * function to map the csv file and process it
437
  *
438
+ * @param $data_rows
439
+ * @param $ret_array
440
+ * @param $session_arr
441
+ * @param $currentLimit
442
+ * @param $extractedimagelocation
443
+ * @param $importinlineimageoption
444
+ * @param null $sample_inlineimage_url
445
+ * @param bool $useexistingimages
446
+ *
447
  * @return boolean
448
  */
449
+ function processDataInWP($data_rows, $ret_array, $session_arr, $currentLimit, $extractedimagelocation, $importinlineimageoption, $sample_inlineimage_url = null, $useexistingimages = false) {
450
  global $wpdb;
451
  $post_id = '';
452
  $new_post = array();
567
 
568
  $f_img = $new_post [$ckey];
569
  $fimg_path = $full_path;
 
570
 
571
+ $fimg_name = @basename($f_img);
572
+ $fimg_name = str_replace(' ', '-', trim($fimg_name));
573
  $fimg_name = preg_replace('/[^a-zA-Z0-9._\-\s]/', '', $fimg_name);
574
  $fimg_name = urlencode($fimg_name);
575
  $parseURL = parse_url($f_img);
578
  $fimg_name = $fimg_name . '.jpg';
579
  }
580
  $f_img_slug = '';
581
+ #$featured_image = str_replace(' ', '-', trim($path_parts['filename']));
582
+ $featured_image = trim($path_parts['filename']);
583
+ $f_img_slug = strtolower(str_replace(' ', '-', trim($f_img_slug)));
584
  $f_img_slug = preg_replace('/[^a-zA-Z0-9._\-\s]/', '', $f_img_slug);
585
  $post_slug_value = strtolower($f_img_slug);
586
+ #if (array_key_exists('extension', $path_parts)) {
587
+ if ($useexistingimages == 'false') {
588
+ $fimg_name = wp_unique_filename($fimg_path, trim($fimg_name));
589
  }
590
  $this->get_fimg_from_URL($f_img, $fimg_path, $fimg_name, $post_slug_value, $currentLimit, $this);
591
  $filepath = $fimg_path . "/" . $fimg_name;
 
592
  if (@getimagesize($filepath)) {
593
  $img = wp_get_image_editor($filepath);
594
  $file ['guid'] = $baseurl . "/" . $fimg_name;
837
  if ($this->MultiImages == 'true') { // Inline image import feature by fredrick marks
838
  $inlineImagesObj = new WPImporter_inlineImages();
839
  $postid = wp_insert_post($data_array);
840
+ $post_id = $inlineImagesObj->importwithInlineImages($postid, $currentLimit, $data_array, $this, $importinlineimageoption, $extractedimagelocation, $sample_inlineimage_url, $useexistingimages);
841
  } else {
842
  /* Check post parent is exist or not */
843
  if(isset($data_array['post_parent']) && isset($data_array['post_type']) && $data_array['post_type'] == 'page'){
955
  if (!empty ($file)) {
956
  //$wp_filetype = wp_check_filetype(@basename($file ['guid']), null);
957
  $wp_upload_dir = wp_upload_dir();
958
+ $attachment = array('guid' => $file ['guid'], 'post_mime_type' => 'image/jpeg', 'post_title' => preg_replace('/[^a-zA-Z0-9._\-\s]/', '', @basename($file ['post_title'])), 'post_content' => '', 'post_status' => 'inherit');
959
  if ($get_media_settings == 1) {
960
  $generate_attachment = $dirname . '/' . $fimg_name;
961
  } else {
965
  /*$attach_id = wp_insert_attachment($attachment, $generate_attachment, $post_id);
966
  $attach_data = wp_generate_attachment_metadata($attach_id, $uploadedImage);
967
  wp_update_attachment_metadata($attach_id, $attach_data);*/
968
+ if($useexistingimages == 'true') {
969
+ $existing_attachment = array();
970
+ $query = $wpdb->get_results($wpdb->prepare("select post_title from $wpdb->posts where post_type = %s and post_mime_type = %s",'attachment','image/jpeg'));
971
+ if(!empty($query)) {
972
+ foreach ( $query as $key ) {
973
+ $existing_attachment[] = $key->post_title;
974
+ }
975
  }
976
+ if ( ! in_array( $attachment['post_title'], $existing_attachment ) ) {
977
+ $attach_id = wp_insert_attachment( $attachment, $generate_attachment, $post_id );
978
+ $attach_data = wp_generate_attachment_metadata( $attach_id, $uploadedImage );
979
+ wp_update_attachment_metadata( $attach_id, $attach_data );
980
+ } else {
981
+ $query2 = $wpdb->get_results( $wpdb->prepare( "select ID from $wpdb->posts where post_title = %s and post_type = %s", $attachment['post_title'], 'attachment' ) );
982
+ foreach ( $query2 as $key2 ) {
983
+ $attach_id = $key2->ID;
984
+ }
985
  }
986
+ } else {
987
+ $attach_id = wp_insert_attachment( $attachment, $generate_attachment, $post_id );
988
+ $attach_data = wp_generate_attachment_metadata( $attach_id, $uploadedImage );
989
+ wp_update_attachment_metadata( $attach_id, $attach_data );
990
  }
991
  set_post_thumbnail($post_id, $attach_id);
992
  }
1230
  return $smack_csv_import_method;
1231
  }
1232
 
1233
+ function helpnotes($media_option = null) {
1234
  $smackhelpnotes = '<span style="position:absolute;margin-top:6px;margin-left:15px;">
1235
  <a href="#" class="tooltip">
1236
  <img src="' . esc_url(WP_CONST_ULTIMATE_CSV_IMP_DIR . "images/help.png").'" />
1241
  </span>
1242
  </a>
1243
  </span>';
1244
+ if($media_option == 'skipDuplicate') {
1245
+ $smackhelpnotes = '<span style="position:absolute;margin-top:6px;margin-left:15px;text-align: justify;">
1246
+ <a href="#" class="tooltip">
1247
+ <img src="' . esc_url(WP_CONST_ULTIMATE_CSV_IMP_DIR . "images/help.png").'" />
1248
+ <span class="tooltipPostStatus">
1249
+ <img class="callout" src="' . esc_url(WP_CONST_ULTIMATE_CSV_IMP_DIR . "images/callout.gif").'" />
1250
+ 1) If checked, skips image with same name and assigns the existing image to the new post. <br>
1251
+ 2) If unchecked, image name is renamed as imagename-number(logo-1.png) similar to the WordPress media handling.
1252
+ <img src="' . esc_url(WP_CONST_ULTIMATE_CSV_IMP_DIR . "images/help.png").'" style="margin-top: 6px;float:right;" />
1253
+ </span>
1254
+ </a>
1255
+ </span>';
1256
+ }
1257
  return $smackhelpnotes;
1258
  }
1259
 
index.php CHANGED
@@ -2,7 +2,7 @@
2
  /******************************
3
  * Plugin Name: WP Ultimate CSV Importer
4
  * Description: A plugin that helps to import the data's from a CSV file.
5
- * Version: 3.9.3
6
  * Author: smackcoders.com
7
  * Text Domain: wp-ultimate-csv-importer
8
  * Domain Path: /languages
@@ -81,7 +81,7 @@ define('WP_CONST_ULTIMATE_CSV_IMP_URL', 'http://www.smackcoders.com/wp-ultimate-
81
  define('WP_CONST_ULTIMATE_CSV_IMP_NAME', 'WP Ultimate CSV Importer');
82
  define('WP_CONST_ULTIMATE_CSV_IMP_SLUG', 'wp-ultimate-csv-importer');
83
  define('WP_CONST_ULTIMATE_CSV_IMP_SETTINGS', 'WP Ultimate CSV Importer');
84
- define('WP_CONST_ULTIMATE_CSV_IMP_VERSION', '3.9.3');
85
  define('WP_CONST_ULTIMATE_CSV_IMP_DIR', WP_PLUGIN_URL . '/' . WP_CONST_ULTIMATE_CSV_IMP_SLUG . '/');
86
  define('WP_CONST_ULTIMATE_CSV_IMP_DIRECTORY', plugin_dir_path(__FILE__));
87
  define('WP_CSVIMP_PLUGIN_BASE', WP_CONST_ULTIMATE_CSV_IMP_DIRECTORY);
2
  /******************************
3
  * Plugin Name: WP Ultimate CSV Importer
4
  * Description: A plugin that helps to import the data's from a CSV file.
5
+ * Version: 3.9.4
6
  * Author: smackcoders.com
7
  * Text Domain: wp-ultimate-csv-importer
8
  * Domain Path: /languages
81
  define('WP_CONST_ULTIMATE_CSV_IMP_NAME', 'WP Ultimate CSV Importer');
82
  define('WP_CONST_ULTIMATE_CSV_IMP_SLUG', 'wp-ultimate-csv-importer');
83
  define('WP_CONST_ULTIMATE_CSV_IMP_SETTINGS', 'WP Ultimate CSV Importer');
84
+ define('WP_CONST_ULTIMATE_CSV_IMP_VERSION', '3.9.4');
85
  define('WP_CONST_ULTIMATE_CSV_IMP_DIR', WP_PLUGIN_URL . '/' . WP_CONST_ULTIMATE_CSV_IMP_SLUG . '/');
86
  define('WP_CONST_ULTIMATE_CSV_IMP_DIRECTORY', plugin_dir_path(__FILE__));
87
  define('WP_CSVIMP_PLUGIN_BASE', WP_CONST_ULTIMATE_CSV_IMP_DIRECTORY);
js/ultimate-importer-free.js CHANGED
@@ -515,11 +515,14 @@ function importRecordsbySettings(siteurl) {
515
  var importinlineimage = false;
516
  var imagehandling = false;
517
  var inline_image_location = false;
 
518
  var currentModule = document.getElementById('current_module').value;
 
519
  if (currentModule != 'users' && currentModule != 'comments') {
520
  importinlineimage = document.getElementById('multiimage').checked;
521
  imagehandling = document.getElementById('inlineimagevalue').value;
522
  inline_image_location = document.getElementById('inline_image_location').value;
 
523
  }
524
  var get_log = document.getElementById('log').innerHTML;
525
  document.getElementById('reportLog').style.display = '';
@@ -565,7 +568,7 @@ function importRecordsbySettings(siteurl) {
565
  'dupContent': dupContent,
566
  'dupTitle': dupTitle,
567
  'importlimit': importlimit,
568
- 'get_requested_count': get_requested_count,
569
  'limit': currentlimit,
570
  'totRecords': tot_no_of_records,
571
  'selectedImporter': importas,
@@ -575,6 +578,7 @@ function importRecordsbySettings(siteurl) {
575
  'inlineimagehandling': imagehandling,
576
  'inline_image_location': inline_image_location,
577
  'advance_media': advancemedia,
 
578
  'wpnonce': noncekey
579
  }
580
 
515
  var importinlineimage = false;
516
  var imagehandling = false;
517
  var inline_image_location = false;
518
+ var useexistingimages = false;
519
  var currentModule = document.getElementById('current_module').value;
520
+ //alert('currentModule: ' + currentModule); alert('ImportAs: ' + importas);
521
  if (currentModule != 'users' && currentModule != 'comments') {
522
  importinlineimage = document.getElementById('multiimage').checked;
523
  imagehandling = document.getElementById('inlineimagevalue').value;
524
  inline_image_location = document.getElementById('inline_image_location').value;
525
+ useexistingimages = document.getElementById('useexistingimages').checked;
526
  }
527
  var get_log = document.getElementById('log').innerHTML;
528
  document.getElementById('reportLog').style.display = '';
568
  'dupContent': dupContent,
569
  'dupTitle': dupTitle,
570
  'importlimit': importlimit,
571
+ 'get_requested_count': get_requested_count,
572
  'limit': currentlimit,
573
  'totRecords': tot_no_of_records,
574
  'selectedImporter': importas,
578
  'inlineimagehandling': imagehandling,
579
  'inline_image_location': inline_image_location,
580
  'advance_media': advancemedia,
581
+ 'useexistingimages': useexistingimages,
582
  'wpnonce': noncekey
583
  }
584
 
modules/custompost/templates/index.php CHANGED
@@ -173,41 +173,41 @@ $nonce_Key = $impCE->create_nonce_key();
173
  <option value='select'>---Select---</option>
174
  <?php
175
  $cust_post_list_count = 0;
176
- if(is_array(get_post_types())){
177
- foreach (get_post_types() as $key => $value) {
178
- $cctm_post_type = array();
179
- $cctm_post_type = get_option('cctm_data');
180
- if(!empty($cctm_post_type) && is_array($cctm_post_type)){
181
- foreach($cctm_post_type['post_type_defs'] as $cctmptkey => $cctmptval) {
182
- if($cctmptkey === $value){
183
- $value = 'createdByCCTM';
184
- }
185
- }
186
- }
187
- $types_post_types = array();
188
- $types_post_types = get_option('wpcf-custom-types');
189
- if(!empty($types_post_types) && is_array($types_post_types)) {
190
- foreach($types_post_types as $tptKey => $tptVal){
191
- if($tptKey === $value) {
192
- $value = 'createdByTypes';
193
- }
194
- }
195
- }
196
- $pods_post_types = array();
197
- $pods_post_types = get_option('_transient_pods_get_type_post_type');
198
- if(!empty($pods_post_types) && is_array($pods_post_types)){
199
- foreach($pods_post_types as $podskey => $podsvalue){
200
- if($podsvalue['name'] === $value){
201
- $value = 'createdByPODS';
202
- }
203
- }
204
- }
205
- if (($value !== 'featured_image') && ($value !== 'attachment') && ($value !== 'wpsc-product') && ($value !== 'wpsc-product-file') && ($value !== 'revision') && ($value !== 'nav_menu_item') && ($value !== 'post') && ($value !== 'page') && ($value !== 'wp-types-group') && ($value !== 'wp-types-user-group') && ($value !== 'product') && ($value !== 'product_variation') && ($value !== 'shop_order') && ($value !== 'shop_coupon') && ($value !== 'acf') && ($value !== 'acf-field-group') && ($value !== 'acf-field') && ($value !== '_pods_pod') && ($value !== '_pods_field') && ($value !== 'mp_order') && ($value !== 'createdByTypes') &&($value !== 'createdByCCTM') && ($value !== 'createdByPODS')) {?>
206
- <option id="<?php echo($value); ?>"> <?php echo($value);?> </option>
207
- <?php
208
- $cust_post_list_count++;
209
- }
210
- }
211
  } ?>
212
  </select>
213
 
@@ -677,7 +677,10 @@ $nonce_Key = $impCE->create_nonce_key();
677
  <input type="hidden" id="currentlimit" name="currentlimit" value="1"/>
678
  <input type="hidden" id="tmpcount" name="tmpcount" value="0"/>
679
  <input type="hidden" id="terminateaction" name="terminateaction" value="continue"/>
680
- <label id="innertitle">Inline image options</label><br/>
 
 
 
681
  <label id='importalign'> <input type='checkbox' id='multiimage' name='multiimage'
682
  value=''> <?php echo esc_attr__('Insert Inline Images', 'wp-ultimate-csv-importer'); ?>
683
  </label><br>
173
  <option value='select'>---Select---</option>
174
  <?php
175
  $cust_post_list_count = 0;
176
+ if(is_array(get_post_types())){
177
+ foreach (get_post_types() as $key => $value) {
178
+ $cctm_post_type = array();
179
+ $cctm_post_type = get_option('cctm_data');
180
+ if(!empty($cctm_post_type) && is_array($cctm_post_type)){
181
+ foreach($cctm_post_type['post_type_defs'] as $cctmptkey => $cctmptval) {
182
+ if($cctmptkey === $value){
183
+ $value = 'createdByCCTM';
184
+ }
185
+ }
186
+ }
187
+ $types_post_types = array();
188
+ $types_post_types = get_option('wpcf-custom-types');
189
+ if(!empty($types_post_types) && is_array($types_post_types)) {
190
+ foreach($types_post_types as $tptKey => $tptVal){
191
+ if($tptKey === $value) {
192
+ $value = 'createdByTypes';
193
+ }
194
+ }
195
+ }
196
+ $pods_post_types = array();
197
+ $pods_post_types = get_option('_transient_pods_get_type_post_type');
198
+ if(!empty($pods_post_types) && is_array($pods_post_types)){
199
+ foreach($pods_post_types as $podskey => $podsvalue){
200
+ if($podsvalue['name'] === $value){
201
+ $value = 'createdByPODS';
202
+ }
203
+ }
204
+ }
205
+ if (($value !== 'featured_image') && ($value !== 'attachment') && ($value !== 'wpsc-product') && ($value !== 'wpsc-product-file') && ($value !== 'revision') && ($value !== 'nav_menu_item') && ($value !== 'post') && ($value !== 'page') && ($value !== 'wp-types-group') && ($value !== 'wp-types-user-group') && ($value !== 'product') && ($value !== 'product_variation') && ($value !== 'shop_order') && ($value !== 'shop_coupon') && ($value !== 'acf') && ($value !== 'acf-field-group') && ($value !== 'acf-field') && ($value !== '_pods_pod') && ($value !== '_pods_field') && ($value !== 'mp_order') && ($value !== 'createdByTypes') &&($value !== 'createdByCCTM') && ($value !== 'createdByPODS')) {?>
206
+ <option id="<?php echo($value); ?>"> <?php echo($value);?> </option>
207
+ <?php
208
+ $cust_post_list_count++;
209
+ }
210
+ }
211
  } ?>
212
  </select>
213
 
677
  <input type="hidden" id="currentlimit" name="currentlimit" value="1"/>
678
  <input type="hidden" id="tmpcount" name="tmpcount" value="0"/>
679
  <input type="hidden" id="terminateaction" name="terminateaction" value="continue"/>
680
+ <label id="innertitle"><?php echo esc_html__('Media Options', 'wp-ultimate-csv-importer'); ?></label><br/>
681
+ <label id='importalign'>
682
+ <input type='checkbox' id='useexistingimages' name='useexistingimages' value='' /> <?php echo esc_html__("Reuse image with same name in Media", 'wp-ultimate-csv-importer'); ?>
683
+ </label> <?php echo $impCE->helpnotes('skipDuplicate'); ?> <br>
684
  <label id='importalign'> <input type='checkbox' id='multiimage' name='multiimage'
685
  value=''> <?php echo esc_attr__('Insert Inline Images', 'wp-ultimate-csv-importer'); ?>
686
  </label><br>
modules/eshop/actions/actions.php CHANGED
@@ -329,9 +329,18 @@ class EshopActions extends SkinnyActions {
329
  /**
330
  * function to map the csv file and process it
331
  *
 
 
 
 
 
 
 
 
 
332
  * @return boolean
333
  */
334
- function processDataInWP($data_rows, $ret_array, $session_arr, $currentLimit, $extractedimagelocation, $importinlineimageoption, $sample_inlineimage_url = null) {
335
  global $wpdb;
336
  $post_id = '';
337
  $new_post = array();
@@ -458,33 +467,33 @@ class EshopActions extends SkinnyActions {
458
  $fimg_path = $full_path;
459
 
460
  $fimg_name = @basename($f_img);
461
- $fimg_name = strtolower(str_replace(' ', '-', $fimg_name));
462
- $fimg_name = preg_replace('/[^a-zA-Z0-9._\s]/', '', $fimg_name);
463
-
464
  $fimg_name = urlencode($fimg_name);
465
-
466
  $parseURL = parse_url($f_img);
467
  $path_parts = pathinfo($f_img);
468
  if (!isset($path_parts['extension'])) {
469
  $fimg_name = $fimg_name . '.jpg';
470
  }
471
-
472
  $f_img_slug = '';
473
- $f_img_slug = strtolower(str_replace('', '-', $f_img_slug));
474
- $f_img_slug = preg_replace('/[^a-zA-Z0-9._\s]/', '', $f_img_slug);
475
-
476
-
477
  $post_slug_value = strtolower($f_img_slug);
478
  require_once(WP_CONST_ULTIMATE_CSV_IMP_DIRECTORY . '/includes/WPImporter_includes_helper.php');
479
  $impCE = new WPImporter_includes_helper();
480
- $path_parts['extension'] = isset($path_parts['extension']) ? $path_parts['extension'] : '';
 
 
 
 
481
  $impCE->get_fimg_from_URL($f_img, $fimg_path, $fimg_name, $post_slug_value, $currentLimit, $this);
482
  $filepath = $fimg_path . "/" . $fimg_name;
483
 
484
  if (@getimagesize($filepath)) {
485
  $img = wp_get_image_editor($filepath);
486
  $file ['guid'] = $baseurl . "/" . $fimg_name;
487
- $file ['post_title'] = $fimg_name;
488
  $file ['post_content'] = '';
489
  $file ['post_status'] = 'attachment';
490
  } else {
@@ -653,7 +662,7 @@ class EshopActions extends SkinnyActions {
653
  if ($this->MultiImages == 'true') {
654
  $inlineImagesObj = new WPImporter_inlineImages();
655
  $postid = wp_insert_post($data_array);
656
- $post_id = $inlineImagesObj->importwithInlineImages($postid, $currentLimit, $data_array, $this, $importinlineimageoption, $extractedimagelocation, $sample_inlineimage_url);
657
  } else {
658
  $post_id = wp_insert_post($data_array);
659
  $this->detailedLog[$currentLimit]['post_id'] = "<b>Created Post_ID - </b>" . $post_id . " - success";
@@ -739,31 +748,37 @@ class EshopActions extends SkinnyActions {
739
  // Add featured image
740
  if (!empty ($file)) {
741
  $wp_upload_dir = wp_upload_dir();
742
- $attachment = array('guid' => $file ['guid'], 'post_mime_type' => 'image/jpeg', 'post_title' => preg_replace('/[^a-zA-Z0-9._\s]/', '', @basename($file ['guid'])), 'post_content' => '', 'post_status' => 'inherit');
743
  if ($get_media_settings == 1) {
744
  $generate_attachment = $dirname . '/' . $fimg_name;
745
  } else {
746
  $generate_attachment = $fimg_name;
747
  }
748
  $uploadedImage = $wp_upload_dir['path'] . '/' . $fimg_name;
749
- $existing_attachment = array();
750
- $query = $wpdb->get_results($wpdb->prepare("select post_title from $wpdb->posts where post_type = %s and post_mime_type = %s",'attachment','image/jpeg'));
751
- if(!empty($query)){
752
- foreach ($query as $key) {
753
- $existing_attachment[] = $key->post_title;
754
- }
755
- }
756
- if (!in_array($fimg_name, $existing_attachment)) {
757
- $attach_id = wp_insert_attachment($attachment, $generate_attachment, $post_id);
758
- $attach_data = wp_generate_attachment_metadata($attach_id, $uploadedImage);
759
- wp_update_attachment_metadata($attach_id, $attach_data);
760
- } else {
761
- $query2 = $wpdb->get_results($wpdb->prepare("select ID from $wpdb->posts where post_title = %s and post_type = %s",$fimg_name,'attachment'));
762
- if(!empty($query2)){
763
- foreach ($query2 as $key2) {
764
- $attach_id = $key2->ID;
765
  }
 
 
 
 
 
 
 
 
 
 
 
766
  }
 
 
 
 
767
  }
768
  set_post_thumbnail($post_id, $attach_id);
769
  }
329
  /**
330
  * function to map the csv file and process it
331
  *
332
+ * @param $data_rows
333
+ * @param $ret_array
334
+ * @param $session_arr
335
+ * @param $currentLimit
336
+ * @param $extractedimagelocation
337
+ * @param $importinlineimageoption
338
+ * @param null $sample_inlineimage_url
339
+ * @param bool $useexistingimages
340
+ *
341
  * @return boolean
342
  */
343
+ function processDataInWP($data_rows, $ret_array, $session_arr, $currentLimit, $extractedimagelocation, $importinlineimageoption, $sample_inlineimage_url = null, $useexistingimages = false) {
344
  global $wpdb;
345
  $post_id = '';
346
  $new_post = array();
467
  $fimg_path = $full_path;
468
 
469
  $fimg_name = @basename($f_img);
470
+ $fimg_name = str_replace(' ', '-', $fimg_name);
471
+ $fimg_name = preg_replace('/[^a-zA-Z0-9._\-\s]/', '', $fimg_name);
 
472
  $fimg_name = urlencode($fimg_name);
 
473
  $parseURL = parse_url($f_img);
474
  $path_parts = pathinfo($f_img);
475
  if (!isset($path_parts['extension'])) {
476
  $fimg_name = $fimg_name . '.jpg';
477
  }
 
478
  $f_img_slug = '';
479
+ $featured_image = trim($path_parts['filename']);
480
+ $f_img_slug = strtolower(str_replace(' ', '-', trim($f_img_slug)));
481
+ $f_img_slug = preg_replace('/[^a-zA-Z0-9._\-\s]/', '', $f_img_slug);
 
482
  $post_slug_value = strtolower($f_img_slug);
483
  require_once(WP_CONST_ULTIMATE_CSV_IMP_DIRECTORY . '/includes/WPImporter_includes_helper.php');
484
  $impCE = new WPImporter_includes_helper();
485
+ #$path_parts['extension'] = isset($path_parts['extension']) ? $path_parts['extension'] : '';
486
+ #if (array_key_exists('extension', $path_parts)) {
487
+ if ($useexistingimages == 'false') {
488
+ $fimg_name = wp_unique_filename($fimg_path, trim($fimg_name));
489
+ }
490
  $impCE->get_fimg_from_URL($f_img, $fimg_path, $fimg_name, $post_slug_value, $currentLimit, $this);
491
  $filepath = $fimg_path . "/" . $fimg_name;
492
 
493
  if (@getimagesize($filepath)) {
494
  $img = wp_get_image_editor($filepath);
495
  $file ['guid'] = $baseurl . "/" . $fimg_name;
496
+ $file ['post_title'] = $featured_image;
497
  $file ['post_content'] = '';
498
  $file ['post_status'] = 'attachment';
499
  } else {
662
  if ($this->MultiImages == 'true') {
663
  $inlineImagesObj = new WPImporter_inlineImages();
664
  $postid = wp_insert_post($data_array);
665
+ $post_id = $inlineImagesObj->importwithInlineImages($postid, $currentLimit, $data_array, $this, $importinlineimageoption, $extractedimagelocation, $sample_inlineimage_url, $useexistingimages);
666
  } else {
667
  $post_id = wp_insert_post($data_array);
668
  $this->detailedLog[$currentLimit]['post_id'] = "<b>Created Post_ID - </b>" . $post_id . " - success";
748
  // Add featured image
749
  if (!empty ($file)) {
750
  $wp_upload_dir = wp_upload_dir();
751
+ $attachment = array('guid' => $file ['guid'], 'post_mime_type' => 'image/jpeg', 'post_title' => preg_replace('/[^a-zA-Z0-9._\-\s]/', '', @basename($file ['post_title'])), 'post_content' => '', 'post_status' => 'inherit');
752
  if ($get_media_settings == 1) {
753
  $generate_attachment = $dirname . '/' . $fimg_name;
754
  } else {
755
  $generate_attachment = $fimg_name;
756
  }
757
  $uploadedImage = $wp_upload_dir['path'] . '/' . $fimg_name;
758
+ if($useexistingimages == 'true') {
759
+ $existing_attachment = array();
760
+ $query = $wpdb->get_results( $wpdb->prepare( "select post_title from $wpdb->posts where post_type = %s and post_mime_type = %s", 'attachment', 'image/jpeg' ) );
761
+ if ( ! empty( $query ) ) {
762
+ foreach ( $query as $key ) {
763
+ $existing_attachment[] = $key->post_title;
764
+ }
 
 
 
 
 
 
 
 
 
765
  }
766
+ if ( ! in_array( $attachment['post_title'], $existing_attachment ) ) {
767
+ $attach_id = wp_insert_attachment( $attachment, $generate_attachment, $post_id );
768
+ $attach_data = wp_generate_attachment_metadata( $attach_id, $uploadedImage );
769
+ wp_update_attachment_metadata( $attach_id, $attach_data );
770
+ } else {
771
+ $query2 = $wpdb->get_results( $wpdb->prepare( "select ID from $wpdb->posts where post_title = %s and post_type = %s", $fimg_name, 'attachment' ) );
772
+ if ( ! empty( $query2 ) ) {
773
+ foreach ( $query2 as $key2 ) {
774
+ $attach_id = $key2->ID;
775
+ }
776
+ }
777
  }
778
+ } else {
779
+ $attach_id = wp_insert_attachment( $attachment, $generate_attachment, $post_id );
780
+ $attach_data = wp_generate_attachment_metadata( $attach_id, $uploadedImage );
781
+ wp_update_attachment_metadata( $attach_id, $attach_data );
782
  }
783
  set_post_thumbnail($post_id, $attach_id);
784
  }
modules/eshop/templates/index.php CHANGED
@@ -534,7 +534,10 @@ if ($_SESSION['SMACK_MAPPING_SETTINGS_VALUES']['isplugin_avail'] !== 'not_avail'
534
  <input type="hidden" id="currentlimit" name="currentlimit" value="1"/>
535
  <input type="hidden" id="tmpcount" name="tmpcount" value="0" />
536
  <input type="hidden" id="terminateaction" name="terminateaction" value="continue" />
537
- <label id="innertitle"><?php echo esc_html__('Inline image options','wp-ultimate-csv-importer'); ?></label><br />
 
 
 
538
  <label id='importalign'> <input type ='checkbox' id='multiimage' name='multiimage' value = ''><?php echo esc_html__('Insert Inline Images','wp-ultimate-csv-importer'); ?> </label><br>
539
  <input type='hidden' id='inlineimagevalue' name='inlineimagevalue' value='none' />
540
  </li>
534
  <input type="hidden" id="currentlimit" name="currentlimit" value="1"/>
535
  <input type="hidden" id="tmpcount" name="tmpcount" value="0" />
536
  <input type="hidden" id="terminateaction" name="terminateaction" value="continue" />
537
+ <label id="innertitle"><?php echo esc_html__('Media Options','wp-ultimate-csv-importer'); ?></label><br />
538
+ <label id='importalign'>
539
+ <input type='checkbox' id='useexistingimages' name='useexistingimages' value='' /> <?php echo esc_html__("Reuse image with same name in Media", 'wp-ultimate-csv-importer'); ?>
540
+ </label> <?php echo $impCE->helpnotes('skipDuplicate'); ?> <br>
541
  <label id='importalign'> <input type ='checkbox' id='multiimage' name='multiimage' value = ''><?php echo esc_html__('Insert Inline Images','wp-ultimate-csv-importer'); ?> </label><br>
542
  <input type='hidden' id='inlineimagevalue' name='inlineimagevalue' value='none' />
543
  </li>
modules/page/templates/index.php CHANGED
@@ -572,9 +572,11 @@ $nonce_Key = $impCE->create_nonce_key();
572
  <input type="hidden" id="tmpcount" name="tmpcount" value="0"/>
573
  <input type="hidden" id="terminateaction" name="terminateaction" value="continue"/>
574
  <label
575
- id="innertitle"><?php echo esc_html__('Inline image options', 'wp-ultimate-csv-importer'); ?></label><br/>
576
- <label id='importalign'> <input type='checkbox' id='multiimage' name='multiimage'
577
- value=''> <?php echo esc_html__('Insert Inline Images', 'wp-ultimate-csv-importer'); ?>
 
 
578
  </label><br>
579
  <input type='hidden' id='inlineimagevalue' name='inlineimagevalue' value='none'/>
580
  </li>
572
  <input type="hidden" id="tmpcount" name="tmpcount" value="0"/>
573
  <input type="hidden" id="terminateaction" name="terminateaction" value="continue"/>
574
  <label
575
+ id="innertitle"><?php echo esc_html__('Media Options', 'wp-ultimate-csv-importer'); ?></label><br/>
576
+ <label id='importalign'>
577
+ <input type='checkbox' id='useexistingimages' name='useexistingimages' value='' /> <?php echo esc_html__("Reuse image with same name in Media", 'wp-ultimate-csv-importer'); ?>
578
+ </label> <?php echo $impCE->helpnotes('skipDuplicate'); ?> <br>
579
+ <label id='importalign'> <input type='checkbox' id='multiimage' name='multiimage' value=''> <?php echo esc_html__('Insert Inline Images', 'wp-ultimate-csv-importer'); ?>
580
  </label><br>
581
  <input type='hidden' id='inlineimagevalue' name='inlineimagevalue' value='none'/>
582
  </li>
modules/post/templates/index.php CHANGED
@@ -554,7 +554,10 @@ $nonce_Key = $impCE->create_nonce_key();
554
  <input type="hidden" id="currentlimit" name="currentlimit" value="1"/>
555
  <input type="hidden" id="tmpcount" name="tmpcount" value="0"/>
556
  <input type="hidden" id="terminateaction" name="terminateaction" value="continue"/>
557
- <label id="innertitle"><?php echo esc_html__('Inline image options', 'wp-ultimate-csv-importer'); ?></label><br/>
 
 
 
558
  <label id='importalign'>
559
  <input type='checkbox' id='multiimage' name='multiimage' value='' /> <?php echo esc_html__('Insert Inline Images', 'wp-ultimate-csv-importer'); ?>
560
  </label><br>
554
  <input type="hidden" id="currentlimit" name="currentlimit" value="1"/>
555
  <input type="hidden" id="tmpcount" name="tmpcount" value="0"/>
556
  <input type="hidden" id="terminateaction" name="terminateaction" value="continue"/>
557
+ <label id="innertitle"><?php echo esc_html__('Media Options', 'wp-ultimate-csv-importer'); ?></label><br/>
558
+ <label id='importalign'>
559
+ <input type='checkbox' id='useexistingimages' name='useexistingimages' value='' /> <?php echo esc_html__("Reuse image with same name in Media", 'wp-ultimate-csv-importer'); ?>
560
+ </label> <?php echo $impCE->helpnotes('skipDuplicate'); ?> <br>
561
  <label id='importalign'>
562
  <input type='checkbox' id='multiimage' name='multiimage' value='' /> <?php echo esc_html__('Insert Inline Images', 'wp-ultimate-csv-importer'); ?>
563
  </label><br>
plugins/class.inlineimages.php CHANGED
@@ -49,12 +49,13 @@ class WPImporter_inlineImages {
49
  * @param $import_image_method
50
  * @param $imgLoc
51
  * @param $sampleURL
 
52
  * @return int|WP_Error
53
  */
54
- function importwithInlineImages($postID, $currentLimit, $data_array, $impObj, $import_image_method, $imgLoc, $sampleURL) {
55
  $helperObj = new WPImporter_includes_helper();
56
  $updatearray = array();
57
- $res_array = $this->capture_all_shortcodes($data_array['post_content'], $postID);
58
  if (isset($res_array['post_content'])) {
59
  $updatearray['post_content'] = $res_array['post_content'];
60
  $updatearray['ID'] = $postID;
@@ -158,7 +159,7 @@ class WPImporter_inlineImages {
158
  $inline_file ['post_content'] = '';
159
  $inline_file ['post_status'] = 'attachment';
160
  $wp_upload_dir = wp_upload_dir();
161
- $attachment = array('guid' => $inline_file ['guid'], 'post_mime_type' => 'image/jpg', 'post_title' => preg_replace('/\.[^.]*$/', '', @basename($inline_file ['guid'])), 'post_content' => '', 'post_status' => 'inherit');
162
  if ($get_media_settings == 1) {
163
  $generate_attachment = $dirname . '/' . $inline;
164
  } else {
@@ -230,9 +231,10 @@ class WPImporter_inlineImages {
230
  /**
231
  * @param $post_content
232
  * @param $postID
 
233
  * @return array
234
  */
235
- public function capture_all_shortcodes($post_content, $postID) {
236
  $result = array();
237
  $pattern = "/([WPIMPINLINE:([\w]+)(.*?)(])/";
238
  $shortcode_prefix = "[WPIMPINLINE:";
@@ -315,7 +317,7 @@ class WPImporter_inlineImages {
315
  $inline_file ['post_content'] = '';
316
  $inline_file ['post_status'] = 'attachment';
317
  $wp_upload_dir = wp_upload_dir();
318
- $attachment = array('guid' => $inline_file ['guid'], 'post_mime_type' => 'image/jpeg', 'post_title' => preg_replace('/\.[^.]+$/', '', @basename($inline_file ['guid'])), 'post_content' => '', 'post_status' => 'inherit');
319
  if ($get_media_settings == 1) {
320
  $generate_attachment = $dirname . '/' . $get_inline_guid;
321
  } else {
@@ -324,23 +326,29 @@ class WPImporter_inlineImages {
324
  $uploadedImage = $wp_upload_dir['path'] . '/' . $get_inlineimage_val;
325
  //duplicate check
326
  global $wpdb;
327
- $existing_attachment = array();
328
- //$query = $wpdb->get_results("select post_title from $wpdb->posts where post_type = 'attachment' and post_mime_type = 'image/jpeg'");
329
- $query = $wpdb->get_results($wpdb->prepare("select post_title from $wpdb->posts where post_type = %s and post_mime_type = %s",'attachment','image/jpeg'));
330
- if(!empty($query)){
331
- foreach ($query as $key) {
 
332
 
333
- $existing_attachment[] = $key->post_title;
334
 
335
- }
336
- }
337
- //duplicate check
338
- if (!in_array($attachment['post_title'], $existing_attachment)) {
339
- $attach_id = wp_insert_attachment($attachment, $generate_attachment, $postID);
340
 
341
- $attach_data = wp_generate_attachment_metadata($attach_id, $uploadedImage);
342
- wp_update_attachment_metadata($attach_id, $attach_data);
343
- //set_post_thumbnail($postID, $attach_id);
 
 
 
 
 
344
  }
345
 
346
  // if($shortcode_mode == 'Inline') {
49
  * @param $import_image_method
50
  * @param $imgLoc
51
  * @param $sampleURL
52
+ * @param $useexistingimages
53
  * @return int|WP_Error
54
  */
55
+ function importwithInlineImages($postID, $currentLimit, $data_array, $impObj, $import_image_method, $imgLoc, $sampleURL, $useexistingimages = false) {
56
  $helperObj = new WPImporter_includes_helper();
57
  $updatearray = array();
58
+ $res_array = $this->capture_all_shortcodes($data_array['post_content'], $postID, $useexistingimages);
59
  if (isset($res_array['post_content'])) {
60
  $updatearray['post_content'] = $res_array['post_content'];
61
  $updatearray['ID'] = $postID;
159
  $inline_file ['post_content'] = '';
160
  $inline_file ['post_status'] = 'attachment';
161
  $wp_upload_dir = wp_upload_dir();
162
+ $attachment = array('guid' => $inline_file ['guid'], 'post_mime_type' => 'image/jpg', 'post_title' => preg_replace('/\.[^.]*$/', '', @basename($inline_file ['post_title'])), 'post_content' => '', 'post_status' => 'inherit');
163
  if ($get_media_settings == 1) {
164
  $generate_attachment = $dirname . '/' . $inline;
165
  } else {
231
  /**
232
  * @param $post_content
233
  * @param $postID
234
+ * @param $useexistingimages
235
  * @return array
236
  */
237
+ public function capture_all_shortcodes($post_content, $postID, $useexistingimages = false) {
238
  $result = array();
239
  $pattern = "/([WPIMPINLINE:([\w]+)(.*?)(])/";
240
  $shortcode_prefix = "[WPIMPINLINE:";
317
  $inline_file ['post_content'] = '';
318
  $inline_file ['post_status'] = 'attachment';
319
  $wp_upload_dir = wp_upload_dir();
320
+ $attachment = array('guid' => $inline_file ['guid'], 'post_mime_type' => 'image/jpeg', 'post_title' => preg_replace('/\.[^.]+$/', '', @basename($inline_file ['post_title'])), 'post_content' => '', 'post_status' => 'inherit');
321
  if ($get_media_settings == 1) {
322
  $generate_attachment = $dirname . '/' . $get_inline_guid;
323
  } else {
326
  $uploadedImage = $wp_upload_dir['path'] . '/' . $get_inlineimage_val;
327
  //duplicate check
328
  global $wpdb;
329
+ if($useexistingimages == 'true') {
330
+ $existing_attachment = array();
331
+ //$query = $wpdb->get_results("select post_title from $wpdb->posts where post_type = 'attachment' and post_mime_type = 'image/jpeg'");
332
+ $query = $wpdb->get_results( $wpdb->prepare( "select post_title from $wpdb->posts where post_type = %s and post_mime_type = %s", 'attachment', 'image/jpeg' ) );
333
+ if ( ! empty( $query ) ) {
334
+ foreach ( $query as $key ) {
335
 
336
+ $existing_attachment[] = $key->post_title;
337
 
338
+ }
339
+ }
340
+ //duplicate check
341
+ if ( ! in_array( $attachment['post_title'], $existing_attachment ) ) {
342
+ $attach_id = wp_insert_attachment( $attachment, $generate_attachment, $postID );
343
 
344
+ $attach_data = wp_generate_attachment_metadata( $attach_id, $uploadedImage );
345
+ wp_update_attachment_metadata( $attach_id, $attach_data );
346
+ //set_post_thumbnail($postID, $attach_id);
347
+ }
348
+ } else {
349
+ $attach_id = wp_insert_attachment( $attachment, $generate_attachment, $postID );
350
+ $attach_data = wp_generate_attachment_metadata( $attach_id, $uploadedImage );
351
+ wp_update_attachment_metadata( $attach_id, $attach_data );
352
  }
353
 
354
  // if($shortcode_mode == 'Inline') {
screenshot-4.png CHANGED
Binary file
templates/import.php CHANGED
@@ -168,7 +168,8 @@ for ($i = $limit; $i <= $count; $i++) {
168
  $extracted_image_location = sanitize_text_field($_POST['postdata']['inline_image_location']);
169
  $sample_inlineimage_url = sanitize_text_field($_POST['postdata']['inlineimagehandling']);
170
  }
171
- $importObj->processDataInWP($to_be_import_rec, $_SESSION['SMACK_MAPPING_SETTINGS_VALUES'], $_SESSION['SMACK_MAPPING_SETTINGS_VALUES'], $i, $extracted_image_location, $importinlineimageoption, $sample_inlineimage_url);
 
172
  $logarr = array('post_id','Failed','assigned_author', 'category', 'tags', 'postdate', 'image', 'poststatus');
173
  if ($curr_action == 'post' || $curr_action == 'page' || $curr_action == 'custompost' || $curr_action == 'eshop') {
174
  if(!empty($importObj->detailedLog) && is_array($importObj->detailedLog)){
168
  $extracted_image_location = sanitize_text_field($_POST['postdata']['inline_image_location']);
169
  $sample_inlineimage_url = sanitize_text_field($_POST['postdata']['inlineimagehandling']);
170
  }
171
+ $useexistingimages = isset($_POST['postdata']['useexistingimages']) ? sanitize_text_field($_POST['postdata']['useexistingimages']) : false;
172
+ $importObj->processDataInWP($to_be_import_rec, $_SESSION['SMACK_MAPPING_SETTINGS_VALUES'], $_SESSION['SMACK_MAPPING_SETTINGS_VALUES'], $i, $extracted_image_location, $importinlineimageoption, $sample_inlineimage_url, $useexistingimages);
173
  $logarr = array('post_id','Failed','assigned_author', 'category', 'tags', 'postdate', 'image', 'poststatus');
174
  if ($curr_action == 'post' || $curr_action == 'page' || $curr_action == 'custompost' || $curr_action == 'eshop') {
175
  if(!empty($importObj->detailedLog) && is_array($importObj->detailedLog)){