Version Description
- Enhancement: Check the post type is already exists.
Download this release
Release Info
Developer | hissy |
Plugin | Really Simple CSV Importer |
Version | 0.5.3 |
Comparing to | |
See all releases |
Code changes from version 0.5.2 to 0.5.3
- readme.txt +22 -5
- rs-csv-importer.php +18 -9
- sample/sample.csv +3 -3
- sample/sample.ods +0 -0
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: hissy, wokamoto
|
|
3 |
Tags: importer, csv, acf
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 3.6.1
|
6 |
-
Stable tag: 0.5.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -30,17 +30,17 @@ Contains CSV file samples in `/wp-content/plugins/really-simple-csv-importer/sam
|
|
30 |
* `post_content`: (string) The full text of the post.
|
31 |
* `post_title`: (string) The title of the post.
|
32 |
* `post_excerpt`: (string) For all your post excerpt needs.
|
33 |
-
* `post_status`: ('draft' or 'publish' or 'pending' or 'future' or 'private' or custom registered status) The status of the post.
|
34 |
* `post_name`: (string) The slug of the post.
|
35 |
* `post_parent`: (int) The post parent id. Used for page or hierarchical post type.
|
36 |
* `menu_order`: (int)
|
37 |
-
* `post_type`: ('post' or 'page' or any other post type name)
|
38 |
* `post_thumbnail`: (string) The uri or path of the post thumbnail.
|
39 |
E.g. http://example.com/example.jpg or /path/to/example.jpg
|
40 |
* `post_category`: (string, comma divided) slug of post categories
|
41 |
* `post_tags`: (string, comma divided) name of post tags
|
42 |
-
* `{custom_field}`: (string)
|
43 |
-
* `{
|
44 |
|
45 |
Note: To set the page template of a page, use custom field key of `_wp_page_template`.
|
46 |
Note: If providing a post_status of 'future' you must specify the post_date in order for WordPress to know when to publish your post.
|
@@ -73,6 +73,21 @@ Yes. Please use ID field.
|
|
73 |
|
74 |
Yes. Please use ID field.
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
= Why should I quote text cells when I save csv file? =
|
77 |
|
78 |
Because PHP cannot read multibyte text cells in some cases.
|
@@ -177,6 +192,8 @@ add_filter( 'really_simple_csv_importer_save_tax', 'really_simple_csv_importer_s
|
|
177 |
|
178 |
== Changelog ==
|
179 |
|
|
|
|
|
180 |
= 0.5.2 =
|
181 |
* New feature: Add Post Thumbnail support
|
182 |
* Bug fixes
|
3 |
Tags: importer, csv, acf
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 3.6.1
|
6 |
+
Stable tag: 0.5.3
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
30 |
* `post_content`: (string) The full text of the post.
|
31 |
* `post_title`: (string) The title of the post.
|
32 |
* `post_excerpt`: (string) For all your post excerpt needs.
|
33 |
+
* `post_status`: ('draft' or 'publish' or 'pending' or 'future' or 'private' or custom registered status) The status of the post. 'draft' is default.
|
34 |
* `post_name`: (string) The slug of the post.
|
35 |
* `post_parent`: (int) The post parent id. Used for page or hierarchical post type.
|
36 |
* `menu_order`: (int)
|
37 |
+
* `post_type`: ('post' or 'page' or any other post type name) *(required)* The post type slug, not labels.
|
38 |
* `post_thumbnail`: (string) The uri or path of the post thumbnail.
|
39 |
E.g. http://example.com/example.jpg or /path/to/example.jpg
|
40 |
* `post_category`: (string, comma divided) slug of post categories
|
41 |
* `post_tags`: (string, comma divided) name of post tags
|
42 |
+
* `{custom_field}`: (string) Any other column labels used as custom field
|
43 |
+
* `tax_{taxonomy}`: (string, comma divided) Any field prefixed with tax_ in the "custom_field" area will be used as a custom taxonomy. Taxonomy must already exist. Entries are names, not slugs
|
44 |
|
45 |
Note: To set the page template of a page, use custom field key of `_wp_page_template`.
|
46 |
Note: If providing a post_status of 'future' you must specify the post_date in order for WordPress to know when to publish your post.
|
73 |
|
74 |
Yes. Please use ID field.
|
75 |
|
76 |
+
= Can I import custom field/custom taxonomy of the post? =
|
77 |
+
|
78 |
+
Yes. You can use column names same as wp_post table, but if the column name does not match, it creates a custom field (post meta) data. Importing custom taxonomy is a bit more complicated, "tax_$taxonomy" means, "tax_" is prefix, and $taxonomy is name of custom taxonomy (not labels).
|
79 |
+
|
80 |
+
Here is a example.
|
81 |
+
|
82 |
+
**csv file**
|
83 |
+
"post_title","released","tax_actors"
|
84 |
+
"Captain Phillips","2013","Tom Hanks, Barkhad Abdi, Barkhad Abdirahman"
|
85 |
+
|
86 |
+
**imported post data**
|
87 |
+
Post Title: Captain Phillips
|
88 |
+
Custom field "released": 2013
|
89 |
+
Custom taxonomy "Actors": Tom Hanks, Barkhad Abdi, Barkhad Abdirahman
|
90 |
+
|
91 |
= Why should I quote text cells when I save csv file? =
|
92 |
|
93 |
Because PHP cannot read multibyte text cells in some cases.
|
192 |
|
193 |
== Changelog ==
|
194 |
|
195 |
+
= 0.5.3 =
|
196 |
+
* Enhancement: Check the post type is already exists.
|
197 |
= 0.5.2 =
|
198 |
* New feature: Add Post Thumbnail support
|
199 |
* Bug fixes
|
rs-csv-importer.php
CHANGED
@@ -7,7 +7,7 @@ Author: Takuro Hishikawa, wokamoto
|
|
7 |
Author URI: https://en.digitalcube.jp/
|
8 |
Text Domain: rs-csv-importer
|
9 |
License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
10 |
-
Version: 0.5.
|
11 |
*/
|
12 |
|
13 |
if ( !defined('WP_LOAD_IMPORTERS') )
|
@@ -163,10 +163,16 @@ class RS_CSV_Importer extends WP_Importer {
|
|
163 |
$is_update = false;
|
164 |
$error = new WP_Error();
|
165 |
|
166 |
-
// (string) post type
|
167 |
$post_type = $h->get_data($this,$data,'post_type');
|
168 |
if ($post_type) {
|
169 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
}
|
171 |
|
172 |
// (int) post id
|
@@ -317,17 +323,20 @@ class RS_CSV_Importer extends WP_Importer {
|
|
317 |
*/
|
318 |
$tax = apply_filters( 'really_simple_csv_importer_save_tax', $tax, $post, $is_update );
|
319 |
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
|
|
|
|
|
|
|
|
324 |
}
|
325 |
|
326 |
-
// show
|
327 |
foreach ($error->get_error_messages() as $message) {
|
328 |
echo esc_html($message).'<br>';
|
329 |
}
|
330 |
-
echo esc_html(sprintf(__('Processing "%s" done.', 'rs-csv-importer'), $post_title));
|
331 |
|
332 |
echo '</li>';
|
333 |
}
|
7 |
Author URI: https://en.digitalcube.jp/
|
8 |
Text Domain: rs-csv-importer
|
9 |
License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
10 |
+
Version: 0.5.3
|
11 |
*/
|
12 |
|
13 |
if ( !defined('WP_LOAD_IMPORTERS') )
|
163 |
$is_update = false;
|
164 |
$error = new WP_Error();
|
165 |
|
166 |
+
// (string) (required) post type
|
167 |
$post_type = $h->get_data($this,$data,'post_type');
|
168 |
if ($post_type) {
|
169 |
+
if (post_type_exists($post_type)) {
|
170 |
+
$post['post_type'] = $post_type;
|
171 |
+
} else {
|
172 |
+
$error->add( 'post_type_exists', sprintf(__('The post type %s is not exists. Please check your csv data.', 'rs-csv-importer'), $post_type) );
|
173 |
+
}
|
174 |
+
} else {
|
175 |
+
echo __('Note: Please include post_type value if that is possible.', 'rs-csv-importer').'<br>';
|
176 |
}
|
177 |
|
178 |
// (int) post id
|
323 |
*/
|
324 |
$tax = apply_filters( 'really_simple_csv_importer_save_tax', $tax, $post, $is_update );
|
325 |
|
326 |
+
if (!$error->get_error_codes()) {
|
327 |
+
// save post data
|
328 |
+
$result = $this->save_post($post,$meta,$tax,$post_thumbnail,$is_update);
|
329 |
+
if ($result) {
|
330 |
+
echo esc_html(sprintf(__('Processing "%s" done.', 'rs-csv-importer'), $post_title));
|
331 |
+
} else {
|
332 |
+
$error->add( 'save_post', __('An error occurred while saving the post to database.', 'rs-csv-importer') );
|
333 |
+
}
|
334 |
}
|
335 |
|
336 |
+
// show error messages
|
337 |
foreach ($error->get_error_messages() as $message) {
|
338 |
echo esc_html($message).'<br>';
|
339 |
}
|
|
|
340 |
|
341 |
echo '</li>';
|
342 |
}
|
sample/sample.csv
CHANGED
@@ -2,6 +2,6 @@
|
|
2 |
,"Import-test","admin",2013/9/13 0:00,"post","publish","CSV Import Test","This is a post for csv import.
|
3 |
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
4 |
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.","fruits","apple,banana","this is custom field value."
|
5 |
-
,,"editor"
|
6 |
-
,,2
|
7 |
-
1,"Hello-world-updated"
|
2 |
,"Import-test","admin",2013/9/13 0:00,"post","publish","CSV Import Test","This is a post for csv import.
|
3 |
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
4 |
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.","fruits","apple,banana","this is custom field value."
|
5 |
+
,,"editor",,"post","publish","define author test",,,,
|
6 |
+
,,2,,"post",,"define author id test",,,,
|
7 |
+
1,"Hello-world-updated",,,"post",,"Hello world! Updated!","Welcome to WordPress. This is your first post. Updated by RS CSV Importer!",,,
|
sample/sample.ods
CHANGED
Binary file
|