Ultimate CSV Importer - Version 2.0.0

Version Description

Download this release

Release Info

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

Code changes from version 1.1.0 to 2.0.0

Files changed (3) hide show
  1. Readme.txt +36 -17
  2. screenshot-2.png +0 -0
  3. wp_ultimate_csv_importer.php +47 -18
Readme.txt CHANGED
@@ -4,8 +4,8 @@ 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
@@ -25,6 +25,8 @@ Wp Ultimate CSV Importer Plugin helps you to import any csv file as post, page o
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
 
@@ -35,20 +37,24 @@ You can follow the instructions as given here
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 ==
43
 
 
44
  Wp Ultimate CSV Importer is very easy to install like any other wordpress plugin. No need to edit or modify anything here.
45
 
46
  1. Unzip the file 'wp-ultimate-csv-importer.zip'.
47
  2. Upload the ' wp-ultimate-csv-importer ' directory to '/wp-content/plugins/' directory using ftp client or upload and install
48
  wp-ultimate-csv-importer.zip through plugin install wizard in wp admin panel
49
- 3. Make /wp-content/plugins/wp-ultimate-csv-importer as writable (chmod 777) to import csv.
50
- 4. Activate the plugin through the 'Plugins' menu in WordPress.
51
- 5. After activating, you will see an option for 'Wp Ultimate CSV Importer' in the admin menu (left navigation) and you will import the csv files to import the data's.
52
 
53
 
54
  == Screenshots ==
@@ -57,27 +63,40 @@ wp-ultimate-csv-importer.zip through plugin install wizard in wp admin panel
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 ==
@@ -108,4 +127,4 @@ For quick response and reply please create issues in our [support](http://code.s
108
 
109
 
110
 
111
-
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: 2.0.0
8
+ Version: 2.0.0
9
  Author: Smackcoders
10
  Author URI: http://profiles.wordpress.org/smackcoders/
11
  License: GPLv2 or later
25
  6. Make imported post as published or make it as draft.
26
  7. Added featured image import functionality.
27
 
28
+ Important Note: To import your posts for scheduled publishing in future, have a date coloumn in your csv with the date of post to be published on. If the date is a future date, then the post will be automatically scheduled for publishing on particular date as mentioned in csv.
29
+
30
  Note: Your theme should support featured image function. If not, please add the following code to header.php or where it needed.
31
  add_theme_support( 'post-thumbnails' );
32
 
37
 
38
  Support and Feature request.
39
  ----------------------------
40
+
41
+ Please create issues only in our tracker http://code.smackcoders.com/wp-csv-importer/issues instead of wordpress support forum.
42
+
43
+ For guides and tutorials, visit http://www.smackcoders.com/category/free-wordpress-plugins/google-seo-author-snippet-plugin.html .
44
+
45
 
46
 
47
  == Installation ==
48
 
49
+
50
  Wp Ultimate CSV Importer is very easy to install like any other wordpress plugin. No need to edit or modify anything here.
51
 
52
  1. Unzip the file 'wp-ultimate-csv-importer.zip'.
53
  2. Upload the ' wp-ultimate-csv-importer ' directory to '/wp-content/plugins/' directory using ftp client or upload and install
54
  wp-ultimate-csv-importer.zip through plugin install wizard in wp admin panel
55
+ 3. Activate the plugin through the 'Plugins' menu in WordPress.
56
+ 4. After activating, you will see an option for 'Wp Ultimate CSV Importer' in the admin menu (left navigation) and you will import the csv files to import the data's.
57
+
58
 
59
 
60
  == Screenshots ==
63
  2. Admin settings for Import Data and Header Mapping configuration to import data's from a csv file.
64
 
65
 
66
+
67
  == Changelog ==
68
 
69
+ = 2.0.0 = WPDEBUG errors fixed. CSV import folder changed to Wp native uploads folder.
70
+
71
+ = 1.1.1 = Renamed the mapping field attachment as featured_image and category as post_category.
72
 
73
+ = 1.1.0 = Added featured image import feature along with post/page/custom post.
74
+
75
+ = 1.0.2 = - Bug fixed to recognize the trimmed trailing space in the CSV file
76
+ - Added validation for the duplicate field mapping.
77
+
78
+ = 1.0.1 = Added features to import multiple tags and categories with different delimiters.
79
+
80
+ = 1.0.0 = Initial release version. Tested and found works well without any issues.
81
 
 
 
82
 
 
83
 
84
 
85
  == Upgrade Notice ==
86
 
87
+ =v 2.0.0= Major Bug fixed and should upgrade. WPDEBUG errors fixed. CSV import folder changed to Wp native uploads folder.
88
+
89
+ =v 1.1.1 = Minor correction and fix applied.
90
 
91
+ =v 1.1.0 = A major new feature added in this version. Update needed.
92
+
93
+ =v 1.0.2 = This version have important bug fixes and newly added features. Must be upgrade immediately.
94
+
95
+ =v 1.0.1 = Added features to import multiple tags and categories with different delimiters.
96
+
97
+ =v 1.0.0 = Initial release of plugin.
98
 
 
99
 
 
100
 
101
 
102
  == Frequently Asked Questions ==
127
 
128
 
129
 
130
+
screenshot-2.png CHANGED
Binary file
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.1.0
7
  *Author: smackcoders.com
8
  *Author URI: http://www.smackcoders.com
9
  *
@@ -27,6 +27,12 @@
27
  ***********************************************************************************************
28
  */
29
 
 
 
 
 
 
 
30
 
31
  // Global variable declaration
32
  global $data_rows;
@@ -37,7 +43,8 @@ global $defaults;
37
  global $wpdb;
38
  global $keys;
39
  global $delim;
40
- $delim = $_POST['delim'];
 
41
  // Get the custom fields
42
  $limit = (int) apply_filters( 'postmeta_form_limit', 30 );
43
  $keys = $wpdb->get_col( "
@@ -48,16 +55,16 @@ $keys = $wpdb->get_col( "
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,
55
  'post_excerpt' => null,
56
  'post_date' => 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){
@@ -69,8 +76,18 @@ function wp_ultimate_csv_importer() {
69
  'upload_csv_file', 'upload_csv_file');
70
  }
71
 
 
 
 
 
 
 
 
 
 
 
 
72
  add_action("admin_menu", "wp_ultimate_csv_importer");
73
- wp_enqueue_script("upload_csv_file", site_url()."/wp-content/plugins/wp-ultimate-csv-importer/wp_ultimate_csv_importer.js", array("jquery"));
74
 
75
  // Plugin description details
76
  function description(){
@@ -95,7 +112,7 @@ function description(){
95
  </p>
96
  <p>Configuring our plugin is as simple as that. If you have any questions, issues and request on new features, plaese visit <a href='http://www.smackcoders.com/category/free-wordpress-plugins.html' target='_blank'>Smackcoders.com Blog </a></p>
97
 
98
- <div align='center' style='margin-top:40px;'> 'While the scripts on this site are free, donations are greatly appreciated. '<br/><br/><a href='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' target='_blank'><img src='".site_url()."/wp-content/plugins/wp-ultimate-csv-importer/images/paypal_donate_button.png' /></a><br/><br/><a href='http://www.smackcoders.com/' target='_blank'><img src='http://www.smackcoders.com/wp-content/uploads/2012/09/Smack_poweredby_200.png'></a>
99
  </div><br/>";
100
  return $string;
101
  }
@@ -107,6 +124,8 @@ function csv_file_data($file,$delim)
107
  global $data_rows;
108
  global $headers;
109
  global $delim;
 
 
110
  $resource = fopen($file, 'r');
111
  while ($keys = fgetcsv($resource,'',"$delim",'"')) {
112
  if ($c == 0) {
@@ -123,7 +142,9 @@ function csv_file_data($file,$delim)
123
  // Move file
124
  function move_file()
125
  {
126
- $uploads_dir = getcwd ().'/../wp-content/plugins/wp-ultimate-csv-importer/imported_csv';
 
 
127
  if ($_FILES["csv_import"]["error"] == 0) {
128
  $tmp_name = $_FILES["csv_import"]["tmp_name"];
129
  $name = $_FILES["csv_import"]["name"];
@@ -150,6 +171,9 @@ function upload_csv_file()
150
  global $keys;
151
  global $custom_array;
152
  global $delim;
 
 
 
153
  $custom_array = array();
154
  if(isset($_POST['Import']))
155
  {
@@ -170,7 +194,7 @@ function upload_csv_file()
170
  <?php
171
  $post_types=get_post_types();
172
  foreach($post_types as $key => $value){
173
- if(($value!='attachment') && ($value!='revision') && ($value!='nav_menu_item')){ ?>
174
  <option id="<?php echo($value);?>" name="<?php echo($value);?>"> <?php echo($value);?> </option>
175
  <?php }
176
  }
@@ -238,7 +262,9 @@ function upload_csv_file()
238
  }
239
  else if(isset($_POST['post_csv']))
240
  {
241
- $dir = getcwd ().'/../wp-content/plugins/wp-ultimate-csv-importer/imported_csv/';
 
 
242
  csv_file_data($dir.$_POST['filename'],$delim);
243
  foreach($_POST as $postkey=>$postvalue){
244
  if($postvalue != '-- Select --'){
@@ -266,7 +292,7 @@ function upload_csv_file()
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
  }
@@ -278,10 +304,10 @@ function upload_csv_file()
278
  if($ckey == 'post_tag'){
279
  $tags[$ckey]=$new_post[$ckey];
280
  }
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);
@@ -342,7 +368,7 @@ function upload_csv_file()
342
 
343
  // Create/Add category to post
344
  if(!empty($categories)){
345
- $split_line = explode('|',$categories['category']);
346
  wp_set_object_terms($post_id, $split_line, 'category');
347
 
348
  } // End of code to add category
@@ -366,11 +392,14 @@ function upload_csv_file()
366
  </form>
367
  </div>
368
  <?php
 
369
  // Remove CSV file
370
- if(file_exists($dir.$filename)){
371
- $filename = $_POST['filename'];
372
- chmod("$dir"."$filename", 755);
373
- fileDelete($dir,$filename);
 
 
374
  }
375
  }
376
  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: 2.0.0
7
  *Author: smackcoders.com
8
  *Author URI: http://www.smackcoders.com
9
  *
27
  ***********************************************************************************************
28
  */
29
 
30
+ $upload_dir = wp_upload_dir();
31
+ $importdir = $upload_dir['basedir']."/imported_csv/";
32
+ if(!is_dir($importdir))
33
+ {
34
+ wp_mkdir_p($importdir);
35
+ }
36
 
37
  // Global variable declaration
38
  global $data_rows;
43
  global $wpdb;
44
  global $keys;
45
  global $delim;
46
+ # Code added by goku
47
+ $delim = empty($_POST['delim']) ? '' : $_POST['delim'];
48
  // Get the custom fields
49
  $limit = (int) apply_filters( 'postmeta_form_limit', 30 );
50
  $keys = $wpdb->get_col( "
55
  ORDER BY meta_key
56
  LIMIT $limit" );
57
  // Default header array
58
+ // Code modified at version 1.1.1 by fredrick
59
  $defaults = array(
60
  'post_title' => null,
61
  'post_content' => null,
62
  'post_excerpt' => null,
63
  'post_date' => null,
64
  'post_tag' => null,
65
+ 'post_category' => null,
66
  'post_author' => null,
67
+ 'featured_image' => null,
68
  'post_parent' => 0,
69
  );
70
  foreach($keys as $val){
76
  'upload_csv_file', 'upload_csv_file');
77
  }
78
 
79
+ # Code added by goku -- Starts here --
80
+
81
+ function LoadWpScript()
82
+ {
83
+ wp_register_script('wp_ultimate_scripts', site_url()."/wp-content/plugins/wp-ultimate-csv-importer/wp_ultimate_csv_importer.js", array("jquery"));
84
+ wp_enqueue_script('wp_ultimate_scripts');
85
+ }
86
+ add_action('admin_enqueue_scripts', 'LoadWpScript');
87
+
88
+ # -- Code ends here --
89
+
90
  add_action("admin_menu", "wp_ultimate_csv_importer");
 
91
 
92
  // Plugin description details
93
  function description(){
112
  </p>
113
  <p>Configuring our plugin is as simple as that. If you have any questions, issues and request on new features, plaese visit <a href='http://www.smackcoders.com/category/free-wordpress-plugins.html' target='_blank'>Smackcoders.com Blog </a></p>
114
 
115
+ <div align='center' style='margin-top:40px;'> 'While the scripts on this site are free, donations are greatly appreciated. '<br/><br/><a href='http://www.smackcoders.com/donate.html' target='_blank'><img src='".site_url()."/wp-content/plugins/wp-ultimate-csv-importer/images/paypal_donate_button.png' /></a><br/><br/><a href='http://www.smackcoders.com/' target='_blank'><img src='http://www.smackcoders.com/wp-content/uploads/2012/09/Smack_poweredby_200.png'></a>
116
  </div><br/>";
117
  return $string;
118
  }
124
  global $data_rows;
125
  global $headers;
126
  global $delim;
127
+ # Code added by goku
128
+ $c = 0;
129
  $resource = fopen($file, 'r');
130
  while ($keys = fgetcsv($resource,'',"$delim",'"')) {
131
  if ($c == 0) {
142
  // Move file
143
  function move_file()
144
  {
145
+ # Code added by goku
146
+ $upload_dir = wp_upload_dir();
147
+ $uploads_dir = $upload_dir['basedir']."/imported_csv/";
148
  if ($_FILES["csv_import"]["error"] == 0) {
149
  $tmp_name = $_FILES["csv_import"]["tmp_name"];
150
  $name = $_FILES["csv_import"]["name"];
171
  global $keys;
172
  global $custom_array;
173
  global $delim;
174
+ # Code added by goku
175
+ $upload_dir = wp_upload_dir();
176
+ $importdir = $upload_dir['basedir']."/imported_csv/";
177
  $custom_array = array();
178
  if(isset($_POST['Import']))
179
  {
194
  <?php
195
  $post_types=get_post_types();
196
  foreach($post_types as $key => $value){
197
+ if(($value!='featured_image') && ($value!='revision') && ($value!='nav_menu_item')){ ?>
198
  <option id="<?php echo($value);?>" name="<?php echo($value);?>"> <?php echo($value);?> </option>
199
  <?php }
200
  }
262
  }
263
  else if(isset($_POST['post_csv']))
264
  {
265
+ # Code added by goku
266
+ $upload_dir = wp_upload_dir();
267
+ $dir = $upload_dir['basedir']."/imported_csv/";
268
  csv_file_data($dir.$_POST['filename'],$delim);
269
  foreach($_POST as $postkey=>$postvalue){
270
  if($postvalue != '-- Select --'){
292
  }
293
  }
294
  foreach($new_post as $ckey => $cval){
295
+ if($ckey!='post_category' && $ckey!='post_tag' && $ckey!='featured_image'){ // Code modified at version 1.0.2 by fredrick
296
  if(array_key_exists($ckey,$custom_array)){
297
  $darray[$ckey]=$new_post[$ckey];
298
  }
304
  if($ckey == 'post_tag'){
305
  $tags[$ckey]=$new_post[$ckey];
306
  }
307
+ if($ckey == 'post_category'){
308
  $categories[$ckey]=$new_post[$ckey];
309
  }
310
+ if($ckey == 'featured_image'){ // Code added at version 1.1.0 by fredrick
311
  $file_url=$filetype[$ckey]=$new_post[$ckey];
312
  $file_type = explode('.',$filetype[$ckey]);
313
  $count = count($file_type);
368
 
369
  // Create/Add category to post
370
  if(!empty($categories)){
371
+ $split_line = explode('|',$categories['post_category']);
372
  wp_set_object_terms($post_id, $split_line, 'category');
373
 
374
  } // End of code to add category
392
  </form>
393
  </div>
394
  <?php
395
+ // Code modified at version 1.1.2
396
  // Remove CSV file
397
+ $upload_dir = wp_upload_dir();
398
+ $csvdir = $upload_dir['basedir']."/imported_csv/";
399
+ $CSVfile = $_POST['filename'];
400
+ if(file_exists($csvdir.$CSVfile)){
401
+ chmod("$csvdir"."$CSVfile", 755);
402
+ fileDelete($csvdir,$CSVfile);
403
  }
404
  }
405
  else