Version Description
Download this release
Release Info
Developer | smackcoders |
Plugin | Ultimate CSV Importer |
Version | 1.0.1 |
Comparing to | |
See all releases |
Code changes from version 1.0.0 to 1.0.1
- Readme.txt +21 -16
- screenshot-1.png +0 -0
- wp_ultimate_csv_importer.php +61 -16
Readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=fenzi
|
|
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.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -32,10 +32,12 @@ Please visit http://www.smackcoders.com/category/free-wordpress-plugins.html for
|
|
32 |
|
33 |
Wp Ultimate CSV Importer is very easy to install like any other wordpress plugin. No need to edit or modify anything here.
|
34 |
|
35 |
-
1.
|
36 |
-
2.
|
37 |
-
|
38 |
-
|
|
|
|
|
39 |
|
40 |
|
41 |
== Screenshots ==
|
@@ -43,36 +45,39 @@ Please visit http://www.smackcoders.com/category/free-wordpress-plugins.html for
|
|
43 |
1. Admin settings for Wp Ultimate CSV Importer Plugin .
|
44 |
2. Admin settings for Import Data and Header Mapping configutration to import data's from a csv file.
|
45 |
|
46 |
-
|
47 |
== Changelog ==
|
|
|
48 |
|
49 |
-
1.0.
|
50 |
-
|
51 |
-
Initial release version. Tested and found works well without any issues.
|
52 |
|
53 |
|
54 |
== Upgrade Notice ==
|
55 |
|
56 |
-
Initial release of plugin
|
|
|
|
|
57 |
|
58 |
|
59 |
== Frequently Asked Questions ==
|
60 |
|
61 |
1. How to install the plugin?
|
62 |
-
Like other plugins wp-ultimate-csv-importer is easy to install. Upload the wp-ultimate-csv-importer.zip file through plugin install page through wp admin. Everything will work fine with it.
|
63 |
|
|
|
|
|
64 |
2. How to use the plugin?
|
65 |
|
66 |
After plugin activation you can see the ' Wp Ultimate CSV Importer ' menu in admin backend.
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
-
|
69 |
-
2. You can mapping the headers to import the data's.
|
70 |
-
3. If you checked the import as draft,it will import as draft then you can publish the data's later.
|
71 |
-
4. The data's are imported based on the post type you selected.
|
72 |
|
73 |
Configuring our plugin is as simple as that.
|
74 |
|
75 |
-
|
76 |
Please use support section in wordpress itself for any further queries and feature request.
|
77 |
|
78 |
|
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.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
32 |
|
33 |
Wp Ultimate CSV Importer is very easy to install like any other wordpress plugin. No need to edit or modify anything here.
|
34 |
|
35 |
+
1. Unzip the file 'wp-ultimate-csv-importer.zip'.
|
36 |
+
2. Upload the ' wp-ultimate-csv-importer ' directory to '/wp-content/plugins/' directory using ftp client or upload and install
|
37 |
+
wp-ultimate-csv-importer.zip through plugin install wizard in wp admin panel
|
38 |
+
3. Make /wp-content/plugins/wp-ultimate-csv-importer/imported_csv as writable (chmod 777) to import csv.
|
39 |
+
4. Activate the plugin through the 'Plugins' menu in WordPress.
|
40 |
+
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.
|
41 |
|
42 |
|
43 |
== Screenshots ==
|
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 |
== Changelog ==
|
49 |
+
1.0.0 Initial release version. Tested and found works well without any issues.
|
50 |
|
51 |
+
1.0.1 Added features to import multiple tags and categories with different delimiters.
|
|
|
|
|
52 |
|
53 |
|
54 |
== Upgrade Notice ==
|
55 |
|
56 |
+
v1.0.0 Initial release of plugin.
|
57 |
+
|
58 |
+
v1.0.1 Added features to import multiple tags and categories with different delimiters.
|
59 |
|
60 |
|
61 |
== Frequently Asked Questions ==
|
62 |
|
63 |
1. How to install the plugin?
|
|
|
64 |
|
65 |
+
Like other plugins wp-ultimate-csv-importer is easy to install. Upload the wp-ultimate-csv-importer.zip file through plugin install page through wp admin. Everything will work fine with it.
|
66 |
+
|
67 |
2. How to use the plugin?
|
68 |
|
69 |
After plugin activation you can see the ' Wp Ultimate CSV Importer ' menu in admin backend.
|
70 |
+
a. Browse csv file to import the data's.
|
71 |
+
b. Select the post type or post / page to import as.
|
72 |
+
b. Map each header to the relevant fields using the drop downs to import.
|
73 |
+
c. If import as draft option is checked, post will be in draft mode.
|
74 |
+
|
75 |
+
3. How to define the multiple tags and categories?
|
76 |
|
77 |
+
In CSV, tags should be seperated by "," to import mutiple tags and categories should be seperated by "|" to import multiple categories.
|
|
|
|
|
|
|
78 |
|
79 |
Configuring our plugin is as simple as that.
|
80 |
|
|
|
81 |
Please use support section in wordpress itself for any further queries and feature request.
|
82 |
|
83 |
|
screenshot-1.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.0.
|
7 |
*Author: smackcoders.com
|
8 |
*Author URI: http://www.smackcoders.com
|
9 |
*
|
@@ -36,7 +36,8 @@ $headers = array();
|
|
36 |
global $defaults;
|
37 |
global $wpdb;
|
38 |
global $keys;
|
39 |
-
|
|
|
40 |
// Get the custom fields
|
41 |
$limit = (int) apply_filters( 'postmeta_form_limit', 30 );
|
42 |
$keys = $wpdb->get_col( "
|
@@ -52,8 +53,8 @@ $defaults = array(
|
|
52 |
'post_content' => null,
|
53 |
'post_excerpt' => null,
|
54 |
'post_date' => null,
|
55 |
-
'
|
56 |
-
'
|
57 |
'post_author' => null,
|
58 |
'post_parent' => 0,
|
59 |
);
|
@@ -98,18 +99,18 @@ function description(){
|
|
98 |
}
|
99 |
|
100 |
// CSV File Reader
|
101 |
-
function csv_file_data($file)
|
102 |
{
|
103 |
global $data_rows;
|
104 |
global $headers;
|
|
|
105 |
$resource = fopen($file, 'r');
|
106 |
-
while ($keys = fgetcsv($resource)) {
|
107 |
if ($c == 0) {
|
108 |
$headers = $keys;
|
109 |
} else {
|
110 |
array_push($data_rows, $keys);
|
111 |
}
|
112 |
-
|
113 |
$c ++;
|
114 |
}
|
115 |
fclose($resource);
|
@@ -144,14 +145,15 @@ function upload_csv_file()
|
|
144 |
global $defaults;
|
145 |
global $keys;
|
146 |
global $custom_array;
|
|
|
147 |
$custom_array = array();
|
148 |
if(isset($_POST['Import']))
|
149 |
{
|
150 |
-
csv_file_data($_FILES['csv_import']['tmp_name']);
|
151 |
move_file();
|
152 |
?>
|
153 |
<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/>
|
154 |
-
|
155 |
<div style="float:left;min-width:45%">
|
156 |
<form class="add:the-list: validate" method="post">
|
157 |
<h3>Import Data Configuration</h3>
|
@@ -176,10 +178,11 @@ function upload_csv_file()
|
|
176 |
<?php $cnt =count($defaults)+2; $cnt1 =count($headers); ?>
|
177 |
<input type="hidden" id="h1" name="h1" value="<?php echo $cnt; ?>"/>
|
178 |
<input type="hidden" id="h2" name="h2" value="<?php echo $cnt1; ?>"/>
|
179 |
-
<
|
|
|
180 |
<?php
|
181 |
$count = 0;
|
182 |
-
foreach($headers as $key=>$value){
|
183 |
?>
|
184 |
<tr>
|
185 |
<td>
|
@@ -212,11 +215,26 @@ function upload_csv_file()
|
|
212 |
<?php $result = description(); print_r($result); ?>
|
213 |
</div>
|
214 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
}
|
216 |
else if(isset($_POST['post_csv']))
|
217 |
{
|
218 |
$dir = getcwd ().'/../wp-content/plugins/wp-ultimate-csv-importer/imported_csv/';
|
219 |
-
csv_file_data($dir.$_POST['filename']);
|
220 |
foreach($_POST as $postkey=>$postvalue){
|
221 |
if($postvalue != '-- Select --'){
|
222 |
$ret_array[$postkey]=$postvalue;
|
@@ -241,17 +259,24 @@ function upload_csv_file()
|
|
241 |
$custom_array[$v] =$new_post[$v];
|
242 |
}
|
243 |
}
|
244 |
-
/* if(array_key_exists('textbox'.$inc,$new_post)){
|
245 |
-
$custom_array['textbox'.$inc] =$new_post['textbox'.$inc];
|
246 |
-
}*/
|
247 |
}
|
248 |
foreach($new_post as $ckey => $cval){
|
|
|
249 |
if(array_key_exists($ckey,$custom_array)){
|
250 |
$darray[$ckey]=$new_post[$ckey];
|
251 |
}
|
252 |
else{
|
253 |
$data_array[$ckey]=$new_post[$ckey];
|
254 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
255 |
}
|
256 |
$data_array['post_status']='publish';
|
257 |
if(isset($_POST['csv_importer_import_as_draft'])){
|
@@ -264,6 +289,20 @@ function upload_csv_file()
|
|
264 |
add_post_meta($post_id, $custom_key, $custom_value);
|
265 |
}
|
266 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
267 |
}
|
268 |
?>
|
269 |
<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>
|
@@ -291,7 +330,13 @@ function upload_csv_file()
|
|
291 |
|
292 |
<!-- File input -->
|
293 |
<p><label for="csv_import">Upload file:</label><br/>
|
294 |
-
<input name="csv_import" id="csv_import" type="file" value="" aria-required="true" /></p
|
|
|
|
|
|
|
|
|
|
|
|
|
295 |
<p class="submit"><input type="submit" class="button" name="Import" value="Import" /></p>
|
296 |
</form>
|
297 |
</div>
|
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.1
|
7 |
*Author: smackcoders.com
|
8 |
*Author URI: http://www.smackcoders.com
|
9 |
*
|
36 |
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( "
|
53 |
'post_content' => null,
|
54 |
'post_excerpt' => null,
|
55 |
'post_date' => null,
|
56 |
+
'post_tag' => null,
|
57 |
+
'category' => null,
|
58 |
'post_author' => null,
|
59 |
'post_parent' => 0,
|
60 |
);
|
99 |
}
|
100 |
|
101 |
// CSV File Reader
|
102 |
+
function csv_file_data($file,$delim)
|
103 |
{
|
104 |
global $data_rows;
|
105 |
global $headers;
|
106 |
+
global $delim;
|
107 |
$resource = fopen($file, 'r');
|
108 |
+
while ($keys = fgetcsv($resource,'',"$delim",'"')) {
|
109 |
if ($c == 0) {
|
110 |
$headers = $keys;
|
111 |
} else {
|
112 |
array_push($data_rows, $keys);
|
113 |
}
|
|
|
114 |
$c ++;
|
115 |
}
|
116 |
fclose($resource);
|
145 |
global $defaults;
|
146 |
global $keys;
|
147 |
global $custom_array;
|
148 |
+
global $delim;
|
149 |
$custom_array = array();
|
150 |
if(isset($_POST['Import']))
|
151 |
{
|
152 |
+
csv_file_data($_FILES['csv_import']['tmp_name'],$delim);
|
153 |
move_file();
|
154 |
?>
|
155 |
<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/>
|
156 |
+
<?php if ( count($headers)>1 && count($data_rows)>1 ){?>
|
157 |
<div style="float:left;min-width:45%">
|
158 |
<form class="add:the-list: validate" method="post">
|
159 |
<h3>Import Data Configuration</h3>
|
178 |
<?php $cnt =count($defaults)+2; $cnt1 =count($headers); ?>
|
179 |
<input type="hidden" id="h1" name="h1" value="<?php echo $cnt; ?>"/>
|
180 |
<input type="hidden" id="h2" name="h2" value="<?php echo $cnt1; ?>"/>
|
181 |
+
<input type="hidden" id="delim" name="delim" value="<?php echo $_POST['delim']; ?>" />
|
182 |
+
<table style="font-size:12px;">
|
183 |
<?php
|
184 |
$count = 0;
|
185 |
+
foreach($headers as $key=>$value){
|
186 |
?>
|
187 |
<tr>
|
188 |
<td>
|
215 |
<?php $result = description(); print_r($result); ?>
|
216 |
</div>
|
217 |
<?php
|
218 |
+
}
|
219 |
+
else { ?>
|
220 |
+
<div style="font-size:16px;margin-left:20px;">Your CSV file cannot be processed. It may contains wrong delimiter or please choose the correct delimiter.
|
221 |
+
</div><br/>
|
222 |
+
<div style="margin-left:20px;">
|
223 |
+
<form class="add:the-list: validate" method="post" action="">
|
224 |
+
<input type="submit" class="button" name="Import Again" value="Import Again"/>
|
225 |
+
</form>
|
226 |
+
</div>
|
227 |
+
<div style="margin-left:20px;margin-top:30px;">
|
228 |
+
<b>Note :-</b>
|
229 |
+
<p>1. Your CSV should contain "," or ";" as delimiters.</p>
|
230 |
+
<p>2. In CSV, tags should be seperated by "," to import mutiple tags and categories should be seperated by "|" to import multiple categories.</p>
|
231 |
+
</div>
|
232 |
+
<?php }
|
233 |
}
|
234 |
else if(isset($_POST['post_csv']))
|
235 |
{
|
236 |
$dir = getcwd ().'/../wp-content/plugins/wp-ultimate-csv-importer/imported_csv/';
|
237 |
+
csv_file_data($dir.$_POST['filename'],$delim);
|
238 |
foreach($_POST as $postkey=>$postvalue){
|
239 |
if($postvalue != '-- Select --'){
|
240 |
$ret_array[$postkey]=$postvalue;
|
259 |
$custom_array[$v] =$new_post[$v];
|
260 |
}
|
261 |
}
|
|
|
|
|
|
|
262 |
}
|
263 |
foreach($new_post as $ckey => $cval){
|
264 |
+
if($ckey!='category' && $ckey!='post_tag'){
|
265 |
if(array_key_exists($ckey,$custom_array)){
|
266 |
$darray[$ckey]=$new_post[$ckey];
|
267 |
}
|
268 |
else{
|
269 |
$data_array[$ckey]=$new_post[$ckey];
|
270 |
}
|
271 |
+
}
|
272 |
+
else{
|
273 |
+
if($ckey == 'post_tag'){
|
274 |
+
$tags[$ckey]=$new_post[$ckey];
|
275 |
+
}
|
276 |
+
if($ckey == 'category'){
|
277 |
+
$categories[$ckey]=$new_post[$ckey];
|
278 |
+
}
|
279 |
+
}
|
280 |
}
|
281 |
$data_array['post_status']='publish';
|
282 |
if(isset($_POST['csv_importer_import_as_draft'])){
|
289 |
add_post_meta($post_id, $custom_key, $custom_value);
|
290 |
}
|
291 |
}
|
292 |
+
|
293 |
+
// Create/Add tags to post
|
294 |
+
if(!empty($tags)){
|
295 |
+
foreach($tags as $tag_key => $tag_value){
|
296 |
+
wp_set_post_tags( $post_id, $tag_value );
|
297 |
+
}
|
298 |
+
} // End of code to add tags
|
299 |
+
|
300 |
+
// Create/Add category to post
|
301 |
+
if(!empty($categories)){
|
302 |
+
$split_line = explode('|',$categories['category']);
|
303 |
+
wp_set_object_terms($post_id, $split_line, 'category');
|
304 |
+
|
305 |
+
} // End of code to add category
|
306 |
}
|
307 |
?>
|
308 |
<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>
|
330 |
|
331 |
<!-- File input -->
|
332 |
<p><label for="csv_import">Upload file:</label><br/>
|
333 |
+
<input name="csv_import" id="csv_import" type="file" value="" aria-required="true" /></p><br/>
|
334 |
+
<p><label>Delimiter</label>
|
335 |
+
<select name="delim" id="delim">
|
336 |
+
<option value=",">,</option>
|
337 |
+
<option value=";">;</option>
|
338 |
+
</select>
|
339 |
+
</p>
|
340 |
<p class="submit"><input type="submit" class="button" name="Import" value="Import" /></p>
|
341 |
</form>
|
342 |
</div>
|