Ultimate CSV Importer - Version 2.6.0

Version Description

Download this release

Release Info

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

Code changes from version 2.5.0 to 2.6.0

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.5.1
7
- Stable tag: 2.5.0
8
- Version: 2.5.0
9
  Author: Smackcoders
10
  Author URI: http://profiles.wordpress.org/smackcoders/
11
  License: GPLv2 or later
@@ -36,14 +36,24 @@ You can follow the instructions as given here
36
  [http://codex.wordpress.org/Function_Reference/the_post_thumbnail](http://codex.wordpress.org/Function_Reference/the_post_thumbnail)
37
  [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)
38
 
39
- The pro version of ultimate csv importer plugin have many more features like
40
 
41
- Bulk products import for WP-e-commerce plugin in few clicks.
42
- Bulk products import for eShop plugin in few clicks.
43
- Custom Taxonomy
44
- Bulk Nested Categories import.
 
 
 
 
 
 
 
 
 
 
 
45
 
46
- Upgrade to pro for these powerful features.
47
 
48
  Support and Feature request.
49
  ----------------------------
@@ -70,6 +80,10 @@ Please click here for [Detailed Installation Instructions](http://www.smackcoder
70
 
71
  == Changelog ==
72
 
 
 
 
 
73
  = 2.5.0 = Major issues fixed and updated to WordPress-3.5.1 compatibility.
74
 
75
  = 2.0.1 = Update to WordPress-3.5 compatibility.
@@ -92,11 +106,12 @@ Please click here for [Detailed Installation Instructions](http://www.smackcoder
92
 
93
  == Upgrade Notice ==
94
 
 
 
95
  =v 2.5.0 = Major issues fixed and updated to WordPress-3.5.1 compatibility.
96
  -- Duplicate detection added.
97
  -- Added more information in success message.
98
  -- Import memory issues solved.
99
- -- Fixed scandinavian character conflicts.
100
 
101
  =v 2.0.1 = Update to WordPress-3.5 compatibility.
102
 
4
  Tags: batch, excel, import, spreadsheet, plugin, admin, csv, importer,
5
  Requires at least: 3.4
6
  Tested up to: 3.5.1
7
+ Stable tag: 2.6.0
8
+ Version: 2.6.0
9
  Author: Smackcoders
10
  Author URI: http://profiles.wordpress.org/smackcoders/
11
  License: GPLv2 or later
36
  [http://codex.wordpress.org/Function_Reference/the_post_thumbnail](http://codex.wordpress.org/Function_Reference/the_post_thumbnail)
37
  [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)
38
 
39
+ Posts and Pages Module - This module will import all your data into bulk posts or pages. There are 9 fields to map, in which post title and content are mandatory. All other fields are optional. You can also have published date field which can also have a future date that reflects as scheduled post. Optionally you can import as many fields you want as custom fields. You can name these fields as your wish while importing. Pages don't need category and tags. You can assign a feature image for each post or page through a list of image urls.
40
 
41
+ Custom posts - Similar to post and pages you can import any custom post types that is configured in your WordPress. You can also assign feature image for each post created.
42
+
43
+ For more powerful features upgrade to pro version of ultimate csv importer plugin have many more features like
44
+
45
+ Category - You can import any number category you want. Category name fields are mandatory. Slug and description field is optional. Slugs are created automatically if not mapped.
46
+
47
+ Nested category - This module is just like category module, provided you can import nested categories. You can import nested categories through name field like category1 | category2 | category3. If the category doesn't exist it will be created in a hierarchy as mention in name field.
48
+
49
+ Tags - Import bulk tags using this module and assign to post, custom post or products.
50
+
51
+ Users with roles - Import bulk users with their roles by role id. There 11 fields to map in which user login, email and role are mandatory fields. Roles are mentioned in CSV as ids. Please ensure roles are created in advance before import. Other wise default role is assigned for missing role ids.
52
+
53
+ Custom taxonomy - Is your Wordpress is configured for custom taxonomy, you can import bulk custom taxonomies as like as nested categories.
54
+
55
+ WP Commerce/ eshop - You can import products in bulk if these modules are installed in your Wordpress.
56
 
 
57
 
58
  Support and Feature request.
59
  ----------------------------
80
 
81
  == Changelog ==
82
 
83
+ = 2.6.0 = Major Bug fixed
84
+ -- Added UTF-8 support.
85
+ -- Fixed Html tag conflicts.
86
+
87
  = 2.5.0 = Major issues fixed and updated to WordPress-3.5.1 compatibility.
88
 
89
  = 2.0.1 = Update to WordPress-3.5 compatibility.
106
 
107
  == Upgrade Notice ==
108
 
109
+ =v 2.6.0 = Major Bug fixed and should upgrade.
110
+
111
  =v 2.5.0 = Major issues fixed and updated to WordPress-3.5.1 compatibility.
112
  -- Duplicate detection added.
113
  -- Added more information in success message.
114
  -- Import memory issues solved.
 
115
 
116
  =v 2.0.1 = Update to WordPress-3.5 compatibility.
117
 
wp_ultimate_csv_importer.js CHANGED
@@ -5,6 +5,12 @@ function addcustomfield(myval,selected_id){
5
  var selected_value;
6
  for(var i=0;i<aa;i++){
7
  var b = document.getElementById('mapping'+i).value;
 
 
 
 
 
 
8
  if(b=='add_custom'+i){
9
  document.getElementById('textbox'+i).style.display="";
10
  }
@@ -20,6 +26,9 @@ function addcustomfield(myval,selected_id){
20
  if(myval == value1 && myval != '-- Select --'){
21
  var selected_dropdown = document.getElementById('mapping'+selected_id);
22
  selected_dropdown.selectedIndex = '-- Select --';
 
 
 
23
  alert(myval+' is already selected!');
24
  }
25
  }
5
  var selected_value;
6
  for(var i=0;i<aa;i++){
7
  var b = document.getElementById('mapping'+i).value;
8
+ if(b == 'post_date'){
9
+ document.getElementById('date'+i).style.display="";
10
+ }
11
+ else{
12
+ document.getElementById('date'+i).style.display="none";
13
+ }
14
  if(b=='add_custom'+i){
15
  document.getElementById('textbox'+i).style.display="";
16
  }
26
  if(myval == value1 && myval != '-- Select --'){
27
  var selected_dropdown = document.getElementById('mapping'+selected_id);
28
  selected_dropdown.selectedIndex = '-- Select --';
29
+ if(myval == 'post_date'){
30
+ document.getElementById('date'+selected_id).style.display="none";
31
+ }
32
  alert(myval+' is already selected!');
33
  }
34
  }
wp_ultimate_csv_importer.php CHANGED
@@ -1,13 +1,13 @@
1
  <?php
2
  /*
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.5.0
7
  *Author: smackcoders.com
8
  *Author URI: http://www.smackcoders.com
9
  *
10
- * Copyright (C) 2012 Fredrick SujinDoss.M (email : fredrickm@smackcoders.com)
11
  *
12
  This program is free software; you can redistribute it and/or modify
13
  it under the terms of the GNU General Public License, version 2, as
@@ -22,7 +22,7 @@
22
  along with this program; if not, write to the Free Software
23
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
  *
25
- * @link http://www.smackcoders.com/category/free-wordpress-plugins.html
26
  ***********************************************************************************************
27
  */
28
 
@@ -32,12 +32,6 @@ ini_set('max_execution_time', 700);
32
  ini_set('memory_limit', '128M');
33
 
34
  require( dirname(__FILE__) . '/../../../wp-load.php' );
35
- $upload_dir = wp_upload_dir();
36
- $importdir = $upload_dir['basedir']."/imported_csv/";
37
- if(!is_dir($importdir))
38
- {
39
- wp_mkdir_p($importdir);
40
- }
41
 
42
  // Global variable declaration
43
  global $data_rows;
@@ -119,6 +113,7 @@ function description(){
119
  <p>
120
  7. Added featured image import functionality.
121
  </p>
 
122
  <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/blog/category/free-wordpress-plugins' target='_blank'>Smackcoders.com blog </a></p>
123
 
124
  <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='".$contentUrl."/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>
@@ -127,8 +122,28 @@ function description(){
127
  }
128
 
129
  // CSV File Reader
 
130
  function csv_file_data($file,$delim)
131
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
  ini_set("auto_detect_line_endings", true);
133
  global $data_rows;
134
  global $headers;
@@ -153,7 +168,7 @@ function move_file()
153
  {
154
  # Code added by goku
155
  $upload_dir = wp_upload_dir();
156
- $uploads_dir = $upload_dir['basedir']."/imported_csv";
157
  if ($_FILES["csv_import"]["error"] == 0) {
158
  $tmp_name = $_FILES["csv_import"]["tmp_name"];
159
  $name = $_FILES["csv_import"]["name"];
@@ -171,20 +186,6 @@ function fileDelete($filepath,$filename) {
171
  return $success;
172
  }
173
 
174
- // Scandinavian characters
175
- function smack_marks_scandiConverter($text){
176
- $returnvalue="";
177
- for($i=0;$i<strlen($text);$i++){
178
- $smacker=hexdec(rawurlencode(substr($text, $i, 1)));
179
- if($smacker<32||$smacker>1114111){
180
- $returnvalue.=substr($text, $i, 1);
181
- }else{
182
- $returnvalue.="&#".$smacker.";";
183
- }
184
- }
185
- return $returnvalue;
186
- }
187
-
188
  // Mapping the fields and upload data's
189
  function upload_csv_file()
190
  {
@@ -197,7 +198,7 @@ function upload_csv_file()
197
  global $wpdb;
198
  # Code added by goku
199
  $upload_dir = wp_upload_dir();
200
- $importdir = $upload_dir['basedir']."/imported_csv/";
201
  $custom_array = array();
202
  if(isset($_POST['Import']))
203
  {
@@ -220,7 +221,7 @@ function upload_csv_file()
220
  <?php
221
  $post_types=get_post_types();
222
  foreach($post_types as $key => $value){
223
- if(($value!='featured_image') && ($value!='attachment') && ($value!='revision') && ($value!='nav_menu_item')){ ?>
224
  <option id="<?php echo($value);?>" name="<?php echo($value);?>"> <?php echo($value);?> </option>
225
  <?php }
226
  }
@@ -260,6 +261,7 @@ function upload_csv_file()
260
  <option value="add_custom<?php print($count);?>">Add Custom Field</option>
261
  </select>
262
  <input type="text" id="textbox<?php print($count); ?>" name="textbox<?php print($count); ?>" style="display:none;"/>
 
263
  </td>
264
  </tr>
265
  <?php
@@ -294,10 +296,11 @@ function upload_csv_file()
294
  else if(isset($_POST['post_csv']))
295
  {
296
  $insertedRecords = 0;
 
297
  $smack_taxo = array();
298
  # Code added by goku
299
  $upload_dir = wp_upload_dir();
300
- $dir = $upload_dir['basedir']."/imported_csv/";
301
  csv_file_data($dir.$_POST['filename'],$delim);
302
  foreach($_POST as $postkey=>$postvalue){
303
  if($postvalue != '-- Select --'){
@@ -404,9 +407,6 @@ function upload_csv_file()
404
  }
405
  $data_array['post_type']=$_POST['csv_importer_cat'];
406
 
407
- $data_array['post_title'] = smack_marks_scandiConverter($data_array['post_title']);
408
- $data_array['post_content'] = smack_marks_scandiConverter($data_array['post_content']);
409
-
410
  // Duplicate Check code starts
411
  $permission = 'notok';
412
  $title = $data_array['post_title'];
@@ -416,6 +416,9 @@ function upload_csv_file()
416
  if(count($post_exist) == 0 && ($title != null || $title != '')){
417
  $permission = 'ok';
418
  }
 
 
 
419
  // Duplicate Check code ends
420
 
421
  if($permission == 'ok'){
@@ -462,8 +465,12 @@ function upload_csv_file()
462
  }
463
  }
464
  }
 
465
  ?>
466
- <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> <?php echo '('.$insertedRecords.')'; ?> records are successfully Imported ! </b></div>
 
 
 
467
  <div style="margin-top:30px;margin-left:10px">
468
  <form class="add:the-list: validate" method="post" enctype="multipart/form-data">
469
  <input type="submit" class='button-primary' id="goto" name="goto" value="Continue" />
@@ -471,7 +478,7 @@ function upload_csv_file()
471
  </div>
472
  <?php
473
  $upload_dir = wp_upload_dir();
474
- $csvdir = $upload_dir['basedir']."/imported_csv/";
475
  $CSVfile = $_POST['filename'];
476
  if(file_exists($csvdir.$CSVfile)){
477
  fileDelete($csvdir,$CSVfile);
1
  <?php
2
  /*
3
  *Plugin Name: WP Ultimate CSV Importer
4
+ *Plugin URI: http://www.smackcoders.com/blog/how-to-guide-for-free-wordpress-ultimate-csv-importer-plugin.html
5
  *Description: A plugin that helps to import the data's from a CSV file.
6
+ *Version: 2.6.0
7
  *Author: smackcoders.com
8
  *Author URI: http://www.smackcoders.com
9
  *
10
+ * Copyright (C) 2012 Smackcoders (www.smackcoders.com)
11
  *
12
  This program is free software; you can redistribute it and/or modify
13
  it under the terms of the GNU General Public License, version 2, as
22
  along with this program; if not, write to the Free Software
23
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
  *
25
+ * @link http://www.smackcoders.com/blog/category/free-wordpress-plugins
26
  ***********************************************************************************************
27
  */
28
 
32
  ini_set('memory_limit', '128M');
33
 
34
  require( dirname(__FILE__) . '/../../../wp-load.php' );
 
 
 
 
 
 
35
 
36
  // Global variable declaration
37
  global $data_rows;
113
  <p>
114
  7. Added featured image import functionality.
115
  </p>
116
+ <p><b> Important Note:- </b></p><p><span style='color:red;'>1. Your csv should have the seperate column for post_date. <br/>2. It must be in the following format. ( yyyy-mm-dd hh:mm:ss ).</span></p>
117
  <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/blog/category/free-wordpress-plugins' target='_blank'>Smackcoders.com blog </a></p>
118
 
119
  <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='".$contentUrl."/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>
122
  }
123
 
124
  // CSV File Reader
125
+ # Code modified by Fredrick Marks
126
  function csv_file_data($file,$delim)
127
  {
128
+ $upload_dir = wp_upload_dir();
129
+ if(!is_dir($upload_dir['basedir'])){
130
+ $returnContent = " <div style='font-size:16px;margin-left:20px;margin-top:25px;'>Your WordPress doesn't have the uploads folder. Please create the uploads folders and set write permission for that.
131
+ </div><br/>
132
+ <div style='margin-left:20px;'>
133
+ <form class='add:the-list: validate' method='post' action=''>
134
+ <input type='submit' class='button-primary' name='Import Again' value='Import Again'/>
135
+ </form>
136
+ </div>
137
+ ";
138
+ echo $returnContent;die;
139
+ }
140
+ else{
141
+ $importdir = $upload_dir['basedir']."/ultimate_importer/";
142
+ if(!is_dir($importdir))
143
+ {
144
+ wp_mkdir_p($importdir);
145
+ }
146
+ }
147
  ini_set("auto_detect_line_endings", true);
148
  global $data_rows;
149
  global $headers;
168
  {
169
  # Code added by goku
170
  $upload_dir = wp_upload_dir();
171
+ $uploads_dir = $upload_dir['basedir']."/ultimate_importer";
172
  if ($_FILES["csv_import"]["error"] == 0) {
173
  $tmp_name = $_FILES["csv_import"]["tmp_name"];
174
  $name = $_FILES["csv_import"]["name"];
186
  return $success;
187
  }
188
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
  // Mapping the fields and upload data's
190
  function upload_csv_file()
191
  {
198
  global $wpdb;
199
  # Code added by goku
200
  $upload_dir = wp_upload_dir();
201
+ $importdir = $upload_dir['basedir']."/ultimate_importer/";
202
  $custom_array = array();
203
  if(isset($_POST['Import']))
204
  {
221
  <?php
222
  $post_types=get_post_types();
223
  foreach($post_types as $key => $value){
224
+ if(($value!='featured_image') && ($value!='attachment') && ($value!='wpsc-product') && ($value!='wpsc-product-file') && ($value!='revision') && ($value!='nav_menu_item')){ ?>
225
  <option id="<?php echo($value);?>" name="<?php echo($value);?>"> <?php echo($value);?> </option>
226
  <?php }
227
  }
261
  <option value="add_custom<?php print($count);?>">Add Custom Field</option>
262
  </select>
263
  <input type="text" id="textbox<?php print($count); ?>" name="textbox<?php print($count); ?>" style="display:none;"/>
264
+ <span id="date<?php print($count); ?>" name="date<?php print($count); ?>" style="display:none;color:red;">Ensure your date is in (yyyy-mm-dd hh:mm:ss) format. </span>
265
  </td>
266
  </tr>
267
  <?php
296
  else if(isset($_POST['post_csv']))
297
  {
298
  $insertedRecords = 0;
299
+ $duplicates = 0;
300
  $smack_taxo = array();
301
  # Code added by goku
302
  $upload_dir = wp_upload_dir();
303
+ $dir = $upload_dir['basedir']."/ultimate_importer/";
304
  csv_file_data($dir.$_POST['filename'],$delim);
305
  foreach($_POST as $postkey=>$postvalue){
306
  if($postvalue != '-- Select --'){
407
  }
408
  $data_array['post_type']=$_POST['csv_importer_cat'];
409
 
 
 
 
410
  // Duplicate Check code starts
411
  $permission = 'notok';
412
  $title = $data_array['post_title'];
416
  if(count($post_exist) == 0 && ($title != null || $title != '')){
417
  $permission = 'ok';
418
  }
419
+ if(count($post_exist) > 0){
420
+ $duplicates = $duplicates+1;
421
+ }
422
  // Duplicate Check code ends
423
 
424
  if($permission == 'ok'){
465
  }
466
  }
467
  }
468
+ if(($insertedRecords != 0) || ($duplicates != 0)){
469
  ?>
470
+ <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> <?php echo '('.$insertedRecords.')'; ?> records are successfully Imported ! <?php echo '('.$duplicates.')'; ?> duplicate records found !</b></div>
471
+ <?php }else if(($insertedRecords == 0) && ($duplicates == 0)){ ?>
472
+ <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> Check your CSV file and format. </b></div>
473
+ <?php } ?>
474
  <div style="margin-top:30px;margin-left:10px">
475
  <form class="add:the-list: validate" method="post" enctype="multipart/form-data">
476
  <input type="submit" class='button-primary' id="goto" name="goto" value="Continue" />
478
  </div>
479
  <?php
480
  $upload_dir = wp_upload_dir();
481
+ $csvdir = $upload_dir['basedir']."/ultimate_importer/";
482
  $CSVfile = $_POST['filename'];
483
  if(file_exists($csvdir.$CSVfile)){
484
  fileDelete($csvdir,$CSVfile);