Version Description
- Enhancement: Support localization
- Bug fixes
Download this release
Release Info
Developer | hissy |
Plugin | Really Simple CSV Importer |
Version | 1.1 |
Comparing to | |
See all releases |
Code changes from version 1.0 to 1.1
- class-rscsv_import_post_helper.php +7 -7
- languages/really-simple-csv-importer-ja.mo +0 -0
- languages/really-simple-csv-importer-ja.po +137 -0
- languages/really-simple-csv-importer.pot +121 -0
- readme.txt +7 -4
- rs-csv-importer.php +35 -31
class-rscsv_import_post_helper.php
CHANGED
@@ -70,7 +70,7 @@ class RSCSV_Import_Post_Helper
|
|
70 |
if (is_object($post)) {
|
71 |
$this->post = $post;
|
72 |
} else {
|
73 |
-
$this->addError('post_id_not_found', __('Provided Post ID not found.', '
|
74 |
}
|
75 |
}
|
76 |
|
@@ -176,7 +176,7 @@ class RSCSV_Import_Post_Helper
|
|
176 |
if ($post instanceof WP_Post) {
|
177 |
update_post_meta($post->ID, $key, $value);
|
178 |
} else {
|
179 |
-
$this->addError('post_is_not_set', __('WP_Post object is not set.', '
|
180 |
}
|
181 |
}
|
182 |
|
@@ -196,7 +196,7 @@ class RSCSV_Import_Post_Helper
|
|
196 |
$this->updateMeta($key, $value);
|
197 |
}
|
198 |
} else {
|
199 |
-
$this->addError('post_is_not_set', __('WP_Post object is not set.', '
|
200 |
}
|
201 |
}
|
202 |
|
@@ -217,7 +217,7 @@ class RSCSV_Import_Post_Helper
|
|
217 |
$this->updateMeta($key, $value);
|
218 |
}
|
219 |
} else {
|
220 |
-
$this->addError('post_is_not_set', __('WP_Post object is not set.', '
|
221 |
}
|
222 |
}
|
223 |
|
@@ -232,7 +232,7 @@ class RSCSV_Import_Post_Helper
|
|
232 |
if ($post instanceof WP_Post) {
|
233 |
wp_set_post_tags($post->ID, $tags);
|
234 |
} else {
|
235 |
-
$this->addError('post_is_not_set', __('WP_Post object is not set.', '
|
236 |
}
|
237 |
}
|
238 |
|
@@ -248,7 +248,7 @@ class RSCSV_Import_Post_Helper
|
|
248 |
if ($post instanceof WP_Post) {
|
249 |
wp_set_object_terms($post->ID, $terms, $taxonomy);
|
250 |
} else {
|
251 |
-
$this->addError('post_is_not_set', __('WP_Post object is not set.', '
|
252 |
}
|
253 |
}
|
254 |
|
@@ -361,7 +361,7 @@ class RSCSV_Import_Post_Helper
|
|
361 |
if ( $body && $wp_filesystem->put_contents($filepath , $body, FS_CHMOD_FILE) ) {
|
362 |
return $filepath;
|
363 |
} else {
|
364 |
-
$this->addError('remote_get_failed', __('Could not get remote file.', '
|
365 |
}
|
366 |
} elseif (is_wp_error($response)) {
|
367 |
$this->addError($response->get_error_code(), $response->get_error_message());
|
70 |
if (is_object($post)) {
|
71 |
$this->post = $post;
|
72 |
} else {
|
73 |
+
$this->addError('post_id_not_found', __('Provided Post ID not found.', 'really-simple-csv-importer'));
|
74 |
}
|
75 |
}
|
76 |
|
176 |
if ($post instanceof WP_Post) {
|
177 |
update_post_meta($post->ID, $key, $value);
|
178 |
} else {
|
179 |
+
$this->addError('post_is_not_set', __('WP_Post object is not set.', 'really-simple-csv-importer'));
|
180 |
}
|
181 |
}
|
182 |
|
196 |
$this->updateMeta($key, $value);
|
197 |
}
|
198 |
} else {
|
199 |
+
$this->addError('post_is_not_set', __('WP_Post object is not set.', 'really-simple-csv-importer'));
|
200 |
}
|
201 |
}
|
202 |
|
217 |
$this->updateMeta($key, $value);
|
218 |
}
|
219 |
} else {
|
220 |
+
$this->addError('post_is_not_set', __('WP_Post object is not set.', 'really-simple-csv-importer'));
|
221 |
}
|
222 |
}
|
223 |
|
232 |
if ($post instanceof WP_Post) {
|
233 |
wp_set_post_tags($post->ID, $tags);
|
234 |
} else {
|
235 |
+
$this->addError('post_is_not_set', __('WP_Post object is not set.', 'really-simple-csv-importer'));
|
236 |
}
|
237 |
}
|
238 |
|
248 |
if ($post instanceof WP_Post) {
|
249 |
wp_set_object_terms($post->ID, $terms, $taxonomy);
|
250 |
} else {
|
251 |
+
$this->addError('post_is_not_set', __('WP_Post object is not set.', 'really-simple-csv-importer'));
|
252 |
}
|
253 |
}
|
254 |
|
361 |
if ( $body && $wp_filesystem->put_contents($filepath , $body, FS_CHMOD_FILE) ) {
|
362 |
return $filepath;
|
363 |
} else {
|
364 |
+
$this->addError('remote_get_failed', __('Could not get remote file.', 'really-simple-csv-importer'));
|
365 |
}
|
366 |
} elseif (is_wp_error($response)) {
|
367 |
$this->addError($response->get_error_code(), $response->get_error_message());
|
languages/really-simple-csv-importer-ja.mo
ADDED
Binary file
|
languages/really-simple-csv-importer-ja.po
ADDED
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (C) 2015
|
2 |
+
# This file is distributed under the same license as the package.
|
3 |
+
msgid ""
|
4 |
+
msgstr ""
|
5 |
+
"Project-Id-Version: Really Simple CSV Importer 1.0.1\n"
|
6 |
+
"Report-Msgid-Bugs-To: http://wordpress.org/tag/really-simple-csv-importer\n"
|
7 |
+
"POT-Creation-Date: 2015-02-01 05:07:15+00:00\n"
|
8 |
+
"MIME-Version: 1.0\n"
|
9 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
+
"Content-Transfer-Encoding: 8bit\n"
|
11 |
+
"PO-Revision-Date: 2015-02-01 14:16+0900\n"
|
12 |
+
"Last-Translator: Takuro Hishikawa <hishikawa@concrete5.co.jp>\n"
|
13 |
+
"Language-Team: \n"
|
14 |
+
"Language: ja\n"
|
15 |
+
"X-Generator: Poedit 1.7.3\n"
|
16 |
+
"Plural-Forms: nplurals=1; plural=0;\n"
|
17 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
18 |
+
|
19 |
+
#: class-rscsv_import_post_helper.php:73
|
20 |
+
msgid "Provided Post ID not found."
|
21 |
+
msgstr "指定された投稿IDが見つかりません。"
|
22 |
+
|
23 |
+
#: class-rscsv_import_post_helper.php:179
|
24 |
+
#: class-rscsv_import_post_helper.php:199
|
25 |
+
#: class-rscsv_import_post_helper.php:220
|
26 |
+
#: class-rscsv_import_post_helper.php:235
|
27 |
+
#: class-rscsv_import_post_helper.php:251
|
28 |
+
msgid "WP_Post object is not set."
|
29 |
+
msgstr "WP_Postオブジェクトがセットされていません。"
|
30 |
+
|
31 |
+
#: class-rscsv_import_post_helper.php:364
|
32 |
+
msgid "Could not get remote file."
|
33 |
+
msgstr "リモートファイルを取得できませんでした。"
|
34 |
+
|
35 |
+
#: rs-csv-importer.php:47
|
36 |
+
msgid "Import CSV"
|
37 |
+
msgstr "CSVをインポート"
|
38 |
+
|
39 |
+
#: rs-csv-importer.php:57
|
40 |
+
msgid "Choose a CSV (.csv) file to upload, then click Upload file and import."
|
41 |
+
msgstr ""
|
42 |
+
"アップロードするCSV (.csv) ファイルを選択し、「ファイルをアップロードしてイ"
|
43 |
+
"ンポート」をクリックしてください。"
|
44 |
+
|
45 |
+
#: rs-csv-importer.php:58
|
46 |
+
msgid ""
|
47 |
+
"Excel-style CSV file is unconventional and not recommended. LibreOffice has "
|
48 |
+
"enough export options and recommended for most users."
|
49 |
+
msgstr ""
|
50 |
+
"エクセル形式のCSVファイルとは互換性がなく、推奨しません。LibreOfficeはほとん"
|
51 |
+
"どのユーザーに最適な出力オプションを提供します。"
|
52 |
+
|
53 |
+
#: rs-csv-importer.php:59
|
54 |
+
msgid "Requirements:"
|
55 |
+
msgstr "必須:"
|
56 |
+
|
57 |
+
#: rs-csv-importer.php:61
|
58 |
+
msgid "Select UTF-8 as charset."
|
59 |
+
msgstr "文字セットにUTF-8を選択してください。"
|
60 |
+
|
61 |
+
#: rs-csv-importer.php:62
|
62 |
+
msgid "You must use field delimiter as \"%s\""
|
63 |
+
msgstr "フィールド区切りに \"%s\" を使用してください。"
|
64 |
+
|
65 |
+
#: rs-csv-importer.php:63
|
66 |
+
msgid "You must quote all text cells."
|
67 |
+
msgstr "全てのテキストセルを引用符で囲ってください。"
|
68 |
+
|
69 |
+
#: rs-csv-importer.php:65
|
70 |
+
msgid "Download example CSV files:"
|
71 |
+
msgstr "サンプルCSVファイルをダウンロード:"
|
72 |
+
|
73 |
+
#: rs-csv-importer.php:66
|
74 |
+
msgid "csv"
|
75 |
+
msgstr "csv"
|
76 |
+
|
77 |
+
#: rs-csv-importer.php:67
|
78 |
+
msgid "ods"
|
79 |
+
msgstr "ods"
|
80 |
+
|
81 |
+
#: rs-csv-importer.php:68
|
82 |
+
msgid ""
|
83 |
+
"(OpenDocument Spreadsheet file format for LibreOffice. Please export as csv "
|
84 |
+
"before import)"
|
85 |
+
msgstr ""
|
86 |
+
"(LibreOffice用のオープンドキュメントスプレッドシートファイル形式です。イン"
|
87 |
+
"ポートする前にcsvとして出力してください)"
|
88 |
+
|
89 |
+
#: rs-csv-importer.php:78 rs-csv-importer.php:82
|
90 |
+
msgid "Sorry, there has been an error."
|
91 |
+
msgstr "エラーが発生しました。"
|
92 |
+
|
93 |
+
#: rs-csv-importer.php:83
|
94 |
+
msgid ""
|
95 |
+
"The export file could not be found at <code>%s</code>. It is likely that "
|
96 |
+
"this was caused by a permissions problem."
|
97 |
+
msgstr ""
|
98 |
+
"エクスポートファイルが<code>%s</code>に見つかりません。これは、パーミッショ"
|
99 |
+
"ンの問題である可能性が高いです。"
|
100 |
+
|
101 |
+
#: rs-csv-importer.php:148
|
102 |
+
msgid "Failed to open file."
|
103 |
+
msgstr "ファイルを開けませんでした。"
|
104 |
+
|
105 |
+
#: rs-csv-importer.php:174
|
106 |
+
msgid "Invalid post type \"%s\"."
|
107 |
+
msgstr "\"%s\" は不正な投稿タイプです。"
|
108 |
+
|
109 |
+
#: rs-csv-importer.php:177
|
110 |
+
msgid "Note: Please include post_type value if that is possible."
|
111 |
+
msgstr "注: 可能な場合 post_type 値を記載してください。"
|
112 |
+
|
113 |
+
#: rs-csv-importer.php:192
|
114 |
+
msgid ""
|
115 |
+
"The post type value from your csv file does not match the existing data in "
|
116 |
+
"your database. post_id: %d, post_type(csv): %s, post_type(db): %s"
|
117 |
+
msgstr ""
|
118 |
+
"CSVファイルからの投稿タイプ値は、データベース内の既存のデータと一致しませ"
|
119 |
+
"ん。post_id: %d、post_type(csv): %s、post_type(db): %s"
|
120 |
+
|
121 |
+
#: rs-csv-importer.php:367
|
122 |
+
msgid "Processing \"%s\" done."
|
123 |
+
msgstr "\"%s\" の処理が完了しました。"
|
124 |
+
|
125 |
+
#: rs-csv-importer.php:386
|
126 |
+
msgid "All Done."
|
127 |
+
msgstr "すべて完了しました。"
|
128 |
+
|
129 |
+
#: rs-csv-importer.php:419
|
130 |
+
msgid "CSV"
|
131 |
+
msgstr "CSV"
|
132 |
+
|
133 |
+
#: rs-csv-importer.php:419
|
134 |
+
msgid "Import posts, categories, tags, custom fields from simple csv file."
|
135 |
+
msgstr ""
|
136 |
+
"投稿、カテゴリー、タグ、カスタムフィールドをシンプルなcsvファイルからイン"
|
137 |
+
"ポートします。"
|
languages/really-simple-csv-importer.pot
ADDED
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (C) 2015
|
2 |
+
# This file is distributed under the same license as the package.
|
3 |
+
msgid ""
|
4 |
+
msgstr ""
|
5 |
+
"Project-Id-Version: \n"
|
6 |
+
"Report-Msgid-Bugs-To: http://wordpress.org/tag/really-simple-csv-importer\n"
|
7 |
+
"POT-Creation-Date: 2015-02-01 05:07:15+00:00\n"
|
8 |
+
"MIME-Version: 1.0\n"
|
9 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
+
"Content-Transfer-Encoding: 8bit\n"
|
11 |
+
"PO-Revision-Date: 2015-MO-DA HO:MI+ZONE\n"
|
12 |
+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
13 |
+
"Language-Team: LANGUAGE <LL@li.org>\n"
|
14 |
+
|
15 |
+
#: class-rscsv_import_post_helper.php:73
|
16 |
+
msgid "Provided Post ID not found."
|
17 |
+
msgstr ""
|
18 |
+
|
19 |
+
#: class-rscsv_import_post_helper.php:179
|
20 |
+
#: class-rscsv_import_post_helper.php:199
|
21 |
+
#: class-rscsv_import_post_helper.php:220
|
22 |
+
#: class-rscsv_import_post_helper.php:235
|
23 |
+
#: class-rscsv_import_post_helper.php:251
|
24 |
+
msgid "WP_Post object is not set."
|
25 |
+
msgstr ""
|
26 |
+
|
27 |
+
#: class-rscsv_import_post_helper.php:364
|
28 |
+
msgid "Could not get remote file."
|
29 |
+
msgstr ""
|
30 |
+
|
31 |
+
#: rs-csv-importer.php:47
|
32 |
+
msgid "Import CSV"
|
33 |
+
msgstr ""
|
34 |
+
|
35 |
+
#: rs-csv-importer.php:57
|
36 |
+
msgid "Choose a CSV (.csv) file to upload, then click Upload file and import."
|
37 |
+
msgstr ""
|
38 |
+
|
39 |
+
#: rs-csv-importer.php:58
|
40 |
+
msgid ""
|
41 |
+
"Excel-style CSV file is unconventional and not recommended. LibreOffice has "
|
42 |
+
"enough export options and recommended for most users."
|
43 |
+
msgstr ""
|
44 |
+
|
45 |
+
#: rs-csv-importer.php:59
|
46 |
+
msgid "Requirements:"
|
47 |
+
msgstr ""
|
48 |
+
|
49 |
+
#: rs-csv-importer.php:61
|
50 |
+
msgid "Select UTF-8 as charset."
|
51 |
+
msgstr ""
|
52 |
+
|
53 |
+
#: rs-csv-importer.php:62
|
54 |
+
msgid "You must use field delimiter as \"%s\""
|
55 |
+
msgstr ""
|
56 |
+
|
57 |
+
#: rs-csv-importer.php:63
|
58 |
+
msgid "You must quote all text cells."
|
59 |
+
msgstr ""
|
60 |
+
|
61 |
+
#: rs-csv-importer.php:65
|
62 |
+
msgid "Download example CSV files:"
|
63 |
+
msgstr ""
|
64 |
+
|
65 |
+
#: rs-csv-importer.php:66
|
66 |
+
msgid "csv"
|
67 |
+
msgstr ""
|
68 |
+
|
69 |
+
#: rs-csv-importer.php:67
|
70 |
+
msgid "ods"
|
71 |
+
msgstr ""
|
72 |
+
|
73 |
+
#: rs-csv-importer.php:68
|
74 |
+
msgid ""
|
75 |
+
"(OpenDocument Spreadsheet file format for LibreOffice. Please export as csv "
|
76 |
+
"before import)"
|
77 |
+
msgstr ""
|
78 |
+
|
79 |
+
#: rs-csv-importer.php:78 rs-csv-importer.php:82
|
80 |
+
msgid "Sorry, there has been an error."
|
81 |
+
msgstr ""
|
82 |
+
|
83 |
+
#: rs-csv-importer.php:83
|
84 |
+
msgid ""
|
85 |
+
"The export file could not be found at <code>%s</code>. It is likely that "
|
86 |
+
"this was caused by a permissions problem."
|
87 |
+
msgstr ""
|
88 |
+
|
89 |
+
#: rs-csv-importer.php:148
|
90 |
+
msgid "Failed to open file."
|
91 |
+
msgstr ""
|
92 |
+
|
93 |
+
#: rs-csv-importer.php:174
|
94 |
+
msgid "Invalid post type \"%s\"."
|
95 |
+
msgstr ""
|
96 |
+
|
97 |
+
#: rs-csv-importer.php:177
|
98 |
+
msgid "Note: Please include post_type value if that is possible."
|
99 |
+
msgstr ""
|
100 |
+
|
101 |
+
#: rs-csv-importer.php:192
|
102 |
+
msgid ""
|
103 |
+
"The post type value from your csv file does not match the existing data in "
|
104 |
+
"your database. post_id: %d, post_type(csv): %s, post_type(db): %s"
|
105 |
+
msgstr ""
|
106 |
+
|
107 |
+
#: rs-csv-importer.php:367
|
108 |
+
msgid "Processing \"%s\" done."
|
109 |
+
msgstr ""
|
110 |
+
|
111 |
+
#: rs-csv-importer.php:386
|
112 |
+
msgid "All Done."
|
113 |
+
msgstr ""
|
114 |
+
|
115 |
+
#: rs-csv-importer.php:419
|
116 |
+
msgid "CSV"
|
117 |
+
msgstr ""
|
118 |
+
|
119 |
+
#: rs-csv-importer.php:419
|
120 |
+
msgid "Import posts, categories, tags, custom fields from simple csv file."
|
121 |
+
msgstr ""
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: hissy
|
3 |
Tags: importer, csv, acf, cfs
|
4 |
Requires at least: 3.6
|
5 |
-
Tested up to: 4.
|
6 |
-
Stable tag: 1.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -216,12 +216,15 @@ Example: [gist](https://gist.github.com/hissy/fe0aa2582b78394a3a82)
|
|
216 |
|
217 |
= really_simple_csv_importer_class =
|
218 |
|
219 |
-
This filter provides availability to completely replace the `RS_CSV_Importer
|
220 |
|
221 |
-
Example: [gist](https://gist.github.com/hissy/
|
222 |
|
223 |
== Changelog ==
|
224 |
|
|
|
|
|
|
|
225 |
= 1.0 =
|
226 |
* Enhancement: Replace a helper class to more better one
|
227 |
* Enhancement: Add action hook
|
2 |
Contributors: hissy
|
3 |
Tags: importer, csv, acf, cfs
|
4 |
Requires at least: 3.6
|
5 |
+
Tested up to: 4.1
|
6 |
+
Stable tag: 1.1
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
216 |
|
217 |
= really_simple_csv_importer_class =
|
218 |
|
219 |
+
This filter provides availability to completely replace the `RS_CSV_Importer#save_post` method.
|
220 |
|
221 |
+
Example: [gist](https://gist.github.com/hissy/199ad9be855ec9be1e54)
|
222 |
|
223 |
== Changelog ==
|
224 |
|
225 |
+
= 1.1 =
|
226 |
+
* Enhancement: Support localization
|
227 |
+
* Bug fixes
|
228 |
= 1.0 =
|
229 |
* Enhancement: Replace a helper class to more better one
|
230 |
* Enhancement: Add action hook
|
rs-csv-importer.php
CHANGED
@@ -3,11 +3,11 @@
|
|
3 |
Plugin Name: Really Simple CSV Importer
|
4 |
Plugin URI: http://wordpress.org/plugins/really-simple-csv-importer/
|
5 |
Description: Import posts, categories, tags, custom fields from simple csv file.
|
6 |
-
Author: Takuro Hishikawa
|
7 |
Author URI: https://en.digitalcube.jp/
|
8 |
-
Text Domain:
|
9 |
License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
10 |
-
Version: 1.
|
11 |
*/
|
12 |
|
13 |
if ( !defined('WP_LOAD_IMPORTERS') )
|
@@ -44,7 +44,7 @@ class RS_CSV_Importer extends WP_Importer {
|
|
44 |
// User interface wrapper start
|
45 |
function header() {
|
46 |
echo '<div class="wrap">';
|
47 |
-
echo '<h2>'.__('Import CSV', '
|
48 |
}
|
49 |
|
50 |
// User interface wrapper end
|
@@ -54,18 +54,18 @@ class RS_CSV_Importer extends WP_Importer {
|
|
54 |
|
55 |
// Step 1
|
56 |
function greet() {
|
57 |
-
echo '<p>'.__( 'Choose a CSV (.csv) file to upload, then click Upload file and import.', '
|
58 |
-
echo '<p>'.__( 'Excel-style CSV file is unconventional and not recommended. LibreOffice has enough export options and recommended for most users.', '
|
59 |
-
echo '<p>'.__( 'Requirements:', '
|
60 |
echo '<ol>';
|
61 |
-
echo '<li>'.__( 'Select UTF-8 as charset.', '
|
62 |
-
echo '<li>'.sprintf( __( 'You must use field delimiter as "%s"', '
|
63 |
-
echo '<li>'.__( 'You must quote all text cells.', '
|
64 |
echo '</ol>';
|
65 |
-
echo '<p>'.__( 'Download example CSV files:', '
|
66 |
-
echo ' <a href="'.plugin_dir_url( __FILE__ ).'sample/sample.csv">'.__( 'csv', '
|
67 |
-
echo ' <a href="'.plugin_dir_url( __FILE__ ).'sample/sample.ods">'.__( 'ods', '
|
68 |
-
echo ' '.__('(OpenDocument Spreadsheet file format for LibreOffice. Please export as csv before import)', '
|
69 |
echo '</p>';
|
70 |
wp_import_upload_form( add_query_arg('step', 1) );
|
71 |
}
|
@@ -75,12 +75,12 @@ class RS_CSV_Importer extends WP_Importer {
|
|
75 |
$file = wp_import_handle_upload();
|
76 |
|
77 |
if ( isset( $file['error'] ) ) {
|
78 |
-
echo '<p><strong>' . __( 'Sorry, there has been an error.', '
|
79 |
echo esc_html( $file['error'] ) . '</p>';
|
80 |
return false;
|
81 |
} else if ( ! file_exists( $file['file'] ) ) {
|
82 |
-
echo '<p><strong>' . __( 'Sorry, there has been an error.', '
|
83 |
-
printf( __( 'The export file could not be found at <code>%s</code>. It is likely that this was caused by a permissions problem.', '
|
84 |
echo '</p>';
|
85 |
return false;
|
86 |
}
|
@@ -93,9 +93,7 @@ class RS_CSV_Importer extends WP_Importer {
|
|
93 |
}
|
94 |
|
95 |
/**
|
96 |
-
* Insert post and postmeta using
|
97 |
-
*
|
98 |
-
* More information: https://gist.github.com/4084471
|
99 |
*
|
100 |
* @param array $post
|
101 |
* @param array $meta
|
@@ -121,7 +119,9 @@ class RS_CSV_Importer extends WP_Importer {
|
|
121 |
}
|
122 |
|
123 |
// Set post tags
|
124 |
-
|
|
|
|
|
125 |
|
126 |
// Set meta data
|
127 |
$h->setMeta($meta);
|
@@ -145,7 +145,7 @@ class RS_CSV_Importer extends WP_Importer {
|
|
145 |
|
146 |
$handle = $h->fopen($this->file, 'r');
|
147 |
if ( $handle == false ) {
|
148 |
-
echo '<p><strong>'.__( 'Failed to open file.', '
|
149 |
wp_import_cleanup($this->id);
|
150 |
return false;
|
151 |
}
|
@@ -171,10 +171,10 @@ class RS_CSV_Importer extends WP_Importer {
|
|
171 |
if (post_type_exists($post_type)) {
|
172 |
$post['post_type'] = $post_type;
|
173 |
} else {
|
174 |
-
$error->add( 'post_type_exists', sprintf(__('Invalid post type "%s".', '
|
175 |
}
|
176 |
} else {
|
177 |
-
echo __('Note: Please include post_type value if that is possible.', '
|
178 |
}
|
179 |
|
180 |
// (int) post id
|
@@ -189,7 +189,7 @@ class RS_CSV_Importer extends WP_Importer {
|
|
189 |
$post['ID'] = $post_id;
|
190 |
$is_update = true;
|
191 |
} else {
|
192 |
-
$error->add( 'post_type_check', sprintf(__('The post type value from your csv file does not match the existing data in your database. post_id: %d, post_type(csv): %s, post_type(db): %s', '
|
193 |
}
|
194 |
}
|
195 |
}
|
@@ -364,7 +364,7 @@ class RS_CSV_Importer extends WP_Importer {
|
|
364 |
do_action( 'really_simple_csv_importer_post_saved', $post_object );
|
365 |
}
|
366 |
|
367 |
-
echo esc_html(sprintf(__('Processing "%s" done.', '
|
368 |
}
|
369 |
}
|
370 |
|
@@ -383,7 +383,7 @@ class RS_CSV_Importer extends WP_Importer {
|
|
383 |
|
384 |
wp_import_cleanup($this->id);
|
385 |
|
386 |
-
echo '<h3>'.__('All Done.', '
|
387 |
}
|
388 |
|
389 |
// dispatcher
|
@@ -413,9 +413,13 @@ class RS_CSV_Importer extends WP_Importer {
|
|
413 |
|
414 |
}
|
415 |
|
416 |
-
//
|
417 |
-
|
418 |
-
|
419 |
-
|
|
|
|
|
|
|
|
|
420 |
|
421 |
} // class_exists( 'WP_Importer' )
|
3 |
Plugin Name: Really Simple CSV Importer
|
4 |
Plugin URI: http://wordpress.org/plugins/really-simple-csv-importer/
|
5 |
Description: Import posts, categories, tags, custom fields from simple csv file.
|
6 |
+
Author: Takuro Hishikawa
|
7 |
Author URI: https://en.digitalcube.jp/
|
8 |
+
Text Domain: really-simple-csv-importer
|
9 |
License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
10 |
+
Version: 1.1
|
11 |
*/
|
12 |
|
13 |
if ( !defined('WP_LOAD_IMPORTERS') )
|
44 |
// User interface wrapper start
|
45 |
function header() {
|
46 |
echo '<div class="wrap">';
|
47 |
+
echo '<h2>'.__('Import CSV', 'really-simple-csv-importer').'</h2>';
|
48 |
}
|
49 |
|
50 |
// User interface wrapper end
|
54 |
|
55 |
// Step 1
|
56 |
function greet() {
|
57 |
+
echo '<p>'.__( 'Choose a CSV (.csv) file to upload, then click Upload file and import.', 'really-simple-csv-importer' ).'</p>';
|
58 |
+
echo '<p>'.__( 'Excel-style CSV file is unconventional and not recommended. LibreOffice has enough export options and recommended for most users.', 'really-simple-csv-importer' ).'</p>';
|
59 |
+
echo '<p>'.__( 'Requirements:', 'really-simple-csv-importer' ).'</p>';
|
60 |
echo '<ol>';
|
61 |
+
echo '<li>'.__( 'Select UTF-8 as charset.', 'really-simple-csv-importer' ).'</li>';
|
62 |
+
echo '<li>'.sprintf( __( 'You must use field delimiter as "%s"', 'really-simple-csv-importer'), RS_CSV_Helper::DELIMITER ).'</li>';
|
63 |
+
echo '<li>'.__( 'You must quote all text cells.', 'really-simple-csv-importer' ).'</li>';
|
64 |
echo '</ol>';
|
65 |
+
echo '<p>'.__( 'Download example CSV files:', 'really-simple-csv-importer' );
|
66 |
+
echo ' <a href="'.plugin_dir_url( __FILE__ ).'sample/sample.csv">'.__( 'csv', 'really-simple-csv-importer' ).'</a>,';
|
67 |
+
echo ' <a href="'.plugin_dir_url( __FILE__ ).'sample/sample.ods">'.__( 'ods', 'really-simple-csv-importer' ).'</a>';
|
68 |
+
echo ' '.__('(OpenDocument Spreadsheet file format for LibreOffice. Please export as csv before import)', 'really-simple-csv-importer' );
|
69 |
echo '</p>';
|
70 |
wp_import_upload_form( add_query_arg('step', 1) );
|
71 |
}
|
75 |
$file = wp_import_handle_upload();
|
76 |
|
77 |
if ( isset( $file['error'] ) ) {
|
78 |
+
echo '<p><strong>' . __( 'Sorry, there has been an error.', 'really-simple-csv-importer' ) . '</strong><br />';
|
79 |
echo esc_html( $file['error'] ) . '</p>';
|
80 |
return false;
|
81 |
} else if ( ! file_exists( $file['file'] ) ) {
|
82 |
+
echo '<p><strong>' . __( 'Sorry, there has been an error.', 'really-simple-csv-importer' ) . '</strong><br />';
|
83 |
+
printf( __( 'The export file could not be found at <code>%s</code>. It is likely that this was caused by a permissions problem.', 'really-simple-csv-importer' ), esc_html( $file['file'] ) );
|
84 |
echo '</p>';
|
85 |
return false;
|
86 |
}
|
93 |
}
|
94 |
|
95 |
/**
|
96 |
+
* Insert post and postmeta using `RSCSV_Import_Post_Helper` class.
|
|
|
|
|
97 |
*
|
98 |
* @param array $post
|
99 |
* @param array $meta
|
119 |
}
|
120 |
|
121 |
// Set post tags
|
122 |
+
if (isset($post_tags)) {
|
123 |
+
$h->setPostTags($post_tags);
|
124 |
+
}
|
125 |
|
126 |
// Set meta data
|
127 |
$h->setMeta($meta);
|
145 |
|
146 |
$handle = $h->fopen($this->file, 'r');
|
147 |
if ( $handle == false ) {
|
148 |
+
echo '<p><strong>'.__( 'Failed to open file.', 'really-simple-csv-importer' ).'</strong></p>';
|
149 |
wp_import_cleanup($this->id);
|
150 |
return false;
|
151 |
}
|
171 |
if (post_type_exists($post_type)) {
|
172 |
$post['post_type'] = $post_type;
|
173 |
} else {
|
174 |
+
$error->add( 'post_type_exists', sprintf(__('Invalid post type "%s".', 'really-simple-csv-importer'), $post_type) );
|
175 |
}
|
176 |
} else {
|
177 |
+
echo __('Note: Please include post_type value if that is possible.', 'really-simple-csv-importer').'<br>';
|
178 |
}
|
179 |
|
180 |
// (int) post id
|
189 |
$post['ID'] = $post_id;
|
190 |
$is_update = true;
|
191 |
} else {
|
192 |
+
$error->add( 'post_type_check', sprintf(__('The post type value from your csv file does not match the existing data in your database. post_id: %d, post_type(csv): %s, post_type(db): %s', 'really-simple-csv-importer'), $post_id, $post_type, $post_exist->post_type) );
|
193 |
}
|
194 |
}
|
195 |
}
|
364 |
do_action( 'really_simple_csv_importer_post_saved', $post_object );
|
365 |
}
|
366 |
|
367 |
+
echo esc_html(sprintf(__('Processing "%s" done.', 'really-simple-csv-importer'), $post_title));
|
368 |
}
|
369 |
}
|
370 |
|
383 |
|
384 |
wp_import_cleanup($this->id);
|
385 |
|
386 |
+
echo '<h3>'.__('All Done.', 'really-simple-csv-importer').'</h3>';
|
387 |
}
|
388 |
|
389 |
// dispatcher
|
413 |
|
414 |
}
|
415 |
|
416 |
+
// Initialize
|
417 |
+
function really_simple_csv_importer() {
|
418 |
+
load_plugin_textdomain( 'really-simple-csv-importer', false, dirname( plugin_basename(__FILE__) ) . '/languages' );
|
419 |
+
|
420 |
+
$rs_csv_importer = new RS_CSV_Importer();
|
421 |
+
register_importer('csv', __('CSV', 'really-simple-csv-importer'), __('Import posts, categories, tags, custom fields from simple csv file.', 'really-simple-csv-importer'), array ($rs_csv_importer, 'dispatch'));
|
422 |
+
}
|
423 |
+
add_action( 'plugins_loaded', 'really_simple_csv_importer' );
|
424 |
|
425 |
} // class_exists( 'WP_Importer' )
|