Ultimate CSV Importer - Version 2.7.0

Version Description

Download this release

Release Info

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

Code changes from version 2.6.0 to 2.7.0

Files changed (3) hide show
  1. Readme.txt +173 -141
  2. wp_ultimate_csv_importer.js +73 -6
  3. wp_ultimate_csv_importer.php +194 -24
Readme.txt CHANGED
@@ -1,141 +1,173 @@
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.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
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
-
15
-
16
- == Description ==
17
-
18
- WP Ultimate CSV Importer Plugin helps you to import any csv file as post, page or even as custom post data's by matching its headers to relevant fields or custom fields.
19
-
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
- The pro version of this plugin is available now with lot more new features, functionalities, controls and usability. Please upgrade to pro version to enjoy the powerful features like importing nested categories, WP-e-commerce products, eShop products, custom taxonomies in bulk with simple clicks.
29
-
30
- 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.
31
-
32
- Note: Your theme should support featured image function. If not, please add the following code to header.php or where it needed.
33
- add_theme_support( 'post-thumbnails' );
34
-
35
- 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
- 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
- ----------------------------
60
-
61
- Please create issues only in our tracker http://forge.smackcoders.com/projects/wp-ultimate-csv-importer-free/issues instead of WordPress support forum.
62
-
63
- For guides and tutorials, visit http://forge.smackcoders.com/projects/wp-ultimate-csv-importer-free .
64
-
65
-
66
-
67
- == Installation ==
68
-
69
-
70
- Please click here for [Detailed Installation Instructions](http://www.smackcoders.com/blog/category/free-wordpress-plugins/wordpress-ultimate-csv-importer-plugin/)
71
-
72
-
73
-
74
- == Screenshots ==
75
-
76
- 1. Admin settings for WP Ultimate CSV Importer Plugin .
77
- 2. Admin settings for Import Data and Header Mapping configuration to import data's from a csv file.
78
-
79
-
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.
90
-
91
- = 2.0.0 = WPDEBUG errors fixed. CSV import folder changed to WP native uploads folder.
92
-
93
- = 1.1.1 = Renamed the mapping field attachment as featured_image and category as post_category.
94
-
95
- = 1.1.0 = Added featured image import feature along with post/page/custom post.
96
-
97
- = 1.0.2 = - Bug fixed to recognize the trimmed trailing space in the CSV file
98
- - Added validation for the duplicate field mapping.
99
-
100
- = 1.0.1 = Added features to import multiple tags and categories with different delimiters.
101
-
102
- = 1.0.0 = Initial release version. Tested and found works well without any issues.
103
-
104
-
105
-
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
-
118
- =v 2.0.0 = Major Bug fixed and should upgrade. WPDEBUG errors fixed. CSV import folder changed to WP native uploads folder.
119
-
120
- =v 1.1.1 = Minor correction and fix applied.
121
-
122
- =v 1.1.0 = A major new feature added in this version. Update needed.
123
-
124
- =v 1.0.2 = This version have important bug fixes and newly added features. Must be upgrade immediately.
125
-
126
- =v 1.0.1 = Added features to import multiple tags and categories with different delimiters.
127
-
128
- =v 1.0.0 = Initial release of plugin.
129
-
130
-
131
-
132
-
133
- == Frequently Asked Questions ==
134
-
135
- Please click here for [ Detailed Frequently Asked Questions](http://www.smackcoders.com/blog/category/free-wordpress-plugins/wordpress-ultimate-csv-importer-plugin/)
136
-
137
- For quick response and reply please create issues in our [support](http://forge.smackcoders.com/projects/wp-ultimate-csv-importer-free/issues) instead of WordPress support forum.
138
-
139
-
140
-
141
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.5.1
7
+ Stable tag: 2.7.0
8
+ Version: 2.7.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
+
15
+
16
+ == Description ==
17
+
18
+ WP Ultimate CSV Importer Plugin helps you to import any csv file as post, page or even as custom post data's by matching its headers to relevant fields or custom fields.
19
+
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
+ The pro version of this plugin is available now with lot more new features, functionalities, controls and usability. Please upgrade to pro version to enjoy the powerful features like importing nested categories, WP-e-commerce products, eShop products, custom taxonomies in bulk with simple clicks.
29
+
30
+ 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.
31
+
32
+ Note: Your theme should support featured image function. If not, please add the following code to header.php or where it needed.
33
+ add_theme_support( 'post-thumbnails' );
34
+
35
+ 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
+ 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
+ ----------------------------
60
+
61
+ Please create issues only in our tracker http://forge.smackcoders.com/projects/wp-ultimate-csv-importer-free/issues instead of WordPress support forum.
62
+
63
+ For guides and tutorials, visit http://forge.smackcoders.com/projects/wp-ultimate-csv-importer-free .
64
+
65
+
66
+
67
+ == Installation ==
68
+
69
+
70
+ Please click here for [Detailed Installation Instructions](http://www.smackcoders.com/blog/category/free-wordpress-plugins/wordpress-ultimate-csv-importer-plugin/)
71
+
72
+
73
+
74
+ == Screenshots ==
75
+
76
+ 1. Admin settings for WP Ultimate CSV Importer Plugin .
77
+ 2. Admin settings for Import Data and Header Mapping configuration to import data's from a csv file.
78
+
79
+
80
+
81
+ == Changelog ==
82
+
83
+ = 2.7.0 = Post Status
84
+ -- Added more post status options
85
+ -- Publish, Sticky, Private, Draft and Pending Status for whole import
86
+ -- Protected status with a common password option added
87
+ -- "Status as in CSV" to assign status for individual psot thorugh CSV as ID or Field Tag
88
+
89
+ Post Author
90
+ -- User ID and User Name support for Post author feature added
91
+ -- In case of missing or false IDs post assigned to admin as draft
92
+ --
93
+
94
+ Extra date formats support added.
95
+ -- 6 Standard date format added as dropdown to choose.
96
+ -- Date format conflict at import fixed.
97
+
98
+ Custom field feature improved.
99
+ -- Listed custom fields with prefix as CF: Name for easy identification.
100
+ -- Add Custom Field Textbox autofilled with CSV header tag.
101
+
102
+ Added Feature
103
+ -- Duplicate detection for post content and post title added as options.
104
+ -- User can choose either one or both to avoid duplicate issues.
105
+
106
+ Post Slug
107
+ -- Renamed post_name as post_slug to avoid confusion
108
+
109
+ Mapping Fields
110
+ -- Field tags are formatted to support auto mapping option (next milestone)
111
+
112
+
113
+ = 2.6.0 = Major Bug fixed
114
+ -- Added UTF-8 support.
115
+ -- Fixed Html tag conflicts.
116
+
117
+ = 2.5.0 = Major issues fixed and updated to WordPress-3.5.1 compatibility.
118
+
119
+ = 2.0.1 = Update to WordPress-3.5 compatibility.
120
+
121
+ = 2.0.0 = WPDEBUG errors fixed. CSV import folder changed to WP native uploads folder.
122
+
123
+ = 1.1.1 = Renamed the mapping field attachment as featured_image and category as post_category.
124
+
125
+ = 1.1.0 = Added featured image import feature along with post/page/custom post.
126
+
127
+ = 1.0.2 = - Bug fixed to recognize the trimmed trailing space in the CSV file
128
+ - Added validation for the duplicate field mapping.
129
+
130
+ = 1.0.1 = Added features to import multiple tags and categories with different delimiters.
131
+
132
+ = 1.0.0 = Initial release version. Tested and found works well without any issues.
133
+
134
+
135
+
136
+
137
+ == Upgrade Notice ==
138
+
139
+ =v 2.7.0 = Major improvements and feature changes.
140
+
141
+ =v 2.6.0 = Bug fixed and should upgrade.
142
+
143
+ =v 2.5.0 = Issues fixed and updated to WordPress-3.5.1 compatibility.
144
+ -- Duplicate detection added.
145
+ -- Added more information in success message.
146
+ -- Import memory issues solved.
147
+
148
+ =v 2.0.1 = Update to WordPress-3.5 compatibility.
149
+
150
+ =v 2.0.0 = Major Bug fixed and should upgrade. WPDEBUG errors fixed. CSV import folder changed to WP native uploads folder.
151
+
152
+ =v 1.1.1 = Minor correction and fix applied.
153
+
154
+ =v 1.1.0 = A major new feature added in this version. Update needed.
155
+
156
+ =v 1.0.2 = This version have important bug fixes and newly added features. Must be upgrade immediately.
157
+
158
+ =v 1.0.1 = Added features to import multiple tags and categories with different delimiters.
159
+
160
+ =v 1.0.0 = Initial release of plugin.
161
+
162
+
163
+
164
+
165
+ == Frequently Asked Questions ==
166
+
167
+ Please click here for [ Detailed Frequently Asked Questions](http://www.smackcoders.com/blog/category/free-wordpress-plugins/wordpress-ultimate-csv-importer-plugin/)
168
+
169
+ For quick response and reply please create issues in our [support](http://forge.smackcoders.com/projects/wp-ultimate-csv-importer-free/issues) instead of WordPress support forum.
170
+
171
+
172
+
173
+
wp_ultimate_csv_importer.js CHANGED
@@ -1,4 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  // Function for add customfield
 
2
  function addcustomfield(myval,selected_id){
3
  var a = document.getElementById('h1').value;
4
  var aa = document.getElementById('h2').value;
@@ -13,9 +58,12 @@ function addcustomfield(myval,selected_id){
13
  }
14
  if(b=='add_custom'+i){
15
  document.getElementById('textbox'+i).style.display="";
 
16
  }
17
  else{
18
- document.getElementById('textbox'+i).style.display="none";
 
 
19
  }
20
  }
21
  var header_count = document.getElementById('h2').value;
@@ -47,9 +95,15 @@ function file_exist(){
47
  }
48
  }
49
 
50
- // Function for import csv
51
  function import_csv(){
52
  var header_count = document.getElementById('h2').value;
 
 
 
 
 
 
 
53
  var array = new Array();
54
  var val1,val2;
55
  val1 = val2 = 'Off';
@@ -65,12 +119,25 @@ function import_csv(){
65
  if(array[j] == 'post_content'){
66
  val2 = 'On';
67
  }
 
 
 
 
 
68
  }
69
- if(val1 == 'On' && val2 == 'On') {
70
  return true;
71
  }
72
- else{
73
- alert('"post_title" and "post_content" should be mapped.');
74
- return false;
 
 
 
 
75
  }
 
 
 
 
76
  }
1
+ function importAllPostStatus(selectedId,headerCount){
2
+ var select;
3
+ var options;
4
+ if(selectedId != 0){
5
+ document.getElementById('poststatusalert').style.display = 'none';
6
+ for(var u=0;u< headerCount;u++){
7
+ select = document.getElementById('mapping'+u);
8
+ options = select.options;
9
+ for(var o=0;o<options.length;o++){
10
+ if(options[o].value == 'post_status'){
11
+ select.remove(o);
12
+ }
13
+ }
14
+ }
15
+ }
16
+ else{
17
+ document.getElementById('poststatusalert').style.display = 'block';
18
+
19
+ for(var v=0;v<headerCount;v++){
20
+ select = document.getElementById('mapping'+v);
21
+ options = select.options;
22
+ poststatus = 0;
23
+ for(var o=0;o<options.length;o++){
24
+ if(options[o].value == 'post_status')
25
+ poststatus = 1;
26
+ }
27
+ if(poststatus == 0){
28
+ var option=document.createElement("option");
29
+ option.text="post_status";
30
+ select.add(option);
31
+ }
32
+
33
+ }
34
+ }//exits post_status show hide
35
+ if(selectedId == 3){
36
+ document.getElementById('postsPassword').style.display = "";
37
+ document.getElementById('passwordlabel').style.display = "";
38
+ }
39
+ else{
40
+ document.getElementById('postsPassword').style.display = "none";
41
+ document.getElementById('passwordlabel').style.display = "none";
42
+ }
43
+ }
44
+
45
  // Function for add customfield
46
+
47
  function addcustomfield(myval,selected_id){
48
  var a = document.getElementById('h1').value;
49
  var aa = document.getElementById('h2').value;
58
  }
59
  if(b=='add_custom'+i){
60
  document.getElementById('textbox'+i).style.display="";
61
+ document.getElementById('customspan'+i).style.display = "";
62
  }
63
  else{
64
+ document.getElementById('textbox'+i).style.display="none";
65
+ document.getElementById('customspan'+i).style.display = "none";
66
+
67
  }
68
  }
69
  var header_count = document.getElementById('h2').value;
95
  }
96
  }
97
 
 
98
  function import_csv(){
99
  var header_count = document.getElementById('h2').value;
100
+ var chk_status_in_csv;
101
+ var post_status_msg;
102
+ var error_msg = '';
103
+ post_status_msg = 'Off';
104
+ chk_status_in_csv = document.getElementById('importallwithps').value;
105
+ if(chk_status_in_csv != 0)
106
+ post_status_msg = 'On';
107
  var array = new Array();
108
  var val1,val2;
109
  val1 = val2 = 'Off';
119
  if(array[j] == 'post_content'){
120
  val2 = 'On';
121
  }
122
+ if(post_status_msg == 'Off'){
123
+ if(array[j] == 'post_status')
124
+ post_status_msg = 'On';
125
+ }
126
+
127
  }
128
+ if(val1 == 'On' && val2 == 'On' && post_status_msg == 'On') {
129
  return true;
130
  }
131
+ else {
132
+ if(val1 == 'Off')
133
+ error_msg += " post_title,";
134
+ if(val2 == 'Off')
135
+ error_msg += " post_content,";
136
+ if(post_status_msg == 'Off')
137
+ error_msg += " post_status";
138
  }
139
+
140
+ alert('Error: '+error_msg+' are mandatory fields. Please map the fields to proceed.');
141
+ return false;
142
+
143
  }
wp_ultimate_csv_importer.php CHANGED
@@ -3,7 +3,7 @@
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
  *
@@ -68,9 +68,10 @@ $defaults = array(
68
  'post_author' => null,
69
  'featured_image' => null,
70
  'post_parent' => 0,
 
71
  );
72
  foreach($keys as $val){
73
- $defaults[$val]=$val;
74
  }
75
  // Admin menu settings
76
  function wp_ultimate_csv_importer() {
@@ -201,7 +202,8 @@ function upload_csv_file()
201
  $importdir = $upload_dir['basedir']."/ultimate_importer/";
202
  $custom_array = array();
203
  if(isset($_POST['Import']))
204
- {
 
205
  csv_file_data($_FILES['csv_import']['tmp_name'],$delim);
206
  move_file();
207
  ?>
@@ -214,7 +216,6 @@ function upload_csv_file()
214
  <h3>Import Data Configuration</h3>
215
  <div style="margin-top:30px;>
216
  <input name="_csv_importer_import_as_draft" type="hidden" value="publish" />
217
- <label><input name="csv_importer_import_as_draft" type="checkbox" <?php if ('draft' == $opt_draft) { echo 'checked="checked"'; } ?> value="draft" /> Import as drafts </label>&nbsp;&nbsp;
218
  </p>
219
  <label> Select Post Type </label>&nbsp;&nbsp;
220
  <select name='csv_importer_cat'>
@@ -227,12 +228,31 @@ function upload_csv_file()
227
  }
228
  ?>
229
  <select>
230
- <br/></div><br/>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
  <h3>Mapping the Fields</h3>
232
  <div id='display_area'>
233
- <?php $cnt =count($defaults)+2; $cnt1 =count($headers); ?>
234
  <input type="hidden" id="h1" name="h1" value="<?php echo $cnt; ?>"/>
235
  <input type="hidden" id="h2" name="h2" value="<?php echo $cnt1; ?>"/>
 
 
236
  <input type="hidden" id="delim" name="delim" value="<?php echo $_POST['delim']; ?>" />
237
  <input type="hidden" id="header_array" name="header_array" value="<?php print_r($headers);?>" />
238
  <table style="font-size:12px;">
@@ -250,8 +270,13 @@ function upload_csv_file()
250
  <?php
251
  foreach($defaults as $key1=>$value1){
252
  ?>
253
- <option value ="<?php print($key1);?>"><?php print($key1);?></option>
254
- <?php } $taxo = get_taxonomies();
 
 
 
 
 
255
  foreach($taxo as $taxokey => $taxovalue){
256
  if($taxokey !='category' && $taxokey !='link_category' && $taxokey != 'post_tag' && $taxokey != 'nav_menu' && $taxokey != 'post_format'){ ?>
257
  <option value ="<?php print($taxokey);?>"><?php print($taxovalue);?></option>
@@ -260,9 +285,19 @@ function upload_csv_file()
260
  ?>
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
268
  $count++; }
@@ -293,10 +328,16 @@ function upload_csv_file()
293
  </div>
294
  <?php }
295
  }
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();
@@ -401,28 +442,148 @@ function upload_csv_file()
401
  }
402
  }
403
  }
404
- $data_array['post_status']='publish';
405
- if(isset($_POST['csv_importer_import_as_draft'])){
406
- $data_array['post_status']='draft';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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'];
413
  $gettype = $data_array['post_type'];
414
  $post_table = $wpdb->posts;
415
  $post_exist = $wpdb->get_results("select ID from $post_table where post_title = \"{$title}\" and post_type = \"{$gettype}\" and post_status in('publish','future','draft')");
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'){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
425
  $post_id = wp_insert_post( $data_array );
 
 
426
  if($post_id){
427
  $insertedRecords = $insertedRecords+1;
428
  }
@@ -433,7 +594,7 @@ function upload_csv_file()
433
  }
434
 
435
  // Create custom taxonomy to post
436
- if(!empty($smack_taxo)){//print_r($smack_taxo);
437
  foreach($smack_taxo as $taxo_key => $taxo_value){
438
  $split_line = explode('|',$taxo_value);
439
  wp_set_object_terms( $post_id, $split_line, $taxo_key );
@@ -467,7 +628,13 @@ function upload_csv_file()
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 } ?>
@@ -497,6 +664,9 @@ function upload_csv_file()
497
  <!-- File input -->
498
  <p><label for="csv_import">Upload file:</label><br/>
499
  <input name="csv_import" id="csv_import" type="file" value="" aria-required="true" /></p><br/>
 
 
 
500
  <p><label>Delimiter</label>&nbsp;&nbsp;&nbsp;
501
  <select name="delim" id="delim">
502
  <option value=",">,</option>
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.7.0
7
  *Author: smackcoders.com
8
  *Author URI: http://www.smackcoders.com
9
  *
68
  'post_author' => null,
69
  'featured_image' => null,
70
  'post_parent' => 0,
71
+ 'post_status' => 0,
72
  );
73
  foreach($keys as $val){
74
+ $defaults["CF: ".$val]=$val;
75
  }
76
  // Admin menu settings
77
  function wp_ultimate_csv_importer() {
202
  $importdir = $upload_dir['basedir']."/ultimate_importer/";
203
  $custom_array = array();
204
  if(isset($_POST['Import']))
205
+ {
206
+ $duplicatesDetection = $_POST['titleduplicatecheck'];
207
  csv_file_data($_FILES['csv_import']['tmp_name'],$delim);
208
  move_file();
209
  ?>
216
  <h3>Import Data Configuration</h3>
217
  <div style="margin-top:30px;>
218
  <input name="_csv_importer_import_as_draft" type="hidden" value="publish" />
 
219
  </p>
220
  <label> Select Post Type </label>&nbsp;&nbsp;
221
  <select name='csv_importer_cat'>
228
  }
229
  ?>
230
  <select>
231
+ <br/>
232
+ <br/>
233
+ <?php $cnt1 = count($headers); ?>
234
+
235
+ <label>Import with post status</label>&nbsp;&nbsp;
236
+ <select name = 'importallwithps' id= 'importallwithps' onchange = 'importAllPostStatus(this.value, "<?php echo $cnt1?>")'>
237
+ <option value = '0'>Status as in CSV</option>
238
+ <option value = '1'>Publish</option>
239
+ <option value = '2'>Sticky</option>
240
+ <option value = '3'>Protected</option>
241
+ <option value = '4'>Private</option>
242
+ <option value = '5'>Draft</option>
243
+ <option value = '6'>Pending</option>
244
+ </select>
245
+ </div><br/>
246
+ <span style='color:red;'id = 'poststatusalert'>post_status field must mapped below as in CSV</span>
247
+ <label style='display:none;' id = 'passwordlabel'>Posts Password</label>&nbsp;&nbsp;
248
+ <input type='text' style='display:none' id = 'postsPassword' name = 'postsPassword'>
249
  <h3>Mapping the Fields</h3>
250
  <div id='display_area'>
251
+ <?php $cnt =count($defaults)+2; ?>
252
  <input type="hidden" id="h1" name="h1" value="<?php echo $cnt; ?>"/>
253
  <input type="hidden" id="h2" name="h2" value="<?php echo $cnt1; ?>"/>
254
+ <input type="hidden" id="titleduplicatecheck" name = "titleduplicatecheck" value="<?php echo $_POST['titleduplicatecheck'] ?>" />
255
+ <input type="hidden" id="contentduplicatecheck" name="contentduplicatecheck" value="<?php echo $_POST['contentduplicatecheck'] ?>" />
256
  <input type="hidden" id="delim" name="delim" value="<?php echo $_POST['delim']; ?>" />
257
  <input type="hidden" id="header_array" name="header_array" value="<?php print_r($headers);?>" />
258
  <table style="font-size:12px;">
270
  <?php
271
  foreach($defaults as $key1=>$value1){
272
  ?>
273
+ <option value ="<?php print($key1);?>">
274
+ <?php if($key1 != 'post_name')
275
+ print($key1);
276
+ else
277
+ print 'post_slug';?>
278
+ </option>
279
+ <?php } $taxo = get_taxonomies();
280
  foreach($taxo as $taxokey => $taxovalue){
281
  if($taxokey !='category' && $taxokey !='link_category' && $taxokey != 'post_tag' && $taxokey != 'nav_menu' && $taxokey != 'post_format'){ ?>
282
  <option value ="<?php print($taxokey);?>"><?php print($taxovalue);?></option>
285
  ?>
286
  <option value="add_custom<?php print($count);?>">Add Custom Field</option>
287
  </select>
288
+ <!-- added to solve issue id 1072-->
289
+ <input type="text" id="textbox<?php print($count); ?>" name="textbox<?php print($count); ?>" style="display:none;" value="<?php echo $value ?>" />
290
+ <span style="display:none;color:red;margin-left:5px;" id="customspan<?php echo $count?>" >Name this Field</span>
291
+ <select id="date<?php print($count); ?>" name="date<?php print($count); ?>" style="display:none;">
292
+ <option value="M/DD/YYYY">M/DD/YYYY</option>
293
+ <option value="M/DD/YYYY HH:MM">M/DD/YYYY HH:MM</option>
294
+ <option value="M/DD/YYYY HH:MM PM">M/DD/YYYY HH:MM PM</option>
295
+ <option value="MM/DD/YYYY">MM/DD/YYYY</option>
296
+ <option value="MM/DD/YYYY HH:MM">MM/DD/YYYY HH:MM</option>
297
+ <option value="MM/DD/YYYY HH:MM PM">MM/DD/YYYY HH:MM PM</option>
298
+ <option value="YYYY-MM-DD HH:MM:SS">YYYY-MM-DD HH:MM:SS</option>
299
+ </select>
300
+ </td>
301
  </tr>
302
  <?php
303
  $count++; }
328
  </div>
329
  <?php }
330
  }
331
+ else if(isset($_POST['post_csv'])){
332
+ # added for issue id 1072
333
+ for($d=0;$d<count($_POST);$d++){
334
+ if($_POST['mapping'.$d] == 'post_date'){
335
+ $dateformat = $_POST['date'.$d];
336
+ }
337
+ }
338
  $insertedRecords = 0;
339
  $duplicates = 0;
340
+ $wrongpostauthor = 0;
341
  $smack_taxo = array();
342
  # Code added by goku
343
  $upload_dir = wp_upload_dir();
442
  }
443
  }
444
  }
445
+ #code added for issue 1087
446
+ $sticky = false;
447
+ if($_POST['importallwithps'] == 0){
448
+ unset($data_array['post_password']);
449
+ if(($data_array['post_status'] == 1)||($data_array['post_status'] == 'Publish'))
450
+ $data_array['post_status'] = 'publish';
451
+ elseif(($data_array['post_status'] == 4)||($data_array['post_status'] == 'Draft'))
452
+ $data_array['post_status'] = 'draft';
453
+ elseif(($data_array['post_status'] == '3')||($data_array['post_status'] == 'Private'))
454
+ $data_array['post_status'] = 'private';
455
+ elseif(($data_array['post_status'] == 5)||($data_array['post_status'] == 'Pending'))
456
+ $data_array['post_status'] = 'pending';
457
+ elseif(($data_array['post_status'] == 2)||($data_array['post_status'] == 'Sticky')){
458
+ $data_array['post_status'] = 'publish';
459
+ $sticky = true;
460
+ }
461
+ elseif(($data_array['post_status'] == ''))
462
+ $data_array['post_status'] = 'publish';
463
+ else {
464
+ if(strlen($data_array['post_status']) <= 10)
465
+ $data_array['post_password'] = $data_array['post_status'];
466
+ else
467
+ $data_array['post_password'] = substr($data_array['post_status'],0,10);
468
+ $data_array['post_status'] = 'publish';
469
+ }
470
+ }
471
+ else{
472
+ unset($data_array['post_password']);
473
+ if($_POST['importallwithps'] == 1)
474
+ $data_array['post_status'] = 'publish';
475
+ if($_POST['importallwithps'] == 2){
476
+ $data_array['post_status'] = 'publish';
477
+ $sticky = true;
478
+ }
479
+ if($_POST['importallwithps'] == 3){
480
+ $data_array['post_status'] = 'publish';
481
+ $data_array['post_password'] = $_POST['postsPassword'];
482
+ }
483
+ if($_POST['importallwithps'] == 4)
484
+ $data_array['post_status'] = 'private';
485
+ if($_POST['importallwithps'] == 5)
486
+ $data_array['post_status'] = 'draft';
487
+ if($_POST['importallwithps'] == 6){
488
+ $data_array['post_status'] = 'pending';
489
+ }
490
  }
491
  $data_array['post_type']=$_POST['csv_importer_cat'];
492
+ $permission = 'ok';
493
+ $chkinsert =1;
494
+ $chkedContent = 1;
495
+ // Duplicate Check code starts
496
+ if($_POST['titleduplicatecheck']){
497
  $permission = 'notok';
498
  $title = $data_array['post_title'];
499
  $gettype = $data_array['post_type'];
500
  $post_table = $wpdb->posts;
501
  $post_exist = $wpdb->get_results("select ID from $post_table where post_title = \"{$title}\" and post_type = \"{$gettype}\" and post_status in('publish','future','draft')");
502
  if(count($post_exist) == 0 && ($title != null || $title != '')){
503
+ $chkinsert = 0;
504
+ $permission = 'ok';
505
  }
 
 
506
  }
507
+ if($_POST['contentduplicatecheck']){
508
+ $permission = 'ok';
509
+ $content = $data_array['post_content'];
510
+ $contentLength = strlen($content);
511
+ $post_table = $wpdb->posts;
512
+ $post_exist = $wpdb->get_results("select ID from $post_table where length(post_content) = \"{$contentLength}\"");
513
+ if(count($post_exist)==0){
514
+ $chkedContent = 0;
515
+ }
516
+ else{
517
+ $chkforeach = 0;
518
+ foreach($post_exist as $singlepost){
519
+ $postdata = $wpdb->get_results("select post_content from $post_table where id = \"{$singlepost->ID}\"");
520
+ $chkDbString = substr($postdata[0]->post_content,0,50);
521
+ $chkFormString = substr($content,0,50);
522
+ if($chkDbString == $chkFormString){
523
+ $permission = 'notok';
524
+ }
525
+
526
+ }
527
+ }
528
+ }
529
+ if($permission == 'notok')
530
+ $duplicates++;
531
+ if(!(is_numeric($data_array['post_author']))){
532
+ $postuserid = $data_array['post_author'];
533
+ $postauthor = $wpdb->get_results("select id from wp_users where user_login = \"{$postuserid}\"");
534
+ if($postauthor == null){
535
+ $data_array['post_author'] = 1;
536
+ $data_array['post_status'] = 'draft';
537
+ $wrongpostauthor++;
538
+ }
539
+ else
540
+ $data_array['post_author'] = $postauthor[0]->id;
541
+ }
542
+ // Duplicate Check code ends
543
 
544
  if($permission == 'ok'){
545
+
546
+ if($dateformat != 'YYYY-MM-DD HH:MM:SS'){
547
+ if($dateformat == 'MM/DD/YYYY HH:MM'){
548
+ $splitdate = explode(" ",$data_array['post_date']);
549
+ $date = $splitdate[0];
550
+ $time = $splitdate[1];
551
+ $formatdatearray = explode("/",$date);
552
+ $exactdate = $formatdatearray[2].'-'.$formatdatearray[0].'-'.$formatdatearray[1];
553
+ $data_array['post_date'] = $exactdate.' '.$time;
554
+ }
555
+ if($dateformat == 'M/DD/YYYY HH:MM'){
556
+ $splitdate = explode(" ",$data_array['post_date']);
557
+ $date = $splitdate[0];
558
+ $time = $splitdate[1];
559
+ $formatdatearray = explode("/",$date);
560
+ $exactdate = $formatdatearray[2].'-'.$formatdatearray[0].'-'.$formatdatearray[1];
561
+ $data_array['post_date'] = $exactdate.' '.$time;
562
+ }
563
+ if(($dateformat == 'M/DD/YYYY')||($dateformat == 'MM/DD/YYYY')){
564
+ $splitdate = explode(" ",$data_array['post_date']);
565
+ $date = $splitdate[0];
566
+ $formatdatearray = explode("/",$date);
567
+ $exactdate = $formatdatearray[2].'-'.$formatdatearray[0].'-'.$formatdatearray[1];
568
+ $data_array['post_date'] = $exactdate;
569
+ }
570
+ if(($dateformat == 'M/DD/YYYY HH:MM PM')||($dateformat == 'MM/DD/YYYY HH:MM PM')){
571
+ $splitdate = explode(" ",$data_array['post_date']);
572
+ $date = $splitdate[0];
573
+ $time = $splitdate[1];
574
+ $chkpm = $splitdate[2];
575
+ if($chkpm == 'PM'||$chkpm == 'pm'){
576
+ $time = strtotime($time .' + 12 hour');
577
+ $time = date('G:i:s',$time);
578
+ }
579
+ $formatdatearray = explode("/",$date);
580
+ $exactdate = $formatdatearray[2].'-'.$formatdatearray[0].'-'.$formatdatearray[1];
581
+ $data_array['post_date'] = $exactdate.' '.$time;
582
+ }
583
+ }
584
  $post_id = wp_insert_post( $data_array );
585
+ if($sticky)
586
+ stick_post($post_id);
587
  if($post_id){
588
  $insertedRecords = $insertedRecords+1;
589
  }
594
  }
595
 
596
  // Create custom taxonomy to post
597
+ if(!empty($smack_taxo)){
598
  foreach($smack_taxo as $taxo_key => $taxo_value){
599
  $split_line = explode('|',$taxo_value);
600
  wp_set_object_terms( $post_id, $split_line, $taxo_key );
628
  }
629
  if(($insertedRecords != 0) || ($duplicates != 0)){
630
  ?>
631
+ <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 !<br> <?php echo '('.$duplicates.')'; ?> duplicate records found !
632
+ <?php if($wrongpostauthor != 0){ ?><br>
633
+ <?php echo $wrongpostauthor; ?> posts with no valid UserID/Name are assigned admin as author.
634
+ <?php
635
+ //ask and fill the error msg
636
+
637
+ } ?></b></div>
638
  <?php }else if(($insertedRecords == 0) && ($duplicates == 0)){ ?>
639
  <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>
640
  <?php } ?>
664
  <!-- File input -->
665
  <p><label for="csv_import">Upload file:</label><br/>
666
  <input name="csv_import" id="csv_import" type="file" value="" aria-required="true" /></p><br/>
667
+ <p><input type="checkbox" name="titleduplicatecheck" value=1> Enable Duplicate Post Title Detection<br>
668
+ <p><input type="checkbox" name="contentduplicatecheck" value = 1> Enable Duplicate Post Content Detection <br>
669
+ <!-- added above checkboxes for issueid 1057-->
670
  <p><label>Delimiter</label>&nbsp;&nbsp;&nbsp;
671
  <select name="delim" id="delim">
672
  <option value=",">,</option>