Ultimate CSV Importer - Version 1.1.0

Version Description

Download this release

Release Info

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

Code changes from version 1.0.2 to 1.1.0

Files changed (2) hide show
  1. Readme.txt +35 -17
  2. wp_ultimate_csv_importer.php +59 -7
Readme.txt CHANGED
@@ -1,12 +1,14 @@
1
  === Wp Ultimate CSV Importer Plugin ===
2
  Contributors: Smackcoders
3
- Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=fenzik@gmail.com&lc=JP&item_name=WordPress%20Plugins&item_number=wp%2dplugins&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted
4
  Tags: batch, excel, import, spreadsheet, plugin, admin, csv, importer,
5
  Requires at least: 3.4
6
  Tested up to: 3.4.2
7
- Stable tag: 1.0.2
 
 
 
8
  License: GPLv2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
  A plugin that helps to import any csv file as post, page or custom post data's by matching csv headers to wp fields.
12
 
@@ -18,14 +20,23 @@ Wp Ultimate CSV Importer Plugin helps you to import any csv file as post, page o
18
  1. Admin can import the data's from any csv file.
19
  2. Can define the type of post and post status while importing.
20
  3. Provides header mapping feature to import the data's as your need.
21
- 4. Users can map coloumn headers to exixting fields or assign as custom fileds.
22
- 5. Import unlimited datas as post.
23
  6. Make imported post as published or make it as draft.
 
24
 
 
 
25
 
26
- Support and Feature requests.
 
 
 
 
 
27
  ----------------------------
28
- Please visit http://www.smackcoders.com/category/free-wordpress-plugins.html for guides and tutorials. Please mail us to wpsupport@smackcoders.com for any timely support or feature request. Support at wordpress is not possible for now.
 
29
 
30
 
31
  == Installation ==
@@ -43,26 +54,30 @@ wp-ultimate-csv-importer.zip through plugin install wizard in wp admin panel
43
  == Screenshots ==
44
 
45
  1. Admin settings for Wp Ultimate CSV Importer Plugin .
46
- 2. Admin settings for Import Data and Header Mapping configutration to import data's from a csv file.
47
 
48
 
49
  == Changelog ==
50
 
51
- 1.0.0 Initial release version. Tested and found works well without any issues.
52
 
53
- 1.0.1 Added features to import multiple tags and categories with different delimiters.
54
 
55
- 1.0.2 - Bug fixed to recognize the trimmed trailing space in the CSV file
56
  - Added validation for the duplicate field mapping.
57
 
 
 
58
 
59
  == Upgrade Notice ==
60
 
61
- v1.0.0 Initial release of plugin.
62
 
63
- v1.0.1 Added features to import multiple tags and categories with different delimiters.
64
 
65
- v1.0.2 This version have important bug fixes and newly added features. Must upgrade immediately.
 
 
66
 
67
 
68
  == Frequently Asked Questions ==
@@ -82,12 +97,15 @@ v1.0.2 This version have important bug fixes and newly added features. Must upg
82
 
83
  3. How to define the multiple tags and categories?
84
 
85
- In CSV, tags should be seperated by "," to import mutiple tags and categories should be seperated by "|" to import multiple categories.
86
-
 
 
87
 
88
  Configuring our plugin is as simple as that.
89
 
 
90
 
91
- Please use support section in wordpress itself for any further queries and feature request.
92
 
93
 
 
1
  === Wp Ultimate CSV Importer Plugin ===
2
  Contributors: Smackcoders
3
+ Donate link: http://www.smackcoders.com/donate.html
4
  Tags: batch, excel, import, spreadsheet, plugin, admin, csv, importer,
5
  Requires at least: 3.4
6
  Tested up to: 3.4.2
7
+ Stable tag: 1.1.0
8
+ Version: 1.1.0
9
+ Author: Smackcoders
10
+ Author URI: http://profiles.wordpress.org/smackcoders/
11
  License: GPLv2 or later
 
12
 
13
  A plugin that helps to import any csv file as post, page or custom post data's by matching csv headers to wp fields.
14
 
20
  1. Admin can import the data's from any csv file.
21
  2. Can define the type of post and post status while importing.
22
  3. Provides header mapping feature to import the data's as your need.
23
+ 4. Users can map column headers to existing fields or assign as custom fields.
24
+ 5. Import unlimited data as post.
25
  6. Make imported post as published or make it as draft.
26
+ 7. Added featured image import functionality.
27
 
28
+ Note: Your theme should support featured image function. If not, please add the following code to header.php or where it needed.
29
+ add_theme_support( 'post-thumbnails' );
30
 
31
+ You can follow the instructions as given here
32
+ [http://codex.wordpress.org/Function_Reference/the_post_thumbnail](http://codex.wordpress.org/Function_Reference/the_post_thumbnail)
33
+ [http://codex.wordpress.org/Post_Thumbnails](http://codex.wordpress.org/Post_Thumbnails) [http://wordpress.org/support/topic/featured-image-not-showing-7?replies=5](http://wordpress.org/support/topic/featured-image-not-showing-7?replies=5)
34
+
35
+
36
+ Support and Feature request.
37
  ----------------------------
38
+ Please visit http://www.smackcoders.com/category/free-wordpress-plugins/google-seo-author-snippet-plugin.html for guides and tutorials.
39
+ For quick response and reply please create issues in our [support](http://code.smackcoders.com/wp-csv-importer/issues) instead of wordpress support forum. Support at wordpress is not possible for now.
40
 
41
 
42
  == Installation ==
54
  == Screenshots ==
55
 
56
  1. Admin settings for Wp Ultimate CSV Importer Plugin .
57
+ 2. Admin settings for Import Data and Header Mapping configuration to import data's from a csv file.
58
 
59
 
60
  == Changelog ==
61
 
62
+ =1.0.0= Initial release version. Tested and found works well without any issues.
63
 
64
+ =1.0.1= Added features to import multiple tags and categories with different delimiters.
65
 
66
+ =1.0.2= - Bug fixed to recognize the trimmed trailing space in the CSV file
67
  - Added validation for the duplicate field mapping.
68
 
69
+ =1.1.0= Added featured image import feature along with post/page/custom post.
70
+
71
 
72
  == Upgrade Notice ==
73
 
74
+ =v 1.0.0= Initial release of plugin.
75
 
76
+ =v 1.0.1= Added features to import multiple tags and categories with different delimiters.
77
 
78
+ =v 1.0.2= This version have important bug fixes and newly added features. Must be upgrade immediately.
79
+
80
+ =v 1.1.0= A major new feature added in this version. Update needed.
81
 
82
 
83
  == Frequently Asked Questions ==
97
 
98
  3. How to define the multiple tags and categories?
99
 
100
+ In CSV, tags should be separated by "," to import multiple tags and categories should be separated by "|" to import multiple categories.
101
+
102
+ 4. How to choose featured image to import?
103
+ Match the coloumn contains url paths to images to Attachment field from the drop down.
104
 
105
  Configuring our plugin is as simple as that.
106
 
107
+ For quick response and reply please create issues in our [support](http://code.smackcoders.com/wp-csv-importer/issues) instead of wordpress support forum.
108
 
 
109
 
110
 
111
+
wp_ultimate_csv_importer.php CHANGED
@@ -3,7 +3,7 @@
3
  *Plugin Name: Wp Ultimate CSV Importer
4
  *Plugin URI: http://www.smackcoders.com/category/free-wordpress-plugins.html
5
  *Description: A plugin that helps to import the data's from a CSV file.
6
- *Version: 1.0.2
7
  *Author: smackcoders.com
8
  *Author URI: http://www.smackcoders.com
9
  *
@@ -48,6 +48,7 @@ $keys = $wpdb->get_col( "
48
  ORDER BY meta_key
49
  LIMIT $limit" );
50
  // Default header array
 
51
  $defaults = array(
52
  'post_title' => null,
53
  'post_content' => null,
@@ -56,6 +57,7 @@ $defaults = array(
56
  'post_tag' => null,
57
  'category' => null,
58
  'post_author' => null,
 
59
  'post_parent' => 0,
60
  );
61
  foreach($keys as $val){
@@ -101,7 +103,7 @@ function description(){
101
  // CSV File Reader
102
  function csv_file_data($file,$delim)
103
  {
104
- ini_set("auto_detect_line_endings", true); // added by fredrick at version 1.0.2
105
  global $data_rows;
106
  global $headers;
107
  global $delim;
@@ -115,7 +117,7 @@ function csv_file_data($file,$delim)
115
  $c ++;
116
  }
117
  fclose($resource);
118
- ini_set("auto_detect_line_endings", false); // added by fredrick at version 1.0.2
119
  }
120
 
121
  // Move file
@@ -155,7 +157,7 @@ function upload_csv_file()
155
  move_file();
156
  ?>
157
  <div style="background-color: #FFFFE0;border-color: #E6DB55;border-radius: 3px 3px 3px 3px;border-style: solid;border-width: 1px;margin: 5px 15px 2px; margin-top:15px;padding: 5px;text-align:center"> Please check out <a href="http://smackcoders.com/category/free-wordpress-plugins.html" target="_blank">www.smackcoders.com</a> for the latest news and details of other great plugins and tools. </div><br/>
158
- <?php if ( count($headers)>1 && count($data_rows)>1 ){?>
159
  <div style="float:left;min-width:45%">
160
  <form class="add:the-list: validate" method="post" onsubmit="return import_csv();">
161
  <h3>Import Data Configuration</h3>
@@ -181,6 +183,7 @@ function upload_csv_file()
181
  <input type="hidden" id="h1" name="h1" value="<?php echo $cnt; ?>"/>
182
  <input type="hidden" id="h2" name="h2" value="<?php echo $cnt1; ?>"/>
183
  <input type="hidden" id="delim" name="delim" value="<?php echo $_POST['delim']; ?>" />
 
184
  <table style="font-size:12px;">
185
  <?php
186
  $count = 0;
@@ -210,7 +213,7 @@ function upload_csv_file()
210
  </table>
211
  </div><br/>
212
  <input type='hidden' name='filename' id='filename' value="<?php echo($_FILES['csv_import']['name']);?>" />
213
- <input type='submit' name= 'post_csv' value='Import' />
214
  </form>
215
  </div>
216
  <div style="min-width:45%;">
@@ -263,7 +266,7 @@ function upload_csv_file()
263
  }
264
  }
265
  foreach($new_post as $ckey => $cval){
266
- if($ckey!='category' && $ckey!='post_tag'){
267
  if(array_key_exists($ckey,$custom_array)){
268
  $darray[$ckey]=$new_post[$ckey];
269
  }
@@ -278,6 +281,44 @@ function upload_csv_file()
278
  if($ckey == 'category'){
279
  $categories[$ckey]=$new_post[$ckey];
280
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
281
  }
282
  }
283
  $data_array['post_status']='publish';
@@ -305,6 +346,17 @@ function upload_csv_file()
305
  wp_set_object_terms($post_id, $split_line, 'category');
306
 
307
  } // End of code to add category
 
 
 
 
 
 
 
 
 
 
 
308
  }
309
  ?>
310
  <div style="background-color: #FFFFE0;border-color: #E6DB55;border-radius: 3px 3px 3px 3px;border-style: solid;border-width: 1px;margin: 5px 15px 2px; padding: 5px;text-align:center"><b> Successfully Imported ! </b></div>
@@ -318,7 +370,7 @@ function upload_csv_file()
318
  if(file_exists($dir.$filename)){
319
  $filename = $_POST['filename'];
320
  chmod("$dir"."$filename", 755);
321
- fileDelete($dir,$filename); //die;
322
  }
323
  }
324
  else
3
  *Plugin Name: Wp Ultimate CSV Importer
4
  *Plugin URI: http://www.smackcoders.com/category/free-wordpress-plugins.html
5
  *Description: A plugin that helps to import the data's from a CSV file.
6
+ *Version: 1.1.0
7
  *Author: smackcoders.com
8
  *Author URI: http://www.smackcoders.com
9
  *
48
  ORDER BY meta_key
49
  LIMIT $limit" );
50
  // Default header array
51
+ // Code modified at version 1.1.0 by fredrick
52
  $defaults = array(
53
  'post_title' => null,
54
  'post_content' => null,
57
  'post_tag' => null,
58
  'category' => null,
59
  'post_author' => null,
60
+ 'attachment' => null,
61
  'post_parent' => 0,
62
  );
63
  foreach($keys as $val){
103
  // CSV File Reader
104
  function csv_file_data($file,$delim)
105
  {
106
+ ini_set("auto_detect_line_endings", true);
107
  global $data_rows;
108
  global $headers;
109
  global $delim;
117
  $c ++;
118
  }
119
  fclose($resource);
120
+ ini_set("auto_detect_line_endings", false);
121
  }
122
 
123
  // Move file
157
  move_file();
158
  ?>
159
  <div style="background-color: #FFFFE0;border-color: #E6DB55;border-radius: 3px 3px 3px 3px;border-style: solid;border-width: 1px;margin: 5px 15px 2px; margin-top:15px;padding: 5px;text-align:center"> Please check out <a href="http://smackcoders.com/category/free-wordpress-plugins.html" target="_blank">www.smackcoders.com</a> for the latest news and details of other great plugins and tools. </div><br/>
160
+ <?php if ( count($headers)>=1 && count($data_rows)>=1 ){?>
161
  <div style="float:left;min-width:45%">
162
  <form class="add:the-list: validate" method="post" onsubmit="return import_csv();">
163
  <h3>Import Data Configuration</h3>
183
  <input type="hidden" id="h1" name="h1" value="<?php echo $cnt; ?>"/>
184
  <input type="hidden" id="h2" name="h2" value="<?php echo $cnt1; ?>"/>
185
  <input type="hidden" id="delim" name="delim" value="<?php echo $_POST['delim']; ?>" />
186
+ <input type="hidden" id="header_array" name="header_array" value="<?php print_r($headers);?>" />
187
  <table style="font-size:12px;">
188
  <?php
189
  $count = 0;
213
  </table>
214
  </div><br/>
215
  <input type='hidden' name='filename' id='filename' value="<?php echo($_FILES['csv_import']['name']);?>" />
216
+ <input type='submit' name= 'post_csv' id='post_csv' value='Import' />
217
  </form>
218
  </div>
219
  <div style="min-width:45%;">
266
  }
267
  }
268
  foreach($new_post as $ckey => $cval){
269
+ if($ckey!='category' && $ckey!='post_tag' && $ckey!='attachment'){ // Code modified at version 1.0.2 by fredrick
270
  if(array_key_exists($ckey,$custom_array)){
271
  $darray[$ckey]=$new_post[$ckey];
272
  }
281
  if($ckey == 'category'){
282
  $categories[$ckey]=$new_post[$ckey];
283
  }
284
+ if($ckey == 'attachment'){ // Code added at version 1.1.0 by fredrick
285
+ $file_url=$filetype[$ckey]=$new_post[$ckey];
286
+ $file_type = explode('.',$filetype[$ckey]);
287
+ $count = count($file_type);
288
+ $type= $file_type[$count-1];
289
+ if($type == 'png'){
290
+ $file['post_mime_type']='image/png';
291
+ }
292
+ else if($type == 'jpg'){
293
+ $file['post_mime_type']='image/jpeg';
294
+ }
295
+ else if($type == 'gif'){
296
+ $file['post_mime_type']='image/gif';
297
+ }
298
+ $img_name = explode('/',$file_url);
299
+ $imgurl_split = count($img_name);
300
+ $img_name = explode('.',$img_name[$imgurl_split-1]);
301
+ $img_title = $img_name = $img_name[0];
302
+ $dir = wp_upload_dir();
303
+ $dirname = 'featured_image';
304
+ $full_path = $dir['basedir'].'/'.$dirname;
305
+ $baseurl = $dir['baseurl'].'/'.$dirname;
306
+ $filename = explode('/',$file_url);
307
+ $file_split = count($filename);
308
+ $filepath = $full_path.'/'.$filename[$file_split-1];
309
+ $fileurl = $baseurl.'/'.$filename[$file_split-1];
310
+ if(is_dir($full_path)){
311
+ copy($file_url,$filepath);
312
+ }
313
+ else{
314
+ wp_mkdir_p($full_path);
315
+ copy($file_url,$filepath);
316
+ }
317
+ $file['guid']=$fileurl;
318
+ $file['post_title']=$img_title;
319
+ $file['post_content']='';
320
+ $file['post_status']='inherit';
321
+ }
322
  }
323
  }
324
  $data_array['post_status']='publish';
346
  wp_set_object_terms($post_id, $split_line, 'category');
347
 
348
  } // End of code to add category
349
+
350
+ // Code added to import featured image at version 1.1.0 by fredrick
351
+ if(!empty($file)){
352
+ $file_name=$dirname.'/'.$img_title.'.'.$type;
353
+ $attach_id = wp_insert_attachment($file, $file_name, $post_id);
354
+ require_once(ABSPATH . 'wp-admin/includes/image.php');
355
+ $attach_data = wp_generate_attachment_metadata( $attach_id, $fileurl );
356
+ wp_update_attachment_metadata( $attach_id, $attach_data );
357
+ //add_post_meta($post_id, '_thumbnail_id', $attach_id, true);
358
+ set_post_thumbnail( $post_id, $attach_id );
359
+ }
360
  }
361
  ?>
362
  <div style="background-color: #FFFFE0;border-color: #E6DB55;border-radius: 3px 3px 3px 3px;border-style: solid;border-width: 1px;margin: 5px 15px 2px; padding: 5px;text-align:center"><b> Successfully Imported ! </b></div>
370
  if(file_exists($dir.$filename)){
371
  $filename = $_POST['filename'];
372
  chmod("$dir"."$filename", 755);
373
+ fileDelete($dir,$filename);
374
  }
375
  }
376
  else